From a8ed809f36c32a9030726aeba50a67555cb7dd36 Mon Sep 17 00:00:00 2001 From: Rubab Khan Date: Mon, 16 Nov 2026 09:59:06 -0800 Subject: [PATCH] fix: Python 3.14 and tooling upgrades, smoke error redaction, comparable tier tables, durable chat history, real truncation and in-flight budget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary This PR carries three bodies of work. **Security hardening from code scanning.** 1. The frontend and browser journeys draw every token and idempotency key from Web Crypto instead of `Math.random`, and a unit guard keeps `Math.random` calls out. 2. Several regular expressions that could backtrack, or that misread HTML tags, are rewritten, and each has tests. 3. `minimatch` is pinned to a fixed release through npm overrides. **Platform upgrade.** 4. **Python 3.14.** The toolchain, every Lambda runtime, Lambda packaging and the CI images move from Python 3.13.18 to 3.14.10. 5. **Infrastructure tooling.** Terraform moves from 1.17.0 to 1.17.2 and the `hashicorp/aws` provider from 6.71.0 to 6.72.0. 6. **Dependencies.** Python, relay and frontend packages get patch and minor upgrades only. 7. **Smoke error redaction.** No smoke check reports an AWS error message any more, because such a message can name the caller's ARN and with it the account id. Every AWS failure is reported as its operation and error code only. 8. **Runtime image content.** The AgentCore agent source no longer ships `src/relay/` and its `node_modules`. **Eval measurement and chat behaviour.** An independent re-pricing of every recorded call showed the arithmetic in `results/matrix.md` was exact. The figures still misled, for four reasons, and each is fixed: 9. **Per-task cost denominator.** "Cost per task, all tasks" divided by every task the arm ran. It now divides by the tasks that apply at the tier, so at 100% completion the two cost rows are equal. 10. **Token rows were not like-for-like.** Anthropic reports input excluding cache reads and writes, while OpenAI reports it including them. Each family's reported input count therefore made Anthropic look impossibly low. Each tier table now shows total input, cache read, cache write and uncached input tokens, computed the same way for both families, so that total input = cache read + cache write + uncached input. 11. **Caching was asymmetric.** OpenAI caches the growing conversation, but the Anthropic adapter cached only the system prefix. It now also places a cache point on the latest message. 12. **Budget exhaustion and truncation were per-task flags shown on one table each.** The tier where a budget ran out is now recorded, and each tier table counts its own budget-exhausted tasks, truncated tool calls and truncated tasks. Analysing the matrix also uncovered three behaviour problems, which are fixed: 13. **A chat follow-up turn could be replayed instead of run.** A same-session follow-up with no resume position was answered by replaying the previous turn's recorded events. That covered every MCP follow-up. A follow-up is now always a fresh turn. Replay happens only when the client sends `resume: true`, which the SPA's reconnect does. Conversation history is now durable in DynamoDB and survives a Runtime restart. 14. **`gt-05-investigation-large-tool-result` could never truncate.** Its data now exceeds the tool-output bound. The bound applies on every dispatch path, and the truncation flag reaches the tier tables. 15. **`gt-04-investigation-turn-budget-partial` measured the delegation choice, not the budget.** Leaf calls inside a delegation were charged only when the delegation returned, so a delegation could overrun the turn cap. They are now charged as they are dispatched, and the task is resized to fit the budget under both strategies. `SECURITY.md` now maps the threat model to the OWASP Top 10 for LLM Applications 2026 and the OWASP Top 10 for Agentic Applications 2026. `results/matrix.md` is re-rendered from a new live sweep. ## Security hardening - **Random tokens.** - A new `frontend/src/lib/randomToken.ts` provides `randomToken(length)`, an unbiased base-36 token from `crypto.getRandomValues`, and `newTransactionKey(prefix)`, which prefers `crypto.randomUUID()`. - Session ids, transcript keys and every form's and board's `transaction_key` use it. - The browser journeys' run ids and keys use the same scheme, from `tests/e2e/browser/fixtures/randomToken.ts`. - `tests/unit/test_no_math_random.py` fails on any `Math.random` call under `frontend/src` or `tests/e2e/browser`. - **Regular expressions.** - The SSE schema parity gate's union pattern and the `iam_roles` smoke's list pattern no longer nest optional repeats. - The test that reads the API route map uses a single-line pattern, and a test asserts it stays linear on an unterminated input. - The CloudFront smoke and the CSP tests match a closing `` tag with trailing content or in any case. - A new test fails when `index.html` carries a script tag that the case-sensitive Terraform hash expression would read differently. - **Test fixtures.** - The relay's JWT test builds its Basic credential at run time instead of embedding an encoded literal. - The pricing-evidence test checks that every cited URL's host is `aws.amazon.com`, rather than looking for a substring. - **Dependencies.** The frontend pins `minimatch` 11.0.8 through `overrides`. ## Python 3.14 - **Pins.** - `.python-version` is 3.14.10. - `requires-python` is `==3.14.*`. - mypy targets 3.14. - ruff targets `py314`. Its reformat rewrites only parenthesised `except` clauses into the PEP 758 form. - **Lambda runtimes.** Every Python Lambda and the `lambda_action` module default move to `python3.14`. The relay stays on `nodejs24.x`. - **Packaging.** - `scripts/package_lambdas.sh` and `check_lambda_zip_imports` target CPython 3.14 (`cp314`). - The runtime-provided distribution set was re-measured in the `python:3.14` Lambda base image. It is the boto3 closure, unchanged from 3.13. `setuptools` is no longer claimed, because neither base image ships it. - **Images.** The Runtime image and the CI images use `python:3.14.10-slim` with pip 26.3. - **Interpreter resolution.** A new `scripts/repo_python.sh` resolves the interpreter in this order: 1. `/.venv/bin/python3`; 2. an ambient `python3` at or above the `.python-version` major.minor; 3. otherwise, it exits 2 naming both versions. Shell scripts, the git hooks, pre-commit and the frontend type generator now call it instead of a bare `python3`. It also pins `LC_ALL=C` and refuses a `.venv` below the required version. - **Vendor SDK seam.** - `sdk_transport` now refuses `ANTHROPIC_CUSTOM_HEADERS`. - It also checks the Anthropic client's default headers after construction. - Tests follow anthropic 2.8.0's move of its AWS auth module. ## Infrastructure tooling - Every `hashicorp/aws` pin moves from 6.71.0 to 6.72.0. Both provider lock files are regenerated over the same platform hash set. - Terraform moves from 1.17.0 to 1.17.2 in CI and the plan-fixture tooling. CI's relay Node moves to 24.22.3. - `tests/fixtures/plans/compliant.base.ndjson` is recaptured. Apart from the following, it is unchanged: - the runtimes and the provider constraint; - the CloudTrail `recursive_logging` attribute, which the provider now computes; - build-artefact content hashes. Its recorded infra digest matches the current tree. - **Provider scan.** A grype scan of the pinned 6.72.0 provider binary found one match: the Go standard library it was built with (go1.27.3, GO-2026-6859, fixed in go1.27.4). The binary is local Terraform tooling and is never deployed. The README's limitations record the result. ## Dependencies | Area | Package | From | To | |---|---|---|---| | Python | anthropic | 2.6.0 | 2.8.0 | | Python | boto3 / botocore | 1.43.125 | 1.44.1 | | Python | openai | 3.46.0 | 3.49.0 | | Python | sse-starlette | 3.6.0 | 3.7.0 | | Python | types-PyYAML | 6.0.12.20261103 | 6.0.12.20261111 | | Relay | @aws-sdk/client-bedrock-agentcore, @aws-sdk/client-ssm | 3.1163.0 | 3.1167.0 | | Frontend | vite | 8.3.6 | 8.3.8 | | Frontend | @vitejs/plugin-react | 6.2.1 | 6.3.0 | | Frontend | typescript-eslint | 8.72.1 | 8.72.2 | | Frontend | @testing-library/user-event | 14.6.8 | 14.6.9 | | Frontend | minimatch (override) | — | 11.0.8 | | Frontend | Node (`.nvmrc`, `engines.node`) | 26.13.0 | 26.13.1 | `requirements.txt` is re-frozen under 3.14.10 and stays the sole install authority. Every lock file is regenerated with `npm ci`. Major upgrades are deliberately deferred: - `python-dateutil` 4, because botocore still caps it below 3; - `watchdog` 7, which strands caps; - `@types/node` 26, because the relay runs on `nodejs24.x`. ## Smoke error redaction - **Shared helpers in `scripts/smoke/harness.py`.** - `aws_error_code(exc)` returns an AWS error's code, or its class name when it has none. It never returns the message. - `aws_error_detail(op, exc)` formats `" failed ()"`. - `exception_detail(exc)` keeps a local error's own text, but masks any AWS error found in its cause or context chain. - **Every smoke module converted.** 32 modules under `scripts/smoke/` now report AWS failures through these helpers. This covers the harness's account check, its expected-count deriver and the `run_main` catch-all. - Local errors raised from an AWS failure no longer embed the AWS text. They chain it with `raise … from`. - A failed Lambda invoke is reported as its `FunctionError` and an identifier-shaped `errorType`, never `errorMessage` or `stackTrace`. - The eval smoke reports a failed run's `error` field only as `present ()`, never its text, which is a failed step's raw error message. - DynamoDB deny probes report the denial code, its classification and the probe role name instead of the denial message. - `deployed_parity` reads every project function's runtime from the account (`lambda_runtime`), and requires every parity target plus the relay to be covered (`lambda_runtime_coverage`). The missing-`CodeSha256` detail lists only the response's key names. - **Tests.** - Each converted module has tests that plant an ARN with a placeholder account in the AWS error, then assert it appears in no detail. - A new `tests/unit/test_smoke_no_raw_aws_error.py` walks every smoke module's syntax tree. It fails when a broad or AWS-error handler interpolates the exception itself, and it has no allow-marker. ## Eval, agents and chat - **Prompt caching (`src/providers/`).** - The Anthropic adapter adds a message-level `cache_control` point on the latest message, beside the system-prefix point. - It stays within Anthropic's limit of four points and omits any point below the model's minimum cacheable size. - The caching method per family is declared in `providers/prompt_caching.CACHING` and recorded in each run's provenance. - **Chat turns and history (`src/agents/`, `src/relay/`, `frontend/`).** - A same-session follow-up runs as a fresh turn. The Runtime replays recorded events only when the request carries `resume: true` and a `resume_from` before the last frame. - The SPA sends `resume: true` from both its automatic and manual reconnect, and the relay forwards the field unchanged. - History is recorded before the turn's `completed` event. - **New store (`src/agents/`, through `src/crm/store/store.py`):** a DynamoDB-backed conversation history store. It writes one `history##` item per session in the existing `reps` table. - Ownership is checked: another `(rep_id, tenant)` reads empty, and its write is refused. - It keeps the existing redaction and turn and field caps. - Each item carries a 24-hour TTL. - Every store call is time-bounded, and a history write that fails is logged without content and never blocks the answer. - **IAM and infrastructure (`infra/`).** - The Runtime role gains an inline policy that allows only the item actions the store calls, on `reps`, keyed to `history#` items. - TTL is enabled on `reps.expires_at`. - **Tool-output bound (`src/agents/`).** - Every tool result is bounded at 32,768 bytes on every path: the supervisor's direct calls, leaf calls inside a delegation, and provider-reported tool events. - A bounded result keeps whole records and carries `truncated: true`. The same flag is recorded on the call's attribution. - A delegation with a bounded leaf reports itself truncated. - **Turn budget (`src/agents/`).** Each leaf call inside a delegation is charged to the turn budget as it is dispatched. A delegation therefore stops at the cap, and the refused call is attributed to the ToolCall tier. - **Golden tasks and fixtures (`fixtures/`, `src/eval/golden_tasks.yaml`).** - Planted defect PD-08 adds 55 activities to `opp-0000`, so a default activity page exceeds the bound. - Tasks that read `opp-0000` have updated expectations. - `gt-04` is resized to one account by prompt. - **Per-call and per-task records (`src/eval/`).** - Every per-invocation and per-tool-call record carries its task id and repeat. - Each task score now also records its repeat and the tier where its budget ran out. The record shape is now version 3. - Older records are refused by the renderer, the `matrix.json`/`matrix.csv` export and the Evals UI with a clear error. Past deployed runs are listed as recorded in an earlier format. - Re-pricing checks unit ids on every stamped entry. - `check_cost_withheld` accepts pre-aggregation archives' non-currency keys. - **Tier tables (`src/eval/matrix.py`, Evals UI).** - The per-task cost row is renamed and uses the applicable-task denominator. - The token rows are, in order: total input, cache read, cache write and uncached input tokens, then total output tokens. Total input = cache read + cache write + uncached input in every column. - The family-specific reported input row is gone. `matrix.json` and `matrix.csv` keep the raw `input_tokens` and `total_prompt_tokens` and add `uncached_input_tokens`. - New rows: budget-exhausted tasks, truncated tool calls and truncated tasks. - The Delegation outcome rows leave the Subagent table; the counts stay in JSON and CSV. - P50 latency comes before P95. - The in-app Tier comparison view renders the same rows. ## Packaging - `scripts/package_lambdas.sh` leaves `src/relay/` out of `agent-source.zip`, the Runtime image's build context. The Python Runtime never loads the relay, and the archive drops from more than 6,000 entries to 150. - A new `tests/unit/test_package_lambdas_agent_source.py` runs the script's staging step and reads the built archive. It fails if any `src/relay/` entry is present. ## Checks - **CI.** - The frontend job fails when the regenerated tier-comparison fixture differs from the committed copy. - It also runs the reconnect `resume` contract. - **Unit tests** gate the Step Functions repeat-index wiring and the two truncation keys. - **A new executing contract** covers the path from SPA through relay to Runtime for `resume` and `resume_from`. - **Smoke:** - a cross-turn history check in the three-tier chat smoke, in content and in tokens; - a Runtime history IAM smoke, with allowed and unused actions and a cross-tenant denial; - the agents smoke deletes the history item its turn wrote; - `verify_deployment.sh` removes its stderr temp file on exit. - **Journey 22** asserts chat recall across four turns, and that a new conversation does not recall. ## Threat model - `SECURITY.md` maps the threat model to the OWASP Top 10 for LLM Applications 2026 and the OWASP Top 10 for Agentic Applications 2026. - The OWASP Top 10 (web) stays on 2025, its current edition. - Three new residual risks are listed under "Accepted risks and open items". ## Documentation - `README.md`, `docs/development.md` and `docs/runbook.md` state Python 3.14.10, Node 26.13.1, Terraform 1.17.2 and provider 6.72.0. The README's plan-fixture provenance names the same versions, and its limitations record the provider scan. - The runbook says to rewrite the browser-journey credential file after `provision_demo_user.py` resets a password. A stale file that gets sourced overrides the current password, and every signed-in journey then fails. - `README.md`, `docs/runbook.md` and `docs/eval-methodology.md` cover: - durable history, its TTL and operator deletion; - the tool-output bound and leaf-call charging; - the reworked tier rows and the matched caching. ## Testing **Against a deployed dev stack**, deployed from this branch. - **Deployed code.** The deployed code differs from the final commit only in `SECURITY.md`. - **Which checks ran on which deploy.** The full verification, the full journey run and the sweep below ran on an earlier deploy. The final deploy changed only the tier tables' token rows, so it was checked with a targeted smoke and journey 21. - **After the final deploy:** - the eval smoke passed 311 checks with 0 failed; - journey 21 (Tier comparison) passed 9/9 and showed the five new token rows on the deployed Evals page. - **Full Layer 4–6 verification:** 13,443 checks passed and 0 failed. 182 were skipped and 38 deferred, all for documented reasons. - Every Python function reports `python3.14` and the relay reports `nodejs24.x`, and the runtime coverage check passes. - The unauthenticated and wrong-tenant paths are refused (401/403). - The relay's Function URL enforces `AWS_IAM`. - The canary tenant holds 0 rows. - **History survives a Runtime restart.** After a 1,020 s idle, which spans the Runtime's idle shutdown, a follow-up turn with no resume flag recalled turn 1's fact. - **T4 browser journeys** (`scripts/run_browser_journeys_container.sh`): 66 passed, 0 failed, 0 flaky. Journey 22 (chat recall) passed. 4 were skipped as declared: - two Hosted UI tests, because no Hosted UI domain is configured; - two live-sweep tests, which need a separate opt-in. - **Live sweep:** 2 arms (Claude Sonnet 5.5 and GPT-6.1 Sol, both at medium effort) × 24 golden tasks × 5 repeats, for $5.72 against a $30 cap. - Pre-flight checks confirmed the data-retention mode and an empty canary tenant. - `results/matrix.md` is re-rendered from the sweep's stored raw record with the final renderer. An independent re-render is byte-equal to it. - `gt-05` returned a truncated, flagged tool result on all 10 runs, and none hid the truncation. - `gt-04` stayed within budget on all 10 runs, and no task in the sweep exhausted a budget. ## Upgrade notes - **Python.** Recreate the virtualenv on Python 3.14.10: ```bash python3.14 -m venv .venv .venv/bin/pip install --no-input --no-deps -r requirements.txt .venv/bin/pip install --no-input --no-deps -e . ``` - **npm.** Run `npm ci` in `frontend/`, `src/relay/` and `tests/e2e/browser/`, using Node 26.13.1 for the frontend. - **Terraform.** Run `terraform init -upgrade` under Terraform 1.17.2 to pick up provider 6.72.0. - **Deploy.** Run `scripts/package_lambdas.sh` and `scripts/package_relay.sh`, then `scripts/deploy.sh` (with `CRM_EXPECTED_ACCOUNT_ID`). The apply: - updates every Python Lambda to the `python3.14` runtime; - rebuilds the Runtime image; - adds the Runtime history policy and enables TTL on `reps`; - updates the eval Lambdas and the relay. - **Old eval runs.** Eval runs recorded before this change stay in the deployed history but are not rendered. Local stored sweep records from before this change no longer render; re-run a sweep to produce new ones. - **Chat history** now persists for 24 hours after a session's last turn. See `docs/runbook.md`, "Conversation history", for operator deletion. ## Known limitations - **The tool-output bound and pagination disagree.** When the bound trims a page, `next_cursor` still resumes after the full page, so a model that follows the cursor never sees the trimmed records. The trim is flagged as truncated, and a smaller `limit` recovers them. On `opp-0000`'s default activity page, 4 of 50 records are affected. - **No deployed check sends `resume: true`.** The reconnect replay path is covered only by unit tests and the executing contract. - **The relay's prompt-cap contract test does not run in CI.** It passes when run with the relay's dependencies installed. - **Some smoke modules leave chat-history items in disposable smoke tenants.** Four modules don't yet delete the history items their turns write: the agent-stream, proposal-card, text-delta and MCP chat smokes. The items expire by TTL. - **A single unclassified stream `ReadError` stops a live sweep.** The interrupted sweep exits without results and has to be re-run. - **Dollar figures are not yet checked against Cost Explorer.** Token counts reconciled exactly with CloudWatch in an earlier sweep. - **A budget-exhausted run's usage is a lower bound,** because an abandoned round is unmetered. - **The eval run record still stores a failed step's raw error message.** The sweep Lambdas write it to the run record's `error` field, and the eval API returns it to the signed-in admin. An unwrapped AWS error there can name the caller's role ARN. The smoke no longer echoes it, but changing the stored value means changing deployed code. - **Runs recorded before this change show the new token rows under their stored notes.** The figures are correct, but those notes still describe the earlier rows and don't define uncached input tokens. - **Provider 6.72.0 carries one Go standard-library match** (GO-2026-6859), fixed upstream in go1.27.4. It is in local tooling only and is never deployed. - The deferred major upgrades listed under Dependencies. --- .github/workflows/verify.yml | 20 +- .gitlab-ci.yml | 54 +- .pre-commit-config.yaml | 4 +- .python-version | 2 +- Dockerfile | 4 +- README.md | 27 +- SECURITY.md | 50 +- docs/development.md | 8 +- docs/eval-methodology.md | 153 ++- docs/planted-defects.md | 22 +- docs/runbook.md | 65 +- docs/security-baseline.md | 2 +- fixtures/activities.json | 770 ++++++++++++++ fixtures/generate.py | 118 ++- frontend/.nvmrc | 2 +- frontend/package-lock.json | 403 +++++--- frontend/package.json | 10 +- frontend/scripts/generate-types.mjs | 14 +- .../AssistantPanel/useAssistantTurn.test.ts | 7 +- .../AssistantPanel/useAssistantTurn.ts | 6 +- frontend/src/hooks/useAgentStream.test.ts | 18 +- frontend/src/hooks/useAgentStream.ts | 9 +- .../src/pages/evals/EvalDashboardPage.tsx | 12 +- frontend/src/pages/evals/EvalRunClient.ts | 4 +- frontend/src/pages/evals/README.md | 3 +- .../evals/TierComparisonSummary.test.tsx | 37 + .../evals/__fixtures__/tierComparison.json | 235 +++-- .../pages/evals/evals.recordFormat.test.tsx | 155 +++ frontend/src/pages/evals/types.ts | 11 + frontend/src/test/responseShapes.test.ts | 7 +- githooks/pre-commit | 2 +- infra/.terraform.lock.hcl | 42 +- infra/backend.tf | 2 +- infra/bootstrap_account/.terraform.lock.hcl | 42 +- infra/bootstrap_account/README.md | 4 +- infra/bootstrap_account/apigw_logging.tf | 2 +- infra/bootstrap_account/versions.tf | 2 +- infra/eval_sfn.tf | 4 +- infra/main.tf | 133 ++- infra/mcp_chat_gateway.tf | 4 +- infra/modules/agent_relay/versions.tf | 2 +- infra/modules/agentcore/README.md | 2 +- infra/modules/agentcore/gateway.tf | 2 +- infra/modules/agentcore/runtime.tf | 4 +- infra/modules/agentcore/versions.tf | 2 +- infra/modules/api/versions.tf | 2 +- infra/modules/api_origin/versions.tf | 2 +- infra/modules/cognito/versions.tf | 2 +- infra/modules/dynamodb/tables.tf | 6 + infra/modules/dynamodb/versions.tf | 2 +- .../eni_function_code_deny/versions.tf | 2 +- infra/modules/eval_artifacts/versions.tf | 2 +- infra/modules/frontend_cdn/versions.tf | 2 +- infra/modules/lambda_action/README.md | 4 +- infra/modules/lambda_action/variables.tf | 2 +- infra/modules/lambda_action/versions.tf | 2 +- infra/modules/mcp_chat_gateway/README.md | 2 +- infra/modules/mcp_chat_gateway/versions.tf | 2 +- infra/modules/observability/versions.tf | 2 +- infra/modules/vpc/versions.tf | 2 +- infra/user_settings.tf | 2 +- pyproject.toml | 16 +- requirements.txt | 12 +- results/matrix.md | 400 +++---- scripts/bootstrap_account.sh | 4 +- scripts/check_cost_withheld.py | 39 +- scripts/check_cost_withheld.sh | 2 +- scripts/check_doc_figures.py | 2 +- scripts/check_emitted_css.py | 2 +- scripts/check_handler_grant_coverage.py | 1 + scripts/check_lambda_zip_imports.py | 84 +- scripts/check_no_untracked_refs.py | 2 +- scripts/check_plan_security_baseline.py | 204 +++- scripts/check_secret_scan.py | 4 +- scripts/check_untracked_artifact_secrets.py | 2 +- scripts/deploy.sh | 22 +- scripts/outputs_provenance.py | 4 +- scripts/package_lambdas.sh | 36 +- scripts/plan_fixtures.py | 2 +- scripts/preflight_adopted_vpc.sh | 4 +- scripts/refresh_outputs.sh | 2 +- scripts/repo_python.sh | 89 ++ scripts/rotate_mcp_client_secret.py | 4 +- scripts/smoke/access_log_delivery.py | 21 +- scripts/smoke/admin_authz.py | 10 +- scripts/smoke/agents.py | 67 +- scripts/smoke/api_routes.py | 5 +- scripts/smoke/chat_path_iam.py | 3 +- scripts/smoke/chat_timeouts.py | 41 +- scripts/smoke/cognito_claims.py | 33 +- scripts/smoke/deployed_parity.py | 182 +++- scripts/smoke/dynamodb_principal_deny.py | 81 +- scripts/smoke/dynamodb_tables.py | 6 +- scripts/smoke/eni_function_code_deny.py | 30 +- scripts/smoke/eval_sfn.py | 227 +++- scripts/smoke/gateway_tools.py | 35 +- scripts/smoke/harness.py | 44 +- scripts/smoke/iam_roles.py | 85 +- scripts/smoke/integration_gateway_scope.py | 8 +- scripts/smoke/integration_proposal_chain.py | 24 +- .../smoke/integration_teardown_privilege.py | 11 +- scripts/smoke/integration_ui_api_ddb.py | 10 +- scripts/smoke/lambda_actions.py | 50 +- scripts/smoke/mcp_chat_gateway.py | 16 +- scripts/smoke/mcp_client_compat.py | 13 +- scripts/smoke/mfa_user.py | 6 +- scripts/smoke/public_exposure.py | 11 +- scripts/smoke/relay_iam.py | 40 +- scripts/smoke/resource_protection.py | 35 +- scripts/smoke/runtime_bedrock_iam.py | 4 +- scripts/smoke/runtime_history_iam.py | 417 ++++++++ scripts/smoke/runtime_inbound_auth.py | 62 +- scripts/smoke/runtime_network_posture.py | 16 +- scripts/smoke/smoke_token.py | 4 +- scripts/smoke/store_principal_deny.py | 11 +- scripts/smoke/three_tier_chat.py | 741 ++++++++++++- scripts/smoke/user_settings_api.py | 7 +- scripts/smoke_agent_stream.py | 6 +- scripts/smoke_text_delta_stream.py | 2 +- scripts/teardown.sh | 8 +- scripts/verify_deployment.sh | 15 +- scripts/verify_fixtures.sh | 2 +- .../verify_terraform_plan_with_kms_absent.sh | 2 +- src/agents/budget.py | 60 +- src/agents/conversation_history.py | 278 ++++- src/agents/events.py | 75 +- src/agents/runtime_entrypoint.py | 14 +- src/agents/runtime_server.py | 147 ++- src/agents/subagent_runner.py | 70 +- src/agents/supervisor.py | 40 +- src/agents/turn_driver.py | 57 +- src/crm/store/keys.py | 11 + src/crm/store/store.py | 74 +- src/eval/golden_tasks.yaml | 87 +- src/eval/harness.py | 5 +- src/eval/matrix.py | 415 +++++--- src/eval/metrics.py | 97 +- src/eval/reprice.py | 93 +- src/eval/runs.py | 42 +- src/eval/scoring.py | 34 + src/eval/sfn_handlers.py | 41 +- src/eval/sweep_units.py | 60 +- src/eval/turn_observation.py | 36 +- src/eval/verification.py | 2 +- src/providers/anthropic_adapter.py | 54 +- src/providers/prompt_caching.py | 93 +- src/providers/sdk_transport.py | 46 +- src/relay/package-lock.json | 284 ++--- src/relay/package.json | 4 +- src/relay/src/index.ts | 1 + src/relay/src/requests.ts | 4 + src/relay/src/runtime.ts | 4 + src/relay/tests/index.test.ts | 13 + src/relay/tests/requests.test.ts | 24 + src/relay/tests/runtime.test.ts | 6 + tests/_dynamodb_local.py | 2 +- .../tier-comparison.spec.ts | 129 ++- .../22-chat-recall/chat-recall.spec.ts | 130 +++ tests/e2e/browser/journeys/README.md | 3 +- tests/fixtures/plans/compliant.base.ndjson | 88 +- .../oracle/scripts_investigation.py | 37 +- tests/integration/oracle/test_oracle_gate.py | 7 +- tests/integration/test_adapters_recorded.py | 2 +- tests/integration/test_gt04_budget_fit.py | 122 +++ tests/integration/test_gt05_truncation.py | 51 + tests/integration/test_history_store_ddb.py | 210 ++++ tests/integration/test_local_eval_sweep.py | 38 + tests/integration/test_reprice_roundtrip.py | 10 +- tests/integration/test_resume_contract.py | 350 +++++++ .../test_tier_comparison_local_sweep.py | 28 +- .../test_tier_comparison_ui_contract.py | 20 +- .../stub/test_sfn_vs_inprocess_equivalence.py | 1 + tests/unit/_terraform_fixture.py | 2 +- tests/unit/test_adapters.py | 207 +++- tests/unit/test_arm_tier_cost_invariant.py | 7 +- tests/unit/test_artifact_byte_identity.py | 1 + tests/unit/test_bootstrap_account_script.py | 1 + tests/unit/test_bound_tool_output.py | 151 +++ tests/unit/test_budget_exhaustion_tier.py | 354 +++++++ tests/unit/test_check_canary_tenant_empty.py | 2 +- tests/unit/test_check_cost_withheld.py | 261 ++++- tests/unit/test_ci_parity.py | 303 +++++- tests/unit/test_conversation_history.py | 343 +++++- tests/unit/test_cost_withheld_gate.py | 1 + tests/unit/test_deploy_script.py | 20 +- tests/unit/test_dockerfile_pins.py | 63 +- tests/unit/test_e2e_browser_scaffold.py | 1 + tests/unit/test_eval_artefacts.py | 30 +- tests/unit/test_eval_run_status_contract.py | 8 + tests/unit/test_eval_trigger.py | 75 +- .../test_forbidden_outcomes_falsifiable.py | 1 + tests/unit/test_gates.py | 2 +- .../test_golden_task_retrieval_scoring.py | 15 +- tests/unit/test_harness.py | 1 + .../test_harness_figure_semantics_parity.py | 1 + tests/unit/test_harness_live_mode.py | 2 +- .../unit/test_harness_multirole_rehearsal.py | 2 +- .../test_harness_tier_comparison_assert.py | 1 + tests/unit/test_hygiene_gates.py | 29 +- tests/unit/test_inflight_leaf_charging.py | 198 ++++ .../test_infra_dynamodb_asserted_actions.py | 191 +++- .../test_infra_dynamodb_principal_deny.py | 27 + tests/unit/test_infra_inline_policy_budget.py | 63 +- tests/unit/test_infra_relay.py | 2 +- tests/unit/test_infra_runtime_history.py | 374 +++++++ tests/unit/test_integration_gateway_scope.py | 53 + tests/unit/test_integration_proposal_chain.py | 76 ++ tests/unit/test_integration_ui_api_ddb.py | 33 + tests/unit/test_lambda_env_contract.py | 1 + tests/unit/test_lambda_zip_imports.py | 98 +- tests/unit/test_matrix.py | 169 ++- tests/unit/test_matrix_record_shape.py | 389 +++++++ tests/unit/test_matrix_repeat_completion.py | 19 +- tests/unit/test_matrix_tier_comparison.py | 353 +++++-- tests/unit/test_matrix_tier_summary.py | 17 +- tests/unit/test_matrix_uncached_input.py | 178 ++++ .../unit/test_metrics_tier_summary_tokens.py | 143 +++ tests/unit/test_metrics_tier_task.py | 95 +- tests/unit/test_package_lambdas.py | 4 +- .../unit/test_package_lambdas_agent_source.py | 93 ++ tests/unit/test_plan_fixtures.py | 8 +- tests/unit/test_plan_security_baseline.py | 137 +++ tests/unit/test_planted_evidence.py | 85 +- tests/unit/test_preflight_adopted_vpc.py | 5 + tests/unit/test_prompt_bundle.py | 8 + tests/unit/test_prompt_bundle_provenance.py | 24 +- ...t_provider_request_tool_schema_contract.py | 2 +- tests/unit/test_refresh_outputs.py | 1 + tests/unit/test_render_agentcore_env.py | 11 + tests/unit/test_repo_python.py | 262 +++++ tests/unit/test_reprice.py | 198 ++++ tests/unit/test_runs_record.py | 160 +++ tests/unit/test_runtime_entrypoint.py | 94 +- .../unit/test_runtime_server_history_store.py | 510 +++++++++ tests/unit/test_scoring.py | 81 ++ tests/unit/test_sdk_credential_surface.py | 14 +- tests/unit/test_sdk_transport.py | 62 +- tests/unit/test_sfn_handlers.py | 64 +- tests/unit/test_sfn_repeat_index_wiring.py | 55 + tests/unit/test_sfn_tier_task_roundtrip.py | 44 +- tests/unit/test_smoke_access_log_delivery.py | 39 +- tests/unit/test_smoke_admin_authz.py | 61 ++ tests/unit/test_smoke_agents.py | 156 ++- tests/unit/test_smoke_api_routes.py | 21 + tests/unit/test_smoke_chat_path_iam.py | 24 + tests/unit/test_smoke_chat_timeouts.py | 48 + tests/unit/test_smoke_cognito_claims.py | 61 ++ tests/unit/test_smoke_deployed_parity.py | 336 +++++- .../test_smoke_dynamodb_principal_deny.py | 211 +++- tests/unit/test_smoke_dynamodb_tables.py | 36 + .../unit/test_smoke_eni_function_code_deny.py | 49 + tests/unit/test_smoke_eval_sfn.py | 379 ++++++- tests/unit/test_smoke_gateway_tools.py | 64 ++ tests/unit/test_smoke_harness.py | 167 +++ tests/unit/test_smoke_iam_roles.py | 96 +- tests/unit/test_smoke_lambda_actions.py | 134 ++- tests/unit/test_smoke_mcp_chat_gateway.py | 45 + tests/unit/test_smoke_mcp_client_compat.py | 46 + tests/unit/test_smoke_mfa_user.py | 32 + tests/unit/test_smoke_no_raw_aws_error.py | 311 ++++++ tests/unit/test_smoke_public_exposure.py | 31 +- tests/unit/test_smoke_relay_iam.py | 63 +- tests/unit/test_smoke_resource_protection.py | 44 + tests/unit/test_smoke_runtime_history_iam.py | 332 ++++++ tests/unit/test_smoke_runtime_inbound_auth.py | 74 +- .../test_smoke_runtime_network_posture.py | 24 + tests/unit/test_smoke_store_principal_deny.py | 49 +- tests/unit/test_smoke_three_tier_chat.py | 978 +++++++++++++++++- tests/unit/test_smoke_token.py | 22 +- tests/unit/test_smoke_user_settings_api.py | 61 ++ tests/unit/test_store_conditional.py | 85 +- tests/unit/test_store_method_action_parity.py | 9 + tests/unit/test_subagent_runner.py | 63 ++ tests/unit/test_supervisor_contract.py | 39 + tests/unit/test_sweep_units.py | 201 +++- tests/unit/test_sweep_units_tier_task.py | 1 + .../unit/test_teardown_deletion_protection.py | 4 + tests/unit/test_temperature_removed.py | 3 +- tests/unit/test_truncation_key_pin.py | 65 ++ tests/unit/test_turn_driver_tiers.py | 101 +- tests/unit/test_turn_observation.py | 101 +- .../test_turn_observation_resolved_efforts.py | 1 + tests/unit/test_turn_row_fixture.py | 35 +- tests/unit/test_verify_deployment.py | 86 +- tests/unit/test_verify_gate_aggregation.py | 73 +- 285 files changed, 18326 insertions(+), 2166 deletions(-) create mode 100644 frontend/src/pages/evals/evals.recordFormat.test.tsx create mode 100755 scripts/repo_python.sh create mode 100644 scripts/smoke/runtime_history_iam.py create mode 100644 tests/e2e/browser/journeys/22-chat-recall/chat-recall.spec.ts create mode 100644 tests/integration/test_gt04_budget_fit.py create mode 100644 tests/integration/test_gt05_truncation.py create mode 100644 tests/integration/test_history_store_ddb.py create mode 100644 tests/integration/test_resume_contract.py create mode 100644 tests/unit/test_bound_tool_output.py create mode 100644 tests/unit/test_budget_exhaustion_tier.py create mode 100644 tests/unit/test_inflight_leaf_charging.py create mode 100644 tests/unit/test_infra_runtime_history.py create mode 100644 tests/unit/test_matrix_record_shape.py create mode 100644 tests/unit/test_matrix_uncached_input.py create mode 100644 tests/unit/test_metrics_tier_summary_tokens.py create mode 100644 tests/unit/test_package_lambdas_agent_source.py create mode 100644 tests/unit/test_repo_python.py create mode 100644 tests/unit/test_runtime_server_history_store.py create mode 100644 tests/unit/test_sfn_repeat_index_wiring.py create mode 100644 tests/unit/test_smoke_no_raw_aws_error.py create mode 100644 tests/unit/test_smoke_runtime_history_iam.py create mode 100644 tests/unit/test_truncation_key_pin.py diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index af0f5e5..7503e6a 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -26,7 +26,7 @@ env: # sudo drops the environment, so each `sudo apt-get` also sets this inline. DEBIAN_FRONTEND: "noninteractive" # Installed into each job's .venv before the lock; equal to `.gitlab-ci.yml`'s. - PIP_VERSION: "26.2.2" + PIP_VERSION: "26.3" jobs: verify: @@ -52,7 +52,7 @@ jobs: AWS_DEFAULT_REGION: "us-east-1" # Exact Node release for the relay; its major must equal the relay Lambda runtime, and it # equals `.gitlab-ci.yml`'s NODE_VERSION. - NODE_VERSION: "24.22.1" + NODE_VERSION: "24.22.3" steps: - name: Checkout @@ -123,7 +123,7 @@ jobs: - name: Set up pinned Terraform uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1 with: - terraform_version: 1.17.0 + terraform_version: 1.17.2 # tests/unit/_terraform_fixture.py parses the real binary's stdout, not the wrapper's. terraform_wrapper: false @@ -327,6 +327,20 @@ jobs: working-directory: . run: .venv/bin/python -m pytest tests/integration/test_envelope_groups_contract.py tests/integration/test_eval_envelopes_contract.py + # The bundled relay and the real Runtime handle the same reconnect bodies. + - name: SPA-relay-Runtime reconnect contract (the frontend's pinned Node) + working-directory: . + run: .venv/bin/python -m pytest tests/integration/test_resume_contract.py + + # The tier-comparison UI contract rewrites the fixture the frontend unit tests read. + - name: Tier-comparison UI contract + working-directory: . + run: .venv/bin/python -m pytest tests/integration/test_tier_comparison_ui_contract.py + + - name: Tier-comparison fixture matches the committed copy + working-directory: . + run: git diff --exit-code -- frontend/src/pages/evals/__fixtures__/tierComparison.json + # src/types/generated/ is gitignored, so types are generated before anything consumes them. - name: Generate types from the Python toolspec run: npm run gen:types diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 966989f..51e7419 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ # Runs `make verify` -- the offline aggregate gate: lint, typecheck, unit, stub, integration, # relay, gates, shellcheck. No AWS credential and no cost. # Tag must match the interpreter in .python-version. -image: python:3.13.18-slim +image: python:3.14.10-slim stages: - verify @@ -13,7 +13,7 @@ variables: LC_ALL: "C.UTF-8" DEBIAN_FRONTEND: "noninteractive" # Installed into each job's .venv before the lock. - PIP_VERSION: "26.2.2" + PIP_VERSION: "26.3" # Base packages both jobs install. .apt_deps: &apt_deps @@ -40,7 +40,7 @@ verify: AWS_ACCESS_KEY_ID: "local" AWS_SECRET_ACCESS_KEY: "local" # pragma: allowlist secret AWS_DEFAULT_REGION: "us-east-1" - TERRAFORM_VERSION: "1.17.0" + TERRAFORM_VERSION: "1.17.2" GITLEAKS_VERSION: "8.30.1" GITLEAKS_SHA256_X64: "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb" # pragma: allowlist secret GITLEAKS_SHA256_ARM64: "e4a487ee7ccd7d3a7f7ec08657610aa3606637dab924210b3aee62570fb4b080" # pragma: allowlist secret @@ -48,9 +48,9 @@ verify: SHELLCHECK_SHA256_X86_64: "8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198" # pragma: allowlist secret SHELLCHECK_SHA256_AARCH64: "12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588" # pragma: allowlist secret # Major must equal the relay Lambda runtime in infra/modules/agent_relay/variables.tf. - NODE_VERSION: "24.22.1" - NODE_SHA256_X64: "6c172a9ab6718f7b801fb5a7bd486af2ee5e32758086a04b84fcce2aa77095e6" # pragma: allowlist secret - NODE_SHA256_ARM64: "dbabf7a1cbf947e6059ffad2c27b80041db97dea1e553b62afdee7f13fca336e" # pragma: allowlist secret + NODE_VERSION: "24.22.3" + NODE_SHA256_X64: "4f2b175a6d53a5c617a80dba2676238a0688cef28c6da4eba35c7d844e66fcfb" # pragma: allowlist secret + NODE_SHA256_ARM64: "6e51a2ada00f0011cc266f65d98922b403d7ad88f809ca2aa615a5fe1ce6e86c" # pragma: allowlist secret # Minimum pytest-xdist worker count; equal to the Makefile's PYTEST_WORKERS default. PYTEST_WORKERS_FLOOR: "4" cache: @@ -240,12 +240,17 @@ verify: # Frontend lint, typecheck, unit tests and build, plus the emitted-CSS gate. frontend: stage: verify - image: node:26.13.0-slim + # Tag must match the interpreter in .python-version; Node comes from the pinned tarball below. + image: python:3.14.10-slim variables: NPM_CONFIG_FUND: "false" NPM_CONFIG_AUDIT: "false" CRM_REQUIRE_EMITTED_CSS: "1" CRM_REQUIRE_TS_CONTRACTS: "1" + # Must equal frontend/.nvmrc. + FRONTEND_NODE_VERSION: "26.13.1" + FRONTEND_NODE_SHA256_X64: "5c063e46bab0fbc1c17cc445d7ff129cbdcd0471be6ed83b6ab864f8143bc864" # pragma: allowlist secret + FRONTEND_NODE_SHA256_ARM64: "89e1853138db51e8b82d3e98ba9c0d3f2956a28e5e55ea1b7e12d25aae92d5dd" # pragma: allowlist secret cache: key: files: @@ -255,14 +260,32 @@ frontend: before_script: - set -euo pipefail - apt-get update -qq - - apt-get install -y -qq --no-install-recommends python3 python3-venv make git + - apt-get install -y -qq --no-install-recommends make git xz-utils curl ca-certificates libatomic1 - | - # Fail unless the image's Node matches frontend/.nvmrc. + # Install the pinned Node release; it must match frontend/.nvmrc. pinned="$(cat frontend/.nvmrc)" - installed="$(node --version | sed 's/^v//')" - [ "$installed" = "$pinned" ] || { - echo "ERROR: frontend/.nvmrc pins ${pinned} but the image ships ${installed}" >&2; exit 1; } - echo "frontend Node ${installed} matches frontend/.nvmrc" + [ "${FRONTEND_NODE_VERSION}" = "$pinned" ] || { + echo "ERROR: frontend/.nvmrc pins ${pinned} but FRONTEND_NODE_VERSION is ${FRONTEND_NODE_VERSION}" >&2; exit 1; } + case "$(uname -m)" in + x86_64) node_arch="x64"; frontend_node_sha="${FRONTEND_NODE_SHA256_X64}" ;; + aarch64) node_arch="arm64"; frontend_node_sha="${FRONTEND_NODE_SHA256_ARM64}" ;; + *) echo "ERROR: no pinned Node digest for architecture $(uname -m)" >&2; exit 1 ;; + esac + node_dir="node-v${FRONTEND_NODE_VERSION}-linux-${node_arch}" + asset="${node_dir}.tar.xz" + curl -fsSL --retry 3 --retry-all-errors -o "/tmp/${asset}" \ + "https://nodejs.org/dist/v${FRONTEND_NODE_VERSION}/${asset}" + echo "${frontend_node_sha} /tmp/${asset}" | sha256sum --check --strict - + tar -xJf "/tmp/${asset}" -C /usr/local --strip-components=1 --no-same-owner \ + "${node_dir}/bin" "${node_dir}/include" "${node_dir}/lib" + rm -f "/tmp/${asset}" + resolved="$(command -v node)" + [ "$resolved" = /usr/local/bin/node ] || { + echo "ERROR: PATH resolves node to ${resolved}, not the pinned install" >&2; exit 1; } + installed="$(node --version)" + [ "$installed" = "v${pinned}" ] || { + echo "ERROR: frontend/.nvmrc pins ${pinned} but PATH resolves ${installed}" >&2; exit 1; } + echo "frontend node ${installed} (npm $(npm --version)) pinned at ${resolved}" - python3 -m venv .venv - .venv/bin/python -m pip install --no-input "pip==${PIP_VERSION}" - | @@ -275,6 +298,11 @@ frontend: script: - .venv/bin/python -m pytest tests/unit/test_check_emitted_css.py - .venv/bin/python -m pytest tests/integration/test_envelope_groups_contract.py tests/integration/test_eval_envelopes_contract.py + # The SPA-relay-Runtime reconnect contract: the bundled relay and the real Runtime on the same bodies. + - .venv/bin/python -m pytest tests/integration/test_resume_contract.py + # The tier-comparison UI contract rewrites the fixture the frontend unit tests read. + - .venv/bin/python -m pytest tests/integration/test_tier_comparison_ui_contract.py + - git diff --exit-code -- frontend/src/pages/evals/__fixtures__/tierComparison.json - cd frontend - npm run gen:types # The full gate, including the frontend consumer byte-diff the verify job defers. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7af6369..f413eae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: check-log-redaction name: check no log call site under src/ can emit a token, secret, or full record payload - entry: python3 scripts/check_log_redaction.py + entry: scripts/repo_python.sh scripts/check_log_redaction.py language: system pass_filenames: false always_run: true @@ -45,7 +45,7 @@ repos: - id: gitleaks name: gitleaks secret scan (working tree, non-ignored files) - entry: env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_OBJECT_DIRECTORY python3 scripts/check_secret_scan.py + entry: env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR -u GIT_OBJECT_DIRECTORY scripts/repo_python.sh scripts/check_secret_scan.py language: system pass_filenames: false always_run: true diff --git a/.python-version b/.python-version index 844fbc4..6345df5 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.13.18 +3.14.10 diff --git a/Dockerfile b/Dockerfile index 0258844..e00a927 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ # ECR Public mirror of the Docker Official Image. Tag must match .python-version; pip must match # .gitlab-ci.yml's PIP_VERSION (tests/unit/test_dockerfile_pins.py). -FROM --platform=linux/arm64 public.ecr.aws/docker/library/python:3.13.18-slim AS base +FROM --platform=linux/arm64 public.ecr.aws/docker/library/python:3.14.10-slim AS base # Fixed UID/GID for the non-root runtime user. ARG APP_UID=10001 @@ -20,7 +20,7 @@ WORKDIR /app # Dependency layer, cached across source-only changes. COPY requirements.txt ./ -RUN pip install --no-cache-dir --no-input pip==26.2.2 \ +RUN pip install --no-cache-dir --no-input pip==26.3 \ && pip install --no-cache-dir --no-input --no-deps -r requirements.txt # src/providers/capabilities.py reads config/ relative to /app. diff --git a/README.md b/README.md index 81294a1..88089ea 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,9 @@ This is a demo and a research instrument, not a production CRM. | Tool | Version | |---|---| -| Python | exactly the version in `.python-version` (3.13.18); a newer host `python3` makes `pip install -e .` fail | -| Node.js | 26.13.0 for `frontend/` (`frontend/.nvmrc`); 24 or later for `src/relay/` (deployed on the `nodejs24.x` Lambda runtime) | -| Terraform | 1.17.0 or later (licensed under BUSL-1.1); the AWS provider is pinned to 6.71.0 | +| Python | exactly the version in `.python-version` (3.14.10); a host `python3` of any other minor version makes `pip install -e .` fail | +| Node.js | 26.13.1 for `frontend/` (`frontend/.nvmrc`); 24 or later for `src/relay/` (deployed on the `nodejs24.x` Lambda runtime) | +| Terraform | 1.17.2 tested; 1.17.0 or later required (licensed under BUSL-1.1); the AWS provider is pinned to 6.72.0 | | Docker | for DynamoDB Local (`amazon/dynamodb-local:3.3.2`, pinned by digest in `scripts/run_local_dynamodb.sh`) | | ShellCheck | 0.11.0 (pinned in CI); `make verify` runs it | | gitleaks | 8.30.1 (pinned in CI); optional locally, where `check_secret_scan` skips without it | @@ -105,7 +105,7 @@ and route tables, and the API Gateway logging role and setting. See ## Install ```bash -python3.13 -m venv .venv # the interpreter whose version matches .python-version +python3.14 -m venv .venv # the interpreter whose version matches .python-version # On a version mismatch this prints "wrong interpreter" and installs no Python packages. { [ "$(.venv/bin/python --version)" = "Python $(cat .python-version)" ] || { echo "wrong interpreter" >&2; false; }; } && .venv/bin/pip install --no-input --no-deps -r requirements.txt && @@ -473,13 +473,18 @@ the backend must go before the Runtime's network interfaces are released. - Most `violation_*.json` plan fixtures still record AWS provider 6.62.0, the version of the plan they were derived from. The compliant plan fixtures and the two violation fixtures derived from them are built at test time by `scripts/plan_fixtures.py`, from - `tests/fixtures/plans/compliant.base.ndjson`, which was captured from a plan under the - then-pinned 6.68.0 provider. -- The last grype scan covered the previous AWS provider pin, `hashicorp/aws` 6.70.0 (go1.26.10, - `golang.org/x/net` v0.61.0): no matches against its DB built 2026-10-25, measured 2026-10-25. The - pinned 6.71.0 has not been scanned. The binary is local Terraform tooling and is never deployed. + `tests/fixtures/plans/compliant.base.ndjson`, which was captured from a plan under + Terraform 1.17.2 and the pinned 6.72.0 provider. +- The last grype scan (grype 0.121.2) covered the pinned AWS provider's `darwin_arm64` build only, + `hashicorp/aws` 6.72.0 (go1.27.3, `golang.org/x/net` v0.62.0): one match against its DB built + 2026-11-13, measured 2026-11-13. The match is GO-2026-6859 in the Go standard library, a race in + HTTP/1 servers that use `MaxBytesReader`, with severity unknown and the fix in go1.27.4. The + binary is local Terraform tooling and is never deployed. - The JWKS fetch in `scripts/smoke/cognito_claims.py` uses PyJWT's own HTTP client, not the smoke harness's https-only opener. +- When the tool-output bound trims a page of records, the page's `next_cursor` still resumes after + the full page, so paging on cannot reach the trimmed records. Requesting the page again with a + smaller `limit` does. - **Principal boundary.** Resource policies deny the data and administration of these stores to every principal outside the project roles that use them, the operators in `crm_operator_principal_arns` and, for administration, the account root: @@ -506,6 +511,10 @@ the backend must go before the Runtime's network interfaces are released. - The CRM log groups stay readable by any principal in the account with CloudWatch Logs read permissions. CloudWatch Logs decrypts under its own service identity, so the logs key Deny refuses direct key use but not log reads. Log redaction applies to what they can read. +- Chat history items in the `reps` table expire 24 hours after their last write, but DynamoDB + deletes expired items in the background, typically within a few days of expiry, and `reps`' + point-in-time recovery keeps them for its 35-day window. Removing a user's history sooner means deleting its `history#` items as an operator (see + `docs/runbook.md`, "Conversation history"). - Until the first secret rotation, the MCP app client's secret stays readable through `cognito-idp:DescribeUserPoolClient` by any principal allowed that action; Cognito user pools have no resource policy. After a rotation (`scripts/rotate_mcp_client_secret.py`, see diff --git a/SECURITY.md b/SECURITY.md index 69fe295..a342196 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -3,9 +3,10 @@ See also: [documentation map](README.md#documentation) · [security baseline](docs/security-baseline.md) · [agent architecture](docs/agent-architecture.md) · [MCP client guide](docs/mcp-client-guide.md) · [runbook](docs/runbook.md) This page is the project's threat model: what the system protects, who might attack it and how, -which controls stand in the way, and which risks remain. It covers the OWASP Top 10 (2025) and the -OWASP Top 10 for LLM Applications (2025). The infrastructure controls themselves, each with its -verification command, live in [`docs/security-baseline.md`](docs/security-baseline.md). +which controls stand in the way, and which risks remain. It maps the system to three OWASP lists: +the OWASP Top 10 (2025), the current web edition; the OWASP Top 10 for LLM Applications (2026); and +the OWASP Top 10 for Agentic Applications (2026). The infrastructure controls themselves, each with +its verification command, live in [`docs/security-baseline.md`](docs/security-baseline.md). ## Reporting a vulnerability @@ -154,20 +155,35 @@ account. | A09 Security Logging and Alerting Failures | detection and attribution | CloudTrail; API Gateway access logs; KMS-encrypted log groups with retention; `check_log_redaction` | no CloudTrail metric filters or alarms; TM-09 | | A10 Mishandling of Exceptional Conditions | AWS errors, misconfiguration | error taxonomy at every module boundary; handler failures returned as classified payloads; fail-closed allowlist, cursor and identity paths | TM-16 | -## OWASP Top 10 for LLM Applications (2025) +## OWASP Top 10 for LLM Applications (2026) | Category | How it applies | Controls | Residual | |---|---|---|---| -| LLM01 Prompt Injection | rep prompts, MCP arguments and CRM text returned as tool output | the model never holds authority: identity, tenant and scope come from verified tokens; tool arguments validated against the toolspec; high-risk writes need human approval | TM-06 | -| LLM02 Sensitive Information Disclosure | CRM data in prompts and answers | answers can only contain what scoped tools returned; images in answers are never fetched, so markdown cannot exfiltrate through a URL; log redaction | TM-11 | -| LLM03 Supply Chain | model access and SDKs | models reached only through Bedrock inference profiles in the account; pinned vendor SDKs in the Runtime image only; model ids in `config/model_capabilities.yaml` | as A03 | -| LLM04 Data and Model Poisoning | golden tasks and seeded data | no fine-tuning or training; golden tasks and fixtures are tracked and reviewed; eval tenants are disposable | planted CRM text is handled as LLM01 | -| LLM05 Improper Output Handling | model output rendered in the SPA and passed to tools | markdown without raw HTML, `https:` and relative links only, no image fetch; tool calls schema-validated; SSE frames generated from one schema | none known | -| LLM06 Excessive Agency | agent write tools | role-scoped subagents with only the tools they need; no tool commits a high-risk change; the agent cannot approve, reject or revert; per-turn tool-call and time budgets | low-risk writes in the rep's own book (TM-06) | -| LLM07 System Prompt Leakage | supervisor and subagent prompts | prompts hold no secret or authority and are published in `config/agent_prompts/`; authorization never depends on prompt text | none | -| LLM08 Vector and Embedding Weaknesses | not applicable | the system has no vector store or retrieval index | none | -| LLM09 Misinformation | fabricated CRM facts in answers | delegation outcomes are typed (`data`, `denied`, `tool_failure`, `no_match`), so a denial or failure is never turned into data; the UI shows the tool trace beside the answer | a model can still misstate data it was given | -| LLM10 Unbounded Consumption | token and cost exhaustion | per-request prompt limit (refused, not trimmed); per-turn token, tool-call and time budgets; eval cost cap and daily live cap; throttles and reserved concurrency | TM-14, TM-15 | +| LLM01 Prompt Injection | rep prompts, MCP arguments, page context, CRM text returned as tool output, and the session's earlier turns | the model never holds authority: identity, tenant and scope come from verified tokens; tool arguments validated against the toolspec; page context is framed to the model as client-supplied data, not instructions; high-risk writes need human approval | TM-06 | +| LLM02 Sensitive Information Disclosure | CRM data in prompts, answers, tool arguments, logs and stored chat history | answers can only contain what scoped tools returned; images in answers are never fetched, so markdown cannot exfiltrate through a URL; log redaction (`check_log_redaction`); stored history is redacted, readable only by its owner and expires 24 hours after its last write | TM-11 | +| LLM03 Excessive Agency | agent write tools | role-scoped subagents with only the tools they need; no tool commits a high-risk change; the agent cannot approve, reject or revert; per-turn tool-call and time budgets | low-risk writes in the rep's own book (TM-06) | +| LLM04 Supply Chain | models, model access and SDKs | models reached only through Bedrock inference profiles in the account, with no third-party weights, adapters or fine-tunes; pinned vendor SDKs in the Runtime image only; model ids in `config/model_capabilities.yaml` | as A03 (TM-19) | +| LLM05 Data and Model Poisoning | golden tasks, seeded data and stored chat history | no fine-tuning, training or embedding; golden tasks and fixtures are tracked and reviewed; eval tenants are disposable; stored history holds only the session owner's own prompts and answers | planted CRM text is handled as LLM01, stored history as ASI06 | +| LLM06 Unbounded Consumption | token and cost exhaustion, including tool-call fan-out | per-request prompt limit (refused, not trimmed); per-turn token, tool-call and time budgets; tool output bounded before it re-enters the context; eval cost cap and daily live cap; throttles and reserved concurrency | TM-14, TM-15 | +| LLM07 Misinformation | fabricated CRM facts in answers | delegation outcomes are typed (`data`, `denied`, `tool_failure`, `no_match`), so a denial or failure is never turned into data; the UI shows the tool trace beside the answer | a model can still misstate data it was given | +| LLM08 Hidden Context Exposure | system prompts, answer style, page-context framing and the tool schemas the models receive | nothing in the model's context is meant to be secret: the prompts are published in `config/agent_prompts/`, and the agents' tool registry and the Gateway MCP tool definitions are generated from the tracked toolspec, which MCP clients can also list; no credential, token or identity is placed in model context; authorization never depends on prompt text or tool descriptions | none: the rest of a turn's context is the user's own prompt, page context and scoped data | +| LLM09 Vector and Embedding Weaknesses | not applicable | the system has no vector store, embedding index or semantic cache; search is a DynamoDB index query with text matching in process | none | +| LLM10 Improper Output Handling | model output rendered in the SPA, passed to tools and returned to MCP clients | markdown without raw HTML, `https:` and relative links only, no image fetch; tool arguments validated by the handler; SSE frames generated from one schema | control characters in answers are not removed, so an MCP client that prints answers to a terminal must neutralise them | + +## OWASP Top 10 for Agentic Applications (2026) + +| Category | How it applies | Controls | Residual | +|---|---|---|---| +| ASI01 Agent Goal Hijack | CRM text, page context or a prompt redirects the supervisor or a subagent across a multi-step turn | the agent's goal carries no authority: every tool call runs as the signed-in user and is re-authorized in the handler; page context is framed as data; a subagent sees only its delegated intent, not the conversation; high-risk changes need human approval; per-turn tool-call and time budgets | TM-06 | +| ASI02 Tool Misuse and Exploitation | an agent applying a legitimate tool unsafely, such as a wrong write or a costly loop | each agent role holds only the tools the toolspec grants it, and only the `mutation` subagent holds write tools; no tool commits a high-risk change; per-call result and read caps; per-turn tool-call and time budgets | low-risk writes in the rep's own book (TM-06); TM-10 | +| ASI03 Identity and Privilege Abuse | delegation from supervisor to subagent to tool tier, and the Runtime acting for a user | agents hold no identity or credential of their own; every call carries the verified user's identity on the `agent` channel, taken from the relay's or chat target's verified claims, and identity keys the model writes are stripped; delegation never widens scope; the agent channel cannot approve, reject or revert; the Runtime resource policy admits only the relay, sweep and chat-target roles | TM-03, TM-17 | +| ASI04 Agentic Supply Chain Vulnerabilities | tools, prompts, models and agent code the Runtime uses | nothing is loaded at run time from an outside source: tools come from the tracked toolspec and prompts from `config/agent_prompts/`, and both are part of the prompt-bundle digest recorded with each eval run; the agents connect to no external MCP server, agent or registry; models only through Bedrock; pinned SDKs built into the Runtime image | TM-19 | +| ASI05 Unexpected Code Execution (RCE) | whether model output can reach an interpreter | no agent holds a code interpreter, shell, browser or file-system tool; model output is only parsed as JSON tool arguments or rendered as text; YAML configuration is read with safe loading | none known | +| ASI06 Memory & Context Poisoning | durable chat history, the only agent memory that outlives a turn | history keeps each turn's prompt and final answer, never tool payloads; it is kept per session and owner and refused to any other user; at most 10 turns of at most 4,000 characters each, redacted; it expires 24 hours after its last write; no long-term, shared or vector memory; eval turns use no history | an answer that repeats injected CRM text is read again by later turns of the same session until the history expires (TM-06) | +| ASI07 Insecure Inter-Agent Communication | supervisor-to-subagent delegation | subagents run in the supervisor's Runtime process and are called in-process, with no network hop, message bus, agent discovery or agent-to-agent protocol; a delegation passes one `intent` string and returns one typed outcome; the callers into the Runtime (relay, chat target, sweep) sign with SigV4 and are admitted by its resource policy | the intent is natural language, so injected text can still shape it (TM-06) | +| ASI08 Cascading Failures | one bad output spreading through delegations, turns or sweeps | per-turn token, tool-call and time budgets end a runaway turn; a denial or failure is never turned into data; writes stay inside the caller's tenant and book; agents run only within a user's turn or an admin-started sweep, and never start another turn; sweep tasks run one at a time in disposable tenants | TM-14, TM-15 | +| ASI09 Human-Agent Trust Exploitation | a rep approving a change because an answer persuaded them | high-risk changes need an explicit approve in the UI; the proposal card renders from the stored proposal, not from model text; the UI shows the tool trace beside the answer | a rep can still approve a stored proposal on the strength of a misleading answer; Low | +| ASI10 Rogue Agents | an agent drifting from its intended scope | an agent keeps no state beyond its session's history, holds no credential and cannot change its own prompts, tools or model; it acts only inside a user's turn or a sweep; every write is audited under the verified rep | no alarm on unusual agent behaviour (TM-09) | ## Accepted risks and open items @@ -182,6 +198,12 @@ listed under [Limitations](README.md#limitations). - CloudTrail has no alarms; audit rows do not record the entry channel (TM-09). - One shared MCP service principal (TM-17). - Prompts and tool results reach Bedrock unredacted; acceptable only for synthetic data (TM-11). +- Injected CRM text that an answer repeats stays in that session's history, and is read by its + later turns, until the history expires (TM-06). +- A rep can approve a stored proposal because a misleading answer persuaded them. The card shows + the stored change, so what is approved is what is stored. +- Answers returned to MCP clients keep any control characters; a client that prints them to a + terminal must neutralise them. ## External threat model review diff --git a/docs/development.md b/docs/development.md index f0149e7..4faa101 100644 --- a/docs/development.md +++ b/docs/development.md @@ -11,7 +11,7 @@ The project's own virtualenv is mandatory: every `make` target invokes `.venv/bi `.venv/bin/ruff` and `.venv/bin/python` by path, and a system `python3` has no `pytest`. ```bash -python3.13 -m venv .venv # the interpreter whose version matches .python-version +python3.14 -m venv .venv # the interpreter whose version matches .python-version # On a version mismatch this prints "wrong interpreter" and installs no Python packages. { [ "$(.venv/bin/python --version)" = "Python $(cat .python-version)" ] || { echo "wrong interpreter" >&2; false; }; } && .venv/bin/pip install --no-input --no-deps -r requirements.txt && @@ -39,9 +39,9 @@ git config core.hooksPath githooks # or: pre-commit install cask `drawio`, whose CLI is `drawio`), using `drawio -x -f svg --embed-svg-images --theme light`; see [`docs/figures/README.md`](figures/README.md). - Security-relevant pins: `cryptography` 50.0.2, `PyJWT` 2.15.1, `urllib3` 2.8.0 and - `pytest` 9.1.1 (`requirements.txt`); `vite` 8.3.6 and `tailwindcss` 4.3.5 (`frontend/package.json`; + `pytest` 9.1.1 (`requirements.txt`); `vite` 8.3.8 and `tailwindcss` 4.3.5 (`frontend/package.json`; Tailwind 4 needs Safari 16.4, Chrome 111 or Firefox 128, see [`frontend/README.md`](../frontend/README.md)); `hashicorp/aws` - 6.71.0 (exact constraint) and `hashicorp/null` 3.3.2 (lock file only; no version constraint), in + 6.72.0 (exact constraint) and `hashicorp/null` 3.3.2 (lock file only; no version constraint), in `infra/.terraform.lock.hcl`. ## Running tests @@ -189,7 +189,7 @@ for each deferred control. | `check_gsi_projection_parity` | every Terraform GSI's projected attributes match the schema's declared projection | | `check_handler_grant_coverage` | each action Lambda's DynamoDB, KMS and log grants match the calls its handler code reaches, in both directions | | `check_payload_validation_coverage` | every path that persists a proposal payload validates it first | -| `check_lambda_zip_imports` | each built Lambda zip, by phase: `closure` (handler imports resolve inside the zip), `vendored_record` (vendored `RECORD` files match the zip contents), `wheel_platform` (Linux x86_64, CPython 3.13 or `abi3` tags), `marker_requires` (dependency markers evaluated for the Lambda environment), `isolated_import` (the handler imports in an isolated interpreter), `source_parity` (first-party files match `src/`), and `tracked_provenance` (first-party files match tracked git content) | +| `check_lambda_zip_imports` | each built Lambda zip, by phase: `closure` (handler imports resolve inside the zip), `vendored_record` (vendored `RECORD` files match the zip contents), `wheel_platform` (Linux x86_64, CPython 3.14 or `abi3` tags), `marker_requires` (dependency markers evaluated for the Lambda environment), `isolated_import` (the handler imports in an isolated interpreter), `source_parity` (first-party files match `src/`), and `tracked_provenance` (first-party files match tracked git content) | | `check_lambda_adapter_isolation` | no Lambda handler reaches a vendor-SDK model adapter: `import_time` (no adapter import on any handler's import path) and `stub_literal` (`eval.trigger` takes only an allowlist of names from `eval.harness`, references no `eval.live`, `providers.factory` or `eval.sweep_units`, and only `submit_sweep` takes a mode-selecting parameter) | | `verify_terraform_plan_with_kms_absent` | `lambda_action`'s KMS grant count comes from an input variable, so the module still plans once the key is gone; `[SKIP]` without `terraform` | | `check_sse_schema_parity` | every generated SSE event consumer matches `src/agents/event_schema.py` | diff --git a/docs/eval-methodology.md b/docs/eval-methodology.md index 7edf0d6..fa22772 100644 --- a/docs/eval-methodology.md +++ b/docs/eval-methodology.md @@ -161,9 +161,41 @@ A deployed sweep (the `eval_sweep` state machine, see `docs/runbook.md`) runs ea calls, 1,000,000 tokens and a 120-second wall clock. The 120-second cap is soft. When it is reached, every pending model wait ends, the turn stops with `error_kind` `budget_exhausted`, and the partial turn is scored against committed state like any other, with `budget_exhausted: true` on its result. +Each task score also records `budget_exhausted_tier`, the tier whose budget ran out (`null` when it +did not), and `repeat_index`, the repeat the run belonged to (from 0), so a raw archive keeps both +per run rather than only as per-arm counts. At 150 seconds (30 seconds past the soft cap) the Runtime cancels the turn at its next await and answers 504, so a turn that cannot unwind in time fails rather than hanging the sweep. +**Leaf calls are charged as they are dispatched.** Every leaf tool call inside a delegation is +charged against the turn's 25-call cap before it runs. At the cap the leaf is refused rather than +run, the refusal is logged as `tool_call_refused`, and ToolCall is recorded as the exhaustion tier. +The delegation stops there and returns what it had gathered, so a turn can no longer overrun the +cap inside a delegation and be charged only after it returns. The supervisor's direct calls count +against the same cap as they complete, and its loop stops the turn when the cap is reached. + +### The tool-output bound + +Every tool result is bounded before a model sees it, on every path: the supervisor's direct calls, +leaf calls inside a delegation, and provider-reported tool events. Size is measured as the UTF-8 +length of the result's Python `repr`, not its JSON. A result over 32,768 bytes +(`TOOL_RESULT_BYTE_CEILING` in `src/agents/events.py`) keeps as many whole records of +its record list as fit, gains a truncation marker record, and carries `truncated: true`. A result +under the ceiling is passed unchanged. The model receives the bounded copy, and the tool call's +attribution records the same flag, so the truncation rows of the tier comparison count what the +model was actually given. A delegation one of whose leaves was bounded reports itself truncated. + +The dataset makes the bound reachable. Planted defect PD-08 adds 55 activities to `opp-0000`, so even +that opportunity's 50 smallest activities together exceed the ceiling. `gt-05` +asks for every activity on `opp-0000` and so exercises truncation: its listing reaches the model +truncated and disclosed, and a summary that hides the truncation is scored as `silent_truncation`. +`gt-01` and `gt-17`, which also read `opp-0000`, keep the fields they score after the bound. + +**`gt-04` fits the budget.** `gt-04` is scoped to rep-ashford's opportunities on `acct-0000` and +expects reads of all four whose primary contact (`cont-0000`) has departed (`opp-0000`, `opp-0040`, +`opp-0080` and `opp-0200`). It completes within 20 tool calls whether the work is done directly or +in two research delegations, so it measures a multi-record investigation inside the 25-call cap. + A model call or round that the deadline cut off, or that the turn stopped, before it reported usage leaves its tokens uncounted, so that turn's usage and cost are a **lower bound**. A call cut off after its usage arrived is counted as metered, and does not make the usage a lower bound. The observed turn carries @@ -254,22 +286,52 @@ Every table has these rows, in this order: | Task completion over repeats | `rate (completed/applicable, majority of N)`. A task counts as completed at the tier when it passed in a strict majority of the repeats in which the tier was applicable (`passes × 2 > applicable repeats`), and as applicable when the tier applied in any repeat. With one repeat it equals the task completion rate. `n/a` when an archive has no tier scores. | | Task accuracy | Supervisor: the arm's `mean_correctness`. Subagent and ToolCall: the completion rate. | | Cost per completed task | The tier's total cost divided by its completed-task count, including spend on tasks that did not complete; `—` at zero completions. | -| P95 latency per completed task (ms) | Per task completed at the tier, the sum of that tier's measured call latencies in the task; nearest-rank P95 over those tasks, shown with n. | -| P50 latency per completed task (ms) | As above, at P50. | +| P50 latency per completed task (ms) | Per task completed at the tier, the sum of that tier's measured call latencies in the task; nearest-rank P50 over those tasks, shown with n. | +| P95 latency per completed task (ms) | As above, at P95. | | Model invocations | Included invocations at the tier. | -| Long-context invocations | The tier's included invocations priced at the invoked model's long-context rates (see Usage and cost); `—` for a run recorded before the count existed. | -| Input tokens | The tier's input tokens, in each family's own accounting. | -| Output tokens | The tier's output tokens. | -| Cost per task, all tasks | The tier's total cost divided by the number of tasks the arm ran. | +| Long-context invocations | The tier's included invocations priced at the invoked model's long-context rates (see Usage and cost). | +| Total input tokens | The tier's whole prompt, summed per call: reported input plus cache read plus cache write for Anthropic, and reported input for OpenAI, or that call's cache read plus cache write where they exceed it (see Usage and cost). Counted the same way for every family. | +| Cache read tokens | The tier's prompt tokens read from the prompt cache. | +| Cache write tokens | The tier's prompt tokens written to the prompt cache. | +| Uncached input tokens | Total input tokens minus Cache read tokens minus Cache write tokens: the prompt tokens neither read from nor written to the cache. Total input tokens = Cache read + Cache write + Uncached input, exactly, in every column. | +| Total output tokens | The tier's output tokens, reasoning tokens included. | +| Cost per applicable task | The tier's total cost divided by the number of task runs applicable at the tier (the denominator of the task completion rate); `—` when no task run is applicable. At 100% completion it equals Cost per completed task. | | Self-corrected retries | The tier's tool calls whose `tool_failure` result was self-corrected (see the retry rule below). `not applicable` at ToolCall, which makes one call per invocation. | -Each table then has its own rows: +Every table then ends with three more rows: -- Supervisor: **Budget-exhausted tasks**, the arm's tasks with `budget_exhausted: true`. -- Subagent: five rows, `Delegation outcome: data`, `: no_match`, `: denied`, `: tool_failure` and - `: none`, counted over every task the arm ran. `none` counts turns that reported no recognised outcome, so - the five rows sum to the arm's task count. -- ToolCall: **Truncated tasks**, the arm's tasks with `truncated: true`. +| Row | Definition, per arm, at the tier | +|---|---| +| Budget-exhausted tasks | The arm's task runs whose turn ran out of budget at this tier. | +| Truncated tool calls | The tool calls issued at this tier whose result reported truncation. `not applicable` at Subagent. | +| Truncated tasks | The arm's task runs with at least one truncated tool call at this tier. `not applicable` at Subagent. | + +A turn that runs out of budget is counted at exactly one tier, the tier where the exhaustion was +first detected; a later detection in the same turn does not move it. + +- A model request refused because its estimated prompt is above the per-request limit counts at the + tier of the refused request. +- A model call cut off by the turn's wall-clock deadline counts at that call's tier. +- A subagent that stops at a round boundary because the deadline passed counts at Subagent. +- A leaf call inside a delegation refused at the tool-call cap counts at ToolCall. +- Running out of the turn's tool-call allowance in the supervisor's own loop, or of its token + allowance, counts at Supervisor, as does any other exhaustion the supervisor's loop detects first. + +A truncated tool call is counted at the tier that issued it. The supervisor's direct tool calls +count at Supervisor, and every call made inside a delegation, whichever role made it, counts at +ToolCall, so both truncation rows read `not applicable` at Subagent. Every call records the +truncation flag of the bounded result its model received (see The tool-output bound). + +In `matrix.json` the three rows are the tier entry's `budget_exhausted_task_count`, +`truncated_tool_call_count` and `truncated_task_count` (`null` at Subagent for both truncation +counts). In `matrix.csv` they are `summary__budget_exhausted_task_count`, +`summary__truncated_tool_call_count` and `summary__truncated_task_count`, with the +Subagent truncation cells empty. + +Delegation outcome counts (`data`, `no_match`, `denied`, `tool_failure` and `none`, over every task +the arm ran) are not a table row. They are in `matrix.json`, as the subagent entry's +`delegation_outcomes`, and in `matrix.csv`, as the `summary_subagent_delegation_*` columns. `none` +counts turns that reported no recognised outcome, so the counts sum to the arm's task count. Reading rules: @@ -295,8 +357,14 @@ Reading rules: that input tokens are not like-for-like (`token_accounting_disclosure` in `src/eval/matrix.py`). Further notes appear when they apply: stub columns, withheld cost, errored items, and arms whose usage is a lower bound. -- **Older archives.** An arm record archived before the summary existed still re-renders; rows that - need the missing per-task block read `—`. +- **Older records are refused.** Every arm record, `matrix.json` and its `tier_comparison` block + carries `record_shape_version` as its first key, currently 3 (3 added the per-run + `budget_exhausted_tier` and `repeat_index` to each task score). A record without it, with any other + value, or missing a required field (such as a tier's `total_prompt_tokens`, `cache_read_tokens` or + `cache_write_tokens`) is refused with `RecordShapeRefused`, naming the version found and the one + required. Nothing is rendered from it: `python -m eval.matrix` and `eval.reprice` exit 2 and write + no file, and `tier_comparison_table` raises. Records from earlier sweeps are not upgraded or + partly rendered. ## Correctness figures @@ -411,9 +479,37 @@ are omitted (not zeroed), `cost_withheld_provisional` becomes `true`, and artifact. Each family reports cached prompt reads in a differently shaped usage object, so `input_tokens` is -not established to be like-for-like across arms. `matrix.md` states the per-family accounting +not like-for-like across arms: Anthropic reports input excluding cache read and cache write tokens, +OpenAI reports input including them. `matrix.md` states the per-family accounting (`token_accounting` in `figure_semantics`, sourced from `src/crm/metering.py`). +**Tier token totals.** Each tier of the tier comparison renders five token rows: Total input +tokens (`total_prompt_tokens`), Cache read tokens (`cache_read_tokens`), Cache write tokens +(`cache_write_tokens`), Uncached input tokens (`uncached_input_tokens`) and Total output tokens +(`output_tokens`), summed over the tier's (tier, role, model) rows. A call's prompt size is +`crm.metering.prompt_tokens`: input plus cache read plus cache write for Anthropic, and the reported +input for OpenAI, which already contains the cache counts (raised to their sum if they exceed it). +So each call's prompt is at least its cache read plus cache write, and the uncached figure is never +negative. Uncached input is derived, not recorded: `eval.matrix.uncached_input_tokens` computes +`total_prompt_tokens - cache_read_tokens - cache_write_tokens` when the summary is built and again +when a stored summary is rendered, so a stored record-shape-3 run without the field renders the +same row. Because the subtraction is linear, the tier figure equals the sum of the per-call figures, +and Total input = Cache read + Cache write + Uncached input holds exactly in every column for both +families. A given prompt yields the same Total, cache and uncached figures under either family. + +The tier tables carry no reported-input row. Each family's own `input_tokens` stays in the +per-model Usage and Cost tables, in `matrix.json` (`tier_comparison.tiers.[].input_tokens`) +and in `matrix.csv` (`summary__input_tokens`). The JSON entry carries +`uncached_input_tokens` beside `total_prompt_tokens`, and the CSV carries +`summary__uncached_input_tokens`. + +**Tier cost rows.** Both cost rows divide the tier's total cost, including spend on task runs that +did not complete. Cost per completed task divides by the task runs completed at the tier; Cost per +applicable task divides by the task runs applicable at the tier. They are equal when every +applicable run completed. In `matrix.json` they are `cost_per_completed_task` and +`cost_per_applicable_task`; in `matrix.csv`, `summary__cost_per_completed_task` and +`summary__cost_per_applicable_task`. + ## Latency (P50/P95) Latency percentiles use the **nearest-rank** method (`eval.metrics.nearest_rank_percentile`): for a @@ -501,16 +597,30 @@ Both family adapters apply one policy, defined in `src/providers/prompt_caching. adapter sends `prompt_cache_options {mode: implicit, ttl: 30m}` on every Responses request, the default mode, which adds an automatic breakpoint on the latest message and also honours explicit breakpoints. -- **One breakpoint, at the end of the stable prefix.** The stable prefix is the tool definitions +- **A breakpoint at the end of the stable prefix.** The stable prefix is the tool definitions plus the leading run of system messages, up to but not including the first message marked `cache_scope: volatile`. The supervisor's page briefing carries that marker, so it follows the breakpoint. The marker is never sent to either API. The Anthropic adapter puts `cache_control {type: ephemeral}` on that system block. The OpenAI adapter puts `prompt_cache_breakpoint {mode: explicit}` on that system message's `input_text` block. The tool tier sends no system message, so its requests carry no explicit breakpoint. -- **No breakpoint below the minimum.** The adapter omits the breakpoint when the prefix is too short - to reach the model's `prompt_cache_min_checkpoint_tokens`. It estimates this at two characters - per token, so it omits a breakpoint only when the prefix cannot reach the minimum. +- **A point on the latest message, matched across families.** The OpenAI platform's implicit + caching already places an automatic breakpoint on the latest message. The Anthropic adapter + matches it: it also puts `cache_control {type: ephemeral}` on the last content block of the + latest non-system message, so a later turn can read the conversation history cached by an earlier + one, not only the stable prefix. This applies at every tier, including the tool tier, which + carries no stable-prefix point. +- **At most four points on an Anthropic request.** A Messages API request carries no more than four + `cache_control` points. When there are more candidates, the latest-message point is kept first, + then the stable-prefix point, then the most recent others; the oldest are dropped. +- **No point below the minimum.** The adapter omits a point when the prefix up to and including it + is too short to reach the model's `prompt_cache_min_checkpoint_tokens`. For the latest-message + point that prefix is the tool definitions plus every message through the latest, including tool + calls and results. It estimates size at two characters per token, so it omits a point only when + the prefix cannot reach the minimum. + +Each arm records its family's method as `provenance.prompt_caching`, the text of `CACHING` in +`src/providers/prompt_caching.py`, so a result record states how its requests asked to be cached. The platform sets these per family. The last two differ between arms: @@ -551,6 +661,11 @@ from it. Each family's caching mechanism is a member of the prompt bundle, so a - **One dataset seed** per sweep. - **One prompt bundle per instrument.** Sweeps with different `prompt_bundle_sha256` values sent different prompts, tool descriptions or caching requests (see What the models are sent). +- **Sweeps before record shape 3 are a different instrument.** Shape 3 coincides with four changes + that move figures: the 55 planted activities on `opp-0000`, the tool-output bound on every path, + leaf calls charged as they are dispatched (with refused leaves counted at ToolCall), and the + resized `gt-04`. Earlier sweeps' correctness, truncation, budget-exhaustion and cost figures are + not comparable with later ones figure for figure, and their records are refused rather than read. - **The CLI `--live` sweep does not exercise the deployed AgentCore Runtime** (`live-aws-lambda-dispatch`). A state-machine sweep runs each task on the Runtime (`agentcore-runtime-eval-turn`). diff --git a/docs/planted-defects.md b/docs/planted-defects.md index ed21282..94a54a5 100644 --- a/docs/planted-defects.md +++ b/docs/planted-defects.md @@ -8,13 +8,14 @@ Each defect has a stable identifier (`PD-NN`) referenced by `src/eval/golden_tas `derived_from` field; the identifiers must never be renumbered once a golden task depends on them. Each defect is applied by a dedicated `_plant_pdNN_...` function in `fixtures/generate.py`, in the -fixed order `PD-01` … `PD-07`, over an already-generated base corpus. Each function touches a +fixed order `PD-01` … `PD-08`, over an already-generated base corpus. Each function touches a disjoint set of records, so the defects cannot interact regardless of order; `tests/unit/test_planted_evidence.py` pins every planted value for two tenants and checks that disabling any one planting changes only its own records. PD-01 and PD-02 were rewritten so that their notes state the evidence a correct proposal needs. PD-04 … PD-07 were added for the multi-field, report-only, ambiguity and multi-step-write tasks. +PD-08 was added so that gt-05's large-tool-result task receives a result over the tool-result bound. | Defect | Records | Golden task | |---|---|---| @@ -25,6 +26,7 @@ PD-04 … PD-07 were added for the multi-field, report-only, ambiguity and multi | PD-05 | `opp-0056`, `note-defect-pd05` | gt-22 | | PD-06 | `cont-0077`, `cont-0078` | gt-23 | | PD-07 | `opp-0088` | gt-24 | +| PD-08 | `act-defect-pd08-00` … `act-defect-pd08-54` (on `opp-0000`) | gt-05 (and every other read of `opp-0000`) | **The `-demo-` ids below are tenant-relative, not literal.** `fixtures/generate.py` prefixes every record id with the tenant it seeds, so `acct-demo-0000`, `cont-demo-0001` and so on are the `demo` @@ -150,9 +152,25 @@ in `Qualification` and has **no** seeded note and **no** seeded `meeting` activi **Expected handling.** Logging a meeting and then adding a note creates two new rows, and they are the only rows that can satisfy the task's new-row assertions. +## PD-08 — Activity history larger than one page + +**What's planted.** Opportunity `opp-demo-0000` gains 55 activities, `act-demo-defect-pd08-00` … +`act-demo-defect-pd08-54`, each with a multi-sentence `body`. They are appended after the base +corpus, drawn from a generator seeded separately from the base corpus, and dated at UTC midnight +between the opportunity's `created_at` and its recorded `last_touch`. No other record changes. + +**Why it matters.** `opp-demo-0000` now has 57 activities. Any 50 of them, the default +`list_activities` page, exceed the agents' tool-result bound (`TOOL_RESULT_BYTE_CEILING`, +32,768 bytes of `repr`). So does a `get_opportunity` on it, which carries the whole timeline. Such a +result reaches the model with its activity list trimmed and a truncation disclosure. The +opportunity record and its notes are not trimmed. + +**Expected handling.** The turn reports the activity listing as truncated rather than presenting it +as complete. gt-04 and gt-05 check this with `forbidden_outcomes: [silent_truncation]`. + ## Regeneration and verification `scripts/verify_fixtures.sh` regenerates the full corpus from `fixtures/generate.py` into a scratch directory and diffs every file against the committed `fixtures/*.json`, failing on any divergence. -All seven defects are covered by that byte-identical check, because they are applied +All eight defects are covered by that byte-identical check, because they are applied deterministically inside `generate_dataset()`; there is no separate defect-injection step. diff --git a/docs/runbook.md b/docs/runbook.md index a93465d..c303d00 100644 --- a/docs/runbook.md +++ b/docs/runbook.md @@ -52,7 +52,7 @@ is on `PATH`: a host `python3` of another minor version (3.14, say) builds a ven `pip install -e .` with `requires a different Python`. Check the version before installing: ```bash -python3.13 -m venv .venv # the interpreter whose --version matches .python-version +python3.14 -m venv .venv # the interpreter whose --version matches .python-version .venv/bin/python3 --version; cat .python-version # must print the same version; if not, stop .venv/bin/pip install --no-input --no-deps -r requirements.txt .venv/bin/pip install --no-input --no-deps -e . @@ -357,9 +357,10 @@ remedy. | `--no-auto-approve` without a TTY | drop the flag | | git index holds unmerged paths | resolve the listed paths and `git add` them (or abort the operation in progress) | | `aws`, `terraform` or `python3` not on `PATH` | install it | +| `no interpreter for the repository's Python scripts`, after a `repo_python.sh: requires Python >= …` line | create `.venv` from the interpreter in `.python-version`, or put a `python3` of at least that minor version first on `PATH` | | `sts get-caller-identity` fails | fix the profile's credentials | | `WRONG ACCOUNT` | pass the right `--profile`, or set `CRM_EXPECTED_ACCOUNT_ID` deliberately | -| a leftover `.bedrock_agentcore.yaml.orig` (only when a template was rendered) | `python3 scripts/render_agentcore_env.py restore --template .bedrock_agentcore.yaml --backup .bedrock_agentcore.yaml.orig` | +| a leftover `.bedrock_agentcore.yaml.orig` (only when a template was rendered) | `scripts/repo_python.sh scripts/render_agentcore_env.py restore --template .bedrock_agentcore.yaml --backup .bedrock_agentcore.yaml.orig` | | the public-exposure gate fails | fix the Terraform | | no `infra/terraform.tfvars` | create it from the example | | `terraform.tfvars` has an empty `vpc_id`, private subnet list, private route-table list or `vpc_runtime_subnet_ids` | fill it in | @@ -520,6 +521,10 @@ Notes: `CRM_E2E_ADMIN_EMAIL` and `CRM_E2E_ADMIN_PASSWORD`. - Keep both passwords in a `0600` file outside the repository (for example under `~/.local/state/crm-eval/`) and `source` it before a run; never in shell history or a tracked file. + Rewrite the file whenever `provision_demo_user.py` resets a password: a sourced stale file + overrides the current value, and every signed-in journey then fails with `SignInRejectedError` + ("Incorrect username or password", then "Password attempts exceeded"). That throttle clears on + its own, so wait before a re-run rather than retrying. - `provision_gateway_principal.py` checks `--profile` and `--region` against the outputs document before writing, writes the `demo` tenant only (it has no tenant option), and lives outside `scripts/smoke/`. The Layer 5/6 @@ -628,19 +633,20 @@ interrupted earlier run left behind. | Module | Asserts | |---|---| | `smoke/lambda_actions.py` | every action Lambda (from `ALL_TOOLS`) succeeds for an in-scope identity envelope and returns typed `scope_denied` (not a 500 or `not_found`) for an out-of-scope target; no response leaks `detail`; `create_opportunity`'s optional `primary_contact_id` is persisted when valid and refused with `validation_failed` when it belongs to another account. The listing tools (`search_opportunities`, `search_accounts`, `pipeline_aggregate`) are denied `scope_denied` naming `account:*` for an empty-book caller, and `explicit_out_of_book_filter_denied` checks that `search_opportunities` with an out-of-book `account_id` names `account:`. On the seeded departed contact: `departed_contact_update_refused` (409 `contact_departed`, missing scope `status:active`), `departed_contact_reactivation_allowed` (an update that sets `status`) and `departed_contact_restored` (set back to `departed`). Pagination cursors on the five paginating tools: page 2 through the real `next_cursor` succeeds, and a tampered cursor, a cursor replayed by another rep or a cursor from another tool is refused 400 `validation_failed` `source: cursor`. `CRM_CURSOR_KMS_KEY_ARN` is set on exactly those five functions. The cursor key has rotation on, is symmetric and single-Region, and carries `data-classification`. `simulate-principal-policy` shows the five roles may Encrypt/Decrypt only under the `crm-cursor` context and nothing else on the key, and other roles are refused, explicitly under the live key policy. A long-text field one character over the cap is refused 400 | -| `smoke/deployed_parity.py` | every deployed action Lambda plus the identity interceptor and pre-token-generation function has `CodeSha256` equal to its local zip's base64 SHA-256. Fail-closed on a missing build directory, zip or function. `--deploy-gate` is the form `deploy.sh` runs. Does not cover the relay | +| `smoke/deployed_parity.py` | every deployed action Lambda plus the identity interceptor and pre-token-generation function has `CodeSha256` equal to its local zip's base64 SHA-256. Fail-closed on a missing build directory, zip or function. `--deploy-gate` is the form `deploy.sh` runs; it compares code only and does not cover the relay. The inventory form also lists every `crm-agent-eval-*` function through `lambda:ListFunctions` (ENI probe functions excluded) and emits one `lambda_runtime` row per function: a Python function must report `python.` from `TARGET_PYTHON_VERSION` in `scripts/check_lambda_zip_imports.py`, and the relay the `nodejs.x` default in `infra/modules/agent_relay/variables.tf`. `lambda_runtime_coverage` fails when any parity target or the relay is missing from that listing, or when `ListFunctions` fails | | `smoke/api_routes.py` | private REST API: every route answers with a real Cognito token and returns 401 unauthenticated; every method names an authorizer and declares `COGNITO_USER_POOLS`; stage throttling is set; a `body-and-params` request validator exists and every method references it, with an `application/json` model on every POST. API client allowlist: every API-integrated function carries `CRM_API_ALLOWED_CLIENT_IDS_PARAMETER`, and none carries the old variable. The parameter is a `String` equal to the `cognito_spa_client_id` output and tagged `data-classification`. Its read grant is the exact ARN, and no project role may write it. A direct invoke of `get_account` with apigw claims that differ only in audience gives 401 for a foreign ID-token `aud` or access-token `client_id` and 2xx for the SPA client, and the refusal is logged with its reason | | `smoke/iam_roles.py` | every execution role, via `iam simulate-principal-policy`: allowed its own actions, denied every other function's. Each non-own pair yields a `simulate:` row (denied, pass/fail) and an `explicit_deny:` row (a matching Deny; an implicit deny fails). Each own grant the matrix declares `leading_keys`/`key_prefix`, sweep roles included, also yields a `conditioned_scope_denied:` row that probes a foreign key independent of the HCL parser, and `conditioned_grants_parity` fails if the parsed and declared conditioned grants differ. `matrix_readable` fails, and no role is examined, when `table_action_role_matrix.json` is malformed. A role whose policies cannot be loaded fails `leading_keys:policies_unreadable`. A `leading_keys:` row fails when a `ForAllValues:*` LeadingKeys Allow also grants an action that carries no LeadingKeys context (the condition holds vacuously for it). A role that cannot be resolved skips its matrix. A tool's Query grant scoped by `local.tool_query_indexes` (revert_audit_record's child check) is simulated on its first index, with `index_only_base_table_denied::dynamodb:Query@
` asserting the base table is refused and `scoped_index_allowed::dynamodb:Query@
/` covering each further index. `own_table_denied::@
` asserts an explicit Deny for each action in `OWN_TABLE_DENIAL_PROBES` (revert_audit_record's PutItem and UpdateItem on notes; sweep_control's PutItem on each seed table, which it writes through `BatchWriteItem` only). A sweep grant carrying a `select_condition` (sweep_control's `demo` Query on `gsi_tenant`, `Select = COUNT` only) yields `extra_condition_allowed:` (COUNT allowed), `extra_condition_denied:` (each other `Select` value denied), `extra_condition_absent_denied:` (no `Select` denied, the key reported missing) and `extra_condition_sibling_allowed:` (the `eval-*` and `canary` grants on the same index still read rows) rows; an unreadable grant list fails `extra_conditions_readable`. `coverage_is_non_vacuous` bounds the run by a derived minimum check count. Supplementary rows: the `sweep_task`, `pre_token_generation` and CodeBuild roles are refused cursor-key Encrypt/Decrypt under the valid context and refused reading or writing the API client-allowlist parameter. The `approve_proposal` role may Query opportunities' `gsi_account` only, not the base table or another index, and may not Scan | | `smoke/gateway_tools.py` | Gateway `tools/list` names exactly the toolspec's tools; `schema_matches`, per tool: the schema `type`, property names, each property's `type` and the `required` set match (constraint keywords such as `enum`, `minLength` and `maximum` cannot be carried by the Gateway and are reported as a `skip`); `description_matches_toolspec`, per tool: the tool's own `description` is byte-identical to the toolspec's (fails on a differing or missing description; `defer` when the tool is absent from `tools/list`); `property_descriptions_match_toolspec`, per tool: every property in both the deployed schema and the toolspec has the same `description`, byte for byte (fails on a differing, missing or undeclared description; `defer` when the deployed properties cannot be read or no property is shared); every tool invokes; a caller-supplied `_identity` is discarded. Provisions its own service principal and `client_credentials` token. An expired token and an underscoped token are each refused, after a premise check on the token's own claims; it mints both itself (a second machine token, minted first and aged past its 5-minute lifetime, so the run takes up to about 5 minutes longer; and a real end-user access token whose user is deleted afterwards). Optional operator overrides: `CRM_SMOKE_EXPIRED_TOKEN`, `CRM_SMOKE_UNDERSCOPED_TOKEN`, and `--gateway-token`/`CRM_SMOKE_GATEWAY_TOKEN`, which also turns off both mints, so the two refusal rows then need the other two overrides. The Gateway refuses a JSON-RPC array body with a tool-error reply (`isError: true`), without invoking the interceptor or a target; `array_body_answers_no_tool_call` fails if any tool output comes back without `isError: true`, and proof that no tool ran is a `defer` | | `smoke/agents.py` | one real chat turn through CloudFront `/agent/*` → relay → Runtime, as a user it provisions on a disposable tenant with an empty book, naming a `demo` account that user cannot see (its listing calls are denied `account:*`): the turn completes, no `tool_result` carries the out-of-book account, every event kind is in the closed vocabulary, and the per-agent grid (`responds`, `no_surplus_tool`, `no_missing_tool`, `no_direct_high_risk_write`, and the mutation subagent's `outcome_discipline_*`). A grid row the stream cannot establish is a `defer` naming its reason (`GRID_DEFER_REASONS`: `stream_carries_no_advertised_tool_surface`, `tool_call_events_carry_no_role`, `relay_turn_cannot_select_an_outcome_trigger`), never a `pass`. One model-backed turn (`MODEL_TURN_ALLOTMENTS`), billable. `demo` is proved untouched | | `smoke/dynamodb_tables.py` | every table in `crm.store.schema`: customer-managed KMS encryption, PITR, every GSI present, `ACTIVE`, queryable and projecting what `crm.store.schema` declares (`tenant` on every index; `subject` on activities' and `body` on notes' `gsi_tenant`, which scoring reads for agent-created rows), a failure naming the missing attributes, every mandatory tag (`AppName = crm-agent-eval` included); schema and `dynamodb_table_names` output reconciled | -| `smoke/dynamodb_principal_deny.py` | the DynamoDB principal boundary, read from the account. `table_policy_shape:
` and `key_policy_shape`: each table's resource policy and the DynamoDB CMK's key policy carry exactly the designed Deny statements, the data-plane allowlist equals the discovered project Lambda roles (each `crm-agent-eval-*` function whose role has a `-dynamodb-kms` inline policy) plus `crm_operator_principal_arns`, and the administration allowlist equals the operators plus the account root. `table_sse_enabled:
`: `ACTIVE`, no `InaccessibleEncryptionDateTime`, SSE `ENABLED`. `data_plane_roles_discovered`: at least one project Lambda role was found. `operator_data_plane_admitted`: the operator's `GetItem` on an absent key succeeds. `probe_denied:` (GetItem, Query on a GSI, conditional PutItem, conditional PutResourcePolicy, `kms:GenerateDataKey`): a run-scoped role `crm-agent-eval-probe-`, trusted by the operator only and holding its own Allow for those actions, is refused with "explicit deny in a resource-based policy"; success, an implicit deny, `ConditionalCheckFailedException` or `PolicyNotFoundException` fails. `probe_role_setup` appears only on failure, when creating, granting or assuming the probe role raised. No probe call can write data. The probe role is deleted in a `finally` (`probe_role_deleted`); if that row fails, delete the role by hand. Before the principal-boundary Deny is applied, the `probe_denied` rows fail and the shape rows fail or defer; after it, every row passes | +| `smoke/dynamodb_principal_deny.py` | the DynamoDB principal boundary, read from the account. `table_policy_shape:
` and `key_policy_shape`: each table's resource policy and the DynamoDB CMK's key policy carry exactly the designed Deny statements, the data-plane allowlist equals the discovered project Lambda roles (each `crm-agent-eval-*` function whose role has a `-dynamodb-kms` inline policy), the AgentCore Runtime's execution role (read with `get-agent-runtime` for the `agentcore_runtime_arn` output), and `crm_operator_principal_arns`, and the administration allowlist equals the operators plus the account root. `table_sse_enabled:
`: `ACTIVE`, no `InaccessibleEncryptionDateTime`, SSE `ENABLED`. `data_plane_roles_discovered`: at least one project Lambda role was found. `runtime_role_discovered`: the Runtime's execution role was read from the account. `operator_data_plane_admitted`: the operator's `GetItem` on an absent key succeeds. `probe_denied:` (GetItem, Query on a GSI, conditional PutItem, conditional PutResourcePolicy, `kms:GenerateDataKey`): a run-scoped role `crm-agent-eval-probe-`, trusted by the operator only and holding its own Allow for those actions, is refused with "explicit deny in a resource-based policy"; success, an implicit deny, `ConditionalCheckFailedException` or `PolicyNotFoundException` fails. `probe_role_setup` appears only on failure, when creating, granting or assuming the probe role raised. No probe call can write data. The probe role is deleted in a `finally` (`probe_role_deleted`); if that row fails, delete the role by hand. Before the principal-boundary Deny is applied, the `probe_denied` rows fail and the shape rows fail or defer; after it, every row passes | | `smoke/store_principal_deny.py` | the principal boundary on the state backend, the eval-artefacts key and bucket, the logs key, the CloudTrail key and bucket, and the frontend key and origin bucket; see "Store principal boundary" for its rows. `admin_simulated_denied` rows are a simulation of the live bucket document, not a call. The probe role is deleted in a `finally` (`probe_role_deleted`). The cursor key joins the boundary: the probe role's `kms:Encrypt` with the valid context is explicitly denied, and live-key-policy simulations deny the probe and key administration while admitting an allowlisted role and an operator | | `smoke/cognito_claims.py` | MFA and password policy; `AllowAdminCreateUserOnly` true (`admin_create_user_only`); an unsigned `SignUp` refused with `NotAuthorizedException` (`self_signup_refused`); the V2 pre-token-generation trigger stamps `rep_id`, `book`, `full_visibility`, `tenant` into a real token. Provisions and deletes its own user. `CRM_SMOKE_COGNITO_USERNAME`/`CRM_SMOKE_COGNITO_PASSWORD` select an existing enrolled user instead. The SPA client has token revocation enabled, and after `RevokeToken` a `REFRESH_TOKEN_AUTH` with the revoked token gets `NotAuthorizedException` | | `smoke/cloudfront.py` | OAC-only S3 origin and a direct S3 request refused; `/*`, `/api/*`, `/agent/*` route to the right origins; a deep link returns the SPA document, a missing `*.js` does not, an unauthenticated `/api/*` returns 401/403. TLS 1.2 minimum reports `defer` (`missing_custom_acm_certificate`). An enforced `Content-Security-Policy` on `/`, an unauthenticated `/api/*` and `/agent/*`, identical everywhere and equal to the distribution's one custom response-headers policy (`Override`, `X-Frame-Options: DENY`). Its directives match the design, connect-src admits Cognito, and every inline script in the served `/` is allowed by hash | | `smoke/access_log_delivery.py` | log objects actually arrive in each access-log bucket under each expected prefix; an empty bucket is `defer` (`no_log_objects_delivered_yet`), since delivery takes hours | | `smoke/relay_iam.py` | the relay execution role's allow and deny simulation matrix with positive controls; every other role denied invoking the Runtime; `X1_chat_target_deny_covers_actions_nobody_enumerated` (a fabricated action on the Runtime, simulated as the chat-target role, is `explicitDeny`); the relay Function URL's `AuthType` is `AWS_IAM`; `R1[]` for each toolspec tool no agent uses (approve, reject, revert): the Runtime role is denied `lambda:InvokeFunction` on it (synthetic-Allow positive control) and its `InvokeActionLambdas` statement names no pattern matching it | | `smoke/runtime_bedrock_iam.py` | the Runtime role is allowed `bedrock:InvokeModel` and `InvokeModelWithResponseStream` on every `global.` inference profile in `config/model_capabilities.yaml`, and denied `bedrock:InvokeModel` on each retired profile in the module's `RETIRED_INFERENCE_PROFILES` | +| `smoke/runtime_history_iam.py` | the Runtime role's conversation-history grant, via `iam simulate-principal-policy` and `describe-time-to-live`: allowed `GetItem` and `PutItem` on `reps` for a `history#` key, and the DynamoDB CMK (`kms:Decrypt`, `kms:GenerateDataKey`) only through DynamoDB for `reps`; `explicitDeny` on `usersettings#`, `conversation#`, a bare rep id and `history#canary#` keys, on every other action on `reps` and its indexes, and on every other table; denied without `dynamodb:LeadingKeys` context, for a `PutItem` writing a `tenant` attribute, and for the CMK on another table or without `kms:ViaService`; `reps` TTL `ENABLED` on `expires_at`. Each Get/Put/KMS deny row shares its action with an allow row | | `smoke/runtime_inbound_auth.py` | the Runtime carries no custom JWT authorizer (IAM inbound auth), with a non-vacuity guard on the response shape; the runner's own principal, which is not an invoker, is refused `InvokeAgentRuntime` (an outside-VPC refusal, which the `SourceVpce` Deny alone could produce); `outside_vpc_invoke_refused_under_declared_deny` judges that refusal against the `aws:SourceVpce` Deny state the deployment declares (declared enabled: an explicit resource-policy refusal passes and an admission fails; declared disabled or unknown, or another error: `defer` with its reason); the resource policies on the runtime ARN and on its DEFAULT endpoint each allow exactly the invoker roles in `local.runtime_invoker_role_arns`, and every Allow names an `AWS` principal only. The policies are read with botocore, or with `aws bedrock-agentcore-control get-resource-policy` under the resolved profile and region when botocore does not model the call; `defer` only when neither does | | `smoke/runtime_network_posture.py` | the Runtime and its `DEFAULT` endpoint are `READY` on the same version (`runtime_ready`, a bounded poll that fails at once on any status other than `READY`, `CREATING` or `UPDATING`, an absent status included); `platformVersion` is `V2` (`platform_version_expected`, read from the raw `GetAgentRuntime` body because the pinned botocore does not model the member); the ARN equals the stack output (`runtime_arn_unchanged`); the Runtime is `networkMode: VPC` in the stack's Runtime subnets (supported AZs) with the dedicated Runtime security group; the interface endpoints exist; no open egress; the `SourceVpce` deny state (`defer` until applied) | | `smoke/chat_timeouts.py` | the deployed relay and `chat_target` Lambda timeouts and the CloudFront relay origin's read timeout equal the configured values; the Runtime's container image tag is the one the local `agent-source.zip` mints, and ECR holds it. The 600 s turn itself is a declared `skip`. A repackage after the deploy makes the image row fail | @@ -682,8 +688,8 @@ refuses to run under `demo`, and reports a teardown failure as its own failing c | `smoke/integration_gateway_scope.py` | Gateway → interceptor → Lambda, opening with the MCP `initialize` handshake; scope enforcement survives the real interceptor hop: in-book reads succeed, out-of-book reads are `scope_denied` naming the missing scope, and an explicit account filter succeeds in book (`in_book_account_filter_succeeds`) and is denied out of book (`out_of_book_account_filter_denied_naming_scope`, `account:`); a forged `_identity` (widening or narrowing) changes no response byte, and forged `_agent_identity` and `requestContext` blocks are refused `scope_denied`; an undeclared argument is refused by the tool's closed schema (`validation_failed`, `source: arguments`, one `{statusCode, error}` item, no data), and a forged identity nested inside one gets the same refusal, byte-identical to a same-shaped decoy; no denial carries internal detail; the service principal is refused `approve_proposal`, `reject_proposal` and `revert_audit_record`, each with HTTP 403 `scope_denied` naming `principal:service` (`service_principal_refused_`) | its own service principal and `client_credentials` token, or `--gateway-token`/`CRM_SMOKE_GATEWAY_TOKEN` with `--in-book-account`/`--out-of-book-account` | | `smoke/integration_proposal_chain.py` | proposal → approval → audit → revert, plus both outcomes of the delete-proposal cascade, the `after_payload` allowlist, a note-create revert in scope (`note_revert:*`: the note is deleted and its audit marked reversed), and an approved delete reverted in scope (`delete_revert:*`: the contact is restored from the before-snapshot and its audit marked reversed); and two out-of-book reverts (`out_of_book_revert:*`): a note-create audit and a contact-delete audit, seeded under the disposable tenant for an account outside the book, are each refused with 403 `scope_denied`, and the note, the absent contact and both audit records read back unchanged | its own MFA-enrolled user, ID token; with `--token`, `--account-id` is optional: when absent, the account is the lowest entry of the token's `custom:book` claim (an absent or empty claim fails) | | `smoke/integration_teardown_privilege.py` | `dynamodb:DeleteItem` simulates as denied for `sweep_control`'s role (the state machine's `Teardown` step) on every tenant-scoped table, each deny resting on positive controls (the action is expressible, the ARN matches teardown's own `Query` grant, and any matrix holder of `DeleteItem` is allowed it); the role holds `BatchWriteItem` and teardown's `Query` on each table (`worker_holds_*`); `teardown_was_not_vacuous`: the fixture corpus the seeder writes is non-empty. No sweep and no tenant write; the teardown itself is `eval_sfn`'s `tenant_emptied_by_the_workers_own_role` | the runner's own credentials (simulation only) | -| `smoke/three_tier_chat.py` | one delegation-forcing turn invokes all three model tiers, attributed to the Runtime role in CloudTrail. The supervisor-tier invocation is the positive control for the role, the window and the supervisor family's CloudTrail event name only; it does not cover a lower tier on the other family. CloudTrail tells tiers apart only by inference profile, so the turn runs under the first `{tier: family}` mapping whose `config/models.yaml` models have three distinct profiles: all-anthropic, then an openai supervisor with anthropic subagent and tool, then the mixed-family mapping. The row detail names the mapping. When none has distinct profiles, the turn is not sent and `attribution_mapping_profiles_distinct` fails, naming each mapping's profiles. The delegation turn gets the mixed-family turn's cost and resolved-tier rows for its mapping, suffixed `:attribution`; a mixed-family turn (schema-3 tuning) completes with non-empty `cost_lines`, a positive `cost_usd` and `resolved_tiers` naming each tier's `config/models.yaml` model and effort, with a priced cost line per tier model; a schema-2 tuning carrying `temperature` is refused as one SSE `error` frame (`invalid_request`, naming `tuning.tiers..temperature`) with no `usage`, `completed` or `text_delta` frame; a second principal reusing another user's session id is refused (HTTP 400 through the relay), while the owner's own reuse succeeds; a delegation-forcing turn with every tier on openai gets the mixed-family turn's rows suffixed `:openai_supervisor`, including `supervisor_resolved_effort_is_:openai_supervisor` (the effort from `config/models.yaml`); for each family, the second of two supervisor turns sharing the stable prefix reports `cache_read_tokens > 0` on its supervisor cost line (`supervisor_prompt_cache_read_on_second_turn:`; the anthropic pair is the mixed-family seed and owner-reuse turns, the openai pair is the openai turn and a short probe turn), `defer` with `platform_reported_no_cache_tokens` when neither turn reports any cache token and `fail` when a write is reported but nothing is read; a `page_context` route planted with a run-unique marker, once longer than the route bound and once outside its character set, is refused with HTTP 400 and the relay's generic validation message with the marker absent from the response, against the probe turn's conforming `page_context` as the control (`page_context_over_bound_route_refused`, `page_context_off_charset_route_refused`; no model call). Five model-backed turns (`MODEL_TURN_ALLOTMENTS`); a turn past that share is not issued | provisioned users | -| `smoke/eval_sfn.py` | the `eval_sweep` state machine through `POST /api/eval_trigger`: a stub rehearsal at `REHEARSAL_REPEATS` repeats (single-flight 409; `unit_tenants_recorded`: the run's `eval_runs` row lists every (arm, repeat) unit tenant; `unit_tenants_seeded`: each holds rows while the run is running; `run_records_repeats`; `completed` with arms x repeats x tasks done, `SUCCEEDED` execution, `eval_results` rows reached the Runtime with one distinct `result_id` per item and an equal share at each `repeat_index`, artifacts pass `assert_artifacts` at tasks x repeats, each arm's `provenance.effort` is `DEFAULT_ARM_EFFORT` (one `arm_effort_is_default:` row per default-sweep family, in sweep order), each arm's models are `config/models.yaml`'s (one `arm_models_are_configured:` row per default-sweep family: `provenance.model_id` is the family's supervisor model and every tier's configured model id is that tier's model; an absent provenance or tier entry fails), `prompt_bundle_matches_repo` (every arm's `provenance.prompt_bundle_sha256` equals `agents.prompt_bundle.prompt_bundle_sha256()` of the checkout running the smoke; an absent digest fails), `artefact_url` presigns a recorded artefact that an https GET fetches (200) while plain http gets 403 `AccessDenied` and a tampered key 403 `SignatureDoesNotMatch` (the S3 error code is asserted, not only the status), the sweep tenant, `canary` and lock left clean, `demo` unchanged; `tenant_emptied_by_the_workers_own_role`: the run's `eval_runs` row is `torn_down` and the run tenant and every unit tenant read back empty, so the `Teardown` step emptied them under `sweep_control`'s own role) and a cancel proof on a second stub sweep at one repeat (`accepted`, then `cancelled` with a partial matrix and clean teardown, then `already_terminal`); least-privilege role simulations for `sweep_control`, `sweep_task`, the state machine role and `eval_trigger`, derived from the `infra/eval_sfn.tf` grant locals: every DynamoDB simulation of `sweep_control`'s role, allows and denies alike, sends `dynamodb:Select = COUNT` (the value its `demo` Query grants admit, so a deny is not the Select condition's doing), and a row answered with a context key missing never passes; an allow per conditioned grant value, denies for out-of-scope keys (a `demo` twin, a foreign key, and a minted-id twin such as `act-` for `act-eval-*`) and for `demo`/`canary` where a `gsi_tenant` grant does not admit them, and an explicit-Deny `*_denies_removed_*` row for each asserted action a role no longer holds on a table, such as the seed `PutItem` (incl. `trigger_allows_artifact_get` on the artefact prefix, and `trigger_denies_{get_outside_prefix,artifact_put,list_bucket}`); `machine_tracing_enabled` (the deployed state machine's `tracingConfiguration.enabled` is true); `machine_allows_{GetSamplingRules,GetSamplingTargets,PutTelemetryRecords,PutTraceSegments}` for the four SFN-XRAY-1 X-Ray actions on `*`, and `machine_denies_{BatchGetTraces,PutEncryptionConfig}` for X-Ray actions outside it. `--live-once --i-understand-this-is-billable` is the single live sweep, gated on a matching `--retention-verdict` | its own MFA-enrolled admin user with `full_visibility`, ID token. The completed stub run's `status` carries `tier_comparison_table` with one column per arm, and `artefact_url` with `download: true` serves `matrix_md` as an attachment with the same bytes | +| `smoke/three_tier_chat.py` | one delegation-forcing turn invokes all three model tiers, attributed to the Runtime role in CloudTrail. The supervisor-tier invocation is the positive control for the role, the window and the supervisor family's CloudTrail event name only; it does not cover a lower tier on the other family. CloudTrail tells tiers apart only by inference profile, so the turn runs under the first `{tier: family}` mapping whose `config/models.yaml` models have three distinct profiles: all-anthropic, then an openai supervisor with anthropic subagent and tool, then the mixed-family mapping. The row detail names the mapping. When none has distinct profiles, the turn is not sent and `attribution_mapping_profiles_distinct` fails, naming each mapping's profiles. The delegation turn gets the mixed-family turn's cost and resolved-tier rows for its mapping, suffixed `:attribution`; a mixed-family turn (schema-3 tuning) completes with non-empty `cost_lines`, a positive `cost_usd` and `resolved_tiers` naming each tier's `config/models.yaml` model and effort, with a priced cost line per tier model; a schema-2 tuning carrying `temperature` is refused as one SSE `error` frame (`invalid_request`, naming `tuning.tiers..temperature`) with no `usage`, `completed` or `text_delta` frame; a second principal reusing another user's session id is refused (HTTP 400 through the relay), while the owner's own reuse succeeds; a delegation-forcing turn with every tier on openai gets the mixed-family turn's rows suffixed `:openai_supervisor`, including `supervisor_resolved_effort_is_:openai_supervisor` (the effort from `config/models.yaml`); for each family, the second of two supervisor turns sharing the stable prefix reports `cache_read_tokens > 0` on its supervisor cost line (`supervisor_prompt_cache_read_on_second_turn:`; the anthropic pair is the mixed-family seed and owner-reuse turns, the openai pair is the openai turn and a short probe turn), `defer` with `platform_reported_no_cache_tokens` when neither turn reports any cache token and `fail` when a write is reported but nothing is read; a `page_context` route planted with a run-unique marker, once longer than the route bound and once outside its character set, is refused with HTTP 400 and the relay's generic validation message with the marker absent from the response, against the probe turn's conforming `page_context` as the control (`page_context_over_bound_route_refused`, `page_context_off_charset_route_refused`; no model call); three tool-free all-anthropic turns with one prompt, C in a fresh session then A and B in one shared session, pass `supervisor_prompt_cache_reads_latest_message:anthropic` when B's supervisor `cache_read_tokens` exceeds C's (a cache point on the latest message is read back by a later turn; this does not show that history reached the model), `defer` with `cache_history_turn_called_a_tool` when any of the three emitted a `tool_call` frame and with `platform_reported_no_cache_tokens` when C read nothing and no turn reported a cache write, and `fail` otherwise; the three are sent only when the share still has room for all of them. Cross-turn history, four tool-free all-anthropic turns: A in a fresh session S states a run-unique code word, B in S asks for it, a control in another fresh session asks the same, and a fourth turn in S sends no `resume_from` (the Gateway chat tool's payload shape) and asks again in other words. `followup_turn_carries_history:anthropic` passes when B's answer contains the code word, B's supervisor `cache_write_tokens` is above 0 with `cache_read_tokens` at least A's, and the control completed without it. `followup_without_resume_from_carries_history:anthropic` passes when the fourth turn's answer contains the code word and its supervisor read exceeds B's, which a replay of B cannot. `history_store_failures_absent_from_runtime_logs` fails on any `history_read_failed`, `history_write_failed` or `history_write_conflict` line in the Runtime log stream of any session the module used; its positive control is that every check-9 turn's `invocation_started` line sits in a stream naming its session. `history_item_owned_and_expiring` reads S's `reps` item (`history##`) as the operator: exactly the store's attributes, owned by user A's tenant, `expires_at` within the store's TTL. `history_items_deleted`: every history item the module's sessions could have written is deleted and re-read as absent before the smoke users are removed. Every turn sends its session's recorded-frame count as `resume_from`, so a follow-up runs rather than replaying. Twelve model-backed turns (`MODEL_TURN_ALLOTMENTS`); a turn past that share is not issued | provisioned users | +| `smoke/eval_sfn.py` | the `eval_sweep` state machine through `POST /api/eval_trigger`: a stub rehearsal at `REHEARSAL_REPEATS` repeats (single-flight 409; `unit_tenants_recorded`: the run's `eval_runs` row lists every (arm, repeat) unit tenant; `unit_tenants_seeded`: each holds rows while the run is running; `run_records_repeats`; `completed` with arms x repeats x tasks done, `SUCCEEDED` execution, `eval_results` rows reached the Runtime with one distinct `result_id` per item and an equal share at each `repeat_index`, artifacts pass `assert_artifacts` at tasks x repeats, each arm's `provenance.effort` is `DEFAULT_ARM_EFFORT` (one `arm_effort_is_default:` row per default-sweep family, in sweep order), each arm's models are `config/models.yaml`'s (one `arm_models_are_configured:` row per default-sweep family: `provenance.model_id` is the family's supervisor model and every tier's configured model id is that tier's model; an absent provenance or tier entry fails), `prompt_bundle_matches_repo` (every arm's `provenance.prompt_bundle_sha256` equals `agents.prompt_bundle.prompt_bundle_sha256()` of the checkout running the smoke; an absent digest fails), `matrix_is_record_shape_3` (the matrix and every arm carry `record_shape_version` 3, every arm a non-empty `provenance.prompt_caching`, every tier's `tier_summary` integer `total_prompt_tokens`, `cache_read_tokens` and `cache_write_tokens`, and every tier's `tier_task_metrics.by_tier` entry `budget_exhausted_task_count`, `truncated_tool_call_count` and `truncated_task_count`, both truncation counts `null` at the subagent tier; the live sweep asserts it too), `artefact_url` presigns a recorded artefact that an https GET fetches (200) while plain http gets 403 `AccessDenied` and a tampered key 403 `SignatureDoesNotMatch` (the S3 error code is asserted, not only the status), the sweep tenant, `canary` and lock left clean, `demo` unchanged; `tenant_emptied_by_the_workers_own_role`: the run's `eval_runs` row is `torn_down` and the run tenant and every unit tenant read back empty, so the `Teardown` step emptied them under `sweep_control`'s own role) and a cancel proof on a second stub sweep at one repeat (`accepted`, then `cancelled` with a partial matrix and clean teardown, then `already_terminal`); least-privilege role simulations for `sweep_control`, `sweep_task`, the state machine role and `eval_trigger`, derived from the `infra/eval_sfn.tf` grant locals: every DynamoDB simulation of `sweep_control`'s role, allows and denies alike, sends `dynamodb:Select = COUNT` (the value its `demo` Query grants admit, so a deny is not the Select condition's doing), and a row answered with a context key missing never passes; an allow per conditioned grant value, denies for out-of-scope keys (a `demo` twin, a foreign key, and a minted-id twin such as `act-` for `act-eval-*`) and for `demo`/`canary` where a `gsi_tenant` grant does not admit them, and an explicit-Deny `*_denies_removed_*` row for each asserted action a role no longer holds on a table, such as the seed `PutItem` (incl. `trigger_allows_artifact_get` on the artefact prefix, and `trigger_denies_{get_outside_prefix,artifact_put,list_bucket}`); `machine_tracing_enabled` (the deployed state machine's `tracingConfiguration.enabled` is true); `machine_allows_{GetSamplingRules,GetSamplingTargets,PutTelemetryRecords,PutTraceSegments}` for the four SFN-XRAY-1 X-Ray actions on `*`, and `machine_denies_{BatchGetTraces,PutEncryptionConfig}` for X-Ray actions outside it. `--live-once --i-understand-this-is-billable` is the single live sweep, gated on a matching `--retention-verdict` | its own MFA-enrolled admin user with `full_visibility`, ID token. The completed stub run's `status` carries `tier_comparison_table` with one column per arm and no `Delegation outcome` row in its Subagent section (`subagent_table_has_no_delegation_outcome_rows`), and `artefact_url` with `download: true` serves `matrix_md` as an attachment with the same bytes | | `smoke/admin_authz.py` | the eval run API's admin-only operations: no token refused; the admin group exists and the admin token carries it; a non-admin's `submit {mode: live, confirmed: false}`, `cancel` and `unlock` each return 403 `eval:admin`; an admin `cancel` of a terminal run returns `already_terminal` and changes nothing | two MFA-enrolled users it provisions, an admin and a non-admin with `full_visibility` | | `smoke/user_settings_api.py` | `POST /api/user_settings` keeps each user's tuning their own: defaults on `config/models.yaml`'s `default_family` before a save; a valid schema-3 `put` reads back; a `put` carrying `temperature` or naming a model no longer configured is 400 with the row unchanged; `GET /api/capabilities` names every `config/models.yaml` model and carries no `temperature`, and its `tiers..supervisor.tuning.effort` equals `config/models.yaml`'s (one `capabilities_supervisor_effort:` row per configured family); the served defaults match the config: `capabilities_default_family`, `capabilities_tier_model::` and `capabilities_tier_effort::` per configured cell, and `capabilities_assignable_tiers:` and `capabilities_selectable:` per `config/model_capabilities.yaml` model (Opus and Astra included); another user in the same tenant still sees defaults; a `put` naming another `rep_id` and an unsupported effort are 400 `validation_failed` with nothing changed; `reset` restores the defaults on the default family; least-privilege simulations for the `user-settings` role | two MFA-enrolled users under one tenant it provisions, each with a distinct run-scoped username | | `smoke/mcp_chat_gateway.py` | Gateway #2 exposes only `chat_with_supervisor` behind its JWT: no token is 401; a token whose signature is replaced is refused (401 or 403, with no `tools/list` result) while the same claims unaltered are answered; the chat-scoped user token is refused on Gateway #1 and a `gateway/invoke`-only token on Gateway #2; a user call and a `client_credentials` call are answered; a call carrying a `temperature` argument returns `isError` `invalid_request` with no answer or conversation id; another user's `conversation_id`, with or without a forged `_agent_identity`, is refused (`isError`, `error_kind` read from the MCP `result`). Two model-backed turns. Each smoke principal's `conversation#` items are found by owner, deleted and re-read | two users and the service principal it provisions | @@ -729,6 +735,14 @@ unit tenant. Layer 5's `eval_sfn` rehearses it in stub mode. One live sweep is `eval_sfn --live-once --i-understand-this-is-billable --retention-verdict=` (see "Data retention"). +Stored results carry `record_shape_version` 3. A run recorded before that format still appears in +the Evals page history with its status, times and spend, and shows "Recorded in an earlier format; +its results are not shown." in place of its tables and artifacts. Its status payload carries +`record_format: "earlier"` and no `matrix`, `tier_comparison_table` or `artifacts`. Offline, +`python -m eval.matrix` refuses such an archive with `RecordShapeRefused` naming the version found +and the one required, exits 2 and writes no file; `eval.reprice` refuses it the same way. Older +records are not converted. + The two sweep roles hold only the DynamoDB grants their code reaches (`infra/eval_sfn.tf`): - `sweep_control` seeds (through `Store.batch_put_items`) and deletes with `BatchWriteItem`. Its seed @@ -882,7 +896,7 @@ Residue the reaper cannot see: | A Cognito user from an interrupted smoke run | `aws cognito-idp list-users --user-pool-id --profile

--region --no-cli-pager`; remove with `admin-delete-user`. Do not lower MFA to clean up | | A `crm-agent-eval-eniprobe-` function from an interrupted `eni_function_code_deny` run | `aws lambda list-functions --profile

--region --no-cli-pager --query "Functions[?starts_with(FunctionName, 'crm-agent-eval-eniprobe-')].FunctionName"`. The next run of that module deletes any carrying the `smoke-run` tag; otherwise `aws lambda delete-function` | | A `selfsignup-smoke-@example.invalid` user (when `self_signup_user_deleted` failed) | `aws cognito-idp list-users --user-pool-id --filter 'email ^= "selfsignup-smoke-"' --profile

--region --no-cli-pager` | -| `results/verify_deployment_stderr.*` scratch files | local only: `rm -f results/verify_deployment_stderr.*` | +| `results/verify_deployment_stderr.*` scratch files | local only. `verify_deployment.sh` now replays each run's module stderr to its own stderr at exit and removes the log, so only files from an earlier version remain: `rm -f results/verify_deployment_stderr.*` | To check a single run's catalog row: @@ -942,8 +956,8 @@ Changes under `src/agents/` reach the Runtime only through a container rebuild: **The Runtime image and `eval_trigger.zip` deploy in the same apply, with no sweep running**. They share the serialised-turn schema, so a skew between them fails every -eval turn: a stale Runtime against a new `sweep_task` as `turn.schema must be 2, got 1`, and a new -Runtime against a stale `sweep_task` as `turn.schema must be 1, got 2`. +eval turn: a stale Runtime against a new `sweep_task` as `turn.schema must be 3, got 2`, and a new +Runtime against a stale `sweep_task` as `turn.schema must be 2, got 3`. Never run two Terraform commands concurrently (they contend on the state lock), and never destroy to resolve a parity failure. @@ -1269,8 +1283,41 @@ it later. Exit 0 means every resource is absent or pending deletion. A later dep | A reader refuses `results/tf-outputs.json` as absent or stale | re-run `deploy.sh`, which rewrites and stamps it; a stale snapshot is detected by its recorded commit | | `make verify-gates` fails with `.venv/bin/python3: No such file or directory` | the project virtualenv is missing; create it as in "Prerequisites" | +## Conversation history + +The Runtime keeps each chat session's recent turns so that a follow-up in the same session reaches +the model with them. Eval turns do not use it. + +| Item | Value | +|---|---| +| Store | `CONVERSATION_HISTORY_STORE` in the Runtime environment: `dynamodb` (set by Terraform) or `memory` (unset, the default for local runs and tests). Any other value fails at import | +| Item | one `reps` item per (tenant, session), key `history##`, attributes `rep_id`, `kind`, `owner_rep_id`, `owner_tenant`, `turns`, `version`, `updated_at`, `expires_at`. It carries no `tenant` attribute, so no index lists it | +| Bounds | the 10 most recent turns; each prompt and answer redacted, then capped at 4,000 characters | +| Expiry | `expires_at` is 24 hours after the last write; `reps` has DynamoDB TTL on it. DynamoDB deletes expired items in the background, typically within a few days of expiry, so the reader also treats an expired item as absent | +| Ownership | the item belongs to the user who started the session. Another user's read or write is refused; a session id under another tenant is a different item | +| Concurrency | a conditional write on `version`, retried up to 3 times; then `history_write_conflict` is logged | +| Failures | a read or write error, or a call past its deadline (5 s read, 8 s write), is logged as `history_read_failed` or `history_write_failed` with a `reason` and no content. The answer is still delivered; a failed read proceeds with no history | +| IAM | the Runtime role's inline policy `crm-agent-eval-runtime-history`: `GetItem` and `PutItem` on `reps` for `history#*` keys only, `PutItem` limited to the item's attributes, the DynamoDB CMK only through DynamoDB for `reps`, and explicit Denies on every other table and index, every other `reps` action, keys outside `history#` and the canary tenant's history. `smoke/runtime_history_iam.py` checks it | + +**Resume and replay.** A chat turn's request carries `session_id` and `resume_from`, the number of +frames the client has already applied. The Runtime replays a session's recorded frames only when the +request also carries `"resume": true` and `resume_from` is below the session's last frame; otherwise +it runs a fresh turn, whatever `resume_from` says. The SPA sends `resume` only from its automatic +reconnect and from the retry button; a follow-up never sends it. The relay forwards `resume` only +when it is exactly the JSON boolean `true`. A Gateway `chat_with_supervisor` follow-up sends no +`resume_from` and runs as a fresh turn with the session's history. + +**Budget note.** The Runtime role's inline policies total about 84% of IAM's 10,240-character +per-role quota (`smoke/iam_policy_budget.py` reports the figure). Put the role's next grant in a +managed policy. + ## Data retention +History items are also captured by `reps`' point-in-time recovery, so a restore within the PITR +window (35 days) can bring back an item that TTL had already deleted. To remove a user's history +before it expires, delete its `history##` items as an operator. + + A live eval sweep that includes the OpenAI models needs the account's Bedrock data-retention setting to permit them. Read it, read-only: diff --git a/docs/security-baseline.md b/docs/security-baseline.md index 641a752..7ecfb39 100644 --- a/docs/security-baseline.md +++ b/docs/security-baseline.md @@ -14,7 +14,7 @@ assertion nor a recorded reason it cannot be one, and by `tests/unit/test_verify | DynamoDB encryption at rest | KMS CMK, not AWS-owned | `describe-table \| jq '.Table.SSEDescription'` → `SSEType=KMS` + CMK ARN | blocks completion | | DynamoDB PITR | enabled all tables | `describe-continuous-backups` → `ENABLED` | blocks completion | | DynamoDB IAM | no `dynamodb:*`; per-table, per-action; `LeadingKeys` conditions where applicable | `iam simulate-principal-policy` | blocks completion | -| DynamoDB IAM | table and CMK policies deny the data plane, key use and administration to every principal outside the project's Lambda roles and `crm_operator_principal_arns` | `check_plan_security_baseline.py --only dynamodb`; Layer 4 smoke `dynamodb_principal_deny` (`get-resource-policy`, `get-key-policy`, denied probe calls) | blocks completion | +| DynamoDB IAM | table and CMK policies deny the data plane, key use and administration to every principal outside the project's Lambda roles, the AgentCore Runtime's execution role and `crm_operator_principal_arns` | `check_plan_security_baseline.py --only dynamodb`; Layer 4 smoke `dynamodb_principal_deny` (`get-resource-policy`, `get-key-policy`, denied probe calls) | blocks completion | | S3 frontend bucket | BPA on, private, OAC-only, TLS-deny policy | `get-public-access-block`, `get-bucket-policy` | blocks completion | | S3 encryption | KMS CMK | `get-bucket-encryption` | blocks completion | | S3 encryption | eval-artefacts, CloudTrail and frontend-origin bucket policies deny the object data plane (writes only, on the origin) and bucket administration to every principal outside the store's allowlist and `crm_operator_principal_arns`; only the CloudTrail bucket's data-plane Deny exempts service principals | `check_plan_security_baseline.py --only store`; Layer 4 smoke `store_principal_deny` | blocks completion | diff --git a/fixtures/activities.json b/fixtures/activities.json index cd7991e..1634b77 100644 --- a/fixtures/activities.json +++ b/fixtures/activities.json @@ -10694,5 +10694,775 @@ "subject": "Discovery call", "tenant": "demo", "updated_at": "2025-11-23T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-00", + "body": "Replied to the operations lead's questions on monitoring and alerting integration, with links to the relevant guides and a short description of how the pilot environment was configured. Offered to set up a working session with our solutions engineer. They accepted and proposed two slots next week; the earlier one is now on both calendars, with an agenda to follow.", + "created_at": "2025-11-06T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-06T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-06T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-01", + "body": "Pipeline review: confirmed the stage, the forecast value and the target close date with the account team. No change recorded; the next checkpoint is after the security review board has met and returned its findings. Risks noted: committee timing and the remaining security documentation, both tracked in the shared plan with owners and dates agreed by the account team.", + "created_at": "2025-11-06T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-06T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-06T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-02", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-06T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-06T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-06T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-03", + "body": "Quarterly review with the account's leadership. Covered adoption so far, the roadmap items they care about most, and the commercial timeline. They asked for a written summary of the next steps and a named contact for escalation during the rollout. The summary was drafted the same day and sent to the account team for a final check, and the escalation contact was confirmed by email afterwards.", + "created_at": "2025-11-06T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-06T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-06T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-04", + "body": "Check-in call with the infrastructure team. They walked through the current rollout plan, asked for a revised sizing estimate for the second region, and raised questions about the support tiers and response times. Agreed to send the updated estimate and a summary of the support options before the next weekly sync. They also mentioned a planned internal reorganisation that may change who signs off.", + "created_at": "2025-11-06T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-06T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-06T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-05", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-06T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-06T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-06T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-06", + "body": "Working session with the platform and security teams. Reviewed the pilot results, the open findings from their internal review and the proposed phased rollout. The security team wants evidence of the access-review process before sign-off; the platform team is ready to proceed with the first phase once that is cleared. Action items were assigned on both sides and captured in the shared plan, with the access-review evidence due first.", + "created_at": "2025-11-07T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-07T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-07T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-07", + "body": "Internal note: engagement remains steady and the technical evaluation is on track, but the decision sits with a committee that meets monthly, so timing depends on getting the remaining security documents to them before the next meeting. No change to the plan. Revisit after the committee meets, and confirm beforehand that the security documents reached the committee secretary in time.", + "created_at": "2025-11-07T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-07T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-07T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-08", + "body": "Quarterly review with the account's leadership. Covered adoption so far, the roadmap items they care about most, and the commercial timeline. They asked for a written summary of the next steps and a named contact for escalation during the rollout. The summary was drafted the same day and sent to the account team for a final check, and the escalation contact was confirmed by email afterwards.", + "created_at": "2025-11-07T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-07T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-07T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-09", + "body": "Quarterly review with the account's leadership. Covered adoption so far, the roadmap items they care about most, and the commercial timeline. They asked for a written summary of the next steps and a named contact for escalation during the rollout. The summary was drafted the same day and sent to the account team for a final check, and the escalation contact was confirmed by email afterwards.", + "created_at": "2025-11-07T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-07T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-07T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-10", + "body": "Short call with procurement to confirm the paperwork sequence. They want the security questionnaire and the data processing addendum reviewed in parallel, and asked whether the pricing proposal can be held for another quarter while budget approvals complete. Promised a written answer on the hold period and the renewal terms by end of week, copied to the account owner.", + "created_at": "2025-11-07T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-07T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-07T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-11", + "body": "Quarterly review with the account's leadership. Covered adoption so far, the roadmap items they care about most, and the commercial timeline. They asked for a written summary of the next steps and a named contact for escalation during the rollout. The summary was drafted the same day and sent to the account team for a final check, and the escalation contact was confirmed by email afterwards.", + "created_at": "2025-11-07T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-07T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-07T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-12", + "body": "Check-in call with the infrastructure team. They walked through the current rollout plan, asked for a revised sizing estimate for the second region, and raised questions about the support tiers and response times. Agreed to send the updated estimate and a summary of the support options before the next weekly sync. They also mentioned a planned internal reorganisation that may change who signs off.", + "created_at": "2025-11-08T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-08T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-08T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-13", + "body": "Stage reviewed after the evaluation checkpoint. The criteria agreed at the start of the evaluation have mostly been met; the outstanding items are the security review and the procurement paperwork, so the stage stays as recorded until both are complete. The account team agreed with that reading and will revisit it at the next checkpoint, with the security review outcome as the first agenda item.", + "created_at": "2025-11-08T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-08T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-08T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-14", + "body": "Stage reviewed after the evaluation checkpoint. The criteria agreed at the start of the evaluation have mostly been met; the outstanding items are the security review and the procurement paperwork, so the stage stays as recorded until both are complete. The account team agreed with that reading and will revisit it at the next checkpoint, with the security review outcome as the first agenda item.", + "created_at": "2025-11-08T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-08T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-08T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-15", + "body": "Short call with procurement to confirm the paperwork sequence. They want the security questionnaire and the data processing addendum reviewed in parallel, and asked whether the pricing proposal can be held for another quarter while budget approvals complete. Promised a written answer on the hold period and the renewal terms by end of week, copied to the account owner.", + "created_at": "2025-11-08T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-08T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-08T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-16", + "body": "Internal note: the account asked for a comparison against their incumbent tooling. Prepared a short summary of the differences in deployment model, support coverage and pricing structure, and shared it with the team for review before sending. The team suggested adding two customer references in the same industry before it goes out, which delays sending by a few days.", + "created_at": "2025-11-08T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-08T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-08T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-17", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-08T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-08T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-08T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-18", + "body": "Working session with the platform and security teams. Reviewed the pilot results, the open findings from their internal review and the proposed phased rollout. The security team wants evidence of the access-review process before sign-off; the platform team is ready to proceed with the first phase once that is cleared. Action items were assigned on both sides and captured in the shared plan, with the access-review evidence due first.", + "created_at": "2025-11-09T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-09T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-09T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-19", + "body": "Replied to the operations lead's questions on monitoring and alerting integration, with links to the relevant guides and a short description of how the pilot environment was configured. Offered to set up a working session with our solutions engineer. They accepted and proposed two slots next week; the earlier one is now on both calendars, with an agenda to follow.", + "created_at": "2025-11-09T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-09T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-09T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-20", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-09T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-09T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-09T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-21", + "body": "Short call with procurement to confirm the paperwork sequence. They want the security questionnaire and the data processing addendum reviewed in parallel, and asked whether the pricing proposal can be held for another quarter while budget approvals complete. Promised a written answer on the hold period and the renewal terms by end of week, copied to the account owner.", + "created_at": "2025-11-09T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-09T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-09T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-22", + "body": "Pipeline review: confirmed the stage, the forecast value and the target close date with the account team. No change recorded; the next checkpoint is after the security review board has met and returned its findings. Risks noted: committee timing and the remaining security documentation, both tracked in the shared plan with owners and dates agreed by the account team.", + "created_at": "2025-11-10T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-10T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-10T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-23", + "body": "Replied to the operations lead's questions on monitoring and alerting integration, with links to the relevant guides and a short description of how the pilot environment was configured. Offered to set up a working session with our solutions engineer. They accepted and proposed two slots next week; the earlier one is now on both calendars, with an agenda to follow.", + "created_at": "2025-11-10T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-10T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-10T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-24", + "body": "Quarterly review with the account's leadership. Covered adoption so far, the roadmap items they care about most, and the commercial timeline. They asked for a written summary of the next steps and a named contact for escalation during the rollout. The summary was drafted the same day and sent to the account team for a final check, and the escalation contact was confirmed by email afterwards.", + "created_at": "2025-11-10T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-10T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-10T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-25", + "body": "Internal note: the account asked for a comparison against their incumbent tooling. Prepared a short summary of the differences in deployment model, support coverage and pricing structure, and shared it with the team for review before sending. The team suggested adding two customer references in the same industry before it goes out, which delays sending by a few days.", + "created_at": "2025-11-10T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-10T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-10T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-26", + "body": "Quarterly review with the account's leadership. Covered adoption so far, the roadmap items they care about most, and the commercial timeline. They asked for a written summary of the next steps and a named contact for escalation during the rollout. The summary was drafted the same day and sent to the account team for a final check, and the escalation contact was confirmed by email afterwards.", + "created_at": "2025-11-10T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-10T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-10T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-27", + "body": "Check-in call with the infrastructure team. They walked through the current rollout plan, asked for a revised sizing estimate for the second region, and raised questions about the support tiers and response times. Agreed to send the updated estimate and a summary of the support options before the next weekly sync. They also mentioned a planned internal reorganisation that may change who signs off.", + "created_at": "2025-11-11T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-11T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-11T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-28", + "body": "Internal note: engagement remains steady and the technical evaluation is on track, but the decision sits with a committee that meets monthly, so timing depends on getting the remaining security documents to them before the next meeting. No change to the plan. Revisit after the committee meets, and confirm beforehand that the security documents reached the committee secretary in time.", + "created_at": "2025-11-11T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-11T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-11T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-29", + "body": "Working session with the platform and security teams. Reviewed the pilot results, the open findings from their internal review and the proposed phased rollout. The security team wants evidence of the access-review process before sign-off; the platform team is ready to proceed with the first phase once that is cleared. Action items were assigned on both sides and captured in the shared plan, with the access-review evidence due first.", + "created_at": "2025-11-11T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-11T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-11T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-30", + "body": "Working session with the platform and security teams. Reviewed the pilot results, the open findings from their internal review and the proposed phased rollout. The security team wants evidence of the access-review process before sign-off; the platform team is ready to proceed with the first phase once that is cleared. Action items were assigned on both sides and captured in the shared plan, with the access-review evidence due first.", + "created_at": "2025-11-11T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-11T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-11T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-31", + "body": "Check-in call with the infrastructure team. They walked through the current rollout plan, asked for a revised sizing estimate for the second region, and raised questions about the support tiers and response times. Agreed to send the updated estimate and a summary of the support options before the next weekly sync. They also mentioned a planned internal reorganisation that may change who signs off.", + "created_at": "2025-11-11T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-11T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-11T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-32", + "body": "Working session with the platform and security teams. Reviewed the pilot results, the open findings from their internal review and the proposed phased rollout. The security team wants evidence of the access-review process before sign-off; the platform team is ready to proceed with the first phase once that is cleared. Action items were assigned on both sides and captured in the shared plan, with the access-review evidence due first.", + "created_at": "2025-11-11T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-11T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-11T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-33", + "body": "Pipeline review: confirmed the stage, the forecast value and the target close date with the account team. No change recorded; the next checkpoint is after the security review board has met and returned its findings. Risks noted: committee timing and the remaining security documentation, both tracked in the shared plan with owners and dates agreed by the account team.", + "created_at": "2025-11-11T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-11T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-11T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-34", + "body": "Internal note: the account asked for a comparison against their incumbent tooling. Prepared a short summary of the differences in deployment model, support coverage and pricing structure, and shared it with the team for review before sending. The team suggested adding two customer references in the same industry before it goes out, which delays sending by a few days.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-35", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-36", + "body": "Stage reviewed after the evaluation checkpoint. The criteria agreed at the start of the evaluation have mostly been met; the outstanding items are the security review and the procurement paperwork, so the stage stays as recorded until both are complete. The account team agreed with that reading and will revisit it at the next checkpoint, with the security review outcome as the first agenda item.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-37", + "body": "Internal note: the account asked for a comparison against their incumbent tooling. Prepared a short summary of the differences in deployment model, support coverage and pricing structure, and shared it with the team for review before sending. The team suggested adding two customer references in the same industry before it goes out, which delays sending by a few days.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-38", + "body": "Working session with the platform and security teams. Reviewed the pilot results, the open findings from their internal review and the proposed phased rollout. The security team wants evidence of the access-review process before sign-off; the platform team is ready to proceed with the first phase once that is cleared. Action items were assigned on both sides and captured in the shared plan, with the access-review evidence due first.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-39", + "body": "Replied to the operations lead's questions on monitoring and alerting integration, with links to the relevant guides and a short description of how the pilot environment was configured. Offered to set up a working session with our solutions engineer. They accepted and proposed two slots next week; the earlier one is now on both calendars, with an agenda to follow.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-40", + "body": "Stage reviewed after the evaluation checkpoint. The criteria agreed at the start of the evaluation have mostly been met; the outstanding items are the security review and the procurement paperwork, so the stage stays as recorded until both are complete. The account team agreed with that reading and will revisit it at the next checkpoint, with the security review outcome as the first agenda item.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-41", + "body": "Internal note: the account asked for a comparison against their incumbent tooling. Prepared a short summary of the differences in deployment model, support coverage and pricing structure, and shared it with the team for review before sending. The team suggested adding two customer references in the same industry before it goes out, which delays sending by a few days.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-42", + "body": "Working session with the platform and security teams. Reviewed the pilot results, the open findings from their internal review and the proposed phased rollout. The security team wants evidence of the access-review process before sign-off; the platform team is ready to proceed with the first phase once that is cleared. Action items were assigned on both sides and captured in the shared plan, with the access-review evidence due first.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "meeting", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Working session", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-43", + "body": "Pipeline review: confirmed the stage, the forecast value and the target close date with the account team. No change recorded; the next checkpoint is after the security review board has met and returned its findings. Risks noted: committee timing and the remaining security documentation, both tracked in the shared plan with owners and dates agreed by the account team.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-44", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-45", + "body": "Pipeline review: confirmed the stage, the forecast value and the target close date with the account team. No change recorded; the next checkpoint is after the security review board has met and returned its findings. Risks noted: committee timing and the remaining security documentation, both tracked in the shared plan with owners and dates agreed by the account team.", + "created_at": "2025-11-12T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-12T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-12T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-46", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-47", + "body": "Internal note: engagement remains steady and the technical evaluation is on track, but the decision sits with a committee that meets monthly, so timing depends on getting the remaining security documents to them before the next meeting. No change to the plan. Revisit after the committee meets, and confirm beforehand that the security documents reached the committee secretary in time.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-48", + "body": "Short call with procurement to confirm the paperwork sequence. They want the security questionnaire and the data processing addendum reviewed in parallel, and asked whether the pricing proposal can be held for another quarter while budget approvals complete. Promised a written answer on the hold period and the renewal terms by end of week, copied to the account owner.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-49", + "body": "Pipeline review: confirmed the stage, the forecast value and the target close date with the account team. No change recorded; the next checkpoint is after the security review board has met and returned its findings. Risks noted: committee timing and the remaining security documentation, both tracked in the shared plan with owners and dates agreed by the account team.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-50", + "body": "Internal note: the account asked for a comparison against their incumbent tooling. Prepared a short summary of the differences in deployment model, support coverage and pricing structure, and shared it with the team for review before sending. The team suggested adding two customer references in the same industry before it goes out, which delays sending by a few days.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-51", + "body": "Check-in call with the infrastructure team. They walked through the current rollout plan, asked for a revised sizing estimate for the second region, and raised questions about the support tiers and response times. Agreed to send the updated estimate and a summary of the support options before the next weekly sync. They also mentioned a planned internal reorganisation that may change who signs off.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "call", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Check-in call", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-52", + "body": "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, the reference customer list and the answers to the open security questions. Asked the team to flag anything missing before the review board meets, and offered a session to go through the migration timeline in more detail. No reply yet; a reminder is scheduled for the start of next week if nothing arrives, with a call as the fallback.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "email", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Follow-up email", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-53", + "body": "Pipeline review: confirmed the stage, the forecast value and the target close date with the account team. No change recorded; the next checkpoint is after the security review board has met and returned its findings. Risks noted: committee timing and the remaining security documentation, both tracked in the shared plan with owners and dates agreed by the account team.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "stage_change", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Stage reviewed", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" + }, + { + "account_id": "acct-demo-0000", + "activity_id": "act-demo-defect-pd08-54", + "body": "Internal note: engagement remains steady and the technical evaluation is on track, but the decision sits with a committee that meets monthly, so timing depends on getting the remaining security documents to them before the next meeting. No change to the plan. Revisit after the committee meets, and confirm beforehand that the security documents reached the committee secretary in time.", + "created_at": "2025-11-13T00:00:00Z", + "created_by": "rep-ashford", + "kind": "note", + "occurred_at": "2025-11-13T00:00:00Z", + "opportunity_id": "opp-demo-0000", + "schema_version": 1, + "subject": "Internal note", + "tenant": "demo", + "updated_at": "2025-11-13T00:00:00Z" } ] diff --git a/fixtures/generate.py b/fixtures/generate.py index 1edd444..17f1e5f 100644 --- a/fixtures/generate.py +++ b/fixtures/generate.py @@ -599,6 +599,75 @@ def _generate_activities_and_notes( PD05_OPPORTUNITY_INDEX: Final[int] = 56 PD07_OPPORTUNITY_INDEX: Final[int] = 88 +#: PD-08's activity count on ``opp-0000``, above one default ``list_activities`` page of 50. +PD08_ACTIVITY_COUNT: Final[int] = 55 + +#: PD-08's activity bodies by kind, each long enough that 50 of them exceed the tool-result bound. +PD08_ACTIVITY_BODIES: Final[dict[str, tuple[str, ...]]] = { + "call": ( + "Check-in call with the infrastructure team. They walked through the current rollout " + "plan, asked for a revised sizing estimate for the second region, and raised questions " + "about the support tiers and response times. Agreed to send the updated estimate and a " + "summary of the support options before the next weekly sync. " + "They also mentioned a planned internal reorganisation that may change who signs off.", + "Short call with procurement to confirm the paperwork sequence. They want the security " + "questionnaire and the data processing addendum reviewed in parallel, and asked whether " + "the pricing proposal can be held for another quarter while budget approvals complete. " + "Promised a written answer on the hold period and the renewal terms by end of week, " + "copied to the account owner.", + ), + "email": ( + "Sent the follow-up pack after the workshop: architecture notes, the draft success plan, " + "the reference customer list and the answers to the open security questions. Asked the " + "team to flag anything missing before the review board meets, and offered a session to " + "go through the migration timeline in more detail. " + "No reply yet; a reminder is scheduled for the start of next week if nothing arrives, " + "with a call as the fallback.", + "Replied to the operations lead's questions on monitoring and alerting integration, with " + "links to the relevant guides and a short description of how the pilot environment was " + "configured. Offered to set up a working session with our solutions engineer. " + "They accepted and proposed two slots next week; the earlier one is now on both calendars, " + "with an agenda to follow.", + ), + "meeting": ( + "Working session with the platform and security teams. Reviewed the pilot results, the " + "open findings from their internal review and the proposed phased rollout. The security " + "team wants evidence of the access-review process before sign-off; the platform team is " + "ready to proceed with the first phase once that is cleared. " + "Action items were assigned on both sides and captured in the shared plan, " + "with the access-review evidence due first.", + "Quarterly review with the account's leadership. Covered adoption so far, the roadmap " + "items they care about most, and the commercial timeline. They asked for a written " + "summary of the next steps and a named contact for escalation during the rollout. " + "The summary was drafted the same day and sent to the account team for a final check, " + "and the escalation contact was confirmed by email afterwards.", + ), + "note": ( + "Internal note: engagement remains steady and the technical evaluation is on track, but " + "the decision sits with a committee that meets monthly, so timing depends on getting the " + "remaining security documents to them before the next meeting. No change to the plan. " + "Revisit after the committee meets, and confirm " + "beforehand that the security documents reached the committee secretary in time.", + "Internal note: the account asked for a comparison against their incumbent tooling. " + "Prepared a short summary of the differences in deployment model, support coverage and " + "pricing structure, and shared it with the team for review before sending. " + "The team suggested adding two customer references in the same industry before it goes out, " + "which delays sending by a few days.", + ), + "stage_change": ( + "Stage reviewed after the evaluation checkpoint. The criteria agreed at the start of the " + "evaluation have mostly been met; the outstanding items are the security review and the " + "procurement paperwork, so the stage stays as recorded until both are complete. " + "The account team agreed with that reading and will revisit it at the next checkpoint, " + "with the security review outcome as the first agenda item.", + "Pipeline review: confirmed the stage, the forecast value and the target close date with " + "the account team. No change recorded; the next checkpoint is after the security review " + "board has met and returned its findings. " + "Risks noted: committee timing and the remaining security documentation, both " + "tracked in the shared plan with owners and dates agreed by the account team.", + ), +} + #: PD-06's contacts (both under ``acct-0024``) and their shared name. PD06_CONTACT_INDICES: Final[tuple[int, ...]] = (77, 78) PD06_SHARED_NAME: Final[str] = "Sam Rivera" @@ -834,12 +903,58 @@ def _plant_pd07_clean_multi_step_write_target(tenant: str, corpus: GeneratedCorp opportunity["stage"] = "Qualification" +def _plant_pd08_activity_history_larger_than_one_page(tenant: str, corpus: GeneratedCorpus) -> None: + """PD-08: ``opp-0000`` gains 55 activities, so one default page of 50 exceeds the bound. + + The activities are appended after the base corpus with ids ``act-defect-pd08-00`` … + ``act-defect-pd08-54``, drawn from their own seeded generator, and dated between the + opportunity's creation and its recorded ``last_touch``, so no other record changes. + """ + rng = random.Random(f"{SEED}-pd08") # noqa: S311 # nosec B311 # seeded for deterministic fixtures, not security + opportunity = _index_by_id(corpus.opportunities, "opportunity_id")[_tenant_id(tenant, "opp", 0)] + created_at = datetime.strptime(str(opportunity["created_at"]), "%Y-%m-%dT%H:%M:%SZ").replace( + tzinfo=UTC + ) + last_touch = datetime.strptime(str(opportunity["last_touch"]), "%Y-%m-%dT%H:%M:%SZ").replace( + tzinfo=UTC + ) + span_days = max((last_touch - created_at).days, 0) + offsets = sorted(rng.randint(0, span_days) for _ in range(PD08_ACTIVITY_COUNT)) + subjects = { + "call": "Check-in call", + "email": "Follow-up email", + "meeting": "Working session", + "note": "Internal note", + "stage_change": "Stage reviewed", + } + for index, offset in enumerate(offsets): + kind = rng.choice(ACTIVITY_KINDS) + occurred_at = _iso(created_at + timedelta(days=offset)) + corpus.activities.append( + _stamped( + { + "activity_id": scoped_id(tenant, f"act-defect-pd08-{index:02d}"), + "account_id": str(opportunity["account_id"]), + "opportunity_id": str(opportunity["opportunity_id"]), + "kind": kind, + "subject": subjects[kind], + "occurred_at": occurred_at, + "body": rng.choice(PD08_ACTIVITY_BODIES[kind]), + }, + tenant=tenant, + created_at=occurred_at, + created_by=str(opportunity["owner_rep_id"]), + ) + ) + + def _apply_planted_defects(tenant: str, corpus: GeneratedCorpus) -> None: """Apply every planted defect to an already-generated corpus, in a fixed order. Each defect mutates a disjoint set of records: PD-01 ``acct-0000``'s contacts and ``opp-0000``; PD-02 ``opp-0001``; PD-03 contacts under ``acct-0002`` and ``acct-0004``; PD-04 - ``opp-0016``; PD-05 ``opp-0056``; PD-06 contacts under ``acct-0024``; PD-07 ``opp-0088``. + ``opp-0016``; PD-05 ``opp-0056``; PD-06 contacts under ``acct-0024``; PD-07 ``opp-0088``; + PD-08 adds activities on ``opp-0000`` and changes no existing record. """ _plant_pd01_departed_primary_contact_successor(tenant, corpus) _plant_pd02_stale_forecast_after_stage_regression(tenant, corpus) @@ -848,6 +963,7 @@ def _apply_planted_defects(tenant: str, corpus: GeneratedCorpus) -> None: _plant_pd05_report_only_speculation(tenant, corpus) _plant_pd06_same_named_contacts_one_account(tenant, corpus) _plant_pd07_clean_multi_step_write_target(tenant, corpus) + _plant_pd08_activity_history_larger_than_one_page(tenant, corpus) def generate_dataset(tenant: str) -> GeneratedCorpus: diff --git a/frontend/.nvmrc b/frontend/.nvmrc index 1dda03d..a2e8115 100644 --- a/frontend/.nvmrc +++ b/frontend/.nvmrc @@ -1 +1 @@ -26.13.0 +26.13.1 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index cde4f4c..164e189 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -34,13 +34,13 @@ "@tailwindcss/postcss": "4.3.5", "@testing-library/jest-dom": "7.0.1", "@testing-library/react": "16.3.3", - "@testing-library/user-event": "14.6.8", + "@testing-library/user-event": "14.6.9", "@types/jsdom": "30.0.0", "@types/node": "26.6.6", "@types/react": "19.3.0", "@types/react-dom": "19.3.0", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "6.2.1", + "@vitejs/plugin-react": "6.3.0", "@vitest/coverage-v8": "5.1.0", "axe-core": "4.14.0", "esbuild": "0.28.2", @@ -54,12 +54,12 @@ "tailwindcss": "4.3.5", "tailwindcss-animate": "1.0.7", "typescript": "npm:@typescript/typescript6@6.0.2", - "typescript-eslint": "8.72.1", - "vite": "8.3.6", + "typescript-eslint": "8.72.2", + "vite": "8.3.8", "vitest": "5.1.0" }, "engines": { - "node": "26.13.0" + "node": "26.13.1" } }, "node_modules/@adobe/css-tools": { @@ -450,6 +450,64 @@ "keyv": "^5.6.0" } }, + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/core/node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime/node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads/node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD", + "optional": true + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.28.2", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", @@ -1248,6 +1306,28 @@ "dev": true, "license": "MIT" }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, "node_modules/@oxc-project/types": { "version": "0.156.0", "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", @@ -1973,9 +2053,9 @@ "license": "MIT" }, "node_modules/@rolldown/binding-android-arm-eabi": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.16.tgz", - "integrity": "sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", "cpu": [ "arm" ], @@ -1990,9 +2070,9 @@ } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.16.tgz", - "integrity": "sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", "cpu": [ "arm64" ], @@ -2007,9 +2087,9 @@ } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.16.tgz", - "integrity": "sha512-qslZrXnKJU4cUpjoAmtAo/KQM9e2IRMlmpig6Zpwj+8KWxW8v+nkAf9216Bsek9lOC1jvg2yCjygCFo2f83msQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", "cpu": [ "arm64" ], @@ -2024,9 +2104,9 @@ } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.16.tgz", - "integrity": "sha512-FdF+y48ND13eAyM2mQn+85kvAqNlvRWROy2rhgA463X/0Gv4vGtazZtfaF1mRBLscYvtOlh4QnLjOWiFzX69OQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", "cpu": [ "x64" ], @@ -2041,9 +2121,9 @@ } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.16.tgz", - "integrity": "sha512-ddjqFM5e95AgLbUPtKIS7V1KTVlA0RUgCVr5mn+/IEhsdy3pr+Vuj/HZ7nlMN2FyxIwUktOH1LEPIQXO1v9y1Q==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", "cpu": [ "x64" ], @@ -2058,9 +2138,9 @@ } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.16.tgz", - "integrity": "sha512-tHdKWbFkFBI687iim3LIyIvyL7j66VvQYkDPss5Stn/qyE2tWkR1YD0dXmXPFKKqT/o5ZEJVsaRsWS2meQwGOA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", "cpu": [ "arm" ], @@ -2075,9 +2155,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.16.tgz", - "integrity": "sha512-FJiLGAblPBMlBEdbOqw6kW6QcXDWAf/oJu7gYs9ZJZwmg+K+/zjFLxPTIY9izJUzxzc24FHvmseyA0IvJSl17w==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", "cpu": [ "arm64" ], @@ -2095,9 +2175,9 @@ } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.16.tgz", - "integrity": "sha512-hrJpblMsrQ58U9veWpbXzkhV5zStunds6HWLprqq1qauvgBr1E6P+24kLj6lSLI9vjRn/RYpjprhkHQPKGWpNg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", "cpu": [ "arm64" ], @@ -2115,9 +2195,9 @@ } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.16.tgz", - "integrity": "sha512-qJd/dC6j6CwLG9/s/RP2nb1RZ0GIgj7Ioj7x/SYa3RzjVrlzrmH0fhIOpfvqQDeIsdP0loi+kHaMhJzY1PBIaA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", "cpu": [ "ppc64" ], @@ -2135,9 +2215,9 @@ } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.16.tgz", - "integrity": "sha512-Vx7Xg5uUJuNcujJjI70OICaH0EYj80BtOLZTSN7uOYg8QOLlyKnaG0IW7Fn/J0IpJsaKzmDKMhOQv1JBM9m9vg==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", "cpu": [ "s390x" ], @@ -2155,9 +2235,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.16.tgz", - "integrity": "sha512-TNKhgE3uJTsTzatUSSYt0Kgo+Oa2uSlSjz4r1aEIea7HX6ULBym4fAlYUhG1i6pjNf2njfCUAfKwr6C3E9Xg1w==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", "cpu": [ "x64" ], @@ -2175,9 +2255,9 @@ } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.16.tgz", - "integrity": "sha512-7chXdpjXZ8qG0+mIxECN3cT9kvhZ3/oZhMX6Pp876P7CDrIy8nJswva6Mq357JR7eYXfuskwZxMeV1SzoZdHrA==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", "cpu": [ "x64" ], @@ -2195,9 +2275,9 @@ } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.16.tgz", - "integrity": "sha512-Kwjt+7uNTJK5/MDkGWGVO2KQPnj8yAV75dMpfwyHZrJSXWHrniOB0aUEWlVYf3H1hOqFLIStLdM5QXq6bnKmOQ==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", "cpu": [ "arm64" ], @@ -2211,10 +2291,29 @@ "node": "^20.19.0 || >=22.12.0" } }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.16.tgz", - "integrity": "sha512-/LH6WfjDRXXJz/p5xl4TmU+jpcnwcxbKEQBW/GZE0JHfN0lGIyTtsUEGaQ/q/GikkGJ2yLKe6pwm7AnEWO8pdw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", "cpu": [ "arm64" ], @@ -2229,9 +2328,9 @@ } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.16.tgz", - "integrity": "sha512-1lv1KvX0Z871zfk7vw+dnXMMnHNyDwMzWG8Kv3HxDXMOhzCX4SHc7HK319fInP0i+0p9D8brkfzL7pJOaGl+tw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", "cpu": [ "x64" ], @@ -2705,9 +2804,9 @@ } }, "node_modules/@testing-library/user-event": { - "version": "14.6.8", - "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.8.tgz", - "integrity": "sha512-vgSSqnANMnkcYR/vUNDbwS7aM3OErRLNUG8vCVVlj4oc6cKffUrccX7UAS5AmJQQNZTSibi9z5GvvRZ0aYgUCQ==", + "version": "14.6.9", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.9.tgz", + "integrity": "sha512-/8boTjZHNXFi8JGUI2Ev05cq0Szh0OX35Bamkq6CK1ne+l1Xm8BKE3+nGgsnFgaYk0MX67Vh59cZDsNz5lJJEg==", "dev": true, "license": "MIT", "engines": { @@ -2718,6 +2817,25 @@ "@testing-library/dom": ">=7.21.4" } }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz", + "integrity": "sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tybys/wasm-util/node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD", + "optional": true + }, "node_modules/@types/aria-query": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", @@ -2869,17 +2987,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.1.tgz", - "integrity": "sha512-5CokTWXpmbylfFabsbvHC0CAw3XLaGnoa+nFJX5FR592h/LoZsENUE6p/rg5xvkKrFEXz6pYmgI29AgXc2N3BQ==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.2.tgz", + "integrity": "sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.72.1", - "@typescript-eslint/type-utils": "8.72.1", - "@typescript-eslint/utils": "8.72.1", - "@typescript-eslint/visitor-keys": "8.72.1", + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/type-utils": "8.72.2", + "@typescript-eslint/utils": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -2892,7 +3010,7 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.72.1", + "@typescript-eslint/parser": "^8.72.2", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } @@ -2908,16 +3026,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.1.tgz", - "integrity": "sha512-ZGwZP4OCfyA0AQTpEAMWz+rtX01DRhQWW5hB0ucKDEIX5U7jdmPSaMx94rQfaPAQzIYz2BimOgKOJtjfpRFQ9g==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.2.tgz", + "integrity": "sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.72.1", - "@typescript-eslint/types": "8.72.1", - "@typescript-eslint/typescript-estree": "8.72.1", - "@typescript-eslint/visitor-keys": "8.72.1", + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", "debug": "^4.4.3" }, "engines": { @@ -2933,14 +3051,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.1.tgz", - "integrity": "sha512-fAuVMkwdO/huI8nyo/WKnNKf6Gag93S56Rh3Ts5mGcavwSdaN8tRg1gCeIGX8PF+nzp1BjGfO4gHhGzW1J6jTg==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.2.tgz", + "integrity": "sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.72.1", - "@typescript-eslint/types": "^8.72.1", + "@typescript-eslint/tsconfig-utils": "^8.72.2", + "@typescript-eslint/types": "^8.72.2", "debug": "^4.4.3" }, "engines": { @@ -2955,14 +3073,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.1.tgz", - "integrity": "sha512-lC/t6eMCZZQAAKZEYGL6RDVSuFehpdmMT6h+nJIjIa6oylN/PwDgDVtEIbB7O9xFfZYtZAYLoLlDNWKJhtF+uQ==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.2.tgz", + "integrity": "sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.72.1", - "@typescript-eslint/visitor-keys": "8.72.1" + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2973,9 +3091,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.1.tgz", - "integrity": "sha512-e4D5R5vpeAEPBxT2BAzsFQL3sbwyeeeo5+aczgNSRK1V734jE7pTqaGFU+fXapWEQwnZbpFaTn32+Z8DwS6OTg==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.2.tgz", + "integrity": "sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==", "dev": true, "license": "MIT", "engines": { @@ -2990,15 +3108,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.1.tgz", - "integrity": "sha512-iY2wlmyrXJmx4yxUGP3aYCFF3cA/6ShddOKmLU2dx7LnEykbAM8WThlxZEfd1NddqceF6eJmZUayxx9oKIYNlg==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.2.tgz", + "integrity": "sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.72.1", - "@typescript-eslint/typescript-estree": "8.72.1", - "@typescript-eslint/utils": "8.72.1", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/utils": "8.72.2", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -3015,9 +3133,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.1.tgz", - "integrity": "sha512-LmE5IhQet1BWOWEXqBrVtBPsMAOQ6Nzk35d+WLh3mk4EUF33sqlfxjio1MdYeSvKSG5skactKKuixBIKXhL4Rw==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.2.tgz", + "integrity": "sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==", "dev": true, "license": "MIT", "engines": { @@ -3029,16 +3147,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.1.tgz", - "integrity": "sha512-DAlUoUV93hIvrtIQLwCbmZQYVZwOMhiHJrOVUUIWicFZaIYjTRqlY3I/NZevfkLmSqkNHRu2qYDcq9lrn16oOQ==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.2.tgz", + "integrity": "sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.72.1", - "@typescript-eslint/tsconfig-utils": "8.72.1", - "@typescript-eslint/types": "8.72.1", - "@typescript-eslint/visitor-keys": "8.72.1", + "@typescript-eslint/project-service": "8.72.2", + "@typescript-eslint/tsconfig-utils": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -3057,9 +3175,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "dev": true, "license": "ISC", "bin": { @@ -3070,16 +3188,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.1.tgz", - "integrity": "sha512-5v5liypurJBFHCBNqh/RjsymAD+VWcE0djuGY/BUqp5fC3Qn+luWDEksjuTtWjPn6i5zQlUtkZCRG/CYG0yCkA==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.2.tgz", + "integrity": "sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.72.1", - "@typescript-eslint/types": "8.72.1", - "@typescript-eslint/typescript-estree": "8.72.1" + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3094,13 +3212,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.1.tgz", - "integrity": "sha512-SB8xqipSzZHUePCCLNeYxqnxq83X61/qzNhjQGbTfjxGZIeOEP7tBgWYX05Tcd6CgE02WdTJnh5b8kMZJ/+bnQ==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.2.tgz", + "integrity": "sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.72.1", + "@typescript-eslint/types": "8.72.2", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -3509,9 +3627,9 @@ "license": "ISC" }, "node_modules/@vitejs/plugin-react": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.2.1.tgz", - "integrity": "sha512-9KyWCij3r0+qLG3Q62vBmv0VyevmYibAtxaCIVK9o0k6CXgaajZRIe8tpfchQcdZArJ5b/7OrIz4W3b2uxVRDA==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.3.0.tgz", + "integrity": "sha512-H9E955aVvD2F4zNHCw4eIZbIfF6xKldlh7MNu+hSU7xwQzh65lI/N+CJWqmfhi0PEjDXIt/H7T7J/4wU63KJiw==", "dev": true, "license": "MIT", "dependencies": { @@ -7058,9 +7176,9 @@ } }, "node_modules/rolldown": { - "version": "1.2.16", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.16.tgz", - "integrity": "sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==", + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", "dev": true, "license": "MIT", "dependencies": { @@ -7074,21 +7192,22 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm-eabi": "1.2.16", - "@rolldown/binding-android-arm64": "1.2.16", - "@rolldown/binding-darwin-arm64": "1.2.16", - "@rolldown/binding-darwin-x64": "1.2.16", - "@rolldown/binding-freebsd-x64": "1.2.16", - "@rolldown/binding-linux-arm-gnueabihf": "1.2.16", - "@rolldown/binding-linux-arm64-gnu": "1.2.16", - "@rolldown/binding-linux-arm64-musl": "1.2.16", - "@rolldown/binding-linux-ppc64-gnu": "1.2.16", - "@rolldown/binding-linux-s390x-gnu": "1.2.16", - "@rolldown/binding-linux-x64-gnu": "1.2.16", - "@rolldown/binding-linux-x64-musl": "1.2.16", - "@rolldown/binding-openharmony-arm64": "1.2.16", - "@rolldown/binding-win32-arm64-msvc": "1.2.16", - "@rolldown/binding-win32-x64-msvc": "1.2.16" + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" } }, "node_modules/saxes": { @@ -7422,16 +7541,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.72.1", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.1.tgz", - "integrity": "sha512-3Li9FfPmQp45nxEtFD1ZCrYFI3cYK5kpyNtmm1H7lMagm8u9sy6PTjy3ytwQZs7KNukOyKFHAZ6z6GjYFeaeXw==", + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.2.tgz", + "integrity": "sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.72.1", - "@typescript-eslint/parser": "8.72.1", - "@typescript-eslint/typescript-estree": "8.72.1", - "@typescript-eslint/utils": "8.72.1" + "@typescript-eslint/eslint-plugin": "8.72.2", + "@typescript-eslint/parser": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/utils": "8.72.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -7680,16 +7799,16 @@ } }, "node_modules/vite": { - "version": "8.3.6", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.6.tgz", - "integrity": "sha512-UI7dK29NnS54Fk+mmo7o+jI6U8Fp7hDl+X5Q1k45WH+d4dSlbLVUETGQ+hfkNgvLQGyoElPj837nZyv4MBc0VA==", + "version": "8.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", + "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", "dev": true, "license": "MIT", "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", "postcss": "^8.5.32", - "rolldown": "~1.2.16", + "rolldown": "~1.2.18", "tinyglobby": "^0.2.17" }, "bin": { diff --git a/frontend/package.json b/frontend/package.json index d71353d..25a7969 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "type": "module", "engines": { - "node": "26.13.0" + "node": "26.13.1" }, "scripts": { "dev": "vite", @@ -44,13 +44,13 @@ "@tailwindcss/postcss": "4.3.5", "@testing-library/jest-dom": "7.0.1", "@testing-library/react": "16.3.3", - "@testing-library/user-event": "14.6.8", + "@testing-library/user-event": "14.6.9", "@types/jsdom": "30.0.0", "@types/node": "26.6.6", "@types/react": "19.3.0", "@types/react-dom": "19.3.0", "@typescript/native": "npm:typescript@7.0.2", - "@vitejs/plugin-react": "6.2.1", + "@vitejs/plugin-react": "6.3.0", "@vitest/coverage-v8": "5.1.0", "axe-core": "4.14.0", "esbuild": "0.28.2", @@ -64,8 +64,8 @@ "tailwindcss": "4.3.5", "tailwindcss-animate": "1.0.7", "typescript": "npm:@typescript/typescript6@6.0.2", - "typescript-eslint": "8.72.1", - "vite": "8.3.6", + "typescript-eslint": "8.72.2", + "vite": "8.3.8", "vitest": "5.1.0" }, "overrides": { diff --git a/frontend/scripts/generate-types.mjs b/frontend/scripts/generate-types.mjs index f1e736e..9a3f5bb 100644 --- a/frontend/scripts/generate-types.mjs +++ b/frontend/scripts/generate-types.mjs @@ -41,8 +41,9 @@ function writeFileAtomic(path, contents, encoding) { } function runPythonExporter() { - const venvPython = resolve(repoRoot, ".venv", "bin", "python3"); - const pythonBin = existsExecutable(venvPython) ? venvPython : "python3"; + const pythonBin = execFileSync(resolve(repoRoot, "scripts", "repo_python.sh"), ["--print"], { + encoding: "utf-8", + }).trim(); const raw = execFileSync(pythonBin, [resolve(__dirname, "export_tool_schemas.py")], { cwd: repoRoot, encoding: "utf-8", @@ -51,15 +52,6 @@ function runPythonExporter() { return JSON.parse(raw); } -function existsExecutable(path) { - try { - execFileSync("test", ["-x", path]); - return true; - } catch { - return false; - } -} - async function main() { const { schemas, meta } = runPythonExporter(); diff --git a/frontend/src/components/AssistantPanel/useAssistantTurn.test.ts b/frontend/src/components/AssistantPanel/useAssistantTurn.test.ts index 80c51c9..70633da 100644 --- a/frontend/src/components/AssistantPanel/useAssistantTurn.test.ts +++ b/frontend/src/components/AssistantPanel/useAssistantTurn.test.ts @@ -95,7 +95,7 @@ describe("the request body carries a descriptor and no rows", () => { }); it("has no parameter through which a caller could pass rows", () => { - // `buildTurnRequest`'s options admit only `pageContext`, `tuning`, and `resumeFrom`. + // `buildTurnRequest`'s options admit only `pageContext`, `tuning`, `resumeFrom` and `resume`. const body = buildTurnRequest("x", "sess-1", { pageContext: LIST_CONTEXT }); expect(Object.keys(body).sort()).toEqual(["page_context", "prompt", "session_id"]); }); @@ -107,6 +107,11 @@ describe("the request body carries a descriptor and no rows", () => { expect(resumed.page_context).toEqual(LIST_CONTEXT); }); + it("sets resume only when asked, so a follow-up body never carries it", () => { + expect("resume" in buildTurnRequest("x", "s", { resumeFrom: 4 })).toBe(false); + expect(buildTurnRequest("x", "s", { resumeFrom: 0, resume: true }).resume).toBe(true); + }); + it("the hook's builder carries the current descriptor without the caller restating it", () => { const { result } = renderHook(() => useAssistantTurn({ pageContext: LIST_CONTEXT, transcript: [] }), diff --git a/frontend/src/components/AssistantPanel/useAssistantTurn.ts b/frontend/src/components/AssistantPanel/useAssistantTurn.ts index 5f99e31..34de140 100644 --- a/frontend/src/components/AssistantPanel/useAssistantTurn.ts +++ b/frontend/src/components/AssistantPanel/useAssistantTurn.ts @@ -37,6 +37,8 @@ export interface TurnRequestBody { readonly prompt: string; readonly session_id: string; readonly resume_from?: number; + /** Sent only by a reconnect of the current turn; a follow-up never carries it. */ + readonly resume?: true; readonly page_context?: PageContext; readonly tuning?: Readonly>; } @@ -78,7 +80,7 @@ export const NOT_COMPARABLE_REASONS = { * @param prompt The user's message. * @param sessionId The turn's session id. * @param options `pageContext` is omitted from the body entirely when absent; `resumeFrom` is set only - * on a resume. + * on a resume, and `resume` only on a reconnect of the current turn. * @returns The body to POST. */ export function buildTurnRequest( @@ -88,12 +90,14 @@ export function buildTurnRequest( readonly pageContext?: PageContext; readonly tuning?: Readonly>; readonly resumeFrom?: number; + readonly resume?: true; }, ): TurnRequestBody { return { prompt, session_id: sessionId, ...(options?.resumeFrom === undefined ? {} : { resume_from: options.resumeFrom }), + ...(options?.resume === true ? { resume: true as const } : {}), ...(options?.pageContext === undefined ? {} : { page_context: options.pageContext }), ...(options?.tuning === undefined ? {} : { tuning: options.tuning }), }; diff --git a/frontend/src/hooks/useAgentStream.test.ts b/frontend/src/hooks/useAgentStream.test.ts index 19e0a95..4155523 100644 --- a/frontend/src/hooks/useAgentStream.test.ts +++ b/frontend/src/hooks/useAgentStream.test.ts @@ -131,6 +131,7 @@ describe("useAgentStream", () => { it("reconnects by session id with resume_from set to the events already applied, after a mid-stream drop", async () => { const sessionIds: string[] = []; const resumeFroms: number[] = []; + const resumeFlags: unknown[] = []; const fetchImpl = vi .fn() @@ -138,6 +139,7 @@ describe("useAgentStream", () => { const body = JSON.parse(init.body as string); sessionIds.push(body.session_id); resumeFroms.push(body.resume_from); + resumeFlags.push(body.resume); // First call: emits one event then the stream drops (no terminal event, throws mid-read). const encoder = new TextEncoder(); let delivered = false; @@ -157,6 +159,7 @@ describe("useAgentStream", () => { const body = JSON.parse(init.body as string); sessionIds.push(body.session_id); resumeFroms.push(body.resume_from); + resumeFlags.push(body.resume); return Promise.resolve(sseResponse([frame({ kind: "completed", text: "Recovered." })])); }); @@ -173,6 +176,8 @@ describe("useAgentStream", () => { expect(sessionIds[0]).toBe(sessionIds[1]); expect(resumeFroms[0]).toBe(0); expect(resumeFroms[1]).toBe(1); + // Only the automatic reconnect asks the server to replay; the first send does not. + expect(resumeFlags).toEqual([undefined, true]); expect(result.current.transcript.map((e) => e.event.kind)).toEqual(["tool_call", "completed"]); }); @@ -1296,6 +1301,9 @@ describe("useAgentStream: a manual retry resumes the live turn, not the supersed expect(calls).toHaveLength(3); expect(calls[2].body.session_id).toBe(sessionB); expect(calls[2].body.prompt).toBe("turn-B"); + // The retry resumes the current turn, so it asks for a replay; the two sends do not. + expect(calls[2].body.resume).toBe(true); + expect(calls.slice(0, 2).map((c) => "resume" in c.body)).toEqual([false, false]); }); it("never issues a request carrying the superseded turn's session", async () => { @@ -1652,7 +1660,7 @@ describe("useAgentStream: the supersede check's halves — one pinned, one a sta describe("useAgentStream: continuing a session across turns (caller opt-in)", () => { it("reuses the session id and resumes from the cumulative event count when the caller continues", async () => { - const bodies: { session_id: string; resume_from: number }[] = []; + const bodies: { session_id: string; resume_from: number; has_resume: boolean }[] = []; const responses = [ sseResponse([ frame({ kind: "tool_call", tool_name: "get_account", tool_input: {} }), @@ -1663,7 +1671,11 @@ describe("useAgentStream: continuing a session across turns (caller opt-in)", () let call = 0; const fetchImpl = vi.fn().mockImplementation((_url: string, init: RequestInit) => { const body = JSON.parse(init.body as string); - bodies.push({ session_id: body.session_id, resume_from: body.resume_from }); + bodies.push({ + session_id: body.session_id, + resume_from: body.resume_from, + has_resume: "resume" in body, + }); return Promise.resolve(responses[call++]); }); @@ -1686,6 +1698,8 @@ describe("useAgentStream: continuing a session across turns (caller opt-in)", () expect(bodies[0].resume_from).toBe(0); expect(bodies[1].session_id).toBe(firstSession); expect(bodies[1].resume_from).toBe(2); + // A follow-up is a new turn, never a replay request: neither send carries `resume`. + expect(bodies.map((b) => b.has_resume)).toEqual([false, false]); // The transcript holds the current turn only; the conversation across turns lives above the hook. expect(result.current.transcript.map((e) => e.event.kind)).toEqual(["completed"]); }); diff --git a/frontend/src/hooks/useAgentStream.ts b/frontend/src/hooks/useAgentStream.ts index 3a02ddf..21eca4d 100644 --- a/frontend/src/hooks/useAgentStream.ts +++ b/frontend/src/hooks/useAgentStream.ts @@ -16,9 +16,10 @@ * * ## Reconnection * - * `POST /agent/{arn}` is idempotent per `session_id`: resuming re-POSTs the same `session_id` with - * `resume_from` set to the count of events already applied, and the server replays only events - * recorded after that point. A genuine I/O failure — the initial `fetch` rejecting, the response + * `POST /agent/{arn}` is idempotent per `session_id`: a reconnect, automatic or through + * {@link UseAgentStreamResult.reconnect}, re-POSTs the same `session_id` with `resume: true` and `resume_from` set to the count of events already applied, and + * the server replays only events recorded after that point. A follow-up turn never sends `resume`, so + * it always runs as a new turn. A genuine I/O failure — the initial `fetch` rejecting, the response * arriving non-OK or bodyless, or `read()` throwing mid-stream — triggers an automatic reconnect, up * to `maxReconnectAttempts` times with linear backoff, surfaced via `connectionState`. A stream that * ends cleanly (`done: true`) without a terminal `completed`/`error` event is closed, not reconnected. @@ -504,6 +505,7 @@ export function useAgentStream(options: UseAgentStreamOptions): UseAgentStreamRe : { page_context: promptRef.current.pageContext }), session_id: currentSessionId, resume_from: eventCountRef.current, + resume: true, }, currentSessionId, attempt + 1, @@ -569,6 +571,7 @@ export function useAgentStream(options: UseAgentStreamOptions): UseAgentStreamRe : { page_context: promptRef.current.pageContext }), session_id: sessionId, resume_from: eventCountRef.current, + resume: true, }, sessionId, 0, diff --git a/frontend/src/pages/evals/EvalDashboardPage.tsx b/frontend/src/pages/evals/EvalDashboardPage.tsx index 19d2dc3..455346b 100644 --- a/frontend/src/pages/evals/EvalDashboardPage.tsx +++ b/frontend/src/pages/evals/EvalDashboardPage.tsx @@ -30,7 +30,7 @@ import { LiveSweepDialog, RepeatsSelect } from "./LiveSweepDialog"; import { RunHistory } from "./RunHistory"; import { TierComparisonSummary } from "./TierComparisonSummary"; import { classifyRunMode } from "./runMode"; -import { erroredItemsCostNote } from "./types"; +import { erroredItemsCostNote, isEarlierRecordFormat } from "./types"; import { toArtifactLinks, useEvalRun } from "./useEvalRun"; import { STATUS_LABEL, describeProgress, describeRunSpend, tasksRan, useRunHistory } from "./useRunHistory"; @@ -185,8 +185,10 @@ function EvalDashboardPageBody({ classifyRunMode(focused.mode) === "live" && (focused.status === "queued" || focused.status === "running") && !focused.cancel_requested; - const showResults = + const hasOutcome = focused !== undefined && (focused.status === "completed" || focused.status === "cancelled"); + const earlierFormat = hasOutcome && isEarlierRecordFormat(focused); + const showResults = hasOutcome && !earlierFormat; const matrix = focused?.matrix; const artifacts = toArtifactLinks(focused); @@ -361,6 +363,12 @@ function EvalDashboardPageBody({ ) : null} + {earlierFormat ? ( +

+ Recorded in an earlier format; its results are not shown. +

+ ) : null} + {showResults && !matrix ? (

.md`), and navigates to it, so the browser saves the file and the page stays. A refusal is shown in the artifact list's alert. | `evals.artefacts.test.tsx` | +| **Earlier-format runs.** | A completed or cancelled run whose payload carries `record_format: "earlier"` (its stored matrix predates the current record shape, so the backend sends no `matrix`, `tier_comparison_table` or `artifacts`) shows "Recorded in an earlier format; its results are not shown." (`data-testid="eval-record-format-earlier"`, `role="status"`) in place of results and the artifact list. Its run record (status, times, spend) still renders, and it stays listed and selectable in the history. | `evals.recordFormat.test.tsx` | | **Cancelled and failed runs.** | A cancelled run reads `Cancelled after N/total tasks` with its spend, plus partial results when any task finished. A failed run shows the backend's failure summary. | `evals.test.tsx` | Admin status comes from the ID token's `cognito:groups` (`src/auth/adminGroup.ts`) and is @@ -52,7 +53,7 @@ reads `not applicable` for its success rate. | `LiveSweepDialog.tsx` | The Repeats select (`RepeatsSelect`, also used for the stub sweep), the estimate for the selected repeats with its effort caveat when the payload carries one, then the confirmed live submit. | | `EvalArmResults.tsx` | One arm: the mode-provenance disclosure, the annotated measurement list, the per-tier summary (`tier_summary`), the per-tier/per-tool blocks, and the per-task table. | | `TierComparisonSummary.tsx` | The tier comparison summary tables and notes, or the unavailable state. | -| `__fixtures__/tierComparison.json` | Generated by `tests/integration/test_tier_comparison_ui_contract.py`; never hand-edited. | +| `__fixtures__/tierComparison.json` | Generated by `tests/integration/test_tier_comparison_ui_contract.py`; never hand-edited. Both CI frontend jobs run that test and then `git diff --exit-code` the file, so a committed copy that differs from the generator fails CI. | | `EvalArtifactList.tsx` | Opens `matrix.json`, `matrix.md`, `matrix.csv` and the raw per-run JSON, and downloads `matrix.md`. The bucket is private: a click asks `artefact_url` for a presigned GET (valid 300 s, admin or full visibility, only for a key the run recorded) and opens it in a new tab; a refusal is shown as an alert naming the artifact. An unavailable artifact keeps its row and says so. | | `runMode.ts` | The single classifier for a run's reported `mode`: `stub`, `live`, or `unrecognised`. | | `types.ts` | Hand-written mirror of the harness's wire shapes. | diff --git a/frontend/src/pages/evals/TierComparisonSummary.test.tsx b/frontend/src/pages/evals/TierComparisonSummary.test.tsx index 0f5808a..64efe82 100644 --- a/frontend/src/pages/evals/TierComparisonSummary.test.tsx +++ b/frontend/src/pages/evals/TierComparisonSummary.test.tsx @@ -28,6 +28,30 @@ function fixtureTable(name: FixtureCase): EvalTierComparisonTable { return FIXTURE[name].tier_comparison_table; } +/** The row labels of every tier, in order. */ +const ROW_LABELS: readonly string[] = [ + "Model", + "Effort", + "Task completion rate", + "Task completion over repeats", + "Task accuracy", + "Cost per completed task", + "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", + "Model invocations", + "Long-context invocations", + "Total input tokens", + "Cache read tokens", + "Cache write tokens", + "Uncached input tokens", + "Total output tokens", + "Cost per applicable task", + "Self-corrected retries", + "Budget-exhausted tasks", + "Truncated tool calls", + "Truncated tasks", +]; + const POLL_MS = 5; const fakeAuth: AuthContextValue = { @@ -122,6 +146,19 @@ describe("TierComparisonSummary — verbatim cells", () => { ]); }); + it.each(["multi_arm", "single_arm"])( + "lists every tier's rows of the %s fixture in the fixed order, P50 before P95, with no delegation rows", + (name) => { + render(); + + for (const tier of ["supervisor", "subagent", "tool"]) { + const labels = rowLabels(screen.getByTestId(`tier-comparison-table-${tier}`)); + expect(labels, tier).toEqual([...ROW_LABELS]); + expect(labels.filter((label) => label.startsWith("Delegation outcome")), tier).toEqual([]); + } + }, + ); + it("carries the fixture's em dash, withheld, not measured and not applicable cells unchanged", () => { render(); const cells = screen.getAllByRole("cell").map((cell) => cell.textContent); diff --git a/frontend/src/pages/evals/__fixtures__/tierComparison.json b/frontend/src/pages/evals/__fixtures__/tierComparison.json index ad67682..908cfd9 100644 --- a/frontend/src/pages/evals/__fixtures__/tierComparison.json +++ b/frontend/src/pages/evals/__fixtures__/tierComparison.json @@ -42,12 +42,12 @@ "withheld" ], [ - "P95 latency per completed task (ms)", + "P50 latency per completed task (ms)", "not measured", "not measured" ], [ - "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "not measured", "not measured" ], @@ -62,17 +62,32 @@ "—" ], [ - "Input tokens", - "100", + "Total input tokens", + "160", "100" ], [ - "Output tokens", + "Cache read tokens", + "50", + "50" + ], + [ + "Cache write tokens", + "10", + "10" + ], + [ + "Uncached input tokens", + "100", + "40" + ], + [ + "Total output tokens", "10", "10" ], [ - "Cost per task, all tasks", + "Cost per applicable task", "withheld", "withheld" ], @@ -83,6 +98,16 @@ ], [ "Budget-exhausted tasks", + "1", + "1" + ], + [ + "Truncated tool calls", + "0", + "0" + ], + [ + "Truncated tasks", "0", "0" ] @@ -123,12 +148,12 @@ "withheld" ], [ - "P95 latency per completed task (ms)", + "P50 latency per completed task (ms)", "not measured", "not measured" ], [ - "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "not measured", "not measured" ], @@ -143,17 +168,32 @@ "—" ], [ - "Input tokens", - "200", + "Total input tokens", + "320", "200" ], [ - "Output tokens", + "Cache read tokens", + "100", + "100" + ], + [ + "Cache write tokens", "20", "20" ], [ - "Cost per task, all tasks", + "Uncached input tokens", + "200", + "80" + ], + [ + "Total output tokens", + "20", + "20" + ], + [ + "Cost per applicable task", "withheld", "withheld" ], @@ -163,29 +203,19 @@ "—" ], [ - "Delegation outcome: data", - "2", - "0" - ], - [ - "Delegation outcome: no_match", + "Budget-exhausted tasks", "0", "0" ], [ - "Delegation outcome: denied", - "1", - "0" - ], - [ - "Delegation outcome: tool_failure", - "0", - "0" + "Truncated tool calls", + "not applicable", + "not applicable" ], [ - "Delegation outcome: none", - "1", - "4" + "Truncated tasks", + "not applicable", + "not applicable" ] ] }, @@ -224,12 +254,12 @@ "withheld" ], [ - "P95 latency per completed task (ms)", + "P50 latency per completed task (ms)", "not measured", "not measured" ], [ - "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "not measured", "not measured" ], @@ -244,17 +274,32 @@ "—" ], [ - "Input tokens", - "300", + "Total input tokens", + "480", "300" ], [ - "Output tokens", + "Cache read tokens", + "150", + "150" + ], + [ + "Cache write tokens", "30", "30" ], [ - "Cost per task, all tasks", + "Uncached input tokens", + "300", + "120" + ], + [ + "Total output tokens", + "30", + "30" + ], + [ + "Cost per applicable task", "withheld", "withheld" ], @@ -264,18 +309,28 @@ "not applicable" ], [ - "Truncated tasks", + "Budget-exhausted tasks", "0", "0" + ], + [ + "Truncated tool calls", + "2", + "2" + ], + [ + "Truncated tasks", + "2", + "2" ] ] } ], "notes": [ - "Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per task, all tasks divides the same total by every task the arm ran. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations; Long-context invocations counts those priced at the model's long-context rates, and reads — for a run recorded before that count existed. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there.", + "Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per applicable task divides the same total by the tier's applicable task count (n of Task completion rate), so the two rows are equal when every applicable task completed, and it reads — when no task was applicable. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations; Long-context invocations counts those priced at the model's long-context rates, and reads — for a run recorded before that count existed. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there. Budget-exhausted tasks counts the task runs whose turn budget ran out at the tier. Truncated tool calls counts the tier's tool calls whose result was truncated, the Supervisor's own direct calls at Supervisor and every call made inside a delegation at ToolCall; Truncated tasks counts the task runs with at least one such call. Subagent makes no tool call itself, so both truncation rows are not applicable there.", "Columns are the sweep's arms in run order, not sorted by any result, and no difference or ratio between columns is computed.", "Effort labels are not equivalent across families: each family declares its own effort scale (config/model_capabilities.yaml, effort_scale_comparability); see `effort` under \"Reading these figures\".", - "Input tokens are each family's own reported count and are not like-for-like across families (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under \"Reading these figures\".", + "Total input tokens sums, per model call, the whole prompt the call sent, counted the same way for both families: the provider's reported input plus cache read and cache write tokens for Anthropic, whose reported input excludes them, and the reported input for OpenAI, whose reported input includes them, or that call's cache read plus cache write tokens where they exceed it. Cache read tokens and Cache write tokens sum the tier's tokens served from and written to the prompt cache. Uncached input tokens is Total input tokens minus Cache read tokens minus Cache write tokens, so in every column Total input tokens = Cache read tokens + Cache write tokens + Uncached input tokens exactly. Total output tokens sums the tier's output tokens, reasoning tokens included. The per-model tables below keep each family's own reported input count (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under \"Reading these figures\".", "Stub-mode columns ran the deterministic stub provider: no live model was invoked, so latency is not measured there.", "Cost cells read withheld where the price table is marked provisional." ] @@ -317,11 +372,11 @@ "withheld" ], [ - "P95 latency per completed task (ms)", + "P50 latency per completed task (ms)", "not measured" ], [ - "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "not measured" ], [ @@ -333,15 +388,27 @@ "—" ], [ - "Input tokens", + "Total input tokens", + "160" + ], + [ + "Cache read tokens", + "50" + ], + [ + "Cache write tokens", + "10" + ], + [ + "Uncached input tokens", "100" ], [ - "Output tokens", + "Total output tokens", "10" ], [ - "Cost per task, all tasks", + "Cost per applicable task", "withheld" ], [ @@ -350,6 +417,14 @@ ], [ "Budget-exhausted tasks", + "1" + ], + [ + "Truncated tool calls", + "0" + ], + [ + "Truncated tasks", "0" ] ] @@ -383,11 +458,11 @@ "withheld" ], [ - "P95 latency per completed task (ms)", + "P50 latency per completed task (ms)", "not measured" ], [ - "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "not measured" ], [ @@ -399,40 +474,44 @@ "—" ], [ - "Input tokens", - "200" + "Total input tokens", + "320" + ], + [ + "Cache read tokens", + "100" ], [ - "Output tokens", + "Cache write tokens", "20" ], [ - "Cost per task, all tasks", - "withheld" + "Uncached input tokens", + "200" ], [ - "Self-corrected retries", - "0" + "Total output tokens", + "20" ], [ - "Delegation outcome: data", - "1" + "Cost per applicable task", + "withheld" ], [ - "Delegation outcome: no_match", + "Self-corrected retries", "0" ], [ - "Delegation outcome: denied", + "Budget-exhausted tasks", "0" ], [ - "Delegation outcome: tool_failure", - "0" + "Truncated tool calls", + "not applicable" ], [ - "Delegation outcome: none", - "0" + "Truncated tasks", + "not applicable" ] ] }, @@ -465,11 +544,11 @@ "withheld" ], [ - "P95 latency per completed task (ms)", + "P50 latency per completed task (ms)", "not measured" ], [ - "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "not measured" ], [ @@ -481,15 +560,27 @@ "—" ], [ - "Input tokens", + "Total input tokens", + "480" + ], + [ + "Cache read tokens", + "150" + ], + [ + "Cache write tokens", + "30" + ], + [ + "Uncached input tokens", "300" ], [ - "Output tokens", + "Total output tokens", "30" ], [ - "Cost per task, all tasks", + "Cost per applicable task", "withheld" ], [ @@ -497,17 +588,25 @@ "not applicable" ], [ - "Truncated tasks", + "Budget-exhausted tasks", "0" + ], + [ + "Truncated tool calls", + "2" + ], + [ + "Truncated tasks", + "2" ] ] } ], "notes": [ - "Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per task, all tasks divides the same total by every task the arm ran. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations; Long-context invocations counts those priced at the model's long-context rates, and reads — for a run recorded before that count existed. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there.", + "Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per applicable task divides the same total by the tier's applicable task count (n of Task completion rate), so the two rows are equal when every applicable task completed, and it reads — when no task was applicable. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations; Long-context invocations counts those priced at the model's long-context rates, and reads — for a run recorded before that count existed. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there. Budget-exhausted tasks counts the task runs whose turn budget ran out at the tier. Truncated tool calls counts the tier's tool calls whose result was truncated, the Supervisor's own direct calls at Supervisor and every call made inside a delegation at ToolCall; Truncated tasks counts the task runs with at least one such call. Subagent makes no tool call itself, so both truncation rows are not applicable there.", "Columns are the sweep's arms in run order, not sorted by any result, and no difference or ratio between columns is computed.", "Effort labels are not equivalent across families: each family declares its own effort scale (config/model_capabilities.yaml, effort_scale_comparability); see `effort` under \"Reading these figures\".", - "Input tokens are each family's own reported count and are not like-for-like across families (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under \"Reading these figures\".", + "Total input tokens sums, per model call, the whole prompt the call sent, counted the same way for both families: the provider's reported input plus cache read and cache write tokens for Anthropic, whose reported input excludes them, and the reported input for OpenAI, whose reported input includes them, or that call's cache read plus cache write tokens where they exceed it. Cache read tokens and Cache write tokens sum the tier's tokens served from and written to the prompt cache. Uncached input tokens is Total input tokens minus Cache read tokens minus Cache write tokens, so in every column Total input tokens = Cache read tokens + Cache write tokens + Uncached input tokens exactly. Total output tokens sums the tier's output tokens, reasoning tokens included. The per-model tables below keep each family's own reported input count (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under \"Reading these figures\".", "Stub-mode columns ran the deterministic stub provider: no live model was invoked, so latency is not measured there.", "Cost cells read withheld where the price table is marked provisional." ] diff --git a/frontend/src/pages/evals/evals.recordFormat.test.tsx b/frontend/src/pages/evals/evals.recordFormat.test.tsx new file mode 100644 index 0000000..7841694 --- /dev/null +++ b/frontend/src/pages/evals/evals.recordFormat.test.tsx @@ -0,0 +1,155 @@ +// SPDX-License-Identifier: MIT +/** + * A run recorded in an earlier format: its payload carries `record_format: "earlier"` and no + * matrix, tier table or artifacts. The page still lists and opens it, shows its run metadata, and + * states that its results are not shown instead of reporting a missing matrix. + */ +import { cleanup, render, screen, within } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { afterEach, describe, expect, it, vi } from "vitest"; + +import type { AuthContextValue } from "../../auth/AuthProvider"; +import { EvalDashboardPage } from "./EvalDashboardPage"; +import { HttpEvalRunClient, type EvalRunStatusResponse } from "./EvalRunClient"; +import { BaseFakeEvalRunClient, jobPayload } from "./testFixtures"; +import { isEarlierRecordFormat } from "./types"; + +const POLL_MS = 5; +const NOTICE_TEXT = "Recorded in an earlier format; its results are not shown."; + +afterEach(() => { + cleanup(); +}); + +const fakeAuth: AuthContextValue = { + status: "signed-in", + identity: { + userId: "user-1", + repId: "rep-1", + book: ["acct-1"], + fullVisibility: false, + expiresAt: 9_999_999_999, + }, + signIn: vi.fn(), + signOut: vi.fn(), + getAccessToken: vi.fn().mockResolvedValue("tok-123"), +}; + +function earlierRun(status: "completed" | "cancelled", runId: string): EvalRunStatusResponse { + return { + ...jobPayload({ status, run_id: runId, mode: "live", cost_spent_usd: 4.52 }), + record_format: "earlier", + }; +} + +async function openRun(run: EvalRunStatusResponse, others: readonly EvalRunStatusResponse[] = []) { + render( + , + ); + await userEvent.click(await screen.findByRole("button", { name: `Show run ${run.run_id}` })); +} + +describe("the HTTP client's run parsing", () => { + async function parsed( + call: (client: HttpEvalRunClient) => Promise, + response: unknown, + ): Promise { + vi.stubGlobal( + "fetch", + vi.fn().mockResolvedValue({ ok: true, json: () => Promise.resolve(response) }), + ); + try { + return await call(new HttpEvalRunClient("/api", { getAccessToken: () => Promise.resolve("tok") })); + } finally { + vi.unstubAllGlobals(); + } + } + + it("keeps record_format on a status response", async () => { + const run = (await parsed((c) => c.getRunStatus("run-e"), earlierRun("completed", "run-e"))) as + EvalRunStatusResponse; + expect(run.record_format).toBe("earlier"); + }); + + it("keeps record_format when an unreadable tier table is dropped", async () => { + const raw = { ...earlierRun("completed", "run-e"), tier_comparison_table: { headers: 1 } }; + const run = (await parsed((c) => c.getRunStatus("run-e"), raw)) as EvalRunStatusResponse; + expect(run.tier_comparison_table).toBeUndefined(); + expect(run.record_format).toBe("earlier"); + }); + + it("keeps record_format on every listed run", async () => { + const page = (await parsed((c) => c.listRuns(), { + runs: [earlierRun("completed", "run-e")], + next_cursor: null, + })) as { runs: readonly EvalRunStatusResponse[] }; + expect(page.runs.map((run) => run.record_format)).toEqual(["earlier"]); + }); +}); + +describe("isEarlierRecordFormat", () => { + it("is true only for the earlier marker", () => { + expect(isEarlierRecordFormat({ record_format: "earlier" })).toBe(true); + expect(isEarlierRecordFormat({})).toBe(false); + }); +}); + +describe.each(["completed", "cancelled"] as const)("an earlier-format %s run", (status) => { + const runId = `run-earlier-${status}`; + + it("shows the notice and run metadata, and no results, tier table or artifacts", async () => { + await openRun(earlierRun(status, runId)); + + const notice = screen.getByTestId("eval-record-format-earlier"); + expect(notice.textContent).toBe(NOTICE_TEXT); + expect(notice.getAttribute("role")).toBe("status"); + + expect(screen.queryByRole("heading", { name: "Results" })).toBeNull(); + expect(screen.queryByText(/returned no result matrix/)).toBeNull(); + expect(screen.queryByText(/has no result matrix/)).toBeNull(); + expect(screen.queryByText(/No artifact manifest was reported/)).toBeNull(); + expect(screen.queryByRole("alert")).toBeNull(); + + const runIdTerm = screen.getByText("Run id", { selector: "dt" }); + expect(runIdTerm.nextElementSibling?.textContent).toBe(runId); + expect(screen.getByText("Spend", { selector: "dt" }).nextElementSibling?.textContent).not.toBe( + "", + ); + expect(screen.getByText("Finished at", { selector: "dt" }).nextElementSibling?.textContent).toBe( + "2026-01-01T00:05:00+00:00", + ); + }); + + it("stays listed in the run history", async () => { + await openRun(earlierRun(status, runId)); + + const rows = screen.getAllByRole("row"); + const listed = rows.filter( + (row) => within(row).queryByRole("button", { name: `Show run ${runId}` }) !== null, + ); + expect(listed).toHaveLength(1); + }); +}); + +describe("a current-format run", () => { + it("does not show the earlier-format notice", async () => { + await openRun(jobPayload({ status: "completed", run_id: "run-current" })); + + expect(screen.queryByTestId("eval-record-format-earlier")).toBeNull(); + expect(screen.getByRole("alert").textContent).toContain("returned no result matrix"); + }); + + it("can be opened after an earlier-format run, which then drops the notice", async () => { + const current = jobPayload({ status: "completed", run_id: "run-current" }); + await openRun(earlierRun("completed", "run-earlier"), [current]); + expect(screen.getByTestId("eval-record-format-earlier")).toBeTruthy(); + + await userEvent.click(screen.getByRole("button", { name: "Show run run-current" })); + expect(screen.queryByTestId("eval-record-format-earlier")).toBeNull(); + }); +}); diff --git a/frontend/src/pages/evals/types.ts b/frontend/src/pages/evals/types.ts index 1e6648d..b5849b9 100644 --- a/frontend/src/pages/evals/types.ts +++ b/frontend/src/pages/evals/types.ts @@ -292,3 +292,14 @@ export interface EvalTierComparisonTable { readonly sections: readonly EvalTierComparisonSection[]; readonly notes: readonly string[]; } + +/** + * The run payload's `record_format` marker: `"earlier"` when the run's stored matrix predates the + * current record shape. Such a payload carries no `matrix`, `tier_comparison_table` or `artifacts`. + */ +export type EvalRecordFormat = "earlier"; + +/** True when the run was recorded in an earlier format, so its results are not shown. */ +export function isEarlierRecordFormat(run: { readonly record_format?: EvalRecordFormat }): boolean { + return run.record_format === "earlier"; +} diff --git a/frontend/src/test/responseShapes.test.ts b/frontend/src/test/responseShapes.test.ts index e104d46..8dae9f1 100644 --- a/frontend/src/test/responseShapes.test.ts +++ b/frontend/src/test/responseShapes.test.ts @@ -9,7 +9,7 @@ * assertions fail if a tool drops out of coverage. */ import { execFileSync } from "node:child_process"; -import { existsSync, readFileSync } from "node:fs"; +import { readFileSync } from "node:fs"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; @@ -18,8 +18,9 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); const repoRoot = resolve(__dirname, "..", "..", ".."); function runPythonExporter(): Record { - const venvPython = resolve(repoRoot, ".venv", "bin", "python3"); - const pythonBin = existsSync(venvPython) ? venvPython : "python3"; + const pythonBin = execFileSync(resolve(repoRoot, "scripts", "repo_python.sh"), ["--print"], { + encoding: "utf-8", + }).trim(); const raw = execFileSync( pythonBin, [resolve(repoRoot, "frontend", "scripts", "export_response_shapes.py")], diff --git a/githooks/pre-commit b/githooks/pre-commit index 53d32f7..fd774b3 100755 --- a/githooks/pre-commit +++ b/githooks/pre-commit @@ -95,7 +95,7 @@ else echo "pre-commit: running gitleaks over the working tree's non-ignored files..." # The gate resolves `gitleaks` from PATH, so put the resolved GITLEAKS_BIN's directory first. _gitleaks_dir="$(dirname -- "$(command -v "$GITLEAKS_BIN")")" - if ! PATH="$_gitleaks_dir:$PATH" python3 scripts/check_secret_scan.py ; then + if ! PATH="$_gitleaks_dir:$PATH" scripts/repo_python.sh scripts/check_secret_scan.py ; then FAILED=1 fi fi diff --git a/infra/.terraform.lock.hcl b/infra/.terraform.lock.hcl index b436441..87b1e05 100644 --- a/infra/.terraform.lock.hcl +++ b/infra/.terraform.lock.hcl @@ -2,29 +2,29 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "6.71.0" - constraints = "6.71.0" + version = "6.72.0" + constraints = "6.72.0" hashes = [ - "h1:HNddcXLjW2P3WWN1JFIqeg8o3ouCwit4fD14Emx6+rc=", - "h1:aLOQts7nCLMR0kb/jCdP56wlQQoGqhKLctKgtQjDopc=", - "h1:sZCupscga0Grk22+04FNY1RYDeOcVbCTd6ff8+hsF94=", - "h1:tmOIsPrIHwR6en567EnkR0nqIr9yD0XQcadgSsPpG2g=", - "zh:09aa14408c5ab26915fb2a469b5eb67c06393a2054d78592ba4c32f7a882e918", - "zh:1d1138128dc4866f6c16b1ef3b871b3fd9a3dc648e9056e06e210d1817aa052b", - "zh:2c17a79821a0e06fbf1834a12e92227db29c2001fef7ef0b347af2e6dad83f14", - "zh:55616730a485c9c7283546a84f1ac5f8341152c5572338a54fc7af5f69ebfb92", - "zh:7e6461ec2976b5961a1d4f3c08c68fae0645d7f5e0a404f7647baa3b88d337d8", - "zh:7ec935166b2251d075fea980012f5267078785399585e8b443dca484fc57df0f", - "zh:885b3290cd48738cbf9ee8a6d47a4452889843f8f53b8cf67fc8c9b16e553721", - "zh:8930fb33c6c965f7cc82230cb7fbb0cfff9bb30becdfce5e0c2242512d849894", + "h1:3AYbyqqXadj43NSHVMZ7HmhzqUDKzUqz/PFKoz2zZF4=", + "h1:SMGODuhkqfLLPqHyfaelK7rfkN8uqLAstPwZ4DKUpv8=", + "h1:mOeaj5DLQjxSyaVbYiilZh4htt9Yo2y0jngHnRucJtw=", + "h1:v8OGTOUuY1sbRr4VDjYW7ypqV5NBB1cosUY5LrcwqTs=", + "zh:2ffb6b2caaf320b61b406cff192d6e4303b64e32990b69384a056fe5af3d015b", + "zh:33cd70e1b3d0f80bfdf07480139142f81a3daec26ab0fd160d00793e819b807e", + "zh:37166439117b6ab889b02513e9cdc09b9ea4dd0b6e0733e83da47fc938acad35", + "zh:676fc5b60e270af38f94da63bb0caa80c3fb24c8c68c77ceb4df8c09f5fd78f0", + "zh:7218399da8607fd00b948e817941d3e543a09347272ff9103d9cf3797ad697e0", + "zh:7fba55258fa19b283b465b2158141f8cffa23d4aa670cd9edfab9e4deaebc5d2", + "zh:81da89c4557a9fb2943f10e229b4e289852df94255b7186dc7e1dcbd36641a9f", + "zh:82b8dd415eb13a81e7e28fc29756e4639c77683534b0ffae6bf25c10b693a374", + "zh:98fd4bbce8d01e99e983b09a824d0d76dacb9131c3d0d6246bc58f4a31ba1e51", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a702f9a4dc7340182a8daf5b6ee562f14657fe14752f7d54dc799cf2fd91a868", - "zh:b624cb320d787fbfa6dc94be5a1fd52683d1ebd11b42646262b221a694e6ffb8", - "zh:bcbaded68b553afeea93604ec22c254b98f3951862bdeb68ae89c179c7dda117", - "zh:cb57bbcaf0fa3a70ea29b60d183d3a0dd020f041b18da5d1725d2acd17fa7d59", - "zh:d4ca164b1b6039557d8f5f5f911c4aaad1a187e9b3758f6885c95f8954f7de58", - "zh:eb0c705337cef7b96086e8b84702ba965eeeace7a4aa3235b2c8aad5f50f2fca", - "zh:f2787f40ce873d8c1308c92adec9b6adbd223506fe9d79bba447729e422f9146", + "zh:9f4805d74c8a217d5226c0a0432aac48bf78e1f1211ebd8e637ef03c371dfe39", + "zh:dea44ec068f2cf22d4c7de93c5639b494d37ae96afd030d930bfb52d5a56993b", + "zh:e36e6b40ecb21c5c11c901a278b3ff8cb16ef553b155d7d22a774d051051803b", + "zh:ed50513dd885ae66c3be4b170931e44775886339027431135cd41aa885307280", + "zh:eefefe233dcb8934d4cdda1cb67e7e89b177a2717ee73822f4915cb3681cdc83", + "zh:f67a7f2d76347698874caab82da856cfd6b99c418b0401768be06c5cc10a488d", ] } diff --git a/infra/backend.tf b/infra/backend.tf index 6fa8557..47ba732 100644 --- a/infra/backend.tf +++ b/infra/backend.tf @@ -11,7 +11,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } diff --git a/infra/bootstrap_account/.terraform.lock.hcl b/infra/bootstrap_account/.terraform.lock.hcl index a85fe58..1dc5f63 100644 --- a/infra/bootstrap_account/.terraform.lock.hcl +++ b/infra/bootstrap_account/.terraform.lock.hcl @@ -2,28 +2,28 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "6.71.0" - constraints = "6.71.0" + version = "6.72.0" + constraints = "6.72.0" hashes = [ - "h1:HNddcXLjW2P3WWN1JFIqeg8o3ouCwit4fD14Emx6+rc=", - "h1:aLOQts7nCLMR0kb/jCdP56wlQQoGqhKLctKgtQjDopc=", - "h1:sZCupscga0Grk22+04FNY1RYDeOcVbCTd6ff8+hsF94=", - "h1:tmOIsPrIHwR6en567EnkR0nqIr9yD0XQcadgSsPpG2g=", - "zh:09aa14408c5ab26915fb2a469b5eb67c06393a2054d78592ba4c32f7a882e918", - "zh:1d1138128dc4866f6c16b1ef3b871b3fd9a3dc648e9056e06e210d1817aa052b", - "zh:2c17a79821a0e06fbf1834a12e92227db29c2001fef7ef0b347af2e6dad83f14", - "zh:55616730a485c9c7283546a84f1ac5f8341152c5572338a54fc7af5f69ebfb92", - "zh:7e6461ec2976b5961a1d4f3c08c68fae0645d7f5e0a404f7647baa3b88d337d8", - "zh:7ec935166b2251d075fea980012f5267078785399585e8b443dca484fc57df0f", - "zh:885b3290cd48738cbf9ee8a6d47a4452889843f8f53b8cf67fc8c9b16e553721", - "zh:8930fb33c6c965f7cc82230cb7fbb0cfff9bb30becdfce5e0c2242512d849894", + "h1:3AYbyqqXadj43NSHVMZ7HmhzqUDKzUqz/PFKoz2zZF4=", + "h1:SMGODuhkqfLLPqHyfaelK7rfkN8uqLAstPwZ4DKUpv8=", + "h1:mOeaj5DLQjxSyaVbYiilZh4htt9Yo2y0jngHnRucJtw=", + "h1:v8OGTOUuY1sbRr4VDjYW7ypqV5NBB1cosUY5LrcwqTs=", + "zh:2ffb6b2caaf320b61b406cff192d6e4303b64e32990b69384a056fe5af3d015b", + "zh:33cd70e1b3d0f80bfdf07480139142f81a3daec26ab0fd160d00793e819b807e", + "zh:37166439117b6ab889b02513e9cdc09b9ea4dd0b6e0733e83da47fc938acad35", + "zh:676fc5b60e270af38f94da63bb0caa80c3fb24c8c68c77ceb4df8c09f5fd78f0", + "zh:7218399da8607fd00b948e817941d3e543a09347272ff9103d9cf3797ad697e0", + "zh:7fba55258fa19b283b465b2158141f8cffa23d4aa670cd9edfab9e4deaebc5d2", + "zh:81da89c4557a9fb2943f10e229b4e289852df94255b7186dc7e1dcbd36641a9f", + "zh:82b8dd415eb13a81e7e28fc29756e4639c77683534b0ffae6bf25c10b693a374", + "zh:98fd4bbce8d01e99e983b09a824d0d76dacb9131c3d0d6246bc58f4a31ba1e51", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a702f9a4dc7340182a8daf5b6ee562f14657fe14752f7d54dc799cf2fd91a868", - "zh:b624cb320d787fbfa6dc94be5a1fd52683d1ebd11b42646262b221a694e6ffb8", - "zh:bcbaded68b553afeea93604ec22c254b98f3951862bdeb68ae89c179c7dda117", - "zh:cb57bbcaf0fa3a70ea29b60d183d3a0dd020f041b18da5d1725d2acd17fa7d59", - "zh:d4ca164b1b6039557d8f5f5f911c4aaad1a187e9b3758f6885c95f8954f7de58", - "zh:eb0c705337cef7b96086e8b84702ba965eeeace7a4aa3235b2c8aad5f50f2fca", - "zh:f2787f40ce873d8c1308c92adec9b6adbd223506fe9d79bba447729e422f9146", + "zh:9f4805d74c8a217d5226c0a0432aac48bf78e1f1211ebd8e637ef03c371dfe39", + "zh:dea44ec068f2cf22d4c7de93c5639b494d37ae96afd030d930bfb52d5a56993b", + "zh:e36e6b40ecb21c5c11c901a278b3ff8cb16ef553b155d7d22a774d051051803b", + "zh:ed50513dd885ae66c3be4b170931e44775886339027431135cd41aa885307280", + "zh:eefefe233dcb8934d4cdda1cb67e7e89b177a2717ee73822f4915cb3681cdc83", + "zh:f67a7f2d76347698874caab82da856cfd6b99c418b0401768be06c5cc10a488d", ] } diff --git a/infra/bootstrap_account/README.md b/infra/bootstrap_account/README.md index 3aa7216..50482fd 100644 --- a/infra/bootstrap_account/README.md +++ b/infra/bootstrap_account/README.md @@ -85,7 +85,7 @@ terraform init -backend=false -input=false -plugin-dir=../.terraform/providers terraform validate ``` -`.terraform.lock.hcl` carries the same `hashicorp/aws` 6.71.0 entry as `infra/.terraform.lock.hcl`. +`.terraform.lock.hcl` carries the same `hashicorp/aws` 6.72.0 entry as `infra/.terraform.lock.hcl`. ## Common failures @@ -107,7 +107,7 @@ terraform validate ## Destroy and the account setting -The `hashicorp/aws` 6.71.0 schema for `aws_api_gateway_account` has no `reset_on_delete` argument +The `hashicorp/aws` 6.72.0 schema for `aws_api_gateway_account` has no `reset_on_delete` argument (checked with `terraform providers schema -json`). The provider's v6 upgrade guide says destroy now always resets the API Gateway account settings, so `--destroy` clears the account+region `cloudwatchRoleArn`. Any other workload's API Gateway logging in that account and region stops with diff --git a/infra/bootstrap_account/apigw_logging.tf b/infra/bootstrap_account/apigw_logging.tf index 9ee2816..36f14d1 100644 --- a/infra/bootstrap_account/apigw_logging.tf +++ b/infra/bootstrap_account/apigw_logging.tf @@ -1,4 +1,4 @@ -# Account-wide API Gateway CloudWatch Logs setting. The 6.71.0 `aws_api_gateway_account` schema +# Account-wide API Gateway CloudWatch Logs setting. The 6.72.0 `aws_api_gateway_account` schema # has no `reset_on_delete` argument; see README.md for the destroy behaviour. resource "aws_iam_role" "apigw_cloudwatch" { diff --git a/infra/bootstrap_account/versions.tf b/infra/bootstrap_account/versions.tf index 4e2862b..42d44b8 100644 --- a/infra/bootstrap_account/versions.tf +++ b/infra/bootstrap_account/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/eval_sfn.tf b/infra/eval_sfn.tf index 8f5b081..137c73d 100644 --- a/infra/eval_sfn.tf +++ b/infra/eval_sfn.tf @@ -130,7 +130,7 @@ module "lambda_action_sweep_control" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "eval.sfn_handlers.sweep_control_handler" - runtime = "python3.13" + runtime = "python3.14" filename = local.eval_lambda_zip source_code_hash = filebase64sha256(local.eval_lambda_zip) @@ -230,7 +230,7 @@ module "lambda_action_sweep_task" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "eval.sfn_handlers.sweep_task_handler" - runtime = "python3.13" + runtime = "python3.14" filename = local.eval_lambda_zip source_code_hash = filebase64sha256(local.eval_lambda_zip) diff --git a/infra/main.tf b/infra/main.tf index c555927..9388b28 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -474,7 +474,8 @@ module "dynamodb" { administrator_principal_arns = concat(var.crm_operator_principal_arns, ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]) } -# The execution role of every `lambda_action` call with `dynamodb_kms_grant_enabled = true`. +# The execution role of every `lambda_action` call with `dynamodb_kms_grant_enabled = true`, and the +# AgentCore Runtime's role. locals { dynamodb_data_plane_role_arns = concat( [for tool in module.lambda_action : tool.role_arn], @@ -487,6 +488,7 @@ locals { module.lambda_action_chat_interceptor.role_arn, module.lambda_action_chat_target.role_arn, module.lambda_action_user_settings.role_arn, + aws_iam_role.agentcore_runtime.arn, ], ) } @@ -643,7 +645,7 @@ module "lambda_action" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = each.value.handler - runtime = "python3.13" + runtime = "python3.14" filename = "${var.lambda_build_dir}/${each.key}.zip" source_code_hash = filebase64sha256("${var.lambda_build_dir}/${each.key}.zip") @@ -730,7 +732,7 @@ module "lambda_action_interceptor" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "gateway.identity_interceptor.lambda_handler" - runtime = "python3.13" + runtime = "python3.14" filename = "${var.lambda_build_dir}/identity_interceptor.zip" source_code_hash = filebase64sha256("${var.lambda_build_dir}/identity_interceptor.zip") @@ -868,7 +870,7 @@ module "lambda_action_eval_trigger" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "crm.handlers.eval_trigger.handler" - runtime = "python3.13" + runtime = "python3.14" filename = local.eval_lambda_zip source_code_hash = filebase64sha256(local.eval_lambda_zip) @@ -931,7 +933,7 @@ module "lambda_action_capabilities" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "crm.handlers.capabilities.handler" - runtime = "python3.13" + runtime = "python3.14" filename = local.eval_lambda_zip source_code_hash = filebase64sha256(local.eval_lambda_zip) @@ -1080,7 +1082,7 @@ module "lambda_action_pre_token_generation" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "crm.auth.pre_token_generation.lambda_handler" - runtime = "python3.13" + runtime = "python3.14" filename = "${var.lambda_build_dir}/pre_token_generation.zip" source_code_hash = filebase64sha256("${var.lambda_build_dir}/pre_token_generation.zip") @@ -2062,7 +2064,7 @@ module "agentcore" { # `aws_s3_object.agent_source` must exist before the image build reads it, and # `aws_iam_role_policy.agentcore_runtime` must be applied before the runtime, because # CreateAgentRuntime checks that the execution role can pull the ECR image. - depends_on = [aws_s3_object.agent_source, aws_iam_role_policy.agentcore_runtime] + depends_on = [aws_s3_object.agent_source, aws_iam_role_policy.agentcore_runtime, aws_iam_role_policy.agentcore_runtime_history] aws_profile = var.aws_profile aws_region = var.aws_region @@ -2103,6 +2105,8 @@ module "agentcore" { # Prefix of every `module.lambda_action` function name, used to resolve a tool to its Lambda. ACTION_LAMBDA_PREFIX = local.name_prefix + + CONVERSATION_HISTORY_STORE = "dynamodb" } cognito_discovery_url = "https://cognito-idp.${var.aws_region}.amazonaws.com/${module.cognito.user_pool_id}/.well-known/openid-configuration" @@ -2273,6 +2277,121 @@ resource "aws_iam_role_policy" "agentcore_runtime" { policy = data.aws_iam_policy_document.agentcore_runtime_permissions.json } +locals { + # Every table but `reps`, with its indexes; the Runtime role is denied all of them. + runtime_denied_table_arns = flatten([ + for table_name, table_arn in module.dynamodb.table_arns : [table_arn, "${table_arn}/index/*"] + if table_name != "reps" + ]) +} + +# The Runtime's conversation history: `history##` items in `reps`, read and +# written once per turn, and nothing else in DynamoDB. +data "aws_iam_policy_document" "agentcore_runtime_history" { + # The Null condition stops the ForAllValues test from matching a request that carries no key. + statement { + sid = "ConversationHistoryRead" + effect = "Allow" + actions = ["dynamodb:GetItem"] + resources = [module.dynamodb.table_arns["reps"]] + condition { + test = "ForAllValues:StringLike" + variable = "dynamodb:LeadingKeys" + values = ["history#*"] + } + condition { + test = "Null" + variable = "dynamodb:LeadingKeys" + values = ["false"] + } + } + + # The attribute list is `agents.conversation_history.HISTORY_ITEM_ATTRIBUTES`; no `tenant`, so no + # history item reaches `gsi_tenant`. + statement { + sid = "ConversationHistoryWrite" + effect = "Allow" + actions = ["dynamodb:PutItem"] + resources = [module.dynamodb.table_arns["reps"]] + condition { + test = "ForAllValues:StringLike" + variable = "dynamodb:LeadingKeys" + values = ["history#*"] + } + condition { + test = "Null" + variable = "dynamodb:LeadingKeys" + values = ["false"] + } + condition { + test = "ForAllValues:StringEquals" + variable = "dynamodb:Attributes" + values = ["expires_at", "kind", "owner_rep_id", "owner_tenant", "rep_id", "turns", "updated_at", "version"] + } + } + + statement { + sid = "ConversationHistoryKms" + effect = "Allow" + actions = ["kms:Decrypt", "kms:GenerateDataKey"] + resources = [module.dynamodb.kms_key_arn] + condition { + test = "StringEquals" + variable = "kms:ViaService" + values = ["dynamodb.${var.aws_region}.amazonaws.com"] + } + condition { + test = "StringEquals" + variable = "kms:EncryptionContext:aws:dynamodb:tableName" + values = [module.dynamodb.table_names["reps"]] + } + } + + statement { + sid = "DenyDynamoDbOtherTables" + effect = "Deny" + actions = ["dynamodb:*"] + resources = local.runtime_denied_table_arns + } + + statement { + sid = "DenyRepsNonGrantedActions" + effect = "Deny" + not_actions = ["dynamodb:GetItem", "dynamodb:PutItem"] + resources = [module.dynamodb.table_arns["reps"], "${module.dynamodb.table_arns["reps"]}/index/*"] + } + + statement { + sid = "DenyRepsOutsideHistoryPrefix" + effect = "Deny" + actions = ["dynamodb:GetItem", "dynamodb:PutItem"] + resources = [module.dynamodb.table_arns["reps"]] + condition { + test = "ForAnyValue:StringNotLike" + variable = "dynamodb:LeadingKeys" + values = ["history#*"] + } + } + + statement { + sid = "DenyCanaryHistory" + effect = "Deny" + actions = ["dynamodb:GetItem", "dynamodb:PutItem"] + resources = [module.dynamodb.table_arns["reps"]] + condition { + test = "ForAnyValue:StringLike" + variable = "dynamodb:LeadingKeys" + values = ["history#canary#*"] + } + } +} + +resource "aws_iam_role_policy" "agentcore_runtime_history" { + name = "crm-agent-eval-runtime-history" + role = aws_iam_role.agentcore_runtime.id + policy = data.aws_iam_policy_document.agentcore_runtime_history.json +} + # Applied after the runtime, because the log group it scopes to is named from the runtime's id. resource "aws_iam_role_policy" "agentcore_runtime_logs" { name = "crm-agent-eval-runtime-logs" diff --git a/infra/mcp_chat_gateway.tf b/infra/mcp_chat_gateway.tf index 71fbf97..1807728 100644 --- a/infra/mcp_chat_gateway.tf +++ b/infra/mcp_chat_gateway.tf @@ -15,7 +15,7 @@ module "lambda_action_chat_interceptor" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "gateway.identity_interceptor.lambda_handler" - runtime = "python3.13" + runtime = "python3.14" filename = "${var.lambda_build_dir}/identity_interceptor.zip" source_code_hash = filebase64sha256("${var.lambda_build_dir}/identity_interceptor.zip") @@ -87,7 +87,7 @@ module "lambda_action_chat_target" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "gateway.chat_target.lambda_handler" - runtime = "python3.13" + runtime = "python3.14" filename = "${var.lambda_build_dir}/chat_target.zip" source_code_hash = filebase64sha256("${var.lambda_build_dir}/chat_target.zip") diff --git a/infra/modules/agent_relay/versions.tf b/infra/modules/agent_relay/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/agent_relay/versions.tf +++ b/infra/modules/agent_relay/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/agentcore/README.md b/infra/modules/agentcore/README.md index 19cd9fa..fdf2148 100644 --- a/infra/modules/agentcore/README.md +++ b/infra/modules/agentcore/README.md @@ -67,7 +67,7 @@ build reads the agent-source object from that bucket). `runtime.tf` sets no `capacity_provider_configuration`. That argument is what opts a runtime into the **Instances** compute type, which bills continuously; without it the runtime uses the default microVM/consumption compute type, billed per second while active and nothing at idle. The pinned -`hashicorp/aws` 6.71.0 schema for `aws_bedrockagentcore_agent_runtime` has no +`hashicorp/aws` 6.72.0 schema for `aws_bedrockagentcore_agent_runtime` has no `capacity_provider_configuration` argument, so the omission is structural. To check any `aws_bedrockagentcore_*` argument against the provider schema: diff --git a/infra/modules/agentcore/gateway.tf b/infra/modules/agentcore/gateway.tf index adf5106..9a85648 100644 --- a/infra/modules/agentcore/gateway.tf +++ b/infra/modules/agentcore/gateway.tf @@ -1,6 +1,6 @@ /** * `aws_bedrockagentcore_gateway` with `authorizer_type = "CUSTOM_JWT"` and a REQUEST interceptor - * pointed at `identity_interceptor`. Arguments match the pinned 6.71.0 provider schema: + * pointed at `identity_interceptor`. Arguments match the pinned 6.72.0 provider schema: * `authorizer_type`, `authorizer_configuration.custom_jwt_authorizer.{discovery_url, * allowed_clients, allowed_audience, allowed_scopes, custom_claim}`, * `interceptor_configuration.{interception_points, input_configuration.pass_request_headers, diff --git a/infra/modules/agentcore/runtime.tf b/infra/modules/agentcore/runtime.tf index f07b0f0..deab13b 100644 --- a/infra/modules/agentcore/runtime.tf +++ b/infra/modules/agentcore/runtime.tf @@ -1,9 +1,9 @@ /** * `aws_bedrockagentcore_agent_runtime`, running the CodeBuild-built image. Arguments match the - * pinned `hashicorp/aws` 6.71.0 provider schema. Inbound auth is IAM/SigV4; the relay is the only + * pinned `hashicorp/aws` 6.72.0 provider schema. Inbound auth is IAM/SigV4; the relay is the only * caller. * - * No `capacity_provider_configuration` is set (the 6.71.0 schema has none), so the runtime uses + * No `capacity_provider_configuration` is set (the 6.72.0 schema has none), so the runtime uses * consumption-mode microVM billing. */ diff --git a/infra/modules/agentcore/versions.tf b/infra/modules/agentcore/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/agentcore/versions.tf +++ b/infra/modules/agentcore/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/api/versions.tf b/infra/modules/api/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/api/versions.tf +++ b/infra/modules/api/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/api_origin/versions.tf b/infra/modules/api_origin/versions.tf index 7e9068f..71ccff0 100644 --- a/infra/modules/api_origin/versions.tf +++ b/infra/modules/api_origin/versions.tf @@ -10,7 +10,7 @@ terraform { aws = { source = "hashicorp/aws" # This version carries `aws_cloudfront_vpc_origin` and `vpc_origin_config`. - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/cognito/versions.tf b/infra/modules/cognito/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/cognito/versions.tf +++ b/infra/modules/cognito/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/dynamodb/tables.tf b/infra/modules/dynamodb/tables.tf index c917007..4a6b9e3 100644 --- a/infra/modules/dynamodb/tables.tf +++ b/infra/modules/dynamodb/tables.tf @@ -651,6 +651,12 @@ resource "aws_dynamodb_table" "reps" { enabled = true } + # Only conversation-history items carry `expires_at`. + ttl { + attribute_name = "expires_at" + enabled = true + } + tags = { "data-classification" = var.data_classification } diff --git a/infra/modules/dynamodb/versions.tf b/infra/modules/dynamodb/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/dynamodb/versions.tf +++ b/infra/modules/dynamodb/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/eni_function_code_deny/versions.tf b/infra/modules/eni_function_code_deny/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/eni_function_code_deny/versions.tf +++ b/infra/modules/eni_function_code_deny/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/eval_artifacts/versions.tf b/infra/modules/eval_artifacts/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/eval_artifacts/versions.tf +++ b/infra/modules/eval_artifacts/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/frontend_cdn/versions.tf b/infra/modules/frontend_cdn/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/frontend_cdn/versions.tf +++ b/infra/modules/frontend_cdn/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/lambda_action/README.md b/infra/modules/lambda_action/README.md index 588bfee..850eb3a 100644 --- a/infra/modules/lambda_action/README.md +++ b/infra/modules/lambda_action/README.md @@ -51,7 +51,7 @@ baseline](../../../docs/security-baseline.md#h-7). Modules named here: [`api`](. | `vpc_subnet_ids` | yes | `module.vpc.lambda_subnet_ids`; at least two. | | `vpc_security_group_ids` | yes | `module.vpc.lambda_security_group_ids`; at least one. | | `eni_function_code_deny_policy_arn` | yes | `module.eni_function_code_deny.policy_arn`; a customer-managed policy ARN. | -| `runtime` | no (`python3.13`) | | +| `runtime` | no (`python3.14`) | | | `timeout_seconds` | no (`30`) | | | `memory_size_mb` | no (`256`) | | | `environment_variables` | no (`{}`) | Plaintext only; secrets are resolved at runtime from Secrets Manager or Parameter Store. | @@ -130,7 +130,7 @@ no `Resource = "*"`, no `LeadingKeys` on an `application_code` table). ## Validation `cd infra && terraform validate` exercises the module through the root. It also validates -standalone; `versions.tf` pins the same `hashicorp/aws` 6.71.0 as the root: +standalone; `versions.tf` pins the same `hashicorp/aws` 6.72.0 as the root: ```bash cd infra/modules/lambda_action diff --git a/infra/modules/lambda_action/variables.tf b/infra/modules/lambda_action/variables.tf index 4ce756d..d0ca54e 100644 --- a/infra/modules/lambda_action/variables.tf +++ b/infra/modules/lambda_action/variables.tf @@ -16,7 +16,7 @@ variable "handler" { variable "runtime" { description = "Lambda runtime identifier." type = string - default = "python3.13" + default = "python3.14" } variable "source_code_hash" { diff --git a/infra/modules/lambda_action/versions.tf b/infra/modules/lambda_action/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/lambda_action/versions.tf +++ b/infra/modules/lambda_action/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/mcp_chat_gateway/README.md b/infra/modules/mcp_chat_gateway/README.md index 73c2e9e..fd79734 100644 --- a/infra/modules/mcp_chat_gateway/README.md +++ b/infra/modules/mcp_chat_gateway/README.md @@ -18,7 +18,7 @@ baseline](../../../docs/security-baseline.md). Modules named here: | File | Declares | |---|---| | `main.tf` | the gateway's execution role, trust policy and permissions; `aws_bedrockagentcore_gateway.this`; `aws_bedrockagentcore_gateway_target.chat`; the interceptor's invoke permission for this gateway | -| `variables.tf`, `outputs.tf`, `versions.tf` | interface and provider pin (`hashicorp/aws` 6.71.0) | +| `variables.tf`, `outputs.tf`, `versions.tf` | interface and provider pin (`hashicorp/aws` 6.72.0) | ## Inputs diff --git a/infra/modules/mcp_chat_gateway/versions.tf b/infra/modules/mcp_chat_gateway/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/mcp_chat_gateway/versions.tf +++ b/infra/modules/mcp_chat_gateway/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/observability/versions.tf b/infra/modules/observability/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/observability/versions.tf +++ b/infra/modules/observability/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/modules/vpc/versions.tf b/infra/modules/vpc/versions.tf index 4a0f231..5faa937 100644 --- a/infra/modules/vpc/versions.tf +++ b/infra/modules/vpc/versions.tf @@ -9,7 +9,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/infra/user_settings.tf b/infra/user_settings.tf index 18977fc..c49822b 100644 --- a/infra/user_settings.tf +++ b/infra/user_settings.tf @@ -14,7 +14,7 @@ module "lambda_action_user_settings" { vpc_subnet_ids = module.vpc.lambda_subnet_ids vpc_security_group_ids = module.vpc.lambda_security_group_ids handler = "crm.handlers.user_settings.handler" - runtime = "python3.13" + runtime = "python3.14" filename = local.eval_lambda_zip source_code_hash = filebase64sha256(local.eval_lambda_zip) diff --git a/pyproject.toml b/pyproject.toml index a6183fb..f9a30aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,21 +9,21 @@ version = "1.0.0" description = "Serverless CRM with a Strands multi-agent assistant, an AgentCore Gateway MCP surface, and an Anthropic-vs-OpenAI evaluation framework." readme = "README.md" license = "MIT" -requires-python = "==3.13.*" +requires-python = "==3.14.*" # Direct dependencies only, exact-version pinned. The full transitive tree is frozen in # requirements.txt, which is the sole install authority. dependencies = [ - "boto3==1.43.125", - "botocore==1.43.125", + "boto3==1.44.1", + "botocore==1.44.1", "PyYAML==6.0.3", "jsonschema==4.26.0", "PyJWT==2.15.1", "cryptography==50.0.2", "strands-agents==1.64.0", "starlette==1.10.0", - "anthropic==2.6.0", - "openai==3.46.0", + "anthropic==2.8.0", + "openai==3.49.0", "httpx2==2.16.0", ] @@ -35,7 +35,7 @@ dev = [ "pytest-cov==7.1.0", "pytest-xdist==3.8.0", "moto==5.2.5", - "types-PyYAML==6.0.12.20261103", + "types-PyYAML==6.0.12.20261111", "defusedxml==0.7.1", "types-defusedxml==0.7.0.20260504", "mcp==2.3.0", @@ -46,7 +46,7 @@ where = ["src"] [tool.ruff] line-length = 100 -target-version = "py313" +target-version = "py314" src = ["src", "tests", "scripts", "fixtures"] [tool.ruff.lint] @@ -67,7 +67,7 @@ ignore = [ "src/crm/errors.py" = ["N818"] [tool.mypy] -python_version = "3.13" +python_version = "3.14" strict = true warn_unreachable = true disallow_untyped_defs = true diff --git a/requirements.txt b/requirements.txt index 86b0498..115f0d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,12 +2,12 @@ # Regenerate with: .venv/bin/pip freeze --exclude-editable | sort # Direct dependencies are declared in pyproject.toml; this file pins everything. annotated-types==0.8.0 -anthropic==2.6.0 +anthropic==2.8.0 anyio==4.16.0 ast_serialize==0.13.1 attrs==26.1.0 -boto3==1.43.125 -botocore==1.43.125 +boto3==1.44.1 +botocore==1.44.1 certifi==2026.10.23 cffi==2.1.1 charset-normalizer==3.5.2 @@ -35,7 +35,7 @@ mcp==2.3.0 moto==5.2.5 mypy_extensions==1.2.0 mypy==2.4.1 -openai==3.46.0 +openai==3.49.0 opentelemetry-api==1.45.2 opentelemetry-instrumentation-threading==0.66b2 opentelemetry-instrumentation==0.66b2 @@ -63,12 +63,12 @@ ruff==0.17.4 s3transfer==0.19.3 six==1.17.0 sniffio==1.3.1 -sse-starlette==3.6.0 +sse-starlette==3.7.0 starlette==1.10.0 strands-agents==1.64.0 truststore==0.10.5 types-defusedxml==0.7.0.20260504 -types-PyYAML==6.0.12.20261103 +types-PyYAML==6.0.12.20261111 typing_extensions==4.16.0 typing-inspection==0.4.5 urllib3==2.8.0 diff --git a/results/matrix.md b/results/matrix.md index 23782a7..859408d 100644 --- a/results/matrix.md +++ b/results/matrix.md @@ -10,19 +10,24 @@ Per-tier figures for each arm, one column per arm in run order; the notes below | --- | --- | --- | | Model | anthropic.claude-sonnet-5-5 | openai.gpt-6.1-sol | | Effort | medium | medium | -| Task completion rate | 0.941667 (113/120) | 0.991667 (119/120) | -| Task completion over repeats | 0.958333 (23/24, majority of 5) | 1.000000 (24/24, majority of 5) | -| Task accuracy | 0.984167 | 0.997500 | -| Cost per completed task | 0.011594 | 0.005498 | -| P95 latency per completed task (ms) | 10541.749459 (n=110) | 10262.295082 (n=114) | -| P50 latency per completed task (ms) | 4630.674541 (n=110) | 4112.333292 (n=114) | -| Model invocations | 273 | 242 | +| Task completion rate | 0.900000 (108/120) | 0.991667 (119/120) | +| Task completion over repeats | 0.916667 (22/24, majority of 5) | 1.000000 (24/24, majority of 5) | +| Task accuracy | 0.975463 | 0.999074 | +| Cost per completed task | 0.023736 | 0.014555 | +| P50 latency per completed task (ms) | 3800.814666 (n=108) | 3696.228625 (n=119) | +| P95 latency per completed task (ms) | 15170.417917 (n=108) | 20859.479959 (n=119) | +| Model invocations | 290 | 268 | | Long-context invocations | 0 | 0 | -| Input tokens | 350986 | 727458 | -| Output tokens | 47818 | 23719 | -| Cost per task, all tasks | 0.010917 | 0.005452 | +| Total input tokens | 2482245 | 1579162 | +| Cache read tokens | 1815158 | 1086832 | +| Cache write tokens | 666267 | 491794 | +| Uncached input tokens | 820 | 536 | +| Total output tokens | 71463 | 39285 | +| Cost per applicable task | 0.021362 | 0.014434 | | Self-corrected retries | 0 | 0 | -| Budget-exhausted tasks | 5 | 5 | +| Budget-exhausted tasks | 0 | 0 | +| Truncated tool calls | 20 | 16 | +| Truncated tasks | 20 | 16 | ### Subagent @@ -30,23 +35,24 @@ Per-tier figures for each arm, one column per arm in run order; the notes below | --- | --- | --- | | Model | anthropic.claude-sonnet-5-5 | openai.gpt-6.1-terra | | Effort | low | low | -| Task completion rate | 1.000000 (115/115) | 1.000000 (115/115) | +| Task completion rate | 1.000000 (115/115) | 0.991304 (114/115) | | Task completion over repeats | 1.000000 (23/23, majority of 5) | 1.000000 (23/23, majority of 5) | -| Task accuracy | 1.000000 | 1.000000 | -| Cost per completed task | 0.013680 | 0.007523 | -| P95 latency per completed task (ms) | 22778.526041 (n=55) | 14190.514624 (n=68) | -| P50 latency per completed task (ms) | 5047.331292 (n=55) | 2678.756750 (n=68) | -| Model invocations | 128 | 195 | +| Task accuracy | 1.000000 | 0.991304 | +| Cost per completed task | 0.004743 | 0.007421 | +| P50 latency per completed task (ms) | 4295.231875 (n=50) | 2629.128000 (n=65) | +| P95 latency per completed task (ms) | 6844.754083 (n=50) | 10918.713583 (n=65) | +| Model invocations | 105 | 193 | | Long-context invocations | 0 | 0 | -| Input tokens | 532299 | 1873711 | -| Output tokens | 41494 | 29117 | -| Cost per task, all tasks | 0.013110 | 0.007210 | +| Total input tokens | 781735 | 1597649 | +| Cache read tokens | 691126 | 1076668 | +| Cache write tokens | 90299 | 520595 | +| Uncached input tokens | 310 | 386 | +| Total output tokens | 24997 | 28195 | +| Cost per applicable task | 0.004743 | 0.007356 | | Self-corrected retries | 0 | 0 | -| Delegation outcome: data | 95 | 95 | -| Delegation outcome: no_match | 5 | 5 | -| Delegation outcome: denied | 15 | 15 | -| Delegation outcome: tool_failure | 5 | 5 | -| Delegation outcome: none | 0 | 0 | +| Budget-exhausted tasks | 0 | 0 | +| Truncated tool calls | not applicable | not applicable | +| Truncated tasks | not applicable | not applicable | ### ToolCall @@ -54,28 +60,31 @@ Per-tier figures for each arm, one column per arm in run order; the notes below | --- | --- | --- | | Model | anthropic.claude-haiku-5-5 | openai.gpt-6-luna | | Effort | low | low | -| Task completion rate | 1.000000 (95/95) | 1.000000 (95/95) | +| Task completion rate | 1.000000 (95/95) | 0.989474 (94/95) | | Task completion over repeats | 1.000000 (19/19, majority of 5) | 1.000000 (19/19, majority of 5) | -| Task accuracy | 1.000000 | 1.000000 | -| Cost per completed task | 0.000331 | 0.000184 | -| P95 latency per completed task (ms) | 61764.406877 (n=55) | 32371.663457 (n=63) | -| P50 latency per completed task (ms) | 2117.928416 (n=55) | 1500.936292 (n=63) | -| Model invocations | 240 | 336 | +| Task accuracy | 1.000000 | 0.989474 | +| Cost per completed task | 0.000169 | 0.000142 | +| P50 latency per completed task (ms) | 2150.232458 (n=50) | 1233.549624 (n=61) | +| P95 latency per completed task (ms) | 4397.095708 (n=50) | 8126.829000 (n=61) | +| Model invocations | 67 | 194 | | Long-context invocations | 0 | 0 | -| Input tokens | 159249 | 72244 | -| Output tokens | 31113 | 20463 | -| Cost per task, all tasks | 0.000262 | 0.000145 | +| Total input tokens | 63158 | 52305 | +| Cache read tokens | 0 | 0 | +| Cache write tokens | 62890 | 0 | +| Uncached input tokens | 268 | 52305 | +| Total output tokens | 16394 | 16250 | +| Cost per applicable task | 0.000169 | 0.000141 | | Self-corrected retries | not applicable | not applicable | -| Truncated tasks | 0 | 0 | +| Budget-exhausted tasks | 0 | 0 | +| Truncated tool calls | 0 | 21 | +| Truncated tasks | 0 | 11 | Notes: -- Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per task, all tasks divides the same total by every task the arm ran. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations; Long-context invocations counts those priced at the model's long-context rates, and reads — for a run recorded before that count existed. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there. +- Model lists the tier's configured model and every model that spent tokens at the tier; Effort lists the efforts the tier's turns ran at, with unsupported for a model that takes no effort setting. Task completion rate is rate (met/applicable) over the arm's tasks applicable at the tier, where n is the applicable task count: at Supervisor a task's correctness is 1.0, at Subagent the observed delegation outcome equals the expected one, and at ToolCall an expected tool was called with schema-valid arguments. Task accuracy is the arm's mean_correctness at Supervisor and the completion rate at Subagent and ToolCall. Task completion over repeats is rate (completed/applicable) over the arm's tasks applicable at the tier in any repeat, where a task counts when its tier expectation was met in a strict majority of its applicable repeats, and N is the per-task repeat count. Cost per completed task divides the tier's total cost by its completed task count, so spend on tasks that did not complete is included; Cost per applicable task divides the same total by the tier's applicable task count (n of Task completion rate), so the two rows are equal when every applicable task completed, and it reads — when no task was applicable. Latency per completed task sums the tier's measured call latencies within each completed task and takes the nearest-rank percentile over those tasks; a completed task with no measured call at the tier contributes no sample, and n counts the contributing tasks. Model invocations sums the tier's included invocations; Long-context invocations counts those priced at the model's long-context rates, and reads — for a run recorded before that count existed. Self-corrected retries counts the tier's tool calls whose tool_failure result was followed, later in the same task, by a call to the same tool from the same role that returned data or no_match; such a call does not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is not applicable there. Budget-exhausted tasks counts the task runs whose turn budget ran out at the tier. Truncated tool calls counts the tier's tool calls whose result was truncated, the Supervisor's own direct calls at Supervisor and every call made inside a delegation at ToolCall; Truncated tasks counts the task runs with at least one such call. Subagent makes no tool call itself, so both truncation rows are not applicable there. - Columns are the sweep's arms in run order, not sorted by any result, and no difference or ratio between columns is computed. - Effort labels are not equivalent across families: each family declares its own effort scale (config/model_capabilities.yaml, effort_scale_comparability); see `effort` under "Reading these figures". -- Input tokens are each family's own reported count and are not like-for-like across families (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under "Reading these figures". -- Usage and cost for anthropic are a lower bound; that arm's section names the affected task runs. -- Usage and cost for openai are a lower bound; that arm's section names the affected task runs. +- Total input tokens sums, per model call, the whole prompt the call sent, counted the same way for both families: the provider's reported input plus cache read and cache write tokens for Anthropic, whose reported input excludes them, and the reported input for OpenAI, whose reported input includes them, or that call's cache read plus cache write tokens where they exceed it. Cache read tokens and Cache write tokens sum the tier's tokens served from and written to the prompt cache. Uncached input tokens is Total input tokens minus Cache read tokens minus Cache write tokens, so in every column Total input tokens = Cache read tokens + Cache write tokens + Uncached input tokens exactly. Total output tokens sums the tier's output tokens, reasoning tokens included. The per-model tables below keep each family's own reported input count (token_accounting_disclosure, src/eval/matrix.py); see `input_tokens` comparability under "Reading these figures". Measured dimensions per model arm — direct measurements only; no reference threshold or conclusion is computed or shown here. @@ -88,7 +97,7 @@ Each figure below names one narrow measured signal. Its boundary is stated here - `tool_call_correct_rate` — Reports that each scored turn issued a tool call which dispatched against an in-scope target. It is derived from exactly three conditions — a turn that issued no tool call at all, a proposal submitted on a task whose proposal limit is zero, and a proposal targeting a record other than the expected one — and from nothing else. It therefore does not report whether the turn chose the most apt tool for the task; where a task names the retrieval its answer requires, an `expected_reads` assertion checks that at least one call to a named tool reached the named record, and contributes to `mean_correctness` and deliberately not to this figure. An entry whose `target_id` is null checks only that one of the named tools was called at all, never that any particular record was reached, because the tools it names take no record id. Read to its exact boundary: it is satisfied incidentally by a turn that calls the named tool on the named record among many other calls, it says nothing about what the turn then reported, and it is therefore a necessary condition for an apt retrieval and never a sufficient one (src/eval/scoring.py, `_check_expected_reads`). - report quality — Not measured anywhere in this project, by any figure in this artifact. Two tasks score retrieval in place of report quality: grading a multi-part prose report needs a judge model, which this project forbids, so their assertions check that the turn read the records the answer requires and nothing checks what the turn then wrote. A turn that reads exactly the right records and then reports them incompletely, or wrongly, still satisfies those assertions and still counts toward `mean_correctness`. The `lookup` tasks' positive signal is retrieval on the same terms, and for two of the four it is weaker still: their `expected_reads` entry carries a null `target_id`, so the satisfied assertion evidences only that the named whole-book tool was called at all, not that any particular record was read. The narrowing was authorised deliberately and each narrowed task's own `notes` in golden_tasks.yaml restate the superseded reasoning at length. The tasks narrowed to retrieval are: `gt-04-investigation-turn-budget-partial`, `gt-05-investigation-large-tool-result`. - retrieval narrowing — A task narrowed to retrieval names the specific retrieval its assertions check, and names only the retrievals that expose an observable target id. A turn that answers such a task by an equally apt retrieval which exposes no target id therefore satisfies none of that task's positive assertions, for a reason unrelated to what the model did. The deduction that conservatism makes to `mean_correctness` is quantified per arm with that arm's aggregate figures, as an upper bound derived from the arm's own per-task records, so a reader of this artifact alone can size it against the figures it appears beside. -- Retrieval-narrowing magnitude: the largest deduction any one arm's retrieval-narrowed tasks account for is 0.000000 of that arm's `mean_correctness`, which is smaller than the largest absolute difference between any two arms' `mean_correctness` in this sweep (0.013333). Which arm sits on which side of that difference is deliberately not computed or stated anywhere in this artifact; the comparison is published because a disclosed measurement conservatism of this size bounds how much the difference between arms can be read as a property of the models (src/eval/golden_tasks.yaml). +- Retrieval-narrowing magnitude: the largest deduction any one arm's retrieval-narrowed tasks account for is 0.000000 of that arm's `mean_correctness`, which is smaller than the largest absolute difference between any two arms' `mean_correctness` in this sweep (0.023611). Which arm sits on which side of that difference is deliberately not computed or stated anywhere in this artifact; the comparison is published because a disclosed measurement conservatism of this size bounds how much the difference between arms can be read as a property of the models (src/eval/golden_tasks.yaml). - `effort` (provenance) — The reasoning-effort string sent to each arm's supervisor tier, pinned identically across arms so the sweep is reproducible; the subagent and tool tiers run their config/models.yaml tier effort. It is not a claim that the arms were given equivalent reasoning budgets: each family declares its own effort scale with its own rung count and its own default, so an identical label sits at a different position on each family's scale. The declared scales, and this non-equivalence, are recorded in config/model_capabilities.yaml under `effort_scale_comparability.compared_models`, per tier. Sweeps recorded before tier efforts were configured ran the subagent and tool tiers at each model's own default effort (the Anthropic subagent at `high`), so their subagent and tool tiers are not effort-comparable with this artifact's. - `long_context_invocation_count` — counts the model invocations priced at the invoked model's long-context rates, i.e. a call whose prompt (input plus cache-read plus cache-write tokens) exceeded the model's long-context threshold in config/pricing.yaml; such a call's every token class is priced at those rates. It is a count of calls, not of tokens, and a model with no long-context tier never contributes. A run recorded before the count existed shows —, never 0. - arm totals — an arm's Usage and Cost (model_metrics) covers only the supervisor-tier calls to the arm's model; the arm totals (the arm cost and arm_long_context_invocation_count) cover every call the arm made at every tier, so the arm cost equals the sum of the three tiers' costs. @@ -103,14 +112,15 @@ Each figure below names one narrow measured signal. Its boundary is stated here | field | value | | --- | --- | | mode | live | -| timestamp | 2026-11-10T20:18:32.528771+00:00 | +| timestamp | 2026-11-15T20:29:19.713862+00:00 | | model_id | anthropic.claude-sonnet-5-5 | | effort | medium | | dataset_seed | 20260101 | | runtime_identifier | live-aws-lambda-dispatch | | price_table_version | 1.3.0 | | answer_style_sha256 | 953efa6d0d26da1fb09cf2cdf625c78f0bd8f7d04da7652e581e623edea67f47 | -| prompt_bundle_sha256 | 2959cde8d2bde46cfdf198614a890110d40d4753501f6151fb49f59285e3cec1 | +| prompt_bundle_sha256 | aaea4152ed4a88dd997bbce0211ebc998f61d01c363faed83cda3aee6194ba7e | +| prompt_caching | explicit: cache_control {type: ephemeral} (5-minute TTL) on the last stable system block and on the last content block of the latest message, at most 4 points, each omitted when its cumulative prefix is below prompt_cache_min_checkpoint_tokens; beside the platform's implicit caching, which no request field turns off | ### Usage and Cost @@ -119,84 +129,77 @@ Supervisor tier only: these figures cover the arm's supervisor-tier calls to ant | field | value | | --- | --- | | model_id | anthropic.claude-sonnet-5-5 | -| included_invocation_count | 273 | +| included_invocation_count | 290 | | long_context_invocation_count | 0 | -| input_tokens | 350986 | -| output_tokens | 47818 | -| cache_write_tokens | 4375 | -| cache_read_tokens | 1190000 | +| input_tokens | 820 | +| output_tokens | 71463 | +| cache_write_tokens | 666267 | +| cache_read_tokens | 1815158 | | cache_min_checkpoint_tokens | 512 | | latency_measured | yes | | latency_percentile_method | nearest-rank | -| task_latency_ms_p50 | 7596.169667 | -| task_latency_ms_p95 | 24924.877333 | +| task_latency_ms_p50 | 8620.837667 | +| task_latency_ms_p95 | 22294.123375 | | cost_withheld_provisional | no | -| cost_input | 0.701972 | -| cost_output | 0.478180 | -| cost_cache_write | 0.010938 | -| cost_cache_read | 0.119000 | -| cost_excluding_cache | 1.180152 | -| cost_cache_total | 0.129938 | -| cost_total | 1.310090 | +| cost_input | 0.001640 | +| cost_output | 0.714630 | +| cost_cache_write | 1.665668 | +| cost_cache_read | 0.181516 | +| cost_excluding_cache | 0.716270 | +| cost_cache_total | 1.847183 | +| cost_total | 2.563453 | | price_table_version | 1.3.0 | All tiers (every call the arm made): | field | value | | --- | --- | -| arm_cost_total | 2.914799 | +| arm_cost_total | 3.124988 | | arm_long_context_invocation_count | 0 | -Usage and cost for this arm are a lower bound: in 5 task run(s) (gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial) a model call ended before reporting token usage, so its tokens and cost are not counted in the figures above. - Call latency by tier (ms): | tier | p50 | p95 | count | | --- | --- | --- | --- | -| supervisor | 1803.318791 | 4399.364166 | 273 | -| subagent | 2267.182459 | 7086.334042 | 128 | -| tool | 1576.261125 | 2854.407583 | 240 | +| supervisor | 1731.026416 | 7774.722125 | 290 | +| subagent | 1944.460500 | 3631.187791 | 105 | +| tool | 1881.982583 | 2646.677500 | 67 | Per tier / role / model: | tier | role | model_id | included_invocation_count | long_context_invocation_count | input_tokens | output_tokens | cache_read_tokens | cache_write_tokens | call_latency_measured | call_latency_ms_p50 | call_latency_ms_p95 | cost_withheld_provisional | cost_input | cost_output | cost_cache_read | cost_cache_write | cost_excluding_cache | cost_cache_total | cost_total | price_table_version | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| subagent | mutation | anthropic.claude-sonnet-5-5 | 105 | 0 | 94965 | 23596 | 674544 | 6486 | yes | 2150.364500 | 4162.445542 | no | 0.189930 | 0.235960 | 0.067454 | 0.016215 | 0.425890 | 0.083669 | 0.509559 | 1.3.0 | -| subagent | research | anthropic.claude-sonnet-5-5 | 23 | 0 | 437334 | 17898 | 46904 | 2132 | yes | 5047.587833 | 11582.232958 | no | 0.874668 | 0.178980 | 0.004690 | 0.005330 | 1.053648 | 0.010020 | 1.063668 | 1.3.0 | -| supervisor | supervisor | anthropic.claude-sonnet-5-5 | 273 | 0 | 350986 | 47818 | 1190000 | 4375 | yes | 1803.318791 | 4399.364166 | no | 0.701972 | 0.478180 | 0.119000 | 0.010938 | 1.180152 | 0.129937 | 1.310090 | 1.3.0 | -| tool | mutation | anthropic.claude-haiku-5-5 | 62 | 0 | 58185 | 15131 | 0 | 0 | yes | 1906.717834 | 2801.624333 | no | 0.005818 | 0.007565 | 0.000000 | 0.000000 | 0.013384 | 0.000000 | 0.013384 | 1.3.0 | -| tool | research | anthropic.claude-haiku-5-5 | 178 | 0 | 101064 | 15982 | 0 | 0 | yes | 1518.533375 | 2929.801709 | no | 0.010106 | 0.007991 | 0.000000 | 0.000000 | 0.018097 | 0.000000 | 0.018097 | 1.3.0 | +| subagent | mutation | anthropic.claude-sonnet-5-5 | 105 | 0 | 310 | 24997 | 691126 | 90299 | yes | 1944.460500 | 3631.187791 | no | 0.000620 | 0.249970 | 0.069113 | 0.225747 | 0.250590 | 0.294860 | 0.545450 | 1.3.0 | +| supervisor | supervisor | anthropic.claude-sonnet-5-5 | 290 | 0 | 820 | 71463 | 1815158 | 666267 | yes | 1731.026416 | 7774.722125 | no | 0.001640 | 0.714630 | 0.181516 | 1.665668 | 0.716270 | 1.847183 | 2.563453 | 1.3.0 | +| tool | mutation | anthropic.claude-haiku-5-5 | 67 | 0 | 268 | 16394 | 0 | 62890 | yes | 1881.982583 | 2646.677500 | no | 0.000027 | 0.008197 | 0.000000 | 0.007861 | 0.008224 | 0.007861 | 0.016085 | 1.3.0 | Per-tier summary: | tier | input_tokens | output_tokens | cost | latency_p50_ms | latency_p95_ms | success (met/applicable) | success_rate | | --- | --- | --- | --- | --- | --- | --- | --- | -| supervisor | 350986 | 47818 | 1.310090 | 1803.318791 | 4399.364166 | 113/120 | 0.941667 | -| subagent | 532299 | 41494 | 1.573228 | 2267.182459 | 7086.334042 | 115/115 | 1.000000 | -| tool | 159249 | 31113 | 0.031481 | 1576.261125 | 2854.407583 | 95/95 | 1.000000 | +| supervisor | 820 | 71463 | 2.563453 | 1731.026416 | 7774.722125 | 108/120 | 0.900000 | +| subagent | 310 | 24997 | 0.545450 | 1944.460500 | 3631.187791 | 115/115 | 1.000000 | +| tool | 268 | 16394 | 0.016085 | 1881.982583 | 2646.677500 | 95/95 | 1.000000 | Per tool: | tool_name | role | count | call_latency_ms_p50 | call_latency_ms_p95 | truncated_count | outcome_data | outcome_no_match | outcome_denied | outcome_tool_failure | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| create_note | mutation | 10 | 350.102125 | 1911.414917 | 0 | 10 | 0 | 0 | 0 | -| get_account | research | 16 | 268.130375 | 295.391167 | 0 | 16 | 0 | 0 | 0 | -| get_account | supervisor | 20 | 287.268959 | 388.594375 | 0 | 20 | 0 | 0 | 0 | -| get_contact | supervisor | 23 | 258.644000 | 368.531209 | 0 | 23 | 0 | 0 | 0 | -| get_opportunity | research | 158 | 309.076709 | 369.213583 | 0 | 158 | 0 | 0 | 0 | -| get_opportunity | supervisor | 46 | 305.912291 | 359.309000 | 0 | 36 | 5 | 5 | 0 | -| list_activities | supervisor | 10 | 2.323250 | 2217.895625 | 0 | 5 | 0 | 0 | 5 | -| list_proposals | supervisor | 5 | 1999.800167 | 2408.586416 | 0 | 5 | 0 | 0 | 0 | -| log_activity | mutation | 10 | 339.626333 | 2101.602416 | 0 | 10 | 0 | 0 | 0 | -| pipeline_aggregate | supervisor | 5 | 2268.992584 | 2705.675875 | 0 | 5 | 0 | 0 | 0 | -| search_accounts | supervisor | 5 | 2101.000834 | 2280.018000 | 0 | 5 | 0 | 0 | 0 | -| search_opportunities | research | 4 | 277.645875 | 2031.635792 | 0 | 4 | 0 | 0 | 0 | -| search_opportunities | supervisor | 16 | 136.441084 | 299.789042 | 0 | 6 | 0 | 10 | 0 | -| submit_proposal | mutation | 32 | 308.653708 | 436.228375 | 0 | 32 | 0 | 0 | 0 | -| update_account | mutation | 5 | 2057.290125 | 2071.808959 | 0 | 5 | 0 | 0 | 0 | -| update_contact | mutation | 5 | 1987.479208 | 2078.091875 | 0 | 5 | 0 | 0 | 0 | - -Excluded invocations: 0 total (cold_start: 0, retry: 0, throttle: 0) +| create_note | mutation | 10 | 310.324792 | 1967.516375 | 0 | 10 | 0 | 0 | 0 | +| get_account | supervisor | 20 | 268.871292 | 1149.386333 | 0 | 20 | 0 | 0 | 0 | +| get_contact | supervisor | 25 | 258.061959 | 676.306125 | 0 | 25 | 0 | 0 | 0 | +| get_opportunity | supervisor | 77 | 302.917583 | 427.858708 | 15 | 67 | 5 | 5 | 0 | +| list_activities | supervisor | 33 | 302.513708 | 456.217166 | 5 | 28 | 0 | 0 | 5 | +| list_proposals | supervisor | 5 | 342.898417 | 1900.332709 | 0 | 5 | 0 | 0 | 0 | +| log_activity | mutation | 10 | 316.870667 | 2107.360917 | 0 | 10 | 0 | 0 | 0 | +| pipeline_aggregate | supervisor | 5 | 582.885750 | 2305.109209 | 0 | 5 | 0 | 0 | 0 | +| search_accounts | supervisor | 5 | 366.768709 | 1969.900708 | 0 | 5 | 0 | 0 | 0 | +| search_opportunities | supervisor | 20 | 246.852084 | 289.532708 | 0 | 10 | 0 | 10 | 0 | +| submit_proposal | mutation | 37 | 307.957333 | 466.227083 | 0 | 37 | 0 | 0 | 0 | +| update_account | mutation | 5 | 346.125333 | 2167.570500 | 0 | 5 | 0 | 0 | 0 | +| update_contact | mutation | 5 | 308.749166 | 1979.124666 | 0 | 5 | 0 | 0 | 0 | + +Excluded invocations: 1 total (cold_start: 0, retry: 1, throttle: 0) ### Aggregate Score @@ -204,13 +207,13 @@ Excluded invocations: 0 total (cold_start: 0, retry: 0, throttle: 0) | --- | --- | | scored_task_count | 120 | | unscored_task_count | 0 | -| mean_correctness | 0.984167 | +| mean_correctness | 0.975463 | | bad_write_rate | 0.000000 | | tool_call_correct_rate | 1.000000 | -`bad_write_rate` basis: all 250 declared `must_not_change` assertion(s) in this arm had a captured pre-turn baseline, so the figure is a measurement over them (src/eval/matrix.py). +`bad_write_rate` basis: all 255 declared `must_not_change` assertion(s) in this arm had a captured pre-turn baseline, so the figure is a measurement over them (src/eval/matrix.py). -`mean_correctness` composition: negative guards a do-nothing turn satisfies are 0.8161 of the assertion mass this figure averages — the mean over the 120 scored tasks of each task's own guard share, weighted exactly as `mean_correctness` itself is, rather than the ratio pooled over assertions (pooled totals, for context and not the basis of the figure just quoted: 682 guard assertions and 145 positive ones across those tasks). So the figure is not a task-achievement rate. Taken alone, 140 of 145 positive assertions were satisfied (0.9655); the guards alone were satisfied at 0.9795 (src/eval/matrix.py). +`mean_correctness` composition: negative guards a do-nothing turn satisfies are 0.8153 of the assertion mass this figure averages — the mean over the 120 scored tasks of each task's own guard share, weighted exactly as `mean_correctness` itself is, rather than the ratio pooled over assertions (pooled totals, for context and not the basis of the figure just quoted: 692 guard assertions and 150 positive ones across those tasks). So the figure is not a task-achievement rate. Taken alone, 143 of 150 positive assertions were satisfied (0.9533); the guards alone were satisfied at 0.9682 (src/eval/matrix.py). Retrieval-narrowed task deduction: the assertions this arm did not satisfy on the tasks narrowed to retrieval account for at most 0.000000 of its `mean_correctness` (`gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000), an upper bound over the 120 scored tasks derived from this arm's own per-task records. The figure itself is unchanged by this disclosure (src/eval/golden_tasks.yaml). @@ -218,15 +221,15 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | task_id | scoring_mode | correctness | unscored_reason | bad_write | tool_call_correct | truncated | budget_exhausted | | --- | --- | --- | --- | --- | --- | --- | --- | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | -| gt-09-enrichment-value-and-close-date-proposal | machine | 1.000000 | — | no | yes | no | no | +| gt-09-enrichment-value-and-close-date-proposal | machine | 0.800000 | — | no | yes | no | no | | gt-10-enrichment-update-account-fields | machine | 1.000000 | — | no | yes | no | no | | gt-11-denial-out-of-book-target | machine | 1.000000 | — | no | yes | no | no | | gt-12-denial-nonexistent-target | machine | 1.000000 | — | no | yes | no | no | @@ -234,7 +237,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -242,11 +245,11 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | @@ -258,7 +261,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -266,11 +269,11 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | -| gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | +| gt-02-investigation-pd02-stale-forecast | machine | 0.777778 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | @@ -282,7 +285,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -290,15 +293,15 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | -| gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | +| gt-02-investigation-pd02-stale-forecast | machine | 0.777778 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | -| gt-09-enrichment-value-and-close-date-proposal | machine | 1.000000 | — | no | yes | no | no | +| gt-09-enrichment-value-and-close-date-proposal | machine | 0.800000 | — | no | yes | no | no | | gt-10-enrichment-update-account-fields | machine | 1.000000 | — | no | yes | no | no | | gt-11-denial-out-of-book-target | machine | 1.000000 | — | no | yes | no | no | | gt-12-denial-nonexistent-target | machine | 1.000000 | — | no | yes | no | no | @@ -306,7 +309,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -314,15 +317,15 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | -| gt-09-enrichment-value-and-close-date-proposal | machine | 1.000000 | — | no | yes | no | no | +| gt-09-enrichment-value-and-close-date-proposal | machine | 0.800000 | — | no | yes | no | no | | gt-10-enrichment-update-account-fields | machine | 1.000000 | — | no | yes | no | no | | gt-11-denial-out-of-book-target | machine | 1.000000 | — | no | yes | no | no | | gt-12-denial-nonexistent-target | machine | 1.000000 | — | no | yes | no | no | @@ -330,7 +333,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -344,14 +347,14 @@ Per-task correctness spread across repeats: | task_id | repeats | correctness_min | correctness_mean | correctness_max | success_fraction | | --- | --- | --- | --- | --- | --- | | gt-01-investigation-pd01-successor | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | -| gt-02-investigation-pd02-stale-forecast | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | +| gt-02-investigation-pd02-stale-forecast | 5 | 0.777778 | 0.911111 | 1.000000 | 0.600000 | | gt-03-investigation-pd03-scoped-lookup | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-04-investigation-turn-budget-partial | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-05-investigation-large-tool-result | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-06-enrichment-create-note | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-07-enrichment-log-activity-last-touch | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-08-enrichment-stage-advance-proposal | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | -| gt-09-enrichment-value-and-close-date-proposal | 5 | 0.800000 | 0.920000 | 1.000000 | 0.600000 | +| gt-09-enrichment-value-and-close-date-proposal | 5 | 0.800000 | 0.800000 | 0.800000 | 0.000000 | | gt-10-enrichment-update-account-fields | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-11-denial-out-of-book-target | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-12-denial-nonexistent-target | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | @@ -375,14 +378,15 @@ Per-task correctness spread across repeats: | field | value | | --- | --- | | mode | live | -| timestamp | 2026-11-10T20:40:59.870904+00:00 | +| timestamp | 2026-11-15T20:50:38.391703+00:00 | | model_id | openai.gpt-6.1-sol | | effort | medium | | dataset_seed | 20260101 | | runtime_identifier | live-aws-lambda-dispatch | | price_table_version | 1.3.0 | | answer_style_sha256 | 953efa6d0d26da1fb09cf2cdf625c78f0bd8f7d04da7652e581e623edea67f47 | -| prompt_bundle_sha256 | 2959cde8d2bde46cfdf198614a890110d40d4753501f6151fb49f59285e3cec1 | +| prompt_bundle_sha256 | aaea4152ed4a88dd997bbce0211ebc998f61d01c363faed83cda3aee6194ba7e | +| prompt_caching | explicit: prompt_cache_breakpoint {mode: explicit} on the last stable system input_text block, beside implicit caching (prompt_cache_options {mode: implicit, ttl: 30m}, an automatic breakpoint on the latest message); minimum prefix from prompt_cache_min_checkpoint_tokens | ### Usage and Cost @@ -391,92 +395,88 @@ Supervisor tier only: these figures cover the arm's supervisor-tier calls to ope | field | value | | --- | --- | | model_id | openai.gpt-6.1-sol | -| included_invocation_count | 242 | +| included_invocation_count | 268 | | long_context_invocation_count | 0 | -| input_tokens | 727458 | -| output_tokens | 23719 | -| cache_write_tokens | 143097 | -| cache_read_tokens | 583877 | +| input_tokens | 1579162 | +| output_tokens | 39285 | +| cache_write_tokens | 491794 | +| cache_read_tokens | 1086832 | | cache_min_checkpoint_tokens | 1024 | | latency_measured | yes | | latency_percentile_method | nearest-rank | -| task_latency_ms_p50 | 7513.681541 | -| task_latency_ms_p95 | 29048.906041 | +| task_latency_ms_p50 | 6716.815625 | +| task_latency_ms_p95 | 36927.114417 | | cost_withheld_provisional | no | -| cost_input | 0.000968 | -| cost_output | 0.237190 | -| cost_cache_write | 0.357743 | -| cost_cache_read | 0.058388 | -| cost_excluding_cache | 0.238158 | -| cost_cache_total | 0.416130 | -| cost_total | 0.654288 | +| cost_input | 0.001072 | +| cost_output | 0.392850 | +| cost_cache_write | 1.229485 | +| cost_cache_read | 0.108683 | +| cost_excluding_cache | 0.393922 | +| cost_cache_total | 1.338168 | +| cost_total | 1.732090 | | price_table_version | 1.3.0 | All tiers (every call the arm made): | field | value | | --- | --- | -| arm_cost_total | 1.536942 | +| arm_cost_total | 2.591384 | | arm_long_context_invocation_count | 0 | -Usage and cost for this arm are a lower bound: in 5 task run(s) (gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial, gt-04-investigation-turn-budget-partial) a model call ended before reporting token usage, so its tokens and cost are not counted in the figures above. - Call latency by tier (ms): | tier | p50 | p95 | count | | --- | --- | --- | --- | -| supervisor | 2064.151709 | 3983.399916 | 242 | -| subagent | 1081.820291 | 3070.852542 | 195 | -| tool | 724.084167 | 1479.331417 | 336 | +| supervisor | 1829.730625 | 5089.577459 | 268 | +| subagent | 1163.972458 | 3181.016541 | 193 | +| tool | 620.995708 | 1462.112541 | 194 | Per tier / role / model: | tier | role | model_id | included_invocation_count | long_context_invocation_count | input_tokens | output_tokens | cache_read_tokens | cache_write_tokens | call_latency_measured | call_latency_ms_p50 | call_latency_ms_p95 | cost_withheld_provisional | cost_input | cost_output | cost_cache_read | cost_cache_write | cost_excluding_cache | cost_cache_total | cost_total | price_table_version | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| subagent | analytics | openai.gpt-6.1-terra | 10 | 0 | 21757 | 1174 | 5366 | 16371 | yes | 1081.820291 | 1867.854583 | no | 0.000020 | 0.005870 | 0.000268 | 0.020464 | 0.005890 | 0.020732 | 0.026622 | 1.3.0 | -| subagent | mutation | openai.gpt-6.1-terra | 135 | 0 | 543002 | 11611 | 468729 | 74003 | yes | 964.570000 | 1789.223250 | no | 0.000270 | 0.058055 | 0.023436 | 0.092504 | 0.058325 | 0.115940 | 0.174265 | 1.3.0 | -| subagent | research | openai.gpt-6.1-terra | 50 | 0 | 1308952 | 16332 | 877929 | 430923 | yes | 1371.243291 | 7899.265125 | no | 0.000100 | 0.081660 | 0.043896 | 0.538654 | 0.081760 | 0.582550 | 0.664310 | 1.3.0 | -| supervisor | supervisor | openai.gpt-6.1-sol | 242 | 0 | 727458 | 23719 | 583877 | 143097 | yes | 2064.151709 | 3983.399916 | no | 0.000968 | 0.237190 | 0.058388 | 0.357743 | 0.238158 | 0.416130 | 0.654288 | 1.3.0 | -| tool | analytics | openai.gpt-6-luna | 10 | 0 | 3270 | 490 | 0 | 0 | yes | 694.980750 | 1042.591792 | no | 0.000327 | 0.000245 | 0.000000 | 0.000000 | 0.000572 | 0.000000 | 0.000572 | 1.3.0 | -| tool | mutation | openai.gpt-6-luna | 80 | 0 | 26761 | 7867 | 0 | 0 | yes | 969.241042 | 1678.421334 | no | 0.002676 | 0.003934 | 0.000000 | 0.000000 | 0.006610 | 0.000000 | 0.006610 | 1.3.0 | -| tool | research | openai.gpt-6-luna | 246 | 0 | 42213 | 12106 | 0 | 0 | yes | 699.093875 | 1096.752833 | no | 0.004221 | 0.006053 | 0.000000 | 0.000000 | 0.010274 | 0.000000 | 0.010274 | 1.3.0 | +| subagent | analytics | openai.gpt-6.1-terra | 10 | 0 | 22008 | 1188 | 5384 | 16604 | yes | 1107.749625 | 1588.076166 | no | 0.000020 | 0.005940 | 0.000269 | 0.020755 | 0.005960 | 0.021024 | 0.026984 | 1.3.0 | +| subagent | mutation | openai.gpt-6.1-terra | 131 | 0 | 540278 | 11252 | 457720 | 82296 | yes | 1032.143500 | 1920.101292 | no | 0.000262 | 0.056260 | 0.022886 | 0.102870 | 0.056522 | 0.125756 | 0.182278 | 1.3.0 | +| subagent | research | openai.gpt-6.1-terra | 52 | 0 | 1035363 | 15755 | 613564 | 421695 | yes | 1506.506541 | 4705.513250 | no | 0.000104 | 0.078775 | 0.030678 | 0.527119 | 0.078879 | 0.557797 | 0.636676 | 1.3.0 | +| supervisor | supervisor | openai.gpt-6.1-sol | 268 | 0 | 1579162 | 39285 | 1086832 | 491794 | yes | 1829.730625 | 5089.577459 | no | 0.001072 | 0.392850 | 0.108683 | 1.229485 | 0.393922 | 1.338168 | 1.732090 | 1.3.0 | +| tool | analytics | openai.gpt-6-luna | 10 | 0 | 3280 | 500 | 0 | 0 | yes | 609.184542 | 925.784292 | no | 0.000328 | 0.000250 | 0.000000 | 0.000000 | 0.000578 | 0.000000 | 0.000578 | 1.3.0 | +| tool | mutation | openai.gpt-6-luna | 78 | 0 | 25823 | 7697 | 0 | 0 | yes | 794.333375 | 1346.836916 | no | 0.002582 | 0.003848 | 0.000000 | 0.000000 | 0.006431 | 0.000000 | 0.006431 | 1.3.0 | +| tool | research | openai.gpt-6-luna | 106 | 0 | 23202 | 8053 | 0 | 0 | yes | 593.677375 | 2147.219084 | no | 0.002320 | 0.004027 | 0.000000 | 0.000000 | 0.006347 | 0.000000 | 0.006347 | 1.3.0 | Per-tier summary: | tier | input_tokens | output_tokens | cost | latency_p50_ms | latency_p95_ms | success (met/applicable) | success_rate | | --- | --- | --- | --- | --- | --- | --- | --- | -| supervisor | 727458 | 23719 | 0.654288 | 2064.151709 | 3983.399916 | 119/120 | 0.991667 | -| subagent | 1873711 | 29117 | 0.865197 | 1081.820291 | 3070.852542 | 115/115 | 1.000000 | -| tool | 72244 | 20463 | 0.017456 | 724.084167 | 1479.331417 | 95/95 | 1.000000 | +| supervisor | 1579162 | 39285 | 1.732090 | 1829.730625 | 5089.577459 | 119/120 | 0.991667 | +| subagent | 1597649 | 28195 | 0.845938 | 1163.972458 | 3181.016541 | 114/115 | 0.991304 | +| tool | 52305 | 16250 | 0.013356 | 620.995708 | 1462.112541 | 94/95 | 0.989474 | Per tool: | tool_name | role | count | call_latency_ms_p50 | call_latency_ms_p95 | truncated_count | outcome_data | outcome_no_match | outcome_denied | outcome_tool_failure | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| create_note | mutation | 10 | 323.062041 | 394.156750 | 0 | 10 | 0 | 0 | 0 | -| get_account | mutation | 10 | 274.082500 | 389.635750 | 0 | 10 | 0 | 0 | 0 | -| get_account | research | 10 | 267.483959 | 292.097791 | 0 | 10 | 0 | 0 | 0 | -| get_account | supervisor | 5 | 296.824750 | 320.795250 | 0 | 5 | 0 | 0 | 0 | -| get_contact | research | 26 | 247.368958 | 294.216417 | 0 | 26 | 0 | 0 | 0 | -| get_contact | supervisor | 5 | 250.503333 | 273.101208 | 0 | 5 | 0 | 0 | 0 | -| get_opportunity | mutation | 6 | 303.956875 | 395.329333 | 0 | 6 | 0 | 0 | 0 | -| get_opportunity | research | 196 | 312.354917 | 414.298959 | 0 | 196 | 0 | 0 | 0 | -| get_opportunity | supervisor | 25 | 305.323792 | 412.832458 | 0 | 15 | 5 | 5 | 0 | -| list_activities | research | 8 | 280.460500 | 511.758250 | 0 | 8 | 0 | 0 | 0 | -| list_activities | supervisor | 8 | 1.360375 | 306.790416 | 0 | 3 | 0 | 0 | 5 | -| list_audit_records | mutation | 2 | 252.085416 | 1976.990250 | 0 | 2 | 0 | 0 | 0 | -| list_audit_records | research | 1 | 1624.517250 | 1624.517250 | 0 | 1 | 0 | 0 | 0 | -| list_proposals | mutation | 1 | 278.802750 | 278.802750 | 0 | 1 | 0 | 0 | 0 | -| list_proposals | supervisor | 5 | 328.874916 | 411.687750 | 0 | 5 | 0 | 0 | 0 | -| log_activity | mutation | 10 | 336.799833 | 400.390917 | 0 | 10 | 0 | 0 | 0 | -| pipeline_aggregate | supervisor | 5 | 499.190875 | 552.098542 | 0 | 5 | 0 | 0 | 0 | -| search_accounts | mutation | 5 | 315.369167 | 1987.302333 | 0 | 5 | 0 | 0 | 0 | -| search_opportunities | analytics | 10 | 125.000666 | 284.981083 | 0 | 5 | 0 | 5 | 0 | -| search_opportunities | research | 5 | 278.005416 | 301.715834 | 0 | 5 | 0 | 0 | 0 | -| search_opportunities | supervisor | 5 | 120.459958 | 130.287458 | 0 | 0 | 0 | 5 | 0 | -| submit_proposal | mutation | 26 | 315.181833 | 352.988250 | 0 | 26 | 0 | 0 | 0 | -| update_account | mutation | 5 | 346.125458 | 2066.207083 | 0 | 5 | 0 | 0 | 0 | -| update_contact | mutation | 5 | 327.592000 | 1943.571542 | 0 | 5 | 0 | 0 | 0 | +| create_note | mutation | 10 | 302.428000 | 494.479000 | 0 | 10 | 0 | 0 | 0 | +| get_account | mutation | 10 | 265.506333 | 543.125542 | 0 | 10 | 0 | 0 | 0 | +| get_account | research | 10 | 266.027083 | 400.150750 | 0 | 10 | 0 | 0 | 0 | +| get_account | supervisor | 9 | 285.640417 | 2040.909209 | 0 | 9 | 0 | 0 | 0 | +| get_contact | mutation | 3 | 241.969708 | 345.087833 | 0 | 3 | 0 | 0 | 0 | +| get_contact | research | 23 | 245.550875 | 279.122250 | 0 | 23 | 0 | 0 | 0 | +| get_contact | supervisor | 20 | 240.077833 | 278.984000 | 0 | 20 | 0 | 0 | 0 | +| get_opportunity | mutation | 6 | 297.985000 | 399.172500 | 1 | 6 | 0 | 0 | 0 | +| get_opportunity | research | 45 | 303.546875 | 400.061709 | 10 | 45 | 0 | 0 | 0 | +| get_opportunity | supervisor | 31 | 302.345458 | 423.821875 | 10 | 21 | 5 | 5 | 0 | +| list_activities | research | 23 | 321.798875 | 425.401500 | 10 | 22 | 0 | 0 | 1 | +| list_activities | supervisor | 15 | 291.893333 | 482.857333 | 6 | 10 | 0 | 0 | 5 | +| list_proposals | supervisor | 6 | 320.169625 | 491.883416 | 0 | 6 | 0 | 0 | 0 | +| log_activity | mutation | 10 | 324.022500 | 481.500125 | 0 | 10 | 0 | 0 | 0 | +| pipeline_aggregate | supervisor | 5 | 472.878166 | 488.353833 | 0 | 5 | 0 | 0 | 0 | +| search_accounts | mutation | 5 | 288.172875 | 415.660791 | 0 | 5 | 0 | 0 | 0 | +| search_opportunities | analytics | 10 | 158.110166 | 297.919458 | 0 | 5 | 0 | 5 | 0 | +| search_opportunities | research | 5 | 273.246833 | 294.147833 | 0 | 5 | 0 | 0 | 0 | +| search_opportunities | supervisor | 5 | 103.697292 | 121.684792 | 0 | 0 | 0 | 5 | 0 | +| submit_proposal | mutation | 24 | 322.448083 | 428.097167 | 0 | 24 | 0 | 0 | 0 | +| update_account | mutation | 5 | 326.202875 | 465.208625 | 0 | 5 | 0 | 0 | 0 | +| update_contact | mutation | 5 | 319.517583 | 495.231125 | 0 | 5 | 0 | 0 | 0 | Excluded invocations: 0 total (cold_start: 0, retry: 0, throttle: 0) @@ -486,13 +486,13 @@ Excluded invocations: 0 total (cold_start: 0, retry: 0, throttle: 0) | --- | --- | | scored_task_count | 120 | | unscored_task_count | 0 | -| mean_correctness | 0.997500 | +| mean_correctness | 0.999074 | | bad_write_rate | 0.000000 | | tool_call_correct_rate | 1.000000 | -`bad_write_rate` basis: all 250 declared `must_not_change` assertion(s) in this arm had a captured pre-turn baseline, so the figure is a measurement over them (src/eval/matrix.py). +`bad_write_rate` basis: all 255 declared `must_not_change` assertion(s) in this arm had a captured pre-turn baseline, so the figure is a measurement over them (src/eval/matrix.py). -`mean_correctness` composition: negative guards a do-nothing turn satisfies are 0.8155 of the assertion mass this figure averages — the mean over the 120 scored tasks of each task's own guard share, weighted exactly as `mean_correctness` itself is, rather than the ratio pooled over assertions (pooled totals, for context and not the basis of the figure just quoted: 676 guard assertions and 145 positive ones across those tasks). So the figure is not a task-achievement rate. Taken alone, 144 of 145 positive assertions were satisfied (0.9931); the guards alone were satisfied at 0.9970 (src/eval/matrix.py). +`mean_correctness` composition: negative guards a do-nothing turn satisfies are 0.8141 of the assertion mass this figure averages — the mean over the 120 scored tasks of each task's own guard share, weighted exactly as `mean_correctness` itself is, rather than the ratio pooled over assertions (pooled totals, for context and not the basis of the figure just quoted: 679 guard assertions and 150 positive ones across those tasks). So the figure is not a task-achievement rate. Taken alone, 149 of 150 positive assertions were satisfied (0.9933); the guards alone were satisfied at 1.0000 (src/eval/matrix.py). Retrieval-narrowed task deduction: the assertions this arm did not satisfy on the tasks narrowed to retrieval account for at most 0.000000 of its `mean_correctness` (`gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000; `gt-04-investigation-turn-budget-partial` scored 1.000000, at most 0.000000; `gt-05-investigation-large-tool-result` scored 1.000000, at most 0.000000), an upper bound over the 120 scored tasks derived from this arm's own per-task records. The figure itself is unchanged by this disclosure (src/eval/golden_tasks.yaml). @@ -500,11 +500,11 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | task_id | scoring_mode | correctness | unscored_reason | bad_write | tool_call_correct | truncated | budget_exhausted | | --- | --- | --- | --- | --- | --- | --- | --- | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | @@ -516,7 +516,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -524,11 +524,11 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | @@ -540,19 +540,19 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | -| gt-21-enrichment-pd04-multi-field-proposal | machine | 0.700000 | — | no | yes | no | no | +| gt-21-enrichment-pd04-multi-field-proposal | machine | 1.000000 | — | no | yes | no | no | | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | @@ -564,7 +564,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -572,11 +572,11 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 0.888889 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | @@ -588,7 +588,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -596,11 +596,11 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-22-investigation-pd05-report-only | machine | 1.000000 | — | no | yes | no | no | | gt-23-investigation-pd06-ambiguous-contact | machine | 1.000000 | — | no | yes | no | no | | gt-24-enrichment-pd07-multi-step-write | machine | 1.000000 | — | no | yes | no | no | -| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | no | no | +| gt-01-investigation-pd01-successor | machine | 1.000000 | — | no | yes | yes | no | | gt-02-investigation-pd02-stale-forecast | machine | 1.000000 | — | no | yes | no | no | | gt-03-investigation-pd03-scoped-lookup | machine | 1.000000 | — | no | yes | no | no | -| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | no | yes | -| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | no | no | +| gt-04-investigation-turn-budget-partial | machine | 1.000000 | — | no | yes | yes | no | +| gt-05-investigation-large-tool-result | machine | 1.000000 | — | no | yes | yes | no | | gt-06-enrichment-create-note | machine | 1.000000 | — | no | yes | no | no | | gt-07-enrichment-log-activity-last-touch | machine | 1.000000 | — | no | yes | no | no | | gt-08-enrichment-stage-advance-proposal | machine | 1.000000 | — | no | yes | no | no | @@ -612,7 +612,7 @@ Retrieval-narrowed task deduction: the assertions this arm did not satisfy on th | gt-14-denial-departed-contact-update | machine | 1.000000 | — | no | yes | no | no | | gt-15-denial-service-principal-no-implicit-visibility | machine | 1.000000 | — | no | yes | no | no | | gt-16-denial-tool-failure-not-conflated | machine | 1.000000 | — | no | yes | no | no | -| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | no | no | +| gt-17-lookup-opportunity-detail | machine | 1.000000 | — | no | yes | yes | no | | gt-18-lookup-account-contacts | machine | 1.000000 | — | no | yes | no | no | | gt-19-lookup-pipeline-aggregate | machine | 1.000000 | — | no | yes | no | no | | gt-20-lookup-proposal-queue | machine | 1.000000 | — | no | yes | no | no | @@ -625,7 +625,7 @@ Per-task correctness spread across repeats: | task_id | repeats | correctness_min | correctness_mean | correctness_max | success_fraction | | --- | --- | --- | --- | --- | --- | -| gt-01-investigation-pd01-successor | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | +| gt-01-investigation-pd01-successor | 5 | 0.888889 | 0.977778 | 1.000000 | 0.800000 | | gt-02-investigation-pd02-stale-forecast | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-03-investigation-pd03-scoped-lookup | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-04-investigation-turn-budget-partial | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | @@ -645,7 +645,7 @@ Per-task correctness spread across repeats: | gt-18-lookup-account-contacts | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-19-lookup-pipeline-aggregate | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-20-lookup-proposal-queue | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | -| gt-21-enrichment-pd04-multi-field-proposal | 5 | 0.700000 | 0.940000 | 1.000000 | 0.800000 | +| gt-21-enrichment-pd04-multi-field-proposal | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-22-investigation-pd05-report-only | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-23-investigation-pd06-ambiguous-contact | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | | gt-24-enrichment-pd07-multi-step-write | 5 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | diff --git a/scripts/bootstrap_account.sh b/scripts/bootstrap_account.sh index a856e4e..4404fc8 100755 --- a/scripts/bootstrap_account.sh +++ b/scripts/bootstrap_account.sh @@ -102,8 +102,8 @@ fi [[ -n "$PROFILE" ]] || refuse "--profile is required; nothing was applied" [[ -n "$REGION" ]] || refuse "--region is required; nothing was applied" -PYTHON="${REPO_ROOT}/.venv/bin/python3" -[[ -x "$PYTHON" ]] || PYTHON="python3" +PYTHON="$("${SCRIPT_DIR}/repo_python.sh" --print)" \ + || refuse "no interpreter for the repository's Python scripts (see above); nothing was applied" REGION_CHECK_RC=0 REGION_CHECK_ERR="$("$PYTHON" scripts/region_map.py az-ids --region "$REGION" 2>&1 >/dev/null)" \ diff --git a/scripts/check_cost_withheld.py b/scripts/check_cost_withheld.py index d2869c4..d5d9d01 100755 --- a/scripts/check_cost_withheld.py +++ b/scripts/check_cost_withheld.py @@ -10,7 +10,8 @@ :func:`iter_published_artifacts`) plus ``README.md`` when ``--readme-file`` is supplied. In a structured artifact whose schema this repo generates (:data:`_ENUMERABLE_SCHEMA_RELPATHS`) a numeric field is a violation unless its key is a known non-currency field - (:data:`_NON_CURRENCY_NUMERIC_FIELDS`). Elsewhere the checks are currency-shape and known-key + (:data:`_NON_CURRENCY_NUMERIC_FIELDS`) or an entry of an id-keyed non-currency map + (:data:`_ID_KEYED_NON_CURRENCY_MAPS`). Elsewhere the checks are currency-shape and known-key detection (:data:`_CURRENCY_SHAPE_PATTERN`, :data:`_CURRENCY_FIELD_NAMES`). 2. The same, on the rendered eval dashboard source (``--frontend-dir``; :func:`find_currency_rendering_in_frontend`). @@ -430,12 +431,16 @@ def find_currency_figures_in_matrix_json(text: str, *, source: str) -> list[str] "unscored_task_count", "total_excluded", "dataset_seed", + "record_shape_version", # Token usage. "input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens", "cache_min_checkpoint_tokens", + "prompt_tokens", + "total_prompt_tokens", + "uncached_input_tokens", # Reliability counters. "cold_start", "retry", @@ -496,6 +501,7 @@ def find_currency_figures_in_matrix_json(text: str, *, source: str) -> list[str] "invocation_count", "task_count", "budget_exhausted_task_count", + "truncated_tool_call_count", "truncated_task_count", "none", *( @@ -511,20 +517,38 @@ def find_currency_figures_in_matrix_json(text: str, *, source: str) -> list[str] "latency_sample_count", "invocation_count", "input_tokens", + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", + "uncached_input_tokens", "output_tokens", ) ), - "summary_supervisor_budget_exhausted_task_count", + *( + f"summary_{tier}_{key}" + for tier in ("supervisor", "subagent", "tool") + for key in ( + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", + ) + ), *( f"summary_subagent_delegation_{kind}" for kind in ("data", "no_match", "denied", "tool_failure", "none") ), - "summary_tool_truncated_task_count", # Self-corrected retries. "retry_count", *(f"summary_{tier}_retry_count" for tier in ("supervisor", "subagent", "tool")), # Task completion over repeats: task counts, repeat count and rate. "completed", + # Pre-aggregation archive: per-call latency and cache tokens, per-task latencies, and the + # repeat a call or score belongs to. + "latency_ms", + "read_tokens", + "write_tokens", + "task_latencies_ms", + "repeat_index", *( f"{prefix}_{tier}_completion_over_repeats_{suffix}" for prefix in ("tier", "summary") @@ -534,6 +558,10 @@ def find_currency_figures_in_matrix_json(text: str, *, source: str) -> list[str] } ) +#: Maps keyed by an id (a task id) whose numeric entries are judged by the map's own name, since the +#: entry's key is data rather than a field name. +_ID_KEYED_NON_CURRENCY_MAPS: frozenset[str] = frozenset({"correctness_by_task"}) + def _numeric_field_violation( *, @@ -549,7 +577,8 @@ def _numeric_field_violation( A recognised cost name on ``key`` or on any of its ``ancestors`` (the enclosing JSON keys, outermost first) is reported as one, so a :data:`_NON_CURRENCY_NUMERIC_FIELDS` name exempts a value only outside every cost-bearing container. With ``invert_burden``, any other key not in - :data:`_NON_CURRENCY_NUMERIC_FIELDS` is reported as an unrecognised numeric field. + :data:`_NON_CURRENCY_NUMERIC_FIELDS`, and not an entry of an + :data:`_ID_KEYED_NON_CURRENCY_MAPS` map, is reported as an unrecognised numeric field. """ if _COST_BEARING_NAME_PATTERN.search(key) is not None: return ( @@ -566,6 +595,8 @@ def _numeric_field_violation( ) if not invert_burden or key in _NON_CURRENCY_NUMERIC_FIELDS: return None + if ancestors and ancestors[-1] in _ID_KEYED_NON_CURRENCY_MAPS: + return None return ( f"{source}: numeric field {path} ({value!r}) is not a known non-currency field, so it " f"cannot be published while the price table is provisional -- add it to " diff --git a/scripts/check_cost_withheld.sh b/scripts/check_cost_withheld.sh index a75d09b..6cc85ba 100755 --- a/scripts/check_cost_withheld.sh +++ b/scripts/check_cost_withheld.sh @@ -70,7 +70,7 @@ fi PYTHON_BIN="${REPO_ROOT}/.venv/bin/python" if [ ! -x "${PYTHON_BIN}" ]; then - PYTHON_BIN="python3" + PYTHON_BIN="$("${SCRIPT_DIR}/repo_python.sh" --print)" || exit 2 fi if ! command -v "${PYTHON_BIN}" >/dev/null 2>&1; then diff --git a/scripts/check_doc_figures.py b/scripts/check_doc_figures.py index af907b0..6103633 100644 --- a/scripts/check_doc_figures.py +++ b/scripts/check_doc_figures.py @@ -240,7 +240,7 @@ def _decode_embed(payload: str, is_base64: bool) -> str | None: text: str | None = base64.b64decode(urllib.parse.unquote(compact), validate=True).decode( "utf-8" ) - except (binascii.Error, ValueError): + except binascii.Error, ValueError: text = None if is_base64 else urllib.parse.unquote(compact) return text if text is not None and "<" in text else None diff --git a/scripts/check_emitted_css.py b/scripts/check_emitted_css.py index 82ae558..664e0e8 100644 --- a/scripts/check_emitted_css.py +++ b/scripts/check_emitted_css.py @@ -314,7 +314,7 @@ def build_stylesheet(content_globs: list[str] | None) -> str | None: timeout=300, check=False, ) - except (OSError, subprocess.TimeoutExpired): + except OSError, subprocess.TimeoutExpired: return None return result.stdout if result.returncode == 0 and result.stdout.strip() else None diff --git a/scripts/check_handler_grant_coverage.py b/scripts/check_handler_grant_coverage.py index fdd7f3f..6bb5152 100644 --- a/scripts/check_handler_grant_coverage.py +++ b/scripts/check_handler_grant_coverage.py @@ -103,6 +103,7 @@ def __post_init__(self) -> None: "get_item": StoreMethod(frozenset({"dynamodb:GetItem"})), "put_item": StoreMethod(frozenset({"dynamodb:PutItem"})), "put_if_absent": StoreMethod(frozenset({"dynamodb:PutItem"})), + "put_conditional": StoreMethod(frozenset({"dynamodb:PutItem"})), "update_item": StoreMethod(frozenset({"dynamodb:UpdateItem"})), "delete_item": StoreMethod(frozenset({"dynamodb:DeleteItem"})), # Re-reads the item at its own primary key before writing. diff --git a/scripts/check_lambda_zip_imports.py b/scripts/check_lambda_zip_imports.py index 7a19ade..fde0339 100644 --- a/scripts/check_lambda_zip_imports.py +++ b/scripts/check_lambda_zip_imports.py @@ -21,17 +21,17 @@ 2. ``vendored_record`` -- every file a vendored distribution's ``*.dist-info/RECORD`` lists is present in the zip. 3. ``wheel_platform`` -- every vendored wheel tag and compiled extension ABI tag targets the Lambda - platform (``manylinux``/``linux_x86_64``, CPython 3.13 or ``abi3``). + platform (``manylinux``/``linux_x86_64``, CPython 3.14 or ``abi3``). 4. ``marker_requires`` -- every vendored ``Requires-Dist`` whose environment marker holds for the Lambda environment (:data:`LAMBDA_MARKER_ENVIRONMENT`) names a distribution the zip carries or the runtime provides. 5. ``isolated_import`` -- import the handler module in a subprocess whose ``sys.path`` is the zip - plus a sandbox of the runtime-provided distributions, under a discovered CPython 3.13 when one - exists (``PYTHON313``, ``python3.13`` on ``PATH``, ``uv python find 3.13``, ``pyenv which - python3.13``) and otherwise under the build host's interpreter. The status suffix names which: - ``pass…_target_python313`` or ``pass…_host_python``. Compiled distributions that cannot load + plus a sandbox of the runtime-provided distributions, under a discovered CPython 3.14 when one + exists (``PYTHON314``, ``python3.14`` on ``PATH``, ``uv python find 3.14``, ``pyenv which + python3.14``) and otherwise under the build host's interpreter. The status suffix names which: + ``pass…_target_python314`` or ``pass…_host_python``. Compiled distributions that cannot load on the build host are substituted from ``infra/build/target-python-shadow`` at the zip's own - vendored version; ``target_python313`` names the interpreter version, never the platform. On a + vendored version; ``target_python314`` names the interpreter version, never the platform. On a build host that matches the Lambda platform the zip is extracted and imported from that directory, as the runtime does, so its own compiled extensions load. 6. ``source_parity`` -- every first-party module in the zip is byte-identical to the same path @@ -68,7 +68,7 @@ class vs git index working tree ``--print-missing-required-distributions DIR`` prints, one per line, the distributions the Lambda target environment requires that a pip ``--target`` directory does not contain; ``scripts/package_lambdas.sh`` loops on it to close its vendored set. ``--print-target-python`` -prints the discovered CPython 3.13. +prints the discovered CPython 3.14. Requires no AWS credential and makes no network call. """ @@ -117,7 +117,7 @@ class vs git index working tree #: `scripts/run_gates.py`'s `GATE_SKIP_EXIT_STATUS`. SKIP_EXIT_STATUS = 3 -#: Top-level modules the Lambda Python 3.13 runtime provides: boto3 and its dependency closure. +#: Top-level modules the Lambda Python 3.14 runtime provides: boto3 and its dependency closure. RUNTIME_PROVIDED_MODULES = frozenset( { "boto3", @@ -133,31 +133,32 @@ class vs git index working tree #: Top-level packages of this repository's own source; the closure walk recurses only through these. FIRST_PARTY_PACKAGES = frozenset({"crm", "gateway", "agents", "providers", "eval", "fixtures"}) -#: Wheel python tag and platform-tag prefixes the Lambda python3.13 x86_64 runtime can load. -TARGET_PYTHON_TAG = "cp313" +#: Wheel python tag and platform-tag prefixes the Lambda python3.14 x86_64 runtime can load. +TARGET_PYTHON_TAG = "cp314" TARGET_PLATFORM_PREFIXES = ("manylinux", "linux_x86_64", "linux_i686") #: The Lambda runtime's `(major, minor)` Python version. -TARGET_PYTHON_VERSION = (3, 13) +TARGET_PYTHON_VERSION = (3, 14) -#: PEP 508 environment of the Lambda python3.13 x86_64 runtime, used to evaluate ``Requires-Dist`` +#: PEP 508 environment of the Lambda python3.14 x86_64 runtime, used to evaluate ``Requires-Dist`` #: markers; ``extra`` is empty, so extras-only dependencies are not required. LAMBDA_MARKER_ENVIRONMENT: dict[str, str] = { "extra": "", "implementation_name": "cpython", - "implementation_version": "3.13.0", + "implementation_version": "3.14.0", "os_name": "posix", "platform_machine": "x86_64", "platform_python_implementation": "CPython", "platform_release": "", "platform_system": "Linux", "platform_version": "", - "python_full_version": "3.13.0", - "python_version": "3.13", + "python_full_version": "3.14.0", + "python_version": "3.14", "sys_platform": "linux", } -#: PEP 503 normalised distribution names the Lambda python3.13 runtime provides. +#: PEP 503 normalised distribution names the Lambda python3.14 runtime provides: boto3 and its +#: dependency closure, as measured in the AWS Lambda python3.14 base image. RUNTIME_PROVIDED_DISTRIBUTIONS = frozenset( { "boto3", @@ -165,7 +166,6 @@ class vs git index working tree "jmespath", "python-dateutil", "s3transfer", - "setuptools", "six", "urllib3", } @@ -648,7 +648,7 @@ def check_closure(spec: ZipSpec, index: ZipModuleIndex, result: ZipResult) -> No continue result.violations.append( f"module {module!r} (imported by {unresolved[module]!r}) is neither vendored in the " - "zip nor provided by the Lambda python3.13 runtime" + "zip nor provided by the Lambda python3.14 runtime" ) if result.allowed_unvendored: if allowance is None: @@ -740,8 +740,11 @@ def check_wheel_platforms(index: ZipModuleIndex, result: ZipResult) -> None: # abi3 / untagged extension: its platform is checked through its wheel's Tag: line. continue major_minor, abi_platform = match.groups() - if major_minor != "313": - result.violations.append(f"extension {member!r} targets CPython {major_minor}, not 313") + target_abi = "".join(str(part) for part in TARGET_PYTHON_VERSION) + if major_minor != target_abi: + result.violations.append( + f"extension {member!r} targets CPython {major_minor}, not {target_abi}" + ) if not any(abi_platform.startswith(p) for p in ("x86_64-linux", "linux")): result.violations.append( f"extension {member!r} targets platform {abi_platform!r}, not x86_64 Linux" @@ -749,7 +752,7 @@ def check_wheel_platforms(index: ZipModuleIndex, result: ZipResult) -> None: def _tag_targets_lambda(tag: str) -> bool: - """True when a wheel tag (``py3-none-any``, ``cp313-abi3-manylinux…``) can load on Lambda.""" + """True when a wheel tag (``py3-none-any``, ``cp314-abi3-manylinux…``) can load on Lambda.""" for single in tag.split("."): parts = single.split("-") if len(parts) != 3: @@ -872,7 +875,7 @@ def check_marker_required_distributions(index: ZipModuleIndex, result: ZipResult f"environment (python_version={LAMBDA_MARKER_ENVIRONMENT['python_version']}, " f"sys_platform={LAMBDA_MARKER_ENVIRONMENT['sys_platform']}, " f"platform_machine={LAMBDA_MARKER_ENVIRONMENT['platform_machine']}) but is neither " - "vendored in the zip nor provided by the Lambda python3.13 runtime" + "vendored in the zip nor provided by the Lambda python3.14 runtime" ) if not missing and not unparseable: result.marker_requirements_resolved = len(metadata) @@ -893,7 +896,7 @@ def check_marker_required_distributions(index: ZipModuleIndex, result: ZipResult #: Environment variable naming an interpreter for the ``isolated_import`` phase, tried first and #: validated like every other candidate. -TARGET_PYTHON_ENV_VAR = "PYTHON313" +TARGET_PYTHON_ENV_VAR = "PYTHON314" _TARGET_PROBE_PROGRAM = ( "import json, sys, sysconfig\n" @@ -921,7 +924,7 @@ def check_marker_required_distributions(index: ZipModuleIndex, result: ZipResult @dataclass(frozen=True) class TargetInterpreter: - """A validated CPython 3.13 the ``isolated_import`` phase can execute under.""" + """A validated CPython 3.14 the ``isolated_import`` phase can execute under.""" executable: str discovered_via: str @@ -957,7 +960,7 @@ def _run_capture(command: list[str], *, env: dict[str, str] | None = None) -> st completed = proc_run.run( command, capture_output=True, text=True, check=False, timeout=60, env=env ) - except (OSError, subprocess.SubprocessError): + except OSError, subprocess.SubprocessError: return None if completed.returncode != 0: return None @@ -988,7 +991,7 @@ def _probe_interpreter(executable: str) -> tuple[tuple[str, ...] | None, str]: probe = json.loads(raw) version = tuple(int(part) for part in probe["version"]) stdlib = tuple(str(part) for part in probe["stdlib"]) - except (KeyError, TypeError, ValueError): + except KeyError, TypeError, ValueError: return None, f"{executable} produced unreadable version output {raw!r}" if version != TARGET_PYTHON_VERSION: return None, ( @@ -1005,15 +1008,15 @@ def _discovery_candidates() -> list[tuple[str, str | None]]: """ return [ (f"env:{TARGET_PYTHON_ENV_VAR}", os.environ.get(TARGET_PYTHON_ENV_VAR) or None), - ("PATH:python3.13", shutil.which("python3.13")), - ("uv python find 3.13", _candidate_from_tool(["uv", "python", "find", "3.13"])), - ("pyenv which python3.13", _candidate_from_tool(["pyenv", "which", "python3.13"])), + ("PATH:python3.14", shutil.which("python3.14")), + ("uv python find 3.14", _candidate_from_tool(["uv", "python", "find", "3.14"])), + ("pyenv which python3.14", _candidate_from_tool(["pyenv", "which", "python3.14"])), ] @functools.cache def discover_target_interpreter() -> InterpreterDiscovery: - """Find a CPython 3.13 to run the ``isolated_import`` phase under, or report why none was found. + """Find a CPython 3.14 to run the ``isolated_import`` phase under, or report why none was found. The build host interpreter is accepted only when it is itself the target version; every candidate tried is recorded in `attempts`. @@ -1076,7 +1079,7 @@ def _resolve_in_interpreter( #: Verification-only directory `scripts/package_lambdas.sh` populates with the zips' pinned -#: distributions built for CPython 3.13 at the build host's platform; never packaged or deployed. +#: distributions built for CPython 3.14 at the build host's platform; never packaged or deployed. DEFAULT_TARGET_SHADOW_DIR = REPO_ROOT / "infra" / "build" / "target-python-shadow" @@ -1113,7 +1116,7 @@ def _shadow_supplies(shadow: Path, distributions: list[str]) -> str | None: def _annotate_pass(base: str, *, ran_on_target: bool) -> str: """Fold *which interpreter actually ran* into a passing ``isolated_import`` status. - Returns ``…_target_python313`` when it ran on the target version, ``…_host_python`` when it + Returns ``…_target_python314`` when it ran on the target version, ``…_host_python`` when it ran on a different host version, and the bare base otherwise. """ if ran_on_target: @@ -1178,7 +1181,7 @@ def _build_runtime_sandbox(directory: Path) -> list[str]: for name in sorted(RUNTIME_PROVIDED_MODULES): try: found = importlib.util.find_spec(name) - except (ImportError, ValueError): # pragma: no cover - defensive + except ImportError, ValueError: # pragma: no cover - defensive continue if found is None: continue @@ -1205,7 +1208,7 @@ def _resolve_host_native(top_levels: list[str]) -> tuple[tuple[str, str], ...] | for name in top_levels: try: found = importlib.util.find_spec(name) - except (ImportError, ValueError): + except ImportError, ValueError: return None if found is None: return None @@ -1329,7 +1332,7 @@ def check_isolated_import( The child's `sys.path` is an optional shadow of substituted compiled distributions, the zip, a sandbox of the runtime-provided distributions, and the standard library. The child runs under - the discovered CPython 3.13 when there is one and it can load any needed substitutes, and + the discovered CPython 3.14 when there is one and it can load any needed substitutes, and otherwise under the build host's interpreter. Substitutes come from :func:`target_shadow_dir` at the zip's vendored version on the target path, and from the build host's environment, unversioned, on the fallback; when the fallback has none either, the phase reports ``skip``. @@ -1388,7 +1391,7 @@ def check_isolated_import( ) attempt = None else: - declined_reason = "no CPython 3.13 was discoverable on this build host" + declined_reason = "no CPython 3.14 was discoverable on this build host" if attempt is None: host_shadow: tuple[tuple[str, str], ...] = () @@ -1456,7 +1459,7 @@ def check_isolated_import( result.isolated_import_status = IMPORT_FAIL result.violations.append( f"isolated import of {spec.module!r} from the zip failed under " - f"{'the target CPython 3.13' if attempt.ran_on_target else 'the build host interpreter'} " + f"{'the target CPython 3.14' if attempt.ran_on_target else 'the build host interpreter'} " f"(exit {attempt.completed.returncode}): {attempt.detail}" ) @@ -1816,7 +1819,7 @@ def _foreign_work_tree_reason(root: Path) -> str: named = fields[0] if not named or (len(fields) == 2 and not fields[1]): return "" - except (OSError, subprocess.SubprocessError): + except OSError, subprocess.SubprocessError: return "" return ( f"`git rev-parse --show-toplevel` names {named} as the work tree containing {root}, which is " @@ -2259,7 +2262,8 @@ def _run_level_note(report: dict[str, object]) -> str | None: if on_host: note += ( f" {len(on_host)}/{len(statuses)} zip(s) fell back to the build host's CPython " - f"{sys.version_info[0]}.{sys.version_info[1]} because that 3.13 has no importable " + f"{sys.version_info[0]}.{sys.version_info[1]} because that " + f"{TARGET_PYTHON_VERSION[0]}.{TARGET_PYTHON_VERSION[1]} has no importable " "substitute for their vendored compiled distribution(s); each says so in its own " "status and note, and for them the marker_requires phase remains the " "host-independent cover for that class." @@ -2280,7 +2284,7 @@ def _run_level_note(report: dict[str, object]) -> str | None: "host-independently, and every passing status carries " f"'_host_python{sys.version_info[0]}{sys.version_info[1]}' so this is never read as " f"target-verified. Candidate interpreters: {attempts_text or 'none tried'}. Set " - f"{TARGET_PYTHON_ENV_VAR}=/path/to/python3.13, or put python3.13 on PATH, to execute the " + f"{TARGET_PYTHON_ENV_VAR}=/path/to/python3.14, or put python3.14 on PATH, to execute the " "phase under the target version. The platform class is unexecuted either way: this host is " f"{sys.platform}/{platform.machine()}." ) diff --git a/scripts/check_no_untracked_refs.py b/scripts/check_no_untracked_refs.py index 1bd5147..ba306ae 100755 --- a/scripts/check_no_untracked_refs.py +++ b/scripts/check_no_untracked_refs.py @@ -241,7 +241,7 @@ def python_segments(text: str) -> list[tuple[int, str, str]]: try: tree = ast.parse(text) tokens = list(tokenize.generate_tokens(io.StringIO(text).readline)) - except (SyntaxError, tokenize.TokenError, ValueError): + except SyntaxError, tokenize.TokenError, ValueError: return hash_segments(text) docstrings: set[tuple[int, int]] = set() for node in ast.walk(tree): diff --git a/scripts/check_plan_security_baseline.py b/scripts/check_plan_security_baseline.py index 384b2dd..62ed19d 100644 --- a/scripts/check_plan_security_baseline.py +++ b/scripts/check_plan_security_baseline.py @@ -875,15 +875,20 @@ def check_dynamodb_no_wildcard_action(plan: Plan) -> list[Finding]: if "dynamodb_kms" not in r["address"] ] managed_modules = _managed_dynamodb_modules(plan) + history_policies = [ + r for r in plan.resource_changes if r.get("address") == RUNTIME_HISTORY_POLICY + ] findings.append( Finding( "dynamodb_no_wildcard_action", "(coverage) one grant document per dynamodb role policy", "pass" - if documents and len(documents) == len(role_policies) + len(managed_modules) + if documents + and len(documents) == len(role_policies) + len(managed_modules) + len(history_policies) else "fail", f"documents={len(documents)} inline dynamodb role policies={len(role_policies)} " - f"modules attaching it as managed policies={len(managed_modules)}; a " + f"modules attaching it as managed policies={len(managed_modules)} " + f"runtime history policies={len(history_policies)}; a " "mismatch means either a role policy renders from something this control does not read, " "or the documents were found while the policies were not -- in both directions the " "statements above are no longer a statement about every grant in the plan.", @@ -945,6 +950,154 @@ def _source_tool_grant_actions(function: str, table: str) -> list[str] | None: return [a for row in rows for a in re.findall(r'"([^"]+)"', row)] if rows else None +#: The AgentCore Runtime's conversation-history grant. It belongs to no `lambda_action` module and so +#: has no matrix row; `check_dynamodb_leading_keys_isolation` asserts it statement by statement. +RUNTIME_HISTORY_DOCUMENT = "data.aws_iam_policy_document.agentcore_runtime_history" +RUNTIME_HISTORY_POLICY = "aws_iam_role_policy.agentcore_runtime_history" +RUNTIME_HISTORY_ATTRIBUTES = ( + "expires_at", + "kind", + "owner_rep_id", + "owner_tenant", + "rep_id", + "turns", + "updated_at", + "version", +) +_HISTORY_KEY = (("ForAllValues:StringLike", "dynamodb:LeadingKeys", ("history#*",)),) +_HISTORY_PRESENT = (("Null", "dynamodb:LeadingKeys", ("false",)),) +_GET_PUT = ("dynamodb:GetItem", "dynamodb:PutItem") + + +def _runtime_history_expected(reps_table: str) -> dict[str, tuple[str, Any, Any, frozenset[Any]]]: + """sid -> (effect, actions, not_actions, conditions) of the designed history document.""" + return { + "ConversationHistoryRead": ( + "Allow", + ("dynamodb:GetItem",), + None, + frozenset(_HISTORY_KEY + _HISTORY_PRESENT), + ), + "ConversationHistoryWrite": ( + "Allow", + ("dynamodb:PutItem",), + None, + frozenset( + _HISTORY_KEY + + _HISTORY_PRESENT + + ( + ( + "ForAllValues:StringEquals", + "dynamodb:Attributes", + RUNTIME_HISTORY_ATTRIBUTES, + ), + ) + ), + ), + "ConversationHistoryKms": ( + "Allow", + ("kms:Decrypt", "kms:GenerateDataKey"), + None, + frozenset( + { + ("StringEquals", "kms:EncryptionContext:aws:dynamodb:tableName", (reps_table,)), + ("StringEquals", "kms:ViaService", ("dynamodb.*",)), + } + ), + ), + "DenyDynamoDbOtherTables": ("Deny", ("dynamodb:*",), None, frozenset()), + "DenyRepsNonGrantedActions": ("Deny", None, _GET_PUT, frozenset()), + "DenyRepsOutsideHistoryPrefix": ( + "Deny", + _GET_PUT, + None, + frozenset({("ForAnyValue:StringNotLike", "dynamodb:LeadingKeys", ("history#*",))}), + ), + "DenyCanaryHistory": ( + "Deny", + _GET_PUT, + None, + frozenset({("ForAnyValue:StringLike", "dynamodb:LeadingKeys", ("history#canary#*",))}), + ), + } + + +def _sorted_or_none(values: Any) -> tuple[str, ...] | None: + return tuple(sorted(str(v) for v in values)) if values else None + + +def _rendered_conditions(statement: dict[str, Any], region_pattern: bool) -> frozenset[Any]: + rendered = set() + for condition in statement.get("condition") or []: + values = tuple(sorted(str(v) for v in condition.get("values") or [])) + if region_pattern and condition.get("variable") == "kms:ViaService": + values = tuple( + "dynamodb.*" if re.fullmatch(r"dynamodb\.[a-z0-9-]+\.amazonaws\.com", v) else v + for v in values + ) + rendered.add((condition.get("test"), condition.get("variable"), values)) + return frozenset(rendered) + + +def _runtime_history_findings(plan: Plan) -> list[Finding]: + """The Runtime history document renders exactly its designed statements, and is attached.""" + control = "dynamodb_leading_keys_isolation" + documents = [r for r in plan.resource_changes if r.get("address") == RUNTIME_HISTORY_DOCUMENT] + policies = [r for r in plan.resource_changes if r.get("address") == RUNTIME_HISTORY_POLICY] + if len(documents) != 1 or len(policies) != 1: + return [ + Finding( + control, + RUNTIME_HISTORY_DOCUMENT, + "fail", + f"expected one {RUNTIME_HISTORY_DOCUMENT} and one {RUNTIME_HISTORY_POLICY}, found " + f"{len(documents)} and {len(policies)}", + ) + ] + reps = [ + Plan.after(r).get("name") + for r in plan.by_type("aws_dynamodb_table") + if str(r.get("address", "")).endswith(".aws_dynamodb_table.reps") + ] + expected = _runtime_history_expected(str(reps[0]) if len(reps) == 1 else "") + statements = {str(s.get("sid")): s for s in Plan.after(documents[0]).get("statement") or []} + findings = [] + if set(statements) != set(expected): + findings.append( + Finding( + control, + f"{RUNTIME_HISTORY_DOCUMENT} (statements)", + "fail", + f"sids={sorted(statements)!r} expected exactly {sorted(expected)!r}", + ) + ) + for sid, (effect, actions, not_actions, conditions) in expected.items(): + statement = statements.get(sid) + if statement is None: + continue + rendered = ( + statement.get("effect"), + _sorted_or_none(statement.get("actions")), + _sorted_or_none(statement.get("not_actions")), + _rendered_conditions(statement, region_pattern=True), + ) + wanted = ( + effect, + tuple(sorted(actions)) if actions else None, + tuple(sorted(not_actions)) if not_actions else None, + conditions, + ) + findings.append( + Finding( + control, + f"{RUNTIME_HISTORY_DOCUMENT}#{sid}", + "pass" if rendered == wanted else "fail", + f"rendered={rendered!r}" + ("" if rendered == wanted else f" expected={wanted!r}"), + ) + ) + return findings + + def check_dynamodb_leading_keys_isolation(plan: Plan) -> list[Finding]: """Every grant's `LeadingKeys` disposition matches `table_action_role_matrix.json` exactly. @@ -986,7 +1139,10 @@ def check_dynamodb_leading_keys_isolation(plan: Plan) -> list[Finding]: pending_conditions_seen: set[str] = set() zero_grant = {str(f) for f in matrix.get("functions_without_dynamodb_grants", [])} + findings.extend(_runtime_history_findings(plan)) for address, statements in _dynamodb_policy_documents(plan): + if address == RUNTIME_HISTORY_DOCUMENT: + continue function = _lambda_action_function_name(address) if function is None: findings.append( @@ -3080,7 +3236,8 @@ def check_relay_denies_command_execution(_plan: Plan) -> list[Finding]: #: whereas `EXPECTED_RESOURCE_COUNTS` counts plan instances. DECLARED_INFRA_BLOCK_COUNTS: dict[str, tuple[int, str]] = { 'resource "aws_iam_role_policy"': ( - 23, + 24, + "`agentcore_runtime_history`, the Runtime's conversation-history grant, is one. " "The lambda_action module's `config_parameter_kms` is one, decrypting the allowlist " "SecureString. `eval_trigger_artifacts` is one. One was removed with eval_worker: " "`eval_trigger_invoke_worker`. Six more are `sweep_control_artifacts`, " @@ -3111,8 +3268,9 @@ def check_relay_denies_command_execution(_plan: Plan) -> list[Finding]: "module's `frontend`; `EXPECTED_RESOURCE_COUNTS` expects the same five in the plan.", ), 'data "aws_iam_policy_document"': ( - 44, - "The lambda_action module's `config_parameter_kms` is one. `eval_trigger_artifacts` is one. Four were removed with eval_worker: " + 45, + "`agentcore_runtime_history` is one. The lambda_action module's `config_parameter_kms` " + "is one. `eval_trigger_artifacts` is one. Four were removed with eval_worker: " "`eval_trigger_invoke_worker`, " "`eval_worker_invoke_tools` and the deleted async_failure_destination module's two. " "Nine more are `sweep_control_artifacts`, `sweep_task_invoke_runtime`, " @@ -3572,6 +3730,8 @@ def check_runtime_resource_policy_sole_invoker(_plan: Plan) -> list[Finding]: #: The root local listing every data-plane Lambda role, and the operator variable. DYNAMODB_DATA_PLANE_LOCAL = "dynamodb_data_plane_role_arns" +#: The one data-plane entry that is not a `lambda_action` role: the AgentCore Runtime's role. +RUNTIME_DATA_PLANE_ROLE = "aws_iam_role.agentcore_runtime.arn" CRM_OPERATOR_PRINCIPALS_VAR = "var.crm_operator_principal_arns" _LAMBDA_ACTION_SOURCE = "./modules/lambda_action" @@ -4000,11 +4160,17 @@ def _data_plane_local_finding() -> Finding: expression = _root_local_expression(DYNAMODB_DATA_PLANE_LOCAL) except ValueError as exc: return Finding(control, resource, "fail", str(exc)) - named, unrecognised = _data_plane_local_modules(expression) + named, entries = _data_plane_local_modules(expression) granted, _ = _lambda_action_grant_modules() problems = [] + unrecognised = [entry for entry in entries if entry != RUNTIME_DATA_PLANE_ROLE] if unrecognised: problems.append(f"entries that are not a module role ARN: {unrecognised!r}") + if entries.count(RUNTIME_DATA_PLANE_ROLE) != 1: + problems.append( + f"{RUNTIME_DATA_PLANE_ROLE} appears {entries.count(RUNTIME_DATA_PLANE_ROLE)} time(s); " + "the Runtime role must be listed exactly once" + ) if granted - named: problems.append( f"grant-holding modules missing from the local: {sorted(granted - named)!r}" @@ -4021,7 +4187,8 @@ def _data_plane_local_finding() -> Finding: "fail" if problems else "pass", "; ".join(problems) if problems - else f"names exactly the {len(granted)} lambda_action calls holding the DynamoDB/KMS grant", + else f"names exactly the {len(granted)} lambda_action calls holding the DynamoDB/KMS grant " + f"and {RUNTIME_DATA_PLANE_ROLE}", ) @@ -6196,7 +6363,7 @@ def plan_is_stale_against_source() -> bool: """ try: document = compliant_fixture() - except (OSError, ValueError): + except OSError, ValueError: return True recorded = recorded_infra_digest(document) if recorded is None: @@ -6780,16 +6947,17 @@ def _vpc_endpoint_count() -> int: ), "aws_iam_role_policy": ExpectedCount( per_tool=5, - fixed=53, + fixed=54, basis="FIVE per action Lambda -- `dynamodb`, `dynamodb_kms`, `logs`, `config_parameter_kms` " "(decrypting the allowlist SecureString), and the `vpc_access` Hyperplane ENI grant, without " - "which the apply is green and every invocation fails -- plus 53 elsewhere: the " + "which the apply is green and every invocation fails -- plus 54 elsewhere: the " "`config_parameter_kms` policies of eval_trigger, capabilities and user_settings (3), less " - "one for the agent-only `get_page_context`, which reads no parameter; and the 51 that follow: four each on the interceptor, pre-token-generation, eval_trigger, " + "one for the agent-only `get_page_context`, which reads no parameter; and the 52 that follow: four each on the interceptor, pre-token-generation, eval_trigger, " "chat_interceptor, chat_target, user_settings, sweep_control and sweep_task lambda_action " "instantiations (32), capabilities' `logs`, `vpc_access` and `dynamodb` (3), the relay's four " - "(invoke-runtime, logs, read-audience-parameter, vpc_access), nine at the root " - "(`agentcore_gateway`, the Runtime's `agentcore_runtime` holding ECR + Bedrock and " + "(invoke-runtime, logs, read-audience-parameter, vpc_access), ten at the root " + "(`agentcore_gateway`, the Runtime's `agentcore_runtime` holding ECR + Bedrock, " + "`agentcore_runtime_history` holding its conversation-history grant and " "`agentcore_runtime_logs` holding CloudWatch, `chat_target_invoke_runtime`, `eval_sweep`, " "`eval_trigger_artifacts`, `eval_trigger_states`, `sweep_control_artifacts`, `sweep_task_invoke_runtime`), the chat " "Gateway's `gateway`, CodeBuild's, and the flow-log delivery policy. The SPLIT is asserted, " @@ -6801,12 +6969,12 @@ def _vpc_endpoint_count() -> int: ), "aws_iam_policy_document": ExpectedCount( per_tool=4, - fixed=53, + fixed=54, basis="one document behind each of an action Lambda's `dynamodb`, `dynamodb_kms`, `logs` and " - "`config_parameter_kms` role policies, plus 53: the `config_parameter_kms` documents of " + "`config_parameter_kms` role policies, plus 54: the `config_parameter_kms` documents of " "eval_trigger, capabilities and user_settings (3), less one for the agent-only " - "`get_page_context`; and the 51 that follow: ten at the root (agentcore_gateway permissions, agentcore_runtime " - "permissions and logs, the two agent-runtime relay-only resource policies, " + "`get_page_context`; and the 52 that follow: eleven at the root (agentcore_gateway permissions, agentcore_runtime " + "permissions, history and logs, the two agent-runtime relay-only resource policies, " "chat_target_invoke_runtime, eval_sweep_permissions, eval_trigger_artifacts, sweep_control_artifacts, " "sweep_task_invoke_runtime), two in agent_relay, two in agentcore, one in api (its resource " "policy), three in frontend_cdn (origin, frontend KMS, logs TLS-deny), three in observability " @@ -7981,7 +8149,7 @@ def control_modules() -> dict[str, str]: "spec_row": "Runtime inbound auth = IAM (asserted from the deployed resource, not from " "the Terraform source)", "reason": "The provider models IAM inbound auth as the ABSENCE of an authorizer block, not " - "as a value: `aws_bedrockagentcore_agent_runtime` in hashicorp/aws 6.71.0 has no " + "as a value: `aws_bedrockagentcore_agent_runtime` in hashicorp/aws 6.72.0 has no " "IAM enum and its only authorizer sub-block is `custom_jwt_authorizer` (verified " "against `terraform providers schema -json`). So source or plan " "inspection cannot distinguish `IAM` from a runtime whose authorizer block was " diff --git a/scripts/check_secret_scan.py b/scripts/check_secret_scan.py index 18064e3..2ecac9b 100644 --- a/scripts/check_secret_scan.py +++ b/scripts/check_secret_scan.py @@ -150,7 +150,7 @@ def _parents_are_present_directories(source: Path, rel: str) -> bool: current = current / part try: mode = current.lstat().st_mode - except (FileNotFoundError, NotADirectoryError): + except FileNotFoundError, NotADirectoryError: return False if stat.S_ISLNK(mode): raise SecretScanError( @@ -211,7 +211,7 @@ def materialise(source: Path, paths: list[str], dest: Path) -> int: origin = source / rel try: mode = origin.lstat().st_mode - except (FileNotFoundError, NotADirectoryError): + except FileNotFoundError, NotADirectoryError: continue if not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)): raise SecretScanError( diff --git a/scripts/check_untracked_artifact_secrets.py b/scripts/check_untracked_artifact_secrets.py index fb0279f..6df49a9 100644 --- a/scripts/check_untracked_artifact_secrets.py +++ b/scripts/check_untracked_artifact_secrets.py @@ -195,7 +195,7 @@ def carries_real_material(path: Path, gate_path: Path = ACCOUNT_ID_GATE) -> bool """ try: text = path.read_text(encoding="utf-8") - except (UnicodeDecodeError, OSError): + except UnicodeDecodeError, OSError: # An unreadable file is treated as sensitive. return True if _UNCONDITIONAL_MATERIAL.search(text) is not None: diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 2ac7cf2..e269cc8 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -185,6 +185,8 @@ fi command -v aws >/dev/null 2>&1 || die "aws CLI not found on PATH" command -v terraform >/dev/null 2>&1 || die "terraform not found on PATH" command -v python3 >/dev/null 2>&1 || die "python3 not found on PATH" +REPO_PYTHON="$("${SCRIPT_DIR}/repo_python.sh" --print)" \ + || die "no interpreter for the repository's Python scripts (see above); nothing was applied." info "Resolved profile=${RESOLVED_PROFILE} region=${RESOLVED_REGION}" @@ -245,7 +247,7 @@ restore_template() { RESTORED=true if [[ -f "$BACKUP_PATH" ]]; then info "Restoring account-agnostic AgentCore config template" - python3 "$RENDER_SCRIPT" restore --template "$TEMPLATE_PATH" --backup "$BACKUP_PATH" \ + "$REPO_PYTHON" "$RENDER_SCRIPT" restore --template "$TEMPLATE_PATH" --backup "$BACKUP_PATH" \ || warn "Restore of ${TEMPLATE_PATH} from ${BACKUP_PATH} failed — manual restore required" fi } @@ -257,12 +259,12 @@ if [[ ! -f "$TEMPLATE_PATH" ]]; then warn "AgentCore config template not found at ${TEMPLATE_PATH} — skipping render step" else if [[ -f "$BACKUP_PATH" ]]; then - die "A pre-render backup already exists at ${BACKUP_PATH}: a previous run did not restore ${TEMPLATE_PATH}, so it may still hold rendered account-specific values. Restore it first (python3 ${RENDER_SCRIPT} restore --template ${TEMPLATE_PATH} --backup ${BACKUP_PATH}), then re-run." + die "A pre-render backup already exists at ${BACKUP_PATH}: a previous run did not restore ${TEMPLATE_PATH}, so it may still hold rendered account-specific values. Restore it first (${REPO_PYTHON} ${RENDER_SCRIPT} restore --template ${TEMPLATE_PATH} --backup ${BACKUP_PATH}), then re-run." fi info "Rendering account-specific AgentCore config" VALUES_JSON="$(python3 -c "import json,sys; print(json.dumps({'ACCOUNT_ID': sys.argv[1], 'AWS_REGION': sys.argv[2], 'AWS_PROFILE': sys.argv[3]}))" \ "$ACCOUNT_ID" "$RESOLVED_REGION" "$RESOLVED_PROFILE")" - python3 "$RENDER_SCRIPT" render \ + "$REPO_PYTHON" "$RENDER_SCRIPT" render \ --template "$TEMPLATE_PATH" \ --backup "$BACKUP_PATH" \ --values-json "$VALUES_JSON" \ @@ -284,7 +286,7 @@ fi # Runs first, before the zip checks. Exit 3 (the gate verified nothing) is fatal here. info "Verifying no resource is internet-facing (scripts/check_no_public_exposure.py)" EXPOSURE_CHECK_PYTHON="${REPO_ROOT}/.venv/bin/python3" -[[ -x "$EXPOSURE_CHECK_PYTHON" ]] || EXPOSURE_CHECK_PYTHON="python3" +[[ -x "$EXPOSURE_CHECK_PYTHON" ]] || EXPOSURE_CHECK_PYTHON="$REPO_PYTHON" set +e (cd "$REPO_ROOT" && "$EXPOSURE_CHECK_PYTHON" scripts/check_no_public_exposure.py) exposure_status=$? @@ -324,7 +326,7 @@ PYEOF } TFVARS_PYTHON="${REPO_ROOT}/.venv/bin/python3" -[[ -x "$TFVARS_PYTHON" ]] || TFVARS_PYTHON="python3" +[[ -x "$TFVARS_PYTHON" ]] || TFVARS_PYTHON="$REPO_PYTHON" PF_VPC_ID="$(tfvars_value vpc_id)" PF_SUBNETS="$(tfvars_value vpc_private_subnet_ids)" @@ -369,13 +371,13 @@ info "Verifying the adopted VPC is safe to apply into (scripts/preflight_adopted info "Verifying every Lambda zip matches the current source tree (scripts/check_lambda_zip_imports.py)" ZIP_CHECK_PYTHON="${REPO_ROOT}/.venv/bin/python3" if [[ ! -x "$ZIP_CHECK_PYTHON" ]]; then - warn "No ${REPO_ROOT}/.venv/bin/python3; falling back to the ambient python3 for the zip and parity gates" - ZIP_CHECK_PYTHON="python3" + warn "No ${REPO_ROOT}/.venv/bin/python3; falling back to ${REPO_PYTHON} for the zip and parity gates" + ZIP_CHECK_PYTHON="$REPO_PYTHON" fi # The post-apply parity gate imports boto3, so its absence is reported here, before the apply. if ! "$ZIP_CHECK_PYTHON" -c 'import boto3' >/dev/null 2>&1; then - die "the interpreter running the deploy-time gates ('${ZIP_CHECK_PYTHON}') cannot import boto3, which the post-apply deployed<->zip parity gate needs. Create the project virtualenv and install the pinned dependencies, then re-run this deploy: python3 -m venv ${REPO_ROOT}/.venv && ${REPO_ROOT}/.venv/bin/pip install -r ${REPO_ROOT}/requirements.txt — nothing was applied." + die "the interpreter running the deploy-time gates ('${ZIP_CHECK_PYTHON}') cannot import boto3, which the post-apply deployed<->zip parity gate needs. Create the project virtualenv and install the pinned dependencies, then re-run this deploy: python$(cut -d. -f1,2 "${REPO_ROOT}/.python-version") -m venv ${REPO_ROOT}/.venv && ${REPO_ROOT}/.venv/bin/pip install -r ${REPO_ROOT}/requirements.txt — nothing was applied." fi (cd "$REPO_ROOT" && "$ZIP_CHECK_PYTHON" scripts/check_lambda_zip_imports.py --require-zips) \ || die "Lambda zips are stale, incomplete or missing relative to src/. Run scripts/package_lambdas.sh and re-run this deploy; nothing was applied." @@ -478,7 +480,7 @@ check_drift_bound() { warn "terraform show -json over the saved post-apply plan failed; the classifier will run without attribute-level detail and will refuse to absorb a deferred policy-document re-render. See ${LOG_FILE}" fi set +e - DRIFT_SUMMARY="$(python3 "${SCRIPT_DIR}/classify_post_apply_drift.py" "${CLASSIFY_ARGS[@]}")" + DRIFT_SUMMARY="$("$REPO_PYTHON" "${SCRIPT_DIR}/classify_post_apply_drift.py" "${CLASSIFY_ARGS[@]}")" CLASSIFY_RC=$? set -e # `${DRIFT_SUMMARY}` carries the classifier's attribution of which allowance applied. @@ -638,7 +640,7 @@ python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); sys.exit(0 if isins "${OUTPUTS_SNAPSHOT}.partial" 2>>"$LOG_FILE" \ || outputs_write_failed "the recorded document is not a non-empty JSON object" # Stamped before the atomic install, so no reader sees the snapshot without its provenance. -python3 "${SCRIPT_DIR}/outputs_provenance.py" --stamp "${OUTPUTS_SNAPSHOT}.partial" 2>>"$LOG_FILE" \ +"$REPO_PYTHON" "${SCRIPT_DIR}/outputs_provenance.py" --stamp "${OUTPUTS_SNAPSHOT}.partial" 2>>"$LOG_FILE" \ || outputs_write_failed "recording the snapshot's provenance commit failed" mv "${OUTPUTS_SNAPSHOT}.partial" "$OUTPUTS_SNAPSHOT" \ || outputs_write_failed "the atomic install (mv) failed" diff --git a/scripts/outputs_provenance.py b/scripts/outputs_provenance.py index 793bca3..d80455e 100644 --- a/scripts/outputs_provenance.py +++ b/scripts/outputs_provenance.py @@ -78,7 +78,7 @@ def _git(*args: str) -> tuple[int, str]: check=False, timeout=_GIT_TIMEOUT_SECONDS, ) - except (OSError, subprocess.SubprocessError): + except OSError, subprocess.SubprocessError: return 1, "" return completed.returncode, completed.stdout @@ -139,7 +139,7 @@ def read_provenance(document: object) -> dict[str, Any] | None: def _load(path: Path) -> dict[str, Any] | None: try: loaded = json.loads(path.read_text(encoding="utf-8")) - except (OSError, json.JSONDecodeError): + except OSError, json.JSONDecodeError: return None return loaded if isinstance(loaded, dict) else None diff --git a/scripts/package_lambdas.sh b/scripts/package_lambdas.sh index 1e3d8f0..ddb6cc0 100755 --- a/scripts/package_lambdas.sh +++ b/scripts/package_lambdas.sh @@ -13,15 +13,15 @@ # the repo-root fixtures/ package, and config/. # - chat_target.zip -- src/gateway/chat_target.py plus crm/, gateway/, providers/ and config/, # laid out like eval_trigger.zip (first-party packages under src/). No model SDK. -# - agent-source.zip -- the full src/ tree plus config/, pyproject.toml, requirements.txt and the -# root Dockerfile: CodeBuild's Docker build context (infra/modules/agentcore/ecr_codebuild.tf), -# not a Lambda zip. +# - agent-source.zip -- the src/ tree except src/relay/, plus config/, pyproject.toml, +# requirements.txt and the root Dockerfile: CodeBuild's Docker build context +# (infra/modules/agentcore/ecr_codebuild.tf), not a Lambda zip. # # Third-party dependencies: boto3/botocore are provided by the Lambda runtime and never vendored. # Each zip declares a seed (jsonschema for the tool zips; PyJWT and cryptography for the interceptor; # none for pre_token_generation; jsonschema, PyYAML, starlette and python-multipart for # eval_trigger; jsonschema and PyYAML for chat_target), and the rest of the closure is resolved: pip installs for the Lambda platform -# (python3.13, x86_64), then scripts/check_lambda_zip_imports.py reports which distributions the +# (python3.14, x86_64), then scripts/check_lambda_zip_imports.py reports which distributions the # Lambda marker environment still requires, and those are installed until a fixed point. Every # vendored version must be exact-pinned in requirements.txt; no version literal appears here. # @@ -148,19 +148,16 @@ if [[ "${PRINT_PINS}" -eq 1 ]]; then exit 0 fi -# Prefers the project's virtualenv, falling back to `python3`. -PYTHON="${REPO_ROOT}/.venv/bin/python3" -if [[ ! -x "${PYTHON}" ]]; then - PYTHON="python3" -fi +# The project's virtualenv, else an ambient `python3` new enough for the repository (scripts/repo_python.sh). +PYTHON="$("${SCRIPT_DIR}/repo_python.sh" --print)" -# Installs `_PIP_PINS` into `$1` for the Lambda platform (x86_64, python3.13); `--constraint` binds +# Installs `_PIP_PINS` into `$1` for the Lambda platform (x86_64, python3.14); `--constraint` binds # every version pip resolves to requirements.txt. _PIP_PINS=() _pip_vendor_install() { local dir="$1" "${PYTHON}" -m pip install --no-input --target "${dir}" --quiet --upgrade \ - --platform manylinux2014_x86_64 --python-version 3.13 --only-binary=:all: \ + --platform manylinux2014_x86_64 --python-version 3.14 --only-binary=:all: \ --constraint "${REQUIREMENTS_FILE}" "${_PIP_PINS[@]}" rm -rf "${dir:?}/bin" find "${dir}" -name '__pycache__' -type d -prune -exec rm -rf {} + 2>/dev/null || true @@ -185,7 +182,7 @@ _verify_vendor_pins() { } # Installs `_PIP_PINS` into `$1`, then repeatedly installs the distributions the Lambda marker -# environment (python_version 3.13 / linux / x86_64) still requires, until none are missing. The round +# environment (python_version 3.14 / linux / x86_64) still requires, until none are missing. The round # cap guards against a metadata cycle. _install_target_closure() { local dir="$1" round=0 missing_text pins_text name pin @@ -330,11 +327,12 @@ rsync -a "${CHAT_TARGET_VENDOR_DIR}/" "${chat_target_dir}/" (cd "${chat_target_dir}" && zip -qr "${BUILD_DIR}/chat_target.zip" .) log "Packaged chat_target.zip" -# agent-source.zip -- src/, config/, pyproject.toml, requirements.txt, and the Dockerfile at the -# archive root, where CodeBuild's `docker build` expects it. +# agent-source.zip -- src/ without src/relay/, config/, pyproject.toml, requirements.txt, and the +# Dockerfile at the archive root, where CodeBuild's `docker build` expects it. agent_source_dir="${STAGE_ROOT}/agent-source" mkdir -p "${agent_source_dir}" -rsync -a --exclude '__pycache__' --exclude '*.pyc' --exclude '*.egg-info' "${SRC_DIR}/" "${agent_source_dir}/src/" +rsync -a --exclude '/relay/' --exclude '__pycache__' --exclude '*.pyc' --exclude '*.egg-info' \ + "${SRC_DIR}/" "${agent_source_dir}/src/" rsync -a "${REPO_ROOT}/config/" "${agent_source_dir}/config/" for f in pyproject.toml requirements.txt Dockerfile; do if [[ -f "${REPO_ROOT}/${f}" ]]; then @@ -346,7 +344,7 @@ log "Packaged agent-source.zip" log "Done. $(find "${BUILD_DIR}" -maxdepth 1 -name '*.zip' | wc -l | tr -d ' ') zip(s) in ${BUILD_DIR}" -# Verification-only, never packaged: a host-loadable CPython 3.13 build of the tool and interceptor +# Verification-only, never packaged: a host-loadable CPython 3.14 build of the tool and interceptor # zips' vendored distributions, at the same pins, for check_lambda_zip_imports's isolated_import phase. Best effort; # when it is absent or incomplete the gate falls back to the build host interpreter and says so. TARGET_SHADOW_DIR="${LAMBDA_TARGET_SHADOW_DIR:-${REPO_ROOT}/infra/build/target-python-shadow}" @@ -355,7 +353,7 @@ _build_target_shadow() { _SHADOW_PINS=() target_python="$("${PYTHON}" "${SCRIPT_DIR}/check_lambda_zip_imports.py" --print-target-python || true)" if [[ -z "${target_python}" ]]; then - log "No CPython 3.13 discoverable; skipping the target-version substitute directory (isolated_import will run on this host and say so)" + log "No CPython 3.14 discoverable; skipping the target-version substitute directory (isolated_import will run on this host and say so)" return 0 fi local dist_info stem @@ -369,11 +367,11 @@ _build_target_shadow() { rm -rf "${TARGET_SHADOW_DIR}" mkdir -p "${TARGET_SHADOW_DIR}" if "${PYTHON}" -m pip install --no-input --target "${TARGET_SHADOW_DIR}" --quiet --upgrade \ - --python-version 3.13 --only-binary=:all: \ + --python-version 3.14 --only-binary=:all: \ --constraint "${REQUIREMENTS_FILE}" "${_SHADOW_PINS[@]}"; then log "Target-version substitute directory built for ${target_python} at ${TARGET_SHADOW_DIR}" else - log "Could not build the target-version substitute directory (no host wheel for a pin at python-version 3.13); isolated_import will fall back to this host and say so" + log "Could not build the target-version substitute directory (no host wheel for a pin at python-version 3.14); isolated_import will fall back to this host and say so" fi } _build_target_shadow diff --git a/scripts/plan_fixtures.py b/scripts/plan_fixtures.py index 6d2a89a..b5e0316 100755 --- a/scripts/plan_fixtures.py +++ b/scripts/plan_fixtures.py @@ -41,7 +41,7 @@ DEFAULT_OUT_DIR: Final[Path] = REPO_ROOT / "results" / "plan-fixtures" #: Top-level fields kept out of the base so no scanner reads it as a plan; restored by `build`. -TERRAFORM_VERSION: Final[str] = "1.17.0" +TERRAFORM_VERSION: Final[str] = "1.17.2" TIMESTAMP: Final[str] = "2026-11-07T02:10:46Z" HEADER_KEYS: Final[frozenset[str]] = frozenset( diff --git a/scripts/preflight_adopted_vpc.sh b/scripts/preflight_adopted_vpc.sh index 869d1d3..ff12e93 100755 --- a/scripts/preflight_adopted_vpc.sh +++ b/scripts/preflight_adopted_vpc.sh @@ -316,8 +316,8 @@ done # The supported set is read from infra/regions.json; a region missing from it refuses. if [[ -n "$RUNTIME_SUBNET_IDS" ]]; then REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" - PYTHON="${REPO_ROOT}/.venv/bin/python3" - [[ -x "$PYTHON" ]] || PYTHON="python3" + PYTHON="$("${REPO_ROOT}/scripts/repo_python.sh" --print)" \ + || die "no interpreter for the repository's Python scripts (see above); nothing was checked" az_rc=0 SUPPORTED_AZ_IDS=$("$PYTHON" "${REPO_ROOT}/scripts/region_map.py" az-ids --region "$RESOLVED_REGION") || az_rc=$? case "$az_rc" in diff --git a/scripts/refresh_outputs.sh b/scripts/refresh_outputs.sh index d6e346a..e7c19d1 100755 --- a/scripts/refresh_outputs.sh +++ b/scripts/refresh_outputs.sh @@ -61,7 +61,7 @@ mkdir -p "$(dirname "${OUTPUTS_SNAPSHOT}")" || refresh_failed "terraform output -json exited non-zero" python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); sys.exit(0 if isinstance(d, dict) and d else 1)' \ "${PARTIAL}" || refresh_failed "the recorded document is not a non-empty JSON object" -python3 "${SCRIPT_DIR}/outputs_provenance.py" --stamp "${PARTIAL}" --recorded-by refresh \ +"${SCRIPT_DIR}/repo_python.sh" "${SCRIPT_DIR}/outputs_provenance.py" --stamp "${PARTIAL}" --recorded-by refresh \ || refresh_failed "recording the snapshot's provenance failed" mv "${PARTIAL}" "${OUTPUTS_SNAPSHOT}" || refresh_failed "the atomic install (mv) failed" echo "${SCRIPT_NAME}: recorded $(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(len([k for k in d if not k.startswith("_")]))' "${OUTPUTS_SNAPSHOT}") outputs to ${OUTPUTS_SNAPSHOT}" diff --git a/scripts/repo_python.sh b/scripts/repo_python.sh new file mode 100755 index 0000000..5b0f537 --- /dev/null +++ b/scripts/repo_python.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MIT +# +# Resolves the interpreter for repository Python: /.venv/bin/python3 when executable, else an +# ambient `python3`. The chosen interpreter must be at least MIN_PYTHON, else exit 2 naming the required +# and found versions; a stale virtualenv is refused rather than skipped. +# +# Usage: scripts/repo_python.sh --print print the resolved interpreter path +# scripts/repo_python.sh ARGS... exec the resolved interpreter with ARGS +# +# MIN_PYTHON must equal the major.minor of .python-version (tests/unit/test_repo_python.py). +# +# Exit codes: 2 no acceptable interpreter, or no arguments; otherwise the interpreter's own status. +set -euo pipefail + +# The script's own matchers run under LC_ALL=C; the exec'd interpreter gets the caller's LC_ALL (set or +# unset as it was). +if [[ -n "${LC_ALL+set}" ]]; then + CALLER_LC_ALL_SET=1 + CALLER_LC_ALL="$LC_ALL" +else + CALLER_LC_ALL_SET=0 + CALLER_LC_ALL="" +fi +export LC_ALL=C + +readonly MIN_PYTHON="3.14" + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +die() { + echo "repo_python.sh: $*" >&2 + exit 2 +} + +[[ $# -gt 0 ]] || die "usage: repo_python.sh --print | repo_python.sh ARGS..." + +# Prints the major.minor of interpreter $1, or exits 2 naming $2 (how the interpreter was found). +version_of() { + local found + if ! found="$("$1" -c 'import sys; print("%d.%d" % sys.version_info[:2])' 2>/dev/null)"; then + die "requires Python >= ${MIN_PYTHON}: could not run $2 $1" + fi + [[ "$found" =~ ^[0-9]+\.[0-9]+$ ]] || + die "requires Python >= ${MIN_PYTHON}: $2 $1 reported an unreadable version '${found}'" + printf '%s\n' "$found" +} + +# Exit 0 when major.minor $1 is at least MIN_PYTHON. +meets_floor() { + local want_major="${MIN_PYTHON%%.*}" want_minor="${MIN_PYTHON#*.}" + local have_major="${1%%.*}" have_minor="${1#*.}" + ((have_major > want_major || (have_major == want_major && have_minor >= want_minor))) +} + +resolve() { + local venv_python="${REPO_ROOT}/.venv/bin/python3" + local found + if [[ -x "$venv_python" ]]; then + found="$(version_of "$venv_python" "the project virtualenv")" + meets_floor "$found" || + die "requires Python >= ${MIN_PYTHON}: the project virtualenv ${venv_python} is ${found}; rebuild .venv" + printf '%s\n' "$venv_python" + return 0 + fi + local ambient + ambient="$(command -v python3 || true)" + [[ -n "$ambient" ]] || + die "requires Python >= ${MIN_PYTHON}: no ${venv_python} and no python3 on PATH" + found="$(version_of "$ambient" "the ambient")" + if meets_floor "$found"; then + printf '%s\n' "$ambient" + return 0 + fi + die "requires Python >= ${MIN_PYTHON}: no ${venv_python}, and the ambient ${ambient} is ${found}" +} + +PYTHON="$(resolve)" +if [[ "$1" == "--print" ]]; then + [[ $# -eq 1 ]] || die "--print takes no further arguments" + printf '%s\n' "$PYTHON" + exit 0 +fi +if ((CALLER_LC_ALL_SET)); then + export LC_ALL="$CALLER_LC_ALL" +else + unset LC_ALL +fi +exec "$PYTHON" "$@" diff --git a/scripts/rotate_mcp_client_secret.py b/scripts/rotate_mcp_client_secret.py index e27dd81..3f2a8be 100644 --- a/scripts/rotate_mcp_client_secret.py +++ b/scripts/rotate_mcp_client_secret.py @@ -246,7 +246,7 @@ def mint(transport: TokenTransport, endpoint: str, client_id: str, secret: str) raise RotationError(f"token endpoint unreachable: {type(exc).__name__}") from None try: payload = json.loads(raw.decode("utf-8")) - except (UnicodeDecodeError, ValueError): + except UnicodeDecodeError, ValueError: payload = None if not isinstance(payload, dict): return MintResult(status=status, error="unparseable_response") @@ -312,7 +312,7 @@ def _roll_back_unreadable_add( idp.delete_user_pool_client_secret( UserPoolId=target.user_pool_id, ClientId=target.client_id, ClientSecretId=secret_id ) - except (BotoCoreError, ClientError): + except BotoCoreError, ClientError: failed.append(secret_id) if failed: return RotationError( diff --git a/scripts/smoke/access_log_delivery.py b/scripts/smoke/access_log_delivery.py index 09492c3..376b9f9 100644 --- a/scripts/smoke/access_log_delivery.py +++ b/scripts/smoke/access_log_delivery.py @@ -27,7 +27,14 @@ from dataclasses import dataclass from typing import Any, Final -from scripts.smoke.harness import CheckResult, ExpectedCheckCount, SmokeContext, run_main +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + MissingTerraformOutputError, + SmokeContext, + aws_error_detail, + run_main, +) LAYER: Final[int] = 4 RESOURCE_CLASS: Final[str] = "access_log_delivery" @@ -116,7 +123,7 @@ def _bucket_log_target(ctx: SmokeContext, source_bucket: str) -> tuple[str, str] try: response = ctx.client("s3").get_bucket_logging(Bucket=source_bucket) except Exception as exc: # noqa: BLE001 - reported per destination, never aborts the run - return f"{type(exc).__name__}: {exc}" + return aws_error_detail("s3:GetBucketLogging", exc) enabled = response.get("LoggingEnabled") if not enabled: return ( @@ -131,7 +138,7 @@ def _distribution_log_target(ctx: SmokeContext, distribution_id: str) -> tuple[s try: response = ctx.client("cloudfront").get_distribution_config(Id=distribution_id) except Exception as exc: # noqa: BLE001 - reported per destination, never aborts the run - return f"{type(exc).__name__}: {exc}" + return aws_error_detail("cloudfront:GetDistributionConfig", exc) config: Any = response.get("DistributionConfig") or {} logging_block: Any = config.get("Logging") or {} if not logging_block.get("Enabled"): @@ -160,7 +167,7 @@ def _check_target(ctx: SmokeContext, destination: LogDestination, bucket: str) - if destination.source_bucket_output is not None: try: source = ctx.outputs.require_str(destination.source_bucket_output) - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except MissingTerraformOutputError as exc: return _fail( resource, CHECK_TARGET, @@ -183,7 +190,7 @@ def _check_target(ctx: SmokeContext, destination: LogDestination, bucket: str) - raise RuntimeError("source_distribution_output is unset; __post_init__ enforces it") try: source = ctx.outputs.require_str(destination.source_distribution_output) - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except MissingTerraformOutputError as exc: return _fail( resource, CHECK_TARGET, @@ -236,7 +243,7 @@ def _delivered_object_count(ctx: SmokeContext, bucket: str, prefix: str) -> int try: response = ctx.client("s3").list_objects_v2(Bucket=bucket, Prefix=prefix, MaxKeys=1) except Exception as exc: # noqa: BLE001 - reported per destination, never aborts the run - return f"{type(exc).__name__}: {exc}" + return aws_error_detail("s3:ListObjectsV2", exc) return int(response.get("KeyCount", 0)) @@ -285,7 +292,7 @@ def checks(ctx: SmokeContext) -> Sequence[CheckResult]: resource = f"{destination.output_name}:{destination.prefix}" try: bucket = ctx.outputs.require_str(destination.output_name) - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except MissingTerraformOutputError as exc: results.append( _fail( resource, diff --git a/scripts/smoke/admin_authz.py b/scripts/smoke/admin_authz.py index 99be8dc..59b5697 100644 --- a/scripts/smoke/admin_authz.py +++ b/scripts/smoke/admin_authz.py @@ -39,7 +39,9 @@ CheckResult, ExpectedCheckCount, SmokeContext, + aws_error_detail, error_code, + exception_detail, open_https, run_main, ) @@ -310,7 +312,7 @@ def simulation_result( resource=resource, check=row.check, status="fail", - detail=f"simulate_principal_policy raised {type(exc).__name__}: {exc} ({subject})", + detail=f"{aws_error_detail('iam:SimulatePrincipalPolicy', exc)} ({subject})", ) if decision == "no_result": ok = False @@ -423,7 +425,7 @@ def provision_or_fail( resource=resource, check=check, status="fail", - detail=f"could not provision the smoke user: {type(exc).__name__}: {exc}", + detail=f"could not provision the smoke user: {aws_error_detail('provision', exc)}", ) return user, CheckResult(resource=resource, check=check, status="pass", detail=user.detail) @@ -460,7 +462,7 @@ def check_admin_group_exists(idp: Any, *, user_pool_id: str) -> CheckResult: resource=RESOURCE_CLASS, check="admin_group_exists", status="fail", - detail=f"get_group({ADMIN_GROUP!r}) raised {type(exc).__name__}: {exc}", + detail=f"{aws_error_detail('cognito-idp:GetGroup', exc)} for {ADMIN_GROUP!r}", ) return CheckResult( resource=RESOURCE_CLASS, @@ -507,7 +509,7 @@ def check_groups_claim( resource=RESOURCE_CLASS, check="admin_token_groups_claim", status="fail", - detail=f"{CLAIM_GROUPS} rendered as {rendering} does not parse: {exc}", + detail=f"{CLAIM_GROUPS} rendered as {rendering} does not parse: {exception_detail(exc)}", ) present = ADMIN_GROUP in groups return CheckResult( diff --git a/scripts/smoke/agents.py b/scripts/smoke/agents.py index 2e02f54..bd789f9 100644 --- a/scripts/smoke/agents.py +++ b/scripts/smoke/agents.py @@ -6,7 +6,8 @@ removed afterwards; the `demo` tenant is proved untouched. One turn is posted through `cloudfront_source`, naming a real `demo` account the caller cannot see, and counted against this module's :data:`scripts.smoke.three_tier_chat.MODEL_TURN_ALLOTMENTS` share. Billable: the turn makes -real model calls. +real model calls. The Runtime's conversation-history item for the turn's session is deleted before +the principal is removed, and proved absent by the `history_items_deleted` row. :func:`relay_turn_checks` turns the parsed stream into rows: the turn completed, no `tool_result` carried the out-of-book account, every event kind is in the closed vocabulary, and the per-agent @@ -18,6 +19,7 @@ from __future__ import annotations +import dataclasses import json import sys import uuid @@ -31,8 +33,15 @@ store_row_reader, writes_only_under_smoke_tenant_check, ) -from scripts.smoke.harness import DEFER, CheckResult, SmokeContext, run_main -from scripts.smoke.three_tier_chat import ModelTurnBudget, budget_refused +from scripts.smoke.harness import DEFER, CheckResult, SmokeContext, exception_detail, run_main +from scripts.smoke.three_tier_chat import ( + HISTORY_ITEMS_DELETED_CHECK, + HistoryItemsFactory, + ModelTurnBudget, + _LiveHistoryItems, + budget_refused, + delete_history_items, +) from scripts.smoke_agent_stream import ( LiveStreamPrincipalProvisioner, cloudfront_source, @@ -43,6 +52,7 @@ from agents.registry import tool_registry_for from agents.subagents import ALL_SUBAGENT_SPECS from agents.supervisor import DIRECT_TOOL_NAMES, SUPERVISOR_ROLE +from crm.store.keys import history_key from crm.toolspec.definitions import ( BY_NAME, TABLES, @@ -494,7 +504,7 @@ def relay_turn_checks( try: events = list(run_turn(prompt)) except Exception as exc: # noqa: BLE001 - a transport failure is a check failure, not a crash - detail = f"turn failed: {type(exc).__name__}: {exc}" + detail = f"turn failed: {exception_detail(exc)}" return [ CheckResult(resource=resource, check=check, status="fail", detail=detail) for resource, check in _turn_rows() @@ -525,16 +535,20 @@ def _event_payloads(chunks: Iterable[bytes]) -> list[dict[str, Any]]: for event in parse_sse_bytes(chunks): try: decoded = json.loads(event.data) - except (TypeError, ValueError): + except TypeError, ValueError: continue if isinstance(decoded, dict): payloads.append(decoded) return payloads -def _cloudfront_turn_runner(ctx: SmokeContext, token: str) -> TurnRunner: +def new_session_id() -> str: + """A fresh session id for this module's relay turn.""" + return f"smoke-agents-{uuid.uuid4().hex}" + + +def _cloudfront_turn_runner(ctx: SmokeContext, token: str, session_id: str) -> TurnRunner: def run(prompt: str) -> list[dict[str, Any]]: - session_id = f"smoke-agents-{uuid.uuid4().hex}" body = {"prompt": prompt, "session_id": session_id, "resume_from": 0} source = cloudfront_source(ctx, token=token, body=body, session_id=session_id) return _event_payloads(source()) @@ -560,14 +574,17 @@ def checks( provisioner_factory: Callable[[SmokeContext], LiveStreamPrincipalProvisioner] = ( LiveStreamPrincipalProvisioner ), - runner_factory: Callable[[SmokeContext, str], TurnRunner] = _cloudfront_turn_runner, + runner_factory: Callable[[SmokeContext, str, str], TurnRunner] = _cloudfront_turn_runner, + history_items: HistoryItemsFactory = _LiveHistoryItems, ) -> Iterable[CheckResult]: """Provision a disposable principal, run one counted turn, prove `demo` untouched, clean up. Every row in :func:`_turn_rows` is emitted on every path: a turn that did not run is a `defer` - naming why. The factories are injectable for the offline test. + naming why. Once the turn has been sent, its session's history item is deleted in the `finally`, + before the principal is removed. The factories are injectable for the offline test. """ budget = ModelTurnBudget(RESOURCE_CLASS) + sent_sessions: list[str] = [] provisioner = provisioner_factory(ctx) reader = store_row_reader(provisioner.store()) demo_before = read_tenant_snapshot(reader, DEMO_TENANT) @@ -581,7 +598,7 @@ def checks( resource="smoke_principal", check="mfa_access_token_issued", status="fail", - detail=f"could not provision the smoke principal: {type(exc).__name__}: {exc}", + detail=f"could not provision the smoke principal: {exception_detail(exc)}", ) ) results.extend( @@ -602,9 +619,11 @@ def checks( label = "relay turn" if budget.spend(label): account = out_of_book_account() + session_id = new_session_id() + sent_sessions.append(session_id) results.extend( relay_turn_checks( - runner_factory(ctx, token), + runner_factory(ctx, token, session_id), prompt=turn_prompt(account), out_of_book_account=account, ) @@ -628,10 +647,36 @@ def checks( resource=RESOURCE_CLASS, tenant=provisioner.tenant(), reader=reader ) ) + results.extend( + _delete_turn_history(ctx, history_items, provisioner.tenant(), sent_sessions) + ) results.extend(provisioner.cleanup()) return results +def _delete_turn_history( + ctx: SmokeContext, + items_factory: HistoryItemsFactory, + tenant: str, + sessions: Sequence[str], +) -> Iterable[CheckResult]: + """Delete the history item of every session a turn was sent with, as this module's row.""" + if not sessions: + return + try: + items = items_factory(ctx) + except Exception as exc: # noqa: BLE001 - surfaced as a failing check, never swallowed + yield CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_ITEMS_DELETED_CHECK, + status="fail", + detail=f"could not address the history items: {exception_detail(exc)}", + ) + return + deleted = delete_history_items(items, [history_key(tenant, session) for session in sessions]) + yield dataclasses.replace(deleted, resource=RESOURCE_CLASS) + + def main(argv: Sequence[str] | None = None) -> int: """Entry point: run the relay-backed agent checks and return 0 pass / 1 fail. diff --git a/scripts/smoke/api_routes.py b/scripts/smoke/api_routes.py index 9ea640e..5de974f 100644 --- a/scripts/smoke/api_routes.py +++ b/scripts/smoke/api_routes.py @@ -50,6 +50,7 @@ CheckResult, MissingTerraformOutputError, SmokeContext, + exception_detail, open_https, run_main, ) @@ -1111,7 +1112,7 @@ def _teardown_check(tenant: str, do_teardown: TenantTeardown) -> Iterable[CheckR resource=RESOURCE_CLASS, check="tenant_left_clean", status="fail", - detail=f"teardown of tenant {tenant!r} failed: {exc}", + detail=f"teardown of tenant {tenant!r} failed: {exception_detail(exc)}", ) return yield CheckResult( @@ -1414,7 +1415,7 @@ def _invoke_payload(lambda_client: Any, name: str, event: Mapping[str, Any]) -> raw = response["Payload"].read() try: payload: Any = json.loads(raw) - except (TypeError, ValueError): + except TypeError, ValueError: payload = raw return str(response.get("FunctionError") or "None"), payload diff --git a/scripts/smoke/chat_path_iam.py b/scripts/smoke/chat_path_iam.py index 981581c..1769087 100644 --- a/scripts/smoke/chat_path_iam.py +++ b/scripts/smoke/chat_path_iam.py @@ -45,6 +45,7 @@ CheckResult, ExpectedCheckCount, SmokeContext, + aws_error_detail, error_code, run_main, ) @@ -272,7 +273,7 @@ def check_resource_policy( resource=function_name, check=check, status="fail", - detail=f"get_policy: {reason or type(exc).__name__}: {exc}", + detail=aws_error_detail("lambda:GetPolicy", exc) + (f": {reason}" if reason else ""), ) problems, grants = policy_violations( document, gateway_role_arn=gateway_role_arn, gateway_arn=gateway_arn, account_id=account_id diff --git a/scripts/smoke/chat_timeouts.py b/scripts/smoke/chat_timeouts.py index 072b2ef..8e4ae3b 100644 --- a/scripts/smoke/chat_timeouts.py +++ b/scripts/smoke/chat_timeouts.py @@ -24,7 +24,14 @@ from pathlib import Path from typing import Any, Final -from scripts.smoke.harness import CheckResult, ExpectedCheckCount, SmokeContext, run_main +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + SmokeContext, + aws_error_detail, + exception_detail, + run_main, +) LAYER: Final[int] = 4 RESOURCE_CLASS: Final[str] = "chat_timeouts" @@ -75,7 +82,7 @@ def _timeout_row( resource=function_name, check=check, status="fail", - detail=f"get_function_configuration raised {type(exc).__name__}: {exc}", + detail=aws_error_detail("lambda:GetFunctionConfiguration", exc), ) observed = configuration.get("Timeout") return CheckResult( @@ -91,13 +98,22 @@ def _origin_read_timeout_row(ctx: SmokeContext) -> CheckResult: try: distribution_id = ctx.outputs.require_str("cloudfront_distribution_id") relay_host = urllib.parse.urlparse(ctx.outputs.require_str("agent_relay_function_url")) + except Exception as exc: # noqa: BLE001 - a failing row, not a crash + return CheckResult( + resource="cloudfront", + check=check, + status="fail", + detail=f"could not read the distribution: {exception_detail(exc)}", + ) + try: config = ctx.client("cloudfront").get_distribution_config(Id=distribution_id) except Exception as exc: # noqa: BLE001 - a failing row, not a crash return CheckResult( resource="cloudfront", check=check, status="fail", - detail=f"could not read the distribution: {type(exc).__name__}: {exc}", + detail="could not read the distribution: " + + aws_error_detail("cloudfront:GetDistributionConfig", exc), ) origins = ((config.get("DistributionConfig") or {}).get("Origins") or {}).get("Items") or [] matching = [o for o in origins if o.get("DomainName") == relay_host.hostname] @@ -132,8 +148,16 @@ def _image_rows(ctx: SmokeContext, zip_path: Path) -> Iterator[CheckResult]: return expected = expected_image_tag(zip_path) try: - runtime_arn = ctx.outputs.require_str("agentcore_runtime_arn") - runtime_id = runtime_arn.rpartition("/")[2] + runtime_id = ctx.outputs.require_str("agentcore_runtime_arn").rpartition("/")[2] + except Exception as exc: # noqa: BLE001 - a failing row, not a crash + yield CheckResult( + resource=resource, + check="runtime_image_is_the_built_one", + status="fail", + detail=f"could not describe the Runtime: {exception_detail(exc)}", + ) + return + try: runtime = ctx.client("bedrock-agentcore-control").get_agent_runtime( agentRuntimeId=runtime_id ) @@ -142,7 +166,8 @@ def _image_rows(ctx: SmokeContext, zip_path: Path) -> Iterator[CheckResult]: resource=resource, check="runtime_image_is_the_built_one", status="fail", - detail=f"could not describe the Runtime: {type(exc).__name__}: {exc}", + detail="could not describe the Runtime: " + + aws_error_detail("bedrock-agentcore-control:GetAgentRuntime", exc), ) return uri = str( @@ -181,7 +206,7 @@ def _ecr_row(ctx: SmokeContext, *, repository: str, tag: str) -> CheckResult: resource=repository, check=check, status="fail", - detail=f"describe_images raised {type(exc).__name__}: {exc}", + detail=aws_error_detail("ecr:DescribeImages", exc), ) details: Sequence[Mapping[str, Any]] = images.get("imageDetails") or [] digests = [str(d.get("imageDigest")) for d in details] @@ -205,7 +230,7 @@ def checks( resource="agent_relay_function_name|dynamodb_table_names", check="terraform_output_present", status="fail", - detail=f"a required Terraform output is absent ({exc}); a missing output is a failure", + detail=f"a required Terraform output is absent ({exception_detail(exc)}); a missing output is a failure", ) return yield _timeout_row( diff --git a/scripts/smoke/cognito_claims.py b/scripts/smoke/cognito_claims.py index 624af74..a1469ef 100644 --- a/scripts/smoke/cognito_claims.py +++ b/scripts/smoke/cognito_claims.py @@ -46,7 +46,10 @@ from scripts.smoke.harness import ( CheckResult, SmokeContext, + aws_error_code, + aws_error_detail, error_code, + exception_detail, run_main, smoke_client_config, ) @@ -364,7 +367,7 @@ def _delete_self_signup_user(admin_idp: Any, *, user_pool_id: str, username: str status="fail", detail=( f"could not confirm deletion of {username!r}: " - f"{error_code(exc) or type(exc).__name__}: {exc}" + f"{aws_error_detail('cognito-idp:AdminDeleteUser/AdminGetUser', exc)}" ), ) @@ -761,7 +764,7 @@ def _cleanup_cognito_user(self) -> Iterable[CheckResult]: try: idp.admin_get_user(UserPoolId=self._user_pool_id(), Username=username) except Exception as exc: # noqa: BLE001 - the expected outcome is an exception - if "UserNotFoundException" not in f"{type(exc).__name__}: {exc}": + if aws_error_code(exc) != "UserNotFoundException": raise yield CheckResult( resource="smoke_user", @@ -781,7 +784,8 @@ def _cleanup_cognito_user(self) -> Iterable[CheckResult]: resource="smoke_user", check="cognito_user_deleted", status="fail", - detail=f"could not confirm smoke user deletion: {type(exc).__name__}: {exc}", + detail="could not confirm smoke user deletion: " + + exception_detail(exc, "cognito-idp:AdminDeleteUser/AdminGetUser"), ) def _cleanup_reps_row(self) -> Iterable[CheckResult]: @@ -806,7 +810,7 @@ def _cleanup_reps_row(self) -> Iterable[CheckResult]: resource="smoke_user", check="reps_row_deleted", status="fail", - detail=f"could not delete the smoke reps row: {type(exc).__name__}: {exc}", + detail=f"could not delete the smoke reps row: {exception_detail(exc)}", ) def _cleanup_tenant(self) -> Iterable[CheckResult]: @@ -838,7 +842,7 @@ def _cleanup_tenant(self) -> Iterable[CheckResult]: resource="smoke_tenant", check="tenant_left_clean", status="fail", - detail=f"teardown of {smoke_tenant.tenant!r} failed: {type(exc).__name__}: {exc}", + detail=f"teardown of {smoke_tenant.tenant!r} failed: {exception_detail(exc)}", ) @@ -1037,7 +1041,7 @@ def _check_token_revocation_enabled(idp: Any, *, user_pool_id: str, client_id: s resource="spa_client", check="token_revocation_enabled", status="fail", - detail=f"describe_user_pool_client failed: {error_code(exc) or type(exc).__name__}", + detail=f"describe_user_pool_client failed: {aws_error_code(exc)}", ) client = described.get("UserPoolClient") if isinstance(described, Mapping) else None enabled = client.get("EnableTokenRevocation") if isinstance(client, Mapping) else None @@ -1119,9 +1123,7 @@ def _all( described = idp.describe_user_pool_client(UserPoolId=user_pool_id, ClientId=client_id) registered = list((described.get("UserPoolClient") or {}).get("LogoutURLs") or []) except Exception as exc: # noqa: BLE001 - reported on both rows - yield from _all( - "fail", f"describe_user_pool_client failed: {error_code(exc) or type(exc).__name__}" - ) + yield from _all("fail", f"describe_user_pool_client failed: {aws_error_code(exc)}") return if not registered: yield from _all("fail", "the SPA client registers no LogoutURLs") @@ -1136,7 +1138,7 @@ def _all( except Exception as exc: # noqa: BLE001 - an unreachable endpoint verified nothing yield from _all( "defer", - f"GET {base} raised {type(exc).__name__}: {exc}", + f"GET {base} raised {exception_detail(exc)}", "hosted_ui_unreachable", ) return @@ -1180,7 +1182,7 @@ def _check_revoked_refresh_token_refused( resource="spa_client", check=check, status="fail", - detail=f"RevokeToken failed: {error_code(exc) or type(exc).__name__}", + detail=f"RevokeToken failed: {aws_error_code(exc)}", ) try: idp.initiate_auth( @@ -1306,7 +1308,8 @@ def checks( resource="id_token", check="authenticate", status="fail", - detail=f"authentication failed for {username!r}: {exc}", + detail=f"authentication failed for {username!r}: " + + exception_detail(exc, "cognito-idp:AdminInitiateAuth"), ) return @@ -1330,7 +1333,7 @@ def checks( resource="id_token", check="decode", status="fail", - detail=f"could not decode issued ID token: {exc}", + detail=f"could not decode issued ID token: {exception_detail(exc)}", ) return @@ -1378,7 +1381,7 @@ def _provisioned_token_checks( status="fail", detail=( "could not provision an MFA-enrolled smoke user and issue a token: " - f"{type(exc).__name__}: {exc}" + f"{exception_detail(exc)}" ), ) return @@ -1390,7 +1393,7 @@ def _provisioned_token_checks( resource="id_token", check="issue_and_decode", status="fail", - detail=f"could not decode the issued ID token: {type(exc).__name__}: {exc}", + detail=f"could not decode the issued ID token: {exception_detail(exc)}", ) return diff --git a/scripts/smoke/deployed_parity.py b/scripts/smoke/deployed_parity.py index d19dfa8..04878c2 100644 --- a/scripts/smoke/deployed_parity.py +++ b/scripts/smoke/deployed_parity.py @@ -14,6 +14,14 @@ * `crm-agent-eval-identity-interceptor` and `crm-agent-eval-pre-token-generation`, the two non-tool Lambda functions `infra/main.tf` declares. +Runtime (inventory path only): every deployed function named `crm-agent-eval-*`, discovered with +`lambda:ListFunctions` and excluding the run-scoped ENI probe functions, gets one `lambda_runtime` +row. A Python function must report `python.` from +`scripts.check_lambda_zip_imports.TARGET_PYTHON_VERSION`; the relay (`RELAY_FUNCTION`) must report +the `nodejs.x` default of `infra/modules/agent_relay/variables.tf`. +`lambda_runtime_coverage` requires every parity target and the relay among the discovered +functions. + Every target gets a pass/fail verdict; nothing here defers. A missing build directory, a missing or unreadable zip, a function that does not exist, or a response carrying no `CodeSha256` is a `fail`. Two coverage checks compare the resource names that reached a verdict against independently obtained @@ -24,8 +32,8 @@ * `python3 -m scripts.smoke.deployed_parity --json` -- the Layer 4 inventory path (`scripts/verify_deployment.sh`), emitting the pinned per-check record shape with provenance. * `python3 -m scripts.smoke.deployed_parity --deploy-gate` -- the post-apply gate - `scripts/deploy.sh` runs. Same comparison over the same targets, but it needs no Terraform - outputs file (it reads nothing but the zips and the Lambda API). + `scripts/deploy.sh` runs. Same code comparison over the same targets, but it needs no Terraform + outputs file (it reads nothing but the zips and the Lambda API) and emits no runtime rows. No AWS account id is written to the output: function names, digests, sizes and timestamps only. """ @@ -36,23 +44,27 @@ import base64 import hashlib import os +import re import sys -from collections.abc import Iterable, Mapping, Sequence +from collections.abc import Iterable, Iterator, Mapping, Sequence from dataclasses import dataclass from pathlib import Path from typing import Any, Final import boto3 from botocore.exceptions import BotoCoreError, ClientError +from scripts.check_lambda_zip_imports import TARGET_PYTHON_VERSION +from scripts.smoke.eni_function_code_deny import PROBE_PREFIX from scripts.smoke.harness import ( CheckResult, SmokeContext, + aws_error_code, resolve_profile, resolve_region, run_main, smoke_client_config, ) -from scripts.smoke.lambda_actions import function_name_for +from scripts.smoke.lambda_actions import FUNCTION_NAME_PREFIX, function_name_for from crm.toolspec.definitions import ALL_TOOLS @@ -81,6 +93,23 @@ ) +#: The check name every per-function runtime verdict publishes. +RUNTIME_CHECK: Final[str] = "lambda_runtime" + +#: The check name of the runtime coverage verdict. +RUNTIME_COVERAGE_CHECK: Final[str] = "lambda_runtime_coverage" + +#: The streaming relay's function name, as `infra/main.tf` declares it; its runtime is Node.js. +RELAY_FUNCTION: Final[str] = f"{FUNCTION_NAME_PREFIX}agent-relay" + +#: The Terraform file whose `variable "runtime"` default is the relay's expected runtime. +RELAY_VARIABLES_TF: Final[Path] = REPO_ROOT / "infra" / "modules" / "agent_relay" / "variables.tf" + +_RELAY_RUNTIME_DEFAULT: Final[re.Pattern[str]] = re.compile( + r'(?ms)^variable\s+"runtime"\s*\{.*?default\s*=\s*"(nodejs\d+\.x)"' +) + + @dataclass(frozen=True) class ParityTarget: """One (deployed function, local zip) pair to compare.""" @@ -155,8 +184,7 @@ def deployed_code(client: Any, function_name: str) -> DeployedCode: try: configuration = client.get_function_configuration(FunctionName=function_name) except ClientError as exc: - code = str(exc.response.get("Error", {}).get("Code", "")) - if code == "ResourceNotFoundException": + if aws_error_code(exc) == "ResourceNotFoundException": raise LookupError( f"function {function_name!r} does not exist in this account/region — parity cannot " "be established (never read as a pass)" @@ -165,8 +193,8 @@ def deployed_code(client: Any, function_name: str) -> DeployedCode: sha = str(configuration.get("CodeSha256") or "") if not sha: raise LookupError( - f"Lambda reported no CodeSha256 for {function_name!r}: {configuration!r} — parity " - "cannot be established (never read as a pass)" + f"Lambda reported no CodeSha256 for {function_name!r} (response keys: " + f"{sorted(configuration)}) — parity cannot be established (never read as a pass)" ) return DeployedCode( code_sha256=sha, @@ -203,7 +231,7 @@ def _compare(client: Any, target: ParityTarget) -> tuple[bool | None, str]: except (ClientError, BotoCoreError) as exc: return None, ( f"lambda:GetFunctionConfiguration for {target.function_name!r} failed " - f"({type(exc).__name__}: {exc}) — parity cannot be established" + f"({aws_error_code(exc)}) — parity cannot be established" ) local_size = _local_size(target.zip_path) @@ -350,20 +378,152 @@ def _non_tool_verdict_resources(results: Iterable[CheckResult]) -> tuple[str, .. def checks(ctx: SmokeContext, *, directory: Path | None = None) -> Iterable[CheckResult]: - """Yield the build-directory check, one verdict per function, and both coverage checks. + """Yield the build-directory check, one parity verdict per function, both parity coverage + checks, then one runtime verdict per discovered function and the runtime coverage check. Every target is evaluated even when an earlier one failed, so the inventory stays complete. """ resolved = build_dir(directory) yield check_build_dir(resolved) client = ctx.client("lambda") + targets = parity_targets(resolved) emitted: list[CheckResult] = [] - for target in parity_targets(resolved): + for target in targets: result = check_parity_target(client, target) emitted.append(result) yield result yield check_coverage(_action_verdict_resources(emitted)) yield check_non_tool_coverage(_non_tool_verdict_resources(emitted)) + yield from runtime_checks(client, targets) + + +def expected_python_runtime() -> str: + """Return the Lambda runtime every Python function must report, e.g. `python3.14`.""" + major, minor = TARGET_PYTHON_VERSION + return f"python{major}.{minor}" + + +def expected_relay_runtime(variables_tf: Path | None = None) -> str: + """Return the relay's `nodejs.x` runtime from its Terraform `variable "runtime"` default. + + `variables_tf` defaults to `RELAY_VARIABLES_TF`. Raises `LookupError` when the file is + unreadable or declares no such default. + """ + if variables_tf is None: + variables_tf = RELAY_VARIABLES_TF + try: + text = variables_tf.read_text(encoding="utf-8") + except OSError as exc: + raise LookupError(f"cannot read {variables_tf} ({type(exc).__name__}: {exc})") from exc + match = _RELAY_RUNTIME_DEFAULT.search(text) + if match is None: + raise LookupError( + f'no `variable "runtime"` with a `default = "nodejs.x"` in {variables_tf}' + ) + return match.group(1) + + +def discovered_functions(client: Any) -> dict[str, str]: + """Return `{function name: Runtime}` for every `crm-agent-eval-*` function, probes excluded. + + Pages `lambda:ListFunctions` to the end. A function reporting no `Runtime` maps to `""`. + Lets `ClientError`/`BotoCoreError` propagate. + """ + functions: dict[str, str] = {} + marker: str | None = None + while True: + page = client.list_functions(**({"Marker": marker} if marker else {})) + for function in page.get("Functions", []): + name = str(function.get("FunctionName", "")) + if name.startswith(FUNCTION_NAME_PREFIX) and not name.startswith(PROBE_PREFIX): + functions[name] = str(function.get("Runtime") or "") + marker = page.get("NextMarker") + if not marker: + return functions + + +def check_runtime(function_name: str, runtime: str, expected: str) -> CheckResult: + """Return the pass/fail verdict for one function's deployed runtime against `expected`.""" + if runtime == expected: + return CheckResult( + resource=function_name, + check=RUNTIME_CHECK, + status="pass", + detail=f"{function_name}: deployed Runtime {runtime} == expected {expected}", + ) + return CheckResult( + resource=function_name, + check=RUNTIME_CHECK, + status="fail", + detail=( + f"{function_name}: deployed Runtime {runtime or ''} != expected {expected} — " + "the function runs on a runtime this source tree does not target; apply the current IaC" + ), + ) + + +def check_runtime_coverage(discovered: Iterable[str], required: Iterable[str]) -> CheckResult: + """Assert every `required` function name is among the `discovered` ones.""" + found = set(discovered) + wanted = sorted(set(required)) + missing = sorted(set(wanted) - found) + if wanted and not missing: + return CheckResult( + resource=RESOURCE_CLASS, + check=RUNTIME_COVERAGE_CHECK, + status="pass", + detail=( + f"all {len(wanted)} parity target(s) and the relay are among the {len(found)} " + f"discovered {FUNCTION_NAME_PREFIX}* function(s)" + ), + ) + return CheckResult( + resource=RESOURCE_CLASS, + check=RUNTIME_COVERAGE_CHECK, + status="fail", + detail=( + f"{len(missing)} of {len(wanted)} required function(s) not discovered by " + f"lambda:ListFunctions — a runtime that was never read is never a pass " + f"(missing={missing})" + ), + ) + + +def runtime_checks(client: Any, targets: Iterable[ParityTarget]) -> Iterator[CheckResult]: + """Yield one `lambda_runtime` verdict per discovered function, then the coverage verdict.""" + required = [*(t.function_name for t in targets), RELAY_FUNCTION] + try: + functions = discovered_functions(client) + except (ClientError, BotoCoreError) as exc: + yield CheckResult( + resource=RESOURCE_CLASS, + check=RUNTIME_COVERAGE_CHECK, + status="fail", + detail=( + f"lambda:ListFunctions failed ({aws_error_code(exc)}) — no function's " + "runtime could be read" + ), + ) + return + python_runtime = expected_python_runtime() + try: + relay_runtime: str | None = expected_relay_runtime() + relay_error = "" + except LookupError as exc: + relay_runtime, relay_error = None, str(exc) + for name in sorted(functions): + if name != RELAY_FUNCTION: + yield check_runtime(name, functions[name], python_runtime) + elif relay_runtime is not None: + yield check_runtime(name, functions[name], relay_runtime) + else: + yield CheckResult( + resource=name, + check=RUNTIME_CHECK, + status="fail", + detail=f"the relay's expected runtime is unknown: {relay_error}", + ) + yield check_runtime_coverage(functions, required) def deploy_gate( diff --git a/scripts/smoke/dynamodb_principal_deny.py b/scripts/smoke/dynamodb_principal_deny.py index 534aa60..0ef57e7 100644 --- a/scripts/smoke/dynamodb_principal_deny.py +++ b/scripts/smoke/dynamodb_principal_deny.py @@ -8,7 +8,8 @@ * the operator ARNs from the `crm_operator_principal_arns` output (the shape rows defer while it is absent, that is, before the apply); * the data-plane roles from the account: the execution role of every `crm-agent-eval-*` Lambda that - holds an inline policy named `-dynamodb-kms`. + holds an inline policy named `-dynamodb-kms`, plus the AgentCore Runtime's execution + role, read with `get-agent-runtime` for the `agentcore_runtime_arn` output. Rows: @@ -18,6 +19,7 @@ * `table_sse_enabled:

`: `TableStatus == ACTIVE`, no `InaccessibleEncryptionDateTime`, and `SSEDescription.Status == ENABLED`. * `data_plane_roles_discovered`: at least one role was found. +* `runtime_role_discovered`: the Runtime's execution role was read from the account. * `operator_data_plane_admitted`: the operator's `GetItem` on a non-existent key succeeds. * `probe_denied:`: a run-scoped role `crm-agent-eval-probe-`, trusted by the operator only and holding an identity Allow for exactly the probed actions, is refused with "explicit deny @@ -48,6 +50,8 @@ Deadline, ExpectedCheckCount, SmokeContext, + aws_error_code, + aws_error_detail, error_code, run_main, smoke_client_config, @@ -60,6 +64,7 @@ TABLE_NAMES_OUTPUT: Final[str] = "dynamodb_table_names" OPERATOR_ARNS_OUTPUT: Final[str] = "crm_operator_principal_arns" +RUNTIME_ARN_OUTPUT: Final[str] = "agentcore_runtime_arn" FUNCTION_PREFIX: Final[str] = "crm-agent-eval-" DYNAMODB_KMS_POLICY_SUFFIX: Final[str] = "-dynamodb-kms" @@ -379,7 +384,7 @@ def caller_identity(ctx: SmokeContext) -> CallerIdentity: arn = str(ctx.client("sts").get_caller_identity()["Arn"]) parts = arn.split(":", 5) if len(parts) != 6: - raise ValueError(f"caller ARN {arn!r} is not an ARN") + raise ValueError("the caller ARN is not an ARN") partition, service, account, resource = parts[1], parts[2], parts[4], parts[5] if service == "sts" and resource.startswith("assumed-role/"): role_name = resource.split("/")[1] @@ -387,7 +392,10 @@ def caller_identity(ctx: SmokeContext) -> CallerIdentity: return CallerIdentity(account=account, partition=partition, principal_arn=role_arn) if service == "iam" and resource.startswith("user/"): return CallerIdentity(account=account, partition=partition, principal_arn=arn) - raise ValueError(f"caller {arn!r} is neither an assumed role nor an IAM user") + raise ValueError( + f"the caller ({service}:{resource.partition('/')[0]}) is neither an assumed role nor an " + "IAM user" + ) def discover_data_plane_roles(ctx: SmokeContext) -> frozenset[str]: @@ -410,6 +418,24 @@ def discover_data_plane_roles(ctx: SmokeContext) -> frozenset[str]: return frozenset(roles) +def discover_runtime_role(ctx: SmokeContext) -> tuple[str | None, str]: + """The Runtime's execution-role ARN from `get-agent-runtime`, or `None` with the reason.""" + runtime_arn = ctx.outputs.get(RUNTIME_ARN_OUTPUT) + if not isinstance(runtime_arn, str) or "/" not in runtime_arn: + return None, f"the {RUNTIME_ARN_OUTPUT} output is absent or not a runtime ARN" + runtime_id = runtime_arn.rpartition("/")[2] + try: + runtime = ctx.client("bedrock-agentcore-control").get_agent_runtime( + agentRuntimeId=runtime_id + ) + except Exception as exc: # noqa: BLE001 - reported as a failing row + return None, aws_error_detail("bedrock-agentcore-control:GetAgentRuntime", exc) + role_arn = runtime.get("roleArn") + if not isinstance(role_arn, str) or ":role/" not in role_arn: + return None, "get-agent-runtime returned no roleArn" + return role_arn, f"the Runtime {runtime_id} runs as {role_arn}" + + def _operator_arns(ctx: SmokeContext) -> tuple[frozenset[str] | None, str]: """The operator ARNs from the outputs, or `None` with a reason (absent or malformed).""" raw = ctx.outputs.get(OPERATOR_ARNS_OUTPUT) @@ -436,7 +462,7 @@ def _describe_tables( resource=physical, check="describe_table", status="fail", - detail=f"describe_table raised {type(exc).__name__}: {exc}", + detail=aws_error_detail("dynamodb:DescribeTable", exc), ) ) continue @@ -508,7 +534,7 @@ def _shape_row( resource=resource, check=check, status="fail", - detail=f"reading the policy raised {error_code(exc) or type(exc).__name__}: {exc}", + detail=aws_error_detail("reading the resource policy", exc), ), None, ) @@ -541,7 +567,7 @@ def _operator_admitted_row(ctx: SmokeContext, target: TableTarget, run_id: str) resource=target.physical, check=check, status="fail", - detail=f"the operator's GetItem raised {error_code(exc) or type(exc).__name__}: {exc}", + detail=aws_error_detail("the operator's dynamodb:GetItem", exc), ) return CheckResult( resource=target.physical, check=check, status="pass", detail="GetItem returned 200" @@ -646,13 +672,13 @@ def classify_probe( ) code = error_code(outcome) message = str((getattr(outcome, "response", {}) or {}).get("Error", {}).get("Message", "")) - quoted = f"{code}: {message}" if code else f"{type(outcome).__name__}: {outcome}" + reported_code = aws_error_code(outcome) if code in _REACHED_RESOURCE_CODES: return CheckResult( resource=resource, check=check, status="fail", - detail=f"the call reached the resource, no boundary refused it ({quoted})", + detail=f"the call reached the resource, no boundary refused it ({reported_code})", ) if code in {"AccessDeniedException", "AccessDenied"}: lowered = message.lower() @@ -662,22 +688,30 @@ def classify_probe( resource=resource, check=check, status="fail", - detail=f"the denial does not name the probe role {probe_role} ({quoted})", + detail=f"the denial does not name the probe role {probe_role} ({reported_code})", ) - return CheckResult(resource=resource, check=check, status="pass", detail=quoted) + return CheckResult( + resource=resource, + check=check, + status="pass", + detail=( + f"{reported_code}: an explicit deny in a resource-based policy naming the probe role " + f"{probe_role}" + ), + ) if "because no " in lowered and "policy allows" in lowered: return CheckResult( resource=resource, check=check, status="fail", - detail=f"an implicit deny, not the resource-based Deny ({quoted})", + detail=f"an implicit deny, not the resource-based Deny ({reported_code})", ) return CheckResult( resource=resource, check=check, status=DEFER, defer_reason=DEFER_PROBE_UNCLASSIFIED, - detail=quoted, + detail=f"unclassified error ({reported_code})", ) @@ -777,8 +811,7 @@ def _delete_probe_role(ctx: SmokeContext, role_name: str) -> CheckResult: check=check, status="fail", detail=( - f"deleting probe role {role_name} raised {error_code(exc) or type(exc).__name__}: " - f"{exc}. Delete it by hand." + f"{aws_error_detail(f'deleting probe role {role_name}', exc)}. Delete it by hand." ), ) return CheckResult( @@ -836,8 +869,7 @@ def _probe( check="probe_role_setup", status="fail", detail=( - f"setting up the probe raised {error_code(exc) or type(exc).__name__}: {exc}; " - "no probe call was classified" + f"{aws_error_detail('setting up the probe', exc)}; no probe call was classified" ), ) ) @@ -871,6 +903,15 @@ def run_checks( status="pass" if discovered else "fail", detail=f"{len(discovered)} execution role(s) hold a {DYNAMODB_KMS_POLICY_SUFFIX} policy", ) + runtime_role, runtime_detail = discover_runtime_role(ctx) + yield CheckResult( + resource=RESOURCE_CLASS, + check="runtime_role_discovered", + status="pass" if runtime_role else "fail", + detail=runtime_detail, + ) + if runtime_role: + discovered = discovered | {runtime_role} operators, operator_reason = _operator_arns(ctx) data_plane = discovered | operators if operators is not None else None @@ -954,14 +995,14 @@ def checks(ctx: SmokeContext) -> Iterable[CheckResult]: def expected_check_count(ctx: SmokeContext) -> ExpectedCheckCount: - """Two rows per table, plus the key, discovery, operator, five probe and deletion rows.""" + """Two rows per table, plus the key, two discovery, operator, five probe and deletion rows.""" tables = len(ctx.outputs.require_mapping(TABLE_NAMES_OUTPUT)) return ExpectedCheckCount( - minimum=2 * tables + 4 + len(PROBE_CALLS), + minimum=2 * tables + 5 + len(PROBE_CALLS), basis=( f"2 x {tables} tables in {TABLE_NAMES_OUTPUT} + key_policy_shape + " - f"data_plane_roles_discovered + operator_data_plane_admitted + {len(PROBE_CALLS)} " - "probe calls + probe_role_deleted" + "data_plane_roles_discovered + runtime_role_discovered + operator_data_plane_admitted + " + f"{len(PROBE_CALLS)} probe calls + probe_role_deleted" ), ) diff --git a/scripts/smoke/dynamodb_tables.py b/scripts/smoke/dynamodb_tables.py index d358737..9dac413 100644 --- a/scripts/smoke/dynamodb_tables.py +++ b/scripts/smoke/dynamodb_tables.py @@ -15,7 +15,7 @@ from collections.abc import Iterable, Mapping, Sequence from typing import Any, Final -from scripts.smoke.harness import CheckResult, SmokeContext, run_main +from scripts.smoke.harness import CheckResult, SmokeContext, aws_error_detail, run_main from crm.store.schema import TABLE_NAMES, GlobalSecondaryIndex, table_schema @@ -236,7 +236,7 @@ def _check_gsi_queryable( resource=table_name, check=check_name, status="fail", - detail=f"query against GSI {gsi.name!r} raised: {exc}", + detail=f"{aws_error_detail('dynamodb:Query', exc)} against GSI {gsi.name!r}", ) return CheckResult(resource=table_name, check=check_name, status="pass") @@ -268,7 +268,7 @@ def checks(ctx: SmokeContext) -> Iterable[CheckResult]: resource=physical_name, check="describe_table", status="fail", - detail=f"describe_table raised: {exc}", + detail=aws_error_detail("dynamodb:DescribeTable", exc), ) ) continue diff --git a/scripts/smoke/eni_function_code_deny.py b/scripts/smoke/eni_function_code_deny.py index b45182b..c07ea5c 100644 --- a/scripts/smoke/eni_function_code_deny.py +++ b/scripts/smoke/eni_function_code_deny.py @@ -33,7 +33,14 @@ from collections.abc import Callable, Iterator, Mapping, Sequence from typing import Any, Final -from scripts.smoke.harness import ExpectedCheckCount, SmokeContext, error_code, run_main +from scripts.smoke.harness import ( + ExpectedCheckCount, + SmokeContext, + aws_error_detail, + error_code, + run_main, +) +from scripts.smoke.lambda_actions import _function_error_detail from eval.verification import CheckResult @@ -257,7 +264,9 @@ def _delete_if_present(lambda_client: Any, name: str) -> None: lambda_client.delete_function(FunctionName=name) except Exception as exc: if error_code(exc) != "ResourceNotFoundException": - sys.stderr.write(f"{RESOURCE_CLASS}: delete_function({name}) raised {exc}\n") + sys.stderr.write( + f"{RESOURCE_CLASS}: {aws_error_detail('lambda:DeleteFunction', exc)} for {name}\n" + ) def check_live_probe( @@ -288,7 +297,7 @@ def check_live_probe( attempted = True lambda_client.create_function( FunctionName=name, - Runtime="python3.13", + Runtime="python3.14", Role=source_config["Role"], Handler="probe.handler", Code={"ZipFile": _probe_zip()}, @@ -299,7 +308,9 @@ def check_live_probe( Tags={"data-classification": "internal", PROBE_TAG: run_id}, ) except Exception as exc: # noqa: BLE001 - reported as the failing row - yield _result(name, "probe_created_active", False, f"create_function failed: {exc}") + yield _result( + name, "probe_created_active", False, aws_error_detail("lambda:CreateFunction", exc) + ) return config = _wait_active(lambda_client, name, clock=clock, sleeper=sleeper) probe_vpc = config.get("VpcConfig") or {} @@ -326,16 +337,19 @@ def check_live_probe( except json.JSONDecodeError: payload = {} outcomes = payload if isinstance(payload, dict) else {} + probed = ("describe_subnets", "delete_network_interface") ok = function_error is None and all( - outcomes.get(call) == EXPECTED_PROBE_ERROR - for call in ("describe_subnets", "delete_network_interface") + outcomes.get(call) == EXPECTED_PROBE_ERROR for call in probed ) + if function_error is not None: + observed = _function_error_detail(str(function_error), raw) + else: + observed = "outcomes=" + repr({call: outcomes.get(call) for call in probed}) yield _result( name, "probe_code_denied_eni_actions", ok, - f"FunctionError={function_error!r}, outcomes={outcomes or raw[:200]!r} " - f"(expected {EXPECTED_PROBE_ERROR} for both)", + f"{observed} (expected {EXPECTED_PROBE_ERROR} for both)", ) finally: if attempted: diff --git a/scripts/smoke/eval_sfn.py b/scripts/smoke/eval_sfn.py index 902d974..9018e7f 100644 --- a/scripts/smoke/eval_sfn.py +++ b/scripts/smoke/eval_sfn.py @@ -13,6 +13,11 @@ holds rows; - the record reaches `completed` with `tasks_done == tasks_total` = arms x repeats x tasks, `repeats` recorded, both arms in the matrix and `tier_summary` for every tier; + - `matrix_is_record_shape_3`: the matrix and every arm carry `record_shape_version` 3, every arm a + non-empty `provenance.prompt_caching`, every tier's `tier_summary` integer + `total_prompt_tokens`/`cache_read_tokens`/`cache_write_tokens`, and every tier's + `tier_task_metrics.by_tier` entry `budget_exhausted_task_count`, `truncated_tool_call_count` and + `truncated_task_count` (integers; both truncation counts `null` at the subagent tier); - each arm's `provenance.effort` is `DEFAULT_ARM_EFFORT`, one `arm_effort_is_default:` row per default-sweep family (arms in sweep order); - each arm's models are `config/models.yaml`'s, one `arm_models_are_configured:` row per @@ -30,6 +35,8 @@ - `status_carries_tier_comparison_table`: the completed run's `status` payload carries `tier_comparison_table` with headers `Metric` plus one column per arm, the Supervisor, Subagent and ToolCall sections in that order, and every row as wide as the headers; + - `subagent_table_has_no_delegation_outcome_rows`: that table's Subagent section has rows and + none labelled `Delegation outcome…`; - `matrix_md_download_is_attachment` and `matrix_md_download_bytes_match_artefact`: `artefact_url` with `download: true` for the recorded `matrix_md` signs a URL whose https GET answers `Content-Disposition: attachment`, with bytes equal to those of the plain URL's GET; @@ -58,9 +65,11 @@ stops after the pre-checks, submits nothing and exits non-zero. Run once without it to read the mode, judge it, then re-run with it; - exactly one `submit {mode: live, confirmed: true}`, never retried; -- poll to terminal, then assert `completed` 40/40, both arms, `tier_summary` per tier, cost spent, - tenant torn down, `canary` empty, and `assert_artifacts` on the downloaded S3 artifacts. -A `failed` run is reported with its failure summary. +- poll to terminal, then assert `completed` 40/40, both arms, `tier_summary` per tier, record + shape 3, cost spent, tenant torn down, `canary` empty, and `assert_artifacts` on the downloaded + S3 artifacts. +A `failed` run is reported with its status and the classification of its `error` field +(:func:`error_classification`), never the error text. Cleanup runs in a `finally`, each step's error reported as a failing row: - any run still non-terminal is cancelled cooperatively and reported as a failure; @@ -100,7 +109,13 @@ simulation_result, summarise, ) -from scripts.smoke.harness import CheckResult, ExpectedCheckCount, SmokeContext, run_main +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + SmokeContext, + exception_detail, + run_main, +) from scripts.smoke.iam_roles import ( INDEX_IN_SCOPE_LEADING_KEY, SWEEP_GRANT_LOCALS, @@ -118,7 +133,7 @@ from crm.store.keys import SWEEP_LOCK_ROW_ID from crm.store.schema import TABLES, TENANT_SCOPED_TABLES from eval.harness import ArtifactAssertionError, assert_artifacts -from eval.matrix import TIER_TASK_METRICS_KEY +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY, TIER_TASK_METRICS_KEY from eval.runs import EVAL_RESULTS_TABLE, EVAL_RUNS_TABLE, MAX_SWEEP_REPEATS, execution_arn_for from eval.sweep_units import DEFAULT_ARM_EFFORT from eval.tenancy import ( @@ -206,6 +221,36 @@ def _row(check: str, ok: bool, detail: str, *, resource: str = RESOURCE_CLASS) - ) +_STEP_FAILED_PREFIX: Final[str] = "step failed: " +_ERROR_CLASS_TOKEN: Final[re.Pattern[str]] = re.compile( + r"([A-Za-z_][A-Za-z0-9_.]{0,127})(?=: |;|$)" +) + + +def error_classification(error: object) -> str | None: + """A message-free stand-in for a run record's `error` field. + + Returns `None` when the field is absent or empty, `"present ()"` when the text (after an + optional `step failed: ` prefix) starts with an identifier-shaped token followed by `": "`, + `";"` or the end of the text, and `"present"` otherwise. No other part of the text is returned. + """ + if error is None or error == "": + return None + if not isinstance(error, str): + return "present" + match = _ERROR_CLASS_TOKEN.match(error.removeprefix(_STEP_FAILED_PREFIX)) + return f"present ({match.group(1)})" if match else "present" + + +def _run_for_detail(run: Mapping[str, Any]) -> dict[str, Any]: + """A copy of a run record safe to render into a detail: `error` replaced by its + :func:`error_classification`.""" + rendered = dict(run) + if "error" in rendered: + rendered["error"] = error_classification(rendered["error"]) + return rendered + + class RunStatusError(RuntimeError): """`status` refused the admin (401/403) or kept answering non-200.""" @@ -231,7 +276,7 @@ def poll_run( while True: try: status, payload = api.status(run_id) - except (OSError, http.client.HTTPException): + except OSError, http.client.HTTPException: errors += 1 if errors >= POLL_MAX_CONSECUTIVE_ERRORS: raise @@ -345,7 +390,98 @@ def check_completed_record( f"status={run.get('status')!r} done={run.get('tasks_done')}/{run.get('tasks_total')} " f"(expected {expected_total}) failed={run.get('tasks_failed')} " f"teardown={run.get('teardown_status')!r} arms={len(arms) if isinstance(arms, list) else None}" - f"/{arm_count} tier_summary_per_tier={tiers_ok} error={run.get('error')!r}", + f"/{arm_count} tier_summary_per_tier={tiers_ok} error={error_classification(run.get('error'))!r}", + ) + + +#: Integer token totals every arm's `tier_summary[]` carries in the current record shape. +RECORD_SHAPE_TIER_SUMMARY_FIELDS: Final[tuple[str, ...]] = ( + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", +) + +#: Per-tier counts every arm's `tier_task_metrics.by_tier[]` carries, each mapped to the tiers +#: where it is `null`; it is an integer at every other tier. +RECORD_SHAPE_TIER_TASK_FIELDS: Final[Mapping[str, frozenset[str]]] = { + "budget_exhausted_task_count": frozenset(), + "truncated_tool_call_count": frozenset({"subagent"}), + "truncated_task_count": frozenset({"subagent"}), +} + + +def _is_count(value: object) -> bool: + return isinstance(value, int) and not isinstance(value, bool) + + +def record_shape_problems(run: Mapping[str, Any]) -> list[str]: + """Every way the run's `matrix` falls short of the current record shape; empty when it holds. + + Requires `record_shape_version` on the matrix and on each arm, a non-empty + `provenance.prompt_caching` string per arm, the integer token totals of + :data:`RECORD_SHAPE_TIER_SUMMARY_FIELDS` per tier, and the per-tier counts of + :data:`RECORD_SHAPE_TIER_TASK_FIELDS`, `null` exactly where that map says so. + """ + matrix = run.get("matrix") + if not isinstance(matrix, Mapping): + return ["matrix absent"] + problems: list[str] = [] + if matrix.get(RECORD_SHAPE_VERSION_KEY) != RECORD_SHAPE_VERSION: + problems.append( + f"matrix.{RECORD_SHAPE_VERSION_KEY}={matrix.get(RECORD_SHAPE_VERSION_KEY)!r}" + ) + arms = matrix.get("arms") + if not isinstance(arms, list) or not arms: + return [*problems, "matrix.arms absent or empty"] + for index, arm in enumerate(arms): + where = f"arms[{index}]" + if not isinstance(arm, Mapping): + problems.append(f"{where} not an object") + continue + if arm.get(RECORD_SHAPE_VERSION_KEY) != RECORD_SHAPE_VERSION: + problems.append( + f"{where}.{RECORD_SHAPE_VERSION_KEY}={arm.get(RECORD_SHAPE_VERSION_KEY)!r}" + ) + caching = (_mapping(arm, "provenance") or {}).get("prompt_caching") + if not (isinstance(caching, str) and caching): + problems.append(f"{where}.provenance.prompt_caching={caching!r}") + summary = _mapping(arm, "tier_summary") + by_tier = _mapping(_mapping(arm, TIER_TASK_METRICS_KEY), "by_tier") + for tier in TIERS: + entry = _mapping(summary, tier) or {} + problems.extend( + f"{where}.tier_summary.{tier}.{field}={entry.get(field)!r}" + for field in RECORD_SHAPE_TIER_SUMMARY_FIELDS + if not _is_count(entry.get(field)) + ) + metrics = _mapping(by_tier, tier) + for field, null_tiers in RECORD_SHAPE_TIER_TASK_FIELDS.items(): + value = (metrics or {}).get(field, ...) + ok = ( + metrics is not None + and field in metrics + and (value is None if tier in null_tiers else _is_count(value)) + ) + if not ok: + shown = "absent" if value is ... else repr(value) + expected = "null" if tier in null_tiers else "an integer" + problems.append( + f"{where}.{TIER_TASK_METRICS_KEY}.by_tier.{tier}.{field}={shown} " + f"(expected {expected})" + ) + return problems + + +def check_record_shape(run: Mapping[str, Any]) -> CheckResult: + """The completed run's `matrix` is the current record shape (:func:`record_shape_problems`).""" + problems = record_shape_problems(run) + return _row( + f"matrix_is_record_shape_{RECORD_SHAPE_VERSION}", + not problems, + "; ".join(problems) + if problems + else f"matrix and every arm carry {RECORD_SHAPE_VERSION_KEY}={RECORD_SHAPE_VERSION} " + "and every required field", ) @@ -564,7 +700,11 @@ def check_tenant_emptied_by_the_workers_own_role( try: catalog = store.get_item(EVAL_RUNS_TABLE, {"run_id": run_id}) except Exception as exc: # noqa: BLE001 - an unreadable discriminator is a failing row - return _row(check, False, f"eval_runs catalog row unreadable: {type(exc).__name__}: {exc}") + return _row( + check, + False, + f"eval_runs catalog row unreadable: {exception_detail(exc)}", + ) lifecycle = str(catalog.get("status") or "absent") if isinstance(catalog, Mapping) else "absent" by_tenant = { name: {table: n for table, n in tenant_row_counts(store, name).items() if n} @@ -609,7 +749,9 @@ def check_unit_tenants_recorded( catalog = store.get_item(EVAL_RUNS_TABLE, {"run_id": run_id}) except Exception as exc: # noqa: BLE001 - an unreadable catalog row is a failing row return _row( - check, False, f"eval_runs catalog row unreadable: {type(exc).__name__}: {exc}" + check, + False, + f"eval_runs catalog row unreadable: {exception_detail(exc)}", ), () raw = catalog.get("unit_tenants") if isinstance(catalog, Mapping) else None recorded = tuple(str(t) for t in raw) if isinstance(raw, list | tuple) else () @@ -767,7 +909,9 @@ def check_artefact_url( key = raw[0] if isinstance(raw, list) and raw and isinstance(raw[0], str) else None if not run_id or key is None: yield _row( - "artefact_url_issued", False, f"no recorded artefact to sign ({summarise(run, 160)})" + "artefact_url_issued", + False, + f"no recorded artefact to sign ({summarise(_run_for_detail(run), 160)})", ) return status, payload = api.artefact_url(run_id, key) @@ -813,6 +957,34 @@ def check_artefact_url( #: The `tier_comparison_table` sections a completed run carries, in order. TIER_TABLE_SECTIONS: Final[tuple[str, ...]] = ("supervisor", "subagent", "tool") +#: Label prefix of a row the Subagent section must not carry. +DELEGATION_OUTCOME_ROW_PREFIX: Final[str] = "Delegation outcome" + + +def check_subagent_table_has_no_delegation_rows(run: Mapping[str, Any]) -> CheckResult: + """The `tier_comparison_table` Subagent section exists and has no "Delegation outcome" row.""" + check = "subagent_table_has_no_delegation_outcome_rows" + table = run.get("tier_comparison_table") + sections = table.get("sections") if isinstance(table, Mapping) else None + subagent = [ + section + for section in (sections if isinstance(sections, list) else []) + if isinstance(section, Mapping) and section.get("tier") == "subagent" + ] + if len(subagent) != 1 or not isinstance(subagent[0].get("rows"), list): + return _row(check, False, f"expected one subagent section with rows, found {len(subagent)}") + labels = [row[0] for row in subagent[0]["rows"] if isinstance(row, list) and row] + delegation = [ + label + for label in labels + if isinstance(label, str) and label.startswith(DELEGATION_OUTCOME_ROW_PREFIX) + ] + return _row( + check, + bool(labels) and not delegation, + f"subagent rows {labels!r}; delegation-outcome rows {delegation!r}", + ) + def check_tier_comparison_table(run: Mapping[str, Any], *, arm_count: int) -> CheckResult: """The `status` payload carries `tier_comparison_table`: `Metric` plus one header per arm, the @@ -888,7 +1060,7 @@ def check_matrix_md_download( artifacts = run.get("artifacts") key = artifacts.get("matrix_md") if isinstance(artifacts, Mapping) else None if not run_id or not isinstance(key, str) or not key: - detail = f"the run recorded no matrix_md artefact ({summarise(run, 160)})" + detail = f"the run recorded no matrix_md artefact ({summarise(_run_for_detail(run), 160)})" yield _row(attachment, False, detail) yield _row(matches, False, detail) return @@ -1362,7 +1534,7 @@ def explicit_deny_result(iam: Any, row: SimulationRow, *, resource: str) -> Chec resource=resource, check=row.check, status="fail", - detail=f"simulate_principal_policy raised {type(exc).__name__}: {exc} ({subject})", + detail=f"{exception_detail(exc, 'iam:SimulatePrincipalPolicy')} ({subject})", ) decisive = decisive_missing_keys(row.action, missing) unset = f"; MissingContextValues={list(decisive)}" if decisive else "" @@ -1551,14 +1723,22 @@ def _reap_tenant(store: Any, tenant: str) -> Iterator[CheckResult]: try: residual = sum(tenant_row_counts(store, tenant).values()) except Exception as exc: # noqa: BLE001 - surfaced as a failing check - yield _row("leftover_tenant_counted", False, f"{tenant}: {type(exc).__name__}: {exc}") + yield _row( + "leftover_tenant_counted", + False, + f"{tenant}: {exception_detail(exc)}", + ) return if not residual: return try: teardown_tenant(store, tenant=tenant) except Exception as exc: # noqa: BLE001 - surfaced as a failing check - yield _row("leftover_tenant_reaped", False, f"{tenant}: {type(exc).__name__}: {exc}") + yield _row( + "leftover_tenant_reaped", + False, + f"{tenant}: {exception_detail(exc)}", + ) return yield _row( "leftover_tenant_reaped", @@ -1597,7 +1777,7 @@ def _settle_runs( else: cancel_status = 0 except Exception as exc: # noqa: BLE001 - surfaced as a failing check - yield _row("run_settled", False, f"{run_id}: {type(exc).__name__}: {exc}") + yield _row("run_settled", False, f"{run_id}: {exception_detail(exc)}") continue if cancel_status: yield _row( @@ -1671,10 +1851,11 @@ def _rehearsal( yield _row( "rehearsal_reached_terminal", False, - f"not terminal after {poll_seconds:.0f}s: {summarise(run, 200)}", + f"not terminal after {poll_seconds:.0f}s: {summarise(_run_for_detail(run), 200)}", ) return yield check_completed_record(run, expected_total=expected_total, arm_count=len(families)) + yield check_record_shape(run) yield check_run_repeats(run, expected=repeats) yield from check_arm_efforts(run, families) yield from check_arm_models(run, families) @@ -1702,6 +1883,7 @@ def _rehearsal( ) yield from check_artefact_url(api, run, fetch=fetch) yield check_tier_comparison_table(run, arm_count=len(families)) + yield check_subagent_table_has_no_delegation_rows(run) yield from check_matrix_md_download(api, run, get=artefact_get) yield check_tenant_empty(store, tenant, check="rehearsal_tenant_empty") yield check_tenant_emptied_by_the_workers_own_role(store, run_id, tenant, expected_units) @@ -1743,7 +1925,7 @@ def _cancel_proof( "cancel_proof_reached_progress", False, f"run did not reach tasks_done>={CANCEL_AFTER_TASKS} while running: " - f"{summarise(progressed, 200)}", + f"{summarise(_run_for_detail(progressed), 200)}", ) return cancel_status, cancel_payload = api.cancel(run_id) @@ -1760,7 +1942,7 @@ def _cancel_proof( yield _row( "cancel_proof_reached_terminal", False, - f"not terminal after {STUB_POLL_SECONDS:.0f}s: {summarise(run, 200)}", + f"not terminal after {STUB_POLL_SECONDS:.0f}s: {summarise(_run_for_detail(run), 200)}", ) return yield check_cancelled_record(run, expected_total=expected_total) @@ -1819,7 +2001,7 @@ def checks( try: yield from simulate(ctx) except Exception as exc: # noqa: BLE001 - the sweep checks still run - yield _row("role_simulations", False, f"{type(exc).__name__}: {exc}") + yield _row("role_simulations", False, exception_detail(exc)) started: dict[str, str] = {} units: dict[str, tuple[str, ...]] = {} api: RunApi | None = None @@ -1827,7 +2009,7 @@ def checks( try: user = admin.provision() except Exception as exc: # noqa: BLE001 - one actionable failing check - yield _row("provision_admin_user", False, f"{type(exc).__name__}: {exc}") + yield _row("provision_admin_user", False, exception_detail(exc)) return yield _row("provision_admin_user", True, user.detail) api = RunApi(api_post, user.id_token) @@ -1986,7 +2168,7 @@ def live_once_checks( try: user = admin.provision() except Exception as exc: # noqa: BLE001 - one actionable failing check - yield _row("provision_admin_user", False, f"{type(exc).__name__}: {exc}") + yield _row("provision_admin_user", False, exception_detail(exc)) return yield _row("provision_admin_user", True, user.detail) api = RunApi(api_post, user.id_token) @@ -2010,10 +2192,11 @@ def live_once_checks( yield _row( "live_sweep_reached_terminal", False, - f"not terminal after {LIVE_POLL_SECONDS:.0f}s: {summarise(run, 200)}", + f"not terminal after {LIVE_POLL_SECONDS:.0f}s: {summarise(_run_for_detail(run), 200)}", ) return yield check_completed_record(run, expected_total=expected_total, arm_count=len(families)) + yield check_record_shape(run) cost = run.get("cost_spent_usd") yield _row( "live_cost_recorded", diff --git a/scripts/smoke/gateway_tools.py b/scripts/smoke/gateway_tools.py index da38313..367c439 100644 --- a/scripts/smoke/gateway_tools.py +++ b/scripts/smoke/gateway_tools.py @@ -58,7 +58,15 @@ import jwt from boto3.dynamodb.types import TypeDeserializer -from scripts.smoke.harness import DEFER, CheckResult, SmokeContext, open_https, run_main +from scripts.smoke.harness import ( + DEFER, + CheckResult, + SmokeContext, + aws_error_detail, + exception_detail, + open_https, + run_main, +) from scripts.smoke.mfa_user import BareMfaUser, LiveBareMfaUserProvisioner from scripts.smoke.tenant import ( SmokeTenant, @@ -444,7 +452,7 @@ def _content_envelope(result: McpResult) -> Mapping[str, Any] | None: continue try: parsed = json.loads(text) - except (TypeError, ValueError): + except TypeError, ValueError: continue if isinstance(parsed, Mapping) and "statusCode" in parsed: return parsed @@ -1099,7 +1107,7 @@ def _check_interceptor_denial_logged( resource=RESOURCE_CLASS, check=check, status="fail", - detail=f"reading the interceptor log group raised {type(exc).__name__}: {exc}", + detail=aws_error_detail("reading the interceptor log group", exc), ) denials = [m for m in messages if any(e in m for e in INTERCEPTOR_DENIAL_EVENTS)] if any(_message_level(m) in {"WARNING", "WARN"} for m in denials): @@ -1404,7 +1412,7 @@ def token_genuinely_expired_check( resource=resource, check=check, status="fail", - detail=f"could not verify the token's claims: {type(exc).__name__}: {exc}", + detail=f"could not verify the token's claims: {exception_detail(exc)}", ) exp = claims.get("exp") iat = claims.get("iat") @@ -1460,7 +1468,7 @@ def underscoped_token_lacks_gateway_scope_check( resource=resource, check=check, status="fail", - detail=f"could not verify the token's claims: {type(exc).__name__}: {exc}", + detail=f"could not verify the token's claims: {exception_detail(exc)}", ) scopes = str(claims.get("scope") or "").split() if not scopes: @@ -1634,8 +1642,9 @@ def _read_prior_row(self, rep_id: str) -> dict[str, Any] | None: ) except Exception as exc: # noqa: BLE001 - re-raised as the refusal to proceed raise RuntimeError( - f"could not read the existing reps row for {rep_id!r} ({type(exc).__name__}: " - f"{exc}); refusing to overwrite a row this run could not restore" + f"could not read the existing reps row for {rep_id!r} " + f"({aws_error_detail('dynamodb:GetItem', exc)}); refusing to overwrite a row this " + "run could not restore" ) from exc item = response.get("Item") return dict(item) if isinstance(item, Mapping) else None @@ -1697,7 +1706,7 @@ def _cleanup_reps_row(self) -> Iterable[CheckResult]: resource="service_principal", check="reps_row_deleted", status="fail", - detail=f"could not delete the seeded reps row: {type(exc).__name__}: {exc}", + detail=(f"could not delete the seeded reps row: {exception_detail(exc)}"), ) def _restore_prior_row(self, rep_id: str, prior: dict[str, Any]) -> CheckResult: @@ -1709,7 +1718,7 @@ def _restore_prior_row(self, rep_id: str, prior: dict[str, Any]) -> CheckResult: restored = client.get_item(**key, ConsistentRead=True).get("Item") error = "" if restored == prior else "a consistent re-read differs from the snapshot" except Exception as exc: # noqa: BLE001 - surfaced as a failing check, never swallowed - error = f"{type(exc).__name__}: {exc}" + error = exception_detail(exc) if not error: return CheckResult( resource="service_principal", @@ -1744,7 +1753,7 @@ def _cleanup_tenant(self) -> Iterable[CheckResult]: resource="smoke_tenant", check="tenant_left_clean", status="fail", - detail=f"teardown of {smoke_tenant.tenant!r} failed: {type(exc).__name__}: {exc}", + detail=(f"teardown of {smoke_tenant.tenant!r} failed: {exception_detail(exc)}"), ) @@ -1959,7 +1968,7 @@ def _then_denial_log(rows: list[CheckResult]) -> list[CheckResult]: except Exception as exc: # noqa: BLE001 - surfaced through the refusal check's detail expired_reason = ( "expired token (minting the to-be-expired machine token failed: " - f"{type(exc).__name__}: {exc})" + f"{exception_detail(exc)})" ) return _then_denial_log( @@ -2008,7 +2017,7 @@ def _provisioned_checks( except Exception as exc: # noqa: BLE001 - surfaced as one actionable failing check underscoped_error = ( "could not mint a real end-user access token for the underscoped-token " - f"check: {type(exc).__name__}: {exc}" + f"check: {exception_detail(exc)}" ) try: fixture = provisioner.provision() @@ -2020,7 +2029,7 @@ def _provisioned_checks( status="fail", detail=( "could not seed the service principal's book and mint its token: " - f"{type(exc).__name__}: {exc}" + f"{exception_detail(exc)}" ), ) ) diff --git a/scripts/smoke/harness.py b/scripts/smoke/harness.py index 04fccde..7554a5f 100644 --- a/scripts/smoke/harness.py +++ b/scripts/smoke/harness.py @@ -31,6 +31,7 @@ from typing import IO, Any, Final, cast import boto3 +from botocore.exceptions import BotoCoreError, ClientError from eval.verification import ( COVERAGE_CHECK as COVERAGE_CHECK, @@ -307,6 +308,42 @@ def error_code(exc: BaseException) -> str: return code if isinstance(code, str) else "" +def aws_error_code(exc: BaseException) -> str: + """Return the AWS error code of `exc`, or its class name when it carries none. Never the message.""" + return error_code(exc) or type(exc).__name__ + + +def aws_error_detail(operation: str, exc: BaseException) -> str: + """Return `" failed ()"`, a detail carrying no error message.""" + return f"{operation} failed ({aws_error_code(exc)})" + + +def _aws_error_in_chain(exc: BaseException) -> ClientError | BotoCoreError | None: + """Return the first `ClientError`/`BotoCoreError` in `exc`'s cause/context chain, else `None`.""" + seen: set[int] = set() + current: BaseException | None = exc + while current is not None and id(current) not in seen: + if isinstance(current, (ClientError, BotoCoreError)): + return current + seen.add(id(current)) + current = current.__cause__ or current.__context__ + return None + + +def exception_detail(exc: BaseException, operation: str | None = None) -> str: + """Describe `exc` for a check detail; an AWS error in its chain yields its code, never a message. + + `operation` names the AWS call when the caller knows it; otherwise a `ClientError`'s own + operation name is used. + """ + aws_exc = _aws_error_in_chain(exc) + if aws_exc is None: + return f"{type(exc).__name__}: {exc}" + if operation is None: + operation = getattr(aws_exc, "operation_name", None) or "an AWS call" + return f"{type(exc).__name__}: {aws_error_detail(operation, aws_exc)}" + + def key_policy_for_simulation(policy_text: str, key_arn: str) -> str: """Return a KMS key policy with every `Resource` of `"*"` rewritten to `key_arn`. @@ -628,7 +665,8 @@ def assert_target_matches_outputs(ctx: SmokeContext) -> tuple[str, ...]: except Exception as exc: # noqa: BLE001 - an unusable credential is a warning, not a wrong target unasserted.append( f"{TARGET_UNASSERTED_WARNING_PREFIX}the account half could not be checked " - f"({type(exc).__name__}: {exc}), so nothing verified which account this run reads. " + f"({exception_detail(exc, 'sts:GetCallerIdentity')}), so nothing verified which " + "account this run reads. " "Proceeding: a credential failure is not a wrong target." ) return tuple(unasserted) @@ -740,7 +778,7 @@ def _resolve_expectation( return expected(ctx) except Exception as exc: # noqa: BLE001 - reported in the check's detail, never swallowed return UnderivableCheckCount( - reason=f"its expected_check_count deriver raised {type(exc).__name__}: {exc}" + reason=f"its expected_check_count deriver raised {exception_detail(exc)}" ) @@ -825,7 +863,7 @@ def run_main( resource=resource_class, check="checks", status="fail", - detail=f"{type(exc).__name__}: {exc}", + detail=exception_detail(exc), ) ) diff --git a/scripts/smoke/iam_roles.py b/scripts/smoke/iam_roles.py index 66f7bb3..fe8464d 100644 --- a/scripts/smoke/iam_roles.py +++ b/scripts/smoke/iam_roles.py @@ -87,6 +87,8 @@ CheckResult, ExpectedCheckCount, SmokeContext, + aws_error_detail, + exception_detail, run_main, ) @@ -1804,7 +1806,7 @@ def _role_exists(ctx: SmokeContext, role_name: str) -> bool | str: except Exception as exc: # noqa: BLE001 - classified below; never silently treated as absent if _is_no_such_entity(exc): return False - return f"{type(exc).__name__}: {exc}" + return aws_error_detail("iam:GetRole", exc) return True @@ -1901,7 +1903,10 @@ def _own_table_denied_check( decision, _ = _simulate_evaluation(ctx, role_arn, action, base_table_arn) except Exception as exc: # noqa: BLE001 - report as a failing check, not a crash return CheckResult( - resource=role_name, check=check, status="fail", detail=f"simulate raised: {exc}" + resource=role_name, + check=check, + status="fail", + detail=aws_error_detail("iam:SimulatePrincipalPolicy", exc), ) return CheckResult( resource=role_name, @@ -1933,7 +1938,10 @@ def _scoped_index_allowed_check( ) except Exception as exc: # noqa: BLE001 - report as a failing check, not a crash return CheckResult( - resource=role_name, check=check, status="fail", detail=f"simulate raised: {exc}" + resource=role_name, + check=check, + status="fail", + detail=aws_error_detail("iam:SimulatePrincipalPolicy", exc), ) return CheckResult( resource=role_name, @@ -1961,7 +1969,7 @@ def _index_only_base_table_check( resource=role_name, check=check, status="fail", - detail=f"simulate_principal_policy raised: {exc}", + detail=aws_error_detail("iam:SimulatePrincipalPolicy", exc), ) if decision == "no_result": return CheckResult( @@ -2040,7 +2048,7 @@ def _extra_condition_row( resource=role_name, check=check, status="fail", - detail=f"simulate raised: {exc} ({subject})", + detail=f"{aws_error_detail('iam:SimulatePrincipalPolicy', exc)} ({subject})", ) if allowed: ok = decision == "allowed" and not unset @@ -2276,7 +2284,7 @@ def _probe_decision( try: return _simulate_with_leading_keys(ctx, role_arn, action, resource_arn, leading_keys) except Exception as exc: # noqa: BLE001 - the caller's row fails on any non-decision - return f"an error ({type(exc).__name__}: {exc})" + return f"an error ({aws_error_detail('iam:SimulatePrincipalPolicy', exc)})" def _role_documents( @@ -2314,7 +2322,7 @@ def _index_scope_denied_check( resource=role_name, check=check, status="fail", - detail=f"simulate_principal_policy raised: {exc} ({subject})", + detail=f"{aws_error_detail('iam:SimulatePrincipalPolicy', exc)} ({subject})", ) if decision in ("explicitDeny", "implicitDeny"): return CheckResult( @@ -2360,7 +2368,7 @@ def _conditioned_scope_denied_check( resource=role_name, check=check, status="fail", - detail=f"simulate_principal_policy raised: {exc} ({subject})", + detail=f"{aws_error_detail('iam:SimulatePrincipalPolicy', exc)} ({subject})", ) if decision not in ("explicitDeny", "implicitDeny"): return CheckResult( @@ -2403,7 +2411,7 @@ def _conditioned_scope_rows( check=f"conditioned_scope_keys_derivable:{function}:{action}@{table}", status="fail", detail=( - f"no parser-derived out-of-scope key could be derived: {exc}. The " + f"no parser-derived out-of-scope key could be derived: {exception_detail(exc)}. The " f"conditioned_scope_denied row probes only {PROBE_FOREIGN_KEY!r}" ), ) @@ -2484,7 +2492,9 @@ def _resolve_intended_grants(matrix: Mapping[str, Any]) -> _IntendedGrants: error = "" except Exception as exc: # noqa: BLE001 - report as a failing check, not a crash computed = {} - error = f"could not read infra/main.tf's local.tool_dynamodb_grants: {exc}" + error = ( + f"could not read infra/main.tf's local.tool_dynamodb_grants: {exception_detail(exc)}" + ) intended: dict[str, set[tuple[str, str]]] = dict(documented) intended.update(computed) return _IntendedGrants(intended=intended, documented=documented, computed=computed, error=error) @@ -2602,7 +2612,8 @@ def _role_matrix_checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C9 check="index_only_grants_readable", status="fail", detail=( - f"could not read infra/main.tf's index-only grants: {exc}. Every index-only grant " + f"could not read infra/main.tf's index-only grants: {exception_detail(exc)}. Every " + "index-only grant " "is simulated against its base-table ARN instead, so its own-grant row fails" ), ) @@ -2617,7 +2628,8 @@ def _role_matrix_checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C9 check="conditioned_grants_readable", status="fail", detail=( - f"could not read the sweep and tool roles' leading_key_condition values: {exc}. " + "could not read the sweep and tool roles' leading_key_condition values: " + f"{exception_detail(exc)}. " "Their own conditioned grants the matrix declares are refused rather than simulated, " f"and each conditioned_scope_denied row probes only {PROBE_FOREIGN_KEY!r}" ), @@ -2711,7 +2723,10 @@ def table_arn(table_name: str) -> str: resource=role_name, check="extra_conditions_readable", status="fail", - detail=f"could not read {SWEEP_GRANT_LOCALS[role_function]}: {exc}", + detail=( + f"could not read {SWEEP_GRANT_LOCALS[role_function]}: " + f"{exception_detail(exc)}" + ), ) else: yield from extra_condition_rows( @@ -2812,7 +2827,7 @@ def table_arn(table_name: str) -> str: ctx, role_arn, action, simulated_arn, probe_keys or None ) except Exception as exc: # noqa: BLE001 - report as a failing check, not a crash - inconclusive = f"simulate_principal_policy raised: {exc}" + inconclusive = aws_error_detail("iam:SimulatePrincipalPolicy", exc) break if arn_decision == "no_result": inconclusive = ( @@ -2973,7 +2988,7 @@ def table_arn(table_name: str) -> str: resource=role_name, check="no_dynamodb_wildcard", status="fail", - detail=f"could not load role policies: {documents_error}", + detail=(f"could not load role policies: {exception_detail(documents_error)}"), ) ) yield CheckResult( @@ -2981,7 +2996,9 @@ def table_arn(table_name: str) -> str: check="leading_keys:policies_unreadable", status="fail", detail=( - f"could not load role policies ({documents_error}), so no statement's " + f"could not load role policies " + f"({exception_detail(documents_error)}), so no " + "statement's " "dynamodb:LeadingKeys condition was examined" ), ) @@ -3203,7 +3220,7 @@ def _discover_role_arns(ctx: SmokeContext) -> tuple[dict[str, str], str | None]: if label is not None: found[label] = str(role["Arn"]) except Exception as exc: # noqa: BLE001 - reported on every row that needs a role - return found, f"iam:ListRoles raised {type(exc).__name__}: {exc}" + return found, aws_error_detail("iam:ListRoles", exc) return found, None @@ -3212,7 +3229,11 @@ def _env_inputs(ctx: SmokeContext, account_id: str) -> tuple[str | None, str | N try: config = ctx.client("lambda").get_function_configuration(FunctionName=CURSOR_ENV_FUNCTION) except Exception as exc: # noqa: BLE001 - reported on every row that needs these inputs - return None, None, f"get_function_configuration({CURSOR_ENV_FUNCTION}) raised {exc}" + return ( + None, + None, + aws_error_detail(f"lambda:GetFunctionConfiguration({CURSOR_ENV_FUNCTION})", exc), + ) env = (config.get("Environment") or {}).get("Variables") or {} key_arn = env.get(CURSOR_KEY_ENV) or None name = env.get(ALLOWLIST_PARAMETER_ENV) or None @@ -3300,7 +3321,7 @@ def _approve_rows( str(g["IndexName"]) for g in table.get("GlobalSecondaryIndexes") or () ) except Exception as exc: # noqa: BLE001 - reported on every approve row - problem = f"describe_table({physical}) raised {type(exc).__name__}: {exc}" + problem = aws_error_detail(f"dynamodb:DescribeTable({physical})", exc) if not problem and APPROVE_INDEX not in indexes: problem = f"{physical} lists no {APPROVE_INDEX} index: {indexes}" if problem or role_arn is None: @@ -3340,7 +3361,7 @@ def supplementary_checks(ctx: SmokeContext) -> Iterator[CheckResult]: try: account_id = str(ctx.client("sts").get_caller_identity()["Account"]) except Exception as exc: # noqa: BLE001 - reported on every row - detail = f"sts:GetCallerIdentity raised {type(exc).__name__}: {exc}" + detail = aws_error_detail("sts:GetCallerIdentity", exc) for label, role_name in NON_API_ROLE_NAMES.items(): for check in ( "cursor_key_use_denied", @@ -3573,7 +3594,10 @@ def _allowlist_rows(ctx: SmokeContext, inputs: _AllowlistInputs) -> Iterator[Che ) except Exception as exc: # noqa: BLE001 - reported on the row yield _row( - inputs.parameter_name, ALLOWLIST_KEY_CHECKS[0], False, f"{type(exc).__name__}: {exc}" + inputs.parameter_name, + ALLOWLIST_KEY_CHECKS[0], + False, + aws_error_detail("ssm:DescribeParameters", exc), ) try: parameter = ssm.get_parameter(Name=inputs.parameter_name, WithDecryption=True)["Parameter"] @@ -3587,13 +3611,18 @@ def _allowlist_rows(ctx: SmokeContext, inputs: _AllowlistInputs) -> Iterator[Che ) except Exception as exc: # noqa: BLE001 - reported on the row yield _row( - inputs.parameter_name, ALLOWLIST_KEY_CHECKS[1], False, f"{type(exc).__name__}: {exc}" + inputs.parameter_name, + ALLOWLIST_KEY_CHECKS[1], + False, + aws_error_detail("ssm:GetParameter", exc), ) try: enabled = bool(kms.get_key_rotation_status(KeyId=key).get("KeyRotationEnabled")) yield _row(key, ALLOWLIST_KEY_CHECKS[2], enabled, f"KeyRotationEnabled={enabled}") except Exception as exc: # noqa: BLE001 - reported on the row - yield _row(key, ALLOWLIST_KEY_CHECKS[2], False, f"{type(exc).__name__}: {exc}") + yield _row( + key, ALLOWLIST_KEY_CHECKS[2], False, aws_error_detail("kms:GetKeyRotationStatus", exc) + ) try: tags = { str(t["TagKey"]): str(t["TagValue"]) @@ -3610,7 +3639,9 @@ def _allowlist_rows(ctx: SmokeContext, inputs: _AllowlistInputs) -> Iterator[Che f"missing={missing} wrong={wrong}", ) except Exception as exc: # noqa: BLE001 - reported on the row - yield _row(key, ALLOWLIST_KEY_CHECKS[3], False, f"{type(exc).__name__}: {exc}") + yield _row( + key, ALLOWLIST_KEY_CHECKS[3], False, aws_error_detail("kms:ListResourceTags", exc) + ) try: wildcards = _wildcard_allows(json.loads(inputs.key_policy)) yield _row( @@ -3688,7 +3719,7 @@ def _allowlist_rows(ctx: SmokeContext, inputs: _AllowlistInputs) -> Iterator[Che status="defer", defer_reason="aws_managed_ssm_key_absent", detail=( - f"describe_key({AWS_SSM_KEY_ALIAS}) raised {type(exc).__name__}: {exc}; the " + f"{aws_error_detail(f'kms:DescribeKey({AWS_SSM_KEY_ALIAS})', exc)}; the " "account's AWS managed SSM key ARN is unknown, so the Deny on decrypting under it " "was not simulated" ), @@ -3810,7 +3841,7 @@ def _allowlist_identity_rows(ctx: SmokeContext, inputs: _AllowlistInputs) -> Ite "dynamodb_table_key", ALLOWLIST_KEY_CHECKS[13], False, - f"the table key is unreadable: {type(exc).__name__}: {exc}", + f"the table key is unreadable: {exception_detail(exc)}", ) cursor_users = { name: (arn, inputs.consumer_envs[name][CURSOR_KEY_ENV]) @@ -3852,7 +3883,7 @@ def allowlist_key_checks(ctx: SmokeContext) -> Iterator[CheckResult]: try: inputs = _allowlist_inputs(ctx) except Exception as exc: # noqa: BLE001 - reported on every row - detail = f"allowlist inputs unreadable: {type(exc).__name__}: {exc}" + detail = f"allowlist inputs unreadable: {exception_detail(exc)}" for check in ALLOWLIST_KEY_CHECKS: yield _row(ALLOWLIST_KEY_OUTPUT, check, False, detail) return diff --git a/scripts/smoke/integration_gateway_scope.py b/scripts/smoke/integration_gateway_scope.py index f0b1773..4193054 100644 --- a/scripts/smoke/integration_gateway_scope.py +++ b/scripts/smoke/integration_gateway_scope.py @@ -72,7 +72,7 @@ ) from scripts.smoke.gateway_tools import _content_envelope as _envelope_of from scripts.smoke.gateway_tools import default_mcp_caller as _gateway_tools_mcp_caller -from scripts.smoke.harness import CheckResult, SmokeContext, run_main +from scripts.smoke.harness import CheckResult, SmokeContext, exception_detail, run_main from crm.envelope import AGENT_IDENTITY_KEY, IDENTITY_KEY, REQUEST_CONTEXT_KEY from crm.errors import ValidationFailed @@ -378,7 +378,7 @@ def _canonicalise(value: Any) -> Any: if isinstance(value, str): try: parsed = json.loads(value) - except (TypeError, ValueError): + except TypeError, ValueError: return value if isinstance(parsed, dict | list): return json.dumps(_canonicalise(parsed), sort_keys=True, separators=(",", ":")) @@ -1235,7 +1235,7 @@ def _provisioned_checks( status="fail", detail=( "could not seed the service principal's book and mint its token: " - f"{type(exc).__name__}: {exc}" + + exception_detail(exc) ), ) ) @@ -1275,7 +1275,7 @@ def _provisioned_checks( resource=RESOURCE_CLASS, check="cleanup_service_principal", status="fail", - detail=f"cleanup raised {type(exc).__name__}: {exc}", + detail=f"cleanup raised {exception_detail(exc)}", ) ) finally: diff --git a/scripts/smoke/integration_proposal_chain.py b/scripts/smoke/integration_proposal_chain.py index 4a74399..126868a 100644 --- a/scripts/smoke/integration_proposal_chain.py +++ b/scripts/smoke/integration_proposal_chain.py @@ -80,7 +80,13 @@ ProvisionedSmokeUser, _live_table_prefix, ) -from scripts.smoke.harness import CheckResult, SmokeContext, open_https, run_main +from scripts.smoke.harness import ( + CheckResult, + SmokeContext, + exception_detail, + open_https, + run_main, +) from scripts.smoke.integration_ui_api_ddb import in_book_accounts from crm.audit import build_audit_record @@ -444,7 +450,7 @@ def release(self) -> Iterable[CheckResult]: resource="smoke_tenant", check="tenant_left_clean", status="fail", - detail=f"teardown of {tenant!r} failed: {type(exc).__name__}: {exc}", + detail=f"teardown of {tenant!r} failed: {exception_detail(exc)}", ) return yield CheckResult( @@ -635,7 +641,7 @@ def checks( resource=RESOURCE_CLASS, check="identity_acquired", status="fail", - detail=f"{type(exc).__name__}: {exc}", + detail=exception_detail(exc), ) yield from resolved_lease.release() return @@ -1202,7 +1208,7 @@ def _derived_index_attributes_check( resource="approve", check="derived_index_attributes_recomputed", status="fail", - detail=f"gsi_stage could not be queried: {type(exc).__name__}: {exc}", + detail=f"gsi_stage could not be queried: {exception_detail(exc, 'dynamodb:Query')}", ) target_id = str(row.get("opportunity_id")) indexed_correctly = target_id in at_new_stage and target_id not in at_old_stage @@ -1263,7 +1269,7 @@ def _proposal_status_index_check( resource="approve", check="proposal_reachable_by_approved_status_index", status="fail", - detail=f"gsi_status could not be queried: {type(exc).__name__}: {exc}", + detail=f"gsi_status could not be queried: {exception_detail(exc, 'dynamodb:Query')}", ) if proposal_id not in approved or proposal_id in pending: return CheckResult( @@ -2038,7 +2044,7 @@ def _demo_tenant_untouched_check(ctx: SmokeContext, demo_before: Mapping[str, in resource=RESOURCE_CLASS, check="demo_tenant_untouched", status="fail", - detail=f"could not re-read the demo tenant's row counts: {type(exc).__name__}: {exc}", + detail=f"could not re-read the demo tenant's row counts: {exception_detail(exc)}", ) drift = { t: (demo_before.get(t), demo_after[t]) @@ -2165,7 +2171,7 @@ def _teardown_removed_everything_checks( resource="smoke_tenant", check=f"{table}_rows_removed", status="fail", - detail=f"could not re-read {table} rows: {type(exc).__name__}: {exc}", + detail=f"could not re-read {table} rows: {exception_detail(exc)}", ) continue if not ids: @@ -2205,7 +2211,7 @@ def _teardown_removed_everything_checks( resource="smoke_tenant", check=f"{table}_empty_for_tenant", status="fail", - detail=f"could not count {table} rows for {tenant!r}: {type(exc).__name__}: {exc}", + detail=f"could not count {table} rows for {tenant!r}: {exception_detail(exc)}", ) continue yield CheckResult( @@ -2550,7 +2556,7 @@ def _out_of_book_revert_leg( resource="out_of_book_revert", check="fixture_seeded_outside_the_book", status="fail", - detail=f"{type(exc).__name__}: {exc}", + detail=exception_detail(exc), ) yield from _skip_leg(leg[1:], "the out-of-book fixture could not be seeded") return diff --git a/scripts/smoke/integration_teardown_privilege.py b/scripts/smoke/integration_teardown_privilege.py index 43000bd..50cc10b 100644 --- a/scripts/smoke/integration_teardown_privilege.py +++ b/scripts/smoke/integration_teardown_privilege.py @@ -28,7 +28,13 @@ from pathlib import Path from typing import Final -from scripts.smoke.harness import CheckResult, ExpectedCheckCount, SmokeContext, run_main +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + SmokeContext, + exception_detail, + run_main, +) from scripts.smoke.iam_roles import ( _function_grants, _load_matrix, @@ -287,7 +293,8 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: check="terraform_output_present", status="fail", detail=( - f"required Terraform output 'eval_state_machine_arn' is absent ({exc}); without the " + f"required Terraform output 'eval_state_machine_arn' is absent " + f"({exception_detail(exc)}); without the " f"sweep state machine there is no {TEARDOWN_FUNCTION} role to simulate every " "DeleteItem deny row against. A missing output is a failure, not a skipped check" ), diff --git a/scripts/smoke/integration_ui_api_ddb.py b/scripts/smoke/integration_ui_api_ddb.py index 400e58c..6850c5a 100644 --- a/scripts/smoke/integration_ui_api_ddb.py +++ b/scripts/smoke/integration_ui_api_ddb.py @@ -41,7 +41,13 @@ _tenant_refusal, verified_token_claims, ) -from scripts.smoke.harness import CheckResult, SmokeContext, open_https, run_main +from scripts.smoke.harness import ( + CheckResult, + SmokeContext, + exception_detail, + open_https, + run_main, +) from crm.authz import DEMO_TENANT from crm.envelope import CLAIM_BOOK, split_book @@ -495,7 +501,7 @@ def checks( # noqa: C901, PLR0912, PLR0915 - one cohesive round trip; splitting ctx, smoke_tenant, [*in_book_accounts(claims), account_id] ) except (ValueError, LookupError, CrmError) as exc: - derivation_failure = f"{type(exc).__name__}: {exc}" + derivation_failure = exception_detail(exc) if out_of_book_account_id is None: yield CheckResult( resource="denial", diff --git a/scripts/smoke/lambda_actions.py b/scripts/smoke/lambda_actions.py index 01c8221..647cdf0 100644 --- a/scripts/smoke/lambda_actions.py +++ b/scripts/smoke/lambda_actions.py @@ -46,6 +46,7 @@ import hashlib import json +import re import sys from collections.abc import Callable, Iterable, Mapping, Sequence from typing import Any, Final, Literal @@ -54,6 +55,8 @@ DEFER, CheckResult, SmokeContext, + aws_error_detail, + exception_detail, key_policy_for_simulation, run_main, ) @@ -378,11 +381,32 @@ def _placeholder_for( return f"smoke-{name}" +_IDENTIFIER: Final[re.Pattern[str]] = re.compile(r"[A-Za-z_][A-Za-z0-9_.]{0,127}") + + +def _function_error_detail(function_error: str, raw_payload: bytes) -> str: + """Return `FunctionError=`, plus ` errorType=` when the payload names one. + + Each value appears only when it is a short identifier. The payload's `errorMessage` and + `stackTrace` never appear. + """ + value = function_error if _IDENTIFIER.fullmatch(function_error) else "" + detail = f"FunctionError={value}" + try: + decoded = json.loads(raw_payload) if raw_payload else None + except ValueError: + return detail + error_type = decoded.get("errorType") if isinstance(decoded, Mapping) else None + if isinstance(error_type, str) and _IDENTIFIER.fullmatch(error_type): + detail += f" errorType={error_type}" + return detail + + def _invoke(ctx: SmokeContext, function_name: str, event: Mapping[str, Any]) -> dict[str, Any]: """Invoke ``function_name`` synchronously with ``event`` and return the decoded response body. - Raises `ValueError` when the invocation reports a `FunctionError`, or when the response - payload is not valid JSON. + Raises `ValueError` when the invocation reports a `FunctionError` (with the + `_function_error_detail` text), or when the response payload is not valid JSON. """ client = ctx.client("lambda") response = client.invoke( @@ -394,10 +418,7 @@ def _invoke(ctx: SmokeContext, function_name: str, event: Mapping[str, Any]) -> payload_stream = response["Payload"] raw_payload = payload_stream.read() if function_error: - raise ValueError( - f"FunctionError={function_error}: " - f"{raw_payload.decode('utf-8', errors='replace') if raw_payload else ''}" - ) + raise ValueError(_function_error_detail(str(function_error), raw_payload)) try: decoded = json.loads(raw_payload) except json.JSONDecodeError as exc: @@ -1271,7 +1292,7 @@ def cursor_key_env_checks( resource=tool.name, check=CURSOR_ENV_CHECK, status="fail", - detail=f"get_function_configuration failed: {exc}", + detail=aws_error_detail("lambda:GetFunctionConfiguration", exc), ) ) continue @@ -1365,7 +1386,7 @@ def row(check: str, failure: str | None, passed: str) -> CheckResult: "KeyRotationEnabled=True", ) except Exception as exc: # noqa: BLE001 - yield row(CURSOR_KEY_ROTATION_CHECK, f"get_key_rotation_status failed: {exc}", "") + yield row(CURSOR_KEY_ROTATION_CHECK, aws_error_detail("kms:GetKeyRotationStatus", exc), "") try: metadata = kms.describe_key(KeyId=key_arn).get("KeyMetadata") or {} @@ -1379,7 +1400,7 @@ def row(check: str, failure: str | None, passed: str) -> CheckResult: f"{shape!r}", ) except Exception as exc: # noqa: BLE001 - yield row(CURSOR_KEY_SHAPE_CHECK, f"describe_key failed: {exc}", "") + yield row(CURSOR_KEY_SHAPE_CHECK, aws_error_detail("kms:DescribeKey", exc), "") try: tags = kms.list_resource_tags(KeyId=key_arn).get("Tags") or [] @@ -1390,7 +1411,7 @@ def row(check: str, failure: str | None, passed: str) -> CheckResult: "data-classification tag present", ) except Exception as exc: # noqa: BLE001 - yield row(CURSOR_KEY_TAG_CHECK, f"list_resource_tags failed: {exc}", "") + yield row(CURSOR_KEY_TAG_CHECK, aws_error_detail("kms:ListResourceTags", exc), "") def _context_entries( @@ -1507,7 +1528,10 @@ def _simulated_row( ) except Exception as exc: # noqa: BLE001 return CheckResult( - resource=resource, check=check, status="fail", detail=f"simulation failed: {exc}" + resource=resource, + check=check, + status="fail", + detail=aws_error_detail("iam:SimulatePrincipalPolicy", exc), ) failure = _decision_failure( results, actions, accept, want, require_complete_context=require_complete_context @@ -1530,7 +1554,7 @@ def cursor_key_simulation_checks( policy_failure = "" except Exception as exc: # noqa: BLE001 key_policy = None - policy_failure = f"get_key_policy failed: {exc}" + policy_failure = aws_error_detail("kms:GetKeyPolicy", exc) def allowed(decision: str) -> bool: return decision == "allowed" @@ -1963,7 +1987,7 @@ def _teardown_check( resource=RESOURCE_CLASS, check="tenant_left_clean", status="fail", - detail=f"teardown of tenant {smoke_tenant.tenant!r} failed: {exc}", + detail=(f"teardown of tenant {smoke_tenant.tenant!r} failed: {exception_detail(exc)}"), ) return yield CheckResult( diff --git a/scripts/smoke/mcp_chat_gateway.py b/scripts/smoke/mcp_chat_gateway.py index c5b0786..d93077f 100644 --- a/scripts/smoke/mcp_chat_gateway.py +++ b/scripts/smoke/mcp_chat_gateway.py @@ -58,7 +58,9 @@ from scripts.smoke.harness import ( CheckResult, ExpectedCheckCount, + MissingTerraformOutputError, SmokeContext, + exception_detail, open_https, run_main, ) @@ -208,7 +210,7 @@ def _token_scopes(token: str, verifier: ClaimsVerifier) -> tuple[list[str], str] try: claims = verifier(token) except Exception as exc: # noqa: BLE001 - the reason is reported by the caller's row - return [], f"the token failed claims verification ({type(exc).__name__}: {exc})" + return [], f"the token failed claims verification ({exception_detail(exc)})" return str(claims.get("scope") or "").split(), "" @@ -393,7 +395,7 @@ def _forged_identity_row( resource=RESOURCE_CLASS, check=check, status="fail", - detail=f"user A's token failed claims verification ({type(exc).__name__}: {exc}), " + detail=f"user A's token failed claims verification ({exception_detail(exc)}), " "so there is no verified identity to forge", ) forged = { @@ -458,7 +460,7 @@ def _refused_row(check: str, call: McpCaller, token: str, what: str) -> CheckRes resource=RESOURCE_CLASS, check=check, status="fail", - detail=f"{what} tools/list could not be sent: {type(exc).__name__}: {exc}", + detail=f"{what} tools/list could not be sent: {exception_detail(exc)}", ) leaked = isinstance(body, Mapping) and "result" in body refused = status in REFUSED_STATUSES and not leaked @@ -488,7 +490,7 @@ def _invoke_only_token_row( resource=RESOURCE_CLASS, check=check, status="fail", - detail=f"could not mint a {scope}-only token: {type(exc).__name__}: {exc}", + detail=f"could not mint a {scope}-only token: {exception_detail(exc)}", ) scopes, error = _token_scopes(token, verifier) if error: @@ -570,8 +572,8 @@ def _remove_conversations( resource=RESOURCE_CLASS, check=check, status="fail", - detail=f"removing the smoke principals' conversation items: {type(exc).__name__}: " - f"{exc}; items may remain", + detail="removing the smoke principals' conversation items: " + f"{exception_detail(exc, 'dynamodb conversation cleanup')}; items may remain", ) unidentified = sum(1 for c in issued if not CONVERSATION_ID_PATTERN.match(c)) unknown_owners = sum(1 for o in owners if not o) @@ -607,7 +609,7 @@ def checks( """ try: url = _mcp_url(ctx) - except Exception as exc: # noqa: BLE001 - a failing row, not a crash + except MissingTerraformOutputError as exc: yield CheckResult( resource="mcp_chat_gateway_url", check="terraform_output_present", diff --git a/scripts/smoke/mcp_client_compat.py b/scripts/smoke/mcp_client_compat.py index b8cfa09..61698ee 100644 --- a/scripts/smoke/mcp_client_compat.py +++ b/scripts/smoke/mcp_client_compat.py @@ -61,6 +61,7 @@ ExpectedCheckCount, InsecureSchemeError, SmokeContext, + exception_detail, run_main, ) @@ -277,7 +278,7 @@ def _http_status_of(exc: BaseException) -> int | None: def _describe(exc: BaseException) -> str: if isinstance(exc, BaseExceptionGroup) and exc.exceptions: return _describe(exc.exceptions[0]) - return f"{type(exc).__name__}: {exc}"[:300] + return exception_detail(exc)[:300] @dataclass @@ -663,7 +664,11 @@ def checks( try: url1, url2 = gateway1_url(ctx), gateway2_url(ctx) except Exception as exc: # noqa: BLE001 - a failing row, not a crash - yield _row("terraform_output_present", False, f"a Gateway URL output is unusable ({exc})") + yield _row( + "terraform_output_present", + False, + f"a Gateway URL output is unusable ({exception_detail(exc)})", + ) return runner: SessionRunner = session_runner or run_session @@ -708,7 +713,9 @@ def checks( try: yield from provisioner.cleanup() except Exception as exc: # noqa: BLE001 - every cleanup is attempted - yield _row("principal_cleanup", False, f"cleanup raised {_describe(exc)}") + yield _row( + "principal_cleanup", False, f"cleanup raised {exception_detail(exc)[:300]}" + ) def expected_check_count(ctx: SmokeContext) -> ExpectedCheckCount: diff --git a/scripts/smoke/mfa_user.py b/scripts/smoke/mfa_user.py index 2373460..c4ee5ae 100644 --- a/scripts/smoke/mfa_user.py +++ b/scripts/smoke/mfa_user.py @@ -21,7 +21,7 @@ from typing import Any, Final from scripts.smoke.cognito_claims import auth_factor_detail, totp_code -from scripts.smoke.harness import CheckResult, SmokeContext +from scripts.smoke.harness import CheckResult, SmokeContext, aws_error_code, exception_detail __all__ = [ "BareMfaUser", @@ -181,7 +181,7 @@ def cleanup(self) -> Iterable[CheckResult]: try: idp.admin_get_user(UserPoolId=self._user_pool_id(), Username=username) except Exception as exc: # noqa: BLE001 - the expected outcome is an exception - if "UserNotFoundException" not in f"{type(exc).__name__}: {exc}": + if aws_error_code(exc) != "UserNotFoundException": raise yield CheckResult( resource=_RESOURCE, @@ -201,5 +201,5 @@ def cleanup(self) -> Iterable[CheckResult]: resource=_RESOURCE, check="cognito_user_deleted", status="fail", - detail=f"could not confirm smoke user deletion: {type(exc).__name__}: {exc}", + detail=f"could not confirm smoke user deletion: {exception_detail(exc)}", ) diff --git a/scripts/smoke/public_exposure.py b/scripts/smoke/public_exposure.py index 1560e5b..b9369e9 100644 --- a/scripts/smoke/public_exposure.py +++ b/scripts/smoke/public_exposure.py @@ -38,6 +38,7 @@ CheckResult, ExpectedCheckCount, SmokeContext, + aws_error_detail, outputs_path, run_main, ) @@ -369,7 +370,7 @@ def rest_api_private_vpce_only(ctx: SmokeContext) -> Iterator[CheckResult]: check=REST_API_CHECK, status="fail", detail=( - f"apigateway.get_rest_api({api_id!r}) failed ({type(exc).__name__}: {exc}); the " + f"{aws_error_detail('apigateway:GetRestApi', exc)} for {api_id!r}; the " "REST API's disposition could not be read. Reported as a fail so the TLS row below " "is still emitted" ), @@ -442,7 +443,7 @@ def _decode_rest_policy_document(policy_text: str) -> Any: except json.JSONDecodeError: try: decoded = json.loads(json.loads(f'"{policy_text}"')) - except (json.JSONDecodeError, TypeError): + except json.JSONDecodeError, TypeError: return None if isinstance(decoded, str): try: @@ -677,21 +678,21 @@ def expected_check_count(ctx: SmokeContext, *, snapshot: Path | None = None) -> def credential_failure_reason(exc: BaseException) -> str | None: - """Return why `exc` means the account was never reached, or `None` if it is a real finding. + """Return the error name or code showing `exc` never reached the account, else `None`. Distinguishes "could not authenticate" (verified nothing) from "authenticated and was denied" (a finding). """ name = type(exc).__name__ if name in _CREDENTIAL_FAILURE_NAMES: - return f"{name}: {exc}" + return name code = ( getattr(exc, "response", {}).get("Error", {}).get("Code") if hasattr(exc, "response") else None ) if isinstance(code, str) and code in _CREDENTIAL_ERROR_CODES: - return f"{code}: {exc}" + return code return None diff --git a/scripts/smoke/relay_iam.py b/scripts/smoke/relay_iam.py index 344b549..4380788 100644 --- a/scripts/smoke/relay_iam.py +++ b/scripts/smoke/relay_iam.py @@ -34,8 +34,11 @@ from scripts.smoke.harness import ( CheckResult, ExpectedCheckCount, + MissingTerraformOutputError, SmokeContext, Status, + aws_error_detail, + exception_detail, run_main, ) @@ -380,7 +383,7 @@ def _inverse_matrix_results( f"role {role_name} does not exist (NoSuchEntity). The enumeration names a role the " "deployment does not have; check the matrix key renders the deployed function name" if _is_no_such_entity(exc) - else f"simulate_principal_policy raised {type(exc).__name__}: {exc}" + else aws_error_detail("iam:SimulatePrincipalPolicy", exc) ) yield CheckResult( resource=role_arn, @@ -423,7 +426,7 @@ def _paired_deny_results( try: positive_decision = _simulate_custom_allow(ctx, row.action, row.resource) except Exception as exc: # noqa: BLE001 - a failing control, never a skip - positive_decision = f"error ({type(exc).__name__}: {exc})" + positive_decision = f"error ({aws_error_detail('iam:SimulateCustomPolicy', exc)})" elif row.positive_role_arn is None: raise ValueError(f"{row.row_id} has no positive control; use an expressibility assertion") else: @@ -601,7 +604,7 @@ def _allow_result( ) -def _missing_output(name: str, remediation: str, exc: Exception) -> CheckResult: +def _missing_output(name: str, remediation: str, exc: MissingTerraformOutputError) -> CheckResult: return CheckResult( resource=name, check="terraform_output_present", @@ -625,7 +628,7 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one row relay_role_arn = ctx.outputs.require_str("agent_relay_role_arn") runtime_arn = ctx.outputs.require_str("agentcore_runtime_arn") relay_function_name = ctx.outputs.require_str("agent_relay_function_name") - except Exception as exc: # noqa: BLE001 - reported as a failing check, not a crash + except MissingTerraformOutputError as exc: yield _missing_output( "agent_relay_role_arn|agentcore_runtime_arn|agent_relay_function_name", "These three are the matrix's own subject; without them no row can be simulated.", @@ -675,7 +678,7 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one row try: log_group_name = ctx.outputs.require_str("agent_relay_log_group_name") - except Exception as exc: # noqa: BLE001 + except MissingTerraformOutputError as exc: log_group_name = "" yield _missing_output( "agent_relay_log_group_name", @@ -827,7 +830,7 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one row runtime_statements: list[Mapping[str, Any]] = [] try: runtime_role_arn = ctx.outputs.require_str("agentcore_runtime_role_arn") - except Exception as exc: # noqa: BLE001 + except MissingTerraformOutputError as exc: yield _missing_output( "agentcore_runtime_role_arn", "It is the positive control for D6 (lambda:InvokeFunction on the action Lambdas) " @@ -904,7 +907,7 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one row # --- D7/D8: the relay never reads or writes CRM data directly. --- try: table_names: Mapping[str, Any] = ctx.outputs.require_mapping("dynamodb_table_names") - except Exception as exc: # noqa: BLE001 + except MissingTerraformOutputError as exc: table_names = {} yield _missing_output( "dynamodb_table_names", @@ -1023,7 +1026,8 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one row check="D12_target_role_resolves", status="fail", detail=( - f"iam get-role failed for {runtime_role_name!r} ({exc}), so D12's target " + f"{aws_error_detail(f'iam:GetRole for {runtime_role_name!r}', exc)}, so " + "D12's target " "ARN names nothing and its implicitDeny would read as a pass. This is the " "one ARN in the matrix with no positive control available, which is why " "resolution is asserted instead" @@ -1157,7 +1161,8 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one row resource="local.runtime_invoker_role_arns", check=_INVOKERS_RESOLVED_CHECK, status="fail", - detail=f"the Runtime invoker list could not be read ({exc}), so no D15/D16 or I1/I2 " + detail=f"the Runtime invoker list could not be read ({exception_detail(exc)}), so no " + "D15/D16 or I1/I2 " "row ran and X1 has no role to simulate", ) @@ -1172,7 +1177,7 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one row check=_INVERSE_MATRIX_ENUMERATED_CHECK, status="fail", detail=f"the roles D15/D16 must assert denied could not be enumerated " - f"({type(exc).__name__}: {exc}), so no D15/D16 row ran", + f"({exception_detail(exc)}), so no D15/D16 row ran", ) for role_name, role_arn in non_relay_roles.items(): yield from _inverse_matrix_results( @@ -1250,7 +1255,10 @@ def _invoker_allow_results( resource=resource, check=f"{row_id}[{role_name}]_allowed", status="fail", - detail=f"{row_id}: simulating {role_name} raised {type(exc).__name__}: {exc}", + detail=f"{row_id}: " + + aws_error_detail( + f"simulating {role_name} (iam:SimulatePrincipalPolicy)", exc + ), ) @@ -1305,8 +1313,9 @@ def _chat_target_exclusion_result( resource=runtime_arn, check=_CHAT_TARGET_EXCLUSION_CHECK, status="fail", - detail=f"X1: simulating {role_name} for {action} on {resource} raised " - f"{type(exc).__name__}: {exc}. Not a pass: no decision was observed", + detail="X1: " + + aws_error_detail(f"simulating {role_name} for {action} on {resource}", exc) + + ". Not a pass: no decision was observed", ) all_explicit = all_explicit and decision in EXPLICIT_DENY_ONLY probes.append(_decision_detail(f"X1[{role_name}]", action, resource, decision)) @@ -1355,8 +1364,9 @@ def _function_url_auth_type_check(ctx: SmokeContext, function_name: str) -> Iter check="U1_function_url_auth_type", status="fail", detail=( - f"could not read the deployed Function URL configuration ({type(exc).__name__}: " - f"{exc}). The relay's only ingress is its Function URL, so this is a broken " + "could not read the deployed Function URL configuration " + f"({aws_error_detail('lambda:GetFunctionUrlConfig', exc)}). The relay's only " + "ingress is its Function URL, so this is a broken " "deployment, not an inapplicable check" ), ) diff --git a/scripts/smoke/resource_protection.py b/scripts/smoke/resource_protection.py index fda9832..6ed2921 100644 --- a/scripts/smoke/resource_protection.py +++ b/scripts/smoke/resource_protection.py @@ -51,7 +51,14 @@ from collections.abc import Mapping, Sequence from typing import Any, Final -from scripts.smoke.harness import CheckResult, ExpectedCheckCount, SmokeContext, run_main +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + MissingTerraformOutputError, + SmokeContext, + aws_error_detail, + run_main, +) from scripts.smoke.lambda_actions import FUNCTION_NAME_PREFIX from scripts.smoke.public_exposure import source_declared_function_names @@ -109,7 +116,7 @@ def _stack_trail(ctx: SmokeContext, bucket: str) -> Mapping[str, Any] | str: try: response = ctx.client("cloudtrail").describe_trails(includeShadowTrails=False) except Exception as exc: # noqa: BLE001 - reported as a fail row, never aborts the run - return f"describe-trails failed: {type(exc).__name__}: {exc}" + return aws_error_detail("cloudtrail:DescribeTrails", exc) matching = [ trail for trail in response.get("trailList", []) if trail.get("S3BucketName") == bucket ] @@ -139,7 +146,7 @@ def _check_logging(ctx: SmokeContext, resource: str, trail: Mapping[str, Any]) - status = ctx.client("cloudtrail").get_trail_status(Name=name) except Exception as exc: # noqa: BLE001 - reported as a fail row, never aborts the run return _fail( - resource, CHECK_TRAIL_LOGGING, f"get-trail-status failed: {type(exc).__name__}: {exc}" + resource, CHECK_TRAIL_LOGGING, aws_error_detail("cloudtrail:GetTrailStatus", exc) ) is_logging = status.get("IsLogging") if is_logging is True: @@ -153,7 +160,7 @@ def resolve_trail(ctx: SmokeContext) -> tuple[str, Mapping[str, Any] | str]: """`(resource, trail)` for the stack's trail, or `(resource, reason)` if it is unidentified.""" try: bucket = ctx.outputs.require_str(TRAIL_BUCKET_OUTPUT) - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except MissingTerraformOutputError as exc: return "cloudtrail", f"cannot locate the trail: {exc}" trail = _stack_trail(ctx, bucket) if isinstance(trail, str): @@ -175,7 +182,7 @@ def alb_check(ctx: SmokeContext) -> CheckResult: """The ALB deletion-protection row.""" try: arn = ctx.outputs.require_str(ALB_ARN_OUTPUT) - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except MissingTerraformOutputError as exc: return _fail("alb", CHECK_ALB_DELETION_PROTECTION, f"cannot locate the ALB: {exc}") resource = f"alb:{arn.partition(':loadbalancer/')[2] or arn}" try: @@ -184,7 +191,7 @@ def alb_check(ctx: SmokeContext) -> CheckResult: return _fail( resource, CHECK_ALB_DELETION_PROTECTION, - f"describe-load-balancer-attributes failed: {type(exc).__name__}: {exc}", + aws_error_detail("elasticloadbalancing:DescribeLoadBalancerAttributes", exc), ) values = [ attribute.get("Value") @@ -224,13 +231,13 @@ def expected_log_groups(ctx: SmokeContext) -> tuple[list[str], list[str]]: for output in LOG_GROUP_OUTPUTS: try: names.append(ctx.outputs.require_str(output)) - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except MissingTerraformOutputError as exc: problems.append(f"output {output!r} unavailable: {exc}") functions = list(source_declared_function_names()) for output in LAMBDA_FUNCTION_OUTPUTS: try: functions.append(ctx.outputs.require_str(output)) - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except MissingTerraformOutputError as exc: problems.append(f"output {output!r} unavailable: {exc}") names += [f"/aws/lambda/{function}" for function in functions] try: @@ -239,7 +246,7 @@ def expected_log_groups(ctx: SmokeContext) -> tuple[list[str], list[str]]: if not marker or not state_machine_name: raise ValueError(f"{state_machine!r} is not a state machine ARN") names.append(f"/aws/vendedlogs/states/{state_machine_name}") - except Exception as exc: # noqa: BLE001 - a missing output is a reportable failure + except (MissingTerraformOutputError, ValueError) as exc: problems.append(f"output {STATE_MACHINE_ARN_OUTPUT!r} unusable: {exc}") names += [f"/aws/codebuild/{CODEBUILD_PROJECT_NAME}", API_ACCESS_LOG_GROUP] return list(dict.fromkeys(names)), problems @@ -284,7 +291,7 @@ def log_group_checks( _fail( "log_groups", CHECK_LOG_GROUPS_DISCOVERED, - f"describe-log-groups failed: {type(exc).__name__}: {exc}", + aws_error_detail("logs:DescribeLogGroups", exc), ) ] problems += [f"prefix {prefix!r} matches no log group" for prefix in unmatched_prefixes] @@ -352,8 +359,14 @@ def codebuild_check(ctx: SmokeContext) -> CheckResult: f"eval-artefacts bucket default KMS keys {bucket_keys!r}; expected exactly one", ) bucket_key = _key_identity(ctx, str(bucket_keys[0])) + except MissingTerraformOutputError as exc: + return _fail(resource, CHECK_CODEBUILD_ENCRYPTION_KEY, str(exc)) except Exception as exc: # noqa: BLE001 - reported as a fail row, never aborts the run - return _fail(resource, CHECK_CODEBUILD_ENCRYPTION_KEY, f"{type(exc).__name__}: {exc}") + return _fail( + resource, + CHECK_CODEBUILD_ENCRYPTION_KEY, + aws_error_detail("codebuild/kms/s3 encryption-key lookup", exc), + ) observed = ( f"encryptionKey resolves to KeyManager={project_key.get('KeyManager')!r}; " f"same key as the eval-artefacts bucket: {project_key.get('KeyId') == bucket_key.get('KeyId')}" diff --git a/scripts/smoke/runtime_bedrock_iam.py b/scripts/smoke/runtime_bedrock_iam.py index 22dd3a3..b088586 100644 --- a/scripts/smoke/runtime_bedrock_iam.py +++ b/scripts/smoke/runtime_bedrock_iam.py @@ -34,6 +34,7 @@ CheckResult, ExpectedCheckCount, SmokeContext, + exception_detail, run_main, ) from scripts.smoke.iam_roles import _is_throttle # one spelling of the throttle predicate @@ -162,7 +163,8 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: check="terraform_output_present", status="fail", detail=( - f"required Terraform output 'agentcore_runtime_role_arn' is absent ({exc}); it is " + f"required Terraform output 'agentcore_runtime_role_arn' is absent " + f"({exception_detail(exc)}); it is " "this module's whole subject. A missing output is a failure, not a skipped class: " "an ARN built from a template that no longer resolves returns implicitDeny and reads " "as a pass" diff --git a/scripts/smoke/runtime_history_iam.py b/scripts/smoke/runtime_history_iam.py new file mode 100644 index 0000000..5b86198 --- /dev/null +++ b/scripts/smoke/runtime_history_iam.py @@ -0,0 +1,417 @@ +# SPDX-License-Identifier: MIT +"""Layer 4 smoke for the Runtime role's conversation-history grant on `reps`. + +Simulates the deployed `crm-agent-eval-runtime-role` (`agentcore_runtime_role_arn` output) and reads +the `reps` table. Targets come from the `agentcore_runtime_role_arn` and `dynamodb_table_names` +outputs; table and key ARNs come from `describe-table`. Rows, all read/simulate-only: + +* ALLOW: `GetItem` and `PutItem` on `reps` with `dynamodb:LeadingKeys` = a run-scoped + `history#demo#` key; `kms:Decrypt` and `kms:GenerateDataKey` on the table's CMK through + DynamoDB for `reps`. +* EXPLICIT DENY: `GetItem`/`PutItem` on `usersettings#`, `conversation#`, a bare rep id and + `history#canary#` keys; every other DynamoDB action on `reps` and its indexes; `GetItem` on every + other table. +* DENY: `GetItem` with no `dynamodb:LeadingKeys` context; `PutItem` writing a `tenant` attribute; + `kms:Decrypt` for another table or without `kms:ViaService`. +* TTL: `describe-time-to-live` on `reps` is ENABLED on `expires_at`. + +Each Get/Put/KMS deny row shares its action with an ALLOW row in the same run, because +`SimulatePrincipalPolicy` returns `implicitDeny` for a misspelled action too. The other-action rows +require `explicitDeny`, which only a matching Deny statement produces. + +Usage: + python3 -m scripts.smoke.runtime_history_iam [--profile P] [--region R] [--outputs PATH] [--json] +""" + +from __future__ import annotations + +import sys +import time +import uuid +from collections.abc import Iterator, Mapping, Sequence +from dataclasses import dataclass +from typing import Any, Final + +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + SmokeContext, + exception_detail, + run_main, +) +from scripts.smoke.iam_roles import _is_throttle # one spelling of the throttle predicate + +from agents.conversation_history import HISTORY_ITEM_ATTRIBUTES as _WRITTEN_ATTRIBUTES +from crm.store.keys import conversation_key, history_key, user_settings_key + +LAYER: Final[int] = 4 +RESOURCE_CLASS: Final[str] = "runtime_history_iam" + +HISTORY_TABLE: Final[str] = "reps" +HISTORY_KEY_PREFIX: Final[str] = "history#" +TTL_ATTRIBUTE: Final[str] = "expires_at" + +GET_ITEM: Final[str] = "dynamodb:GetItem" +PUT_ITEM: Final[str] = "dynamodb:PutItem" +GRANTED_ACTIONS: Final[tuple[str, ...]] = (GET_ITEM, PUT_ITEM) + +#: DynamoDB actions on `reps` the role must be explicitly denied. +DENIED_TABLE_ACTIONS: Final[tuple[str, ...]] = ( + "dynamodb:DeleteItem", + "dynamodb:Query", + "dynamodb:Scan", + "dynamodb:BatchWriteItem", + "dynamodb:UpdateItem", + "dynamodb:BatchGetItem", + "dynamodb:ConditionCheckItem", + "dynamodb:PartiQLSelect", +) + +#: Attributes a history item carries; a write naming any other attribute must be denied. +HISTORY_ITEM_ATTRIBUTES: Final[tuple[str, ...]] = tuple(sorted(_WRITTEN_ATTRIBUTES)) + +KMS_ACTIONS: Final[tuple[str, ...]] = ("kms:Decrypt", "kms:GenerateDataKey") + +_LEADING_KEYS: Final[str] = "dynamodb:LeadingKeys" +_ATTRIBUTES: Final[str] = "dynamodb:Attributes" +_VIA_SERVICE: Final[str] = "kms:ViaService" +_TABLE_NAME_CONTEXT: Final[str] = "kms:EncryptionContext:aws:dynamodb:tableName" + +_ALLOWED: Final[frozenset[str]] = frozenset({"allowed"}) +_EXPLICIT_DENY: Final[frozenset[str]] = frozenset({"explicitDeny"}) +_DENIED: Final[frozenset[str]] = frozenset({"explicitDeny", "implicitDeny"}) +_NO_RESULT: Final[str] = "no_result" +_DEFER_NO_EVALUATION: Final[str] = "simulate_returned_no_evaluation_result" +_DEFER_TTL_ENABLING: Final[str] = "ttl_enabling" +_SIMULATE_MAX_ATTEMPTS: Final[int] = 4 +_SIMULATE_BACKOFF_SECONDS: Final[float] = 1.0 + +__all__ = [ + "DENIED_TABLE_ACTIONS", + "GRANTED_ACTIONS", + "HISTORY_ITEM_ATTRIBUTES", + "HISTORY_KEY_PREFIX", + "KMS_ACTIONS", + "LAYER", + "RESOURCE_CLASS", + "checks", + "expected_check_count", + "main", +] + + +@dataclass(frozen=True) +class _Targets: + role_arn: str + table_names: Mapping[str, str] + table_arns: Mapping[str, str] + kms_key_arn: str + + +def _context(name: str, values: Sequence[str], kind: str) -> dict[str, Any]: + return {"ContextKeyName": name, "ContextKeyValues": list(values), "ContextKeyType": kind} + + +def _leading_keys(key: str) -> list[dict[str, Any]]: + return [_context(_LEADING_KEYS, [key], "stringList")] + + +def _simulate( + ctx: SmokeContext, + role_arn: str, + action: str, + resource_arn: str, + context_entries: list[dict[str, Any]] | None = None, +) -> str: + """Return the simulate decision for one action/resource, retrying throttles only.""" + iam = ctx.client("iam") + kwargs: dict[str, Any] = { + "PolicySourceArn": role_arn, + "ActionNames": [action], + "ResourceArns": [resource_arn], + } + if context_entries: + kwargs["ContextEntries"] = context_entries + for attempt in range(1, _SIMULATE_MAX_ATTEMPTS + 1): + try: + response = iam.simulate_principal_policy(**kwargs) + break + except Exception as exc: # noqa: BLE001 - re-raised unless a retryable throttle + if attempt == _SIMULATE_MAX_ATTEMPTS or not _is_throttle(exc): + raise + time.sleep(_SIMULATE_BACKOFF_SECONDS * attempt) + results = response.get("EvaluationResults", []) + if not results: + return _NO_RESULT + return str(results[0]["EvalDecision"]) + + +def _row( + resource: str, check: str, decision: str, expected: frozenset[str], why: str +) -> CheckResult: + if decision == _NO_RESULT: + return CheckResult( + resource=resource, + check=check, + status="defer", + detail=f"{check}: {resource} returned no evaluation result, so this row asserts nothing", + defer_reason=_DEFER_NO_EVALUATION, + ) + return CheckResult( + resource=resource, + check=check, + status="pass" if decision in expected else "fail", + detail=f"evaluated {decision}; expected one of {sorted(expected)} -- {why}", + ) + + +def _resolve_targets(ctx: SmokeContext) -> _Targets | CheckResult: + try: + role_arn = ctx.outputs.require_str("agentcore_runtime_role_arn") + table_names = dict(ctx.outputs.require_mapping("dynamodb_table_names")) + except Exception as exc: # noqa: BLE001 - reported as a failing check, not a crash + return CheckResult( + resource="terraform_outputs", + check="terraform_output_present", + status="fail", + detail=( + "required outputs 'agentcore_runtime_role_arn' and 'dynamodb_table_names' are this " + f"module's subject ({exception_detail(exc)})" + ), + ) + if HISTORY_TABLE not in table_names or len(table_names) < 2: + return CheckResult( + resource="dynamodb_table_names", + check="history_table_present", + status="fail", + detail=f"dynamodb_table_names lacks '{HISTORY_TABLE}' or any other table", + ) + dynamodb = ctx.client("dynamodb") + table_arns: dict[str, str] = {} + kms_key_arn = "" + for logical, physical in sorted(table_names.items()): + try: + table = dynamodb.describe_table(TableName=str(physical))["Table"] + except Exception as exc: # noqa: BLE001 - reported as a failing check + return CheckResult( + resource=str(physical), + check="describe_table", + status="fail", + detail=exception_detail(exc, "DescribeTable"), + ) + table_arns[logical] = str(table["TableArn"]) + if logical == HISTORY_TABLE: + kms_key_arn = str((table.get("SSEDescription") or {}).get("KMSMasterKeyArn") or "") + if not kms_key_arn: + return CheckResult( + resource=table_arns[HISTORY_TABLE], + check="history_table_cmk", + status="fail", + detail="reps reports no SSEDescription.KMSMasterKeyArn, so the KMS rows have no subject", + ) + return _Targets(role_arn, table_names, table_arns, kms_key_arn) + + +def _ttl_row(ctx: SmokeContext, physical: str, table_arn: str) -> CheckResult: + check = f"ttl_enabled:{TTL_ATTRIBUTE}" + try: + description = ctx.client("dynamodb").describe_time_to_live(TableName=physical) + except Exception as exc: # noqa: BLE001 - reported as a failing check + return CheckResult(table_arn, check, "fail", exception_detail(exc, "DescribeTimeToLive")) + ttl = description.get("TimeToLiveDescription") or {} + status, attribute = ttl.get("TimeToLiveStatus"), ttl.get("AttributeName") + if attribute == TTL_ATTRIBUTE and status == "ENABLED": + return CheckResult(table_arn, check, "pass", f"TTL ENABLED on {attribute}") + if attribute == TTL_ATTRIBUTE and status == "ENABLING": + return CheckResult( + table_arn, + check, + "defer", + "TTL is ENABLING on expires_at; re-run once DynamoDB reports ENABLED", + defer_reason=_DEFER_TTL_ENABLING, + ) + return CheckResult( + table_arn, + check, + "fail", + f"TTL status={status!r} attribute={attribute!r}; expected ENABLED on {TTL_ATTRIBUTE!r}", + ) + + +def checks(ctx: SmokeContext) -> Iterator[CheckResult]: + """Yield the allow, deny, KMS and TTL rows for the Runtime role's history grant.""" + targets = _resolve_targets(ctx) + if isinstance(targets, CheckResult): + yield targets + return + run = uuid.uuid4().hex[:12] + role = targets.role_arn + reps_arn = targets.table_arns[HISTORY_TABLE] + own_key = history_key("demo", f"smoke-{run}") + + def simulate(action: str, resource: str, entries: list[dict[str, Any]] | None = None) -> str: + return _simulate(ctx, role, action, resource, entries) + + for action in GRANTED_ACTIONS: + entries = _leading_keys(own_key) + if action == PUT_ITEM: + entries.append(_context(_ATTRIBUTES, HISTORY_ITEM_ATTRIBUTES, "stringList")) + yield _row( + reps_arn, + f"allow:{action}@history#", + simulate(action, reps_arn, entries), + _ALLOWED, + "the Runtime reads and writes its conversation-history items", + ) + + foreign_keys = { + "usersettings#": user_settings_key("demo", f"smoke-{run}"), + "conversation#": conversation_key(f"smoke-{run}"), + "rep_id": f"rep-smoke-{run}", + "history#canary#": history_key("canary", f"smoke-{run}"), + } + for label, key in foreign_keys.items(): + for action in GRANTED_ACTIONS: + yield _row( + reps_arn, + f"explicit_deny:{action}@{label}", + simulate(action, reps_arn, _leading_keys(key)), + _EXPLICIT_DENY, + "a key outside the history prefix, or the canary tenant's history, is denied by " + "a Deny statement, not only by the Allow's absence", + ) + + yield _row( + reps_arn, + f"deny_without_leading_keys:{GET_ITEM}", + simulate(GET_ITEM, reps_arn), + _DENIED, + "with no dynamodb:LeadingKeys context the Allow's Null condition must not match", + ) + yield _row( + reps_arn, + f"deny_tenant_attribute:{PUT_ITEM}", + simulate( + PUT_ITEM, + reps_arn, + [ + *_leading_keys(own_key), + _context(_ATTRIBUTES, [*HISTORY_ITEM_ATTRIBUTES, "tenant"], "stringList"), + ], + ), + _DENIED, + "a history write carrying `tenant` would surface in gsi_tenant reads", + ) + + for action in DENIED_TABLE_ACTIONS: + yield _row( + reps_arn, + f"explicit_deny:{action}@reps", + simulate(action, reps_arn, _leading_keys(own_key)), + _EXPLICIT_DENY, + "only GetItem and PutItem are granted on reps; every other action is denied", + ) + index_arn = f"{reps_arn}/index/gsi_tenant" + yield _row( + index_arn, + "explicit_deny:dynamodb:Query@reps/index", + simulate("dynamodb:Query", index_arn, _leading_keys(own_key)), + _EXPLICIT_DENY, + "the reps indexes are denied", + ) + + for logical, table_arn in sorted(targets.table_arns.items()): + if logical == HISTORY_TABLE: + continue + yield _row( + table_arn, + f"explicit_deny:{GET_ITEM}@{logical}", + simulate(GET_ITEM, table_arn, _leading_keys(own_key)), + _EXPLICIT_DENY, + "the Runtime role is on every table's data-plane allowlist, so its identity policy " + "must deny every table but reps", + ) + + via_dynamodb = _context(_VIA_SERVICE, [f"dynamodb.{ctx.region}.amazonaws.com"], "string") + reps_name = str(targets.table_names[HISTORY_TABLE]) + other_name = str(next(v for k, v in sorted(targets.table_names.items()) if k != HISTORY_TABLE)) + for action in KMS_ACTIONS: + yield _row( + targets.kms_key_arn, + f"allow:{action}@reps", + simulate( + action, + targets.kms_key_arn, + [via_dynamodb, _context(_TABLE_NAME_CONTEXT, [reps_name], "string")], + ), + _ALLOWED, + "DynamoDB uses the CMK on the Runtime's behalf for reps", + ) + yield _row( + targets.kms_key_arn, + "deny:kms:Decrypt@other_table", + simulate( + "kms:Decrypt", + targets.kms_key_arn, + [via_dynamodb, _context(_TABLE_NAME_CONTEXT, [other_name], "string")], + ), + _DENIED, + "the CMK is shared by every table; the Runtime may use it for reps only", + ) + yield _row( + targets.kms_key_arn, + "deny:kms:Decrypt@without_via_service", + simulate( + "kms:Decrypt", + targets.kms_key_arn, + [_context(_TABLE_NAME_CONTEXT, [reps_name], "string")], + ), + _DENIED, + "the CMK is usable only through DynamoDB", + ) + + yield _ttl_row(ctx, reps_name, reps_arn) + + +def expected_check_count(ctx: SmokeContext) -> ExpectedCheckCount: + """Derived from the action tuples and the `dynamodb_table_names` output.""" + try: + other_tables = len(ctx.outputs.require_mapping("dynamodb_table_names")) - 1 + except Exception: # noqa: BLE001 - an absent output yields the single failing row + other_tables = 0 + granted = len(GRANTED_ACTIONS) + minimum = ( + granted # allow rows + + 4 * granted # four foreign key prefixes + + 2 # no-context and tenant-attribute denies + + len(DENIED_TABLE_ACTIONS) + + 1 # index Query + + max(other_tables, 0) + + len(KMS_ACTIONS) + + 2 # KMS denies + + 1 # TTL + ) + return ExpectedCheckCount( + minimum=minimum, + basis=( + f"{granted} allow + {4 * granted} foreign-key denies + 2 condition denies + " + f"{len(DENIED_TABLE_ACTIONS)} other-action denies + 1 index deny + {other_tables} " + f"other-table denies + {len(KMS_ACTIONS)} KMS allow + 2 KMS denies + 1 TTL row" + ), + ) + + +def main(argv: Sequence[str] | None = None) -> int: + """CLI entry point: emit the Runtime history grant inventory, non-zero on any fail.""" + return run_main( + argv, + description=__doc__ or "", + layer=LAYER, + resource_class=RESOURCE_CLASS, + checks=checks, + expected=expected_check_count, + ) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/smoke/runtime_inbound_auth.py b/scripts/smoke/runtime_inbound_auth.py index ab45569..18dcfcb 100644 --- a/scripts/smoke/runtime_inbound_auth.py +++ b/scripts/smoke/runtime_inbound_auth.py @@ -35,13 +35,22 @@ from __future__ import annotations import json +import re import sys import uuid from collections.abc import Callable, Iterator, Mapping, Sequence from typing import Any, Final from scripts import proc_run -from scripts.smoke.harness import CheckResult, ExpectedCheckCount, SmokeContext, run_main +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + SmokeContext, + aws_error_code, + aws_error_detail, + exception_detail, + run_main, +) from scripts.smoke.runtime_network_posture import ( DeclaredDeny, DeclaredDenyState, @@ -80,6 +89,9 @@ #: How the AWS CLI reports an operation it does not model. _CLI_UNSUPPORTED_MARKER: Final[str] = "invalid choice" +#: The AWS error code in an AWS CLI `An error occurred ()` stderr line. +_CLI_ERROR_CODE: Final[re.Pattern[str]] = re.compile(r"An error occurred \(([A-Za-z0-9.]+)\)") + #: The error code an unlisted principal's `InvokeAgentRuntime` must be refused with. ACCESS_DENIED_CODE: Final[str] = "AccessDeniedException" @@ -131,7 +143,7 @@ def _caller_role_name(caller_arn: str) -> str: def _refusal_result(exc: BaseException, *, runtime_arn: str, role: str) -> CheckResult: - """Classify the unlisted caller's refused `InvokeAgentRuntime`; the detail quotes the message. + """Classify the unlisted caller's refused `InvokeAgentRuntime`; the detail names the code only. Only an `AccessDeniedException` from an explicit deny in this Runtime's resource-based policy passes. Any other `AccessDeniedException` (an implicit deny, an identity-policy, SCP or @@ -139,10 +151,8 @@ def _refusal_result(exc: BaseException, *, runtime_arn: str, role: str) -> Check """ from scripts.smoke.runtime_invoke import is_explicit_inbound_deny - error = getattr(exc, "response", {}).get("Error", {}) - code = str(error.get("Code", type(exc).__name__)) - message = str(error.get("Message", exc)) - observed = f"InvokeAgentRuntime as {role!r} -> {code}: {message!r}" + code = aws_error_code(exc) + observed = f"InvokeAgentRuntime as {role!r} -> {code}" passed = is_explicit_inbound_deny(exc, runtime_arn=runtime_arn) if passed: suffix = OUTSIDE_VPC_BOUND @@ -219,13 +229,22 @@ def _unlisted_principal_results( verdict.""" try: caller = str(ctx.client("sts").get_caller_identity()["Arn"]) + except Exception as exc: # noqa: BLE001 - a failing row, not a crash + yield CheckResult( + resource=runtime_arn, + check="caller_is_not_a_runtime_invoker", + status="fail", + detail=f"could not establish the caller: {aws_error_detail('sts:GetCallerIdentity', exc)}", + ) + return + try: invokers = _invoker_role_names() except Exception as exc: # noqa: BLE001 - a failing row, not a crash yield CheckResult( resource=runtime_arn, check="caller_is_not_a_runtime_invoker", status="fail", - detail=f"could not establish the caller or the invoker list: {type(exc).__name__}: {exc}", + detail=f"could not read the invoker list: {exception_detail(exc)}", ) return role = _caller_role_name(caller) @@ -339,6 +358,16 @@ class _PolicyReadUnsupportedError(Exception): """Neither botocore nor the AWS CLI supports `get-resource-policy`; the message says which.""" +class _PolicyCliReadError(Exception): + """The AWS CLI policy read exited non-zero; `response` carries the parsed AWS error code only.""" + + def __init__(self, returncode: int, stderr: str) -> None: + match = _CLI_ERROR_CODE.search(stderr) + code = match.group(1) if match else f"CliExit{returncode}" + super().__init__(f"aws CLI exit {returncode}") + self.response: dict[str, dict[str, str]] = {"Error": {"Code": code}} + + def _read_policy_text(ctx: SmokeContext, client: Any, arn: str, runner: CliRunner) -> str: """The policy document text, from botocore when it models the operation, else from the CLI. @@ -360,7 +389,7 @@ def _read_policy_text(ctx: SmokeContext, client: Any, arn: str, runner: CliRunne "neither botocore nor the installed aws CLI supports " f"bedrock-agentcore-control get-resource-policy ({err.strip()[:160]})" ) - raise RuntimeError(f"aws CLI exit {code}: {err.strip()[:240]}") + raise _PolicyCliReadError(code, err) return str(json.loads(out)["policy"]) @@ -370,13 +399,23 @@ def _principal_set_results( """One row per resource policy: its Allow principals equal exactly the invoker role ARNs.""" try: account = str(ctx.client("sts").get_caller_identity()["Account"]) + except Exception as exc: # noqa: BLE001 - a failing row, not a crash + yield CheckResult( + resource=runtime_arn, + check=PRINCIPAL_SET_CHECK, + status="fail", + detail="could not derive the invoker role ARNs: " + + aws_error_detail("sts:GetCallerIdentity", exc), + ) + return + try: expected = {f"arn:aws:iam::{account}:role/{name}" for name in _invoker_role_names()} except Exception as exc: # noqa: BLE001 - a failing row, not a crash yield CheckResult( resource=runtime_arn, check=PRINCIPAL_SET_CHECK, status="fail", - detail=f"could not derive the invoker role ARNs: {type(exc).__name__}: {exc}", + detail=f"could not derive the invoker role ARNs: {exception_detail(exc)}", ) return client = ctx.client("bedrock-agentcore-control") @@ -399,7 +438,8 @@ def _principal_set_results( resource=arn, check=PRINCIPAL_SET_CHECK, status="fail", - detail=f"the resource policy could not be read: {type(exc).__name__}: {exc}", + detail="the resource policy could not be read: " + + aws_error_detail("bedrock-agentcore-control:GetResourcePolicy", exc), ) continue exact = bool(expected) and principals == expected and not problems @@ -438,7 +478,7 @@ def checks( check="terraform_output_present", status="fail", detail=( - f"required Terraform output 'agentcore_runtime_arn' is absent ({exc}); the " + f"required Terraform output 'agentcore_runtime_arn' is absent ({exception_detail(exc)}); the " "Runtime to describe cannot be identified. A missing output is a failure, not " "a skipped resource class" ), diff --git a/scripts/smoke/runtime_network_posture.py b/scripts/smoke/runtime_network_posture.py index b5525e6..4d17c3b 100644 --- a/scripts/smoke/runtime_network_posture.py +++ b/scripts/smoke/runtime_network_posture.py @@ -42,7 +42,13 @@ from typing import Any, Final from scripts import region_map -from scripts.smoke.harness import CheckResult, ExpectedCheckCount, SmokeContext, run_main +from scripts.smoke.harness import ( + CheckResult, + ExpectedCheckCount, + SmokeContext, + exception_detail, + run_main, +) LAYER: Final[int] = 4 RESOURCE_CLASS: Final[str] = "runtime_network_posture" @@ -184,7 +190,7 @@ def copy_platform_version(http_response: Any, parsed: Any, **_: Any) -> None: return try: body = json.loads(getattr(http_response, "content", b"") or b"{}") - except (ValueError, TypeError): + except ValueError, TypeError: return if isinstance(body, Mapping) and isinstance(body.get(_PLATFORM_VERSION_KEY), str): parsed[_PLATFORM_VERSION_KEY] = body[_PLATFORM_VERSION_KEY] @@ -345,7 +351,7 @@ def _resource_policy_has_source_vpce_deny(ctx: SmokeContext, resource_arn: str) return DenyReadResult.READ_FAILED try: document = json.loads(policy_text) - except (ValueError, TypeError): + except ValueError, TypeError: return DenyReadResult.READ_FAILED for statement in document.get("Statement", []): if not isinstance(statement, Mapping): @@ -368,7 +374,7 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one line resource="agentcore_runtime_arn", check="terraform_output_present", status="fail", - detail=f"required Terraform output 'agentcore_runtime_arn' is absent ({exc})", + detail=f"required Terraform output 'agentcore_runtime_arn' is absent ({exception_detail(exc)})", ) return @@ -389,7 +395,7 @@ def checks(ctx: SmokeContext) -> Iterator[CheckResult]: # noqa: C901 - one line resource=runtime_arn, check="runtime_ready", status="fail", - detail=f"the runtime or its endpoint status could not be read: {type(exc).__name__}: {exc}", + detail=f"the runtime or its endpoint status could not be read: {exception_detail(exc)}", ) return yield CheckResult( diff --git a/scripts/smoke/smoke_token.py b/scripts/smoke/smoke_token.py index 94f0330..4e3facc 100644 --- a/scripts/smoke/smoke_token.py +++ b/scripts/smoke/smoke_token.py @@ -30,7 +30,7 @@ from typing import Any, Final from scripts.smoke.cognito_claims import LiveSmokeUserProvisioner, _live_decode_for -from scripts.smoke.harness import SmokeContext, smoke_context +from scripts.smoke.harness import SmokeContext, exception_detail, smoke_context from scripts.smoke.tenant import SmokeTenant, is_smoke_run_id from crm.authz import DEMO_TENANT @@ -154,7 +154,7 @@ def assert_supplied_token(ctx: SmokeContext, *, id_token: str, expected_tenant: except Exception as exc: raise RuntimeError( f"the supplied token could not be decoded or verified against the pool: " - f"{type(exc).__name__}: {exc}. A token that cannot be verified cannot be shown to name " + f"{exception_detail(exc)}. A token that cannot be verified cannot be shown to name " "this run's tenant, so it is refused rather than passed on." ) from exc return assert_token_tenant(claims, expected=expected_tenant) diff --git a/scripts/smoke/store_principal_deny.py b/scripts/smoke/store_principal_deny.py index 8cfec60..447d615 100644 --- a/scripts/smoke/store_principal_deny.py +++ b/scripts/smoke/store_principal_deny.py @@ -129,6 +129,7 @@ ExpectedCheckCount, SmokeContext, Status, + aws_error_code, error_code, key_policy_for_simulation, open_https, @@ -608,7 +609,7 @@ def _fail(resource: str, check: str, detail: str) -> CheckResult: def _raised(action: str, exc: BaseException) -> str: - return f"{action} raised {error_code(exc) or type(exc).__name__}: {exc}" + return f"{action} raised {aws_error_code(exc)}" def read_backend_config(path: Path) -> dict[str, str] | None: @@ -1852,11 +1853,10 @@ def classify_store_probe( else None ) if code in REACHED_RESOURCE_CODES or status_code in (404, 412): - message = str((getattr(outcome, "response", {}) or {}).get("Error", {}).get("Message", "")) return _fail( resource, f"probe_denied:{check_suffix}", - f"the call reached the resource, no boundary refused it ({code or status_code}: {message})", + f"the call reached the resource, no boundary refused it ({code or status_code})", ) return classify_probe(check_suffix, resource, outcome, probe_role) @@ -2023,7 +2023,7 @@ def _delete_probe_role(ctx: SmokeContext, role_name: str) -> CheckResult: return _fail( role_name, CHECK_PROBE_ROLE_DELETED, - f"deleting probe role {role_name} {_raised('', exc).strip()}. Delete it by hand.", + f"deleting probe role {role_name} raised {aws_error_code(exc)}. Delete it by hand.", ) return CheckResult( resource=role_name, @@ -2191,7 +2191,8 @@ def _probe_rows( _fail( role_name, CHECK_PROBE_ROLE_SETUP, - f"{_raised('setting up or running the probe', exc)}; the rows below were not classified", + f"setting up or running the probe raised {aws_error_code(exc)}; " + "the rows below were not classified", ) ) done = {row.check for row in rows} diff --git a/scripts/smoke/three_tier_chat.py b/scripts/smoke/three_tier_chat.py index b7f491a..5609d4e 100644 --- a/scripts/smoke/three_tier_chat.py +++ b/scripts/smoke/three_tier_chat.py @@ -45,8 +45,37 @@ generic validation message, with the marker absent from the response body. They make no model call and are not counted. +**Check 8 — latest-message prompt caching.** Three tool-free anthropic-supervisor turns with one +prompt from :func:`cache_history_prompt`: **C** in a fresh session, then **A** and **B** in one +shared session S. The prompt carries a nonce drawn once per run, so a re-run within the cache TTL +cannot read an earlier run's cached copy of it. `pass` when no turn emitted a `tool_call` frame and +B's supervisor `cache_read_tokens` exceeds C's: a cache point on the latest message is read back by +a later turn. The row does not show that the session's history reached the model; check 9 does. A +`tool_call` frame on any of the three is a `defer` (:data:`CACHE_HISTORY_TOOL_CALL_REASON`); C +reading zero with no write reported on any turn is a `defer` (:data:`CACHE_UNREPORTED_REASON`); +otherwise B not exceeding C fails. The three turns are issued only when the module's share still has +room for all of them. + +**Check 9 — a follow-up turn carries the session's history.** Four tool-free anthropic-supervisor +turns: **A** in a fresh session S states a run-unique code word (:func:`history_fact_prompt`), **B** +in S asks for it, and a control in another fresh session asks the same. `pass` when B's answer +contains the code word, B's supervisor `cache_write_tokens > 0` with `cache_read_tokens` at least +A's, and the control completed without it. A fourth turn in S omits `resume_from`, as an MCP +client's follow-up does, and repeats the question in other words: it must answer with the code word +and read more cached prompt than B, which a replay of B cannot. The Runtime log streams must show +every check-9 turn, and no stream of any of this module's sessions may carry a +`history_read_failed`, `history_write_failed` or `history_write_conflict` line. The operator then +reads S's history item in `reps` (:func:`crm.store.keys.history_key` under user A's tenant): it must +exist, name user A's tenant as its owner, and expire within the store's TTL. Every history item this +module's sessions could have written is deleted in a `finally` and proved absent by re-read. The +four turns are issued only when the module's share still has room for all of them. + Runtime-role Bedrock IAM is checked by `scripts/smoke/runtime_bedrock_iam.py`, not here. +Every live turn sends its session's recorded-frame count as `resume_from` +(:class:`ResumeCursor`), so a follow-up turn in a session runs rather than replaying the session's +previous turn. + Tokens come from disposable smoke users removed in a `finally`; never the `demo` or `canary` tenant. Billable: a live turn makes real model calls. Model-backed turns are counted against this module's share of the post-deploy envelope (:data:`MODEL_TURN_ALLOTMENTS`) and the count is printed; @@ -65,10 +94,21 @@ import urllib.request from collections.abc import Callable, Iterable, Mapping, Sequence from dataclasses import dataclass -from typing import Any, Final, NamedTuple - -from scripts.smoke.harness import DEFER, CheckResult, SmokeContext, open_https, run_main +from decimal import Decimal +from typing import Any, Final, NamedTuple, Protocol + +from scripts.smoke.harness import ( + DEFER, + CheckResult, + ExpectedCheckCount, + SmokeContext, + exception_detail, + open_https, + run_main, +) +from agents.conversation_history import DEFAULT_TTL_SECONDS, HISTORY_ITEM_ATTRIBUTES +from crm.store.keys import history_key from crm.toolspec.page_context import ROUTE_MAX_LENGTH from providers.capabilities import CapabilityMatrix, load_capability_matrix from providers.tier_tuning import WIRE_SCHEMA_VERSION @@ -120,7 +160,7 @@ #: Post-deploy model-backed turns, split between the modules that spend them. MODEL_TURN_ENVELOPE: Final[int] = 20 MODEL_TURN_ALLOTMENTS: Final[Mapping[str, int]] = { - "three_tier_chat": 5, + "three_tier_chat": 12, "mcp_chat_gateway": 2, "agents": 1, } @@ -140,6 +180,71 @@ #: Check 6's second openai turn: no tool needed, so it is one supervisor round. _OPENAI_CACHE_PROBE_PROMPT: Final[str] = "Reply with the single word: ready. Do not call any tool." +#: Check 8's instruction, which :func:`cache_history_prompt` follows with the run's nonce. +_CACHE_HISTORY_INSTRUCTION: Final[str] = ( + "Reply with one short sentence confirming you are ready. Do not call any tool." +) + + +def cache_history_prompt(nonce: str) -> str: + """Check 8's prompt for one run: the instruction plus `nonce`, sent unchanged on C, A and B.""" + return f"{_CACHE_HISTORY_INSTRUCTION} Ignore this cache-busting nonce: {nonce}." + + +#: Check 8's model-backed turns: C (fresh session), then A and B (one shared session). +CACHE_HISTORY_TURNS: Final[int] = 3 + +#: Check 8's defer reason when a turn called a tool, so it was not a single supervisor call. +CACHE_HISTORY_TOOL_CALL_REASON: Final[str] = "cache_history_turn_called_a_tool" + +CACHE_HISTORY_CHECK: Final[str] = "supervisor_prompt_cache_reads_latest_message:anthropic" + +#: Check 9's model-backed turns: A and B in one session, a fresh-session control, then a follow-up +#: in A's session that omits `resume_from`. +HISTORY_RECALL_TURNS: Final[int] = 4 + +HISTORY_RECALL_CHECK: Final[str] = "followup_turn_carries_history:anthropic" +HISTORY_ITEM_CHECK: Final[str] = "history_item_owned_and_expiring" +HISTORY_ITEMS_DELETED_CHECK: Final[str] = "history_items_deleted" +HISTORY_OMITTED_RESUME_CHECK: Final[str] = "followup_without_resume_from_carries_history:anthropic" +HISTORY_LOG_CHECK: Final[str] = "history_store_failures_absent_from_runtime_logs" + +#: The Runtime's log events for a history store error or a write lost after its retries; the turn's +#: answer is delivered regardless. +HISTORY_FAILURE_EVENTS: Final[tuple[str, ...]] = ( + "history_read_failed", + "history_write_failed", + "history_write_conflict", +) + +#: How long check 9 polls the Runtime log group for its turns' `invocation_started` lines. +_HISTORY_LOG_POLL_SECONDS: Final[float] = 180.0 +_HISTORY_LOG_POLL_INTERVAL: Final[float] = 10.0 + +#: The `reps` table, which holds the Runtime's conversation-history items. +_HISTORY_TABLE: Final[str] = "reps" + +#: Check 9's question, sent unchanged on B and on the control; it never carries the code word. +HISTORY_RECALL_PROMPT: Final[str] = ( + "What is my project code word? Reply with the code word only. Do not call any tool." +) + +#: Check 9's fourth turn, sent without `resume_from`; worded apart from B's so it is a new request. +HISTORY_REPEAT_PROMPT: Final[str] = ( + "Repeat my project code word once more, with no other text. Do not call any tool." +) + + +def history_fact_prompt(code_word: str) -> str: + """Check 9's turn A: states `code_word` as a fact for a later turn in the session to recall.""" + return f"My project code word is {code_word}. Reply OK. Do not call any tool." + + +def history_code_word() -> str: + """A run-unique code word for check 9; it occurs in no prompt but turn A's.""" + return f"zq{_suffix()[:12]}" + + #: Check 7's prompt; the turn is refused before any model call. _PAGE_REFUSAL_PROMPT: Final[str] = "Reply with the single word: ready." @@ -334,6 +439,67 @@ class CloudTrailEvent: ProvisionerFactory = Callable[[SmokeContext], Any] +class HistoryItems(Protocol): + """Operator access to the `reps` history items, by their `rep_id` key.""" + + def get(self, rep_id: str) -> Mapping[str, Any] | None: + """The item at `rep_id`, strongly consistent, or `None`.""" + ... + + def delete(self, rep_id: str) -> None: + """Delete the item at `rep_id`; absent is not an error.""" + ... + + +#: `(ctx) -> HistoryItems`. Live default addresses the deployed `reps` table. +HistoryItemsFactory = Callable[[SmokeContext], HistoryItems] + + +class _LiveHistoryItems: + """`HistoryItems` over the deployed `reps` table, as the operator credential.""" + + def __init__(self, ctx: SmokeContext) -> None: + from crm.store.store import Store + + names = ctx.outputs.require_mapping("dynamodb_table_names") + accounts = str(names["accounts"]) + self._store = Store( + client=ctx.client("dynamodb"), table_prefix=accounts[: -len("accounts")] + ) + + def get(self, rep_id: str) -> Mapping[str, Any] | None: + return self._store.get_item(_HISTORY_TABLE, {"rep_id": rep_id}, consistent=True) + + def delete(self, rep_id: str) -> None: + self._store.delete_item(_HISTORY_TABLE, {"rep_id": rep_id}) + + +def delete_history_items(items: HistoryItems, keys: Sequence[str]) -> CheckResult: + """Delete every history item in `keys` and prove each absent by a consistent re-read.""" + remaining: list[str] = [] + try: + for key in keys: + items.delete(key) + if items.get(key) is not None: + remaining.append(key) + except Exception as exc: # noqa: BLE001 - surfaced as a failing check, never swallowed + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_ITEMS_DELETED_CHECK, + status="fail", + detail=f"could not delete the history items: {exception_detail(exc)}", + ) + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_ITEMS_DELETED_CHECK, + status="fail" if remaining else "pass", + detail=( + f"{len(keys)} history key(s) deleted, {len(remaining)} still present on re-read" + + (f": {remaining}" if remaining else "") + ), + ) + + def _tier_profiles( families: Mapping[str, str], matrix: CapabilityMatrix | None = None ) -> dict[str, str]: @@ -400,6 +566,7 @@ def _live_run_turn( tuning: Mapping[str, Any], *, page_context: Mapping[str, Any] | None = None, + resume_from: int | None = 0, ) -> TurnResult: """Issue one authenticated turn through CloudFront -> relay -> Runtime, returning status + reason. @@ -416,12 +583,10 @@ def _live_run_turn( domain = ctx.outputs.require_str("cloudfront_domain_name") runtime_arn = ctx.outputs.require_str("agentcore_runtime_arn") url = f"https://{domain}/agent/{urllib.parse.quote(runtime_arn, safe='')}" - body_fields: dict[str, Any] = { - "prompt": prompt, - "session_id": session_id, - "resume_from": 0, - "tuning": dict(tuning), - } + body_fields: dict[str, Any] = {"prompt": prompt, "session_id": session_id} + if resume_from is not None: + body_fields["resume_from"] = resume_from + body_fields["tuning"] = dict(tuning) if page_context is not None: body_fields["page_context"] = dict(page_context) payload = json.dumps(body_fields).encode("utf-8") @@ -477,6 +642,59 @@ def _live_run_turn( ) +class ResumeCursor: + """Per-session count of the frames the Runtime records (every kind but `heartbeat`). + + A turn in a session that already has recorded frames must send that count as `resume_from`; + a lower value is a reconnect, and the Runtime replays the earlier frames instead of running it. + """ + + def __init__(self) -> None: + self._recorded: dict[str, int] = {} + + def resume_from(self, session_id: str) -> int: + """The `resume_from` the next turn in `session_id` sends.""" + return self._recorded.get(session_id, 0) + + def advance(self, session_id: str, kinds: Iterable[str]) -> None: + """Count the recorded frames of a turn in `session_id` that streamed `kinds`.""" + recorded = sum(1 for kind in kinds if kind != "heartbeat") + self._recorded[session_id] = self.resume_from(session_id) + recorded + + +class _LiveTurns: + """The live `RunTurn`: :func:`_live_run_turn` with each session's :class:`ResumeCursor` value. + + `omit_resume_from=True` sends no `resume_from` at all, as an MCP client's follow-up does. + """ + + def __init__(self) -> None: + self.cursor = ResumeCursor() + + def __call__( + self, + ctx: SmokeContext, + token: str, + session_id: str, + prompt: str, + tuning: Mapping[str, Any], + *, + page_context: Mapping[str, Any] | None = None, + omit_resume_from: bool = False, + ) -> TurnResult: + result = _live_run_turn( + ctx, + token, + session_id, + prompt, + tuning, + page_context=page_context, + resume_from=None if omit_resume_from else self.cursor.resume_from(session_id), + ) + self.cursor.advance(session_id, result.kinds) + return result + + def _live_cloudtrail_lookup(ctx: SmokeContext, start_ms: int, end_ms: int) -> list[CloudTrailEvent]: """LookupEvents for Bedrock model-invocation events in the window, parsed to (role, model_id). @@ -902,6 +1120,343 @@ def evaluate_cache_read( ) +def evaluate_cache_history( + fresh: TurnResult, seed: TurnResult, followup: TurnResult, *, model: str +) -> CheckResult: + """Check 8: the follow-up turn in a session reads more cached prompt than a fresh session. + + `fresh` is C, `seed` is A and `followup` is B (A's session). `fail` when any turn's supervisor + line on `model` is missing or malformed; `defer` when any turn emitted a `tool_call` frame, or + when C read nothing and no turn reported a cache write; `pass` when B's read exceeds C's; `fail` + otherwise. + """ + turns = {"C": fresh, "A": seed, "B": followup} + counts = {label: _supervisor_cache_counts(turn, model) for label, turn in turns.items()} + observed = ( + f"{model}: supervisor (read, write) C={counts['C']} A={counts['A']} B={counts['B']}; " + f"statuses {'/'.join(str(t.status) for t in turns.values())}" + ) + tool_turns = [label for label, turn in turns.items() if "tool_call" in turn.kinds] + if any(value is None for value in counts.values()): + return CheckResult( + resource=RESOURCE_CLASS, + check=CACHE_HISTORY_CHECK, + status="fail", + detail=( + f"{observed}; expected a completed frame with integer cache_read_tokens and " + "cache_write_tokens on each turn's supervisor cost line" + ), + ) + if tool_turns: + return CheckResult( + resource=RESOURCE_CLASS, + check=CACHE_HISTORY_CHECK, + status=DEFER, + detail=f"{observed}; turn(s) {tool_turns} called a tool, so the reads are not comparable", + defer_reason=CACHE_HISTORY_TOOL_CALL_REASON, + ) + read = {label: value[0] for label, value in counts.items() if value is not None} + written = sum(value[1] for value in counts.values() if value is not None) + if read["B"] > read["C"]: + return CheckResult( + resource=RESOURCE_CLASS, + check=CACHE_HISTORY_CHECK, + status="pass", + detail=f"{observed}; B read cached session history beyond C's prefix", + ) + if read["C"] == 0 and written == 0: + return CheckResult( + resource=RESOURCE_CLASS, + check=CACHE_HISTORY_CHECK, + status=DEFER, + detail=f"{observed}; the platform reported no prompt-cache write on any turn", + defer_reason=CACHE_UNREPORTED_REASON, + ) + return CheckResult( + resource=RESOURCE_CLASS, + check=CACHE_HISTORY_CHECK, + status="fail", + detail=f"{observed}; B read no more cached prompt than the fresh-session turn C", + ) + + +def evaluate_history_recall( + seed: TurnResult, + followup: TurnResult, + control: TurnResult, + *, + code_word: str, + model: str, +) -> CheckResult: + """Check 9: B recalls A's code word from the session's history, and a fresh session does not. + + `seed` is A, `followup` is B (A's session) and `control` is the fresh-session turn. `pass` only + when B's answer contains `code_word`, B's supervisor line on `model` reports + `cache_write_tokens > 0` with `cache_read_tokens` at least A's, and the control completed with + an answer that does not contain `code_word`. Anything else fails. + """ + counts = { + "A": _supervisor_cache_counts(seed, model), + "B": _supervisor_cache_counts(followup, model), + } + recalled = code_word in followup.answer + control_completed = control.status == 200 and control.completed is not None + leaked = code_word in control.answer + observed = ( + f"{model}: supervisor (read, write) A={counts['A']} B={counts['B']}; statuses " + f"{seed.status}/{followup.status}/{control.status}; B recalled the code word: {recalled}; " + f"control completed: {control_completed}, control carried it: {leaked}" + ) + seed_counts, followup_counts = counts["A"], counts["B"] + if seed_counts is None or followup_counts is None: + reason = "expected integer cache tokens on A's and B's supervisor cost lines" + elif not recalled: + reason = "B's answer does not contain the code word A stated in the same session" + elif followup_counts[1] <= 0: + reason = "B reported no cache write, so no new history tail was sent to the model" + elif followup_counts[0] < seed_counts[0]: + reason = "B read less cached prompt than A, so B's prompt does not extend A's" + elif not control_completed: + reason = "the fresh-session control did not complete, so a leak cannot be ruled out" + elif leaked: + reason = "the fresh-session control answered with the code word: history crossed sessions" + else: + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_RECALL_CHECK, + status="pass", + detail=f"{observed}; B recalled the session's history and the control did not", + ) + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_RECALL_CHECK, + status="fail", + detail=f"{observed}; {reason}", + ) + + +def evaluate_history_item( + item: Mapping[str, Any] | None, *, tenant: str, now: float, ttl_seconds: int +) -> CheckResult: + """Check 9's operator read: the history item exists, is owned by `tenant`, and expires in TTL. + + `pass` when `item` carries exactly :data:`HISTORY_ITEM_ATTRIBUTES` (so no `tenant`), with + `kind == "history"`, `owner_tenant == tenant`, a non-empty `owner_rep_id`, and a numeric + `expires_at` in `(now, now + ttl_seconds]`. + """ + if item is None: + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_ITEM_CHECK, + status="fail", + detail=f"no history item for the session under tenant {tenant!r}", + ) + expires_at = item.get("expires_at") + numeric = isinstance(expires_at, int | float | Decimal) and not isinstance(expires_at, bool) + in_window = numeric and now < float(expires_at) <= now + ttl_seconds # type: ignore[arg-type] + owner_rep = item.get("owner_rep_id") + extra = sorted(set(item) - HISTORY_ITEM_ATTRIBUTES) + missing = sorted(HISTORY_ITEM_ATTRIBUTES - set(item)) + ok = ( + not extra + and not missing + and item.get("kind") == "history" + and item.get("owner_tenant") == tenant + and isinstance(owner_rep, str) + and bool(owner_rep) + and in_window + ) + turns = item.get("turns") + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_ITEM_CHECK, + status="pass" if ok else "fail", + detail=( + f"kind={item.get('kind')!r} owner_tenant matches: {item.get('owner_tenant') == tenant} " + f"owner_rep_id set: {isinstance(owner_rep, str) and bool(owner_rep)} " + f"turns={len(turns) if isinstance(turns, list) else turns!r} expires_at={expires_at!r} " + f"window=({now:.0f}, {now + ttl_seconds:.0f}] extra={extra} missing={missing}" + + ("" if ok else "; expected a history item owned by user A's tenant within the TTL") + ), + ) + + +def evaluate_omitted_resume_recall( + followup: TurnResult, repeat: TurnResult, *, code_word: str, model: str +) -> CheckResult: + """Check 9's fourth turn: a same-session follow-up without `resume_from` still recalls. + + `followup` is B and `repeat` the fourth turn. `pass` when the repeat's answer contains + `code_word` and its supervisor `cache_read_tokens` exceeds B's. A replay of B carries B's + answer and B's counts unchanged, so it fails. + """ + counts = { + "B": _supervisor_cache_counts(followup, model), + "R": _supervisor_cache_counts(repeat, model), + } + recalled = code_word in repeat.answer + observed = ( + f"{model}: supervisor (read, write) B={counts['B']} repeat={counts['R']}; statuses " + f"{followup.status}/{repeat.status}; repeat recalled the code word: {recalled}" + ) + b_counts, r_counts = counts["B"], counts["R"] + if b_counts is None or r_counts is None: + reason = "expected integer cache tokens on B's and the repeat's supervisor cost lines" + elif not recalled: + reason = "the follow-up sent without resume_from does not carry the code word" + elif r_counts[0] <= b_counts[0]: + reason = ( + "the follow-up read no more cached prompt than B, so it did not extend the session " + "(a replay of B reports B's counts)" + ) + else: + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_OMITTED_RESUME_CHECK, + status="pass", + detail=f"{observed}; a follow-up without resume_from ran and carried the history", + ) + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_OMITTED_RESUME_CHECK, + status="fail", + detail=f"{observed}; {reason}", + ) + + +@dataclass(frozen=True, slots=True) +class RuntimeLogLine: + """One Runtime log event: the stream it was written to and its message.""" + + stream: str + message: str + + +#: `(ctx, start_ms, end_ms) -> list[RuntimeLogLine]`. Live default reads the Runtime log group. +RuntimeLogLookup = Callable[[SmokeContext, int, int], "list[RuntimeLogLine]"] + + +def _live_runtime_log_lookup(ctx: SmokeContext, start_ms: int, end_ms: int) -> list[RuntimeLogLine]: + """Every event in the Runtime log group between `start_ms` and `end_ms`, following pages.""" + client = ctx.client("logs") + request: dict[str, Any] = { + "logGroupName": ctx.outputs.require_str("agentcore_runtime_log_group_name"), + "startTime": start_ms, + "endTime": end_ms, + } + lines: list[RuntimeLogLine] = [] + while True: + response = client.filter_log_events(**request) + lines.extend( + RuntimeLogLine( + stream=str(e.get("logStreamName", "")), message=str(e.get("message", "")) + ) + for e in response.get("events", []) + ) + token = response.get("nextToken") + if not token: + return lines + request["nextToken"] = token + + +def _invocations_by_session( + lines: Sequence[RuntimeLogLine], sessions: Sequence[str] +) -> dict[str, list[str]]: + """`{session: [stream, ...]}` of the `invocation_started` lines naming each session.""" + found: dict[str, list[str]] = {session: [] for session in sessions} + for line in lines: + if '"invocation_started"' not in line.message: + continue + for session in sessions: + if f'"session_id": "{session}"' in line.message: + found[session].append(line.stream) + return found + + +def evaluate_history_logs( + lines: Sequence[RuntimeLogLine], + turns_by_session: Mapping[str, int], + *, + module_sessions: Sequence[str] = (), + poll_summary: str = "", +) -> CheckResult: + """Check 9's log read: no history store failure on any of the module's turns. + + A history failure line carries no session id, so it is attributed by its log stream: a stream + whose name contains one of `module_sessions` or of `turns_by_session`'s sessions. The control + is that each of `turns_by_session`'s sessions has at least that many `invocation_started` + lines, all in streams whose name contains the session id; without it a missing failure line + proves nothing. + """ + sessions = list(turns_by_session) + invocations = _invocations_by_session(lines, sessions) + seen = {session: len(streams) for session, streams in invocations.items()} + attributable = {*sessions, *module_sessions} + session_streams = { + line.stream for line in lines if any(session in line.stream for session in attributable) + } + attributed = all( + seen[session] >= turns_by_session[session] + and all(session in stream for stream in invocations[session]) + for session in sessions + ) + failures = [ + f"{line.stream}: {event}" + for line in lines + if line.stream in session_streams + for event in HISTORY_FAILURE_EVENTS + if f'"{event}"' in line.message + ] + observed = ( + f"invocation_started per session {seen} (expected {dict(turns_by_session)}); " + f"{len(session_streams)} session stream(s); history failure lines {failures}" + + (f" [{poll_summary}]" if poll_summary else "") + ) + if not attributed: + reason = ( + "the log read did not find every turn's invocation_started line in a stream naming " + "its session, so the absence of a failure line is not evidence" + ) + elif failures: + reason = "the history store failed on a module turn; the answer is delivered either way" + else: + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_LOG_CHECK, + status="pass", + detail=f"{observed}; every turn logged and no history store failure", + ) + return CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_LOG_CHECK, + status="fail", + detail=f"{observed}; {reason}", + ) + + +def _poll_history_logs( + lookup: RuntimeLogLookup, + ctx: SmokeContext, + start_ms: int, + turns_by_session: Mapping[str, int], + *, + clock: Callable[[], float], + sleeper: Callable[[float], None] | None, +) -> tuple[list[RuntimeLogLine], str]: + """Poll until every session's `invocation_started` lines are in, or the bound elapses.""" + wait = sleeper if sleeper is not None else time.sleep + started = clock() + polls = 0 + while True: + lines = lookup(ctx, start_ms, int(clock() * 1000) + 60_000) + polls += 1 + seen = _invocations_by_session(lines, list(turns_by_session)) + complete = all(len(seen[s]) >= n for s, n in turns_by_session.items()) + if complete or clock() - started >= _HISTORY_LOG_POLL_SECONDS: + return lines, f"polls={polls} elapsed={clock() - started:.0f}s lines={len(lines)}" + wait(_HISTORY_LOG_POLL_INTERVAL) + + def evaluate_page_context_refusal( check: str, result: TurnResult, *, marker: str, control: TurnResult ) -> CheckResult: @@ -943,10 +1498,28 @@ def checks( cloudtrail_lookup: CloudTrailLookup | None = None, clock: Callable[[], float] | None = None, sleeper: Callable[[float], None] | None = None, + history_items: HistoryItemsFactory | None = None, + runtime_logs: RuntimeLogLookup | None = None, ) -> Iterable[CheckResult]: - """Provision users, drive the live turns of checks 1-7, assert, and clean up in a `finally`.""" + """Provision users, drive the live turns of checks 1-9, assert, and clean up in a `finally`. + + Every session id a token is sent with is recorded, and each provisioned user's history items + for those sessions are deleted before the users are removed. + """ factory = provisioner_factory if provisioner_factory is not None else _default_provisioner - turn = run_turn if run_turn is not None else _live_run_turn + send = run_turn if run_turn is not None else _LiveTurns() + items_factory = history_items if history_items is not None else _LiveHistoryItems + log_lookup = runtime_logs if runtime_logs is not None else _live_runtime_log_lookup + sessions_by_token: dict[str, list[str]] = {} + + def turn( + ctx: SmokeContext, token: str, session_id: str, *args: Any, **kwargs: Any + ) -> TurnResult: + sessions = sessions_by_token.setdefault(token, []) + if session_id not in sessions: + sessions.append(session_id) + return send(ctx, token, session_id, *args, **kwargs) + lookup = cloudtrail_lookup if cloudtrail_lookup is not None else _live_cloudtrail_lookup now = clock if clock is not None else time.time attribution = select_attribution_mapping() @@ -957,12 +1530,15 @@ def checks( runtime_role = _runtime_role_name(ctx) budget = ModelTurnBudget(RESOURCE_CLASS) + logs_from_ms = int(now() * 1000) - 60_000 provisioners: list[Any] = [] + tokens: dict[int, str] = {} try: # --- Check 1: three-tier CloudTrail attribution --- prov_a = factory(ctx) provisioners.append(prov_a) token_a = prov_a.provision() + tokens[id(prov_a)] = token_a if attribution.families is None: yield attribution_collision_row(attribution) else: @@ -1027,6 +1603,7 @@ def checks( prov_b = factory(ctx) provisioners.append(prov_b) token_b = prov_b.provision() + tokens[id(prov_b)] = token_b shared_session = f"t3-hist-{_suffix()}" # A seeds the session under the mixed-family tuning (check 2), then reuses it (control: # owner reuse is permitted). B reusing A's session_id must be refused as a session @@ -1100,12 +1677,149 @@ def checks( page_context=page_context_for(route), ) yield evaluate_page_context_refusal(check, refusal, marker=marker, control=probe) + + # --- Check 8: a same-session follow-up reads cached history beyond the stable prefix --- + if budget.allotment - len(budget.used) < CACHE_HISTORY_TURNS: + yield budget_refused(budget, "cache-history turns") + return + history_tuning = tuning_block(dict.fromkeys(_TIERS, _FAMILY)) + history_model = expected_tier_models(dict.fromkeys(_TIERS, _FAMILY))["supervisor"] + history_session = f"t3-chist-{_suffix()}" + history_prompt = cache_history_prompt(_suffix()) + history: list[TurnResult] = [] + for label, session in ( + ("cache-history turn C", f"t3-cfresh-{_suffix()}"), + ("cache-history turn A", history_session), + ("cache-history turn B", history_session), + ): + budget.spend(label) + history.append(turn(ctx, token_a, session, history_prompt, history_tuning)) + yield evaluate_cache_history(*history, model=history_model) + + # --- Check 9: a same-session follow-up recalls a fact from the session's history --- + if budget.allotment - len(budget.used) < HISTORY_RECALL_TURNS: + yield budget_refused(budget, "history-recall turns") + return + code_word = history_code_word() + recall_session = f"t3-recall-{_suffix()}" + control_session = f"t3-rfresh-{_suffix()}" + recall: list[TurnResult] = [] + for label, session, prompt in ( + ("history-recall turn A", recall_session, history_fact_prompt(code_word)), + ("history-recall turn B", recall_session, HISTORY_RECALL_PROMPT), + ("history-recall control", control_session, HISTORY_RECALL_PROMPT), + ): + budget.spend(label) + recall.append(turn(ctx, token_a, session, prompt, history_tuning)) + yield evaluate_history_recall(*recall, code_word=code_word, model=history_model) + budget.spend("history-recall follow-up without resume_from") + repeat = turn( + ctx, + token_a, + recall_session, + HISTORY_REPEAT_PROMPT, + history_tuning, + omit_resume_from=True, + ) + yield evaluate_omitted_resume_recall( + recall[1], repeat, code_word=code_word, model=history_model + ) + turns_by_session = {recall_session: 3, control_session: 1} + try: + lines, poll_summary = _poll_history_logs( + log_lookup, ctx, logs_from_ms, turns_by_session, clock=now, sleeper=sleeper + ) + yield evaluate_history_logs( + lines, + turns_by_session, + module_sessions=[sid for sids in sessions_by_token.values() for sid in sids], + poll_summary=poll_summary, + ) + except Exception as exc: # noqa: BLE001 - surfaced as a failing check, never swallowed + yield CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_LOG_CHECK, + status="fail", + detail=f"could not read the Runtime log group: {exception_detail(exc)}", + ) + tenant_a = str(prov_a.tenant()) + try: + item = items_factory(ctx).get(history_key(tenant_a, recall_session)) + yield evaluate_history_item( + item, tenant=tenant_a, now=now(), ttl_seconds=DEFAULT_TTL_SECONDS + ) + except Exception as exc: # noqa: BLE001 - surfaced as a failing check, never swallowed + yield CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_ITEM_CHECK, + status="fail", + detail=f"could not read the session's history item: {exception_detail(exc)}", + ) finally: yield budget.result() + yield from _delete_module_history( + ctx, items_factory, provisioners, tokens, sessions_by_token + ) for prov in provisioners: yield from prov.cleanup() +def _delete_module_history( + ctx: SmokeContext, + items_factory: HistoryItemsFactory, + provisioners: Sequence[Any], + tokens: Mapping[int, str], + sessions_by_token: Mapping[str, Sequence[str]], +) -> Iterable[CheckResult]: + """Delete each provisioned user's history items for every session its token was sent with.""" + keys: list[str] = [] + for prov in provisioners: + token = tokens.get(id(prov)) + sessions = sessions_by_token.get(token, ()) if token is not None else () + tenant = str(prov.tenant()) if sessions else "" + keys.extend(history_key(tenant, session) for session in sessions if tenant) + if not keys: + return + try: + items = items_factory(ctx) + except Exception as exc: # noqa: BLE001 - surfaced as a failing check, never swallowed + yield CheckResult( + resource=RESOURCE_CLASS, + check=HISTORY_ITEMS_DELETED_CHECK, + status="fail", + detail=f"could not address the history items: {exception_detail(exc)}", + ) + return + yield delete_history_items(items, keys) + + +def expected_check_count(_ctx: SmokeContext) -> ExpectedCheckCount: + """The rows a run that issues every turn emits whatever each turn's outcome.""" + cost_rows = { + label: 4 + len(expected_tier_models(families)) + len(expected_tier_efforts(families)) + for label, families in (("mixed-family", MIXED_FAMILIES), ("openai", OPENAI_FAMILIES)) + } + single_rows = { + "check 1 collision or attribution control": 1, + "stale-tuning refusal": 1, + "owner session reuse control": 1, + "cache read per family": 2, + "page-context route refusals": len(refused_routes("m")), + "latest-message caching": 1, + "history recall, omitted-resume recall, logs and history item": 4, + "model-backed turn count": 1, + "history items deleted": 1, + } + return ExpectedCheckCount( + minimum=sum(cost_rows.values()) + sum(single_rows.values()), + basis=( + f"turn-cost rows {cost_rows} (4 plus one per tier model and tier effort from " + f"config/models.yaml) and one-row checks {single_rows}; provisioner cleanup rows are " + "not counted" + ), + ) + + def _poll_cloudtrail( lookup: CloudTrailLookup, ctx: SmokeContext, @@ -1156,13 +1870,14 @@ def _suffix() -> str: def main(argv: Sequence[str] | None = None) -> int: - """Entry point. Live path provisions users and drives checks 1-7.""" + """Entry point. Live path provisions users and drives checks 1-9.""" return run_main( argv, layer=LAYER, resource_class=RESOURCE_CLASS, description=__doc__ or RESOURCE_CLASS, checks=checks, + expected=expected_check_count, ) diff --git a/scripts/smoke/user_settings_api.py b/scripts/smoke/user_settings_api.py index 96c805e..0bf3bf7 100644 --- a/scripts/smoke/user_settings_api.py +++ b/scripts/smoke/user_settings_api.py @@ -62,6 +62,7 @@ CheckResult, ExpectedCheckCount, SmokeContext, + exception_detail, open_https, run_main, ) @@ -559,7 +560,7 @@ def _delete_settings_item(store: Any, *, tenant: str, rep_id: str, who: str) -> store.delete_item(SETTINGS_TABLE, {"rep_id": key}) remaining = store.get_item(SETTINGS_TABLE, {"rep_id": key}) except Exception as exc: # noqa: BLE001 - surfaced as a failing check - return _row(check, False, "", f"{type(exc).__name__}: {exc}") + return _row(check, False, "", exception_detail(exc)) return _row( check, remaining is None, @@ -572,7 +573,7 @@ def _teardown(store: Any, smoke_tenant: SmokeTenant) -> CheckResult: try: deleted = teardown_smoke_tenant(store, smoke_tenant) except Exception as exc: # noqa: BLE001 - a failed teardown must never read as clean - return _row("tenant_torn_down", False, "", f"{type(exc).__name__}: {exc}") + return _row("tenant_torn_down", False, "", exception_detail(exc)) return _row("tenant_torn_down", True, f"{sum(deleted.values())} item(s) deleted", "") @@ -611,7 +612,7 @@ def checks( try: yield from simulate(ctx) except Exception as exc: # noqa: BLE001 - the API rows still run - yield _row("role_simulations", False, "", f"{type(exc).__name__}: {exc}") + yield _row("role_simulations", False, "", exception_detail(exc)) smoke_tenant = allocate_smoke_tenant(resolved_store) provisioners: list[Provisioner] = [] diff --git a/scripts/smoke_agent_stream.py b/scripts/smoke_agent_stream.py index 7db651b..ea7198e 100644 --- a/scripts/smoke_agent_stream.py +++ b/scripts/smoke_agent_stream.py @@ -767,7 +767,7 @@ def _event_kind(event: SseEvent) -> str: """Return the `kind` field of one SSE record's JSON payload, or `""` if it has none.""" try: decoded = json.loads(event.data) - except (ValueError, TypeError): + except ValueError, TypeError: return "" return str(decoded.get("kind", "")) if isinstance(decoded, dict) else "" @@ -862,7 +862,7 @@ def _dispatched_tool_name(measurement: ArrivalMeasurement) -> str: continue try: decoded = json.loads(event.data) - except (ValueError, TypeError): + except ValueError, TypeError: return "" if isinstance(decoded, dict): return str(decoded.get("tool_name") or "") @@ -1059,7 +1059,7 @@ def _event_payloads(events: Sequence[SseEvent]) -> list[dict[str, Any]]: for event in events: try: decoded = json.loads(event.data) - except (TypeError, ValueError): + except TypeError, ValueError: continue if isinstance(decoded, dict): payloads.append(decoded) diff --git a/scripts/smoke_text_delta_stream.py b/scripts/smoke_text_delta_stream.py index 183286b..e44f508 100644 --- a/scripts/smoke_text_delta_stream.py +++ b/scripts/smoke_text_delta_stream.py @@ -53,7 +53,7 @@ def _event_kind(event: SseEvent) -> str: """The `kind` field of one SSE record's JSON payload, or `""` if it has none.""" try: return str(json.loads(event.data).get("kind") or "") - except (json.JSONDecodeError, AttributeError): + except json.JSONDecodeError, AttributeError: return "" diff --git a/scripts/teardown.sh b/scripts/teardown.sh index baa3754..2c0d281 100755 --- a/scripts/teardown.sh +++ b/scripts/teardown.sh @@ -83,6 +83,8 @@ export AWS_DEFAULT_REGION="$RESOLVED_REGION" command -v aws >/dev/null 2>&1 || die "aws CLI not found on PATH" command -v terraform >/dev/null 2>&1 || die "terraform not found on PATH" command -v python3 >/dev/null 2>&1 || die "python3 not found on PATH" +REPO_PYTHON="$("${SCRIPT_DIR}/repo_python.sh" --print)" \ + || die "no interpreter for the repository's Python scripts (see above); nothing was destroyed." info "Resolved profile=${RESOLVED_PROFILE} region=${RESOLVED_REGION}" @@ -105,7 +107,7 @@ restore_template() { RESTORED=true if [[ -f "$BACKUP_PATH" ]]; then info "Restoring account-agnostic AgentCore config template" - python3 "$RENDER_SCRIPT" restore --template "$TEMPLATE_PATH" --backup "$BACKUP_PATH" \ + "$REPO_PYTHON" "$RENDER_SCRIPT" restore --template "$TEMPLATE_PATH" --backup "$BACKUP_PATH" \ || warn "Restore of ${TEMPLATE_PATH} from ${BACKUP_PATH} failed — manual restore required" fi } @@ -117,12 +119,12 @@ if [[ ! -f "$TEMPLATE_PATH" ]]; then warn "AgentCore config template not found at ${TEMPLATE_PATH} — skipping render step" else if [[ -f "$BACKUP_PATH" ]]; then - die "A pre-render backup already exists at ${BACKUP_PATH}: a previous run did not restore ${TEMPLATE_PATH}, so it may still hold rendered account-specific values. Restore it first (python3 ${RENDER_SCRIPT} restore --template ${TEMPLATE_PATH} --backup ${BACKUP_PATH}), then re-run." + die "A pre-render backup already exists at ${BACKUP_PATH}: a previous run did not restore ${TEMPLATE_PATH}, so it may still hold rendered account-specific values. Restore it first (${REPO_PYTHON} ${RENDER_SCRIPT} restore --template ${TEMPLATE_PATH} --backup ${BACKUP_PATH}), then re-run." fi info "Rendering account-specific AgentCore config (destroy needs the same values apply used)" VALUES_JSON="$(python3 -c "import json,sys; print(json.dumps({'ACCOUNT_ID': sys.argv[1], 'AWS_REGION': sys.argv[2], 'AWS_PROFILE': sys.argv[3]}))" \ "$ACCOUNT_ID" "$RESOLVED_REGION" "$RESOLVED_PROFILE")" - python3 "$RENDER_SCRIPT" render \ + "$REPO_PYTHON" "$RENDER_SCRIPT" render \ --template "$TEMPLATE_PATH" \ --backup "$BACKUP_PATH" \ --values-json "$VALUES_JSON" \ diff --git a/scripts/verify_deployment.sh b/scripts/verify_deployment.sh index 435db66..fda6c9d 100755 --- a/scripts/verify_deployment.sh +++ b/scripts/verify_deployment.sh @@ -195,6 +195,7 @@ LAYER_4_MODULES=( "scripts.smoke.access_log_delivery" "scripts.smoke.relay_iam" "scripts.smoke.runtime_bedrock_iam" + "scripts.smoke.runtime_history_iam" "scripts.smoke.runtime_inbound_auth" "scripts.smoke.runtime_network_posture" "scripts.smoke.chat_timeouts" @@ -505,6 +506,17 @@ teardown_smoke_tenant(store, SmokeTenant(run_id=run_id, tenant=tenant)) return 1 } +# Replays the per-run module stderr log to this script's stderr, then removes the log. +# shellcheck disable=SC2329 # invoked from on_exit. +finish_stderr_log() { + [[ -n "${STDERR_LOG:-}" && -f "${STDERR_LOG}" ]] || return 0 + if [[ -s "${STDERR_LOG}" ]]; then + echo "${SCRIPT_NAME}: module stderr from this run follows; ${STDERR_LOG} is removed after it." >&2 + cat "${STDERR_LOG}" >&2 + fi + rm -f "${STDERR_LOG}" +} + # Teardown runs on normal exit, on a failing layer, and on interrupt/termination. # shellcheck disable=SC2329 # invoked indirectly, via `trap on_exit EXIT INT TERM` below. on_exit() { @@ -518,6 +530,7 @@ on_exit() { # The user is removed first; each step sets TEARDOWN_EXIT_CODE on failure. teardown_smoke_user || true teardown_tenant || true + finish_stderr_log || true # A teardown failure becomes the exit code only when nothing else failed. if [[ "${LAYER_EXIT_CODE}" -ne 0 ]]; then exit "${LAYER_EXIT_CODE}" @@ -593,7 +606,7 @@ run_module() { if [[ -z "${json_output}" ]]; then # No parseable stdout is recorded as a failed resource class. local resource_class="${module_args[0]##*.}" - json_output="$(printf '{"layer": %s, "resource_class": "%s", "checks": [{"resource": "%s", "check": "invocation", "status": "fail", "detail": "no parseable output; see %s"}]}' \ + json_output="$(printf '{"layer": %s, "resource_class": "%s", "checks": [{"resource": "%s", "check": "invocation", "status": "fail", "detail": "no parseable output; its stderr is replayed at the end of this run (log %s, removed at exit)"}]}' \ "${layer_number}" "${resource_class}" "${resource_class}" "${STDERR_LOG}")" rc=1 else diff --git a/scripts/verify_fixtures.sh b/scripts/verify_fixtures.sh index d1166e4..e84779e 100755 --- a/scripts/verify_fixtures.sh +++ b/scripts/verify_fixtures.sh @@ -12,7 +12,7 @@ SCRATCH_DIR="$(mktemp -d)" trap 'rm -rf "${SCRATCH_DIR}"' EXIT cd "${REPO_ROOT}" -python3 -m fixtures.generate --tenant demo --out "${SCRATCH_DIR}" +"${REPO_ROOT}/scripts/repo_python.sh" -m fixtures.generate --tenant demo --out "${SCRATCH_DIR}" STATUS=0 for generated_file in "${SCRATCH_DIR}"/*.json; do diff --git a/scripts/verify_terraform_plan_with_kms_absent.sh b/scripts/verify_terraform_plan_with_kms_absent.sh index 42abb00..dbde3aa 100644 --- a/scripts/verify_terraform_plan_with_kms_absent.sh +++ b/scripts/verify_terraform_plan_with_kms_absent.sh @@ -75,7 +75,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "6.71.0" + version = "6.72.0" } } } diff --git a/src/agents/budget.py b/src/agents/budget.py index 6138052..55968b0 100644 --- a/src/agents/budget.py +++ b/src/agents/budget.py @@ -27,9 +27,10 @@ import time from collections.abc import AsyncIterator, Awaitable, Callable from dataclasses import dataclass, field -from typing import Final +from typing import Final, cast, get_args from agents.events import AgentEvent, budget_exhausted_event +from providers.capabilities import Tier #: Maximum tool calls permitted in one chat turn. CHAT_MAX_TOOL_CALLS: Final[int] = 100 @@ -147,6 +148,8 @@ class TurnBudget: are a lower bound whenever this is non-zero. refused_request: The request :meth:`refuse_request` refused, or ``None``; once set, the budget is exhausted on the ``request_prompt_limit`` dimension. + exhausted_tier: The tier at which the budget was first found exhausted, recorded via + :meth:`note_exhausted_at`, or ``None`` while no detection site has recorded one. started_at: The ``clock`` reading at construction, against which the deadline is measured. """ @@ -159,6 +162,7 @@ class TurnBudget: completed_actions: list[str] = field(default_factory=list) calls_without_usage: int = 0 refused_request: RequestRefusal | None = None + exhausted_tier: Tier | None = None started_at: float = field(init=False) def __post_init__(self) -> None: @@ -193,6 +197,36 @@ def record_tool_call(self, description: str) -> None: self.tool_calls_made += 1 self.completed_actions.append(description) + def charge_tool_call(self, description: str, *, tier: str, role: str) -> None: + """Charge one tool call before it is dispatched, or refuse it at the tool-call cap. + + Under the cap this is :meth:`record_tool_call`. At the cap the call is not charged, + ``tier`` is recorded via :meth:`note_exhausted_at`, the refusal is logged, and + :class:`RequestRefusedError` is raised so the caller does not dispatch it. + + Args: + description: What the call does, as for :meth:`record_tool_call`. + tier: The tier dispatching the call (``supervisor``, ``subagent`` or ``tool``). + role: The agent role it runs for. + + Raises: + RequestRefusedError: If :attr:`tool_calls_made` has reached :attr:`max_tool_calls`. + """ + if self.tool_calls_made >= self.max_tool_calls: + self.note_exhausted_at(_as_tier(tier)) + _logger.warning( + json.dumps( + { + "event": "tool_call_refused", + "reason": f"tier={tier} role={role} max_tool_calls={self.max_tool_calls}", + } + ) + ) + raise RequestRefusedError( + f"tool call refused: {self.max_tool_calls} tool call(s) already made" + ) + self.record_tool_call(description) + def record_tokens(self, count: int) -> None: """Record tokens consumed by one model invocation within this turn. @@ -210,15 +244,24 @@ def elapsed_seconds(self) -> float: """Return wall-clock seconds since this turn started.""" return self.clock() - self.started_at + def note_exhausted_at(self, tier: Tier) -> None: + """Record ``tier`` as where the budget ran out, unless an earlier site already did.""" + if self.exhausted_tier is None: + self.exhausted_tier = tier + def note_call_without_usage(self, *, tier: str, role: str, cause: str) -> None: """Record one model call whose token usage will never be reported, and log it. + A ``deadline`` cause also records ``tier`` via :meth:`note_exhausted_at`. + Args: tier: The call's tier (``supervisor``, ``subagent`` or ``tool``). role: The agent role it ran for. cause: Why it ended unmetered, for example ``deadline`` or ``turn_stopped``. """ self.calls_without_usage += 1 + if cause == "deadline": + self.note_exhausted_at(_as_tier(tier)) _logger.warning( json.dumps( { @@ -233,8 +276,10 @@ def refuse_request( ) -> None: """Record one model request refused for an estimated prompt above ``limit``, and log it. - The budget is exhausted from then on; the first refusal is the one reported. + The budget is exhausted from then on; the first refusal is the one reported, and + ``tier`` is recorded via :meth:`note_exhausted_at`. """ + self.note_exhausted_at(_as_tier(tier)) if self.refused_request is None: self.refused_request = RequestRefusal( estimated_prompt_tokens=estimated_prompt_tokens, limit=limit, tier=tier, role=role @@ -344,6 +389,15 @@ def exhausted_event(self) -> AgentEvent: ) +_TIERS: Final[frozenset[str]] = frozenset(get_args(Tier)) + + +def _as_tier(tier: str) -> Tier: + if tier not in _TIERS: + raise ValueError(f"tier must be one of {sorted(_TIERS)}, got {tier!r}") + return cast(Tier, tier) + + class DeadlineReachedError(Exception): """Raised by :func:`within_deadline` when the turn's wall clock runs out during the wait.""" @@ -422,7 +476,7 @@ async def until_deadline[T]( in_flight=started, metered=metered, ) - except (StopAsyncIteration, DeadlineReachedError): + except StopAsyncIteration, DeadlineReachedError: return started = True metered = metered or (is_metered is not None and is_metered(item)) diff --git a/src/agents/conversation_history.py b/src/agents/conversation_history.py index 21d4a9e..bcda81c 100644 --- a/src/agents/conversation_history.py +++ b/src/agents/conversation_history.py @@ -6,18 +6,31 @@ write time and refuses a read or write by any other principal with a generic :class:`crm.errors.ScopeDenied`; an unknown session reads empty. The oldest turns beyond ``max_turns`` are dropped, and each field is redacted with :func:`crm.metering.redact` token-wise -and then capped at ``max_field_chars``. Process-local and lost on restart. +and then capped at ``max_field_chars``. + +:class:`InMemoryConversationHistory` is process-local and lost on restart. +:class:`DynamoDbConversationHistory` keeps one ``reps`` item per ``(tenant, session_id)`` through +:class:`crm.store.store.Store`, expiring ``ttl_seconds`` after its last write, and serialises +concurrent writers with an optimistic version check. """ from __future__ import annotations +import random import re +import time +from collections.abc import Callable, Mapping from dataclasses import dataclass, field -from typing import Final, Protocol +from datetime import UTC, datetime +from typing import TYPE_CHECKING, Final, Protocol from crm.authz import Identity -from crm.errors import ScopeDenied, ValidationFailed +from crm.errors import Conflict, CrmError, ScopeDenied, ValidationFailed from crm.metering import redact +from crm.store.keys import history_key + +if TYPE_CHECKING: + from crm.store.store import Store #: Scope name reported on a refused history read/write; it embeds no session id. HISTORY_SCOPE: Final[str] = "session:history:own" @@ -37,6 +50,38 @@ #: Matches each run of non-whitespace; redaction is applied per token and whitespace is preserved. _NON_WHITESPACE: Final[re.Pattern[str]] = re.compile(r"\S+") +#: Default lifetime of a durable history item after its last write. +DEFAULT_TTL_SECONDS: Final[int] = 86_400 + +#: Logical table holding durable history items. +HISTORY_TABLE: Final[str] = "reps" + +#: The ``kind`` attribute value of a durable history item. +HISTORY_KIND: Final[str] = "history" + +#: Read-modify-write attempts :meth:`DynamoDbConversationHistory.record_turn` makes before +#: raising :class:`HistoryWriteConflict`. +MAX_WRITE_ATTEMPTS: Final[int] = 3 + +#: Bounds, in seconds, of the jittered pause before each retried history write. +RETRY_BACKOFF_SECONDS: Final[tuple[float, float]] = (0.02, 0.08) + +_PARTITION_KEY: Final[str] = "rep_id" + +#: Every attribute a durable history item carries; no other attribute is ever written. +HISTORY_ITEM_ATTRIBUTES: Final[frozenset[str]] = frozenset( + { + _PARTITION_KEY, + "kind", + "owner_rep_id", + "owner_tenant", + "turns", + "version", + "updated_at", + "expires_at", + } +) + @dataclass(frozen=True, slots=True) class _Owner: @@ -83,11 +128,15 @@ def history_for(self, session_id: str, *, identity: Identity) -> tuple[HistoryTu """Return the prior turns for ``session_id`` visible to ``identity`` (oldest first).""" raise NotImplementedError - def clear(self, session_id: str) -> None: - """Forget ``session_id``'s history entirely.""" + def clear(self, session_id: str, *, identity: Identity) -> None: + """Forget ``session_id``'s history on behalf of its owner ``identity``.""" raise NotImplementedError +class HistoryWriteConflict(Conflict): + """Concurrent writers kept winning the race for one session's history item.""" + + @dataclass(slots=True) class InMemoryConversationHistory: """A process-local :class:`ConversationHistoryStore` that owns its identity+tenant scope. @@ -104,10 +153,7 @@ class InMemoryConversationHistory: _sessions: dict[str, _SessionHistory] = field(default_factory=dict) def __post_init__(self) -> None: - if self.max_turns < 1: - raise ValueError(f"max_turns must be positive, got {self.max_turns}") - if self.max_field_chars < 1: - raise ValueError(f"max_field_chars must be positive, got {self.max_field_chars}") + _validate_bounds(self.max_turns, self.max_field_chars) def record_turn(self, session_id: str, *, identity: Identity, prompt: str, answer: str) -> None: """Record a redacted, bounded ``(prompt, answer)`` for ``session_id``. @@ -129,7 +175,10 @@ def record_turn(self, session_id: str, *, identity: Identity, prompt: str, answe raise _denied("write to a session the caller does not own") session = existing if existing is not None else _SessionHistory(owner=owner) session.turns.append( - HistoryTurn(prompt=self._sanitise(prompt), answer=self._sanitise(answer)) + HistoryTurn( + prompt=_sanitise(prompt, self.max_field_chars), + answer=_sanitise(answer, self.max_field_chars), + ) ) while len(session.turns) > self.max_turns: session.turns.pop(0) @@ -154,16 +203,199 @@ def history_for(self, session_id: str, *, identity: Identity) -> tuple[HistoryTu raise _denied("read of a session the caller does not own") return tuple(session.turns) - def clear(self, session_id: str) -> None: - """Forget ``session_id``'s history. A no-op when it is not present.""" + def clear(self, session_id: str, *, identity: Identity) -> None: + """Forget ``session_id``'s history. A no-op when it is not present. + + Raises: + crm.errors.ScopeDenied: ``session_id`` belongs to a different principal. + """ + session = self._sessions.get(session_id) + if session is not None and session.owner != _Owner.of(identity): + raise _denied("clear of a session the caller does not own") self._sessions.pop(session_id, None) - def _sanitise(self, text: str) -> str: - """Redact secret-shaped tokens, then cap length.""" - redacted = _NON_WHITESPACE.sub(lambda match: str(redact(match.group())), text) - if len(redacted) > self.max_field_chars: - return redacted[: self.max_field_chars] + TRUNCATION_SUFFIX - return redacted + +def _utc_now() -> datetime: + return datetime.now(UTC) + + +class DynamoDbConversationHistory: + """A durable :class:`ConversationHistoryStore` on the ``reps`` table, one item per session. + + The item key embeds the caller's tenant, so another tenant's session reads empty. An item past + its ``expires_at`` reads empty, whether or not a TTL has deleted it yet. Every read is strongly + consistent. Item attributes are exactly :data:`HISTORY_ITEM_ATTRIBUTES`; there is no + ``tenant``, so no index lists the item. + + Args: + store: The store every read and write goes through. + max_turns: Prior turns kept per session before dropping the oldest. Must be positive. + max_field_chars: Per-field character cap applied after redaction. Must be positive. + ttl_seconds: Item lifetime after its last write, in seconds. Must be positive. + clock: Returns the current time as a timezone-aware datetime. + sleep: Pauses between retried writes, taking seconds. + """ + + def __init__( + self, + store: Store, + *, + max_turns: int = DEFAULT_MAX_TURNS, + max_field_chars: int = DEFAULT_MAX_FIELD_CHARS, + ttl_seconds: int = DEFAULT_TTL_SECONDS, + clock: Callable[[], datetime] = _utc_now, + sleep: Callable[[float], None] = time.sleep, + ) -> None: + _validate_bounds(max_turns, max_field_chars) + if ttl_seconds < 1: + raise ValueError(f"ttl_seconds must be positive, got {ttl_seconds}") + self._store = store + self.max_turns = max_turns + self.max_field_chars = max_field_chars + self.ttl_seconds = ttl_seconds + self._clock = clock + self._sleep = sleep + + def record_turn(self, session_id: str, *, identity: Identity, prompt: str, answer: str) -> None: + """Append a redacted, bounded ``(prompt, answer)`` to ``session_id``'s item. + + Raises: + crm.errors.ValidationFailed: ``session_id`` is blank. + crm.errors.ScopeDenied: ``session_id`` already belongs to a different principal. + HistoryWriteConflict: Every one of :data:`MAX_WRITE_ATTEMPTS` writes lost a race. + crm.errors.CrmError: The store failed, or the stored item is malformed. + """ + key = self._key(session_id, identity) + owner = _Owner.of(identity) + new_turn = { + "prompt": _sanitise(prompt, self.max_field_chars), + "answer": _sanitise(answer, self.max_field_chars), + } + for attempt in range(MAX_WRITE_ATTEMPTS): + if attempt: + self._sleep(random.uniform(*RETRY_BACKOFF_SECONDS)) # noqa: S311 + now = self._clock() + item = self._store.get_item(HISTORY_TABLE, {_PARTITION_KEY: key}, consistent=True) + expected_version = None if item is None else _version_of(item) + prior: list[dict[str, str]] = [] + if item is not None and not _expired(item, now): + if _owner_of(item) != owner: + raise _denied("write to a session the caller does not own") + prior = [{"prompt": turn.prompt, "answer": turn.answer} for turn in _turns_of(item)] + turns = [*prior, new_turn][-self.max_turns :] + written = self._store.put_conditional( + HISTORY_TABLE, + { + _PARTITION_KEY: key, + "kind": HISTORY_KIND, + "owner_rep_id": owner.rep_id, + "owner_tenant": owner.tenant, + "turns": turns, + "version": 1 if expected_version is None else expected_version + 1, + "updated_at": now.isoformat(), + "expires_at": int(now.timestamp()) + self.ttl_seconds, + }, + expected_version=expected_version, + ) + if written: + return + raise HistoryWriteConflict( + "This conversation was updated concurrently; the turn was not added to its history.", + detail=f"history write lost {MAX_WRITE_ATTEMPTS} optimistic-version races", + ) + + def history_for(self, session_id: str, *, identity: Identity) -> tuple[HistoryTurn, ...]: + """Return ``session_id``'s prior turns visible to ``identity`` (oldest first). + + A missing or expired item returns an empty tuple. + + Raises: + crm.errors.ValidationFailed: ``session_id`` is blank. + crm.errors.ScopeDenied: The item belongs to a different principal. + crm.errors.CrmError: The store failed, or the stored item is malformed. + """ + key = self._key(session_id, identity) + item = self._store.get_item(HISTORY_TABLE, {_PARTITION_KEY: key}, consistent=True) + if item is None or _expired(item, self._clock()): + return () + if _owner_of(item) != _Owner.of(identity): + raise _denied("read of a session the caller does not own") + return _turns_of(item) + + def clear(self, session_id: str, *, identity: Identity) -> None: + """Delete ``session_id``'s item. A no-op when it is missing or expired. + + Raises: + crm.errors.ValidationFailed: ``session_id`` is blank. + crm.errors.ScopeDenied: The item belongs to a different principal. + crm.errors.CrmError: The store failed, or the stored item is malformed. + """ + key = self._key(session_id, identity) + item = self._store.get_item(HISTORY_TABLE, {_PARTITION_KEY: key}, consistent=True) + if item is None or _expired(item, self._clock()): + return + if _owner_of(item) != _Owner.of(identity): + raise _denied("clear of a session the caller does not own") + self._store.delete_item(HISTORY_TABLE, {_PARTITION_KEY: key}) + + @staticmethod + def _key(session_id: str, identity: Identity) -> str: + return history_key(identity.tenant, _require_session_id(session_id)) + + +def _validate_bounds(max_turns: int, max_field_chars: int) -> None: + if max_turns < 1: + raise ValueError(f"max_turns must be positive, got {max_turns}") + if max_field_chars < 1: + raise ValueError(f"max_field_chars must be positive, got {max_field_chars}") + + +def _sanitise(text: str, max_field_chars: int) -> str: + """Redact secret-shaped tokens, then cap length.""" + redacted = _NON_WHITESPACE.sub(lambda match: str(redact(match.group())), text) + if len(redacted) > max_field_chars: + return redacted[:max_field_chars] + TRUNCATION_SUFFIX + return redacted + + +def _malformed(detail: str) -> CrmError: + return CrmError("Conversation history could not be read.", detail=f"history item: {detail}") + + +def _owner_of(item: Mapping[str, object]) -> _Owner: + rep_id, tenant = item.get("owner_rep_id"), item.get("owner_tenant") + if not isinstance(rep_id, str) or not isinstance(tenant, str): + raise _malformed("owner attributes are not strings") + return _Owner(rep_id=rep_id, tenant=tenant) + + +def _version_of(item: Mapping[str, object]) -> int: + version = item.get("version") + if isinstance(version, bool) or not isinstance(version, int): + raise _malformed("version is not an integer") + return version + + +def _expired(item: Mapping[str, object], now: datetime) -> bool: + expires_at = item.get("expires_at") + if isinstance(expires_at, bool) or not isinstance(expires_at, int): + raise _malformed("expires_at is not an integer") + return expires_at <= now.timestamp() + + +def _turns_of(item: Mapping[str, object]) -> tuple[HistoryTurn, ...]: + raw = item.get("turns") + if not isinstance(raw, list): + raise _malformed("turns is not a list") + turns: list[HistoryTurn] = [] + for entry in raw: + if not isinstance(entry, Mapping): + raise _malformed("a turn is not a map") + prompt, answer = entry.get("prompt"), entry.get("answer") + if not isinstance(prompt, str) or not isinstance(answer, str): + raise _malformed("a turn's prompt or answer is not a string") + turns.append(HistoryTurn(prompt=prompt, answer=answer)) + return tuple(turns) def _denied(detail: str) -> ScopeDenied: @@ -179,7 +411,7 @@ def _require_session_id(session_id: str) -> str: """ if not session_id.strip(): raise ValidationFailed( - "A conversation id is required to read history.", + "A conversation id is required for conversation history.", source="agent.history.session_id", detail="history requested with an empty session_id", ) @@ -189,9 +421,17 @@ def _require_session_id(session_id: str) -> str: __all__ = [ "DEFAULT_MAX_FIELD_CHARS", "DEFAULT_MAX_TURNS", + "DEFAULT_TTL_SECONDS", + "HISTORY_ITEM_ATTRIBUTES", + "HISTORY_KIND", "HISTORY_SCOPE", + "HISTORY_TABLE", + "MAX_WRITE_ATTEMPTS", + "RETRY_BACKOFF_SECONDS", "ConversationHistoryStore", + "DynamoDbConversationHistory", "HistoryTurn", + "HistoryWriteConflict", "InMemoryConversationHistory", "TRUNCATION_SUFFIX", ] diff --git a/src/agents/events.py b/src/agents/events.py index dc9d767..d908822 100644 --- a/src/agents/events.py +++ b/src/agents/events.py @@ -11,12 +11,13 @@ An exhausted turn budget ends the stream with a terminal ``error`` event whose ``error_kind`` is ``"budget_exhausted"``. An oversized tool result is truncated at a record boundary and marked with -:data:`TRUNCATION_MARKER`. +:data:`TRUNCATION_MARKER`; :func:`bound_tool_output` is the one bound every dispatch path applies. """ from __future__ import annotations import math +from collections.abc import Mapping from dataclasses import dataclass from typing import Final, Literal, TypedDict, get_args @@ -53,6 +54,9 @@ #: The tool-result payload byte ceiling before truncation applies. TOOL_RESULT_BYTE_CEILING: Final[int] = 32_768 +#: The payload key a bounded tool result sets to ``True`` to report it was truncated. +TOOL_OUTPUT_TRUNCATED_KEY: Final[str] = "truncated" + class CostLine(TypedDict): """One priced ``(tier, role, model_id)`` group of a turn's model usage. @@ -335,6 +339,72 @@ def truncate_tool_output( return kept, truncated +def _repr_size(value: object) -> int: + """The UTF-8 length of ``value``'s ``repr``, the measure :func:`truncate_tool_output` uses.""" + return len(repr(value).encode("utf-8")) + + +def record_list_field(container: Mapping[str, object]) -> tuple[str, list[object]] | None: + """Return the list to trim at a record boundary: ``items`` if a list, else the largest list. + + The largest is the non-empty list value with the greatest ``repr`` size. Returns ``None`` when + ``container`` holds no such list. + """ + items = container.get("items") + if isinstance(items, list): + return "items", items + lists = [(key, value) for key, value in container.items() if isinstance(value, list) and value] + if not lists: + return None + return max(lists, key=lambda pair: _repr_size(pair[1])) + + +def bound_tool_output( + raw: Mapping[str, object], *, byte_ceiling: int = TOOL_RESULT_BYTE_CEILING +) -> tuple[dict[str, object], bool]: + """Bound one tool result to ``byte_ceiling`` bytes by trimming its record list. + + The container is ``raw["body"]`` when that is a dict, else ``raw``; its record list is chosen + by :func:`record_list_field`. When the container's ``repr`` exceeds ``byte_ceiling``, the list + is cut at a record boundary, :data:`TRUNCATION_MARKER` is appended to it and + :data:`TOOL_OUTPUT_TRUNCATED_KEY` is set to ``True`` in the container, so the bounded container + stays within ``byte_ceiling`` (when its other fields alone fit). Non-dict list entries are not + kept in a trimmed list. + + Returns: + ``(bounded, True)`` when trimmed; otherwise ``(raw, False)``, with ``raw`` itself returned + when it is a dict. A container over the ceiling with no list to trim is returned + unchanged with ``False``. + """ + unchanged = raw if isinstance(raw, dict) else dict(raw) + body = raw.get("body") + container: Mapping[str, object] = body if isinstance(body, dict) else raw + if _repr_size(container) <= byte_ceiling: + return unchanged, False + record_list = record_list_field(container) + if record_list is None: + return unchanged, False + field_name, records = record_list + marker: dict[str, object] = {TRUNCATION_MARKER: True} + + def _with(kept: list[dict[str, object]]) -> dict[str, object]: + return {**container, field_name: [*kept, marker], TOOL_OUTPUT_TRUNCATED_KEY: True} + + room = max(byte_ceiling - _repr_size(_with([])), 0) + kept, _ = truncate_tool_output( + [record for record in records if isinstance(record, dict)], byte_ceiling=room + ) + if kept and kept[-1] == marker: + kept.pop() + bounded = _with(kept) + while kept and _repr_size(bounded) > byte_ceiling: + kept.pop() + bounded = _with(kept) + if isinstance(body, dict): + return {**raw, "body": bounded}, True + return bounded, True + + def budget_exhausted_event(*, partial_work: str, error_message: str) -> AgentEvent: """Build the terminal event a turn emits when its budget is exhausted. @@ -356,6 +426,7 @@ def budget_exhausted_event(*, partial_work: str, error_message: str) -> AgentEve __all__ = [ "EVENT_KINDS", + "TOOL_OUTPUT_TRUNCATED_KEY", "TOOL_RESULT_BYTE_CEILING", "TRUNCATION_MARKER", "AgentEvent", @@ -363,6 +434,8 @@ def budget_exhausted_event(*, partial_work: str, error_message: str) -> AgentEve "ErrorKind", "EventKind", "ResolvedTierInfo", + "bound_tool_output", "budget_exhausted_event", + "record_list_field", "truncate_tool_output", ] diff --git a/src/agents/runtime_entrypoint.py b/src/agents/runtime_entrypoint.py index 0088baf..0d3e66c 100644 --- a/src/agents/runtime_entrypoint.py +++ b/src/agents/runtime_entrypoint.py @@ -387,29 +387,31 @@ def run_turn( *, store: SessionStore, resume_from: int = 0, + resume: bool = False, ) -> Iterator[str]: """Drive one turn's already-produced event stream into resumable SSE lines. A fresh turn first calls :meth:`SessionStore.begin_turn`, dropping the session's earlier turns, then records every event from ``events`` except a ``heartbeat`` in ``store`` before - rendering it; a heartbeat is rendered only. When - ``resume_from`` is below the session's last recorded sequence, only the recorded events after - it are yielded and ``events`` is not consumed. + rendering it; a heartbeat is rendered only. A reconnect, where ``resume`` is ``True`` and + ``resume_from`` is at least ``0`` and below the session's last recorded sequence, yields only + the recorded events after it and does not consume ``events``. Any other call is a fresh turn. Args: invocation: The decoded, tuning-validated invocation driving this turn. events: The turn's own event stream, e.g. from repeated calls to :func:`agents.supervisor.provider_event_to_agent_event` over a provider's stream. - Consumed only when ``resume_from`` is at or beyond the last recorded sequence. + Not consumed on a reconnect. store: Where events are recorded and replayed from. resume_from: The highest sequence number the caller already received for this session. - ``0`` means "from the start" — a fresh turn. + resume: Whether the caller is reconnecting to the session's last turn. Only the value + ``True`` counts; anything else is a fresh turn. Yields: One SSE data line per event, in :func:`format_sse_line`'s framing. """ last_recorded = store.last_sequence(invocation.session_id) - if resume_from < last_recorded: + if resume is True and 0 <= resume_from < last_recorded: for replayed in store.events_after(invocation.session_id, sequence=resume_from): yield format_sse_line(replayed) return diff --git a/src/agents/runtime_server.py b/src/agents/runtime_server.py index f6e21ef..789e219 100644 --- a/src/agents/runtime_server.py +++ b/src/agents/runtime_server.py @@ -15,11 +15,13 @@ from __future__ import annotations import asyncio +import functools import json import logging import os +import threading import time -from collections.abc import AsyncGenerator, Iterator, Mapping +from collections.abc import AsyncGenerator, Callable, Iterator, Mapping from typing import Any, Final from starlette.applications import Starlette @@ -36,7 +38,9 @@ ) from agents.conversation_history import ( ConversationHistoryStore, + DynamoDbConversationHistory, HistoryTurn, + HistoryWriteConflict, InMemoryConversationHistory, ) from agents.events import AgentEvent, ErrorKind @@ -82,7 +86,7 @@ ValidationFailed, ) from crm.handlers._common import ok -from crm.store.store import Store +from crm.store.store import Store, bounded_store from providers.base import ModelProvider from providers.capabilities import CapabilityMatrix, Family, load_capability_matrix from providers.sdk_loggers import quiet_sdk_loggers @@ -141,12 +145,47 @@ def _is_page_context_validation(exc: ValidationFailed) -> bool: #: Seconds a chat turn's stream may go without an event before a ``heartbeat`` event is emitted. HEARTBEAT_INTERVAL_SECONDS: Final[float] = 20.0 +#: Payload field marking a reconnect to the session's last turn; only the JSON value ``true`` +#: counts. +_RESUME_KEY: Final[str] = "resume" + +#: Seconds a turn waits for its history read, and for its history write before ``completed``, after +#: which it proceeds without them. +HISTORY_READ_DEADLINE_SECONDS: Final[float] = 5.0 +HISTORY_WRITE_DEADLINE_SECONDS: Final[float] = 8.0 + #: Process-local session event store, shared across requests. _session_store = InMemorySessionStore() #: Process-local cooperative cancellation markers, read between agent steps. _cancellation_store: CancellationStore = InMemoryCancellationStore() -#: Process-local per-session conversation history, scoped to ``(rep_id, tenant)``. -_history_store: ConversationHistoryStore = InMemoryConversationHistory() +#: Environment variable selecting the conversation-history backend, and its accepted values. +_HISTORY_STORE_ENV_VAR: Final[str] = "CONVERSATION_HISTORY_STORE" +_MEMORY_HISTORY_STORE: Final[str] = "memory" +_DYNAMODB_HISTORY_STORE: Final[str] = "dynamodb" + + +def build_history_store() -> ConversationHistoryStore: + """Return the conversation-history store ``CONVERSATION_HISTORY_STORE`` selects. + + ``dynamodb`` builds a :class:`agents.conversation_history.DynamoDbConversationHistory` over + :func:`crm.store.store.bounded_store` with ``CRM_TABLE_PREFIX``; unset, empty or ``memory`` builds a + process-local :class:`agents.conversation_history.InMemoryConversationHistory`. + + Raises: + RuntimeError: ``CONVERSATION_HISTORY_STORE`` names any other value. + """ + selected = os.environ.get(_HISTORY_STORE_ENV_VAR, "").strip().lower() or _MEMORY_HISTORY_STORE + if selected == _MEMORY_HISTORY_STORE: + return InMemoryConversationHistory() + if selected == _DYNAMODB_HISTORY_STORE: + return DynamoDbConversationHistory( + bounded_store(table_prefix=os.environ.get("CRM_TABLE_PREFIX", "")) + ) + raise RuntimeError(f"unrecognised {_HISTORY_STORE_ENV_VAR} value: {selected!r}") + + +#: Per-session conversation history, scoped to ``(rep_id, tenant)``; built once at import. +_history_store: ConversationHistoryStore = build_history_store() _matrix: CapabilityMatrix | None = None #: Provider selection state: one process-wide stub, and one cached live adapter per family. _stub_provider: ModelProvider | None = None @@ -309,6 +348,9 @@ def _history_messages(session_id: str, identity: Identity) -> list[dict[str, obj except ScopeDenied: logger.info(json.dumps({"event": "history_read_denied"})) return [] + except CrmError as exc: + logger.warning(json.dumps({"event": "history_read_failed", "reason": type(exc).__name__})) + return [] messages: list[dict[str, object]] = [] for turn in turns: messages.append({"role": "user", "content": turn.prompt}) @@ -319,7 +361,8 @@ def _history_messages(session_id: str, identity: Identity) -> list[dict[str, obj def _record_history(invocation: RuntimeInvocation, *, answer: str) -> None: """Record this turn's ``(prompt, answer)`` for the session, scoped to the caller's identity. - Nothing is recorded when the ``session_id`` belongs to a different principal. + Nothing is recorded when the ``session_id`` belongs to a different principal. A failed write is + logged with its error kind only and never raised, so the turn's answer is still delivered. """ try: _history_store.record_turn( @@ -330,6 +373,26 @@ def _record_history(invocation: RuntimeInvocation, *, answer: str) -> None: ) except ScopeDenied: logger.info(json.dumps({"event": "history_write_denied"})) + except HistoryWriteConflict: + logger.warning(json.dumps({"event": "history_write_conflict"})) + except CrmError as exc: + logger.warning(json.dumps({"event": "history_write_failed", "reason": type(exc).__name__})) + + +async def _bounded_history_call( + call: Callable[[], object], *, deadline: float, failed_event: str +) -> bool: + """Run ``call`` on a worker thread, waiting at most ``deadline`` seconds. + + Returns ``True`` when ``call`` finished in time. A timeout is logged as ``failed_event`` with + reason ``TimeoutError`` and returns ``False``; ``call`` may still finish in the background. + """ + try: + await asyncio.wait_for(asyncio.to_thread(call), timeout=deadline) + except TimeoutError: + logger.warning(json.dumps({"event": failed_event, "reason": "TimeoutError"})) + return False + return True async def _agent_events_for_turn( @@ -345,12 +408,20 @@ async def _agent_events_for_turn( Supplies the identity-bound :func:`agents.tool_dispatch.production_dispatch`, the decoded per-tier ``tuning``, the per-family ``providers`` resolver (a single :class:`ModelProvider` is used for every family), :data:`agents.budget.CHAT_BUDGET`, and the session's prior turns, then - re-yields the driver's events. On a terminal ``completed`` event the turn's - ``(prompt, answer)`` is recorded to history, unless the turn was cancelled. + re-yields the driver's events. The turn's ``(prompt, answer)`` is recorded to history before + its text-bearing ``completed`` event is yielded, unless the turn was cancelled. History calls + run on a worker thread, bounded by :data:`HISTORY_READ_DEADLINE_SECONDS` and + :data:`HISTORY_WRITE_DEADLINE_SECONDS`, so heartbeats keep flowing and a slow store delays + the answer by at most the deadline. """ records = TurnRecords() - history_messages = _history_messages(invocation.session_id, invocation.identity) - final_answer: str | None = None + read: list[list[dict[str, object]]] = [] + await _bounded_history_call( + lambda: read.append(_history_messages(invocation.session_id, invocation.identity)), + deadline=HISTORY_READ_DEADLINE_SECONDS, + failed_event="history_read_failed", + ) + history_messages = read[0] if read else [] async for event in drive_turn( prompt=invocation.prompt, session_id=invocation.session_id, @@ -365,13 +436,18 @@ async def _agent_events_for_turn( max_rounds=max_rounds, cancellation=cancellation, ): - if event.kind == "completed" and event.text is not None: - final_answer = None if is_cancellation_event(event) else event.text + if ( + event.kind == "completed" + and event.text is not None + and not is_cancellation_event(event) + ): + await _bounded_history_call( + functools.partial(_record_history, invocation, answer=event.text), + deadline=HISTORY_WRITE_DEADLINE_SECONDS, + failed_event="history_write_failed", + ) yield event - if final_answer is not None: - _record_history(invocation, answer=final_answer) - async def _next_event(agen: AsyncGenerator[AgentEvent]) -> AgentEvent | None: """Advance ``agen`` by one event, returning ``None`` once it is exhausted.""" @@ -413,11 +489,39 @@ def _sync_agent_events( return yield event finally: - if pending is not None and not pending.done(): - pending.cancel() - loop.run_until_complete(asyncio.gather(pending, return_exceptions=True)) - loop.run_until_complete(agen.aclose()) - loop.close() + _close_turn_loop(loop, agen, pending) + + +def _close_turn_loop( + loop: asyncio.AbstractEventLoop, + agen: AsyncGenerator[AgentEvent], + pending: asyncio.Task[AgentEvent | None] | None, +) -> None: + """Cancel ``pending``, close ``agen`` and every async generator still open on ``loop``, then + close ``loop``. + + When the calling thread is already running another event loop, the cleanup runs on a helper + thread, because ``loop`` cannot be driven from inside a running loop. + """ + + def close() -> None: + try: + if pending is not None and not pending.done(): + pending.cancel() + loop.run_until_complete(asyncio.gather(pending, return_exceptions=True)) + loop.run_until_complete(agen.aclose()) + loop.run_until_complete(loop.shutdown_asyncgens()) + finally: + loop.close() + + try: + asyncio.get_running_loop() + except RuntimeError: + close() + return + closer = threading.Thread(target=close, name="turn-loop-close") + closer.start() + closer.join() async def ping(_request: Request) -> Response: @@ -1096,12 +1200,15 @@ async def invocations(request: Request) -> Response: resume_from_raw = payload.get("resume_from", 0) resume_from = int(resume_from_raw) if isinstance(resume_from_raw, int | str) else 0 + resume = payload.get(_RESUME_KEY) is True events = _sync_agent_events(invocation, providers, matrix=matrix, cancellation=cancellation) def _sse_body() -> Iterator[bytes]: try: - for line in run_turn(invocation, events, store=_session_store, resume_from=resume_from): + for line in run_turn( + invocation, events, store=_session_store, resume_from=resume_from, resume=resume + ): yield line.encode("utf-8") except Exception: # Headers are already sent, so the failure is reported as a terminal `error` event. diff --git a/src/agents/subagent_runner.py b/src/agents/subagent_runner.py index 3335806..0b2b6ab 100644 --- a/src/agents/subagent_runner.py +++ b/src/agents/subagent_runner.py @@ -16,13 +16,14 @@ The subagent's first message is the system prompt ``config/agent_prompts/subagent.yaml`` rendered with the spec's ``role`` and ``purpose`` (:func:`subagent_system_message`); the intent follows as -the user message. A ``data`` outcome carries every successful leaf result in call order, -``{"results": [{"tool": name, "body": payload}, ...]}``, the list bounded once by -:func:`bound_results` and marked ``"truncated": true`` when cut. A +the user message. A ``data`` outcome carries every successful (bounded) leaf result in call +order, ``{"results": [{"tool": name, "body": payload}, ...]}``, the list bounded by +:func:`bound_results` and marked ``"truncated": true`` when it or any leaf result was cut. A ``tool_failure`` from a leaf tool is cleared when a later call to the same tool returns ``data`` or ``no_match``; a denial is never cleared. -Tool results pass through verbatim, bounded only by :func:`agents.events.truncate_tool_output`. +Each leaf result is bounded by :func:`agents.events.bound_tool_output`; the bounded copy is what the +model and the aggregate receive. The runner reads no wall clock of its own. Given the turn's :class:`~agents.budget.TurnBudget`, it checks the budget's wall clock between rounds and bounds every model wait by the time left (:func:`agents.budget.until_deadline`, :func:`agents.budget.within_deadline`). When the clock runs @@ -54,6 +55,8 @@ TOOL_RESULT_BYTE_CEILING, TRUNCATION_MARKER, AgentEvent, + bound_tool_output, + record_list_field, truncate_tool_output, ) from agents.prompt_estimate import refuse_if_over_limit @@ -269,6 +272,7 @@ class _SubagentDriver: tool_calls: list[ToolCallAttribution] = field(default_factory=list) _results: list[dict[str, object]] = field(default_factory=list) _matched_nothing: bool = False + _bounded_leaf_data: bool = False _denied: SubagentOutcome | None = None _open_failures: dict[str, str] = field(default_factory=dict) @@ -285,6 +289,7 @@ async def _consume(self, *, intent: str, max_rounds: int) -> None: if round_number > max_rounds: return if self.budget is not None and self.budget.is_deadline_expired(): + self.budget.note_exhausted_at(SUBAGENT_TIER) return total_input = total_output = total_cache_read = total_cache_write = 0 saw_usage = False @@ -430,10 +435,12 @@ async def _dispatch_leaf( ) -> dict[str, object]: """Realise one leaf tool call through the actor, classify it, and record events+attribution. - The actor may be sync or async (:data:`ToolActor`). Returns the actor's raw ``output`` - verbatim for the next round's tool result; the emitted ``tool_result`` event carries the - record-boundary-bounded copy. + The actor may be sync or async (:data:`ToolActor`). The actor's ``output`` is bounded by + :func:`agents.events.bound_tool_output`; the bounded copy is classified, carried by the + emitted ``tool_result`` event and returned for the next round's tool result. """ + if self.budget is not None: + self.budget.charge_tool_call(f"called {tool.name}", tier=TOOL_TIER, role=self.spec.role) call = self.tool_actor(tool, _call_intent(tool_input, fallback_intent)) if isinstance(call, Awaitable): result = await ( @@ -446,16 +453,18 @@ async def _dispatch_leaf( raw_output = result.output self.invocations.append(result.invocation) - display_output, truncated = _bounded_output(raw_output) - notice = describe_truncation(raw_output, event_truncated=truncated) - outcome = classify_tool_result(raw_output) + bounded_output, truncated = bound_tool_output(raw_output) + notice = describe_truncation(bounded_output, event_truncated=truncated) + outcome = classify_tool_result(bounded_output) self._record_outcome(tool.name, outcome) + if truncated and outcome.kind == "data": + self._bounded_leaf_data = True self.events.append( AgentEvent(kind="tool_call", tool_name=tool.name, tool_input=dict(tool_input)) ) self.events.append( - AgentEvent(kind="tool_result", tool_output=display_output, truncated=truncated) + AgentEvent(kind="tool_result", tool_output=bounded_output, truncated=truncated) ) if tool.name == _SUBMIT_PROPOSAL_TOOL_NAME and "error" not in raw_output: self.events.append(proposal_event_for(raw_output)) @@ -468,7 +477,7 @@ async def _dispatch_leaf( truncated=truncated or notice is not None, ) ) - return raw_output + return bounded_output def _record_outcome(self, tool_name: str, outcome: SubagentOutcome) -> None: """Fold one leaf outcome into the delegation's aggregate. @@ -517,7 +526,7 @@ def _aggregate_outcome(self) -> SubagentOutcome: if self._results: results, truncated = bound_results(self._results) data: dict[str, object] = {RESULTS_KEY: results} - if truncated: + if truncated or self._bounded_leaf_data: data["truncated"] = True return SubagentOutcome(kind="data", data=data) return SubagentOutcome(kind="no_match") @@ -528,17 +537,6 @@ def _repr_size(value: object) -> int: return len(repr(value).encode("utf-8")) -def _record_list_field(body: dict[str, object]) -> tuple[str, list[object]] | None: - """Return the ``body`` list to trim at a record boundary: ``items``, else its largest list.""" - items = body.get("items") - if isinstance(items, list): - return "items", items - lists = [(key, value) for key, value in body.items() if isinstance(value, list) and value] - if not lists: - return None - return max(lists, key=lambda pair: _repr_size(pair[1])) - - def _trim_entry(entry: dict[str, object], budget: int) -> dict[str, object] | None: """Return ``entry`` cut to ``budget`` bytes by trimming its body's record list. @@ -547,7 +545,7 @@ def _trim_entry(entry: dict[str, object], budget: int) -> dict[str, object] | No body = entry.get("body") if not isinstance(body, dict): return None - record_list = _record_list_field(body) + record_list = record_list_field(body) if record_list is None: return None field_name, records = record_list @@ -598,28 +596,6 @@ def bound_results( return kept, False -def _bounded_output(raw_output: dict[str, object]) -> tuple[dict[str, object], bool]: - """Apply the existing record-boundary byte ceiling to a result's ``items``, if any. - - Uses :func:`agents.events.truncate_tool_output`, as direct tool results do. A payload with no - ``items`` list passes through unchanged. - """ - body = raw_output.get("body") - container = body if isinstance(body, dict) else raw_output - items = container.get("items") - if not isinstance(items, list): - return raw_output, False - bounded_items, truncated = truncate_tool_output( - [item for item in items if isinstance(item, dict)] - ) - if not truncated: - return raw_output, False - bounded_container = {**container, "items": bounded_items} - if isinstance(body, dict): - return {**raw_output, "body": bounded_container}, True - return bounded_container, True - - __all__ = [ "DEFAULT_MAX_SUBAGENT_ROUNDS", "RESULTS_KEY", diff --git a/src/agents/supervisor.py b/src/agents/supervisor.py index b1a9211..0fed439 100644 --- a/src/agents/supervisor.py +++ b/src/agents/supervisor.py @@ -26,7 +26,7 @@ from agents.budget import TurnBudget from agents.cancellation import CancellationStore -from agents.events import AgentEvent, truncate_tool_output +from agents.events import TOOL_OUTPUT_TRUNCATED_KEY, AgentEvent, bound_tool_output from agents.registry import RegisteredTool, tool_registry_for from agents.subagents import ALL_SUBAGENT_SPECS, SUBAGENT_SPECS_BY_ROLE from agents.subagents.base import SubagentSpec @@ -59,7 +59,7 @@ #: Field a ``search_opportunities`` tool result carries alongside ``items`` when the search #: examination budget (:data:`crm.search.EXAMINATION_BUDGET`) was reached before either the #: underlying index was exhausted or the caller's ``limit`` was satisfied. -_SEARCH_TRUNCATED_KEY: Final[str] = "truncated" +_SEARCH_TRUNCATED_KEY: Final[str] = TOOL_OUTPUT_TRUNCATED_KEY _SEARCH_EXAMINED_COUNT_KEY: Final[str] = "examined_count" #: Error codes classified as ``"denied"``, each mapped to the scope named when the payload omits one. @@ -163,15 +163,15 @@ def classify_tool_result(tool_output: dict[str, object]) -> SubagentOutcome: def describe_truncation(tool_output: dict[str, object], *, event_truncated: bool) -> str | None: """Return a user-facing truncation notice, or ``None`` when nothing was truncated. - Two independent signals are checked: the byte-ceiling flag - :attr:`agents.events.AgentEvent.truncated`, and ``search_opportunities``'s own - ``truncated``/``examined_count`` fields from :data:`crm.search.EXAMINATION_BUDGET`. Either alone - produces a notice; the search signal takes precedence. + Two signals are checked: the search examination budget (``search_opportunities``'s + ``truncated`` with its ``examined_count``, from :data:`crm.search.EXAMINATION_BUDGET`), and the + byte ceiling (``event_truncated``, or a ``truncated`` flag without ``examined_count``, as + :func:`agents.events.bound_tool_output` writes). Either alone produces a notice; the search + signal takes precedence. Args: - tool_output: The raw tool result payload, possibly carrying ``truncated`` and - ``examined_count`` (the ``search_opportunities`` shape) at either its top level or - under a nested ``body``. + tool_output: The tool result payload, possibly carrying ``truncated`` and + ``examined_count`` at either its top level or under a nested ``body``. event_truncated: Whether the enclosing :class:`agents.events.AgentEvent` reported ``truncated=True`` — the byte-ceiling signal, independent of the search-specific one. @@ -181,15 +181,14 @@ def describe_truncation(tool_output: dict[str, object], *, event_truncated: bool body = tool_output.get("body", tool_output) payload = body if isinstance(body, dict) else tool_output - search_truncated = bool(payload.get(_SEARCH_TRUNCATED_KEY)) - if search_truncated: - examined = payload.get(_SEARCH_EXAMINED_COUNT_KEY) + flagged = bool(payload.get(_SEARCH_TRUNCATED_KEY)) + examined = payload.get(_SEARCH_EXAMINED_COUNT_KEY) + if flagged and examined is not None: return ( - "Search stopped early after examining " - f"{examined if examined is not None else 'a bounded number of'} records; " + f"Search stopped early after examining {examined} records; " "not every matching record may be included." ) - if event_truncated: + if event_truncated or flagged: return "The tool result was too large to include in full and was truncated." return None @@ -643,8 +642,8 @@ def provider_event_to_agent_event( With ``stream_event_id`` unset, a ``text_delta`` maps to ``None`` and the caller accumulates its text (see :class:`TextAccumulator`) for ``accumulated_text`` on ``completed``. With it set, a ``text_delta`` maps to a ``partial=True`` frame carrying that ``event_id``. Every other provider - event type maps onto its identically named agent event kind, with a large ``tool_result`` - payload truncated at a record boundary via :func:`agents.events.truncate_tool_output`. + event type maps onto its identically named agent event kind, with a ``tool_result`` payload + bounded by :func:`agents.events.bound_tool_output`. Args: event: One event from a provider's normalised stream. @@ -681,12 +680,7 @@ def provider_event_to_agent_event( if event.type == "tool_result": if event.tool_output is None: raise ValueError("tool_result provider event missing tool_output") - items = event.tool_output.get("items") - if isinstance(items, list): - kept, truncated = truncate_tool_output(items) - output = {**event.tool_output, "items": kept} - else: - output, truncated = event.tool_output, False + output, truncated = bound_tool_output(event.tool_output) return AgentEvent(kind="tool_result", tool_output=output, truncated=truncated) if event.type == "usage": if event.input_tokens is None or event.output_tokens is None: diff --git a/src/agents/turn_driver.py b/src/agents/turn_driver.py index 72ed896..8fac98c 100644 --- a/src/agents/turn_driver.py +++ b/src/agents/turn_driver.py @@ -37,7 +37,7 @@ from agents.answer_style import answer_style_system_message from agents.budget import RequestRefusedError, TurnBudget, TurnBudgetSpec, until_deadline from agents.cancellation import CancellationStore -from agents.events import AgentEvent, ResolvedTierInfo, budget_exhausted_event +from agents.events import AgentEvent, ResolvedTierInfo, bound_tool_output, budget_exhausted_event from agents.prompt_estimate import refuse_if_over_limit from agents.registry import RegisteredTool, tool_registry_for from agents.subagent_runner import SubagentRunResult, run_subagent_async @@ -50,6 +50,7 @@ SubagentOutcome, TurnGuard, classify_tool_result, + describe_truncation, page_context_briefing, proposal_event_for, provider_event_to_agent_event, @@ -103,6 +104,8 @@ class TurnRecords: calls_without_usage: Model calls of the turn that ended before reporting token usage (:attr:`agents.budget.TurnBudget.calls_without_usage`); when non-zero, ``invocations`` under-count the turn's usage and cost. + budget_exhausted_tier: The tier where the turn's budget ran out + (:attr:`agents.budget.TurnBudget.exhausted_tier`), or ``None``. """ invocations: list[InvocationAttribution] = field(default_factory=list) @@ -114,6 +117,18 @@ def calls_without_usage(self) -> int: """Model calls of the turn that ended before reporting token usage; 0 before it starts.""" return 0 if self._budget is None else self._budget.calls_without_usage + @property + def budget_exhausted_tier(self) -> Tier | None: + """The tier where the turn's budget ran out; ``None`` if it did not or before it starts.""" + return None if self._budget is None else self._budget.exhausted_tier + + +def _noting_supervisor_exhaustion(event: AgentEvent, budget: TurnBudget) -> AgentEvent: + """Return ``event``, first recording the supervisor tier when it reports budget exhaustion.""" + if event.error_kind == "budget_exhausted": + budget.note_exhausted_at(SUPERVISOR_TIER) + return event + def _direct_tool_schemas(tools: tuple[RegisteredTool, ...]) -> list[dict[str, object]]: """Render the supervisor's direct tools in the `{name, description, input_schema}` shape.""" @@ -328,7 +343,7 @@ async def drive_turn( pre_flight = guard.terminal_event() if pre_flight is not None: - yield pre_flight + yield _noting_supervisor_exhaustion(pre_flight, turn_budget) return effective_max_rounds = max_rounds if max_rounds is not None else budget.max_tool_calls + 1 @@ -343,12 +358,15 @@ async def drive_turn( if turn_budget.completed_actions else "no tool calls completed" ) - yield budget_exhausted_event( - partial_work=partial_work, - error_message=( - f"Turn stopped after reaching the maximum of {effective_max_rounds} model " - "round(s) without producing a final answer." + yield _noting_supervisor_exhaustion( + budget_exhausted_event( + partial_work=partial_work, + error_message=( + f"Turn stopped after reaching the maximum of {effective_max_rounds} model " + "round(s) without producing a final answer." + ), ), + turn_budget, ) return @@ -370,7 +388,7 @@ async def drive_turn( ) except RequestRefusedError: guard.note_terminal() - yield turn_budget.exhausted_event() + yield _noting_supervisor_exhaustion(turn_budget.exhausted_event(), turn_budget) return provider_events: AsyncIterator[ProviderEvent] = until_deadline( @@ -466,15 +484,13 @@ async def drive_turn( budget=turn_budget, dispatch_clock=dispatch_clock, ) - # The turn budget is charged with the delegation's tokens and leaf calls. + # Leaf calls were charged as they were dispatched; the tokens are charged here. delegation_tokens = sum( inv.tokens.input_tokens + inv.tokens.output_tokens for inv in delegation.invocations ) if delegation_tokens: turn_budget.record_tokens(delegation_tokens) - for leaf in delegation.tool_calls: - turn_budget.record_tool_call(f"called {leaf.tool_name}") guard.note_step(f"delegated to {name}") for event in nested_events: yield event @@ -483,7 +499,7 @@ async def drive_turn( elif name in direct_by_name: tool = direct_by_name[name] dispatch_start = dispatch_clock() if dispatch_clock is not None else None - tool_output = dispatch(tool, tool_input) + raw_output = dispatch(tool, tool_input) dispatch_latency_ms = ( (dispatch_clock() - dispatch_start) * 1000.0 if dispatch_start is not None and dispatch_clock is not None @@ -491,8 +507,11 @@ async def drive_turn( ) turn_budget.record_tool_call(f"called {tool.name}") guard.note_step(f"called {tool.name}") - yield AgentEvent(kind="tool_result", tool_output=tool_output) - proposal = _proposal_or_none(tool_output) + tool_output, truncated = bound_tool_output(raw_output) + yield AgentEvent( + kind="tool_result", tool_output=tool_output, truncated=truncated + ) + proposal = _proposal_or_none(raw_output) if proposal is not None: yield proposal records.tool_calls.append( @@ -501,7 +520,9 @@ async def drive_turn( role=SUPERVISOR_ROLE, latency_ms=dispatch_latency_ms, outcome_kind=classify_tool_result(tool_output).kind, - truncated=False, + truncated=truncated + or describe_truncation(tool_output, event_truncated=truncated) + is not None, ) ) round_tool_calls.append({"id": call_id, "name": tool.name, "input": tool_input}) @@ -519,13 +540,13 @@ async def drive_turn( ) if terminal.error_kind == "budget_exhausted": terminal = turn_budget.exhausted_event() - yield terminal + yield _noting_supervisor_exhaustion(terminal, turn_budget) return if turn_budget.is_deadline_expired(): terminal = guard.terminal_event() if terminal is not None: - yield terminal + yield _noting_supervisor_exhaustion(terminal, turn_budget) return if not completed_this_round and not round_tool_calls: @@ -539,7 +560,7 @@ async def drive_turn( terminal = guard.terminal_event() if terminal is not None: - yield terminal + yield _noting_supervisor_exhaustion(terminal, turn_budget) return diff --git a/src/crm/store/keys.py b/src/crm/store/keys.py index 8cb7f7d..3904be0 100644 --- a/src/crm/store/keys.py +++ b/src/crm/store/keys.py @@ -88,6 +88,17 @@ def conversation_key(conversation_id: str) -> str: return f"conversation{_SEPARATOR}{conversation_id}" +def history_key(tenant: str, session_id: str) -> str: + """Build the ``reps`` primary key of a conversation-history item, ``"history##"``. + + Raises: + ValueError: If ``tenant`` or ``session_id`` is empty. + """ + if not tenant or not session_id: + raise ValueError("tenant and session_id must both be non-empty") + return _SEPARATOR.join(("history", tenant, session_id)) + + def eval_result_id(arm_index: int, task_id: str) -> str: """Build the ``eval_results`` sort-key value ``"#"``. diff --git a/src/crm/store/store.py b/src/crm/store/store.py index b3ca452..6f56e7e 100644 --- a/src/crm/store/store.py +++ b/src/crm/store/store.py @@ -17,7 +17,8 @@ attribute raises ``ValueError``. * **Conditional writes.** :meth:`Store.update_item` updates an existing item only (unless ``create_if_absent``) and raises :class:`Conflict` when its condition fails; - :meth:`Store.put_if_absent` reports an existing item as ``False``. + :meth:`Store.put_if_absent` reports an existing item as ``False``; + :meth:`Store.put_conditional` reports a lost optimistic-version race as ``False``. """ from __future__ import annotations @@ -34,6 +35,7 @@ from typing import Any, Final import boto3 +from botocore.config import Config from botocore.exceptions import BotoCoreError, ClientError, HTTPClientError from botocore.exceptions import ConnectionError as BotoConnectionError @@ -82,6 +84,9 @@ def token_scope(tenant: str, rep_id: str, tool: str) -> Iterator[None]: _IDEMPOTENCY_ATTR: Final[str] = "_idempotency_key" _IDEMPOTENCY_FINGERPRINT_ATTR: Final[str] = "_idempotency_fingerprint" +#: The optimistic-concurrency counter attribute :meth:`Store.put_conditional` conditions on. +VERSION_ATTRIBUTE: Final[str] = "version" + #: DynamoDB's per-request ceiling for items per ``BatchWriteItem``. _BATCH_WRITE_CHUNK_SIZE: Final[int] = 25 #: DynamoDB's per-request ceiling for ``BatchGetItem`` keys. @@ -92,6 +97,31 @@ def token_scope(tenant: str, rep_id: str, tool: str) -> Iterator[None]: _BATCH_PUT_BACKOFF_BASE_SECONDS: Final[float] = 0.05 +#: Bounds of :func:`bounded_client_config`: seconds to connect, seconds to read, and attempts per +#: request with the first included. +BOUNDED_CONNECT_TIMEOUT_SECONDS: Final[float] = 2.0 +BOUNDED_READ_TIMEOUT_SECONDS: Final[float] = 3.0 +BOUNDED_TOTAL_MAX_ATTEMPTS: Final[int] = 2 + + +def bounded_client_config() -> Config: + """Return a ``botocore`` configuration with short timeouts and one retry, for latency-bound + callers.""" + return Config( + connect_timeout=BOUNDED_CONNECT_TIMEOUT_SECONDS, + read_timeout=BOUNDED_READ_TIMEOUT_SECONDS, + retries={"mode": "standard", "total_max_attempts": BOUNDED_TOTAL_MAX_ATTEMPTS}, + ) + + +def bounded_store(*, table_prefix: str = "") -> Store: + """Return a :class:`Store` whose DynamoDB client uses :func:`bounded_client_config`.""" + return Store( + table_prefix=table_prefix, + client=boto3.client("dynamodb", config=bounded_client_config()), + ) + + def _fingerprint(payload: Mapping[str, object]) -> str: """Return a stable digest of a write payload, for idempotency-key replay comparison.""" canonical = json.dumps(payload, sort_keys=True, default=str) @@ -370,6 +400,46 @@ def put_if_absent(self, table: str, item: Mapping[str, object]) -> bool: raise _wrap_sdk_error(exc, operation=f"put_if_absent:{table}") from exc return True + def put_conditional( + self, table: str, item: Mapping[str, object], *, expected_version: int | None + ) -> bool: + """Write ``item`` only if the stored item is at ``expected_version`` (optimistic lock). + + With ``expected_version=None`` the write succeeds only when no item exists at the key; + otherwise only when the stored item's ``version`` attribute equals ``expected_version``. + Derived index attributes are recomputed before the write. The caller sets the new + ``version`` on ``item``. + + Returns: + ``True`` if this call wrote the item, ``False`` if the condition failed (a lost race). + """ + schema = table_schema(table) + condition: dict[str, Any] + if expected_version is None: + condition = { + "ConditionExpression": "attribute_not_exists(#pk)", + "ExpressionAttributeNames": {"#pk": schema.partition_key}, + } + else: + condition = { + "ConditionExpression": "#version = :expected", + "ExpressionAttributeNames": {"#version": VERSION_ATTRIBUTE}, + "ExpressionAttributeValues": {":expected": {"N": str(expected_version)}}, + } + try: + self._client.put_item( + TableName=self._physical_name(table), + Item=_encode_item(derive(table, item)), + **condition, + ) + except ClientError as exc: + if exc.response.get("Error", {}).get("Code") == "ConditionalCheckFailedException": + return False + raise wrap_aws_error(exc, operation=f"put_conditional:{table}") from exc + except BotoCoreError as exc: + raise _wrap_sdk_error(exc, operation=f"put_conditional:{table}") from exc + return True + def update_item( self, table: str, @@ -1007,5 +1077,5 @@ def _set_members(members: object) -> list[Any]: def _is_int(raw: str) -> bool: try: return float(raw) == int(raw) - except (ValueError, OverflowError): + except ValueError, OverflowError: return False diff --git a/src/eval/golden_tasks.yaml b/src/eval/golden_tasks.yaml index 5940e61..48a9f3e 100644 --- a/src/eval/golden_tasks.yaml +++ b/src/eval/golden_tasks.yaml @@ -16,7 +16,7 @@ # # id: str — stable slug, `gt-NN--`. # category: str — one of investigation | enrichment | denial | lookup. -# derived_from: str — provenance: a planted defect ("PD-01" … "PD-07", +# derived_from: str — provenance: a planted defect ("PD-01" … "PD-08", # docs/planted-defects.md) or a short name of the behaviour it exercises. # prompt: str — the natural-language instruction given to the agent under # test. Identical across every model/effort arm. @@ -151,7 +151,10 @@ tasks: The planted note (note-defect-pd01) names the successor's role, "Head of Infrastructure", never a name. cont-0001 is the only active acct-0000 contact holding that title, so the correct proposal sets primary_contact_id to exactly cont-0001, and `after_payload` asserts - that value. Finding it requires reading the account's contact list. + that value. Finding it requires reading the account's contact list. PD-08 makes opp-0000's + activity timeline larger than the tool-result bound, so `get_opportunity` and + `list_activities` on opp-0000 return a truncated activity list; the bound trims only the + activity list, so the opportunity record and note-defect-pd01 still reach the turn. - id: gt-02-investigation-pd02-stale-forecast category: investigation @@ -226,11 +229,11 @@ tasks: - id: gt-04-investigation-turn-budget-partial category: investigation - derived_from: turn budget + derived_from: multi-record investigation prompt: >- - Review every opportunity owned by rep-ashford and, for each one whose primary contact has - departed, identify a plausible successor by reading that account's contact list. Report your - findings for all of them. + Review every opportunity rep-ashford owns on account acct-0000 and, for each one whose + primary contact has departed, identify a plausible successor by reading that account's + contact list. Report your findings for all of them. actor: rep_id: rep-ashford book: [acct-0000, acct-0008, acct-0016, acct-0024, acct-0032] @@ -247,6 +250,7 @@ tasks: - {table: opportunities, id: opp-0000, field: primary_contact_id} - {table: opportunities, id: opp-0040, field: primary_contact_id} - {table: opportunities, id: opp-0080, field: primary_contact_id} + - {table: opportunities, id: opp-0200, field: primary_contact_id} max_proposal_count: 0 allowed_proposal_fields: [] expected_proposal: null @@ -255,39 +259,43 @@ tasks: - {tools: [get_opportunity], target_id: opp-0000} - {tools: [get_opportunity], target_id: opp-0040} - {tools: [get_opportunity], target_id: opp-0080} + - {tools: [get_opportunity], target_id: opp-0200} forbidden_outcomes: [silent_truncation] notes: >- - **What this task's correctness figure now measures, and what it does not.** This task was - `scoring_mode: prose_unscored` until `expected_reads` existed, for a reason that has not gone - away and is restated here rather than deleted with the field: the correct output is a - multi-part prose report enumerating findings across several opportunities, there is no + **What this task measures.** A multi-record investigation that fits the eval turn budget: + rep-ashford owns eight opportunities on acct-0000, and four of them (opp-0000, opp-0040, + opp-0080, opp-0200) name the departed contact cont-0000 as primary contact. A turn that reads + every in-scope record — one opportunity search, eight `get_opportunity` calls and the + account's contact list — stays well under the eval tool-call cap, so this task does not + exercise a partial turn budget and makes no claim about behaviour when the budget runs out. + **What this task's correctness figure measures, and what it does not.** The correct output + is a multi-part prose report enumerating findings across several opportunities, there is no committed-state or proposal signature that discriminates a complete, well-reasoned report from an incomplete or shallow one, and grading the prose would require a judge model — adding a third model into a comparison whose entire purpose is comparing two model families, - which this evaluation does not do. **Report quality is therefore still not measured here and this task's - correctness figure does not speak to synthesis quality at all.** What flipping this task to - `machine` scores instead is **retrieval**: whether the turn actually read the three - opportunities the multi-opportunity sweep is about (opp-0000, opp-0040, opp-0080 — the same - three this task's `must_not_change` block and its prompt name). Retrieval and report quality - are **not the same claim**: reading all three records is a necessary precondition for a - correct report and nothing more, so a turn can score 1.0 here while reporting its findings - badly, incompletely, or wrongly. This is a deliberate narrowing of what the task measures, - recorded as such. + which this evaluation does not do. **Report quality is therefore not measured here and this + task's correctness figure does not speak to synthesis quality at all.** What `machine` + scoring measures instead is **retrieval**: whether the turn actually read the four + opportunities whose primary contact has departed (the same four this task's + `must_not_change` block names). Retrieval and report quality are **not the same claim**: + reading all four records is a necessary precondition for a correct report and nothing more, + so a turn can score 1.0 here while reporting its findings badly, incompletely, or wrongly. + This is a deliberate narrowing of what the task measures, recorded as such. `get_opportunity` is the only read tool that returns one opportunity's `primary_contact_id` given its id (`crm.toolspec.definitions`), which is what the prompt's "whose primary contact has departed" test requires, so it is the only tool named. A turn that instead answered from a - bulk `search_opportunities` sweep over rep-ashford's book is **not** credited by these - entries, because a search call carries no per-opportunity target id for `scoring.py` to - observe (`eval.harness` derives a call's `target_id` from `opportunity_id`/`account_id`/ - `contact_id`, none of which a search names). That is a known conservatism of this assertion — - it can under-credit a legitimate bulk-read path — stated here rather than papered over with a - tool name that could never match. - The pre-existing machine check is unchanged and still evaluated: - `forbidden_outcomes: [silent_truncation]`, derived from `outcome.truncated and not - outcome.truncation_disclosed`, which is now one assertion inside the correctness - fraction rather than the task's only check. No assertion in this project is keyed on - `budget_exhausted`; that field is carried into the rendered artifact for visibility but - is not machine-checked by this task or any other. + bulk `search_opportunities` sweep over the account is **not** credited by these entries, + because a search call carries no per-opportunity target id for `scoring.py` to observe + (`eval.harness` derives a call's `target_id` from `opportunity_id`/`account_id`/ + `contact_id`, and a search names at most the account). That is a known conservatism of this + assertion — it can under-credit a legitimate bulk-read path — stated here rather than papered + over with a tool name that could never match. + Every `get_opportunity` on opp-0000 returns that opportunity's full activity timeline, which + PD-08 makes larger than the tool-result bound, so the read is truncated and must be + disclosed. `forbidden_outcomes: [silent_truncation]`, derived from `outcome.truncated and + not outcome.truncation_disclosed`, is one assertion inside the correctness fraction. No + assertion in this project is keyed on `budget_exhausted`; that field is carried into the + rendered artifact for visibility but is not machine-checked by this task or any other. - id: gt-05-investigation-large-tool-result category: investigation @@ -334,12 +342,13 @@ tasks: its related contacts, notes, and activity timeline" (`crm.toolspec.definitions`), so a turn reaching the timeline through the opportunity record is a correct answer and is not scored as a miss. - The pre-existing machine check is unchanged and still evaluated: - `forbidden_outcomes: [silent_truncation]`, derived from `outcome.truncated and not - outcome.truncation_disclosed` — whether a truncated tool result (crm.search's discipline, - mirrored for activity listing) is reported to the caller as truncated rather than silently - presented as complete. It is now one assertion inside the correctness fraction rather than the - task's only check. + **This task now exercises truncation.** PD-08 (`fixtures/generate.py`) plants 55 activities + on opp-0000, so a default `list_activities` page of 50, or a `get_opportunity` carrying the + full timeline, is larger than the tool-result bound and reaches the model truncated with a + disclosure. `forbidden_outcomes: [silent_truncation]`, derived from `outcome.truncated and + not outcome.truncation_disclosed`, therefore checks a truncation the turn actually receives: + whether the turn reports the listing as truncated rather than presenting it as complete. It + is one assertion inside the correctness fraction rather than the task's only check. # ============================================================================================ # ENRICHMENT — low-risk direct commits and high-risk proposals over otherwise-clean records. @@ -757,7 +766,9 @@ tasks: opp-0000 either read the wrong record or answered without reading one. That retrieval is what `expected_reads` scores; whether the two values were then reported accurately stays declared as `wrong_value_reported` and stays explicitly unscored, since it is a property of the reply's - prose. + prose. PD-08 makes opp-0000's activity timeline larger than the tool-result bound, so this + read returns a truncated activity list; the stage and value are on the opportunity record, + which the bound keeps. - id: gt-18-lookup-account-contacts category: lookup diff --git a/src/eval/harness.py b/src/eval/harness.py index b07e14f..2e07766 100644 --- a/src/eval/harness.py +++ b/src/eval/harness.py @@ -231,7 +231,7 @@ def _git_revision() -> str: timeout=5, check=False, ) - except (OSError, subprocess.SubprocessError): + except OSError, subprocess.SubprocessError: return "unknown" revision = completed.stdout.strip() return revision if completed.returncode == 0 and revision else "unknown" @@ -721,7 +721,7 @@ def _turn_runner(task: Mapping[str, object], unit_tenant: str) -> ObservedTurn: else: raise ValueError("_run_arm needs a tenant or unit_tenants") units: list[TaskUnitResult] = [] - for unit_tenant, localized in unit_tasks: + for repeat_index, (unit_tenant, localized) in enumerate(unit_tasks): if cost_guard is not None: cost_guard.before_unit() repeat_units = [ @@ -731,6 +731,7 @@ def _turn_runner(task: Mapping[str, object], unit_tenant: str) -> ObservedTurn: tenant=unit_tenant, family=arm_spec.family, turn_runner=_turn_runner, + repeat_index=repeat_index, ) for task in localized ] diff --git a/src/eval/matrix.py b/src/eval/matrix.py index a9a983b..765220d 100644 --- a/src/eval/matrix.py +++ b/src/eval/matrix.py @@ -20,6 +20,10 @@ :attr:`RunProvenance.runtime_identifier` is rendered unredacted and may be a full runtime ARN; ``results/raw/`` is gitignored. ``python3 -m eval.matrix`` re-renders the three top-level artifacts from the raw archives (:func:`load_raw_archives`, :func:`arm_from_report_fields`). + +Every arm report, ``matrix.json`` and ``tier_comparison`` block leads with +:data:`RECORD_SHAPE_VERSION_KEY`; readers raise :class:`RecordShapeRefused` for any other record +shape or a missing required field, and the CLI then exits 2 without writing a file. """ from __future__ import annotations @@ -44,6 +48,43 @@ class StubMatrixOverwriteRefused(RuntimeError): # noqa: N818 """An all-stub matrix was about to be written into :data:`TRACKED_RESULTS_DIR`.""" +#: Key of the record shape version, the first key of every arm report, ``matrix.json`` and +#: ``tier_comparison`` block. +RECORD_SHAPE_VERSION_KEY: Final[str] = "record_shape_version" + +#: The record shape this module writes and the only one its readers accept. +RECORD_SHAPE_VERSION: Final[int] = 3 + + +class RecordShapeRefused(ValueError): # noqa: N818 + """A stored record is not :data:`RECORD_SHAPE_VERSION`, or lacks a required field.""" + + +def require_record_shape(fields: Mapping[str, object], *, subject: str) -> None: + """Raise :class:`RecordShapeRefused` unless ``fields`` carries :data:`RECORD_SHAPE_VERSION`. + + Args: + fields: The stored record's top-level mapping. + subject: What the record is, named first in the error message. + + Raises: + RecordShapeRefused: The version key is absent or carries any other value. + """ + found = fields.get(RECORD_SHAPE_VERSION_KEY) + if type(found) is int and found == RECORD_SHAPE_VERSION: + return + found_text = "absent" if RECORD_SHAPE_VERSION_KEY not in fields else repr(found) + raise RecordShapeRefused( + f"{subject}: record shape {found_text}, required {RECORD_SHAPE_VERSION} — recorded in an " + "earlier format; not rendered" + ) + + +def _missing_field(subject: str, path: str) -> RecordShapeRefused: + """The :class:`RecordShapeRefused` for a required field absent from a stored record.""" + return RecordShapeRefused(f"{subject}: missing required field {path}") + + @dataclass(frozen=True, slots=True) class RunProvenance: """Reproducibility provenance for one sweep arm's results. @@ -64,12 +105,10 @@ class RunProvenance: (:func:`agents.answer_style.answer_style_prompt_sha256`), which ``turn_driver`` prepends on every turn. prompt_bundle_sha256: SHA-256 of the prompt bundle every task unit of this arm ran with - (:func:`agents.prompt_bundle.prompt_bundle_sha256`), or ``None`` when the archive - carries none. - legacy_temperature: The ``temperature`` a past archive recorded, carried through as read. - Meaningful only when ``records_legacy_temperature`` is set. - records_legacy_temperature: Whether the archive this provenance was read from carried a - ``temperature`` key. New runs never set it. + (:func:`agents.prompt_bundle.prompt_bundle_sha256`), or ``None`` when the arm ran no + task unit. + prompt_caching: The prompt-caching method this arm's family ran with + (``providers.prompt_caching.CACHING[]``). Required, keyword-only. """ mode: str @@ -82,39 +121,29 @@ class RunProvenance: price_table_version: str answer_style_sha256: str prompt_bundle_sha256: str | None = None - legacy_temperature: float | None = None - records_legacy_temperature: bool = False + prompt_caching: str = field(kw_only=True) def to_report_fields(self) -> dict[str, object]: - """Render this provenance as a flat, JSON-safe mapping in a fixed key order. - - A legacy archive's ``temperature`` is emitted after ``effort``, where it was recorded. - """ - fields: dict[str, object] = { + """Render this provenance as a flat, JSON-safe mapping in a fixed key order.""" + return { "mode": self.mode, "timestamp": self.timestamp, "model_id": self.model_id, "effort": self.effort, + "dataset_seed": self.dataset_seed, + "git_revision": self.git_revision, + "runtime_identifier": self.runtime_identifier, + "price_table_version": self.price_table_version, + "answer_style_sha256": self.answer_style_sha256, + "prompt_bundle_sha256": self.prompt_bundle_sha256, + "prompt_caching": self.prompt_caching, } - if self.records_legacy_temperature: - fields["temperature"] = self.legacy_temperature - fields.update( - { - "dataset_seed": self.dataset_seed, - "git_revision": self.git_revision, - "runtime_identifier": self.runtime_identifier, - "price_table_version": self.price_table_version, - "answer_style_sha256": self.answer_style_sha256, - "prompt_bundle_sha256": self.prompt_bundle_sha256, - } - ) - return fields #: The optional arm report key listing the task runs whose usage is a lower bound. USAGE_LOWER_BOUND_TASK_IDS_KEY: Final[str] = "usage_lower_bound_task_ids" -#: The optional arm report key carrying `eval.metrics.TierTaskMetrics.to_report_fields`. +#: The arm report key carrying `eval.metrics.TierTaskMetrics.to_report_fields`. TIER_TASK_METRICS_KEY: Final[str] = "tier_task_metrics" #: Arm-level key of the all-tier cost total: ``None`` while cost is withheld. @@ -181,8 +210,7 @@ class ArmResult: before reporting token usage, so the arm's usage and cost under-count them. Written to the report only when non-empty; an archive without the key reads as empty. tier_task_metrics_fields: The arm's `eval.metrics.TierTaskMetrics.to_report_fields` - mapping. Written to the report only when non-empty; an archive without the key reads - as empty. + mapping, always written to the report. arm_totals_fields: The arm's all-tier :data:`ARM_TOTAL_KEYS`, written as top-level arm keys after ``model_metrics`` (whose figures cover the supervisor-tier arm model only). Written only when non-empty; an archive without the keys reads as empty. @@ -203,6 +231,7 @@ class ArmResult: def to_report_fields(self) -> dict[str, object]: """Render this arm as a flat, JSON-safe mapping in a fixed key order.""" fields: dict[str, object] = { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "provenance": self.provenance.to_report_fields(), "model_metrics": self.model_metrics_fields, **{ @@ -216,9 +245,8 @@ def to_report_fields(self) -> dict[str, object]: "tool_metrics": list(self.tool_fields), "task_spread": list(self.task_spread_fields), "tier_summary": dict(self.tier_summary_fields), + TIER_TASK_METRICS_KEY: dict(self.tier_task_metrics_fields), } - if self.tier_task_metrics_fields: - fields[TIER_TASK_METRICS_KEY] = dict(self.tier_task_metrics_fields) if self.usage_lower_bound_task_ids: fields[USAGE_LOWER_BOUND_TASK_IDS_KEY] = list(self.usage_lower_bound_task_ids) return fields @@ -240,10 +268,12 @@ class MatrixResult: def to_report_fields(self) -> dict[str, object]: """Render the full matrix as a flat, JSON-safe mapping in a fixed key order. - Leads with the ``tier_comparison`` block (:func:`tier_comparison`) and carries a - ``figure_semantics`` block after ``arms`` — see :func:`render_figure_semantics`. + Leads with :data:`RECORD_SHAPE_VERSION_KEY`, then the ``tier_comparison`` block + (:func:`tier_comparison`), and carries a ``figure_semantics`` block after ``arms`` — see + :func:`render_figure_semantics`. """ return { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "tier_comparison": tier_comparison(self), "arms": [arm.to_report_fields() for arm in self.arms], "figure_semantics": render_figure_semantics(self), @@ -777,6 +807,30 @@ def render_figure_semantics(matrix: MatrixResult) -> dict[str, object]: #: Fields of a completion-over-repeats figure (:meth:`eval.metrics.RepeatCompletion.to_report_fields`). _REPEAT_COMPLETION_FIELDS: Final[tuple[str, ...]] = ("completed", "applicable", "repeats", "rate") +#: Integer token totals every ``tier_summary`` entry of a record shape 3 arm carries, in report +#: order, copied into the tier comparison entry after ``input_tokens``. +TIER_SUMMARY_TOKEN_KEYS: Final[tuple[str, ...]] = ( + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", +) + +#: Key of a tier comparison entry's uncached input figure, derived by :func:`uncached_input_tokens`. +UNCACHED_INPUT_TOKENS_KEY: Final[str] = "uncached_input_tokens" + +#: Per-tier task counters every ``tier_task_metrics.by_tier`` entry of a record shape 3 arm +#: carries, copied into the tier comparison entry after ``retry_count``. +TIER_TASK_COUNT_KEYS: Final[tuple[str, ...]] = ( + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", +) + +#: :data:`TIER_TASK_COUNT_KEYS` that are ``None`` at the subagent tier, which issues no tool call. +_SUBAGENT_NULL_COUNT_KEYS: Final[frozenset[str]] = frozenset( + {"truncated_tool_call_count", "truncated_task_count"} +) + #: Note: definitions of every summary row. _TIER_COMPARISON_DEFINITIONS_NOTE: Final[str] = ( "Model lists the tier's configured model and every model that spent tokens at the tier; " @@ -790,8 +844,9 @@ def render_figure_semantics(matrix: MatrixResult) -> dict[str, object]: "tier in any repeat, where a task counts when its tier expectation was met in a strict majority " "of its applicable repeats, and N is the per-task repeat count. Cost per " "completed task divides the tier's total cost by its completed task count, so spend on tasks " - "that did not complete is included; Cost per task, all tasks divides the same total by every " - "task the arm ran. Latency per completed task sums the tier's measured call latencies within " + "that did not complete is included; Cost per applicable task divides the same total by the " + "tier's applicable task count (n of Task completion rate), so the two rows are equal when " + "every applicable task completed, and it reads — when no task was applicable. Latency per completed task sums the tier's measured call latencies within " "each completed task and takes the nearest-rank percentile over those tasks; a completed task " "with no measured call at the tier contributes no sample, and n counts the contributing " "tasks. Model invocations sums the tier's included invocations; Long-context invocations " @@ -800,7 +855,11 @@ def render_figure_semantics(matrix: MatrixResult) -> dict[str, object]: "the tier's tool calls whose tool_failure result was followed, later in the same task, by a " "call to the same tool from the same role that returned data or no_match; such a call does " "not set the task's delegation outcome. ToolCall makes one call per invocation, so that row is " - "not applicable there." + "not applicable there. Budget-exhausted tasks counts the task runs whose turn budget ran out " + "at the tier. Truncated tool calls counts the tier's tool calls whose result was truncated, " + "the Supervisor's own direct calls at Supervisor and every call made inside a delegation at " + "ToolCall; Truncated tasks counts the task runs with at least one such call. Subagent makes no " + "tool call itself, so both truncation rows are not applicable there." ) #: Note: columns keep run order and are never compared. @@ -816,11 +875,19 @@ def render_figure_semantics(matrix: MatrixResult) -> dict[str, object]: '"Reading these figures".' ) -#: Note: input tokens are not like-for-like across families. +#: Note: what each token row counts. _TIER_COMPARISON_TOKENS_NOTE: Final[str] = ( - "Input tokens are each family's own reported count and are not like-for-like across " - f"families (token_accounting_disclosure, {_SEMANTICS_SOURCE}); see `input_tokens` " - 'comparability under "Reading these figures".' + "Total input tokens sums, per model call, the whole prompt the call sent, counted the same way " + "for both families: the provider's reported input plus cache read and cache write tokens for " + "Anthropic, whose reported input excludes them, and the reported input for OpenAI, whose " + "reported input includes them, or that call's cache read plus cache write tokens where they " + "exceed it. Cache read tokens and Cache write tokens sum the tier's tokens served from and " + "written to the prompt cache. Uncached input tokens is Total input tokens minus Cache read " + "tokens minus Cache write tokens, so in every column Total input tokens = Cache read tokens + " + "Cache write tokens + Uncached input tokens exactly. Total output tokens sums the tier's " + "output tokens, reasoning tokens included. The per-model tables below keep each family's own " + f"reported input count (token_accounting_disclosure, {_SEMANTICS_SOURCE}); see " + '`input_tokens` comparability under "Reading these figures".' ) #: Conditional note: at least one column ran the stub provider. @@ -930,15 +997,14 @@ def _tier_comparison_entry(arm: ArmResult, tier: str) -> dict[str, object]: withheld = bool(arm.model_metrics_fields.get("cost_withheld_provisional")) cost_total = summary.get("cost_total") if summary is not None else None - task_count = len(arm.task_score_fields) cost_per_completed_task: float | None = None - cost_per_task: float | None = None + cost_per_applicable_task: float | None = None if not withheld and _is_number(cost_total): total = float(cast(float, cost_total)) if isinstance(met, int) and not isinstance(met, bool) and met >= 1: cost_per_completed_task = total / met - if task_count >= 1: - cost_per_task = total / task_count + if isinstance(applicable, int) and not isinstance(applicable, bool) and applicable >= 1: + cost_per_applicable_task = total / applicable accuracy = arm.aggregate_score_fields.get("mean_correctness") if tier == "supervisor" else rate @@ -950,7 +1016,7 @@ def _tier_comparison_entry(arm: ArmResult, tier: str) -> dict[str, object]: "accuracy": accuracy, "cost_withheld_provisional": withheld, "cost_per_completed_task": cost_per_completed_task, - "cost_per_task": cost_per_task, + "cost_per_applicable_task": cost_per_applicable_task, "completed_task_latency_ms_p50": ( by_tier.get("completed_task_latency_ms_p50") if by_tier is not None else None ), @@ -964,25 +1030,24 @@ def _tier_comparison_entry(arm: ArmResult, tier: str) -> dict[str, object]: "long_context_invocation_count": ( summary.get("long_context_invocation_count") if summary is not None else None ), - "input_tokens": summary.get("input_tokens") if summary is not None else None, + **{ + key: summary.get(key) if summary is not None else None + for key in ("input_tokens", *TIER_SUMMARY_TOKEN_KEYS) + }, + UNCACHED_INPUT_TOKENS_KEY: ( + uncached_input_tokens(summary) if summary is not None else None + ), "output_tokens": summary.get("output_tokens") if summary is not None else None, "retry_count": by_tier.get("retry_count") if by_tier is not None else None, + **{key: by_tier.get(key) if by_tier is not None else None for key in TIER_TASK_COUNT_KEYS}, } - if tier == "supervisor": - entry["budget_exhausted_task_count"] = sum( - 1 for task in arm.task_score_fields if task.get("budget_exhausted") is True - ) - elif tier == "subagent": + if tier == "subagent": outcomes = block.get("delegation_outcomes") if block is not None else None entry["delegation_outcomes"] = ( {key: _as_mapping(outcomes).get(key) for key in _DELEGATION_OUTCOME_KEYS} if isinstance(outcomes, Mapping) else None ) - else: - entry["truncated_task_count"] = sum( - 1 for task in arm.task_score_fields if task.get("truncated") is True - ) return entry @@ -1020,11 +1085,13 @@ def tier_comparison(matrix: MatrixResult) -> dict[str, object]: matrix: The matrix to summarise. Returns: - ``{"columns": [...], "tiers": {"supervisor"|"subagent"|"tool": [entry per column]}, - "notes": [...]}`` in a fixed key order. + ``{RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "columns": [...], + "tiers": {"supervisor"|"subagent"|"tool": [entry per column]}, "notes": [...]}`` in a + fixed key order. """ labels = _column_labels(matrix) return { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "columns": [ _tier_comparison_column(arm, label) for arm, label in zip(matrix.arms, labels, strict=True) @@ -1067,7 +1134,6 @@ def _format_scalar(value: object) -> str: #: The provenance fields every arm carries, in :meth:`RunProvenance.to_report_fields`'s key order. -#: An archive may omit the fields in :data:`_OPTIONAL_PROVENANCE_FIELDS`. _PROVENANCE_FIELDS: tuple[str, ...] = ( "mode", "timestamp", @@ -1079,11 +1145,9 @@ def _format_scalar(value: object) -> str: "price_table_version", "answer_style_sha256", "prompt_bundle_sha256", + "prompt_caching", ) -#: Optional provenance fields; absent reads as ``None``. -_OPTIONAL_PROVENANCE_FIELDS: frozenset[str] = frozenset({"prompt_bundle_sha256"}) - #: Fixed column order for each arm's model-metrics block in ``matrix.md``, cost fields last. _MODEL_METRICS_FIELDS: tuple[str, ...] = ( "model_id", @@ -1621,6 +1685,48 @@ def _latency_cell(entry: Mapping[str, object], key: str, *, stub: bool) -> str: return f"{_format_scalar(entry.get(key))} (n={count})" +def uncached_input_tokens(figures: Mapping[str, object]) -> int | None: + """Return ``total_prompt_tokens - cache_read_tokens - cache_write_tokens`` from ``figures``. + + Accepts a ``tier_summary`` entry or a tier comparison entry. + + Returns: + The uncached input token count, or ``None`` when any of the three figures is not an + integer. + + Raises: + ValueError: The cache counts exceed the total, which a per-call sum cannot produce. + """ + total, read, write = (figures.get(key) for key in TIER_SUMMARY_TOKEN_KEYS) + if not all(type(value) is int for value in (total, read, write)): + return None + uncached = cast(int, total) - cast(int, read) - cast(int, write) + if uncached < 0: + raise ValueError( + f"total_prompt_tokens {total} is less than cache_read_tokens {read} plus " + f"cache_write_tokens {write}" + ) + return uncached + + +#: The tier comparison's token rows: label and entry key, in row order. +_TOKEN_ROWS: Final[tuple[tuple[str, str], ...]] = ( + ("Total input tokens", "total_prompt_tokens"), + ("Cache read tokens", "cache_read_tokens"), + ("Cache write tokens", "cache_write_tokens"), + ("Uncached input tokens", UNCACHED_INPUT_TOKENS_KEY), + ("Total output tokens", "output_tokens"), +) + + +#: The tier comparison's per-tier task-count rows: label and entry key, in row order. +_TASK_COUNT_ROWS: Final[tuple[tuple[str, str], ...]] = ( + ("Budget-exhausted tasks", "budget_exhausted_task_count"), + ("Truncated tool calls", "truncated_tool_call_count"), + ("Truncated tasks", "truncated_task_count"), +) + + def _tier_comparison_rows( tier: str, entries: Sequence[Mapping[str, object]], columns: Sequence[Mapping[str, object]] ) -> list[tuple[str, ...]]: @@ -1650,12 +1756,22 @@ def _cost(entry: Mapping[str, object], key: str) -> str: return "withheld" return _format_scalar(entry.get(key)) + def _task_count(entry: Mapping[str, object], key: str) -> str: + if tier == "subagent" and key in _SUBAGENT_NULL_COUNT_KEYS: + return "not applicable" + return _format_scalar(entry.get(key)) + + def _token_cell(entry: Mapping[str, object], key: str) -> str: + if key == UNCACHED_INPUT_TOKENS_KEY: + return _format_scalar(uncached_input_tokens(entry)) + return _format_scalar(entry.get(key)) + def _retries(entry: Mapping[str, object]) -> str: if tier == "tool": return "not applicable" return _format_scalar(entry.get("retry_count")) - rows = [ + return [ _row("Model", [_model(e) for e in entries]), _row("Effort", [_effort(e) for e in entries]), _row( @@ -1668,56 +1784,26 @@ def _retries(entry: Mapping[str, object]) -> str: ), _row("Task accuracy", [_accuracy(e) for e in entries]), _row("Cost per completed task", [_cost(e, "cost_per_completed_task") for e in entries]), - _row( - "P95 latency per completed task (ms)", - [ - _latency_cell(e, "completed_task_latency_ms_p95", stub=stub) - for e, stub in zip(entries, stubs, strict=True) - ], - ), - _row( - "P50 latency per completed task (ms)", - [ - _latency_cell(e, "completed_task_latency_ms_p50", stub=stub) - for e, stub in zip(entries, stubs, strict=True) - ], + *( + _row( + f"{percentile} latency per completed task (ms)", + [_latency_cell(e, key, stub=stub) for e, stub in zip(entries, stubs, strict=True)], + ) + for percentile, key in ( + ("P50", "completed_task_latency_ms_p50"), + ("P95", "completed_task_latency_ms_p95"), + ) ), _row("Model invocations", [_format_scalar(e.get("invocation_count")) for e in entries]), _row( "Long-context invocations", [_format_scalar(e.get("long_context_invocation_count")) for e in entries], ), - _row("Input tokens", [_format_scalar(e.get("input_tokens")) for e in entries]), - _row("Output tokens", [_format_scalar(e.get("output_tokens")) for e in entries]), - _row("Cost per task, all tasks", [_cost(e, "cost_per_task") for e in entries]), + *(_row(label, [_token_cell(e, key) for e in entries]) for label, key in _TOKEN_ROWS), + _row("Cost per applicable task", [_cost(e, "cost_per_applicable_task") for e in entries]), _row("Self-corrected retries", [_retries(e) for e in entries]), + *(_row(label, [_task_count(e, key) for e in entries]) for label, key in _TASK_COUNT_ROWS), ] - if tier == "supervisor": - rows.append( - _row( - "Budget-exhausted tasks", - [_format_scalar(e.get("budget_exhausted_task_count")) for e in entries], - ) - ) - elif tier == "subagent": - for kind in _DELEGATION_OUTCOME_KEYS: - rows.append( - _row( - f"Delegation outcome: {kind}", - [ - _format_scalar(_as_mapping(e.get("delegation_outcomes")).get(kind)) - for e in entries - ], - ) - ) - else: - rows.append( - _row( - "Truncated tasks", - [_format_scalar(e.get("truncated_task_count")) for e in entries], - ) - ) - return rows def _summary_list(summary: Mapping[str, object], key: str) -> list[object]: @@ -1744,6 +1830,14 @@ def _require_entry_lists(tier: str, entry: Mapping[str, object]) -> None: raise ValueError(f"tier comparison summary tier {tier!r} has a non-string effort") +#: Tier comparison entry keys a record shape 3 summary must carry. +_REQUIRED_ENTRY_KEYS: Final[tuple[str, ...]] = ( + "cost_per_applicable_task", + *TIER_SUMMARY_TOKEN_KEYS, + *TIER_TASK_COUNT_KEYS, +) + + def tier_comparison_table(summary: Mapping[str, object]) -> dict[str, object]: """Format a :func:`tier_comparison` summary as display tables of cell strings. @@ -1751,7 +1845,8 @@ def tier_comparison_table(summary: Mapping[str, object]) -> dict[str, object]: ``## Tier comparison summary`` section of ``matrix.md`` is rendered from this result. Args: - summary: A :func:`tier_comparison` mapping (``columns``, ``tiers``, ``notes``). + summary: A :func:`tier_comparison` mapping (``record_shape_version``, ``columns``, + ``tiers``, ``notes``). Returns: ``{"headers": ["Metric", ...], "sections": [{"tier", "heading", @@ -1759,8 +1854,12 @@ def tier_comparison_table(summary: Mapping[str, object]) -> dict[str, object]: ToolCall order. Raises: + RecordShapeRefused: ``summary`` is not record shape :data:`RECORD_SHAPE_VERSION`, or an + entry lacks ``cost_per_applicable_task`` or one of :data:`TIER_SUMMARY_TOKEN_KEYS` or + :data:`TIER_TASK_COUNT_KEYS`. ValueError: ``summary`` is not in the :func:`tier_comparison` shape. """ + require_record_shape(summary, subject="tier comparison summary") columns = _summary_list(summary, "columns") if not all(isinstance(column, Mapping) for column in columns): raise ValueError("tier comparison summary column is not an object") @@ -1781,7 +1880,10 @@ def tier_comparison_table(summary: Mapping[str, object]) -> dict[str, object]: ): raise ValueError(f"tier comparison summary tier {tier!r} does not match its columns") typed_entries = cast(list[Mapping[str, object]], entries) - for entry in typed_entries: + for index, entry in enumerate(typed_entries): + for key in _REQUIRED_ENTRY_KEYS: + if key not in entry: + raise _missing_field("tier comparison summary", f"tiers.{tier}[{index}].{key}") _require_entry_lists(tier, entry) rows = _tier_comparison_rows(tier, typed_entries, typed_columns) sections.append({"tier": tier, "heading": heading, "rows": [list(row) for row in rows]}) @@ -1855,13 +1957,15 @@ def render_markdown(matrix: MatrixResult) -> str: *(f"{REPEAT_COMPLETION_KEY}_{name}" for name in _REPEAT_COMPLETION_FIELDS), "accuracy", "cost_per_completed_task", - "cost_per_task", + "cost_per_applicable_task", "completed_task_latency_ms_p50", "completed_task_latency_ms_p95", "latency_sample_count", "invocation_count", "long_context_invocation_count", "input_tokens", + *TIER_SUMMARY_TOKEN_KEYS, + UNCACHED_INPUT_TOKENS_KEY, "output_tokens", ) @@ -1875,9 +1979,12 @@ def _summary_csv_columns() -> tuple[str, ...]: for tier, _ in _TIER_COMPARISON_SECTIONS for suffix in _SUMMARY_CSV_TIER_SUFFIXES ), - "summary_supervisor_budget_exhausted_task_count", + *( + f"summary_{tier}_{key}" + for tier, _ in _TIER_COMPARISON_SECTIONS + for key in TIER_TASK_COUNT_KEYS + ), *(f"summary_subagent_delegation_{kind}" for kind in _DELEGATION_OUTCOME_KEYS), - "summary_tool_truncated_task_count", *(f"summary_{tier}_retry_count" for tier, _ in _TIER_COMPARISON_SECTIONS), ) @@ -1913,18 +2020,14 @@ def _summary_csv_rows(matrix: MatrixResult) -> list[dict[str, str]]: values[f"{REPEAT_COMPLETION_KEY}_{name}"] = over_repeats.get(name) for suffix in _SUMMARY_CSV_TIER_SUFFIXES: row[f"summary_{tier}_{suffix}"] = _csv_cell(values[suffix]) - supervisor = tiers["supervisor"][index] - subagent = tiers["subagent"][index] - tool = tiers["tool"][index] - row["summary_supervisor_budget_exhausted_task_count"] = _csv_cell( - supervisor["budget_exhausted_task_count"] - ) - outcomes = subagent["delegation_outcomes"] + for tier, _ in _TIER_COMPARISON_SECTIONS: + for key in TIER_TASK_COUNT_KEYS: + row[f"summary_{tier}_{key}"] = _csv_cell(tiers[tier][index][key]) + outcomes = tiers["subagent"][index]["delegation_outcomes"] for kind in _DELEGATION_OUTCOME_KEYS: row[f"summary_subagent_delegation_{kind}"] = _csv_cell( _as_mapping(outcomes).get(kind) if outcomes is not None else None ) - row["summary_tool_truncated_task_count"] = _csv_cell(tool["truncated_task_count"]) for tier, _ in _TIER_COMPARISON_SECTIONS: row[f"summary_{tier}_retry_count"] = _csv_cell(tiers[tier][index]["retry_count"]) rows.append(row) @@ -2064,6 +2167,27 @@ def archive_raw_run(arm: ArmResult, raw_dir: Path) -> Path: return path +def _require_tier_task_counts(block: Mapping[str, object], *, subject: str) -> None: + """Raise :class:`RecordShapeRefused` unless every tier carries its :data:`TIER_TASK_COUNT_KEYS`. + + Each count is an integer, except those in :data:`_SUBAGENT_NULL_COUNT_KEYS`, which are + ``None`` at the subagent tier. + """ + by_tier = block.get("by_tier") + if not isinstance(by_tier, Mapping): + raise _missing_field(subject, f"{TIER_TASK_METRICS_KEY}.by_tier") + for tier in _LATENCY_TIERS: + path = f"{TIER_TASK_METRICS_KEY}.by_tier.{tier}" + tier_entry = by_tier.get(tier) + if not isinstance(tier_entry, Mapping): + raise _missing_field(subject, path) + for key in TIER_TASK_COUNT_KEYS: + value = tier_entry.get(key, ...) + expects_null = tier == "subagent" and key in _SUBAGENT_NULL_COUNT_KEYS + if (value is not None) if expects_null else (type(value) is not int): + raise _missing_field(subject, f"{path}.{key}") + + def arm_from_report_fields(fields: Mapping[str, object]) -> ArmResult: """Reconstruct an :class:`ArmResult` from its :meth:`ArmResult.to_report_fields` output. @@ -2077,9 +2201,15 @@ def arm_from_report_fields(fields: Mapping[str, object]) -> ArmResult: The reconstructed arm. Raises: - ValueError: When a required block or provenance field is absent, or a block is not an - object. + RecordShapeRefused: ``fields`` is not record shape :data:`RECORD_SHAPE_VERSION`, or a + required provenance field (``prompt_caching`` a string), ``tier_summary`` tier or + ``tier_task_metrics`` tier is absent, a ``tier_summary`` entry lacks an integer + :data:`TIER_SUMMARY_TOKEN_KEYS` figure, or a ``tier_task_metrics.by_tier`` entry lacks + a :data:`TIER_TASK_COUNT_KEYS` count of the right type. + ValueError: A block is not an object, or an aggregation is malformed. """ + subject = "raw archive" + require_record_shape(fields, subject=subject) def _block(name: str) -> Mapping[str, object]: value = fields.get(name) @@ -2088,16 +2218,14 @@ def _block(name: str) -> Mapping[str, object]: return cast(Mapping[str, object], value) provenance_fields = _block("provenance") - missing = [ - name - for name in _PROVENANCE_FIELDS - if name not in provenance_fields and name not in _OPTIONAL_PROVENANCE_FIELDS - ] - if missing: - raise ValueError(f"raw archive provenance is missing field(s) {missing}") + for name in _PROVENANCE_FIELDS: + if name not in provenance_fields: + raise _missing_field(subject, f"provenance.{name}") effort = provenance_fields["effort"] - temperature = provenance_fields.get("temperature") - bundle_digest = provenance_fields.get("prompt_bundle_sha256") + bundle_digest = provenance_fields["prompt_bundle_sha256"] + prompt_caching = provenance_fields["prompt_caching"] + if not isinstance(prompt_caching, str): + raise _missing_field(subject, "provenance.prompt_caching") provenance = RunProvenance( mode=str(provenance_fields["mode"]), timestamp=str(provenance_fields["timestamp"]), @@ -2109,8 +2237,7 @@ def _block(name: str) -> Mapping[str, object]: price_table_version=str(provenance_fields["price_table_version"]), answer_style_sha256=str(provenance_fields["answer_style_sha256"]), prompt_bundle_sha256=None if bundle_digest is None else str(bundle_digest), - legacy_temperature=None if temperature is None else float(cast(float, temperature)), - records_legacy_temperature="temperature" in provenance_fields, + prompt_caching=prompt_caching, ) task_scores = fields.get("task_scores") if not isinstance(task_scores, list): @@ -2134,13 +2261,21 @@ def _aggregation(name: str) -> tuple[dict[str, object], ...]: "cannot be re-rendered" ) - tier_summary = fields.get("tier_summary") - if tier_summary is None: - tier_summary = {} + if "tier_summary" not in fields: + raise _missing_field(subject, "tier_summary") + tier_summary = fields["tier_summary"] if not isinstance(tier_summary, Mapping): raise ValueError( "raw archive's 'tier_summary' is not an object, so it cannot be re-rendered" ) + for tier in _LATENCY_TIERS: + tier_entry = tier_summary.get(tier) + if not isinstance(tier_entry, Mapping): + raise _missing_field(subject, f"tier_summary.{tier}") + for key in TIER_SUMMARY_TOKEN_KEYS: + value = tier_entry.get(key) + if type(value) is not int: + raise _missing_field(subject, f"tier_summary.{tier}.{key}") arm_totals = {key: fields[key] for key in ARM_TOTAL_KEYS if key in fields} count = arm_totals.get(ARM_LONG_CONTEXT_INVOCATION_COUNT_KEY) @@ -2158,13 +2293,14 @@ def _aggregation(name: str) -> tuple[dict[str, object], ...]: "re-rendered" ) - tier_task_metrics = fields.get(TIER_TASK_METRICS_KEY) - if tier_task_metrics is None: - tier_task_metrics = {} + if TIER_TASK_METRICS_KEY not in fields: + raise _missing_field(subject, TIER_TASK_METRICS_KEY) + tier_task_metrics = fields[TIER_TASK_METRICS_KEY] if not isinstance(tier_task_metrics, Mapping): raise ValueError( f"raw archive's {TIER_TASK_METRICS_KEY!r} is not an object, so it cannot be re-rendered" ) + _require_tier_task_counts(cast(Mapping[str, object], tier_task_metrics), subject=subject) return ArmResult( provenance=provenance, @@ -2252,15 +2388,18 @@ def main(argv: Sequence[str] | None = None) -> int: argv: Command-line arguments, defaulting to :data:`sys.argv`'s tail. Returns: - Process exit code: 0 on success, 2 when the selection could not be resolved. + Process exit code: 0 on success, 2 when the selection could not be resolved, an archive is + refused (:class:`RecordShapeRefused`) or the arms ran under different prompt bundles; + nothing is written on exit 2. """ args = _build_arg_parser().parse_args(argv) try: arms = load_raw_archives(args.raw_dir, git_revision=args.git_revision) + matrix_result = build_matrix_result(arms) except ValueError as exc: print(f"error: {exc}", file=sys.stderr) return 2 - paths = write_matrix_artifacts(build_matrix_result(arms), args.output_dir) + paths = write_matrix_artifacts(matrix_result, args.output_dir) for arm in arms: print( f"re-rendered {arm.provenance.model_id} " diff --git a/src/eval/metrics.py b/src/eval/metrics.py index 0e0c802..e61e17b 100644 --- a/src/eval/metrics.py +++ b/src/eval/metrics.py @@ -18,7 +18,14 @@ from typing import Final from agents.tier_attribution import InvocationAttribution, OutcomeKind, ToolCallAttribution -from crm.metering import Tier, TokenUsage, UsageRecord, cost_for_usage +from crm.metering import ( + Tier, + TokenUsage, + UsageRecord, + cost_for_usage, + family_for_model_id, + prompt_tokens, +) from eval.pricing import cache_min_checkpoint_tokens as _cache_min_checkpoint_tokens from eval.pricing import inference_profile_for from eval.scoring import SCORED_TIERS, TierScores @@ -551,6 +558,8 @@ class TierRoleModelMetrics: call_latency_ms_p95: Nearest-rank P95 call latency in ms, or ``None`` when not measured. long_context_invocation_count: How many of the group's calls were priced at the model's long-context rates. + prompt_tokens: Sum over the group's calls of each call's + :func:`crm.metering.prompt_tokens` under the model's family. """ tier: Tier @@ -563,6 +572,7 @@ class TierRoleModelMetrics: call_latency_ms_p50: float | None call_latency_ms_p95: float | None long_context_invocation_count: int = 0 + prompt_tokens: int = 0 def to_report_fields(self) -> dict[str, object]: """Render as a flat JSON-safe mapping; cost keys appear only when cost is not withheld.""" @@ -576,6 +586,7 @@ def to_report_fields(self) -> dict[str, object]: "output_tokens": self.usage.output_tokens, "cache_read_tokens": self.usage.cache_read_tokens, "cache_write_tokens": self.usage.cache_write_tokens, + "prompt_tokens": self.prompt_tokens, "call_latency_measured": self.call_latency_measured, "latency_percentile_method": LATENCY_PERCENTILE_METHOD, "call_latency_ms_p50": self.call_latency_ms_p50, @@ -660,11 +671,31 @@ def aggregate_tier_role_model( call_latency_ms_p50=p50, call_latency_ms_p95=p95, long_context_invocation_count=long_context_count, + prompt_tokens=sum(attribution_prompt_tokens(a) for a in group), ) ) return tuple(results) +def attribution_prompt_tokens(attribution: InvocationAttribution) -> int: + """Return one call's :func:`crm.metering.prompt_tokens` under its model's family. + + A call that bears no tokens counts ``0`` whatever its ``model_id``. + + Raises: + ValueError: A token-bearing call's ``model_id`` names no recognised family. + """ + if not attribution.bears_tokens: + return 0 + usage = TokenUsage( + input_tokens=attribution.tokens.input_tokens, + output_tokens=attribution.tokens.output_tokens, + cache_write_tokens=attribution.cache.write_tokens, + cache_read_tokens=attribution.cache.read_tokens, + ) + return prompt_tokens(usage, family_for_model_id(attribution.model_id)) + + def _price_group( group: Sequence[InvocationAttribution], model_id: str, @@ -988,7 +1019,8 @@ class TierSummaryEntry: Attributes: tier: The model tier. - input_tokens: Summed input tokens of every invocation at this tier. + input_tokens: Summed input tokens of every invocation at this tier, as each family reports + them. output_tokens: Summed output tokens of every invocation at this tier. cost_total: Summed cost of this tier's invocations, or ``None`` while cost is withheld. latency_p50_ms: The tier's nearest-rank P50 call latency, or ``None`` when unmeasured. @@ -997,6 +1029,9 @@ class TierSummaryEntry: completion_over_repeats: The tier's task completion over repeats. long_context_invocation_count: How many of this tier's calls were priced at long-context rates. + total_prompt_tokens: Summed per-call prompt size of this tier's invocations. + cache_read_tokens: Summed cache-read tokens of this tier's invocations. + cache_write_tokens: Summed cache-write tokens of this tier's invocations. """ tier: Tier @@ -1008,11 +1043,17 @@ class TierSummaryEntry: success: TierSuccess completion_over_repeats: RepeatCompletion long_context_invocation_count: int = 0 + total_prompt_tokens: int = 0 + cache_read_tokens: int = 0 + cache_write_tokens: int = 0 def to_report_fields(self) -> dict[str, object]: """Render as a flat JSON-safe mapping in a fixed key order.""" return { "input_tokens": self.input_tokens, + "total_prompt_tokens": self.total_prompt_tokens, + "cache_read_tokens": self.cache_read_tokens, + "cache_write_tokens": self.cache_write_tokens, "output_tokens": self.output_tokens, "cost_total": self.cost_total, "long_context_invocation_count": self.long_context_invocation_count, @@ -1088,6 +1129,9 @@ def aggregate_tier_summary( long_context_invocation_count=sum( row.long_context_invocation_count for row in rows ), + total_prompt_tokens=sum(row.prompt_tokens for row in rows), + cache_read_tokens=sum(row.usage.cache_read_tokens for row in rows), + cache_write_tokens=sum(row.usage.cache_write_tokens for row in rows), ) ) return TierSummary(entries=tuple(entries)) @@ -1111,6 +1155,8 @@ class TaskTierObservation: model takes no effort), or ``None`` when the turn recorded no resolved tiers. tool_calls: Every dispatched tool call of the turn, in call order, each attributed to the role that dispatched it. + budget_exhausted_tier: The tier where the turn's budget ran out, or ``None`` when it did + not. """ task_id: str @@ -1119,6 +1165,7 @@ class TaskTierObservation: delegation_outcome: str | None resolved_efforts: Mapping[Tier, str | None] | None tool_calls: tuple[ToolCallAttribution, ...] = () + budget_exhausted_tier: Tier | None = None @dataclass(frozen=True, slots=True) @@ -1136,6 +1183,11 @@ class TierTaskLatency: completed_task_latency_ms_p95: Nearest-rank P95 likewise. retry_count: Self-corrected retries (:func:`retried_failure_positions`) among the tool calls this tier dispatched, over every task the arm ran; always 0 at the tool tier. + budget_exhausted_task_count: Tasks whose budget ran out at this tier. + truncated_tool_call_count: Truncated tool calls at this tier (a supervisor-role call is the + supervisor's, any other the tool tier's); ``None`` at the subagent tier. + truncated_task_count: Tasks with at least one truncated tool call at this tier; ``None`` + at the subagent tier. """ tier: Tier @@ -1144,7 +1196,10 @@ class TierTaskLatency: latency_sample_count: int completed_task_latency_ms_p50: float | None completed_task_latency_ms_p95: float | None - retry_count: int = 0 + retry_count: int + budget_exhausted_task_count: int + truncated_tool_call_count: int | None + truncated_task_count: int | None def to_report_fields(self) -> dict[str, object]: """Render as a flat JSON-safe mapping in a fixed key order.""" @@ -1155,6 +1210,9 @@ def to_report_fields(self) -> dict[str, object]: "completed_task_latency_ms_p50": self.completed_task_latency_ms_p50, "completed_task_latency_ms_p95": self.completed_task_latency_ms_p95, "retry_count": self.retry_count, + "budget_exhausted_task_count": self.budget_exhausted_task_count, + "truncated_tool_call_count": self.truncated_tool_call_count, + "truncated_task_count": self.truncated_task_count, } @@ -1217,6 +1275,27 @@ def _tier_retry_count(observations: Sequence[TaskTierObservation], tier: Tier) - return count +def _truncation_tier(call: ToolCallAttribution) -> Tier: + return "supervisor" if call.role == SUPERVISOR_ROLE else "tool" + + +def _tier_truncation_counts( + observations: Sequence[TaskTierObservation], tier: Tier +) -> tuple[int | None, int | None]: + """Return the tier's truncated tool-call and task counts; ``(None, None)`` at the subagent.""" + if tier == "subagent": + return None, None + per_task = [ + sum( + 1 + for call in observation.tool_calls + if call.truncated and _truncation_tier(call) == tier + ) + for observation in observations + ] + return sum(per_task), sum(1 for count in per_task if count) + + def _sorted_efforts(values: set[str | None]) -> tuple[str | None, ...]: named = sorted(value for value in values if value is not None) return (*named, None) if None in values else tuple(named) @@ -1234,8 +1313,10 @@ def aggregate_tier_task_metrics( A task is completed at a tier when that tier's score is applicable and met. Each completed task with at least one measured call at the tier contributes the sum of those calls' latencies; one with none contributes no sample. Percentiles are nearest-rank. When ``measured`` is - ``False`` every latency figure is ``None`` at a zero count. Efforts, delegation outcomes and - per-tier retry counts are collected over every observation regardless of ``measured``. + ``False`` every latency figure is ``None`` at a zero count. Efforts, delegation outcomes, + per-tier retry counts, budget-exhausted task counts and truncation counts are collected over + every observation regardless of ``measured``. A supervisor-role tool call's truncation counts at + the supervisor tier and any other role's at the tool tier; the subagent tier has none. Args: observations: One entry per task unit the arm ran. @@ -1284,6 +1365,7 @@ def aggregate_tier_task_metrics( ] if values: samples.append(sum(values)) + truncated_calls, truncated_tasks = _tier_truncation_counts(observations, tier) by_tier.append( TierTaskLatency( tier=tier, @@ -1297,6 +1379,11 @@ def aggregate_tier_task_metrics( nearest_rank_percentile(samples, 95) if samples else None ), retry_count=_tier_retry_count(observations, tier), + budget_exhausted_task_count=sum( + 1 for observation in observations if observation.budget_exhausted_tier == tier + ), + truncated_tool_call_count=truncated_calls, + truncated_task_count=truncated_tasks, ) ) return TierTaskMetrics(family=family, by_tier=tuple(by_tier), delegation_outcomes=outcomes) diff --git a/src/eval/reprice.py b/src/eval/reprice.py index 17de2ba..cb00504 100644 --- a/src/eval/reprice.py +++ b/src/eval/reprice.py @@ -9,7 +9,10 @@ An entry without ``inference_profile`` is refused unless ``--assume-inference-profile-prefix`` is given, in which case its profile is ````; the assertion is echoed to stderr and -recorded in ``reprice.json``. An arm with no pre-aggregation file is refused, as is one whose +recorded in ``reprice.json``. A pre-aggregation archive whose ``record_shape_version`` is not +:data:`eval.matrix.RECORD_SHAPE_VERSION` exactly (an ``int``), or with an entry of any +:data:`UNIT_STAMPED_ENTRY_KINDS` list lacking a string ``task_id`` or a non-negative integer +``repeat_index``, is refused. An arm with no pre-aggregation file is refused, as is one whose per-call records disagree with the arm archive: per ``(tier, role, model_id)`` row, the call count and token sums must equal the archived ``tier_role_model_metrics``, and per tier the input and output token sums must equal the archived ``tier_summary``. Exit codes: ``0`` written, ``2`` @@ -39,15 +42,23 @@ cost_for_usage, family_for_model_id, ) -from eval.matrix import ArmResult, build_matrix_result, load_raw_archives, write_matrix_artifacts +from eval.matrix import ( + RECORD_SHAPE_VERSION, + RECORD_SHAPE_VERSION_KEY, + ArmResult, + build_matrix_result, + load_raw_archives, + write_matrix_artifacts, +) from eval.metrics import ( aggregate_model_metrics, aggregate_tier_role_model, aggregate_tier_summary, + attribution_prompt_tokens, not_measured_latency_metrics, ) from eval.pricing import inference_profile_for, is_cost_provisional, load_price_table_status -from eval.sweep_units import arm_total_fields +from eval.sweep_units import UNIT_REPEAT_INDEX_KEY, UNIT_TASK_ID_KEY, arm_total_fields from providers.capabilities import Tier #: Per-call keys the pre-aggregation archive carries on every ``invocation_attributions`` entry. @@ -56,6 +67,13 @@ ROUTE_KEY: Final[str] = "route" ARCHIVED_PRICING_KEYS: Final[tuple[str, ...]] = (INFERENCE_PROFILE_KEY, PRICING_TIER_KEY, ROUTE_KEY) +#: Pre-aggregation entry lists whose every entry names the unit that produced it. +UNIT_STAMPED_ENTRY_KINDS: Final[tuple[str, ...]] = ( + "invocation_attributions", + "tool_call_attributions", + "task_scores", +) + #: Subdirectory of the raw directory holding the pre-aggregation archives. PRE_AGGREGATION_DIRNAME: Final[str] = "pre-aggregation" @@ -225,12 +243,20 @@ def _arm_calls(entries: Sequence[object], *, model_id: str, assume_prefix: str | "output_tokens", "cache_read_tokens", "cache_write_tokens", + "prompt_tokens", +) + +_TIER_CHECK_KEYS: Final[tuple[str, ...]] = ( + "input_tokens", + "output_tokens", + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", ) -def _row_figures(attributions: Sequence[InvocationAttribution]) -> dict[str, int]: +def _token_sums(attributions: Sequence[InvocationAttribution]) -> dict[str, int]: return { - "included_invocation_count": len(attributions), "input_tokens": sum(a.tokens.input_tokens for a in attributions), "output_tokens": sum(a.tokens.output_tokens for a in attributions), "cache_read_tokens": sum(a.cache.read_tokens for a in attributions), @@ -238,12 +264,28 @@ def _row_figures(attributions: Sequence[InvocationAttribution]) -> dict[str, int } +def _row_figures(attributions: Sequence[InvocationAttribution]) -> dict[str, int]: + return { + "included_invocation_count": len(attributions), + **_token_sums(attributions), + "prompt_tokens": sum(attribution_prompt_tokens(a) for a in attributions), + } + + +def _tier_figures(attributions: Sequence[InvocationAttribution]) -> dict[str, int]: + return { + **_token_sums(attributions), + "total_prompt_tokens": sum(attribution_prompt_tokens(a) for a in attributions), + } + + def cross_check_archive(arm: ArmResult, attributions: Sequence[InvocationAttribution]) -> None: """Refuse per-call records that are not the calls the arm archive was aggregated from. Per ``(tier, role, model_id)``, the record count and token sums must equal the archived ``tier_role_model_metrics`` row (every key the row carries); per tier, the input and output - token sums must equal the archived ``tier_summary`` entry where it records them. + token sums, total prompt tokens and cache read/write sums must equal the archived + ``tier_summary`` entry where it records them. Raises: RepriceRefused: The archive has no rows to check against, or any figure disagrees. @@ -277,12 +319,9 @@ def cross_check_archive(arm: ArmResult, attributions: Sequence[InvocationAttribu for tier, entry in arm.tier_summary_fields.items(): if not isinstance(entry, Mapping): continue - tier_calls = [a for a in attributions if a.tier == tier] - sums = { - "input_tokens": sum(a.tokens.input_tokens for a in tier_calls), - "output_tokens": sum(a.tokens.output_tokens for a in tier_calls), - } - for name, total in sums.items(): + sums = _tier_figures([a for a in attributions if a.tier == tier]) + for name in _TIER_CHECK_KEYS: + total = sums[name] if name in entry and entry[name] != total: mismatches.append( f"tier_summary[{tier!r}] {name}: archived {entry[name]!r}, per-call {total}" @@ -401,11 +440,32 @@ def repriced_arm(arm: ArmResult, calls: _ArmCalls, *, withhold_cost: bool) -> Ar ) +def _require_unit_ids(path: Path, payload: Mapping[str, object]) -> None: + """Refuse unless every :data:`UNIT_STAMPED_ENTRY_KINDS` entry names its unit's ids.""" + for kind in UNIT_STAMPED_ENTRY_KINDS: + entries = payload.get(kind) + if not isinstance(entries, list): + raise RepriceRefused(f"{path}: no {kind} list") + for position, entry in enumerate(entries): + if not isinstance(entry, Mapping): + raise RepriceRefused(f"{path}: {kind}[{position}] is not an object") + task_id = entry.get(UNIT_TASK_ID_KEY) + repeat_index = entry.get(UNIT_REPEAT_INDEX_KEY) + if not isinstance(task_id, str) or not task_id: + raise RepriceRefused(f"{path}: {kind}[{position}] carries no {UNIT_TASK_ID_KEY}") + if type(repeat_index) is not int or repeat_index < 0: + raise RepriceRefused( + f"{path}: {kind}[{position}] carries no {UNIT_REPEAT_INDEX_KEY}" + ) + + def _load_pre_aggregation(raw_dir: Path) -> dict[str, tuple[Path, list[object]]]: """Map each pre-aggregation archive's ``model_id`` to its path and attribution entries. Raises: - RepriceRefused: An archive is unreadable or malformed, or two name the same model. + RepriceRefused: An archive is unreadable or malformed, is not + :data:`eval.matrix.RECORD_SHAPE_VERSION`, has a :data:`UNIT_STAMPED_ENTRY_KINDS` entry + without its unit's task id and repeat index, or two name the same model. """ found: dict[str, tuple[Path, list[object]]] = {} for path in sorted((raw_dir / PRE_AGGREGATION_DIRNAME).glob("*.json")): @@ -417,6 +477,12 @@ def _load_pre_aggregation(raw_dir: Path) -> dict[str, tuple[Path, list[object]]] entries = payload.get("invocation_attributions") if isinstance(payload, dict) else None if not isinstance(model_id, str) or not isinstance(entries, list): raise RepriceRefused(f"{path}: no model_id and invocation_attributions list") + version = payload.get(RECORD_SHAPE_VERSION_KEY) + if type(version) is not int or version != RECORD_SHAPE_VERSION: + raise RepriceRefused( + f"{path}: {RECORD_SHAPE_VERSION_KEY} is {version!r}, not {RECORD_SHAPE_VERSION}" + ) + _require_unit_ids(path, payload) if model_id in found: raise RepriceRefused( f"{path} and {found[model_id][0]} both hold pre-aggregation records for {model_id!r}" @@ -536,6 +602,7 @@ def main(argv: Sequence[str] | None = None) -> int: "PRICING_TIER_KEY", "REPRICE_RECORD_FILENAME", "ROUTE_KEY", + "UNIT_STAMPED_ENTRY_KINDS", "RepriceRefused", "attribution_from_entry", "cross_check_archive", diff --git a/src/eval/runs.py b/src/eval/runs.py index c96a00a..00e1f81 100644 --- a/src/eval/runs.py +++ b/src/eval/runs.py @@ -41,7 +41,7 @@ from crm.store import keys from crm.store.store import Store from eval.harness import EvalMode -from eval.matrix import tier_comparison_table +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY, tier_comparison_table from eval.sweep_units import DEFAULT_ARM_EFFORT _logger = logging.getLogger(__name__) @@ -219,6 +219,12 @@ def to_payload(self) -> dict[str, Any]: The execution ARN is not emitted. ``tier_comparison_table`` is the :func:`eval.matrix.tier_comparison_table` of the matrix's ``tier_comparison`` block when the block is a mapping; a block that cannot be formatted is omitted and logged. + + A stored ``matrix_report`` whose top-level ``record_shape_version`` is not + :data:`eval.matrix.RECORD_SHAPE_VERSION` (absent included) is an earlier-format record: the + payload omits ``matrix``, ``tier_comparison_table`` and ``artifacts``, carries + ``record_format: "earlier"``, and one ``eval_record_format_earlier`` line is logged per run id + per process (see :func:`_log_earlier_record_format`). """ payload: dict[str, Any] = { "run_id": self.run_id, @@ -245,14 +251,42 @@ def to_payload(self) -> dict[str, Any]: "estimate_basis": self.estimate_basis, "teardown_status": self.teardown_status, "error": self.failure_summary, - "matrix": self.matrix_report, - "tier_comparison_table": _payload_tier_table(self.run_id, self.matrix_report), - "artifacts": self.artifact_links, } + if _is_earlier_record_format(self.matrix_report): + _log_earlier_record_format(self.run_id) + optional["record_format"] = EARLIER_RECORD_FORMAT + else: + optional["matrix"] = self.matrix_report + optional["tier_comparison_table"] = _payload_tier_table(self.run_id, self.matrix_report) + optional["artifacts"] = self.artifact_links payload.update({key: value for key, value in optional.items() if value is not None}) return payload +#: The payload's ``record_format`` for a run whose stored matrix predates the current record shape. +EARLIER_RECORD_FORMAT: Final[str] = "earlier" + + +#: Run ids this process has already logged ``eval_record_format_earlier`` for. +_EARLIER_FORMAT_LOGGED_RUN_IDS: set[str] = set() + + +def _log_earlier_record_format(run_id: str) -> None: + """Log ``eval_record_format_earlier`` for ``run_id`` unless this process already has.""" + if run_id in _EARLIER_FORMAT_LOGGED_RUN_IDS: + return + _EARLIER_FORMAT_LOGGED_RUN_IDS.add(run_id) + _logger.info(json.dumps({"event": "eval_record_format_earlier", "correlation_id": run_id})) + + +def _is_earlier_record_format(matrix_report: Mapping[str, Any] | None) -> bool: + """True when a stored matrix is present and its top-level record shape is not the current one.""" + if matrix_report is None: + return False + version = matrix_report.get(RECORD_SHAPE_VERSION_KEY) + return type(version) is not int or version != RECORD_SHAPE_VERSION + + #: Longest refusal text an ``eval_tier_table_unavailable`` line carries. _MAX_TIER_TABLE_REASON: Final[int] = 300 diff --git a/src/eval/scoring.py b/src/eval/scoring.py index 211cebb..8d9cef5 100644 --- a/src/eval/scoring.py +++ b/src/eval/scoring.py @@ -47,6 +47,7 @@ from crm.toolspec.definitions import BY_NAME as TOOLS_BY_NAME from crm.toolspec.validation import arguments_conform from eval.tenancy import tenant_for_run +from providers.capabilities import Tier #: Sentinel in a golden task's ``expected_field_changes[i].id`` meaning "locate the row by #: (table, distinguishing field)" rather than a pre-known id. @@ -167,6 +168,8 @@ class TurnOutcome: :class:`crm.errors.ScopeDenied.missing_scope`; ``None`` for every other outcome. budget_exhausted: Whether the turn ended via :func:`agents.events.budget_exhausted_event` rather than completing. + budget_exhausted_tier: The tier that ran the turn out of budget; set exactly when + ``budget_exhausted`` is ``True``. truncated: Whether any dispatched tool call's raw output reported truncation this turn (:func:`eval.harness._tool_output_reports_truncation`). truncation_disclosed: Whether the turn surfaced a truncation notice, via @@ -184,10 +187,20 @@ class TurnOutcome: denial_outcome: str | None = None denial_missing_scope: str | None = None budget_exhausted: bool = False + budget_exhausted_tier: Tier | None = None truncated: bool = False truncation_disclosed: bool = False observed_outcomes: frozenset[str] = field(default_factory=frozenset) + def __post_init__(self) -> None: + """Raise ``ValueError`` unless ``budget_exhausted_tier`` is set iff ``budget_exhausted``.""" + if self.budget_exhausted != (self.budget_exhausted_tier is not None): + raise ValueError( + "budget_exhausted_tier must be set exactly when budget_exhausted is true, got " + f"budget_exhausted={self.budget_exhausted!r}, " + f"budget_exhausted_tier={self.budget_exhausted_tier!r}" + ) + @dataclass(frozen=True, slots=True) class AssertionResult: @@ -226,6 +239,9 @@ class TaskScore: :func:`_check_tool_call_correctness`). truncated: Copied from the scored :class:`TurnOutcome`. budget_exhausted: Copied from the scored :class:`TurnOutcome`. + budget_exhausted_tier: Copied from the scored :class:`TurnOutcome`; set exactly when + ``budget_exhausted`` is ``True``. + repeat_index: The sweep repeat the scored turn ran in, from 0. assertion_results: Every individual assertion checked. """ @@ -237,8 +253,21 @@ class TaskScore: tool_call_correct: bool | None truncated: bool = False budget_exhausted: bool = False + budget_exhausted_tier: Tier | None = None + repeat_index: int = 0 assertion_results: tuple[AssertionResult, ...] = field(default_factory=tuple) + def __post_init__(self) -> None: + """Raise ``ValueError`` on an inconsistent exhaustion tier or a negative repeat index.""" + if self.budget_exhausted != (self.budget_exhausted_tier is not None): + raise ValueError( + "budget_exhausted_tier must be set exactly when budget_exhausted is true, got " + f"budget_exhausted={self.budget_exhausted!r}, " + f"budget_exhausted_tier={self.budget_exhausted_tier!r}" + ) + if isinstance(self.repeat_index, bool) or self.repeat_index < 0: + raise ValueError(f"repeat_index must be a non-negative int, got {self.repeat_index!r}") + def to_report_fields(self) -> dict[str, object]: """Render this score as a flat, JSON-safe mapping for a result artifact. @@ -253,6 +282,8 @@ def to_report_fields(self) -> dict[str, object]: "tool_call_correct": self.tool_call_correct, "truncated": self.truncated, "budget_exhausted": self.budget_exhausted, + "budget_exhausted_tier": self.budget_exhausted_tier, + "repeat_index": self.repeat_index, "assertion_results": [ { "name": result.name, @@ -1171,6 +1202,7 @@ def score_task( task: Mapping[str, Any], outcome: TurnOutcome, pre_turn_values: Mapping[tuple[str, str, str], object] | None = None, + repeat_index: int = 0, ) -> TaskScore: """Score one golden task against one turn's observed outcome. @@ -1301,6 +1333,8 @@ def score_task( tool_call_correct=tool_call_result.passed, truncated=outcome.truncated, budget_exhausted=outcome.budget_exhausted, + budget_exhausted_tier=outcome.budget_exhausted_tier, + repeat_index=repeat_index, assertion_results=tuple(results), ) diff --git a/src/eval/sfn_handlers.py b/src/eval/sfn_handlers.py index e58f964..7c1b70b 100644 --- a/src/eval/sfn_handlers.py +++ b/src/eval/sfn_handlers.py @@ -56,7 +56,7 @@ from dataclasses import dataclass from datetime import datetime from pathlib import Path -from typing import Any, Final, Protocol +from typing import Any, Final, Protocol, cast, get_args from botocore.exceptions import BotoCoreError, ClientError, ReadTimeoutError @@ -140,7 +140,7 @@ deserialise_turn, serialise_turn, ) -from providers.capabilities import load_capability_matrix +from providers.capabilities import Tier, load_capability_matrix from providers.tier_tuning import to_wire _logger = logging.getLogger(__name__) @@ -598,6 +598,9 @@ def _require(condition: bool, field: str) -> None: raise ValidationFailed("A stored task result is unreadable.", source=field) +_TASK_SCORE_TIERS: Final[frozenset[str]] = frozenset(get_args(Tier)) + + def task_score_from_fields(fields: Mapping[str, Any]) -> TaskScore: """The inverse of :meth:`eval.scoring.TaskScore.to_report_fields`. @@ -618,6 +621,20 @@ def task_score_from_fields(fields: Mapping[str, Any]) -> TaskScore: ) for flag in ("bad_write", "truncated", "budget_exhausted"): _require(isinstance(fields.get(flag), bool), f"task_score.{flag}") + exhausted_tier = fields.get("budget_exhausted_tier") + _require( + exhausted_tier is None or exhausted_tier in _TASK_SCORE_TIERS, + "task_score.budget_exhausted_tier", + ) + _require( + fields["budget_exhausted"] == (exhausted_tier is not None), + "task_score.budget_exhausted_tier", + ) + repeat_index = fields.get("repeat_index") + _require( + isinstance(repeat_index, int) and not isinstance(repeat_index, bool) and repeat_index >= 0, + "task_score.repeat_index", + ) _require( fields.get("tool_call_correct") is None or isinstance(fields.get("tool_call_correct"), bool), @@ -649,6 +666,8 @@ def task_score_from_fields(fields: Mapping[str, Any]) -> TaskScore: tool_call_correct=fields.get("tool_call_correct"), truncated=bool(fields["truncated"]), budget_exhausted=bool(fields["budget_exhausted"]), + budget_exhausted_tier=cast(Tier | None, exhausted_tier), + repeat_index=cast(int, repeat_index), assertion_results=tuple(results), ) @@ -722,17 +741,23 @@ def turn_from_row(row: Mapping[str, object]) -> ObservedTurn: def unit_from_row( - row: Mapping[str, object], *, task: Mapping[str, object], arm_spec: ArmSpec + row: Mapping[str, object], + *, + task: Mapping[str, object], + arm_spec: ArmSpec, + repeat_index: int, ) -> TaskUnitResult: """Rebuild one ``done`` item's :class:`eval.sweep_units.TaskUnitResult` from its stored row. - Usage records are re-derived from the stored invocations, as :func:`run_task_unit` derives them. + ``repeat_index`` is the item's repeat, from its :class:`eval.sweep_units.TaskRef`. Usage + records are re-derived from the stored invocations, as :func:`run_task_unit` derives them. """ turn = turn_from_row(row) task_score = task_score_from_fields(_json_field(row, "task_score")) task_id = task_score.task_id return TaskUnitResult( task_id=task_id, + repeat_index=repeat_index, task_score=task_score, tier_scores=tier_scores_from_fields(_json_field(row, "tier_scores")), turn=turn, @@ -918,6 +943,7 @@ def _aggregate( row, task=_task_by_id(_unit_tasks(run_id, ref), ref.task_id), arm_spec=DEFAULT_ARM_SPECS[ref.arm_index], + repeat_index=ref.repeat_index, ) ) if unrecorded: @@ -1442,7 +1468,12 @@ def _turn_runner(unit_task: Mapping[str, object], unit_tenant: str) -> ObservedT return _invoke_eval_turn(runtime, config, request) unit = run_task_unit( - store=store, task=task, tenant=tenant, family=arm_spec.family, turn_runner=_turn_runner + store=store, + task=task, + tenant=tenant, + family=arm_spec.family, + turn_runner=_turn_runner, + repeat_index=ref.repeat_index, ) digest = unit.turn.prompt_bundle_sha256 if run_bundle.reference_found and digest != run_bundle.reference: diff --git a/src/eval/sweep_units.py b/src/eval/sweep_units.py index ff09abf..70d8f64 100644 --- a/src/eval/sweep_units.py +++ b/src/eval/sweep_units.py @@ -29,6 +29,8 @@ from eval.matrix import ( ARM_COST_TOTAL_KEY, ARM_LONG_CONTEXT_INVOCATION_COUNT_KEY, + RECORD_SHAPE_VERSION, + RECORD_SHAPE_VERSION_KEY, ArmResult, RunProvenance, ) @@ -65,6 +67,7 @@ from eval.turn_observation import ObservedTurn from providers.base import Tuning, validate_tuning from providers.capabilities import CapabilityMatrix, Family, Tier +from providers.prompt_caching import CACHING from providers.tier_tuning import TurnTuning EvalMode = Literal["stub", "live"] @@ -110,6 +113,13 @@ class ArmRunResult: aggregate_score: AggregateScore +#: The key naming the owning unit's task on every pre-aggregation per-call entry. +UNIT_TASK_ID_KEY: Final[str] = "task_id" + +#: The key naming the owning unit's repeat on every pre-aggregation per-call entry. +UNIT_REPEAT_INDEX_KEY: Final[str] = "repeat_index" + + @dataclass(frozen=True, slots=True) class TaskRef: """One cell of the sweep grid. @@ -131,6 +141,7 @@ class TaskUnitResult: Attributes: task_id: The golden task's ``id``. + repeat_index: The repeat the unit ran in, from 0. task_score: The :func:`eval.scoring.score_task` result. tier_scores: The :func:`eval.scoring.score_tiers` result. turn: The observed turn the scores were computed from. @@ -138,6 +149,7 @@ class TaskUnitResult: """ task_id: str + repeat_index: int task_score: TaskScore tier_scores: TierScores turn: ObservedTurn @@ -280,6 +292,7 @@ def run_task_unit( tenant: str, family: Family, turn_runner: TurnRunner, + repeat_index: int, ) -> TaskUnitResult: """Run, score and meter one golden task. @@ -289,6 +302,7 @@ def run_task_unit( tenant: The eval tenant the turn ran in. family: The arm's family, recorded on each usage record. turn_runner: Produces the task's observed turn. + repeat_index: The repeat the unit runs in, from 0, carried onto the result. Raises: ValueError: The task carries no usable ``actor`` block. @@ -297,9 +311,16 @@ def run_task_unit( task_id = _task_id(task) pre_turn_values = capture_pre_turn_values(store, task=task, tenant=tenant) turn = turn_runner(task, tenant) - task_score = score_task(store, task=task, outcome=turn.outcome, pre_turn_values=pre_turn_values) + task_score = score_task( + store, + task=task, + outcome=turn.outcome, + pre_turn_values=pre_turn_values, + repeat_index=repeat_index, + ) return TaskUnitResult( task_id=task_id, + repeat_index=repeat_index, task_score=task_score, tier_scores=_tier_scores(task, turn, task_score), turn=turn, @@ -309,23 +330,43 @@ def run_task_unit( ) +def _unit_entries( + units: Sequence[TaskUnitResult], + records: Callable[[TaskUnitResult], Sequence[InvocationAttribution | ToolCallAttribution]], +) -> list[dict[str, object]]: + """Every unit's records as dicts, each stamped with its unit's task id and repeat index.""" + return [ + { + **asdict(record), + UNIT_TASK_ID_KEY: unit.task_id, + UNIT_REPEAT_INDEX_KEY: unit.repeat_index, + } + for unit in units + for record in records(unit) + ] + + def _raw_arm_records_payload( *, model_id: str, mode: EvalMode, - attributions: Sequence[InvocationAttribution], - tool_calls: Sequence[ToolCallAttribution], + units: Sequence[TaskUnitResult], task_scores: Sequence[TaskScore], correctness_by_task: Mapping[str, Sequence[float]], task_latencies_ms: Sequence[float], call_samples: Sequence[CallLatencySample], ) -> dict[str, object]: - """A JSON-safe snapshot of one arm's raw per-run records, taken before aggregation.""" + """A JSON-safe snapshot of one arm's raw per-run records, taken before aggregation. + + Every ``invocation_attributions`` and ``tool_call_attributions`` entry carries + :data:`UNIT_TASK_ID_KEY` and :data:`UNIT_REPEAT_INDEX_KEY` from the unit that produced it. + """ return { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "model_id": model_id, "mode": mode, - "invocation_attributions": [asdict(a) for a in attributions], - "tool_call_attributions": [asdict(t) for t in tool_calls], + "invocation_attributions": _unit_entries(units, lambda unit: unit.turn.invocations), + "tool_call_attributions": _unit_entries(units, lambda unit: unit.turn.tool_calls), "task_scores": [asdict(s) for s in task_scores], "correctness_by_task": { task_id: list(values) for task_id, values in correctness_by_task.items() @@ -472,8 +513,7 @@ def assemble_arm( _raw_arm_records_payload( model_id=resolved.model.model_id, mode=mode, - attributions=all_attributions, - tool_calls=all_tool_calls, + units=units, task_scores=task_scores, correctness_by_task=correctness_by_task, task_latencies_ms=task_latencies_ms, @@ -500,6 +540,7 @@ def assemble_arm( delegation_outcome=unit.turn.outcome.denial_outcome, resolved_efforts=unit.turn.resolved_efforts, tool_calls=unit.turn.tool_calls, + budget_exhausted_tier=unit.turn.outcome.budget_exhausted_tier, ) for unit in units ], @@ -521,6 +562,7 @@ def assemble_arm( price_table_version=price_table_version, answer_style_sha256=answer_style_prompt_sha256(), prompt_bundle_sha256=next(iter(bundle_digests), None), + prompt_caching=CACHING[arm_spec.family], ) arm_result = ArmResult( provenance=provenance, @@ -560,6 +602,8 @@ def assemble_arm( "TaskRef", "TaskUnitResult", "TurnRunner", + "UNIT_REPEAT_INDEX_KEY", + "UNIT_TASK_ID_KEY", "arm_tuning", "arm_turn_tuning", "assemble_arm", diff --git a/src/eval/turn_observation.py b/src/eval/turn_observation.py index 1307189..fd010ed 100644 --- a/src/eval/turn_observation.py +++ b/src/eval/turn_observation.py @@ -20,6 +20,7 @@ from typing import Any, Final, Protocol, cast, get_args, runtime_checkable from agents.budget import EVAL_BUDGET +from agents.events import TOOL_OUTPUT_TRUNCATED_KEY, bound_tool_output from agents.registry import RegisteredTool from agents.supervisor import classify_tool_result, describe_truncation from agents.tier_attribution import ( @@ -40,11 +41,7 @@ from providers.tier_tuning import TurnTuning #: Version of the :func:`serialise_turn` wire shape. -SERIALISED_TURN_SCHEMA: Final[int] = 2 - -#: The tool-result payload key a bounded read sets to report truncation; the same value as -#: :data:`agents.supervisor._SEARCH_TRUNCATED_KEY`. -TOOL_OUTPUT_TRUNCATED_KEY: Final[str] = "truncated" +SERIALISED_TURN_SCHEMA: Final[int] = 3 def tool_output_reports_truncation(tool_output: Mapping[str, object]) -> bool: @@ -86,16 +83,21 @@ def __init__(self, base: ToolDispatch) -> None: self._truncation_disclosed = False def __call__(self, tool: RegisteredTool, tool_input: dict[str, object]) -> dict[str, Any]: - """Dispatch one tool call and record its effects; returns the output unchanged.""" + """Dispatch one tool call and record its effects; returns the output unchanged. + + Truncation is observed on the copy :func:`agents.events.bound_tool_output` makes, the + bound every dispatch path applies before the model sees a result. + """ self._tool_arguments.append( ObservedToolArguments(tool_name=tool.name, arguments=dict(tool_input)) ) tool_output = self._base(tool, tool_input) tool_name = tool.name - if tool_output_reports_truncation(tool_output): + bounded_output, bound_truncated = bound_tool_output(tool_output) + if tool_output_reports_truncation(bounded_output): self._truncated = True - if describe_truncation(tool_output, event_truncated=False) is not None: + if describe_truncation(bounded_output, event_truncated=bound_truncated) is not None: self._truncation_disclosed = True self._tool_calls.append( @@ -157,6 +159,7 @@ def outcome( *, tenant: str, budget_exhausted: bool, + budget_exhausted_tier: Tier | None = None, tool_calls: Sequence[ToolCallAttribution] = (), ) -> TurnOutcome: """Build the turn's :class:`eval.scoring.TurnOutcome` from everything observed so far. @@ -195,6 +198,7 @@ def outcome( denial_outcome=denial_outcome, denial_missing_scope=self._denial_missing_scope, budget_exhausted=budget_exhausted, + budget_exhausted_tier=budget_exhausted_tier, truncated=self._truncated, truncation_disclosed=self._truncation_disclosed, observed_outcomes=frozenset(self._observed_outcomes), @@ -359,7 +363,10 @@ def counted(family: Family) -> ModelProvider: ] return ObservedTurn( outcome=observing.outcome( - tenant=tenant, budget_exhausted=budget_exhausted, tool_calls=records.tool_calls + tenant=tenant, + budget_exhausted=budget_exhausted, + budget_exhausted_tier=records.budget_exhausted_tier, + tool_calls=records.tool_calls, ), tool_arguments=observing.tool_arguments, invocations=tuple(records.invocations), @@ -408,6 +415,7 @@ def serialise_turn(turn: ObservedTurn) -> dict[str, Any]: "denial_outcome": outcome.denial_outcome, "denial_missing_scope": outcome.denial_missing_scope, "budget_exhausted": outcome.budget_exhausted, + "budget_exhausted_tier": outcome.budget_exhausted_tier, "truncated": outcome.truncated, "truncation_disclosed": outcome.truncation_disclosed, "observed_outcomes": sorted(outcome.observed_outcomes), @@ -554,6 +562,7 @@ def _outcome(raw: object) -> TurnOutcome: "denial_outcome", "denial_missing_scope", "budget_exhausted", + "budget_exhausted_tier", "truncated", "truncation_disclosed", "observed_outcomes", @@ -582,6 +591,9 @@ def _outcome(raw: object) -> TurnOutcome: labels = reader.array("observed_outcomes") if not all(isinstance(label, str) for label in labels): raise ValueError("outcome.observed_outcomes must be an array of strings") + exhausted_tier = reader.optional_string("budget_exhausted_tier") + if exhausted_tier is not None and exhausted_tier not in _TIERS: + raise ValueError(f"outcome.budget_exhausted_tier names an unknown tier {exhausted_tier!r}") return TurnOutcome( tenant=reader.string("tenant"), tool_calls=tuple(tool_calls), @@ -589,6 +601,7 @@ def _outcome(raw: object) -> TurnOutcome: denial_outcome=reader.optional_string("denial_outcome"), denial_missing_scope=reader.optional_string("denial_missing_scope"), budget_exhausted=reader.boolean("budget_exhausted"), + budget_exhausted_tier=cast(Tier | None, exhausted_tier), truncated=reader.boolean("truncated"), truncation_disclosed=reader.boolean("truncation_disclosed"), observed_outcomes=frozenset(cast("list[str]", labels)), @@ -618,8 +631,9 @@ def deserialise_turn(payload: Mapping[str, Any]) -> ObservedTurn: Raises: ValueError: ``payload`` is not exactly the :data:`SERIALISED_TURN_SCHEMA` shape: a key is - missing or extra, a value has the wrong type, or an attribution fails its own - validation. + missing or extra, a value has the wrong type, ``outcome.budget_exhausted_tier`` names + no tier or is not set exactly when ``outcome.budget_exhausted`` is true, or an + attribution fails its own validation. """ body = dict(payload) if isinstance(payload, Mapping) else payload usage_lower_bound = False diff --git a/src/eval/verification.py b/src/eval/verification.py index c63bf54..ef064a3 100644 --- a/src/eval/verification.py +++ b/src/eval/verification.py @@ -67,7 +67,7 @@ def _run_git(*arguments: str) -> str | None: timeout=_GIT_TIMEOUT_SECONDS, check=False, ) - except (OSError, subprocess.SubprocessError): + except OSError, subprocess.SubprocessError: return None if completed.returncode != 0: return None diff --git a/src/providers/anthropic_adapter.py b/src/providers/anthropic_adapter.py index bc8009f..0aed294 100644 --- a/src/providers/anthropic_adapter.py +++ b/src/providers/anthropic_adapter.py @@ -54,7 +54,7 @@ ResolvedInvocation, guard_invocation_family, ) -from providers.prompt_caching import breakpoint_index +from providers.prompt_caching import breakpoint_index, latest_message_index, select_cache_points from providers.sdk_transport import ( MODEL_CALL_DEADLINE_SECONDS, CredentialPolicyError, @@ -253,12 +253,21 @@ def build_request( ``stream`` is not included; the caller adds it. """ - cache_at = breakpoint_index(invocation.model.model_id, messages, tools) - system_prompt, conversation = _split_system(messages, cache_at=cache_at) + model_id = invocation.model.model_id + system_at = breakpoint_index(model_id, messages, tools) + points = select_cache_points( + (), latest=latest_message_index(model_id, messages, tools), system=system_at + ) + system_prompt, conversation = _split_system( + messages, cache_at=system_at if system_at in points else None + ) request: dict[str, Any] = { "model": invocation.model.inference_profile, "max_tokens": MAX_OUTPUT_TOKENS, - "messages": [_to_messages_api_turn(message) for message in conversation], + "messages": [ + _to_messages_api_turn(message, cache_point=index in points) + for index, message in conversation + ], } if system_prompt is not None: request["system"] = system_prompt @@ -360,16 +369,16 @@ def _split_system( messages: list[dict[str, object]], *, cache_at: int | None = None, -) -> tuple[str | list[dict[str, Any]] | None, list[dict[str, object]]]: +) -> tuple[str | list[dict[str, Any]] | None, list[tuple[int, dict[str, object]]]]: """Lift ``system``-role messages into the top-level system prompt, in order. The Messages API rejects a ``system`` role inside ``messages``; ``user``/``assistant``/``tool`` - turns pass through untouched. With ``cache_at`` (a message index from + turns pass through untouched, each paired with its seam index. With ``cache_at`` (a message index from :func:`providers.prompt_caching.breakpoint_index`) the prompt is a list of text blocks and that message's block carries ``cache_control``; otherwise the parts are joined into one string. """ blocks: list[dict[str, Any]] = [] - conversation: list[dict[str, object]] = [] + conversation: list[tuple[int, dict[str, object]]] = [] for index, message in enumerate(messages): content = message.get("content") if message.get("role") == "system" and isinstance(content, str) and content: @@ -378,7 +387,7 @@ def _split_system( block["cache_control"] = {"type": "ephemeral"} blocks.append(block) else: - conversation.append(message) + conversation.append((index, message)) if not blocks: return None, conversation if cache_at is None: @@ -386,12 +395,37 @@ def _split_system( return blocks, conversation -def _to_messages_api_turn(message: dict[str, object]) -> dict[str, Any]: +def _to_messages_api_turn( + message: dict[str, object], *, cache_point: bool = False +) -> dict[str, Any]: """Translate one seam message into a Messages API turn. An ``assistant`` turn with ``tool_calls`` becomes ``tool_use`` blocks, and a ``tool`` turn with - ``tool_results`` becomes a ``user`` turn of ``tool_result`` blocks. + ``tool_results`` becomes a ``user`` turn of ``tool_result`` blocks. With ``cache_point`` the + turn's last content block carries ``cache_control``. + """ + turn = _translate_turn(message) + return _with_cache_point(turn) if cache_point else turn + + +def _with_cache_point(turn: dict[str, Any]) -> dict[str, Any]: + """Return ``turn`` with ``cache_control`` on its last content block, leaving ``turn`` unchanged. + + String content becomes one text block; empty content is returned without a point. """ + content = turn["content"] + if isinstance(content, str) and content: + blocks: list[dict[str, Any]] = [{"type": "text", "text": content}] + elif isinstance(content, list) and content and isinstance(content[-1], dict): + blocks = [*content[:-1], dict(content[-1])] + else: + return turn + blocks[-1]["cache_control"] = {"type": "ephemeral"} + return {**turn, "content": blocks} + + +def _translate_turn(message: dict[str, object]) -> dict[str, Any]: + """Translate one seam message into a Messages API turn without any cache point.""" tool_calls = message.get("tool_calls") if message.get("role") == "assistant" and isinstance(tool_calls, list): content: list[dict[str, Any]] = [] diff --git a/src/providers/prompt_caching.py b/src/providers/prompt_caching.py index a1143da..4f4977e 100644 --- a/src/providers/prompt_caching.py +++ b/src/providers/prompt_caching.py @@ -5,12 +5,16 @@ part of the prompt bundle (:mod:`agents.prompt_bundle`), so changing a mechanism changes the bundle digest recorded in eval provenance. -Both families keep the platform's implicit caching and place at most one explicit breakpoint, at -the end of the stable prefix: the tool -definitions plus the leading run of system messages up to, not including, the first one marked -``{CACHE_SCOPE_KEY: VOLATILE}`` (for example a per-page briefing). :func:`breakpoint_index` picks -that message, or ``None`` when there is no stable system message or the prefix cannot reach the -model's ``prompt_cache_min_checkpoint_tokens`` in ``config/model_capabilities.yaml``. +Both families keep the platform's implicit caching and place one explicit breakpoint at the end of +the stable prefix: the tool definitions plus the leading run of system messages up to, not +including, the first one marked ``{CACHE_SCOPE_KEY: VOLATILE}`` (for example a per-page briefing). +:func:`breakpoint_index` picks that message, or ``None`` when there is no stable system message or +the prefix cannot reach the model's ``prompt_cache_min_checkpoint_tokens`` in +``config/model_capabilities.yaml``. + +The Anthropic adapter also places a point on the latest message (:func:`latest_message_index`), as +the OpenAI platform's implicit caching does, and keeps the request within +:data:`ANTHROPIC_MAX_CACHE_POINTS` through :func:`select_cache_points`. """ from __future__ import annotations @@ -43,8 +47,9 @@ { "anthropic": ( "explicit: cache_control {type: ephemeral} (5-minute TTL) on the last stable system " - "block, beside the platform's implicit caching, which no request field turns off; " - "minimum prefix from prompt_cache_min_checkpoint_tokens" + "block and on the last content block of the latest message, at most 4 points, each " + "omitted when its cumulative prefix is below prompt_cache_min_checkpoint_tokens; " + "beside the platform's implicit caching, which no request field turns off" ), "openai": ( "explicit: prompt_cache_breakpoint {mode: explicit} on the last stable system " @@ -55,6 +60,9 @@ } ) +#: Most ``cache_control`` points one Messages API request may carry. +ANTHROPIC_MAX_CACHE_POINTS: Final[int] = 4 + #: The ``prompt_cache_options`` body field the OpenAI adapter sends on every Responses request. OPENAI_PROMPT_CACHE_OPTIONS: Final[Mapping[str, str]] = MappingProxyType( {"mode": "implicit", "ttl": "30m"} @@ -103,12 +111,81 @@ def breakpoint_index( return end +def latest_message_index( + model_id: str, + messages: Sequence[Mapping[str, object]], + tools: Sequence[Mapping[str, object]], +) -> int | None: + """Return the index of the last non-system message when the cumulative prefix through it can + reach the model's minimum; ``None`` otherwise or when there is no non-system message. + + The prefix is the tool definitions plus every message up to and including that one, text and + tool calls and results alike. + """ + latest = next( + ( + index + for index in reversed(range(len(messages))) + if messages[index].get("role") != "system" + ), + None, + ) + if latest is None: + return None + minimum = min_prefix_tokens(model_id) + if minimum is None: + return None + characters = len(json.dumps(list(tools), sort_keys=True)) + sum( + _message_characters(message) for message in messages[: latest + 1] + ) + if characters < minimum * _CHARS_PER_TOKEN_FLOOR: + return None + return latest + + +def select_cache_points( + candidates: Sequence[int], + *, + latest: int | None, + system: int | None, + limit: int = ANTHROPIC_MAX_CACHE_POINTS, +) -> tuple[int, ...]: + """Return at most ``limit`` cache-point indices, sorted ascending. + + ``latest`` and ``system`` are kept even when absent from ``candidates``. Priority is ``latest``, + then ``system``, then the remaining candidates most recent first; the oldest are dropped. + + Raises: + ValueError: When ``limit`` is negative. + """ + if limit < 0: + raise ValueError(f"limit must be non-negative, got {limit}") + ordered: list[int] = [] + for index in (latest, system, *sorted(candidates, reverse=True)): + if index is not None and index not in ordered: + ordered.append(index) + return tuple(sorted(ordered[:limit])) + + +def _message_characters(message: Mapping[str, object]) -> int: + """Characters one seam message contributes to a prefix: its text plus any tool calls/results.""" + characters = len(str(message.get("content") or "")) + for key in ("tool_calls", "tool_results"): + value = message.get(key) + if isinstance(value, list): + characters += len(json.dumps(value, sort_keys=True)) + return characters + + __all__ = [ + "ANTHROPIC_MAX_CACHE_POINTS", "CACHE_SCOPE_KEY", "CACHING", "OPENAI_PROMPT_CACHE_OPTIONS", "VOLATILE", "breakpoint_index", + "latest_message_index", "min_prefix_tokens", + "select_cache_points", "stable_system_end", ] diff --git a/src/providers/sdk_transport.py b/src/providers/sdk_transport.py index 2ccbaa0..6284d30 100644 --- a/src/providers/sdk_transport.py +++ b/src/providers/sdk_transport.py @@ -20,9 +20,9 @@ * :func:`require_credentials` resolves the credential chain once before the SDK call and raises :class:`CredentialPolicyError` when it is empty. * :func:`anthropic_client_kwargs` / :func:`openai_client_kwargs` are the only way to assemble the SDK - constructor arguments. They refuse the SDKs' bearer and base-URL environment fallbacks, pin an - explicit ``bedrock-runtime`` base URL, have no ``api_key`` field, and switch the Anthropic SDK's - OpenTelemetry tracing off. After constructing the client, pass it to :func:`assert_runtime_client`. + constructor arguments. They refuse the SDKs' bearer, base-URL and header environment variables, + pin an explicit ``bedrock-runtime`` base URL, have no ``api_key`` field, and switch the Anthropic + SDK's OpenTelemetry tracing off. After constructing the client, pass it to :func:`assert_runtime_client`. * :func:`session_credentials_provider` adapts a ``boto3`` session to the OpenAI SDK's ``aws_credentials_provider``, resolving credentials on every signed request. @@ -58,7 +58,7 @@ import os import re import time -from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable, Iterator +from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable, Iterator, Mapping from contextlib import asynccontextmanager, contextmanager from contextvars import ContextVar from dataclasses import dataclass, field, replace @@ -84,18 +84,21 @@ #: The SDK retry count. MAX_RETRIES: Final[int] = 2 -#: Environment variables that would make an SDK authenticate with a bearer token or address a -#: non-``bedrock-runtime`` endpoint. Their mere presence refuses client construction. +#: Environment variables that would make an SDK authenticate with a bearer token, address a +#: non-``bedrock-runtime`` endpoint, or add request headers (``ANTHROPIC_CUSTOM_HEADERS``, merged +#: into the Anthropic Bedrock client's default headers). Their mere presence refuses client +#: construction. FORBIDDEN_ENV_VARS: Final[tuple[str, ...]] = ( "AWS_BEARER_TOKEN_BEDROCK", "AWS_BEDROCK_BASE_URL", "ANTHROPIC_BEDROCK_BASE_URL", + "ANTHROPIC_CUSTOM_HEADERS", ) RETRY_COUNT_HEADER: Final[str] = "x-stainless-retry-count" -#: The Anthropic Bedrock signer deletes ``connection`` from its signing copy and raises -#: ``KeyError`` when it is absent, so that client alone sends it, unsigned. +#: The Anthropic Bedrock client's complete default headers. Its signer leaves ``connection`` out of +#: the signature, so that client alone sends it, unsigned. ANTHROPIC_DEFAULT_HEADERS: Final[dict[str, str]] = {"Connection": "keep-alive"} OPENAI_PATH: Final[str] = "/openai/v1" @@ -342,7 +345,7 @@ def runtime_base_url(region: str) -> str: def assert_no_bearer_or_mantle(base_url: str, *, region: str) -> None: - """Refuse the SDKs' bearer/base-URL environment fallbacks and any non-runtime endpoint. + """Refuse the SDKs' bearer/base-URL/header environment variables and any non-runtime endpoint. Args: base_url: The base URL about to be handed to (or already resolved by) an SDK client. @@ -356,7 +359,8 @@ def assert_no_bearer_or_mantle(base_url: str, *, region: str) -> None: for name in FORBIDDEN_ENV_VARS: if name in os.environ: raise CredentialPolicyError( - f"{name} is set; Bedrock access is IAM/SigV4 on bedrock-runtime only.", + f"{name} is set; Bedrock access is IAM/SigV4 on bedrock-runtime only, and no " + "environment variable shapes a request.", source=name, ) url = httpx2.URL(base_url) @@ -405,8 +409,8 @@ def anthropic_client_kwargs( Credentials come from the SDK's own ``boto3.Session(profile_name=profile, region_name=region)``, re-read on every signed request so refreshable (role) credentials stay current. Static keys are - never passed. :data:`ANTHROPIC_DEFAULT_HEADERS` restores the ``Connection`` header the SDK's - signer requires; it is excluded from the signature. + never passed. :data:`ANTHROPIC_DEFAULT_HEADERS` sets the ``Connection`` header, which the SDK's + signer excludes from the signature. Args: region: The region to sign for and address. @@ -473,7 +477,9 @@ def assert_runtime_client(client: object, *, region: str) -> None: empty string included, so it must hold ``None``, and its OpenTelemetry traces must be disabled. The OpenAI client always holds ``""`` under SigV4, so it must hold a falsy key, and its own ``_uses_aws_auth()`` must report SigV4; that predicate is false for a ``bedrock_token_provider`` - client, whose key is also ``""``. A client lacking the predicate is refused. + client, whose key is also ``""``. A client lacking the predicate is refused. An Anthropic + client's default headers must be exactly :data:`ANTHROPIC_DEFAULT_HEADERS`, so a header the + SDK merged in from the environment at construction is refused. Args: client: An ``AsyncAnthropicBedrock`` or ``AsyncBedrockOpenAI`` instance (or a sync twin). @@ -483,7 +489,9 @@ def assert_runtime_client(client: object, *, region: str) -> None: CredentialPolicyError: When ``client`` is neither SDK's Bedrock client (``source="client"``), holds a bearer ``api_key`` (``source="api_key"``), is an OpenAI client not on SigV4 (``source="auth_mode"``), is an Anthropic client with traces enabled - (``source="open_telemetry"``), or its resolved ``base_url`` fails + (``source="open_telemetry"``), is an Anthropic client carrying any default header + beyond :data:`ANTHROPIC_DEFAULT_HEADERS` (``source="default_headers"``), or its + resolved ``base_url`` fails :func:`assert_no_bearer_or_mantle`. """ names = {cls.__name__ for cls in type(client).__mro__} @@ -502,6 +510,14 @@ def assert_runtime_client(client: object, *, region: str) -> None: raise CredentialPolicyError( "SDK client has OpenTelemetry traces enabled.", source="open_telemetry" ) + custom_headers = getattr(client, "_custom_headers", None) + if not isinstance(custom_headers, Mapping) or dict(custom_headers) != dict( + ANTHROPIC_DEFAULT_HEADERS + ): + raise CredentialPolicyError( + "SDK client carries default headers beyond the transport's own.", + source="default_headers", + ) else: uses_aws_auth = getattr(client, "_uses_aws_auth", None) if not callable(uses_aws_auth) or uses_aws_auth() is not True: @@ -581,7 +597,7 @@ def session_credentials_provider(session: _CredentialSession) -> Callable[[], ob * OpenAI: ``openai.OpenAIError`` whose ``__cause__`` is the :class:`CredentialPolicyError`; :func:`credential_policy_cause` recovers it. * Anthropic (which resolves through its own ``boto3`` session, not this callable): a bare - ``RuntimeError("could not resolve credentials from session")`` from the request signer, + ``RuntimeError("Could not resolve AWS credentials from session")`` from the request signer, outside the SDK's error types. :func:`require_credentials` before the call makes both unreachable for an empty chain. diff --git a/src/relay/package-lock.json b/src/relay/package-lock.json index 8456b80..7e93437 100644 --- a/src/relay/package-lock.json +++ b/src/relay/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@aws-sdk/client-bedrock-agentcore": "3.1163.0", - "@aws-sdk/client-ssm": "3.1163.0", + "@aws-sdk/client-bedrock-agentcore": "3.1167.0", + "@aws-sdk/client-ssm": "3.1167.0", "aws-jwt-verify": "5.2.1" }, "devDependencies": { @@ -24,18 +24,18 @@ } }, "node_modules/@aws-sdk/client-bedrock-agentcore": { - "version": "3.1163.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-bedrock-agentcore/-/client-bedrock-agentcore-3.1163.0.tgz", - "integrity": "sha512-DqV/F2LKbAv+8EiFcjJ7j2xxwVQwL3RbFVhfI2ZKvJaPNLDhBQuiW0ILzmI94iTIClKka9d3Dmvn6wmHFmYZSQ==", + "version": "3.1167.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-bedrock-agentcore/-/client-bedrock-agentcore-3.1167.0.tgz", + "integrity": "sha512-8qp3s4xiZrRE1dK3zy/dP9xm34uUTg/USkDzo1U5U6ub1vC4CvTRXg7y907WywueOGF9g5Y7mHgS9rTP10C6sg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/credential-provider-node": "^3.972.93", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/fetch-http-handler": "^5.8.0", - "@smithy/node-http-handler": "^4.14.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/credential-provider-node": "^3.972.97", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -43,18 +43,18 @@ } }, "node_modules/@aws-sdk/client-ssm": { - "version": "3.1163.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-ssm/-/client-ssm-3.1163.0.tgz", - "integrity": "sha512-IsYFhnlm3joRTShEzO31jmWzVqCVo9C0wbDAH36rpRKs8rp5wf68Zb1uTRu34RoQ+XRKrFDRREf5oSYc1L6mWg==", + "version": "3.1167.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-ssm/-/client-ssm-3.1167.0.tgz", + "integrity": "sha512-y7oFX6o+FLJoJBsOTJEmGZp9J+zjfurhfTXQ8oht3YXvLD2yls+6+TMx5Kbux40UtNNo1Ss/x4PDWwFw4CkEMA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/credential-provider-node": "^3.972.93", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/fetch-http-handler": "^5.8.0", - "@smithy/node-http-handler": "^4.14.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/credential-provider-node": "^3.972.97", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -62,17 +62,17 @@ } }, "node_modules/@aws-sdk/core": { - "version": "3.980.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.980.0.tgz", - "integrity": "sha512-2RVSP/SsPS8HSPPzIPWNYFnSmlOdxx8VDlt5gDOuMaq9UiIi35pUyo6ZEuJcysjVCu0L8Lv5dJevLLpEkyF0/Q==", + "version": "3.981.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.981.0.tgz", + "integrity": "sha512-Mnu7gaDrC5UCdyH8uLxLfB2eWbjE/HbjKX1U1J2VQxG3TTATUDObW2wU3I8iH3e9YH5NN2CY6w1mlAIe2XJ3jg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.975.0", - "@aws-sdk/xml-builder": "^3.972.42", + "@aws-sdk/types": "^3.975.1", + "@aws-sdk/xml-builder": "^3.972.43", "@aws/lambda-invoke-store": "^0.3.0", - "@smithy/core": "^3.38.0", + "@smithy/core": "^3.40.0", "@smithy/signature-v4": "^5.7.5", - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "bowser": "^2.11.0", "tslib": "^2.6.2" }, @@ -81,15 +81,15 @@ } }, "node_modules/@aws-sdk/credential-provider-env": { - "version": "3.972.81", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.81.tgz", - "integrity": "sha512-VD+EVZ9UHNZhSm4KtakXZAPzgfOw4mRx66dAXNUtHcdJUisbsE7kpi1PRZFMquvuqVfx52fCDBgJgYyOFT/4hQ==", + "version": "3.972.84", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.84.tgz", + "integrity": "sha512-akZJetiMVeLRHsKzYh3LamDCo74ZUCeo0XoyRKMEMZT5qP7ReM6LhpioBCyuqKP5Vav5gEOeCmaQV0VVQr1Meg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -97,17 +97,17 @@ } }, "node_modules/@aws-sdk/credential-provider-http": { - "version": "3.972.83", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.83.tgz", - "integrity": "sha512-NsLT02HXcWAQAgpuDJznoJDPIDH/Hh2LiQVlYc+1bVGsksEUZuYCMKa1E1L5qvzc5LLTphp7BP9LYVIhf+MbQA==", + "version": "3.972.86", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.86.tgz", + "integrity": "sha512-U4mHaDRPWAn63yhl7FXIzbppNmW1F+4dSLeuiUpej2v3Xb6rGwvayEJ8SdlrdMV+/mZtd+GStTEP2HqurEzXtw==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/fetch-http-handler": "^5.8.0", - "@smithy/node-http-handler": "^4.14.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -115,23 +115,23 @@ } }, "node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.973.26", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.26.tgz", - "integrity": "sha512-vRydnN8wPqh5APe5R+/y4/UOts7QQQQP1UTczJq3fLcLzkQblbkYpLn+Srr8w9S/gzXU1pbiPKTv479unRawAA==", + "version": "3.973.30", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.30.tgz", + "integrity": "sha512-r6r6499GWoGN943NA5YEhBEQ6TEOGTf7tTOBhHd/zw0UbNvSzd1/zPCNcDkPmRarA+e24X7KgxutqxjoWcskBg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/credential-provider-env": "^3.972.81", - "@aws-sdk/credential-provider-http": "^3.972.83", - "@aws-sdk/credential-provider-login": "^3.972.88", - "@aws-sdk/credential-provider-process": "^3.972.81", - "@aws-sdk/credential-provider-sso": "^3.973.25", - "@aws-sdk/credential-provider-web-identity": "^3.972.87", - "@aws-sdk/nested-clients": "^3.998.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/credential-provider-env": "^3.972.84", + "@aws-sdk/credential-provider-http": "^3.972.86", + "@aws-sdk/credential-provider-login": "^3.972.92", + "@aws-sdk/credential-provider-process": "^3.972.84", + "@aws-sdk/credential-provider-sso": "^3.973.28", + "@aws-sdk/credential-provider-web-identity": "^3.972.90", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", "@smithy/credential-provider-imds": "^4.5.2", - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -139,16 +139,16 @@ } }, "node_modules/@aws-sdk/credential-provider-login": { - "version": "3.972.88", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.88.tgz", - "integrity": "sha512-J8IcBpuFj3j3RImHq/dVO5HtnUbFgvzg7JQvzLt5A42VmzLLgPLM+CUWN68jpIMdIPayu1bb1T+mJjDv9Sq1aA==", + "version": "3.972.92", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.92.tgz", + "integrity": "sha512-96bcp9Pe/Xd60OEwncZ+kAQTQSu+fJnpUGz1qE6ghF5jnETmrk8XMU86mIP3lolvnCgR61XbZ+Ht6hdBjiQOmQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/nested-clients": "^3.998.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -156,21 +156,21 @@ } }, "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.972.93", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.93.tgz", - "integrity": "sha512-f5Grg1sgckk11ojxZ7NUYG1ZCOvcNhuuPngKWVxOKGuZokj8eOmo/75+GyR6qAQx4wAGytglZ53r4a3UPleAPQ==", + "version": "3.972.97", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.97.tgz", + "integrity": "sha512-E4a0IXXJVsIdo/K9roX4JAEfI0JJr7KTPymkbKgETRDqEcLygE4ZlLTe24+7Qkh8Dl5YpnPd+Tt0DOPJDFXIwA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/credential-provider-env": "^3.972.81", - "@aws-sdk/credential-provider-http": "^3.972.83", - "@aws-sdk/credential-provider-ini": "^3.973.26", - "@aws-sdk/credential-provider-process": "^3.972.81", - "@aws-sdk/credential-provider-sso": "^3.973.25", - "@aws-sdk/credential-provider-web-identity": "^3.972.87", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", + "@aws-sdk/credential-provider-env": "^3.972.84", + "@aws-sdk/credential-provider-http": "^3.972.86", + "@aws-sdk/credential-provider-ini": "^3.973.30", + "@aws-sdk/credential-provider-process": "^3.972.84", + "@aws-sdk/credential-provider-sso": "^3.973.28", + "@aws-sdk/credential-provider-web-identity": "^3.972.90", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", "@smithy/credential-provider-imds": "^4.5.2", - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -178,15 +178,15 @@ } }, "node_modules/@aws-sdk/credential-provider-process": { - "version": "3.972.81", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.81.tgz", - "integrity": "sha512-6NBoFaNJbHB0YjcKW4WfrYIDmaMjtwbxlRreAf3MnXkD9WJX8XYu62pa78M0AQGgEt2TJmcNxqL3btAAjV67bA==", + "version": "3.972.84", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.84.tgz", + "integrity": "sha512-199C6OpNejd0nq9GFAkEFIKids1FL0R6LJtL9c1OTiDOXki7S1OduuPxW4+hE0LwndcYJ7YHOuYTlqScfpCocA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -194,17 +194,17 @@ } }, "node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.973.25", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.25.tgz", - "integrity": "sha512-p1fNaa3as6S2L0wrWqe1cEz1r4iGQa7GbW23KJE3rJy+ZZxhPr6pr9cyCAJ7fAnzoMELvQGZZAuv/rG1ogRuOQ==", + "version": "3.973.28", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.28.tgz", + "integrity": "sha512-bGg7wH8wVDJQIcJggO9lg1ZYbG7l+PbLwHuM3Bi/e1TlCZhU712JS1W3tdRpyptdJD1UGyhBNGO/YrhrQCHKbg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/nested-clients": "^3.998.0", - "@aws-sdk/token-providers": "3.1162.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/token-providers": "3.1166.0", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -212,16 +212,16 @@ } }, "node_modules/@aws-sdk/credential-provider-web-identity": { - "version": "3.972.87", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.87.tgz", - "integrity": "sha512-O2P6CUfMP2qi8vgYB6UHYj/NYTEAAdTr2geEVdVchr3JBofK4Q6W917FiVr2sleA72R59YAXMEhrpzPwkX/xdA==", + "version": "3.972.90", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.90.tgz", + "integrity": "sha512-duLeE3xlf0viHeH+1RM4z5duR3b32BCZTWVMu+MbxFPjQBxy7hmIGEqt5hekuFPRuXoyhMovjNl+PNNsb5oiGQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/nested-clients": "^3.998.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -229,18 +229,18 @@ } }, "node_modules/@aws-sdk/nested-clients": { - "version": "3.998.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.998.0.tgz", - "integrity": "sha512-aOD1oQVWG6UjOOEdp0MsrWE93vG8pPbvtymmeNtglGxAARplh1wzhHs4npqtY5JN5GBSrTaLbn1hQQ3W2Lk8ow==", + "version": "3.998.3", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.998.3.tgz", + "integrity": "sha512-acHTTzMB13CU6dU4sxABYExMI3PQM2zStWH2MiUwJp/7QKTrLg2f7mbzSXoegW2kYOk2tdqQYagsZrWB8Xv7eA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/signature-v4-multi-region": "^3.996.51", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/fetch-http-handler": "^5.8.0", - "@smithy/node-http-handler": "^4.14.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/signature-v4-multi-region": "^3.996.52", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/fetch-http-handler": "^5.8.1", + "@smithy/node-http-handler": "^4.14.2", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -248,14 +248,14 @@ } }, "node_modules/@aws-sdk/signature-v4-multi-region": { - "version": "3.996.51", - "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.51.tgz", - "integrity": "sha512-+aHvUugVBuMPXxgkPfWnTMyGdE/yWS8GHi5+qQ37HowS0YqzrbuaDLznj+Dtmtu5jgCdqz36gXmujOToUhNNWw==", + "version": "3.996.52", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.52.tgz", + "integrity": "sha512-6W6SjGc8OXUhMzNxU1X922ghD+PP1XvzmCk5Scui0jaYsLezycMYR1RaLp5xTIOUrhTXyb4DnAbPr3fBgmdnzg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.975.0", + "@aws-sdk/types": "^3.975.1", "@smithy/signature-v4": "^5.7.5", - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -263,16 +263,16 @@ } }, "node_modules/@aws-sdk/token-providers": { - "version": "3.1162.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1162.0.tgz", - "integrity": "sha512-vOD6Ac0M43LtXaPu+/+wUMQCd27zIpKt/Le/a645qhx7T1MZeEK71PDhtIHGHgnQjGyNSfC6Z5RNud/hQb3veg==", + "version": "3.1166.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1166.0.tgz", + "integrity": "sha512-ngJ8mxXqtQ9mnp7QV6TWKJCxkpjVfPWxKQSc2FYhCyCfOVFIGdFv7P+/RqVffFrJAorwBPpktnv32gNlcEgF4g==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.980.0", - "@aws-sdk/nested-clients": "^3.998.0", - "@aws-sdk/types": "^3.975.0", - "@smithy/core": "^3.38.0", - "@smithy/types": "^4.19.0", + "@aws-sdk/core": "^3.981.0", + "@aws-sdk/nested-clients": "^3.998.3", + "@aws-sdk/types": "^3.975.1", + "@smithy/core": "^3.40.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -280,12 +280,12 @@ } }, "node_modules/@aws-sdk/types": { - "version": "3.975.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.975.0.tgz", - "integrity": "sha512-WQlhs6juByzWOzj5fwxOx0mPJaEqMcG/sDpl3Id61B3XhKE63xY+0QWcnG+sWR/sCfprmreyUo1lM7IKZmHMzw==", + "version": "3.975.1", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.975.1.tgz", + "integrity": "sha512-7rGxUkCB2QPoQOeJmonmAICTN2zrH+fpmi1p4Iwu72lnxNaMhOgqcbpyddifnM1DBb19TWQ1u6z/XjkaFNEDWw==", "license": "Apache-2.0", "dependencies": { - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -293,12 +293,12 @@ } }, "node_modules/@aws-sdk/xml-builder": { - "version": "3.972.42", - "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.42.tgz", - "integrity": "sha512-smX8/gNP8Kjq+CWTBMZQLQ912vOQjiWExzwzvMO+eujPB5RY8IbtF0AGdUUXHKN7KoDWK9dIcuW0WG269kiP6w==", + "version": "3.972.43", + "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.43.tgz", + "integrity": "sha512-rG8QVx4DOrJWptsogu1Aq+CDsnPKaBrAlJpKLxrJrIDXAq1ElnW0yQjjBnlWSXll0cDakCG6UDvaqwz0A9d9Og==", "license": "Apache-2.0", "dependencies": { - "@smithy/types": "^4.19.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { @@ -650,9 +650,9 @@ "peer": true }, "node_modules/@smithy/core": { - "version": "3.39.0", - "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.39.0.tgz", - "integrity": "sha512-JJ/46AWQ4ipS1N2eZmUj7yzIhH8NhQIfAE+dce7NSB6dmFh+7hvD4pbofcoT4I0Xzfy/LNhZx3V2QhwYyAiqdg==", + "version": "3.40.0", + "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.40.0.tgz", + "integrity": "sha512-DssGno52pzZ5m6RlDtyKuBIpZNPg9pqgs0CnNDKz9IatxCsmvNmJNn5Zn6rf77MthZo9wf89OvZFhTY/RwxhxQ==", "license": "Apache-2.0", "dependencies": { "@smithy/types": "^4.20.0", @@ -677,13 +677,13 @@ } }, "node_modules/@smithy/fetch-http-handler": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.0.tgz", - "integrity": "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA==", + "version": "5.8.1", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.1.tgz", + "integrity": "sha512-h8BdMUrUBhMhMaeK7QqAdINRZezCGuYOCpcOZZ1ewxbHST9rdTd09xwNpvLTYfzDRehxQiReK4SKbdYZxBA+ew==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.33.3", - "@smithy/types": "^4.18.0", + "@smithy/core": "^3.39.0", + "@smithy/types": "^4.20.0", "tslib": "^2.6.2" }, "engines": { diff --git a/src/relay/package.json b/src/relay/package.json index 4381c7e..08005c8 100644 --- a/src/relay/package.json +++ b/src/relay/package.json @@ -16,8 +16,8 @@ "test:watch": "vitest" }, "dependencies": { - "@aws-sdk/client-bedrock-agentcore": "3.1163.0", - "@aws-sdk/client-ssm": "3.1163.0", + "@aws-sdk/client-bedrock-agentcore": "3.1167.0", + "@aws-sdk/client-ssm": "3.1167.0", "aws-jwt-verify": "5.2.1" }, "devDependencies": { diff --git a/src/relay/src/index.ts b/src/relay/src/index.ts index 9bfc325..7dc7fd8 100644 --- a/src/relay/src/index.ts +++ b/src/relay/src/index.ts @@ -277,6 +277,7 @@ export async function streamTurn( ...(body.pageContext === undefined ? {} : { pageContext: body.pageContext }), ...(body.tuning === undefined ? {} : { tuning: body.tuning }), ...(body.resumeFrom === undefined ? {} : { resumeFrom: body.resumeFrom }), + ...(body.resume === true ? { resume: true as const } : {}), }); } catch (error) { // A Runtime client-side rejection is a 400; every other pre-stream failure is a 502. diff --git a/src/relay/src/requests.ts b/src/relay/src/requests.ts index f98b3b4..3699ddf 100644 --- a/src/relay/src/requests.ts +++ b/src/relay/src/requests.ts @@ -31,6 +31,8 @@ export interface TurnBody { readonly pageContext?: unknown; readonly tuning?: unknown; readonly resumeFrom?: number; + /** Present only when the body's `resume` is exactly the JSON boolean `true`. */ + readonly resume?: true; } /** @@ -69,6 +71,7 @@ export function decodeBody(event: LambdaFunctionURLEvent): TurnBody | undefined return undefined; } const resumeFrom = typeof body["resume_from"] === "number" ? body["resume_from"] : undefined; + const resume = body["resume"] === true; return { prompt, sessionId, @@ -77,6 +80,7 @@ export function decodeBody(event: LambdaFunctionURLEvent): TurnBody | undefined : { pageContext: stripIdentityChannels(body["page_context"]) }), ...(body["tuning"] === undefined ? {} : { tuning: stripIdentityChannels(body["tuning"]) }), ...(resumeFrom === undefined ? {} : { resumeFrom }), + ...(resume ? { resume: true as const } : {}), }; } diff --git a/src/relay/src/runtime.ts b/src/relay/src/runtime.ts index 1a2f3de..415b77d 100644 --- a/src/relay/src/runtime.ts +++ b/src/relay/src/runtime.ts @@ -86,6 +86,7 @@ export interface TurnRequest { readonly pageContext?: unknown; readonly tuning?: unknown; readonly resumeFrom?: number; + readonly resume?: true; } /** The principal type the relay declares: it serves only Cognito user tokens. */ @@ -122,6 +123,9 @@ export function buildRuntimePayload(request: TurnRequest): Record { expect(deps.requests[0]?.sessionId).toBe(SESSION_ID); expect(deps.requests[0]?.pageContext).toEqual({ kind: "opaque", reason: "test" }); expect(deps.requests[0]?.resumeFrom).toBe(3); + expect(deps.requests[0]).not.toHaveProperty("resume"); + }); + + it("forwards a resume flag of exactly true and drops any other value", async () => { + for (const [resume, forwarded] of [ + [true, true], + [false, undefined], + ["true", undefined], + ] as const) { + const deps = depsFor(streamOf(runtimeFrame({ kind: "completed", text: "done" }))); + await streamTurn(eventFor(turnBody({ resume_from: 2, resume })), new RecordingSink(), deps); + expect(deps.requests[0]?.resume).toBe(forwarded); + } }); it("ends the stream exactly once", async () => { diff --git a/src/relay/tests/requests.test.ts b/src/relay/tests/requests.test.ts index f30670a..17a9f9d 100644 --- a/src/relay/tests/requests.test.ts +++ b/src/relay/tests/requests.test.ts @@ -9,6 +9,7 @@ import { describe, expect, it } from "vitest"; import { PROMPT_MAX_CHARS, PROMPT_TOO_LONG_MESSAGE, + decodeBody, isPromptWithinCap, promptLengthError, } from "../src/requests.js"; @@ -71,3 +72,26 @@ describe("promptLengthError", () => { expect(promptLengthError(event)).toBeUndefined(); }); }); + +describe("decodeBody's resume flag", () => { + function decodedResume(extra: Record): unknown { + const event = eventWithBody(JSON.stringify({ prompt: "hi", session_id: "s".repeat(40), ...extra })); + const body = decodeBody(event); + expect(body).toBeDefined(); + return body === undefined ? undefined : "resume" in body ? body.resume : "absent"; + } + + it("keeps resume when it is exactly the JSON boolean true", () => { + expect(decodedResume({ resume: true })).toBe(true); + }); + + it.each([ + ["absent", {}], + ["false", { resume: false }], + ["the string 'true'", { resume: "true" }], + ["the number 1", { resume: 1 }], + ["null", { resume: null }], + ])("drops resume when it is %s", (_label, extra) => { + expect(decodedResume(extra)).toBe("absent"); + }); +}); diff --git a/src/relay/tests/runtime.test.ts b/src/relay/tests/runtime.test.ts index cbe131e..6b9ad3c 100644 --- a/src/relay/tests/runtime.test.ts +++ b/src/relay/tests/runtime.test.ts @@ -137,6 +137,12 @@ describe("the invocation payload carries identity through the retained agent cha expect(Object.keys(payload)).not.toContain("page_context"); expect(Object.keys(payload)).not.toContain("tuning"); expect(Object.keys(payload)).not.toContain("resume_from"); + expect(Object.keys(payload)).not.toContain("resume"); + }); + + it("sends resume only when the turn carries the flag", () => { + expect(buildRuntimePayload(turn({ resumeFrom: 0, resume: true }))["resume"]).toBe(true); + expect(Object.keys(buildRuntimePayload(turn({ resumeFrom: 0 })))).not.toContain("resume"); }); it("forwards page context, tuning, and a resume point when the caller supplies them", () => { diff --git a/tests/_dynamodb_local.py b/tests/_dynamodb_local.py index 70ae364..ff99dce 100644 --- a/tests/_dynamodb_local.py +++ b/tests/_dynamodb_local.py @@ -59,7 +59,7 @@ def _run_start_script(start_script: Path) -> bool: timeout=_START_TIMEOUT_SECONDS, check=False, ) - except (OSError, subprocess.TimeoutExpired): + except OSError, subprocess.TimeoutExpired: return False return result.returncode == 0 diff --git a/tests/e2e/browser/journeys/21-tier-comparison/tier-comparison.spec.ts b/tests/e2e/browser/journeys/21-tier-comparison/tier-comparison.spec.ts index 1c0e2f9..3b1b8cb 100644 --- a/tests/e2e/browser/journeys/21-tier-comparison/tier-comparison.spec.ts +++ b/tests/e2e/browser/journeys/21-tier-comparison/tier-comparison.spec.ts @@ -42,35 +42,49 @@ const TIERS: readonly { readonly tier: string; readonly heading: string }[] = [ { tier: "tool", heading: "ToolCall" }, ]; -/** Row labels every tier carries, in order. */ -const COMMON_ROW_LABELS: readonly string[] = [ +/** The row labels of every tier, in order. */ +const ROW_LABELS: readonly string[] = [ "Model", "Effort", "Task completion rate", "Task completion over repeats", "Task accuracy", "Cost per completed task", - "P95 latency per completed task (ms)", "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "Model invocations", "Long-context invocations", - "Input tokens", - "Output tokens", - "Cost per task, all tasks", + "Total input tokens", + "Cache read tokens", + "Cache write tokens", + "Uncached input tokens", + "Total output tokens", + "Cost per applicable task", "Self-corrected retries", + "Budget-exhausted tasks", + "Truncated tool calls", + "Truncated tasks", ]; /** The row counting calls priced at long-context rates. */ const LONG_CONTEXT_ROW = "Long-context invocations"; -/** Row labels that follow the common ones, per tier. */ -const TIER_ROW_LABELS: Readonly> = { - supervisor: ["Budget-exhausted tasks"], - subagent: ["data", "no_match", "denied", "tool_failure", "none"].map( - (kind) => `Delegation outcome: ${kind}`, - ), - tool: ["Truncated tasks"], -}; +/** Asserts Total input tokens = Cache read + Cache write + Uncached input tokens in every column. */ +function expectInputTokenIdentity(heading: string, rows: readonly (readonly string[])[]): void { + const cells = (label: string): number[] => + (rows.find((row) => row[0] === label) ?? []).slice(1).map((cell) => Number(cell)); + const total = cells("Total input tokens"); + const read = cells("Cache read tokens"); + const write = cells("Cache write tokens"); + const uncached = cells("Uncached input tokens"); + expect(total.length, `${heading} carries the input token rows`).toBeGreaterThan(0); + for (const [column, value] of total.entries()) { + expect( + value, + `${heading} column ${column + 1}: total input is cache read + cache write + uncached`, + ).toBe(read[column] + write[column] + uncached[column]); + } +} /** Words that state a judgement; none may appear anywhere in the summary. */ const VERDICT_WORDS = [ @@ -117,11 +131,6 @@ interface WireStatus { readonly tier_comparison_table?: WireTierTable; } -/** The expected row labels of `tier`, in order. */ -function expectedRowLabels(tier: string): string[] { - return [...COMMON_ROW_LABELS, ...(TIER_ROW_LABELS[tier] ?? [])]; -} - /** Split one GitHub-flavoured Markdown table line into its trimmed cells. */ function markdownCells(line: string): string[] { const trimmed = line.trim(); @@ -300,15 +309,16 @@ test.describe("the tier comparison summary and its matrix.md download", () => { const { tables, notes } = parseTierSection(readFileSync(SAMPLE_MATRIX, "utf-8")); expect([...tables.keys()]).toEqual(TIERS.map(({ heading }) => heading)); - for (const { tier, heading } of TIERS) { + for (const { heading } of TIERS) { const table = tables.get(heading); expect(table?.headers[0], `${heading}'s first column`).toBe("Metric"); expect(table?.rows.map((row) => row[0]), `${heading}'s row labels`).toEqual( - expectedRowLabels(tier), + [...ROW_LABELS], ); for (const row of table?.rows ?? []) { expect(row.length, `${heading} row ${row[0]}`).toBe(table?.headers.length); } + expectInputTokenIdentity(heading, table?.rows ?? []); } expect(notes.length).toBeGreaterThan(0); expect(firstVerdictWord(tierSectionText(readFileSync(SAMPLE_MATRIX, "utf-8")))).toBeNull(); @@ -318,7 +328,7 @@ test.describe("the tier comparison summary and its matrix.md download", () => { for (const sample of ["anthropic wins", "Winner: openai", "we recommend x", "x outperforms y"]) { expect(firstVerdictWord(sample), `${sample} states a judgement`).not.toBeNull(); } - const vocabulary = [...COMMON_ROW_LABELS, ...Object.values(TIER_ROW_LABELS).flat(), "withheld"]; + const vocabulary = [...ROW_LABELS, "withheld"]; for (const label of vocabulary) { expect(firstVerdictWord(label), `${label} is a measurement label`).toBeNull(); } @@ -361,7 +371,7 @@ test.describe("the tier comparison summary and its matrix.md download", () => { expect( table.rows.map((row) => row[0]), `${heading} carries the fixed row labels in order`, - ).toEqual(expectedRowLabels(tier)); + ).toEqual([...ROW_LABELS]); for (const row of table.rows) { expect(row.length, `${heading} row ${row[0]} has one cell per arm`).toBe(armCount + 1); } @@ -373,6 +383,7 @@ test.describe("the tier comparison summary and its matrix.md download", () => { for (const cell of longContext.slice(1)) { expect(cell, `${heading}'s ${LONG_CONTEXT_ROW} is a recorded count, not —`).toMatch(/^\d+$/); } + expectInputTokenIdentity(heading, table.rows); } const summaryText = (await summary.innerText()).replace(/\s+/g, " "); @@ -407,6 +418,78 @@ test.describe("the tier comparison summary and its matrix.md download", () => { }); }); +/** One history entry as the `list` action returns it. Mirrored, never imported. */ +interface WireListedRun { + readonly run_id?: string; + readonly status?: string; + readonly record_format?: string; +} +interface WireRunList { + readonly runs?: readonly WireListedRun[]; + readonly next_cursor?: string | null; +} + +/** History pages read while looking for an earlier-format run, at most. */ +const MAX_HISTORY_PAGES = 20; + +/** Wait for the next `eval_trigger` `list` response and return its body. */ +async function nextHistoryPage(page: Page): Promise { + const response = await page.waitForResponse((candidate) => { + if (!EVAL_TRIGGER_PATH.test(new URL(candidate.url()).pathname)) return false; + if (candidate.request().method() !== "POST") return false; + try { + return (candidate.request().postDataJSON() as { action?: unknown }).action === "list"; + } catch { + return false; + } + }); + expect(response.status(), "the run history request succeeds").toBeLessThan(400); + return (await response.json()) as WireRunList; +} + +test.describe("a run recorded in an earlier format", () => { + test("is listed in history and opens to the earlier-format notice with no tier table", async ({ + signedInPage: page, + }) => { + const firstPage = nextHistoryPage(page); + await page.goto(EVAL_ROUTE); + let history = await firstPage; + let earlier: WireListedRun | undefined; + for (let pages = 1; pages <= MAX_HISTORY_PAGES; pages += 1) { + earlier = (history.runs ?? []).find( + (run) => + run.record_format === "earlier" && + typeof run.run_id === "string" && + (run.status === "completed" || run.status === "cancelled"), + ); + if (earlier !== undefined || !history.next_cursor) break; + const nextPage = nextHistoryPage(page); + await page.getByRole("button", { name: "Load more runs" }).click(); + history = await nextPage; + } + test.skip( + earlier === undefined, + "the stack's run history holds no completed or cancelled run recorded in an earlier format", + ); + const runId = earlier?.run_id ?? ""; + + const show = page + .getByRole("table", { name: "Evaluation sweeps, newest first" }) + .getByRole("button", { name: `Show run ${runId}` }); + await expect(show, "the earlier-format run is listed in history").toBeVisible(); + await show.click(); + + await expect(page.getByTestId("eval-record-format-earlier")).toHaveText( + "Recorded in an earlier format; its results are not shown.", + ); + await expect(page.getByTestId("tier-comparison-summary")).toHaveCount(0); + for (const { tier } of TIERS) { + await expect(page.getByTestId(`tier-comparison-table-${tier}`)).toHaveCount(0); + } + await expect(page.getByRole("alert")).toHaveCount(0); + }); +}); + /** An origin no request ever leaves the browser for: every URL under it is fulfilled by `page.route`. */ const PLANTED_ORIGIN = "http://csp-trap.test"; diff --git a/tests/e2e/browser/journeys/22-chat-recall/chat-recall.spec.ts b/tests/e2e/browser/journeys/22-chat-recall/chat-recall.spec.ts new file mode 100644 index 0000000..8ba091b --- /dev/null +++ b/tests/e2e/browser/journeys/22-chat-recall/chat-recall.spec.ts @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: MIT +/** + * Journey 22: the assistant recalls a fact from an earlier turn of the same conversation, and a new + * conversation does not. + * + * Turn 1 asks the assistant to remember a run-scoped code word and to reply without repeating it. + * Turn 2, in the same conversation, asks for the code word, and its answer must contain it. Both + * requests are read at the network boundary. Turn 2 must reuse turn 1's `session_id` with a + * positive `resume_from`, and its answer must differ from turn 1's, so a replay of turn 1 cannot + * pass. Turn 3 states a second code word, and turn 4 must recall both. After "New conversation", the + * first question gets a fresh `session_id` and an answer that does not contain the code word. + * Every request is the SPA's own; nothing is overridden. + * + * User: the demo user (`CRM_DEMO_USER_EMAIL`). Each turn calls a real model and is billed as any + * chat turn is. + */ +import type { Page, Request } from "@playwright/test"; + +import { expect, test } from "../../fixtures/auth"; +import { randomToken } from "../../fixtures/randomToken"; + +/** Matches the `data-testid`s in `AssistantConversation.tsx` and `MarkdownAnswer.tsx`. */ +const PANEL_TESTID = "assistant-panel"; +const MARKDOWN_ANSWER_TESTID = "markdown-answer"; +const NEW_CONVERSATION_TESTID = "assistant-new-conversation"; +const TURN_BUBBLE_TESTID = "assistant-turn"; + +const TURN_TIMEOUT_MS = 90_000; + +/** The fields of one chat-turn request body this journey reads. */ +interface TurnRequestBody { + readonly prompt: string; + readonly session_id: string; + readonly resume_from: number | undefined; +} + +function isTurnRequest(request: Request): boolean { + return request.method() === "POST" && new URL(request.url()).pathname.startsWith("/agent/"); +} + +function turnBody(request: Request): TurnRequestBody { + const body = JSON.parse(request.postData() ?? "{}") as Record; + return { + prompt: String(body.prompt ?? ""), + session_id: String(body.session_id ?? ""), + resume_from: typeof body.resume_from === "number" ? body.resume_from : undefined, + }; +} + +/** Send `prompt`, wait for its answer to render, and return the request body and the answer text. */ +async function sendTurn(page: Page, prompt: string): Promise<{ body: TurnRequestBody; answer: string }> { + const answers = page.getByTestId(MARKDOWN_ANSWER_TESTID); + const before = await answers.count(); + const requested = page.waitForRequest( + (request) => isTurnRequest(request) && turnBody(request).prompt === prompt, + { timeout: TURN_TIMEOUT_MS }, + ); + await page.getByTestId("assistant-prompt").fill(prompt); + await page.getByTestId("assistant-send").click(); + const body = turnBody(await requested); + await expect(answers).toHaveCount(before + 1, { timeout: TURN_TIMEOUT_MS }); + await expect(page.getByTestId("turn-state-pill").last()).toHaveAttribute("data-status", "completed", { + timeout: TURN_TIMEOUT_MS, + }); + const answer = (await answers.last().textContent()) ?? ""; + return { body, answer }; +} + +async function openCleanPanel(page: Page): Promise { + await page.goto("/pipeline"); + const panel = page.getByTestId(PANEL_TESTID); + if (await panel.isHidden()) await page.getByTestId("panel-toggle").click(); + await expect(panel).toBeVisible(); + const reset = page.getByTestId(NEW_CONVERSATION_TESTID); + if (await reset.isVisible()) await reset.click(); + await expect(page.getByTestId(TURN_BUBBLE_TESTID)).toHaveCount(0); +} + +test.describe("chat recall across turns", () => { + test("follow-ups in the same conversation recall earlier code words; a new conversation does not", async ({ + signedInPage: page, + }) => { + const codeWord = `kestrel-${randomToken(8)}`; + const question = "What is the code word I asked you to remember? Reply with the code word only."; + await openCleanPanel(page); + + const seed = await sendTurn( + page, + `Remember the code word ${codeWord} for later in this conversation. Do not repeat it now; reply with only the word OK.`, + ); + expect(seed.body.session_id, "turn 1 carries a session id").not.toBe(""); + expect( + seed.answer.toLowerCase(), + "turn 1's answer does not contain the code word, so recall below is not an echo of it", + ).not.toContain(codeWord); + + const recall = await sendTurn(page, question); + expect(recall.body.session_id, "turn 2 continues turn 1's session").toBe(seed.body.session_id); + expect(recall.body.resume_from ?? 0, "turn 2 sends the events already received").toBeGreaterThan(0); + expect(recall.answer, "turn 2 is a new answer, not a replay of turn 1").not.toBe(seed.answer); + expect(recall.answer.toLowerCase(), "turn 2 recalls the code word").toContain(codeWord); + + const secondWord = `heron-${randomToken(8)}`; + const secondSeed = await sendTurn( + page, + `Also remember a second code word, ${secondWord}. Do not repeat either code word now; reply with only the word OK.`, + ); + expect(secondSeed.body.session_id, "turn 3 continues the same session").toBe(seed.body.session_id); + expect( + secondSeed.body.resume_from ?? 0, + "turn 3's cursor is past every event of turns 1 and 2", + ).toBeGreaterThan(recall.body.resume_from ?? 0); + expect(secondSeed.answer.toLowerCase(), "turn 3's answer does not echo the second code word").not.toContain( + secondWord, + ); + + const both = await sendTurn(page, "List both code words I asked you to remember, and nothing else."); + expect(both.body.session_id, "turn 4 continues the same session").toBe(seed.body.session_id); + const bothAnswer = both.answer.toLowerCase(); + expect(bothAnswer, "turn 4 recalls the code word from turn 1").toContain(codeWord); + expect(bothAnswer, "turn 4 recalls the code word from turn 3").toContain(secondWord); + + await page.getByTestId(NEW_CONVERSATION_TESTID).click(); + await expect(page.getByTestId(TURN_BUBBLE_TESTID)).toHaveCount(0); + + const fresh = await sendTurn(page, question); + expect(fresh.body.session_id, "a new conversation mints a new session id").not.toBe(seed.body.session_id); + expect(fresh.answer.toLowerCase(), "a new conversation does not know the code word").not.toContain(codeWord); + }); +}); diff --git a/tests/e2e/browser/journeys/README.md b/tests/e2e/browser/journeys/README.md index 5df94b9..b250911 100644 --- a/tests/e2e/browser/journeys/README.md +++ b/tests/e2e/browser/journeys/README.md @@ -26,8 +26,9 @@ describes what it asserts and its declared limits. | `19-account-opportunities` | An account's detail page lists its opportunities in the shared table; an account with none shows "No opportunities yet." and no table | | `20-chat-cost` | Each reply shows its cost with a per-tier breakdown and the header totals the conversation; the withheld text appears only when `config/pricing.yaml` is `provisional: true` | | `21-tier-comparison` | A stub sweep's tier comparison summary renders three tables (Supervisor, Subagent, ToolCall), each headed `Metric` plus one column per arm with fixed row labels and the notes beneath; every cell equals the run status's `tier_comparison_table`, and the downloaded `matrix.md`'s tier section carries the same cells and notes. No verdict or winner term appears in either | +| `22-chat-recall` | A follow-up in the same conversation recalls a code word stated in an earlier turn: it reuses the turn's `session_id` with a positive `resume_from` and its answer differs from the earlier one, so a replay cannot pass. A later turn recalls two code words. After "New conversation" the same question gets a fresh `session_id` and an answer without the code word. Real model turns, billed as chat | -Journeys 14–20 sit in one directory each. +Journeys 14–22 sit in one directory each. ## Running them diff --git a/tests/fixtures/plans/compliant.base.ndjson b/tests/fixtures/plans/compliant.base.ndjson index 2cd15e7..fabce19 100644 --- a/tests/fixtures/plans/compliant.base.ndjson +++ b/tests/fixtures/plans/compliant.base.ndjson @@ -1,7 +1,8 @@ -{"_fixture_provenance": {"captured_at": "2026-11-10", "captured_infra_digest": "b1c86a9cee195503b2144d10e481d32e31b2e8095601e6993df98b62fd1e0a56", "currency": "Captured from a tree whose tracked infra/**/*.tf digest is captured_infra_digest. plan_freshness passes while plan_fixtures.infra_digest of the working tree equals it. The adopted network (VPC, subnets, route tables, the CloudFront VPC-origin security group) is created outside Terraform and adopted by the gitignored tfvars, so its ids are scrubbed to placeholders.", "derived_from": "native capture; no earlier fixture content", "how": "terraform show -json of a create-everything plan captured against EMPTY LOCAL STATE in a scratch copy of infra/ (providers and build/ symlinked, backend block removed so state is local), no deploy. Plan: 680 to add, 0 to change, 0 to destroy; 159 data reads. Scrubbed by scripts/scrub_plan_capture.py: account id -> 123456789012, IAM unique ids -> AIDA-example-caller-user-id, caller role and session -> example-deployer/example-session, operator principals -> example-operator-, aws_profile -> example-deployer, adopted-network ids -> non-hex placeholder tokens.", "variables_at_capture": "runtime_source_vpce_deny_enabled = false; runtime_source_vpce_report_only_enabled = true; vpc_flow_log_enabled = true; vpc_nat_gateway_enabled = true; adopted-network variables and crm_operator_principal_arns from the gitignored infra/terraform.tfvars. NONE has a tracked default that supplies a real id."}, "configuration": {"provider_config": {"aws": {"expressions": {"default_tags": [{"tags": {"references": ["var.service", "var.environment", "var.owner", "var.cost_center", "var.data_classification"]}}], "profile": {"references": ["var.aws_profile"]}, "region": {"references": ["var.aws_region"]}}, "full_name": "registry.terraform.io/hashicorp/aws", "name": "aws", "version_constraint": "6.71.0"}, "module.agentcore:null": {"full_name": "registry.terraform.io/hashicorp/null", "module_address": "module.agentcore", "name": "null"}, "terraform": {"full_name": "terraform.io/builtin/terraform", "name": "terraform"}}, "root_module": {"module_calls": {"agent_relay": {"expressions": {"agent_runtime_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "agent_runtime_qualifier": {"references": ["local.relay_runtime_qualifier"]}, "cognito_audience_parameter_arn": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.relay_cognito_audience_parameter_name"]}, "cognito_audience_parameter_name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "cognito_issuer": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "log_retention_days": {"constant_value": 365}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"agent_relay\"]", "local.reserved_concurrency"]}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"environment_variable_names": {"description": "Names of every environment variable this module sets on the relay. Lets a contract test assert the config surface in both directions \u2014 nothing the relay reads is unset, nothing set is unread.", "expression": {"references": ["local.environment_variables"]}}, "function_arn": {"description": "The relay function's ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The relay function's name. Consumed by `modules/frontend_cdn` to attach the CloudFront-scoped `lambda:InvokeFunctionUrl` permission.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "function_url": {"description": "The Function URL, scheme and trailing slash included, as Lambda returns it.", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "function_url_domain": {"description": "Host portion of the Function URL, for use as a CloudFront custom-origin `domain_name` (which rejects a scheme or a path).", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "log_group_name": {"description": "The relay's CloudWatch log group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "The relay execution role's ARN. Consumed by the Layer 4 `simulate-principal-policy` check.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "The relay execution role's name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.invoke_runtime", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.invoke_runtime.json", "data.aws_iam_policy_document.invoke_runtime"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.read_audience_parameter", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.read_audience_parameter.json", "data.aws_iam_policy_document.read_audience_parameter"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"environment": [{"variables": {"references": ["local.environment_variables"]}}], "filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_function_url.this", "expressions": {"authorization_type": {"constant_value": "AWS_IAM"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "invoke_mode": {"constant_value": "RESPONSE_STREAM"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function_url"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "InvokeOneRuntimeAndItsEndpoints"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "DenyEverythingButTheOnePermittedInvokeOnThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:*"]}, "effect": {"constant_value": "Deny"}, "resources": {"references": ["local.agentcore_harness_arn"]}, "sid": {"constant_value": "DenyEveryHarness"}}]}, "mode": "data", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.read_audience_parameter", "expressions": {"statement": [{"actions": {"constant_value": ["ssm:GetParameter"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.cognito_audience_parameter_arn"]}, "sid": {"constant_value": "ReadRelayParameters"}}]}, "mode": "data", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_arn": {"description": "ARN of the one AgentCore Runtime this relay may invoke\n(`module.agentcore.agent_runtime_arn`). The execution role is granted\n`bedrock-agentcore:InvokeAgentRuntime` on this ARN and its endpoint sub-resources and on nothing\nelse \u2014 no wildcard, no second runtime.\n"}, "agent_runtime_qualifier": {"default": "DEFAULT", "description": "Runtime endpoint qualifier the relay invokes, passed to the relay as `AGENT_RUNTIME_QUALIFIER`\n(`src/relay/src/runtime.ts`). The execution role's `InvokeAgentRuntime` grant covers the endpoint\nthis value names.\n"}, "cognito_audience_parameter_arn": {"description": "ARN of that same parameter, for the execution role's `ssm:GetParameter` grant. The caller constructs\nit from region, account and name, not from `aws_ssm_parameter.\u2026arn`, to avoid a module cycle.\n"}, "cognito_audience_parameter_name": {"description": "Name of the SSM parameter holding the SPA app-client id the relay requires. The relay reads it at\ncold start and rejects any token issued to a different client.\n"}, "cognito_issuer": {"description": "Cognito user-pool issuer URL (`https://cognito-idp..amazonaws.com/`). The relay derives its JWKS URL from this and rejects any token whose `iss` differs."}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables and its log group."}, "filename": {"description": "Path to the relay deployment package built by `scripts/package_relay.sh`."}, "function_name": {"description": "Unique Lambda function name. Also names this module's IAM role and log group."}, "handler": {"default": "index.handler", "description": "Lambda handler entry point inside the relay zip."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the relay's log group."}, "memory_size_mb": {"default": 512, "description": "Lambda memory allocation in MB, sizing the Node runtime and the JWKS cache."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for the relay. Must be greater than zero; 0 makes the function permanently\nuninvokable.\n\nOne chat turn holds one invocation for up to `timeout_seconds`. The caller keeps the sum of every\nreserved concurrency in the deployment below the account pool minus unreserved headroom.\n\nNo default; the caller states a value.\n"}, "runtime": {"default": "nodejs24.x", "description": "Lambda runtime identifier. Must be a Node.js runtime, which supports response streaming."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the relay package, forcing redeploy on code change."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "timeout_seconds": {"default": 660, "description": "Lambda invocation timeout in seconds. Must exceed the 600s chat turn wall clock."}, "vpc_security_group_ids": {"description": "Security groups for the relay's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress; the relay is invoked through the Lambda control plane (a signed Function URL invoke).\n"}, "vpc_subnet_ids": {"description": "Private subnet ids the relay's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default; at least two subnets.\n\nThe relay's outbound calls (`bedrock-agentcore:InvokeAgentRuntime`, `ssm:GetParameter` and the\nCognito JWKS fetch) leave through these subnets, via the VPC endpoints and the NAT gateway. A missing\npath presents as a hung turn, not as an authorization error.\n"}}}, "source": "./modules/agent_relay"}, "agentcore": {"depends_on": ["aws_s3_object.agent_source", "aws_iam_role_policy.agentcore_runtime"], "expressions": {"agent_runtime_environment_variables": {"references": ["module.cognito.user_pool_id", "module.cognito", "module.api.stage_invoke_url", "module.api", "local.name_prefix", "local.name_prefix"]}, "agent_runtime_name": {"constant_value": "crm_agent_eval_runtime"}, "agent_runtime_role_arn": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}, "aws_profile": {"references": ["var.aws_profile"]}, "aws_region": {"references": ["var.aws_region"]}, "buildspec": {"references": ["local.agent_buildspec"]}, "cognito_allowed_audiences": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "cognito_required_custom_claims": {"constant_value": []}, "data_classification": {"references": ["var.data_classification"]}, "ecr_repository_name": {"references": ["local.agent_ecr_repository_name"]}, "gateway_name": {"constant_value": "crm-agent-eval-gateway"}, "gateway_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_interceptor.function_name", "module.lambda_action_interceptor"]}, "image_retention_count": {"constant_value": 10}, "image_tag": {"references": ["local.agent_image_tag"]}, "kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "log_retention_days": {"constant_value": 365}, "name_prefix": {"references": ["local.name_prefix"]}, "runtime_network_mode": {"constant_value": "VPC"}, "runtime_security_group_ids": {"references": ["module.vpc.runtime_security_group_id", "module.vpc"]}, "runtime_subnet_ids": {"references": ["module.vpc.runtime_subnet_ids", "module.vpc"]}, "source_bucket_arn": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}, "source_content_hash": {"references": ["var.lambda_build_dir"]}, "source_key": {"references": ["aws_s3_object.agent_source.key", "aws_s3_object.agent_source"]}, "source_kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "tool_lambda_arns": {"references": ["module.lambda_action"]}, "tool_schemas": {"references": ["local.tool_names", "local.tools", "local.tool_schema_properties"]}}, "module": {"outputs": {"agent_runtime_arn": {"description": "The deployed AgentCore Runtime ARN.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_arn", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_id": {"description": "The deployed AgentCore Runtime id.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_log_group_arn": {"description": "CloudWatch Logs group ARN for the AgentCore Runtime's default endpoint stdout, for scoping the execution role's logs:* grant.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.arn", "aws_cloudwatch_log_group.runtime"]}}, "agent_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.name", "aws_cloudwatch_log_group.runtime"]}}, "codebuild_role_arn": {"description": "ARN of the CodeBuild image-build project's service role, which reads the agent-source object and uses its CMK. The root admits it to the eval-artefacts bucket and key policies.", "expression": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}}, "ecr_repository_arn": {"description": "ARN of the ECR repository the agent container image is pushed to. The root composition scopes the\nAgentCore Runtime execution role's `ecr:BatchGetImage`/`ecr:GetDownloadUrlForLayer` grant to this\nARN.\n", "expression": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}}, "ecr_repository_url": {"description": "The ECR repository URL the agent container image is pushed to.", "expression": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, "gateway_arn": {"description": "The deployed Gateway ARN.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "The deployed Gateway id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_target_ids": {"description": "Map of tool_name -> that tool's gateway target id, one entry per entry in var.tool_lambda_arns.", "expression": {"references": ["aws_bedrockagentcore_gateway_target.tool"]}}, "gateway_url": {"description": "The deployed Gateway's invocation URL.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}}, "resources": [{"address": "aws_bedrockagentcore_agent_runtime.this", "depends_on": ["null_resource.image_build"], "expressions": {"agent_runtime_artifact": [{"container_configuration": [{"container_uri": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent", "var.image_tag"]}}]}], "agent_runtime_name": {"references": ["var.agent_runtime_name"]}, "environment_variables": {"references": ["var.agent_runtime_environment_variables"]}, "network_configuration": [{"network_mode": {"references": ["var.runtime_network_mode"]}}], "platform_version": {"references": ["var.platform_version"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.agent_runtime_role_arn"]}, "tags": {"references": ["var.tags"]}, "timeouts": {"create": {"constant_value": "30m"}, "update": {"constant_value": "30m"}}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_agent_runtime"}, {"address": "aws_bedrockagentcore_gateway.this", "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.gateway_role_arn"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.tool", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"references": ["each.key"]}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"references": ["each.key"]}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["each.value"]}, "tool_schema": [{"inline_payload": [{"description": {"references": ["var.tool_schemas", "each.key"]}, "input_schema": [{"type": {"constant_value": "object"}}], "name": {"references": ["each.key"]}}]}]}]}]}]}, "for_each_expression": {"references": ["var.tool_lambda_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_cloudwatch_log_group.codebuild", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_cloudwatch_log_group.runtime", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_codebuild_project.agent_image", "expressions": {"artifacts": [{"type": {"constant_value": "NO_ARTIFACTS"}}], "build_timeout": {"constant_value": 30}, "description": {"constant_value": "Builds and pushes the AgentCore Runtime container image."}, "encryption_key": {"references": ["var.source_kms_key_arn"]}, "environment": [{"compute_type": {"constant_value": "BUILD_GENERAL1_SMALL"}, "environment_variable": [{"name": {"constant_value": "ECR_REPOSITORY_URI"}, "value": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, {"name": {"constant_value": "AWS_DEFAULT_REGION"}, "value": {"references": ["var.aws_region"]}}], "image": {"constant_value": "aws/codebuild/amazonlinux2-aarch64-standard:3.0"}, "image_pull_credentials_type": {"constant_value": "CODEBUILD"}, "privileged_mode": {"constant_value": true}, "type": {"constant_value": "ARM_CONTAINER"}}], "logs_config": [{"cloudwatch_logs": [{"group_name": {"references": ["aws_cloudwatch_log_group.codebuild.name", "aws_cloudwatch_log_group.codebuild"]}}]}], "name": {"references": ["var.name_prefix"]}, "service_role": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}, "source": [{"buildspec": {"references": ["var.buildspec"]}, "location": {"references": ["var.source_bucket_arn", "var.source_bucket_arn", "var.source_key"]}, "type": {"constant_value": "S3"}}], "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent_image", "provider_config_key": "aws", "schema_version": 0, "type": "aws_codebuild_project"}, {"address": "aws_ecr_lifecycle_policy.agent", "expressions": {"policy": {"references": ["var.image_retention_count", "var.image_retention_count"]}, "repository": {"references": ["aws_ecr_repository.agent.name", "aws_ecr_repository.agent"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_lifecycle_policy"}, {"address": "aws_ecr_repository.agent", "expressions": {"encryption_configuration": [{"encryption_type": {"constant_value": "KMS"}, "kms_key": {"references": ["var.kms_key_arn"]}}], "force_delete": {"constant_value": true}, "image_scanning_configuration": [{"scan_on_push": {"constant_value": true}}], "image_tag_mutability": {"constant_value": "IMMUTABLE"}, "name": {"references": ["var.ecr_repository_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_repository"}, {"address": "aws_iam_role.codebuild", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.codebuild_assume_role.json", "data.aws_iam_policy_document.codebuild_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.codebuild", "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.codebuild_permissions.json", "data.aws_iam_policy_document.codebuild_permissions"]}, "role": {"references": ["aws_iam_role.codebuild.id", "aws_iam_role.codebuild"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "null_resource.image_build", "depends_on": ["aws_codebuild_project.agent_image"], "expressions": {"triggers": {"references": ["var.source_content_hash", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image"]}}, "mode": "managed", "name": "image_build", "provider_config_key": "module.agentcore:null", "provisioners": [{"expressions": {"command": {"references": ["var.image_tag", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "var.aws_profile", "var.aws_region", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region", "var.aws_profile", "var.aws_region", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region"]}}, "type": "local-exec"}], "schema_version": 0, "type": "null_resource"}, {"address": "data.aws_iam_policy_document.codebuild_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["codebuild.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "codebuild_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.codebuild_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.codebuild.arn", "aws_cloudwatch_log_group.codebuild"]}, "sid": {"constant_value": "Logs"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrAuth"}}, {"actions": {"constant_value": ["ecr:BatchCheckLayerAvailability", "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", "ecr:PutImage", "ecr:InitiateLayerUpload", "ecr:UploadLayerPart", "ecr:CompleteLayerUpload"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}, "sid": {"constant_value": "EcrPush"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_bucket_arn", "var.source_key"]}, "sid": {"constant_value": "SourceObject"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_kms_key_arn"]}, "sid": {"constant_value": "ProjectKms"}}]}, "mode": "data", "name": "codebuild_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_environment_variables": {"default": {}, "description": "Plaintext environment variables for the runtime. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "agent_runtime_name": {"default": "crm_agent_eval_runtime", "description": "Name for the AgentCore Runtime resource. Must satisfy the CreateAgentRuntime pattern [a-zA-Z][a-zA-Z0-9_]{0,47} -- no hyphens."}, "agent_runtime_role_arn": {"description": "Execution role ARN the AgentCore Runtime assumes to run the agent container."}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile used by the in-apply CodeBuild trigger's `local-exec` provisioner."}, "aws_region": {"default": "us-east-1", "description": "AWS region for the AgentCore resources and the in-apply build trigger."}, "buildspec": {"description": "Inline buildspec for the CodeBuild project (Docker build + ECR push steps)."}, "cognito_allowed_audiences": {"description": "Accepted `aud` claim values for the CUSTOM_JWT authorizer."}, "cognito_allowed_client_ids": {"description": "App client ids accepted as valid callers by the CUSTOM_JWT authorizer."}, "cognito_allowed_scopes": {"default": [], "description": "Scopes required to be present on an inbound access token, enforced by the Gateway CUSTOM_JWT authorizer."}, "cognito_discovery_url": {"description": "Cognito user pool OIDC discovery URL, ending in /.well-known/openid-configuration."}, "cognito_required_custom_claims": {"default": [], "description": "Custom claims the Gateway CUSTOM_JWT authorizer requires on an inbound token, each matched by\nequality against one fixed `required_value` (for example a fixed `token_use` claim). Presence-only\nchecks are not expressible here; the interceptor's `decode_identity` rejects a token without the\nidentity claims. Defaults to empty.\n"}, "data_classification": {"description": "Value for the mandatory `data-classification` tag, applied per-resource (mirrors every sibling module's convention)."}, "ecr_repository_name": {"default": "crm-agent-eval-agent", "description": "Name of the ECR repository holding the agent container image."}, "gateway_name": {"default": "crm-agent-eval-gateway", "description": "Name for the AgentCore Gateway resource."}, "gateway_role_arn": {"description": "Execution role ARN the Gateway assumes, including to invoke each target Lambda via credential_provider_configuration.gateway_iam_role."}, "identity_interceptor_lambda_arn": {"description": "Invoke ARN of the identity_interceptor Lambda (src/gateway/identity_interceptor.py), attached as the Gateway's REQUEST interceptor."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the identity_interceptor Lambda, used to grant this Gateway invoke permission in the function resource policy."}, "image_retention_count": {"default": 10, "description": "Number of most-recent tagged images retained by the ECR lifecycle policy."}, "image_tag": {"default": "latest", "description": "Tag applied to the image the agent_runtime resource consumes (e.g. a short content-hash-derived tag the caller mints alongside source_content_hash)."}, "kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the ECR repository and the module's CloudWatch Logs log groups (runtime and CodeBuild) at rest."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the CodeBuild project's log group."}, "name_prefix": {"default": "crm-agent-eval", "description": "Prefix applied to the CodeBuild project, its IAM role, and its log group names."}, "platform_version": {"default": "V2", "description": "AgentCore Runtime `platformVersion`: \"V1\" or \"V2\". V2 restores each instance from a\nprepared snapshot; creates and updates take minutes. Switching either way is an in-place update.\nRollback: set \"V1\" and apply (docs/runbook.md).\n"}, "runtime_network_mode": {"default": "PUBLIC", "description": "AgentCore Runtime `networkMode`: \"PUBLIC\" or \"VPC\". VPC mode places the microVM's ENIs in the\nadopted VPC's Runtime subnets on a dedicated no-ingress security group; it governs egress only.\nDefaults to \"PUBLIC\"; the root composition sets \"VPC\" and wires the subnet and security-group\nvariables.\n"}, "runtime_security_group_ids": {"default": [], "description": "Security group ids for the Runtime's VPC-mode ENIs. Required (at least one) when\nruntime_network_mode is \"VPC\"; ignored under \"PUBLIC\". Must be the dedicated Runtime security group\n(no ingress, egress only to the endpoint security group and the gateway prefix lists), not the\nLambda security group.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the Runtime's VPC-mode ENIs. Required (at least one) when runtime_network_mode is\n\"VPC\"; ignored under \"PUBLIC\". Set through the gitignored tfvars.\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`);\n`scripts/preflight_adopted_vpc.sh` asserts that at deploy time.\n"}, "source_bucket_arn": {"description": "S3 bucket ARN holding the zipped agent source CodeBuild reads from as its `source`."}, "source_content_hash": {"description": "Content hash of the agent source tree, used as this module's `null_resource.image_build` trigger\nvalue. The image build re-runs when this value changes between applies.\n"}, "source_key": {"description": "S3 object key, within source_bucket_arn, of the zipped agent source archive."}, "source_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting `source_bucket_arn`'s objects at rest, also used as\nthe CodeBuild project's `encryption_key`. The CodeBuild role is granted `kms:Decrypt`,\n`kms:Encrypt`, `kms:GenerateDataKey*` and `kms:DescribeKey` on exactly this key. The key's own\npolicy must also admit `aws_iam_role.codebuild` (or a broader principal it belongs to).\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "tool_lambda_arns": {"description": "Map of tool_name -> that tool's action Lambda ARN (`module.lambda_action[tool_name].function_arn`),\none entry per tool in `crm.toolspec.definitions.ALL_TOOLS`. Each entry produces exactly one gateway\ntarget. Its keys are a superset of the `api` module's tool routes: `get_page_context` is reachable\nby the agents and the Gateway but has no HTTP route (`local.agent_only_tools` in `infra/main.tf`).\nThat the key set equals `ALL_TOOLS` is `scripts/check_toolspec_parity.py`'s check on\n`local.tools`, which this map is built from.\n"}, "tool_schemas": {"description": "Map of tool_name -> that tool's flattened MCP tool schema, for the required\n`target_configuration.mcp.lambda.tool_schema` block of each `aws_bedrockagentcore_gateway_target`.\nCarries exactly the keys of `tool_lambda_arns`; the gateway target resource's precondition fails\nthe plan otherwise.\n\nThe root composition derives each entry's `description` and `properties` from\n`crm.toolspec.definitions.ALL_TOOLS[tool_name]` (`.description` and the top-level keys of\n`.input_schema[\"properties\"]`).\n\nOnly top-level scalar properties, and arrays of scalars, are expressible; a property whose type is\n`object`, or an array of objects, needs this variable's shape extended.\n"}}}, "source": "./modules/agentcore"}, "api": {"expressions": {"access_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "api_name": {"constant_value": "crm-agent-eval-api"}, "cognito_user_pool_arn": {"references": ["module.cognito.user_pool_arn", "module.cognito"]}, "extra_routes": {"references": ["module.lambda_action_eval_trigger.invoke_arn", "module.lambda_action_eval_trigger", "module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger", "module.lambda_action_capabilities.invoke_arn", "module.lambda_action_capabilities", "module.lambda_action_capabilities.function_name", "module.lambda_action_capabilities", "module.lambda_action_user_settings.invoke_arn", "module.lambda_action_user_settings", "module.lambda_action_user_settings.function_name", "module.lambda_action_user_settings"]}, "log_retention_days": {"constant_value": 365}, "stage_name": {"constant_value": "prod"}, "tool_lambda_function_names": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "tool_lambda_invoke_arns": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "vpc_endpoint_ids": {"references": ["module.vpc.execute_api_vpc_endpoint_id", "module.vpc"]}}, "module": {"outputs": {"access_log_group_name": {"description": "CloudWatch Logs group name receiving API Gateway access logs.", "expression": {"references": ["aws_cloudwatch_log_group.access_logs.name", "aws_cloudwatch_log_group.access_logs"]}}, "api_id": {"description": "Private REST API id.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "authorizer_id": {"description": "Cognito authorizer id \u2014 every method in this module references this one authorizer; exposed for the Layer 3 gate's authorizer-coverage assertion.", "expression": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}}, "execution_arn": {"description": "API execution ARN, for Lambda resource-policy `source_arn` patterns outside this module if needed.", "expression": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this"]}}, "private_origin_domain_name": {"description": "Hostname for the CloudFront `/api/*` origin's `domain_name` (`-.execute-api..amazonaws.com`). Sent as the Host header to the private API; requires no custom domain and no `x-apigw-api-id`. Uses the first entry of `vpc_endpoint_ids`.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this", "var.vpc_endpoint_ids[0]", "var.vpc_endpoint_ids", "data.aws_region.current.region", "data.aws_region.current"]}}, "route_tool_names": {"description": "Sorted list of the tool names this module generated routes for, derived from `var.tool_lambda_invoke_arns`'s keys \u2014 for the Layer 3 gate to diff against `crm.toolspec.definitions.ALL_TOOLS`.", "expression": {"references": ["local.tool_names"]}}, "stage_invoke_url": {"description": "Full invoke URL for the deployed stage. For this private API it is reachable only from inside the VPC through a named interface endpoint; it is not a publicly callable URL.", "expression": {"references": ["aws_api_gateway_stage.this.invoke_url", "aws_api_gateway_stage.this"]}}, "stage_name": {"description": "Deployed stage name. Every route is served beneath it (`//`), so a path-prefixed CloudFront behaviour in front of this API rewrites onto the stage path.", "expression": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "vpc_endpoint_ids": {"description": "The `execute-api` interface endpoint ids this API is associated with and whose `aws:sourceVpce` its resource policy allows.", "expression": {"references": ["var.vpc_endpoint_ids"]}}}, "resources": [{"address": "aws_api_gateway_authorizer.cognito", "expressions": {"identity_source": {"constant_value": "method.request.header.Authorization"}, "name": {"constant_value": "cognito-user-pools"}, "provider_arns": {"references": ["var.cognito_user_pool_arn"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "COGNITO_USER_POOLS"}}, "mode": "managed", "name": "cognito", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_authorizer"}, {"address": "aws_api_gateway_deployment.this", "depends_on": ["aws_api_gateway_method.tool", "aws_api_gateway_integration.tool", "aws_api_gateway_request_validator.body_and_params", "aws_api_gateway_model.json_object"], "expressions": {"rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "triggers": {"references": ["local.deployment_trigger"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_deployment"}, {"address": "aws_api_gateway_integration.tool", "expressions": {"http_method": {"references": ["aws_api_gateway_method.tool", "each.key"]}, "integration_http_method": {"constant_value": "POST"}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "AWS_PROXY"}, "uri": {"references": ["each.value"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_integration"}, {"address": "aws_api_gateway_method.tool", "expressions": {"authorization": {"constant_value": "COGNITO_USER_POOLS"}, "authorizer_id": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}, "http_method": {"references": ["local.route_methods", "each.key"]}, "request_models": {"references": ["local.route_methods", "each.key", "aws_api_gateway_model.json_object.name", "aws_api_gateway_model.json_object"]}, "request_validator_id": {"references": ["aws_api_gateway_request_validator.body_and_params.id", "aws_api_gateway_request_validator.body_and_params"]}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method"}, {"address": "aws_api_gateway_method_settings.this", "expressions": {"method_path": {"constant_value": "*/*"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "settings": [{"throttling_burst_limit": {"references": ["var.throttle_burst_limit"]}, "throttling_rate_limit": {"references": ["var.throttle_rate_limit"]}}], "stage_name": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method_settings"}, {"address": "aws_api_gateway_model.json_object", "expressions": {"content_type": {"constant_value": "application/json"}, "name": {"constant_value": "JsonObject"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "schema": {}}, "mode": "managed", "name": "json_object", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_model"}, {"address": "aws_api_gateway_request_validator.body_and_params", "expressions": {"name": {"constant_value": "body-and-params"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "validate_request_body": {"constant_value": true}, "validate_request_parameters": {"constant_value": true}}, "mode": "managed", "name": "body_and_params", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_request_validator"}, {"address": "aws_api_gateway_resource.tool", "expressions": {"parent_id": {"references": ["aws_api_gateway_rest_api.this.root_resource_id", "aws_api_gateway_rest_api.this"]}, "path_part": {"references": ["each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_resource"}, {"address": "aws_api_gateway_rest_api.this", "expressions": {"endpoint_configuration": [{"types": {"constant_value": ["PRIVATE"]}, "vpc_endpoint_ids": {"references": ["var.vpc_endpoint_ids"]}}], "name": {"references": ["var.api_name"]}, "policy": {"references": ["data.aws_iam_policy_document.resource_policy.json", "data.aws_iam_policy_document.resource_policy"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_rest_api"}, {"address": "aws_api_gateway_stage.this", "expressions": {"access_log_settings": [{"destination_arn": {"references": ["aws_cloudwatch_log_group.access_logs.arn", "aws_cloudwatch_log_group.access_logs"]}, "format": {}}], "deployment_id": {"references": ["aws_api_gateway_deployment.this.id", "aws_api_gateway_deployment.this"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "stage_name": {"references": ["var.stage_name"]}, "tags": {"references": ["var.tags"]}, "xray_tracing_enabled": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_stage"}, {"address": "aws_cloudwatch_log_group.access_logs", "expressions": {"kms_key_id": {"references": ["var.access_log_kms_key_arn"]}, "name": {"references": ["var.api_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_lambda_permission.apigw_invoke", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["each.value"]}, "principal": {"constant_value": "apigateway.amazonaws.com"}, "source_arn": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this", "local.route_methods", "each.key", "each.key"]}, "statement_id": {"references": ["each.key"]}}, "for_each_expression": {"references": ["local.route_function_names"]}, "mode": "managed", "name": "apigw_invoke", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.resource_policy", "expressions": {"statement": [{"actions": {"constant_value": ["execute-api:Invoke"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "AllowInvokeFromNamedVpcEndpointsOnly"}}, {"actions": {"constant_value": ["execute-api:Invoke"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"references": ["var.vpc_endpoint_ids"]}, "variable": {"constant_value": "aws:sourceVpce"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "DenyInvokeFromAnyOtherVpcEndpoint"}}]}, "mode": "data", "name": "resource_policy", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"access_log_kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the API Gateway access log group at rest."}, "api_name": {"default": "crm-agent-eval-api", "description": "Name for the REST API."}, "cognito_user_pool_arn": {"description": "ARN of the Cognito user pool whose tokens the authorizer accepts (the `cognito` module user pool ARN output). A COGNITO_USER_POOLS authorizer validates that the token was issued by this pool; it does not validate the app-client audience."}, "extra_routes": {"default": {}, "description": "Routes that are not toolspec tools, and so are absent from `tool_lambda_invoke_arns`. Merged with\nthe tool map into the single local that generates every integration, route and permission, so\nthese carry the Cognito authorizer on the same terms as the tool routes.\n\nThe permitted keys are the allowlist validated below (`eval_trigger`, `capabilities`, `user_settings`).\n\n`method` is the HTTP method the client calls and defaults to `POST`; `capabilities` is a browser\n`GET` (`frontend/src/components/tuning/capabilityMatrix.ts`). The Lambda integration method is\nalways `POST` for `AWS_PROXY`, whatever the client method.\n"}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the API Gateway access log group."}, "stage_name": {"default": "prod", "description": "API Gateway stage name."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "throttle_burst_limit": {"default": 50, "description": "Per-route burst limit (concurrent requests) enforced at the default-route throttle setting."}, "throttle_rate_limit": {"default": 25, "description": "Per-route steady-state rate limit (requests/second) enforced at the default-route throttle setting."}, "tool_lambda_function_names": {"description": "Map of tool_name -> that tool's action Lambda function name\n(`module.lambda_action[tool_name].function_name`), used to grant API Gateway\n`lambda:InvokeFunction` per function. Carries exactly the key set of `tool_lambda_invoke_arns`;\nthe REST API resource's precondition fails the plan otherwise.\n"}, "tool_lambda_invoke_arns": {"description": "Map of tool_name -> that tool's action Lambda invoke ARN (`module.lambda_action[tool_name].invoke_arn`),\none entry per routed tool in `crm.toolspec.definitions.ALL_TOOLS`. Every route, integration and\nauthorizer attachment is generated from this map (see `main.tf`). Must not be empty.\n"}, "vpc_endpoint_ids": {"description": "The `execute-api` interface VPC endpoint ids this private API is reachable through. Sets `endpoint_configuration.vpc_endpoint_ids` and is the allowlist in the API resource policy."}}}, "source": "./modules/api"}, "api_origin": {"expressions": {"access_logs_bucket": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "access_logs_prefix": {"references": ["local.alb_access_log_prefix"]}, "alb_ingress_security_group_ids": {"references": ["var.api_origin_ingress_security_group_ids"]}, "execute_api_security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "execute_api_target_ips": {"references": ["data.aws_network_interface.execute_api"]}, "name_prefix": {"references": ["local.name_prefix"]}, "private_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}, "tags": {"references": ["var.data_classification"]}, "vpc_id": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "module": {"outputs": {"alb_arn": {"description": "Internal ALB ARN. The VPC origin references the ALB by this ARN, which is how CloudFront routes without resolving the origin's domain name.", "expression": {"references": ["aws_lb.this.arn", "aws_lb.this"]}}, "alb_dns_name": {"description": "Internal ALB DNS name, for diagnostics only. It is not the CloudFront origin `domain_name`, which is `module.api.private_origin_domain_name`: API Gateway routes the private API on that Host header.", "expression": {"references": ["aws_lb.this.dns_name", "aws_lb.this"]}}, "alb_security_group_id": {"description": "The ALB's security group id, for asserting its ingress source and single scoped egress.", "expression": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}}, "listener_protocol": {"description": "The listener protocol configured on the ALB, for a check asserting the deployed `HTTP` listener.", "expression": {"references": ["aws_lb_listener.this.protocol", "aws_lb_listener.this"]}}, "target_group_arn": {"description": "Target group holding the execute-api endpoint ENI IPs, for the T3 check to assert target health from.", "expression": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}}, "vpc_origin_id": {"description": "Id of the CloudFront VPC origin. Goes into the distribution origin's `vpc_origin_config.vpc_origin_id` for the `/api/*` behaviour.", "expression": {"references": ["aws_cloudfront_vpc_origin.this.id", "aws_cloudfront_vpc_origin.this"]}}}, "resources": [{"address": "aws_cloudfront_vpc_origin.this", "expressions": {"tags": {"references": ["var.tags"]}, "vpc_origin_endpoint_config": [{"arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "http_port": {"references": ["var.listener_port"]}, "https_port": {"constant_value": 443}, "name": {"references": ["var.name_prefix"]}, "origin_protocol_policy": {"references": ["var.origin_protocol_policy"]}, "origin_ssl_protocols": [{"items": {"constant_value": ["TLSv1.2"]}, "quantity": {"constant_value": 1}}]}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_vpc_origin"}, {"address": "aws_lb.this", "expressions": {"access_logs": [{"bucket": {"references": ["var.access_logs_bucket"]}, "enabled": {"constant_value": true}, "prefix": {"references": ["var.access_logs_prefix"]}}], "drop_invalid_header_fields": {"constant_value": true}, "enable_deletion_protection": {"constant_value": true}, "internal": {"constant_value": true}, "load_balancer_type": {"constant_value": "application"}, "name": {"references": ["var.name_prefix"]}, "security_groups": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "subnets": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb"}, {"address": "aws_lb_listener.this", "expressions": {"default_action": [{"target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "type": {"constant_value": "forward"}}], "load_balancer_arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "port": {"references": ["var.listener_port"]}, "protocol": {"references": ["var.listener_protocol"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_listener"}, {"address": "aws_lb_target_group.execute_api", "expressions": {"health_check": [{"healthy_threshold": {"constant_value": 2}, "interval": {"constant_value": 30}, "matcher": {"constant_value": "200,403"}, "path": {"constant_value": "/"}, "protocol": {"constant_value": "HTTPS"}, "timeout": {"constant_value": 5}, "unhealthy_threshold": {"constant_value": 2}}], "name": {"references": ["var.name_prefix"]}, "port": {"constant_value": 443}, "protocol": {"constant_value": "HTTPS"}, "tags": {"references": ["var.tags"]}, "target_type": {"constant_value": "ip"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group"}, {"address": "aws_lb_target_group_attachment.execute_api", "count_expression": {"references": ["var.private_subnet_ids"]}, "expressions": {"port": {"constant_value": 443}, "target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "target_id": {"references": ["var.execute_api_target_ips", "count.index"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group_attachment"}, {"address": "aws_security_group.alb", "expressions": {"description": {"constant_value": "Internal ALB fronting the private REST API for the CloudFront /api/* VPC origin"}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "alb", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_security_group_egress_rule.alb_to_endpoint", "expressions": {"description": {"constant_value": "internal ALB to execute-api interface endpoint (443, TLS)"}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["var.execute_api_security_group_id"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "alb_to_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.alb_from_cloudfront", "expressions": {"description": {"references": ["var.listener_port"]}, "from_port": {"references": ["var.listener_port"]}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["each.value"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"references": ["var.listener_port"]}}, "for_each_expression": {"references": ["var.alb_ingress_security_group_ids"]}, "mode": "managed", "name": "alb_from_cloudfront", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}], "variables": {"access_logs_bucket": {"description": "S3 bucket receiving ALB access logs. Required."}, "access_logs_prefix": {"description": "Key prefix the ALB writes access logs under. No default; it must equal the prefix in the destination bucket policy grant (`//AWSLogs//*`). The root passes one local to both sides."}, "alb_ingress_security_group_ids": {"description": "Security group ids permitted to reach the ALB listener port: the security group the deployed CloudFront VPC origin presents. No default; see the first-deployment steps in `docs/runbook.md`."}, "execute_api_security_group_id": {"description": "Security group id of the `execute-api` interface endpoint, the ALB single egress destination on 443."}, "execute_api_target_ips": {"description": "Private IPv4 addresses of the `execute-api` interface endpoint's ENIs, one per entry in `private_subnet_ids`, resolved in the root. Registered as the target group's IP targets."}, "listener_port": {"default": 80, "description": "ALB listener port. 80 with the `http-only` origin protocol policy; 443 only if an origin certificate exists, which requires a domain the owner controls."}, "listener_protocol": {"default": "HTTP", "description": "ALB listener protocol. `HTTP` on the CloudFront->ALB hop: an accepted deviation from encryption-in-transit on that hop only. The ALB->endpoint hop is HTTPS regardless."}, "name_prefix": {"description": "Resource name prefix, from the root's `local.name_prefix`."}, "origin_protocol_policy": {"default": "http-only", "description": "How CloudFront connects to the VPC origin. Defaults to `http-only`; `match-viewer` is rejected by validation, since the viewer is always HTTPS and this stack has no origin certificate."}, "private_subnet_ids": {"description": "Private subnet ids for the ALB. Also fixes the plan-time count of endpoint ENIs, since the interface endpoint places one ENI per subnet (see the `count` note in main.tf)."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "vpc_id": {"description": "Id of the adopted VPC the ALB and target group live in (`modules/vpc`'s vpc id output)."}}}, "source": "./modules/api_origin"}, "cognito": {"expressions": {"mcp_client_generate_secret": {"constant_value": true}, "pre_token_generation_lambda_arn": {"references": ["module.lambda_action_pre_token_generation.function_arn", "module.lambda_action_pre_token_generation"]}, "pre_token_generation_lambda_function_name": {"references": ["module.lambda_action_pre_token_generation.function_name", "module.lambda_action_pre_token_generation"]}, "spa_callback_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "spa_logout_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "user_pool_name": {"constant_value": "crm-agent-eval"}}, "module": {"outputs": {"admin_group_name": {"description": "Name of the Cognito group whose members are admin.", "expression": {"references": ["aws_cognito_user_group.admin.name", "aws_cognito_user_group.admin"]}}, "allowed_client_ids": {"description": "The SPA and MCP app client ids, for Gateway #1's authorizer and interceptor `COGNITO_ALLOWED_CLIENT_IDS`. Excludes the MCP OAuth client.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "chat_gateway_allowed_client_ids": {"description": "`allowed_client_ids` plus the MCP OAuth client: Gateway #2's authorizer `allowed_clients` and its interceptor's `COGNITO_ALLOWED_CLIENT_IDS`.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp", "aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "chat_scope_identifier": {"description": "Gateway #2's own `supervisor/chat` scope: its `CUSTOM_JWT` `allowedScopes`, the pre-token trigger's and interceptor's `CHAT_SCOPE`. Distinct from `gateway_scope_identifier`.", "expression": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}}, "domain": {"description": "Cognito user pool prefix domain (no custom ACM certificate). The base for the `/oauth2/token` token endpoint the MCP `client_credentials` flow mints against.", "expression": {"references": ["aws_cognito_user_pool_domain.this.domain", "aws_cognito_user_pool_domain.this"]}}, "gateway_scope_identifier": {"description": "Fully-qualified `/` custom scope\n(`aws_cognito_resource_server.gateway.scope_identifiers[0]`) that the MCP app client's\n`client_credentials` token carries, and the value the AgentCore Gateway's `CUSTOM_JWT` authorizer\nallows (`allowedScopes`). The root composition consumes this output for both.\n", "expression": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway"]}}, "mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "mcp_client_secret": {"description": "App client secret for the MCP client. Sensitive; held in Terraform state and the gitignored results/tf-outputs.json, never in a tracked file. This stack creates no Secrets Manager entry for it.", "expression": {"references": ["aws_cognito_user_pool_client.mcp.client_secret", "aws_cognito_user_pool_client.mcp"]}, "sensitive": true}, "mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, no secret; Gateway #2 only).", "expression": {"references": ["aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "spa_client_id": {"description": "App client id for the SPA (public client, no secret).", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa"]}}, "user_pool_arn": {"description": "Cognito user pool ARN.", "expression": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}}, "user_pool_endpoint": {"description": "Cognito user pool endpoint, used to derive the OIDC discovery and JWKS URLs.", "expression": {"references": ["aws_cognito_user_pool.this.endpoint", "aws_cognito_user_pool.this"]}}, "user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}}, "resources": [{"address": "aws_cognito_resource_server.gateway", "expressions": {"identifier": {"constant_value": "gateway"}, "name": {"constant_value": "AgentCore Gateway"}, "scope": [{"scope_description": {"constant_value": "Invoke the AgentCore Gateway MCP surface machine-to-machine."}, "scope_name": {"constant_value": "invoke"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_resource_server.supervisor", "expressions": {"identifier": {"constant_value": "supervisor"}, "name": {"constant_value": "AgentCore chat Gateway"}, "scope": [{"scope_description": {"constant_value": "Call chat_with_supervisor on the MCP chat Gateway."}, "scope_name": {"constant_value": "chat"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "supervisor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_user_group.admin", "expressions": {"description": {"constant_value": "CRM eval administrators: live sweeps, cancel and unlock."}, "name": {"constant_value": "admin"}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "admin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_group"}, {"address": "aws_cognito_user_pool.this", "expressions": {"account_recovery_setting": [{"recovery_mechanism": [{"name": {"constant_value": "verified_email"}, "priority": {"constant_value": 1}}]}], "admin_create_user_config": [{"allow_admin_create_user_only": {"constant_value": true}}], "auto_verified_attributes": {"constant_value": ["email"]}, "lambda_config": [{"pre_token_generation_config": [{"lambda_arn": {"references": ["var.pre_token_generation_lambda_arn"]}, "lambda_version": {"constant_value": "V2_0"}}]}], "mfa_configuration": {"references": ["var.mfa_configuration"]}, "name": {"references": ["var.user_pool_name"]}, "password_policy": [{"minimum_length": {"constant_value": 14}, "require_lowercase": {"constant_value": true}, "require_numbers": {"constant_value": true}, "require_symbols": {"constant_value": true}, "require_uppercase": {"constant_value": true}, "temporary_password_validity_days": {"constant_value": 7}}], "schema": [{"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "rep_id"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "book"}, "string_attribute_constraints": [{"max_length": {"constant_value": "2048"}, "min_length": {"constant_value": "0"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "full_visibility"}, "string_attribute_constraints": [{"max_length": {"constant_value": "8"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "tenant"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}], "software_token_mfa_configuration": [{"enabled": {"constant_value": true}}], "user_pool_tier": {"constant_value": "ESSENTIALS"}, "username_attributes": {"constant_value": ["email"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool"}, {"address": "aws_cognito_user_pool_client.mcp", "expressions": {"access_token_validity": {"constant_value": 5}, "allowed_oauth_flows": {"constant_value": ["client_credentials"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway", "aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"references": ["var.mcp_client_generate_secret"]}, "name": {"constant_value": "crm-agent-eval-mcp"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "minutes"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.mcp_oauth", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "callback_urls": {"constant_value": ["http://localhost:6274/oauth/callback", "http://localhost:6274/oauth/callback/debug", "http://localhost:33418/callback"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "name": {"constant_value": "crm-agent-eval-mcp-oauth"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp_oauth", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.spa", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"constant_value": ["openid", "email", "profile"]}, "callback_urls": {"references": ["var.spa_callback_urls"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_USER_SRP_AUTH", "ALLOW_REFRESH_TOKEN_AUTH", "ALLOW_ADMIN_USER_PASSWORD_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "logout_urls": {"references": ["var.spa_logout_urls"]}, "name": {"constant_value": "crm-agent-eval-spa"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "spa", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_domain.this", "expressions": {"domain": {"references": ["var.user_pool_name", "aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_domain"}, {"address": "aws_lambda_permission.pre_token_generation", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.pre_token_generation_lambda_function_name"]}, "principal": {"constant_value": "cognito-idp.amazonaws.com"}, "source_arn": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}, "statement_id": {"constant_value": "AllowCognitoInvokePreTokenGeneration"}}, "mode": "managed", "name": "pre_token_generation", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}], "variables": {"mcp_client_generate_secret": {"default": true, "description": "Whether the MCP app client is confidential (generates a client secret) and uses\n`client_credentials`. Defaults to true: the MCP client is a machine-to-machine caller. The stack\ncreates no Secrets Manager entry for the secret; see docs/mcp-client-guide.md.\n"}, "mfa_configuration": {"default": "OPTIONAL", "description": "Pool-level MFA enforcement. Defaults to `OPTIONAL`; the SPA does not implement TOTP enrollment, so\n`ON` makes interactive sign-in through the deployed frontend impossible. TOTP stays enabled either\nway, so a user who enrolls is still challenged.\n\n`OFF` is rejected by validation. Set `ON` once the frontend can complete\n`MFA_SETUP`/`SOFTWARE_TOKEN_MFA`.\n"}, "pre_token_generation_lambda_arn": {"description": "ARN of the pre-token-generation Lambda (V2 event) that stamps `custom:rep_id`,\n`custom:book`, `custom:full_visibility`, and `custom:tenant` into the access\ntoken. Created by the root composition and passed in.\n"}, "pre_token_generation_lambda_function_name": {"description": "Name of the pre-token-generation Lambda, used to scope the\n`aws_lambda_permission` that lets Cognito invoke it. Must be the function\nbehind `pre_token_generation_lambda_arn`.\n"}, "spa_callback_urls": {"description": "Allowed OAuth callback URLs for the SPA app client."}, "spa_logout_urls": {"description": "Allowed OAuth sign-out redirect URLs for the SPA app client."}, "user_pool_name": {"default": "crm-agent-eval", "description": "Name for the Cognito user pool."}}}, "source": "./modules/cognito"}, "dynamodb": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.dynamodb_data_plane_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"gsi_arns": {"description": "Map of logical table name to a map of GSI name to that index's full ARN\n(`/index/`). Consumed by `infra/main.tf`'s per-tool\n`dynamodb_grants[].index_arns`: every `dynamodb:Query` in this schema targets a named GSI (see\n`crm.store.store.query_gsi`), so the grant names the index ARN.\n", "expression": {"references": ["local.tables"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}, "kms_key_id": {"description": "Key ID of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "table_arns": {"description": "Map of logical table name to table ARN.", "expression": {"references": ["local.tables"]}}, "table_names": {"description": "Map of logical table name to physical DynamoDB table name.", "expression": {"references": ["local.tables"]}}, "table_stream_arns": {"description": "Map of logical table name to stream ARN (null where streams are disabled).", "expression": {"references": ["local.tables"]}}}, "resources": [{"address": "aws_dynamodb_resource_policy.tables", "expressions": {"policy": {"references": ["local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.data_plane_principal_arns", "local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.administrator_principal_arns"]}, "resource_arn": {"references": ["each.value.arn", "each.value"]}}, "for_each_expression": {"references": ["local.tables"]}, "mode": "managed", "name": "tables", "provider_config_key": "aws", "schema_version": 0, "type": "aws_dynamodb_resource_policy"}, {"address": "aws_dynamodb_table.accounts", "expressions": {"attribute": [{"name": {"constant_value": "account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner"}, "non_key_attributes": {"constant_value": ["account_id", "owner_rep_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "account_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "accounts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.activities", "expressions": {"attribute": [{"name": {"constant_value": "activity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "occurred_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["activity_id", "account_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "activity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "activities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.audit_records", "expressions": {"attribute": [{"name": {"constant_value": "audit_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["audit_id", "target_table", "target_id", "actor_rep_id", "reversed_at", "account_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["audit_id", "actor_rep_id", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["audit_id", "account_id", "target_id", "target_table", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "audit_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "audit_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.contacts", "expressions": {"attribute": [{"name": {"constant_value": "contact_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "contact_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "contacts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_results", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "result_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "run_id_task_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "arm"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "run_id_task_id"}, "name": {"constant_value": "gsi_task"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "result_id", "arm"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "arm"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "range_key": {"constant_value": "result_id"}, "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_results", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_runs", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "started_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "status"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "started_at"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_runs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.notes", "expressions": {"attribute": [{"name": {"constant_value": "note_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "note_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "notes", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.opportunities", "expressions": {"attribute": [{"name": {"constant_value": "opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "stage_close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_stage"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "stage_close_date"}}, {"hash_key": {"constant_value": "tenant_stage"}, "name": {"constant_value": "gsi_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "close_date"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "opportunity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "opportunities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.proposals", "expressions": {"attribute": [{"name": {"constant_value": "proposal_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["proposal_id", "status", "target_table", "target_id", "actor_rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["proposal_id", "actor_rep_id", "status", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["proposal_id", "target_table", "target_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["proposal_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "proposal_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "proposals", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.reps", "expressions": {"attribute": [{"name": {"constant_value": "rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "rep_id"}}], "hash_key": {"constant_value": "rep_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "reps", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.usage_records", "expressions": {"attribute": [{"name": {"constant_value": "usage_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_correlation_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_correlation_id"}, "name": {"constant_value": "gsi_correlation"}, "non_key_attributes": {"constant_value": ["usage_id", "correlation_id", "run_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_run_id"}, "name": {"constant_value": "gsi_run"}, "non_key_attributes": {"constant_value": ["usage_id", "run_id", "correlation_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["usage_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "usage_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "usage_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_kms_alias.dynamodb", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.dynamodb", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM DynamoDB table encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.dynamodb", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.dynamodb.id", "aws_kms_key.dynamodb"]}, "policy": {"references": ["var.account_id", "var.data_plane_principal_arns", "var.administrator_principal_arns"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"account_id": {"description": "Account id of the account-root statement in the CMK key policy."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to table and CMK administration. Every other principal is denied by the table and key policies."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The table and key policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the tables' data plane and to the CMK's key use. Every other principal is denied by the table and key policies."}, "name_prefix": {"default": "", "description": "Prefix applied to table and alias names, e.g. tenant or environment scoping."}}}, "source": "./modules/dynamodb"}, "eni_function_code_deny": {"expressions": {"name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"policy_arn": {"description": "ARN of the ENI function-code Deny policy, passed to every `lambda_action` and `agent_relay` instantiation.", "expression": {"references": ["aws_iam_policy.this.arn", "aws_iam_policy.this"]}}}, "resources": [{"address": "aws_iam_policy.this", "expressions": {"description": {"constant_value": "Denies the Hyperplane ENI actions to Lambda function code; Lambda's own ENI management is unaffected."}, "name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.this.json", "data.aws_iam_policy_document.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "data.aws_iam_policy_document.this", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:DetachNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "condition": [{"test": {"constant_value": "Null"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "lambda:SourceFunctionArn"}}], "effect": {"constant_value": "Deny"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyEniActionsToFunctionCode"}}]}, "mode": "data", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the policy name."}}}, "source": "./modules/eni_function_code_deny"}, "eval_artifacts": {"expressions": {"access_log_bucket_id": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns"]}, "kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "name_prefix": {"references": ["local.name_prefix"]}, "writer_role_name": {"constant_value": null}}, "module": {"outputs": {"artifact_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the writer grant covers.", "expression": {"references": ["var.artifact_prefix"]}}, "bucket_arn": {"description": "ARN of the eval-artefacts bucket, for a consumer composing its own policy against it.", "expression": {"references": ["aws_s3_bucket.this.arn", "aws_s3_bucket.this"]}}, "bucket_name": {"description": "Name of the eval-artefacts bucket, which embeds the account id. Read by application code and the smoke suite.", "expression": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}}}, "resources": [{"address": "aws_iam_role_policy.writer", "count_expression": {"references": ["var.writer_role_name"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.writer.json", "data.aws_iam_policy_document.writer"]}, "role": {"references": ["var.writer_role_name"]}}, "mode": "managed", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_s3_bucket.this", "expressions": {"bucket": {"references": ["local.bucket_name"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.artifact_retention_days"]}}], "filter": [{"prefix": {"references": ["var.artifact_prefix"]}}], "id": {"constant_value": "expire-artifacts"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}, {"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-noncurrent-and-abort-uploads"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "target_bucket": {"references": ["var.access_log_bucket_id"]}, "target_prefix": {"constant_value": "s3-access-logs/eval-artifacts/"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "policy": {"references": ["data.aws_iam_policy_document.bucket.json", "data.aws_iam_policy_document.bucket"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.this", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["var.kms_key_arn"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_iam_policy_document.bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"constant_value": ["aws:kms"]}, "variable": {"constant_value": "s3:x-amz-server-side-encryption"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyUnencryptedObjectUploads"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.data_plane_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.writer", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bucket_arn", "var.artifact_prefix"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.kms_key_arn"]}, "sid": {"constant_value": "UseBucketCmk"}}]}, "mode": "data", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}], "variables": {"access_log_bucket_id": {"description": "Bucket id receiving this bucket S3 access logs. Must be a different bucket."}, "account_id": {"description": "AWS account id, part of the globally-unique bucket name. Passed in by the caller so the module plans offline."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to bucket administration. Every other principal is denied it by the bucket policy."}, "artifact_prefix": {"default": "sweeps", "description": "Single key prefix all artefacts are written under, and the only prefix the writer grant covers."}, "artifact_retention_days": {"default": 30, "description": "Lifecycle expiry in days, applied to current objects, noncurrent versions and incomplete multipart\nuploads alike. Artefacts are reproducible from a sweep with the same arguments and `dataset_seed`.\n"}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The bucket policy refuses to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"description": "Value of the mandatory `data-classification` tag."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the bucket's object reads, lists and writes. Every other principal is denied them by the bucket policy."}, "kms_key_arn": {"description": "Customer-managed key ARN encrypting this bucket's objects, and the key the writer grant covers.\nCreated by the caller; it must be a dedicated key (see README).\n"}, "name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the bucket name alongside the account id."}, "writer_role_name": {"default": null, "description": "IAM role name the writer policy is attached to (the sweep worker's role). `null` (the default)\nattaches nothing. The grant's scope comes from the policy's own resources, not from this value.\n"}}}, "source": "./modules/eval_artifacts"}, "frontend_cdn": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "agent_relay_function_name": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}, "agent_relay_function_url_domain": {"references": ["module.agent_relay.function_url_domain", "module.agent_relay"]}, "alb_access_log_prefix": {"references": ["local.alb_access_log_prefix"]}, "api_gateway_domain_name": {"references": ["module.api.private_origin_domain_name", "module.api"]}, "api_gateway_stage_name": {"references": ["module.api.stage_name", "module.api"]}, "api_origin_vpc_origin_id": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "csp_connect_src_extra": {"references": ["local.spa_connect_src_extra"]}, "csp_script_hashes": {"references": ["local.spa_inline_script_hashes"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 90}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}, "origin_noncurrent_version_retention_days": {"constant_value": 30}}, "module": {"outputs": {"distribution_arn": {"description": "ARN of the CloudFront distribution, used by the origin bucket policy's `AWS:SourceArn` condition.", "expression": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}}, "distribution_domain_name": {"description": "CloudFront distribution domain name (e.g. `d111111abcdef8.cloudfront.net`).", "expression": {"references": ["aws_cloudfront_distribution.frontend.domain_name", "aws_cloudfront_distribution.frontend"]}}, "distribution_id": {"description": "ID of the CloudFront distribution.", "expression": {"references": ["aws_cloudfront_distribution.frontend.id", "aws_cloudfront_distribution.frontend"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the origin bucket.", "expression": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}}, "logs_bucket_name": {"description": "Name of the S3 bucket receiving S3 access logs and CloudFront access logs.", "expression": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}}, "origin_bucket_arn": {"description": "ARN of the private S3 origin bucket.", "expression": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}}, "origin_bucket_name": {"description": "Name of the private S3 bucket that holds the frontend static build.", "expression": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}}}, "resources": [{"address": "aws_cloudfront_distribution.frontend", "expressions": {"comment": {"references": ["var.name_prefix"]}, "default_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_optimized.id", "data.aws_cloudfront_cache_policy.caching_optimized"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.spa_history_fallback.arn", "aws_cloudfront_function.spa_history_fallback"]}}], "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "s3-frontend-origin"}, "viewer_protocol_policy": {"constant_value": "redirect-to-https"}}], "default_root_object": {"constant_value": "index.html"}, "enabled": {"constant_value": true}, "logging_config": [{"bucket": {"references": ["aws_s3_bucket.logs.bucket_domain_name", "aws_s3_bucket.logs"]}, "include_cookies": {"constant_value": false}, "prefix": {"constant_value": "cloudfront-access-logs/"}}], "ordered_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.api_path_rewrite.arn", "aws_cloudfront_function.api_path_rewrite"]}}], "origin_request_policy_id": {"references": ["data.aws_cloudfront_origin_request_policy.all_viewer_except_host.id", "data.aws_cloudfront_origin_request_policy.all_viewer_except_host"]}, "path_pattern": {"constant_value": "/api/*"}, "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "api-gateway-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}, {"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": false}, "origin_request_policy_id": {"references": ["aws_cloudfront_origin_request_policy.agent_relay.id", "aws_cloudfront_origin_request_policy.agent_relay"]}, "path_pattern": {"constant_value": "/agent/*"}, "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "agent-relay-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}], "origin": [{"domain_name": {"references": ["aws_s3_bucket.origin.bucket_regional_domain_name", "aws_s3_bucket.origin"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.origin.id", "aws_cloudfront_origin_access_control.origin"]}, "origin_id": {"constant_value": "s3-frontend-origin"}}, {"domain_name": {"references": ["var.api_gateway_domain_name"]}, "origin_id": {"constant_value": "api-gateway-origin"}, "vpc_origin_config": [{"vpc_origin_id": {"references": ["var.api_origin_vpc_origin_id"]}}]}, {"custom_origin_config": [{"http_port": {"constant_value": 80}, "https_port": {"constant_value": 443}, "origin_protocol_policy": {"constant_value": "https-only"}, "origin_read_timeout": {"constant_value": 60}, "origin_ssl_protocols": {"constant_value": ["TLSv1.2"]}}], "domain_name": {"references": ["var.agent_relay_function_url_domain"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.agent_relay.id", "aws_cloudfront_origin_access_control.agent_relay"]}, "origin_id": {"constant_value": "agent-relay-origin"}}], "price_class": {"constant_value": "PriceClass_100"}, "restrictions": [{"geo_restriction": [{"restriction_type": {"constant_value": "none"}}]}], "tags": {"references": ["var.data_classification"]}, "viewer_certificate": [{"cloudfront_default_certificate": {"constant_value": true}}]}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudfront_distribution"}, {"address": "aws_cloudfront_function.api_path_rewrite", "expressions": {"code": {"references": ["path.module", "var.api_gateway_stage_name"]}, "comment": {"constant_value": "Rewrite /api/* onto the REST API's stage path"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "api_path_rewrite", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_function.spa_history_fallback", "expressions": {"code": {"references": ["path.module"]}, "comment": {"constant_value": "Serve /index.html for SPA client-side routes"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "spa_history_fallback", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_origin_access_control.agent_relay", "expressions": {"description": {"constant_value": "SigV4-signs origin requests to the relay's AWS_IAM Function URL"}, "name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "lambda"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_access_control.origin", "expressions": {"name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "s3"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_request_policy.agent_relay", "expressions": {"comment": {"constant_value": "Forward every viewer header except Host to the relay origin"}, "cookies_config": [{"cookie_behavior": {"constant_value": "all"}}], "headers_config": [{"header_behavior": {"constant_value": "allExcept"}, "headers": [{"items": {"constant_value": ["host"]}}]}], "name": {"references": ["var.name_prefix"]}, "query_strings_config": [{"query_string_behavior": {"constant_value": "all"}}]}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "aws_cloudfront_response_headers_policy.security_headers", "expressions": {"comment": {"constant_value": "Security headers and an enforced Content-Security-Policy for the CRM frontend"}, "name": {"references": ["var.name_prefix"]}, "security_headers_config": [{"content_security_policy": [{"content_security_policy": {"references": ["local.content_security_policy"]}, "override": {"constant_value": true}}], "content_type_options": [{"override": {"constant_value": true}}], "frame_options": [{"frame_option": {"constant_value": "DENY"}, "override": {"constant_value": true}}], "referrer_policy": [{"override": {"constant_value": true}, "referrer_policy": {"constant_value": "strict-origin-when-cross-origin"}}], "strict_transport_security": [{"access_control_max_age_sec": {"constant_value": 31536000}, "include_subdomains": {"constant_value": true}, "override": {"constant_value": true}, "preload": {"constant_value": true}}], "xss_protection": [{"mode_block": {"constant_value": true}, "override": {"constant_value": true}, "protection": {"constant_value": true}}]}]}, "mode": "managed", "name": "security_headers", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_response_headers_policy"}, {"address": "aws_kms_alias.frontend", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.frontend.key_id", "aws_kms_key.frontend"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.frontend", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM frontend CDN origin bucket encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.frontend", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.frontend.id", "aws_kms_key.frontend"]}, "policy": {"references": ["data.aws_iam_policy_document.frontend_kms.json", "data.aws_iam_policy_document.frontend_kms"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_lambda_permission.agent_relay_function_url", "expressions": {"action": {"constant_value": "lambda:InvokeFunctionUrl"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "function_url_auth_type": {"constant_value": "AWS_IAM"}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunctionUrl"}}, "mode": "managed", "name": "agent_relay_function_url", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_lambda_permission.agent_relay_invoke_function", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunction"}}, "mode": "managed", "name": "agent_relay_invoke_function", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_s3_bucket.logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.origin", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-superseded-builds"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.origin_noncurrent_version_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "target_bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "target_prefix": {"constant_value": "s3-access-logs/origin/"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerPreferred"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "policy": {"references": ["data.aws_iam_policy_document.logs_tls_deny.json", "data.aws_iam_policy_document.logs_tls_deny"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "policy": {"references": ["data.aws_iam_policy_document.origin.json", "data.aws_iam_policy_document.origin"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.origin", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_cloudfront_cache_policy.caching_disabled", "expressions": {"name": {"constant_value": "Managed-CachingDisabled"}}, "mode": "data", "name": "caching_disabled", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_cache_policy.caching_optimized", "expressions": {"name": {"constant_value": "Managed-CachingOptimized"}}, "mode": "data", "name": "caching_optimized", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_origin_request_policy.all_viewer_except_host", "expressions": {"name": {"constant_value": "Managed-AllViewerExceptHostHeader"}}, "mode": "data", "name": "all_viewer_except_host", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "data.aws_iam_policy_document.frontend_kms", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudFrontOACDecrypt"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "frontend_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_partition.current.partition", "data.aws_partition.current", "data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logdelivery.elasticloadbalancing.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "var.alb_access_log_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AllowAlbAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.origin", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "AllowCloudFrontOACRead"}}, {"actions": {"constant_value": ["s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyObjectWritesToNonOperators"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of the frontend CMK and the origin bucket. Every other principal is denied it."}, "agent_relay_function_name": {"description": "The relay function name (`module.agent_relay.function_name`), for the distribution-scoped `lambda:InvokeFunctionUrl` permission this module declares."}, "agent_relay_function_url_domain": {"description": "Host portion of the relay's Lambda Function URL that the `/agent/*` behaviour routes to (`module.agent_relay.function_url_domain`). The browser reaches the Runtime only through the relay."}, "alb_access_log_prefix": {"description": "Key prefix the internal ALB writes access logs under, used to scope this module ELB log-delivery grant to `//AWSLogs//*`. No default; it must equal the prefix the load balancer is configured with, and the root passes one local to both modules."}, "api_gateway_domain_name": {"description": "Origin hostname for the `/api/*` behaviour, from `module.api.private_origin_domain_name` (`-.execute-api..amazonaws.com`). It is the `Host` header the private REST API routes on, not a name CloudFront resolves; the VPC origin routes by ALB ARN."}, "api_gateway_stage_name": {"description": "Stage name the REST API serves its routes beneath (`infra/modules/api/` `stage_name`). The `/api/*` viewer-request function rewrites `/api/` to `//`, since CloudFront forwards the viewer path to a custom origin unchanged."}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin fronting the private REST API (`module.api_origin.vpc_origin_id`), consumed by the `/api/*` origin `vpc_origin_config`."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and origin-bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "csp_connect_src_extra": {"description": "Origins (`https://`) added to the CSP `connect-src` beside `'self'`: the endpoints the SPA calls directly, such as the regional Cognito user-pool endpoint and the hosted-UI domain."}, "csp_script_hashes": {"description": "CSP source hashes (`sha256-`, unquoted) of the SPA's inline scripts, added to `script-src` beside `'self'`."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "log_retention_days": {"default": 90, "description": "Retention, in days, for the S3 bucket holding S3 access logs and CloudFront access logs."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to frontend-CMK use and to writes into the origin bucket."}, "origin_noncurrent_version_retention_days": {"default": 30, "description": "Days a superseded (noncurrent) object version in the origin bucket is kept before it expires. Current objects never expire."}}}, "source": "./modules/frontend_cdn"}, "lambda_action": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "config_parameter_arns": {"references": ["local.routed_tool_names", "each.key", "local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["local.routed_tool_names", "each.key", "aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "cursor_kms_grant_enabled": {"references": ["local.cursor_tools", "each.key"]}, "cursor_kms_key_arn": {"references": ["local.cursor_tools", "each.key", "aws_kms_key.cursor.arn", "aws_kms_key.cursor"]}, "denied_own_table_actions": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.tool_dynamodb_grants", "each.key"]}, "dynamodb_grants": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.tool_query_indexes", "each.key", "local.tool_query_indexes", "each.key", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "local.tool_query_indexes", "each.key"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.routed_tool_names", "each.key", "local.api_allowed_client_ids_parameter_name", "local.cursor_tools", "each.key", "aws_kms_key.cursor.arn", "aws_kms_key.cursor"]}, "filename": {"references": ["var.lambda_build_dir", "each.key"]}, "function_name": {"references": ["each.key"]}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"references": ["each.value.handler", "each.value"]}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency", "each.key"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir", "each.key"]}, "table_action_role_matrix_entries": {"references": ["local.tool_dynamodb_grants", "each.key", "each.key"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "for_each_expression": {"references": ["local.tools"]}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_capabilities": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"constant_value": []}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.api_allowed_client_ids_parameter_name"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-capabilities"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.capabilities.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"capabilities\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_gateway_allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_target": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.chat_target.lambda_handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_target\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix", "local.name_prefix"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_eval_trigger": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.eval_trigger_eval_runs_grants", "module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["local.eval_trigger_eval_runs_grants"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.api_allowed_client_ids_parameter_name", "local.eval_sweep_state_machine_arn", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-eval-trigger"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.eval_trigger.handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"eval_trigger\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.gateway_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-identity-interceptor"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"identity_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "leading_keys", "leading_keys_enforced": true, "role": "crm-agent-eval-identity-interceptor-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_pre_token_generation": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.chat_scope_identifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-pre-token-generation"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "crm.auth.pre_token_generation.lambda_handler"}, "memory_size_mb": {"constant_value": 128}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"pre_token_generation\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "not_applicable", "leading_keys_enforced": false, "role": "crm-agent-eval-pre-token-generation-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_control": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_control_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_control_granted_tables"]}, "dynamodb_allow_statements_per_policy": {"constant_value": 20}, "dynamodb_grants": {"references": ["local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-control"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_control_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_control\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 120}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_task": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_task_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_task_granted_tables"]}, "dynamodb_grants": {"references": ["local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-task"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_task_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_task\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 300}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_user_settings": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.api_allowed_client_ids_parameter_name"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.user_settings.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"user_settings\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.13"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.13", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "mcp_chat_gateway": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "aws_region": {"references": ["var.aws_region"]}, "chat_target_lambda_arn": {"references": ["module.lambda_action_chat_target.function_arn", "module.lambda_action_chat_target"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.chat_gateway_allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.chat_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "gateway_name": {"references": ["local.name_prefix"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_chat_interceptor.function_arn", "module.lambda_action_chat_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_chat_interceptor.function_name", "module.lambda_action_chat_interceptor"]}, "role_name": {"references": ["local.name_prefix"]}, "tags": {"references": ["var.data_classification"]}}, "module": {"outputs": {"gateway_arn": {"description": "Gateway #2 ARN; the interceptor permission's `source_arn`.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "Gateway #2 id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_url": {"description": "MCP endpoint URL of Gateway #2.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}, "role_arn": {"description": "Gateway #2 execution role ARN; the only Gateway principal admitted by the chat target's resource policy.", "expression": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}}, "role_name": {"description": "Gateway #2 execution role name.", "expression": {"references": ["aws_iam_role.gateway.name", "aws_iam_role.gateway"]}}}, "resources": [{"address": "aws_bedrockagentcore_gateway.this", "depends_on": ["aws_iam_role_policy.gateway"], "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "protocol_configuration": [{"mcp": [{"supported_versions": {"constant_value": ["2025-03-26", "2025-06-18", "2025-11-25"]}}]}], "protocol_type": {"constant_value": "MCP"}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.chat", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"constant_value": "Gateway target for chat_with_supervisor, backed by the chat_target Lambda."}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"constant_value": "chat-with-supervisor"}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["var.chat_target_lambda_arn"]}, "tool_schema": [{"inline_payload": [{"description": {"constant_value": "Send one message to the CRM supervisor agent and receive its answer. Pass the returned conversation_id on later calls to continue the same conversation."}, "input_schema": [{"property": [{"description": {"constant_value": "The message to send, 1 to 8000 characters."}, "name": {"constant_value": "message"}, "required": {"constant_value": true}, "type": {"constant_value": "string"}}, {"description": {"constant_value": "A conversation_id returned by an earlier call; omit to start a new conversation."}, "name": {"constant_value": "conversation_id"}, "required": {"constant_value": false}, "type": {"constant_value": "string"}}], "type": {"constant_value": "object"}}], "name": {"constant_value": "chat_with_supervisor"}}]}]}]}]}]}, "mode": "managed", "name": "chat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_iam_role.gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.role_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.gateway", "expressions": {"name": {"references": ["var.role_name"]}, "policy": {"references": ["data.aws_iam_policy_document.gateway_permissions.json", "data.aws_iam_policy_document.gateway_permissions"]}, "role": {"references": ["aws_iam_role.gateway.id", "aws_iam_role.gateway"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_account": {"references": ["var.account_id"]}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowChatGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.account_id"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["var.aws_region", "var.account_id"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.chat_target_lambda_arn"]}, "sid": {"constant_value": "InvokeChatTarget"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.identity_interceptor_lambda_arn"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"account_id": {"description": "Account id for the trust policy's `aws:SourceAccount` and `aws:SourceArn` conditions and the interceptor permission's `source_account`."}, "aws_region": {"description": "Region of the gateway; also the region segment of the trust policy's `aws:SourceArn` pattern."}, "chat_target_lambda_arn": {"description": "ARN of the `chat_with_supervisor` target Lambda; the only target this gateway's role may invoke."}, "cognito_allowed_client_ids": {"description": "Cognito app client ids the `CUSTOM_JWT` authorizer accepts, as on Gateway #1."}, "cognito_allowed_scopes": {"description": "Scopes the `CUSTOM_JWT` authorizer accepts: this gateway's own chat scope, never Gateway #1's."}, "cognito_discovery_url": {"description": "OIDC discovery URL of the Cognito user pool, as on Gateway #1."}, "gateway_name": {"description": "Name of the AgentCore Gateway."}, "identity_interceptor_lambda_arn": {"description": "ARN of the shared REQUEST interceptor Lambda."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the shared REQUEST interceptor Lambda, for this gateway's invoke permission."}, "role_name": {"description": "Name of this gateway's own execution role."}, "tags": {"default": {}, "description": "Tags for the gateway and its role. The provider's default_tags carries the mandatory set."}}}, "source": "./modules/mcp_chat_gateway"}, "observability": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 365}, "logs_key_user_principal_arns": {"references": ["local.logs_key_user_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}}, "module": {"outputs": {"cloudtrail_access_logs_bucket_name": {"description": "Name of the S3 bucket receiving the CloudTrail delivery bucket's own S3 server access logs (`aws_s3_bucket_logging.cloudtrail`'s target). Distinct from `cloudtrail_s3_bucket_name`, which is the source of those logs.", "expression": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}}, "cloudtrail_arn": {"description": "ARN of the CloudTrail trail for API activity.", "expression": {"references": ["aws_cloudtrail.this.arn", "aws_cloudtrail.this"]}}, "cloudtrail_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the CloudTrail S3 destination bucket.", "expression": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}}, "cloudtrail_s3_bucket_name": {"description": "Name of the S3 bucket CloudTrail delivers log files to: the log source whose access logs land in `cloudtrail_access_logs_bucket_name`.", "expression": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}}, "cloudwatch_logs_kms_key_arn": {"description": "ARN of the customer-managed KMS key for CloudWatch Logs log-group encryption. Sibling modules' `aws_cloudwatch_log_group` resources pass this as `kms_key_id`.", "expression": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}}, "cloudwatch_logs_kms_key_id": {"description": "Key ID of the customer-managed KMS key for CloudWatch Logs log-group encryption.", "expression": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "eval_metric_namespace": {"description": "CloudWatch custom metric namespace reserved for eval-run metrics; passthrough of `var.eval_metric_namespace`.", "expression": {"references": ["var.eval_metric_namespace"]}}}, "resources": [{"address": "aws_cloudtrail.this", "depends_on": ["aws_s3_bucket_policy.cloudtrail"], "expressions": {"cloud_watch_logs_group_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}, "cloud_watch_logs_role_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_iam_role.cloudtrail_cloudwatch_logs[0].arn", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}, "enable_log_file_validation": {"constant_value": true}, "event_selector": [{"include_management_events": {"constant_value": true}, "read_write_type": {"constant_value": "All"}}], "include_global_service_events": {"constant_value": true}, "is_multi_region_trail": {"constant_value": true}, "kms_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "name": {"references": ["local.cloudtrail_name"]}, "s3_bucket_name": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudtrail"}, {"address": "aws_cloudwatch_log_group.cloudtrail", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"kms_key_id": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery"]}, "role": {"references": ["aws_iam_role.cloudtrail_cloudwatch_logs[0].id", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.cloudtrail", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.cloudtrail.key_id", "aws_kms_key.cloudtrail"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.logs", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.cloudtrail", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudTrail S3 log destination encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cmk.json", "data.aws_iam_policy_document.cloudtrail_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.logs", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudWatch Logs log group encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudwatch_logs_cmk.json", "data.aws_iam_policy_document.cloudwatch_logs_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_s3_bucket.cloudtrail", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-trail-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "target_bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "target_prefix": {"constant_value": "s3-access-logs/cloudtrail/"}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_bucket.json", "data.aws_iam_policy_document.cloudtrail_bucket"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny.json", "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail_access_logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs", "aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "cloudtrail_access_logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetBucketAcl"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "AWSCloudTrailAclCheck"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}, {"test": {"constant_value": "StringEquals"}, "values": {"constant_value": ["bucket-owner-full-control"]}, "variable": {"constant_value": "s3:x-amz-acl"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AWSCloudTrailWrite"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "BoolIfExists"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_assume", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:GenerateDataKey*"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToEncryptLogs"}}, {"actions": {"constant_value": ["kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToDescribeKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:ReEncryptFrom"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:CallerAccount"}}, {"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowPrincipalsInAccountToDecryptLogFiles"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudwatch_logs_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:Describe*"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:logs:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_region.current.region", "data.aws_region.current"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudWatchLogsUseOfTheKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.logs_key_user_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudwatch_logs_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of both CMKs and of the CloudTrail bucket. Every other principal is denied it."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "cloudtrail_s3_log_retention_days": {"default": 365, "description": "Lifecycle expiration, in days, for CloudTrail delivered log objects in the trail S3 destination bucket."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "enable_cloudtrail_cloudwatch_logs": {"default": false, "description": "Whether the trail also delivers to a CloudWatch Logs log group (via\n`cloud_watch_logs_group_arn`/`cloud_watch_logs_role_arn`), in addition to its S3 destination.\nDefaults to false. The CMK this module creates already grants `logs..amazonaws.com` the\nactions CloudWatch Logs needs.\n"}, "eval_metric_namespace": {"default": "CrmAgentEval/Eval", "description": "CloudWatch custom metric namespace reserved for eval-run metrics. No code\nunder `src/` publishes a CloudWatch metric; eval metrics are written to the\n`matrix.json`/`.md`/`.csv` report files instead.\n"}, "log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the CloudTrail CloudWatch Logs integration log group this module creates."}, "logs_key_user_principal_arns": {"description": "IAM role or user ARNs admitted to key use on the CloudWatch Logs CMK: every execution role whose Lambda environment the key encrypts, plus the operators. Every other non-service principal is denied key use."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to CloudTrail-key use and to the CloudTrail bucket's data plane."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}}}, "source": "./modules/observability"}, "vpc": {"expressions": {"flow_log_enabled": {"references": ["var.vpc_flow_log_enabled"]}, "flow_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "gateway_endpoint_service_names": {"constant_value": ["s3", "dynamodb"]}, "interface_endpoint_service_names": {"references": ["local.vpc_interface_endpoint_services"]}, "name_prefix": {"references": ["local.name_prefix"]}, "nat_gateway_enabled": {"references": ["var.vpc_nat_gateway_enabled"]}, "nat_public_subnet_id": {"references": ["var.vpc_nat_public_subnet_id"]}, "private_route_table_ids": {"references": ["var.vpc_private_route_table_ids"]}, "private_subnet_ids": {"references": ["var.vpc_private_subnet_ids"]}, "region": {"references": ["var.aws_region"]}, "runtime_route_table_ids": {"references": ["var.vpc_runtime_route_table_ids"]}, "runtime_subnet_ids": {"references": ["var.vpc_runtime_subnet_ids"]}, "tags": {"references": ["var.data_classification"]}, "vpc_cidr_block": {"references": ["var.vpc_cidr_block"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "module": {"outputs": {"bedrock_agentcore_vpc_endpoint_id": {"description": "The `bedrock-agentcore` interface endpoint's id, for the runtime resource policies' `aws:SourceVpce`\ncondition: the Deny keyed on it denies every caller not arriving through this endpoint. Read from the\nendpoint map by key. Fails at plan time if `bedrock-agentcore` is absent from the interface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"bedrock-agentcore\"].id", "aws_vpc_endpoint.interface[\"bedrock-agentcore\"]", "aws_vpc_endpoint.interface"]}}, "endpoint_security_group_id": {"description": "The interface-endpoint security group's id.", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_network_interface_ids": {"description": "The `execute-api` endpoint's ENI ids, for the private-origin ALB's target group.\n\n`modules/api_origin` indexes this list positionally under `count = length(var.private_subnet_ids)`,\nso it holds exactly one entry per private subnet; the precondition below asserts the length.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].network_interface_ids", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "execute_api_security_group_id": {"description": "The security group on the `execute-api` endpoint's ENIs, and the ALB's single egress destination.\nEvery interface endpoint in this module shares it; its ingress is 443 from the Lambda group, plus\nthe ALB's 443 ingress rule, which the root composition attaches.\n", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_vpc_endpoint_id": {"description": "The `execute-api` interface endpoint's id, for the private REST API's\n`endpoint_configuration.vpc_endpoint_ids` and its resource-policy allowlist. Read from the endpoint\nmap by key. Fails at plan time if `execute-api` is absent from the endpoint list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].id", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Read by the access-log delivery smoke check as its source-side target.", "expression": {"references": ["var.flow_log_enabled", "aws_cloudwatch_log_group.flow_logs[0].name", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}}, "gateway_endpoint_service_names": {"description": "Fully-qualified service names of the gateway endpoints created.", "expression": {"references": ["aws_vpc_endpoint.gateway"]}}, "interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created, for a Layer 4 check asserting the deployed set.", "expression": {"references": ["aws_vpc_endpoint.interface"]}}, "lambda_security_group_ids": {"description": "The single Lambda security group, for the `security_group_ids` half of every Lambda `vpc_config`. No ingress.", "expression": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}}, "lambda_subnet_ids": {"description": "Private subnet ids, for the `subnet_ids` half of every Lambda `vpc_config`. Returns `var.private_subnet_ids` alone, sorted; a precondition in `nat.tf` asserts `var.nat_public_subnet_id` is absent from it.", "expression": {"references": ["var.private_subnet_ids"]}}, "nat_gateway_public_ip": {"description": "The NAT gateway Elastic IP, or null when NAT is disabled. A Layer 4 check asserts the relay egress leaves by this address.", "expression": {"references": ["var.nat_gateway_enabled", "aws_eip.nat[0].public_ip", "aws_eip.nat[0]", "aws_eip.nat"]}}, "runtime_security_group_id": {"description": "The dedicated AgentCore Runtime security group's id, for the Runtime's VPC-mode\n`network_mode_config.security_groups`. No ingress; egress only to the endpoint group and the gateway\nprefix lists. Distinct from `lambda_security_group_ids`.\n", "expression": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}}, "runtime_subnet_ids": {"description": "The Runtime VPC-mode subnet ids, for the Runtime `network_mode_config.subnets`. Returns `var.runtime_subnet_ids` sorted. Empty when the Runtime is not in VPC mode.", "expression": {"references": ["var.runtime_subnet_ids"]}}, "states_vpc_endpoint_id": {"description": "The `states` interface endpoint's id, for the root's endpoint policy scoping it to the eval sweep.\nRead from the endpoint map by key. Fails at plan time if `states` is absent from the\ninterface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"states\"].id", "aws_vpc_endpoint.interface[\"states\"]", "aws_vpc_endpoint.interface"]}}, "vpc_cidr_block": {"description": "The VPC's IPv4 CIDR.", "expression": {"references": ["var.vpc_cidr_block"]}}, "vpc_id": {"description": "The VPC's id.", "expression": {"references": ["var.vpc_id"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"kms_key_id": {"references": ["var.flow_log_kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.flow_log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_eip.nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"domain": {"constant_value": "vpc"}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_eip"}, {"address": "aws_flow_log.this", "count_expression": {"references": ["var.flow_log_enabled"]}, "depends_on": ["aws_iam_role_policy.flow_logs"], "expressions": {"iam_role_arn": {"references": ["aws_iam_role.flow_logs[0].arn", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}, "log_destination": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "log_destination_type": {"constant_value": "cloud-watch-logs"}, "max_aggregation_interval": {"constant_value": 60}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "traffic_type": {"constant_value": "ALL"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_flow_log"}, {"address": "aws_iam_role.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.flow_logs_assume_role[0].json", "data.aws_iam_policy_document.flow_logs_assume_role[0]", "data.aws_iam_policy_document.flow_logs_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.flow_logs_delivery[0].json", "data.aws_iam_policy_document.flow_logs_delivery[0]", "data.aws_iam_policy_document.flow_logs_delivery"]}, "role": {"references": ["aws_iam_role.flow_logs[0].id", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_nat_gateway.this", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"allocation_id": {"references": ["aws_eip.nat[0].id", "aws_eip.nat[0]", "aws_eip.nat"]}, "subnet_id": {"references": ["var.nat_public_subnet_id"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_nat_gateway"}, {"address": "aws_route.private_nat", "expressions": {"destination_cidr_block": {"constant_value": "0.0.0.0/0"}, "nat_gateway_id": {"references": ["aws_nat_gateway.this[0].id", "aws_nat_gateway.this[0]", "aws_nat_gateway.this"]}, "route_table_id": {"references": ["each.value"]}}, "for_each_expression": {"references": ["var.nat_gateway_enabled", "var.private_route_table_ids"]}, "mode": "managed", "name": "private_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_route"}, {"address": "aws_security_group.agent_runtime", "expressions": {"description": {"constant_value": "AgentCore Runtime ENIs: no ingress, egress only to the VPC endpoint group and gateway prefix lists on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "agent_runtime", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.endpoints", "expressions": {"description": {"constant_value": "Interface VPC endpoint ENIs: ingress 443 from the Lambda group only, no egress."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "endpoints", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.lambda", "expressions": {"description": {"constant_value": "Lambda ENIs: no ingress, egress only to the VPC endpoint group on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "lambda", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_endpoint.gateway", "expressions": {"route_table_ids": {"references": ["var.private_route_table_ids", "var.runtime_route_table_ids"]}, "service_name": {"references": ["var.region", "each.key"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Gateway"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_endpoint.interface", "expressions": {"private_dns_enabled": {"references": ["var.private_dns_disabled_services", "each.key"]}, "security_group_ids": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "service_name": {"references": ["var.region", "each.key"]}, "subnet_ids": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Interface"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.interface_endpoint_service_names"]}, "mode": "managed", "name": "interface", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. Reaches bedrock-runtime, ecr.api, ecr.dkr, lambda and logs cross-AZ via private DNS."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "agent_runtime_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "agent_runtime_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_https_via_nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"cidr_ipv4": {"constant_value": "0.0.0.0/0"}, "description": {"constant_value": "HTTPS egress via the NAT gateway for the relay Cognito JWKS fetch."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_https_via_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. The only in-VPC egress any Lambda has."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "lambda_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_agent_runtime", "expressions": {"description": {"constant_value": "HTTPS from the Runtime ENIs. The second SG source on the endpoint group, alongside the Lambda group and the root module ALB rule."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_agent_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_lambda", "expressions": {"description": {"constant_value": "HTTPS from the Lambda ENIs. One of two ingresses on the endpoint group: the root adds the private-origin ALB for health checks."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_lambda", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "data.aws_iam_policy_document.flow_logs_assume_role", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["vpc-flow-logs.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "flow_logs_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.flow_logs_delivery", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "sid": {"constant_value": "DeliverFlowLogsToOwnGroup"}}]}, "mode": "data", "name": "flow_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs. A plain `bool` input, so the flow-log `count`\nis known at plan time.\n"}, "flow_log_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the flow-log group."}, "flow_log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the flow-log group."}, "gateway_endpoint_service_names": {"default": ["s3", "dynamodb"], "description": "Short service names for the gateway VPC endpoints (route-table entries, not ENIs); only `s3` and `dynamodb` support this form."}, "interface_endpoint_service_names": {"description": "Short service names for the interface (AWS PrivateLink) VPC endpoints this workload needs, e.g.\n`[\"kms\", \"logs\"]`. Each is expanded to `com.amazonaws..`. A Lambda call to an AWS\nservice with no endpoint here presents as a connection timeout, not as an authorization error.\n"}, "name_prefix": {"description": "Prefix for every resource name and `Name` tag this module creates."}, "nat_gateway_enabled": {"description": "Whether to create the egress-only internet path: an EIP and NAT gateway in the adopted IGW-routed\nsubnet, the default route it adds to the adopted private route tables, and a 443-only egress rule on\nthe Lambda group. The NAT gateway admits no inbound connection, and the private subnets are never\nassociated with the public route table (see `nat.tf`).\n\nNo default; plan refuses until a value is set. With `false` the relay cannot fetch the Cognito JWKS\n(the user pool has a domain, so the `cognito-idp` interface endpoint cannot serve it) and every agent\nturn fails authentication. `true` creates a NAT gateway, billed hourly and per GB.\n"}, "nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`nat_gateway_enabled` is true; ignored otherwise. No default.\n\nMust not appear in `private_subnet_ids`; a precondition on `aws_nat_gateway.this` in `nat.tf`\nasserts that at plan time.\n"}, "private_dns_disabled_services": {"default": ["execute-api"], "description": "Interface-endpoint services whose private DNS is off. Defaults to `[\"execute-api\"]`: private DNS on\nan `execute-api` endpoint would resolve `*.execute-api..amazonaws.com` to this endpoint for\nevery workload in the adopted VPC. CloudFront routes to the VPC origin by load balancer ARN and uses\nthe hostname only as the `Host` header.\n"}, "private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table, nor a table serving subnets outside `private_subnet_ids`;\npreconditions refuse both at plan time.\n\nTwo consumers: the NAT default route in `nat.tf`, and the gateway endpoints' `route_table_ids` in\n`endpoints.tf`. Every table named here receives a `0.0.0.0/0` route to this stack's NAT gateway;\n`scripts/teardown.sh` removes exactly that route.\n"}, "private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC to place Lambda ENIs in. No default.\n\nThese are the subnets whose route tables receive the NAT default route. They must be private; the\nmodule cannot detect a public subnet from its id.\n"}, "region": {"description": "Region the endpoint service names are built for."}, "runtime_route_table_ids": {"default": [], "description": "Route table ids of the Runtime subnets, associated with the S3/DynamoDB gateway endpoints so ECR\nimage-layer pulls have an S3 path. Separate from `private_route_table_ids`: these tables get no NAT\ndefault route, so the Runtime has no internet path. Empty when the Runtime is not in VPC mode.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the AgentCore Runtime's VPC-mode ENIs, separate from `private_subnet_ids` (which\nfeeds every interface endpoint's `subnet_ids` and the `execute-api` positional-length contract). The\nRuntime reaches the interface endpoints through private DNS, so it needs no local endpoint ENI.\n\nEmpty when the Runtime is not in VPC mode. When non-empty, the subnets must be in AgentCore-supported\nAZs for the region (`infra/regions.json`) and must not include `nat_public_subnet_id`;\n`preflight_adopted_vpc.sh` asserts the AZs and the precondition below asserts the disjointness.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "vpc_cidr_block": {"description": "The adopted VPC's IPv4 CIDR, used only for the `vpc_cidr_block` output that Layer 4 checks read."}, "vpc_id": {"description": "Id of the existing VPC to adopt. This module creates no VPC.\n\nNo default; set it through the gitignored tfvars. `terraform.tfvars.example` carries a placeholder.\n"}}}, "source": "./modules/vpc"}}, "outputs": {"agent_relay_function_name": {"description": "The relay Lambda's function name, for the relay smoke check's `get-function-configuration` env-var assertions.", "expression": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}}, "agent_relay_function_url": {"description": "The relay Function URL, scheme included. The relay smoke check asserts an unauthenticated call to this hostname, not through the distribution, is denied.", "expression": {"references": ["module.agent_relay.function_url", "module.agent_relay"]}}, "agent_relay_log_group_name": {"description": "The relay Lambda CloudWatch log group name, taken from `aws_cloudwatch_log_group.this.name`. Read by the relay-IAM smoke check to simulate `logs:CreateLogStream`/`logs:PutLogEvents` against the deployed group.", "expression": {"references": ["module.agent_relay.log_group_name", "module.agent_relay"]}}, "agent_relay_role_arn": {"description": "The relay Lambda execution role ARN. Read by `scripts/smoke/iam_roles.py` to simulate the relay rows against the deployed role.", "expression": {"references": ["module.agent_relay.role_arn", "module.agent_relay"]}}, "agentcore_gateway_mcp_url": {"description": "MCP endpoint of Gateway #1: `agentcore_gateway_url` with the `/mcp` path, which the deployed `gatewayUrl` omits.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_gateway_url": {"description": "AgentCore Gateway invocation URL.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_runtime_arn": {"description": "Deployed AgentCore Runtime ARN.", "expression": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "agentcore_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["module.agentcore.agent_runtime_log_group_name", "module.agentcore"]}}, "agentcore_runtime_role_arn": {"description": "Execution role ARN of the AgentCore Runtime, the positive-control principal for the relay-IAM smoke check deny rows.", "expression": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}}, "api_allowlist_kms_key_arn": {"description": "The CMK encrypting the API client-allowlist SecureString parameter. Read by the smoke checks to assert the parameter's key, the key policy and rotation, and to simulate the roles' KMS access.", "expression": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}}, "api_endpoint": {"description": "The private REST API invoke hostname. Not a public endpoint: it is reachable only through the `execute-api` VPC endpoint, and CloudFront uses it only as a `Host` header. Use `api_id` to identify the API.", "expression": {"references": ["module.api.private_origin_domain_name", "module.api"]}}, "api_id": {"description": "The REST API's id, read by `scripts/smoke/api_routes.py` to identify the API.", "expression": {"references": ["module.api.api_id", "module.api"]}}, "api_origin_alb_arn": {"description": "Internal ALB fronting the private REST API. The CloudFront VPC origin references it by this ARN and performs no DNS lookup.", "expression": {"references": ["module.api_origin.alb_arn", "module.api_origin"]}}, "api_origin_alb_security_group_id": {"description": "The ALB security group, the source of `aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb`. A T3 check asserts the endpoint group admits this group.", "expression": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}}, "api_origin_listener_protocol": {"description": "The listener protocol deployed on the ALB. A check asserts the `http-only` listener against the resource.", "expression": {"references": ["module.api_origin.listener_protocol", "module.api_origin"]}}, "api_origin_target_group_arn": {"description": "Target group holding the `execute-api` endpoint ENI IPs. A T3 check reads `describe-target-health` here.", "expression": {"references": ["module.api_origin.target_group_arn", "module.api_origin"]}}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin, which `module.frontend_cdn` consumes as `api_origin_vpc_origin_id` for the `/api/*` origin `vpc_origin_config`. A T3 check asserts the deployed distribution routes `/api/*` through this origin.", "expression": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}}, "api_stage_invoke_url": {"description": "Full invoke URL for the deployed API stage.", "expression": {"references": ["module.api.stage_invoke_url", "module.api"]}}, "cloudfront_distribution_id": {"description": "CloudFront distribution id, used to invalidate cached assets after a frontend publish.", "expression": {"references": ["module.frontend_cdn.distribution_id", "module.frontend_cdn"]}}, "cloudfront_domain_name": {"description": "CloudFront distribution domain name serving the frontend build.", "expression": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}}, "cloudtrail_access_logs_bucket_name": {"description": "Destination bucket for the CloudTrail delivery bucket S3 server access logs. Its log source is `cloudtrail_s3_bucket_name`, a different bucket.", "expression": {"references": ["module.observability.cloudtrail_access_logs_bucket_name", "module.observability"]}}, "cloudtrail_s3_bucket_name": {"description": "The CloudTrail log-file delivery bucket, whose access logs land in `cloudtrail_access_logs_bucket_name`. Read by the delivery smoke check as the source side of its target assertion.", "expression": {"references": ["module.observability.cloudtrail_s3_bucket_name", "module.observability"]}}, "cognito_domain": {"description": "Cognito prefix domain (no custom ACM certificate). Combine with `var.aws_region` as `https://.auth..amazoncognito.com` to reach the `/oauth2/token` endpoint the MCP `client_credentials` flow uses; see `docs/mcp-client-guide.md`.", "expression": {"references": ["module.cognito.domain", "module.cognito"]}}, "cognito_gateway_scope": {"description": "The `gateway/invoke` resource-server scope identifier, re-exported from `module.cognito.gateway_scope_identifier`. Read by `scripts/smoke/gateway_tools.py`.", "expression": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}}, "cognito_mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["module.cognito.mcp_client_id", "module.cognito"]}}, "cognito_mcp_client_secret": {"description": "App client secret for the MCP client, empty after the first secret rotation (`scripts/rotate_mcp_client_secret.py`). Sensitive; never write it to a tracked file. Any copy kept elsewhere, for example in Secrets Manager, is made out of band; nothing in this stack stores one.", "expression": {"references": ["module.cognito.mcp_client_secret", "module.cognito"]}, "sensitive": true}, "cognito_mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, authorization code, loopback callbacks); accepted by Gateway #2 only.", "expression": {"references": ["module.cognito.mcp_oauth_client_id", "module.cognito"]}}, "cognito_spa_client_id": {"description": "App client id for the SPA (public client).", "expression": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "cognito_token_endpoint": {"description": "Fully-formed Cognito `/oauth2/token` endpoint URL for the MCP app client's `client_credentials` grant.", "expression": {"references": ["module.cognito.domain", "module.cognito", "var.aws_region"]}}, "cognito_user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["module.cognito.user_pool_id", "module.cognito"]}}, "crm_operator_principal_arns": {"description": "The operator principals admitted by the DynamoDB table and CMK policies. Read by the Layer 4 `dynamodb_principal_deny` smoke check to assert the deployed policies' allowlists.", "expression": {"references": ["var.crm_operator_principal_arns"]}}, "dynamodb_table_names": {"description": "Map of logical table name to physical DynamoDB table name, for the 11 tables.", "expression": {"references": ["module.dynamodb.table_names", "module.dynamodb"]}}, "eval_artifacts_bucket_arn": {"description": "The eval-artefacts bucket ARN, for a smoke check composing its own policy or simulation against it.", "expression": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}}, "eval_artifacts_bucket_name": {"description": "The eval-artefacts bucket name, which embeds the account id. Read by `sweep_control` (as EVAL_ARTIFACTS_BUCKET) and by the presigned-URL smoke check.", "expression": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}}, "eval_artifacts_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the `sweep_control` artifacts grant covers. Read by `sweep_control` as EVAL_ARTIFACTS_PREFIX.", "expression": {"references": ["module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}}, "eval_state_machine_arn": {"description": "ARN of the eval_sweep Step Functions state machine, started by eval_trigger.", "expression": {"references": ["aws_sfn_state_machine.eval_sweep.arn", "aws_sfn_state_machine.eval_sweep"]}}, "eval_trigger_function_name": {"description": "The `eval_trigger` Lambda's function name. Read by the smoke checks: `admin_authz` derives the Lambda name prefix from it, `eval_sfn` and `chat_path_iam` read its configuration, and `resource_protection` checks its log group.", "expression": {"references": ["module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger"]}}, "frontend_cdn_logs_bucket_name": {"description": "Destination bucket for the CloudFront origin bucket and eval-artefacts bucket S3 server access logs, and for CloudFront standard access logs. Log sources: `frontend_origin_bucket_name`, `eval_artifacts_bucket_name`, and the distribution.", "expression": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}}, "frontend_origin_bucket_name": {"description": "Private S3 bucket holding the frontend static build \u2014 the `aws s3 sync` target of the deploy script's publish step.", "expression": {"references": ["module.frontend_cdn.origin_bucket_name", "module.frontend_cdn"]}}, "mcp_chat_gateway_url": {"description": "MCP endpoint URL of Gateway #2, which exposes only `chat_with_supervisor`.", "expression": {"references": ["module.mcp_chat_gateway.gateway_url", "module.mcp_chat_gateway"]}}, "vpc_flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Blocked egress appears here as REJECT records.", "expression": {"references": ["module.vpc.flow_log_group_name", "module.vpc"]}}, "vpc_id": {"description": "Id of the adopted VPC the stack deploys into. Read by the Layer 4 VPC smoke check.", "expression": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "vpc_interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created: the AWS services the workload can reach privately. Read by checks that assert a dependency is reachable.", "expression": {"references": ["module.vpc.interface_endpoint_service_names", "module.vpc"]}}, "vpc_lambda_security_group_ids": {"description": "The Lambda ENI security group. Read by Layer 4 to assert it has no ingress rule and no egress destination outside this VPC's endpoints.", "expression": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}}, "vpc_lambda_subnet_ids": {"description": "The private subnet ids every Lambda's `vpc_config` places ENIs in. Read by the Layer 4 VPC smoke check to assert each subnet's route table carries no route to a gateway.", "expression": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}}, "resources": [{"address": "aws_bedrockagentcore_resource_policy.agent_runtime_endpoint_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_endpoint_relay_only.json", "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only"]}, "resource_arn": {"references": ["local.agent_runtime_endpoint_arn"]}}, "mode": "managed", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_bedrockagentcore_resource_policy.agent_runtime_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_relay_only.json", "data.aws_iam_policy_document.agent_runtime_relay_only"]}, "resource_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "mode": "managed", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_cloudwatch_log_group.eval_sweep", "expressions": {"kms_key_id": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.agentcore_gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-gateway-role"}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.agentcore_runtime", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-runtime-role"}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.eval_sweep", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.eval_sweep_assume_role.json", "data.aws_iam_policy_document.eval_sweep_assume_role"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.agentcore_gateway", "expressions": {"name": {"constant_value": "crm-agent-eval-gateway-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_gateway_permissions.json", "data.aws_iam_policy_document.agentcore_gateway_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_gateway.id", "aws_iam_role.agentcore_gateway"]}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_permissions.json", "data.aws_iam_policy_document.agentcore_runtime_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime_logs", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-logs"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_logs.json", "data.aws_iam_policy_document.agentcore_runtime_logs"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.chat_target_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.chat_target_invoke_runtime.json", "data.aws_iam_policy_document.chat_target_invoke_runtime"]}, "role": {"references": ["module.lambda_action_chat_target.role_name", "module.lambda_action_chat_target"]}}, "mode": "managed", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_sweep", "expressions": {"name": {"references": ["local.eval_sweep_state_machine_name"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_sweep_permissions.json", "data.aws_iam_policy_document.eval_sweep_permissions"]}, "role": {"references": ["aws_iam_role.eval_sweep.name", "aws_iam_role.eval_sweep"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_artifacts.json", "data.aws_iam_policy_document.eval_trigger_artifacts"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_states", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_states.json", "data.aws_iam_policy_document.eval_trigger_states"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_control_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_control_artifacts.json", "data.aws_iam_policy_document.sweep_control_artifacts"]}, "role": {"references": ["module.lambda_action_sweep_control.role_name", "module.lambda_action_sweep_control"]}}, "mode": "managed", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_task_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_task_invoke_runtime.json", "data.aws_iam_policy_document.sweep_task_invoke_runtime"]}, "role": {"references": ["module.lambda_action_sweep_task.role_name", "module.lambda_action_sweep_task"]}}, "mode": "managed", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.api_allowlist", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.api_allowlist.key_id", "aws_kms_key.api_allowlist"]}}, "mode": "managed", "name": "api_allowlist", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.cursor", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.cursor.key_id", "aws_kms_key.cursor"]}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.eval_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.eval_artifacts.key_id", "aws_kms_key.eval_artifacts"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.api_allowlist", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "api_allowlist", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.cursor", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.eval_artifacts", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.api_allowlist", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.api_allowlist.id", "aws_kms_key.api_allowlist"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "var.crm_operator_principal_arns", "local.api_allowlist_ssm_service", "local.api_allowlist_key_consumer_arns", "local.api_allowlist_ssm_service", "local.api_allowed_client_ids_parameter_arn", "var.crm_operator_principal_arns", "local.api_allowlist_key_consumer_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "api_allowlist", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_kms_key_policy.cursor", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.cursor.id", "aws_kms_key.cursor"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.cursor_key_principal_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_kms_key_policy.eval_artifacts", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.eval_artifacts.id", "aws_kms_key.eval_artifacts"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_s3_object.agent_source", "expressions": {"bucket": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}, "key": {"constant_value": "agent-source/agent.zip"}, "kms_key_id": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "source": {"references": ["var.lambda_build_dir"]}, "source_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "agent_source", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_object"}, {"address": "aws_sfn_state_machine.eval_sweep", "depends_on": ["aws_iam_role_policy.eval_sweep"], "expressions": {"definition": {"references": ["path.module", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "logging_configuration": [{"include_execution_data": {"constant_value": false}, "level": {"constant_value": "ALL"}, "log_destination": {"references": ["aws_cloudwatch_log_group.eval_sweep.arn", "aws_cloudwatch_log_group.eval_sweep"]}}], "name": {"references": ["local.eval_sweep_state_machine_name"]}, "role_arn": {"references": ["aws_iam_role.eval_sweep.arn", "aws_iam_role.eval_sweep"]}, "tags": {"references": ["var.data_classification"]}, "tracing_configuration": [{"enabled": {"constant_value": true}}], "type": {"constant_value": "STANDARD"}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_sfn_state_machine"}, {"address": "aws_ssm_parameter.api_allowed_client_ids", "depends_on": ["aws_kms_key_policy.api_allowlist"], "expressions": {"key_id": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "name": {"references": ["local.api_allowed_client_ids_parameter_name"]}, "tags": {"constant_value": {"data-classification": "internal"}}, "tier": {"constant_value": "Standard"}, "type": {"constant_value": "SecureString"}, "value": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "mode": "managed", "name": "api_allowed_client_ids", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ssm_parameter"}, {"address": "aws_ssm_parameter.relay_cognito_audience", "expressions": {"name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "tags": {"constant_value": {"data-classification": "internal"}}, "type": {"constant_value": "String"}, "value": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "mode": "managed", "name": "relay_cognito_audience", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ssm_parameter"}, {"address": "aws_vpc_endpoint_policy.states", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.states_endpoint.json", "data.aws_iam_policy_document.states_endpoint"]}, "vpc_endpoint_id": {"references": ["module.vpc.states_vpc_endpoint_id", "module.vpc"]}}, "mode": "managed", "name": "states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint_policy"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb", "expressions": {"description": {"constant_value": "HTTPS from the private-origin ALB. The only ingress any endpoint has besides the Lambda group."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}, "security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_api_origin_alb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "terraform_data.agent_only_tools_guard", "mode": "managed", "name": "agent_only_tools_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.chat_scope_agreement", "mode": "managed", "name": "chat_scope_agreement", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.reserved_concurrency_headroom_guard", "mode": "managed", "name": "reserved_concurrency_headroom_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisEndpoint"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agent_runtime_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "agentcore_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "agentcore_gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_log_group_arn", "module.agentcore", "module.agentcore.agent_runtime_log_group_arn", "module.agentcore"]}, "sid": {"constant_value": "CloudWatchLogsAccess"}}]}, "mode": "data", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action", "local.runtime_uninvocable_tools"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "BedrockInference"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "bedrock:InferenceProfileArn"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_foundation_models", "local.bedrock_foundation_models"]}, "sid": {"constant_value": "BedrockInferenceFoundationModels"}}, {"actions": {"constant_value": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.agent_ecr_repository_name"]}, "sid": {"constant_value": "EcrImageAccess"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrTokenAccess"}}]}, "mode": "data", "name": "agentcore_runtime_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.chat_target_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeTheRuntimeDefaultEndpoint"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyEverythingButInvokeOnThisRuntime"}}]}, "mode": "data", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnEquals"}, "values": {"references": ["local.eval_sweep_state_machine_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["states.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "eval_sweep_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "sid": {"constant_value": "InvokeSweepLambdas"}}, {"actions": {"references": ["local.sfn_vended_log_delivery_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnVendedLogDelivery"}}, {"actions": {"references": ["local.sfn_xray_tracing_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnXRayTracing"}}]}, "mode": "data", "name": "eval_sweep_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "ReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.aws_region"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "DecryptArtifactsViaS3"}}]}, "mode": "data", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_states", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.states_endpoint", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "states_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_control_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "UseArtifactsBucketCmk"}}]}, "mode": "data", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_task_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeAgentRuntimeEvalTurn"}}]}, "mode": "data", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_session_context.current", "expressions": {"arn": {"references": ["data.aws_caller_identity.current.arn", "data.aws_caller_identity.current"]}}, "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_session_context"}, {"address": "data.aws_network_interface.execute_api", "count_expression": {"references": ["var.vpc_private_subnet_ids"]}, "expressions": {"id": {"references": ["module.vpc.execute_api_network_interface_ids", "module.vpc", "count.index"]}}, "mode": "data", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_network_interface"}], "variables": {"api_origin_ingress_security_group_ids": {"description": "Security group ids permitted to reach the internal ALB's listener port (the `/api/*` private origin\npath). Passed to `modules/api_origin`, whose validation refuses anything that is not an `sg-` id.\nNo default; set it in the gitignored `terraform.tfvars`.\n\nThe value is the CloudFront service-managed group `CloudFront-VPCOrigins-Service-SG`, which AWS\ncreates in the adopted VPC when `aws_cloudfront_vpc_origin` is first applied. The first deployment\nof this path is therefore two-phase: apply, read the group id, set this variable, apply again. See\nthe `api_origin` variables and the runbook.\n"}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile to use for all provider operations."}, "aws_region": {"default": "us-east-1", "description": "AWS region to deploy into: a US commercial region listed in `infra/regions.json`."}, "cost_center": {"default": "crm-agent-eval", "description": "Value for the mandatory `cost-center` tag applied to every resource."}, "crm_operator_principal_arns": {"description": "IAM role or user ARNs of the operators who deploy, seed and smoke-test this stack. Admitted to the\nDynamoDB tables' data plane and to table and CMK administration; every principal outside these and\nthe project's Lambda roles is denied. No default; set it in the gitignored\n`terraform.tfvars`. A plan whose caller is not listed fails at a precondition.\n"}, "data_classification": {"default": "confidential", "description": "Default value for the mandatory `data-classification` tag. Individual modules may override this per resource where a more specific classification applies."}, "environment": {"default": "dev", "description": "Value for the mandatory `environment` tag applied to every resource."}, "lambda_build_dir": {"default": "build/lambda", "description": "Directory holding the pre-built archives this composition reads, resolved\nrelative to `infra/`: one Lambda zip per `local.tool_names` entry, plus\n`identity_interceptor.zip`, `pre_token_generation.zip`, `eval_trigger.zip`\n(shared by the eval trigger, capabilities, user-settings and sweep functions),\n`chat_target.zip` (the chat Gateway's target) and `relay.zip` \u2014 and\n`agent-source.zip`, the CodeBuild source for the AgentCore container image. `scripts/package_lambdas.sh` and `scripts/package_relay.sh`\npopulate the default location, `infra/build/lambda`.\n"}, "owner": {"default": "crm-agent-eval-team", "description": "Value for the mandatory `owner` tag applied to every resource."}, "runtime_source_vpce_deny_enabled": {"default": false, "description": "Stage 2: whether the runtime resource policies carry the inbound Deny. When true, both policies deny\n`InvokeAgentRuntime` from every principal not arriving through the bedrock-agentcore VPC endpoint\n(with `aws:ViaAWSService = false` exempting internal service calls).\n\nDefaults to false. Enable it only once the relay's calls are shown to carry `aws:SourceVpce`;\notherwise every chat turn is denied. Set `-var runtime_source_vpce_deny_enabled=true` (or in a\ngitignored `*.auto.tfvars`) as a separate apply after stage 1 is verified.\n"}, "runtime_source_vpce_report_only_enabled": {"default": true, "description": "Stage 1: whether the runtime resource policies carry the report-only `aws:SourceVpce` Allow for any\nprincipal arriving through the bedrock-agentcore VPC endpoint. It grants nothing the relay-role\nAllow does not already cover for the relay; it shows, before the Deny, that traffic through this\nstack's endpoint is admitted by the SourceVpce condition.\n"}, "service": {"default": "crm-agent-eval", "description": "Value for the mandatory `service` tag applied to every resource."}, "vpc_cidr_block": {"default": "10.20.0.0/20", "description": "The adopted VPC's IPv4 CIDR, published as an output for Layer 4 checks. Nothing is sized from it.\nIt must match the adopted VPC.\n"}, "vpc_flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs."}, "vpc_id": {"description": "Id of the existing VPC this deployment adopts. The stack creates no VPC; it creates only the NAT\ngateway path, the route that path adds to the adopted private route tables, two security groups,\nand the VPC endpoints.\n\nNo default. Set it in the gitignored `terraform.tfvars`; `terraform.tfvars.example` shows the shape\nwith a placeholder.\n"}, "vpc_nat_gateway_enabled": {"description": "Whether to create the egress-only internet path the relay's Cognito JWKS fetch requires.\n\nNo default; `terraform plan` refuses until a value is set. `false` leaves the relay unable to\nauthenticate any request (the user pool has a domain, so the `cognito-idp` interface endpoint cannot\nserve it). `true` creates a NAT gateway, billed hourly and per GB.\n\nSet it on the command line (`-var vpc_nat_gateway_enabled=true`) or in a gitignored `*.auto.tfvars`.\nThe NAT gateway is egress-only: it admits no inbound connection (see `infra/modules/vpc/nat.tf`).\n"}, "vpc_nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`vpc_nat_gateway_enabled` is true; the plan fails otherwise. No default.\n\nMust not also appear in `vpc_private_subnet_ids`; the module asserts that at plan time.\n"}, "vpc_private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table; a precondition refuses it at plan time.\n\nEvery table named here receives a `0.0.0.0/0` route to this stack's NAT gateway and the S3/DynamoDB\ngateway-endpoint associations.\n"}, "vpc_private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC that every Lambda's ENIs are placed in. No\ndefault; set it in the gitignored `terraform.tfvars`.\n\nThe AZ set is whatever these subnets are; it is not derived from the region.\n"}, "vpc_runtime_route_table_ids": {"default": [], "description": "Route table ids of the `vpc_runtime_subnet_ids` subnets, associated with the S3/DynamoDB gateway\nendpoints so ECR image-layer pulls have an S3 path. They receive no NAT default route (that stays\non `vpc_private_route_table_ids`), so the Runtime has no internet path. Defaults to empty.\n"}, "vpc_runtime_subnet_ids": {"default": [], "description": "Ids of the private subnets for the AgentCore Runtime's VPC-mode ENIs, separate from\n`vpc_private_subnet_ids` (see the vpc module's `runtime_subnet_ids`).\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`) and must\nnot be `vpc_nat_public_subnet_id`; `scripts/preflight_adopted_vpc.sh` and a module precondition\nassert both. The Runtime runs in VPC mode, so an empty list fails the plan.\n"}}}}, "format_version": "1.2", "variables": {"api_origin_ingress_security_group_ids": {"value": ["sg-cloudfrontvpcoriginplaceholder"]}, "aws_profile": {"value": "example-deployer"}, "aws_region": {"value": "us-east-1"}, "cost_center": {"value": "crm-agent-eval"}, "crm_operator_principal_arns": {"value": ["arn:aws:iam::123456789012:role/example-deployer"]}, "data_classification": {"value": "confidential"}, "environment": {"value": "dev"}, "lambda_build_dir": {"value": "build/lambda"}, "owner": {"value": "crm-agent-eval-team"}, "runtime_source_vpce_deny_enabled": {"value": false}, "runtime_source_vpce_report_only_enabled": {"value": true}, "service": {"value": "crm-agent-eval"}, "vpc_cidr_block": {"value": "10.20.0.0/20"}, "vpc_flow_log_enabled": {"value": true}, "vpc_id": {"value": "vpc-adoptedplaceholder"}, "vpc_nat_gateway_enabled": {"value": true}, "vpc_nat_public_subnet_id": {"value": "subnet-natpublicplaceholder"}, "vpc_private_route_table_ids": {"value": ["rtb-privateoneplaceholder", "rtb-privatetwoplaceholder"]}, "vpc_private_subnet_ids": {"value": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}, "vpc_runtime_route_table_ids": {"value": ["rtb-runtimeplaceholder"]}, "vpc_runtime_subnet_ids": {"value": ["subnet-runtimeoneplaceholder", "subnet-runtimetwoplaceholder"]}}} +{"_fixture_provenance": {"captured_at": "2026-11-15", "captured_infra_digest": "7768652aabbe1e9a9ad81077adaa2e80e7c991660e95a4dd0850712ea07ee5b0", "currency": "Captured from a tree whose tracked infra/**/*.tf digest is captured_infra_digest. plan_freshness passes while plan_fixtures.infra_digest of the working tree equals it. The adopted network (VPC, subnets, route tables, the CloudFront VPC-origin security group) is created outside Terraform and adopted by the gitignored tfvars, so its ids are scrubbed to placeholders.", "derived_from": "native capture; no earlier fixture content", "how": "terraform show -json of a create-everything plan captured against EMPTY LOCAL STATE in a scratch copy of infra/ (providers and build/ symlinked, backend block removed so state is local), no deploy. Plan: 681 to add, 0 to change, 0 to destroy; 160 data reads. Scrubbed by scripts/scrub_plan_capture.py: account id -> 123456789012, IAM unique ids -> AIDA-example-caller-user-id, caller role and session -> example-deployer/example-session, operator principals -> example-operator-, aws_profile -> example-deployer, adopted-network ids -> non-hex placeholder tokens.", "variables_at_capture": "runtime_source_vpce_deny_enabled = false; runtime_source_vpce_report_only_enabled = true; vpc_flow_log_enabled = true; vpc_nat_gateway_enabled = true; adopted-network variables and crm_operator_principal_arns from the gitignored infra/terraform.tfvars. NONE has a tracked default that supplies a real id."}, "configuration": {"provider_config": {"aws": {"expressions": {"default_tags": [{"tags": {"references": ["var.service", "var.environment", "var.owner", "var.cost_center", "var.data_classification"]}}], "profile": {"references": ["var.aws_profile"]}, "region": {"references": ["var.aws_region"]}}, "full_name": "registry.terraform.io/hashicorp/aws", "name": "aws", "version_constraint": "6.72.0"}, "module.agentcore:null": {"full_name": "registry.terraform.io/hashicorp/null", "module_address": "module.agentcore", "name": "null"}, "terraform": {"full_name": "terraform.io/builtin/terraform", "name": "terraform"}}, "root_module": {"module_calls": {"agent_relay": {"expressions": {"agent_runtime_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "agent_runtime_qualifier": {"references": ["local.relay_runtime_qualifier"]}, "cognito_audience_parameter_arn": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.relay_cognito_audience_parameter_name"]}, "cognito_audience_parameter_name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "cognito_issuer": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "log_retention_days": {"constant_value": 365}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"agent_relay\"]", "local.reserved_concurrency"]}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"environment_variable_names": {"description": "Names of every environment variable this module sets on the relay. Lets a contract test assert the config surface in both directions \u2014 nothing the relay reads is unset, nothing set is unread.", "expression": {"references": ["local.environment_variables"]}}, "function_arn": {"description": "The relay function's ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The relay function's name. Consumed by `modules/frontend_cdn` to attach the CloudFront-scoped `lambda:InvokeFunctionUrl` permission.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "function_url": {"description": "The Function URL, scheme and trailing slash included, as Lambda returns it.", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "function_url_domain": {"description": "Host portion of the Function URL, for use as a CloudFront custom-origin `domain_name` (which rejects a scheme or a path).", "expression": {"references": ["aws_lambda_function_url.this.function_url", "aws_lambda_function_url.this"]}}, "log_group_name": {"description": "The relay's CloudWatch log group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "The relay execution role's ARN. Consumed by the Layer 4 `simulate-principal-policy` check.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "The relay execution role's name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.invoke_runtime", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.invoke_runtime.json", "data.aws_iam_policy_document.invoke_runtime"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.read_audience_parameter", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.read_audience_parameter.json", "data.aws_iam_policy_document.read_audience_parameter"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"environment": [{"variables": {"references": ["local.environment_variables"]}}], "filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_function_url.this", "expressions": {"authorization_type": {"constant_value": "AWS_IAM"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "invoke_mode": {"constant_value": "RESPONSE_STREAM"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function_url"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "InvokeOneRuntimeAndItsEndpoints"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["var.agent_runtime_arn", "local.agent_runtime_endpoints_arn"]}, "sid": {"constant_value": "DenyEverythingButTheOnePermittedInvokeOnThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:*"]}, "effect": {"constant_value": "Deny"}, "resources": {"references": ["local.agentcore_harness_arn"]}, "sid": {"constant_value": "DenyEveryHarness"}}]}, "mode": "data", "name": "invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.read_audience_parameter", "expressions": {"statement": [{"actions": {"constant_value": ["ssm:GetParameter"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.cognito_audience_parameter_arn"]}, "sid": {"constant_value": "ReadRelayParameters"}}]}, "mode": "data", "name": "read_audience_parameter", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_arn": {"description": "ARN of the one AgentCore Runtime this relay may invoke\n(`module.agentcore.agent_runtime_arn`). The execution role is granted\n`bedrock-agentcore:InvokeAgentRuntime` on this ARN and its endpoint sub-resources and on nothing\nelse \u2014 no wildcard, no second runtime.\n"}, "agent_runtime_qualifier": {"default": "DEFAULT", "description": "Runtime endpoint qualifier the relay invokes, passed to the relay as `AGENT_RUNTIME_QUALIFIER`\n(`src/relay/src/runtime.ts`). The execution role's `InvokeAgentRuntime` grant covers the endpoint\nthis value names.\n"}, "cognito_audience_parameter_arn": {"description": "ARN of that same parameter, for the execution role's `ssm:GetParameter` grant. The caller constructs\nit from region, account and name, not from `aws_ssm_parameter.\u2026arn`, to avoid a module cycle.\n"}, "cognito_audience_parameter_name": {"description": "Name of the SSM parameter holding the SPA app-client id the relay requires. The relay reads it at\ncold start and rejects any token issued to a different client.\n"}, "cognito_issuer": {"description": "Cognito user-pool issuer URL (`https://cognito-idp..amazonaws.com/`). The relay derives its JWKS URL from this and rejects any token whose `iss` differs."}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables and its log group."}, "filename": {"description": "Path to the relay deployment package built by `scripts/package_relay.sh`."}, "function_name": {"description": "Unique Lambda function name. Also names this module's IAM role and log group."}, "handler": {"default": "index.handler", "description": "Lambda handler entry point inside the relay zip."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the relay's log group."}, "memory_size_mb": {"default": 512, "description": "Lambda memory allocation in MB, sizing the Node runtime and the JWKS cache."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for the relay. Must be greater than zero; 0 makes the function permanently\nuninvokable.\n\nOne chat turn holds one invocation for up to `timeout_seconds`. The caller keeps the sum of every\nreserved concurrency in the deployment below the account pool minus unreserved headroom.\n\nNo default; the caller states a value.\n"}, "runtime": {"default": "nodejs24.x", "description": "Lambda runtime identifier. Must be a Node.js runtime, which supports response streaming."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the relay package, forcing redeploy on code change."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "timeout_seconds": {"default": 660, "description": "Lambda invocation timeout in seconds. Must exceed the 600s chat turn wall clock."}, "vpc_security_group_ids": {"description": "Security groups for the relay's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress; the relay is invoked through the Lambda control plane (a signed Function URL invoke).\n"}, "vpc_subnet_ids": {"description": "Private subnet ids the relay's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default; at least two subnets.\n\nThe relay's outbound calls (`bedrock-agentcore:InvokeAgentRuntime`, `ssm:GetParameter` and the\nCognito JWKS fetch) leave through these subnets, via the VPC endpoints and the NAT gateway. A missing\npath presents as a hung turn, not as an authorization error.\n"}}}, "source": "./modules/agent_relay"}, "agentcore": {"depends_on": ["aws_s3_object.agent_source", "aws_iam_role_policy.agentcore_runtime", "aws_iam_role_policy.agentcore_runtime_history"], "expressions": {"agent_runtime_environment_variables": {"references": ["module.cognito.user_pool_id", "module.cognito", "module.api.stage_invoke_url", "module.api", "local.name_prefix", "local.name_prefix"]}, "agent_runtime_name": {"constant_value": "crm_agent_eval_runtime"}, "agent_runtime_role_arn": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}, "aws_profile": {"references": ["var.aws_profile"]}, "aws_region": {"references": ["var.aws_region"]}, "buildspec": {"references": ["local.agent_buildspec"]}, "cognito_allowed_audiences": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "cognito_required_custom_claims": {"constant_value": []}, "data_classification": {"references": ["var.data_classification"]}, "ecr_repository_name": {"references": ["local.agent_ecr_repository_name"]}, "gateway_name": {"constant_value": "crm-agent-eval-gateway"}, "gateway_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_interceptor.function_name", "module.lambda_action_interceptor"]}, "image_retention_count": {"constant_value": 10}, "image_tag": {"references": ["local.agent_image_tag"]}, "kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "log_retention_days": {"constant_value": 365}, "name_prefix": {"references": ["local.name_prefix"]}, "runtime_network_mode": {"constant_value": "VPC"}, "runtime_security_group_ids": {"references": ["module.vpc.runtime_security_group_id", "module.vpc"]}, "runtime_subnet_ids": {"references": ["module.vpc.runtime_subnet_ids", "module.vpc"]}, "source_bucket_arn": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}, "source_content_hash": {"references": ["var.lambda_build_dir"]}, "source_key": {"references": ["aws_s3_object.agent_source.key", "aws_s3_object.agent_source"]}, "source_kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "tool_lambda_arns": {"references": ["module.lambda_action"]}, "tool_schemas": {"references": ["local.tool_names", "local.tools", "local.tool_schema_properties"]}}, "module": {"outputs": {"agent_runtime_arn": {"description": "The deployed AgentCore Runtime ARN.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_arn", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_id": {"description": "The deployed AgentCore Runtime id.", "expression": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}}, "agent_runtime_log_group_arn": {"description": "CloudWatch Logs group ARN for the AgentCore Runtime's default endpoint stdout, for scoping the execution role's logs:* grant.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.arn", "aws_cloudwatch_log_group.runtime"]}}, "agent_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["aws_cloudwatch_log_group.runtime.name", "aws_cloudwatch_log_group.runtime"]}}, "codebuild_role_arn": {"description": "ARN of the CodeBuild image-build project's service role, which reads the agent-source object and uses its CMK. The root admits it to the eval-artefacts bucket and key policies.", "expression": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}}, "ecr_repository_arn": {"description": "ARN of the ECR repository the agent container image is pushed to. The root composition scopes the\nAgentCore Runtime execution role's `ecr:BatchGetImage`/`ecr:GetDownloadUrlForLayer` grant to this\nARN.\n", "expression": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}}, "ecr_repository_url": {"description": "The ECR repository URL the agent container image is pushed to.", "expression": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, "gateway_arn": {"description": "The deployed Gateway ARN.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "The deployed Gateway id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_target_ids": {"description": "Map of tool_name -> that tool's gateway target id, one entry per entry in var.tool_lambda_arns.", "expression": {"references": ["aws_bedrockagentcore_gateway_target.tool"]}}, "gateway_url": {"description": "The deployed Gateway's invocation URL.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}}, "resources": [{"address": "aws_bedrockagentcore_agent_runtime.this", "depends_on": ["null_resource.image_build"], "expressions": {"agent_runtime_artifact": [{"container_configuration": [{"container_uri": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent", "var.image_tag"]}}]}], "agent_runtime_name": {"references": ["var.agent_runtime_name"]}, "environment_variables": {"references": ["var.agent_runtime_environment_variables"]}, "network_configuration": [{"network_mode": {"references": ["var.runtime_network_mode"]}}], "platform_version": {"references": ["var.platform_version"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.agent_runtime_role_arn"]}, "tags": {"references": ["var.tags"]}, "timeouts": {"create": {"constant_value": "30m"}, "update": {"constant_value": "30m"}}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_agent_runtime"}, {"address": "aws_bedrockagentcore_gateway.this", "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["var.gateway_role_arn"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.tool", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"references": ["each.key"]}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"references": ["each.key"]}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["each.value"]}, "tool_schema": [{"inline_payload": [{"description": {"references": ["var.tool_schemas", "each.key"]}, "input_schema": [{"type": {"constant_value": "object"}}], "name": {"references": ["each.key"]}}]}]}]}]}]}, "for_each_expression": {"references": ["var.tool_lambda_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_cloudwatch_log_group.codebuild", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_cloudwatch_log_group.runtime", "expressions": {"kms_key_id": {"references": ["var.kms_key_arn"]}, "name": {"references": ["aws_bedrockagentcore_agent_runtime.this.agent_runtime_id", "aws_bedrockagentcore_agent_runtime.this"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_codebuild_project.agent_image", "expressions": {"artifacts": [{"type": {"constant_value": "NO_ARTIFACTS"}}], "build_timeout": {"constant_value": 30}, "description": {"constant_value": "Builds and pushes the AgentCore Runtime container image."}, "encryption_key": {"references": ["var.source_kms_key_arn"]}, "environment": [{"compute_type": {"constant_value": "BUILD_GENERAL1_SMALL"}, "environment_variable": [{"name": {"constant_value": "ECR_REPOSITORY_URI"}, "value": {"references": ["aws_ecr_repository.agent.repository_url", "aws_ecr_repository.agent"]}}, {"name": {"constant_value": "AWS_DEFAULT_REGION"}, "value": {"references": ["var.aws_region"]}}], "image": {"constant_value": "aws/codebuild/amazonlinux2-aarch64-standard:3.0"}, "image_pull_credentials_type": {"constant_value": "CODEBUILD"}, "privileged_mode": {"constant_value": true}, "type": {"constant_value": "ARM_CONTAINER"}}], "logs_config": [{"cloudwatch_logs": [{"group_name": {"references": ["aws_cloudwatch_log_group.codebuild.name", "aws_cloudwatch_log_group.codebuild"]}}]}], "name": {"references": ["var.name_prefix"]}, "service_role": {"references": ["aws_iam_role.codebuild.arn", "aws_iam_role.codebuild"]}, "source": [{"buildspec": {"references": ["var.buildspec"]}, "location": {"references": ["var.source_bucket_arn", "var.source_bucket_arn", "var.source_key"]}, "type": {"constant_value": "S3"}}], "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent_image", "provider_config_key": "aws", "schema_version": 0, "type": "aws_codebuild_project"}, {"address": "aws_ecr_lifecycle_policy.agent", "expressions": {"policy": {"references": ["var.image_retention_count", "var.image_retention_count"]}, "repository": {"references": ["aws_ecr_repository.agent.name", "aws_ecr_repository.agent"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_lifecycle_policy"}, {"address": "aws_ecr_repository.agent", "expressions": {"encryption_configuration": [{"encryption_type": {"constant_value": "KMS"}, "kms_key": {"references": ["var.kms_key_arn"]}}], "force_delete": {"constant_value": true}, "image_scanning_configuration": [{"scan_on_push": {"constant_value": true}}], "image_tag_mutability": {"constant_value": "IMMUTABLE"}, "name": {"references": ["var.ecr_repository_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "agent", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ecr_repository"}, {"address": "aws_iam_role.codebuild", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.codebuild_assume_role.json", "data.aws_iam_policy_document.codebuild_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.codebuild", "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.codebuild_permissions.json", "data.aws_iam_policy_document.codebuild_permissions"]}, "role": {"references": ["aws_iam_role.codebuild.id", "aws_iam_role.codebuild"]}}, "mode": "managed", "name": "codebuild", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "null_resource.image_build", "depends_on": ["aws_codebuild_project.agent_image"], "expressions": {"triggers": {"references": ["var.source_content_hash", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image"]}}, "mode": "managed", "name": "image_build", "provider_config_key": "module.agentcore:null", "provisioners": [{"expressions": {"command": {"references": ["var.image_tag", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "var.aws_profile", "var.aws_region", "aws_ecr_repository.agent.name", "aws_ecr_repository.agent", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region", "var.aws_profile", "var.aws_region", "aws_codebuild_project.agent_image.name", "aws_codebuild_project.agent_image", "var.aws_profile", "var.aws_region"]}}, "type": "local-exec"}], "schema_version": 0, "type": "null_resource"}, {"address": "data.aws_iam_policy_document.codebuild_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["codebuild.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "codebuild_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.codebuild_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.codebuild.arn", "aws_cloudwatch_log_group.codebuild"]}, "sid": {"constant_value": "Logs"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrAuth"}}, {"actions": {"constant_value": ["ecr:BatchCheckLayerAvailability", "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", "ecr:PutImage", "ecr:InitiateLayerUpload", "ecr:UploadLayerPart", "ecr:CompleteLayerUpload"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_ecr_repository.agent.arn", "aws_ecr_repository.agent"]}, "sid": {"constant_value": "EcrPush"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_bucket_arn", "var.source_key"]}, "sid": {"constant_value": "SourceObject"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.source_kms_key_arn"]}, "sid": {"constant_value": "ProjectKms"}}]}, "mode": "data", "name": "codebuild_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"agent_runtime_environment_variables": {"default": {}, "description": "Plaintext environment variables for the runtime. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "agent_runtime_name": {"default": "crm_agent_eval_runtime", "description": "Name for the AgentCore Runtime resource. Must satisfy the CreateAgentRuntime pattern [a-zA-Z][a-zA-Z0-9_]{0,47} -- no hyphens."}, "agent_runtime_role_arn": {"description": "Execution role ARN the AgentCore Runtime assumes to run the agent container."}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile used by the in-apply CodeBuild trigger's `local-exec` provisioner."}, "aws_region": {"default": "us-east-1", "description": "AWS region for the AgentCore resources and the in-apply build trigger."}, "buildspec": {"description": "Inline buildspec for the CodeBuild project (Docker build + ECR push steps)."}, "cognito_allowed_audiences": {"description": "Accepted `aud` claim values for the CUSTOM_JWT authorizer."}, "cognito_allowed_client_ids": {"description": "App client ids accepted as valid callers by the CUSTOM_JWT authorizer."}, "cognito_allowed_scopes": {"default": [], "description": "Scopes required to be present on an inbound access token, enforced by the Gateway CUSTOM_JWT authorizer."}, "cognito_discovery_url": {"description": "Cognito user pool OIDC discovery URL, ending in /.well-known/openid-configuration."}, "cognito_required_custom_claims": {"default": [], "description": "Custom claims the Gateway CUSTOM_JWT authorizer requires on an inbound token, each matched by\nequality against one fixed `required_value` (for example a fixed `token_use` claim). Presence-only\nchecks are not expressible here; the interceptor's `decode_identity` rejects a token without the\nidentity claims. Defaults to empty.\n"}, "data_classification": {"description": "Value for the mandatory `data-classification` tag, applied per-resource (mirrors every sibling module's convention)."}, "ecr_repository_name": {"default": "crm-agent-eval-agent", "description": "Name of the ECR repository holding the agent container image."}, "gateway_name": {"default": "crm-agent-eval-gateway", "description": "Name for the AgentCore Gateway resource."}, "gateway_role_arn": {"description": "Execution role ARN the Gateway assumes, including to invoke each target Lambda via credential_provider_configuration.gateway_iam_role."}, "identity_interceptor_lambda_arn": {"description": "Invoke ARN of the identity_interceptor Lambda (src/gateway/identity_interceptor.py), attached as the Gateway's REQUEST interceptor."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the identity_interceptor Lambda, used to grant this Gateway invoke permission in the function resource policy."}, "image_retention_count": {"default": 10, "description": "Number of most-recent tagged images retained by the ECR lifecycle policy."}, "image_tag": {"default": "latest", "description": "Tag applied to the image the agent_runtime resource consumes (e.g. a short content-hash-derived tag the caller mints alongside source_content_hash)."}, "kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the ECR repository and the module's CloudWatch Logs log groups (runtime and CodeBuild) at rest."}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the CodeBuild project's log group."}, "name_prefix": {"default": "crm-agent-eval", "description": "Prefix applied to the CodeBuild project, its IAM role, and its log group names."}, "platform_version": {"default": "V2", "description": "AgentCore Runtime `platformVersion`: \"V1\" or \"V2\". V2 restores each instance from a\nprepared snapshot; creates and updates take minutes. Switching either way is an in-place update.\nRollback: set \"V1\" and apply (docs/runbook.md).\n"}, "runtime_network_mode": {"default": "PUBLIC", "description": "AgentCore Runtime `networkMode`: \"PUBLIC\" or \"VPC\". VPC mode places the microVM's ENIs in the\nadopted VPC's Runtime subnets on a dedicated no-ingress security group; it governs egress only.\nDefaults to \"PUBLIC\"; the root composition sets \"VPC\" and wires the subnet and security-group\nvariables.\n"}, "runtime_security_group_ids": {"default": [], "description": "Security group ids for the Runtime's VPC-mode ENIs. Required (at least one) when\nruntime_network_mode is \"VPC\"; ignored under \"PUBLIC\". Must be the dedicated Runtime security group\n(no ingress, egress only to the endpoint security group and the gateway prefix lists), not the\nLambda security group.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the Runtime's VPC-mode ENIs. Required (at least one) when runtime_network_mode is\n\"VPC\"; ignored under \"PUBLIC\". Set through the gitignored tfvars.\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`);\n`scripts/preflight_adopted_vpc.sh` asserts that at deploy time.\n"}, "source_bucket_arn": {"description": "S3 bucket ARN holding the zipped agent source CodeBuild reads from as its `source`."}, "source_content_hash": {"description": "Content hash of the agent source tree, used as this module's `null_resource.image_build` trigger\nvalue. The image build re-runs when this value changes between applies.\n"}, "source_key": {"description": "S3 object key, within source_bucket_arn, of the zipped agent source archive."}, "source_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting `source_bucket_arn`'s objects at rest, also used as\nthe CodeBuild project's `encryption_key`. The CodeBuild role is granted `kms:Decrypt`,\n`kms:Encrypt`, `kms:GenerateDataKey*` and `kms:DescribeKey` on exactly this key. The key's own\npolicy must also admit `aws_iam_role.codebuild` (or a broader principal it belongs to).\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "tool_lambda_arns": {"description": "Map of tool_name -> that tool's action Lambda ARN (`module.lambda_action[tool_name].function_arn`),\none entry per tool in `crm.toolspec.definitions.ALL_TOOLS`. Each entry produces exactly one gateway\ntarget. Its keys are a superset of the `api` module's tool routes: `get_page_context` is reachable\nby the agents and the Gateway but has no HTTP route (`local.agent_only_tools` in `infra/main.tf`).\nThat the key set equals `ALL_TOOLS` is `scripts/check_toolspec_parity.py`'s check on\n`local.tools`, which this map is built from.\n"}, "tool_schemas": {"description": "Map of tool_name -> that tool's flattened MCP tool schema, for the required\n`target_configuration.mcp.lambda.tool_schema` block of each `aws_bedrockagentcore_gateway_target`.\nCarries exactly the keys of `tool_lambda_arns`; the gateway target resource's precondition fails\nthe plan otherwise.\n\nThe root composition derives each entry's `description` and `properties` from\n`crm.toolspec.definitions.ALL_TOOLS[tool_name]` (`.description` and the top-level keys of\n`.input_schema[\"properties\"]`).\n\nOnly top-level scalar properties, and arrays of scalars, are expressible; a property whose type is\n`object`, or an array of objects, needs this variable's shape extended.\n"}}}, "source": "./modules/agentcore"}, "api": {"expressions": {"access_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "api_name": {"constant_value": "crm-agent-eval-api"}, "cognito_user_pool_arn": {"references": ["module.cognito.user_pool_arn", "module.cognito"]}, "extra_routes": {"references": ["module.lambda_action_eval_trigger.invoke_arn", "module.lambda_action_eval_trigger", "module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger", "module.lambda_action_capabilities.invoke_arn", "module.lambda_action_capabilities", "module.lambda_action_capabilities.function_name", "module.lambda_action_capabilities", "module.lambda_action_user_settings.invoke_arn", "module.lambda_action_user_settings", "module.lambda_action_user_settings.function_name", "module.lambda_action_user_settings"]}, "log_retention_days": {"constant_value": 365}, "stage_name": {"constant_value": "prod"}, "tool_lambda_function_names": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "tool_lambda_invoke_arns": {"references": ["local.routed_tool_names", "module.lambda_action"]}, "vpc_endpoint_ids": {"references": ["module.vpc.execute_api_vpc_endpoint_id", "module.vpc"]}}, "module": {"outputs": {"access_log_group_name": {"description": "CloudWatch Logs group name receiving API Gateway access logs.", "expression": {"references": ["aws_cloudwatch_log_group.access_logs.name", "aws_cloudwatch_log_group.access_logs"]}}, "api_id": {"description": "Private REST API id.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "authorizer_id": {"description": "Cognito authorizer id \u2014 every method in this module references this one authorizer; exposed for the Layer 3 gate's authorizer-coverage assertion.", "expression": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}}, "execution_arn": {"description": "API execution ARN, for Lambda resource-policy `source_arn` patterns outside this module if needed.", "expression": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this"]}}, "private_origin_domain_name": {"description": "Hostname for the CloudFront `/api/*` origin's `domain_name` (`-.execute-api..amazonaws.com`). Sent as the Host header to the private API; requires no custom domain and no `x-apigw-api-id`. Uses the first entry of `vpc_endpoint_ids`.", "expression": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this", "var.vpc_endpoint_ids[0]", "var.vpc_endpoint_ids", "data.aws_region.current.region", "data.aws_region.current"]}}, "route_tool_names": {"description": "Sorted list of the tool names this module generated routes for, derived from `var.tool_lambda_invoke_arns`'s keys \u2014 for the Layer 3 gate to diff against `crm.toolspec.definitions.ALL_TOOLS`.", "expression": {"references": ["local.tool_names"]}}, "stage_invoke_url": {"description": "Full invoke URL for the deployed stage. For this private API it is reachable only from inside the VPC through a named interface endpoint; it is not a publicly callable URL.", "expression": {"references": ["aws_api_gateway_stage.this.invoke_url", "aws_api_gateway_stage.this"]}}, "stage_name": {"description": "Deployed stage name. Every route is served beneath it (`//`), so a path-prefixed CloudFront behaviour in front of this API rewrites onto the stage path.", "expression": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "vpc_endpoint_ids": {"description": "The `execute-api` interface endpoint ids this API is associated with and whose `aws:sourceVpce` its resource policy allows.", "expression": {"references": ["var.vpc_endpoint_ids"]}}}, "resources": [{"address": "aws_api_gateway_authorizer.cognito", "expressions": {"identity_source": {"constant_value": "method.request.header.Authorization"}, "name": {"constant_value": "cognito-user-pools"}, "provider_arns": {"references": ["var.cognito_user_pool_arn"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "COGNITO_USER_POOLS"}}, "mode": "managed", "name": "cognito", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_authorizer"}, {"address": "aws_api_gateway_deployment.this", "depends_on": ["aws_api_gateway_method.tool", "aws_api_gateway_integration.tool", "aws_api_gateway_request_validator.body_and_params", "aws_api_gateway_model.json_object"], "expressions": {"rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "triggers": {"references": ["local.deployment_trigger"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_deployment"}, {"address": "aws_api_gateway_integration.tool", "expressions": {"http_method": {"references": ["aws_api_gateway_method.tool", "each.key"]}, "integration_http_method": {"constant_value": "POST"}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "type": {"constant_value": "AWS_PROXY"}, "uri": {"references": ["each.value"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_integration"}, {"address": "aws_api_gateway_method.tool", "expressions": {"authorization": {"constant_value": "COGNITO_USER_POOLS"}, "authorizer_id": {"references": ["aws_api_gateway_authorizer.cognito.id", "aws_api_gateway_authorizer.cognito"]}, "http_method": {"references": ["local.route_methods", "each.key"]}, "request_models": {"references": ["local.route_methods", "each.key", "aws_api_gateway_model.json_object.name", "aws_api_gateway_model.json_object"]}, "request_validator_id": {"references": ["aws_api_gateway_request_validator.body_and_params.id", "aws_api_gateway_request_validator.body_and_params"]}, "resource_id": {"references": ["aws_api_gateway_resource.tool", "each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method"}, {"address": "aws_api_gateway_method_settings.this", "expressions": {"method_path": {"constant_value": "*/*"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "settings": [{"throttling_burst_limit": {"references": ["var.throttle_burst_limit"]}, "throttling_rate_limit": {"references": ["var.throttle_rate_limit"]}}], "stage_name": {"references": ["aws_api_gateway_stage.this.stage_name", "aws_api_gateway_stage.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_method_settings"}, {"address": "aws_api_gateway_model.json_object", "expressions": {"content_type": {"constant_value": "application/json"}, "name": {"constant_value": "JsonObject"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "schema": {}}, "mode": "managed", "name": "json_object", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_model"}, {"address": "aws_api_gateway_request_validator.body_and_params", "expressions": {"name": {"constant_value": "body-and-params"}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "validate_request_body": {"constant_value": true}, "validate_request_parameters": {"constant_value": true}}, "mode": "managed", "name": "body_and_params", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_request_validator"}, {"address": "aws_api_gateway_resource.tool", "expressions": {"parent_id": {"references": ["aws_api_gateway_rest_api.this.root_resource_id", "aws_api_gateway_rest_api.this"]}, "path_part": {"references": ["each.key"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}}, "for_each_expression": {"references": ["local.route_invoke_arns"]}, "mode": "managed", "name": "tool", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_resource"}, {"address": "aws_api_gateway_rest_api.this", "expressions": {"endpoint_configuration": [{"types": {"constant_value": ["PRIVATE"]}, "vpc_endpoint_ids": {"references": ["var.vpc_endpoint_ids"]}}], "name": {"references": ["var.api_name"]}, "policy": {"references": ["data.aws_iam_policy_document.resource_policy.json", "data.aws_iam_policy_document.resource_policy"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_rest_api"}, {"address": "aws_api_gateway_stage.this", "expressions": {"access_log_settings": [{"destination_arn": {"references": ["aws_cloudwatch_log_group.access_logs.arn", "aws_cloudwatch_log_group.access_logs"]}, "format": {}}], "deployment_id": {"references": ["aws_api_gateway_deployment.this.id", "aws_api_gateway_deployment.this"]}, "rest_api_id": {"references": ["aws_api_gateway_rest_api.this.id", "aws_api_gateway_rest_api.this"]}, "stage_name": {"references": ["var.stage_name"]}, "tags": {"references": ["var.tags"]}, "xray_tracing_enabled": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_api_gateway_stage"}, {"address": "aws_cloudwatch_log_group.access_logs", "expressions": {"kms_key_id": {"references": ["var.access_log_kms_key_arn"]}, "name": {"references": ["var.api_name"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_lambda_permission.apigw_invoke", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["each.value"]}, "principal": {"constant_value": "apigateway.amazonaws.com"}, "source_arn": {"references": ["aws_api_gateway_rest_api.this.execution_arn", "aws_api_gateway_rest_api.this", "local.route_methods", "each.key", "each.key"]}, "statement_id": {"references": ["each.key"]}}, "for_each_expression": {"references": ["local.route_function_names"]}, "mode": "managed", "name": "apigw_invoke", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.resource_policy", "expressions": {"statement": [{"actions": {"constant_value": ["execute-api:Invoke"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "AllowInvokeFromNamedVpcEndpointsOnly"}}, {"actions": {"constant_value": ["execute-api:Invoke"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"references": ["var.vpc_endpoint_ids"]}, "variable": {"constant_value": "aws:sourceVpce"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["execute-api:/*"]}, "sid": {"constant_value": "DenyInvokeFromAnyOtherVpcEndpoint"}}]}, "mode": "data", "name": "resource_policy", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"access_log_kms_key_arn": {"description": "KMS customer-managed key ARN encrypting the API Gateway access log group at rest."}, "api_name": {"default": "crm-agent-eval-api", "description": "Name for the REST API."}, "cognito_user_pool_arn": {"description": "ARN of the Cognito user pool whose tokens the authorizer accepts (the `cognito` module user pool ARN output). A COGNITO_USER_POOLS authorizer validates that the token was issued by this pool; it does not validate the app-client audience."}, "extra_routes": {"default": {}, "description": "Routes that are not toolspec tools, and so are absent from `tool_lambda_invoke_arns`. Merged with\nthe tool map into the single local that generates every integration, route and permission, so\nthese carry the Cognito authorizer on the same terms as the tool routes.\n\nThe permitted keys are the allowlist validated below (`eval_trigger`, `capabilities`, `user_settings`).\n\n`method` is the HTTP method the client calls and defaults to `POST`; `capabilities` is a browser\n`GET` (`frontend/src/components/tuning/capabilityMatrix.ts`). The Lambda integration method is\nalways `POST` for `AWS_PROXY`, whatever the client method.\n"}, "log_retention_days": {"default": 365, "description": "Explicit CloudWatch Logs retention for the API Gateway access log group."}, "stage_name": {"default": "prod", "description": "API Gateway stage name."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "throttle_burst_limit": {"default": 50, "description": "Per-route burst limit (concurrent requests) enforced at the default-route throttle setting."}, "throttle_rate_limit": {"default": 25, "description": "Per-route steady-state rate limit (requests/second) enforced at the default-route throttle setting."}, "tool_lambda_function_names": {"description": "Map of tool_name -> that tool's action Lambda function name\n(`module.lambda_action[tool_name].function_name`), used to grant API Gateway\n`lambda:InvokeFunction` per function. Carries exactly the key set of `tool_lambda_invoke_arns`;\nthe REST API resource's precondition fails the plan otherwise.\n"}, "tool_lambda_invoke_arns": {"description": "Map of tool_name -> that tool's action Lambda invoke ARN (`module.lambda_action[tool_name].invoke_arn`),\none entry per routed tool in `crm.toolspec.definitions.ALL_TOOLS`. Every route, integration and\nauthorizer attachment is generated from this map (see `main.tf`). Must not be empty.\n"}, "vpc_endpoint_ids": {"description": "The `execute-api` interface VPC endpoint ids this private API is reachable through. Sets `endpoint_configuration.vpc_endpoint_ids` and is the allowlist in the API resource policy."}}}, "source": "./modules/api"}, "api_origin": {"expressions": {"access_logs_bucket": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "access_logs_prefix": {"references": ["local.alb_access_log_prefix"]}, "alb_ingress_security_group_ids": {"references": ["var.api_origin_ingress_security_group_ids"]}, "execute_api_security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "execute_api_target_ips": {"references": ["data.aws_network_interface.execute_api"]}, "name_prefix": {"references": ["local.name_prefix"]}, "private_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}, "tags": {"references": ["var.data_classification"]}, "vpc_id": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "module": {"outputs": {"alb_arn": {"description": "Internal ALB ARN. The VPC origin references the ALB by this ARN, which is how CloudFront routes without resolving the origin's domain name.", "expression": {"references": ["aws_lb.this.arn", "aws_lb.this"]}}, "alb_dns_name": {"description": "Internal ALB DNS name, for diagnostics only. It is not the CloudFront origin `domain_name`, which is `module.api.private_origin_domain_name`: API Gateway routes the private API on that Host header.", "expression": {"references": ["aws_lb.this.dns_name", "aws_lb.this"]}}, "alb_security_group_id": {"description": "The ALB's security group id, for asserting its ingress source and single scoped egress.", "expression": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}}, "listener_protocol": {"description": "The listener protocol configured on the ALB, for a check asserting the deployed `HTTP` listener.", "expression": {"references": ["aws_lb_listener.this.protocol", "aws_lb_listener.this"]}}, "target_group_arn": {"description": "Target group holding the execute-api endpoint ENI IPs, for the T3 check to assert target health from.", "expression": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}}, "vpc_origin_id": {"description": "Id of the CloudFront VPC origin. Goes into the distribution origin's `vpc_origin_config.vpc_origin_id` for the `/api/*` behaviour.", "expression": {"references": ["aws_cloudfront_vpc_origin.this.id", "aws_cloudfront_vpc_origin.this"]}}}, "resources": [{"address": "aws_cloudfront_vpc_origin.this", "expressions": {"tags": {"references": ["var.tags"]}, "vpc_origin_endpoint_config": [{"arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "http_port": {"references": ["var.listener_port"]}, "https_port": {"constant_value": 443}, "name": {"references": ["var.name_prefix"]}, "origin_protocol_policy": {"references": ["var.origin_protocol_policy"]}, "origin_ssl_protocols": [{"items": {"constant_value": ["TLSv1.2"]}, "quantity": {"constant_value": 1}}]}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_vpc_origin"}, {"address": "aws_lb.this", "expressions": {"access_logs": [{"bucket": {"references": ["var.access_logs_bucket"]}, "enabled": {"constant_value": true}, "prefix": {"references": ["var.access_logs_prefix"]}}], "drop_invalid_header_fields": {"constant_value": true}, "enable_deletion_protection": {"constant_value": true}, "internal": {"constant_value": true}, "load_balancer_type": {"constant_value": "application"}, "name": {"references": ["var.name_prefix"]}, "security_groups": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "subnets": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb"}, {"address": "aws_lb_listener.this", "expressions": {"default_action": [{"target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "type": {"constant_value": "forward"}}], "load_balancer_arn": {"references": ["aws_lb.this.arn", "aws_lb.this"]}, "port": {"references": ["var.listener_port"]}, "protocol": {"references": ["var.listener_protocol"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_listener"}, {"address": "aws_lb_target_group.execute_api", "expressions": {"health_check": [{"healthy_threshold": {"constant_value": 2}, "interval": {"constant_value": 30}, "matcher": {"constant_value": "200,403"}, "path": {"constant_value": "/"}, "protocol": {"constant_value": "HTTPS"}, "timeout": {"constant_value": 5}, "unhealthy_threshold": {"constant_value": 2}}], "name": {"references": ["var.name_prefix"]}, "port": {"constant_value": 443}, "protocol": {"constant_value": "HTTPS"}, "tags": {"references": ["var.tags"]}, "target_type": {"constant_value": "ip"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group"}, {"address": "aws_lb_target_group_attachment.execute_api", "count_expression": {"references": ["var.private_subnet_ids"]}, "expressions": {"port": {"constant_value": 443}, "target_group_arn": {"references": ["aws_lb_target_group.execute_api.arn", "aws_lb_target_group.execute_api"]}, "target_id": {"references": ["var.execute_api_target_ips", "count.index"]}}, "mode": "managed", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lb_target_group_attachment"}, {"address": "aws_security_group.alb", "expressions": {"description": {"constant_value": "Internal ALB fronting the private REST API for the CloudFront /api/* VPC origin"}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "alb", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_security_group_egress_rule.alb_to_endpoint", "expressions": {"description": {"constant_value": "internal ALB to execute-api interface endpoint (443, TLS)"}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["var.execute_api_security_group_id"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "alb_to_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.alb_from_cloudfront", "expressions": {"description": {"references": ["var.listener_port"]}, "from_port": {"references": ["var.listener_port"]}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["each.value"]}, "security_group_id": {"references": ["aws_security_group.alb.id", "aws_security_group.alb"]}, "to_port": {"references": ["var.listener_port"]}}, "for_each_expression": {"references": ["var.alb_ingress_security_group_ids"]}, "mode": "managed", "name": "alb_from_cloudfront", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}], "variables": {"access_logs_bucket": {"description": "S3 bucket receiving ALB access logs. Required."}, "access_logs_prefix": {"description": "Key prefix the ALB writes access logs under. No default; it must equal the prefix in the destination bucket policy grant (`//AWSLogs//*`). The root passes one local to both sides."}, "alb_ingress_security_group_ids": {"description": "Security group ids permitted to reach the ALB listener port: the security group the deployed CloudFront VPC origin presents. No default; see the first-deployment steps in `docs/runbook.md`."}, "execute_api_security_group_id": {"description": "Security group id of the `execute-api` interface endpoint, the ALB single egress destination on 443."}, "execute_api_target_ips": {"description": "Private IPv4 addresses of the `execute-api` interface endpoint's ENIs, one per entry in `private_subnet_ids`, resolved in the root. Registered as the target group's IP targets."}, "listener_port": {"default": 80, "description": "ALB listener port. 80 with the `http-only` origin protocol policy; 443 only if an origin certificate exists, which requires a domain the owner controls."}, "listener_protocol": {"default": "HTTP", "description": "ALB listener protocol. `HTTP` on the CloudFront->ALB hop: an accepted deviation from encryption-in-transit on that hop only. The ALB->endpoint hop is HTTPS regardless."}, "name_prefix": {"description": "Resource name prefix, from the root's `local.name_prefix`."}, "origin_protocol_policy": {"default": "http-only", "description": "How CloudFront connects to the VPC origin. Defaults to `http-only`; `match-viewer` is rejected by validation, since the viewer is always HTTPS and this stack has no origin certificate."}, "private_subnet_ids": {"description": "Private subnet ids for the ALB. Also fixes the plan-time count of endpoint ENIs, since the interface endpoint places one ENI per subnet (see the `count` note in main.tf)."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}, "vpc_id": {"description": "Id of the adopted VPC the ALB and target group live in (`modules/vpc`'s vpc id output)."}}}, "source": "./modules/api_origin"}, "cognito": {"expressions": {"mcp_client_generate_secret": {"constant_value": true}, "pre_token_generation_lambda_arn": {"references": ["module.lambda_action_pre_token_generation.function_arn", "module.lambda_action_pre_token_generation"]}, "pre_token_generation_lambda_function_name": {"references": ["module.lambda_action_pre_token_generation.function_name", "module.lambda_action_pre_token_generation"]}, "spa_callback_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "spa_logout_urls": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}, "user_pool_name": {"constant_value": "crm-agent-eval"}}, "module": {"outputs": {"admin_group_name": {"description": "Name of the Cognito group whose members are admin.", "expression": {"references": ["aws_cognito_user_group.admin.name", "aws_cognito_user_group.admin"]}}, "allowed_client_ids": {"description": "The SPA and MCP app client ids, for Gateway #1's authorizer and interceptor `COGNITO_ALLOWED_CLIENT_IDS`. Excludes the MCP OAuth client.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "chat_gateway_allowed_client_ids": {"description": "`allowed_client_ids` plus the MCP OAuth client: Gateway #2's authorizer `allowed_clients` and its interceptor's `COGNITO_ALLOWED_CLIENT_IDS`.", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa", "aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp", "aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "chat_scope_identifier": {"description": "Gateway #2's own `supervisor/chat` scope: its `CUSTOM_JWT` `allowedScopes`, the pre-token trigger's and interceptor's `CHAT_SCOPE`. Distinct from `gateway_scope_identifier`.", "expression": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}}, "domain": {"description": "Cognito user pool prefix domain (no custom ACM certificate). The base for the `/oauth2/token` token endpoint the MCP `client_credentials` flow mints against.", "expression": {"references": ["aws_cognito_user_pool_domain.this.domain", "aws_cognito_user_pool_domain.this"]}}, "gateway_scope_identifier": {"description": "Fully-qualified `/` custom scope\n(`aws_cognito_resource_server.gateway.scope_identifiers[0]`) that the MCP app client's\n`client_credentials` token carries, and the value the AgentCore Gateway's `CUSTOM_JWT` authorizer\nallows (`allowedScopes`). The root composition consumes this output for both.\n", "expression": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway"]}}, "mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["aws_cognito_user_pool_client.mcp.id", "aws_cognito_user_pool_client.mcp"]}}, "mcp_client_secret": {"description": "App client secret for the MCP client. Sensitive; held in Terraform state and the gitignored results/tf-outputs.json, never in a tracked file. This stack creates no Secrets Manager entry for it.", "expression": {"references": ["aws_cognito_user_pool_client.mcp.client_secret", "aws_cognito_user_pool_client.mcp"]}, "sensitive": true}, "mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, no secret; Gateway #2 only).", "expression": {"references": ["aws_cognito_user_pool_client.mcp_oauth.id", "aws_cognito_user_pool_client.mcp_oauth"]}}, "spa_client_id": {"description": "App client id for the SPA (public client, no secret).", "expression": {"references": ["aws_cognito_user_pool_client.spa.id", "aws_cognito_user_pool_client.spa"]}}, "user_pool_arn": {"description": "Cognito user pool ARN.", "expression": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}}, "user_pool_endpoint": {"description": "Cognito user pool endpoint, used to derive the OIDC discovery and JWKS URLs.", "expression": {"references": ["aws_cognito_user_pool.this.endpoint", "aws_cognito_user_pool.this"]}}, "user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}}, "resources": [{"address": "aws_cognito_resource_server.gateway", "expressions": {"identifier": {"constant_value": "gateway"}, "name": {"constant_value": "AgentCore Gateway"}, "scope": [{"scope_description": {"constant_value": "Invoke the AgentCore Gateway MCP surface machine-to-machine."}, "scope_name": {"constant_value": "invoke"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_resource_server.supervisor", "expressions": {"identifier": {"constant_value": "supervisor"}, "name": {"constant_value": "AgentCore chat Gateway"}, "scope": [{"scope_description": {"constant_value": "Call chat_with_supervisor on the MCP chat Gateway."}, "scope_name": {"constant_value": "chat"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "supervisor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_resource_server"}, {"address": "aws_cognito_user_group.admin", "expressions": {"description": {"constant_value": "CRM eval administrators: live sweeps, cancel and unlock."}, "name": {"constant_value": "admin"}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "admin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_group"}, {"address": "aws_cognito_user_pool.this", "expressions": {"account_recovery_setting": [{"recovery_mechanism": [{"name": {"constant_value": "verified_email"}, "priority": {"constant_value": 1}}]}], "admin_create_user_config": [{"allow_admin_create_user_only": {"constant_value": true}}], "auto_verified_attributes": {"constant_value": ["email"]}, "lambda_config": [{"pre_token_generation_config": [{"lambda_arn": {"references": ["var.pre_token_generation_lambda_arn"]}, "lambda_version": {"constant_value": "V2_0"}}]}], "mfa_configuration": {"references": ["var.mfa_configuration"]}, "name": {"references": ["var.user_pool_name"]}, "password_policy": [{"minimum_length": {"constant_value": 14}, "require_lowercase": {"constant_value": true}, "require_numbers": {"constant_value": true}, "require_symbols": {"constant_value": true}, "require_uppercase": {"constant_value": true}, "temporary_password_validity_days": {"constant_value": 7}}], "schema": [{"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "rep_id"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "book"}, "string_attribute_constraints": [{"max_length": {"constant_value": "2048"}, "min_length": {"constant_value": "0"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "full_visibility"}, "string_attribute_constraints": [{"max_length": {"constant_value": "8"}, "min_length": {"constant_value": "1"}}]}, {"attribute_data_type": {"constant_value": "String"}, "mutable": {"constant_value": true}, "name": {"constant_value": "tenant"}, "string_attribute_constraints": [{"max_length": {"constant_value": "128"}, "min_length": {"constant_value": "1"}}]}], "software_token_mfa_configuration": [{"enabled": {"constant_value": true}}], "user_pool_tier": {"constant_value": "ESSENTIALS"}, "username_attributes": {"constant_value": ["email"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool"}, {"address": "aws_cognito_user_pool_client.mcp", "expressions": {"access_token_validity": {"constant_value": 5}, "allowed_oauth_flows": {"constant_value": ["client_credentials"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.gateway.scope_identifiers[0]", "aws_cognito_resource_server.gateway.scope_identifiers", "aws_cognito_resource_server.gateway", "aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"references": ["var.mcp_client_generate_secret"]}, "name": {"constant_value": "crm-agent-eval-mcp"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "minutes"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.mcp_oauth", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"references": ["aws_cognito_resource_server.supervisor.scope_identifiers[0]", "aws_cognito_resource_server.supervisor.scope_identifiers", "aws_cognito_resource_server.supervisor"]}, "callback_urls": {"constant_value": ["http://localhost:6274/oauth/callback", "http://localhost:6274/oauth/callback/debug", "http://localhost:33418/callback"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_REFRESH_TOKEN_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "name": {"constant_value": "crm-agent-eval-mcp-oauth"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "mcp_oauth", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_client.spa", "expressions": {"access_token_validity": {"constant_value": 1}, "allowed_oauth_flows": {"constant_value": ["code"]}, "allowed_oauth_flows_user_pool_client": {"constant_value": true}, "allowed_oauth_scopes": {"constant_value": ["openid", "email", "profile"]}, "callback_urls": {"references": ["var.spa_callback_urls"]}, "enable_token_revocation": {"constant_value": true}, "explicit_auth_flows": {"constant_value": ["ALLOW_USER_SRP_AUTH", "ALLOW_REFRESH_TOKEN_AUTH", "ALLOW_ADMIN_USER_PASSWORD_AUTH"]}, "generate_secret": {"constant_value": false}, "id_token_validity": {"constant_value": 1}, "logout_urls": {"references": ["var.spa_logout_urls"]}, "name": {"constant_value": "crm-agent-eval-spa"}, "prevent_user_existence_errors": {"constant_value": "ENABLED"}, "read_attributes": {"references": ["local.writable_profile_attributes", "local.scope_bearing_attributes"]}, "refresh_token_validity": {"constant_value": 30}, "supported_identity_providers": {"constant_value": ["COGNITO"]}, "token_validity_units": [{"access_token": {"constant_value": "hours"}, "id_token": {"constant_value": "hours"}, "refresh_token": {"constant_value": "days"}}], "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "write_attributes": {"references": ["local.writable_profile_attributes"]}}, "mode": "managed", "name": "spa", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_client"}, {"address": "aws_cognito_user_pool_domain.this", "expressions": {"domain": {"references": ["var.user_pool_name", "aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}, "user_pool_id": {"references": ["aws_cognito_user_pool.this.id", "aws_cognito_user_pool.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cognito_user_pool_domain"}, {"address": "aws_lambda_permission.pre_token_generation", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.pre_token_generation_lambda_function_name"]}, "principal": {"constant_value": "cognito-idp.amazonaws.com"}, "source_arn": {"references": ["aws_cognito_user_pool.this.arn", "aws_cognito_user_pool.this"]}, "statement_id": {"constant_value": "AllowCognitoInvokePreTokenGeneration"}}, "mode": "managed", "name": "pre_token_generation", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}], "variables": {"mcp_client_generate_secret": {"default": true, "description": "Whether the MCP app client is confidential (generates a client secret) and uses\n`client_credentials`. Defaults to true: the MCP client is a machine-to-machine caller. The stack\ncreates no Secrets Manager entry for the secret; see docs/mcp-client-guide.md.\n"}, "mfa_configuration": {"default": "OPTIONAL", "description": "Pool-level MFA enforcement. Defaults to `OPTIONAL`; the SPA does not implement TOTP enrollment, so\n`ON` makes interactive sign-in through the deployed frontend impossible. TOTP stays enabled either\nway, so a user who enrolls is still challenged.\n\n`OFF` is rejected by validation. Set `ON` once the frontend can complete\n`MFA_SETUP`/`SOFTWARE_TOKEN_MFA`.\n"}, "pre_token_generation_lambda_arn": {"description": "ARN of the pre-token-generation Lambda (V2 event) that stamps `custom:rep_id`,\n`custom:book`, `custom:full_visibility`, and `custom:tenant` into the access\ntoken. Created by the root composition and passed in.\n"}, "pre_token_generation_lambda_function_name": {"description": "Name of the pre-token-generation Lambda, used to scope the\n`aws_lambda_permission` that lets Cognito invoke it. Must be the function\nbehind `pre_token_generation_lambda_arn`.\n"}, "spa_callback_urls": {"description": "Allowed OAuth callback URLs for the SPA app client."}, "spa_logout_urls": {"description": "Allowed OAuth sign-out redirect URLs for the SPA app client."}, "user_pool_name": {"default": "crm-agent-eval", "description": "Name for the Cognito user pool."}}}, "source": "./modules/cognito"}, "dynamodb": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.dynamodb_data_plane_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"gsi_arns": {"description": "Map of logical table name to a map of GSI name to that index's full ARN\n(`/index/`). Consumed by `infra/main.tf`'s per-tool\n`dynamodb_grants[].index_arns`: every `dynamodb:Query` in this schema targets a named GSI (see\n`crm.store.store.query_gsi`), so the grant names the index ARN.\n", "expression": {"references": ["local.tables"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}, "kms_key_id": {"description": "Key ID of the customer-managed KMS key encrypting all eleven tables.", "expression": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "table_arns": {"description": "Map of logical table name to table ARN.", "expression": {"references": ["local.tables"]}}, "table_names": {"description": "Map of logical table name to physical DynamoDB table name.", "expression": {"references": ["local.tables"]}}, "table_stream_arns": {"description": "Map of logical table name to stream ARN (null where streams are disabled).", "expression": {"references": ["local.tables"]}}}, "resources": [{"address": "aws_dynamodb_resource_policy.tables", "expressions": {"policy": {"references": ["local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.data_plane_principal_arns", "local.table_policy_arns", "each.key", "local.table_policy_arns", "each.key", "var.administrator_principal_arns"]}, "resource_arn": {"references": ["each.value.arn", "each.value"]}}, "for_each_expression": {"references": ["local.tables"]}, "mode": "managed", "name": "tables", "provider_config_key": "aws", "schema_version": 0, "type": "aws_dynamodb_resource_policy"}, {"address": "aws_dynamodb_table.accounts", "expressions": {"attribute": [{"name": {"constant_value": "account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner"}, "non_key_attributes": {"constant_value": ["account_id", "owner_rep_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "account_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "accounts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.activities", "expressions": {"attribute": [{"name": {"constant_value": "activity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "occurred_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["activity_id", "account_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "occurred_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["activity_id", "opportunity_id", "kind", "subject", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "activity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "activities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.audit_records", "expressions": {"attribute": [{"name": {"constant_value": "audit_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["audit_id", "target_table", "target_id", "actor_rep_id", "reversed_at", "account_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["audit_id", "actor_rep_id", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["audit_id", "account_id", "target_id", "target_table", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "audit_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "audit_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.contacts", "expressions": {"attribute": [{"name": {"constant_value": "contact_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["contact_id", "account_id", "name", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "contact_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "contacts", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_results", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "result_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "run_id_task_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "arm"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "run_id_task_id"}, "name": {"constant_value": "gsi_task"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "result_id", "arm"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "arm"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "range_key": {"constant_value": "result_id"}, "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_results", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.eval_runs", "expressions": {"attribute": [{"name": {"constant_value": "run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "started_at"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["tenant", "run_id", "status"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "started_at"}}], "hash_key": {"constant_value": "run_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_runs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.notes", "expressions": {"attribute": [{"name": {"constant_value": "note_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_opportunity_id"}, "name": {"constant_value": "gsi_opportunity"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["note_id", "opportunity_id", "body", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "note_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "notes", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.opportunities", "expressions": {"attribute": [{"name": {"constant_value": "opportunity_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_account_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_owner_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "stage_close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_stage"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "close_date"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "name_lower"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_account_id"}, "name": {"constant_value": "gsi_account"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_owner_rep_id"}, "name": {"constant_value": "gsi_owner_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "stage_close_date"}}, {"hash_key": {"constant_value": "tenant_stage"}, "name": {"constant_value": "gsi_stage"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "name_lower", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "close_date"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["opportunity_id", "account_id", "name", "owner_rep_id", "stage", "close_date", "value", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "name_lower"}}], "hash_key": {"constant_value": "opportunity_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "opportunities", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.proposals", "expressions": {"attribute": [{"name": {"constant_value": "proposal_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_status"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_actor_rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_target_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_status"}, "name": {"constant_value": "gsi_status"}, "non_key_attributes": {"constant_value": ["proposal_id", "status", "target_table", "target_id", "actor_rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_actor_rep_id"}, "name": {"constant_value": "gsi_actor"}, "non_key_attributes": {"constant_value": ["proposal_id", "actor_rep_id", "status", "target_table", "target_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_target_id"}, "name": {"constant_value": "gsi_target"}, "non_key_attributes": {"constant_value": ["proposal_id", "target_table", "target_id", "status", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["proposal_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "proposal_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "proposals", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.reps", "expressions": {"attribute": [{"name": {"constant_value": "rep_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["rep_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "rep_id"}}], "hash_key": {"constant_value": "rep_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}, "ttl": [{"attribute_name": {"constant_value": "expires_at"}, "enabled": {"constant_value": true}}]}, "mode": "managed", "name": "reps", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_dynamodb_table.usage_records", "expressions": {"attribute": [{"name": {"constant_value": "usage_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_correlation_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "created_at"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant_run_id"}, "type": {"constant_value": "S"}}, {"name": {"constant_value": "tenant"}, "type": {"constant_value": "S"}}], "billing_mode": {"constant_value": "PAY_PER_REQUEST"}, "global_secondary_index": [{"hash_key": {"constant_value": "tenant_correlation_id"}, "name": {"constant_value": "gsi_correlation"}, "non_key_attributes": {"constant_value": ["usage_id", "correlation_id", "run_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant_run_id"}, "name": {"constant_value": "gsi_run"}, "non_key_attributes": {"constant_value": ["usage_id", "run_id", "correlation_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}, {"hash_key": {"constant_value": "tenant"}, "name": {"constant_value": "gsi_tenant"}, "non_key_attributes": {"constant_value": ["usage_id", "tenant"]}, "projection_type": {"constant_value": "INCLUDE"}, "range_key": {"constant_value": "created_at"}}], "hash_key": {"constant_value": "usage_id"}, "name": {"references": ["var.name_prefix"]}, "point_in_time_recovery": [{"enabled": {"constant_value": true}}], "server_side_encryption": [{"enabled": {"constant_value": true}, "kms_key_arn": {"references": ["aws_kms_key.dynamodb.arn", "aws_kms_key.dynamodb"]}}], "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "usage_records", "provider_config_key": "aws", "schema_version": 1, "type": "aws_dynamodb_table"}, {"address": "aws_kms_alias.dynamodb", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.dynamodb.key_id", "aws_kms_key.dynamodb"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.dynamodb", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM DynamoDB table encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.dynamodb", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.dynamodb.id", "aws_kms_key.dynamodb"]}, "policy": {"references": ["var.account_id", "var.data_plane_principal_arns", "var.administrator_principal_arns"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"account_id": {"description": "Account id of the account-root statement in the CMK key policy."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to table and CMK administration. Every other principal is denied by the table and key policies."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The table and key policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the tables' data plane and to the CMK's key use. Every other principal is denied by the table and key policies."}, "name_prefix": {"default": "", "description": "Prefix applied to table and alias names, e.g. tenant or environment scoping."}}}, "source": "./modules/dynamodb"}, "eni_function_code_deny": {"expressions": {"name_prefix": {"references": ["local.name_prefix"]}}, "module": {"outputs": {"policy_arn": {"description": "ARN of the ENI function-code Deny policy, passed to every `lambda_action` and `agent_relay` instantiation.", "expression": {"references": ["aws_iam_policy.this.arn", "aws_iam_policy.this"]}}}, "resources": [{"address": "aws_iam_policy.this", "expressions": {"description": {"constant_value": "Denies the Hyperplane ENI actions to Lambda function code; Lambda's own ENI management is unaffected."}, "name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.this.json", "data.aws_iam_policy_document.this"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "data.aws_iam_policy_document.this", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:DetachNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "condition": [{"test": {"constant_value": "Null"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "lambda:SourceFunctionArn"}}], "effect": {"constant_value": "Deny"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyEniActionsToFunctionCode"}}]}, "mode": "data", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the policy name."}}}, "source": "./modules/eni_function_code_deny"}, "eval_artifacts": {"expressions": {"access_log_bucket_id": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}, "account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "data_plane_principal_arns": {"references": ["local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns"]}, "kms_key_arn": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "name_prefix": {"references": ["local.name_prefix"]}, "writer_role_name": {"constant_value": null}}, "module": {"outputs": {"artifact_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the writer grant covers.", "expression": {"references": ["var.artifact_prefix"]}}, "bucket_arn": {"description": "ARN of the eval-artefacts bucket, for a consumer composing its own policy against it.", "expression": {"references": ["aws_s3_bucket.this.arn", "aws_s3_bucket.this"]}}, "bucket_name": {"description": "Name of the eval-artefacts bucket, which embeds the account id. Read by application code and the smoke suite.", "expression": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}}}, "resources": [{"address": "aws_iam_role_policy.writer", "count_expression": {"references": ["var.writer_role_name"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.writer.json", "data.aws_iam_policy_document.writer"]}, "role": {"references": ["var.writer_role_name"]}}, "mode": "managed", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_s3_bucket.this", "expressions": {"bucket": {"references": ["local.bucket_name"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.artifact_retention_days"]}}], "filter": [{"prefix": {"references": ["var.artifact_prefix"]}}], "id": {"constant_value": "expire-artifacts"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}, {"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-noncurrent-and-abort-uploads"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.artifact_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "target_bucket": {"references": ["var.access_log_bucket_id"]}, "target_prefix": {"constant_value": "s3-access-logs/eval-artifacts/"}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "policy": {"references": ["data.aws_iam_policy_document.bucket.json", "data.aws_iam_policy_document.bucket"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.this", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["var.kms_key_arn"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.this", "expressions": {"bucket": {"references": ["aws_s3_bucket.this.id", "aws_s3_bucket.this"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_iam_policy_document.bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringNotEquals"}, "values": {"constant_value": ["aws:kms"]}, "variable": {"constant_value": "s3:x-amz-server-side-encryption"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyUnencryptedObjectUploads"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.data_plane_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn", "local.bucket_arn"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.bucket_arn"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.writer", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bucket_arn", "var.artifact_prefix"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.kms_key_arn"]}, "sid": {"constant_value": "UseBucketCmk"}}]}, "mode": "data", "name": "writer", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}], "variables": {"access_log_bucket_id": {"description": "Bucket id receiving this bucket S3 access logs. Must be a different bucket."}, "account_id": {"description": "AWS account id, part of the globally-unique bucket name. Passed in by the caller so the module plans offline."}, "administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to bucket administration. Every other principal is denied it by the bucket policy."}, "artifact_prefix": {"default": "sweeps", "description": "Single key prefix all artefacts are written under, and the only prefix the writer grant covers."}, "artifact_retention_days": {"default": 30, "description": "Lifecycle expiry in days, applied to current objects, noncurrent versions and incomplete multipart\nuploads alike. Artefacts are reproducible from a sweep with the same arguments and `dataset_seed`.\n"}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The bucket policy refuses to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "data_classification": {"description": "Value of the mandatory `data-classification` tag."}, "data_plane_principal_arns": {"description": "IAM role or user ARNs admitted to the bucket's object reads, lists and writes. Every other principal is denied them by the bucket policy."}, "kms_key_arn": {"description": "Customer-managed key ARN encrypting this bucket's objects, and the key the writer grant covers.\nCreated by the caller; it must be a dedicated key (see README).\n"}, "name_prefix": {"description": "Deployment name prefix, from the root composition's `local.name_prefix`. Part of the bucket name alongside the account id."}, "writer_role_name": {"default": null, "description": "IAM role name the writer policy is attached to (the sweep worker's role). `null` (the default)\nattaches nothing. The grant's scope comes from the policy's own resources, not from this value.\n"}}}, "source": "./modules/eval_artifacts"}, "frontend_cdn": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "agent_relay_function_name": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}, "agent_relay_function_url_domain": {"references": ["module.agent_relay.function_url_domain", "module.agent_relay"]}, "alb_access_log_prefix": {"references": ["local.alb_access_log_prefix"]}, "api_gateway_domain_name": {"references": ["module.api.private_origin_domain_name", "module.api"]}, "api_gateway_stage_name": {"references": ["module.api.stage_name", "module.api"]}, "api_origin_vpc_origin_id": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "csp_connect_src_extra": {"references": ["local.spa_connect_src_extra"]}, "csp_script_hashes": {"references": ["local.spa_inline_script_hashes"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 90}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}, "origin_noncurrent_version_retention_days": {"constant_value": 30}}, "module": {"outputs": {"distribution_arn": {"description": "ARN of the CloudFront distribution, used by the origin bucket policy's `AWS:SourceArn` condition.", "expression": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}}, "distribution_domain_name": {"description": "CloudFront distribution domain name (e.g. `d111111abcdef8.cloudfront.net`).", "expression": {"references": ["aws_cloudfront_distribution.frontend.domain_name", "aws_cloudfront_distribution.frontend"]}}, "distribution_id": {"description": "ID of the CloudFront distribution.", "expression": {"references": ["aws_cloudfront_distribution.frontend.id", "aws_cloudfront_distribution.frontend"]}}, "kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the origin bucket.", "expression": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}}, "logs_bucket_name": {"description": "Name of the S3 bucket receiving S3 access logs and CloudFront access logs.", "expression": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}}, "origin_bucket_arn": {"description": "ARN of the private S3 origin bucket.", "expression": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}}, "origin_bucket_name": {"description": "Name of the private S3 bucket that holds the frontend static build.", "expression": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}}}, "resources": [{"address": "aws_cloudfront_distribution.frontend", "expressions": {"comment": {"references": ["var.name_prefix"]}, "default_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_optimized.id", "data.aws_cloudfront_cache_policy.caching_optimized"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.spa_history_fallback.arn", "aws_cloudfront_function.spa_history_fallback"]}}], "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "s3-frontend-origin"}, "viewer_protocol_policy": {"constant_value": "redirect-to-https"}}], "default_root_object": {"constant_value": "index.html"}, "enabled": {"constant_value": true}, "logging_config": [{"bucket": {"references": ["aws_s3_bucket.logs.bucket_domain_name", "aws_s3_bucket.logs"]}, "include_cookies": {"constant_value": false}, "prefix": {"constant_value": "cloudfront-access-logs/"}}], "ordered_cache_behavior": [{"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": true}, "function_association": [{"event_type": {"constant_value": "viewer-request"}, "function_arn": {"references": ["aws_cloudfront_function.api_path_rewrite.arn", "aws_cloudfront_function.api_path_rewrite"]}}], "origin_request_policy_id": {"references": ["data.aws_cloudfront_origin_request_policy.all_viewer_except_host.id", "data.aws_cloudfront_origin_request_policy.all_viewer_except_host"]}, "path_pattern": {"constant_value": "/api/*"}, "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "api-gateway-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}, {"allowed_methods": {"constant_value": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]}, "cache_policy_id": {"references": ["data.aws_cloudfront_cache_policy.caching_disabled.id", "data.aws_cloudfront_cache_policy.caching_disabled"]}, "cached_methods": {"constant_value": ["GET", "HEAD"]}, "compress": {"constant_value": false}, "origin_request_policy_id": {"references": ["aws_cloudfront_origin_request_policy.agent_relay.id", "aws_cloudfront_origin_request_policy.agent_relay"]}, "path_pattern": {"constant_value": "/agent/*"}, "response_headers_policy_id": {"references": ["aws_cloudfront_response_headers_policy.security_headers.id", "aws_cloudfront_response_headers_policy.security_headers"]}, "target_origin_id": {"constant_value": "agent-relay-origin"}, "viewer_protocol_policy": {"constant_value": "https-only"}}], "origin": [{"domain_name": {"references": ["aws_s3_bucket.origin.bucket_regional_domain_name", "aws_s3_bucket.origin"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.origin.id", "aws_cloudfront_origin_access_control.origin"]}, "origin_id": {"constant_value": "s3-frontend-origin"}}, {"domain_name": {"references": ["var.api_gateway_domain_name"]}, "origin_id": {"constant_value": "api-gateway-origin"}, "vpc_origin_config": [{"vpc_origin_id": {"references": ["var.api_origin_vpc_origin_id"]}}]}, {"custom_origin_config": [{"http_port": {"constant_value": 80}, "https_port": {"constant_value": 443}, "origin_protocol_policy": {"constant_value": "https-only"}, "origin_read_timeout": {"constant_value": 60}, "origin_ssl_protocols": {"constant_value": ["TLSv1.2"]}}], "domain_name": {"references": ["var.agent_relay_function_url_domain"]}, "origin_access_control_id": {"references": ["aws_cloudfront_origin_access_control.agent_relay.id", "aws_cloudfront_origin_access_control.agent_relay"]}, "origin_id": {"constant_value": "agent-relay-origin"}}], "price_class": {"constant_value": "PriceClass_100"}, "restrictions": [{"geo_restriction": [{"restriction_type": {"constant_value": "none"}}]}], "tags": {"references": ["var.data_classification"]}, "viewer_certificate": [{"cloudfront_default_certificate": {"constant_value": true}}]}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudfront_distribution"}, {"address": "aws_cloudfront_function.api_path_rewrite", "expressions": {"code": {"references": ["path.module", "var.api_gateway_stage_name"]}, "comment": {"constant_value": "Rewrite /api/* onto the REST API's stage path"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "api_path_rewrite", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_function.spa_history_fallback", "expressions": {"code": {"references": ["path.module"]}, "comment": {"constant_value": "Serve /index.html for SPA client-side routes"}, "name": {"references": ["var.name_prefix"]}, "publish": {"constant_value": true}, "runtime": {"constant_value": "cloudfront-js-2.0"}}, "mode": "managed", "name": "spa_history_fallback", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_function"}, {"address": "aws_cloudfront_origin_access_control.agent_relay", "expressions": {"description": {"constant_value": "SigV4-signs origin requests to the relay's AWS_IAM Function URL"}, "name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "lambda"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_access_control.origin", "expressions": {"name": {"references": ["var.name_prefix"]}, "origin_access_control_origin_type": {"constant_value": "s3"}, "signing_behavior": {"constant_value": "always"}, "signing_protocol": {"constant_value": "sigv4"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_access_control"}, {"address": "aws_cloudfront_origin_request_policy.agent_relay", "expressions": {"comment": {"constant_value": "Forward every viewer header except Host to the relay origin"}, "cookies_config": [{"cookie_behavior": {"constant_value": "all"}}], "headers_config": [{"header_behavior": {"constant_value": "allExcept"}, "headers": [{"items": {"constant_value": ["host"]}}]}], "name": {"references": ["var.name_prefix"]}, "query_strings_config": [{"query_string_behavior": {"constant_value": "all"}}]}, "mode": "managed", "name": "agent_relay", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "aws_cloudfront_response_headers_policy.security_headers", "expressions": {"comment": {"constant_value": "Security headers and an enforced Content-Security-Policy for the CRM frontend"}, "name": {"references": ["var.name_prefix"]}, "security_headers_config": [{"content_security_policy": [{"content_security_policy": {"references": ["local.content_security_policy"]}, "override": {"constant_value": true}}], "content_type_options": [{"override": {"constant_value": true}}], "frame_options": [{"frame_option": {"constant_value": "DENY"}, "override": {"constant_value": true}}], "referrer_policy": [{"override": {"constant_value": true}, "referrer_policy": {"constant_value": "strict-origin-when-cross-origin"}}], "strict_transport_security": [{"access_control_max_age_sec": {"constant_value": 31536000}, "include_subdomains": {"constant_value": true}, "override": {"constant_value": true}, "preload": {"constant_value": true}}], "xss_protection": [{"mode_block": {"constant_value": true}, "override": {"constant_value": true}, "protection": {"constant_value": true}}]}]}, "mode": "managed", "name": "security_headers", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_response_headers_policy"}, {"address": "aws_kms_alias.frontend", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.frontend.key_id", "aws_kms_key.frontend"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.frontend", "expressions": {"deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CRM frontend CDN origin bucket encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.frontend", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.frontend.id", "aws_kms_key.frontend"]}, "policy": {"references": ["data.aws_iam_policy_document.frontend_kms.json", "data.aws_iam_policy_document.frontend_kms"]}}, "mode": "managed", "name": "frontend", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_lambda_permission.agent_relay_function_url", "expressions": {"action": {"constant_value": "lambda:InvokeFunctionUrl"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "function_url_auth_type": {"constant_value": "AWS_IAM"}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunctionUrl"}}, "mode": "managed", "name": "agent_relay_function_url", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_lambda_permission.agent_relay_invoke_function", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.agent_relay_function_name"]}, "principal": {"constant_value": "cloudfront.amazonaws.com"}, "source_arn": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "statement_id": {"constant_value": "AllowCloudFrontOacInvokeFunction"}}, "mode": "managed", "name": "agent_relay_invoke_function", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "aws_s3_bucket.logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.origin", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "filter": [{}], "id": {"constant_value": "expire-superseded-builds"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.origin_noncurrent_version_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "target_bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "target_prefix": {"constant_value": "s3-access-logs/origin/"}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerPreferred"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "policy": {"references": ["data.aws_iam_policy_document.logs_tls_deny.json", "data.aws_iam_policy_document.logs_tls_deny"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "policy": {"references": ["data.aws_iam_policy_document.origin.json", "data.aws_iam_policy_document.origin"]}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.origin", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.frontend.arn", "aws_kms_key.frontend"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.logs.id", "aws_s3_bucket.logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.origin", "expressions": {"bucket": {"references": ["aws_s3_bucket.origin.id", "aws_s3_bucket.origin"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_cloudfront_cache_policy.caching_disabled", "expressions": {"name": {"constant_value": "Managed-CachingDisabled"}}, "mode": "data", "name": "caching_disabled", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_cache_policy.caching_optimized", "expressions": {"name": {"constant_value": "Managed-CachingOptimized"}}, "mode": "data", "name": "caching_optimized", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_cache_policy"}, {"address": "data.aws_cloudfront_origin_request_policy.all_viewer_except_host", "expressions": {"name": {"constant_value": "Managed-AllViewerExceptHostHeader"}}, "mode": "data", "name": "all_viewer_except_host", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudfront_origin_request_policy"}, {"address": "data.aws_iam_policy_document.frontend_kms", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudFrontOACDecrypt"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "frontend_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_partition.current.partition", "data.aws_partition.current", "data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logdelivery.elasticloadbalancing.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "var.alb_access_log_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AllowAlbAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.logs.arn", "aws_s3_bucket.logs", "aws_s3_bucket.logs.arn", "aws_s3_bucket.logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.origin", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["aws_cloudfront_distribution.frontend.arn", "aws_cloudfront_distribution.frontend"]}, "variable": {"constant_value": "AWS:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudfront.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "AllowCloudFrontOACRead"}}, {"actions": {"constant_value": ["s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin", "aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyObjectWritesToNonOperators"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.origin.arn", "aws_s3_bucket.origin"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "origin", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_partition.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_partition"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of the frontend CMK and the origin bucket. Every other principal is denied it."}, "agent_relay_function_name": {"description": "The relay function name (`module.agent_relay.function_name`), for the distribution-scoped `lambda:InvokeFunctionUrl` permission this module declares."}, "agent_relay_function_url_domain": {"description": "Host portion of the relay's Lambda Function URL that the `/agent/*` behaviour routes to (`module.agent_relay.function_url_domain`). The browser reaches the Runtime only through the relay."}, "alb_access_log_prefix": {"description": "Key prefix the internal ALB writes access logs under, used to scope this module ELB log-delivery grant to `//AWSLogs//*`. No default; it must equal the prefix the load balancer is configured with, and the root passes one local to both modules."}, "api_gateway_domain_name": {"description": "Origin hostname for the `/api/*` behaviour, from `module.api.private_origin_domain_name` (`-.execute-api..amazonaws.com`). It is the `Host` header the private REST API routes on, not a name CloudFront resolves; the VPC origin routes by ALB ARN."}, "api_gateway_stage_name": {"description": "Stage name the REST API serves its routes beneath (`infra/modules/api/` `stage_name`). The `/api/*` viewer-request function rewrites `/api/` to `//`, since CloudFront forwards the viewer path to a custom origin unchanged."}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin fronting the private REST API (`module.api_origin.vpc_origin_id`), consumed by the `/api/*` origin `vpc_origin_config`."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and origin-bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "csp_connect_src_extra": {"description": "Origins (`https://`) added to the CSP `connect-src` beside `'self'`: the endpoints the SPA calls directly, such as the regional Cognito user-pool endpoint and the hosted-UI domain."}, "csp_script_hashes": {"description": "CSP source hashes (`sha256-`, unquoted) of the SPA's inline scripts, added to `script-src` beside `'self'`."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "log_retention_days": {"default": 90, "description": "Retention, in days, for the S3 bucket holding S3 access logs and CloudFront access logs."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to frontend-CMK use and to writes into the origin bucket."}, "origin_noncurrent_version_retention_days": {"default": 30, "description": "Days a superseded (noncurrent) object version in the origin bucket is kept before it expires. Current objects never expire."}}}, "source": "./modules/frontend_cdn"}, "lambda_action": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "config_parameter_arns": {"references": ["local.routed_tool_names", "each.key", "local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["local.routed_tool_names", "each.key", "aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "cursor_kms_grant_enabled": {"references": ["local.cursor_tools", "each.key"]}, "cursor_kms_key_arn": {"references": ["local.cursor_tools", "each.key", "aws_kms_key.cursor.arn", "aws_kms_key.cursor"]}, "denied_own_table_actions": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.tool_dynamodb_grants", "each.key"]}, "dynamodb_grants": {"references": ["local.tool_dynamodb_grants", "each.key", "module.dynamodb.table_arns", "module.dynamodb", "local.tool_query_indexes", "each.key", "local.tool_query_indexes", "each.key", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "local.tool_query_indexes", "each.key"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.routed_tool_names", "each.key", "local.api_allowed_client_ids_parameter_name", "local.cursor_tools", "each.key", "aws_kms_key.cursor.arn", "aws_kms_key.cursor"]}, "filename": {"references": ["var.lambda_build_dir", "each.key"]}, "function_name": {"references": ["each.key"]}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"references": ["each.value.handler", "each.value"]}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency", "each.key"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["var.lambda_build_dir", "each.key"]}, "table_action_role_matrix_entries": {"references": ["local.tool_dynamodb_grants", "each.key", "each.key"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "for_each_expression": {"references": ["local.tools"]}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_capabilities": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"constant_value": []}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.api_allowed_client_ids_parameter_name"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-capabilities"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.capabilities.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"capabilities\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_gateway_allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.chat_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_chat_target": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"references": ["module.mcp_chat_gateway.role_arn", "module.mcp_chat_gateway"]}, "handler": {"constant_value": "gateway.chat_target.lambda_handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"chat_target\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix", "local.name_prefix"]}, "timeout_seconds": {"constant_value": 660}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_eval_trigger": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.eval_trigger_eval_runs_grants", "module.dynamodb.table_arns[\"eval_runs\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["local.eval_trigger_eval_runs_grants"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.api_allowed_client_ids_parameter_name", "local.eval_sweep_state_machine_arn", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-eval-trigger"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.eval_trigger.handler"}, "memory_size_mb": {"constant_value": 512}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"eval_trigger\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "timeout_seconds": {"constant_value": 30}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_interceptor": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.gateway_service_principal_rep_id"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.allowed_client_ids", "module.cognito", "var.aws_region", "module.cognito.user_pool_id", "module.cognito", "module.cognito.gateway_scope_identifier", "module.cognito", "local.gateway_service_principal_rep_id", "local.name_prefix"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-identity-interceptor"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "gateway.identity_interceptor.lambda_handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"identity_interceptor\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "leading_keys", "leading_keys_enforced": true, "role": "crm-agent-eval-identity-interceptor-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_pre_token_generation": {"expressions": {"attach_gateway_target_grant": {"constant_value": true}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.chat_scope_identifier"]}, "filename": {"references": ["var.lambda_build_dir"]}, "function_name": {"constant_value": "crm-agent-eval-pre-token-generation"}, "gateway_target_role_arn": {"references": ["aws_iam_role.agentcore_gateway.arn", "aws_iam_role.agentcore_gateway"]}, "handler": {"constant_value": "crm.auth.pre_token_generation.lambda_handler"}, "memory_size_mb": {"constant_value": 128}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"pre_token_generation\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["var.lambda_build_dir"]}, "table_action_role_matrix_entries": {"constant_value": [{"action": "dynamodb:GetItem", "isolation_mechanism": "not_applicable", "leading_keys_enforced": false, "role": "crm-agent-eval-pre-token-generation-role", "table": "reps"}]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_control": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_control_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_control_granted_tables"]}, "dynamodb_allow_statements_per_policy": {"constant_value": 20}, "dynamodb_grants": {"references": ["local.sweep_control_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.eval_artifacts.bucket_name", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-control"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_control_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_control\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 120}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_sweep_task": {"expressions": {"denied_own_table_actions": {"references": ["local.sweep_task_granted_tables", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb", "local.sweep_task_granted_tables"]}, "dynamodb_grants": {"references": ["local.sweep_task_dynamodb_grants", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.gsi_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "dynamodb_policy_managed": {"constant_value": true}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "module.agentcore.agent_runtime_arn", "module.agentcore", "local.relay_runtime_qualifier"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"constant_value": "crm-agent-eval-sweep-task"}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "eval.sfn_handlers.sweep_task_handler"}, "memory_size_mb": {"constant_value": 1024}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"sweep_task\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "tags": {"references": ["var.data_classification"]}, "timeout_seconds": {"constant_value": 300}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "lambda_action_user_settings": {"expressions": {"config_parameter_arns": {"references": ["local.api_allowed_client_ids_parameter_arn"]}, "config_parameter_kms_key_arn": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "denied_own_table_actions": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "local.dynamodb_asserted_actions", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "denied_table_arns": {"references": ["module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_grants": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "dynamodb_kms_grant_enabled": {"constant_value": true}, "dynamodb_kms_key_arn": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "eni_function_code_deny_policy_arn": {"references": ["module.eni_function_code_deny.policy_arn", "module.eni_function_code_deny"]}, "environment_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "environment_variables": {"references": ["local.name_prefix", "local.api_allowed_client_ids_parameter_name"]}, "filename": {"references": ["local.eval_lambda_zip"]}, "function_name": {"references": ["local.name_prefix"]}, "gateway_target_role_arn": {"constant_value": null}, "handler": {"constant_value": "crm.handlers.user_settings.handler"}, "memory_size_mb": {"constant_value": 256}, "reserved_concurrent_executions": {"references": ["local.reserved_concurrency[\"user_settings\"]", "local.reserved_concurrency"]}, "runtime": {"constant_value": "python3.14"}, "source_code_hash": {"references": ["local.eval_lambda_zip"]}, "table_action_role_matrix_entries": {"references": ["local.name_prefix"]}, "timeout_seconds": {"constant_value": 10}, "vpc_security_group_ids": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}, "vpc_subnet_ids": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}, "module": {"outputs": {"function_arn": {"description": "The deployed Lambda function ARN.", "expression": {"references": ["aws_lambda_function.this.arn", "aws_lambda_function.this"]}}, "function_name": {"description": "The deployed Lambda function name.", "expression": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}}, "invoke_arn": {"description": "The function's invoke ARN, for wiring an API Gateway integration or a Gateway target.", "expression": {"references": ["aws_lambda_function.this.invoke_arn", "aws_lambda_function.this"]}}, "log_group_name": {"description": "This instantiation's CloudWatch Logs group name.", "expression": {"references": ["aws_cloudwatch_log_group.this.name", "aws_cloudwatch_log_group.this"]}}, "role_arn": {"description": "This instantiation's dedicated execution role ARN.", "expression": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}}, "role_name": {"description": "This instantiation dedicated execution role name.", "expression": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "table_action_role_matrix_rows": {"description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix,\nwith `role` filled in from the actual generated role\nname. The root composition collects every instantiation's rows (via\n`flatten([for m in module.lambda_action : m.table_action_role_matrix_rows])`)\ninto one machine-readable file for the consolidated Layer 3 gate to assert\nagainst.\n", "expression": {"references": ["local.matrix_rows"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.this", "expressions": {"kms_key_id": {"references": ["var.environment_kms_key_arn"]}, "name": {"references": ["var.function_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_policy.dynamodb", "expressions": {"description": {"references": ["each.value.chunk", "each.value", "each.value.effect", "each.value", "var.function_name", "each.value.chunk", "each.value", "var.function_name"]}, "name": {"references": ["var.function_name", "each.key"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb", "local.dynamodb_managed_statements", "each.key"]}, "tags": {"references": ["var.tags"]}}, "for_each_expression": {"references": ["local.dynamodb_managed_policies"]}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy"}, {"address": "aws_iam_role.this", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.function_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.config_parameter_kms[0].json", "data.aws_iam_policy_document.config_parameter_kms[0]", "data.aws_iam_policy_document.config_parameter_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb", "count_expression": {"references": ["var.dynamodb_policy_managed", "var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb[0].json", "data.aws_iam_policy_document.dynamodb[0]", "data.aws_iam_policy_document.dynamodb"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.dynamodb_kms[0].json", "data.aws_iam_policy_document.dynamodb_kms[0]", "data.aws_iam_policy_document.dynamodb_kms"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.logs", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.logs.json", "data.aws_iam_policy_document.logs"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.vpc_access", "expressions": {"name": {"references": ["var.function_name"]}, "policy": {"references": ["data.aws_iam_policy_document.vpc_access.json", "data.aws_iam_policy_document.vpc_access"]}, "role": {"references": ["aws_iam_role.this.id", "aws_iam_role.this"]}}, "mode": "managed", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy_attachment.dynamodb_allow", "count_expression": {"references": ["var.dynamodb_policy_managed", "local.dynamodb_allow_chunk_count"]}, "depends_on": ["aws_iam_role_policy_attachment.dynamodb_deny"], "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb", "local.dynamodb_allow_chunk_keys", "count.index"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_allow", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.dynamodb_deny", "count_expression": {"references": ["local.dynamodb_managed_policies"]}, "expressions": {"policy_arn": {"references": ["aws_iam_policy.dynamodb[\"deny\"].arn", "aws_iam_policy.dynamodb[\"deny\"]", "aws_iam_policy.dynamodb"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "dynamodb_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_iam_role_policy_attachment.eni_function_code_deny", "expressions": {"policy_arn": {"references": ["var.eni_function_code_deny_policy_arn"]}, "role": {"references": ["aws_iam_role.this.name", "aws_iam_role.this"]}}, "mode": "managed", "name": "eni_function_code_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy_attachment"}, {"address": "aws_lambda_function.this", "depends_on": ["aws_iam_role_policy.logs", "aws_iam_role_policy.vpc_access", "aws_cloudwatch_log_group.this"], "expressions": {"filename": {"references": ["var.filename"]}, "function_name": {"references": ["var.function_name"]}, "handler": {"references": ["var.handler"]}, "kms_key_arn": {"references": ["var.environment_kms_key_arn"]}, "memory_size": {"references": ["var.memory_size_mb"]}, "reserved_concurrent_executions": {"references": ["var.reserved_concurrent_executions"]}, "role": {"references": ["aws_iam_role.this.arn", "aws_iam_role.this"]}, "runtime": {"references": ["var.runtime"]}, "source_code_hash": {"references": ["var.source_code_hash"]}, "tags": {"references": ["var.tags"]}, "timeout": {"references": ["var.timeout_seconds"]}, "tracing_config": [{"mode": {"constant_value": "Active"}}], "vpc_config": [{"security_group_ids": {"references": ["var.vpc_security_group_ids"]}, "subnet_ids": {"references": ["var.vpc_subnet_ids"]}}]}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_function"}, {"address": "aws_lambda_permission.gateway_target_role", "count_expression": {"references": ["var.attach_gateway_target_grant"]}, "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["aws_lambda_function.this.function_name", "aws_lambda_function.this"]}, "principal": {"references": ["var.gateway_target_role_arn"]}, "statement_id": {"constant_value": "AllowGatewayTargetRoleInvoke"}}, "mode": "managed", "name": "gateway_target_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["lambda.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.config_parameter_kms", "count_expression": {"references": ["var.config_parameter_arns"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.config_parameter_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.config_parameter_arns"]}, "variable": {"constant_value": "kms:EncryptionContext:PARAMETER_ARN"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DecryptConfigParameters"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"constant_value": ["ssm.*.amazonaws.com"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Deny"}, "not_resources": {"references": ["var.config_parameter_kms_key_arn"]}, "sid": {"constant_value": "DenyConfigParameterDecryptUnderOtherKeys"}}]}, "mode": "data", "name": "config_parameter_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb", "count_expression": {"references": ["var.dynamodb_grants", "var.denied_table_arns", "var.denied_own_table_actions"]}, "mode": "data", "name": "dynamodb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.dynamodb_kms", "count_expression": {"references": ["var.dynamodb_kms_grant_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.dynamodb_kms_key_arn"]}, "sid": {"constant_value": "DecryptDynamoDbTableKey"}}]}, "mode": "data", "name": "dynamodb_kms", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.this.arn", "aws_cloudwatch_log_group.this"]}, "sid": {"constant_value": "WriteOwnLogGroup"}}]}, "mode": "data", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.vpc_access", "expressions": {"statement": [{"actions": {"constant_value": ["ec2:CreateNetworkInterface", "ec2:DescribeNetworkInterfaces", "ec2:DescribeSubnets", "ec2:DeleteNetworkInterface", "ec2:AssignPrivateIpAddresses", "ec2:UnassignPrivateIpAddresses"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "ManageOwnHyperplaneEnis"}}, {"actions": {"constant_value": ["xray:PutTraceSegments", "xray:PutTelemetryRecords"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "WriteXRayTraceSegments"}}]}, "mode": "data", "name": "vpc_access", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"attach_gateway_target_grant": {"default": false, "description": "Whether to declare the Gateway-role invoke permission, as a plan-time-known flag. Must agree with\n`gateway_target_role_arn` being non-`null`; a precondition on the permission asserts that.\n"}, "config_parameter_arns": {"default": [], "description": "SSM parameter ARNs the function reads at runtime. Each is granted `ssm:GetParameter` in the `-logs` policy; no wildcard."}, "config_parameter_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the SecureString `config_parameter_arns`. The\n`-config-kms` policy allows `kms:Decrypt` on it through SSM under each parameter's\n`PARAMETER_ARN` encryption context, and denies `kms:Decrypt` through SSM on every other key.\nRequired when `config_parameter_arns` is non-empty.\n"}, "cursor_kms_grant_enabled": {"default": false, "description": "Whether the `-dynamodb-kms` policy also grants use of `cursor_kms_key_arn`, as a plan-time-known flag. Requires `dynamodb_kms_grant_enabled`."}, "cursor_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key that seals pagination cursors. The role's\n`-dynamodb-kms` policy grants `kms:Encrypt` and `kms:Decrypt` on it only with the\nencryption context `purpose = crm-cursor`. Required when `cursor_kms_grant_enabled` is true.\n"}, "denied_own_table_actions": {"default": [], "description": "Per-action explicit denies on granted tables. Each entry names one granted table and the actions\nthis function is explicitly denied on it. Entries with an empty `actions` list are ignored.\n"}, "denied_table_arns": {"default": [], "description": "ARNs of every table this function is not granted access to via `dynamodb_grants`. The module\nattaches one explicit `Deny` on the full `dynamodb:*` action surface for these resources. An empty\nlist is valid for a function with no DynamoDB grants; no dynamodb policy document is attached then.\n"}, "dynamodb_allow_statements_per_policy": {"default": null, "description": "With `dynamodb_policy_managed`, the most Allow statements one managed policy holds; the Allows\nare split in lexical order of the grant index (0, 1, 10, 11, 2, \u2026) into\n`-dynamodb-allow`, `-allow-2`, ... `null` keeps them in one policy.\n"}, "dynamodb_grants": {"description": "Least-privilege per-table DynamoDB IAM grants for this function's execution role. Each entry names\none table (or one table's index) and the exact actions permitted on it. The validation blocks below\nreject `dynamodb:*` actions and `Resource = \"*\"`.\n\n`leading_key_condition` is optional and applies only where the table's partition key encodes the\ncaller's own identity (for example `reps`, keyed by `rep_id`). The four synthetic-id entity tables\n(`accounts`, `contacts`, `opportunities`, `activities`) are keyed by the record's own id, so they\ncarry no `LeadingKeys` condition; rep-scoped isolation for them is enforced in `crm.authz`. See\n`table_action_role_matrix.json` for the disposition per table.\n"}, "dynamodb_kms_grant_enabled": {"default": false, "description": "Whether to attach the `dynamodb_kms_key_arn` grant policy; it drives the policy's `count` with a\nplan-time-known value. Set true exactly when `dynamodb_grants` is non-empty and the tables use a\ncustomer-managed key; `dynamodb_kms_key_arn` must then be non-null.\n"}, "dynamodb_kms_key_arn": {"default": null, "description": "ARN of the customer-managed KMS key encrypting the DynamoDB tables named in `dynamodb_grants`\n(`module.dynamodb.kms_key_arn`), for the role's `kms:Decrypt`/`kms:GenerateDataKey` grant. Required\nwhenever `dynamodb_grants` is non-empty.\n"}, "dynamodb_policy_managed": {"default": false, "description": "Attach the DynamoDB document as customer-managed policies instead of the inline\n`-dynamodb` policy: `-dynamodb-allow` holds its Allow statements and\n`-dynamodb-deny` its Deny statements. For a role whose inline-policy aggregate nears\nIAM's 10,240-char cap; each managed policy has its own 6,144-char cap and spends one of the role's\nmanaged-policy attachments.\n"}, "eni_function_code_deny_policy_arn": {"description": "ARN of the managed policy denying the Hyperplane ENI actions to function code (`modules/eni_function_code_deny`). Attached to this function's role."}, "environment_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the function environment variables. When null, Lambda uses its AWS-managed default key."}, "environment_variables": {"default": {}, "description": "Plaintext environment variables for the function. Anything sensitive must instead be a Secrets Manager / SSM Parameter Store reference resolved at runtime, never an inline secret value."}, "filename": {"description": "Path to the zipped deployment package for this function."}, "function_name": {"description": "Unique Lambda function name. Also names this instantiation's dedicated IAM role, log group, and CloudWatch alarms."}, "gateway_target_role_arn": {"default": null, "description": "The AgentCore Gateway target execution role ARN permitted to invoke this function via its resource\npolicy, the only non-API-Gateway principal admitted for a CRM tool. `null` declares no such\npermission, for a function that is not a Gateway target.\n"}, "handler": {"description": "Lambda handler entry point, e.g. `crm.handlers.get_opportunity.handler`."}, "memory_size_mb": {"default": 256, "description": "Lambda memory allocation in MB."}, "reserved_concurrent_executions": {"description": "Reserved concurrency for this function. Must be greater than zero; 0 makes the function permanently\nuninvokable, and the validation below rejects it.\n\nCallers keep the sum of every instantiation's reserved concurrency, across the whole deployment,\nbelow the account's concurrency pool (1,000 by default) minus the headroom the root composition\nreserves for unreserved invocations. The root composition and the Layer 3 gate check that sum.\n"}, "runtime": {"default": "python3.14", "description": "Lambda runtime identifier."}, "source_code_hash": {"description": "Base64-encoded SHA256 of the deployment package, forcing redeploy on code change."}, "table_action_role_matrix_entries": {"default": [], "description": "This instantiation's rows in the project-wide table \u00d7 action \u00d7 role matrix. Each entry records, for\none (table, action) pair this function is granted, whether `dynamodb:LeadingKeys` enforces rep\nisolation or application code does. Not read at plan time by this module; the Layer 3 gate asserts\nagainst it.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-function override or addition."}, "timeout_seconds": {"default": 30, "description": "Lambda invocation timeout in seconds."}, "vpc_security_group_ids": {"description": "Security groups for this function's ENIs (`module.vpc.lambda_security_group_ids`). The group has no\ningress.\n"}, "vpc_subnet_ids": {"description": "Private subnet ids this function's Hyperplane ENIs are placed in (`module.vpc.lambda_subnet_ids`).\nRequired, with no default.\n"}}}, "source": "./modules/lambda_action"}, "mcp_chat_gateway": {"expressions": {"account_id": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "aws_region": {"references": ["var.aws_region"]}, "chat_target_lambda_arn": {"references": ["module.lambda_action_chat_target.function_arn", "module.lambda_action_chat_target"]}, "cognito_allowed_client_ids": {"references": ["module.cognito.chat_gateway_allowed_client_ids", "module.cognito"]}, "cognito_allowed_scopes": {"references": ["module.cognito.chat_scope_identifier", "module.cognito"]}, "cognito_discovery_url": {"references": ["var.aws_region", "module.cognito.user_pool_id", "module.cognito"]}, "gateway_name": {"references": ["local.name_prefix"]}, "identity_interceptor_lambda_arn": {"references": ["module.lambda_action_chat_interceptor.function_arn", "module.lambda_action_chat_interceptor"]}, "identity_interceptor_lambda_function_name": {"references": ["module.lambda_action_chat_interceptor.function_name", "module.lambda_action_chat_interceptor"]}, "role_name": {"references": ["local.name_prefix"]}, "tags": {"references": ["var.data_classification"]}}, "module": {"outputs": {"gateway_arn": {"description": "Gateway #2 ARN; the interceptor permission's `source_arn`.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}}, "gateway_id": {"description": "Gateway #2 id.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}}, "gateway_url": {"description": "MCP endpoint URL of Gateway #2.", "expression": {"references": ["aws_bedrockagentcore_gateway.this.gateway_url", "aws_bedrockagentcore_gateway.this"]}}, "role_arn": {"description": "Gateway #2 execution role ARN; the only Gateway principal admitted by the chat target's resource policy.", "expression": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}}, "role_name": {"description": "Gateway #2 execution role name.", "expression": {"references": ["aws_iam_role.gateway.name", "aws_iam_role.gateway"]}}}, "resources": [{"address": "aws_bedrockagentcore_gateway.this", "depends_on": ["aws_iam_role_policy.gateway"], "expressions": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": {"constant_value": null}, "allowed_clients": {"references": ["var.cognito_allowed_client_ids"]}, "allowed_scopes": {"references": ["var.cognito_allowed_scopes"]}, "discovery_url": {"references": ["var.cognito_discovery_url"]}}]}], "authorizer_type": {"constant_value": "CUSTOM_JWT"}, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": {"constant_value": true}}], "interception_points": {"constant_value": ["REQUEST"]}, "interceptor": [{"lambda": [{"arn": {"references": ["var.identity_interceptor_lambda_arn"]}}]}]}], "name": {"references": ["var.gateway_name"]}, "protocol_configuration": [{"mcp": [{"supported_versions": {"constant_value": ["2025-03-26", "2025-06-18", "2025-11-25"]}}]}], "protocol_type": {"constant_value": "MCP"}, "region": {"references": ["var.aws_region"]}, "role_arn": {"references": ["aws_iam_role.gateway.arn", "aws_iam_role.gateway"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway"}, {"address": "aws_bedrockagentcore_gateway_target.chat", "expressions": {"credential_provider_configuration": [{"gateway_iam_role": [{}]}], "description": {"constant_value": "Gateway target for chat_with_supervisor, backed by the chat_target Lambda."}, "gateway_identifier": {"references": ["aws_bedrockagentcore_gateway.this.gateway_id", "aws_bedrockagentcore_gateway.this"]}, "name": {"constant_value": "chat-with-supervisor"}, "target_configuration": [{"mcp": [{"lambda": [{"lambda_arn": {"references": ["var.chat_target_lambda_arn"]}, "tool_schema": [{"inline_payload": [{"description": {"constant_value": "Send one message to the CRM supervisor agent and receive its answer. Pass the returned conversation_id on later calls to continue the same conversation."}, "input_schema": [{"property": [{"description": {"constant_value": "The message to send, 1 to 8000 characters."}, "name": {"constant_value": "message"}, "required": {"constant_value": true}, "type": {"constant_value": "string"}}, {"description": {"constant_value": "A conversation_id returned by an earlier call; omit to start a new conversation."}, "name": {"constant_value": "conversation_id"}, "required": {"constant_value": false}, "type": {"constant_value": "string"}}], "type": {"constant_value": "object"}}], "name": {"constant_value": "chat_with_supervisor"}}]}]}]}]}]}, "mode": "managed", "name": "chat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_gateway_target"}, {"address": "aws_iam_role.gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.assume_role.json", "data.aws_iam_policy_document.assume_role"]}, "name": {"references": ["var.role_name"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.gateway", "expressions": {"name": {"references": ["var.role_name"]}, "policy": {"references": ["data.aws_iam_policy_document.gateway_permissions.json", "data.aws_iam_policy_document.gateway_permissions"]}, "role": {"references": ["aws_iam_role.gateway.id", "aws_iam_role.gateway"]}}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_lambda_permission.gateway_invoke_interceptor", "expressions": {"action": {"constant_value": "lambda:InvokeFunction"}, "function_name": {"references": ["var.identity_interceptor_lambda_function_name"]}, "principal": {"constant_value": "bedrock-agentcore.amazonaws.com"}, "source_account": {"references": ["var.account_id"]}, "source_arn": {"references": ["aws_bedrockagentcore_gateway.this.gateway_arn", "aws_bedrockagentcore_gateway.this"]}, "statement_id": {"constant_value": "AllowChatGatewayInvokeIdentityInterceptor"}}, "mode": "managed", "name": "gateway_invoke_interceptor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_lambda_permission"}, {"address": "data.aws_iam_policy_document.assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.account_id"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["var.aws_region", "var.account_id"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.chat_target_lambda_arn"]}, "sid": {"constant_value": "InvokeChatTarget"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.identity_interceptor_lambda_arn"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"account_id": {"description": "Account id for the trust policy's `aws:SourceAccount` and `aws:SourceArn` conditions and the interceptor permission's `source_account`."}, "aws_region": {"description": "Region of the gateway; also the region segment of the trust policy's `aws:SourceArn` pattern."}, "chat_target_lambda_arn": {"description": "ARN of the `chat_with_supervisor` target Lambda; the only target this gateway's role may invoke."}, "cognito_allowed_client_ids": {"description": "Cognito app client ids the `CUSTOM_JWT` authorizer accepts, as on Gateway #1."}, "cognito_allowed_scopes": {"description": "Scopes the `CUSTOM_JWT` authorizer accepts: this gateway's own chat scope, never Gateway #1's."}, "cognito_discovery_url": {"description": "OIDC discovery URL of the Cognito user pool, as on Gateway #1."}, "gateway_name": {"description": "Name of the AgentCore Gateway."}, "identity_interceptor_lambda_arn": {"description": "ARN of the shared REQUEST interceptor Lambda."}, "identity_interceptor_lambda_function_name": {"description": "Function name of the shared REQUEST interceptor Lambda, for this gateway's invoke permission."}, "role_name": {"description": "Name of this gateway's own execution role."}, "tags": {"default": {}, "description": "Tags for the gateway and its role. The provider's default_tags carries the mandatory set."}}}, "source": "./modules/mcp_chat_gateway"}, "observability": {"expressions": {"administrator_principal_arns": {"references": ["var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "caller_principal_arn": {"references": ["data.aws_iam_session_context.current.issuer_arn", "data.aws_iam_session_context.current"]}, "data_classification": {"references": ["var.data_classification"]}, "log_retention_days": {"constant_value": 365}, "logs_key_user_principal_arns": {"references": ["local.logs_key_user_role_arns", "var.crm_operator_principal_arns"]}, "name_prefix": {"references": ["local.name_prefix"]}, "operator_principal_arns": {"references": ["var.crm_operator_principal_arns"]}}, "module": {"outputs": {"cloudtrail_access_logs_bucket_name": {"description": "Name of the S3 bucket receiving the CloudTrail delivery bucket's own S3 server access logs (`aws_s3_bucket_logging.cloudtrail`'s target). Distinct from `cloudtrail_s3_bucket_name`, which is the source of those logs.", "expression": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}}, "cloudtrail_arn": {"description": "ARN of the CloudTrail trail for API activity.", "expression": {"references": ["aws_cloudtrail.this.arn", "aws_cloudtrail.this"]}}, "cloudtrail_kms_key_arn": {"description": "ARN of the customer-managed KMS key encrypting the CloudTrail S3 destination bucket.", "expression": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}}, "cloudtrail_s3_bucket_name": {"description": "Name of the S3 bucket CloudTrail delivers log files to: the log source whose access logs land in `cloudtrail_access_logs_bucket_name`.", "expression": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}}, "cloudwatch_logs_kms_key_arn": {"description": "ARN of the customer-managed KMS key for CloudWatch Logs log-group encryption. Sibling modules' `aws_cloudwatch_log_group` resources pass this as `kms_key_id`.", "expression": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}}, "cloudwatch_logs_kms_key_id": {"description": "Key ID of the customer-managed KMS key for CloudWatch Logs log-group encryption.", "expression": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "eval_metric_namespace": {"description": "CloudWatch custom metric namespace reserved for eval-run metrics; passthrough of `var.eval_metric_namespace`.", "expression": {"references": ["var.eval_metric_namespace"]}}}, "resources": [{"address": "aws_cloudtrail.this", "depends_on": ["aws_s3_bucket_policy.cloudtrail"], "expressions": {"cloud_watch_logs_group_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}, "cloud_watch_logs_role_arn": {"references": ["var.enable_cloudtrail_cloudwatch_logs", "aws_iam_role.cloudtrail_cloudwatch_logs[0].arn", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}, "enable_log_file_validation": {"constant_value": true}, "event_selector": [{"include_management_events": {"constant_value": true}, "read_write_type": {"constant_value": "All"}}], "include_global_service_events": {"constant_value": true}, "is_multi_region_trail": {"constant_value": true}, "kms_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "name": {"references": ["local.cloudtrail_name"]}, "s3_bucket_name": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_cloudtrail"}, {"address": "aws_cloudwatch_log_group.cloudtrail", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"kms_key_id": {"references": ["aws_kms_key.logs.arn", "aws_kms_key.logs"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.log_retention_days"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.cloudtrail_cloudwatch_logs", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0].json", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery[0]", "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery"]}, "role": {"references": ["aws_iam_role.cloudtrail_cloudwatch_logs[0].id", "aws_iam_role.cloudtrail_cloudwatch_logs[0]", "aws_iam_role.cloudtrail_cloudwatch_logs"]}}, "mode": "managed", "name": "cloudtrail_cloudwatch_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.cloudtrail", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.cloudtrail.key_id", "aws_kms_key.cloudtrail"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.logs", "expressions": {"name": {"references": ["var.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.logs.key_id", "aws_kms_key.logs"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.cloudtrail", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudTrail S3 log destination encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_cmk.json", "data.aws_iam_policy_document.cloudtrail_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.logs", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "deletion_window_in_days": {"constant_value": 30}, "description": {"constant_value": "CMK for CloudWatch Logs log group encryption at rest"}, "enable_key_rotation": {"constant_value": true}, "policy": {"references": ["data.aws_iam_policy_document.cloudwatch_logs_cmk.json", "data.aws_iam_policy_document.cloudwatch_logs_cmk"]}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_s3_bucket.cloudtrail", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["var.name_prefix", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "force_destroy": {"constant_value": true}, "tags": {"references": ["var.tags", "var.data_classification"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-trail-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_lifecycle_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"abort_incomplete_multipart_upload": [{"days_after_initiation": {"constant_value": 7}}], "expiration": [{"days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "filter": [{}], "id": {"constant_value": "expire-access-logs"}, "noncurrent_version_expiration": [{"noncurrent_days": {"references": ["var.cloudtrail_s3_log_retention_days"]}}], "status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 1, "type": "aws_s3_bucket_lifecycle_configuration"}, {"address": "aws_s3_bucket_logging.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "target_bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "target_prefix": {"constant_value": "s3-access-logs/cloudtrail/"}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_logging"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_ownership_controls.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"object_ownership": {"constant_value": "BucketOwnerEnforced"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_ownership_controls"}, {"address": "aws_s3_bucket_policy.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_bucket.json", "data.aws_iam_policy_document.cloudtrail_bucket"]}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_policy.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "policy": {"references": ["data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny.json", "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny"]}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_policy"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_public_access_block.cloudtrail_access_logs", "expressions": {"block_public_acls": {"constant_value": true}, "block_public_policy": {"constant_value": true}, "bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "ignore_public_acls": {"constant_value": true}, "restrict_public_buckets": {"constant_value": true}}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_public_access_block"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "rule": [{"apply_server_side_encryption_by_default": [{"kms_master_key_id": {"references": ["aws_kms_key.cloudtrail.arn", "aws_kms_key.cloudtrail"]}, "sse_algorithm": {"constant_value": "aws:kms"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_server_side_encryption_configuration.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "rule": [{"apply_server_side_encryption_by_default": [{"sse_algorithm": {"constant_value": "AES256"}}], "bucket_key_enabled": {"constant_value": true}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_server_side_encryption_configuration"}, {"address": "aws_s3_bucket_versioning.cloudtrail", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail.id", "aws_s3_bucket.cloudtrail"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "aws_s3_bucket_versioning.cloudtrail_access_logs", "expressions": {"bucket": {"references": ["aws_s3_bucket.cloudtrail_access_logs.id", "aws_s3_bucket.cloudtrail_access_logs"]}, "versioning_configuration": [{"status": {"constant_value": "Enabled"}}]}, "mode": "managed", "name": "cloudtrail_access_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_bucket_versioning"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnLike"}, "values": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["logging.s3.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "AllowS3ServerAccessLogDelivery"}}, {"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs", "aws_s3_bucket.cloudtrail_access_logs.arn", "aws_s3_bucket.cloudtrail_access_logs"]}, "sid": {"constant_value": "DenyInsecureTransport"}}]}, "mode": "data", "name": "cloudtrail_access_logs_tls_deny", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_bucket", "expressions": {"statement": [{"actions": {"constant_value": ["s3:*"]}, "condition": [{"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:SecureTransport"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyInsecureTransport"}}, {"actions": {"constant_value": ["s3:GetBucketAcl"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "AWSCloudTrailAclCheck"}}, {"actions": {"constant_value": ["s3:PutObject"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.cloudtrail_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}, {"test": {"constant_value": "StringEquals"}, "values": {"constant_value": ["bucket-owner-full-control"]}, "variable": {"constant_value": "s3:x-amz-acl"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "AWSCloudTrailWrite"}}, {"actions": {"constant_value": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectAttributes", "s3:GetObjectVersionAttributes", "s3:GetObjectTagging", "s3:GetObjectVersionTagging", "s3:RestoreObject", "s3:ListBucket", "s3:ListBucketVersions", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:DeleteObjectTagging", "s3:AbortMultipartUpload", "s3:PutObjectVersionTagging", "s3:DeleteObjectVersionTagging"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "BoolIfExists"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail", "aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyObjectDataPlaneToNonProjectPrincipals"}}, {"actions": {"constant_value": ["s3:DeleteBucket", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketVersioning", "s3:PutEncryptionConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketLogging", "s3:PutBucketPublicAccessBlock", "s3:PutBucketOwnershipControls", "s3:PutBucketAcl", "s3:PutBucketTagging", "s3:PutReplicationConfiguration", "s3:PutInventoryConfiguration", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketRequestPayment", "s3:PutBucketWebsite", "s3:PutBucketCORS", "s3:PutAccelerateConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutMetricsConfiguration"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["aws_s3_bucket.cloudtrail.arn", "aws_s3_bucket.cloudtrail"]}, "sid": {"constant_value": "DenyBucketAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_bucket", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_assume", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_assume", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cloudwatch_logs_delivery", "count_expression": {"references": ["var.enable_cloudtrail_cloudwatch_logs"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.cloudtrail[0].arn", "aws_cloudwatch_log_group.cloudtrail[0]", "aws_cloudwatch_log_group.cloudtrail"]}}]}, "mode": "data", "name": "cloudtrail_cloudwatch_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudtrail_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:GenerateDataKey*"]}, "condition": [{"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToEncryptLogs"}}, {"actions": {"constant_value": ["kms:DescribeKey"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["cloudtrail.amazonaws.com"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudTrailToDescribeKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:ReEncryptFrom"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:CallerAccount"}}, {"test": {"constant_value": "StringLike"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:cloudtrail:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowPrincipalsInAccountToDecryptLogFiles"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.operator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudtrail_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.cloudwatch_logs_cmk", "expressions": {"statement": [{"actions": {"constant_value": ["kms:*"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "type": {"constant_value": "AWS"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EnableIAMUserPermissions"}}, {"actions": {"constant_value": ["kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:Describe*"]}, "condition": [{"test": {"constant_value": "ArnLike"}, "values": {"references": ["data.aws_region.current.region", "data.aws_region.current", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:logs:arn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["data.aws_region.current.region", "data.aws_region.current"]}, "type": {"constant_value": "Service"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "AllowCloudWatchLogsUseOfTheKey"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", "kms:CreateGrant"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.logs_key_user_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}, {"test": {"constant_value": "Bool"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "aws:PrincipalIsAWSService"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyUseToNonProjectPrincipals"}}, {"actions": {"constant_value": ["kms:PutKeyPolicy", "kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:RevokeGrant", "kms:DisableKeyRotation", "kms:CreateAlias", "kms:UpdateAlias", "kms:DeleteAlias", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["var.administrator_principal_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "DenyKeyAdministrationToNonOperators"}}]}, "mode": "data", "name": "cloudwatch_logs_cmk", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_region.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_region"}], "variables": {"administrator_principal_arns": {"description": "IAM role or user ARNs, or the account root, admitted to administration of both CMKs and of the CloudTrail bucket. Every other principal is denied it."}, "caller_principal_arn": {"description": "Role or user ARN of the principal running this plan. The key and bucket policies refuse to plan unless it is a listed administrator other than the account root, so no apply can lock its own caller out."}, "cloudtrail_s3_log_retention_days": {"default": 365, "description": "Lifecycle expiration, in days, for CloudTrail delivered log objects in the trail S3 destination bucket."}, "data_classification": {"default": "confidential", "description": "Value for the `data-classification` tag on resources in this module."}, "enable_cloudtrail_cloudwatch_logs": {"default": false, "description": "Whether the trail also delivers to a CloudWatch Logs log group (via\n`cloud_watch_logs_group_arn`/`cloud_watch_logs_role_arn`), in addition to its S3 destination.\nDefaults to false. The CMK this module creates already grants `logs..amazonaws.com` the\nactions CloudWatch Logs needs.\n"}, "eval_metric_namespace": {"default": "CrmAgentEval/Eval", "description": "CloudWatch custom metric namespace reserved for eval-run metrics. No code\nunder `src/` publishes a CloudWatch metric; eval metrics are written to the\n`matrix.json`/`.md`/`.csv` report files instead.\n"}, "log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the CloudTrail CloudWatch Logs integration log group this module creates."}, "logs_key_user_principal_arns": {"description": "IAM role or user ARNs admitted to key use on the CloudWatch Logs CMK: every execution role whose Lambda environment the key encrypts, plus the operators. Every other non-service principal is denied key use."}, "name_prefix": {"default": "", "description": "Prefix applied to resource names, e.g. project or environment scoping."}, "operator_principal_arns": {"description": "IAM role or user ARNs of the operators: the only non-service principals admitted to CloudTrail-key use and to the CloudTrail bucket's data plane."}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already covers the mandatory tags; this allows a per-resource override or addition."}}}, "source": "./modules/observability"}, "vpc": {"expressions": {"flow_log_enabled": {"references": ["var.vpc_flow_log_enabled"]}, "flow_log_kms_key_arn": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "gateway_endpoint_service_names": {"constant_value": ["s3", "dynamodb"]}, "interface_endpoint_service_names": {"references": ["local.vpc_interface_endpoint_services"]}, "name_prefix": {"references": ["local.name_prefix"]}, "nat_gateway_enabled": {"references": ["var.vpc_nat_gateway_enabled"]}, "nat_public_subnet_id": {"references": ["var.vpc_nat_public_subnet_id"]}, "private_route_table_ids": {"references": ["var.vpc_private_route_table_ids"]}, "private_subnet_ids": {"references": ["var.vpc_private_subnet_ids"]}, "region": {"references": ["var.aws_region"]}, "runtime_route_table_ids": {"references": ["var.vpc_runtime_route_table_ids"]}, "runtime_subnet_ids": {"references": ["var.vpc_runtime_subnet_ids"]}, "tags": {"references": ["var.data_classification"]}, "vpc_cidr_block": {"references": ["var.vpc_cidr_block"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "module": {"outputs": {"bedrock_agentcore_vpc_endpoint_id": {"description": "The `bedrock-agentcore` interface endpoint's id, for the runtime resource policies' `aws:SourceVpce`\ncondition: the Deny keyed on it denies every caller not arriving through this endpoint. Read from the\nendpoint map by key. Fails at plan time if `bedrock-agentcore` is absent from the interface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"bedrock-agentcore\"].id", "aws_vpc_endpoint.interface[\"bedrock-agentcore\"]", "aws_vpc_endpoint.interface"]}}, "endpoint_security_group_id": {"description": "The interface-endpoint security group's id.", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_network_interface_ids": {"description": "The `execute-api` endpoint's ENI ids, for the private-origin ALB's target group.\n\n`modules/api_origin` indexes this list positionally under `count = length(var.private_subnet_ids)`,\nso it holds exactly one entry per private subnet; the precondition below asserts the length.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].network_interface_ids", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "execute_api_security_group_id": {"description": "The security group on the `execute-api` endpoint's ENIs, and the ALB's single egress destination.\nEvery interface endpoint in this module shares it; its ingress is 443 from the Lambda group, plus\nthe ALB's 443 ingress rule, which the root composition attaches.\n", "expression": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}}, "execute_api_vpc_endpoint_id": {"description": "The `execute-api` interface endpoint's id, for the private REST API's\n`endpoint_configuration.vpc_endpoint_ids` and its resource-policy allowlist. Read from the endpoint\nmap by key. Fails at plan time if `execute-api` is absent from the endpoint list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"execute-api\"].id", "aws_vpc_endpoint.interface[\"execute-api\"]", "aws_vpc_endpoint.interface"]}}, "flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Read by the access-log delivery smoke check as its source-side target.", "expression": {"references": ["var.flow_log_enabled", "aws_cloudwatch_log_group.flow_logs[0].name", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}}, "gateway_endpoint_service_names": {"description": "Fully-qualified service names of the gateway endpoints created.", "expression": {"references": ["aws_vpc_endpoint.gateway"]}}, "interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created, for a Layer 4 check asserting the deployed set.", "expression": {"references": ["aws_vpc_endpoint.interface"]}}, "lambda_security_group_ids": {"description": "The single Lambda security group, for the `security_group_ids` half of every Lambda `vpc_config`. No ingress.", "expression": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}}, "lambda_subnet_ids": {"description": "Private subnet ids, for the `subnet_ids` half of every Lambda `vpc_config`. Returns `var.private_subnet_ids` alone, sorted; a precondition in `nat.tf` asserts `var.nat_public_subnet_id` is absent from it.", "expression": {"references": ["var.private_subnet_ids"]}}, "nat_gateway_public_ip": {"description": "The NAT gateway Elastic IP, or null when NAT is disabled. A Layer 4 check asserts the relay egress leaves by this address.", "expression": {"references": ["var.nat_gateway_enabled", "aws_eip.nat[0].public_ip", "aws_eip.nat[0]", "aws_eip.nat"]}}, "runtime_security_group_id": {"description": "The dedicated AgentCore Runtime security group's id, for the Runtime's VPC-mode\n`network_mode_config.security_groups`. No ingress; egress only to the endpoint group and the gateway\nprefix lists. Distinct from `lambda_security_group_ids`.\n", "expression": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}}, "runtime_subnet_ids": {"description": "The Runtime VPC-mode subnet ids, for the Runtime `network_mode_config.subnets`. Returns `var.runtime_subnet_ids` sorted. Empty when the Runtime is not in VPC mode.", "expression": {"references": ["var.runtime_subnet_ids"]}}, "states_vpc_endpoint_id": {"description": "The `states` interface endpoint's id, for the root's endpoint policy scoping it to the eval sweep.\nRead from the endpoint map by key. Fails at plan time if `states` is absent from the\ninterface list.\n", "expression": {"references": ["aws_vpc_endpoint.interface[\"states\"].id", "aws_vpc_endpoint.interface[\"states\"]", "aws_vpc_endpoint.interface"]}}, "vpc_cidr_block": {"description": "The VPC's IPv4 CIDR.", "expression": {"references": ["var.vpc_cidr_block"]}}, "vpc_id": {"description": "The VPC's id.", "expression": {"references": ["var.vpc_id"]}}}, "resources": [{"address": "aws_cloudwatch_log_group.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"kms_key_id": {"references": ["var.flow_log_kms_key_arn"]}, "name": {"references": ["var.name_prefix"]}, "retention_in_days": {"references": ["var.flow_log_retention_days"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_eip.nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"domain": {"constant_value": "vpc"}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_eip"}, {"address": "aws_flow_log.this", "count_expression": {"references": ["var.flow_log_enabled"]}, "depends_on": ["aws_iam_role_policy.flow_logs"], "expressions": {"iam_role_arn": {"references": ["aws_iam_role.flow_logs[0].arn", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}, "log_destination": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "log_destination_type": {"constant_value": "cloud-watch-logs"}, "max_aggregation_interval": {"constant_value": 60}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "traffic_type": {"constant_value": "ALL"}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 1, "type": "aws_flow_log"}, {"address": "aws_iam_role.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.flow_logs_assume_role[0].json", "data.aws_iam_policy_document.flow_logs_assume_role[0]", "data.aws_iam_policy_document.flow_logs_assume_role"]}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.flow_logs", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"name": {"references": ["var.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.flow_logs_delivery[0].json", "data.aws_iam_policy_document.flow_logs_delivery[0]", "data.aws_iam_policy_document.flow_logs_delivery"]}, "role": {"references": ["aws_iam_role.flow_logs[0].id", "aws_iam_role.flow_logs[0]", "aws_iam_role.flow_logs"]}}, "mode": "managed", "name": "flow_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_nat_gateway.this", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"allocation_id": {"references": ["aws_eip.nat[0].id", "aws_eip.nat[0]", "aws_eip.nat"]}, "subnet_id": {"references": ["var.nat_public_subnet_id"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}}, "mode": "managed", "name": "this", "provider_config_key": "aws", "schema_version": 0, "type": "aws_nat_gateway"}, {"address": "aws_route.private_nat", "expressions": {"destination_cidr_block": {"constant_value": "0.0.0.0/0"}, "nat_gateway_id": {"references": ["aws_nat_gateway.this[0].id", "aws_nat_gateway.this[0]", "aws_nat_gateway.this"]}, "route_table_id": {"references": ["each.value"]}}, "for_each_expression": {"references": ["var.nat_gateway_enabled", "var.private_route_table_ids"]}, "mode": "managed", "name": "private_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_route"}, {"address": "aws_security_group.agent_runtime", "expressions": {"description": {"constant_value": "AgentCore Runtime ENIs: no ingress, egress only to the VPC endpoint group and gateway prefix lists on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "agent_runtime", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.endpoints", "expressions": {"description": {"constant_value": "Interface VPC endpoint ENIs: ingress 443 from the Lambda group only, no egress."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "endpoints", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_security_group.lambda", "expressions": {"description": {"constant_value": "Lambda ENIs: no ingress, egress only to the VPC endpoint group on 443."}, "name": {"references": ["var.name_prefix"]}, "tags": {"references": ["var.tags", "var.name_prefix"]}, "vpc_id": {"references": ["var.vpc_id"]}}, "mode": "managed", "name": "lambda", "provider_config_key": "aws", "schema_version": 1, "type": "aws_security_group"}, {"address": "aws_vpc_endpoint.gateway", "expressions": {"route_table_ids": {"references": ["var.private_route_table_ids", "var.runtime_route_table_ids"]}, "service_name": {"references": ["var.region", "each.key"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Gateway"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_endpoint.interface", "expressions": {"private_dns_enabled": {"references": ["var.private_dns_disabled_services", "each.key"]}, "security_group_ids": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "service_name": {"references": ["var.region", "each.key"]}, "subnet_ids": {"references": ["var.private_subnet_ids"]}, "tags": {"references": ["var.tags", "var.name_prefix", "each.key"]}, "vpc_endpoint_type": {"constant_value": "Interface"}, "vpc_id": {"references": ["var.vpc_id"]}}, "for_each_expression": {"references": ["var.interface_endpoint_service_names"]}, "mode": "managed", "name": "interface", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. Reaches bedrock-runtime, ecr.api, ecr.dkr, lambda and logs cross-AZ via private DNS."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "agent_runtime_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.agent_runtime_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "agent_runtime_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_https_via_nat", "count_expression": {"references": ["var.nat_gateway_enabled"]}, "expressions": {"cidr_ipv4": {"constant_value": "0.0.0.0/0"}, "description": {"constant_value": "HTTPS egress via the NAT gateway for the relay Cognito JWKS fetch."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_https_via_nat", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_endpoints", "expressions": {"description": {"constant_value": "HTTPS to the interface VPC endpoints. The only in-VPC egress any Lambda has."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "lambda_to_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_egress_rule.lambda_to_gateway_endpoints", "expressions": {"description": {"references": ["each.key"]}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "prefix_list_id": {"references": ["aws_vpc_endpoint.gateway", "each.key"]}, "security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "to_port": {"constant_value": 443}}, "for_each_expression": {"references": ["var.gateway_endpoint_service_names"]}, "mode": "managed", "name": "lambda_to_gateway_endpoints", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_egress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_agent_runtime", "expressions": {"description": {"constant_value": "HTTPS from the Runtime ENIs. The second SG source on the endpoint group, alongside the Lambda group and the root module ALB rule."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.agent_runtime.id", "aws_security_group.agent_runtime"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_agent_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_lambda", "expressions": {"description": {"constant_value": "HTTPS from the Lambda ENIs. One of two ingresses on the endpoint group: the root adds the private-origin ALB for health checks."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["aws_security_group.lambda.id", "aws_security_group.lambda"]}, "security_group_id": {"references": ["aws_security_group.endpoints.id", "aws_security_group.endpoints"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_lambda", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "data.aws_iam_policy_document.flow_logs_assume_role", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["vpc-flow-logs.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "flow_logs_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.flow_logs_delivery", "count_expression": {"references": ["var.flow_log_enabled"]}, "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_cloudwatch_log_group.flow_logs[0].arn", "aws_cloudwatch_log_group.flow_logs[0]", "aws_cloudwatch_log_group.flow_logs"]}, "sid": {"constant_value": "DeliverFlowLogsToOwnGroup"}}]}, "mode": "data", "name": "flow_logs_delivery", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}], "variables": {"flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs. A plain `bool` input, so the flow-log `count`\nis known at plan time.\n"}, "flow_log_kms_key_arn": {"default": null, "description": "KMS customer-managed key ARN encrypting the flow-log group."}, "flow_log_retention_days": {"default": 365, "description": "CloudWatch Logs retention, in days, for the flow-log group."}, "gateway_endpoint_service_names": {"default": ["s3", "dynamodb"], "description": "Short service names for the gateway VPC endpoints (route-table entries, not ENIs); only `s3` and `dynamodb` support this form."}, "interface_endpoint_service_names": {"description": "Short service names for the interface (AWS PrivateLink) VPC endpoints this workload needs, e.g.\n`[\"kms\", \"logs\"]`. Each is expanded to `com.amazonaws..`. A Lambda call to an AWS\nservice with no endpoint here presents as a connection timeout, not as an authorization error.\n"}, "name_prefix": {"description": "Prefix for every resource name and `Name` tag this module creates."}, "nat_gateway_enabled": {"description": "Whether to create the egress-only internet path: an EIP and NAT gateway in the adopted IGW-routed\nsubnet, the default route it adds to the adopted private route tables, and a 443-only egress rule on\nthe Lambda group. The NAT gateway admits no inbound connection, and the private subnets are never\nassociated with the public route table (see `nat.tf`).\n\nNo default; plan refuses until a value is set. With `false` the relay cannot fetch the Cognito JWKS\n(the user pool has a domain, so the `cognito-idp` interface endpoint cannot serve it) and every agent\nturn fails authentication. `true` creates a NAT gateway, billed hourly and per GB.\n"}, "nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`nat_gateway_enabled` is true; ignored otherwise. No default.\n\nMust not appear in `private_subnet_ids`; a precondition on `aws_nat_gateway.this` in `nat.tf`\nasserts that at plan time.\n"}, "private_dns_disabled_services": {"default": ["execute-api"], "description": "Interface-endpoint services whose private DNS is off. Defaults to `[\"execute-api\"]`: private DNS on\nan `execute-api` endpoint would resolve `*.execute-api..amazonaws.com` to this endpoint for\nevery workload in the adopted VPC. CloudFront routes to the VPC origin by load balancer ARN and uses\nthe hostname only as the `Host` header.\n"}, "private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table, nor a table serving subnets outside `private_subnet_ids`;\npreconditions refuse both at plan time.\n\nTwo consumers: the NAT default route in `nat.tf`, and the gateway endpoints' `route_table_ids` in\n`endpoints.tf`. Every table named here receives a `0.0.0.0/0` route to this stack's NAT gateway;\n`scripts/teardown.sh` removes exactly that route.\n"}, "private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC to place Lambda ENIs in. No default.\n\nThese are the subnets whose route tables receive the NAT default route. They must be private; the\nmodule cannot detect a public subnet from its id.\n"}, "region": {"description": "Region the endpoint service names are built for."}, "runtime_route_table_ids": {"default": [], "description": "Route table ids of the Runtime subnets, associated with the S3/DynamoDB gateway endpoints so ECR\nimage-layer pulls have an S3 path. Separate from `private_route_table_ids`: these tables get no NAT\ndefault route, so the Runtime has no internet path. Empty when the Runtime is not in VPC mode.\n"}, "runtime_subnet_ids": {"default": [], "description": "Subnet ids for the AgentCore Runtime's VPC-mode ENIs, separate from `private_subnet_ids` (which\nfeeds every interface endpoint's `subnet_ids` and the `execute-api` positional-length contract). The\nRuntime reaches the interface endpoints through private DNS, so it needs no local endpoint ENI.\n\nEmpty when the Runtime is not in VPC mode. When non-empty, the subnets must be in AgentCore-supported\nAZs for the region (`infra/regions.json`) and must not include `nat_public_subnet_id`;\n`preflight_adopted_vpc.sh` asserts the AZs and the precondition below asserts the disjointness.\n"}, "tags": {"default": {}, "description": "Resource tags. The provider's default_tags already carries the mandatory tags; this adds or overrides per-resource."}, "vpc_cidr_block": {"description": "The adopted VPC's IPv4 CIDR, used only for the `vpc_cidr_block` output that Layer 4 checks read."}, "vpc_id": {"description": "Id of the existing VPC to adopt. This module creates no VPC.\n\nNo default; set it through the gitignored tfvars. `terraform.tfvars.example` carries a placeholder.\n"}}}, "source": "./modules/vpc"}}, "outputs": {"agent_relay_function_name": {"description": "The relay Lambda's function name, for the relay smoke check's `get-function-configuration` env-var assertions.", "expression": {"references": ["module.agent_relay.function_name", "module.agent_relay"]}}, "agent_relay_function_url": {"description": "The relay Function URL, scheme included. The relay smoke check asserts an unauthenticated call to this hostname, not through the distribution, is denied.", "expression": {"references": ["module.agent_relay.function_url", "module.agent_relay"]}}, "agent_relay_log_group_name": {"description": "The relay Lambda CloudWatch log group name, taken from `aws_cloudwatch_log_group.this.name`. Read by the relay-IAM smoke check to simulate `logs:CreateLogStream`/`logs:PutLogEvents` against the deployed group.", "expression": {"references": ["module.agent_relay.log_group_name", "module.agent_relay"]}}, "agent_relay_role_arn": {"description": "The relay Lambda execution role ARN. Read by `scripts/smoke/iam_roles.py` to simulate the relay rows against the deployed role.", "expression": {"references": ["module.agent_relay.role_arn", "module.agent_relay"]}}, "agentcore_gateway_mcp_url": {"description": "MCP endpoint of Gateway #1: `agentcore_gateway_url` with the `/mcp` path, which the deployed `gatewayUrl` omits.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_gateway_url": {"description": "AgentCore Gateway invocation URL.", "expression": {"references": ["module.agentcore.gateway_url", "module.agentcore"]}}, "agentcore_runtime_arn": {"description": "Deployed AgentCore Runtime ARN.", "expression": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "agentcore_runtime_log_group_name": {"description": "CloudWatch Logs group name for the AgentCore Runtime's default endpoint stdout.", "expression": {"references": ["module.agentcore.agent_runtime_log_group_name", "module.agentcore"]}}, "agentcore_runtime_role_arn": {"description": "Execution role ARN of the AgentCore Runtime, the positive-control principal for the relay-IAM smoke check deny rows.", "expression": {"references": ["aws_iam_role.agentcore_runtime.arn", "aws_iam_role.agentcore_runtime"]}}, "api_allowlist_kms_key_arn": {"description": "The CMK encrypting the API client-allowlist SecureString parameter. Read by the smoke checks to assert the parameter's key, the key policy and rotation, and to simulate the roles' KMS access.", "expression": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}}, "api_endpoint": {"description": "The private REST API invoke hostname. Not a public endpoint: it is reachable only through the `execute-api` VPC endpoint, and CloudFront uses it only as a `Host` header. Use `api_id` to identify the API.", "expression": {"references": ["module.api.private_origin_domain_name", "module.api"]}}, "api_id": {"description": "The REST API's id, read by `scripts/smoke/api_routes.py` to identify the API.", "expression": {"references": ["module.api.api_id", "module.api"]}}, "api_origin_alb_arn": {"description": "Internal ALB fronting the private REST API. The CloudFront VPC origin references it by this ARN and performs no DNS lookup.", "expression": {"references": ["module.api_origin.alb_arn", "module.api_origin"]}}, "api_origin_alb_security_group_id": {"description": "The ALB security group, the source of `aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb`. A T3 check asserts the endpoint group admits this group.", "expression": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}}, "api_origin_listener_protocol": {"description": "The listener protocol deployed on the ALB. A check asserts the `http-only` listener against the resource.", "expression": {"references": ["module.api_origin.listener_protocol", "module.api_origin"]}}, "api_origin_target_group_arn": {"description": "Target group holding the `execute-api` endpoint ENI IPs. A T3 check reads `describe-target-health` here.", "expression": {"references": ["module.api_origin.target_group_arn", "module.api_origin"]}}, "api_origin_vpc_origin_id": {"description": "Id of the CloudFront VPC origin, which `module.frontend_cdn` consumes as `api_origin_vpc_origin_id` for the `/api/*` origin `vpc_origin_config`. A T3 check asserts the deployed distribution routes `/api/*` through this origin.", "expression": {"references": ["module.api_origin.vpc_origin_id", "module.api_origin"]}}, "api_stage_invoke_url": {"description": "Full invoke URL for the deployed API stage.", "expression": {"references": ["module.api.stage_invoke_url", "module.api"]}}, "cloudfront_distribution_id": {"description": "CloudFront distribution id, used to invalidate cached assets after a frontend publish.", "expression": {"references": ["module.frontend_cdn.distribution_id", "module.frontend_cdn"]}}, "cloudfront_domain_name": {"description": "CloudFront distribution domain name serving the frontend build.", "expression": {"references": ["module.frontend_cdn.distribution_domain_name", "module.frontend_cdn"]}}, "cloudtrail_access_logs_bucket_name": {"description": "Destination bucket for the CloudTrail delivery bucket S3 server access logs. Its log source is `cloudtrail_s3_bucket_name`, a different bucket.", "expression": {"references": ["module.observability.cloudtrail_access_logs_bucket_name", "module.observability"]}}, "cloudtrail_s3_bucket_name": {"description": "The CloudTrail log-file delivery bucket, whose access logs land in `cloudtrail_access_logs_bucket_name`. Read by the delivery smoke check as the source side of its target assertion.", "expression": {"references": ["module.observability.cloudtrail_s3_bucket_name", "module.observability"]}}, "cognito_domain": {"description": "Cognito prefix domain (no custom ACM certificate). Combine with `var.aws_region` as `https://.auth..amazoncognito.com` to reach the `/oauth2/token` endpoint the MCP `client_credentials` flow uses; see `docs/mcp-client-guide.md`.", "expression": {"references": ["module.cognito.domain", "module.cognito"]}}, "cognito_gateway_scope": {"description": "The `gateway/invoke` resource-server scope identifier, re-exported from `module.cognito.gateway_scope_identifier`. Read by `scripts/smoke/gateway_tools.py`.", "expression": {"references": ["module.cognito.gateway_scope_identifier", "module.cognito"]}}, "cognito_mcp_client_id": {"description": "App client id for MCP clients (confidential client).", "expression": {"references": ["module.cognito.mcp_client_id", "module.cognito"]}}, "cognito_mcp_client_secret": {"description": "App client secret for the MCP client, empty after the first secret rotation (`scripts/rotate_mcp_client_secret.py`). Sensitive; never write it to a tracked file. Any copy kept elsewhere, for example in Secrets Manager, is made out of band; nothing in this stack stores one.", "expression": {"references": ["module.cognito.mcp_client_secret", "module.cognito"]}, "sensitive": true}, "cognito_mcp_oauth_client_id": {"description": "App client id for interactive MCP OAuth clients (public client, authorization code, loopback callbacks); accepted by Gateway #2 only.", "expression": {"references": ["module.cognito.mcp_oauth_client_id", "module.cognito"]}}, "cognito_spa_client_id": {"description": "App client id for the SPA (public client).", "expression": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "cognito_token_endpoint": {"description": "Fully-formed Cognito `/oauth2/token` endpoint URL for the MCP app client's `client_credentials` grant.", "expression": {"references": ["module.cognito.domain", "module.cognito", "var.aws_region"]}}, "cognito_user_pool_id": {"description": "Cognito user pool id.", "expression": {"references": ["module.cognito.user_pool_id", "module.cognito"]}}, "crm_operator_principal_arns": {"description": "The operator principals admitted by the DynamoDB table and CMK policies. Read by the Layer 4 `dynamodb_principal_deny` smoke check to assert the deployed policies' allowlists.", "expression": {"references": ["var.crm_operator_principal_arns"]}}, "dynamodb_table_names": {"description": "Map of logical table name to physical DynamoDB table name, for the 11 tables.", "expression": {"references": ["module.dynamodb.table_names", "module.dynamodb"]}}, "eval_artifacts_bucket_arn": {"description": "The eval-artefacts bucket ARN, for a smoke check composing its own policy or simulation against it.", "expression": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts"]}}, "eval_artifacts_bucket_name": {"description": "The eval-artefacts bucket name, which embeds the account id. Read by `sweep_control` (as EVAL_ARTIFACTS_BUCKET) and by the presigned-URL smoke check.", "expression": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}}, "eval_artifacts_prefix": {"description": "The single key prefix artefacts are written under, and the only prefix the `sweep_control` artifacts grant covers. Read by `sweep_control` as EVAL_ARTIFACTS_PREFIX.", "expression": {"references": ["module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}}, "eval_state_machine_arn": {"description": "ARN of the eval_sweep Step Functions state machine, started by eval_trigger.", "expression": {"references": ["aws_sfn_state_machine.eval_sweep.arn", "aws_sfn_state_machine.eval_sweep"]}}, "eval_trigger_function_name": {"description": "The `eval_trigger` Lambda's function name. Read by the smoke checks: `admin_authz` derives the Lambda name prefix from it, `eval_sfn` and `chat_path_iam` read its configuration, and `resource_protection` checks its log group.", "expression": {"references": ["module.lambda_action_eval_trigger.function_name", "module.lambda_action_eval_trigger"]}}, "frontend_cdn_logs_bucket_name": {"description": "Destination bucket for the CloudFront origin bucket and eval-artefacts bucket S3 server access logs, and for CloudFront standard access logs. Log sources: `frontend_origin_bucket_name`, `eval_artifacts_bucket_name`, and the distribution.", "expression": {"references": ["module.frontend_cdn.logs_bucket_name", "module.frontend_cdn"]}}, "frontend_origin_bucket_name": {"description": "Private S3 bucket holding the frontend static build \u2014 the `aws s3 sync` target of the deploy script's publish step.", "expression": {"references": ["module.frontend_cdn.origin_bucket_name", "module.frontend_cdn"]}}, "mcp_chat_gateway_url": {"description": "MCP endpoint URL of Gateway #2, which exposes only `chat_with_supervisor`.", "expression": {"references": ["module.mcp_chat_gateway.gateway_url", "module.mcp_chat_gateway"]}}, "vpc_flow_log_group_name": {"description": "The VPC flow-log group name, or null when flow logs are disabled. Blocked egress appears here as REJECT records.", "expression": {"references": ["module.vpc.flow_log_group_name", "module.vpc"]}}, "vpc_id": {"description": "Id of the adopted VPC the stack deploys into. Read by the Layer 4 VPC smoke check.", "expression": {"references": ["module.vpc.vpc_id", "module.vpc"]}}, "vpc_interface_endpoint_service_names": {"description": "Fully-qualified service names of the interface endpoints created: the AWS services the workload can reach privately. Read by checks that assert a dependency is reachable.", "expression": {"references": ["module.vpc.interface_endpoint_service_names", "module.vpc"]}}, "vpc_lambda_security_group_ids": {"description": "The Lambda ENI security group. Read by Layer 4 to assert it has no ingress rule and no egress destination outside this VPC's endpoints.", "expression": {"references": ["module.vpc.lambda_security_group_ids", "module.vpc"]}}, "vpc_lambda_subnet_ids": {"description": "The private subnet ids every Lambda's `vpc_config` places ENIs in. Read by the Layer 4 VPC smoke check to assert each subnet's route table carries no route to a gateway.", "expression": {"references": ["module.vpc.lambda_subnet_ids", "module.vpc"]}}}, "resources": [{"address": "aws_bedrockagentcore_resource_policy.agent_runtime_endpoint_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_endpoint_relay_only.json", "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only"]}, "resource_arn": {"references": ["local.agent_runtime_endpoint_arn"]}}, "mode": "managed", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_bedrockagentcore_resource_policy.agent_runtime_relay_only", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.agent_runtime_relay_only.json", "data.aws_iam_policy_document.agent_runtime_relay_only"]}, "resource_arn": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}}, "mode": "managed", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_bedrockagentcore_resource_policy"}, {"address": "aws_cloudwatch_log_group.eval_sweep", "expressions": {"kms_key_id": {"references": ["module.observability.cloudwatch_logs_kms_key_arn", "module.observability"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "retention_in_days": {"constant_value": 365}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_cloudwatch_log_group"}, {"address": "aws_iam_role.agentcore_gateway", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-gateway-role"}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.agentcore_runtime", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.agentcore_assume_role.json", "data.aws_iam_policy_document.agentcore_assume_role"]}, "name": {"constant_value": "crm-agent-eval-runtime-role"}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role.eval_sweep", "expressions": {"assume_role_policy": {"references": ["data.aws_iam_policy_document.eval_sweep_assume_role.json", "data.aws_iam_policy_document.eval_sweep_assume_role"]}, "name": {"references": ["local.eval_sweep_state_machine_name"]}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role"}, {"address": "aws_iam_role_policy.agentcore_gateway", "expressions": {"name": {"constant_value": "crm-agent-eval-gateway-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_gateway_permissions.json", "data.aws_iam_policy_document.agentcore_gateway_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_gateway.id", "aws_iam_role.agentcore_gateway"]}}, "mode": "managed", "name": "agentcore_gateway", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-permissions"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_permissions.json", "data.aws_iam_policy_document.agentcore_runtime_permissions"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime_history", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-history"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_history.json", "data.aws_iam_policy_document.agentcore_runtime_history"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime_history", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.agentcore_runtime_logs", "expressions": {"name": {"constant_value": "crm-agent-eval-runtime-logs"}, "policy": {"references": ["data.aws_iam_policy_document.agentcore_runtime_logs.json", "data.aws_iam_policy_document.agentcore_runtime_logs"]}, "role": {"references": ["aws_iam_role.agentcore_runtime.id", "aws_iam_role.agentcore_runtime"]}}, "mode": "managed", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.chat_target_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.chat_target_invoke_runtime.json", "data.aws_iam_policy_document.chat_target_invoke_runtime"]}, "role": {"references": ["module.lambda_action_chat_target.role_name", "module.lambda_action_chat_target"]}}, "mode": "managed", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_sweep", "expressions": {"name": {"references": ["local.eval_sweep_state_machine_name"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_sweep_permissions.json", "data.aws_iam_policy_document.eval_sweep_permissions"]}, "role": {"references": ["aws_iam_role.eval_sweep.name", "aws_iam_role.eval_sweep"]}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_artifacts.json", "data.aws_iam_policy_document.eval_trigger_artifacts"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.eval_trigger_states", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.eval_trigger_states.json", "data.aws_iam_policy_document.eval_trigger_states"]}, "role": {"references": ["module.lambda_action_eval_trigger.role_name", "module.lambda_action_eval_trigger"]}}, "mode": "managed", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_control_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_control_artifacts.json", "data.aws_iam_policy_document.sweep_control_artifacts"]}, "role": {"references": ["module.lambda_action_sweep_control.role_name", "module.lambda_action_sweep_control"]}}, "mode": "managed", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_iam_role_policy.sweep_task_invoke_runtime", "expressions": {"name": {"references": ["local.name_prefix"]}, "policy": {"references": ["data.aws_iam_policy_document.sweep_task_invoke_runtime.json", "data.aws_iam_policy_document.sweep_task_invoke_runtime"]}, "role": {"references": ["module.lambda_action_sweep_task.role_name", "module.lambda_action_sweep_task"]}}, "mode": "managed", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_role_policy"}, {"address": "aws_kms_alias.api_allowlist", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.api_allowlist.key_id", "aws_kms_key.api_allowlist"]}}, "mode": "managed", "name": "api_allowlist", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.cursor", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.cursor.key_id", "aws_kms_key.cursor"]}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_alias.eval_artifacts", "expressions": {"name": {"references": ["local.name_prefix"]}, "target_key_id": {"references": ["aws_kms_key.eval_artifacts.key_id", "aws_kms_key.eval_artifacts"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_alias"}, {"address": "aws_kms_key.api_allowlist", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "api_allowlist", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.cursor", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key.eval_artifacts", "expressions": {"deletion_window_in_days": {"constant_value": 7}, "description": {"references": ["local.name_prefix"]}, "enable_key_rotation": {"constant_value": true}, "tags": {"references": ["var.data_classification"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key"}, {"address": "aws_kms_key_policy.api_allowlist", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.api_allowlist.id", "aws_kms_key.api_allowlist"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "var.crm_operator_principal_arns", "local.api_allowlist_ssm_service", "local.api_allowlist_key_consumer_arns", "local.api_allowlist_ssm_service", "local.api_allowed_client_ids_parameter_arn", "var.crm_operator_principal_arns", "local.api_allowlist_key_consumer_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "api_allowlist", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_kms_key_policy.cursor", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.cursor.id", "aws_kms_key.cursor"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.cursor_key_principal_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "cursor", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_kms_key_policy.eval_artifacts", "expressions": {"bypass_policy_lockout_safety_check": {"constant_value": false}, "key_id": {"references": ["aws_kms_key.eval_artifacts.id", "aws_kms_key.eval_artifacts"]}, "policy": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.eval_artifacts_principal_arns", "var.crm_operator_principal_arns", "var.crm_operator_principal_arns", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}}, "mode": "managed", "name": "eval_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_kms_key_policy"}, {"address": "aws_s3_object.agent_source", "expressions": {"bucket": {"references": ["module.eval_artifacts.bucket_name", "module.eval_artifacts"]}, "key": {"constant_value": "agent-source/agent.zip"}, "kms_key_id": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "source": {"references": ["var.lambda_build_dir"]}, "source_hash": {"references": ["var.lambda_build_dir"]}, "tags": {"constant_value": {"data-classification": "internal"}}}, "mode": "managed", "name": "agent_source", "provider_config_key": "aws", "schema_version": 0, "type": "aws_s3_object"}, {"address": "aws_sfn_state_machine.eval_sweep", "depends_on": ["aws_iam_role_policy.eval_sweep"], "expressions": {"definition": {"references": ["path.module", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "logging_configuration": [{"include_execution_data": {"constant_value": false}, "level": {"constant_value": "ALL"}, "log_destination": {"references": ["aws_cloudwatch_log_group.eval_sweep.arn", "aws_cloudwatch_log_group.eval_sweep"]}}], "name": {"references": ["local.eval_sweep_state_machine_name"]}, "role_arn": {"references": ["aws_iam_role.eval_sweep.arn", "aws_iam_role.eval_sweep"]}, "tags": {"references": ["var.data_classification"]}, "tracing_configuration": [{"enabled": {"constant_value": true}}], "type": {"constant_value": "STANDARD"}}, "mode": "managed", "name": "eval_sweep", "provider_config_key": "aws", "schema_version": 0, "type": "aws_sfn_state_machine"}, {"address": "aws_ssm_parameter.api_allowed_client_ids", "depends_on": ["aws_kms_key_policy.api_allowlist"], "expressions": {"key_id": {"references": ["aws_kms_key.api_allowlist.arn", "aws_kms_key.api_allowlist"]}, "name": {"references": ["local.api_allowed_client_ids_parameter_name"]}, "tags": {"constant_value": {"data-classification": "internal"}}, "tier": {"constant_value": "Standard"}, "type": {"constant_value": "SecureString"}, "value": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "mode": "managed", "name": "api_allowed_client_ids", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ssm_parameter"}, {"address": "aws_ssm_parameter.relay_cognito_audience", "expressions": {"name": {"references": ["local.relay_cognito_audience_parameter_name"]}, "tags": {"constant_value": {"data-classification": "internal"}}, "type": {"constant_value": "String"}, "value": {"references": ["module.cognito.spa_client_id", "module.cognito"]}}, "mode": "managed", "name": "relay_cognito_audience", "provider_config_key": "aws", "schema_version": 0, "type": "aws_ssm_parameter"}, {"address": "aws_vpc_endpoint_policy.states", "expressions": {"policy": {"references": ["data.aws_iam_policy_document.states_endpoint.json", "data.aws_iam_policy_document.states_endpoint"]}, "vpc_endpoint_id": {"references": ["module.vpc.states_vpc_endpoint_id", "module.vpc"]}}, "mode": "managed", "name": "states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_endpoint_policy"}, {"address": "aws_vpc_security_group_ingress_rule.endpoints_from_api_origin_alb", "expressions": {"description": {"constant_value": "HTTPS from the private-origin ALB. The only ingress any endpoint has besides the Lambda group."}, "from_port": {"constant_value": 443}, "ip_protocol": {"constant_value": "tcp"}, "referenced_security_group_id": {"references": ["module.api_origin.alb_security_group_id", "module.api_origin"]}, "security_group_id": {"references": ["module.vpc.execute_api_security_group_id", "module.vpc"]}, "to_port": {"constant_value": 443}}, "mode": "managed", "name": "endpoints_from_api_origin_alb", "provider_config_key": "aws", "schema_version": 0, "type": "aws_vpc_security_group_ingress_rule"}, {"address": "terraform_data.agent_only_tools_guard", "mode": "managed", "name": "agent_only_tools_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.chat_scope_agreement", "mode": "managed", "name": "chat_scope_agreement", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "terraform_data.reserved_concurrency_headroom_guard", "mode": "managed", "name": "reserved_concurrency_headroom_guard", "provider_config_key": "terraform", "schema_version": 0, "type": "terraform_data"}, {"address": "data.aws_caller_identity.current", "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_caller_identity"}, {"address": "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisEndpoint"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_endpoint_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agent_runtime_relay_only", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"references": ["local.runtime_invoker_role_arns"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "OnlyTheInvokerRolesMayInvokeThisRuntime"}}, {"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession", "bedrock-agentcore:GetAgentCard"]}, "condition": [{"test": {"constant_value": "ArnNotEquals"}, "values": {"references": ["local.runtime_invoker_role_arns"]}, "variable": {"constant_value": "aws:PrincipalArn"}}], "effect": {"constant_value": "Deny"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "AWS"}}], "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore"]}, "sid": {"constant_value": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}}]}, "mode": "data", "name": "agent_runtime_relay_only", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["bedrock-agentcore.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "agentcore_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_gateway_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_interceptor.function_arn", "module.lambda_action_interceptor"]}, "sid": {"constant_value": "InvokeInterceptor"}}]}, "mode": "data", "name": "agentcore_gateway_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_history", "expressions": {"statement": [{"actions": {"constant_value": ["dynamodb:GetItem"]}, "condition": [{"test": {"constant_value": "ForAllValues:StringLike"}, "values": {"constant_value": ["history#*"]}, "variable": {"constant_value": "dynamodb:LeadingKeys"}}, {"test": {"constant_value": "Null"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "dynamodb:LeadingKeys"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "sid": {"constant_value": "ConversationHistoryRead"}}, {"actions": {"constant_value": ["dynamodb:PutItem"]}, "condition": [{"test": {"constant_value": "ForAllValues:StringLike"}, "values": {"constant_value": ["history#*"]}, "variable": {"constant_value": "dynamodb:LeadingKeys"}}, {"test": {"constant_value": "Null"}, "values": {"constant_value": ["false"]}, "variable": {"constant_value": "dynamodb:LeadingKeys"}}, {"test": {"constant_value": "ForAllValues:StringEquals"}, "values": {"constant_value": ["expires_at", "kind", "owner_rep_id", "owner_tenant", "rep_id", "turns", "updated_at", "version"]}, "variable": {"constant_value": "dynamodb:Attributes"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "sid": {"constant_value": "ConversationHistoryWrite"}}, {"actions": {"constant_value": ["kms:Decrypt", "kms:GenerateDataKey"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.aws_region"]}, "variable": {"constant_value": "kms:ViaService"}}, {"test": {"constant_value": "StringEquals"}, "values": {"references": ["module.dynamodb.table_names[\"reps\"]", "module.dynamodb.table_names", "module.dynamodb"]}, "variable": {"constant_value": "kms:EncryptionContext:aws:dynamodb:tableName"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.dynamodb.kms_key_arn", "module.dynamodb"]}, "sid": {"constant_value": "ConversationHistoryKms"}}, {"actions": {"constant_value": ["dynamodb:*"]}, "effect": {"constant_value": "Deny"}, "resources": {"references": ["local.runtime_denied_table_arns"]}, "sid": {"constant_value": "DenyDynamoDbOtherTables"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["dynamodb:GetItem", "dynamodb:PutItem"]}, "resources": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb", "module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "sid": {"constant_value": "DenyRepsNonGrantedActions"}}, {"actions": {"constant_value": ["dynamodb:GetItem", "dynamodb:PutItem"]}, "condition": [{"test": {"constant_value": "ForAnyValue:StringNotLike"}, "values": {"constant_value": ["history#*"]}, "variable": {"constant_value": "dynamodb:LeadingKeys"}}], "effect": {"constant_value": "Deny"}, "resources": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "sid": {"constant_value": "DenyRepsOutsideHistoryPrefix"}}, {"actions": {"constant_value": ["dynamodb:GetItem", "dynamodb:PutItem"]}, "condition": [{"test": {"constant_value": "ForAnyValue:StringLike"}, "values": {"constant_value": ["history#canary#*"]}, "variable": {"constant_value": "dynamodb:LeadingKeys"}}], "effect": {"constant_value": "Deny"}, "resources": {"references": ["module.dynamodb.table_arns[\"reps\"]", "module.dynamodb.table_arns", "module.dynamodb"]}, "sid": {"constant_value": "DenyCanaryHistory"}}]}, "mode": "data", "name": "agentcore_runtime_history", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_logs", "expressions": {"statement": [{"actions": {"constant_value": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:DescribeLogStreams"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_log_group_arn", "module.agentcore", "module.agentcore.agent_runtime_log_group_arn", "module.agentcore"]}, "sid": {"constant_value": "CloudWatchLogsAccess"}}]}, "mode": "data", "name": "agentcore_runtime_logs", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.agentcore_runtime_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action", "local.runtime_uninvocable_tools"]}, "sid": {"constant_value": "InvokeActionLambdas"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "sid": {"constant_value": "BedrockInference"}}, {"actions": {"constant_value": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["local.bedrock_inference_profiles", "var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "bedrock:InferenceProfileArn"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.bedrock_foundation_models", "local.bedrock_foundation_models"]}, "sid": {"constant_value": "BedrockInferenceFoundationModels"}}, {"actions": {"constant_value": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["var.aws_region", "data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current", "local.agent_ecr_repository_name"]}, "sid": {"constant_value": "EcrImageAccess"}}, {"actions": {"constant_value": ["ecr:GetAuthorizationToken"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "EcrTokenAccess"}}]}, "mode": "data", "name": "agentcore_runtime_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.chat_target_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeTheRuntimeDefaultEndpoint"}}, {"effect": {"constant_value": "Deny"}, "not_actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "DenyEverythingButInvokeOnThisRuntime"}}]}, "mode": "data", "name": "chat_target_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_assume_role", "expressions": {"statement": [{"actions": {"constant_value": ["sts:AssumeRole"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:SourceAccount"}}, {"test": {"constant_value": "ArnEquals"}, "values": {"references": ["local.eval_sweep_state_machine_arn"]}, "variable": {"constant_value": "aws:SourceArn"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["states.amazonaws.com"]}, "type": {"constant_value": "Service"}}]}]}, "mode": "data", "name": "eval_sweep_assume_role", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_sweep_permissions", "expressions": {"statement": [{"actions": {"constant_value": ["lambda:InvokeFunction"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_control.function_arn", "module.lambda_action_sweep_control", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task", "module.lambda_action_sweep_task.function_arn", "module.lambda_action_sweep_task"]}, "sid": {"constant_value": "InvokeSweepLambdas"}}, {"actions": {"references": ["local.sfn_vended_log_delivery_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnVendedLogDelivery"}}, {"actions": {"references": ["local.sfn_xray_tracing_actions"]}, "effect": {"constant_value": "Allow"}, "resources": {"constant_value": ["*"]}, "sid": {"constant_value": "SfnXRayTracing"}}]}, "mode": "data", "name": "eval_sweep_permissions", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "ReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:Decrypt"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["var.aws_region"]}, "variable": {"constant_value": "kms:ViaService"}}], "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "DecryptArtifactsViaS3"}}]}, "mode": "data", "name": "eval_trigger_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.eval_trigger_states", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "eval_trigger_states", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.states_endpoint", "expressions": {"statement": [{"actions": {"constant_value": ["states:StartExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_state_machine_arn"]}, "sid": {"constant_value": "StartTheEvalSweep"}}, {"actions": {"constant_value": ["states:DescribeExecution"]}, "condition": [{"test": {"constant_value": "StringEquals"}, "values": {"references": ["data.aws_caller_identity.current.account_id", "data.aws_caller_identity.current"]}, "variable": {"constant_value": "aws:PrincipalAccount"}}], "effect": {"constant_value": "Allow"}, "principals": [{"identifiers": {"constant_value": ["*"]}, "type": {"constant_value": "*"}}], "resources": {"references": ["local.eval_sweep_execution_arn_pattern"]}, "sid": {"constant_value": "DescribeEvalSweepExecutions"}}]}, "mode": "data", "name": "states_endpoint", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_control_artifacts", "expressions": {"statement": [{"actions": {"constant_value": ["s3:PutObject", "s3:GetObject"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.eval_artifacts.bucket_arn", "module.eval_artifacts", "module.eval_artifacts.artifact_prefix", "module.eval_artifacts"]}, "sid": {"constant_value": "WriteAndReadArtifactPrefix"}}, {"actions": {"constant_value": ["kms:GenerateDataKey", "kms:Decrypt"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["aws_kms_key.eval_artifacts.arn", "aws_kms_key.eval_artifacts"]}, "sid": {"constant_value": "UseArtifactsBucketCmk"}}]}, "mode": "data", "name": "sweep_control_artifacts", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_policy_document.sweep_task_invoke_runtime", "expressions": {"statement": [{"actions": {"constant_value": ["bedrock-agentcore:InvokeAgentRuntime"]}, "effect": {"constant_value": "Allow"}, "resources": {"references": ["module.agentcore.agent_runtime_arn", "module.agentcore", "local.agent_runtime_endpoint_arn"]}, "sid": {"constant_value": "InvokeAgentRuntimeEvalTurn"}}]}, "mode": "data", "name": "sweep_task_invoke_runtime", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_policy_document"}, {"address": "data.aws_iam_session_context.current", "expressions": {"arn": {"references": ["data.aws_caller_identity.current.arn", "data.aws_caller_identity.current"]}}, "mode": "data", "name": "current", "provider_config_key": "aws", "schema_version": 0, "type": "aws_iam_session_context"}, {"address": "data.aws_network_interface.execute_api", "count_expression": {"references": ["var.vpc_private_subnet_ids"]}, "expressions": {"id": {"references": ["module.vpc.execute_api_network_interface_ids", "module.vpc", "count.index"]}}, "mode": "data", "name": "execute_api", "provider_config_key": "aws", "schema_version": 0, "type": "aws_network_interface"}], "variables": {"api_origin_ingress_security_group_ids": {"description": "Security group ids permitted to reach the internal ALB's listener port (the `/api/*` private origin\npath). Passed to `modules/api_origin`, whose validation refuses anything that is not an `sg-` id.\nNo default; set it in the gitignored `terraform.tfvars`.\n\nThe value is the CloudFront service-managed group `CloudFront-VPCOrigins-Service-SG`, which AWS\ncreates in the adopted VPC when `aws_cloudfront_vpc_origin` is first applied. The first deployment\nof this path is therefore two-phase: apply, read the group id, set this variable, apply again. See\nthe `api_origin` variables and the runbook.\n"}, "aws_profile": {"default": "default", "description": "Named AWS CLI profile to use for all provider operations."}, "aws_region": {"default": "us-east-1", "description": "AWS region to deploy into: a US commercial region listed in `infra/regions.json`."}, "cost_center": {"default": "crm-agent-eval", "description": "Value for the mandatory `cost-center` tag applied to every resource."}, "crm_operator_principal_arns": {"description": "IAM role or user ARNs of the operators who deploy, seed and smoke-test this stack. Admitted to the\nDynamoDB tables' data plane and to table and CMK administration; every principal outside these and\nthe project's Lambda roles is denied. No default; set it in the gitignored\n`terraform.tfvars`. A plan whose caller is not listed fails at a precondition.\n"}, "data_classification": {"default": "confidential", "description": "Default value for the mandatory `data-classification` tag. Individual modules may override this per resource where a more specific classification applies."}, "environment": {"default": "dev", "description": "Value for the mandatory `environment` tag applied to every resource."}, "lambda_build_dir": {"default": "build/lambda", "description": "Directory holding the pre-built archives this composition reads, resolved\nrelative to `infra/`: one Lambda zip per `local.tool_names` entry, plus\n`identity_interceptor.zip`, `pre_token_generation.zip`, `eval_trigger.zip`\n(shared by the eval trigger, capabilities, user-settings and sweep functions),\n`chat_target.zip` (the chat Gateway's target) and `relay.zip` \u2014 and\n`agent-source.zip`, the CodeBuild source for the AgentCore container image. `scripts/package_lambdas.sh` and `scripts/package_relay.sh`\npopulate the default location, `infra/build/lambda`.\n"}, "owner": {"default": "crm-agent-eval-team", "description": "Value for the mandatory `owner` tag applied to every resource."}, "runtime_source_vpce_deny_enabled": {"default": false, "description": "Stage 2: whether the runtime resource policies carry the inbound Deny. When true, both policies deny\n`InvokeAgentRuntime` from every principal not arriving through the bedrock-agentcore VPC endpoint\n(with `aws:ViaAWSService = false` exempting internal service calls).\n\nDefaults to false. Enable it only once the relay's calls are shown to carry `aws:SourceVpce`;\notherwise every chat turn is denied. Set `-var runtime_source_vpce_deny_enabled=true` (or in a\ngitignored `*.auto.tfvars`) as a separate apply after stage 1 is verified.\n"}, "runtime_source_vpce_report_only_enabled": {"default": true, "description": "Stage 1: whether the runtime resource policies carry the report-only `aws:SourceVpce` Allow for any\nprincipal arriving through the bedrock-agentcore VPC endpoint. It grants nothing the relay-role\nAllow does not already cover for the relay; it shows, before the Deny, that traffic through this\nstack's endpoint is admitted by the SourceVpce condition.\n"}, "service": {"default": "crm-agent-eval", "description": "Value for the mandatory `service` tag applied to every resource."}, "vpc_cidr_block": {"default": "10.20.0.0/20", "description": "The adopted VPC's IPv4 CIDR, published as an output for Layer 4 checks. Nothing is sized from it.\nIt must match the adopted VPC.\n"}, "vpc_flow_log_enabled": {"default": true, "description": "Whether to deliver VPC flow logs to CloudWatch Logs."}, "vpc_id": {"description": "Id of the existing VPC this deployment adopts. The stack creates no VPC; it creates only the NAT\ngateway path, the route that path adds to the adopted private route tables, two security groups,\nand the VPC endpoints.\n\nNo default. Set it in the gitignored `terraform.tfvars`; `terraform.tfvars.example` shows the shape\nwith a placeholder.\n"}, "vpc_nat_gateway_enabled": {"description": "Whether to create the egress-only internet path the relay's Cognito JWKS fetch requires.\n\nNo default; `terraform plan` refuses until a value is set. `false` leaves the relay unable to\nauthenticate any request (the user pool has a domain, so the `cognito-idp` interface endpoint cannot\nserve it). `true` creates a NAT gateway, billed hourly and per GB.\n\nSet it on the command line (`-var vpc_nat_gateway_enabled=true`) or in a gitignored `*.auto.tfvars`.\nThe NAT gateway is egress-only: it admits no inbound connection (see `infra/modules/vpc/nat.tf`).\n"}, "vpc_nat_public_subnet_id": {"default": null, "description": "Id of an existing IGW-routed subnet in the adopted VPC for the NAT gateway to land in. Required when\n`vpc_nat_gateway_enabled` is true; the plan fails otherwise. No default.\n\nMust not also appear in `vpc_private_subnet_ids`; the module asserts that at plan time.\n"}, "vpc_private_route_table_ids": {"description": "Route table ids the adopted private subnets use. No default.\n\nMust not be the VPC's main route table; a precondition refuses it at plan time.\n\nEvery table named here receives a `0.0.0.0/0` route to this stack's NAT gateway and the S3/DynamoDB\ngateway-endpoint associations.\n"}, "vpc_private_subnet_ids": {"description": "Ids of the existing private subnets in the adopted VPC that every Lambda's ENIs are placed in. No\ndefault; set it in the gitignored `terraform.tfvars`.\n\nThe AZ set is whatever these subnets are; it is not derived from the region.\n"}, "vpc_runtime_route_table_ids": {"default": [], "description": "Route table ids of the `vpc_runtime_subnet_ids` subnets, associated with the S3/DynamoDB gateway\nendpoints so ECR image-layer pulls have an S3 path. They receive no NAT default route (that stays\non `vpc_private_route_table_ids`), so the Runtime has no internet path. Defaults to empty.\n"}, "vpc_runtime_subnet_ids": {"default": [], "description": "Ids of the private subnets for the AgentCore Runtime's VPC-mode ENIs, separate from\n`vpc_private_subnet_ids` (see the vpc module's `runtime_subnet_ids`).\n\nEvery subnet must be in an AgentCore-supported AZ for the region (`infra/regions.json`) and must\nnot be `vpc_nat_public_subnet_id`; `scripts/preflight_adopted_vpc.sh` and a module precondition\nassert both. The Runtime runs in VPC mode, so an empty list fails the plan.\n"}}}}, "format_version": "1.2", "variables": {"api_origin_ingress_security_group_ids": {"value": ["sg-cloudfrontvpcoriginplaceholder"]}, "aws_profile": {"value": "example-deployer"}, "aws_region": {"value": "us-east-1"}, "cost_center": {"value": "crm-agent-eval"}, "crm_operator_principal_arns": {"value": ["arn:aws:iam::123456789012:role/example-deployer"]}, "data_classification": {"value": "confidential"}, "environment": {"value": "dev"}, "lambda_build_dir": {"value": "build/lambda"}, "owner": {"value": "crm-agent-eval-team"}, "runtime_source_vpce_deny_enabled": {"value": false}, "runtime_source_vpce_report_only_enabled": {"value": true}, "service": {"value": "crm-agent-eval"}, "vpc_cidr_block": {"value": "10.20.0.0/20"}, "vpc_flow_log_enabled": {"value": true}, "vpc_id": {"value": "vpc-adoptedplaceholder"}, "vpc_nat_gateway_enabled": {"value": true}, "vpc_nat_public_subnet_id": {"value": "subnet-natpublicplaceholder"}, "vpc_private_route_table_ids": {"value": ["rtb-privateoneplaceholder", "rtb-privatetwoplaceholder"]}, "vpc_private_subnet_ids": {"value": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}, "vpc_runtime_route_table_ids": {"value": ["rtb-runtimeplaceholder"]}, "vpc_runtime_subnet_ids": {"value": ["subnet-runtimeoneplaceholder", "subnet-runtimetwoplaceholder"]}}} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agent_runtime_endpoint_relay_only", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "OnlyTheInvokerRolesMayInvokeThisEndpoint"}, {"actions": ["bedrock-agentcore:GetAgentCard", "bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession"], "condition": [{"test": "ArnNotEquals", "values": [null, null, null], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null], "sid": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}, {"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [{"test": "StringEquals", "values": [null], "variable": "aws:SourceVpce"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "AllowInvokeViaOurVpcEndpoint"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [true, true, true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agent_runtime_endpoint_relay_only", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agent_runtime_relay_only", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "OnlyTheInvokerRolesMayInvokeThisRuntime"}, {"actions": ["bedrock-agentcore:GetAgentCard", "bedrock-agentcore:InvokeAgentRuntime", "bedrock-agentcore:InvokeAgentRuntimeCommand", "bedrock-agentcore:InvokeAgentRuntimeCommandShell", "bedrock-agentcore:InvokeAgentRuntimeForUser", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream", "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUser", "bedrock-agentcore:StopRuntimeSession"], "condition": [{"test": "ArnNotEquals", "values": [null, null, null], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null], "sid": "DenyRuntimeDataPlaneToAnyOtherPrincipal"}, {"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [{"test": "StringEquals", "values": [null], "variable": "aws:SourceVpce"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": [null, null, null], "type": "AWS"}], "resources": [null], "sid": "AllowInvokeViaOurVpcEndpoint"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false, false, false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}, {"actions": [false, false, false, false, false, false, false, false], "condition": [{"values": [true, true, true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [true, true, true]}], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agent_runtime_relay_only", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agentcore_gateway_permissions", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "InvokeActionLambdas"}, {"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "InvokeInterceptor"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agentcore_gateway_permissions", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} +{"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agentcore_runtime_history", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["history#*"], "variable": "dynamodb:LeadingKeys"}, {"test": "Null", "values": ["false"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "ConversationHistoryRead"}, {"actions": ["dynamodb:PutItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["expires_at", "kind", "owner_rep_id", "owner_tenant", "rep_id", "turns", "updated_at", "version"], "variable": "dynamodb:Attributes"}, {"test": "ForAllValues:StringLike", "values": ["history#*"], "variable": "dynamodb:LeadingKeys"}, {"test": "Null", "values": ["false"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "ConversationHistoryWrite"}, {"actions": ["kms:Decrypt", "kms:GenerateDataKey"], "condition": [{"test": "StringEquals", "values": ["crm-agent-evalreps"], "variable": "kms:EncryptionContext:aws:dynamodb:tableName"}, {"test": "StringEquals", "values": ["dynamodb.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "ConversationHistoryKms"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "DenyDynamoDbOtherTables"}, {"actions": null, "condition": [], "effect": "Deny", "not_actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "DenyRepsNonGrantedActions"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [{"test": "ForAnyValue:StringNotLike", "values": ["history#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DenyRepsOutsideHistoryPrefix"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [{"test": "ForAnyValue:StringLike", "values": ["history#canary#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DenyCanaryHistory"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false, false, false, false, false, false, false, false]}, {"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"condition": [], "not_actions": [false, false], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false, false, false, false, false, false, false, false]}, {"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"condition": [], "not_actions": [false, false], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agentcore_runtime_history", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agentcore_runtime_logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:DescribeLogStreams", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "CloudWatchLogsAccess"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agentcore_runtime_logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.agentcore_runtime_permissions", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "InvokeActionLambdas"}, {"actions": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.anthropic.claude-haiku-5-5", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.anthropic.claude-opus-5-5", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.anthropic.claude-sonnet-5-5", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6-astra", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6-luna", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6.1-sol", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6.1-terra", "arn:aws:bedrock:us-east-1:123456789012:project/default"], "sid": "BedrockInference"}, {"actions": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"], "condition": [{"test": "StringEquals", "values": ["arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.anthropic.claude-haiku-5-5", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.anthropic.claude-opus-5-5", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.anthropic.claude-sonnet-5-5", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6-astra", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6-luna", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6.1-sol", "arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.openai.gpt-6.1-terra"], "variable": "bedrock:InferenceProfileArn"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:bedrock:*::foundation-model/anthropic.claude-haiku-5-5", "arn:aws:bedrock:*::foundation-model/anthropic.claude-opus-5-5", "arn:aws:bedrock:*::foundation-model/anthropic.claude-sonnet-5-5", "arn:aws:bedrock:*::foundation-model/openai.gpt-6-astra", "arn:aws:bedrock:*::foundation-model/openai.gpt-6-luna", "arn:aws:bedrock:*::foundation-model/openai.gpt-6.1-sol", "arn:aws:bedrock:*::foundation-model/openai.gpt-6.1-terra", "arn:aws:bedrock:::foundation-model/anthropic.claude-haiku-5-5", "arn:aws:bedrock:::foundation-model/anthropic.claude-opus-5-5", "arn:aws:bedrock:::foundation-model/anthropic.claude-sonnet-5-5", "arn:aws:bedrock:::foundation-model/openai.gpt-6-astra", "arn:aws:bedrock:::foundation-model/openai.gpt-6-luna", "arn:aws:bedrock:::foundation-model/openai.gpt-6.1-sol", "arn:aws:bedrock:::foundation-model/openai.gpt-6.1-terra"], "sid": "BedrockInferenceFoundationModels"}, {"actions": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["arn:aws:ecr:us-east-1:123456789012:repository/crm-agent-eval-agent"], "sid": "EcrImageAccess"}, {"actions": ["ecr:GetAuthorizationToken"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["*"], "sid": "EcrTokenAccess"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false, false, false, false]}], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false]}, {"actions": [false, false], "condition": [{"values": [false, false, false, false, false, false, false]}], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "agentcore_runtime_permissions", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "data.aws_iam_policy_document.chat_target_invoke_runtime", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["bedrock-agentcore:InvokeAgentRuntime"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "InvokeTheRuntimeDefaultEndpoint"}, {"actions": null, "condition": [], "effect": "Deny", "not_actions": ["bedrock-agentcore:InvokeAgentRuntime"], "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "DenyEverythingButInvokeOnThisRuntime"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"condition": [], "not_actions": [false], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"condition": [], "not_actions": [false], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "name": "chat_target_invoke_runtime", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -19,6 +20,7 @@ {"address": "aws_iam_role.eval_sweep", "change": {"actions": ["create"], "after": {"assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Condition\":{\"ArnEquals\":{\"aws:SourceArn\":\"arn:aws:states:us-east-1:123456789012:stateMachine:crm-agent-eval-eval-sweep\"},\"StringEquals\":{\"aws:SourceAccount\":\"123456789012\"}},\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"states.amazonaws.com\"}}],\"Version\":\"2012-10-17\"}", "description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-eval-sweep-role", "path": "/", "permissions_boundary": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags": {}, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_sweep", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "aws_iam_role_policy.agentcore_gateway", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-gateway-permissions"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agentcore_gateway", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "aws_iam_role_policy.agentcore_runtime", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-runtime-permissions"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agentcore_runtime", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} +{"address": "aws_iam_role_policy.agentcore_runtime_history", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-runtime-history"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agentcore_runtime_history", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "aws_iam_role_policy.agentcore_runtime_logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-runtime-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agentcore_runtime_logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "aws_iam_role_policy.chat_target_invoke_runtime", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-target-invoke-runtime", "role": "crm-agent-eval-chat-target-role"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "chat_target_invoke_runtime", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "aws_iam_role_policy.eval_sweep", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-eval-sweep-permissions", "role": "crm-agent-eval-eval-sweep-role"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_sweep", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} @@ -35,7 +37,7 @@ {"address": "aws_kms_key_policy.api_allowlist", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "region": "us-east-1"}, "after_sensitive": {}, "after_unknown": {"id": true, "key_id": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "api_allowlist", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key_policy"} {"address": "aws_kms_key_policy.cursor", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "region": "us-east-1"}, "after_sensitive": {}, "after_unknown": {"id": true, "key_id": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "cursor", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key_policy"} {"address": "aws_kms_key_policy.eval_artifacts", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "region": "us-east-1"}, "after_sensitive": {}, "after_unknown": {"id": true, "key_id": true, "policy": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_artifacts", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key_policy"} -{"address": "aws_s3_object.agent_source", "change": {"actions": ["create"], "after": {"cache_control": null, "checksum_algorithm": null, "content": null, "content_base64": null, "content_disposition": null, "content_encoding": null, "content_language": null, "force_destroy": false, "key": "agent-source/agent.zip", "metadata": null, "object_lock_legal_hold_status": null, "object_lock_mode": null, "object_lock_retain_until_date": null, "override_provider": [], "region": "us-east-1", "source": "build/lambda/agent-source.zip", "source_hash": "8qYnkxPz6aW9xkQhOqs0b13C5721OXtXEb+d+IGu1mI=", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "website_redirect": null}, "after_identity": {"account_id": null, "bucket": null, "key": null, "region": null}, "after_sensitive": {"override_provider": [], "tags": {}, "tags_all": {}}, "after_unknown": {"acl": true, "arn": true, "bucket": true, "bucket_key_enabled": true, "checksum_crc32": true, "checksum_crc32c": true, "checksum_crc64nvme": true, "checksum_sha1": true, "checksum_sha256": true, "content_type": true, "etag": true, "id": true, "kms_key_id": true, "override_provider": [], "server_side_encryption": true, "storage_class": true, "tags": {}, "tags_all": {}, "version_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agent_source", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_s3_object"} +{"address": "aws_s3_object.agent_source", "change": {"actions": ["create"], "after": {"cache_control": null, "checksum_algorithm": null, "content": null, "content_base64": null, "content_disposition": null, "content_encoding": null, "content_language": null, "force_destroy": false, "key": "agent-source/agent.zip", "metadata": null, "object_lock_legal_hold_status": null, "object_lock_mode": null, "object_lock_retain_until_date": null, "override_provider": [], "region": "us-east-1", "source": "build/lambda/agent-source.zip", "source_hash": "Cb1ZYQiwTeDuq/mREs+smndajLZ6a3U0e6Y5aFoMa/o=", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "website_redirect": null}, "after_identity": {"account_id": null, "bucket": null, "key": null, "region": null}, "after_sensitive": {"override_provider": [], "tags": {}, "tags_all": {}}, "after_unknown": {"acl": true, "arn": true, "bucket": true, "bucket_key_enabled": true, "checksum_crc32": true, "checksum_crc32c": true, "checksum_crc64nvme": true, "checksum_sha1": true, "checksum_sha256": true, "content_type": true, "etag": true, "id": true, "kms_key_id": true, "override_provider": [], "server_side_encryption": true, "storage_class": true, "tags": {}, "tags_all": {}, "version_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "agent_source", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_s3_object"} {"address": "aws_sfn_state_machine.eval_sweep", "change": {"actions": ["create"], "after": {"logging_configuration": [{"include_execution_data": false, "level": "ALL"}], "name": "crm-agent-eval-eval-sweep", "publish": false, "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "tracing_configuration": [{"enabled": true}], "type": "STANDARD"}, "after_identity": {"arn": null}, "after_sensitive": {"encryption_configuration": [], "logging_configuration": [{}], "tags": {}, "tags_all": {}, "tracing_configuration": [{}]}, "after_unknown": {"arn": true, "creation_date": true, "definition": true, "description": true, "encryption_configuration": true, "id": true, "logging_configuration": [{"log_destination": true}], "name_prefix": true, "revision_id": true, "role_arn": true, "state_machine_version_arn": true, "status": true, "tags": {}, "tags_all": {}, "tracing_configuration": [{}], "version_description": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "eval_sweep", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_sfn_state_machine"} {"address": "aws_ssm_parameter.api_allowed_client_ids", "change": {"actions": ["create"], "after": {"allowed_pattern": null, "description": null, "name": "/crm-agent-eval/api/allowed-client-ids", "overwrite": null, "region": "us-east-1", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tier": "Standard", "type": "SecureString", "value_wo": null, "value_wo_version": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}, "value": true, "value_wo": true}, "after_unknown": {"arn": true, "data_type": true, "has_value_wo": true, "id": true, "insecure_value": true, "key_id": true, "tags": {}, "tags_all": {}, "value": true, "version": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "api_allowed_client_ids", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ssm_parameter"} {"address": "aws_ssm_parameter.relay_cognito_audience", "change": {"actions": ["create"], "after": {"allowed_pattern": null, "description": null, "name": "/crm-agent-eval/relay/cognito-audience", "overwrite": null, "region": "us-east-1", "tags": {"data-classification": "internal"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "internal", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "type": "String", "value_wo": null, "value_wo_version": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}, "value": true, "value_wo": true}, "after_unknown": {"arn": true, "data_type": true, "has_value_wo": true, "id": true, "insecure_value": true, "key_id": true, "tags": {}, "tags_all": {}, "tier": true, "value": true, "version": true}, "before": null, "before_sensitive": false}, "mode": "managed", "name": "relay_cognito_audience", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ssm_parameter"} @@ -53,11 +55,11 @@ {"address": "module.agent_relay.aws_iam_role_policy.read_audience_parameter", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-agent-relay-read-parameters", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"ssm:GetParameter\",\"Effect\":\"Allow\",\"Resource\":\"arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/relay/cognito-audience\",\"Sid\":\"ReadRelayParameters\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "read_audience_parameter", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.agent_relay.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-agent-relay-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.agent_relay.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-agent-relay-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.agent_relay.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/relay.zip", "function_name": "crm-agent-eval-agent-relay", "handler": "index.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "nodejs24.x", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "zVuL6+DPVWA/MrpkDv7c/+PhzDk2ObDL8quQitkWv1s=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.agent_relay.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/relay.zip", "function_name": "crm-agent-eval-agent-relay", "handler": "index.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "nodejs24.x", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "/marz1B3NPQo2GDp4TMBHang+88TQOTEfYTOWz6G4O0=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.agent_relay.aws_lambda_function_url.this", "change": {"actions": ["create"], "after": {"authorization_type": "AWS_IAM", "cors": [], "function_name": "crm-agent-eval-agent-relay", "invoke_mode": "RESPONSE_STREAM", "qualifier": null, "region": "us-east-1", "timeouts": null}, "after_sensitive": {"cors": []}, "after_unknown": {"cors": [], "function_arn": true, "function_url": true, "id": true, "url_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agent_relay", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function_url"} {"action_reason": "read_because_dependency_pending", "address": "module.agentcore.data.aws_iam_policy_document.codebuild_assume_role", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["sts:AssumeRole"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["codebuild.amazonaws.com"], "type": "Service"}], "resources": null, "sid": null}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.agentcore", "name": "codebuild_assume_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.agentcore.data.aws_iam_policy_document.codebuild_permissions", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "Logs"}, {"actions": ["ecr:GetAuthorizationToken"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": ["*"], "sid": "EcrAuth"}, {"actions": ["ecr:BatchCheckLayerAvailability", "ecr:BatchGetImage", "ecr:CompleteLayerUpload", "ecr:GetDownloadUrlForLayer", "ecr:InitiateLayerUpload", "ecr:PutImage", "ecr:UploadLayerPart"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "EcrPush"}, {"actions": ["s3:GetObject", "s3:GetObjectVersion"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "SourceObject"}, {"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:Encrypt", "kms:GenerateDataKey*"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "ProjectKms"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.agentcore", "name": "codebuild_permissions", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"address": "module.agentcore.aws_bedrockagentcore_agent_runtime.this", "change": {"actions": ["create"], "after": {"agent_runtime_artifact": [{"code_configuration": [], "container_configuration": [{}]}], "agent_runtime_name": "crm_agent_eval_runtime", "authorizer_configuration": [], "description": null, "environment_variables": {"ACTION_LAMBDA_PREFIX": "crm-agent-eval", "AGENT_PROVIDER": "anthropic", "CRM_TABLE_PREFIX": "crm-agent-eval"}, "filesystem_configuration": [], "network_configuration": [{"network_mode": "VPC", "network_mode_config": [{"security_groups": [null], "subnets": ["subnet-runtimeoneplaceholder", "subnet-runtimetwoplaceholder"]}]}], "platform_version": "V2", "protocol_configuration": [], "region": "us-east-1", "request_header_configuration": [], "tags": {}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": {"create": "30m", "delete": null, "update": "30m"}}, "after_sensitive": {"agent_runtime_artifact": [{"code_configuration": [], "container_configuration": [{}]}], "authorizer_configuration": [], "environment_variables": {}, "filesystem_configuration": [], "lifecycle_configuration": [], "network_configuration": [{"network_mode_config": [{"security_groups": [false], "subnets": [false, false]}]}], "protocol_configuration": [], "request_header_configuration": [], "tags": {}, "tags_all": {}, "timeouts": {}, "workload_identity_details": []}, "after_unknown": {"agent_runtime_arn": true, "agent_runtime_artifact": [{"code_configuration": [], "container_configuration": [{"container_uri": true}]}], "agent_runtime_id": true, "agent_runtime_version": true, "authorizer_configuration": [], "environment_variables": {"API_BASE_URL": true, "COGNITO_USER_POOL_ID": true}, "filesystem_configuration": [], "lifecycle_configuration": true, "network_configuration": [{"network_mode_config": [{"require_service_s3_endpoint": true, "security_groups": [true], "subnets": [false, false]}]}], "protocol_configuration": [], "request_header_configuration": [], "role_arn": true, "tags": {}, "tags_all": {}, "timeouts": {}, "workload_identity_details": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_agent_runtime"} +{"address": "module.agentcore.aws_bedrockagentcore_agent_runtime.this", "change": {"actions": ["create"], "after": {"agent_runtime_artifact": [{"code_configuration": [], "container_configuration": [{}]}], "agent_runtime_name": "crm_agent_eval_runtime", "authorizer_configuration": [], "description": null, "environment_variables": {"ACTION_LAMBDA_PREFIX": "crm-agent-eval", "AGENT_PROVIDER": "anthropic", "CONVERSATION_HISTORY_STORE": "dynamodb", "CRM_TABLE_PREFIX": "crm-agent-eval"}, "filesystem_configuration": [], "network_configuration": [{"network_mode": "VPC", "network_mode_config": [{"security_groups": [null], "subnets": ["subnet-runtimeoneplaceholder", "subnet-runtimetwoplaceholder"]}]}], "platform_version": "V2", "protocol_configuration": [], "region": "us-east-1", "request_header_configuration": [], "tags": {}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": {"create": "30m", "delete": null, "update": "30m"}}, "after_sensitive": {"agent_runtime_artifact": [{"code_configuration": [], "container_configuration": [{}]}], "authorizer_configuration": [], "environment_variables": {}, "filesystem_configuration": [], "lifecycle_configuration": [], "network_configuration": [{"network_mode_config": [{"security_groups": [false], "subnets": [false, false]}]}], "protocol_configuration": [], "request_header_configuration": [], "tags": {}, "tags_all": {}, "timeouts": {}, "workload_identity_details": []}, "after_unknown": {"agent_runtime_arn": true, "agent_runtime_artifact": [{"code_configuration": [], "container_configuration": [{"container_uri": true}]}], "agent_runtime_id": true, "agent_runtime_version": true, "authorizer_configuration": [], "environment_variables": {"API_BASE_URL": true, "COGNITO_USER_POOL_ID": true}, "filesystem_configuration": [], "lifecycle_configuration": true, "network_configuration": [{"network_mode_config": [{"require_service_s3_endpoint": true, "security_groups": [true], "subnets": [false, false]}]}], "protocol_configuration": [], "request_header_configuration": [], "role_arn": true, "tags": {}, "tags_all": {}, "timeouts": {}, "workload_identity_details": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_agent_runtime"} {"address": "module.agentcore.aws_bedrockagentcore_gateway.this", "change": {"actions": ["create"], "after": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": null, "allowed_clients": [null, null], "allowed_scopes": [null], "allowed_workload_configuration": [], "custom_claim": [], "private_endpoint": [], "private_endpoint_overrides": []}]}], "authorizer_type": "CUSTOM_JWT", "description": null, "exception_level": null, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": true}], "interception_points": ["REQUEST"], "interceptor": [{"lambda": [{}]}]}], "kms_key_arn": null, "name": "crm-agent-eval-gateway", "policy_engine_configuration": [], "protocol_configuration": [], "region": "us-east-1", "tags": {}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_sensitive": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_clients": [false, false], "allowed_scopes": [false], "allowed_workload_configuration": [], "custom_claim": [], "private_endpoint": [], "private_endpoint_overrides": []}]}], "interceptor_configuration": [{"input_configuration": [{}], "interception_points": [false], "interceptor": [{"lambda": [{}]}]}], "policy_engine_configuration": [], "protocol_configuration": [], "tags": {}, "tags_all": {}, "workload_identity_details": []}, "after_unknown": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_clients": [true, true], "allowed_scopes": [true], "allowed_workload_configuration": [], "custom_claim": [], "discovery_url": true, "private_endpoint": [], "private_endpoint_overrides": []}]}], "gateway_arn": true, "gateway_id": true, "gateway_url": true, "interceptor_configuration": [{"input_configuration": [{}], "interception_points": [false], "interceptor": [{"lambda": [{"arn": true}]}]}], "policy_engine_configuration": [], "protocol_configuration": [], "protocol_type": true, "role_arn": true, "tags": {}, "tags_all": {}, "workload_identity_details": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway"} {"address": "module.agentcore.aws_bedrockagentcore_gateway_target.tool[\"approve_proposal\"]", "change": {"actions": ["create"], "after": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{"region": null, "service": null}], "jwt_passthrough": [], "oauth": []}], "description": "Gateway target for CRM tool approve_proposal, backed by its action Lambda.", "metadata_configuration": [], "name": "approve-proposal", "private_endpoint": [], "region": "us-east-1", "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"description": "Approve a pending proposal. The stored before-snapshot is re-checked against current state; if the record has changed since the proposal was raised, approval is refused as a conflict rather than overwriting the newer value.", "input_schema": [{"description": null, "items": [], "property": [{"description": "Idempotency key. Use a new unique value (for example a random UUID) for each distinct change. Reuse a key only to retry the exact same change: a retry is never applied twice and returns the original result or a conflict. Never reuse a key for a different change; it can be refused as a conflict.", "items": [], "name": "transaction_key", "property": [], "required": true, "type": "string"}, {"description": null, "items": [], "name": "proposal_id", "property": [], "required": true, "type": "string"}], "type": "object"}], "name": "approve_proposal", "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "timeouts": null}, "after_sensitive": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}]}, "after_unknown": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "gateway_identifier": true, "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"lambda_arn": true, "tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "target_id": true}, "before": null, "before_sensitive": false}, "index": "approve_proposal", "mode": "managed", "module_address": "module.agentcore", "name": "tool", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway_target"} {"address": "module.agentcore.aws_bedrockagentcore_gateway_target.tool[\"create_account\"]", "change": {"actions": ["create"], "after": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{"region": null, "service": null}], "jwt_passthrough": [], "oauth": []}], "description": "Gateway target for CRM tool create_account, backed by its action Lambda.", "metadata_configuration": [], "name": "create-account", "private_endpoint": [], "region": "us-east-1", "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"description": "Create a new account. Commits immediately.", "input_schema": [{"description": null, "items": [], "property": [{"description": "Idempotency key. Use a new unique value (for example a random UUID) for each distinct change. Reuse a key only to retry the exact same change: a retry is never applied twice and returns the original result or a conflict. Never reuse a key for a different change; it can be refused as a conflict.", "items": [], "name": "transaction_key", "property": [], "required": true, "type": "string"}, {"description": null, "items": [], "name": "employee_count", "property": [], "required": false, "type": "integer"}, {"description": null, "items": [], "name": "industry", "property": [], "required": false, "type": "string"}, {"description": null, "items": [], "name": "name", "property": [], "required": true, "type": "string"}, {"description": null, "items": [], "name": "region", "property": [], "required": false, "type": "string"}, {"description": null, "items": [], "name": "website", "property": [], "required": false, "type": "string"}], "type": "object"}], "name": "create_account", "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "timeouts": null}, "after_sensitive": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}]}, "after_unknown": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "gateway_identifier": true, "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"lambda_arn": true, "tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "target_id": true}, "before": null, "before_sensitive": false}, "index": "create_account", "mode": "managed", "module_address": "module.agentcore", "name": "tool", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway_target"} @@ -87,13 +89,13 @@ {"address": "module.agentcore.aws_bedrockagentcore_gateway_target.tool[\"update_opportunity\"]", "change": {"actions": ["create"], "after": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{"region": null, "service": null}], "jwt_passthrough": [], "oauth": []}], "description": "Gateway target for CRM tool update_opportunity, backed by its action Lambda.", "metadata_configuration": [], "name": "update-opportunity", "private_endpoint": [], "region": "us-east-1", "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"description": "Update low-risk opportunity fields such as name, description, source, and competitor. Stage, value, close date, owner, and primary contact are not changeable here \u2014 use submit_proposal for those.", "input_schema": [{"description": null, "items": [], "property": [{"description": "Fields to change, keyed by field name. Allowed keys: competitor, description, name, source. Omit any field you are not changing. close_date, owner_rep_id, primary_contact_id, stage, value are not accepted here; use submit_proposal.", "items": [], "name": "fields", "property": [], "required": true, "type": "object"}, {"description": "Idempotency key. Use a new unique value (for example a random UUID) for each distinct change. Reuse a key only to retry the exact same change: a retry is never applied twice and returns the original result or a conflict. Never reuse a key for a different change; it can be refused as a conflict.", "items": [], "name": "transaction_key", "property": [], "required": true, "type": "string"}, {"description": null, "items": [], "name": "opportunity_id", "property": [], "required": true, "type": "string"}], "type": "object"}], "name": "update_opportunity", "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "timeouts": null}, "after_sensitive": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}]}, "after_unknown": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "gateway_identifier": true, "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"lambda_arn": true, "tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "target_id": true}, "before": null, "before_sensitive": false}, "index": "update_opportunity", "mode": "managed", "module_address": "module.agentcore", "name": "tool", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway_target"} {"address": "module.agentcore.aws_cloudwatch_log_group.codebuild", "change": {"actions": ["create"], "after": {"name": "/aws/codebuild/crm-agent-eval-agent-image", "region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name_prefix": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "codebuild", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} {"address": "module.agentcore.aws_cloudwatch_log_group.runtime", "change": {"actions": ["create"], "after": {"region": "us-east-1", "retention_in_days": 365, "skip_destroy": false, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "deletion_protection_enabled": true, "id": true, "kms_key_id": true, "log_group_class": true, "name": true, "name_prefix": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "runtime", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudwatch_log_group"} -{"address": "module.agentcore.aws_codebuild_project.agent_image", "change": {"actions": ["create"], "after": {"artifacts": [{"artifact_identifier": null, "bucket_owner_access": null, "encryption_disabled": false, "location": null, "name": null, "namespace_type": null, "override_artifact_name": false, "packaging": null, "path": null, "type": "NO_ARTIFACTS"}], "badge_enabled": false, "build_batch_config": [], "build_timeout": 30, "cache": [], "concurrent_build_limit": null, "description": "Builds and pushes the AgentCore Runtime container image.", "environment": [{"certificate": null, "compute_type": "BUILD_GENERAL1_SMALL", "docker_server": [], "environment_variable": [{"name": "ECR_REPOSITORY_URI", "type": "PLAINTEXT"}, {"name": "AWS_DEFAULT_REGION", "type": "PLAINTEXT", "value": "us-east-1"}], "fleet": [], "image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", "image_pull_credentials_type": "CODEBUILD", "privileged_mode": true, "registry_credential": [], "type": "ARM_CONTAINER"}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{"group_name": "/aws/codebuild/crm-agent-eval-agent-image", "status": "ENABLED", "stream_name": null}], "s3_logs": []}], "name": "crm-agent-eval-agent-image", "project_visibility": "PRIVATE", "queued_timeout": 480, "region": "us-east-1", "resource_access_role": null, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "buildspec": "\"phases\":\n \"build\":\n \"commands\":\n - \"docker build -t ${ECR_REPOSITORY_URI}:sha-f2a6279313f3 .\"\n \"post_build\":\n \"commands\":\n - \"docker push ${ECR_REPOSITORY_URI}:sha-f2a6279313f3\"\n \"pre_build\":\n \"commands\":\n - \"REGISTRY_HOST=${ECR_REPOSITORY_URI%%/*}\"\n - \"aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username\n AWS --password-stdin ${REGISTRY_HOST}\"\n\"version\": \"0.2\"\n", "git_clone_depth": null, "git_submodules_config": [], "insecure_ssl": null, "report_build_status": null, "type": "S3"}], "source_version": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "vpc_config": []}, "after_identity": {"arn": null}, "after_sensitive": {"artifacts": [{}], "build_batch_config": [], "cache": [], "environment": [{"docker_server": [], "environment_variable": [{}, {}], "fleet": [], "registry_credential": []}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "git_submodules_config": []}], "tags_all": {}, "vpc_config": []}, "after_unknown": {"arn": true, "artifacts": [{}], "auto_retry_limit": true, "badge_url": true, "build_batch_config": [], "cache": [], "encryption_key": true, "environment": [{"docker_server": [], "environment_variable": [{"value": true}, {}], "fleet": [], "host_kernel": true, "registry_credential": []}], "file_system_locations": [], "id": true, "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "public_project_alias": true, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "service_role": true, "source": [{"auth": [], "build_status_config": [], "git_submodules_config": [], "location": true}], "tags_all": {}, "vpc_config": []}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent_image", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_codebuild_project"} +{"address": "module.agentcore.aws_codebuild_project.agent_image", "change": {"actions": ["create"], "after": {"artifacts": [{"artifact_identifier": null, "bucket_owner_access": null, "encryption_disabled": false, "location": null, "name": null, "namespace_type": null, "override_artifact_name": false, "packaging": null, "path": null, "type": "NO_ARTIFACTS"}], "badge_enabled": false, "build_batch_config": [], "build_timeout": 30, "cache": [], "concurrent_build_limit": null, "description": "Builds and pushes the AgentCore Runtime container image.", "environment": [{"certificate": null, "compute_type": "BUILD_GENERAL1_SMALL", "docker_server": [], "environment_variable": [{"name": "ECR_REPOSITORY_URI", "type": "PLAINTEXT"}, {"name": "AWS_DEFAULT_REGION", "type": "PLAINTEXT", "value": "us-east-1"}], "fleet": [], "image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", "image_pull_credentials_type": "CODEBUILD", "privileged_mode": true, "registry_credential": [], "type": "ARM_CONTAINER"}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{"group_name": "/aws/codebuild/crm-agent-eval-agent-image", "status": "ENABLED", "stream_name": null}], "s3_logs": []}], "name": "crm-agent-eval-agent-image", "project_visibility": "PRIVATE", "queued_timeout": 480, "region": "us-east-1", "resource_access_role": null, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "buildspec": "\"phases\":\n \"build\":\n \"commands\":\n - \"docker build -t ${ECR_REPOSITORY_URI}:sha-09bd596108b0 .\"\n \"post_build\":\n \"commands\":\n - \"docker push ${ECR_REPOSITORY_URI}:sha-09bd596108b0\"\n \"pre_build\":\n \"commands\":\n - \"REGISTRY_HOST=${ECR_REPOSITORY_URI%%/*}\"\n - \"aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username\n AWS --password-stdin ${REGISTRY_HOST}\"\n\"version\": \"0.2\"\n", "git_clone_depth": null, "git_submodules_config": [], "insecure_ssl": null, "report_build_status": null, "type": "S3"}], "source_version": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "vpc_config": []}, "after_identity": {"arn": null}, "after_sensitive": {"artifacts": [{}], "build_batch_config": [], "cache": [], "environment": [{"docker_server": [], "environment_variable": [{}, {}], "fleet": [], "registry_credential": []}], "file_system_locations": [], "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "source": [{"auth": [], "build_status_config": [], "git_submodules_config": []}], "tags_all": {}, "vpc_config": []}, "after_unknown": {"arn": true, "artifacts": [{}], "auto_retry_limit": true, "badge_url": true, "build_batch_config": [], "cache": [], "encryption_key": true, "environment": [{"docker_server": [], "environment_variable": [{"value": true}, {}], "fleet": [], "host_kernel": true, "registry_credential": []}], "file_system_locations": [], "id": true, "logs_config": [{"cloudwatch_logs": [{}], "s3_logs": []}], "public_project_alias": true, "secondary_artifacts": [], "secondary_source_version": [], "secondary_sources": [], "service_role": true, "source": [{"auth": [], "build_status_config": [], "git_submodules_config": [], "location": true}], "tags_all": {}, "vpc_config": []}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent_image", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_codebuild_project"} {"address": "module.agentcore.aws_ecr_lifecycle_policy.agent", "change": {"actions": ["create"], "after": {"policy": "{\"rules\":[{\"action\":{\"type\":\"expire\"},\"description\":\"Expire untagged images after 14 days\",\"rulePriority\":1,\"selection\":{\"countNumber\":14,\"countType\":\"sinceImagePushed\",\"countUnit\":\"days\",\"tagStatus\":\"untagged\"}},{\"action\":{\"type\":\"expire\"},\"description\":\"Keep only the most recent 10 tagged images\",\"rulePriority\":2,\"selection\":{\"countNumber\":10,\"countType\":\"imageCountMoreThan\",\"tagPrefixList\":[\"sha-\"],\"tagStatus\":\"tagged\"}}]}", "region": "us-east-1", "repository": "crm-agent-eval-agent"}, "after_identity": {"account_id": null, "region": null, "repository": null}, "after_sensitive": {}, "after_unknown": {"id": true, "registry_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ecr_lifecycle_policy"} {"address": "module.agentcore.aws_ecr_repository.agent", "change": {"actions": ["create"], "after": {"encryption_configuration": [{"encryption_type": "KMS"}], "force_delete": true, "image_scanning_configuration": [{"scan_on_push": true}], "image_tag_mutability": "IMMUTABLE", "image_tag_mutability_exclusion_filter": [], "name": "crm-agent-eval-agent", "region": "us-east-1", "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"encryption_configuration": [{}], "image_scanning_configuration": [{}], "image_tag_mutability_exclusion_filter": [], "tags_all": {}}, "after_unknown": {"arn": true, "encryption_configuration": [{"kms_key": true}], "id": true, "image_scanning_configuration": [{}], "image_tag_mutability_exclusion_filter": [], "registry_id": true, "repository_url": true, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "agent", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_ecr_repository"} {"address": "module.agentcore.aws_iam_role.codebuild", "change": {"actions": ["create"], "after": {"description": null, "force_detach_policies": false, "max_session_duration": 3600, "name": "crm-agent-eval-codebuild-role", "path": "/", "permissions_boundary": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"account_id": null, "name": null}, "after_sensitive": {"inline_policy": [], "managed_policy_arns": [], "tags_all": {}}, "after_unknown": {"arn": true, "assume_role_policy": true, "create_date": true, "id": true, "inline_policy": true, "managed_policy_arns": true, "name_prefix": true, "tags_all": {}, "unique_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "codebuild", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role"} {"address": "module.agentcore.aws_iam_role_policy.codebuild", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-codebuild"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "codebuild", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.agentcore.aws_lambda_permission.gateway_invoke_interceptor", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-identity-interceptor", "function_url_auth_type": null, "invoked_via_function_url": null, "principal": "bedrock-agentcore.amazonaws.com", "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "statement_id": "AllowGatewayInvokeIdentityInterceptor", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "source_arn": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "gateway_invoke_interceptor", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} -{"address": "module.agentcore.null_resource.image_build", "change": {"actions": ["create"], "after": {"triggers": {"project_name": "crm-agent-eval-agent-image", "source_content_hash": "8qYnkxPz6aW9xkQhOqs0b13C5721OXtXEb+d+IGu1mI="}}, "after_sensitive": {"triggers": {}}, "after_unknown": {"id": true, "triggers": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "image_build", "provider_name": "registry.terraform.io/hashicorp/null", "type": "null_resource"} +{"address": "module.agentcore.null_resource.image_build", "change": {"actions": ["create"], "after": {"triggers": {"project_name": "crm-agent-eval-agent-image", "source_content_hash": "Cb1ZYQiwTeDuq/mREs+smndajLZ6a3U0e6Y5aFoMa/o="}}, "after_sensitive": {"triggers": {}}, "after_unknown": {"id": true, "triggers": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.agentcore", "name": "image_build", "provider_name": "registry.terraform.io/hashicorp/null", "type": "null_resource"} {"action_reason": "read_because_config_unknown", "address": "module.api.data.aws_iam_policy_document.resource_policy", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["execute-api:Invoke"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": ["execute-api:/*"], "sid": "AllowInvokeFromNamedVpcEndpointsOnly"}, {"actions": ["execute-api:Invoke"], "condition": [{"test": "StringNotEquals", "values": [null], "variable": "aws:sourceVpce"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": ["execute-api:/*"], "sid": "DenyInvokeFromAnyOtherVpcEndpoint"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [true]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.api", "name": "resource_policy", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.api.aws_api_gateway_authorizer.cognito", "change": {"actions": ["create"], "after": {"authorizer_credentials": null, "authorizer_result_ttl_in_seconds": 300, "authorizer_uri": null, "identity_source": "method.request.header.Authorization", "identity_validation_expression": null, "name": "cognito-user-pools", "region": "us-east-1", "type": "COGNITO_USER_POOLS"}, "after_sensitive": {"provider_arns": []}, "after_unknown": {"arn": true, "id": true, "provider_arns": true, "rest_api_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.api", "name": "cognito", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_api_gateway_authorizer"} {"address": "module.api.aws_api_gateway_deployment.this", "change": {"actions": ["create"], "after": {"description": null, "region": "us-east-1", "variables": null}, "after_identity": {"account_id": null, "id": null, "region": null, "rest_api_id": null}, "after_sensitive": {"triggers": {}}, "after_unknown": {"created_date": true, "id": true, "rest_api_id": true, "triggers": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.api", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_api_gateway_deployment"} @@ -253,7 +255,7 @@ {"address": "module.dynamodb.aws_dynamodb_table.notes", "change": {"actions": ["create"], "after": {"attribute": [{"name": "created_at", "type": "S"}, {"name": "note_id", "type": "S"}, {"name": "tenant", "type": "S"}, {"name": "tenant_opportunity_id", "type": "S"}], "billing_mode": "PAY_PER_REQUEST", "deletion_protection_enabled": null, "global_secondary_index": [{"hash_key": "tenant", "name": "gsi_tenant", "non_key_attributes": ["body", "note_id", "opportunity_id", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}, {"hash_key": "tenant_opportunity_id", "name": "gsi_opportunity", "non_key_attributes": ["body", "note_id", "opportunity_id", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}], "hash_key": "note_id", "import_table": [], "local_secondary_index": [], "name": "crm-agent-evalnotes", "on_demand_throughput": [], "point_in_time_recovery": [{"enabled": true}], "range_key": null, "region": "us-east-1", "replica": [], "restore_backup_arn": null, "restore_date_time": null, "restore_source_name": null, "restore_source_table_arn": null, "restore_to_latest_time": null, "server_side_encryption": [{"enabled": true}], "stream_enabled": null, "table_class": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"attribute": [{}, {}, {}, {}], "global_secondary_index": [{"key_schema": [], "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}], "global_table_witness": [], "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{}], "replica": [], "server_side_encryption": [{}], "tags": {}, "tags_all": {}, "ttl": [], "warm_throughput": []}, "after_unknown": {"arn": true, "attribute": [{}, {}, {}, {}], "global_secondary_index": [{"key_schema": true, "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}], "global_table_witness": true, "id": true, "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{"recovery_period_in_days": true}], "read_capacity": true, "replica": [], "server_side_encryption": [{"kms_key_arn": true}], "stream_arn": true, "stream_label": true, "stream_view_type": true, "tags": {}, "tags_all": {}, "ttl": true, "warm_throughput": true, "write_capacity": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "notes", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_dynamodb_table"} {"address": "module.dynamodb.aws_dynamodb_table.opportunities", "change": {"actions": ["create"], "after": {"attribute": [{"name": "close_date", "type": "S"}, {"name": "created_at", "type": "S"}, {"name": "name_lower", "type": "S"}, {"name": "opportunity_id", "type": "S"}, {"name": "stage_close_date", "type": "S"}, {"name": "tenant", "type": "S"}, {"name": "tenant_account_id", "type": "S"}, {"name": "tenant_owner_rep_id", "type": "S"}, {"name": "tenant_stage", "type": "S"}], "billing_mode": "PAY_PER_REQUEST", "deletion_protection_enabled": null, "global_secondary_index": [{"hash_key": "tenant", "name": "gsi_tenant", "non_key_attributes": ["account_id", "close_date", "name", "opportunity_id", "owner_rep_id", "stage", "tenant", "value"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "name_lower"}, {"hash_key": "tenant_account_id", "name": "gsi_account", "non_key_attributes": ["account_id", "close_date", "name", "name_lower", "opportunity_id", "owner_rep_id", "stage", "tenant", "value"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}, {"hash_key": "tenant_owner_rep_id", "name": "gsi_owner_stage", "non_key_attributes": ["account_id", "close_date", "name", "name_lower", "opportunity_id", "owner_rep_id", "stage", "tenant", "value"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "stage_close_date"}, {"hash_key": "tenant_stage", "name": "gsi_stage", "non_key_attributes": ["account_id", "close_date", "name", "name_lower", "opportunity_id", "owner_rep_id", "stage", "tenant", "value"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "close_date"}], "hash_key": "opportunity_id", "import_table": [], "local_secondary_index": [], "name": "crm-agent-evalopportunities", "on_demand_throughput": [], "point_in_time_recovery": [{"enabled": true}], "range_key": null, "region": "us-east-1", "replica": [], "restore_backup_arn": null, "restore_date_time": null, "restore_source_name": null, "restore_source_table_arn": null, "restore_to_latest_time": null, "server_side_encryption": [{"enabled": true}], "stream_enabled": null, "table_class": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"attribute": [{}, {}, {}, {}, {}, {}, {}, {}, {}], "global_secondary_index": [{"key_schema": [], "non_key_attributes": [false, false, false, false, false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false, false, false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false, false, false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false, false, false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}], "global_table_witness": [], "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{}], "replica": [], "server_side_encryption": [{}], "tags": {}, "tags_all": {}, "ttl": [], "warm_throughput": []}, "after_unknown": {"arn": true, "attribute": [{}, {}, {}, {}, {}, {}, {}, {}, {}], "global_secondary_index": [{"key_schema": true, "non_key_attributes": [false, false, false, false, false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false, false, false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false, false, false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false, false, false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}], "global_table_witness": true, "id": true, "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{"recovery_period_in_days": true}], "read_capacity": true, "replica": [], "server_side_encryption": [{"kms_key_arn": true}], "stream_arn": true, "stream_label": true, "stream_view_type": true, "tags": {}, "tags_all": {}, "ttl": true, "warm_throughput": true, "write_capacity": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "opportunities", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_dynamodb_table"} {"address": "module.dynamodb.aws_dynamodb_table.proposals", "change": {"actions": ["create"], "after": {"attribute": [{"name": "created_at", "type": "S"}, {"name": "proposal_id", "type": "S"}, {"name": "tenant", "type": "S"}, {"name": "tenant_actor_rep_id", "type": "S"}, {"name": "tenant_status", "type": "S"}, {"name": "tenant_target_id", "type": "S"}], "billing_mode": "PAY_PER_REQUEST", "deletion_protection_enabled": null, "global_secondary_index": [{"hash_key": "tenant", "name": "gsi_tenant", "non_key_attributes": ["proposal_id", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}, {"hash_key": "tenant_actor_rep_id", "name": "gsi_actor", "non_key_attributes": ["actor_rep_id", "proposal_id", "status", "target_id", "target_table", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}, {"hash_key": "tenant_status", "name": "gsi_status", "non_key_attributes": ["actor_rep_id", "proposal_id", "status", "target_id", "target_table", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}, {"hash_key": "tenant_target_id", "name": "gsi_target", "non_key_attributes": ["proposal_id", "status", "target_id", "target_table", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}], "hash_key": "proposal_id", "import_table": [], "local_secondary_index": [], "name": "crm-agent-evalproposals", "on_demand_throughput": [], "point_in_time_recovery": [{"enabled": true}], "range_key": null, "region": "us-east-1", "replica": [], "restore_backup_arn": null, "restore_date_time": null, "restore_source_name": null, "restore_source_table_arn": null, "restore_to_latest_time": null, "server_side_encryption": [{"enabled": true}], "stream_enabled": null, "table_class": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"attribute": [{}, {}, {}, {}, {}, {}], "global_secondary_index": [{"key_schema": [], "non_key_attributes": [false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}], "global_table_witness": [], "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{}], "replica": [], "server_side_encryption": [{}], "tags": {}, "tags_all": {}, "ttl": [], "warm_throughput": []}, "after_unknown": {"arn": true, "attribute": [{}, {}, {}, {}, {}, {}], "global_secondary_index": [{"key_schema": true, "non_key_attributes": [false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}], "global_table_witness": true, "id": true, "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{"recovery_period_in_days": true}], "read_capacity": true, "replica": [], "server_side_encryption": [{"kms_key_arn": true}], "stream_arn": true, "stream_label": true, "stream_view_type": true, "tags": {}, "tags_all": {}, "ttl": true, "warm_throughput": true, "write_capacity": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "proposals", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_dynamodb_table"} -{"address": "module.dynamodb.aws_dynamodb_table.reps", "change": {"actions": ["create"], "after": {"attribute": [{"name": "rep_id", "type": "S"}, {"name": "tenant", "type": "S"}], "billing_mode": "PAY_PER_REQUEST", "deletion_protection_enabled": null, "global_secondary_index": [{"hash_key": "tenant", "name": "gsi_tenant", "non_key_attributes": ["rep_id", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "rep_id"}], "hash_key": "rep_id", "import_table": [], "local_secondary_index": [], "name": "crm-agent-evalreps", "on_demand_throughput": [], "point_in_time_recovery": [{"enabled": true}], "range_key": null, "region": "us-east-1", "replica": [], "restore_backup_arn": null, "restore_date_time": null, "restore_source_name": null, "restore_source_table_arn": null, "restore_to_latest_time": null, "server_side_encryption": [{"enabled": true}], "stream_enabled": null, "table_class": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"attribute": [{}, {}], "global_secondary_index": [{"key_schema": [], "non_key_attributes": [false, false], "on_demand_throughput": [], "warm_throughput": []}], "global_table_witness": [], "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{}], "replica": [], "server_side_encryption": [{}], "tags": {}, "tags_all": {}, "ttl": [], "warm_throughput": []}, "after_unknown": {"arn": true, "attribute": [{}, {}], "global_secondary_index": [{"key_schema": true, "non_key_attributes": [false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}], "global_table_witness": true, "id": true, "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{"recovery_period_in_days": true}], "read_capacity": true, "replica": [], "server_side_encryption": [{"kms_key_arn": true}], "stream_arn": true, "stream_label": true, "stream_view_type": true, "tags": {}, "tags_all": {}, "ttl": true, "warm_throughput": true, "write_capacity": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "reps", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_dynamodb_table"} +{"address": "module.dynamodb.aws_dynamodb_table.reps", "change": {"actions": ["create"], "after": {"attribute": [{"name": "rep_id", "type": "S"}, {"name": "tenant", "type": "S"}], "billing_mode": "PAY_PER_REQUEST", "deletion_protection_enabled": null, "global_secondary_index": [{"hash_key": "tenant", "name": "gsi_tenant", "non_key_attributes": ["rep_id", "tenant"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "rep_id"}], "hash_key": "rep_id", "import_table": [], "local_secondary_index": [], "name": "crm-agent-evalreps", "on_demand_throughput": [], "point_in_time_recovery": [{"enabled": true}], "range_key": null, "region": "us-east-1", "replica": [], "restore_backup_arn": null, "restore_date_time": null, "restore_source_name": null, "restore_source_table_arn": null, "restore_to_latest_time": null, "server_side_encryption": [{"enabled": true}], "stream_enabled": null, "table_class": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "ttl": [{"attribute_name": "expires_at", "enabled": true}]}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"attribute": [{}, {}], "global_secondary_index": [{"key_schema": [], "non_key_attributes": [false, false], "on_demand_throughput": [], "warm_throughput": []}], "global_table_witness": [], "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{}], "replica": [], "server_side_encryption": [{}], "tags": {}, "tags_all": {}, "ttl": [{}], "warm_throughput": []}, "after_unknown": {"arn": true, "attribute": [{}, {}], "global_secondary_index": [{"key_schema": true, "non_key_attributes": [false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}], "global_table_witness": true, "id": true, "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{"recovery_period_in_days": true}], "read_capacity": true, "replica": [], "server_side_encryption": [{"kms_key_arn": true}], "stream_arn": true, "stream_label": true, "stream_view_type": true, "tags": {}, "tags_all": {}, "ttl": [{}], "warm_throughput": true, "write_capacity": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "reps", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_dynamodb_table"} {"address": "module.dynamodb.aws_dynamodb_table.usage_records", "change": {"actions": ["create"], "after": {"attribute": [{"name": "created_at", "type": "S"}, {"name": "tenant", "type": "S"}, {"name": "tenant_correlation_id", "type": "S"}, {"name": "tenant_run_id", "type": "S"}, {"name": "usage_id", "type": "S"}], "billing_mode": "PAY_PER_REQUEST", "deletion_protection_enabled": null, "global_secondary_index": [{"hash_key": "tenant", "name": "gsi_tenant", "non_key_attributes": ["tenant", "usage_id"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}, {"hash_key": "tenant_correlation_id", "name": "gsi_correlation", "non_key_attributes": ["correlation_id", "run_id", "tenant", "usage_id"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}, {"hash_key": "tenant_run_id", "name": "gsi_run", "non_key_attributes": ["correlation_id", "run_id", "tenant", "usage_id"], "on_demand_throughput": [], "projection_type": "INCLUDE", "range_key": "created_at"}], "hash_key": "usage_id", "import_table": [], "local_secondary_index": [], "name": "crm-agent-evalusage_records", "on_demand_throughput": [], "point_in_time_recovery": [{"enabled": true}], "range_key": null, "region": "us-east-1", "replica": [], "restore_backup_arn": null, "restore_date_time": null, "restore_source_name": null, "restore_source_table_arn": null, "restore_to_latest_time": null, "server_side_encryption": [{"enabled": true}], "stream_enabled": null, "table_class": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {"attribute": [{}, {}, {}, {}, {}], "global_secondary_index": [{"key_schema": [], "non_key_attributes": [false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}, {"key_schema": [], "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "warm_throughput": []}], "global_table_witness": [], "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{}], "replica": [], "server_side_encryption": [{}], "tags": {}, "tags_all": {}, "ttl": [], "warm_throughput": []}, "after_unknown": {"arn": true, "attribute": [{}, {}, {}, {}, {}], "global_secondary_index": [{"key_schema": true, "non_key_attributes": [false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}, {"key_schema": true, "non_key_attributes": [false, false, false, false], "on_demand_throughput": [], "read_capacity": true, "warm_throughput": true, "write_capacity": true}], "global_table_witness": true, "id": true, "import_table": [], "local_secondary_index": [], "on_demand_throughput": [], "point_in_time_recovery": [{"recovery_period_in_days": true}], "read_capacity": true, "replica": [], "server_side_encryption": [{"kms_key_arn": true}], "stream_arn": true, "stream_label": true, "stream_view_type": true, "tags": {}, "tags_all": {}, "ttl": true, "warm_throughput": true, "write_capacity": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "usage_records", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_dynamodb_table"} {"address": "module.dynamodb.aws_kms_alias.dynamodb", "change": {"actions": ["create"], "after": {"name": "alias/crm-agent-evaldynamodb", "region": "us-east-1"}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {}, "after_unknown": {"arn": true, "id": true, "name_prefix": true, "target_key_arn": true, "target_key_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_alias"} {"address": "module.dynamodb.aws_kms_key.dynamodb", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "custom_key_store_id": null, "customer_master_key_spec": "SYMMETRIC_DEFAULT", "deletion_window_in_days": 30, "description": "CMK for CRM DynamoDB table encryption at rest", "enable_key_rotation": true, "is_enabled": true, "key_usage": "ENCRYPT_DECRYPT", "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "xks_key_id": null}, "after_identity": {"account_id": null, "id": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "id": true, "key_id": true, "multi_region": true, "policy": true, "rotation_period_in_days": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.dynamodb", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key"} @@ -311,7 +313,7 @@ {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-approve_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-approve_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"approve_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-approve_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"approve_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/approve_proposal.zip", "function_name": "crm-agent-eval-approve_proposal", "handler": "crm.handlers.approve_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LpYD+DGtYorjRcUNTELq9RqGEbr9S9DTOxcn7rSBi40=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"approve_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/approve_proposal.zip", "function_name": "crm-agent-eval-approve_proposal", "handler": "crm.handlers.approve_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "wnV2NYKZJZKVYiDhhN3hu46iAkzWHugZ67TM18JGgJE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"approve_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-approve_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"approve_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_account\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_account\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_account\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -325,7 +327,7 @@ {"address": "module.lambda_action[\"create_account\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_account-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_account\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_account-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_account\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_account-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_account.zip", "function_name": "crm-agent-eval-create_account", "handler": "crm.handlers.create_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "8awmYIQBmv4iAd4QoSQQQJktla7zJ5QsOXzOhl/xDjg=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_account.zip", "function_name": "crm-agent-eval-create_account", "handler": "crm.handlers.create_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "G9+SpqREFqZ/Njs4iJrm6iUtvGVky2TZrKT0rnTST18=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_account\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_account", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_account\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_contact\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_contact\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_contact\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords2"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -339,7 +341,7 @@ {"address": "module.lambda_action[\"create_contact\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_contact-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_contact\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_contact-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_contact\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_contact-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_contact.zip", "function_name": "crm-agent-eval-create_contact", "handler": "crm.handlers.create_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "rhL97htT2Wm0nHX6MuZLjcbKWyUEW5oul86dxcM2tzo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_contact.zip", "function_name": "crm-agent-eval-create_contact", "handler": "crm.handlers.create_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "u7KTCFRU2s+9eB523kWTSS4cZ6IWwF8+Q24efvtD5m8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_contact\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_contact", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_contact\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_note\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_note\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_note\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities1"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords2"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_note\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -353,7 +355,7 @@ {"address": "module.lambda_action[\"create_note\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_note-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_note\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_note-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_note\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_note-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_note\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_note.zip", "function_name": "crm-agent-eval-create_note", "handler": "crm.handlers.create_note.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "tLhuF6wRhyqdW+/iohwNT+wFqYPqbIXMCkGrC/1mzrg=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_note\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_note.zip", "function_name": "crm-agent-eval-create_note", "handler": "crm.handlers.create_note.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "wnV2NYKZJZKVYiDhhN3hu46iAkzWHugZ67TM18JGgJE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_note\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_note", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_note\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_opportunity\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"create_opportunity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords3"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords3"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -367,7 +369,7 @@ {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_opportunity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-create_opportunity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"create_opportunity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-create_opportunity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"create_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_opportunity.zip", "function_name": "crm-agent-eval-create_opportunity", "handler": "crm.handlers.create_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "rhL97htT2Wm0nHX6MuZLjcbKWyUEW5oul86dxcM2tzo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"create_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/create_opportunity.zip", "function_name": "crm-agent-eval-create_opportunity", "handler": "crm.handlers.create_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "u7KTCFRU2s+9eB523kWTSS4cZ6IWwF8+Q24efvtD5m8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"create_opportunity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-create_opportunity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"create_opportunity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"draft_message\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"draft_message\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"draft_message\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"draft_message\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -381,7 +383,7 @@ {"address": "module.lambda_action[\"draft_message\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-draft_message-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"draft_message\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-draft_message-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"draft_message\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-draft_message-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"draft_message\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/draft_message.zip", "function_name": "crm-agent-eval-draft_message", "handler": "crm.handlers.draft_message.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "8awmYIQBmv4iAd4QoSQQQJktla7zJ5QsOXzOhl/xDjg=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"draft_message\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/draft_message.zip", "function_name": "crm-agent-eval-draft_message", "handler": "crm.handlers.draft_message.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "G9+SpqREFqZ/Njs4iJrm6iUtvGVky2TZrKT0rnTST18=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"draft_message\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-draft_message", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"draft_message\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_account\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_account\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_account\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbContacts1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -395,7 +397,7 @@ {"address": "module.lambda_action[\"get_account\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_account-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_account\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_account-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_account\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_account-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_account.zip", "function_name": "crm-agent-eval-get_account", "handler": "crm.handlers.get_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "9G22VJcMiGOsgM4iPUP1jo73vD7oB6N3s72S64v46Yc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_account.zip", "function_name": "crm-agent-eval-get_account", "handler": "crm.handlers.get_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "XFSa3zMyS3q0FYKL5tKQQPry9Gyypv6Uq/h0Jn2nF9s=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_account\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_account", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_account\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_audit_record\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_audit_record\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -409,7 +411,7 @@ {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_audit_record-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_audit_record-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_audit_record\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_audit_record-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_audit_record.zip", "function_name": "crm-agent-eval-get_audit_record", "handler": "crm.handlers.get_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "rIWVSzEVFAeL7cXJBaXD2ahxknUx1fSFTOStTKzEG7g=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_audit_record.zip", "function_name": "crm-agent-eval-get_audit_record", "handler": "crm.handlers.get_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "G9+SpqREFqZ/Njs4iJrm6iUtvGVky2TZrKT0rnTST18=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_audit_record\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_audit_record", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_audit_record\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_contact\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_contact\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_contact\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -423,7 +425,7 @@ {"address": "module.lambda_action[\"get_contact\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_contact-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_contact\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_contact-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_contact\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_contact-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_contact.zip", "function_name": "crm-agent-eval-get_contact", "handler": "crm.handlers.get_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "9G22VJcMiGOsgM4iPUP1jo73vD7oB6N3s72S64v46Yc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_contact.zip", "function_name": "crm-agent-eval-get_contact", "handler": "crm.handlers.get_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "m8RDtZ8Fqh7QHDNnMIxiGsix3xuI9ELDUDn5Ww+w5hQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_contact\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_contact", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_contact\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_opportunity\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_opportunity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null], "sid": "DynamoDbActivities1"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbNotes2"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbContacts3"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts3"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -437,7 +439,7 @@ {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_opportunity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_opportunity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_opportunity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_opportunity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_opportunity.zip", "function_name": "crm-agent-eval-get_opportunity", "handler": "crm.handlers.get_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "9G22VJcMiGOsgM4iPUP1jo73vD7oB6N3s72S64v46Yc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_opportunity.zip", "function_name": "crm-agent-eval-get_opportunity", "handler": "crm.handlers.get_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "WuLCcG5KDA3nKD3gqoD4R8JasodjHhuhkYj4Bi3eK/8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_opportunity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_opportunity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_opportunity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_page_context\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities2"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities3"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities3"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"get_page_context\"].data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -449,7 +451,7 @@ {"address": "module.lambda_action[\"get_page_context\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_page_context-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_page_context\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-get_page_context-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"get_page_context\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-get_page_context-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"get_page_context\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_page_context.zip", "function_name": "crm-agent-eval-get_page_context", "handler": "crm.handlers.get_page_context.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "9Rj+TwGJ39xWAV94o3vg8pqeSYktm04Eoq917h5/oic=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"get_page_context\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/get_page_context.zip", "function_name": "crm-agent-eval-get_page_context", "handler": "crm.handlers.get_page_context.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "hOgdaZNZtlKAqEyKlP2KYT41NfR2NcOahqADrUABelc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"get_page_context\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-get_page_context", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"get_page_context\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_activities\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_activities\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_activities\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null], "sid": "DynamoDbActivities1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_activities\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -463,7 +465,7 @@ {"address": "module.lambda_action[\"list_activities\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_activities-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_activities\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_activities-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_activities\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-list_activities-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"list_activities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_activities.zip", "function_name": "crm-agent-eval-list_activities", "handler": "crm.handlers.list_activities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "9G22VJcMiGOsgM4iPUP1jo73vD7oB6N3s72S64v46Yc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"list_activities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_activities.zip", "function_name": "crm-agent-eval-list_activities", "handler": "crm.handlers.list_activities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "m8RDtZ8Fqh7QHDNnMIxiGsix3xuI9ELDUDn5Ww+w5hQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"list_activities\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-list_activities", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_activities\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_audit_records\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_audit_records\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null], "sid": "DynamoDbAuditrecords0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -477,7 +479,7 @@ {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_audit_records-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_audit_records-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_audit_records\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-list_audit_records-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"list_audit_records\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_audit_records.zip", "function_name": "crm-agent-eval-list_audit_records", "handler": "crm.handlers.list_audit_records.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "rIWVSzEVFAeL7cXJBaXD2ahxknUx1fSFTOStTKzEG7g=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"list_audit_records\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_audit_records.zip", "function_name": "crm-agent-eval-list_audit_records", "handler": "crm.handlers.list_audit_records.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "G9+SpqREFqZ/Njs4iJrm6iUtvGVky2TZrKT0rnTST18=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"list_audit_records\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-list_audit_records", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_audit_records\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_proposals\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"list_proposals\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:BatchGetItem", "dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -491,7 +493,7 @@ {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_proposals-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-list_proposals-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"list_proposals\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-list_proposals-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"list_proposals\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_proposals.zip", "function_name": "crm-agent-eval-list_proposals", "handler": "crm.handlers.list_proposals.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "rIWVSzEVFAeL7cXJBaXD2ahxknUx1fSFTOStTKzEG7g=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"list_proposals\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/list_proposals.zip", "function_name": "crm-agent-eval-list_proposals", "handler": "crm.handlers.list_proposals.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "m8RDtZ8Fqh7QHDNnMIxiGsix3xuI9ELDUDn5Ww+w5hQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"list_proposals\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-list_proposals", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"list_proposals\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"log_activity\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"log_activity\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"log_activity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities0"}, {"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities1"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords2"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"log_activity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -505,7 +507,7 @@ {"address": "module.lambda_action[\"log_activity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-log_activity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"log_activity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-log_activity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"log_activity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-log_activity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"log_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/log_activity.zip", "function_name": "crm-agent-eval-log_activity", "handler": "crm.handlers.log_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "tLhuF6wRhyqdW+/iohwNT+wFqYPqbIXMCkGrC/1mzrg=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"log_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/log_activity.zip", "function_name": "crm-agent-eval-log_activity", "handler": "crm.handlers.log_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "c3XgZPFH7DMs8354g8FgdxSmHg2MjHgSDNOkfIOk/Lg=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"log_activity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-log_activity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"log_activity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"pipeline_aggregate\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"pipeline_aggregate\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:BatchGetItem", "dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -519,7 +521,7 @@ {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pipeline_aggregate-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pipeline_aggregate-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-pipeline_aggregate-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"pipeline_aggregate\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pipeline_aggregate.zip", "function_name": "crm-agent-eval-pipeline_aggregate", "handler": "crm.handlers.pipeline_aggregate.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "UsJdYskmsh+QqP8Iax8TOWUs1qbdRJhnkGSBCc+JrDA=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"pipeline_aggregate\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pipeline_aggregate.zip", "function_name": "crm-agent-eval-pipeline_aggregate", "handler": "crm.handlers.pipeline_aggregate.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "m8RDtZ8Fqh7QHDNnMIxiGsix3xuI9ELDUDn5Ww+w5hQ=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"pipeline_aggregate\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-pipeline_aggregate", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"pipeline_aggregate\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"rebase_proposal\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"rebase_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords5"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords5"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -533,7 +535,7 @@ {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-rebase_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-rebase_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-rebase_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"rebase_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/rebase_proposal.zip", "function_name": "crm-agent-eval-rebase_proposal", "handler": "crm.handlers.rebase_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LpYD+DGtYorjRcUNTELq9RqGEbr9S9DTOxcn7rSBi40=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"rebase_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/rebase_proposal.zip", "function_name": "crm-agent-eval-rebase_proposal", "handler": "crm.handlers.rebase_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "hOgdaZNZtlKAqEyKlP2KYT41NfR2NcOahqADrUABelc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"rebase_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-rebase_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"rebase_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"reject_proposal\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"reject_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -547,7 +549,7 @@ {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-reject_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-reject_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"reject_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-reject_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"reject_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/reject_proposal.zip", "function_name": "crm-agent-eval-reject_proposal", "handler": "crm.handlers.reject_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LpYD+DGtYorjRcUNTELq9RqGEbr9S9DTOxcn7rSBi40=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"reject_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/reject_proposal.zip", "function_name": "crm-agent-eval-reject_proposal", "handler": "crm.handlers.reject_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "hOgdaZNZtlKAqEyKlP2KYT41NfR2NcOahqADrUABelc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"reject_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-reject_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"reject_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"revert_audit_record\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"revert_audit_record\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords0"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts5"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities6"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "DynamoDbActivities7"}, {"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes8"}, {"actions": ["dynamodb:DeleteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes9"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes5"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -561,7 +563,7 @@ {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-revert_audit_record-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-revert_audit_record-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-revert_audit_record-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"revert_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/revert_audit_record.zip", "function_name": "crm-agent-eval-revert_audit_record", "handler": "crm.handlers.revert_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "bZe8IPeIYiyyQQ5YWGKidzstaYSuT8hEgKHhp6TRKo8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"revert_audit_record\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/revert_audit_record.zip", "function_name": "crm-agent-eval-revert_audit_record", "handler": "crm.handlers.revert_audit_record.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "hOgdaZNZtlKAqEyKlP2KYT41NfR2NcOahqADrUABelc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"revert_audit_record\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-revert_audit_record", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"revert_audit_record\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_accounts\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_accounts\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -575,7 +577,7 @@ {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_accounts-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_accounts-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_accounts\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-search_accounts-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"search_accounts\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/search_accounts.zip", "function_name": "crm-agent-eval-search_accounts", "handler": "crm.handlers.search_accounts.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "QE9WmAJOVl6QAsPV+ciQFfIYYNSovqHyNuhl+ZUE2r8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"search_accounts\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/search_accounts.zip", "function_name": "crm-agent-eval-search_accounts", "handler": "crm.handlers.search_accounts.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "WuLCcG5KDA3nKD3gqoD4R8JasodjHhuhkYj4Bi3eK/8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"search_accounts\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-search_accounts", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"search_accounts\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_opportunities\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"search_opportunities\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -589,7 +591,7 @@ {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_opportunities-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-search_opportunities-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"search_opportunities\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-search_opportunities-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"search_opportunities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/search_opportunities.zip", "function_name": "crm-agent-eval-search_opportunities", "handler": "crm.handlers.search_opportunities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "QE9WmAJOVl6QAsPV+ciQFfIYYNSovqHyNuhl+ZUE2r8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"search_opportunities\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/search_opportunities.zip", "function_name": "crm-agent-eval-search_opportunities", "handler": "crm.handlers.search_opportunities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 40, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "WuLCcG5KDA3nKD3gqoD4R8JasodjHhuhkYj4Bi3eK/8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"search_opportunities\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-search_opportunities", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"search_opportunities\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"submit_proposal\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"submit_proposal\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals0"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts1"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts2"}, {"actions": ["dynamodb:GetItem", "dynamodb:Query"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null], "sid": "DynamoDbOpportunities3"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities4"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities4"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -603,7 +605,7 @@ {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-submit_proposal-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-submit_proposal-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"submit_proposal\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-submit_proposal-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"submit_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/submit_proposal.zip", "function_name": "crm-agent-eval-submit_proposal", "handler": "crm.handlers.submit_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "LpYD+DGtYorjRcUNTELq9RqGEbr9S9DTOxcn7rSBi40=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"submit_proposal\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/submit_proposal.zip", "function_name": "crm-agent-eval-submit_proposal", "handler": "crm.handlers.submit_proposal.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "wnV2NYKZJZKVYiDhhN3hu46iAkzWHugZ67TM18JGgJE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"submit_proposal\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-submit_proposal", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"submit_proposal\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_account\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_account\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_account\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_account\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -617,7 +619,7 @@ {"address": "module.lambda_action[\"update_account\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_account-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_account\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_account-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_account\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_account-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_account.zip", "function_name": "crm-agent-eval-update_account", "handler": "crm.handlers.update_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "8awmYIQBmv4iAd4QoSQQQJktla7zJ5QsOXzOhl/xDjg=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_account\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_account.zip", "function_name": "crm-agent-eval-update_account", "handler": "crm.handlers.update_account.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "G9+SpqREFqZ/Njs4iJrm6iUtvGVky2TZrKT0rnTST18=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_account\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_account", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_account\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_activity\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_activity\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_activity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_activity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -631,7 +633,7 @@ {"address": "module.lambda_action[\"update_activity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_activity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_activity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_activity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_activity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_activity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_activity.zip", "function_name": "crm-agent-eval-update_activity", "handler": "crm.handlers.update_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "tLhuF6wRhyqdW+/iohwNT+wFqYPqbIXMCkGrC/1mzrg=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_activity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_activity.zip", "function_name": "crm-agent-eval-update_activity", "handler": "crm.handlers.update_activity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "wnV2NYKZJZKVYiDhhN3hu46iAkzWHugZ67TM18JGgJE=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_activity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_activity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_activity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_contact\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_contact\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_contact\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_contact\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -645,7 +647,7 @@ {"address": "module.lambda_action[\"update_contact\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_contact-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_contact\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_contact-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_contact\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_contact-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_contact.zip", "function_name": "crm-agent-eval-update_contact", "handler": "crm.handlers.update_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "rhL97htT2Wm0nHX6MuZLjcbKWyUEW5oul86dxcM2tzo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_contact\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_contact.zip", "function_name": "crm-agent-eval-update_contact", "handler": "crm.handlers.update_contact.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "u7KTCFRU2s+9eB523kWTSS4cZ6IWwF8+Q24efvtD5m8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_contact\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_contact", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_contact\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_opportunity\"].data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action[\"update_opportunity\"].data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities0"}, {"actions": ["dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords1"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -659,7 +661,7 @@ {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_opportunity-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-update_opportunity-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action[\"update_opportunity\"].aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-update_opportunity-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action[\"update_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_opportunity.zip", "function_name": "crm-agent-eval-update_opportunity", "handler": "crm.handlers.update_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "rhL97htT2Wm0nHX6MuZLjcbKWyUEW5oul86dxcM2tzo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action[\"update_opportunity\"].aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/update_opportunity.zip", "function_name": "crm-agent-eval-update_opportunity", "handler": "crm.handlers.update_opportunity.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "u7KTCFRU2s+9eB523kWTSS4cZ6IWwF8+Q24efvtD5m8=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action[\"update_opportunity\"].aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-update_opportunity", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action[\"update_opportunity\"]", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_capabilities.data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_capabilities", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_capabilities.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_capabilities", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -671,7 +673,7 @@ {"address": "module.lambda_action_capabilities.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-capabilities-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_capabilities.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-capabilities-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_capabilities.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-capabilities-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_capabilities.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-capabilities", "handler": "crm.handlers.capabilities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 10, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "1lcHiyt5k7zCwP5rWmD1sZL0GGDuwg7SN7OTVc2fKJo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_capabilities.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-capabilities", "handler": "crm.handlers.capabilities.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 10, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "6BrP5yZ6Wl8qULcaupkTzU77LsG2blKAdSKkDPOfRNU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_capabilities", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_interceptor.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["svc-mcp-gateway"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_interceptor", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_interceptor.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_interceptor", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_interceptor.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_chat_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -682,7 +684,7 @@ {"address": "module.lambda_action_chat_interceptor.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-identity-interceptor-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_interceptor.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-identity-interceptor-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_interceptor.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-chat-identity-interceptor-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_chat_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-chat-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "JkDuAPuPZknWRl7NpMs/xBp5HO9GbCDJ9rafwHGYElc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_chat_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-chat-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "2R7DHiX7bkRO1YJxpc4tf9y/Cu86Eq4n4VrwFGf3/TU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_chat_interceptor.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-chat-identity-interceptor", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_chat_interceptor", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_target.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["usersettings#*", "conversation#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:PutItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["conversation#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps1"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_target", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_chat_target.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_chat_target", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -694,7 +696,7 @@ {"address": "module.lambda_action_chat_target.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-target-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_target.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-chat-target-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_chat_target.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-chat-target-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_chat_target.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/chat_target.zip", "function_name": "crm-agent-eval-chat-target", "handler": "gateway.chat_target.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "aRRm4AOd5uG9ulA+19aBx5z5so1w/uEYzBzZ/rosAIo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_chat_target.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/chat_target.zip", "function_name": "crm-agent-eval-chat-target", "handler": "gateway.chat_target.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "3Lyxeb3gW3Od/fatD92fY7H0fErjpru4zCBt4sj56uY=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 660, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_chat_target.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-chat-target", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_chat_target", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_eval_trigger.data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_eval_trigger", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_eval_trigger.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:BatchGetItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["job#*", "lock#sweep", "livequota#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns0"}, {"actions": ["dynamodb:DeleteItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["lock#sweep"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns1"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["job"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns2"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalruns0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false, false], "condition": [{"values": [false, false, false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_eval_trigger", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -708,7 +710,7 @@ {"address": "module.lambda_action_eval_trigger.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-eval-trigger-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_eval_trigger.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-eval-trigger-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_eval_trigger.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-eval-trigger-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_eval_trigger.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-eval-trigger", "handler": "crm.handlers.eval_trigger.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "1lcHiyt5k7zCwP5rWmD1sZL0GGDuwg7SN7OTVc2fKJo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_eval_trigger.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-eval-trigger", "handler": "crm.handlers.eval_trigger.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 512, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "6BrP5yZ6Wl8qULcaupkTzU77LsG2blKAdSKkDPOfRNU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 30, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_eval_trigger", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_interceptor.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["svc-mcp-gateway"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_interceptor", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_interceptor.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_interceptor", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_interceptor.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -719,7 +721,7 @@ {"address": "module.lambda_action_interceptor.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-identity-interceptor-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_interceptor.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-identity-interceptor-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_interceptor.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-identity-interceptor-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "JkDuAPuPZknWRl7NpMs/xBp5HO9GbCDJ9rafwHGYElc=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_interceptor.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/identity_interceptor.zip", "function_name": "crm-agent-eval-identity-interceptor", "handler": "gateway.identity_interceptor.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "2R7DHiX7bkRO1YJxpc4tf9y/Cu86Eq4n4VrwFGf3/TU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_interceptor.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-identity-interceptor", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_interceptor", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_pre_token_generation.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_pre_token_generation", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_pre_token_generation.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_pre_token_generation", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -731,7 +733,7 @@ {"address": "module.lambda_action_pre_token_generation.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pre-token-generation-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_pre_token_generation.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-pre-token-generation-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_pre_token_generation.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-pre-token-generation-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_pre_token_generation.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CHAT_SCOPE": "supervisor/chat", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pre_token_generation.zip", "function_name": "crm-agent-eval-pre-token-generation", "handler": "crm.auth.pre_token_generation.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 128, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "sQ3sHWmi5hOL6+lziz32S0qfNIa/UaeHc1X3DjxY+gM=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_pre_token_generation.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CHAT_SCOPE": "supervisor/chat", "CRM_TABLE_PREFIX": "crm-agent-eval"}}], "file_system_config": [], "filename": "build/lambda/pre_token_generation.zip", "function_name": "crm-agent-eval-pre-token-generation", "handler": "crm.auth.pre_token_generation.lambda_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 128, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 20, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "FFDUVK34+D9545tnvO2xd6MZM13zQ3Xg0onRTuPZg/w=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"address": "module.lambda_action_pre_token_generation.aws_lambda_permission.gateway_target_role[0]", "change": {"actions": ["create"], "after": {"action": "lambda:InvokeFunction", "event_source_token": null, "function_name": "crm-agent-eval-pre-token-generation", "function_url_auth_type": null, "invoked_via_function_url": null, "principal_org_id": null, "qualifier": null, "region": "us-east-1", "source_account": null, "source_arn": null, "statement_id": "AllowGatewayTargetRoleInvoke", "timeouts": null}, "after_identity": {"account_id": null, "function_name": null, "qualifier": null, "region": null, "statement_id": null}, "after_sensitive": {}, "after_unknown": {"id": true, "principal": true, "statement_id_prefix": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_pre_token_generation", "name": "gateway_target_role", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_permission"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_control.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["job#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns0"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["????????????????????????????????"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns1"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals10"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps11"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbUsagerecords12"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAccounts13"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbContacts14"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbOpportunities15"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbActivities16"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbNotes17"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAuditrecords18"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbProposals19"}, {"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["lock#sweep"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns2"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbReps20"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*", "canary"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbUsagerecords21"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAccounts22"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbContacts23"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbOpportunities24"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbActivities25"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbNotes26"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbAuditrecords27"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbProposals28"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbReps29"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalresults3"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringEquals", "values": ["demo"], "variable": "dynamodb:LeadingKeys"}, {"test": "StringEquals", "values": ["COUNT"], "variable": "dynamodb:Select"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "sid": "DynamoDbUsagerecords30"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts4"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts5"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities6"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities7"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes8"}, {"actions": ["dynamodb:BatchWriteItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAuditrecords9"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalruns0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalresults1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedUsagerecords10"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities5"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes6"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAuditrecords7"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals8"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps9"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": []}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": true}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_control.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -748,7 +750,7 @@ {"address": "module.lambda_action_sweep_control.aws_iam_role_policy_attachment.dynamodb_allow[1]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-control-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 1, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb_allow", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_control.aws_iam_role_policy_attachment.dynamodb_deny[0]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-control-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "dynamodb_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_control.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-control-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_sweep_control.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-control", "handler": "eval.sfn_handlers.sweep_control_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 2, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "1lcHiyt5k7zCwP5rWmD1sZL0GGDuwg7SN7OTVc2fKJo=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 120, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_sweep_control.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-control", "handler": "eval.sfn_handlers.sweep_control_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 2, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "6BrP5yZ6Wl8qULcaupkTzU77LsG2blKAdSKkDPOfRNU=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 120, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_control", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_task.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:GetItem", "dynamodb:UpdateItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["job#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalruns0"}, {"actions": ["dynamodb:GetItem", "dynamodb:PutItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbEvalresults1"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities10"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities11"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes12"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["acct-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts2"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["cont-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts3"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["opp-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbOpportunities4"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["act-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbActivities5"}, {"actions": ["dynamodb:GetItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["note-eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbNotes6"}, {"actions": ["dynamodb:GetItem"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbProposals7"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbAccounts8"}, {"actions": ["dynamodb:Query"], "condition": [{"test": "ForAllValues:StringLike", "values": ["eval-*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbContacts9"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalruns0"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedEvalresults1"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedAccounts2"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedContacts3"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedOpportunities4"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedActivities5"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedNotes6"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedProposals7"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}, {"actions": [false, false, false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_task.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_sweep_task.data.aws_iam_policy_document.logs", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["logs:CreateLogStream", "logs:PutLogEvents"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "WriteOwnLogGroup"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.lambda_action_sweep_task", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -762,7 +764,7 @@ {"address": "module.lambda_action_sweep_task.aws_iam_role_policy_attachment.dynamodb_allow[0]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-task-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb_allow", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_task.aws_iam_role_policy_attachment.dynamodb_deny[0]", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-task-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "index": 0, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "dynamodb_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} {"address": "module.lambda_action_sweep_task.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-sweep-task-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_sweep_task.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-task", "handler": "eval.sfn_handlers.sweep_task_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 1, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "1lcHiyt5k7zCwP5rWmD1sZL0GGDuwg7SN7OTVc2fKJo=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 300, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_sweep_task.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-sweep-task", "handler": "eval.sfn_handlers.sweep_task_handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 1024, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 1, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "6BrP5yZ6Wl8qULcaupkTzU77LsG2blKAdSKkDPOfRNU=", "source_kms_key_arn": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 300, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": true}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags": {}, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_sweep_task", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_user_settings.data.aws_iam_policy_document.config_parameter_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt"], "condition": [{"test": "StringEquals", "values": ["arn:aws:ssm:us-east-1:123456789012:parameter/crm-agent-eval/api/allowed-client-ids"], "variable": "kms:EncryptionContext:PARAMETER_ARN"}, {"test": "StringEquals", "values": ["ssm.us-east-1.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptConfigParameters"}, {"actions": ["kms:Decrypt"], "condition": [{"test": "StringLike", "values": ["ssm.*.amazonaws.com"], "variable": "kms:ViaService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": [null], "principals": [], "resources": null, "sid": "DenyConfigParameterDecryptUnderOtherKeys"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [false], "principals": []}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "not_resources": [true], "principals": []}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_user_settings", "name": "config_parameter_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_user_settings.data.aws_iam_policy_document.dynamodb[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem"], "condition": [{"test": "ForAllValues:StringLike", "values": ["usersettings#*"], "variable": "dynamodb:LeadingKeys"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DynamoDbReps0"}, {"actions": ["dynamodb:*"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], "sid": "ExplicitDenyCrossFunctionIsolation"}, {"actions": ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:Query", "dynamodb:UpdateItem"], "condition": [], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null, null], "sid": "ExplicitDenyNonGrantedReps0"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]}, {"actions": [false, false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_user_settings", "name": "dynamodb", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.lambda_action_user_settings.data.aws_iam_policy_document.dynamodb_kms[0]", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "DecryptDynamoDbTableKey"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false, false, false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "index": 0, "mode": "data", "module_address": "module.lambda_action_user_settings", "name": "dynamodb_kms", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} @@ -775,7 +777,7 @@ {"address": "module.lambda_action_user_settings.aws_iam_role_policy.logs", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-user-settings-logs"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "policy": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_user_settings.aws_iam_role_policy.vpc_access", "change": {"actions": ["create"], "after": {"name": "crm-agent-eval-user-settings-vpc-access", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"ec2:UnassignPrivateIpAddresses\",\"ec2:DescribeSubnets\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:CreateNetworkInterface\",\"ec2:AssignPrivateIpAddresses\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"ManageOwnHyperplaneEnis\"},{\"Action\":[\"xray:PutTraceSegments\",\"xray:PutTelemetryRecords\"],\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"WriteXRayTraceSegments\"}]}"}, "after_identity": {"account_id": null, "name": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "name_prefix": true, "role": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "vpc_access", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy"} {"address": "module.lambda_action_user_settings.aws_iam_role_policy_attachment.eni_function_code_deny", "change": {"actions": ["create"], "after": {"role": "crm-agent-eval-user-settings-role"}, "after_identity": {"account_id": null, "policy_arn": null, "role": null}, "after_sensitive": {}, "after_unknown": {"id": true, "policy_arn": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "eni_function_code_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_role_policy_attachment"} -{"address": "module.lambda_action_user_settings.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval", "PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-user-settings", "handler": "crm.handlers.user_settings.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.13", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "1lcHiyt5k7zCwP5rWmD1sZL0GGDuwg7SN7OTVc2fKJo=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} +{"address": "module.lambda_action_user_settings.aws_lambda_function.this", "change": {"actions": ["create"], "after": {"capacity_provider_config": [], "code_signing_config_arn": null, "dead_letter_config": [], "description": null, "durable_config": [], "environment": [{"variables": {"CRM_API_ALLOWED_CLIENT_IDS_PARAMETER": "/crm-agent-eval/api/allowed-client-ids", "CRM_TABLE_PREFIX": "crm-agent-eval", "PYTHONPATH": "/var/task/src"}}], "file_system_config": [], "filename": "build/lambda/eval_trigger.zip", "function_name": "crm-agent-eval-user-settings", "handler": "crm.handlers.user_settings.handler", "image_config": [], "image_uri": null, "layers": null, "memory_size": 256, "package_type": "Zip", "publish": false, "publish_to": null, "region": "us-east-1", "replace_security_groups_on_destroy": null, "replacement_security_group_ids": null, "reserved_concurrent_executions": 5, "runtime": "python3.14", "s3_bucket": null, "s3_key": null, "s3_object_version": null, "skip_destroy": false, "snap_start": [], "source_code_hash": "6BrP5yZ6Wl8qULcaupkTzU77LsG2blKAdSKkDPOfRNU=", "source_kms_key_arn": null, "tags": null, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "tenancy_config": [], "timeout": 10, "timeouts": null, "tracing_config": [{"mode": "Active"}], "use_resource_timeout_for_propagation": null, "vpc_config": [{"ipv6_allowed_for_dual_stack": false, "subnet_ids": ["subnet-privateoneplaceholder", "subnet-privatetwoplaceholder"]}]}, "after_identity": {"account_id": null, "function_name": null, "region": null}, "after_sensitive": {"architectures": [], "capacity_provider_config": [], "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": [], "file_system_config": [], "image_config": [], "logging_config": [], "snap_start": [], "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "vpc_config": [{"security_group_ids": [], "subnet_ids": [false, false]}]}, "after_unknown": {"architectures": true, "arn": true, "capacity_provider_config": [], "code_sha256": true, "dead_letter_config": [], "durable_config": [], "environment": [{"variables": {}}], "ephemeral_storage": true, "file_system_config": [], "id": true, "image_config": [], "invoke_arn": true, "kms_key_arn": true, "last_modified": true, "logging_config": true, "qualified_arn": true, "qualified_invoke_arn": true, "response_streaming_invoke_arn": true, "role": true, "signing_job_arn": true, "signing_profile_version_arn": true, "snap_start": [], "source_code_size": true, "tags_all": {}, "tenancy_config": [], "tracing_config": [{}], "version": true, "vpc_config": [{"security_group_ids": true, "subnet_ids": [false, false], "vpc_id": true}]}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.lambda_action_user_settings", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_lambda_function"} {"action_reason": "read_because_config_unknown", "address": "module.mcp_chat_gateway.data.aws_iam_policy_document.gateway_permissions", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "InvokeChatTarget"}, {"actions": ["lambda:InvokeFunction"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [], "resources": [null], "sid": "InvokeInterceptor"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}, {"actions": [false], "condition": [], "not_principals": [], "principals": [], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.mcp_chat_gateway", "name": "gateway_permissions", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"address": "module.mcp_chat_gateway.aws_bedrockagentcore_gateway.this", "change": {"actions": ["create"], "after": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_audience": null, "allowed_clients": [null, null, null], "allowed_scopes": [null], "allowed_workload_configuration": [], "custom_claim": [], "private_endpoint": [], "private_endpoint_overrides": []}]}], "authorizer_type": "CUSTOM_JWT", "description": null, "exception_level": null, "interceptor_configuration": [{"input_configuration": [{"pass_request_headers": true}], "interception_points": ["REQUEST"], "interceptor": [{"lambda": [{}]}]}], "kms_key_arn": null, "name": "crm-agent-eval-chat-gateway", "policy_engine_configuration": [], "protocol_configuration": [{"mcp": [{"instructions": null, "search_type": null, "session_configuration": [], "streaming_configuration": [], "supported_versions": ["2025-03-26", "2025-06-18", "2025-11-25"]}]}], "protocol_type": "MCP", "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null}, "after_sensitive": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_clients": [false, false, false], "allowed_scopes": [false], "allowed_workload_configuration": [], "custom_claim": [], "private_endpoint": [], "private_endpoint_overrides": []}]}], "interceptor_configuration": [{"input_configuration": [{}], "interception_points": [false], "interceptor": [{"lambda": [{}]}]}], "policy_engine_configuration": [], "protocol_configuration": [{"mcp": [{"session_configuration": [], "streaming_configuration": [], "supported_versions": [false, false, false]}]}], "tags": {}, "tags_all": {}, "workload_identity_details": []}, "after_unknown": {"authorizer_configuration": [{"custom_jwt_authorizer": [{"allowed_clients": [true, true, true], "allowed_scopes": [true], "allowed_workload_configuration": [], "custom_claim": [], "discovery_url": true, "private_endpoint": [], "private_endpoint_overrides": []}]}], "gateway_arn": true, "gateway_id": true, "gateway_url": true, "interceptor_configuration": [{"input_configuration": [{}], "interception_points": [false], "interceptor": [{"lambda": [{"arn": true}]}]}], "policy_engine_configuration": [], "protocol_configuration": [{"mcp": [{"session_configuration": [], "streaming_configuration": [], "supported_versions": [false, false, false]}]}], "role_arn": true, "tags": {}, "tags_all": {}, "workload_identity_details": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.mcp_chat_gateway", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway"} {"address": "module.mcp_chat_gateway.aws_bedrockagentcore_gateway_target.chat", "change": {"actions": ["create"], "after": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{"region": null, "service": null}], "jwt_passthrough": [], "oauth": []}], "description": "Gateway target for chat_with_supervisor, backed by the chat_target Lambda.", "metadata_configuration": [], "name": "chat-with-supervisor", "private_endpoint": [], "region": "us-east-1", "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"description": "Send one message to the CRM supervisor agent and receive its answer. Pass the returned conversation_id on later calls to continue the same conversation.", "input_schema": [{"description": null, "items": [], "property": [{"description": "A conversation_id returned by an earlier call; omit to start a new conversation.", "items": [], "name": "conversation_id", "property": [], "required": false, "type": "string"}, {"description": "The message to send, 1 to 8000 characters.", "items": [], "name": "message", "property": [], "required": true, "type": "string"}], "type": "object"}], "name": "chat_with_supervisor", "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "timeouts": null}, "after_sensitive": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}]}, "after_unknown": {"credential_provider_configuration": [{"api_key": [], "caller_iam_credentials": [], "gateway_iam_role": [{}], "jwt_passthrough": [], "oauth": []}], "gateway_identifier": true, "metadata_configuration": [], "private_endpoint": [], "target_configuration": [{"http": [], "inference": [], "mcp": [{"api_gateway": [], "connector": [], "lambda": [{"lambda_arn": true, "tool_schema": [{"inline_payload": [{"input_schema": [{"items": [], "property": [{"items": [], "property": []}, {"items": [], "property": []}]}], "output_schema": []}], "s3": []}]}], "mcp_server": [], "open_api_schema": [], "smithy_model": []}]}], "target_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.mcp_chat_gateway", "name": "chat", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_bedrockagentcore_gateway_target"} @@ -785,7 +787,7 @@ {"action_reason": "read_because_config_unknown", "address": "module.observability.data.aws_iam_policy_document.cloudtrail_access_logs_tls_deny", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["s3:PutObject"], "condition": [{"test": "ArnLike", "values": [null], "variable": "aws:SourceArn"}, {"test": "StringEquals", "values": ["123456789012"], "variable": "aws:SourceAccount"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["logging.s3.amazonaws.com"], "type": "Service"}], "resources": [null], "sid": "AllowS3ServerAccessLogDelivery"}, {"actions": ["s3:*"], "condition": [{"test": "Bool", "values": ["false"], "variable": "aws:SecureTransport"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null, null], "sid": "DenyInsecureTransport"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false, false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [true]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true, true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.observability", "name": "cloudtrail_access_logs_tls_deny", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.observability.data.aws_iam_policy_document.cloudtrail_bucket", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["s3:*"], "condition": [{"test": "Bool", "values": ["false"], "variable": "aws:SecureTransport"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "AWS"}], "resources": [null, null], "sid": "DenyInsecureTransport"}, {"actions": ["s3:GetBucketAcl"], "condition": [{"test": "StringEquals", "values": ["arn:aws:cloudtrail:us-east-1:123456789012:trail/crm-agent-evalcrm-agent-eval-trail"], "variable": "aws:SourceArn"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["cloudtrail.amazonaws.com"], "type": "Service"}], "resources": [null], "sid": "AWSCloudTrailAclCheck"}, {"actions": ["s3:PutObject"], "condition": [{"test": "StringEquals", "values": ["arn:aws:cloudtrail:us-east-1:123456789012:trail/crm-agent-evalcrm-agent-eval-trail"], "variable": "aws:SourceArn"}, {"test": "StringEquals", "values": ["bucket-owner-full-control"], "variable": "s3:x-amz-acl"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["cloudtrail.amazonaws.com"], "type": "Service"}], "resources": [null], "sid": "AWSCloudTrailWrite"}, {"actions": ["s3:AbortMultipartUpload", "s3:DeleteObject", "s3:DeleteObjectTagging", "s3:DeleteObjectVersion", "s3:DeleteObjectVersionTagging", "s3:GetObject", "s3:GetObjectAttributes", "s3:GetObjectTagging", "s3:GetObjectVersion", "s3:GetObjectVersionAttributes", "s3:GetObjectVersionTagging", "s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:ListBucketVersions", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectTagging", "s3:PutObjectVersionTagging", "s3:RestoreObject"], "condition": [{"test": "ArnNotEquals", "values": ["arn:aws:iam::123456789012:role/example-deployer"], "variable": "aws:PrincipalArn"}, {"test": "BoolIfExists", "values": ["false"], "variable": "aws:PrincipalIsAWSService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": [null, null], "sid": "DenyObjectDataPlaneToNonProjectPrincipals"}, {"actions": ["s3:DeleteBucket", "s3:DeleteBucketPolicy", "s3:PutAccelerateConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutBucketAcl", "s3:PutBucketCORS", "s3:PutBucketLogging", "s3:PutBucketNotification", "s3:PutBucketObjectLockConfiguration", "s3:PutBucketOwnershipControls", "s3:PutBucketPolicy", "s3:PutBucketPublicAccessBlock", "s3:PutBucketRequestPayment", "s3:PutBucketTagging", "s3:PutBucketVersioning", "s3:PutBucketWebsite", "s3:PutEncryptionConfiguration", "s3:PutIntelligentTieringConfiguration", "s3:PutInventoryConfiguration", "s3:PutLifecycleConfiguration", "s3:PutMetricsConfiguration", "s3:PutReplicationConfiguration"], "condition": [{"test": "ArnNotEquals", "values": ["arn:aws:iam::123456789012:role/example-deployer", "arn:aws:iam::123456789012:root"], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": [null], "sid": "DenyBucketAdministrationToNonOperators"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false, false]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false, false]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true, true]}, {"actions": [false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true, true]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [true]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.observability", "name": "cloudtrail_bucket", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} {"action_reason": "read_because_config_unknown", "address": "module.observability.data.aws_iam_policy_document.cloudwatch_logs_cmk", "change": {"actions": ["read"], "after": {"override_json": null, "override_policy_documents": null, "policy_id": null, "source_json": null, "source_policy_documents": null, "statement": [{"actions": ["kms:*"], "condition": [], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["arn:aws:iam::123456789012:root"], "type": "AWS"}], "resources": ["*"], "sid": "EnableIAMUserPermissions"}, {"actions": ["kms:Decrypt", "kms:Describe*", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*"], "condition": [{"test": "ArnLike", "values": ["arn:aws:logs:us-east-1:123456789012:log-group:*"], "variable": "kms:EncryptionContext:aws:logs:arn"}], "effect": "Allow", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["logs.us-east-1.amazonaws.com"], "type": "Service"}], "resources": ["*"], "sid": "AllowCloudWatchLogsUseOfTheKey"}, {"actions": ["kms:CreateGrant", "kms:Decrypt", "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*"], "condition": [{"test": "ArnNotEquals", "values": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "arn:aws:iam::123456789012:role/example-deployer"], "variable": "aws:PrincipalArn"}, {"test": "Bool", "values": ["false"], "variable": "aws:PrincipalIsAWSService"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": ["*"], "sid": "DenyKeyUseToNonProjectPrincipals"}, {"actions": ["kms:CreateAlias", "kms:DeleteAlias", "kms:DisableKey", "kms:DisableKeyRotation", "kms:PutKeyPolicy", "kms:RevokeGrant", "kms:ScheduleKeyDeletion", "kms:TagResource", "kms:UntagResource", "kms:UpdateAlias", "kms:UpdateKeyDescription"], "condition": [{"test": "ArnNotEquals", "values": ["arn:aws:iam::123456789012:role/example-deployer", "arn:aws:iam::123456789012:root"], "variable": "aws:PrincipalArn"}], "effect": "Deny", "not_actions": null, "not_principals": [], "not_resources": null, "principals": [{"identifiers": ["*"], "type": "*"}], "resources": ["*"], "sid": "DenyKeyAdministrationToNonOperators"}], "version": null}, "after_sensitive": {"statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false], "condition": [{"values": [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "after_unknown": {"id": true, "json": true, "minified_json": true, "statement": [{"actions": [false], "condition": [], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false], "condition": [{"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false], "condition": [{"values": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false]}, {"values": [false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}, {"actions": [false, false, false, false, false, false, false, false, false, false, false], "condition": [{"values": [false, false]}], "not_principals": [], "principals": [{"identifiers": [false]}], "resources": [false]}]}, "before": null, "before_sensitive": false}, "mode": "data", "module_address": "module.observability", "name": "cloudwatch_logs_cmk", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_iam_policy_document"} -{"address": "module.observability.aws_cloudtrail.this", "change": {"actions": ["create"], "after": {"advanced_event_selector": [], "cloud_watch_logs_group_arn": null, "cloud_watch_logs_role_arn": null, "enable_log_file_validation": true, "enable_logging": true, "event_selector": [{"data_resource": [], "exclude_management_event_sources": null, "include_management_events": true, "read_write_type": "All"}], "include_global_service_events": true, "insight_selector": [], "is_multi_region_trail": true, "is_organization_trail": false, "name": "crm-agent-evalcrm-agent-eval-trail", "region": "us-east-1", "s3_key_prefix": null, "sns_topic_name": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"arn": null}, "after_sensitive": {"advanced_event_selector": [], "event_selector": [{"data_resource": []}], "insight_selector": [], "tags": {}, "tags_all": {}}, "after_unknown": {"advanced_event_selector": [], "arn": true, "event_selector": [{"data_resource": []}], "home_region": true, "id": true, "insight_selector": [], "kms_key_id": true, "s3_bucket_name": true, "sns_topic_arn": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.observability", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudtrail"} +{"address": "module.observability.aws_cloudtrail.this", "change": {"actions": ["create"], "after": {"advanced_event_selector": [], "cloud_watch_logs_group_arn": null, "cloud_watch_logs_role_arn": null, "enable_log_file_validation": true, "enable_logging": true, "event_selector": [{"data_resource": [], "exclude_management_event_sources": null, "include_management_events": true, "read_write_type": "All"}], "include_global_service_events": true, "insight_selector": [], "is_multi_region_trail": true, "is_organization_trail": false, "name": "crm-agent-evalcrm-agent-eval-trail", "region": "us-east-1", "s3_key_prefix": null, "sns_topic_name": null, "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}}, "after_identity": {"arn": null}, "after_sensitive": {"advanced_event_selector": [], "event_selector": [{"data_resource": []}], "insight_selector": [], "tags": {}, "tags_all": {}}, "after_unknown": {"advanced_event_selector": [], "arn": true, "event_selector": [{"data_resource": []}], "home_region": true, "id": true, "insight_selector": [], "kms_key_id": true, "recursive_logging": true, "s3_bucket_name": true, "sns_topic_arn": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.observability", "name": "this", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_cloudtrail"} {"address": "module.observability.aws_kms_alias.cloudtrail", "change": {"actions": ["create"], "after": {"name": "alias/crm-agent-evalcloudtrail", "region": "us-east-1"}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {}, "after_unknown": {"arn": true, "id": true, "name_prefix": true, "target_key_arn": true, "target_key_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.observability", "name": "cloudtrail", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_alias"} {"address": "module.observability.aws_kms_alias.logs", "change": {"actions": ["create"], "after": {"name": "alias/crm-agent-evalcloudwatch-logs", "region": "us-east-1"}, "after_identity": {"account_id": null, "name": null, "region": null}, "after_sensitive": {}, "after_unknown": {"arn": true, "id": true, "name_prefix": true, "target_key_arn": true, "target_key_id": true}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.observability", "name": "logs", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_alias"} {"address": "module.observability.aws_kms_key.cloudtrail", "change": {"actions": ["create"], "after": {"bypass_policy_lockout_safety_check": false, "custom_key_store_id": null, "customer_master_key_spec": "SYMMETRIC_DEFAULT", "deletion_window_in_days": 30, "description": "CMK for CloudTrail S3 log destination encryption at rest", "enable_key_rotation": true, "is_enabled": true, "key_usage": "ENCRYPT_DECRYPT", "policy": "{\"Statement\":[{\"Action\":\"kms:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789012:root\"},\"Resource\":\"*\",\"Sid\":\"EnableIAMUserPermissions\"},{\"Action\":\"kms:GenerateDataKey*\",\"Condition\":{\"StringLike\":{\"kms:EncryptionContext:aws:cloudtrail:arn\":\"arn:aws:cloudtrail:*:123456789012:trail/*\"}},\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"cloudtrail.amazonaws.com\"},\"Resource\":\"*\",\"Sid\":\"AllowCloudTrailToEncryptLogs\"},{\"Action\":\"kms:DescribeKey\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"cloudtrail.amazonaws.com\"},\"Resource\":\"*\",\"Sid\":\"AllowCloudTrailToDescribeKey\"},{\"Action\":[\"kms:ReEncryptFrom\",\"kms:Decrypt\"],\"Condition\":{\"StringEquals\":{\"kms:CallerAccount\":\"123456789012\"},\"StringLike\":{\"kms:EncryptionContext:aws:cloudtrail:arn\":\"arn:aws:cloudtrail:*:123456789012:trail/*\"}},\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Resource\":\"*\",\"Sid\":\"AllowPrincipalsInAccountToDecryptLogFiles\"},{\"Action\":[\"kms:ReEncrypt*\",\"kms:GenerateDataKey*\",\"kms:Encrypt\",\"kms:Decrypt\",\"kms:CreateGrant\"],\"Condition\":{\"ArnNotEquals\":{\"aws:PrincipalArn\":\"arn:aws:iam::123456789012:role/example-deployer\"},\"Bool\":{\"aws:PrincipalIsAWSService\":\"false\"}},\"Effect\":\"Deny\",\"Principal\":\"*\",\"Resource\":\"*\",\"Sid\":\"DenyKeyUseToNonProjectPrincipals\"},{\"Action\":[\"kms:UpdateKeyDescription\",\"kms:UpdateAlias\",\"kms:UntagResource\",\"kms:TagResource\",\"kms:ScheduleKeyDeletion\",\"kms:RevokeGrant\",\"kms:PutKeyPolicy\",\"kms:DisableKeyRotation\",\"kms:DisableKey\",\"kms:DeleteAlias\",\"kms:CreateAlias\"],\"Condition\":{\"ArnNotEquals\":{\"aws:PrincipalArn\":[\"arn:aws:iam::123456789012:role/example-deployer\",\"arn:aws:iam::123456789012:root\"]}},\"Effect\":\"Deny\",\"Principal\":\"*\",\"Resource\":\"*\",\"Sid\":\"DenyKeyAdministrationToNonOperators\"}],\"Version\":\"2012-10-17\"}", "region": "us-east-1", "tags": {"data-classification": "confidential"}, "tags_all": {"AppName": "crm-agent-eval", "cost-center": "crm-agent-eval", "data-classification": "confidential", "environment": "dev", "owner": "crm-agent-eval-team", "service": "crm-agent-eval"}, "timeouts": null, "xks_key_id": null}, "after_identity": {"account_id": null, "id": null, "region": null}, "after_sensitive": {"tags": {}, "tags_all": {}}, "after_unknown": {"arn": true, "id": true, "key_id": true, "multi_region": true, "rotation_period_in_days": true, "tags": {}, "tags_all": {}}, "before": null, "before_sensitive": false}, "mode": "managed", "module_address": "module.observability", "name": "cloudtrail", "provider_name": "registry.terraform.io/hashicorp/aws", "type": "aws_kms_key"} diff --git a/tests/integration/oracle/scripts_investigation.py b/tests/integration/oracle/scripts_investigation.py index c7e55b2..3079e66 100644 --- a/tests/integration/oracle/scripts_investigation.py +++ b/tests/integration/oracle/scripts_investigation.py @@ -134,24 +134,51 @@ tool="research", args={ "intent": ( - "Read opp-0000, opp-0040 and opp-0080, and the contact list of their account " - "acct-0000." + "Find the opportunities rep-ashford owns on acct-0000 and read opp-0000, " + "opp-0040, opp-0080 and opp-0120." ) }, ), + Call( + role="research", + tool="search_opportunities", + args={"account_id": "acct-0000", "owner_rep_id": "rep-ashford"}, + ), Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0000"}), Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0040"}), Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0080"}), + Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0120"}), + Answer( + role="research", + text=( + "rep-ashford owns eight opportunities on acct-0000; opp-0000, opp-0040 and opp-0080 " + "name the departed cont-0000 as primary contact." + ), + ), + Call( + role="supervisor", + tool="research", + args={ + "intent": ( + "Read opp-0160, opp-0200, opp-0240 and opp-0280, and the contact list of acct-0000." + ) + }, + ), + Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0160"}), + Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0200"}), + Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0240"}), + Call(role="research", tool="get_opportunity", args={"opportunity_id": "opp-0280"}), Call(role="research", tool="get_account", args={"account_id": "acct-0000"}), Answer( role="research", - text="opp-0000's primary contact cont-0000 has departed; cont-0001 is an active successor.", + text="opp-0200 also names cont-0000; cont-0001 is an active successor at acct-0000.", ), Answer( role="supervisor", text=( - "Of opp-0000, opp-0040 and opp-0080, opp-0000's primary contact cont-0000 has " - "departed; cont-0001 at acct-0000 is a plausible successor." + "Of rep-ashford's opportunities on acct-0000, opp-0000, opp-0040, opp-0080 and " + "opp-0200 have the departed cont-0000 as primary contact; cont-0001 at acct-0000 is a " + "plausible successor." ), ), ) diff --git a/tests/integration/oracle/test_oracle_gate.py b/tests/integration/oracle/test_oracle_gate.py index fbc9b62..e303a00 100644 --- a/tests/integration/oracle/test_oracle_gate.py +++ b/tests/integration/oracle/test_oracle_gate.py @@ -463,7 +463,12 @@ def _turn_runner(unit_task: Mapping[str, object], unit_tenant: str) -> ObservedT ) unit = run_task_unit( - store=store, task=task, tenant=tenant, family=_ARM.family, turn_runner=_turn_runner + store=store, + task=task, + tenant=tenant, + family=_ARM.family, + turn_runner=_turn_runner, + repeat_index=0, ) if evidence is not None: evidence.extend(evidence_problems(source, task, dispatched, _PLANTED)) diff --git a/tests/integration/test_adapters_recorded.py b/tests/integration/test_adapters_recorded.py index 90df0d1..ecaccad 100644 --- a/tests/integration/test_adapters_recorded.py +++ b/tests/integration/test_adapters_recorded.py @@ -17,7 +17,7 @@ import anthropic import httpx2 import pytest -from anthropic.lib.bedrock import _auth +from anthropic.lib.aws import _auth from botocore.credentials import Credentials from eval.live import is_retryable_error diff --git a/tests/integration/test_gt04_budget_fit.py b/tests/integration/test_gt04_budget_fit.py new file mode 100644 index 0000000..ed27e92 --- /dev/null +++ b/tests/integration/test_gt04_budget_fit.py @@ -0,0 +1,122 @@ +# SPDX-License-Identifier: MIT +"""gt-04 fits the eval turn budget under both strategies, and an overrunning delegation stops at the cap. + +Each script runs through the real :func:`eval.turn_observation.observe_turn` against a freshly +seeded DynamoDB Local tenant under :data:`agents.budget.EVAL_BUDGET`. The direct strategy reads every +in-scope record with the supervisor's own tools; the delegated strategy is the task's oracle script, +which reads everything through two research delegations because one delegation is bounded by +:data:`agents.subagent_runner.DEFAULT_MAX_SUBAGENT_ROUNDS`. The overrun script asks four +delegations for more leaf calls than the budget allows, so the leaf call that reaches the cap is +refused and the turn ends exhausted at the tool tier. Harness: +``tests.integration.oracle.test_oracle_gate``. +""" + +from __future__ import annotations + +from typing import Final + +import pytest + +from agents.budget import EVAL_MAX_TOOL_CALLS +from agents.subagent_runner import DEFAULT_MAX_SUBAGENT_ROUNDS +from crm.store.store import Store +from tests.integration.oracle._contract import Answer, Call, OracleScript, Step +from tests.integration.oracle.test_oracle_gate import _SCRIPTS, _run_scripted, _tables + +__all__ = ["_tables"] + +GT04 = "gt-04-investigation-turn-budget-partial" + +#: The most tool calls either fitting strategy may use: the cap less a margin of five. +FIT_CEILING: Final[int] = 20 + +#: rep-ashford's opportunities on acct-0000, in the order a read-everything turn reads them. +IN_SCOPE_OPPORTUNITIES: Final[tuple[str, ...]] = ( + "opp-0000", + "opp-0040", + "opp-0080", + "opp-0120", + "opp-0160", + "opp-0200", + "opp-0240", + "opp-0280", +) + +DIRECT_READ_EVERYTHING: Final[OracleScript] = ( + Call( + role="supervisor", + tool="search_opportunities", + args={"account_id": "acct-0000", "owner_rep_id": "rep-ashford"}, + ), + *( + Call(role="supervisor", tool="get_opportunity", args={"opportunity_id": opp}) + for opp in IN_SCOPE_OPPORTUNITIES + ), + Call(role="supervisor", tool="get_account", args={"account_id": "acct-0000"}), + Answer( + role="supervisor", + text=( + "opp-0000, opp-0040, opp-0080 and opp-0200 name the departed cont-0000; cont-0001 is " + "an active successor at acct-0000." + ), + ), +) + +#: Leaf reads per overrun delegation: one round short of the round cap, leaving the answer round. +_OVERRUN_READS_PER_DELEGATION: Final[int] = DEFAULT_MAX_SUBAGENT_ROUNDS - 1 +_OVERRUN_DELEGATIONS: Final[int] = 4 + + +def _overrun_script() -> OracleScript: + steps: list[Step] = [] + for delegation in range(_OVERRUN_DELEGATIONS): + steps.append( + Call( + role="supervisor", + tool="research", + args={"intent": f"Read batch {delegation} of acct-0000's opportunities again."}, + ) + ) + steps.extend( + Call( + role="research", + tool="get_opportunity", + args={"opportunity_id": IN_SCOPE_OPPORTUNITIES[i % len(IN_SCOPE_OPPORTUNITIES)]}, + ) + for i in range(_OVERRUN_READS_PER_DELEGATION) + ) + steps.append(Answer(role="research", text=f"Read batch {delegation}.")) + steps.append(Answer(role="supervisor", text="Read every batch.")) + return tuple(steps) + + +def test_the_overrun_script_asks_for_more_leaf_calls_than_the_cap() -> None: + leaf_calls = sum( + 1 for step in _overrun_script() if isinstance(step, Call) and step.role != "supervisor" + ) + assert leaf_calls > EVAL_MAX_TOOL_CALLS + + +@pytest.mark.parametrize( + "strategy", + ["direct", "delegated"], +) +def test_gt04_completes_within_budget_with_margin(_tables: Store, strategy: str) -> None: + script = DIRECT_READ_EVERYTHING if strategy == "direct" else _SCRIPTS[GT04][0] + unit, provider = _run_scripted(_tables, GT04, script) + provider.assert_fully_consumed() + outcome = unit.turn.outcome + assert outcome.budget_exhausted is False + assert outcome.budget_exhausted_tier is None + assert len(unit.turn.tool_calls) <= FIT_CEILING + assert unit.task_score.correctness == 1.0 + + +def test_an_overrunning_delegation_stops_at_the_cap_at_the_tool_tier(_tables: Store) -> None: + unit, _provider = _run_scripted(_tables, GT04, _overrun_script()) + outcome = unit.turn.outcome + assert outcome.budget_exhausted is True + assert outcome.budget_exhausted_tier == "tool" + assert len(unit.turn.tool_calls) == EVAL_MAX_TOOL_CALLS + assert unit.task_score.budget_exhausted is True + assert unit.task_score.budget_exhausted_tier == "tool" diff --git a/tests/integration/test_gt05_truncation.py b/tests/integration/test_gt05_truncation.py new file mode 100644 index 0000000..10315da --- /dev/null +++ b/tests/integration/test_gt05_truncation.py @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: MIT +"""gt-05 reaches the model truncated and disclosed, and a stripped notice is scored as silent. + +The task's oracle script runs through the real :func:`eval.turn_observation.observe_turn` against a +freshly seeded DynamoDB Local tenant whose opp-0000 carries more activity than the tool-result +bound admits. The control removes the disclosure the observation reads, so the same truncated +listing must be observed as ``silent_truncation`` and fail that assertion. Harness: +``tests.integration.oracle.test_oracle_gate``. +""" + +from __future__ import annotations + +import pytest + +from crm.store.store import Store +from eval import turn_observation +from eval.scoring import AssertionResult, TaskScore +from tests.integration.oracle.test_oracle_gate import _SCRIPTS, _run_scripted, _tables + +__all__ = ["_tables"] + +GT05 = "gt-05-investigation-large-tool-result" + + +def _silent_truncation_assertion(score: TaskScore) -> AssertionResult: + (result,) = [r for r in score.assertion_results if "silent_truncation" in r.name] + return result + + +def test_gt05_list_activities_is_truncated_and_disclosed(_tables: Store) -> None: + (script,) = _SCRIPTS[GT05] + unit, _provider = _run_scripted(_tables, GT05, script) + listings = [call for call in unit.turn.tool_calls if call.tool_name == "list_activities"] + assert listings, "the script lists opp-0000's activities" + assert all(call.truncated for call in listings) + assert unit.turn.outcome.truncated is True + assert unit.turn.outcome.truncation_disclosed is True + assert unit.task_score.truncated is True + assert _silent_truncation_assertion(unit.task_score).passed is True + + +def test_a_stripped_truncation_notice_is_observed_as_silent_truncation( + _tables: Store, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.setattr(turn_observation, "describe_truncation", lambda *_a, **_k: None) + (script,) = _SCRIPTS[GT05] + unit, _provider = _run_scripted(_tables, GT05, script) + assert unit.turn.outcome.truncated is True + assert unit.turn.outcome.truncation_disclosed is False + result = _silent_truncation_assertion(unit.task_score) + assert result.passed is False and not result.unscored diff --git a/tests/integration/test_history_store_ddb.py b/tests/integration/test_history_store_ddb.py new file mode 100644 index 0000000..badaae4 --- /dev/null +++ b/tests/integration/test_history_store_ddb.py @@ -0,0 +1,210 @@ +# SPDX-License-Identifier: MIT +"""The DynamoDB conversation-history store against DynamoDB Local. + +The real engine evaluates the optimistic-version condition, enforces the 400 KB item limit and +maintains `reps.gsi_tenant`, so these tests prove the round trip, the expiry bound, tenant and owner +isolation, concurrent writers, index absence and the size bound at the caps. +""" + +from __future__ import annotations + +import threading +from collections.abc import Mapping +from datetime import UTC, datetime, timedelta +from typing import Any + +import pytest + +from agents.conversation_history import ( + DEFAULT_MAX_FIELD_CHARS, + DEFAULT_MAX_TURNS, + DEFAULT_TTL_SECONDS, + HISTORY_TABLE, + TRUNCATION_SUFFIX, + DynamoDbConversationHistory, + HistoryTurn, +) +from crm.authz import Identity +from crm.errors import ScopeDenied +from crm.store import keys +from crm.store.store import Store + +_SESSION = "session-ddb-1" + +#: DynamoDB's maximum item size. +_ITEM_SIZE_LIMIT_BYTES = 400 * 1024 + + +def _identity(*, rep_id: str = "rep-1", tenant: str = "demo") -> Identity: + return Identity( + rep_id=rep_id, + book=frozenset({"acc-1"}), + full_visibility=False, + principal_type="user", + session_id=_SESSION, + source="agent", + tenant=tenant, + ) + + +def _raw_item(client: Any, prefix: str, tenant: str = "demo") -> dict[str, Any]: + response = client.get_item( + TableName=f"{prefix}{HISTORY_TABLE}", + Key={"rep_id": {"S": keys.history_key(tenant, _SESSION)}}, + ConsistentRead=True, + ) + item: dict[str, Any] = response["Item"] + return item + + +def _encoded_size(value: Any) -> int: + """Upper-bound estimate of an encoded attribute value's stored size, in bytes.""" + if "S" in value: + return len(value["S"].encode("utf-8")) + if "N" in value: + return len(value["N"]) + 1 + if "M" in value: + return 3 + sum(len(k.encode("utf-8")) + 1 + _encoded_size(v) for k, v in value["M"].items()) + if "L" in value: + return 3 + sum(1 + _encoded_size(v) for v in value["L"]) + raise AssertionError(f"unexpected attribute shape {sorted(value)}") + + +def test_round_trip_keeps_turns_in_order(dynamodb_local_store: tuple[Store, str]) -> None: + store, _ = dynamodb_local_store + history = DynamoDbConversationHistory(store) + history.record_turn(_SESSION, identity=_identity(), prompt="first", answer="one") + history.record_turn(_SESSION, identity=_identity(), prompt="second", answer="two") + assert history.history_for(_SESSION, identity=_identity()) == ( + HistoryTurn(prompt="first", answer="one"), + HistoryTurn(prompt="second", answer="two"), + ) + + +def test_expires_at_is_bounded_by_the_ttl( + dynamodb_local_store: tuple[Store, str], dynamodb_local_client: Any +) -> None: + store, prefix = dynamodb_local_store + before = int(datetime.now(UTC).timestamp()) + DynamoDbConversationHistory(store).record_turn( + _SESSION, identity=_identity(), prompt="p", answer="a" + ) + after = int(datetime.now(UTC).timestamp()) + expires_at = int(_raw_item(dynamodb_local_client, prefix)["expires_at"]["N"]) + assert before + DEFAULT_TTL_SECONDS <= expires_at <= after + DEFAULT_TTL_SECONDS + + +def test_an_item_past_expiry_reads_empty_before_ttl_deletion( + dynamodb_local_store: tuple[Store, str], +) -> None: + store, _ = dynamodb_local_store + now = [datetime.now(UTC)] + history = DynamoDbConversationHistory(store, ttl_seconds=60, clock=lambda: now[0]) + history.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") + now[0] += timedelta(seconds=61) + assert store.get_item(HISTORY_TABLE, {"rep_id": keys.history_key("demo", _SESSION)}) + assert history.history_for(_SESSION, identity=_identity()) == () + + +def test_a_foreign_tenant_reads_empty(dynamodb_local_store: tuple[Store, str]) -> None: + store, _ = dynamodb_local_store + history = DynamoDbConversationHistory(store) + history.record_turn(_SESSION, identity=_identity(), prompt="secret", answer="a") + assert history.history_for(_SESSION, identity=_identity(tenant="eval-run-1")) == () + + +def test_a_foreign_rep_is_refused_on_read_and_write( + dynamodb_local_store: tuple[Store, str], +) -> None: + store, _ = dynamodb_local_store + history = DynamoDbConversationHistory(store) + history.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") + foreign = _identity(rep_id="rep-attacker") + with pytest.raises(ScopeDenied): + history.history_for(_SESSION, identity=foreign) + with pytest.raises(ScopeDenied): + history.record_turn(_SESSION, identity=foreign, prompt="inject", answer="x") + assert history.history_for(_SESSION, identity=_identity()) == ( + HistoryTurn(prompt="p", answer="a"), + ) + + +class _BarrierStore(Store): + """A `Store` whose first conditional write per thread waits until both writers have read.""" + + def __init__(self, inner: Store, barrier: threading.Barrier) -> None: + self.__dict__.update(inner.__dict__) + self._barrier = barrier + self._waited = threading.local() + + def put_conditional( + self, table: str, item: Mapping[str, object], *, expected_version: int | None + ) -> bool: + if not getattr(self._waited, "done", False): + self._waited.done = True + self._barrier.wait(timeout=10) + return super().put_conditional(table, item, expected_version=expected_version) + + +def test_two_concurrent_writers_both_land(dynamodb_local_store: tuple[Store, str]) -> None: + """Both writers read the same version before either writes; the loser retries and lands.""" + store, _ = dynamodb_local_store + history = DynamoDbConversationHistory(store) + history.record_turn(_SESSION, identity=_identity(), prompt="seed", answer="s") + racing = DynamoDbConversationHistory(_BarrierStore(store, threading.Barrier(2))) + errors: list[Exception] = [] + + def write(prompt: str) -> None: + try: + racing.record_turn(_SESSION, identity=_identity(), prompt=prompt, answer="x") + except Exception as exc: + errors.append(exc) + + threads = [threading.Thread(target=write, args=(name,)) for name in ("left", "right")] + for thread in threads: + thread.start() + for thread in threads: + thread.join(timeout=30) + assert errors == [] + prompts = [turn.prompt for turn in history.history_for(_SESSION, identity=_identity())] + assert prompts[0] == "seed" + assert sorted(prompts[1:]) == ["left", "right"] + item = store.get_item(HISTORY_TABLE, {"rep_id": keys.history_key("demo", _SESSION)}) + assert item is not None and item["version"] == 3 + + +def test_history_items_are_absent_from_gsi_tenant(dynamodb_local_store: tuple[Store, str]) -> None: + store, _ = dynamodb_local_store + store.put_item("reps", {"rep_id": "rep-1", "tenant": "demo", "created_at": "2026-11-15"}) + DynamoDbConversationHistory(store).record_turn( + _SESSION, identity=_identity(), prompt="p", answer="a" + ) + items, _ = store.query_gsi("reps", "gsi_tenant", partition_value="demo") + assert [item["rep_id"] for item in items] == ["rep-1"] + + +def test_an_item_at_the_caps_is_well_under_the_item_size_limit( + dynamodb_local_store: tuple[Store, str], dynamodb_local_client: Any +) -> None: + store, prefix = dynamodb_local_store + history = DynamoDbConversationHistory(store) + oversized = ("wörd " * DEFAULT_MAX_FIELD_CHARS)[: DEFAULT_MAX_FIELD_CHARS * 2] + for _ in range(DEFAULT_MAX_TURNS + 2): + history.record_turn(_SESSION, identity=_identity(), prompt=oversized, answer=oversized) + turns = history.history_for(_SESSION, identity=_identity()) + assert len(turns) == DEFAULT_MAX_TURNS + capped = oversized[:DEFAULT_MAX_FIELD_CHARS] + TRUNCATION_SUFFIX + assert all(turn.prompt == capped and turn.answer == capped for turn in turns) + item = _raw_item(dynamodb_local_client, prefix) + assert set(item) == { + "rep_id", + "kind", + "owner_rep_id", + "owner_tenant", + "turns", + "version", + "updated_at", + "expires_at", + } + size = sum(len(name.encode("utf-8")) + _encoded_size(value) for name, value in item.items()) + assert size < _ITEM_SIZE_LIMIT_BYTES / 4 diff --git a/tests/integration/test_local_eval_sweep.py b/tests/integration/test_local_eval_sweep.py index cefd7ea..76edd09 100644 --- a/tests/integration/test_local_eval_sweep.py +++ b/tests/integration/test_local_eval_sweep.py @@ -7,6 +7,7 @@ from __future__ import annotations +import json import uuid from collections.abc import Iterator from pathlib import Path @@ -20,6 +21,9 @@ from crm.store.schema import TABLE_NAMES from crm.store.store import Store from eval.harness import DEFAULT_ARM_SPECS, run_sweep +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY +from eval.reprice import PRE_AGGREGATION_DIRNAME +from eval.sweep_units import UNIT_REPEAT_INDEX_KEY, UNIT_TASK_ID_KEY from eval.tenancy import TenantTeardownError, teardown_tenant #: Unique per process, so concurrent xdist workers never share a table. @@ -87,6 +91,40 @@ def test_a_full_stub_sweep_runs_end_to_end_against_the_real_dynamodb_engine( assert post_teardown_opps == [] +def test_every_archived_call_names_its_task_and_repeat_on_the_real_engine( + sweep_store: Store, tmp_path: Path +) -> None: + """With `--archive-raw` and two repeats, every pre-aggregation invocation and tool-call entry + names a task the arm scored and a repeat below the repeat count, and every (task, repeat) cell + is present. + """ + repeats = 2 + result = run_sweep( + store=sweep_store, + mode="stub", + output_dir=tmp_path, + archive_raw=True, + repeats=repeats, + ) + archives = sorted((tmp_path / "raw" / PRE_AGGREGATION_DIRNAME).glob("*.json")) + assert len(archives) == len(DEFAULT_ARM_SPECS) + for arm_run, archive in zip(result.arm_runs, archives, strict=True): + payload = json.loads(archive.read_text(encoding="utf-8")) + assert payload[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION + task_ids = {score.task_id for score in arm_run.task_scores} + cells = {(task_id, repeat) for task_id in task_ids for repeat in range(repeats)} + invocation_cells = set() + for key in ("invocation_attributions", "tool_call_attributions"): + entries = payload[key] + assert entries, (archive.name, key) + for entry in entries: + cell = (entry[UNIT_TASK_ID_KEY], entry[UNIT_REPEAT_INDEX_KEY]) + assert cell in cells, (archive.name, key, cell) + if key == "invocation_attributions": + invocation_cells.add(cell) + assert invocation_cells == cells, archive.name + + def test_the_demo_tenant_is_never_written_or_touched_by_a_sweep( sweep_store: Store, tmp_path: Path ) -> None: diff --git a/tests/integration/test_reprice_roundtrip.py b/tests/integration/test_reprice_roundtrip.py index 02622f7..acddbeb 100644 --- a/tests/integration/test_reprice_roundtrip.py +++ b/tests/integration/test_reprice_roundtrip.py @@ -2,7 +2,8 @@ """A full stub sweep against DynamoDB Local, re-priced by `eval.reprice`, reproduces its matrix. Also pins the pre-aggregation contract between the harness writer and the re-price reader: the -keys the writer adds to each archived call are exactly the keys the reader prices from. +keys the writer adds to each archived call are exactly the keys the reader prices from, plus the +owning unit's task id and repeat index. """ from __future__ import annotations @@ -17,6 +18,7 @@ from crm.store.store import Store from eval.harness import DEFAULT_ARM_SPECS, run_sweep from eval.reprice import ARCHIVED_PRICING_KEYS, PRE_AGGREGATION_DIRNAME, main +from eval.sweep_units import UNIT_REPEAT_INDEX_KEY, UNIT_TASK_ID_KEY _ISO_TIMESTAMP = re.compile(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+\+00:00") @@ -89,4 +91,8 @@ def test_the_writer_adds_exactly_the_keys_the_reader_prices_from( entries = json.loads(path.read_text(encoding="utf-8"))["invocation_attributions"] assert entries, path for entry in entries: - assert set(entry) - attribution_keys == set(ARCHIVED_PRICING_KEYS) + assert set(entry) - attribution_keys == { + *ARCHIVED_PRICING_KEYS, + UNIT_TASK_ID_KEY, + UNIT_REPEAT_INDEX_KEY, + } diff --git a/tests/integration/test_resume_contract.py b/tests/integration/test_resume_contract.py new file mode 100644 index 0000000..25bf7c5 --- /dev/null +++ b/tests/integration/test_resume_contract.py @@ -0,0 +1,350 @@ +# SPDX-License-Identifier: MIT +"""The reconnect fields `resume` and `resume_from` mean the same thing on every hop of a chat turn. + +The two wire names are read as text from each of their owners: the SPA body builder +(`frontend/src/components/AssistantPanel/useAssistantTurn.ts`), the SPA reconnect bodies +(`frontend/src/hooks/useAgentStream.ts`), the relay decode (`src/relay/src/requests.ts`), the relay +payload (`src/relay/src/runtime.ts`) and the Runtime reader (`src/agents/runtime_server.py`). Each +read must find its declaration exactly once, so a rename or removal fails rather than skips. + +Both enforcing sides then handle the same bodies. The real relay `decodeBody` and +`buildRuntimePayload` are bundled with the frontend's pinned esbuild, with the AWS SDK aliased to a +stub generated from `runtime.ts`'s own import names, and run under node to turn each SPA body into a +Runtime payload. That payload is posted to the real `agents.runtime_server.app` with a stub provider +that records each model request. Those cases need `node` and `frontend/node_modules`; without them +they skip, unless `CRM_REQUIRE_TS_CONTRACTS=1`, which turns the skip into a failure. +""" + +from __future__ import annotations + +import ast +import json +import os +import re +import shutil +import uuid +from collections.abc import AsyncIterator, Iterator +from pathlib import Path +from typing import Any + +import pytest +from scripts import proc_run +from starlette.testclient import TestClient + +from agents import runtime_server +from agents.cancellation import InMemoryCancellationStore +from agents.conversation_history import InMemoryConversationHistory +from agents.runtime_entrypoint import InMemorySessionStore +from crm.envelope import CLAIM_BOOK, CLAIM_REP_ID, CLAIM_TENANT +from providers.base import ProviderEvent, ResolvedInvocation +from providers.stub import StubProvider + +REPO_ROOT = Path(__file__).resolve().parents[2] + +SPA_BUILDER = ( + REPO_ROOT / "frontend" / "src" / "components" / "AssistantPanel" / "useAssistantTurn.ts" +) +SPA_HOOK = REPO_ROOT / "frontend" / "src" / "hooks" / "useAgentStream.ts" +RELAY_REQUESTS = REPO_ROOT / "src" / "relay" / "src" / "requests.ts" +RELAY_RUNTIME = REPO_ROOT / "src" / "relay" / "src" / "runtime.ts" +RUNTIME_SERVER = REPO_ROOT / "src" / "agents" / "runtime_server.py" + +FRONTEND = REPO_ROOT / "frontend" +ESBUILD = FRONTEND / "node_modules" / ".bin" / "esbuild" +REQUIRE_ENV_VAR = "CRM_REQUIRE_TS_CONTRACTS" + +#: Owner -> (pattern capturing the `resume` wire name, pattern capturing the `resume_from` one). +_TS_READERS: dict[str, tuple[Path, re.Pattern[str], re.Pattern[str]]] = { + "spa_builder": ( + SPA_BUILDER, + re.compile(r"\{ (\w+): true as const \}"), + re.compile(r"\{ ([a-z_]+): options\.resumeFrom \}"), + ), + "relay_decode": ( + RELAY_REQUESTS, + re.compile(r'const resume = body\["(\w+)"\] === true;'), + re.compile(r'const resumeFrom = typeof body\["(\w+)"\] === "number"'), + ), + "relay_payload": ( + RELAY_RUNTIME, + re.compile(r'if \(request\.resume === true\) \{\s*payload\["(\w+)"\] = true;'), + re.compile( + r'if \(request\.resumeFrom !== undefined\) \{\s*payload\["(\w+)"\] = request\.resumeFrom;' + ), + ), +} + +#: The SPA's two reconnect bodies (automatic and manual): the applied-event count, then the flag. +_SPA_RECONNECT_BODY = re.compile(r"(\w+): eventCountRef\.current,\s*(\w+): true,") + + +def _one(pattern: re.Pattern[str], source: str, where: str) -> str: + matches = pattern.findall(source) + assert len(matches) == 1, f"{where}: expected one match of {pattern.pattern!r}, found {matches}" + return str(matches[0]) + + +def ts_wire_names(owner: str) -> tuple[str, str]: + """Return ``(resume name, resume_from name)`` as ``owner``'s TypeScript source spells them.""" + path, resume, resume_from = _TS_READERS[owner] + source = path.read_text(encoding="utf-8") + return _one(resume, source, owner), _one(resume_from, source, owner) + + +def spa_reconnect_wire_names(source: str) -> set[tuple[str, str]]: + """Return the ``(resume_from name, resume name)`` pairs of the SPA's two reconnect bodies.""" + pairs = _SPA_RECONNECT_BODY.findall(source) + assert len(pairs) == 2, f"expected the automatic and the manual reconnect body, found {pairs}" + return {(str(a), str(b)) for a, b in pairs} + + +def runtime_wire_names(source: str) -> tuple[str, str]: + """Return the Runtime's ``(resume name, resume_from name)``: `_RESUME_KEY` and the `.get` key.""" + tree = ast.parse(source) + resume = [ + node.value.value + for node in tree.body + if isinstance(node, ast.AnnAssign) + and isinstance(node.target, ast.Name) + and node.target.id == "_RESUME_KEY" + and isinstance(node.value, ast.Constant) + ] + resume_from = [ + node.value.args[0].value + for node in ast.walk(tree) + if isinstance(node, ast.Assign) + and len(node.targets) == 1 + and isinstance(node.targets[0], ast.Name) + and node.targets[0].id == "resume_from_raw" + and isinstance(node.value, ast.Call) + and isinstance(node.value.func, ast.Attribute) + and node.value.func.attr == "get" + and node.value.args + and isinstance(node.value.args[0], ast.Constant) + ] + assert len(resume) == 1, f"expected one literal _RESUME_KEY, found {resume}" + assert len(resume_from) == 1, ( + f"expected one resume_from_raw = payload.get(...), found {resume_from}" + ) + return str(resume[0]), str(resume_from[0]) + + +def test_every_owner_spells_resume_and_resume_from_the_same_way() -> None: + names = {owner: ts_wire_names(owner) for owner in _TS_READERS} + names["runtime"] = runtime_wire_names(RUNTIME_SERVER.read_text(encoding="utf-8")) + assert len(set(names.values())) == 1, names + resume, resume_from = names["runtime"] + assert spa_reconnect_wire_names(SPA_HOOK.read_text(encoding="utf-8")) == {(resume_from, resume)} + + +def test_the_runtime_key_read_from_source_is_the_one_it_reads() -> None: + assert runtime_wire_names(RUNTIME_SERVER.read_text(encoding="utf-8"))[0] == ( + runtime_server._RESUME_KEY + ) + + +@pytest.mark.parametrize( + "source", + [ + '_RESUME_KEY: Final[str] = "resume"\n_RESUME_KEY: Final[str] = "resume"\n' + 'resume_from_raw = payload.get("resume_from", 0)\n', + 'resume_from_raw = payload.get("resume_from", 0)\n', + '_RESUME_KEY: Final[str] = "resume"\n', + ], + ids=["duplicated-key", "missing-key", "missing-resume-from"], +) +def test_the_runtime_reader_refuses_a_missing_or_duplicated_declaration(source: str) -> None: + with pytest.raises(AssertionError): + runtime_wire_names(source) + + +def test_the_spa_reader_refuses_a_single_reconnect_body() -> None: + with pytest.raises(AssertionError): + spa_reconnect_wire_names("resume_from: eventCountRef.current,\n resume: true,\n") + + +# --------------------------------------------------------------------------- executing both sides + +_SESSION = "s" * 40 +#: The events the mid-turn reconnect has already applied. +_MID_TURN_APPLIED = 1 +_CLAIMS = {CLAIM_REP_ID: "rep-ashford", CLAIM_BOOK: "acct-0000", CLAIM_TENANT: "demo"} + +#: Case name -> the SPA body (the relay's input), without `prompt` and `session_id`. +_BODIES: dict[str, dict[str, object]] = { + "first_send": {"resume_from": 0}, + "zero_frame_reconnect": {"resume_from": 0, "resume": True}, + "mid_turn_reconnect": {"resume_from": _MID_TURN_APPLIED, "resume": True}, + "follow_up": {"resume_from": 3}, + "string_true": {"resume_from": 0, "resume": "true"}, + "number_one": {"resume_from": 0, "resume": 1}, +} + +_DRIVER = """ +const requests = await import(process.argv[2]); +const runtime = await import(process.argv[3]); +const bodies = JSON.parse(await new Promise((resolve) => { + let text = ""; + process.stdin.on("data", (chunk) => (text += chunk)); + process.stdin.on("end", () => resolve(text)); +})); +const out = {}; +for (const [name, body] of Object.entries(bodies)) { + const decoded = requests.decodeBody({ body: JSON.stringify(body), isBase64Encoded: false }); + out[name] = runtime.buildRuntimePayload({ ...decoded, claims: CLAIMS }); +} +console.log(JSON.stringify(out)); +""" + +_SDK_IMPORT = re.compile(r'import \{([^}]*)\} from "(@aws-sdk/[\w-]+)";') + + +def _sdk_stub(runtime_source: str) -> tuple[str, str]: + """Return ``(package, stub module text)``: one inert class per name `runtime.ts` imports.""" + (match,) = _SDK_IMPORT.findall(runtime_source) + names = [name.strip() for name in match[0].split(",") if name.strip()] + assert names, "runtime.ts imports nothing from the AWS SDK" + return match[1], "".join(f"export class {name} {{}}\n" for name in names) + + +def _bundle(source: Path, outfile: Path, *, alias: str) -> None: + proc_run.run( + [ + str(ESBUILD), + str(source), + "--bundle", + "--platform=node", + "--format=esm", + f"--alias:{alias}", + f"--outfile={outfile}", + "--log-level=error", + ], + cwd=source.parent, + check=True, + ) + + +@pytest.fixture(scope="module") +def relay_payloads(tmp_path_factory: pytest.TempPathFactory) -> Iterator[dict[str, dict[str, Any]]]: + """The real relay's Runtime payload for every body in `_BODIES`, from the bundled TypeScript.""" + reason = None + if shutil.which("node") is None: + reason = "node is not on PATH" + elif not ESBUILD.exists(): + reason = f"{ESBUILD} is absent (run `cd frontend && npm ci`)" + if reason is not None: + if os.environ.get(REQUIRE_ENV_VAR) == "1": + pytest.fail(f"{REQUIRE_ENV_VAR}=1 and {reason}") + pytest.skip(reason) + work = tmp_path_factory.mktemp("resume-contract") + package, stub_text = _sdk_stub(RELAY_RUNTIME.read_text(encoding="utf-8")) + stub = work / "sdk-stub.mjs" + stub.write_text(stub_text, encoding="utf-8") + alias = f"{package}={stub}" + _bundle(RELAY_REQUESTS, work / "requests.mjs", alias=alias) + _bundle(RELAY_RUNTIME, work / "runtime.mjs", alias=alias) + driver = work / "driver.mjs" + driver.write_text(f"const CLAIMS = {json.dumps(_CLAIMS)};\n{_DRIVER}", encoding="utf-8") + bodies = { + name: {"prompt": f"prompt for {name}", "session_id": _SESSION, **fields} + for name, fields in _BODIES.items() + } + completed = proc_run.run( + ["node", str(driver), str(work / "requests.mjs"), str(work / "runtime.mjs")], + input=json.dumps(bodies), + capture_output=True, + text=True, + check=True, + ) + yield json.loads(completed.stdout) + + +class _RecordingStub(StubProvider): + """The stub provider, offered no tools so no Lambda is dispatched, counting its requests.""" + + def __init__(self) -> None: + self.requests = 0 + + async def stream( + self, + invocation: ResolvedInvocation, + messages: list[dict[str, object]], + tools: list[dict[str, object]], + ) -> AsyncIterator[ProviderEvent]: + self.requests += 1 + async for event in super().stream(invocation, messages, []): + yield event + + +@pytest.fixture +def runtime(monkeypatch: pytest.MonkeyPatch) -> _RecordingStub: + """A fresh in-process Runtime: stub provider, in-memory session, history and cancel stores.""" + monkeypatch.delenv("AGENT_PROVIDER", raising=False) + stub = _RecordingStub() + monkeypatch.setattr(runtime_server, "_stub_provider", stub) + monkeypatch.setattr(runtime_server, "_session_store", InMemorySessionStore()) + monkeypatch.setattr(runtime_server, "_history_store", InMemoryConversationHistory()) + monkeypatch.setattr(runtime_server, "_cancellation_store", InMemoryCancellationStore()) + return stub + + +def _frames(client: TestClient, payload: dict[str, Any], session: str) -> list[dict[str, Any]]: + """Post ``payload`` under ``session`` and return its decoded SSE frames.""" + retargeted = json.loads(json.dumps(payload).replace(_SESSION, session)) + response = client.post("/invocations", json=retargeted) + assert response.status_code == 200, response.text + return [ + json.loads(line[6:]) for line in response.text.splitlines() if line.startswith("data: ") + ] + + +def _seeded( + client: TestClient, payloads: dict[str, dict[str, Any]] +) -> tuple[str, list[dict[str, Any]]]: + """Run the first send on a new session; return the session and its frames.""" + session = f"contract-{uuid.uuid4()}" + first = _frames(client, payloads["first_send"], session) + assert [frame["kind"] for frame in first][-1] == "completed" + return session, first + + +def test_the_relay_forwards_resume_only_as_true_and_resume_from_unchanged( + relay_payloads: dict[str, dict[str, Any]], +) -> None: + resume, resume_from = runtime_wire_names(RUNTIME_SERVER.read_text(encoding="utf-8")) + for name, fields in _BODIES.items(): + payload = relay_payloads[name] + assert payload[resume_from] == fields["resume_from"], name + expected = fields.get("resume") is True + assert (payload.get(resume) is True) is expected, (name, payload) + assert resume in payload or not expected, name + + +def test_a_zero_frame_reconnect_replays_the_whole_turn( + relay_payloads: dict[str, dict[str, Any]], runtime: _RecordingStub +) -> None: + with TestClient(runtime_server.app) as client: + session, first = _seeded(client, relay_payloads) + replay = _frames(client, relay_payloads["zero_frame_reconnect"], session) + assert runtime.requests == 1 + assert replay == first + + +def test_a_mid_turn_reconnect_replays_only_what_follows_resume_from( + relay_payloads: dict[str, dict[str, Any]], runtime: _RecordingStub +) -> None: + with TestClient(runtime_server.app) as client: + session, first = _seeded(client, relay_payloads) + replay = _frames(client, relay_payloads["mid_turn_reconnect"], session) + assert runtime.requests == 1 + assert replay == first[_MID_TURN_APPLIED:] + + +@pytest.mark.parametrize("case", ["follow_up", "string_true", "number_one"]) +def test_a_body_without_a_true_resume_runs_a_fresh_turn( + relay_payloads: dict[str, dict[str, Any]], runtime: _RecordingStub, case: str +) -> None: + with TestClient(runtime_server.app) as client: + session, _first = _seeded(client, relay_payloads) + _frames(client, relay_payloads[case], session) + assert runtime.requests == 2, case diff --git a/tests/integration/test_tier_comparison_local_sweep.py b/tests/integration/test_tier_comparison_local_sweep.py index caa158b..198473b 100644 --- a/tests/integration/test_tier_comparison_local_sweep.py +++ b/tests/integration/test_tier_comparison_local_sweep.py @@ -51,23 +51,21 @@ "Task completion over repeats", "Task accuracy", "Cost per completed task", - "P95 latency per completed task (ms)", "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "Model invocations", "Long-context invocations", - "Input tokens", - "Output tokens", - "Cost per task, all tasks", + "Total input tokens", + "Cache read tokens", + "Cache write tokens", + "Uncached input tokens", + "Total output tokens", + "Cost per applicable task", "Self-corrected retries", + "Budget-exhausted tasks", + "Truncated tool calls", + "Truncated tasks", ) -_SPECIFIC_ROWS = { - "Supervisor": ("Budget-exhausted tasks",), - "Subagent": tuple( - f"Delegation outcome: {kind}" - for kind in ("data", "no_match", "denied", "tool_failure", "none") - ), - "ToolCall": ("Truncated tasks",), -} @dataclass(frozen=True) @@ -192,7 +190,7 @@ def test_matrix_md_opens_with_the_summary_in_the_ac1_order(sweeps: _Sweeps) -> N assert positions == sorted(positions) for section in _SECTIONS: rows = _summary_table(markdown, section) - assert list(rows) == ["Metric", "---", *_COMMON_ROWS, *_SPECIFIC_ROWS[section]] + assert list(rows) == ["Metric", "---", *_COMMON_ROWS] assert all(len(cells) == len(DEFAULT_ARM_SPECS) for cells in rows.values()) assert rows["Metric"] == [spec.family for spec in DEFAULT_ARM_SPECS] @@ -201,7 +199,7 @@ def test_stub_columns_read_not_measured_for_latency(sweeps: _Sweeps) -> None: markdown = _markdown(sweeps) for section in _SECTIONS: rows = _summary_table(markdown, section) - for label in ("P95 latency per completed task (ms)", "P50 latency per completed task (ms)"): + for label in ("P50 latency per completed task (ms)", "P95 latency per completed task (ms)"): assert rows[label] == ["not measured"] * len(DEFAULT_ARM_SPECS) @@ -209,7 +207,7 @@ def test_withheld_cost_cells_read_withheld(sweeps: _Sweeps) -> None: markdown = _markdown(sweeps) for section in _SECTIONS: rows = _summary_table(markdown, section) - for label in ("Cost per completed task", "Cost per task, all tasks"): + for label in ("Cost per completed task", "Cost per applicable task"): assert rows[label] == ["withheld"] * len(DEFAULT_ARM_SPECS) diff --git a/tests/integration/test_tier_comparison_ui_contract.py b/tests/integration/test_tier_comparison_ui_contract.py index a9bf2c5..f60e24e 100644 --- a/tests/integration/test_tier_comparison_ui_contract.py +++ b/tests/integration/test_tier_comparison_ui_contract.py @@ -39,9 +39,17 @@ _TIERS = ("supervisor", "subagent", "tool") -def _summary_entry(met: int, applicable: int, tokens: tuple[int, int]) -> dict[str, object]: +def _summary_entry( + family: str, met: int, applicable: int, tokens: tuple[int, int] +) -> dict[str, object]: + """A tier summary entry; Anthropic's reported input excludes cache tokens, OpenAI's includes.""" + cache_read, cache_write = tokens[0] // 2, tokens[0] // 10 + total_prompt = tokens[0] + cache_read + cache_write if family == "anthropic" else tokens[0] return { "input_tokens": tokens[0], + "total_prompt_tokens": total_prompt, + "cache_read_tokens": cache_read, + "cache_write_tokens": cache_write, "output_tokens": tokens[1], "cost_total": None, "latency_p50_ms": None, @@ -75,6 +83,13 @@ def _stub_arm( if family == "anthropic": for tier in _TIERS: by_tier[tier]["retry_count"] = 0 + for index, tier in enumerate(_TIERS): + truncated = None if tier == "subagent" else index + by_tier[tier].update( + budget_exhausted_task_count=1 if tier == "supervisor" else 0, + truncated_tool_call_count=truncated, + truncated_task_count=truncated, + ) tasks: tuple[dict[str, object], ...] = tuple( { "task_id": f"gt-{index:02d}", @@ -100,6 +115,7 @@ def _stub_arm( runtime_identifier="local-stub-runtime", price_table_version="v1", answer_style_sha256="0" * 64, + prompt_caching="explicit cache points", ), model_metrics_fields={ "cost_withheld_provisional": True, @@ -125,7 +141,7 @@ def _stub_arm( for tier, model_id in zip(_TIERS, models, strict=True) ), tier_summary_fields={ - tier: _summary_entry(met, applicable, (100 * (i + 1), 10 * (i + 1))) + tier: _summary_entry(family, met, applicable, (100 * (i + 1), 10 * (i + 1))) for i, (tier, (met, applicable)) in enumerate(zip(_TIERS, completions, strict=True)) }, tier_task_metrics_fields={ diff --git a/tests/stub/test_sfn_vs_inprocess_equivalence.py b/tests/stub/test_sfn_vs_inprocess_equivalence.py index 23ed910..8790a78 100644 --- a/tests/stub/test_sfn_vs_inprocess_equivalence.py +++ b/tests/stub/test_sfn_vs_inprocess_equivalence.py @@ -133,6 +133,7 @@ def runner(task: Mapping[str, object], tenant: str, spec: Any = spec) -> Observe tenant=TENANT, family=spec.family, turn_runner=runner, + repeat_index=ref.repeat_index, ) ) return [ diff --git a/tests/unit/_terraform_fixture.py b/tests/unit/_terraform_fixture.py index df65a49..a86fdf3 100644 --- a/tests/unit/_terraform_fixture.py +++ b/tests/unit/_terraform_fixture.py @@ -28,7 +28,7 @@ CAPABILITIES_YAML = REPO_ROOT / "config" / "model_capabilities.yaml" #: The aws provider version the fixture root pins. -AWS_PROVIDER_VERSION = "6.71.0" +AWS_PROVIDER_VERSION = "6.72.0" REQUIRE_TERRAFORM_ENV_VAR = "CRM_REQUIRE_TERRAFORM" diff --git a/tests/unit/test_adapters.py b/tests/unit/test_adapters.py index 74d0190..a7da725 100644 --- a/tests/unit/test_adapters.py +++ b/tests/unit/test_adapters.py @@ -20,7 +20,7 @@ import anthropic import httpx2 import pytest -from anthropic.lib.bedrock import _auth +from anthropic.lib.aws import _auth from botocore.credentials import Credentials from crm.errors import ValidationFailed @@ -985,17 +985,154 @@ def _openai_body( return adapter._build_responses_body(_resolve(matrix, "openai", "supervisor"), messages, tools) +_EPHEMERAL = {"type": "ephemeral"} + + +def _cache_point_count(request: dict[str, Any]) -> int: + return json.dumps(request).count('"cache_control"') + + def test_anthropic_caches_the_stable_system_block_and_leaves_the_briefing_after_it( matrix: Any, ) -> None: request = build_request(_resolve(matrix, "anthropic", "supervisor"), _cached_turn(), []) assert request["system"] == [ - {"type": "text", "text": _LONG_STABLE, "cache_control": {"type": "ephemeral"}}, + {"type": "text", "text": _LONG_STABLE, "cache_control": _EPHEMERAL}, {"type": "text", "text": _BRIEFING}, ] assert [m["role"] for m in request["messages"]] == ["user"] +@pytest.mark.parametrize("tier", ANTHROPIC_TIERS) +def test_anthropic_marks_the_latest_message_beside_the_system_point_on_every_tier( + matrix: Any, tier: str +) -> None: + """String content of the latest message becomes one text block carrying ``cache_control``.""" + request = build_request(_resolve(matrix, "anthropic", tier), _cached_turn(), []) + assert request["messages"] == [ + { + "role": "user", + "content": [ + {"type": "text", "text": "How many in Negotiation?", "cache_control": _EPHEMERAL} + ], + } + ] + assert request["system"][0]["cache_control"] == _EPHEMERAL + assert _cache_point_count(request) == 2 + + +def test_anthropic_marks_only_the_latest_message_of_a_multi_turn_conversation( + matrix: Any, +) -> None: + messages: list[dict[str, object]] = [ + *_cached_turn(), + {"role": "assistant", "content": "Three."}, + {"role": "user", "content": "And in Proposal?"}, + ] + request = build_request(_resolve(matrix, "anthropic", "supervisor"), messages, []) + assert request["messages"] == [ + {"role": "user", "content": "How many in Negotiation?"}, + {"role": "assistant", "content": "Three."}, + { + "role": "user", + "content": [{"type": "text", "text": "And in Proposal?", "cache_control": _EPHEMERAL}], + }, + ] + assert _cache_point_count(request) == 2 + + +def test_anthropic_marks_the_last_tool_result_block_of_a_latest_tool_turn(matrix: Any) -> None: + messages: list[dict[str, object]] = [ + {"role": "system", "content": _LONG_STABLE}, + {"role": "user", "content": "find a-1 and a-2"}, + { + "role": "assistant", + "content": "Looking.", + "tool_calls": [ + {"id": "toolu_1", "name": "get_account", "input": {"a": 1}}, + {"id": "toolu_2", "name": "get_account", "input": {"a": 2}}, + ], + }, + { + "role": "tool", + "tool_results": [ + {"id": "toolu_1", "output": '{"ok": 1}'}, + {"id": "toolu_2", "output": '{"ok": 2}'}, + ], + }, + ] + request = build_request(_resolve(matrix, "anthropic", "supervisor"), messages, []) + assert request["messages"][1]["content"][-1] == { + "type": "tool_use", + "id": "toolu_2", + "name": "get_account", + "input": {"a": 2}, + } + assert request["messages"][2] == { + "role": "user", + "content": [ + {"type": "tool_result", "tool_use_id": "toolu_1", "content": '{"ok": 1}'}, + { + "type": "tool_result", + "tool_use_id": "toolu_2", + "content": '{"ok": 2}', + "cache_control": _EPHEMERAL, + }, + ], + } + assert _cache_point_count(request) == 2 + + +def test_anthropic_cache_point_never_mutates_the_callers_messages(matrix: Any) -> None: + """The point is placed on copies, so a reused history never accumulates points.""" + blocks: list[dict[str, Any]] = [{"type": "text", "text": "a"}, {"type": "text", "text": "b"}] + messages: list[dict[str, object]] = [ + {"role": "system", "content": _LONG_STABLE}, + {"role": "user", "content": blocks}, + ] + before = json.dumps(messages) + invocation = _resolve(matrix, "anthropic", "supervisor") + first = build_request(invocation, messages, []) + second = build_request(invocation, messages, []) + assert json.dumps(messages) == before + assert first == second + assert first["messages"][0]["content"] == [ + {"type": "text", "text": "a"}, + {"type": "text", "text": "b", "cache_control": _EPHEMERAL}, + ] + + +def test_anthropic_omits_the_system_point_but_keeps_the_latest_when_only_the_latest_reaches( + matrix: Any, +) -> None: + long_question = "Which accounts are in Negotiation? " * 40 + messages: list[dict[str, object]] = [ + {"role": "system", "content": "Short."}, + {"role": "user", "content": long_question}, + ] + request = build_request(_resolve(matrix, "anthropic", "supervisor"), messages, []) + assert request["system"] == "Short." + assert request["messages"] == [ + { + "role": "user", + "content": [{"type": "text", "text": long_question, "cache_control": _EPHEMERAL}], + } + ] + assert _cache_point_count(request) == 1 + + +def test_anthropic_request_without_a_conversation_carries_only_the_system_point( + matrix: Any, +) -> None: + messages: list[dict[str, object]] = [{"role": "system", "content": _LONG_STABLE}] + request = build_request(_resolve(matrix, "anthropic", "supervisor"), messages, []) + assert request["messages"] == [] + assert request["system"] == [ + {"type": "text", "text": _LONG_STABLE, "cache_control": _EPHEMERAL} + ] + assert prompt_caching.latest_message_index("anthropic.claude-opus-5-5", messages, []) is None + + def test_anthropic_sends_no_breakpoint_when_the_stable_prefix_is_under_the_minimum( matrix: Any, ) -> None: @@ -1004,7 +1141,10 @@ def test_anthropic_sends_no_breakpoint_when_the_stable_prefix_is_under_the_minim assert "cache_control" not in json.dumps(request) -def test_anthropic_sends_no_breakpoint_without_a_stable_system_message(matrix: Any) -> None: +def test_anthropic_places_only_the_latest_point_without_a_stable_system_message( + matrix: Any, +) -> None: + """The tool definitions count toward the latest point's prefix; no system point exists.""" tools: list[dict[str, object]] = [ {"name": "t", "description": "d" * 4000, "input_schema": {"type": "object"}} ] @@ -1012,7 +1152,10 @@ def test_anthropic_sends_no_breakpoint_without_a_stable_system_message(matrix: A _resolve(matrix, "anthropic", "subagent"), [{"role": "user", "content": "go"}], tools ) assert "system" not in request - assert "cache_control" not in json.dumps(request) + assert request["messages"] == [ + {"role": "user", "content": [{"type": "text", "text": "go", "cache_control": _EPHEMERAL}]} + ] + assert _cache_point_count(request) == 1 def test_the_cache_scope_marker_never_reaches_either_request(matrix: Any) -> None: @@ -1052,6 +1195,62 @@ def test_the_breakpoint_needs_a_prefix_that_can_reach_the_model_minimum() -> Non assert prompt_caching.breakpoint_index("anthropic.claude-opus-5-5", one_short, tools) is None +def test_the_latest_point_needs_a_cumulative_prefix_that_can_reach_the_model_minimum() -> None: + """System, conversation and tool-call characters all count toward the latest point's prefix.""" + model_id = "anthropic.claude-opus-5-5" + minimum = prompt_caching.min_prefix_tokens(model_id) + assert minimum == 512 + tools: list[dict[str, object]] = [] + head: list[dict[str, object]] = [ + {"role": "system", "content": "s" * 100}, + {"role": "user", "content": "u" * 100}, + ] + calls = [{"id": "c", "input": {}, "name": "n"}] + calls_characters = len(json.dumps(calls, sort_keys=True)) + remaining = minimum * 2 - 2 - 200 - calls_characters + + def turn(final: int) -> list[dict[str, object]]: + return [ + *head, + {"role": "assistant", "content": "", "tool_calls": calls}, + {"role": "user", "content": "x" * final}, + ] + + assert prompt_caching.latest_message_index(model_id, turn(remaining), tools) == 3 + assert prompt_caching.latest_message_index(model_id, turn(remaining - 1), tools) is None + + +def test_the_latest_point_skips_trailing_system_messages() -> None: + messages: list[dict[str, object]] = [ + {"role": "user", "content": "x" * 2000}, + {"role": "system", "content": "late briefing"}, + ] + assert prompt_caching.latest_message_index("anthropic.claude-opus-5-5", messages, []) == 0 + + +def test_select_cache_points_keeps_at_most_the_limit_dropping_the_oldest_first() -> None: + six = (0, 1, 2, 3, 4, 5) + assert prompt_caching.ANTHROPIC_MAX_CACHE_POINTS == 4 + assert prompt_caching.select_cache_points(six, latest=5, system=0) == (0, 3, 4, 5) + assert prompt_caching.select_cache_points(six, latest=None, system=None) == (2, 3, 4, 5) + + +def test_select_cache_points_keeps_latest_then_system_then_the_most_recent() -> None: + six = (0, 1, 2, 3, 4, 5) + assert prompt_caching.select_cache_points(six, latest=5, system=0, limit=1) == (5,) + assert prompt_caching.select_cache_points(six, latest=5, system=0, limit=2) == (0, 5) + assert prompt_caching.select_cache_points(six, latest=5, system=0, limit=3) == (0, 4, 5) + assert prompt_caching.select_cache_points(six, latest=None, system=1, limit=2) == (1, 5) + assert prompt_caching.select_cache_points((), latest=7, system=None) == (7,) + assert prompt_caching.select_cache_points((3, 3), latest=3, system=3) == (3,) + assert prompt_caching.select_cache_points((), latest=None, system=None) == () + + +def test_select_cache_points_refuses_a_negative_limit() -> None: + with pytest.raises(ValueError, match="non-negative"): + prompt_caching.select_cache_points((1,), latest=1, system=None, limit=-1) + + def test_a_volatile_message_ends_the_stable_run() -> None: assert prompt_caching.stable_system_end(_cached_turn()) == 0 volatile_first = [ diff --git a/tests/unit/test_arm_tier_cost_invariant.py b/tests/unit/test_arm_tier_cost_invariant.py index d023150..70cf8cd 100644 --- a/tests/unit/test_arm_tier_cost_invariant.py +++ b/tests/unit/test_arm_tier_cost_invariant.py @@ -124,7 +124,12 @@ def _published_arm(store: Store) -> dict[str, Any]: stream_calls=len(INVOCATIONS), ) unit = run_task_unit( - store=store, task=task, tenant=_TENANT, family="anthropic", turn_runner=lambda _t, _n: turn + store=store, + task=task, + tenant=_TENANT, + family="anthropic", + turn_runner=lambda _t, _n: turn, + repeat_index=0, ) arm = assemble_arm( [unit], diff --git a/tests/unit/test_artifact_byte_identity.py b/tests/unit/test_artifact_byte_identity.py index d80013e..44cbd5e 100644 --- a/tests/unit/test_artifact_byte_identity.py +++ b/tests/unit/test_artifact_byte_identity.py @@ -110,6 +110,7 @@ def _arm_at_timestamp(timestamp: str) -> ArmResult: price_table_version=provenance.price_table_version, answer_style_sha256=provenance.answer_style_sha256, prompt_bundle_sha256=provenance.prompt_bundle_sha256, + prompt_caching=provenance.prompt_caching, ), model_metrics_fields=base.model_metrics_fields, aggregate_score_fields=base.aggregate_score_fields, diff --git a/tests/unit/test_bootstrap_account_script.py b/tests/unit/test_bootstrap_account_script.py index fc0e298..3088160 100644 --- a/tests/unit/test_bootstrap_account_script.py +++ b/tests/unit/test_bootstrap_account_script.py @@ -165,6 +165,7 @@ def _write_stub(path: Path, tool: str, body: str, *, read_stdin: bool = False) - def sandbox(tmp_path: Path) -> Sandbox: root = tmp_path / "repo" (root / "scripts").mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh") (root / "infra" / "bootstrap_account").mkdir(parents=True) shutil.copy2(SCRIPT, root / "scripts" / "bootstrap_account.sh") shutil.copy2(REGION_MAP_SCRIPT, root / "scripts" / "region_map.py") diff --git a/tests/unit/test_bound_tool_output.py b/tests/unit/test_bound_tool_output.py new file mode 100644 index 0000000..69fea42 --- /dev/null +++ b/tests/unit/test_bound_tool_output.py @@ -0,0 +1,151 @@ +# SPDX-License-Identifier: MIT +"""Tests for :func:`agents.events.bound_tool_output`, the shared tool-result bound.""" + +from __future__ import annotations + +from agents.events import ( + TOOL_OUTPUT_TRUNCATED_KEY, + TOOL_RESULT_BYTE_CEILING, + TRUNCATION_MARKER, + bound_tool_output, + record_list_field, +) +from agents.supervisor import describe_truncation + +_MARKER: dict[str, object] = {TRUNCATION_MARKER: True} + + +def _size(value: object) -> int: + return len(repr(value).encode("utf-8")) + + +def _records(prefix: str, count: int, pad: int = 700) -> list[dict[str, object]]: + return [{"id": f"{prefix}-{n:04d}", "text": "x" * pad} for n in range(count)] + + +def _assert_record_boundary_trim( + bounded_list: object, source: list[dict[str, object]] +) -> list[object]: + assert isinstance(bounded_list, list) + assert bounded_list[-1] == _MARKER + kept = bounded_list[:-1] + assert 0 < len(kept) < len(source) + assert kept == source[: len(kept)] + return kept + + +def test_the_truncation_key_is_the_truncated_field() -> None: + assert TOOL_OUTPUT_TRUNCATED_KEY == "truncated" + + +def test_an_oversized_items_list_is_cut_at_a_record_boundary_and_flagged() -> None: + items = _records("opp", 60) + raw: dict[str, object] = {"items": items, "next_token": "t-1"} + assert _size(raw) > TOOL_RESULT_BYTE_CEILING + + bounded, truncated = bound_tool_output(raw) + + assert truncated is True + _assert_record_boundary_trim(bounded["items"], items) + assert bounded[TOOL_OUTPUT_TRUNCATED_KEY] is True + assert bounded["next_token"] == "t-1" + assert _size(bounded) <= TOOL_RESULT_BYTE_CEILING + assert describe_truncation(bounded, event_truncated=truncated) is not None + assert raw["items"] is items and TOOL_OUTPUT_TRUNCATED_KEY not in raw + + +def test_items_is_chosen_over_a_larger_list() -> None: + items = _records("opp", 60) + container: dict[str, object] = {"items": items, "notes": _records("note", 80)} + assert record_list_field(container) == ("items", items) + + +def test_without_items_the_largest_list_is_trimmed_and_the_rest_survive() -> None: + activities = _records("act", 55) + contacts = _records("cont", 2, pad=50) + notes = _records("note", 3, pad=50) + body: dict[str, object] = { + "opportunity": {"opportunity_id": "opp-0000", "stage": "Proposal"}, + "contacts": contacts, + "notes": notes, + "activities": activities, + } + raw: dict[str, object] = {"statusCode": 200, "body": body} + + bounded, truncated = bound_tool_output(raw) + + assert truncated is True + bounded_body = bounded["body"] + assert isinstance(bounded_body, dict) + _assert_record_boundary_trim(bounded_body["activities"], activities) + assert bounded_body["contacts"] == contacts + assert bounded_body["notes"] == notes + assert bounded_body["opportunity"] == body["opportunity"] + assert bounded_body[TOOL_OUTPUT_TRUNCATED_KEY] is True + assert describe_truncation(bounded, event_truncated=truncated) is not None + + +def test_a_body_envelope_is_bounded_inside_the_body_and_keeps_the_envelope() -> None: + items = _records("opp", 60) + raw: dict[str, object] = {"statusCode": 200, "body": {"items": items}} + + bounded, truncated = bound_tool_output(raw) + + assert truncated is True + assert bounded["statusCode"] == 200 + assert TOOL_OUTPUT_TRUNCATED_KEY not in bounded + bounded_body = bounded["body"] + assert isinstance(bounded_body, dict) + _assert_record_boundary_trim(bounded_body["items"], items) + assert bounded_body[TOOL_OUTPUT_TRUNCATED_KEY] is True + assert _size(bounded_body) <= TOOL_RESULT_BYTE_CEILING + + +def test_an_output_under_the_ceiling_is_returned_unchanged() -> None: + raw: dict[str, object] = {"statusCode": 200, "body": {"items": _records("opp", 5)}} + + bounded, truncated = bound_tool_output(raw) + + assert truncated is False + assert bounded is raw + assert describe_truncation(bounded, event_truncated=truncated) is None + + +def test_bounding_a_bounded_output_again_changes_nothing() -> None: + raw: dict[str, object] = {"statusCode": 200, "body": {"items": _records("opp", 60)}} + bounded, _ = bound_tool_output(raw) + + again, truncated = bound_tool_output(bounded) + + assert truncated is False + assert again is bounded + + +def test_an_oversized_container_with_no_list_is_returned_unchanged() -> None: + raw: dict[str, object] = {"body": {"blob": "x" * (TOOL_RESULT_BYTE_CEILING + 10)}} + + bounded, truncated = bound_tool_output(raw) + + assert truncated is False + assert bounded is raw + + +def test_a_single_oversized_record_leaves_only_the_marker() -> None: + raw: dict[str, object] = {"items": [{"id": "big", "text": "x" * (TOOL_RESULT_BYTE_CEILING)}]} + + bounded, truncated = bound_tool_output(raw) + + assert truncated is True + assert bounded["items"] == [_MARKER] + assert bounded[TOOL_OUTPUT_TRUNCATED_KEY] is True + + +def test_a_custom_ceiling_is_honoured() -> None: + items = _records("opp", 10, pad=100) + raw: dict[str, object] = {"items": items} + + bounded, truncated = bound_tool_output(raw, byte_ceiling=600) + + assert truncated is True + _assert_record_boundary_trim(bounded["items"], items) + assert _size(bounded) <= 600 diff --git a/tests/unit/test_budget_exhaustion_tier.py b/tests/unit/test_budget_exhaustion_tier.py new file mode 100644 index 0000000..a602d53 --- /dev/null +++ b/tests/unit/test_budget_exhaustion_tier.py @@ -0,0 +1,354 @@ +# SPDX-License-Identifier: MIT +"""Where a turn's budget ran out: :attr:`agents.budget.TurnBudget.exhausted_tier`. + +Each detection site records its tier once, the first writer wins, and +:attr:`agents.turn_driver.TurnRecords.budget_exhausted_tier` exposes it after the turn. Also covers +the supervisor direct call's truncation flag, read from the tool result itself. +""" + +from __future__ import annotations + +import asyncio +import dataclasses +import time +from collections.abc import AsyncIterator, Callable +from dataclasses import dataclass +from typing import Any + +import pytest + +from agents.budget import CHAT_BUDGET, TurnBudget, TurnBudgetSpec +from agents.events import AgentEvent +from agents.registry import RegisteredTool +from agents.turn_driver import TurnRecords, drive_turn +from providers.base import ModelProvider, ProviderEvent, ResolvedInvocation +from providers.capabilities import CapabilityMatrix, Family, Tier +from tests.unit.test_turn_driver_tiers import MATRIX, MIXED, _delegating_rounds + + +@dataclass +class _Clock: + """A settable monotonic clock shared by the budget and the scripted providers.""" + + now: float = 0.0 + + def __call__(self) -> float: + return self.now + + +@dataclass +class _Round: + """One scripted provider round. + + ``advance_after`` moves the settable clock past any deadline before the event at that index + (``len(events)``: after the last one); ``sleep_seconds`` waits in real time before the first. + """ + + events: list[ProviderEvent] + advance_after: int | None = None + sleep_seconds: float = 0.0 + + +@dataclass +class _Script: + rounds: list[_Round] + clock: _Clock + + +@dataclass +class _Provider(ModelProvider): + family: Family + script: _Script + + def stream( + self, + invocation: ResolvedInvocation, + messages: list[dict[str, object]], + tools: list[dict[str, object]], + ) -> AsyncIterator[ProviderEvent]: + del messages, tools + assert invocation.model.family == self.family + assert self.script.rounds, "provider.stream called more times than scripted" + return self._emit(self.script.rounds.pop(0)) + + async def _emit(self, scripted: _Round) -> AsyncIterator[ProviderEvent]: + if scripted.sleep_seconds: + await asyncio.sleep(scripted.sleep_seconds) + for index, event in enumerate(scripted.events): + if scripted.advance_after == index: + self.script.clock.now += 10_000.0 + yield event + if scripted.advance_after == len(scripted.events): + self.script.clock.now += 10_000.0 + + +def _ok_dispatch(tool: RegisteredTool, tool_input: dict[str, object]) -> dict[str, Any]: + del tool, tool_input + return {"statusCode": 200, "body": {"account_id": "acc-1", "name": "Acme"}} + + +def _drive( + rounds: list[_Round], + *, + budget: TurnBudgetSpec = CHAT_BUDGET, + matrix: CapabilityMatrix = MATRIX, + dispatch: Callable[[RegisteredTool, dict[str, object]], dict[str, Any]] = _ok_dispatch, + max_rounds: int | None = None, + clock: _Clock | None = None, + real_clock: bool = False, +) -> tuple[list[AgentEvent], TurnRecords]: + settable = clock if clock is not None else _Clock() + turn_clock: Callable[[], float] = time.monotonic if real_clock else settable + script = _Script(rounds, settable) + records = TurnRecords() + + async def _run() -> list[AgentEvent]: + return [ + event + async for event in drive_turn( + prompt="find acme", + session_id="sess-exhaustion", + providers=lambda family: _Provider(family, script), + matrix=matrix, + tuning=MIXED, + budget=budget, + dispatch=dispatch, + records=records, + max_rounds=max_rounds, + clock=turn_clock, + ) + ] + + return asyncio.run(_run()), records + + +def _direct_call_round(tool_name: str = "search_accounts") -> _Round: + return _Round( + [ + ProviderEvent( + type="tool_call", tool_name=tool_name, tool_input={"q": "a"}, tool_id="t1" + ), + ProviderEvent(type="usage", input_tokens=1, output_tokens=1), + ProviderEvent(type="completed", awaiting_tools=True), + ] + ) + + +def _answer_round() -> _Round: + return _Round( + [ + ProviderEvent(type="text_delta", text="Done."), + ProviderEvent(type="usage", input_tokens=1, output_tokens=1), + ProviderEvent(type="completed", awaiting_tools=False), + ] + ) + + +def _assert_exhausted(events: list[AgentEvent]) -> None: + assert events[-1].kind == "error" + assert events[-1].error_kind == "budget_exhausted" + + +def _with_limit(tier: Tier, limit: int) -> CapabilityMatrix: + return dataclasses.replace( + MATRIX, request_prompt_limits={**MATRIX.request_prompt_limits, tier: limit} + ) + + +# -- TurnBudget --------------------------------------------------------------------------------- + + +def test_a_fresh_budget_records_no_exhaustion_tier() -> None: + assert TurnBudget().exhausted_tier is None + + +def test_the_first_recorded_tier_wins() -> None: + budget = TurnBudget() + budget.note_exhausted_at("tool") + budget.note_exhausted_at("supervisor") + assert budget.exhausted_tier == "tool" + + +def test_a_refused_request_records_the_refusals_tier() -> None: + budget = TurnBudget() + budget.refuse_request(estimated_prompt_tokens=10, limit=5, tier="subagent", role="research") + assert budget.exhausted_tier == "subagent" + + +def test_a_call_abandoned_at_the_deadline_records_its_tier() -> None: + budget = TurnBudget() + budget.note_call_without_usage(tier="tool", role="research", cause="deadline") + assert budget.exhausted_tier == "tool" + + +@pytest.mark.parametrize("cause", ["turn_stopped", "provider_error", "partial_usage"]) +def test_a_call_unmetered_for_another_cause_records_no_tier(cause: str) -> None: + budget = TurnBudget() + budget.note_call_without_usage(tier="tool", role="research", cause=cause) + assert budget.exhausted_tier is None + + +def test_an_unknown_tier_is_refused() -> None: + with pytest.raises(ValueError, match="tier must be one of"): + TurnBudget().note_call_without_usage(tier="router", role="r", cause="deadline") + + +# -- drive_turn detection sites ----------------------------------------------------------------- + + +def test_a_completed_turn_records_no_exhaustion_tier() -> None: + events, records = _drive([_answer_round()]) + assert events[-1].kind == "completed" + assert records.budget_exhausted_tier is None + + +def test_records_report_no_tier_before_a_turn_starts() -> None: + assert TurnRecords().budget_exhausted_tier is None + + +def test_the_tool_call_cap_is_recorded_at_the_supervisor() -> None: + events, records = _drive( + [_direct_call_round()], budget=TurnBudgetSpec(max_tool_calls=1, max_wall_clock_seconds=60.0) + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "supervisor" + + +def test_a_leaf_refused_at_the_tool_call_cap_is_recorded_at_the_tool_tier() -> None: + supervisor, subagent, tool, answer = _delegating_rounds() + two_leaves = [subagent[0], *subagent] + events, records = _drive( + [_Round(supervisor), _Round(two_leaves), _Round(tool), _Round(tool), _Round(answer)], + budget=TurnBudgetSpec(max_tool_calls=1, max_wall_clock_seconds=60.0), + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "tool" + assert len(records.tool_calls) == 1 + + +def test_a_cap_reached_exactly_by_leaves_is_detected_at_the_supervisor() -> None: + rounds = [_Round(events) for events in _delegating_rounds()] + events, records = _drive( + rounds, budget=TurnBudgetSpec(max_tool_calls=1, max_wall_clock_seconds=60.0) + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "supervisor" + assert len(records.tool_calls) == 1 + + +def test_the_token_cap_is_recorded_at_the_supervisor() -> None: + events, records = _drive( + [_direct_call_round()], + budget=TurnBudgetSpec(max_tool_calls=10, max_tokens=2, max_wall_clock_seconds=60.0), + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "supervisor" + + +def test_the_round_backstop_is_recorded_at_the_supervisor() -> None: + events, records = _drive([_direct_call_round()], max_rounds=1) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "supervisor" + + +def test_a_supervisor_call_cut_off_at_the_deadline_is_recorded_at_the_supervisor() -> None: + events, records = _drive( + [_Round(_direct_call_round().events, advance_after=1), _answer_round()], + budget=TurnBudgetSpec(max_tool_calls=10, max_wall_clock_seconds=60.0), + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "supervisor" + + +def test_a_refused_supervisor_request_is_recorded_at_the_supervisor() -> None: + events, records = _drive([_answer_round()], matrix=_with_limit("supervisor", 1)) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "supervisor" + + +def test_a_refused_subagent_request_is_recorded_at_the_subagent() -> None: + rounds = [_Round(events) for events in _delegating_rounds()] + events, records = _drive(rounds, matrix=_with_limit("subagent", 1)) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "subagent" + + +def test_a_refused_tool_tier_request_is_recorded_at_the_tool_tier() -> None: + rounds = [_Round(events) for events in _delegating_rounds()] + events, records = _drive(rounds, matrix=_with_limit("tool", 1)) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "tool" + + +def _cut_off_round() -> _Round: + """A round whose clock passes the deadline before its first event, so it ends unmetered.""" + return _Round( + [ + ProviderEvent(type="text_delta", text="working"), + ProviderEvent(type="usage", input_tokens=1, output_tokens=1), + ProviderEvent(type="completed", awaiting_tools=False), + ], + advance_after=0, + ) + + +def test_a_subagent_call_cut_off_at_the_deadline_is_recorded_at_the_subagent() -> None: + supervisor, *_ = _delegating_rounds() + events, records = _drive( + [_Round(supervisor), _cut_off_round()], + budget=TurnBudgetSpec(max_tool_calls=10, max_wall_clock_seconds=60.0), + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "subagent" + + +def test_a_tool_tier_call_cut_off_at_the_deadline_is_recorded_at_the_tool_tier() -> None: + supervisor, subagent, tool, _ = _delegating_rounds() + events, records = _drive( + [_Round(supervisor), _Round(subagent), _Round(tool, sleep_seconds=5.0)], + budget=TurnBudgetSpec(max_tool_calls=10, max_wall_clock_seconds=0.5), + real_clock=True, + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "tool" + + +def test_a_deadline_seen_at_the_subagent_round_boundary_is_recorded_at_the_subagent() -> None: + supervisor, subagent, tool, _ = _delegating_rounds() + subagent_continues = [*subagent[:-1], ProviderEvent(type="completed", awaiting_tools=True)] + events, records = _drive( + [ + _Round(supervisor), + _Round(subagent_continues, advance_after=len(subagent_continues)), + _Round(tool), + ], + budget=TurnBudgetSpec(max_tool_calls=10, max_wall_clock_seconds=60.0), + ) + _assert_exhausted(events) + assert records.budget_exhausted_tier == "subagent" + + +# -- supervisor direct-call truncation ---------------------------------------------------------- + + +@pytest.mark.parametrize( + ("body", "truncated"), + [ + ({"items": [], "truncated": True, "examined_count": 50}, True), + ({"items": [], "truncated": False}, False), + ({"items": []}, False), + ], +) +def test_a_supervisor_direct_call_records_the_truncation_its_result_reports( + body: dict[str, object], truncated: bool +) -> None: + def _dispatch(tool: RegisteredTool, tool_input: dict[str, object]) -> dict[str, Any]: + del tool, tool_input + return {"statusCode": 200, "body": body} + + _, records = _drive( + [_direct_call_round("search_opportunities"), _answer_round()], dispatch=_dispatch + ) + (call,) = records.tool_calls + assert call.role == "supervisor" + assert call.truncated is truncated diff --git a/tests/unit/test_check_canary_tenant_empty.py b/tests/unit/test_check_canary_tenant_empty.py index 524f960..2ef0b5c 100644 --- a/tests/unit/test_check_canary_tenant_empty.py +++ b/tests/unit/test_check_canary_tenant_empty.py @@ -386,7 +386,7 @@ def _instantiate_for_classification(exception_type: type[Exception]) -> Exceptio """Return an instance of ``exception_type``, bypassing ``__init__`` if construction fails.""" try: return exception_type() - except (TypeError, KeyError): + except TypeError, KeyError: return exception_type.__new__(exception_type) diff --git a/tests/unit/test_check_cost_withheld.py b/tests/unit/test_check_cost_withheld.py index 92a8347..11249ae 100644 --- a/tests/unit/test_check_cost_withheld.py +++ b/tests/unit/test_check_cost_withheld.py @@ -916,6 +916,16 @@ def test_a_tier_cost_figure_fails_while_provisional(self, tmp_path: Path) -> Non def provisional_stub_sweep(tmp_path_factory: pytest.TempPathFactory) -> tuple[Path, Path]: """One real stub sweep plus a scratch copy of `config/pricing.yaml` forced provisional. + Returns `(pricing_path, results_dir)`. + """ + return _run_provisional_stub_sweep(tmp_path_factory.mktemp("provisional_stub_sweep")) + + +def _run_provisional_stub_sweep( + root: Path, *, archive_raw: bool = False, repeats: int = 1 +) -> tuple[Path, Path]: + """Run a stub sweep into `root/results` with pricing forced provisional. + Returns `(pricing_path, results_dir)`. """ import boto3 @@ -928,7 +938,6 @@ def provisional_stub_sweep(tmp_path_factory: pytest.TempPathFactory) -> tuple[Pa def _noop_seeder(store: Store, *, tenant: str) -> None: del store, tenant - root = tmp_path_factory.mktemp("provisional_stub_sweep") pricing_path = root / "pricing.yaml" config_text = PRICING.read_text(encoding="utf-8") forced = re.sub(r"(?m)^provisional:\s*false\s*$", "provisional: true", config_text) @@ -944,7 +953,12 @@ def _noop_seeder(store: Store, *, tenant: str) -> None: with mock_aws(): client = boto3.client("dynamodb", region_name="us-east-1") create_all_tables(client) - run_sweep(store=Store(client=client), output_dir=results_dir) + run_sweep( + store=Store(client=client), + output_dir=results_dir, + archive_raw=archive_raw, + repeats=repeats, + ) return pricing_path, results_dir @@ -987,7 +1001,7 @@ def walk(node: object) -> None: for column, value in row.items(): try: float(value) - except (TypeError, ValueError): + except TypeError, ValueError: continue numeric_columns.add(column) assert set(_SWEEP_CLASSIFIED_KEYS) <= numeric_json_keys | numeric_columns @@ -1184,15 +1198,23 @@ def test_the_violation_names_the_full_path(self) -> None: "completion_rate", "accuracy", "cost_per_completed_task", - "cost_per_task", + "cost_per_applicable_task", "completed_task_latency_ms_p50", "completed_task_latency_ms_p95", "latency_sample_count", "invocation_count", "input_tokens", + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", "output_tokens", ) _DELEGATION_KINDS: tuple[str, ...] = ("data", "no_match", "denied", "tool_failure", "none") +_TASK_COUNT_KEYS: tuple[str, ...] = ( + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", +) def _summary_csv_columns() -> list[str]: @@ -1204,9 +1226,8 @@ def _summary_csv_columns() -> list[str]: for tier in _SUMMARY_TIERS for suffix in _SUMMARY_CSV_SUFFIXES ), - "summary_supervisor_budget_exhausted_task_count", + *(f"summary_{tier}_{key}" for tier in _SUMMARY_TIERS for key in _TASK_COUNT_KEYS), *(f"summary_subagent_delegation_{kind}" for kind in _DELEGATION_KINDS), - "summary_tool_truncated_task_count", *(f"summary_{tier}_retry_count" for tier in _SUMMARY_TIERS), ] @@ -1219,18 +1240,22 @@ def _summary_entry(tier: str, *, cost: float | None) -> dict[str, object]: "accuracy": 0.6, "cost_withheld_provisional": cost is None, "cost_per_completed_task": cost, - "cost_per_task": cost, + "cost_per_applicable_task": cost, "completed_task_latency_ms_p50": 1200.0, "completed_task_latency_ms_p95": 2500.0, "latency_sample_count": 3, "invocation_count": 9, "input_tokens": 1000, + "total_prompt_tokens": 1300, + "cache_read_tokens": 200, + "cache_write_tokens": 100, "output_tokens": 200, "retry_count": 1, + "budget_exhausted_task_count": 1, + "truncated_tool_call_count": None if tier == "subagent" else 3, + "truncated_task_count": None if tier == "subagent" else 2, } - if tier == "supervisor": - entry["budget_exhausted_task_count"] = 1 - elif tier == "subagent": + if tier == "subagent": entry["delegation_outcomes"] = { "data": 2, "no_match": 1, @@ -1238,8 +1263,6 @@ def _summary_entry(tier: str, *, cost: float | None) -> dict[str, object]: "tool_failure": 0, "none": 1, } - else: - entry["truncated_task_count"] = 2 return entry @@ -1266,7 +1289,9 @@ def _summary_matrix_json(*, cost: float | None = None) -> dict[str, object]: }, } return { + "record_shape_version": 2, "tier_comparison": { + "record_shape_version": 2, "columns": [ { "label": "anthropic", @@ -1280,7 +1305,7 @@ def _summary_matrix_json(*, cost: float | None = None) -> dict[str, object]: "tiers": {tier: [_summary_entry(tier, cost=cost)] for tier in _SUMMARY_TIERS}, "notes": ["Columns are arms in run order."], }, - "arms": [{"tier_task_metrics": arm_block}], + "arms": [{"record_shape_version": 2, "tier_task_metrics": arm_block}], "figure_semantics": {}, } @@ -1329,7 +1354,7 @@ def test_a_withheld_summary_raises_no_violation_while_provisional(self, tmp_path ) assert gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) == [] - @pytest.mark.parametrize("cost_key", ["cost_per_completed_task", "cost_per_task"]) + @pytest.mark.parametrize("cost_key", ["cost_per_completed_task", "cost_per_applicable_task"]) def test_a_numeric_summary_cost_key_is_one_violation( self, tmp_path: Path, cost_key: str ) -> None: @@ -1350,12 +1375,14 @@ def test_a_non_empty_summary_cost_column_is_one_violation_per_row(self, tmp_path tmp_path, pricing=PROVISIONAL_PRICING, artifacts={ - "matrix.csv": _summary_matrix_csv({"summary_supervisor_cost_per_task": "0.03"}) + "matrix.csv": _summary_matrix_csv( + {"summary_supervisor_cost_per_applicable_task": "0.03"} + ) }, ) violations = gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) assert len(violations) == 2, violations - assert all("summary_supervisor_cost_per_task" in v for v in violations) + assert all("summary_supervisor_cost_per_applicable_task" in v for v in violations) def test_an_unknown_numeric_key_beside_the_summary_is_still_reported( self, tmp_path: Path @@ -1376,7 +1403,7 @@ def test_an_unknown_numeric_key_beside_the_summary_is_still_reported( def test_no_summary_cost_key_or_column_is_allowlisted(self) -> None: cost_columns = [c for c in _summary_csv_columns() if "_cost_" in c] assert len(cost_columns) == 2 * len(_SUMMARY_TIERS) - for name in ("cost_per_completed_task", "cost_per_task", *cost_columns): + for name in ("cost_per_completed_task", "cost_per_applicable_task", *cost_columns): assert name not in gate._NON_CURRENCY_NUMERIC_FIELDS assert gate._COST_BEARING_NAME_PATTERN.search(name) @@ -1399,9 +1426,12 @@ def test_every_numeric_summary_csv_column_is_allowlisted(self) -> None: "invocation_count", "task_count", "budget_exhausted_task_count", + "truncated_tool_call_count", "truncated_task_count", "none", "retry_count", + "record_shape_version", + "total_prompt_tokens", ], ) def test_each_new_json_key_is_load_bearing( @@ -1422,7 +1452,17 @@ def test_each_new_json_key_is_load_bearing( assert all(f".{key} (" in violation for violation in violations), violations @pytest.mark.parametrize( - "column", ["summary_subagent_delegation_none", "summary_supervisor_retry_count"] + "column", + [ + "summary_subagent_delegation_none", + "summary_supervisor_retry_count", + *( + f"summary_{tier}_{key}" + for tier in _SUMMARY_TIERS + for key in ("total_prompt_tokens", "cache_read_tokens", "cache_write_tokens") + ), + *(f"summary_{tier}_{key}" for tier in _SUMMARY_TIERS for key in _TASK_COUNT_KEYS), + ], ) def test_each_new_csv_column_is_load_bearing( self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch, column: str @@ -1584,3 +1624,188 @@ def test_a_published_arm_cost_total_is_refused_while_provisional(self, tmp_path: ) violations = gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) assert violations and all("arm_cost_total" in v for v in violations), violations + + +# --------------------------------------------------------------------------- +# Pre-aggregation archives carry non-currency keys only. +# --------------------------------------------------------------------------- + + +@pytest.fixture(scope="class") +def provisional_archived_stub_sweep(tmp_path_factory: pytest.TempPathFactory) -> tuple[Path, Path]: + """A two-repeat stub sweep with raw archives, under pricing forced provisional.""" + return _run_provisional_stub_sweep( + tmp_path_factory.mktemp("provisional_archived_stub_sweep"), archive_raw=True, repeats=2 + ) + + +def _pre_aggregation_archives(results_dir: Path) -> list[Path]: + """The sweep's pre-aggregation archives, asserted present.""" + archives = sorted((results_dir / "raw" / "pre-aggregation").glob("*.json")) + assert archives, "the sweep wrote no pre-aggregation archive" + return archives + + +#: Keys a stub sweep's pre-aggregation archive carries as numbers. +_ARCHIVE_STUB_NUMERIC_KEYS: tuple[str, ...] = ("repeat_index", "read_tokens", "write_tokens") + +#: Keys only a live archive carries as numbers; a stub leaves latency unmeasured. +_ARCHIVE_LIVE_NUMERIC_KEYS: tuple[str, ...] = ("latency_ms", "task_latencies_ms") + + +def _live_shaped_pre_aggregation_archive() -> str: + """A pre-aggregation archive with the live-only numeric keys and string-valued task keys.""" + import json + + return json.dumps( + { + "record_shape_version": 3, + "model_id": "anthropic.claude-opus-5-5", + "mode": "live", + "call_latency_samples": [{"tier": "supervisor", "latency_ms": 1440.4}], + "task_latencies_ms": [5120.0, 6880.5], + "correctness_by_task": {"gt-01-investigation-pd01-successor": [1.0, 0.5]}, + "invocation_attributions": [ + { + "task_id": "gt-01-investigation-pd01-successor", + "repeat_index": 1, + "latency_ms": 980.2, + "tokens": {"input_tokens": 1200, "output_tokens": 300}, + "cache": {"read_tokens": 900, "write_tokens": 0}, + } + ], + "task_scores": [ + { + "task_id": "gt-04-investigation-turn-budget-partial", + "repeat_index": 1, + "budget_exhausted": True, + "budget_exhausted_tier": "supervisor", + "correctness": 0.5, + } + ], + } + ) + + +class TestPreAggregationArchives: + """Under provisional pricing an archive's non-currency keys pass; a currency key still fails.""" + + def test_the_archive_carries_each_non_currency_key_as_a_number( + self, provisional_archived_stub_sweep: tuple[Path, Path] + ) -> None: + import json + + _, results_dir = provisional_archived_stub_sweep + numeric_keys: set[str] = set() + by_task_entries: list[object] = [] + + def walk(node: object) -> None: + if isinstance(node, dict): + for key, value in node.items(): + if gate._is_published_currency_value(value): + numeric_keys.add(key) + walk(value) + elif isinstance(node, list): + for value in node: + walk(value) + + for archive in _pre_aggregation_archives(results_dir): + document = json.loads(archive.read_text(encoding="utf-8")) + walk(document) + by_task_entries.extend(document["correctness_by_task"].values()) + assert set(_ARCHIVE_STUB_NUMERIC_KEYS) <= numeric_keys + assert any( + gate._is_published_currency_value(score) + for entry in by_task_entries + if isinstance(entry, list) + for score in entry + ) + + def test_the_gate_passes_the_archived_sweep_under_provisional_pricing( + self, provisional_archived_stub_sweep: tuple[Path, Path] + ) -> None: + pricing_path, results_dir = provisional_archived_stub_sweep + _pre_aggregation_archives(results_dir) + assert gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) == [] + + @pytest.mark.parametrize("key", _ARCHIVE_STUB_NUMERIC_KEYS) + def test_each_archive_key_exemption_is_load_bearing( + self, + provisional_archived_stub_sweep: tuple[Path, Path], + monkeypatch: pytest.MonkeyPatch, + key: str, + ) -> None: + pricing_path, results_dir = provisional_archived_stub_sweep + monkeypatch.setattr( + gate, "_NON_CURRENCY_NUMERIC_FIELDS", gate._NON_CURRENCY_NUMERIC_FIELDS - {key} + ) + violations = gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) + assert violations + assert all(key in violation for violation in violations), violations + + def test_the_task_keyed_correctness_map_exemption_is_load_bearing( + self, provisional_archived_stub_sweep: tuple[Path, Path], monkeypatch: pytest.MonkeyPatch + ) -> None: + pricing_path, results_dir = provisional_archived_stub_sweep + monkeypatch.setattr(gate, "_ID_KEYED_NON_CURRENCY_MAPS", frozenset()) + violations = gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) + assert violations + assert all("$.correctness_by_task.gt-" in violation for violation in violations), violations + + def test_a_live_shaped_archive_passes_under_provisional_pricing(self, tmp_path: Path) -> None: + pricing_path, results_dir = _tree( + tmp_path, + pricing=PROVISIONAL_PRICING, + artifacts={"raw/pre-aggregation/arm-0.json": _live_shaped_pre_aggregation_archive()}, + ) + assert gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) == [] + + @pytest.mark.parametrize("key", _ARCHIVE_LIVE_NUMERIC_KEYS) + def test_each_live_archive_key_exemption_is_load_bearing( + self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch, key: str + ) -> None: + pricing_path, results_dir = _tree( + tmp_path, + pricing=PROVISIONAL_PRICING, + artifacts={"raw/pre-aggregation/arm-0.json": _live_shaped_pre_aggregation_archive()}, + ) + monkeypatch.setattr( + gate, "_NON_CURRENCY_NUMERIC_FIELDS", gate._NON_CURRENCY_NUMERIC_FIELDS - {key} + ) + violations = gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) + assert violations + assert all(key in violation for violation in violations), violations + + @pytest.mark.parametrize( + ("planted_key", "plant"), + [ + ("cost_input", lambda doc: doc["invocation_attributions"][0].update(cost_input=0.47)), + ( + "spend", + lambda doc: doc["invocation_attributions"][0].update(spend={"read_tokens": 0.47}), + ), + ("cost_by_task", lambda doc: doc.update(cost_by_task={"gt-01": [0.47]})), + ( + "billing", + lambda doc: doc.update(billing={"correctness_by_task": {"gt-01": [0.47]}}), + ), + ], + ) + def test_a_currency_key_planted_in_the_archive_still_fails( + self, + provisional_archived_stub_sweep: tuple[Path, Path], + tmp_path: Path, + planted_key: str, + plant: object, + ) -> None: + import json + + pricing_path, source = provisional_archived_stub_sweep + results_dir = _copy_results(source, tmp_path) + archive = _pre_aggregation_archives(results_dir)[0] + document = json.loads(archive.read_text(encoding="utf-8")) + assert callable(plant) + plant(document) + archive.write_text(json.dumps(document, indent=2), encoding="utf-8") + violations = gate.run_gate(pricing_path=pricing_path, results_dir=results_dir) + assert [v for v in violations if planted_key in v and "0.47" in v], violations diff --git a/tests/unit/test_ci_parity.py b/tests/unit/test_ci_parity.py index 1d9daab..6b3b580 100644 --- a/tests/unit/test_ci_parity.py +++ b/tests/unit/test_ci_parity.py @@ -1990,8 +1990,8 @@ def _pip_pin_violations(doc: dict[str, Any]) -> list[str]: problems.append( f"{name}: venv at {venv_at}, pip pin at {pin_at}, lock install at {lock_at}" ) - if not re.fullmatch(r"\d+\.\d+\.\d+", str(_env_of(doc, job).get("PIP_VERSION", ""))): - problems.append(f"{name}: PIP_VERSION is not an exact X.Y.Z pin") + if not re.fullmatch(r"\d+\.\d+(\.\d+)?", str(_env_of(doc, job).get("PIP_VERSION", ""))): + problems.append(f"{name}: PIP_VERSION is not an exact X.Y or X.Y.Z release") return problems @@ -2016,6 +2016,12 @@ def test_every_venv_installs_the_pinned_pip_before_the_lock() -> None: assert _pip_pin_violations(yaml.safe_load(floating)), ( f"{path.name}: a range PIP_VERSION went unseen" ) + pinned = str(_env_of(doc, _verify_job_of(path, doc)).get("PIP_VERSION")) + major_only = text.replace(f'PIP_VERSION: "{pinned}"', 'PIP_VERSION: "26"', 1) + assert major_only != text, f"{path.name}: the PIP_VERSION anchor is absent" + assert _pip_pin_violations(yaml.safe_load(major_only)), ( + f"{path.name}: a major-only PIP_VERSION went unseen" + ) def _declared_pins(path: Path, name: str) -> set[str]: @@ -2100,6 +2106,91 @@ def test_gitlab_node_is_a_digest_verified_release_on_the_relay_runtime_major() - assert "apt-get" not in block, "Node comes from the distribution, not the pinned release" +#: Shared libraries the official Node linux tarball links against that a python slim image lacks. +_NODE_TARBALL_APT_LIBS = frozenset({"libatomic1"}) + + +def _frontend_missing_node_libs(doc: dict[str, Any]) -> set[str]: + """Node runtime libraries no `apt-get install` in the GitLab frontend job provides.""" + job = _ci_jobs_from_doc(doc)["frontend"] + installed: set[str] = set().union(*_apt_install_sets(job)) + return set(_NODE_TARBALL_APT_LIBS - installed) + + +def test_gitlab_frontend_job_installs_the_libraries_the_node_tarball_needs() -> None: + """The pinned Node binary cannot start on the python slim image without `libatomic1`.""" + assert _frontend_missing_node_libs(_gitlab_doc()) == set() + + text = GITLAB_CI_PATH.read_text(encoding="utf-8") + anchor = "curl ca-certificates libatomic1" + assert text.count(anchor) == 1, "the frontend apt line is not where this control expects it" + dropped = yaml.safe_load(text.replace(anchor, "curl ca-certificates")) + assert _frontend_missing_node_libs(dropped) == {"libatomic1"}, ( + "a frontend job without libatomic1 went unseen" + ) + + +def test_gitlab_frontend_node_is_a_digest_verified_release_asserted_against_nvmrc() -> None: + """The GitLab frontend job runs a python image and installs Node from a pinned tarball.""" + doc = _gitlab_doc() + job = _ci_jobs_from_doc(doc)[_FRONTEND_JOB] + assert str(job.get("image", "")).startswith("python:"), ( + f"frontend job image {job.get('image')!r} is not a python image" + ) + for packages in _apt_install_sets(job): + assert not {"python3", "python3-venv"} & packages, ( + f"the frontend job apt-installs the distribution Python: {sorted(packages)}" + ) + env = _env_of(doc, job) + for arch in ("X64", "ARM64"): + digest = str(env.get(f"FRONTEND_NODE_SHA256_{arch}", "")) + assert re.fullmatch(r"[0-9a-f]{64}", digest), ( + f"FRONTEND_NODE_SHA256_{arch} is not a literal sha256" + ) + assert env["FRONTEND_NODE_SHA256_X64"] != env["FRONTEND_NODE_SHA256_ARM64"] + + block, _ = _pinned_install(GITLAB_CI_PATH, _NODE_RELEASE_HOST, doc, _FRONTEND_JOB) + nvmrc_at = block.find("frontend/.nvmrc") + verify_at = block.find("sha256sum --check --strict") + unpack_at = block.find("tar -xJf") + run_at = block.find("node --version") + assert -1 < nvmrc_at < verify_at < unpack_at < run_at, ( + "the frontend Node is unpacked or run before its pin and digest are checked" + ) + assert "SHASUMS256" not in block, "the digest is fetched beside the asset rather than pinned" + assert "command -v node" in block, "the install never asserts which node PATH resolves" + assert '"v${pinned}"' in block, "the install never compares node --version with .nvmrc" + + +def _frontend_pin_prefix(doc: dict[str, Any]) -> tuple[str, dict[str, str]]: + block, env = _pinned_install(GITLAB_CI_PATH, _NODE_RELEASE_HOST, doc, _FRONTEND_JOB) + return block[: block.index('case "$(uname -m)"')], env + + +@pytest.mark.parametrize(("nvmrc", "expect_ok"), [(None, True), ("26.0.0", False)]) +def test_the_frontend_node_pin_assertion_runs_against_nvmrc( + nvmrc: str | None, expect_ok: bool, tmp_path: Path +) -> None: + """Executed: the frontend install stops before any download when .nvmrc differs from the pin.""" + prefix, env = _frontend_pin_prefix(_gitlab_doc()) + (tmp_path / "frontend").mkdir() + pinned = (REPO_ROOT / "frontend" / ".nvmrc").read_text(encoding="utf-8") + (tmp_path / "frontend" / ".nvmrc").write_text( + pinned if nvmrc is None else nvmrc + "\n", encoding="utf-8" + ) + result = proc_run.run( + ["bash", "-c", "set -euo pipefail\n" + prefix], + cwd=tmp_path, + env={"PATH": os.environ["PATH"], **env}, + capture_output=True, + text=True, + check=False, + ) + assert (result.returncode == 0) is expect_ok, result.stderr[-300:] + if not expect_ok: + assert "FRONTEND_NODE_VERSION" in result.stderr, result.stderr[-300:] + + def test_github_node_is_the_exact_pinned_release_and_is_asserted_on_path() -> None: """setup-node gets the exact NODE_VERSION via the derivation, and a later step asserts it.""" steps = list(_verify_job().get("steps", [])) @@ -2272,15 +2363,24 @@ def test_the_verify_job_builds_the_zips_its_gates_verify() -> None: # `tar` and `uname` replaced, so a swallowed or misdirected check is observed rather than read. # --------------------------------------------------------------------------- -#: `(definition, release host)` for each install verified against a pinned digest. -_PINNED_RELEASE_INSTALLS = ( - (GITLAB_CI_PATH, GITLEAKS_RELEASE_HOST), - (GITLAB_CI_PATH, _SHELLCHECK_RELEASE_HOST), - (GITLAB_CI_PATH, _NODE_RELEASE_HOST), - (WORKFLOW_PATH, GITLEAKS_RELEASE_HOST), - (WORKFLOW_PATH, _SHELLCHECK_RELEASE_HOST), +#: GitLab jobs that install a pinned Node release: the relay's in `verify`, the SPA's in `frontend`. +_GITLAB_NODE_JOBS = ("verify", "frontend") + +#: `(definition, release host, job or None for any)` for each install verified against a digest. +_PINNED_RELEASE_INSTALLS: tuple[tuple[Path, str, str | None], ...] = ( + (GITLAB_CI_PATH, GITLEAKS_RELEASE_HOST, None), + (GITLAB_CI_PATH, _SHELLCHECK_RELEASE_HOST, None), + *((GITLAB_CI_PATH, _NODE_RELEASE_HOST, job) for job in _GITLAB_NODE_JOBS), + (WORKFLOW_PATH, GITLEAKS_RELEASE_HOST, None), + (WORKFLOW_PATH, _SHELLCHECK_RELEASE_HOST, None), ) + +def _release_install_id(path: Path, host: str, job: str | None) -> str: + tool = host.split("/")[-3] if "github" in host else "node" + return f"{path.name}:{tool}" + (f":{job}" if job else "") + + _VERIFIED_PATH_RE = re.compile(r'echo "\$\{?\w+\}? ([^"]+)" \| sha256sum\b') _EXTRACTED_PATH_RE = re.compile(r'\btar -x\w*f "([^"]+)"') _DOWNLOADED_PATH_RE = re.compile(r'\bcurl\b[^\n]*?-o "([^"]+)"') @@ -2288,12 +2388,14 @@ def test_the_verify_job_builds_the_zips_its_gates_verify() -> None: def _pinned_install( - path: Path, host: str, doc: dict[str, Any] | None = None + path: Path, host: str, doc: dict[str, Any] | None = None, job_name: str | None = None ) -> tuple[str, dict[str, str]]: - """Return the shell block installing from `host` and the variables it runs with.""" + """Return the shell block installing from `host` (in `job_name`, if given) and its variables.""" doc = _load_ci(path) if doc is None else doc found: list[tuple[str, dict[str, str]]] = [] - for job in _ci_jobs_from_doc(doc).values(): + for name, job in _ci_jobs_from_doc(doc).items(): + if job_name is not None and name != job_name: + continue job_env = {str(k): str(v) for k, v in _env_of(doc, job).items()} if "steps" in job: for step in job.get("steps") or []: @@ -2444,18 +2546,15 @@ def _effective_digest_problems( @pytest.mark.parametrize( - ("path", "host"), + ("path", "host", "job_name"), _PINNED_RELEASE_INSTALLS, - ids=[ - f"{p.name}:{h.split('/')[-3] if 'github' in h else 'node'}" - for p, h in _PINNED_RELEASE_INSTALLS - ], + ids=[_release_install_id(*entry) for entry in _PINNED_RELEASE_INSTALLS], ) def test_each_pinned_release_install_verifies_the_file_it_unpacks( - path: Path, host: str, tmp_path: Path + path: Path, host: str, job_name: str | None, tmp_path: Path ) -> None: """Static shape plus an executed run: a wrong digest never reaches tar, the right one does.""" - script, env = _pinned_install(path, host) + script, env = _pinned_install(path, host, job_name=job_name) assert _digest_check_problems(script) == [], path.name assert _effective_digest_problems(path, script, env, tmp_path) == [], path.name @@ -2474,62 +2573,71 @@ def test_each_pinned_release_install_verifies_the_file_it_unpacks( @pytest.mark.parametrize("mutant", sorted(_DIGEST_CHECK_MUTANTS)) @pytest.mark.parametrize( - ("path", "host"), + ("path", "host", "job_name"), _PINNED_RELEASE_INSTALLS, - ids=[ - f"{p.name}:{h.split('/')[-3] if 'github' in h else 'node'}" - for p, h in _PINNED_RELEASE_INSTALLS - ], + ids=[_release_install_id(*entry) for entry in _PINNED_RELEASE_INSTALLS], ) def test_non_vacuity_a_disabled_digest_check_is_caught( - path: Path, host: str, mutant: str, tmp_path: Path + path: Path, host: str, job_name: str | None, mutant: str, tmp_path: Path ) -> None: """Each mutant of each install's digest line is reported, statically or by the executed run.""" text = path.read_text(encoding="utf-8") - original, _ = _pinned_install(path, host) + original, _ = _pinned_install(path, host, job_name=job_name) line = next(line for line in original.splitlines() if "sha256sum" in line) mutated_line = _DIGEST_CHECK_MUTANTS[mutant](line) assert mutated_line != line, f"{mutant}: the mutant changed nothing" assert text.count(line) == 1, f"{path.name}: the digest line is not unique in the file" - script, env = _pinned_install(path, host, yaml.safe_load(text.replace(line, mutated_line))) + script, env = _pinned_install( + path, host, yaml.safe_load(text.replace(line, mutated_line)), job_name=job_name + ) caught = _digest_check_problems(script) + _effective_digest_problems( path, script, env, tmp_path ) assert caught, f"{path.name} {host}: the {mutant!r} mutant went unseen" -#: GitLab installs that select their asset by `uname -m`: host -> {machine: (digest var, asset)}. -_GITLAB_PER_ARCH_INSTALLS: dict[str, dict[str, tuple[str, str]]] = { - GITLEAKS_RELEASE_HOST: { +#: GitLab installs that select their asset by `uname -m`: +#: (host, job or None for any) -> {machine: (digest var, asset)}. +_GITLAB_PER_ARCH_INSTALLS: dict[tuple[str, str | None], dict[str, tuple[str, str]]] = { + (GITLEAKS_RELEASE_HOST, None): { "x86_64": ("GITLEAKS_SHA256_X64", "_linux_x64.tar.gz"), "aarch64": ("GITLEAKS_SHA256_ARM64", "_linux_arm64.tar.gz"), }, - _SHELLCHECK_RELEASE_HOST: { + (_SHELLCHECK_RELEASE_HOST, None): { "x86_64": ("SHELLCHECK_SHA256_X86_64", ".linux.x86_64.tar.xz"), "aarch64": ("SHELLCHECK_SHA256_AARCH64", ".linux.aarch64.tar.xz"), }, - _NODE_RELEASE_HOST: { + (_NODE_RELEASE_HOST, "verify"): { "x86_64": ("NODE_SHA256_X64", "-linux-x64.tar.xz"), "aarch64": ("NODE_SHA256_ARM64", "-linux-arm64.tar.xz"), }, + (_NODE_RELEASE_HOST, "frontend"): { + "x86_64": ("FRONTEND_NODE_SHA256_X64", "-linux-x64.tar.xz"), + "aarch64": ("FRONTEND_NODE_SHA256_ARM64", "-linux-arm64.tar.xz"), + }, } +def _from_arch_case(host: str, script: str) -> str: + """A Node install's script from its arch `case` on, past the version assertions above it.""" + return script[script.index('case "$(uname -m)"') :] if host == _NODE_RELEASE_HOST else script + + @pytest.mark.parametrize("machine", ["x86_64", "aarch64"]) @pytest.mark.parametrize( - "host", - sorted(_GITLAB_PER_ARCH_INSTALLS), - ids=lambda h: h.split("/")[-3] if "github" in h else "node", + "install", + sorted(_GITLAB_PER_ARCH_INSTALLS, key=str), + ids=lambda i: _release_install_id(GITLAB_CI_PATH, *i).split(":", 1)[1], ) def test_each_gitlab_install_fetches_and_verifies_the_asset_of_the_runner_arch( - host: str, machine: str, tmp_path: Path + install: tuple[str, str | None], machine: str, tmp_path: Path ) -> None: """On each runner arch the install fetches that arch's asset and accepts only that arch's digest.""" - script, env = _pinned_install(GITLAB_CI_PATH, host) - if host == _NODE_RELEASE_HOST: - script = script[script.index('case "$(uname -m)"') :] - own_var, asset_suffix = _GITLAB_PER_ARCH_INSTALLS[host][machine] - other_var = next(v for m, (v, _) in _GITLAB_PER_ARCH_INSTALLS[host].items() if m != machine) + host, job_name = install + script, env = _pinned_install(GITLAB_CI_PATH, host, job_name=job_name) + script = _from_arch_case(host, script) + own_var, asset_suffix = _GITLAB_PER_ARCH_INSTALLS[install][machine] + other_var = next(v for m, (v, _) in _GITLAB_PER_ARCH_INSTALLS[install].items() if m != machine) assert {own_var, other_var} <= set(env), ( f"{host}: the job does not define {own_var}/{other_var}" ) @@ -2566,10 +2674,9 @@ def test_each_gitlab_install_fetches_and_verifies_the_asset_of_the_runner_arch( def test_an_unpinned_runner_arch_stops_each_gitlab_install(tmp_path: Path) -> None: """A runner arch with no pinned digest fails the install before anything is fetched.""" - for host in sorted(_GITLAB_PER_ARCH_INSTALLS): - script, env = _pinned_install(GITLAB_CI_PATH, host) - if host == _NODE_RELEASE_HOST: - script = script[script.index('case "$(uname -m)"') :] + for host, job_name in sorted(_GITLAB_PER_ARCH_INSTALLS, key=str): + script, env = _pinned_install(GITLAB_CI_PATH, host, job_name=job_name) + script = _from_arch_case(host, script) genuine = hashlib.sha256(_STAND_IN_ARTEFACT.encode()).hexdigest() rc, stderr, downloaded, tar_args = _run_install_prefix( GITLAB_CI_PATH, script, env, tmp_path, genuine, machine="riscv64" @@ -2593,9 +2700,10 @@ def test_gitlab_gitleaks_pins_the_github_release_and_a_digest_per_arch() -> None assert arm64 != x64, "the arm64 digest is the x64 digest" -def test_non_vacuity_extracting_before_verifying_is_caught(tmp_path: Path) -> None: - """Moving the Node tar ahead of its digest check is reported.""" - script, env = _pinned_install(GITLAB_CI_PATH, _NODE_RELEASE_HOST) +@pytest.mark.parametrize("job_name", _GITLAB_NODE_JOBS) +def test_non_vacuity_extracting_before_verifying_is_caught(job_name: str, tmp_path: Path) -> None: + """Moving a Node tar ahead of its digest check is reported.""" + script, env = _pinned_install(GITLAB_CI_PATH, _NODE_RELEASE_HOST, job_name=job_name) lines = _logical_lines(script) check_at = next(i for i, line in enumerate(lines) if "sha256sum" in line) tar_at = next(i for i, line in enumerate(lines) if _EXTRACTED_PATH_RE.search(line)) @@ -2693,6 +2801,7 @@ def test_the_journeys_install_from_the_lockfile_and_never_resolve_versions() -> TS_CONTRACT_FILES = ( "tests/integration/test_envelope_groups_contract.py", "tests/integration/test_eval_envelopes_contract.py", + "tests/integration/test_resume_contract.py", ) _FRONTEND_JOB = "frontend" @@ -2706,10 +2815,8 @@ def _sets_ts_contracts(path: Path, job: dict[str, Any]) -> bool: def _runs_every_ts_contract(job: dict[str, Any]) -> bool: - return any( - "pytest" in scalar and all(name in scalar for name in TS_CONTRACT_FILES) - for scalar in _job_scalars(job) - ) + pytest_steps = [scalar for scalar in _job_scalars(job) if "pytest" in scalar] + return all(any(name in step for step in pytest_steps) for name in TS_CONTRACT_FILES) def _ts_contract_violations(path: Path, jobs: dict[str, Any]) -> list[str]: @@ -2723,7 +2830,7 @@ def _ts_contract_violations(path: Path, jobs: dict[str, Any]) -> list[str]: f"{path.name}: the frontend job does not set {TS_CONTRACTS_REQUIRE_ENV_VAR}=1" ) if not _runs_every_ts_contract(frontend): - problems.append(f"{path.name}: the frontend job does not run both TS contract files") + problems.append(f"{path.name}: the frontend job does not run every TS contract file") for name, job in jobs.items(): if name != _FRONTEND_JOB and _sets_ts_contracts(path, job): problems.append( @@ -2740,10 +2847,21 @@ def test_the_ts_contracts_variable_has_a_reader_under_tests() -> None: @pytest.mark.parametrize("path", [WORKFLOW_PATH, GITLAB_CI_PATH], ids=lambda p: p.name) def test_only_the_frontend_job_runs_the_ts_contracts_and_requires_them(path: Path) -> None: - """The frontend job sets the variable and runs both files; no Node-22 job sets it.""" + """The frontend job sets the variable and runs every file; no Node-22 job sets it.""" assert _ts_contract_violations(path, _ci_jobs(path)) == [] +@pytest.mark.parametrize("path", [WORKFLOW_PATH, GITLAB_CI_PATH], ids=lambda p: p.name) +@pytest.mark.parametrize("contract", TS_CONTRACT_FILES) +def test_dropping_a_ts_contract_step_is_a_violation(path: Path, contract: str) -> None: + """Removing the lines that name one contract file leaves the frontend job in violation.""" + text = path.read_text(encoding="utf-8") + assert contract in text + stripped = "\n".join(line for line in text.splitlines() if contract not in line) + violations = _ts_contract_violations(path, _ci_jobs_from_doc(yaml.safe_load(stripped))) + assert any("does not run every TS contract file" in v for v in violations), violations + + def test_make_verify_does_not_export_the_ts_contracts_variable() -> None: """The verify jobs run Node 22, so `make verify` must not turn the skip into a failure.""" makefile_text = MAKEFILE_PATH.read_text(encoding="utf-8") @@ -2850,3 +2968,80 @@ def is_diff(entry: Any) -> bool: early = [e for e in entries if is_diff(e)] + dropped assert _wire_tuning_violations(path, {**jobs, _FRONTEND_JOB: {**frontend, key: early}}) + + +# --------------------------------------------------------------------------- +# The tier-comparison UI contract rewrites the frontend's fixture, and the rewrite is diffed against +# the committed copy, in both CI frontend jobs. +# --------------------------------------------------------------------------- + +TIER_COMPARISON_FIXTURE = "frontend/src/pages/evals/__fixtures__/tierComparison.json" +_TIER_COMPARISON_WRITER = "tests/integration/test_tier_comparison_ui_contract.py" +_TIER_COMPARISON_DIFF = f"git diff --exit-code -- {TIER_COMPARISON_FIXTURE}" + + +def _tier_comparison_violations(path: Path, jobs: dict[str, Any]) -> list[str]: + """Why the frontend job does not diff the fixture after the contract test that writes it.""" + frontend = jobs.get(_FRONTEND_JOB) + if not isinstance(frontend, dict): + return [f"{path.name}: no `{_FRONTEND_JOB}` job"] + commands = _job_commands(frontend) + writer = [i for i, c in enumerate(commands) if "pytest" in c and _TIER_COMPARISON_WRITER in c] + diff = [i for i, c in enumerate(commands) if c.strip() == _TIER_COMPARISON_DIFF] + if not writer: + return [f"{path.name}: the frontend job never runs `{_TIER_COMPARISON_WRITER}`"] + if not diff: + return [f"{path.name}: the frontend job never runs `{_TIER_COMPARISON_DIFF}`"] + if max(diff) < min(writer): + return [f"{path.name}: `{_TIER_COMPARISON_DIFF}` runs before the contract test"] + return [] + + +def test_the_tier_comparison_fixture_is_tracked_and_written_by_the_contract_test() -> None: + """The diffed path is tracked, and the contract test still writes exactly that path.""" + tracked = proc_run.run( + ["git", "ls-files", "--error-unmatch", TIER_COMPARISON_FIXTURE], + cwd=REPO_ROOT, + capture_output=True, + check=False, + ) + assert tracked.returncode == 0, TIER_COMPARISON_FIXTURE + from tests.integration import test_tier_comparison_ui_contract as writer + + assert writer.FRONTEND_FIXTURE == REPO_ROOT / TIER_COMPARISON_FIXTURE + + +@pytest.mark.parametrize("path", [WORKFLOW_PATH, GITLAB_CI_PATH], ids=lambda p: p.name) +def test_the_frontend_job_diffs_the_tier_comparison_fixture_after_its_contract_test( + path: Path, +) -> None: + """A regenerated fixture that differs from the committed copy fails the frontend job.""" + assert _tier_comparison_violations(path, _ci_jobs(path)) == [] + + +@pytest.mark.parametrize("path", [WORKFLOW_PATH, GITLAB_CI_PATH], ids=lambda p: p.name) +def test_non_vacuity_a_missing_or_early_tier_comparison_diff_is_detected(path: Path) -> None: + """Dropping the diff, dropping the writer, or diffing before the writer each reads as a + violation.""" + jobs = _ci_jobs(path) + assert _tier_comparison_violations(path, jobs) == [], "fixture assumption broken" + frontend = jobs[_FRONTEND_JOB] + key = "steps" if isinstance(frontend.get("steps"), list) else "script" + entries = list(frontend[key]) + + def is_diff(entry: Any) -> bool: + return _TIER_COMPARISON_DIFF in json.dumps(entry) + + def is_writer(entry: Any) -> bool: + return _TIER_COMPARISON_WRITER in json.dumps(entry) + + no_diff = [e for e in entries if not is_diff(e)] + assert len(no_diff) == len(entries) - 1 + assert _tier_comparison_violations(path, {**jobs, _FRONTEND_JOB: {**frontend, key: no_diff}}) + + no_writer = [e for e in entries if not is_writer(e)] + assert len(no_writer) == len(entries) - 1 + assert _tier_comparison_violations(path, {**jobs, _FRONTEND_JOB: {**frontend, key: no_writer}}) + + early = [e for e in entries if is_diff(e)] + no_diff + assert _tier_comparison_violations(path, {**jobs, _FRONTEND_JOB: {**frontend, key: early}}) diff --git a/tests/unit/test_conversation_history.py b/tests/unit/test_conversation_history.py index 7ae3363..5c91256 100644 --- a/tests/unit/test_conversation_history.py +++ b/tests/unit/test_conversation_history.py @@ -2,25 +2,84 @@ """Server-side conversation history: identity+tenant scope, size bound, redaction, no cross-session. The store enforces its own `(rep_id, tenant)` scope, so a foreign-principal read is denied with no -cancellation marker involved. +cancellation marker involved. The contract tests run against both the in-memory store and the +DynamoDB store (over a `moto`-mocked client); the DynamoDB-only tests cover expiry, the item +shape and the optimistic-version retry. """ from __future__ import annotations +from collections.abc import Callable, Iterator, Mapping +from datetime import UTC, datetime, timedelta +from typing import Any + +import boto3 import pytest +from moto import mock_aws from agents.conversation_history import ( DEFAULT_MAX_FIELD_CHARS, + DEFAULT_TTL_SECONDS, + HISTORY_ITEM_ATTRIBUTES, + HISTORY_KIND, HISTORY_SCOPE, + HISTORY_TABLE, + MAX_WRITE_ATTEMPTS, + RETRY_BACKOFF_SECONDS, TRUNCATION_SUFFIX, + ConversationHistoryStore, + DynamoDbConversationHistory, HistoryTurn, + HistoryWriteConflict, InMemoryConversationHistory, ) from crm.authz import Identity -from crm.errors import ScopeDenied, ValidationFailed +from crm.errors import Conflict, CrmError, ScopeDenied, ValidationFailed +from crm.store import keys +from crm.store.provisioning import create_all_tables +from crm.store.store import Store + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") _SESSION = "session-abc" +_T0 = datetime(2026, 11, 15, 8, 0, tzinfo=UTC) + +#: Builds a store under test from `(max_turns, max_field_chars)`. +StoreFactory = Callable[..., ConversationHistoryStore] + + +class _Clock: + """A settable clock for the DynamoDB store.""" + + def __init__(self, now: datetime = _T0) -> None: + self.now = now + + def __call__(self) -> datetime: + return self.now + + +@pytest.fixture +def ddb_store() -> Iterator[Store]: + """A `Store` over a moto-mocked DynamoDB client with every declared table created.""" + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + yield Store(client=client) + + +@pytest.fixture(params=["memory", "dynamodb"]) +def make_store(request: pytest.FixtureRequest) -> Iterator[StoreFactory]: + """A factory for the store under test, parametrised over both implementations.""" + if request.param == "memory": + yield lambda **kwargs: InMemoryConversationHistory(**kwargs) + return + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + backing = Store(client=client) + yield lambda **kwargs: DynamoDbConversationHistory(backing, clock=_Clock(), **kwargs) + def _identity(*, rep_id: str = "rep-1", tenant: str = "demo") -> Identity: """The identity shape `decode_identity` produces for a Hosted-UI caller.""" @@ -38,8 +97,8 @@ def _identity(*, rep_id: str = "rep-1", tenant: str = "demo") -> Identity: # --- basic record / read --------------------------------------------------------------------- -def test_records_and_returns_prior_turns_oldest_first() -> None: - store = InMemoryConversationHistory() +def test_records_and_returns_prior_turns_oldest_first(make_store: StoreFactory) -> None: + store = make_store() ident = _identity() store.record_turn(_SESSION, identity=ident, prompt="hello", answer="hi there") store.record_turn(_SESSION, identity=ident, prompt="and again", answer="second answer") @@ -51,14 +110,14 @@ def test_records_and_returns_prior_turns_oldest_first() -> None: ) -def test_a_new_or_unknown_session_reads_empty_not_denied() -> None: +def test_a_new_or_unknown_session_reads_empty_not_denied(make_store: StoreFactory) -> None: # The production path reads before recording, so a brand-new session must not raise. - store = InMemoryConversationHistory() + store = make_store() assert store.history_for("never-seen", identity=_identity()) == () -def test_blank_session_id_is_rejected_on_read_and_write() -> None: - store = InMemoryConversationHistory() +def test_blank_session_id_is_rejected_on_read_and_write(make_store: StoreFactory) -> None: + store = make_store() ident = _identity() with pytest.raises(ValidationFailed): store.history_for(" ", identity=ident) @@ -69,9 +128,11 @@ def test_blank_session_id_is_rejected_on_read_and_write() -> None: # --- the store owns its (rep_id, tenant) scope ------------------------------------------------ -def test_foreign_rep_cannot_read_another_reps_history_with_no_cancellation_marker() -> None: +def test_foreign_rep_cannot_read_another_reps_history_with_no_cancellation_marker( + make_store: StoreFactory, +) -> None: # The cancellation store is never touched, so only the history store's scope check can deny. - store = InMemoryConversationHistory() + store = make_store() owner = _identity(rep_id="rep-owner") store.record_turn(_SESSION, identity=owner, prompt="secret plan", answer="the answer") @@ -90,8 +151,10 @@ def test_foreign_tenant_cannot_read_history_even_with_same_rep_id() -> None: store.history_for(_SESSION, identity=_identity(tenant="eval-run-1")) -def test_foreign_principal_cannot_inject_into_another_reps_history() -> None: - store = InMemoryConversationHistory() +def test_foreign_principal_cannot_inject_into_another_reps_history( + make_store: StoreFactory, +) -> None: + store = make_store() store.record_turn(_SESSION, identity=_identity(rep_id="rep-owner"), prompt="p", answer="a") with pytest.raises(ScopeDenied): store.record_turn( @@ -103,8 +166,8 @@ def test_foreign_principal_cannot_inject_into_another_reps_history() -> None: ) -def test_the_owner_still_reads_after_a_foreign_read_is_refused() -> None: - store = InMemoryConversationHistory() +def test_the_owner_still_reads_after_a_foreign_read_is_refused(make_store: StoreFactory) -> None: + store = make_store() owner = _identity(rep_id="rep-owner") store.record_turn(_SESSION, identity=owner, prompt="p", answer="a") with pytest.raises(ScopeDenied): @@ -115,8 +178,8 @@ def test_the_owner_still_reads_after_a_foreign_read_is_refused() -> None: # --- size bound (drop oldest) ---------------------------------------------------------------- -def test_drops_oldest_turns_beyond_the_budget() -> None: - store = InMemoryConversationHistory(max_turns=2) +def test_drops_oldest_turns_beyond_the_budget(make_store: StoreFactory) -> None: + store = make_store(max_turns=2) ident = _identity() for i in range(4): store.record_turn(_SESSION, identity=ident, prompt=f"p{i}", answer=f"a{i}") @@ -126,8 +189,8 @@ def test_drops_oldest_turns_beyond_the_budget() -> None: assert [t.prompt for t in history] == ["p2", "p3"] # oldest two dropped -def test_caps_each_field_length() -> None: - store = InMemoryConversationHistory(max_field_chars=10) +def test_caps_each_field_length(make_store: StoreFactory) -> None: + store = make_store(max_field_chars=10) ident = _identity() # spaced words, so no single token matches the opaque-secret shape and redaction is a no-op long_prose = "ab cd ef gh ij kl mn op" # 23 chars, ordinary prose @@ -137,11 +200,11 @@ def test_caps_each_field_length() -> None: assert turn.answer == "short" -def test_invalid_bounds_are_rejected() -> None: +def test_invalid_bounds_are_rejected(make_store: StoreFactory) -> None: with pytest.raises(ValueError, match="max_turns"): - InMemoryConversationHistory(max_turns=0) + make_store(max_turns=0) with pytest.raises(ValueError, match="max_field_chars"): - InMemoryConversationHistory(max_field_chars=0) + make_store(max_field_chars=0) # --- log-grade redaction --------------------------------------------------------------------- @@ -152,8 +215,8 @@ def test_invalid_bounds_are_rejected() -> None: _OPAQUE_CREDENTIAL = "aB3dE6gH9jK2mN5pQ8sT" + "1vW4xZ7bC0dF3gH6jK9m" # gitleaks:allow -def test_redacts_a_credential_shaped_token_embedded_in_prose() -> None: - store = InMemoryConversationHistory() +def test_redacts_a_credential_shaped_token_embedded_in_prose(make_store: StoreFactory) -> None: + store = make_store() ident = _identity() # an opaque credential embedded mid-sentence must be scrubbed while the prose survives store.record_turn( @@ -171,8 +234,8 @@ def test_redacts_a_credential_shaped_token_embedded_in_prose() -> None: assert turn.answer == "the value [REDACTED] was rotated" -def test_ordinary_prose_is_not_over_redacted() -> None: - store = InMemoryConversationHistory() +def test_ordinary_prose_is_not_over_redacted(make_store: StoreFactory) -> None: + store = make_store() ident = _identity() store.record_turn( _SESSION, identity=ident, prompt="what are my top accounts?", answer="Acme and Globex." @@ -183,9 +246,11 @@ def test_ordinary_prose_is_not_over_redacted() -> None: assert "[REDACTED]" not in turn.prompt + turn.answer -def test_a_secret_is_redacted_before_truncation_so_no_partial_leaks() -> None: +def test_a_secret_is_redacted_before_truncation_so_no_partial_leaks( + make_store: StoreFactory, +) -> None: # Redaction runs before truncation, so no 15-char partial of the secret is stored. - store = InMemoryConversationHistory(max_field_chars=15) + store = make_store(max_field_chars=15) ident = _identity() secret = "A" * 40 # matches the opaque-secret shape (>=32 chars) store.record_turn(_SESSION, identity=ident, prompt=secret, answer="ok") @@ -197,13 +262,22 @@ def test_a_secret_is_redacted_before_truncation_so_no_partial_leaks() -> None: # --- clear ----------------------------------------------------------------------------------- -def test_clear_forgets_a_session_and_is_idempotent() -> None: - store = InMemoryConversationHistory() +def test_clear_forgets_a_session_and_is_idempotent(make_store: StoreFactory) -> None: + store = make_store() ident = _identity() store.record_turn(_SESSION, identity=ident, prompt="p", answer="a") - store.clear(_SESSION) + store.clear(_SESSION, identity=ident) assert store.history_for(_SESSION, identity=ident) == () - store.clear(_SESSION) # no-op, no raise + store.clear(_SESSION, identity=ident) # no-op, no raise + + +def test_a_foreign_principal_cannot_clear_another_reps_history(make_store: StoreFactory) -> None: + store = make_store() + owner = _identity(rep_id="rep-owner") + store.record_turn(_SESSION, identity=owner, prompt="p", answer="a") + with pytest.raises(ScopeDenied): + store.clear(_SESSION, identity=_identity(rep_id="rep-attacker")) + assert store.history_for(_SESSION, identity=owner) == (HistoryTurn(prompt="p", answer="a"),) def test_history_turn_is_frozen() -> None: @@ -217,3 +291,210 @@ def test_history_turn_is_frozen() -> None: def test_default_field_cap_is_generous_enough_for_ordinary_answers() -> None: # a guard that the default is a real bound, not a near-zero that would truncate normal prose assert DEFAULT_MAX_FIELD_CHARS >= 1000 + + +# --- DynamoDB store: tenant in the key, expiry, item shape, optimistic retry ----------------- + + +def _raw_item(backing: Store, tenant: str = "demo") -> dict[str, object] | None: + return backing.get_item(HISTORY_TABLE, {"rep_id": keys.history_key(tenant, _SESSION)}) + + +def test_dynamodb_foreign_tenant_reads_empty_and_writes_its_own_item(ddb_store: Store) -> None: + store = DynamoDbConversationHistory(ddb_store, clock=_Clock()) + store.record_turn(_SESSION, identity=_identity(tenant="demo"), prompt="p", answer="a") + foreign = _identity(tenant="eval-run-1") + assert store.history_for(_SESSION, identity=foreign) == () + store.record_turn(_SESSION, identity=foreign, prompt="q", answer="b") + assert store.history_for(_SESSION, identity=_identity(tenant="demo")) == ( + HistoryTurn(prompt="p", answer="a"), + ) + assert store.history_for(_SESSION, identity=foreign) == (HistoryTurn(prompt="q", answer="b"),) + + +def test_dynamodb_item_carries_exactly_the_declared_attributes(ddb_store: Store) -> None: + clock = _Clock() + store = DynamoDbConversationHistory(ddb_store, clock=clock) + store.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") + item = _raw_item(ddb_store) + assert item == { + "rep_id": "history#demo#session-abc", + "kind": HISTORY_KIND, + "owner_rep_id": "rep-1", + "owner_tenant": "demo", + "turns": [{"prompt": "p", "answer": "a"}], + "version": 1, + "updated_at": _T0.isoformat(), + "expires_at": int(_T0.timestamp()) + DEFAULT_TTL_SECONDS, + } + assert set(item) == HISTORY_ITEM_ATTRIBUTES + assert "tenant" not in item + + +def test_dynamodb_each_write_bumps_the_version_and_refreshes_expiry(ddb_store: Store) -> None: + clock = _Clock() + store = DynamoDbConversationHistory(ddb_store, clock=clock, ttl_seconds=600) + store.record_turn(_SESSION, identity=_identity(), prompt="p1", answer="a1") + clock.now = _T0 + timedelta(seconds=300) + store.record_turn(_SESSION, identity=_identity(), prompt="p2", answer="a2") + item = _raw_item(ddb_store) + assert item is not None + assert item["version"] == 2 + assert item["expires_at"] == int(clock.now.timestamp()) + 600 + + +def test_dynamodb_an_expired_item_reads_empty(ddb_store: Store) -> None: + clock = _Clock() + store = DynamoDbConversationHistory(ddb_store, clock=clock, ttl_seconds=60) + store.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") + clock.now = _T0 + timedelta(seconds=59) + assert store.history_for(_SESSION, identity=_identity()) != () + clock.now = _T0 + timedelta(seconds=60) + assert store.history_for(_SESSION, identity=_identity()) == () + + +def test_dynamodb_a_write_after_expiry_starts_a_fresh_history(ddb_store: Store) -> None: + clock = _Clock() + store = DynamoDbConversationHistory(ddb_store, clock=clock, ttl_seconds=60) + store.record_turn(_SESSION, identity=_identity(), prompt="old", answer="a") + clock.now = _T0 + timedelta(seconds=61) + store.record_turn(_SESSION, identity=_identity(), prompt="new", answer="b") + assert store.history_for(_SESSION, identity=_identity()) == ( + HistoryTurn(prompt="new", answer="b"), + ) + item = _raw_item(ddb_store) + assert item is not None and item["version"] == 2 + + +def test_dynamodb_rejects_a_non_positive_ttl(ddb_store: Store) -> None: + with pytest.raises(ValueError, match="ttl_seconds"): + DynamoDbConversationHistory(ddb_store, ttl_seconds=0) + + +class _RacingStore(Store): + """A `Store` that lets a competing writer land just before each of the first `races` writes.""" + + def __init__(self, inner: Store, compete: Callable[[], None], races: int) -> None: + self.__dict__.update(inner.__dict__) + self._compete = compete + self._races = races + self.attempts = 0 + + def put_conditional( + self, table: str, item: Mapping[str, object], *, expected_version: int | None + ) -> bool: + self.attempts += 1 + if self.attempts <= self._races: + self._compete() + return super().put_conditional(table, item, expected_version=expected_version) + + +def test_dynamodb_a_lost_race_is_retried_and_both_turns_land(ddb_store: Store) -> None: + rival = DynamoDbConversationHistory(ddb_store, clock=_Clock()) + racing = _RacingStore( + ddb_store, + lambda: rival.record_turn(_SESSION, identity=_identity(), prompt="rival", answer="r"), + races=1, + ) + store = DynamoDbConversationHistory(racing, clock=_Clock()) + store.record_turn(_SESSION, identity=_identity(), prompt="mine", answer="m") + assert racing.attempts == 2 + assert [t.prompt for t in store.history_for(_SESSION, identity=_identity())] == [ + "rival", + "mine", + ] + + +def test_dynamodb_raises_history_write_conflict_after_the_last_attempt(ddb_store: Store) -> None: + rival = DynamoDbConversationHistory(ddb_store, clock=_Clock()) + racing = _RacingStore( + ddb_store, + lambda: rival.record_turn(_SESSION, identity=_identity(), prompt="rival", answer="r"), + races=MAX_WRITE_ATTEMPTS, + ) + pauses: list[float] = [] + store = DynamoDbConversationHistory(racing, clock=_Clock(), sleep=pauses.append) + with pytest.raises(HistoryWriteConflict) as excinfo: + store.record_turn(_SESSION, identity=_identity(), prompt="mine", answer="m") + assert isinstance(excinfo.value, Conflict) + assert racing.attempts == MAX_WRITE_ATTEMPTS == 3 + low, high = RETRY_BACKOFF_SECONDS + assert len(pauses) == MAX_WRITE_ATTEMPTS - 1 + assert all(low <= pause <= high for pause in pauses) + prompts = [t.prompt for t in store.history_for(_SESSION, identity=_identity())] + assert "mine" not in prompts and prompts == ["rival"] * MAX_WRITE_ATTEMPTS + + +def test_dynamodb_a_first_write_that_lands_does_not_pause(ddb_store: Store) -> None: + pauses: list[float] = [] + store = DynamoDbConversationHistory(ddb_store, clock=_Clock(), sleep=pauses.append) + store.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") + assert pauses == [] + + +class _CapturingClient: + """Forwards every call to a real client and records each `get_item` call's keyword arguments.""" + + def __init__(self, inner: Any) -> None: + self._inner = inner + self.get_item_calls: list[dict[str, Any]] = [] + + def get_item(self, **kwargs: Any) -> Any: + self.get_item_calls.append(kwargs) + return self._inner.get_item(**kwargs) + + def __getattr__(self, name: str) -> Any: + return getattr(self._inner, name) + + +def test_dynamodb_every_history_read_is_strongly_consistent(ddb_store: Store) -> None: + capturing = _CapturingClient(ddb_store._client) + store = DynamoDbConversationHistory(Store(client=capturing), clock=_Clock()) + store.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") + store.history_for(_SESSION, identity=_identity()) + store.clear(_SESSION, identity=_identity()) + assert len(capturing.get_item_calls) == 3 + assert all(call.get("ConsistentRead") is True for call in capturing.get_item_calls) + + +def test_dynamodb_clear_of_an_expired_foreign_item_is_a_no_op(ddb_store: Store) -> None: + clock = _Clock() + store = DynamoDbConversationHistory(ddb_store, clock=clock, ttl_seconds=60) + store.record_turn(_SESSION, identity=_identity(rep_id="rep-owner"), prompt="p", answer="a") + clock.now = _T0 + timedelta(seconds=61) + store.clear(_SESSION, identity=_identity(rep_id="rep-other")) + assert _raw_item(ddb_store) is not None + + +@pytest.mark.parametrize( + ("attribute", "value"), + [ + ("turns", "not-a-list"), + ("turns", [{"prompt": "p"}]), + ("turns", ["not-a-map"]), + ("owner_rep_id", 7), + ("expires_at", "soon"), + ("version", "one"), + ], +) +def test_dynamodb_a_malformed_item_is_an_error_not_silent_history( + ddb_store: Store, attribute: str, value: object +) -> None: + store = DynamoDbConversationHistory(ddb_store, clock=_Clock()) + store.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") + item = _raw_item(ddb_store) + assert item is not None + ddb_store.put_item(HISTORY_TABLE, {**item, attribute: value}) + with pytest.raises(CrmError, match="could not be read"): + if attribute == "version": + store.record_turn(_SESSION, identity=_identity(), prompt="p2", answer="a2") + else: + store.history_for(_SESSION, identity=_identity()) + + +def test_dynamodb_a_store_failure_propagates(ddb_store: Store) -> None: + store = DynamoDbConversationHistory(Store(table_prefix="missing-", client=ddb_store._client)) + with pytest.raises(CrmError): + store.history_for(_SESSION, identity=_identity()) + with pytest.raises(CrmError): + store.record_turn(_SESSION, identity=_identity(), prompt="p", answer="a") diff --git a/tests/unit/test_cost_withheld_gate.py b/tests/unit/test_cost_withheld_gate.py index c3e70ff..93edabc 100644 --- a/tests/unit/test_cost_withheld_gate.py +++ b/tests/unit/test_cost_withheld_gate.py @@ -173,6 +173,7 @@ def _fixture_arm(model_id: str, family: str, *, index: int) -> Any: runtime_identifier="local-runtime", price_table_version="provisional-copy", answer_style_sha256="0" * 64, + prompt_caching="explicit cache points", ), model_metrics_fields=metrics.to_report_fields(), aggregate_score_fields={ diff --git a/tests/unit/test_deploy_script.py b/tests/unit/test_deploy_script.py index 614820a..2732b81 100644 --- a/tests/unit/test_deploy_script.py +++ b/tests/unit/test_deploy_script.py @@ -435,6 +435,7 @@ def _run_tfvars_block(tmp_path: Path, tfvars_text: str) -> _PreflightRun: root = tmp_path / "repo" (root / "infra").mkdir(parents=True) (root / "scripts").mkdir() + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh") (root / "infra" / "terraform.tfvars").write_text(tfvars_text, encoding="utf-8") argv_file = tmp_path / "preflight.argv" (root / "scripts" / "preflight_adopted_vpc.sh").write_text( @@ -449,9 +450,13 @@ def _run_tfvars_block(tmp_path: Path, tfvars_text: str) -> _PreflightRun: f'REPO_ROOT="{root}"\n' 'INFRA_DIR="${REPO_ROOT}/infra"\n' "RESOLVED_REGION=us-east-1\n" - "RESOLVED_PROFILE=p2-test\n" + _tfvars_block() + "\n", + "RESOLVED_PROFILE=p2-test\n" + 'REPO_PYTHON="$("${REPO_ROOT}/scripts/repo_python.sh" --print)"\n' + _tfvars_block() + "\n", encoding="utf-8", ) + bin_dir = tmp_path / "bin" + bin_dir.mkdir() + (bin_dir / "python3").symlink_to(sys.executable) interpreter = shutil.which("bash") assert interpreter is not None, "bash is not on the host PATH" result = proc_run.run( @@ -460,7 +465,7 @@ def _run_tfvars_block(tmp_path: Path, tfvars_text: str) -> _PreflightRun: capture_output=True, text=True, check=False, - env={"PATH": os.environ.get("PATH", "/usr/bin:/bin")}, + env={"PATH": f"{bin_dir}:{os.environ.get('PATH', '/usr/bin:/bin')}"}, ) argv = argv_file.read_text(encoding="utf-8").splitlines() if argv_file.exists() else None return _PreflightRun(result=result, argv=argv) @@ -770,6 +775,7 @@ def _sandbox_bin(directory: Path, *, include_git: bool = True) -> Path: def _make_repo(root: Path, *, script_text: str | None = None) -> _Repo: """A throwaway git repo holding `scripts/deploy.sh`, so the script's own `REPO_ROOT` is this repo.""" (root / "scripts").mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh") (root / "scripts" / "deploy.sh").write_text( _script() if script_text is None else script_text, encoding="utf-8" ) @@ -857,6 +863,7 @@ def _make_nested_repo( _leave_index_unmerged(repo, operation, scratch) inner = root / "vendored" (inner / "scripts").mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", (inner / "scripts") / "repo_python.sh") (inner / "scripts" / "deploy.sh").write_text( _script() if script_text is None else script_text, encoding="utf-8" ) @@ -1046,6 +1053,9 @@ def test_an_unreadable_index_refuses_rather_than_proceeding(self, tmp_path: Path """A present but unusable `.git` is refused.""" root = tmp_path / "corrupt" (root / "scripts").mkdir(parents=True) + shutil.copy2( + REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh" + ) (root / "scripts" / "deploy.sh").write_text(_script(), encoding="utf-8") (root / ".git").mkdir() bin_dir = _sandbox_bin(tmp_path / "sandbox-bin") @@ -1063,6 +1073,9 @@ def test_a_tree_that_is_no_checkout_says_so_and_does_not_refuse(self, tmp_path: proceeds.""" root = tmp_path / "no-checkout" (root / "scripts").mkdir(parents=True) + shutil.copy2( + REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh" + ) (root / "scripts" / "deploy.sh").write_text(_script(), encoding="utf-8") bin_dir = _sandbox_bin(tmp_path / "sandbox-bin") # The fixture's control: git resolves no work tree from here. @@ -1226,6 +1239,9 @@ def test_an_absent_git_in_a_tree_with_no_dot_git_warns_rather_than_refusing( proceeds.""" root = tmp_path / "no-checkout" (root / "scripts").mkdir(parents=True) + shutil.copy2( + REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh" + ) (root / "scripts" / "deploy.sh").write_text(_script(), encoding="utf-8") bin_dir = _sandbox_bin(tmp_path / "sandbox-bin", include_git=False) assert shutil.which("git", path=str(bin_dir)) is None, "the sandbox PATH still reaches git" diff --git a/tests/unit/test_dockerfile_pins.py b/tests/unit/test_dockerfile_pins.py index c3c7c99..b209ac9 100644 --- a/tests/unit/test_dockerfile_pins.py +++ b/tests/unit/test_dockerfile_pins.py @@ -2,8 +2,9 @@ """Pins the AgentCore runtime image's interpreter and pip to the same versions CI uses. One interpreter version across the `Dockerfile` base tag, `.python-version` and the -`.gitlab-ci.yml` image tag; one pip version across the `Dockerfile` pin and `.gitlab-ci.yml`'s -`PIP_VERSION`. The `Dockerfile` must install that pip before `-r requirements.txt`, and install the +`.gitlab-ci.yml` global and `frontend` job image tags; one pip version across the `Dockerfile` pin +and `.gitlab-ci.yml`'s `PIP_VERSION`; the `frontend` job's `FRONTEND_NODE_VERSION` equal to +`frontend/.nvmrc`. The `Dockerfile` must install that pip before `-r requirements.txt`, and install the lock with `--no-deps`. `pin_drift` takes the repository root so each check is proved red against a mutated copy. """ @@ -20,7 +21,8 @@ import yaml REPO_ROOT = Path(__file__).resolve().parents[2] -PINNED_FILES = ("Dockerfile", ".python-version", ".gitlab-ci.yml") +PINNED_FILES = ("Dockerfile", ".python-version", ".gitlab-ci.yml", "frontend/.nvmrc") +FRONTEND_JOB = "frontend" _FROM = re.compile(r"^FROM\s+(?P.*)$", re.M) _BASE_TAG = re.compile(r"public\.ecr\.aws/docker/library/python:(?P[^\s-]+)-slim\b") @@ -79,6 +81,28 @@ def pin_drift(root: Path) -> list[str]: f".gitlab-ci.yml image {ci_image['version']} != .python-version {python_version}" ) + frontend = ci.get(FRONTEND_JOB) + if not isinstance(frontend, dict): + errors.append(f".gitlab-ci.yml has no {FRONTEND_JOB} job") + else: + frontend_image = _CI_IMAGE.match(str(frontend.get("image", ""))) + if frontend_image is None: + errors.append( + f".gitlab-ci.yml {FRONTEND_JOB} image {frontend.get('image')!r} " + "is not python:-slim" + ) + elif frontend_image["version"] != python_version: + errors.append( + f".gitlab-ci.yml {FRONTEND_JOB} image {frontend_image['version']} " + f"!= .python-version {python_version}" + ) + nvmrc = (root / "frontend" / ".nvmrc").read_text(encoding="utf-8").strip() + node = str((frontend.get("variables") or {}).get("FRONTEND_NODE_VERSION", "")) + if node != nvmrc: + errors.append( + f".gitlab-ci.yml FRONTEND_NODE_VERSION {node!r} != frontend/.nvmrc {nvmrc}" + ) + pip_pins = _PIP_PIN.findall(dockerfile) requirements_installs = list(_REQUIREMENTS_INSTALL.finditer(dockerfile)) if len(pip_pins) != 1: @@ -125,6 +149,10 @@ def _python_version(root: Path) -> str: return (root / ".python-version").read_text(encoding="utf-8").strip() +def _nvmrc(root: Path) -> str: + return (root / "frontend" / ".nvmrc").read_text(encoding="utf-8").strip() + + def _ci_pip_version(root: Path) -> str: ci = yaml.safe_load((root / ".gitlab-ci.yml").read_text(encoding="utf-8")) return next(iter(_ci_pip_versions(ci))) @@ -167,6 +195,34 @@ def _ci_pip_version(root: Path) -> str: lambda r: _replace(r / "Dockerfile", f"pip=={_ci_pip_version(r)}", "pip"), "0 pip== installs", ), + "ci-frontend-image-moved": ( + lambda r: _replace( + r / ".gitlab-ci.yml", + f" image: python:{_python_version(r)}-slim", + " image: python:3.13.0-slim", + ), + "frontend image 3.13.0 != .python-version", + ), + "ci-frontend-image-node": ( + lambda r: _replace( + r / ".gitlab-ci.yml", + f" image: python:{_python_version(r)}-slim", + " image: node:26.13.1-slim", + ), + "is not python:-slim", + ), + "ci-frontend-node-moved": ( + lambda r: _replace( + r / ".gitlab-ci.yml", + f'FRONTEND_NODE_VERSION: "{_nvmrc(r)}"', + 'FRONTEND_NODE_VERSION: "26.0.0"', + ), + "FRONTEND_NODE_VERSION '26.0.0' != frontend/.nvmrc", + ), + "nvmrc-moved": ( + lambda r: (r / "frontend" / ".nvmrc").write_text("26.0.0\n", encoding="utf-8"), + "!= frontend/.nvmrc 26.0.0", + ), "ci-pip-moved": ( lambda r: _replace( r / ".gitlab-ci.yml", f'PIP_VERSION: "{_ci_pip_version(r)}"', 'PIP_VERSION: "25.2"' @@ -186,6 +242,7 @@ def _ci_pip_version(root: Path) -> str: @pytest.mark.parametrize("mutation", sorted(_MUTATIONS)) def test_each_pin_drift_is_reported(mutation: str, tmp_path: Path) -> None: for name in PINNED_FILES: + (tmp_path / name).parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(REPO_ROOT / name, tmp_path / name) assert pin_drift(tmp_path) == [] diff --git a/tests/unit/test_e2e_browser_scaffold.py b/tests/unit/test_e2e_browser_scaffold.py index b37ea4e..68bbb99 100644 --- a/tests/unit/test_e2e_browser_scaffold.py +++ b/tests/unit/test_e2e_browser_scaffold.py @@ -268,6 +268,7 @@ def import_escapes_the_package(specifier: str, containing: Path) -> bool: "journeys/18-approval-rebase/approval-rebase.spec.ts", "journeys/19-account-opportunities/account-opportunities.spec.ts", "journeys/20-chat-cost/chat-cost.spec.ts", + "journeys/22-chat-recall/chat-recall.spec.ts", ) diff --git a/tests/unit/test_eval_artefacts.py b/tests/unit/test_eval_artefacts.py index 180ad21..13cb1d3 100644 --- a/tests/unit/test_eval_artefacts.py +++ b/tests/unit/test_eval_artefacts.py @@ -35,6 +35,7 @@ download_disposition, validate_artefact_key, ) +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY from eval.runs import job_row_id from eval.trigger import EVAL_STATE_MACHINE_ARN_ENV_VAR @@ -463,7 +464,7 @@ def _tier_record(summary: object) -> runs.RunRecord: mode="stub", status="completed", started_at="2026-11-06T00:00:00+00:00", - matrix_report={"tier_comparison": summary}, + matrix_report={RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "tier_comparison": summary}, ) @@ -483,7 +484,9 @@ def test_a_summary_the_formatter_refuses_is_omitted_and_logged_with_its_reason( caplog: pytest.LogCaptureFixture, ) -> None: caplog.set_level("INFO") - payload = _tier_record({"tiers": {}, "notes": []}).to_payload() + payload = _tier_record( + {RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "tiers": {}, "notes": []} + ).to_payload() assert "tier_comparison_table" not in payload assert _unavailable_lines(caplog) == [ { @@ -504,7 +507,14 @@ def _broken(_summary: object) -> dict[str, object]: monkeypatch.setattr(runs, "tier_comparison_table", _broken) caplog.set_level("INFO") with pytest.raises(bug): - _tier_record({"columns": [], "tiers": {}, "notes": []}).to_payload() + _tier_record( + { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, + "columns": [], + "tiers": {}, + "notes": [], + } + ).to_payload() assert _unavailable_lines(caplog) == [] @@ -512,6 +522,7 @@ def _stored_summary() -> dict[str, Any]: from eval.matrix import build_matrix_result, tier_comparison stored: dict[str, Any] = json.loads(json.dumps(tier_comparison(build_matrix_result([])))) + assert stored[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION return stored @@ -530,7 +541,18 @@ def test_a_stored_entry_with_unjoinable_lists_is_refused_as_malformed( summary = _stored_summary() summary["columns"] = [{"label": "anthropic", "mode": "stub"}] - entry: dict[str, Any] = {"model_ids": ["m"], "efforts": ["medium"], field: value} + entry: dict[str, Any] = { + "model_ids": ["m"], + "efforts": ["medium"], + "cost_per_applicable_task": None, + "total_prompt_tokens": 0, + "cache_read_tokens": 0, + "cache_write_tokens": 0, + "budget_exhausted_task_count": 0, + "truncated_tool_call_count": 0, + "truncated_task_count": 0, + field: value, + } summary["tiers"] = {tier: [dict(entry)] for tier in ("supervisor", "subagent", "tool")} with pytest.raises(ValueError, match=reason): tier_comparison_table(summary) diff --git a/tests/unit/test_eval_run_status_contract.py b/tests/unit/test_eval_run_status_contract.py index 5031f48..ae11004 100644 --- a/tests/unit/test_eval_run_status_contract.py +++ b/tests/unit/test_eval_run_status_contract.py @@ -224,6 +224,14 @@ def _emitted_keys(statuses: frozenset[str] | None = None) -> set[str]: replace( base, status="cancelled", finished_at="2026-01-01T00:05:00+00:00", tasks_skipped=37 ), + replace( + base, + status="completed", + finished_at="2026-01-01T00:05:00+00:00", + teardown_status="ok", + matrix_report={"arms": []}, + artifact_links=artifacts, + ), replace( base, status="failed", diff --git a/tests/unit/test_eval_trigger.py b/tests/unit/test_eval_trigger.py index e490a8a..3027384 100644 --- a/tests/unit/test_eval_trigger.py +++ b/tests/unit/test_eval_trigger.py @@ -32,6 +32,7 @@ from crm.store.provisioning import create_all_tables from crm.store.store import Store from eval import trigger +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY from eval.runs import RunRecord from eval.tenancy import ( tenant_for_run, @@ -395,6 +396,31 @@ def _record(matrix_report: dict[str, Any] | None) -> RunRecord: ) +#: The row labels every tier section of the payload table carries, in order. +_ROW_LABELS = [ + "Model", + "Effort", + "Task completion rate", + "Task completion over repeats", + "Task accuracy", + "Cost per completed task", + "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", + "Model invocations", + "Long-context invocations", + "Total input tokens", + "Cache read tokens", + "Cache write tokens", + "Uncached input tokens", + "Total output tokens", + "Cost per applicable task", + "Self-corrected retries", + "Budget-exhausted tasks", + "Truncated tool calls", + "Truncated tasks", +] + + def _summary() -> dict[str, object]: note = "Columns are the sweep's arms in run order." entry: dict[str, object] = { @@ -405,21 +431,35 @@ def _summary() -> dict[str, object]: "accuracy": 0.5, "cost_withheld_provisional": True, "cost_per_completed_task": None, - "cost_per_task": None, + "cost_per_applicable_task": None, "completed_task_latency_ms_p50": None, "completed_task_latency_ms_p95": None, "latency_sample_count": None, "invocation_count": 3, "input_tokens": 10, + "total_prompt_tokens": 14, + "cache_read_tokens": 3, + "cache_write_tokens": 1, "output_tokens": 2, "retry_count": None, + "budget_exhausted_task_count": 0, + "truncated_tool_call_count": 0, + "truncated_task_count": 0, } return { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "columns": [{"label": "anthropic", "mode": "stub"}], "tiers": { - "supervisor": [{**entry, "budget_exhausted_task_count": 0}], - "subagent": [{**entry, "delegation_outcomes": None}], - "tool": [{**entry, "truncated_task_count": 0}], + "supervisor": [entry], + "subagent": [ + { + **entry, + "truncated_tool_call_count": None, + "truncated_task_count": None, + "delegation_outcomes": None, + } + ], + "tool": [entry], }, "notes": [note], } @@ -440,14 +480,24 @@ def _table_events(caplog: pytest.LogCaptureFixture) -> list[dict[str, Any]]: def test_the_payload_carries_the_tier_table_of_the_stored_summary() -> None: from eval.matrix import tier_comparison_table - payload = _record({"tier_comparison": _summary(), "arms": []}).to_payload() + payload = _record( + {RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "tier_comparison": _summary(), "arms": []} + ).to_payload() assert payload["tier_comparison_table"] == tier_comparison_table(_summary()) table = payload["tier_comparison_table"] assert table["headers"] == ["Metric", "anthropic"] assert [section["tier"] for section in table["sections"]] == ["supervisor", "subagent", "tool"] + for section in table["sections"]: + assert [row[0] for row in section["rows"]] == _ROW_LABELS, section["tier"] supervisor = {row[0]: row[1:] for row in table["sections"][0]["rows"]} assert supervisor["Cost per completed task"] == ["withheld"] assert supervisor["P95 latency per completed task (ms)"] == ["not measured"] + assert supervisor["Total input tokens"] == ["14"] + assert supervisor["Uncached input tokens"] == ["10"] + assert supervisor["Cost per applicable task"] == ["withheld"] + assert supervisor["Truncated tool calls"] == ["0"] + subagent = {row[0]: row[1:] for row in table["sections"][1]["rows"]} + assert subagent["Truncated tasks"] == ["not applicable"] assert payload["matrix"]["tier_comparison"] == _summary() json.dumps(payload) @@ -472,8 +522,17 @@ def test_a_record_without_a_summary_mapping_omits_the_table( lambda s: s["tiers"].pop("tool"), lambda s: s.update(notes=[7]), lambda s: s["tiers"]["supervisor"][0].update(model_ids=[1, 2]), + lambda s: s.pop(RECORD_SHAPE_VERSION_KEY), + lambda s: s["tiers"]["tool"][0].pop("total_prompt_tokens"), + ], + ids=[ + "no-columns", + "missing-tier", + "non-string-note", + "non-string-model", + "no-record-shape", + "missing-token-field", ], - ids=["no-columns", "missing-tier", "non-string-note", "non-string-model"], ) def test_a_malformed_summary_is_omitted_and_logged_never_raised( corrupt: Any, caplog: pytest.LogCaptureFixture @@ -481,7 +540,9 @@ def test_a_malformed_summary_is_omitted_and_logged_never_raised( summary = _summary() corrupt(summary) caplog.set_level("INFO") - payload = _record({"tier_comparison": summary}).to_payload() + payload = _record( + {RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "tier_comparison": summary} + ).to_payload() assert "tier_comparison_table" not in payload assert payload["status"] == "completed" events = _table_events(caplog) diff --git a/tests/unit/test_forbidden_outcomes_falsifiable.py b/tests/unit/test_forbidden_outcomes_falsifiable.py index f9dc5f9..f24bece 100644 --- a/tests/unit/test_forbidden_outcomes_falsifiable.py +++ b/tests/unit/test_forbidden_outcomes_falsifiable.py @@ -864,6 +864,7 @@ def test_truncated_and_budget_exhausted_are_carried_into_the_task_score(store: S tool_calls=(ToolCall("search_opportunities"),), truncated=True, budget_exhausted=True, + budget_exhausted_tier="supervisor", ) score = score_task(store, task=task, outcome=outcome) diff --git a/tests/unit/test_gates.py b/tests/unit/test_gates.py index d235db4..9db85e8 100644 --- a/tests/unit/test_gates.py +++ b/tests/unit/test_gates.py @@ -1614,7 +1614,7 @@ def _derived(cls) -> dict[str, tuple[int, bool]]: path = REPO_ROOT / rel try: text = path.read_text(encoding="utf-8") - except (OSError, UnicodeDecodeError): + except OSError, UnicodeDecodeError: continue shell, python = cls._is_shell(path), path.suffix == ".py" if not (shell or python): diff --git a/tests/unit/test_golden_task_retrieval_scoring.py b/tests/unit/test_golden_task_retrieval_scoring.py index d95575f..2c7f83d 100644 --- a/tests/unit/test_golden_task_retrieval_scoring.py +++ b/tests/unit/test_golden_task_retrieval_scoring.py @@ -37,7 +37,7 @@ #: Each narrowed task's expected read targets, stated independently of the task file. _EXPECTED_TARGETS: dict[str, tuple[str, ...]] = { - "gt-04-investigation-turn-budget-partial": ("opp-0000", "opp-0040", "opp-0080"), + "gt-04-investigation-turn-budget-partial": ("opp-0000", "opp-0040", "opp-0080", "opp-0200"), "gt-05-investigation-large-tool-result": ("opp-0000",), } @@ -135,10 +135,10 @@ def test_narrowed_task_fails_when_the_turn_read_the_wrong_opportunity( assert score.correctness is not None and score.correctness < 1.0 -def test_gt04_fails_the_two_opportunities_it_never_read( +def test_gt04_fails_the_three_opportunities_it_never_read( store: Store, tasks_by_id: dict[str, dict[str, Any]] ) -> None: - """Reading one of gt-04's three opportunities passes one read assertion and fails the others.""" + """Reading one of gt-04's four opportunities passes one read assertion and fails the others.""" task = tasks_by_id["gt-04-investigation-turn-budget-partial"] outcome = TurnOutcome( tenant=_TENANT, @@ -147,24 +147,25 @@ def test_gt04_fails_the_two_opportunities_it_never_read( score = score_task(store, task=task, outcome=outcome) results = _read_results(score) - assert [r.passed for r in results] == [True, False, False] + assert [r.passed for r in results] == [True, False, False, False] assert _scoped("opp-0040") in results[1].name assert _scoped("opp-0080") in results[2].name + assert _scoped("opp-0200") in results[3].name # --- Passing cases -------------------------------------------------------------------------------- -def test_gt04_passes_when_all_three_opportunities_were_read( +def test_gt04_passes_when_all_four_opportunities_were_read( store: Store, tasks_by_id: dict[str, dict[str, Any]] ) -> None: - """Reading all three opportunities the sweep is about satisfies gt-04's retrieval assertions.""" + """Reading all four departed-contact opportunities satisfies gt-04's retrieval assertions.""" task = tasks_by_id["gt-04-investigation-turn-budget-partial"] outcome = TurnOutcome( tenant=_TENANT, tool_calls=tuple( ToolCall(tool_name="get_opportunity", target_id=_scoped(local_id)) - for local_id in ("opp-0000", "opp-0040", "opp-0080") + for local_id in _EXPECTED_TARGETS["gt-04-investigation-turn-budget-partial"] ), ) score = score_task(store, task=task, outcome=outcome) diff --git a/tests/unit/test_harness.py b/tests/unit/test_harness.py index f728c3e..3ae46e4 100644 --- a/tests/unit/test_harness.py +++ b/tests/unit/test_harness.py @@ -347,6 +347,7 @@ def test_every_arm_provenance_carries_the_fr_9_12_fields_and_no_temperature(stor "price_table_version", "answer_style_sha256", # the answer-style prompt hash "prompt_bundle_sha256", # the whole prompt bundle's hash + "prompt_caching", # the arm family's prompt-caching method } assert set(provenance_fields) == expected_keys assert provenance_fields["mode"] == "stub" diff --git a/tests/unit/test_harness_figure_semantics_parity.py b/tests/unit/test_harness_figure_semantics_parity.py index d0f3358..81a1af1 100644 --- a/tests/unit/test_harness_figure_semantics_parity.py +++ b/tests/unit/test_harness_figure_semantics_parity.py @@ -41,6 +41,7 @@ def _arm() -> ArmResult: runtime_identifier="local-stub-runtime", price_table_version="v0-provisional", answer_style_sha256="0" * 64, + prompt_caching="explicit cache points", ), model_metrics_fields={ "model_id": _MODEL_ID, diff --git a/tests/unit/test_harness_live_mode.py b/tests/unit/test_harness_live_mode.py index da1581c..0edeadb 100644 --- a/tests/unit/test_harness_live_mode.py +++ b/tests/unit/test_harness_live_mode.py @@ -20,7 +20,7 @@ import httpx2 import openai import pytest -from anthropic.lib.bedrock import _auth +from anthropic.lib.aws import _auth from botocore.credentials import Credentials from moto import mock_aws diff --git a/tests/unit/test_harness_multirole_rehearsal.py b/tests/unit/test_harness_multirole_rehearsal.py index b84c17b..a9a64bb 100644 --- a/tests/unit/test_harness_multirole_rehearsal.py +++ b/tests/unit/test_harness_multirole_rehearsal.py @@ -581,7 +581,7 @@ def real_adapter_wires(monkeypatch: pytest.MonkeyPatch) -> dict[str, _ScriptedWi ``eval.live.build_live_provider`` and ``ThrottleRetryingProvider`` run unmodified. """ from anthropic import AsyncAnthropicBedrock - from anthropic.lib.bedrock import _auth + from anthropic.lib.aws import _auth from openai import AsyncBedrockOpenAI from eval import live diff --git a/tests/unit/test_harness_tier_comparison_assert.py b/tests/unit/test_harness_tier_comparison_assert.py index d842307..08266d1 100644 --- a/tests/unit/test_harness_tier_comparison_assert.py +++ b/tests/unit/test_harness_tier_comparison_assert.py @@ -42,6 +42,7 @@ def _arm(model_id: str, family: str) -> ArmResult: runtime_identifier="local-stub-runtime", price_table_version="v0-provisional", answer_style_sha256="0" * 64, + prompt_caching="explicit cache points", ), model_metrics_fields={ "model_id": model_id, diff --git a/tests/unit/test_hygiene_gates.py b/tests/unit/test_hygiene_gates.py index aab5f24..360fad5 100644 --- a/tests/unit/test_hygiene_gates.py +++ b/tests/unit/test_hygiene_gates.py @@ -13,6 +13,7 @@ import importlib.util import os +import shutil import subprocess import sys from collections import Counter @@ -312,7 +313,7 @@ def _clone_for_ref_mode(work: Path) -> Path: def _clone_for_subject_selection(work: Path) -> Path: - """The clone recipe :class:`TestSubjectSelection` reads: copies four worktree files into the + """The clone recipe :class:`TestSubjectSelection` reads: copies five worktree files into the clone and syncs the index to them.""" proc_run.run( ["git", "clone", "--quiet", "--shared", str(REPO_ROOT), str(work)], @@ -324,10 +325,12 @@ def _clone_for_subject_selection(work: Path) -> Path: for relative in ( ("scripts", "check_no_account_id.sh"), ("scripts", "check_no_vendor_keys.sh"), + ("scripts", "repo_python.sh"), ("githooks", "pre-commit"), ("tests", "unit", "test_hygiene_gates.py"), ): (work / Path(*relative)).write_bytes((REPO_ROOT / Path(*relative)).read_bytes()) + (work / "scripts" / "repo_python.sh").chmod(0o755) proc_run.run(["git", "-C", str(work), "add", "-A"], check=True, capture_output=True) return work @@ -1222,6 +1225,7 @@ def test_hook_is_installable_via_core_hooks_path(self, tmp_path: Path) -> None: # The hook resolves its scripts and any local .gitleaks.toml relative to the repo root. scripts_dir = tmp_path / "scripts" scripts_dir.mkdir() + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") for name in ( "check_no_account_id.sh", "check_no_vendor_keys.sh", @@ -1290,6 +1294,7 @@ def _scratch_repo_with_hook(self, root: Path, hook_text: str | None = None) -> P hook_dest.chmod(0o755) scripts_dir = root / "scripts" scripts_dir.mkdir() + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") for name in ( "check_no_account_id.sh", "check_no_vendor_keys.sh", @@ -1428,7 +1433,7 @@ def test_both_subjects_are_named_in_the_hook_and_the_declared_config(self) -> No """Both the staged and worktree scans are named in the hook and in `.pre-commit-config.yaml`.""" hook_text = PRE_COMMIT_HOOK.read_text(encoding="utf-8") assert "protect --staged" in hook_text - assert "python3 scripts/check_secret_scan.py" in hook_text + assert "scripts/repo_python.sh scripts/check_secret_scan.py" in hook_text assert "detect --no-git" not in hook_text, "the hook still runs a raw working-tree scan" import yaml @@ -1436,9 +1441,10 @@ def test_both_subjects_are_named_in_the_hook_and_the_declared_config(self) -> No config = yaml.safe_load(PRE_COMMIT_CONFIG_YAML.read_text(encoding="utf-8")) entries = [hook["entry"] for repo in config["repos"] for hook in repo["hooks"]] assert any("protect --staged" in entry for entry in entries), entries - assert any(entry.endswith("python3 scripts/check_secret_scan.py") for entry in entries), ( - entries - ) + assert any( + entry.endswith("scripts/repo_python.sh scripts/check_secret_scan.py") + for entry in entries + ), entries assert not any("detect --no-git" in entry for entry in entries), entries def test_a_gitignored_secret_does_not_block_the_hook(self, tmp_path: Path) -> None: @@ -1821,6 +1827,9 @@ def _repo(tmp_path: Path, *, planted: str | None, gate_source: str | None = None violation.""" work = tmp_path / "subject" (work / "scripts").mkdir(parents=True) + shutil.copy2( + REPO_ROOT / "scripts" / "repo_python.sh", (work / "scripts") / "repo_python.sh" + ) source = ( gate_source if gate_source is not None @@ -2334,6 +2343,9 @@ def _repo(work: Path, line: bytes, planted: str, *, gate_text: str | None = None """A scratch repo holding one tracked text file whose violating line carries an invalid byte.""" work.mkdir(parents=True) (work / "scripts").mkdir() + shutil.copy2( + REPO_ROOT / "scripts" / "repo_python.sh", (work / "scripts") / "repo_python.sh" + ) (work / "scripts" / "check_no_account_id.sh").write_text( gate_text if gate_text is not None else CHECK_NO_ACCOUNT_ID.read_text(encoding="utf-8"), encoding="utf-8", @@ -2449,6 +2461,9 @@ class TestCheckLicenseHeadersSubjectSubstitution: def _repo(tmp_path: Path, *, headerless: bool) -> Path: work = tmp_path / "subject" (work / "scripts").mkdir(parents=True) + shutil.copy2( + REPO_ROOT / "scripts" / "repo_python.sh", (work / "scripts") / "repo_python.sh" + ) (work / "src").mkdir(parents=True) gate = REPO_ROOT / "scripts" / "check_license_headers.sh" (work / "scripts" / "check_license_headers.sh").write_text( @@ -2537,6 +2552,9 @@ def _repo(tmp_path: Path, *, gate_source: str | None = None) -> Path: """A scratch repository whose pre-commit hook runs only this gate.""" work = tmp_path / "subject" (work / "scripts").mkdir(parents=True) + shutil.copy2( + REPO_ROOT / "scripts" / "repo_python.sh", (work / "scripts") / "repo_python.sh" + ) (work / "githooks").mkdir(parents=True) source = ( gate_source @@ -2805,6 +2823,7 @@ def _repo(root: Path, *, hook_text: str | None = None) -> Path: hook.chmod(0o755) scripts = root / "scripts" scripts.mkdir() + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts / "repo_python.sh") for gate in (CHECK_NO_ACCOUNT_ID, CHECK_NO_VENDOR_KEYS, CHECK_SECRET_SCAN, PROC_RUN): dest = scripts / gate.name dest.write_text(gate.read_text(encoding="utf-8"), encoding="utf-8") diff --git a/tests/unit/test_inflight_leaf_charging.py b/tests/unit/test_inflight_leaf_charging.py new file mode 100644 index 0000000..1a0a11f --- /dev/null +++ b/tests/unit/test_inflight_leaf_charging.py @@ -0,0 +1,198 @@ +# SPDX-License-Identifier: MIT +"""Leaf tool calls are charged to the turn budget as they are dispatched. + +:meth:`agents.budget.TurnBudget.charge_tool_call` charges a call or refuses it at the cap; the +subagent runner charges each leaf before dispatching it, so a delegation cannot run past the turn's +tool-call cap, and the turn driver does not charge the same leaves again afterwards. +""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Any + +import pytest + +from agents.budget import RequestRefusedError, TurnBudget, TurnBudgetSpec +from agents.events import AgentEvent +from agents.registry import RegisteredTool +from agents.subagents import SUBAGENT_SPECS_BY_ROLE +from providers.base import ProviderEvent +from tests.unit.test_budget_exhaustion_tier import _answer_round, _drive, _Round + +_LEAF_TOOL = SUBAGENT_SPECS_BY_ROLE["research"].tools[0].name + + +@dataclass +class _CountingDispatch: + """Counts every dispatched tool call and returns one small account record.""" + + names: list[str] = field(default_factory=list) + + def __call__(self, tool: RegisteredTool, tool_input: dict[str, object]) -> dict[str, Any]: + del tool_input + self.names.append(tool.name) + return {"statusCode": 200, "body": {"account_id": "acc-1", "name": "Acme"}} + + +def _supervisor_delegates() -> _Round: + return _Round( + [ + ProviderEvent( + type="tool_call", tool_name="research", tool_input={"intent": "acme"}, tool_id="d1" + ), + ProviderEvent(type="usage", input_tokens=10, output_tokens=2), + ProviderEvent(type="completed", awaiting_tools=True), + ] + ) + + +def _subagent_calls(count: int) -> _Round: + calls = [ + ProviderEvent( + type="tool_call", + tool_name=_LEAF_TOOL, + tool_input={"account_id": f"acc-{n}"}, + tool_id=f"s{n}", + ) + for n in range(count) + ] + return _Round( + [ + *calls, + ProviderEvent(type="usage", input_tokens=10, output_tokens=2), + ProviderEvent(type="completed", awaiting_tools=False), + ] + ) + + +def _tool_tier_round() -> _Round: + return _Round( + [ + ProviderEvent(type="tool_call", tool_name=_LEAF_TOOL, tool_input={"account_id": "x"}), + ProviderEvent(type="usage", input_tokens=2, output_tokens=1), + ProviderEvent(type="completed", awaiting_tools=False), + ] + ) + + +def _delegation_of(leaves: int, *, tool_rounds: int | None = None) -> list[_Round]: + rounds = tool_rounds if tool_rounds is not None else leaves + return [ + _supervisor_delegates(), + _subagent_calls(leaves), + *(_tool_tier_round() for _ in range(rounds)), + _answer_round(), + ] + + +def _terminal(events: list[AgentEvent]) -> AgentEvent: + return events[-1] + + +# -- TurnBudget.charge_tool_call ----------------------------------------------------------------- + + +def test_a_charge_under_the_cap_records_the_call() -> None: + budget = TurnBudget(max_tool_calls=2) + budget.charge_tool_call("called get_account", tier="tool", role="research") + assert budget.tool_calls_made == 1 + assert budget.completed_actions == ["called get_account"] + assert budget.exhausted_tier is None + + +def test_a_charge_at_the_cap_is_refused_uncharged_and_records_its_tier() -> None: + budget = TurnBudget(max_tool_calls=1) + budget.charge_tool_call("called get_account", tier="tool", role="research") + with pytest.raises(RequestRefusedError): + budget.charge_tool_call("called get_contact", tier="tool", role="research") + assert budget.tool_calls_made == 1 + assert budget.completed_actions == ["called get_account"] + assert budget.exhausted_tier == "tool" + + +def test_a_refused_charge_keeps_an_earlier_tier() -> None: + budget = TurnBudget(max_tool_calls=1) + budget.note_exhausted_at("subagent") + budget.charge_tool_call("called get_account", tier="tool", role="research") + with pytest.raises(RequestRefusedError): + budget.charge_tool_call("called get_account", tier="tool", role="research") + assert budget.exhausted_tier == "subagent" + + +def test_a_refused_charge_is_logged(caplog: pytest.LogCaptureFixture) -> None: + budget = TurnBudget(max_tool_calls=1) + budget.charge_tool_call("called get_account", tier="tool", role="research") + with caplog.at_level("WARNING"), pytest.raises(RequestRefusedError): + budget.charge_tool_call("called get_account", tier="tool", role="research") + assert any("tool_call_refused" in record.getMessage() for record in caplog.records) + + +def test_an_unknown_tier_is_rejected_by_a_refused_charge() -> None: + budget = TurnBudget(max_tool_calls=1) + budget.charge_tool_call("called get_account", tier="tool", role="research") + with pytest.raises(ValueError): + budget.charge_tool_call("called get_account", tier="nowhere", role="research") + + +# -- a delegation against the turn's cap ------------------------------------------------------- + + +def test_a_delegation_of_40_leaf_calls_stops_at_25_total() -> None: + dispatch = _CountingDispatch() + events, records = _drive( + _delegation_of(40, tool_rounds=25), + budget=TurnBudgetSpec(max_tool_calls=25, max_wall_clock_seconds=60.0), + dispatch=dispatch, + ) + + assert len(dispatch.names) == 25 + assert len(records.tool_calls) == 25 + terminal = _terminal(events) + assert terminal.kind == "error" and terminal.error_kind == "budget_exhausted" + assert "25 of 25 tool call(s)" in (terminal.error_message or "") + assert records.budget_exhausted_tier == "tool" + + +def test_a_delegation_stopped_at_the_cap_reports_only_what_it_gathered() -> None: + dispatch = _CountingDispatch() + events, _ = _drive( + _delegation_of(40, tool_rounds=25), + budget=TurnBudgetSpec(max_tool_calls=25, max_wall_clock_seconds=60.0), + dispatch=dispatch, + ) + + tool_results = [e for e in events if e.kind == "tool_result"] + assert len(tool_results) == 25 + assert all( + e.tool_output == {"statusCode": 200, "body": {"account_id": "acc-1", "name": "Acme"}} + for e in tool_results + ) + assert not [e for e in events if e.kind == "completed"] + + +def test_leaf_calls_are_charged_once_not_again_after_the_delegation() -> None: + dispatch = _CountingDispatch() + events, records = _drive( + _delegation_of(3), + budget=TurnBudgetSpec(max_tool_calls=5, max_wall_clock_seconds=60.0), + dispatch=dispatch, + ) + + assert len(dispatch.names) == 3 + terminal = _terminal(events) + assert terminal.kind == "completed" + assert records.budget_exhausted_tier is None + + +def test_a_delegation_under_the_cap_runs_every_leaf() -> None: + dispatch = _CountingDispatch() + events, records = _drive( + _delegation_of(10), + budget=TurnBudgetSpec(max_tool_calls=25, max_wall_clock_seconds=60.0), + dispatch=dispatch, + ) + + assert len(dispatch.names) == 10 + assert _terminal(events).kind == "completed" + assert records.budget_exhausted_tier is None diff --git a/tests/unit/test_infra_dynamodb_asserted_actions.py b/tests/unit/test_infra_dynamodb_asserted_actions.py index a24950b..faa84e2 100644 --- a/tests/unit/test_infra_dynamodb_asserted_actions.py +++ b/tests/unit/test_infra_dynamodb_asserted_actions.py @@ -4,7 +4,8 @@ Every role's explicit same-table Deny is `setsubtract(local.dynamodb_asserted_actions, )`, so an action missing from the asserted set appears in no Deny. The scan reads every `dynamodb:` action literal in the root `infra/*.tf` files, including grants written inline as module arguments, and -asserts the asserted set equals the granted set in both directions. +asserts the asserted set equals the granted set in both directions. A `Deny` statement grants +nothing and a condition `variable` names a context key, not an action, so neither is read as a grant. """ from __future__ import annotations @@ -13,6 +14,9 @@ from pathlib import Path from typing import Final +import pytest +from scripts.hcl_text import blank_comments + _INFRA: Final[Path] = Path(__file__).resolve().parents[2] / "infra" #: Any `"dynamodb:Something"` literal, excluding wildcards. @@ -76,8 +80,67 @@ def _asserted_actions(text: str) -> set[str]: return actions +#: A policy-document condition's context-key line, `variable = "dynamodb:..."`. +_CONDITION_VARIABLE: Final[re.Pattern[str]] = re.compile(r'^\s*variable\s*=\s*"[^"]*"\s*$', re.M) + +_STATEMENT_START: Final[re.Pattern[str]] = re.compile(r"^[ \t]*statement[ \t]*\{", re.M) + +#: A statement's own `effect = "Deny"` line, judged on the statement's depth-1 text only. +_DENY_EFFECT: Final[re.Pattern[str]] = re.compile(r'^\s*effect\s*=\s*"Deny"\s*$', re.M) + + +def _statement_blocks(text: str) -> list[tuple[int, int, str]]: + """`(start, end, own_text)` of every `statement { ... }` block, brace-balanced. + + Braces are counted on a comment-blanked copy, so a brace in a comment is ignored. `own_text` is + the block's depth-1 text, without its nested blocks, so an attribute belongs to this statement. + """ + blanked = blank_comments(text) + assert len(blanked) == len(text), "comment blanking must preserve offsets" + blocks: list[tuple[int, int, str]] = [] + position = 0 + for match in _STATEMENT_START.finditer(blanked): + if match.start() < position: + continue + opening = blanked.index("{", match.start()) + depth = 0 + own: list[str] = [] + for index in range(opening, len(blanked)): + char = blanked[index] + if char == "{": + depth += 1 + elif char == "}": + depth -= 1 + if depth == 0: + blocks.append((match.start(), index + 1, "".join(own))) + position = index + 1 + break + elif depth == 1: + own.append(char) + else: + raise AssertionError(f"unbalanced statement block at offset {match.start()}") + return blocks + + +def _without_denies(text: str) -> str: + """`text` with every `statement { ... }` block whose own effect is `Deny` removed.""" + pieces = [] + position = 0 + for start, end, own in _statement_blocks(text): + if _DENY_EFFECT.search(own): + pieces.append(text[position:start]) + position = end + pieces.append(text[position:]) + return "".join(pieces) + + +def _grant_text(text: str) -> str: + """The root text that can grant: Deny statements and condition context keys removed.""" + return _CONDITION_VARIABLE.sub("", _without_denies(text)) + + def _all_granted_actions(text: str) -> set[str]: - return set(_ACTION_LITERAL.findall(text)) + return set(_ACTION_LITERAL.findall(_grant_text(text))) def test_the_asserted_set_covers_every_action_granted_anywhere_in_the_file() -> None: @@ -130,9 +193,131 @@ def test_the_scan_is_not_vacuous_and_sees_no_wildcard() -> None: f"vacuous: {sorted(granted)}" ) assert _asserted_actions(text), "no actions were parsed from the asserted-actions sources" - wildcards = sorted(set(_WILDCARD_LITERAL.findall(text))) + wildcards = sorted(set(_WILDCARD_LITERAL.findall(_grant_text(text)))) assert not wildcards, ( f"{wildcards} is a wildcard dynamodb action literal. The equality assertions above treat every " "literal as a grant, which a wildcard is not — teach this file the distinction rather than " "widening the exclusion." ) + + +def test_a_deny_statement_and_a_condition_key_grant_nothing() -> None: + """Only the Allow's action is read; the Deny's wildcard and the condition key are not.""" + text = """ + statement { + effect = "Allow" + actions = ["dynamodb:GetItem"] + condition { + test = "ForAllValues:StringEquals" + variable = "dynamodb:Attributes" + values = ["rep_id"] + } + } + + statement { + effect = "Deny" + actions = ["dynamodb:*"] + resources = ["*"] + } +""" + assert _all_granted_actions(text) == {"dynamodb:GetItem"} + assert not _WILDCARD_LITERAL.findall(_grant_text(text)) + + +def test_a_wildcard_in_an_allow_statement_is_still_seen() -> None: + text = """ + statement { + effect = "Allow" + actions = ["dynamodb:*"] + } +""" + assert _WILDCARD_LITERAL.findall(_grant_text(text)) == ['"dynamodb:*"'] + + +def test_the_real_tree_has_deny_statements_to_exclude() -> None: + """Control: the exclusion acts on the real tree, so the wildcard check above is not vacuous.""" + text = _source() + assert _WILDCARD_LITERAL.findall(text), "no wildcard anywhere: the Deny exclusion tests nothing" + assert _grant_text(text) != text + + +_ALLOW_GET: Final[str] = """ + statement { + effect = "Allow" + actions = ["dynamodb:GetItem"] + } +""" + +_ALLOW_WILDCARD: Final[str] = """ + statement { + effect = "Allow" + actions = ["dynamodb:*"] + } +""" + +_DENY_WILDCARD: Final[str] = """ + statement { + effect = "Deny" + actions = ["dynamodb:*"] + resources = ["*"] + condition { + test = "Bool" + variable = "aws:SecureTransport" + values = ["false"] + } + } +""" + +#: Layouts `terraform fmt` accepts. The middle statement of each is the Allow under test. +_LAYOUTS: Final[dict[str, tuple[str, str]]] = { + "blank_line_after_open": (" statement {\n", " statement {\n\n"), + "comment_line_inside": (" statement {\n", " statement {\n # a { brace in a comment\n"), +} + + +def _document(*statements: str) -> str: + """The statements inside a policy-document block, as they appear in the root files.""" + return 'data "aws_iam_policy_document" "subject" {' + "".join(statements) + "}\n" + + +def _layout(statement: str, layout: str) -> str: + old, new = _LAYOUTS[layout] + assert statement.count(old) == 1 + return statement.replace(old, new) + + +@pytest.mark.parametrize("layout", sorted(_LAYOUTS)) +def test_an_allow_between_two_denies_is_read_in_every_layout(layout: str) -> None: + text = _document(_DENY_WILDCARD, _layout(_ALLOW_GET, layout), _DENY_WILDCARD) + assert _all_granted_actions(text) == {"dynamodb:GetItem"} + + +@pytest.mark.parametrize("layout", sorted(_LAYOUTS)) +def test_an_allow_followed_by_a_deny_is_read_in_every_layout(layout: str) -> None: + text = _document(_layout(_ALLOW_GET, layout), _DENY_WILDCARD) + assert _all_granted_actions(text) == {"dynamodb:GetItem"} + + +@pytest.mark.parametrize("layout", sorted(_LAYOUTS)) +def test_an_allow_wildcard_is_caught_in_every_layout(layout: str) -> None: + for text in ( + _document(_DENY_WILDCARD, _layout(_ALLOW_WILDCARD, layout), _DENY_WILDCARD), + _document(_layout(_ALLOW_WILDCARD, layout), _DENY_WILDCARD), + ): + assert _WILDCARD_LITERAL.findall(_grant_text(text)) == ['"dynamodb:*"'], text + + +def test_a_deny_effect_in_a_nested_block_does_not_make_its_statement_a_deny() -> None: + """Only the statement's own depth-1 `effect` counts, not text inside a nested block.""" + text = _document( + """ + statement { + effect = "Allow" + actions = ["dynamodb:PutItem"] + nested { + effect = "Deny" + } + } +""" + ) + assert _all_granted_actions(text) == {"dynamodb:PutItem"} diff --git a/tests/unit/test_infra_dynamodb_principal_deny.py b/tests/unit/test_infra_dynamodb_principal_deny.py index 2c5c370..e19c5a8 100644 --- a/tests/unit/test_infra_dynamodb_principal_deny.py +++ b/tests/unit/test_infra_dynamodb_principal_deny.py @@ -601,6 +601,33 @@ def test_allowlist_check_reds_on_a_dropped_entry() -> None: assert _allowlisted_modules(mutated) != _grant_holding_modules(files) +def _non_module_entries(main_tf: str) -> list[str]: + """Entries of `local.dynamodb_data_plane_role_arns` that are not a `module.*` role ARN.""" + match = re.search( + r"dynamodb_data_plane_role_arns\s*=\s*concat\((.*?)\n \)", main_tf, re.DOTALL + ) + assert match is not None, "no `dynamodb_data_plane_role_arns = concat(...)` local" + body = re.sub( + r"\[\s*for\s+\w+\s+in\s+module\.\w+\s*:\s*\w+\.role_arn\s*\]", " ", match.group(1) + ) + return [ + token + for token in re.findall(r"[A-Za-z_][\w.\[\]\"]*\.arn\b", body) + if not token.startswith("module.") + ] + + +def test_the_allowlist_adds_exactly_the_runtime_role_beyond_the_lambda_roles() -> None: + assert _non_module_entries(_root_files()["main.tf"]) == ["aws_iam_role.agentcore_runtime.arn"] + + +def test_the_runtime_role_check_reds_when_the_entry_is_dropped() -> None: + main_tf = _root_files()["main.tf"] + mutated = main_tf.replace(" aws_iam_role.agentcore_runtime.arn,\n", "", 1) + assert mutated != main_tf + assert _non_module_entries(mutated) == [] + + def test_root_passes_operators_to_both_lists_and_root_to_administrators_only() -> None: block = _block(_code(MAIN_TF), 'module "dynamodb"') assert re.search( diff --git a/tests/unit/test_infra_inline_policy_budget.py b/tests/unit/test_infra_inline_policy_budget.py index 8d830cb..ebc0884 100644 --- a/tests/unit/test_infra_inline_policy_budget.py +++ b/tests/unit/test_infra_inline_policy_budget.py @@ -1,8 +1,9 @@ # SPDX-License-Identifier: MIT -"""Plan-time bound: every VPC Lambda role's IAM policy sizes stay under `iam_policy_budget`. +"""Plan-time bound: the VPC Lambda and Runtime roles' IAM policy sizes stay under `iam_policy_budget`. Plans the root's real `lambda_action`, `agent_relay`, `eval_artifacts` and `eni_function_code_deny` -blocks, its locals, and the root inline and managed policies attached to those roles, read verbatim +blocks, its locals, and the root inline and managed policies attached to those roles and to the +AgentCore Runtime's execution role, read verbatim from `infra/main.tf` and every sibling `infra/*.tf`. The modules they depend on but that attach no policy to these roles (dynamodb, vpc, observability, cognito, agentcore, frontend_cdn) are replaced by stub modules whose outputs are literals shaped like the deployed values: DynamoDB table and index @@ -52,6 +53,9 @@ REGION: Final[str] = "us-east-1" _KEY_ID: Final[str] = "11111111-2222-3333-4444-5555eeee5555" +#: The AgentCore Runtime's execution role; its root inline policies are planned and measured too. +RUNTIME_ROLE: Final[str] = "crm-agent-eval-runtime-role" + #: Modules planned from their real source. Every other referenced module becomes a stub. REAL_MODULES: Final[frozenset[str]] = frozenset( { @@ -72,6 +76,13 @@ "aws_kms_key.cursor.arn": f'"arn:aws:kms:{REGION}:{ACCOUNT}:key/{_KEY_ID}"', "aws_kms_key.api_allowlist.arn": f'"arn:aws:kms:{REGION}:{ACCOUNT}:key/{_KEY_ID}"', '"${path.module}/../frontend/index.html"': f'"{REPO_ROOT / "frontend" / "index.html"}"', + # A whole-module reference waits on every output of the module, so the read would be deferred. + "[for name, m in module.lambda_action : m.function_arn if": ( + '[for name, _ in local.tools : "arn:aws:lambda:${var.aws_region}:' + f'{ACCOUNT}:function:crm-agent-eval-${{name}}" if' + ), + "aws_iam_role.agentcore_runtime.arn": f'"arn:aws:iam::{ACCOUNT}:role/{RUNTIME_ROLE}"', + "aws_iam_role.agentcore_runtime.id": f'"{RUNTIME_ROLE}"', "aws_iam_role.agentcore_gateway.arn": ( f'"arn:aws:iam::{ACCOUNT}:role/crm-agent-eval-agentcore-gateway-role"' ), @@ -112,6 +123,11 @@ f"arn:aws:bedrock-agentcore:{REGION}:{ACCOUNT}:runtime/crm_agent_eval_runtime-AAAAAAAAAA" ) +_RUNTIME_LOG_GROUP_ARN: Final[str] = ( + f"arn:aws:logs:{REGION}:{ACCOUNT}:log-group:/aws/bedrock-agentcore/runtimes/" + "crm_agent_eval_runtime-AAAAAAAAAA-DEFAULT" +) + _BLOCK_START = re.compile(r"^(locals|module|resource|data|variable|check)\b[^\n]*\{\s*(\}\s*)?$") @@ -166,7 +182,8 @@ def _selected_root(text: str) -> str: else: continue role = re.search(r"^\s*role\s*=\s*module\.([a-z_]+)\.", block, re.MULTILINE) - if role is None or role.group(1) not in real_names: + on_runtime = re.search(r"^\s*role\s*=\s*aws_iam_role\.agentcore_runtime\.", block, re.M) + if on_runtime is None and (role is None or role.group(1) not in real_names): continue selected.append(block) if policy_block is not block: @@ -211,6 +228,8 @@ def _stub_value(module: str, output: str) -> Any: return _dynamodb_outputs()[output] if output == "agent_runtime_arn": return _RUNTIME_ARN + if output == "agent_runtime_log_group_arn": + return _RUNTIME_LOG_GROUP_ARN if output.endswith("_ids"): return [f"stub-{module}-{output}-a", f"stub-{module}-{output}-b"] if "kms" in output and output.endswith("_arn"): @@ -403,8 +422,8 @@ def aggregates(plan: Plan) -> dict[str, tuple[int, int]]: def test_the_harness_measures_every_vpc_lambda_role( plan: Plan, aggregates: dict[str, tuple[int, int]] ) -> None: - """One role per `lambda_action` instantiation in any `infra/*.tf`, plus the relay.""" - expected = set(_lambda_action_roles(plan).values()) | {RELAY_ROLE} + """One role per `lambda_action` instantiation in any `infra/*.tf`, plus the relay and Runtime.""" + expected = set(_lambda_action_roles(plan).values()) | {RELAY_ROLE, RUNTIME_ROLE} assert len(_lambda_action_roles(plan)) == len(_expected_lambda_action_modules()) assert set(aggregates) == expected, sorted(set(aggregates) ^ expected) # The module's five, plus the root's `eval_trigger_states` and `eval_trigger_artifacts`. @@ -697,3 +716,37 @@ def test_capabilities_inline_aggregate_stays_under_the_fail_threshold( chars, count = aggregates[CAPABILITIES_ROLE] assert count == 4, "logs, vpc-access, dynamodb and config-kms" assert chars < FAIL_USAGE_FRACTION * INLINE_POLICY_AGGREGATE_LIMIT_CHARS, chars + + +RUNTIME_POLICIES: Final[frozenset[str]] = frozenset( + { + "crm-agent-eval-runtime-permissions", + "crm-agent-eval-runtime-history", + "crm-agent-eval-runtime-logs", + } +) + + +def test_the_runtime_role_measures_its_three_inline_policies_under_the_threshold( + plan: Plan, aggregates: dict[str, tuple[int, int]] +) -> None: + """The Runtime role's permissions, history and logs policies, measured with real-shaped ARNs.""" + sizes = { + str(plan.after(address)["name"]): _policy_document_chars( + json.loads(plan.after(address)["policy"]) + ) + for address in plan.addresses_of_type("aws_iam_role_policy") + if plan.after(address).get("role") == RUNTIME_ROLE + } + assert set(sizes) == RUNTIME_POLICIES, sorted(sizes) + chars, count = aggregates[RUNTIME_ROLE] + assert (chars, count) == (sum(sizes.values()), 3) + limit = FAIL_USAGE_FRACTION * INLINE_POLICY_AGGREGATE_LIMIT_CHARS + assert chars < limit, ( + f"{RUNTIME_ROLE}: {chars} chars ({chars / INLINE_POLICY_AGGREGATE_LIMIT_CHARS:.1%}) " + f"per policy {sizes}" + ) + print( + f"{RUNTIME_ROLE} inline aggregate {chars} chars " + f"({chars / INLINE_POLICY_AGGREGATE_LIMIT_CHARS:.1%}); per policy {sizes}" + ) diff --git a/tests/unit/test_infra_relay.py b/tests/unit/test_infra_relay.py index 54bc03e..938c0b5 100644 --- a/tests/unit/test_infra_relay.py +++ b/tests/unit/test_infra_relay.py @@ -390,7 +390,7 @@ def test_the_role_is_this_function_s_own(plan: Plan) -> None: ("overrides", "expected_message"), [ pytest.param( - {"runtime": '"python3.13"'}, + {"runtime": '"python3.14"'}, "only Node.js managed runtimes support response streaming", id="python-runtime-cannot-stream", ), diff --git a/tests/unit/test_infra_runtime_history.py b/tests/unit/test_infra_runtime_history.py new file mode 100644 index 0000000..cf7b7bb --- /dev/null +++ b/tests/unit/test_infra_runtime_history.py @@ -0,0 +1,374 @@ +# SPDX-License-Identifier: MIT +"""Plan-time tests of the Runtime's conversation-history grant, `reps` TTL and history store env var. + +* `agentcore_runtime_history` in `infra/main.tf`, planned offline with stand-in table, name and key + values, renders exactly the designed statements. Each mutation of a scratch copy reds the + statement it weakens. +* The write grant's `dynamodb:Attributes` list equals `HISTORY_ITEM_ATTRIBUTES`, the attributes the + history store writes. +* The `dynamodb` module plans TTL on `expires_at` for `reps` and for no other table. A scratch copy + without the block reds the TTL assertion. +* The Runtime environment sets `CONVERSATION_HISTORY_STORE = "dynamodb"`, and the Runtime role is in + `local.dynamodb_data_plane_role_arns`. +* The compliant plan fixture carries the history policy, the TTL and the env var. +Terraform-backed cells skip when terraform is absent, unless `CRM_REQUIRE_TERRAFORM=1`. +""" + +from __future__ import annotations + +import json +import re +import shutil +from collections.abc import Mapping +from pathlib import Path +from typing import Any, Final + +import pytest +from scripts import plan_fixtures + +from agents.conversation_history import HISTORY_ITEM_ATTRIBUTES +from crm.store.schema import TABLE_NAMES +from tests.unit._terraform_fixture import ( + _PROVIDER_BLOCK, + MODULES_DIR, + Plan, + plan_directory, + plan_module, + plan_root, + require_terraform, + terraform_unavailable_reason, +) +from tests.unit.test_infra_bedrock_grant import _top_level_blocks + +_REPO_ROOT: Final[Path] = Path(__file__).resolve().parents[2] +_MAIN_TF: Final[Path] = _REPO_ROOT / "infra" / "main.tf" +_ACCOUNT: Final[str] = "123456789012" +_REGION: Final[str] = "us-east-1" +_PREFIX: Final[str] = "crm-agent-eval" +_KEY_ARN: Final[str] = f"arn:aws:kms:{_REGION}:{_ACCOUNT}:key/fixture-dynamodb-cmk" +_DOCUMENT: Final[str] = 'data "aws_iam_policy_document" "agentcore_runtime_history"' +_GET: Final[str] = "dynamodb:GetItem" +_PUT: Final[str] = "dynamodb:PutItem" + + +def _table_arn(table: str) -> str: + return f"arn:aws:dynamodb:{_REGION}:{_ACCOUNT}:table/{_PREFIX}{table}" + + +_REPS: Final[str] = _table_arn("reps") +_KEY_CONDITIONS: Final[dict[str, dict[str, frozenset[str]]]] = { + "ForAllValues:StringLike": {"dynamodb:LeadingKeys": frozenset({"history#*"})}, + "Null": {"dynamodb:LeadingKeys": frozenset({"false"})}, +} + +#: sid -> (effect, Action, NotAction, Resource, Condition), each set-valued, as designed. +EXPECTED: Final[dict[str, tuple[str, frozenset[str], frozenset[str], frozenset[str], Any]]] = { + "ConversationHistoryRead": ( + "Allow", + frozenset({_GET}), + frozenset(), + frozenset({_REPS}), + _KEY_CONDITIONS, + ), + "ConversationHistoryWrite": ( + "Allow", + frozenset({_PUT}), + frozenset(), + frozenset({_REPS}), + { + **_KEY_CONDITIONS, + "ForAllValues:StringEquals": { + "dynamodb:Attributes": frozenset(HISTORY_ITEM_ATTRIBUTES) + }, + }, + ), + "ConversationHistoryKms": ( + "Allow", + frozenset({"kms:Decrypt", "kms:GenerateDataKey"}), + frozenset(), + frozenset({_KEY_ARN}), + { + "StringEquals": { + "kms:ViaService": frozenset({f"dynamodb.{_REGION}.amazonaws.com"}), + "kms:EncryptionContext:aws:dynamodb:tableName": frozenset({f"{_PREFIX}reps"}), + } + }, + ), + "DenyDynamoDbOtherTables": ( + "Deny", + frozenset({"dynamodb:*"}), + frozenset(), + frozenset( + arn + for table in TABLE_NAMES + if table != "reps" + for arn in (_table_arn(table), f"{_table_arn(table)}/index/*") + ), + {}, + ), + "DenyRepsNonGrantedActions": ( + "Deny", + frozenset(), + frozenset({_GET, _PUT}), + frozenset({_REPS, f"{_REPS}/index/*"}), + {}, + ), + "DenyRepsOutsideHistoryPrefix": ( + "Deny", + frozenset({_GET, _PUT}), + frozenset(), + frozenset({_REPS}), + {"ForAnyValue:StringNotLike": {"dynamodb:LeadingKeys": frozenset({"history#*"})}}, + ), + "DenyCanaryHistory": ( + "Deny", + frozenset({_GET, _PUT}), + frozenset(), + frozenset({_REPS}), + {"ForAnyValue:StringLike": {"dynamodb:LeadingKeys": frozenset({"history#canary#*"})}}, + ), +} + + +def _as_set(value: Any) -> frozenset[str]: + if value is None: + return frozenset() + return frozenset([value] if isinstance(value, str) else value) + + +def _conditions( + raw: Mapping[str, Mapping[str, Any]] | None, +) -> dict[str, dict[str, frozenset[str]]]: + return { + test: {key: _as_set(values) for key, values in pairs.items()} + for test, pairs in (raw or {}).items() + } + + +def statement_problems(statements: list[Mapping[str, Any]]) -> dict[str, str]: + """sid -> what differs from :data:`EXPECTED`; an extra or missing sid is a problem too.""" + by_sid = {str(s.get("Sid")): s for s in statements} + problems = {sid: "statement absent" for sid in EXPECTED if sid not in by_sid} | { + sid: "unexpected statement" for sid in by_sid if sid not in EXPECTED + } + for sid, (effect, actions, not_actions, resources, conditions) in EXPECTED.items(): + statement = by_sid.get(sid) + if statement is None: + continue + rendered = ( + statement.get("Effect"), + _as_set(statement.get("Action")), + _as_set(statement.get("NotAction")), + _as_set(statement.get("Resource")), + _conditions(statement.get("Condition")), + ) + if rendered != (effect, actions, not_actions, resources, conditions): + problems[sid] = f"rendered {rendered!r}" + return problems + + +def _skip_without_terraform() -> None: + reason = terraform_unavailable_reason() + if reason is not None and not require_terraform(): + pytest.skip(reason) + + +def _subject_hcl(mutate: tuple[str, str] | None = None) -> str: + blocks = _top_level_blocks(_MAIN_TF.read_text(encoding="utf-8")) + locals_blocks = [ + b for b in blocks if b.startswith("locals ") and "runtime_denied_table_arns" in b + ] + documents = [b for b in blocks if b.startswith(_DOCUMENT)] + assert len(locals_blocks) == 1 and len(documents) == 1, (len(locals_blocks), len(documents)) + subject = f"{locals_blocks[0]}\n\n{documents[0]}\n" + if mutate is not None: + old, new = mutate + assert old in subject, f"mutation anchor {old!r} is no longer in the subject" + subject = subject.replace(old, new, 1) + subject = subject.replace("module.dynamodb.", "local.stand_in_dynamodb.").replace( + "var.aws_region", f'"{_REGION}"' + ) + arns = ",\n".join(f' {t} = "{_table_arn(t)}"' for t in sorted(TABLE_NAMES)) + names = ",\n".join(f' {t} = "{_PREFIX}{t}"' for t in sorted(TABLE_NAMES)) + stand_in = ( + "locals {\n stand_in_dynamodb = {\n" + f" table_arns = {{\n{arns}\n }}\n" + f" table_names = {{\n{names}\n }}\n" + f' kms_key_arn = "{_KEY_ARN}"\n }}\n}}\n' + ) + return ( + f"{stand_in}\n{subject}\n" + 'resource "terraform_data" "history" {\n' + " input = data.aws_iam_policy_document.agentcore_runtime_history.json\n}\n" + ) + + +def _rendered(work_dir: Path, mutate: tuple[str, str] | None = None) -> list[Mapping[str, Any]]: + _skip_without_terraform() + plan = plan_root(work_dir, _subject_hcl(mutate)) + document: Any = json.loads(plan.after("terraform_data.history")["input"]) + statements: list[Mapping[str, Any]] = document["Statement"] + return statements + + +def test_the_history_document_renders_exactly_the_designed_statements(tmp_path: Path) -> None: + assert statement_problems(_rendered(tmp_path)) == {} + + +def test_the_write_grant_names_exactly_the_attributes_the_store_writes() -> None: + assert "tenant" not in HISTORY_ITEM_ATTRIBUTES + match = re.search( + r'variable = "dynamodb:Attributes"\s*\n\s*values\s*=\s*\[([^\]]*)\]', + _MAIN_TF.read_text(encoding="utf-8"), + ) + assert match is not None, "no dynamodb:Attributes condition in infra/main.tf" + assert set(re.findall(r'"([^"]+)"', match.group(1))) == set(HISTORY_ITEM_ATTRIBUTES) + + +_NULL_CONDITION: Final[str] = ( + " condition {\n" + ' test = "Null"\n' + ' variable = "dynamodb:LeadingKeys"\n' + ' values = ["false"]\n' + " }\n" +) + +#: id -> ((old, new) applied to the first match in the subject, the sid that must red). +MUTATIONS: Final[dict[str, tuple[tuple[str, str], str]]] = { + "read_null_condition_dropped": ((_NULL_CONDITION, ""), "ConversationHistoryRead"), + "read_action_widened": ( + ('actions = ["dynamodb:GetItem"]', 'actions = ["dynamodb:GetItem", "dynamodb:Query"]'), + "ConversationHistoryRead", + ), + "write_attributes_dropped": ( + ('variable = "dynamodb:Attributes"', 'variable = "dynamodb:ReturnValues"'), + "ConversationHistoryWrite", + ), + "kms_table_condition_dropped": ( + ( + 'variable = "kms:EncryptionContext:aws:dynamodb:tableName"', + 'variable = "kms:EncryptionContext:other"', + ), + "ConversationHistoryKms", + ), + "kms_via_service_widened": ( + ('"dynamodb.${var.aws_region}.amazonaws.com"', '"dynamodb.*.amazonaws.com"'), + "ConversationHistoryKms", + ), + "other_tables_deny_narrowed": ( + ('if table_name != "reps"', 'if table_name != "reps" && table_name != "accounts"'), + "DenyDynamoDbOtherTables", + ), + "not_actions_widened": ( + ( + 'not_actions = ["dynamodb:GetItem", "dynamodb:PutItem"]', + 'not_actions = ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Query"]', + ), + "DenyRepsNonGrantedActions", + ), + "prefix_deny_quantifier": ( + ('"ForAnyValue:StringNotLike"', '"ForAllValues:StringNotLike"'), + "DenyRepsOutsideHistoryPrefix", + ), + "canary_deny_retargeted": ( + ('"history#canary#*"', '"history#none#*"'), + "DenyCanaryHistory", + ), +} + + +@pytest.mark.parametrize("mutation", sorted(MUTATIONS)) +def test_each_weakening_reds_the_statement_it_guards(tmp_path: Path, mutation: str) -> None: + edit, sid = MUTATIONS[mutation] + assert set(statement_problems(_rendered(tmp_path, edit))) == {sid} + + +_MODULE_ARGUMENTS: Final[str] = ( + f' name_prefix = "{_PREFIX}"\n' + f' account_id = "{_ACCOUNT}"\n' + f' caller_principal_arn = "arn:aws:iam::{_ACCOUNT}:role/fixture-operator"\n' + f' data_plane_principal_arns = ["arn:aws:iam::{_ACCOUNT}:role/fixture-data-plane"]\n' + f' administrator_principal_arns = ["arn:aws:iam::{_ACCOUNT}:role/fixture-operator"]' +) + + +def _ttl_by_table(plan: Plan) -> dict[str, list[Mapping[str, Any]]]: + by_table: dict[str, list[Mapping[str, Any]]] = {} + for address in plan.addresses_of_type("aws_dynamodb_table"): + after = plan.after(address) + by_table[str(after["name"]).removeprefix(_PREFIX)] = list(after.get("ttl") or []) + return by_table + + +def _ttl_problems(by_table: Mapping[str, list[Mapping[str, Any]]]) -> list[str]: + problems = [] + if by_table.get("reps") != [{"attribute_name": "expires_at", "enabled": True}]: + problems.append(f"reps ttl is {by_table.get('reps')!r}") + for table, ttl in sorted(by_table.items()): + if table != "reps" and any(entry.get("enabled") for entry in ttl): + problems.append(f"{table} has TTL enabled") + return problems + + +def test_reps_alone_has_ttl_on_expires_at(tmp_path: Path) -> None: + _skip_without_terraform() + by_table = _ttl_by_table(plan_module(tmp_path, "dynamodb", _MODULE_ARGUMENTS)) + assert set(by_table) == set(TABLE_NAMES) + assert _ttl_problems(by_table) == [] + + +def test_without_the_ttl_block_the_ttl_check_reds(tmp_path: Path) -> None: + _skip_without_terraform() + modules = tmp_path / "modules" + shutil.copytree(MODULES_DIR / "dynamodb", modules / "dynamodb") + tables_tf = modules / "dynamodb" / "tables.tf" + text = tables_tf.read_text(encoding="utf-8") + block = ' ttl {\n attribute_name = "expires_at"\n enabled = true\n }\n' + assert text.count(block) == 1, "the reps ttl block moved; update this control" + tables_tf.write_text(text.replace(block, ""), encoding="utf-8") + work = tmp_path / "root" + work.mkdir() + (work / "main.tf").write_text( + f'{_PROVIDER_BLOCK}\nmodule "subject" {{\n source = "{modules / "dynamodb"}"\n\n' + f"{_MODULE_ARGUMENTS}\n}}\n", + encoding="utf-8", + ) + assert _ttl_problems(_ttl_by_table(plan_directory(work))) != [] + + +def _runtime_environment_block(text: str) -> str: + match = re.search(r"agent_runtime_environment_variables\s*=\s*\{(.*?)\n \}", text, re.DOTALL) + assert match is not None, "no agent_runtime_environment_variables map in infra/main.tf" + return match.group(1) + + +def test_the_runtime_environment_selects_the_dynamodb_history_store() -> None: + block = _runtime_environment_block(_MAIN_TF.read_text(encoding="utf-8")) + assert re.search(r'^\s*CONVERSATION_HISTORY_STORE\s*=\s*"dynamodb"\s*$', block, re.MULTILINE) + + +def test_the_runtime_role_is_a_data_plane_principal() -> None: + match = re.search( + r"dynamodb_data_plane_role_arns\s*=\s*concat\((.*?)\n \)", + _MAIN_TF.read_text(encoding="utf-8"), + re.DOTALL, + ) + assert match is not None + assert re.findall(r"^\s*aws_iam_role\.agentcore_runtime\.arn,\s*$", match.group(1), re.M) == [ + " aws_iam_role.agentcore_runtime.arn," + ] + + +def _fixture_changes() -> dict[str, Mapping[str, Any]]: + document = plan_fixtures.build("compliant") + return {str(change["address"]): change["change"] for change in document["resource_changes"]} + + +def test_the_compliant_plan_carries_the_history_policy_ttl_and_env_var() -> None: + changes = _fixture_changes() + policy = changes["aws_iam_role_policy.agentcore_runtime_history"] + assert policy["after"]["name"] == "crm-agent-eval-runtime-history" + reps = changes["module.dynamodb.aws_dynamodb_table.reps"]["after"] + assert reps["ttl"] == [{"attribute_name": "expires_at", "enabled": True}] + runtime = changes["module.agentcore.aws_bedrockagentcore_agent_runtime.this"]["after"] + assert runtime["environment_variables"]["CONVERSATION_HISTORY_STORE"] == "dynamodb" diff --git a/tests/unit/test_integration_gateway_scope.py b/tests/unit/test_integration_gateway_scope.py index 9d7256e..b9c4743 100644 --- a/tests/unit/test_integration_gateway_scope.py +++ b/tests/unit/test_integration_gateway_scope.py @@ -17,6 +17,7 @@ import pytest import scripts.smoke.integration_gateway_scope as smoke +from botocore.exceptions import ClientError from scripts.smoke.demo_tenant_guard import DEMO_TENANT, WATCHED_TABLES from scripts.smoke.gateway_tools import ServicePrincipalFixture from scripts.smoke.harness import CheckResult, context_for_test @@ -1363,3 +1364,55 @@ def test_an_unadvertised_filter_tool_fails_both_rows() -> None: ) assert {row.status for row in rows.values()} == {"fail"} assert all(FILTER_TOOL in row.detail for row in rows.values()) + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +class _DeniedProvisioner(_FakeProvisioner): + """Provisioning and cleanup both raise an AWS error whose message carries a planted ARN.""" + + def __init__(self, *, fail_provision: bool) -> None: + super().__init__() + self._fail_provision = fail_provision + + def provision(self) -> ServicePrincipalFixture: + if self._fail_provision: + raise self._denied("PutItem") + return super().provision() + + def cleanup(self) -> list[CheckResult]: + super().cleanup() + raise self._denied("DeleteItem") + + @staticmethod + def _denied(operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, + operation, + ) + + +@pytest.mark.parametrize( + ("fail_provision", "check", "text"), + [ + (True, "provision_service_principal", "PutItem failed (AccessDeniedException)"), + (False, "cleanup_service_principal", "DeleteItem failed (AccessDeniedException)"), + ], + ids=["provision", "cleanup"], +) +def test_aws_failures_name_the_code_never_the_message( + fail_provision: bool, check: str, text: str +) -> None: + published = { + r.check: r + for r in checks( + _ctx(), + mcp_caller=_FakeGateway(token_identity=_VERIFIED_IDENTITY), + provisioner=_DeniedProvisioner(fail_provision=fail_provision), + row_reader=_FakeRowReader(smoke_rows=3), + ) + } + assert published[check].status == "fail" + assert text in published[check].detail + assert _PLANTED_ARN not in published[check].detail diff --git a/tests/unit/test_integration_proposal_chain.py b/tests/unit/test_integration_proposal_chain.py index a5199d5..19d53a4 100644 --- a/tests/unit/test_integration_proposal_chain.py +++ b/tests/unit/test_integration_proposal_chain.py @@ -15,6 +15,7 @@ import boto3 import pytest +from botocore.exceptions import ClientError from moto import mock_aws from scripts.smoke import verified_claims from scripts.smoke.harness import CheckResult, context_for_test @@ -1117,3 +1118,78 @@ def recording_client_get_item(**kwargs: Any) -> Any: call for call in sent if any("-oob-" in str(v.get("S")) for v in call["Key"].values()) ] assert wire_oob and all(call.get("ConsistentRead") is True for call in wire_oob) + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted_error(operation: str) -> ClientError: + return ClientError( + { + "Error": { + "Code": "AccessDeniedException", + "Message": f"{_PLANTED_ARN} is not authorized", + } + }, + operation, + ) + + +def _assert_masked(results: list[CheckResult], row: CheckResult) -> None: + assert row.status == "fail" + assert "failed (AccessDeniedException)" in row.detail + assert not [r for r in results if _PLANTED_ARN in r.detail] + + +def test_an_identity_aws_error_is_reported_by_code_not_message(store: Store) -> None: + class _Denied: + def acquire(self) -> SmokeIdentity: + raise _planted_error("AdminInitiateAuth") + + def release(self) -> Iterable[CheckResult]: + return () + + results = list( + checks(_test_context(store), http_caller=_make_handler_http_caller(store), lease=_Denied()) + ) + _assert_masked(results, results[0]) + + +@pytest.mark.parametrize( + ("attribute", "resource", "check"), + [ + ("_stage_index_ids", "approve", "derived_index_attributes_recomputed"), + ("_proposals_by_status", "approve", "proposal_reachable_by_approved_status_index"), + ], +) +def test_an_index_query_aws_error_is_reported_by_code_not_message( + store: Store, monkeypatch: pytest.MonkeyPatch, attribute: str, resource: str, check: str +) -> None: + import scripts.smoke.integration_proposal_chain as module + + def denied(*_args: Any, **_kwargs: Any) -> set[str]: + raise RuntimeError("store call failed") from _planted_error("Query") + + monkeypatch.setattr(module, attribute, denied) + results = _run_chain(store) + _assert_masked(results, _find(results, resource, check)) + + +def test_a_row_count_aws_error_is_reported_by_code_not_message( + store: Store, monkeypatch: pytest.MonkeyPatch +) -> None: + import scripts.smoke.integration_proposal_chain as module + + real_count = module._tenant_row_count # noqa: SLF001 + demo_reads: list[str] = [] + + def denied_after_the_snapshot(ctx: Any, table: str, tenant: str) -> int: + if tenant == "demo": + demo_reads.append(table) + if len(demo_reads) > len(module._DEMO_WATCHED_TABLES): # noqa: SLF001 + raise _planted_error("Query") + return real_count(ctx, table, tenant) + + monkeypatch.setattr(module, "_tenant_row_count", denied_after_the_snapshot) + results = _run_chain(store) + _assert_masked(results, _find(results, RESOURCE_CLASS, "demo_tenant_untouched")) diff --git a/tests/unit/test_integration_ui_api_ddb.py b/tests/unit/test_integration_ui_api_ddb.py index 96ba2a5..0dd0445 100644 --- a/tests/unit/test_integration_ui_api_ddb.py +++ b/tests/unit/test_integration_ui_api_ddb.py @@ -767,6 +767,39 @@ def test_derived_out_of_book_candidate_of_another_tenant_is_never_used() -> None assert not [tool for tool, _ in calls if tool == "get_account"] +def test_a_failed_out_of_book_read_names_the_aws_code_never_the_message() -> None: + """A DynamoDB error while deriving the 403 target is reported by operation and code only.""" + planted_arn = "arn:aws:sts::123456789012:assumed-role/x/y" + book = [f"acct-{SMOKE_TENANT}-0000", f"acct-{SMOKE_TENANT}-0001"] + client = _dynamodb_client() + stubber = Stubber(client) + _stub_full_round_trip(stubber) + stubber.add_client_error( + "get_item", + service_error_code="AccessDeniedException", + service_message=f"User: {planted_arn} is not authorized", + http_status_code=400, + ) + stubber.activate() + token = _token_with_claims({"custom:tenant": SMOKE_TENANT, "custom:book": ",".join(book)}) + + results = list( + checks( + _make_ctx(client), + http_caller=_happy_http_caller(), + token=token, + account_id=ACCOUNT_ID, + out_of_book_account_id=None, + ) + ) + stubber.deactivate() + + denial = _check(results, "out_of_book_refused_403") + assert denial.status == "fail" + assert "failed (AccessDeniedException)" in denial.detail + assert planted_arn not in denial.detail + + @pytest.mark.parametrize("kind", ["not_a_jwt", "forged"]) def test_an_unverifiable_token_is_refused_before_any_call_even_with_a_tenant_flag( kind: str, diff --git a/tests/unit/test_lambda_env_contract.py b/tests/unit/test_lambda_env_contract.py index 6224734..5936ac1 100644 --- a/tests/unit/test_lambda_env_contract.py +++ b/tests/unit/test_lambda_env_contract.py @@ -55,6 +55,7 @@ class _Function: "AWS_CONFIG_FILE", "AWS_PROFILE", "AWS_SHARED_CREDENTIALS_FILE", + "CONVERSATION_HISTORY_STORE", "EVAL_SUBSTRATE", "LOG_LEVEL", } diff --git a/tests/unit/test_lambda_zip_imports.py b/tests/unit/test_lambda_zip_imports.py index 058fe12..851f02c 100644 --- a/tests/unit/test_lambda_zip_imports.py +++ b/tests/unit/test_lambda_zip_imports.py @@ -42,8 +42,8 @@ def _load_gate() -> ModuleType: gate = _load_gate() -LINUX_WHEEL = "Wheel-Version: 1.0\nGenerator: test\nRoot-Is-Purelib: false\nTag: cp313-cp313-manylinux2014_x86_64\n" -DARWIN_WHEEL = "Wheel-Version: 1.0\nGenerator: test\nRoot-Is-Purelib: false\nTag: cp313-cp313-macosx_11_0_arm64\n" +LINUX_WHEEL = "Wheel-Version: 1.0\nGenerator: test\nRoot-Is-Purelib: false\nTag: cp314-cp314-manylinux2014_x86_64\n" +DARWIN_WHEEL = "Wheel-Version: 1.0\nGenerator: test\nRoot-Is-Purelib: false\nTag: cp314-cp314-macosx_11_0_arm64\n" PURE_WHEEL = "Wheel-Version: 1.0\nGenerator: test\nRoot-Is-Purelib: true\nTag: py3-none-any\n" @@ -279,15 +279,15 @@ def test_a_linux_wheel_tag_and_a_pure_python_tag_both_pass(tmp_path: Path) -> No @pytest.mark.parametrize( "members", [ - {"vendormod-1.0.dist-info/WHEEL": LINUX_WHEEL.replace("cp313-cp313", "cp312-cp312")}, - {"ext/__init__.py": "", "ext/ext.cpython-312-x86_64-linux-gnu.so": "\x00binary"}, + {"vendormod-1.0.dist-info/WHEEL": LINUX_WHEEL.replace("cp314-cp314", "cp313-cp313")}, + {"ext/__init__.py": "", "ext/ext.cpython-313-x86_64-linux-gnu.so": "\x00binary"}, ], - ids=["cp312_wheel_tag", "cpython_312_extension"], + ids=["cp313_wheel_tag", "cpython_313_extension"], ) def test_an_artifact_built_for_the_previous_runtime_minor_version_fails( tmp_path: Path, members: dict[str, str] ) -> None: - """A cp312 wheel tag or a cpython-312 extension does not load on the python3.13 runtime.""" + """A cp313 wheel tag or a cpython-313 extension does not load on the python3.14 runtime.""" zip_members = { "crm/__init__.py": "", "crm/handlers/__init__.py": "", @@ -297,7 +297,7 @@ def test_an_artifact_built_for_the_previous_runtime_minor_version_fails( result = gate.check_zip( SYNTHETIC_SPEC, _write_zip(tmp_path / "synthetic.zip", zip_members), source_root=None ) - assert any("cp312" in v or "CPython 312, not 313" in v for v in result.violations), ( + assert any("cp313" in v or "CPython 313, not 314" in v for v in result.violations), ( result.violations ) @@ -308,7 +308,7 @@ def test_a_darwin_extension_module_filename_fails(tmp_path: Path) -> None: "crm/handlers/__init__.py": "", "crm/handlers/synthetic.py": "def handler(event, context):\n return None\n", "ext/__init__.py": "", - "ext/ext.cpython-313-darwin.so": "\x00binary", + "ext/ext.cpython-314-darwin.so": "\x00binary", } result = gate.check_zip( SYNTHETIC_SPEC, _write_zip(tmp_path / "synthetic.zip", members), source_root=None @@ -316,18 +316,18 @@ def test_a_darwin_extension_module_filename_fails(tmp_path: Path) -> None: assert any("not x86_64 Linux" in v for v in result.violations), result.violations -def test_a_cpython_314_extension_module_fails(tmp_path: Path) -> None: +def test_a_cpython_315_extension_module_fails(tmp_path: Path) -> None: members = { "crm/__init__.py": "", "crm/handlers/__init__.py": "", "crm/handlers/synthetic.py": "def handler(event, context):\n return None\n", "ext/__init__.py": "", - "ext/ext.cpython-314-x86_64-linux-gnu.so": "\x00binary", + "ext/ext.cpython-315-x86_64-linux-gnu.so": "\x00binary", } result = gate.check_zip( SYNTHETIC_SPEC, _write_zip(tmp_path / "synthetic.zip", members), source_root=None ) - assert any("targets CPython 314" in v for v in result.violations), result.violations + assert any("targets CPython 315" in v for v in result.violations), result.violations def test_a_wheel_with_no_tag_line_is_a_violation_rather_than_a_pass(tmp_path: Path) -> None: @@ -381,8 +381,8 @@ def test_a_partially_built_directory_always_fails(tmp_path: Path) -> None: #: correctly-built zip legitimately drops — a `../../bin/` console script and a `__pycache__` entry). COMPILED_RECORD = ( "vendormod/__init__.py,sha256=aaa,10\n" - "vendormod/vendormod.cpython-313-x86_64-linux-gnu.so,sha256=bbb,20\n" - "vendormod/__pycache__/__init__.cpython-313.pyc,,\n" + "vendormod/vendormod.cpython-314-x86_64-linux-gnu.so,sha256=bbb,20\n" + "vendormod/__pycache__/__init__.cpython-314.pyc,,\n" "../../bin/vendorcli,sha256=ccc,30\n" "vendormod-1.0.dist-info/WHEEL,sha256=ddd,40\n" "vendormod-1.0.dist-info/RECORD,,\n" @@ -409,7 +409,7 @@ def _compiled_vendor_zip(path: Path, *, body: bool, extension: bool) -> Path: if body: members["vendormod/__init__.py"] = "VALUE = 1\n" if extension: - members["vendormod/vendormod.cpython-313-x86_64-linux-gnu.so"] = "\x00binary" + members["vendormod/vendormod.cpython-314-x86_64-linux-gnu.so"] = "\x00binary" return _write_zip(path, members) @@ -444,7 +444,7 @@ def test_a_vendored_distribution_missing_only_its_compiled_leaf_fails(tmp_path: """A distribution missing only its compiled `.so`, with its pure-Python body kept, fails.""" path = _compiled_vendor_zip(tmp_path / "synthetic.zip", body=True, extension=False) result = gate.check_zip(SYNTHETIC_SPEC, path, source_root=None) - assert any("vendormod.cpython-313-x86_64-linux-gnu.so" in v for v in result.violations), ( + assert any("vendormod.cpython-314-x86_64-linux-gnu.so" in v for v in result.violations), ( result.violations ) @@ -504,19 +504,19 @@ def test_the_real_zip_with_a_vendored_distribution_stripped_fails( def test_the_marker_environment_is_the_lambda_runtime_and_not_the_build_host() -> None: """Markers are evaluated against the Lambda runtime's environment, not the build host's.""" - assert gate.LAMBDA_MARKER_ENVIRONMENT["python_version"] == "3.13" + assert gate.LAMBDA_MARKER_ENVIRONMENT["python_version"] == "3.14" assert gate.LAMBDA_MARKER_ENVIRONMENT["sys_platform"] == "linux" assert gate.LAMBDA_MARKER_ENVIRONMENT["platform_machine"] == "x86_64" - assert gate.TARGET_PYTHON_VERSION == (3, 13) + assert gate.TARGET_PYTHON_VERSION == (3, 14) @pytest.mark.parametrize( ("marker", "required"), [ ("", True), - ('; python_version < "3.14"', True), - ('; python_version >= "3.14"', False), - ('; python_version < "3.13"', False), + ('; python_version < "3.15"', True), + ('; python_version >= "3.15"', False), + ('; python_version < "3.14"', False), ('; python_version < "3.9"', False), ('; sys_platform == "linux"', True), ('; sys_platform == "win32"', False), @@ -560,11 +560,11 @@ def test_a_requirement_the_lambda_runtime_provides_is_not_reported_missing() -> def test_a_zip_missing_a_marker_required_distribution_fails(tmp_path: Path) -> None: - """A zip missing a distribution required under the 3.13 target's markers fails.""" + """A zip missing a distribution required under the 3.14 target's markers fails.""" path = _handler_zip( tmp_path / "synthetic.zip", vendor=True, - requires=('typing-extensions>=4.4.0; python_version < "3.14"',), + requires=('typing-extensions>=4.4.0; python_version < "3.15"',), ) result = gate.check_zip(SYNTHETIC_SPEC, path, source_root=None) assert result.violations, "a marker-required distribution absent from the zip must fail" @@ -572,7 +572,7 @@ def test_a_zip_missing_a_marker_required_distribution_fails(tmp_path: Path) -> N "typing-extensions" in v and "required by vendored 'vendormod'" in v for v in result.violations ), result.violations - assert any("python_version=3.13" in v for v in result.violations), result.violations + assert any("python_version=3.14" in v for v in result.violations), result.violations # The host's own interpreter satisfies the import, so only the marker phase sees the gap. assert result.isolated_import_status.startswith("pass") @@ -580,12 +580,12 @@ def test_a_zip_missing_a_marker_required_distribution_fails(tmp_path: Path) -> N def test_a_zip_whose_marker_does_not_apply_to_the_target_does_not_false_fail( tmp_path: Path, ) -> None: - """A dependency whose marker does not apply to the 3.13 Lambda target is not required.""" + """A dependency whose marker does not apply to the 3.14 Lambda target is not required.""" path = _handler_zip( tmp_path / "synthetic.zip", vendor=True, requires=( - 'futuremod>=1.0; python_version >= "3.14"', + 'futuremod>=1.0; python_version >= "3.15"', 'windowsmod>=1.0; sys_platform == "win32"', 'armmod>=1.0; platform_machine == "aarch64"', 'extrasmod>=1.0; extra == "docs"', @@ -601,7 +601,7 @@ def test_a_satisfied_marker_requirement_present_in_the_zip_passes(tmp_path: Path path = _handler_zip( tmp_path / "synthetic.zip", vendor=True, - requires=('typing-extensions>=4.4.0; python_version < "3.13"',), + requires=('typing-extensions>=4.4.0; python_version < "3.14"',), ) with zipfile.ZipFile(path, "a") as archive: archive.writestr("typing_extensions.py", "TYPE = 1\n") @@ -638,7 +638,7 @@ def test_an_unparseable_requires_dist_is_a_violation_rather_than_a_silent_skip( assert any("unparseable Requires-Dist" in v for v in result.violations), result.violations -def test_the_real_referencing_metadata_needs_no_typing_extensions_on_the_313_target() -> None: +def test_the_real_referencing_metadata_needs_no_typing_extensions_on_the_314_target() -> None: """`referencing`'s installed METADATA gates `typing-extensions` below 3.13, so the target does not require it. @@ -759,12 +759,14 @@ def test_the_embedded_referencing_reproduction_matches_the_real_vendored_module( assert line in real, line -def test_the_same_zip_passes_on_the_313_build_host_which_is_why_the_outage_shipped( +def test_the_same_zip_passes_on_a_non_target_build_host_which_is_why_the_outage_shipped( tmp_path: Path, ) -> None: - """Without a 3.13 interpreter the same zip imports cleanly and reports a host status.""" + """Without a target interpreter the same zip imports cleanly and reports a host status.""" if sys.version_info[:2] == gate.TARGET_PYTHON_VERSION: - pytest.skip("this host is itself CPython 3.13, so there is no non-target host to contrast") + pytest.skip( + "this host is itself the target CPython, so there is no non-target host to contrast" + ) path = _pep696_zip(tmp_path / "pep696.zip", vendor_typing_extensions=False) result = _isolated_import_only(path, NO_TARGET_INTERPRETER) assert result.isolated_import_status == ( @@ -824,29 +826,29 @@ def test_the_print_target_python_mode_agrees_with_discovery( def test_the_discovery_order_is_env_override_then_path_then_uv_then_pyenv( monkeypatch: pytest.MonkeyPatch, ) -> None: - monkeypatch.setenv(gate.TARGET_PYTHON_ENV_VAR, "/nonexistent/python3.13") + monkeypatch.setenv(gate.TARGET_PYTHON_ENV_VAR, "/nonexistent/python3.14") sources = [source for source, _ in gate._discovery_candidates()] assert sources == [ f"env:{gate.TARGET_PYTHON_ENV_VAR}", - "PATH:python3.13", - "uv python find 3.13", - "pyenv which python3.13", + "PATH:python3.14", + "uv python find 3.14", + "pyenv which python3.14", ] def test_an_interpreter_reporting_another_minor_version_is_rejected_not_used( tmp_path: Path, ) -> None: - """A candidate reporting CPython 3.12 is rejected as a target candidate for the 3.13 runtime.""" - fake = tmp_path / "python3.12" + """A candidate reporting CPython 3.13 is rejected as a target candidate for the 3.14 runtime.""" + fake = tmp_path / "python3.13" fake.write_text( - '#!/bin/sh\necho \'{"version": [3, 12], "stdlib": ["/x", "/x", "/x/lib-dynload"]}\'\n', + '#!/bin/sh\necho \'{"version": [3, 13], "stdlib": ["/x", "/x", "/x/lib-dynload"]}\'\n', encoding="utf-8", ) fake.chmod(0o755) stdlib, description = gate._probe_interpreter(str(fake)) assert stdlib is None - assert "is CPython 3.12, not the target 3.13" in description + assert "is CPython 3.13, not the target 3.14" in description def test_the_host_interpreter_is_accepted_only_when_it_is_the_target_version() -> None: @@ -856,7 +858,7 @@ def test_the_host_interpreter_is_accepted_only_when_it_is_the_target_version() - def test_a_candidate_that_cannot_be_executed_is_rejected_with_a_reason() -> None: - stdlib, description = gate._probe_interpreter("/nonexistent/python3.13") + stdlib, description = gate._probe_interpreter("/nonexistent/python3.14") assert stdlib is None assert "could not be executed" in description @@ -864,18 +866,18 @@ def test_a_candidate_that_cannot_be_executed_is_rejected_with_a_reason() -> None def test_no_discoverable_interpreter_keeps_the_non_target_status_and_names_what_was_tried( tmp_path: Path, ) -> None: - """With no discoverable 3.13 the phase still passes, keeps a non-target status, and names the + """With no discoverable 3.14 the phase still passes, keeps a non-target status, and names the candidates tried.""" if sys.version_info[:2] == gate.TARGET_PYTHON_VERSION: - pytest.skip("this host is itself CPython 3.13, which discovery always accepts") + pytest.skip("this host is itself the target CPython, which discovery always accepts") result = _isolated_import_only( _handler_zip(tmp_path / "synthetic.zip", vendor=True), - gate.InterpreterDiscovery(None, ("env:PYTHON313: not found", "PATH:python3.13: not found")), + gate.InterpreterDiscovery(None, ("env:PYTHON314: not found", "PATH:python3.14: not found")), ) assert result.violations == [] assert "target_python" not in result.isolated_import_status note = " ".join(result.notes) - assert "PATH:python3.13: not found" in note + assert "PATH:python3.14: not found" in note assert gate.TARGET_PYTHON_ENV_VAR in note @@ -899,7 +901,7 @@ def test_a_skipped_isolated_import_is_counted_as_skipped_and_never_as_executed( _handler_zip(tmp_path / "synthetic.zip", vendor=True), {"rpds_py-2026.6.3": ["a_top_level_no_build_host_provides"]}, result, - discovery=gate.InterpreterDiscovery(None, ("env:PYTHON313: not found",)), + discovery=gate.InterpreterDiscovery(None, ("env:PYTHON314: not found",)), ) assert result.isolated_import_status == "skip" assert result.violations == [] @@ -976,7 +978,7 @@ def test_the_reports_json_states_both_the_host_and_the_target_python_version( # compare against; the report fields under test are independent of it. status, report = gate.run(tmp_path, require_zips=True, source_root=None) assert status == 0, report - assert report["target_python_version"] == "3.13" + assert report["target_python_version"] == "3.14" assert report["host_python_version"] == f"{sys.version_info[0]}.{sys.version_info[1]}" assert isinstance(report["marker_environment"], dict) @@ -995,8 +997,8 @@ def test_the_missing_required_distributions_mode_names_what_the_target_still_nee _metadata( "requirer", "1.0", - 'typing-extensions>=4.4.0; python_version < "3.14"', - 'futuremod>=1.0; python_version >= "3.14"', + 'typing-extensions>=4.4.0; python_version < "3.15"', + 'futuremod>=1.0; python_version >= "3.15"', ), encoding="utf-8", ) @@ -1455,7 +1457,7 @@ def test_bytecode_caches_are_not_compared_since_the_build_never_ships_them( tmp_path: Path, ) -> None: """`package_lambdas.sh` excludes `__pycache__`/`*.pyc`, so their absence is not staleness.""" - with_cache = {**_PARITY_FILES, "crm/handlers/__pycache__/synthetic.cpython-313.pyc": "x"} + with_cache = {**_PARITY_FILES, "crm/handlers/__pycache__/synthetic.cpython-314.pyc": "x"} assert _parity_violations(tmp_path, zip_files=_PARITY_FILES, source_files=with_cache) == [] diff --git a/tests/unit/test_matrix.py b/tests/unit/test_matrix.py index 0990a01..f1e49de 100644 --- a/tests/unit/test_matrix.py +++ b/tests/unit/test_matrix.py @@ -20,6 +20,7 @@ from eval.matrix import ( ARM_COST_TOTAL_KEY, ARM_LONG_CONTEXT_INVOCATION_COUNT_KEY, + RECORD_SHAPE_VERSION_KEY, ArmResult, MatrixResult, RunProvenance, @@ -63,6 +64,7 @@ def _sample_provenance( price_table_version="v0-provisional", answer_style_sha256="0" * 64, prompt_bundle_sha256="1" * 64, + prompt_caching="explicit cache points", ) @@ -133,6 +135,37 @@ def _sample_arm( ) +def _sample_tier_summary_fields() -> dict[str, object]: + """An all-zero record shape 3 ``tier_summary``, as :mod:`eval.metrics` emits it.""" + from eval.metrics import aggregate_tier_summary, not_measured_latency_metrics + + return aggregate_tier_summary( + (), not_measured_latency_metrics(), (), withhold_cost=True + ).to_report_fields() + + +def _sample_tier_task_metrics_fields() -> dict[str, object]: + """An empty record shape 3 ``tier_task_metrics`` block, as :mod:`eval.metrics` emits it.""" + from eval.metrics import aggregate_tier_task_metrics + + model_id = "us.anthropic.claude-opus-5-v1:0" + return aggregate_tier_task_metrics( + (), + measured=False, + family="anthropic", + configured_model_ids={"supervisor": model_id, "subagent": model_id, "tool": model_id}, + ).to_report_fields() + + +def _archivable_arm(**kwargs: object) -> ArmResult: + """:func:`_sample_arm` with the blocks a raw archive must carry to be re-read.""" + return dataclasses.replace( + _sample_arm(**kwargs), # type: ignore[arg-type] + tier_summary_fields=_sample_tier_summary_fields(), + tier_task_metrics_fields=_sample_tier_task_metrics_fields(), + ) + + def _sample_matrix(*, withheld: bool = True) -> MatrixResult: return build_matrix_result([_sample_arm(withheld=withheld)]) @@ -250,7 +283,7 @@ def _sample_task_spread_fields() -> list[dict[str, object]]: def _sample_arm_with_aggregations(*, withheld: bool = True) -> ArmResult: - """`_sample_arm` extended with the three per-arm aggregations.""" + """`_sample_arm` extended with the three per-arm aggregations and a `tier_summary`.""" base = _sample_arm(withheld=withheld) return ArmResult( provenance=base.provenance, @@ -260,6 +293,8 @@ def _sample_arm_with_aggregations(*, withheld: bool = True) -> ArmResult: tier_role_model_fields=tuple(_sample_tier_role_model_fields(withheld=withheld)), tool_fields=tuple(_sample_tool_fields()), task_spread_fields=tuple(_sample_task_spread_fields()), + tier_summary_fields=_sample_tier_summary_fields(), + tier_task_metrics_fields=_sample_tier_task_metrics_fields(), ) @@ -668,6 +703,7 @@ def test_raw_archive_file_names_do_not_collide_across_repeated_runs(tmp_path: Pa price_table_version=arm_two_provenance.price_table_version, answer_style_sha256=arm_two_provenance.answer_style_sha256, prompt_bundle_sha256=arm_two_provenance.prompt_bundle_sha256, + prompt_caching=arm_two_provenance.prompt_caching, ), model_metrics_fields=_sample_model_metrics_fields(), aggregate_score_fields=_sample_aggregate_score_fields(), @@ -794,6 +830,7 @@ def test_arm_heading_names_live_mode_when_provenance_is_live() -> None: price_table_version=live_provenance.price_table_version, answer_style_sha256=live_provenance.answer_style_sha256, prompt_bundle_sha256=live_provenance.prompt_bundle_sha256, + prompt_caching=live_provenance.prompt_caching, ), model_metrics_fields=_sample_model_metrics_fields(), aggregate_score_fields=_sample_aggregate_score_fields(), @@ -834,6 +871,7 @@ def test_stub_mode_disclosure_precedes_the_aggregate_score_table() -> None: price_table_version=live_provenance.price_table_version, answer_style_sha256=live_provenance.answer_style_sha256, prompt_bundle_sha256=live_provenance.prompt_bundle_sha256, + prompt_caching=live_provenance.prompt_caching, ), model_metrics_fields=_sample_model_metrics_fields(), aggregate_score_fields=_sample_aggregate_score_fields(), @@ -1053,7 +1091,12 @@ def test_rendered_json_carries_the_figure_semantics_block_additively() -> None: """`matrix.json` carries the figure-semantics block and leaves `arms` unchanged.""" matrix = _sample_matrix() payload = json.loads(render_json(matrix)) - assert list(payload) == ["tier_comparison", "arms", "figure_semantics"] + assert list(payload) == [ + RECORD_SHAPE_VERSION_KEY, + "tier_comparison", + "arms", + "figure_semantics", + ] assert len(payload["arms"]) == 1 semantics = payload["figure_semantics"] assert semantics["source"] == "src/eval/matrix.py" @@ -1470,12 +1513,12 @@ def test_tool_call_correct_rate_note_states_expected_reads_is_only_necessary() - def test_arm_round_trips_through_its_raw_archive_fields() -> None: - arm = _sample_arm() + arm = _archivable_arm() assert matrix.arm_from_report_fields(arm.to_report_fields()) == arm def test_arm_from_report_fields_refuses_an_archive_missing_a_block() -> None: - fields = _sample_arm().to_report_fields() + fields = _archivable_arm().to_report_fields() del fields["model_metrics"] with pytest.raises(ValueError, match="model_metrics"): matrix.arm_from_report_fields(fields) @@ -1494,20 +1537,31 @@ def test_provenance_records_the_prompt_bundle_hash_after_the_answer_style_hash() assert fields["prompt_bundle_sha256"] == "1" * 64 names = list(fields) assert names.index("prompt_bundle_sha256") == names.index("answer_style_sha256") + 1 - assert list(matrix._PROVENANCE_FIELDS) == [name for name in names if name != "temperature"] + assert list(matrix._PROVENANCE_FIELDS) == names -def test_an_archive_without_the_prompt_bundle_hash_reads_none_and_renders_a_dash() -> None: - fields = _sample_arm().to_report_fields() +def test_an_archive_without_the_prompt_bundle_hash_is_refused() -> None: + fields = _archivable_arm().to_report_fields() del cast(dict[str, object], fields["provenance"])["prompt_bundle_sha256"] - arm = matrix.arm_from_report_fields(fields) - assert arm.provenance.prompt_bundle_sha256 is None - assert "| prompt_bundle_sha256 | — |" in render_markdown(build_matrix_result([arm])) + with pytest.raises( + matrix.RecordShapeRefused, match="missing required field provenance.prompt_bundle_sha256" + ): + matrix.arm_from_report_fields(fields) + + +def test_a_null_prompt_bundle_hash_reads_none_and_renders_a_dash() -> None: + arm = dataclasses.replace( + _archivable_arm(), + provenance=dataclasses.replace(_sample_provenance(), prompt_bundle_sha256=None), + ) + rebuilt = matrix.arm_from_report_fields(arm.to_report_fields()) + assert rebuilt.provenance.prompt_bundle_sha256 is None + assert "| prompt_bundle_sha256 | — |" in render_markdown(build_matrix_result([rebuilt])) def test_arm_from_report_fields_refuses_an_archive_missing_the_answer_style_hash() -> None: """A raw archive with no answer-style hash is refused, never defaulted.""" - fields = _sample_arm().to_report_fields() + fields = _archivable_arm().to_report_fields() provenance = cast(dict[str, object], fields["provenance"]) del provenance["answer_style_sha256"] with pytest.raises(ValueError, match="answer_style_sha256"): @@ -1517,7 +1571,7 @@ def test_arm_from_report_fields_refuses_an_archive_missing_the_answer_style_hash def test_re_render_from_raw_reproduces_every_artifact(tmp_path: Path) -> None: """A sweep's artifacts are reproduced from its raw archives alone.""" raw_dir = tmp_path / "raw" - arm = _sample_arm() + arm = _archivable_arm() archive_raw_run(arm, raw_dir) original = write_matrix_artifacts(build_matrix_result([arm]), tmp_path / "original") assert matrix.main(["--raw-dir", str(raw_dir), "--output-dir", str(tmp_path / "again")]) == 0 @@ -1527,7 +1581,7 @@ def test_re_render_from_raw_reproduces_every_artifact(tmp_path: Path) -> None: def test_load_raw_archives_selects_one_sweep_by_git_revision(tmp_path: Path) -> None: raw_dir = tmp_path / "raw" - published = _sample_arm() + published = _archivable_arm() superseded = ArmResult( provenance=RunProvenance( mode="stub", @@ -1539,10 +1593,13 @@ def test_load_raw_archives_selects_one_sweep_by_git_revision(tmp_path: Path) -> runtime_identifier="local-stub-runtime", price_table_version="v0-provisional", answer_style_sha256="0" * 64, + prompt_caching="explicit cache points", ), model_metrics_fields=_sample_model_metrics_fields(), aggregate_score_fields=_sample_aggregate_score_fields(), task_score_fields=published.task_score_fields, + tier_summary_fields=_sample_tier_summary_fields(), + tier_task_metrics_fields=_sample_tier_task_metrics_fields(), ) archive_raw_run(published, raw_dir) archive_raw_run(superseded, raw_dir) @@ -1554,7 +1611,7 @@ def test_load_raw_archives_selects_one_sweep_by_git_revision(tmp_path: Path) -> def test_load_raw_archives_refuses_an_empty_selection(tmp_path: Path) -> None: raw_dir = tmp_path / "raw" - archive_raw_run(_sample_arm(), raw_dir) + archive_raw_run(_archivable_arm(), raw_dir) with pytest.raises(ValueError, match="no raw archive"): matrix.load_raw_archives(raw_dir, git_revision="0000000") assert matrix.main(["--raw-dir", str(raw_dir), "--git-revision", "0000000"]) == 2 @@ -1902,18 +1959,9 @@ def _publish(matrix_result: MatrixResult) -> tuple[Path, ...]: # --------------------------------------------------------------------------------------------- -# Temperature-era archives stay readable +# Temperature is not a provenance field # --------------------------------------------------------------------------------------------- -_LEGACY_ARTIFACT = ( - Path(__file__).resolve().parents[1] / "fixtures" / "eval" / "legacy_matrix_artifact.json" -) - - -def _legacy_arm_fields() -> list[dict[str, object]]: - payload = json.loads(_LEGACY_ARTIFACT.read_text(encoding="utf-8")) - return cast(list[dict[str, object]], payload["arms"]) - def test_a_new_provenance_carries_no_temperature_key_or_markdown_row() -> None: matrix_result = build_matrix_result([_sample_arm()]) @@ -1923,65 +1971,6 @@ def test_a_new_provenance_carries_no_temperature_key_or_markdown_row() -> None: assert "| temperature |" not in render_markdown(matrix_result) -def test_a_legacy_archive_re_renders_its_temperature_as_recorded() -> None: - """A temperature-era arm, retired tier models included, keeps its provenance key for key.""" - for fields in _legacy_arm_fields(): - recorded = cast(dict[str, object], fields["provenance"]) - assert "temperature" in recorded - arm = matrix.arm_from_report_fields(fields) - assert arm.provenance.records_legacy_temperature - assert "prompt_bundle_sha256" not in recorded - assert arm.provenance.prompt_bundle_sha256 is None - assert arm.provenance.to_report_fields() == {**recorded, "prompt_bundle_sha256": None} - assert list(arm.provenance.to_report_fields()) == [*recorded, "prompt_bundle_sha256"] - assert arm.tier_role_model_fields == tuple( - cast(list[dict[str, object]], fields["tier_role_model_metrics"]) - ) - - -def test_a_legacy_numeric_temperature_renders_in_json_and_markdown() -> None: - fields = _legacy_arm_fields()[0] - pinned = {**fields, "provenance": {**cast(dict[str, object], fields["provenance"])}} - cast(dict[str, object], pinned["provenance"])["temperature"] = 0.2 - arm = matrix.arm_from_report_fields(pinned) - matrix_result = build_matrix_result([arm]) - - assert json.loads(render_json(matrix_result))["arms"][0]["provenance"]["temperature"] == 0.2 - assert "| temperature | 0.200000 |" in render_markdown(matrix_result) - - -def test_a_legacy_artifact_publishes_and_passes_assert_artifacts(tmp_path: Path) -> None: - from eval.harness import FR93_INVENTORY_RELATIVE_PATH, assert_artifacts - - arms = [matrix.arm_from_report_fields(fields) for fields in _legacy_arm_fields()] - write_matrix_artifacts(build_matrix_result(arms), tmp_path) - raw_paths = tuple(archive_raw_run(arm, tmp_path / "raw") for arm in arms) - inventory = tmp_path / FR93_INVENTORY_RELATIVE_PATH - inventory.parent.mkdir(parents=True) - inventory.write_text( - json.dumps( - { - "resource_class": "eval_sweep", - "layer": 6, - "checks": [ - {"check": "demo_tenant_untouched", "status": "pass", "detail": "0 rows"}, - {"check": "writes_only_under_smoke_tenant", "status": "pass", "detail": "1"}, - ], - } - ), - encoding="utf-8", - ) - aggregate = cast(dict[str, int], _legacy_arm_fields()[0]["aggregate_score"]) - - assert_artifacts( - output_dir=tmp_path, - expected_arm_count=len(arms), - expected_task_count=aggregate["scored_task_count"] + aggregate["unscored_task_count"], - raw_archive_paths=raw_paths, - ) - assert render_markdown(build_matrix_result(arms)).count("| temperature | — |") == len(arms) - - # --------------------------------------------------------------------------------------------- # Usage completeness # --------------------------------------------------------------------------------------------- @@ -1994,6 +1983,8 @@ def _lower_bound_arm(*task_ids: str) -> ArmResult: model_metrics_fields=arm.model_metrics_fields, aggregate_score_fields=arm.aggregate_score_fields, task_score_fields=arm.task_score_fields, + tier_summary_fields=_sample_tier_summary_fields(), + tier_task_metrics_fields=_sample_tier_task_metrics_fields(), usage_lower_bound_task_ids=task_ids, ) @@ -2027,9 +2018,9 @@ def test_the_lower_bound_ids_round_trip_through_a_raw_archive() -> None: assert rebuilt.usage_lower_bound_task_ids == ("gt-01-investigation-x", "gt-04-enrichment-y") -def test_a_legacy_archive_without_the_key_reads_as_complete_usage() -> None: - """An archive written before the key existed re-renders with no lower-bound note.""" - fields = _sample_arm(withheld=False).to_report_fields() +def test_an_archive_without_the_key_reads_as_complete_usage() -> None: + """An archive of an arm with complete usage carries no key and re-renders with no note.""" + fields = _archivable_arm(withheld=False).to_report_fields() assert matrix.USAGE_LOWER_BOUND_TASK_IDS_KEY not in fields assert matrix.arm_from_report_fields(fields).usage_lower_bound_task_ids == () @@ -2055,7 +2046,7 @@ def test_the_csv_flags_each_task_row_whose_usage_is_a_lower_bound() -> None: def test_the_csv_lower_bound_column_reads_no_for_a_complete_or_legacy_arm() -> None: """An arm with complete usage, or an archive without the key, renders the column as no.""" - legacy = matrix.arm_from_report_fields(_sample_arm(withheld=False).to_report_fields()) + legacy = matrix.arm_from_report_fields(_archivable_arm(withheld=False).to_report_fields()) rows = _csv_rows(build_matrix_result([_sample_arm(withheld=False), legacy])) assert rows assert {row["usage_lower_bound"] for row in rows} == {"no"} @@ -2101,7 +2092,7 @@ def test_the_artifact_verdict_scan_finds_nothing_in_the_errored_items_note() -> def _arm_with_totals(*, withheld: bool, cost: float | None = 0.25, count: int = 3) -> ArmResult: return dataclasses.replace( - _sample_arm(withheld=withheld), + _archivable_arm(withheld=withheld), arm_totals_fields={ ARM_COST_TOTAL_KEY: None if withheld else cost, ARM_LONG_CONTEXT_INVOCATION_COUNT_KEY: count, @@ -2166,7 +2157,7 @@ def test_the_arm_totals_round_trip_through_a_raw_archive() -> None: arm = _arm_with_totals(withheld=False) rebuilt = arm_from_report_fields(json.loads(json.dumps(arm.to_report_fields()))) assert rebuilt.arm_totals_fields == arm.arm_totals_fields - legacy = arm_from_report_fields(json.loads(json.dumps(_sample_arm().to_report_fields()))) + legacy = arm_from_report_fields(json.loads(json.dumps(_archivable_arm().to_report_fields()))) assert legacy.arm_totals_fields == {} diff --git a/tests/unit/test_matrix_record_shape.py b/tests/unit/test_matrix_record_shape.py new file mode 100644 index 0000000..4e71af8 --- /dev/null +++ b/tests/unit/test_matrix_record_shape.py @@ -0,0 +1,389 @@ +# SPDX-License-Identifier: MIT +"""Record shape 3: every writer leads with the version and every reader refuses any other record. + +The refusals are checked against a record that is otherwise readable, so each case fails for the +one reason it names; a positive control shows the same record loads once the defect is undone. +""" + +from __future__ import annotations + +import dataclasses +import json +import sys +from pathlib import Path +from typing import Any, cast + +import pytest +from scripts import proc_run + +from eval import matrix +from eval.matrix import ( + RECORD_SHAPE_VERSION, + RECORD_SHAPE_VERSION_KEY, + TIER_SUMMARY_TOKEN_KEYS, + TIER_TASK_COUNT_KEYS, + ArmResult, + RecordShapeRefused, + archive_raw_run, + arm_from_report_fields, + build_matrix_result, + render_json, + require_record_shape, + tier_comparison, + tier_comparison_table, +) +from tests.unit.test_matrix_tier_comparison import _anthropic_arm + +_LEGACY_ARTIFACT = ( + Path(__file__).resolve().parents[1] / "fixtures" / "eval" / "legacy_matrix_artifact.json" +) + +_TIERS: tuple[str, ...] = ("supervisor", "subagent", "tool") + +_REPO_ROOT = Path(__file__).resolve().parents[2] + + +def _arm() -> ArmResult: + return _anthropic_arm() + + +def _fields() -> dict[str, Any]: + return cast(dict[str, Any], json.loads(json.dumps(_arm().to_report_fields()))) + + +def _legacy_payload() -> dict[str, Any]: + return cast(dict[str, Any], json.loads(_LEGACY_ARTIFACT.read_text(encoding="utf-8"))) + + +# ------------------------------------------------------------------------------------ constants + + +def test_the_version_is_the_integer_three_under_its_named_key() -> None: + assert RECORD_SHAPE_VERSION == 3 + assert type(RECORD_SHAPE_VERSION) is int + assert RECORD_SHAPE_VERSION_KEY == "record_shape_version" + assert issubclass(RecordShapeRefused, ValueError) + + +# -------------------------------------------------------------------------------------- writers + + +def test_the_arm_report_leads_with_the_version() -> None: + fields = _arm().to_report_fields() + assert next(iter(fields)) == RECORD_SHAPE_VERSION_KEY + assert fields[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION + + +def test_matrix_json_and_its_tier_comparison_block_lead_with_the_version() -> None: + payload = json.loads(render_json(build_matrix_result([_arm()]))) + assert next(iter(payload)) == RECORD_SHAPE_VERSION_KEY + assert payload[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION + block = payload["tier_comparison"] + assert next(iter(block)) == RECORD_SHAPE_VERSION_KEY + assert block[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION + assert next(iter(payload["arms"][0])) == RECORD_SHAPE_VERSION_KEY + + +def test_the_raw_archive_file_carries_the_version_first(tmp_path: Path) -> None: + path = archive_raw_run(_arm(), tmp_path) + assert next(iter(json.loads(path.read_text(encoding="utf-8")))) == RECORD_SHAPE_VERSION_KEY + + +# ------------------------------------------------------------------------- require_record_shape + + +def test_require_record_shape_accepts_version_three() -> None: + require_record_shape({RECORD_SHAPE_VERSION_KEY: 3}, subject="x") + + +@pytest.mark.parametrize( + ("record", "found"), + [ + ({}, "absent"), + ({RECORD_SHAPE_VERSION_KEY: 1}, "1"), + ({RECORD_SHAPE_VERSION_KEY: 2}, "2"), + ({RECORD_SHAPE_VERSION_KEY: None}, "None"), + ({RECORD_SHAPE_VERSION_KEY: "3"}, "'3'"), + ({RECORD_SHAPE_VERSION_KEY: 3.0}, "3.0"), + ({RECORD_SHAPE_VERSION_KEY: True}, "True"), + ], + ids=["absent", "one", "two", "null", "string", "float", "bool"], +) +def test_require_record_shape_names_the_found_and_required_version( + record: dict[str, object], found: str +) -> None: + with pytest.raises(RecordShapeRefused) as excinfo: + require_record_shape(record, subject="the subject") + assert str(excinfo.value) == ( + f"the subject: record shape {found}, required 3 — recorded in an earlier format; " + "not rendered" + ) + + +# ------------------------------------------------------------------------ arm_from_report_fields + + +def test_a_shape_three_arm_loads_as_the_positive_control() -> None: + assert arm_from_report_fields(_fields()) == _arm() + + +@pytest.mark.parametrize("version", [None, 1, 2], ids=["absent", "one", "two"]) +def test_an_arm_of_another_record_shape_is_refused(version: int | None) -> None: + fields = _fields() + if version is None: + del fields[RECORD_SHAPE_VERSION_KEY] + else: + fields[RECORD_SHAPE_VERSION_KEY] = version + found = "absent" if version is None else str(version) + with pytest.raises(RecordShapeRefused, match=f"raw archive: record shape {found}, required 3"): + arm_from_report_fields(fields) + + +def _missing_field_paths() -> list[tuple[str, ...]]: + """Every required field of an arm report, as the key path that reaches it.""" + paths: list[tuple[str, ...]] = [("provenance", name) for name in matrix._PROVENANCE_FIELDS] + metrics = matrix.TIER_TASK_METRICS_KEY + paths.extend([("tier_summary",), (metrics,), (metrics, "by_tier")]) + for tier in _TIERS: + paths.append(("tier_summary", tier)) + paths.extend(("tier_summary", tier, key) for key in TIER_SUMMARY_TOKEN_KEYS) + paths.append((metrics, "by_tier", tier)) + paths.extend((metrics, "by_tier", tier, key) for key in TIER_TASK_COUNT_KEYS) + return paths + + +@pytest.mark.parametrize("path", _missing_field_paths(), ids=".".join) +def test_an_arm_missing_a_required_field_is_refused_naming_it(path: tuple[str, ...]) -> None: + fields = _fields() + parent: dict[str, Any] = fields + for key in path[:-1]: + parent = parent[key] + del parent[path[-1]] + with pytest.raises(RecordShapeRefused) as excinfo: + arm_from_report_fields(fields) + assert str(excinfo.value) == f"raw archive: missing required field {'.'.join(path)}" + + +@pytest.mark.parametrize("value", [None, "7", 7.0, True], ids=["null", "string", "float", "bool"]) +@pytest.mark.parametrize("key", TIER_SUMMARY_TOKEN_KEYS) +def test_a_non_integer_token_total_is_refused(key: str, value: object) -> None: + fields = _fields() + fields["tier_summary"]["subagent"][key] = value + with pytest.raises(RecordShapeRefused, match=rf"tier_summary\.subagent\.{key}$"): + arm_from_report_fields(fields) + + +def test_the_prompt_caching_text_round_trips_after_the_bundle_digest() -> None: + fields = _fields() + names = list(fields["provenance"]) + assert names.index("prompt_caching") == names.index("prompt_bundle_sha256") + 1 + assert arm_from_report_fields(fields).provenance.prompt_caching == "explicit cache points" + + +@pytest.mark.parametrize("value", [None, 1, ["x"]], ids=["null", "int", "list"]) +def test_a_non_string_prompt_caching_is_refused(value: object) -> None: + fields = _fields() + fields["provenance"]["prompt_caching"] = value + with pytest.raises(RecordShapeRefused, match=r"provenance\.prompt_caching$"): + arm_from_report_fields(fields) + + +@pytest.mark.parametrize( + ("tier", "key", "value"), + [ + ("supervisor", "budget_exhausted_task_count", None), + ("supervisor", "truncated_tool_call_count", None), + ("tool", "truncated_task_count", "3"), + ("tool", "budget_exhausted_task_count", True), + ("subagent", "budget_exhausted_task_count", None), + ("subagent", "truncated_tool_call_count", 0), + ("subagent", "truncated_task_count", 0), + ], +) +def test_a_tier_task_count_of_the_wrong_type_is_refused(tier: str, key: str, value: object) -> None: + """Counts are integers, except the subagent truncation pair, which must be null.""" + fields = _fields() + fields[matrix.TIER_TASK_METRICS_KEY]["by_tier"][tier][key] = value + with pytest.raises(RecordShapeRefused) as excinfo: + arm_from_report_fields(fields) + assert str(excinfo.value) == ( + f"raw archive: missing required field {matrix.TIER_TASK_METRICS_KEY}.by_tier.{tier}.{key}" + ) + + +def test_the_subagent_truncation_pair_is_null_in_the_positive_control() -> None: + by_tier = _fields()[matrix.TIER_TASK_METRICS_KEY]["by_tier"] + assert [by_tier["subagent"][key] for key in TIER_TASK_COUNT_KEYS] == [1, None, None] + assert all( + type(by_tier[tier][key]) is int + for tier in ("supervisor", "tool") + for key in TIER_TASK_COUNT_KEYS + ) + + +def test_a_legacy_temperature_key_is_not_carried_into_a_reloaded_arm() -> None: + fields = _fields() + fields["provenance"]["temperature"] = 0.2 + reloaded = arm_from_report_fields(fields).to_report_fields() + assert "temperature" not in cast(dict[str, object], reloaded["provenance"]) + + +# ------------------------------------------------------------------------ tier_comparison_table + + +def _summary() -> dict[str, Any]: + return cast( + dict[str, Any], json.loads(json.dumps(tier_comparison(build_matrix_result([_arm()])))) + ) + + +def test_a_shape_three_summary_formats_as_the_positive_control() -> None: + summary = _summary() + assert tier_comparison_table(summary)["headers"] == [ + "Metric", + *(column["label"] for column in summary["columns"]), + ] + + +@pytest.mark.parametrize("version", [None, 1, 2], ids=["absent", "one", "two"]) +def test_a_summary_of_another_record_shape_is_refused(version: int | None) -> None: + summary = _summary() + if version is None: + del summary[RECORD_SHAPE_VERSION_KEY] + else: + summary[RECORD_SHAPE_VERSION_KEY] = version + with pytest.raises(RecordShapeRefused, match="tier comparison summary: record shape"): + tier_comparison_table(summary) + + +@pytest.mark.parametrize( + "key", ["cost_per_applicable_task", *TIER_SUMMARY_TOKEN_KEYS, *TIER_TASK_COUNT_KEYS] +) +@pytest.mark.parametrize("tier", _TIERS) +def test_a_summary_entry_missing_a_required_key_is_refused(tier: str, key: str) -> None: + summary = _summary() + del summary["tiers"][tier][0][key] + with pytest.raises(RecordShapeRefused) as excinfo: + tier_comparison_table(summary) + assert str(excinfo.value) == ( + f"tier comparison summary: missing required field tiers.{tier}[0].{key}" + ) + + +# ----------------------------------------------------------------------- the tracked legacy file + + +def test_every_arm_of_the_legacy_artifact_is_refused() -> None: + arms = _legacy_payload()["arms"] + assert arms + for fields in arms: + assert RECORD_SHAPE_VERSION_KEY not in fields + with pytest.raises(RecordShapeRefused, match="record shape absent, required 3"): + arm_from_report_fields(fields) + + +def test_the_legacy_artifact_matrix_is_refused_at_its_top_level() -> None: + with pytest.raises(RecordShapeRefused, match="record shape absent"): + require_record_shape(_legacy_payload(), subject="matrix.json") + + +def test_the_legacy_artifact_refusal_is_the_version_not_a_field() -> None: + """Control: stamping the version on a legacy arm moves the refusal to a missing field.""" + fields = {RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, **_legacy_payload()["arms"][0]} + with pytest.raises(RecordShapeRefused, match="missing required field"): + arm_from_report_fields(fields) + + +# ------------------------------------------------------------------------------ python -m eval.matrix + + +def _archive_legacy_arms(raw_dir: Path) -> None: + raw_dir.mkdir(parents=True) + for index, fields in enumerate(_legacy_payload()["arms"]): + (raw_dir / f"legacy-{index}.json").write_text(json.dumps(fields), encoding="utf-8") + + +def test_the_re_render_cli_exits_2_and_writes_nothing_for_a_legacy_archive( + tmp_path: Path, capsys: pytest.CaptureFixture[str] +) -> None: + raw_dir, output_dir = tmp_path / "raw", tmp_path / "out" + _archive_legacy_arms(raw_dir) + assert matrix.main(["--raw-dir", str(raw_dir), "--output-dir", str(output_dir)]) == 2 + assert "record shape absent, required 3" in capsys.readouterr().err + assert not output_dir.exists() + + +def test_one_legacy_archive_beside_a_shape_three_one_still_writes_nothing(tmp_path: Path) -> None: + raw_dir, output_dir = tmp_path / "raw", tmp_path / "out" + _archive_legacy_arms(raw_dir) + archive_raw_run(_arm(), raw_dir) + assert matrix.main(["--raw-dir", str(raw_dir), "--output-dir", str(output_dir)]) == 2 + assert not output_dir.exists() + + +def test_the_re_render_cli_exits_2_and_writes_nothing_for_mismatched_prompt_bundles( + tmp_path: Path, capsys: pytest.CaptureFixture[str] +) -> None: + raw_dir, output_dir = tmp_path / "raw", tmp_path / "out" + first = _arm() + second = dataclasses.replace( + first, + provenance=dataclasses.replace( + first.provenance, model_id="openai.gpt-6-1-sol", prompt_bundle_sha256="2" * 64 + ), + ) + archive_raw_run(first, raw_dir) + archive_raw_run(second, raw_dir) + assert matrix.main(["--raw-dir", str(raw_dir), "--output-dir", str(output_dir)]) == 2 + assert "different prompt bundles" in capsys.readouterr().err + assert not output_dir.exists() + + +def test_the_module_entry_point_exits_2_with_the_refusal(tmp_path: Path) -> None: + raw_dir, output_dir = tmp_path / "raw", tmp_path / "out" + _archive_legacy_arms(raw_dir) + result = proc_run.run( + [ + sys.executable, + "-m", + "eval.matrix", + "--raw-dir", + str(raw_dir), + "--output-dir", + str(output_dir), + ], + capture_output=True, + text=True, + check=False, + cwd=_REPO_ROOT, + ) + assert result.returncode == 2, result.stderr + assert "record shape absent, required 3" in result.stderr + assert not output_dir.exists() + + +def test_the_module_entry_point_renders_a_shape_three_archive(tmp_path: Path) -> None: + """Control: the same invocation succeeds once the archive is record shape 3.""" + raw_dir, output_dir = tmp_path / "raw", tmp_path / "out" + archive_raw_run(_arm(), raw_dir) + result = proc_run.run( + [ + sys.executable, + "-m", + "eval.matrix", + "--raw-dir", + str(raw_dir), + "--output-dir", + str(output_dir), + ], + capture_output=True, + text=True, + check=False, + cwd=_REPO_ROOT, + ) + assert result.returncode == 0, result.stderr + assert sorted(path.name for path in output_dir.iterdir()) == [ + "matrix.csv", + "matrix.json", + "matrix.md", + ] diff --git a/tests/unit/test_matrix_repeat_completion.py b/tests/unit/test_matrix_repeat_completion.py index 52213cf..17755dd 100644 --- a/tests/unit/test_matrix_repeat_completion.py +++ b/tests/unit/test_matrix_repeat_completion.py @@ -10,7 +10,6 @@ import dataclasses import io import json -from pathlib import Path from typing import cast from eval import harness, matrix @@ -26,11 +25,7 @@ ) from eval.metrics import aggregate_tier_summary, not_measured_latency_metrics from eval.scoring import SCORED_TIERS, TierScore, TierScores -from tests.unit.test_matrix import _sample_arm - -_LEGACY_ARTIFACT = ( - Path(__file__).resolve().parents[1] / "fixtures" / "eval" / "legacy_matrix_artifact.json" -) +from tests.unit.test_matrix import _archivable_arm _DEFINITION = ( "a task counts when its tier expectation was met in a strict majority of its applicable repeats" @@ -61,7 +56,7 @@ def _arm() -> ArmResult: summary = aggregate_tier_summary( (), not_measured_latency_metrics(), _three_repeat_turns(), withhold_cost=True ) - return dataclasses.replace(_sample_arm(), tier_summary_fields=summary.to_report_fields()) + return dataclasses.replace(_archivable_arm(), tier_summary_fields=summary.to_report_fields()) def _matrix() -> MatrixResult: @@ -213,16 +208,6 @@ def test_an_archive_lacking_the_key_loads_and_renders_n_a() -> None: ) -def test_the_pre_spec_legacy_archive_still_loads_and_renders() -> None: - payload = json.loads(_LEGACY_ARTIFACT.read_text(encoding="utf-8")) - arms = [arm_from_report_fields(fields) for fields in payload["arms"]] - matrix_result = build_matrix_result(arms) - markdown = render_markdown(matrix_result) - assert _md_rows(markdown, "Supervisor")["Task completion over repeats"] == ["n/a"] * len(arms) - render_csv(matrix_result) - render_json(matrix_result) - - def test_an_archive_carrying_the_key_round_trips_it() -> None: arm = _arm() restored = arm_from_report_fields(json.loads(json.dumps(arm.to_report_fields()))) diff --git a/tests/unit/test_matrix_tier_comparison.py b/tests/unit/test_matrix_tier_comparison.py index 0a2a47d..7d4a0b1 100644 --- a/tests/unit/test_matrix_tier_comparison.py +++ b/tests/unit/test_matrix_tier_comparison.py @@ -22,6 +22,8 @@ from eval import harness, matrix from eval.matrix import ( + RECORD_SHAPE_VERSION, + RECORD_SHAPE_VERSION_KEY, TIER_TASK_METRICS_KEY, ArmResult, MatrixResult, @@ -41,10 +43,6 @@ ASTRA = "openai.gpt-6-astra" SOL = "openai.gpt-6-1-sol" -_LEGACY_ARTIFACT = ( - Path(__file__).resolve().parents[1] / "fixtures" / "eval" / "legacy_matrix_artifact.json" -) - _ENTRY_KEYS = [ "model_ids", "efforts", @@ -53,15 +51,22 @@ "accuracy", "cost_withheld_provisional", "cost_per_completed_task", - "cost_per_task", + "cost_per_applicable_task", "completed_task_latency_ms_p50", "completed_task_latency_ms_p95", "latency_sample_count", "invocation_count", "long_context_invocation_count", "input_tokens", + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", + "uncached_input_tokens", "output_tokens", "retry_count", + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", ] _ROW_LABELS = [ @@ -71,14 +76,20 @@ "Task completion over repeats", "Task accuracy", "Cost per completed task", - "P95 latency per completed task (ms)", "P50 latency per completed task (ms)", + "P95 latency per completed task (ms)", "Model invocations", "Long-context invocations", - "Input tokens", - "Output tokens", - "Cost per task, all tasks", + "Total input tokens", + "Cache read tokens", + "Cache write tokens", + "Uncached input tokens", + "Total output tokens", + "Cost per applicable task", "Self-corrected retries", + "Budget-exhausted tasks", + "Truncated tool calls", + "Truncated tasks", ] @@ -95,6 +106,7 @@ def _provenance( runtime_identifier="local-stub-runtime", price_table_version="v1", answer_style_sha256="0" * 64, + prompt_caching="explicit cache points", ) @@ -134,8 +146,12 @@ def _metrics(*, withheld: bool) -> dict[str, object]: def _summary_entry( met: int, applicable: int, cost_total: float | None, tokens: tuple[int, int] ) -> dict[str, object]: + """A ``tier_summary`` entry; prompt and cache totals derive from ``tokens[0]``.""" return { "input_tokens": tokens[0], + "total_prompt_tokens": tokens[0] + 3 * (tokens[0] // 10), + "cache_read_tokens": 2 * (tokens[0] // 10), + "cache_write_tokens": tokens[0] // 10, "output_tokens": tokens[1], "cost_total": cost_total, "latency_p50_ms": None, @@ -167,8 +183,18 @@ def _block( efforts: dict[str, list[str | None]], outcomes: tuple[int, int, int, int, int], retries: tuple[int, int, int] | None = None, + counts: dict[str, tuple[int, int | None, int | None]] | None = None, ) -> dict[str, object]: - """An arm's ``tier_task_metrics`` block; ``retries=None`` omits ``retry_count``.""" + """An arm's ``tier_task_metrics`` block; ``retries=None`` omits ``retry_count``. + + ``counts`` maps each tier to its budget-exhausted, truncated-call and truncated-task counts; + absent, every count is zero (``None`` for the subagent truncation pair). + """ + tier_counts = counts or { + "supervisor": (0, 0, 0), + "subagent": (0, None, None), + "tool": (0, 0, 0), + } tiers = ("supervisor", "subagent", "tool") by_tier: dict[str, dict[str, object]] = { tier: { @@ -183,6 +209,18 @@ def _block( if retries is not None: for tier, count in zip(tiers, retries, strict=True): by_tier[tier]["retry_count"] = count + for tier in tiers: + by_tier[tier].update( + zip( + ( + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", + ), + tier_counts[tier], + strict=True, + ) + ) return { "family": family, "by_tier": by_tier, @@ -227,6 +265,11 @@ def _anthropic_arm() -> ArmResult: efforts={"supervisor": ["medium"], "subagent": ["high"], "tool": [None]}, outcomes=(2, 1, 1, 0, 1), retries=(2, 1, 0), + counts={ + "supervisor": (2, 1, 1), + "subagent": (1, None, None), + "tool": (0, 4, 3), + }, ), ) @@ -299,23 +342,32 @@ def _csv_rows(matrix_result: MatrixResult) -> list[dict[str, str]]: def test_matrix_json_leads_with_the_tier_comparison_block() -> None: payload = json.loads(render_json(_three_arm_matrix())) - assert list(payload) == ["tier_comparison", "arms", "figure_semantics"] + assert list(payload) == [ + RECORD_SHAPE_VERSION_KEY, + "tier_comparison", + "arms", + "figure_semantics", + ] + assert payload[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION == 3 summary = payload["tier_comparison"] - assert list(summary) == ["columns", "tiers", "notes"] + assert list(summary) == [RECORD_SHAPE_VERSION_KEY, "columns", "tiers", "notes"] + assert summary[RECORD_SHAPE_VERSION_KEY] == 3 + assert all(list(arm)[0] == RECORD_SHAPE_VERSION_KEY for arm in payload["arms"]) + assert all(arm[RECORD_SHAPE_VERSION_KEY] == 3 for arm in payload["arms"]) assert list(summary["tiers"]) == ["supervisor", "subagent", "tool"] assert all(len(entries) == 3 for entries in summary["tiers"].values()) -def test_every_entry_carries_the_design_keys_in_order_with_one_tier_specific_key_last() -> None: +def test_every_entry_carries_the_design_keys_in_order_and_subagent_adds_delegation() -> None: summary = tier_comparison(_three_arm_matrix()) - specific = { - "supervisor": "budget_exhausted_task_count", - "subagent": "delegation_outcomes", - "tool": "truncated_task_count", + expected = { + "supervisor": _ENTRY_KEYS, + "subagent": [*_ENTRY_KEYS, "delegation_outcomes"], + "tool": _ENTRY_KEYS, } - for tier, last_key in specific.items(): + for tier, keys in expected.items(): for column in range(3): - assert list(_entry(summary, tier, column)) == [*_ENTRY_KEYS, last_key] + assert list(_entry(summary, tier, column)) == keys def test_columns_describe_each_arm_in_arm_order() -> None: @@ -342,20 +394,27 @@ def test_every_figure_equals_its_definition_for_a_published_cost_arm() -> None: assert supervisor["accuracy"] == 0.7 assert supervisor["cost_withheld_provisional"] is False assert supervisor["cost_per_completed_task"] == pytest.approx(0.6 / 3) - assert supervisor["cost_per_task"] == pytest.approx(0.6 / 5) + assert supervisor["cost_per_applicable_task"] == pytest.approx(0.6 / 5) assert supervisor["completed_task_latency_ms_p50"] == 1200.0 assert supervisor["completed_task_latency_ms_p95"] == 2500.0 assert supervisor["latency_sample_count"] == 3 assert supervisor["invocation_count"] == 5 assert (supervisor["input_tokens"], supervisor["output_tokens"]) == (1000, 200) + assert ( + supervisor["total_prompt_tokens"], + supervisor["cache_read_tokens"], + supervisor["cache_write_tokens"], + ) == (1300, 200, 100) assert supervisor["budget_exhausted_task_count"] == 2 + assert supervisor["truncated_tool_call_count"] == 1 + assert supervisor["truncated_task_count"] == 1 subagent = _entry(summary, "subagent", 0) assert subagent["model_ids"] == sorted([HAIKU, SONNET]) assert subagent["completion"] == {"passed": 2, "applicable": 4, "rate": 0.5} assert subagent["accuracy"] == 0.5 assert subagent["cost_per_completed_task"] == pytest.approx(0.2 / 2) - assert subagent["cost_per_task"] == pytest.approx(0.2 / 5) + assert subagent["cost_per_applicable_task"] == pytest.approx(0.2 / 4) assert subagent["invocation_count"] == 4 assert subagent["delegation_outcomes"] == { "data": 2, @@ -369,10 +428,21 @@ def test_every_figure_equals_its_definition_for_a_published_cost_arm() -> None: assert tool["efforts"] == [None] assert tool["completion"] == {"passed": 0, "applicable": 3, "rate": 0.0} assert tool["cost_per_completed_task"] is None - assert tool["cost_per_task"] == pytest.approx(0.09 / 5) + assert tool["cost_per_applicable_task"] == pytest.approx(0.09 / 3) assert tool["latency_sample_count"] == 0 assert tool["completed_task_latency_ms_p95"] is None assert tool["truncated_task_count"] == 3 + assert tool["truncated_tool_call_count"] == 4 + assert tool["budget_exhausted_task_count"] == 0 + subagent_counts = [ + _entry(summary, "subagent", 0)[key] + for key in ( + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", + ) + ] + assert subagent_counts == [1, None, None] def test_a_withheld_arm_carries_no_cost_figure() -> None: @@ -381,7 +451,7 @@ def test_a_withheld_arm_carries_no_cost_figure() -> None: entry = _entry(summary, tier, 1) assert entry["cost_withheld_provisional"] is True assert entry["cost_per_completed_task"] is None - assert entry["cost_per_task"] is None + assert entry["cost_per_applicable_task"] is None def test_the_model_row_is_the_configured_model_with_every_model_that_spent_tokens() -> None: @@ -448,13 +518,12 @@ def test_matrix_md_orders_title_summary_intro_reading_then_arms() -> None: assert positions == sorted(positions) -def test_every_section_carries_the_r1_rows_in_order() -> None: +def test_every_section_carries_its_full_label_list_in_order() -> None: markdown = render_markdown(_three_arm_matrix()) - delegation = [f"Delegation outcome: {kind}" for kind in matrix._DELEGATION_OUTCOME_KEYS] expected = { - "Supervisor": [*_ROW_LABELS, "Budget-exhausted tasks"], - "Subagent": [*_ROW_LABELS, *delegation], - "ToolCall": [*_ROW_LABELS, "Truncated tasks"], + "Supervisor": list(_ROW_LABELS), + "Subagent": list(_ROW_LABELS), + "ToolCall": list(_ROW_LABELS), } for heading, labels in expected.items(): rows = _md_table_rows(markdown, heading) @@ -479,7 +548,7 @@ def test_markdown_cells_render_each_definition() -> None: ] assert supervisor["Task accuracy"] == ["0.700000", "0.500000", "0.500000"] assert supervisor["Cost per completed task"] == ["0.200000", "withheld", "withheld"] - assert supervisor["Cost per task, all tasks"] == ["0.120000", "withheld", "withheld"] + assert supervisor["Cost per applicable task"] == ["0.120000", "withheld", "withheld"] assert supervisor["P95 latency per completed task (ms)"] == [ "2500.000000 (n=3)", "900.000000 (n=1)", @@ -487,8 +556,14 @@ def test_markdown_cells_render_each_definition() -> None: ] assert supervisor["P50 latency per completed task (ms)"][0] == "1200.000000 (n=3)" assert supervisor["Model invocations"] == ["5", "2", "2"] - assert supervisor["Input tokens"] == ["1000", "300", "300"] + assert supervisor["Total input tokens"] == ["1300", "390", "390"] + assert supervisor["Cache read tokens"] == ["200", "60", "60"] + assert supervisor["Cache write tokens"] == ["100", "30", "30"] + assert supervisor["Uncached input tokens"] == ["1000", "300", "300"] + assert supervisor["Total output tokens"] == ["200", "60", "60"] assert supervisor["Budget-exhausted tasks"] == ["2", "0", "0"] + assert supervisor["Truncated tool calls"] == ["1", "0", "0"] + assert supervisor["Truncated tasks"] == ["1", "0", "0"] subagent = _md_table_rows(markdown, "Subagent") assert subagent["Model"][0] == f"{HAIKU}, {SONNET}" @@ -499,14 +574,20 @@ def test_markdown_cells_render_each_definition() -> None: "not applicable", ] assert subagent["Task accuracy"] == ["0.500000", "not applicable", "not applicable"] - assert subagent["Delegation outcome: none"] == ["1", "2", "2"] + assert subagent["Cost per applicable task"] == ["0.050000", "withheld", "withheld"] tool = _md_table_rows(markdown, "ToolCall") assert tool["Effort"][0] == "unsupported" assert tool["Task completion rate"][0] == "0.000000 (0/3)" assert tool["Cost per completed task"][0] == "—" + assert tool["Cost per applicable task"][0] == "0.030000" assert tool["P95 latency per completed task (ms)"][0] == "— (n=0)" assert tool["Truncated tasks"] == ["3", "0", "0"] + assert tool["Truncated tool calls"] == ["4", "0", "0"] + assert tool["Budget-exhausted tasks"] == ["0", "0", "0"] + assert subagent["Budget-exhausted tasks"] == ["1", "0", "0"] + assert subagent["Truncated tool calls"] == ["not applicable"] * 3 + assert subagent["Truncated tasks"] == ["not applicable"] * 3 def test_every_note_appears_verbatim_in_matrix_md() -> None: @@ -580,24 +661,35 @@ def _expected_summary_columns() -> list[str]: "completion_over_repeats_rate", "accuracy", "cost_per_completed_task", - "cost_per_task", + "cost_per_applicable_task", "completed_task_latency_ms_p50", "completed_task_latency_ms_p95", "latency_sample_count", "invocation_count", "long_context_invocation_count", "input_tokens", + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", + "uncached_input_tokens", "output_tokens", ] return [ "summary_column", *(f"summary_{tier}_{s}" for tier in ("supervisor", "subagent", "tool") for s in suffixes), - "summary_supervisor_budget_exhausted_task_count", + *( + f"summary_{tier}_{key}" + for tier in ("supervisor", "subagent", "tool") + for key in ( + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", + ) + ), *( f"summary_subagent_delegation_{kind}" for kind in ("data", "no_match", "denied", "tool_failure", "none") ), - "summary_tool_truncated_task_count", *(f"summary_{tier}_retry_count" for tier in ("supervisor", "subagent", "tool")), ] @@ -624,8 +716,16 @@ def test_csv_repeats_each_arms_summary_values_on_its_task_rows() -> None: assert first["summary_supervisor_latency_sample_count"] == "3" assert first["summary_subagent_delegation_data"] == "2" assert first["summary_tool_truncated_task_count"] == "3" + assert first["summary_supervisor_budget_exhausted_task_count"] == "2" + assert first["summary_subagent_budget_exhausted_task_count"] == "1" + assert first["summary_subagent_truncated_tool_call_count"] == "" + assert first["summary_subagent_truncated_task_count"] == "" withheld = rows[5] - assert withheld["summary_supervisor_cost_per_task"] == "" + assert first["summary_supervisor_cost_per_applicable_task"] == "0.120000" + assert first["summary_supervisor_total_prompt_tokens"] == "1300" + assert first["summary_subagent_cache_read_tokens"] == "80" + assert first["summary_tool_cache_write_tokens"] == "12" + assert withheld["summary_supervisor_cost_per_applicable_task"] == "" assert withheld["summary_subagent_efforts"] == "" assert withheld["summary_subagent_completion_rate"] == "" @@ -665,6 +765,7 @@ def test_existing_sections_are_unchanged_once_the_summary_is_projected_out( payload = json.loads(render_json(matrix_result)) payload.pop("tier_comparison") + assert payload.pop(RECORD_SHAPE_VERSION_KEY) == RECORD_SHAPE_VERSION assert payload == { "arms": [arm.to_report_fields() for arm in matrix_result.arms], "figure_semantics": matrix.render_figure_semantics(matrix_result), @@ -681,9 +782,9 @@ def test_existing_sections_are_unchanged_once_the_summary_is_projected_out( assert [row[:-width] for row in rows] == [row[:-width] for row in bare_rows] -def test_an_arm_without_the_block_emits_no_tier_task_metrics_key() -> None: +def test_the_tier_task_metrics_key_is_written_even_when_the_block_is_empty() -> None: bare = dataclasses.replace(_anthropic_arm(), tier_task_metrics_fields={}) - assert TIER_TASK_METRICS_KEY not in bare.to_report_fields() + assert bare.to_report_fields()[TIER_TASK_METRICS_KEY] == {} fields = list(_anthropic_arm().to_report_fields()) assert fields.index(TIER_TASK_METRICS_KEY) == fields.index("tier_summary") + 1 @@ -693,21 +794,6 @@ def test_an_arm_without_the_block_emits_no_tier_task_metrics_key() -> None: # --------------------------------------------------------------------------------------------- -def test_a_pre_spec_archive_re_renders_with_absent_rows_as_dashes() -> None: - payload = json.loads(_LEGACY_ARTIFACT.read_text(encoding="utf-8")) - arms = [arm_from_report_fields(fields) for fields in payload["arms"]] - assert all(arm.tier_task_metrics_fields == {} for arm in arms) - matrix_result = build_matrix_result(arms) - markdown = render_markdown(matrix_result) - supervisor = _md_table_rows(markdown, "Supervisor") - assert supervisor["Effort"] == ["—"] * len(arms) - assert supervisor["P95 latency per completed task (ms)"] == ["—"] * len(arms) - assert supervisor["Task completion rate"] == ["—"] * len(arms) - assert _md_table_rows(markdown, "Subagent")["Delegation outcome: data"] == ["—"] * len(arms) - render_csv(matrix_result) - render_json(matrix_result) - - def test_an_archived_arm_round_trips_its_block(tmp_path: Path) -> None: arm = _anthropic_arm() path = archive_raw_run(arm, tmp_path) @@ -761,38 +847,24 @@ def test_the_retry_count_is_in_the_json_entry_and_the_csv_columns() -> None: assert _csv_rows(_three_arm_matrix())[5]["summary_supervisor_retry_count"] == "" -def test_a_pre_spec_archive_renders_the_retry_row_as_dashes() -> None: - payload = json.loads(_LEGACY_ARTIFACT.read_text(encoding="utf-8")) - arms = [arm_from_report_fields(fields) for fields in payload["arms"]] - markdown = render_markdown(build_matrix_result(arms)) - assert _md_table_rows(markdown, "Supervisor")["Self-corrected retries"] == ["—"] * len(arms) - - # --------------------------------------------------------------------------------------------- # Display table (tier_comparison_table) # --------------------------------------------------------------------------------------------- -#: sha256 of each fixture's ``## Tier comparison summary`` block as rendered before the display -#: table was extracted; the Markdown must stay byte-identical. +#: sha256 of each fixture's ``## Tier comparison summary`` block; the Markdown must stay +#: byte-identical for identical input. _SUMMARY_BLOCK_SHA256 = { - "three_arm": "7b8e1b5660043e6a80f6a2872ab5515d0f97618d4ab48fa0ac04848ea021b243", - "single_anthropic": "e2e15c22b74b69b68645197b5b3df48f057f8173dea7b1334775b99d4399fb7c", - "single_openai_stub": "49e873b4c6f086c526a30e08cd97c5602deaaf2330d7c3fbde323cd14a726c96", - "legacy": "d3b5445014b8fabf050577255414115161ec7532d9d94b79d714a7dc52e23759", + "three_arm": "923317f03b8ea3de616207dd888e9f66df692d7356ce627fe4a208c37e4259b5", + "single_anthropic": "359173c77c3bae8ed3c172290269f0a0ac04f132fb49018762622dac6c761bae", + "single_openai_stub": "86c0d38dd5b1bb4feeb44560f9951d71a5620020a05cff922e35d0dddfd24026", } -def _legacy_matrix() -> MatrixResult: - payload = json.loads(_LEGACY_ARTIFACT.read_text(encoding="utf-8")) - return build_matrix_result([arm_from_report_fields(fields) for fields in payload["arms"]]) - - def _fixture_matrices() -> dict[str, MatrixResult]: return { "three_arm": _three_arm_matrix(), "single_anthropic": build_matrix_result([_anthropic_arm()]), "single_openai_stub": build_matrix_result([_openai_arm(SOL, mode="stub", effort="low")]), - "legacy": _legacy_matrix(), } @@ -833,7 +905,7 @@ def _section_rows(table: dict[str, object], tier: str) -> dict[str, list[str]]: @pytest.mark.parametrize("name", sorted(_SUMMARY_BLOCK_SHA256)) -def test_the_summary_markdown_is_byte_identical_to_the_pre_extraction_render(name: str) -> None: +def test_the_summary_markdown_is_byte_identical_to_its_pinned_render(name: str) -> None: block = _summary_block(render_markdown(_fixture_matrices()[name])) assert hashlib.sha256(block.encode("utf-8")).hexdigest() == _SUMMARY_BLOCK_SHA256[name] @@ -884,14 +956,6 @@ def test_table_cells_render_null_withheld_and_not_applicable() -> None: assert tool["Self-corrected retries"] == ["not applicable"] * 3 -def test_a_pre_spec_archive_table_renders_absent_figures_as_dashes() -> None: - matrix_result = _legacy_matrix() - supervisor = _section_rows(_table(matrix_result), "supervisor") - columns = len(matrix_result.arms) - assert supervisor["Effort"] == ["—"] * columns - assert supervisor["Task completion rate"] == ["—"] * columns - - def test_a_single_arm_table_has_one_cell_per_row() -> None: table = _table(build_matrix_result([_anthropic_arm()])) assert table["headers"] == ["Metric", "anthropic"] @@ -903,7 +967,7 @@ def test_an_unexercised_tier_still_renders_its_section() -> None: subagent = _section_rows(_table(build_matrix_result([_openai_arm()])), "subagent") assert subagent["Task completion rate"] == ["not applicable"] assert subagent["Model"] == [SOL] - assert subagent["Delegation outcome: none"] == ["2"] + assert subagent["Cost per applicable task"] == ["withheld"] @pytest.mark.parametrize( @@ -1032,3 +1096,130 @@ def test_the_run_payload_tier_table_passes_the_count_through_and_dashes_an_older _section_rows(older, t)["Long-context invocations"] for t in ("supervisor", "subagent", "tool") ] == [["—"], ["—"], ["—"]] + + +# --------------------------------------------------------------------------------------------- +# Cost per applicable task, token rows and delegation counts +# --------------------------------------------------------------------------------------------- + + +def _all_completed_arm() -> ArmResult: + """The anthropic arm with every applicable task completed at every tier.""" + arm = _anthropic_arm() + return dataclasses.replace( + arm, + tier_summary_fields={ + "supervisor": _summary_entry(5, 5, 0.6, (1000, 200)), + "subagent": _summary_entry(4, 4, 0.2, (400, 80)), + "tool": _summary_entry(3, 3, 0.09, (120, 30)), + }, + ) + + +def test_both_cost_rows_render_identical_cells_at_full_completion() -> None: + table = _table(build_matrix_result([_all_completed_arm(), _openai_arm()])) + for tier in ("supervisor", "subagent", "tool"): + rows = _section_rows(table, tier) + assert rows["Cost per completed task"] == rows["Cost per applicable task"] + assert rows["Cost per applicable task"][0] != "—" + entries = cast( + dict[str, list[dict[str, object]]], + tier_comparison(build_matrix_result([_all_completed_arm()]))["tiers"], + ) + for tier, (total, applicable) in { + "supervisor": (0.6, 5), + "subagent": (0.2, 4), + "tool": (0.09, 3), + }.items(): + assert entries[tier][0]["cost_per_applicable_task"] == pytest.approx(total / applicable) + + +def test_the_cost_per_applicable_task_is_none_and_a_dash_when_nothing_was_applicable() -> None: + arm = dataclasses.replace( + _anthropic_arm(), + tier_summary_fields={ + **_anthropic_arm().tier_summary_fields, + "subagent": _summary_entry(0, 0, 0.2, (400, 80)), + }, + ) + matrix_result = build_matrix_result([arm]) + assert _entry(tier_comparison(matrix_result), "subagent", 0)["cost_per_applicable_task"] is None + assert _section_rows(_table(matrix_result), "subagent")["Cost per applicable task"] == ["—"] + assert _md_table_rows(render_markdown(matrix_result), "Subagent")[ + "Cost per applicable task" + ] == ["—"] + + +def test_no_delegation_outcome_row_is_rendered_but_json_and_csv_keep_the_counts() -> None: + matrix_result = _three_arm_matrix() + markdown = render_markdown(matrix_result) + assert "Delegation outcome" not in markdown + table = _table(matrix_result) + labels = [ + row[0] + for section in cast(list[dict[str, object]], table["sections"]) + for row in cast(list[list[str]], section["rows"]) + ] + assert not any(label.startswith("Delegation outcome") for label in labels) + payload = json.loads(render_json(matrix_result)) + assert payload["tier_comparison"]["tiers"]["subagent"][0]["delegation_outcomes"] == { + "data": 2, + "no_match": 1, + "denied": 1, + "tool_failure": 0, + "none": 1, + } + first = _csv_rows(matrix_result)[0] + assert [ + first[f"summary_subagent_delegation_{kind}"] + for kind in ("data", "no_match", "denied", "tool_failure", "none") + ] == ["2", "1", "1", "0", "1"] + + +def test_the_p50_row_precedes_the_p95_row_in_every_section() -> None: + for section in cast(list[dict[str, object]], _table(_three_arm_matrix())["sections"]): + labels = [row[0] for row in cast(list[list[str]], section["rows"])] + assert labels.index("P50 latency per completed task (ms)") + 1 == labels.index( + "P95 latency per completed task (ms)" + ) + + +def test_the_tokens_note_defines_each_token_row_and_compares_nothing() -> None: + note = matrix._TIER_COMPARISON_TOKENS_NOTE + for label in ( + "Total input tokens", + "Cache read tokens", + "Cache write tokens", + "Uncached input tokens", + "Total output tokens", + ): + assert label in note + assert not re.search(r"\b(ratio|difference|winner|better|worse|cheaper)\b", note, re.I) + + +def test_the_tokens_note_states_the_per_call_cache_clamp() -> None: + assert ( + "reported input for OpenAI, whose reported input includes them, or that call's cache read " + "plus cache write tokens where they exceed it." in matrix._TIER_COMPARISON_TOKENS_NOTE + ) + + +def test_the_clamp_the_tokens_note_states_is_what_prompt_tokens_computes() -> None: + from crm.metering import TokenUsage, prompt_tokens + + clamped = TokenUsage( + input_tokens=100, output_tokens=0, cache_read_tokens=90, cache_write_tokens=40 + ) + unclamped = TokenUsage( + input_tokens=200, output_tokens=0, cache_read_tokens=90, cache_write_tokens=40 + ) + assert prompt_tokens(clamped, "openai") == 130 + assert prompt_tokens(unclamped, "openai") == 200 + + +def test_a_record_shape_3_summary_missing_a_token_or_cost_key_is_refused() -> None: + for key in ("cost_per_applicable_task", *matrix.TIER_SUMMARY_TOKEN_KEYS): + summary: dict[str, Any] = json.loads(json.dumps(tier_comparison(_three_arm_matrix()))) + del summary["tiers"]["tool"][1][key] + with pytest.raises(matrix.RecordShapeRefused, match=rf"tiers\.tool\[1\]\.{key}"): + matrix.tier_comparison_table(summary) diff --git a/tests/unit/test_matrix_tier_summary.py b/tests/unit/test_matrix_tier_summary.py index c569df8..8764c04 100644 --- a/tests/unit/test_matrix_tier_summary.py +++ b/tests/unit/test_matrix_tier_summary.py @@ -16,6 +16,7 @@ from eval import harness from eval.matrix import ( ArmResult, + RecordShapeRefused, arm_from_report_fields, build_matrix_result, render_csv, @@ -33,7 +34,7 @@ not_measured_latency_metrics, ) from eval.scoring import SCORED_TIERS, TierScore, TierScores -from tests.unit.test_matrix import _sample_arm +from tests.unit.test_matrix import _archivable_arm, _sample_arm def _row( @@ -163,6 +164,9 @@ def test_an_empty_arm_still_reports_every_tier() -> None: assert list(fields) == list(SCORED_TIERS) assert fields["supervisor"] == { "input_tokens": 0, + "total_prompt_tokens": 0, + "cache_read_tokens": 0, + "cache_write_tokens": 0, "output_tokens": 0, "cost_total": 0.0, "long_context_invocation_count": 0, @@ -182,7 +186,7 @@ def test_the_report_key_is_tier_summary() -> None: def _arm_with_summary(*, withhold_cost: bool = True) -> ArmResult: return dataclasses.replace( - _sample_arm(), tier_summary_fields=_summary_fields(withhold_cost=withhold_cost) + _archivable_arm(), tier_summary_fields=_summary_fields(withhold_cost=withhold_cost) ) @@ -251,14 +255,15 @@ def test_the_summary_round_trips_through_a_raw_archive() -> None: assert rebuilt.tier_summary_fields == json.loads(json.dumps(arm.tier_summary_fields)) -def test_an_archive_without_a_summary_rebuilds_an_empty_one() -> None: - fields = _sample_arm().to_report_fields() +def test_an_archive_without_a_summary_is_refused() -> None: + fields = _arm_with_summary().to_report_fields() del fields["tier_summary"] - assert arm_from_report_fields(fields).tier_summary_fields == {} + with pytest.raises(RecordShapeRefused, match="missing required field tier_summary$"): + arm_from_report_fields(fields) def test_an_archive_with_a_non_object_summary_is_refused() -> None: - fields = _sample_arm().to_report_fields() + fields = _arm_with_summary().to_report_fields() fields["tier_summary"] = ["supervisor"] with pytest.raises(ValueError, match="'tier_summary' is not an object"): arm_from_report_fields(fields) diff --git a/tests/unit/test_matrix_uncached_input.py b/tests/unit/test_matrix_uncached_input.py new file mode 100644 index 0000000..14e3856 --- /dev/null +++ b/tests/unit/test_matrix_uncached_input.py @@ -0,0 +1,178 @@ +# SPDX-License-Identifier: MIT +"""Tests for the tier tables' input token rows in :mod:`eval.matrix`. + +Total input tokens is the per-call prompt size, Uncached input tokens is derived from it and the +two cache counts, and the identity Total = cache read + cache write + uncached holds exactly. +""" + +from __future__ import annotations + +import csv +import io +import json +from typing import Any, cast + +import pytest + +from agents.tier_attribution import CacheCounts, InvocationAttribution, TokenCounts +from eval import matrix +from eval.matrix import render_csv, render_json, render_markdown, tier_comparison +from eval.metrics import ( + aggregate_tier_role_model, + aggregate_tier_summary, + not_measured_latency_metrics, +) +from tests.unit import test_matrix_tier_comparison as fixtures + +_ANTHROPIC = "anthropic.claude-sonnet-5-5" +_OPENAI = "openai.gpt-6.1-sol" +_OLD_LABELS = ("Reported input tokens", "Total prompt tokens", "Output tokens") +_TOKEN_LABELS = [ + "Total input tokens", + "Cache read tokens", + "Cache write tokens", + "Uncached input tokens", + "Total output tokens", +] + + +def _sections(summary: dict[str, object]) -> list[dict[str, list[str]]]: + table = matrix.tier_comparison_table(summary) + return [ + {row[0]: row[1:] for row in cast(list[list[str]], section["rows"])} + for section in cast(list[dict[str, object]], table["sections"]) + ] + + +def _supervisor_entry(call: InvocationAttribution) -> dict[str, object]: + rows = aggregate_tier_role_model((call,), withhold_cost=True) + summary = aggregate_tier_summary(rows, not_measured_latency_metrics(), (), withhold_cost=True) + return cast(dict[str, object], summary.to_report_fields()["supervisor"]) + + +def _call(model_id: str, *, input_tokens: int, read: int, write: int) -> InvocationAttribution: + return InvocationAttribution( + tier="supervisor", + role="supervisor", + model_id=model_id, + tokens=TokenCounts(input_tokens=input_tokens, output_tokens=7), + cache=CacheCounts(read_tokens=read, write_tokens=write), + ) + + +def test_the_token_rows_are_the_five_input_and_output_rows_in_order() -> None: + for rows in _sections(tier_comparison(fixtures._three_arm_matrix())): + labels = list(rows) + start = labels.index("Total input tokens") + assert labels[start : start + len(_TOKEN_LABELS)] == _TOKEN_LABELS + + +def test_total_input_is_cache_read_plus_cache_write_plus_uncached_in_every_column() -> None: + matrix_result = fixtures._three_arm_matrix() + columns = cast(list[dict[str, object]], tier_comparison(matrix_result)["columns"]) + families = {column["family"] for column in columns} + assert families == {"anthropic", "openai"} + checked = 0 + for rows in _sections(tier_comparison(matrix_result)): + total, read, write, uncached = ( + [int(cell) for cell in rows[label]] for label in _TOKEN_LABELS[:4] + ) + for column in range(len(total)): + assert total[column] == read[column] + write[column] + uncached[column] + checked += 1 + assert checked == 9 + + +def test_the_identity_holds_for_live_shaped_calls_of_both_families() -> None: + for call in ( + _call(_ANTHROPIC, input_tokens=40, read=50, write=10), + _call(_OPENAI, input_tokens=100, read=50, write=10), + _call(_OPENAI, input_tokens=20, read=50, write=10), + ): + entry = _supervisor_entry(call) + uncached = matrix.uncached_input_tokens(entry) + assert uncached is not None and uncached >= 0 + assert entry["total_prompt_tokens"] == ( + cast(int, entry["cache_read_tokens"]) + + cast(int, entry["cache_write_tokens"]) + + uncached + ) + + +def test_the_same_prompt_gives_the_same_uncached_input_for_both_families() -> None: + anthropic = _supervisor_entry(_call(_ANTHROPIC, input_tokens=40, read=50, write=10)) + openai = _supervisor_entry(_call(_OPENAI, input_tokens=100, read=50, write=10)) + assert anthropic["input_tokens"] != openai["input_tokens"] + assert anthropic["total_prompt_tokens"] == openai["total_prompt_tokens"] == 100 + assert matrix.uncached_input_tokens(anthropic) == matrix.uncached_input_tokens(openai) == 40 + + +@pytest.mark.parametrize("label", _OLD_LABELS) +def test_no_surface_carries_an_old_token_row_label(label: str) -> None: + matrix_result = fixtures._three_arm_matrix() + summary = tier_comparison(matrix_result) + for rows in _sections(summary): + assert label not in rows + assert f"| {label} |" not in render_markdown(matrix_result) + assert not any(label in note for note in cast(list[str], summary["notes"])) + + +def test_json_entries_carry_the_derived_uncached_figure_beside_total_prompt_tokens() -> None: + payload = json.loads(render_json(fixtures._three_arm_matrix())) + for entries in payload["tier_comparison"]["tiers"].values(): + for entry in entries: + keys = list(entry) + assert keys.index("uncached_input_tokens") == keys.index("cache_write_tokens") + 1 + assert entry["uncached_input_tokens"] == ( + entry["total_prompt_tokens"] + - entry["cache_read_tokens"] + - entry["cache_write_tokens"] + ) + assert "input_tokens" in entry + + +def test_csv_carries_the_uncached_column_for_every_tier() -> None: + reader = csv.DictReader(io.StringIO(render_csv(fixtures._three_arm_matrix()))) + first = next(reader) + for tier in ("supervisor", "subagent", "tool"): + assert int(first[f"summary_{tier}_uncached_input_tokens"]) == ( + int(first[f"summary_{tier}_total_prompt_tokens"]) + - int(first[f"summary_{tier}_cache_read_tokens"]) + - int(first[f"summary_{tier}_cache_write_tokens"]) + ) + assert f"summary_{tier}_input_tokens" in first + + +def test_a_stored_summary_without_the_uncached_key_still_renders_the_derived_row() -> None: + matrix_result = fixtures._three_arm_matrix() + stored: dict[str, Any] = json.loads(render_json(matrix_result))["tier_comparison"] + for entries in stored["tiers"].values(): + for entry in entries: + del entry["uncached_input_tokens"] + assert stored[matrix.RECORD_SHAPE_VERSION_KEY] == 3 + assert matrix.tier_comparison_table(stored) == matrix.tier_comparison_table( + tier_comparison(matrix_result) + ) + + +def test_an_unrecorded_token_figure_renders_a_dash_for_uncached_input() -> None: + stored: dict[str, Any] = json.loads(json.dumps(tier_comparison(fixtures._three_arm_matrix()))) + stored["tiers"]["tool"][1]["cache_write_tokens"] = None + tool = _sections(stored)[2] + assert tool["Uncached input tokens"][1] == "—" + + +def test_cache_counts_exceeding_the_total_are_refused() -> None: + with pytest.raises(ValueError, match="less than cache_read_tokens"): + matrix.uncached_input_tokens( + {"total_prompt_tokens": 10, "cache_read_tokens": 8, "cache_write_tokens": 3} + ) + + +def test_a_boolean_token_figure_is_not_read_as_an_integer() -> None: + assert ( + matrix.uncached_input_tokens( + {"total_prompt_tokens": 10, "cache_read_tokens": True, "cache_write_tokens": 0} + ) + is None + ) diff --git a/tests/unit/test_metrics_tier_summary_tokens.py b/tests/unit/test_metrics_tier_summary_tokens.py new file mode 100644 index 0000000..d79c5c3 --- /dev/null +++ b/tests/unit/test_metrics_tier_summary_tokens.py @@ -0,0 +1,143 @@ +# SPDX-License-Identifier: MIT +"""Tests for the per-tier prompt and cache token totals in :mod:`eval.metrics`. + +Anthropic reports input tokens exclusive of cache tokens; OpenAI reports them inclusive. The +total prompt figure is summed per call, so a call whose cache counts exceed its reported input +clamps on its own rather than against the tier's sums. +""" + +from __future__ import annotations + +import pytest + +from agents.tier_attribution import CacheCounts, InvocationAttribution, TokenCounts +from eval.metrics import ( + aggregate_tier_role_model, + aggregate_tier_summary, + attribution_prompt_tokens, + not_measured_latency_metrics, +) + +_ANTHROPIC = "anthropic.claude-sonnet-5-5" +_OPENAI = "openai.gpt-6.1-sol" + + +def _call( + tier: str, + model_id: str, + *, + input_tokens: int, + read: int = 0, + write: int = 0, + output_tokens: int = 5, + role: str | None = None, +) -> InvocationAttribution: + return InvocationAttribution( + tier=tier, # type: ignore[arg-type] + role=role or ("supervisor" if tier == "supervisor" else "research"), + model_id=model_id, + tokens=TokenCounts(input_tokens=input_tokens, output_tokens=output_tokens), + cache=CacheCounts(read_tokens=read, write_tokens=write), + ) + + +_ANTHROPIC_SUPERVISOR = ( + _call("supervisor", _ANTHROPIC, input_tokens=100, read=50, write=20), + _call("supervisor", _ANTHROPIC, input_tokens=30), +) +_OPENAI_TOOL = ( + _call("tool", _OPENAI, input_tokens=100, read=60), + _call("tool", _OPENAI, input_tokens=10, read=30), +) + + +def _summary(calls: tuple[InvocationAttribution, ...]) -> dict[str, dict[str, object]]: + rows = aggregate_tier_role_model(calls, withhold_cost=True) + summary = aggregate_tier_summary(rows, not_measured_latency_metrics(), (), withhold_cost=True) + fields = summary.to_report_fields() + return {tier: entry for tier, entry in fields.items() if isinstance(entry, dict)} + + +def test_an_exclusive_call_prompt_adds_cache_read_and_write_to_input() -> None: + assert attribution_prompt_tokens(_ANTHROPIC_SUPERVISOR[0]) == 170 + assert attribution_prompt_tokens(_ANTHROPIC_SUPERVISOR[1]) == 30 + + +def test_an_inclusive_call_prompt_is_its_reported_input() -> None: + assert attribution_prompt_tokens(_OPENAI_TOOL[0]) == 100 + + +def test_an_inclusive_call_whose_cache_exceeds_its_input_clamps_per_call() -> None: + assert attribution_prompt_tokens(_OPENAI_TOOL[1]) == 30 + + +def test_a_zero_token_call_counts_zero_without_a_model_id() -> None: + structural = _call("subagent", "", input_tokens=0, output_tokens=0) + assert attribution_prompt_tokens(structural) == 0 + + +def test_a_token_bearing_call_of_no_known_family_is_refused() -> None: + with pytest.raises(ValueError, match="no recognised provider-family prefix"): + attribution_prompt_tokens(_call("tool", "acme.model-1", input_tokens=1)) + + +def test_a_row_reports_its_summed_per_call_prompt_tokens() -> None: + (row,) = aggregate_tier_role_model(_ANTHROPIC_SUPERVISOR, withhold_cost=True) + assert row.prompt_tokens == 200 + assert row.to_report_fields()["prompt_tokens"] == 200 + + +def test_a_row_reports_prompt_tokens_right_after_cache_write_tokens() -> None: + (row,) = aggregate_tier_role_model(_ANTHROPIC_SUPERVISOR, withhold_cost=True) + keys = list(row.to_report_fields()) + assert keys[keys.index("cache_write_tokens") + 1] == "prompt_tokens" + + +def test_an_anthropic_tier_totals_pin_every_figure() -> None: + entry = _summary(_ANTHROPIC_SUPERVISOR)["supervisor"] + assert entry["input_tokens"] == 130 + assert entry["total_prompt_tokens"] == 200 + assert entry["cache_read_tokens"] == 50 + assert entry["cache_write_tokens"] == 20 + assert entry["output_tokens"] == 10 + + +def test_an_openai_tier_totals_pin_every_figure_with_the_per_call_clamp() -> None: + entry = _summary(_OPENAI_TOOL)["tool"] + assert entry["input_tokens"] == 110 + assert entry["total_prompt_tokens"] == 130 + assert entry["cache_read_tokens"] == 90 + assert entry["cache_write_tokens"] == 0 + assert entry["output_tokens"] == 10 + + +def test_each_tier_totals_only_its_own_calls() -> None: + summary = _summary(_ANTHROPIC_SUPERVISOR + _OPENAI_TOOL) + assert summary["supervisor"]["total_prompt_tokens"] == 200 + assert summary["tool"]["total_prompt_tokens"] == 130 + assert summary["subagent"]["total_prompt_tokens"] == 0 + assert summary["subagent"]["cache_read_tokens"] == 0 + assert summary["subagent"]["cache_write_tokens"] == 0 + + +def test_a_tier_sums_prompt_tokens_across_its_role_and_model_rows() -> None: + calls = ( + _call("subagent", _ANTHROPIC, input_tokens=10, read=4, write=2, role="research"), + _call("subagent", _OPENAI, input_tokens=20, read=25, role="mutation"), + ) + entry = _summary(calls)["subagent"] + assert entry["total_prompt_tokens"] == 16 + 25 + assert entry["cache_read_tokens"] == 29 + assert entry["cache_write_tokens"] == 2 + + +def test_a_tier_entry_reports_token_keys_in_the_fixed_order() -> None: + keys = list(_summary(_ANTHROPIC_SUPERVISOR)["supervisor"]) + assert keys[:6] == [ + "input_tokens", + "total_prompt_tokens", + "cache_read_tokens", + "cache_write_tokens", + "output_tokens", + "cost_total", + ] diff --git a/tests/unit/test_metrics_tier_task.py b/tests/unit/test_metrics_tier_task.py index fac1ca2..b153d82 100644 --- a/tests/unit/test_metrics_tier_task.py +++ b/tests/unit/test_metrics_tier_task.py @@ -59,6 +59,7 @@ def _obs( outcome: str | None = None, efforts: Mapping[Tier, str | None] | None = None, tool_calls: tuple[ToolCallAttribution, ...] = (), + exhausted_at: Tier | None = None, ) -> TaskTierObservation: return TaskTierObservation( task_id=task_id, @@ -72,6 +73,7 @@ def _obs( delegation_outcome=outcome, resolved_efforts=efforts, tool_calls=tool_calls, + budget_exhausted_tier=exhausted_at, ) @@ -178,6 +180,9 @@ def test_tier_with_no_completed_task_reports_none_at_count_zero() -> None: "completed_task_latency_ms_p50": None, "completed_task_latency_ms_p95": None, "retry_count": 0, + "budget_exhausted_task_count": 0, + "truncated_tool_call_count": 0, + "truncated_task_count": 0, } @@ -271,6 +276,9 @@ def test_report_fields_key_order() -> None: "completed_task_latency_ms_p50", "completed_task_latency_ms_p95", "retry_count", + "budget_exhausted_task_count", + "truncated_tool_call_count", + "truncated_task_count", ] assert entry["configured_model_id"] == _CONFIGURED[tier] @@ -279,9 +287,11 @@ def test_all_tiers_matches_report_order() -> None: assert ALL_TIERS == ("supervisor", "subagent", "tool") -def _tc(tool_name: str, role: str, kind: OutcomeKind) -> ToolCallAttribution: +def _tc( + tool_name: str, role: str, kind: OutcomeKind, *, truncated: bool = False +) -> ToolCallAttribution: return ToolCallAttribution( - tool_name=tool_name, role=role, latency_ms=None, outcome_kind=kind, truncated=False + tool_name=tool_name, role=role, latency_ms=None, outcome_kind=kind, truncated=truncated ) @@ -360,3 +370,84 @@ def test_retry_count_is_zero_without_tool_calls() -> None: def test_the_supervisor_role_matches_the_agents_constant() -> None: assert SUPERVISOR_ROLE == AGENTS_SUPERVISOR_ROLE + + +# -- budget exhaustion and truncation per tier -------------------------------------------------- + + +def test_budget_exhausted_tasks_are_counted_at_the_tier_where_the_budget_ran_out() -> None: + observations = [ + _obs("t1", exhausted_at="supervisor"), + _obs("t2", exhausted_at="subagent"), + _obs("t3", exhausted_at="tool"), + _obs("t4", exhausted_at="tool"), + _obs("t5"), + ] + by_tier = _by_tier(observations) + assert {tier: by_tier[tier]["budget_exhausted_task_count"] for tier in ALL_TIERS} == { # type: ignore[index] + "supervisor": 1, + "subagent": 1, + "tool": 2, + } + + +def test_budget_exhausted_tasks_are_zero_at_every_tier_with_no_exhaustion() -> None: + by_tier = _by_tier([_obs("t1"), _obs("t2")]) + for tier in ALL_TIERS: + assert by_tier[tier]["budget_exhausted_task_count"] == 0 # type: ignore[index] + + +def test_budget_exhausted_tasks_are_counted_for_an_unmeasured_arm() -> None: + entry = _tier([_obs("t1", exhausted_at="supervisor")], "supervisor", measured=False) + assert entry["budget_exhausted_task_count"] == 1 + + +def _truncation_observations() -> list[TaskTierObservation]: + return [ + _obs( + "t1", + tool_calls=( + _tc("search_opportunities", SUPERVISOR_ROLE, "data", truncated=True), + _tc("search_opportunities", SUPERVISOR_ROLE, "data", truncated=True), + _tc("list_activities", "research", "data", truncated=True), + ), + ), + _obs( + "t2", + tool_calls=( + _tc("list_activities", "research", "data", truncated=True), + _tc("get_account", "research", "data"), + ), + ), + _obs("t3", tool_calls=(_tc("get_account", SUPERVISOR_ROLE, "data"),)), + ] + + +def test_a_supervisor_role_truncated_call_counts_at_the_supervisor() -> None: + entry = _tier(_truncation_observations(), "supervisor") + assert entry["truncated_tool_call_count"] == 2 + assert entry["truncated_task_count"] == 1 + + +def test_a_truncated_call_inside_a_delegation_counts_at_the_tool_tier() -> None: + entry = _tier(_truncation_observations(), "tool") + assert entry["truncated_tool_call_count"] == 2 + assert entry["truncated_task_count"] == 2 + + +def test_the_subagent_tier_reports_no_truncation_figures() -> None: + entry = _tier(_truncation_observations(), "subagent") + assert entry["truncated_tool_call_count"] is None + assert entry["truncated_task_count"] is None + + +def test_truncation_is_zero_not_none_at_supervisor_and_tool_without_truncation() -> None: + by_tier = _by_tier([_obs("t1", tool_calls=(_tc("get_account", "research", "data"),))]) + for tier in ("supervisor", "tool"): + assert by_tier[tier]["truncated_tool_call_count"] == 0 # type: ignore[index] + assert by_tier[tier]["truncated_task_count"] == 0 # type: ignore[index] + + +def test_truncation_is_counted_for_an_unmeasured_arm() -> None: + entry = _tier(_truncation_observations(), "tool", measured=False) + assert entry["truncated_tool_call_count"] == 2 diff --git a/tests/unit/test_package_lambdas.py b/tests/unit/test_package_lambdas.py index 591a90f..eb4e427 100644 --- a/tests/unit/test_package_lambdas.py +++ b/tests/unit/test_package_lambdas.py @@ -104,7 +104,7 @@ def test_the_eval_zip_carries_the_user_settings_handler() -> None: assert "config/models.yaml" in members -#: A Python Lambda runtime literal in Terraform: `runtime = "python3.13"` or a variable default. +#: A Python Lambda runtime literal in Terraform: `runtime = "python3.14"` or a variable default. _TF_PYTHON_RUNTIME: Final = re.compile(r'^\s*(?:runtime|default)\s*=\s*"python(\d+\.\d+)"', re.M) @@ -127,4 +127,4 @@ def test_every_python_runtime_names_the_version_packaging_and_the_gate_target() assert infra_versions == {target}, infra_versions assert packager_versions == {target}, packager_versions assert smoke_versions == {target}, smoke_versions - assert target == "3.13" + assert target == "3.14" diff --git a/tests/unit/test_package_lambdas_agent_source.py b/tests/unit/test_package_lambdas_agent_source.py new file mode 100644 index 0000000..02fc3ac --- /dev/null +++ b/tests/unit/test_package_lambdas_agent_source.py @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: MIT +"""`agent-source.zip`, the AgentCore image build context, carries no `src/relay/` tree. + +Two subjects. The script's own staging `rsync` command runs against a scratch `src/` tree, so a +removed exclusion reds without a rebuild. The real built archive is read when one exists; it skips +when nothing has been built, unless `CRM_REQUIRE_RELAY_PACKAGING=1`, which turns either skip into a +failure. +""" + +from __future__ import annotations + +import os +import re +import shutil +import zipfile +from pathlib import Path +from typing import Final, NoReturn + +import pytest +from scripts import proc_run + +REPO_ROOT: Final = Path(__file__).resolve().parents[2] +SCRIPT: Final = REPO_ROOT / "scripts" / "package_lambdas.sh" +BUILT_ARCHIVE: Final = REPO_ROOT / "infra" / "build" / "lambda" / "agent-source.zip" +REQUIRE_ENV: Final = "CRM_REQUIRE_RELAY_PACKAGING" + +#: The staging command: from the `rsync` after `agent_source_dir` is created up to its `src/` target. +_STAGING_RSYNC: Final = re.compile( + r'mkdir -p "\$\{agent_source_dir\}"\n(rsync -a [^\n]*(?:\\\n[^\n]*)*"\$\{agent_source_dir\}/src/")' +) + + +def _skip_or_fail(message: str) -> NoReturn: + if os.environ.get(REQUIRE_ENV) == "1": + pytest.fail(f"{message} ({REQUIRE_ENV}=1 forbids skipping)") + pytest.skip(message) + + +def _staging_command() -> str: + match = _STAGING_RSYNC.search(SCRIPT.read_text(encoding="utf-8")) + assert match is not None, ( + "the agent-source staging rsync is gone or reshaped; re-point this test" + ) + return match.group(1) + + +def _write(path: Path, text: str = "x") -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(text, encoding="utf-8") + + +def test_the_staging_rsync_drops_src_relay_and_keeps_the_python_packages(tmp_path: Path) -> None: + """Only the top-level `relay/` is dropped; a nested directory named `relay` is still staged.""" + rsync = shutil.which("rsync") + if rsync is None: + _skip_or_fail("rsync is not on PATH, so the staging command cannot run") + src = tmp_path / "src" + _write(src / "relay" / "package.json", "{}") + _write(src / "relay" / "node_modules" / "dep" / "index.js") + _write(src / "relay" / "src" / "handler.ts") + _write(src / "agents" / "supervisor.py") + _write(src / "crm" / "relay" / "nested.py") + _write(src / "crm" / "__pycache__" / "cached.pyc") + stage = tmp_path / "stage" + stage.mkdir() + + result = proc_run.run( + ["bash", "-euo", "pipefail", "-c", _staging_command()], + env={ + "SRC_DIR": str(src), + "agent_source_dir": str(stage), + "PATH": f"{Path(rsync).parent}:/bin:/usr/bin", + }, + capture_output=True, + text=True, + check=False, + ) + + assert result.returncode == 0, f"{result.stdout}{result.stderr}" + staged = {p.relative_to(stage).as_posix() for p in stage.rglob("*") if p.is_file()} + assert staged == {"src/agents/supervisor.py", "src/crm/relay/nested.py"}, sorted(staged) + + +def test_the_built_agent_source_zip_has_no_relay_entries() -> None: + """The last build's archive holds the Python packages and nothing under `src/relay/`.""" + if not BUILT_ARCHIVE.is_file(): + _skip_or_fail(f"no built {BUILT_ARCHIVE.name}; run scripts/package_lambdas.sh") + with zipfile.ZipFile(BUILT_ARCHIVE) as archive: + members = archive.namelist() + relay = [m for m in members if m == "src/relay/" or m.startswith("src/relay/")] + assert relay == [], relay[:5] + assert "src/agents/supervisor.py" in members + assert "Dockerfile" in members diff --git a/tests/unit/test_plan_fixtures.py b/tests/unit/test_plan_fixtures.py index cc9cd16..b503a1f 100644 --- a/tests/unit/test_plan_fixtures.py +++ b/tests/unit/test_plan_fixtures.py @@ -24,15 +24,15 @@ #: sha256 of `json.dumps(build(name), sort_keys=True)` per name. EXPECTED_SHA256 = { - "compliant": "d9dd799f5d32997be6f0d5c41cb5298fa5f0d4078fec75ec0656dce5a2084005", + "compliant": "f6dec943e81e652ef2ee27ead8b8d32f6ef3a3d44ffb61aacb36c5fde4ddfc98", "compliant_gateway_role_known_arn": ( - "d74f7982321b59662ab93488a428d33149c9447122ed31a155244cd88cdc18ca" + "200bb43354db8bc6cb228620336941290d62649d673f2ce5124704b06fb6d20d" ), "violation_log_group_no_kms": ( - "9b556f57694c25fce782841d349ea5bbe9a01a5739bf4b714e145026eea2cef5" + "b04e891dbb41c075133c3c462e5d7fb400d4417d1e7f3337245f237651538859" ), "violation_relay_function_url_buffered": ( - "aac904c0a3c097fbaad20a33b20d9720a5bfdd67e76160325c2348ee8f3da9d4" + "104d63ef5e93b2af2672411a9a88dc68e0cab308ba97e32ce005ec73597beb45" ), } diff --git a/tests/unit/test_plan_security_baseline.py b/tests/unit/test_plan_security_baseline.py index d54d5a4..3911706 100644 --- a/tests/unit/test_plan_security_baseline.py +++ b/tests/unit/test_plan_security_baseline.py @@ -6990,6 +6990,30 @@ def test_a_non_module_local_entry_reds_the_local_row_only(self, infra: Path) -> ) assert list(self._failed_rows(infra)) == [f"local.{gate.DYNAMODB_DATA_PLANE_LOCAL}"] + def test_a_missing_runtime_role_reds_the_local_row_only(self, infra: Path) -> None: + _mutate(infra / "main.tf", f" {gate.RUNTIME_DATA_PLANE_ROLE},\n", "") + failed = self._failed_rows(infra) + assert list(failed) == [f"local.{gate.DYNAMODB_DATA_PLANE_LOCAL}"] + assert "exactly once" in failed[f"local.{gate.DYNAMODB_DATA_PLANE_LOCAL}"] + + def test_a_duplicated_runtime_role_reds_the_local_row_only(self, infra: Path) -> None: + line = f" {gate.RUNTIME_DATA_PLANE_ROLE},\n" + _mutate(infra / "main.tf", line, line + line) + assert list(self._failed_rows(infra)) == [f"local.{gate.DYNAMODB_DATA_PLANE_LOCAL}"] + + def test_the_runtime_role_is_the_only_accepted_non_module_entry(self, infra: Path) -> None: + _mutate( + infra / "main.tf", + f" {gate.RUNTIME_DATA_PLANE_ROLE},\n", + " aws_iam_role.agentcore_gateway.arn,\n", + ) + failed = self._failed_rows(infra) + assert list(failed) == [f"local.{gate.DYNAMODB_DATA_PLANE_LOCAL}"] + assert ( + "aws_iam_role.agentcore_gateway.arn" + in failed[f"local.{gate.DYNAMODB_DATA_PLANE_LOCAL}"] + ) + @pytest.mark.parametrize( ("file", "policy"), [("modules/dynamodb/policy.tf", _TABLE_POLICY), ("modules/dynamodb/kms.tf", _KEY_POLICY)], @@ -7822,3 +7846,116 @@ def test_a_wrong_app_name_value_fails(self) -> None: def test_the_unmutated_copy_passes(self) -> None: assert self._first_finding(lambda _tags: None).status == "pass" + + +class TestRuntimeHistoryGrant: + """`dynamodb_leading_keys_isolation` asserts the Runtime history document statement by statement.""" + + @staticmethod + def _findings(document: dict[str, Any]) -> list[gate.Finding]: + plan = gate.Plan( + resource_changes=document["resource_changes"], + configuration=document.get("configuration", {}), + ) + return [ + f + for f in gate.check_dynamodb_leading_keys_isolation(plan) + if f.resource.startswith(gate.RUNTIME_HISTORY_DOCUMENT) + ] + + @staticmethod + def _statement(document: dict[str, Any], sid: str) -> dict[str, Any]: + change = next( + r for r in document["resource_changes"] if r["address"] == gate.RUNTIME_HISTORY_DOCUMENT + ) + statement: dict[str, Any] = next( + s for s in change["change"]["after"]["statement"] if s["sid"] == sid + ) + return statement + + def _failed(self, document: dict[str, Any]) -> set[str]: + return {f.resource for f in self._findings(document) if f.status == "fail"} + + def test_the_compliant_plan_passes_every_history_statement(self) -> None: + findings = self._findings(plan_fixtures.build("compliant")) + assert len(findings) == 7 + assert all(f.status == "pass" for f in findings), findings + + def test_the_gate_attributes_are_the_store_attributes(self) -> None: + from agents.conversation_history import HISTORY_ITEM_ATTRIBUTES + + assert set(gate.RUNTIME_HISTORY_ATTRIBUTES) == set(HISTORY_ITEM_ATTRIBUTES) + + @pytest.mark.parametrize( + ("sid", "edit"), + [ + ( + "ConversationHistoryRead", + lambda s: s.update(condition=[c for c in s["condition"] if c["test"] != "Null"]), + ), + ("ConversationHistoryRead", lambda s: s["actions"].append("dynamodb:Query")), + ( + "ConversationHistoryWrite", + lambda s: s.update( + condition=[c for c in s["condition"] if c["variable"] != "dynamodb:Attributes"] + ), + ), + ( + "ConversationHistoryKms", + lambda s: next( + c for c in s["condition"] if c["variable"] == "kms:ViaService" + ).update(values=["dynamodb.*.amazonaws.com"]), + ), + ( + "ConversationHistoryKms", + lambda s: s.update( + condition=[ + c + for c in s["condition"] + if c["variable"] != "kms:EncryptionContext:aws:dynamodb:tableName" + ] + ), + ), + ("DenyRepsNonGrantedActions", lambda s: s["not_actions"].append("dynamodb:Query")), + ("DenyDynamoDbOtherTables", lambda s: s.update(effect="Allow")), + ( + "DenyRepsOutsideHistoryPrefix", + lambda s: s["condition"][0].update(test="ForAllValues:StringNotLike"), + ), + ("DenyCanaryHistory", lambda s: s["condition"][0].update(values=["history#x#*"])), + ], + ) + def test_each_weakening_reds_that_statement_only(self, sid: str, edit: Any) -> None: + document = plan_fixtures.build("compliant") + edit(self._statement(document, sid)) + assert self._failed(document) == {f"{gate.RUNTIME_HISTORY_DOCUMENT}#{sid}"} + + def test_a_dropped_statement_reds_the_statement_list(self) -> None: + document = plan_fixtures.build("compliant") + change = next( + r for r in document["resource_changes"] if r["address"] == gate.RUNTIME_HISTORY_DOCUMENT + ) + change["change"]["after"]["statement"] = [ + s for s in change["change"]["after"]["statement"] if s["sid"] != "DenyCanaryHistory" + ] + assert self._failed(document) == {f"{gate.RUNTIME_HISTORY_DOCUMENT} (statements)"} + + def test_a_missing_history_policy_fails(self) -> None: + document = plan_fixtures.build("compliant") + document["resource_changes"] = [ + r for r in document["resource_changes"] if r["address"] != gate.RUNTIME_HISTORY_POLICY + ] + assert self._failed(document) == {gate.RUNTIME_HISTORY_DOCUMENT} + + def test_the_coverage_row_counts_the_history_policy(self) -> None: + document = plan_fixtures.build("compliant") + document["resource_changes"] = [ + r for r in document["resource_changes"] if r["address"] != gate.RUNTIME_HISTORY_POLICY + ] + plan = gate.Plan(resource_changes=document["resource_changes"]) + coverage = [ + f + for f in gate.check_dynamodb_no_wildcard_action(plan) + if f.resource == "(coverage) one grant document per dynamodb role policy" + ] + assert [f.status for f in coverage] == ["fail"] diff --git a/tests/unit/test_planted_evidence.py b/tests/unit/test_planted_evidence.py index 0423d38..a802950 100644 --- a/tests/unit/test_planted_evidence.py +++ b/tests/unit/test_planted_evidence.py @@ -1,8 +1,9 @@ # SPDX-License-Identifier: MIT -"""Pin every planted-defect value PD-01..PD-07 for two tenants.""" +"""Pin every planted-defect value PD-01..PD-08 for two tenants.""" from __future__ import annotations +import json from collections.abc import Iterator from typing import Any @@ -10,6 +11,8 @@ import pytest from fixtures.generate import GeneratedCorpus, generate_dataset, scoped_id +from agents.events import TOOL_RESULT_BYTE_CEILING + TENANTS = ("demo", "eval-x") PD01_NOTE = ( @@ -42,8 +45,14 @@ "_plant_pd05_report_only_speculation": frozenset({"opp-0056", "note-defect-pd05"}), "_plant_pd06_same_named_contacts_one_account": frozenset({"cont-0077", "cont-0078"}), "_plant_pd07_clean_multi_step_write_target": frozenset({"opp-0088"}), + "_plant_pd08_activity_history_larger_than_one_page": frozenset( + f"act-defect-pd08-{index:02d}" for index in range(55) + ), } +#: ``list_activities``'s default page size. +DEFAULT_ACTIVITY_PAGE: int = 50 + _ID_FIELDS = { "accounts": "account_id", "contacts": "contact_id", @@ -191,6 +200,80 @@ def test_pd07_target_is_open_with_no_seeded_note_or_meeting( ] == [] +def _pd08_activities(corpus: GeneratedCorpus, tenant: str) -> list[dict[str, object]]: + prefix = scoped_id(tenant, "act-defect-pd08-") + return [a for a in corpus.activities if str(a["activity_id"]).startswith(prefix)] + + +def _base_corpus(tenant: str, monkeypatch: pytest.MonkeyPatch) -> GeneratedCorpus: + monkeypatch.setattr(generate, "_plant_pd08_activity_history_larger_than_one_page", _no_planting) + return generate_dataset(tenant) + + +def test_pd08_plants_55_activities_on_opp_0000(corpus: GeneratedCorpus, tenant: str) -> None: + """PD-08 adds 55 activities to opp-0000, each with a body, all ids distinct.""" + planted = _pd08_activities(corpus, tenant) + assert len(planted) == 55 + assert {a["opportunity_id"] for a in planted} == {scoped_id(tenant, "opp-0000")} + assert {a["account_id"] for a in planted} == {scoped_id(tenant, "acct-0000")} + assert len({a["activity_id"] for a in planted}) == 55 + assert all(isinstance(a["body"], str) and a["body"] for a in planted) + assert {a["kind"] for a in planted} <= set(generate.ACTIVITY_KINDS) + + +def test_pd08_ids_are_disjoint_from_the_base_corpus( + corpus: GeneratedCorpus, tenant: str, monkeypatch: pytest.MonkeyPatch +) -> None: + """No PD-08 id occurs in the corpus generated without PD-08.""" + base = _base_corpus(tenant, monkeypatch) + planted_ids = {a["activity_id"] for a in _pd08_activities(corpus, tenant)} + assert planted_ids.isdisjoint(_flatten(base)) + + +def test_pd08_leaves_every_other_activity_byte_identical( + corpus: GeneratedCorpus, tenant: str, monkeypatch: pytest.MonkeyPatch +) -> None: + """Every activity outside PD-08 serialises identically, and in order, to the base corpus.""" + base = _base_corpus(tenant, monkeypatch) + planted_ids = {a["activity_id"] for a in _pd08_activities(corpus, tenant)} + others = [a for a in corpus.activities if a["activity_id"] not in planted_ids] + assert [a["activity_id"] for a in others] == [a["activity_id"] for a in base.activities] + differing = [ + str(mine["activity_id"]) + for mine, theirs in zip(others, base.activities, strict=True) + if json.dumps(mine, sort_keys=True) != json.dumps(theirs, sort_keys=True) + ] + assert differing == [] + assert [a["activity_id"] for a in corpus.activities[: len(base.activities)]] == [ + a["activity_id"] for a in base.activities + ] + + +def test_pd08_activities_fall_inside_the_opportunity_timeline( + corpus: GeneratedCorpus, tenant: str +) -> None: + """Each PD-08 activity occurs between opp-0000's creation and its recorded last touch.""" + opportunity = _record(corpus, tenant, "opportunities", "opp-0000") + for activity in _pd08_activities(corpus, tenant): + assert str(opportunity["created_at"]) <= str(activity["occurred_at"]) + assert str(activity["occurred_at"]) <= str(opportunity["last_touch"]) + + +def test_pd08_is_deterministic(corpus: GeneratedCorpus, tenant: str) -> None: + """A second generation produces the same PD-08 activities.""" + assert _pd08_activities(generate_dataset(tenant), tenant) == _pd08_activities(corpus, tenant) + + +def test_any_default_page_of_opp_0000_activities_exceeds_the_tool_result_bound( + corpus: GeneratedCorpus, tenant: str +) -> None: + """Even the 50 smallest of opp-0000's activities exceed the tool-result byte ceiling.""" + activities = _children(corpus, "activities", scoped_id(tenant, "opp-0000")) + assert len(activities) > DEFAULT_ACTIVITY_PAGE + sizes = sorted(len(repr(a)) for a in activities) + assert sum(sizes[:DEFAULT_ACTIVITY_PAGE]) > TOOL_RESULT_BYTE_CEILING + + def test_no_contact_other_than_pd01s_is_departed(corpus: GeneratedCorpus, tenant: str) -> None: """gt-04's premise: cont-0000 is the corpus's only departed contact.""" departed = [c["contact_id"] for c in corpus.contacts if c["status"] == "departed"] diff --git a/tests/unit/test_preflight_adopted_vpc.py b/tests/unit/test_preflight_adopted_vpc.py index 705fc0f..4e2c0ea 100644 --- a/tests/unit/test_preflight_adopted_vpc.py +++ b/tests/unit/test_preflight_adopted_vpc.py @@ -12,6 +12,7 @@ import os import shutil import subprocess +import sys from pathlib import Path import pytest @@ -104,6 +105,9 @@ def _run( ) -> subprocess.CompletedProcess[str]: bin_dir = tmp_path / "bin" _write_stub(bin_dir, responses) + python_shim = bin_dir / "python3" + python_shim.unlink(missing_ok=True) + python_shim.symlink_to(sys.executable) env = dict(os.environ, PATH=f"{bin_dir}:{os.environ['PATH']}") env.pop("AWS_REGION", None) env.pop("AWS_PROFILE", None) @@ -369,6 +373,7 @@ def _scratch_preflight(tmp_path: Path, map_text: str | None) -> Path: """A two-script repo copy whose `infra/regions.json` is `map_text` (absent when None).""" root = tmp_path / "repo" (root / "scripts").mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh") (root / "infra").mkdir() for name in ("preflight_adopted_vpc.sh", "region_map.py"): shutil.copy2(REPO_ROOT / "scripts" / name, root / "scripts" / name) diff --git a/tests/unit/test_prompt_bundle.py b/tests/unit/test_prompt_bundle.py index 14a5838..d4fec5e 100644 --- a/tests/unit/test_prompt_bundle.py +++ b/tests/unit/test_prompt_bundle.py @@ -64,6 +64,14 @@ def test_the_bundle_carries_every_model_facing_member_at_schema_2() -> None: assert set(briefings) == {"entity", "list", "board", "opaque"} +def test_the_anthropic_caching_text_names_both_points_the_limit_and_the_minimum() -> None: + text = prompt_caching.CACHING["anthropic"] + assert "last stable system block" in text + assert "last content block of the latest message" in text + assert f"at most {prompt_caching.ANTHROPIC_MAX_CACHE_POINTS} points" in text + assert "prompt_cache_min_checkpoint_tokens" in text + + def test_the_validation_messages_cover_every_message_branch_and_end_with_the_hint() -> None: messages = prompt_bundle.prompt_bundle()["validation_messages"] assert isinstance(messages, dict) diff --git a/tests/unit/test_prompt_bundle_provenance.py b/tests/unit/test_prompt_bundle_provenance.py index 1fb8122..c6272e8 100644 --- a/tests/unit/test_prompt_bundle_provenance.py +++ b/tests/unit/test_prompt_bundle_provenance.py @@ -86,6 +86,7 @@ def _unit(store: Store, turn: ObservedTurn) -> TaskUnitResult: tenant=TENANT, family="anthropic", turn_runner=lambda _t, _n: turn, + repeat_index=0, ) @@ -208,7 +209,11 @@ def _arm_fields(store: Store, digest: str | None) -> dict[str, object]: def test_the_digest_is_emitted_right_after_the_answer_style_digest(store: Store) -> None: provenance = list(cast(dict[str, object], _arm_fields(store, DIGEST_A)["provenance"])) assert provenance.index("prompt_bundle_sha256") == provenance.index("answer_style_sha256") + 1 - assert list(matrix._PROVENANCE_FIELDS)[-2:] == ["answer_style_sha256", "prompt_bundle_sha256"] + assert list(matrix._PROVENANCE_FIELDS)[-3:] == [ + "answer_style_sha256", + "prompt_bundle_sha256", + "prompt_caching", + ] def test_an_archive_with_the_digest_reloads_it(store: Store) -> None: @@ -216,13 +221,13 @@ def test_an_archive_with_the_digest_reloads_it(store: Store) -> None: assert arm.provenance.prompt_bundle_sha256 == DIGEST_A -def test_an_archive_without_the_field_loads_and_renders_a_dash(store: Store) -> None: +def test_an_archive_without_the_field_is_refused(store: Store) -> None: fields = _arm_fields(store, DIGEST_A) del cast(dict[str, object], fields["provenance"])["prompt_bundle_sha256"] - arm = matrix.arm_from_report_fields(fields) - assert arm.provenance.prompt_bundle_sha256 is None - rendered = matrix.render_markdown(matrix.build_matrix_result([arm])) - assert "| prompt_bundle_sha256 | — |" in rendered + with pytest.raises( + matrix.RecordShapeRefused, match="missing required field provenance.prompt_bundle_sha256" + ): + matrix.arm_from_report_fields(fields) def test_an_archive_missing_a_required_field_is_still_refused(store: Store) -> None: @@ -237,6 +242,13 @@ def test_the_provenance_dataclass_defaults_the_digest_to_none() -> None: assert field.default is None +def test_the_prompt_caching_text_is_a_required_keyword_with_no_default() -> None: + field = {f.name: f for f in dataclasses.fields(matrix.RunProvenance)}["prompt_caching"] + assert field.kw_only is True + assert field.default is dataclasses.MISSING + assert field.default_factory is dataclasses.MISSING + + # --- one matrix, one instrument ------------------------------------------------------------------- diff --git a/tests/unit/test_provider_request_tool_schema_contract.py b/tests/unit/test_provider_request_tool_schema_contract.py index 0b2c0f4..f6ffef1 100644 --- a/tests/unit/test_provider_request_tool_schema_contract.py +++ b/tests/unit/test_provider_request_tool_schema_contract.py @@ -26,7 +26,7 @@ import httpx2 import openai import pytest -from anthropic.lib.bedrock import _auth +from anthropic.lib.aws import _auth from botocore.credentials import Credentials from agents.budget import EVAL_BUDGET diff --git a/tests/unit/test_refresh_outputs.py b/tests/unit/test_refresh_outputs.py index 9e8f7ba..aa2432c 100644 --- a/tests/unit/test_refresh_outputs.py +++ b/tests/unit/test_refresh_outputs.py @@ -38,6 +38,7 @@ def tree(tmp_path: Path) -> Path: """A copy holding the script and its stamper, with a stub terraform first on PATH.""" root = tmp_path / "repo" (root / "scripts").mkdir(parents=True) + shutil.copy2(_REPO_ROOT / "scripts" / "repo_python.sh", (root / "scripts") / "repo_python.sh") (root / "infra").mkdir() for name in ("refresh_outputs.sh", "outputs_provenance.py", "proc_run.py"): shutil.copy2(_REPO_ROOT / "scripts" / name, root / "scripts" / name) diff --git a/tests/unit/test_render_agentcore_env.py b/tests/unit/test_render_agentcore_env.py index 363f032..f7da266 100644 --- a/tests/unit/test_render_agentcore_env.py +++ b/tests/unit/test_render_agentcore_env.py @@ -13,6 +13,7 @@ import json import os import re +import shutil import signal import subprocess import sys @@ -426,6 +427,7 @@ def _run( sandbox = tmp_path / "sandbox_guard" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (scripts_dir / "deploy.sh").write_text(DEPLOY_SH.read_text(encoding="utf-8"), "utf-8") (scripts_dir / "deploy.sh").chmod(0o755) for name, src in ( @@ -624,6 +626,7 @@ def _make_precedence_sandbox(self, tmp_path: Path) -> tuple[Path, Path, Path]: sandbox = tmp_path / "sandbox" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() for name, source in (("deploy.sh", DEPLOY_SH), ("teardown.sh", TEARDOWN_SH)): @@ -740,6 +743,7 @@ def _make_sandbox(self, tmp_path: Path) -> tuple[Path, Path, Path]: sandbox = tmp_path / "sandbox" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() (scripts_dir / "deploy.sh").write_text( @@ -942,6 +946,7 @@ def test_restore_happens_when_terraform_destroy_fails_via_teardown( sandbox = tmp_path / "sandbox_teardown" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() (scripts_dir / "teardown.sh").write_text( @@ -1064,6 +1069,7 @@ def _sandbox(self, tmp_path: Path, script_name: str, terraform_body: str) -> tup sandbox = tmp_path / f"sandbox_{script_name}" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() source = DEPLOY_SH if script_name == "deploy.sh" else TEARDOWN_SH (scripts_dir / script_name).write_text(source.read_text(encoding="utf-8"), encoding="utf-8") @@ -1270,6 +1276,7 @@ def _sandbox( sandbox = tmp_path / "sandbox_relay" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() (scripts_dir / "deploy.sh").write_text( DEPLOY_SH.read_text(encoding="utf-8"), encoding="utf-8" @@ -1374,6 +1381,7 @@ def _sandbox(self, tmp_path: Path, *, parity_exit: int) -> tuple[Path, Path]: sandbox = tmp_path / "sandbox_parity" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() (scripts_dir / "deploy.sh").write_text( DEPLOY_SH.read_text(encoding="utf-8"), encoding="utf-8" @@ -1496,6 +1504,7 @@ def _sandbox(self, tmp_path: Path, plan_script: str) -> tuple[Path, Path]: sandbox = tmp_path / "sandbox_drift" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() (scripts_dir / "deploy.sh").write_text( DEPLOY_SH.read_text(encoding="utf-8"), encoding="utf-8" @@ -1703,6 +1712,7 @@ def _sandbox( sandbox = tmp_path / "sandbox_publish" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() (scripts_dir / "deploy.sh").write_text( DEPLOY_SH.read_text(encoding="utf-8"), encoding="utf-8" @@ -1940,6 +1950,7 @@ def _sandbox( sandbox = tmp_path / "sandbox_deployfix" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (scripts_dir / "deploy.sh").write_text(DEPLOY_SH.read_text(encoding="utf-8"), "utf-8") (scripts_dir / "deploy.sh").chmod(0o755) for name, src in ( diff --git a/tests/unit/test_repo_python.py b/tests/unit/test_repo_python.py new file mode 100644 index 0000000..32d8e63 --- /dev/null +++ b/tests/unit/test_repo_python.py @@ -0,0 +1,262 @@ +# SPDX-License-Identifier: MIT +"""Tests for `scripts/repo_python.sh` and the scripts that resolve repository Python through it.""" + +from __future__ import annotations + +import os +import re +import shutil +import subprocess +from pathlib import Path +from typing import Final + +import pytest +from scripts import proc_run + +_REPO_ROOT: Final[Path] = Path(__file__).resolve().parents[2] +_HELPER: Final[Path] = _REPO_ROOT / "scripts" / "repo_python.sh" +_BASH: Final[str] = shutil.which("bash") or "/bin/bash" + +#: Answers the helper's version probe with __VERSION__; otherwise records that it was executed and the +#: LC_ALL it received. +_PYTHON_SHIM: Final[str] = """#!/bin/sh +if [ "$1" = "-c" ] && case "$2" in *version_info*) true;; *) false;; esac; then + echo "__VERSION__" + exit 0 +fi +echo "shim-ran $*" +echo "lc_all=${LC_ALL-}" +""" + +#: Every caller that runs repository Python through the helper, as a path relative to the repo. +_CALLERS: Final[tuple[str, ...]] = ( + ".pre-commit-config.yaml", + "githooks/pre-commit", + "scripts/deploy.sh", + "scripts/refresh_outputs.sh", + "scripts/teardown.sh", + "scripts/verify_fixtures.sh", + "scripts/bootstrap_account.sh", + "scripts/check_cost_withheld.sh", + "scripts/package_lambdas.sh", + "scripts/preflight_adopted_vpc.sh", + "frontend/scripts/generate-types.mjs", + "frontend/src/test/responseShapes.test.ts", +) + + +def _tool_bin(tmp_path: Path) -> Path: + """A PATH directory holding only the external tools the scripts need, and no python3.""" + tools = tmp_path / "tools" + tools.mkdir() + for name in ("bash", "env", "dirname", "basename", "mktemp", "rm", "mkdir", "cat"): + found = shutil.which(name) + assert found is not None, name + (tools / name).symlink_to(found) + return tools + + +def _shim(directory: Path, version: str = "${SHIM_VERSION}") -> Path: + """A `python3` shim reporting ``version``; by default, whatever ``$SHIM_VERSION`` holds.""" + directory.mkdir(parents=True, exist_ok=True) + shim = directory / "python3" + shim.write_text(_PYTHON_SHIM.replace("__VERSION__", version), encoding="utf-8") + shim.chmod(0o755) + return shim + + +@pytest.fixture +def sandbox(tmp_path: Path) -> Path: + """A repo root holding only the helper; no virtualenv.""" + root = tmp_path / "repo" + (root / "scripts").mkdir(parents=True) + shutil.copy2(_HELPER, root / "scripts" / "repo_python.sh") + return root + + +def _run_helper( + root: Path, path: str, *args: str, version: str = "", extra_env: dict[str, str] | None = None +) -> subprocess.CompletedProcess[str]: + return proc_run.run( + [_BASH, str(root / "scripts" / "repo_python.sh"), *args], + cwd=root, + capture_output=True, + text=True, + env={"PATH": path, "HOME": str(root.parent), "SHIM_VERSION": version, **(extra_env or {})}, + check=False, + ) + + +def test_the_project_virtualenv_wins_whatever_the_ambient_python3(sandbox: Path) -> None: + venv_python = _shim(sandbox / ".venv" / "bin", version="3.14") + ambient = _shim(sandbox.parent / "ambient") + tools = _tool_bin(sandbox.parent) + result = _run_helper(sandbox, f"{ambient.parent}:{tools}", "--print", version="3.13") + assert result.returncode == 0, result.stderr + assert result.stdout.strip() == str(venv_python) + + +def test_a_stale_virtualenv_below_the_floor_is_refused_naming_both_versions(sandbox: Path) -> None: + venv_python = _shim(sandbox / ".venv" / "bin", version="3.13") + ambient = _shim(sandbox.parent / "ambient") + tools = _tool_bin(sandbox.parent) + path = f"{ambient.parent}:{tools}" + for args in (("--print",), ("scripts/x.py",)): + result = _run_helper(sandbox, path, *args, version="3.14") + assert result.returncode == 2, result.stdout + assert result.stdout == "" + assert "requires Python >= 3.14" in result.stderr + assert f"the project virtualenv {venv_python} is 3.13" in result.stderr + + +def test_an_unreadable_virtualenv_version_is_refused(sandbox: Path) -> None: + _shim(sandbox / ".venv" / "bin", version="garbage") + tools = _tool_bin(sandbox.parent) + result = _run_helper(sandbox, str(tools), "--print") + assert result.returncode == 2 + assert "unreadable version 'garbage'" in result.stderr + + +@pytest.mark.parametrize( + ("caller_env", "expected"), + [({}, "lc_all="), ({"LC_ALL": "en_US.UTF-8"}, "lc_all=en_US.UTF-8")], + ids=["unset", "set"], +) +def test_the_interpreter_runs_under_the_callers_lc_all( + sandbox: Path, caller_env: dict[str, str], expected: str +) -> None: + _shim(sandbox / ".venv" / "bin", version="3.14") + tools = _tool_bin(sandbox.parent) + result = _run_helper(sandbox, str(tools), "scripts/x.py", extra_env=caller_env) + assert result.returncode == 0, result.stderr + assert result.stdout.splitlines() == ["shim-ran scripts/x.py", expected] + + +def test_an_ambient_python3_at_the_floor_is_accepted_and_executed(sandbox: Path) -> None: + ambient = _shim(sandbox.parent / "ambient") + tools = _tool_bin(sandbox.parent) + path = f"{ambient.parent}:{tools}" + printed = _run_helper(sandbox, path, "--print", version="3.14") + assert printed.returncode == 0, printed.stderr + assert printed.stdout.strip() == str(ambient) + executed = _run_helper(sandbox, path, "scripts/x.py", "--flag", version="3.14") + assert executed.returncode == 0, executed.stderr + assert executed.stdout.splitlines()[0] == "shim-ran scripts/x.py --flag" + + +def test_a_newer_ambient_python3_is_accepted(sandbox: Path) -> None: + ambient = _shim(sandbox.parent / "ambient") + tools = _tool_bin(sandbox.parent) + result = _run_helper(sandbox, f"{ambient.parent}:{tools}", "--print", version="4.0") + assert result.returncode == 0, result.stderr + assert result.stdout.strip() == str(ambient) + + +def test_an_ambient_python3_below_the_floor_is_refused_by_name(sandbox: Path) -> None: + ambient = _shim(sandbox.parent / "ambient") + tools = _tool_bin(sandbox.parent) + result = _run_helper(sandbox, f"{ambient.parent}:{tools}", "scripts/x.py", version="3.13") + assert result.returncode == 2 + assert "shim-ran" not in result.stdout + assert "requires Python >= 3.14" in result.stderr + assert f"the ambient {ambient} is 3.13" in result.stderr + + +def test_an_unreadable_ambient_version_is_refused(sandbox: Path) -> None: + ambient = _shim(sandbox.parent / "ambient") + tools = _tool_bin(sandbox.parent) + result = _run_helper(sandbox, f"{ambient.parent}:{tools}", "--print", version="garbage") + assert result.returncode == 2 + assert "unreadable version 'garbage'" in result.stderr + + +def test_no_python3_at_all_is_refused(sandbox: Path) -> None: + tools = _tool_bin(sandbox.parent) + result = _run_helper(sandbox, str(tools), "--print") + assert result.returncode == 2 + assert "no python3 on PATH" in result.stderr + + +def test_no_arguments_is_a_usage_error(sandbox: Path) -> None: + tools = _tool_bin(sandbox.parent) + _shim(sandbox / ".venv" / "bin", version="3.14") + result = _run_helper(sandbox, str(tools)) + assert result.returncode == 2 + assert "usage" in result.stderr + + +def test_the_floor_is_the_major_minor_of_python_version() -> None: + floor = re.search(r'^readonly MIN_PYTHON="([^"]+)"$', _HELPER.read_text(), re.MULTILINE) + assert floor is not None + pinned = (_REPO_ROOT / ".python-version").read_text(encoding="utf-8").strip() + assert floor.group(1) == ".".join(pinned.split(".")[:2]) + + +@pytest.mark.parametrize("caller", _CALLERS) +def test_each_caller_resolves_repository_python_through_the_helper(caller: str) -> None: + text = (_REPO_ROOT / caller).read_text(encoding="utf-8") + assert "repo_python.sh" in text + bare = re.compile(r'(^|[\s"(;&|`])python3\s+("?\$\{?\w+\}?/|scripts/|src/|tests/|-m\s)') + offenders = [line for line in text.splitlines() if bare.search(line)] + assert offenders == [] + assert not re.search(r'(PYTHON\w*)="python3"', text) + assert ': "python3"' not in text + + +def _sandbox_with(tmp_path: Path, *names: str) -> Path: + root = tmp_path / "repo" + (root / "scripts").mkdir(parents=True) + for name in names: + shutil.copy2(_REPO_ROOT / "scripts" / name, root / "scripts" / name) + return root + + +def test_verify_fixtures_refuses_an_ambient_python3_below_the_floor(tmp_path: Path) -> None: + root = _sandbox_with(tmp_path, "verify_fixtures.sh", "repo_python.sh") + ambient = _shim(tmp_path / "ambient") + tools = _tool_bin(tmp_path) + result = proc_run.run( + [_BASH, str(root / "scripts" / "verify_fixtures.sh")], + cwd=root, + capture_output=True, + text=True, + env={"PATH": f"{ambient.parent}:{tools}", "HOME": str(tmp_path), "SHIM_VERSION": "3.13"}, + check=False, + ) + assert result.returncode != 0 + assert "shim-ran" not in result.stdout + assert "requires Python >= 3.14" in result.stderr + + +def test_refresh_outputs_refuses_before_stamping_with_an_old_ambient_python3( + tmp_path: Path, +) -> None: + root = _sandbox_with( + tmp_path, "refresh_outputs.sh", "repo_python.sh", "outputs_provenance.py", "proc_run.py" + ) + (root / "infra").mkdir() + ambient = _shim(tmp_path / "ambient") + tools = _tool_bin(tmp_path) + (tools / "mv").symlink_to(shutil.which("mv") or "/bin/mv") + terraform = tools / "terraform" + terraform.write_text('#!/bin/sh\nprintf \'{"a": {"value": 1}}\'\n', encoding="utf-8") + terraform.chmod(0o755) + result = proc_run.run( + [_BASH, str(root / "scripts" / "refresh_outputs.sh"), "--profile", "p", "--region", "r"], + cwd=root, + capture_output=True, + text=True, + env={ + "PATH": f"{ambient.parent}:{tools}", + "HOME": str(tmp_path), + "SHIM_VERSION": "3.13", + }, + check=False, + ) + assert result.returncode != 0 + assert "requires Python >= 3.14" in result.stderr + assert not (root / "results" / "tf-outputs.json").exists() + + +def test_the_helper_is_executable_in_the_tree() -> None: + assert os.access(_HELPER, os.X_OK) diff --git a/tests/unit/test_reprice.py b/tests/unit/test_reprice.py index d44bbdb..83e7d59 100644 --- a/tests/unit/test_reprice.py +++ b/tests/unit/test_reprice.py @@ -16,17 +16,21 @@ from crm.store.provisioning import create_all_tables from crm.store.store import Store from eval.harness import ArmSpec, run_sweep +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY +from eval.metrics import attribution_prompt_tokens from eval.reprice import ( ARCHIVED_PRICING_KEYS, INFERENCE_PROFILE_KEY, PRE_AGGREGATION_DIRNAME, REPRICE_RECORD_FILENAME, + UNIT_STAMPED_ENTRY_KINDS, RepriceRefused, attribution_from_entry, main, reprice_run, with_archived_pricing, ) +from eval.sweep_units import UNIT_REPEAT_INDEX_KEY, UNIT_TASK_ID_KEY _SONNET = "anthropic.claude-sonnet-5-5" _HAIKU = "anthropic.claude-haiku-5-5" @@ -97,16 +101,20 @@ def _record_in_arm_archive(sweep_dir: Path, entries: list[dict[str, Any]]) -> No "output_tokens": 0, "cache_read_tokens": 0, "cache_write_tokens": 0, + "prompt_tokens": 0, } ) rows = arm["tier_role_model_metrics"][-1:] (row,) = rows + prompt = attribution_prompt_tokens(attribution_from_entry(entry)) row["included_invocation_count"] += 1 row["input_tokens"] += entry["tokens"]["input_tokens"] row["output_tokens"] += entry["tokens"]["output_tokens"] + row["prompt_tokens"] += prompt summary = arm["tier_summary"][entry["tier"]] summary["input_tokens"] += entry["tokens"]["input_tokens"] summary["output_tokens"] += entry["tokens"]["output_tokens"] + summary["total_prompt_tokens"] += prompt path.write_text(json.dumps(arm), encoding="utf-8") @@ -131,6 +139,8 @@ def _entry(model_id: str, input_tokens: int, tier: str = "supervisor") -> dict[s "tokens": {"input_tokens": input_tokens, "output_tokens": 10}, "cache": {"read_tokens": 0, "write_tokens": 0}, "latency_ms": None, + "task_id": "gt-added", + "repeat_index": 0, } @@ -356,3 +366,191 @@ def test_an_arm_archive_without_rows_cannot_be_cross_checked( path.write_text(json.dumps(arm), encoding="utf-8") with pytest.raises(RepriceRefused, match="cannot be cross-checked"): reprice_run(sweep_dir / "raw", tmp_path / "repriced") + + +def test_a_stub_archive_records_tier_prompt_and_cache_totals(sweep_dir: Path) -> None: + arm = json.loads(_arm_archive_path(sweep_dir).read_text(encoding="utf-8")) + for tier, entry in arm["tier_summary"].items(): + for key in ("total_prompt_tokens", "cache_read_tokens", "cache_write_tokens"): + assert isinstance(entry[key], int), (tier, key) + for row in arm["tier_role_model_metrics"]: + assert isinstance(row["prompt_tokens"], int), row + + +@pytest.mark.parametrize("key", ["total_prompt_tokens", "cache_read_tokens", "cache_write_tokens"]) +def test_a_tier_summary_token_total_that_disagrees_with_the_calls_is_refused( + sweep_dir: Path, tmp_path: Path, key: str +) -> None: + path = _arm_archive_path(sweep_dir) + arm = json.loads(path.read_text(encoding="utf-8")) + arm["tier_summary"]["supervisor"][key] += 1 + path.write_text(json.dumps(arm), encoding="utf-8") + with pytest.raises(RepriceRefused, match=rf"tier_summary\['supervisor'\] {key}: archived"): + reprice_run(sweep_dir / "raw", tmp_path / "repriced") + + +def test_a_row_prompt_total_that_disagrees_with_the_calls_is_refused( + sweep_dir: Path, tmp_path: Path +) -> None: + path = _arm_archive_path(sweep_dir) + arm = json.loads(path.read_text(encoding="utf-8")) + arm["tier_role_model_metrics"][0]["prompt_tokens"] += 1 + path.write_text(json.dumps(arm), encoding="utf-8") + with pytest.raises(RepriceRefused, match="prompt_tokens: archived"): + reprice_run(sweep_dir / "raw", tmp_path / "repriced") + + +def test_per_call_cache_tokens_that_differ_from_the_tier_summary_are_refused( + sweep_dir: Path, tmp_path: Path +) -> None: + def _add_cache_read(entries: list[dict[str, Any]]) -> list[dict[str, Any]]: + first = {**entries[0], "cache": {**entries[0]["cache"]}} + first["cache"]["read_tokens"] += 7 + return [first, *entries[1:]] + + _rewrite_entries(sweep_dir, _add_cache_read) + with pytest.raises(RepriceRefused) as refused: + reprice_run(sweep_dir / "raw", tmp_path / "repriced") + assert "cache_read_tokens: archived" in str(refused.value) + + +# -- record shape and unit ids ------------------------------------------------------------------ + + +def _rewrite_payload(sweep_dir: Path, edit: Any) -> None: + path = _pre_aggregation_path(sweep_dir) + payload = json.loads(path.read_text(encoding="utf-8")) + edit(payload) + path.write_text(json.dumps(payload), encoding="utf-8") + + +def test_the_archive_names_the_record_shape_and_every_entrys_unit(sweep_dir: Path) -> None: + payload = json.loads(_pre_aggregation_path(sweep_dir).read_text(encoding="utf-8")) + assert payload[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION + for key in UNIT_STAMPED_ENTRY_KINDS: + assert payload[key], key + for entry in payload[key]: + assert isinstance(entry[UNIT_TASK_ID_KEY], str) and entry[UNIT_TASK_ID_KEY] + assert entry[UNIT_REPEAT_INDEX_KEY] == 0 + + +def test_the_unit_stamped_kinds_are_exactly_the_archives_id_carrying_lists( + sweep_dir: Path, +) -> None: + payload = json.loads(_pre_aggregation_path(sweep_dir).read_text(encoding="utf-8")) + id_carrying = { + key + for key, value in payload.items() + if isinstance(value, list) + and value + and all(isinstance(entry, dict) and UNIT_REPEAT_INDEX_KEY in entry for entry in value) + } + assert id_carrying == set(UNIT_STAMPED_ENTRY_KINDS) + + +@pytest.mark.parametrize( + "version", + [ + None, + RECORD_SHAPE_VERSION - 1, + RECORD_SHAPE_VERSION + 1, + True, + str(RECORD_SHAPE_VERSION), + float(RECORD_SHAPE_VERSION), + ], + ids=repr, +) +def test_an_archive_at_another_record_shape_is_refused( + sweep_dir: Path, tmp_path: Path, version: object +) -> None: + def _set_version(payload: dict[str, Any]) -> None: + if version is None: + del payload[RECORD_SHAPE_VERSION_KEY] + else: + payload[RECORD_SHAPE_VERSION_KEY] = version + + _rewrite_payload(sweep_dir, _set_version) + with pytest.raises(RepriceRefused, match=RECORD_SHAPE_VERSION_KEY): + reprice_run(sweep_dir / "raw", tmp_path / "out") + assert not (tmp_path / "out" / REPRICE_RECORD_FILENAME).exists() + + +def test_an_earlier_shape_archive_without_task_score_repeats_is_refused_by_its_version( + sweep_dir: Path, tmp_path: Path +) -> None: + def _as_earlier_shape(payload: dict[str, Any]) -> None: + payload[RECORD_SHAPE_VERSION_KEY] = RECORD_SHAPE_VERSION - 1 + for score in payload["task_scores"]: + del score[UNIT_REPEAT_INDEX_KEY] + + _rewrite_payload(sweep_dir, _as_earlier_shape) + with pytest.raises(RepriceRefused, match=f"{RECORD_SHAPE_VERSION_KEY} is") as refused: + reprice_run(sweep_dir / "raw", tmp_path / "out") + assert "carries no" not in str(refused.value) + assert not (tmp_path / "out" / REPRICE_RECORD_FILENAME).exists() + + +@pytest.mark.parametrize( + ("key", "value"), + [ + (UNIT_TASK_ID_KEY, None), + (UNIT_TASK_ID_KEY, ""), + (UNIT_TASK_ID_KEY, 7), + (UNIT_REPEAT_INDEX_KEY, None), + (UNIT_REPEAT_INDEX_KEY, -1), + (UNIT_REPEAT_INDEX_KEY, True), + (UNIT_REPEAT_INDEX_KEY, "0"), + ], + ids=repr, +) +@pytest.mark.parametrize("kind", UNIT_STAMPED_ENTRY_KINDS) +def test_an_entry_without_its_units_ids_is_refused( + sweep_dir: Path, tmp_path: Path, kind: str, key: str, value: object +) -> None: + def _break_last(payload: dict[str, Any]) -> None: + entries = payload[kind] + last = dict(entries[-1]) + if value is None: + del last[key] + else: + last[key] = value + payload[kind] = [*entries[:-1], last] + + _rewrite_payload(sweep_dir, _break_last) + with pytest.raises(RepriceRefused, match=rf"{kind}\[\d+\] carries no {key}"): + reprice_run(sweep_dir / "raw", tmp_path / "out") + assert not (tmp_path / "out" / REPRICE_RECORD_FILENAME).exists() + + +@pytest.mark.parametrize("kind", UNIT_STAMPED_ENTRY_KINDS) +@pytest.mark.parametrize("replacement", [None, {}, "entries"], ids=repr) +def test_an_archive_without_a_unit_stamped_list_is_refused( + sweep_dir: Path, tmp_path: Path, kind: str, replacement: object +) -> None: + def _replace(payload: dict[str, Any]) -> None: + if replacement is None: + del payload[kind] + else: + payload[kind] = replacement + + _rewrite_payload(sweep_dir, _replace) + with pytest.raises(RepriceRefused, match=kind): + reprice_run(sweep_dir / "raw", tmp_path / "out") + assert not (tmp_path / "out" / REPRICE_RECORD_FILENAME).exists() + + +@pytest.mark.parametrize("kind", UNIT_STAMPED_ENTRY_KINDS) +def test_a_non_object_entry_is_refused(sweep_dir: Path, tmp_path: Path, kind: str) -> None: + def _append_scalar(payload: dict[str, Any]) -> None: + payload[kind] = [*payload[kind], 7] + + _rewrite_payload(sweep_dir, _append_scalar) + with pytest.raises(RepriceRefused, match=rf"{kind}\[\d+\] is not an object"): + reprice_run(sweep_dir / "raw", tmp_path / "out") + assert not (tmp_path / "out" / REPRICE_RECORD_FILENAME).exists() + + +def test_the_unmutated_archive_reprices(sweep_dir: Path, tmp_path: Path) -> None: + record = reprice_run(sweep_dir / "raw", tmp_path / "out") + assert (tmp_path / "out" / REPRICE_RECORD_FILENAME).exists() + assert record["arms"] diff --git a/tests/unit/test_runs_record.py b/tests/unit/test_runs_record.py index 044c47b..d5c8a96 100644 --- a/tests/unit/test_runs_record.py +++ b/tests/unit/test_runs_record.py @@ -11,6 +11,7 @@ import json from collections.abc import Iterator from datetime import UTC, datetime, timedelta +from decimal import Decimal from pathlib import Path from typing import Any @@ -25,6 +26,7 @@ from crm.store.provisioning import create_all_tables from crm.store.store import Store from eval import runs +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY _FIXTURE = Path(__file__).resolve().parents[2] / "tests" / "fixtures" / "events" _REST_V1 = json.loads((_FIXTURE / "apigw_v1_proxy_post_get_account.json").read_text("utf-8")) @@ -38,6 +40,14 @@ def identity(rep_id: str = "rep-admin") -> Identity: return decode(event)[0] +@pytest.fixture(autouse=True) +def _fresh_earlier_format_log() -> Iterator[None]: + """Each test starts as a fresh process that has logged no earlier-format run.""" + runs._EARLIER_FORMAT_LOGGED_RUN_IDS.clear() + yield + runs._EARLIER_FORMAT_LOGGED_RUN_IDS.clear() + + @pytest.fixture def store() -> Iterator[Store]: with mock_aws(): @@ -58,6 +68,54 @@ def _create(store: Store, run_id: str = "r1", **overrides: Any) -> runs.RunRecor ) +_ARTIFACTS: dict[str, Any] = {"matrix_json": "s3://b/r1/matrix.json", "raw": []} + + +def _stored_payload( + store: Store, matrix_report: dict[str, Any], caplog: pytest.LogCaptureFixture +) -> dict[str, Any]: + """Store a completed run ``r1`` with ``matrix_report`` and artifact links; return its payload.""" + _create(store) + store.update_item( + runs.EVAL_RUNS_TABLE, + {"run_id": runs.job_row_id("r1")}, + set_values={ + "job_status": "completed", + "finished_at": NOW.isoformat(), + "tasks_done": 40, + "cost_spent_usd": Decimal("1.25"), + "matrix_report": json.dumps(matrix_report), + "artifact_links": json.dumps(_ARTIFACTS), + }, + condition=None, + ) + caplog.set_level("INFO") + return runs.require_run(store, "r1").to_payload() + + +def _store_matrix(store: Store, run_id: str, matrix_report: dict[str, Any], minute: int) -> None: + """Create a completed run ``run_id`` whose stored matrix is ``matrix_report``.""" + _create(store, run_id=run_id, now=NOW + timedelta(minutes=minute)) + store.update_item( + runs.EVAL_RUNS_TABLE, + {"run_id": runs.job_row_id(run_id)}, + set_values={"job_status": "completed", "matrix_report": json.dumps(matrix_report)}, + condition=None, + ) + + +def _format_events(caplog: pytest.LogCaptureFixture) -> list[dict[str, Any]]: + events = [] + for record in caplog.records: + try: + parsed = json.loads(record.getMessage()) + except ValueError: + continue + if isinstance(parsed, dict) and parsed.get("event") == "eval_record_format_earlier": + events.append(parsed) + return events + + class TestVocabulary: def test_the_six_statuses_and_three_terminal_ones(self) -> None: assert runs.JOB_STATUSES == ( @@ -239,5 +297,107 @@ def test_the_payload_omits_absent_fields_and_never_carries_the_execution_arn( assert not any("arn" in key for key in payload) assert "123456789012" not in json.dumps(payload) + def test_an_earlier_format_record_omits_its_results_and_says_so( + self, store: Store, caplog: pytest.LogCaptureFixture + ) -> None: + payload = _stored_payload(store, {"arms": [], "tier_comparison": {"columns": []}}, caplog) + assert payload["record_format"] == "earlier" + assert not {"matrix", "tier_comparison_table", "artifacts"} & set(payload) + assert payload["status"] == "completed" + assert payload["tasks_done"] == 40 + assert payload["cost_spent_usd"] == pytest.approx(1.25) + assert payload["finished_at"] == NOW.isoformat() + assert _format_events(caplog) == [ + {"event": "eval_record_format_earlier", "correlation_id": "r1"} + ] + + @pytest.mark.parametrize( + "version", + [1, 2, "3", 3.0, True, None], + ids=["v1", "v2", "string", "float", "bool", "null"], + ) + def test_any_record_shape_other_than_the_current_int_is_earlier( + self, store: Store, caplog: pytest.LogCaptureFixture, version: object + ) -> None: + payload = _stored_payload(store, {RECORD_SHAPE_VERSION_KEY: version, "arms": []}, caplog) + assert payload["record_format"] == "earlier" + assert "matrix" not in payload and "artifacts" not in payload + + def test_a_current_shape_record_keeps_its_results_and_no_marker( + self, store: Store, caplog: pytest.LogCaptureFixture + ) -> None: + report = {RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "arms": []} + payload = _stored_payload(store, report, caplog) + assert "record_format" not in payload + assert payload["matrix"] == report + assert payload["artifacts"] == _ARTIFACTS + assert _format_events(caplog) == [] + + def test_a_run_without_a_matrix_carries_no_marker( + self, store: Store, caplog: pytest.LogCaptureFixture + ) -> None: + caplog.set_level("INFO") + _create(store) + payload = runs.require_run(store, "r1").to_payload() + assert "record_format" not in payload + assert _format_events(caplog) == [] + + def test_an_earlier_format_run_is_still_listed( + self, store: Store, caplog: pytest.LogCaptureFixture + ) -> None: + _stored_payload(store, {"arms": []}, caplog) + _create(store, run_id="r2", now=NOW + timedelta(minutes=1)) + page, _cursor = runs.list_runs(store) + listed = {record.run_id: record.to_payload() for record in page} + assert set(listed) == {"r1", "r2"} + assert listed["r1"]["record_format"] == "earlier" + assert "record_format" not in listed["r2"] + def test_stale_queued_age_constant(self) -> None: assert timedelta(seconds=runs.STALE_QUEUED_SECONDS) == timedelta(minutes=5) + + +class TestEarlierFormatLogOncePerRun: + """``eval_record_format_earlier`` is logged once per run id per process, not per page.""" + + def _history(self, store: Store) -> None: + _store_matrix(store, "e1", {"arms": []}, minute=1) + _store_matrix(store, "e2", {RECORD_SHAPE_VERSION_KEY: 1, "arms": []}, minute=2) + _store_matrix(store, "c1", {RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION}, minute=3) + + def _page_everything(self, store: Store) -> list[dict[str, Any]]: + payloads: list[dict[str, Any]] = [] + cursor: str | None = None + while True: + page, cursor = runs.list_runs(store, cursor=cursor, limit=2) + payloads.extend(record.to_payload() for record in page) + if cursor is None: + return payloads + + def test_paging_the_history_twice_logs_one_line_per_earlier_run( + self, store: Store, caplog: pytest.LogCaptureFixture + ) -> None: + self._history(store) + _page, cursor = runs.list_runs(store, limit=2) + assert cursor is not None, "the history must span more than one page" + caplog.set_level("INFO") + first = self._page_everything(store) + second = self._page_everything(store) + assert [p["run_id"] for p in first] == [p["run_id"] for p in second] == ["c1", "e2", "e1"] + assert {p["run_id"] for p in second if p.get("record_format") == "earlier"} == {"e1", "e2"} + assert sorted(event["correlation_id"] for event in _format_events(caplog)) == ["e1", "e2"] + + def test_a_fresh_process_logs_the_earlier_run_again( + self, store: Store, caplog: pytest.LogCaptureFixture + ) -> None: + self._history(store) + caplog.set_level("INFO") + self._page_everything(store) + runs._EARLIER_FORMAT_LOGGED_RUN_IDS.clear() + self._page_everything(store) + assert sorted(event["correlation_id"] for event in _format_events(caplog)) == [ + "e1", + "e1", + "e2", + "e2", + ] diff --git a/tests/unit/test_runtime_entrypoint.py b/tests/unit/test_runtime_entrypoint.py index 949f50c..8937149 100644 --- a/tests/unit/test_runtime_entrypoint.py +++ b/tests/unit/test_runtime_entrypoint.py @@ -392,7 +392,7 @@ def test_run_turn_replays_only_events_after_resume_from_on_reconnect() -> None: store.append("sess-2", event) # Client saw only the first event (sequence 1) before the connection dropped. - replay_lines = list(run_turn(invocation, iter([]), store=store, resume_from=1)) + replay_lines = list(run_turn(invocation, iter([]), store=store, resume_from=1, resume=True)) assert len(replay_lines) == 2 kinds = [json.loads(line[len("data: ") : -2])["kind"] for line in replay_lines] assert kinds == ["tool_result", "completed"] @@ -402,6 +402,7 @@ def test_run_turn_replay_never_consumes_the_live_event_iterator() -> None: """On a pure replay, the turn's own event stream (which would re-invoke the model) is untouched.""" store = InMemorySessionStore() invocation = _fake_invocation(session_id="sess-3") + store.append("sess-3", AgentEvent(kind="usage", input_tokens=1, output_tokens=1)) store.append("sess-3", AgentEvent(kind="completed", text="done")) consumed: list[AgentEvent] = [] @@ -411,10 +412,91 @@ def _tracking_events() -> Iterator[AgentEvent]: consumed.append(event) yield event - list(run_turn(invocation, _tracking_events(), store=store, resume_from=0)) + list(run_turn(invocation, _tracking_events(), store=store, resume_from=1, resume=True)) assert consumed == [] +@pytest.mark.parametrize("resume_from", [0, -1]) +def test_run_turn_with_resume_from_zero_or_less_runs_a_fresh_turn_despite_recorded_events( + resume_from: int, +) -> None: + """A same-session follow-up sending no cursor runs the new turn instead of replaying the last.""" + store = InMemorySessionStore() + invocation = _fake_invocation(session_id="sess-follow") + first = [AgentEvent(kind="usage", input_tokens=1, output_tokens=1)] + list( + run_turn( + invocation, iter([*first, AgentEvent(kind="completed", text="first")]), store=store + ) + ) + assert store.last_sequence("sess-follow") == 2 + + lines = list( + run_turn( + invocation, + iter([AgentEvent(kind="completed", text="second")]), + store=store, + resume_from=resume_from, + ) + ) + + assert _sse_texts(lines) == ["second"] + + +def test_run_turn_with_resume_and_resume_from_zero_replays_the_whole_last_turn() -> None: + """A reconnect that applied no frame yet replays the turn instead of running it again.""" + store = InMemorySessionStore() + invocation = _fake_invocation(session_id="sess-zero") + first = [ + AgentEvent(kind="usage", input_tokens=1, output_tokens=1), + AgentEvent(kind="completed", text="first"), + ] + list(run_turn(invocation, iter(first), store=store)) + consumed: list[AgentEvent] = [] + + def _rerun() -> Iterator[AgentEvent]: + event = AgentEvent(kind="completed", text="rerun") + consumed.append(event) + yield event + + lines = list(run_turn(invocation, _rerun(), store=store, resume_from=0, resume=True)) + + assert consumed == [] + assert [json.loads(line[len("data: ") : -2])["kind"] for line in lines] == [ + "usage", + "completed", + ] + + +@pytest.mark.parametrize("resume", ["true", 1, "1", None, False]) +def test_run_turn_ignores_a_resume_value_that_is_not_true(resume: object) -> None: + """Only the boolean ``True`` marks a reconnect; any other value runs a fresh turn.""" + store = InMemorySessionStore() + invocation = _fake_invocation(session_id="sess-flag") + list(run_turn(invocation, iter([AgentEvent(kind="completed", text="first")]), store=store)) + lines = list( + run_turn( + invocation, + iter([AgentEvent(kind="completed", text="second")]), + store=store, + resume_from=0, + resume=resume, # type: ignore[arg-type] + ) + ) + assert _sse_texts(lines) == ["second"] + + +def test_run_turn_with_resume_from_omitted_runs_a_fresh_turn_despite_recorded_events() -> None: + """The default cursor is a fresh turn, never a replay of the session's previous turn.""" + store = InMemorySessionStore() + invocation = _fake_invocation(session_id="sess-default") + list(run_turn(invocation, iter([AgentEvent(kind="completed", text="first")]), store=store)) + lines = list( + run_turn(invocation, iter([AgentEvent(kind="completed", text="second")]), store=store) + ) + assert _sse_texts(lines) == ["second"] + + def test_run_turn_with_resume_from_at_or_beyond_last_sequence_runs_a_fresh_turn() -> None: """resume_from equal to (or beyond) the last recorded sequence means nothing to replay, so a genuinely new turn's events are consumed and recorded normally.""" @@ -423,7 +505,7 @@ def test_run_turn_with_resume_from_at_or_beyond_last_sequence_runs_a_fresh_turn( store.append("sess-4", AgentEvent(kind="completed", text="turn one")) new_events = iter([AgentEvent(kind="completed", text="turn two")]) - lines = list(run_turn(invocation, new_events, store=store, resume_from=1)) + lines = list(run_turn(invocation, new_events, store=store, resume_from=1, resume=True)) assert len(lines) == 1 body = json.loads(lines[0][len("data: ") : -2]) assert body["text"] == "turn two" @@ -508,7 +590,7 @@ def test_run_turn_replays_a_whole_turn_that_exactly_fills_the_bound() -> None: turn = [AgentEvent(kind="completed", text=f"e{index}") for index in range(1, 5)] list(run_turn(invocation, iter(turn), store=store, resume_from=0)) - replayed = list(run_turn(invocation, iter([]), store=store, resume_from=0)) + replayed = list(run_turn(invocation, iter([]), store=store, resume_from=0, resume=True)) assert [json.loads(line[len("data: ") : -2])["text"] for line in replayed] == [ "e1", @@ -530,7 +612,7 @@ def test_run_turn_resumes_the_latest_turn_after_earlier_turns_were_dropped() -> ) ) - replayed = list(run_turn(invocation, iter([]), store=store, resume_from=7)) + replayed = list(run_turn(invocation, iter([]), store=store, resume_from=7, resume=True)) assert [json.loads(line[len("data: ") : -2])["text"] for line in replayed] == ["t3e2", "t3e3"] @@ -565,7 +647,7 @@ def test_run_turn_resume_inside_a_later_turn_returns_every_event_after_the_curso _run_fresh_turn(store, invocation, ["t1e1", "t1e2", "t1e3"]) _run_fresh_turn(store, invocation, ["t2e1", "t2e2", "t2e3", "t2e4"]) - replayed = list(run_turn(invocation, iter([]), store=store, resume_from=4)) + replayed = list(run_turn(invocation, iter([]), store=store, resume_from=4, resume=True)) assert _sse_texts(replayed) == ["t2e2", "t2e3", "t2e4"] diff --git a/tests/unit/test_runtime_server_history_store.py b/tests/unit/test_runtime_server_history_store.py new file mode 100644 index 0000000..5737141 --- /dev/null +++ b/tests/unit/test_runtime_server_history_store.py @@ -0,0 +1,510 @@ +# SPDX-License-Identifier: MIT +"""Conversation history through the real ``/invocations`` ASGI app, and the store selection. + +- ``CONVERSATION_HISTORY_STORE`` selects the in-memory or DynamoDB store, and an unknown value fails + at import; +- a same-session follow-up with no ``resume_from`` (the Gateway chat target's shape) or with + ``resume_from=0`` runs a fresh turn that carries the earlier turn as history, while a reconnect + with ``0 < resume_from < last`` replays only the tail; +- history is recorded even when the client disconnects right after the ``completed`` frame; +- a history read or write failure is logged by kind only and never stops the turn's answer; +- the DynamoDB store carries a fact across two turns of the real app. +""" + +from __future__ import annotations + +import asyncio +import json +import logging +import sys +import time +import uuid +from collections.abc import AsyncIterator, Iterator +from pathlib import Path +from typing import Any + +import boto3 +import pytest +from moto import mock_aws +from scripts import proc_run +from starlette.testclient import TestClient + +from agents import runtime_server +from agents.cancellation import InMemoryCancellationStore +from agents.conversation_history import ( + DynamoDbConversationHistory, + HistoryTurn, + HistoryWriteConflict, + InMemoryConversationHistory, +) +from agents.events import AgentEvent +from agents.runtime_entrypoint import InMemorySessionStore, decode_invocation +from crm.authz import Identity +from crm.envelope import ( + AGENT_IDENTITY_KEY, + CLAIM_BOOK, + CLAIM_REP_ID, + CLAIM_TENANT, + identity_from_claims, +) +from crm.errors import CrmError, ServiceBusy +from crm.store.provisioning import create_all_tables +from crm.store.store import ( + BOUNDED_CONNECT_TIMEOUT_SECONDS, + BOUNDED_READ_TIMEOUT_SECONDS, + BOUNDED_TOTAL_MAX_ATTEMPTS, + Store, +) +from gateway.chat_target import runtime_payload +from providers.base import ProviderEvent, ResolvedInvocation +from providers.stub import StubProvider + +pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") + +REPO_ROOT = Path(__file__).resolve().parents[2] + +_CLAIMS: dict[str, Any] = { + CLAIM_REP_ID: "rep-ashford", + CLAIM_BOOK: "acct-0000", + CLAIM_TENANT: "demo", +} +_FACT_PROMPT = "Remember the code word ALPHA-7." +_ASK_PROMPT = "What is the code word?" + + +class _RecordingStub(StubProvider): + """A stub provider that is offered no tools and records every message list it is sent.""" + + def __init__(self) -> None: + self.requests: list[list[dict[str, object]]] = [] + + async def stream( + self, + invocation: ResolvedInvocation, + messages: list[dict[str, object]], + tools: list[dict[str, object]], + ) -> AsyncIterator[ProviderEvent]: + self.requests.append([dict(message) for message in messages]) + async for event in super().stream(invocation, messages, []): + yield event + + +@pytest.fixture +def stub() -> Iterator[_RecordingStub]: + """Fresh process-local state with a recording stub provider.""" + recording = _RecordingStub() + runtime_server._matrix = None + runtime_server._stub_provider = recording + runtime_server._session_store = InMemorySessionStore() + runtime_server._cancellation_store = InMemoryCancellationStore() + runtime_server._history_store = InMemoryConversationHistory() + yield recording + runtime_server._stub_provider = None + runtime_server._history_store = InMemoryConversationHistory() + + +def _relay_body(session: str, prompt: str, **extra: object) -> dict[str, Any]: + return { + **extra, + "prompt": prompt, + "session_id": session, + AGENT_IDENTITY_KEY: { + "claims": dict(_CLAIMS), + "principal_type": "user", + "session_id": session, + }, + } + + +def _gateway_body(session: str, prompt: str) -> dict[str, Any]: + identity = identity_from_claims(dict(_CLAIMS), source="gateway") + body = runtime_payload(message=prompt, conversation_id=session, tuning={}, identity=identity) + body.pop("tuning") + return body + + +def _frames(text: str) -> list[dict[str, Any]]: + return [json.loads(line[6:]) for line in text.splitlines() if line.startswith("data: ")] + + +def _completed_text(frames: list[dict[str, Any]]) -> str | None: + done = [frame for frame in frames if frame["kind"] == "completed"] + return done[-1]["text"] if done else None + + +def _carries_prior_turn(request: list[dict[str, object]], prompt: str, answer: str) -> bool: + users = [message.get("content") for message in request if message.get("role") == "user"] + assistants = [ + message.get("content") for message in request if message.get("role") == "assistant" + ] + return prompt in users[:-1] and answer in assistants + + +def _owner() -> Identity: + return identity_from_claims(dict(_CLAIMS), source="agent") + + +# --- store selection ------------------------------------------------------------------------- + + +@pytest.mark.parametrize("value", [None, "", "memory", " MEMORY "]) +def test_unset_or_memory_selects_the_in_memory_store( + monkeypatch: pytest.MonkeyPatch, value: str | None +) -> None: + if value is None: + monkeypatch.delenv("CONVERSATION_HISTORY_STORE", raising=False) + else: + monkeypatch.setenv("CONVERSATION_HISTORY_STORE", value) + assert isinstance(runtime_server.build_history_store(), InMemoryConversationHistory) + + +def test_dynamodb_selects_the_durable_store_on_the_prefixed_table( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setenv("CONVERSATION_HISTORY_STORE", "dynamodb") + monkeypatch.setenv("CRM_TABLE_PREFIX", "crm-unit-") + monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1") + store = runtime_server.build_history_store() + assert isinstance(store, DynamoDbConversationHistory) + assert store._store.physical_name("reps") == "crm-unit-reps" + config = store._store._client.meta.config + assert config.connect_timeout == BOUNDED_CONNECT_TIMEOUT_SECONDS == 2.0 + assert config.read_timeout == BOUNDED_READ_TIMEOUT_SECONDS == 3.0 + assert config.retries == {"mode": "standard", "total_max_attempts": BOUNDED_TOTAL_MAX_ATTEMPTS} + assert BOUNDED_TOTAL_MAX_ATTEMPTS == 2 + + +def test_an_unknown_store_value_is_refused(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("CONVERSATION_HISTORY_STORE", "redis") + with pytest.raises(RuntimeError, match="CONVERSATION_HISTORY_STORE"): + runtime_server.build_history_store() + + +def test_an_unknown_store_value_fails_the_module_import() -> None: + completed = proc_run.run( + [sys.executable, "-c", "import agents.runtime_server"], + capture_output=True, + text=True, + cwd=REPO_ROOT, + env={"CONVERSATION_HISTORY_STORE": "redis", "PATH": "/usr/bin:/bin", "HOME": "/tmp"}, + check=False, + ) + assert completed.returncode != 0 + assert "unrecognised CONVERSATION_HISTORY_STORE value: 'redis'" in completed.stderr + + +# --- follow-ups run fresh; only a real reconnect replays -------------------------------------- + + +def test_a_gateway_style_follow_up_without_resume_from_runs_with_history( + stub: _RecordingStub, +) -> None: + session = f"conv-{uuid.uuid4()}" + with TestClient(runtime_server.app) as client: + first = _frames(client.post("/invocations", json=_gateway_body(session, _FACT_PROMPT)).text) + second = _frames(client.post("/invocations", json=_gateway_body(session, _ASK_PROMPT)).text) + answer = _completed_text(first) + assert answer is not None + assert len(stub.requests) == 2 + assert _carries_prior_turn(stub.requests[-1], _FACT_PROMPT, answer) + assert second != first + + +def test_a_follow_up_with_resume_from_zero_runs_with_history(stub: _RecordingStub) -> None: + session = f"sess-{uuid.uuid4()}" + with TestClient(runtime_server.app) as client: + first = _frames( + client.post("/invocations", json=_relay_body(session, _FACT_PROMPT, resume_from=0)).text + ) + client.post("/invocations", json=_relay_body(session, _ASK_PROMPT, resume_from=0)) + answer = _completed_text(first) + assert answer is not None + assert len(stub.requests) == 2 + assert _carries_prior_turn(stub.requests[-1], _FACT_PROMPT, answer) + + +def test_a_reconnect_inside_the_last_turn_replays_only_the_tail(stub: _RecordingStub) -> None: + session = f"sess-{uuid.uuid4()}" + with TestClient(runtime_server.app) as client: + first = _frames(client.post("/invocations", json=_relay_body(session, _FACT_PROMPT)).text) + assert len(first) >= 2 + replay = _frames( + client.post( + "/invocations", json=_relay_body(session, _FACT_PROMPT, resume_from=1, resume=True) + ).text + ) + assert len(stub.requests) == 1 + assert replay == first[1:] + + +def test_a_zero_frame_reconnect_replays_the_whole_turn(stub: _RecordingStub) -> None: + session = f"sess-{uuid.uuid4()}" + with TestClient(runtime_server.app) as client: + first = _frames(client.post("/invocations", json=_relay_body(session, _FACT_PROMPT)).text) + replay = _frames( + client.post( + "/invocations", json=_relay_body(session, _FACT_PROMPT, resume_from=0, resume=True) + ).text + ) + assert len(stub.requests) == 1 + assert replay == first + + +@pytest.mark.parametrize("resume", ["true", 1, False, None]) +def test_a_resume_value_other_than_json_true_runs_a_fresh_turn( + stub: _RecordingStub, resume: object +) -> None: + session = f"sess-{uuid.uuid4()}" + with TestClient(runtime_server.app) as client: + client.post("/invocations", json=_relay_body(session, _FACT_PROMPT)) + client.post( + "/invocations", json=_relay_body(session, _ASK_PROMPT, resume_from=0, resume=resume) + ) + assert len(stub.requests) == 2 + + +# --- history is recorded before `completed` reaches the client -------------------------------- + + +def _drive_with_disconnect_after_completed(body: dict[str, Any]) -> list[bytes]: + """Run one ``/invocations`` request whose client disconnects right after ``completed``.""" + raw = json.dumps(body).encode() + + async def drive() -> list[bytes]: + sent: list[bytes] = [] + completed_sent = asyncio.Event() + requested = False + + async def receive() -> dict[str, Any]: + nonlocal requested + if not requested: + requested = True + return {"type": "http.request", "body": raw, "more_body": False} + await completed_sent.wait() + return {"type": "http.disconnect"} + + async def send(message: dict[str, Any]) -> None: + if message["type"] == "http.response.body": + chunk = message.get("body", b"") + sent.append(chunk) + if b'"kind": "completed"' in chunk: + completed_sent.set() + + scope = { + "type": "http", + "asgi": {"version": "3.0", "spec_version": "2.3"}, + "http_version": "1.1", + "method": "POST", + "scheme": "http", + "path": "/invocations", + "raw_path": b"/invocations", + "query_string": b"", + "root_path": "", + "headers": [(b"content-type", b"application/json")], + "client": ("127.0.0.1", 1), + "server": ("127.0.0.1", 8080), + } + await runtime_server.app(scope, receive, send) # type: ignore[arg-type] + return sent + + return asyncio.run(drive()) + + +def test_a_disconnect_right_after_completed_still_records_history(stub: _RecordingStub) -> None: + session = f"sess-{uuid.uuid4()}" + sent = _drive_with_disconnect_after_completed(_relay_body(session, _FACT_PROMPT)) + assert any(b'"kind": "completed"' in chunk for chunk in sent) + turns = runtime_server._history_store.history_for(session, identity=_owner()) + assert [turn.prompt for turn in turns] == [_FACT_PROMPT] + + +# --- the sync bridge closes its async generator from inside a running loop -------------------- + + +def test_closing_the_turn_bridge_inside_a_running_loop_closes_the_turn( + stub: _RecordingStub, monkeypatch: pytest.MonkeyPatch +) -> None: + closed: list[bool] = [] + + async def agent_events(*_args: Any, **_kwargs: Any) -> AsyncIterator[AgentEvent]: + try: + yield AgentEvent(kind="usage", input_tokens=1, output_tokens=1) + yield AgentEvent(kind="completed", text="done") + finally: + closed.append(True) + + monkeypatch.setattr(runtime_server, "_agent_events_for_turn", agent_events) + invocation = decode_invocation( + _relay_body("sess-close", "p"), runtime_server._capability_matrix() + ) + bridge = runtime_server._sync_agent_events( + invocation, stub, matrix=runtime_server._capability_matrix() + ) + assert next(bridge).kind == "usage" + + async def close_inside_loop() -> None: + bridge.close() # type: ignore[attr-defined] + + asyncio.run(close_inside_loop()) + assert closed == [True] + + +# --- failures are logged by kind and never stop the answer ------------------------------------ + + +class _FailingHistory(InMemoryConversationHistory): + """An in-memory store whose reads or writes raise a chosen error.""" + + def __init__(self, *, read: CrmError | None = None, write: CrmError | None = None) -> None: + super().__init__() + self._read = read + self._write = write + + def history_for(self, session_id: str, *, identity: Identity) -> tuple[HistoryTurn, ...]: + if self._read is not None: + raise self._read + return super().history_for(session_id, identity=identity) + + def record_turn(self, session_id: str, *, identity: Identity, prompt: str, answer: str) -> None: + if self._write is not None: + raise self._write + super().record_turn(session_id, identity=identity, prompt=prompt, answer=answer) + + +def _history_events(caplog: pytest.LogCaptureFixture) -> list[dict[str, Any]]: + events: list[dict[str, Any]] = [] + for record in caplog.records: + try: + parsed = json.loads(record.getMessage()) + except ValueError: + continue + if isinstance(parsed, dict) and str(parsed.get("event", "")).startswith("history_"): + events.append(parsed) + return events + + +@pytest.mark.parametrize( + ("write_error", "expected"), + [ + ( + ServiceBusy("busy", detail="d"), + {"event": "history_write_failed", "reason": "ServiceBusy"}, + ), + ( + CrmError("broken", detail="d"), + {"event": "history_write_failed", "reason": "CrmError"}, + ), + (HistoryWriteConflict("raced", detail="d"), {"event": "history_write_conflict"}), + ], +) +def test_a_failed_history_write_is_logged_by_kind_and_the_answer_is_delivered( + stub: _RecordingStub, + caplog: pytest.LogCaptureFixture, + write_error: CrmError, + expected: dict[str, str], +) -> None: + runtime_server._history_store = _FailingHistory(write=write_error) + with caplog.at_level(logging.INFO), TestClient(runtime_server.app) as client: + frames = _frames(client.post("/invocations", json=_relay_body("sess-w", _FACT_PROMPT)).text) + assert _completed_text(frames) is not None + assert not any(frame["kind"] == "error" for frame in frames) + assert _history_events(caplog) == [expected] + assert "ALPHA-7" not in caplog.text + + +def test_a_failed_history_read_is_logged_and_the_turn_runs_without_history( + stub: _RecordingStub, caplog: pytest.LogCaptureFixture +) -> None: + runtime_server._history_store = _FailingHistory(read=ServiceBusy("busy", detail="d")) + with caplog.at_level(logging.INFO), TestClient(runtime_server.app) as client: + frames = _frames(client.post("/invocations", json=_relay_body("sess-r", _ASK_PROMPT)).text) + assert _completed_text(frames) is not None + assert {"event": "history_read_failed", "reason": "ServiceBusy"} in _history_events(caplog) + assert [m.get("role") for m in stub.requests[-1]].count("assistant") == 0 + + +# --- slow history calls neither stall heartbeats nor hold `completed` past the deadline --------- + + +class _SlowHistory(InMemoryConversationHistory): + """An in-memory store whose reads and writes each sleep ``delay`` seconds first.""" + + def __init__(self, *, read_delay: float = 0.0, write_delay: float = 0.0) -> None: + super().__init__() + self._read_delay = read_delay + self._write_delay = write_delay + + def history_for(self, session_id: str, *, identity: Identity) -> tuple[HistoryTurn, ...]: + time.sleep(self._read_delay) + return super().history_for(session_id, identity=identity) + + def record_turn(self, session_id: str, *, identity: Identity, prompt: str, answer: str) -> None: + time.sleep(self._write_delay) + super().record_turn(session_id, identity=identity, prompt=prompt, answer=answer) + + +def _bridge_kinds(stub: _RecordingStub, prompt: str) -> tuple[list[str], float]: + invocation = decode_invocation( + _relay_body("sess-slow", prompt), runtime_server._capability_matrix() + ) + started = time.monotonic() + kinds: list[str] = [ + event.kind + for event in runtime_server._sync_agent_events( + invocation, stub, matrix=runtime_server._capability_matrix(), heartbeat_interval=0.05 + ) + ] + return kinds, time.monotonic() - started + + +def test_heartbeats_keep_flowing_while_the_history_write_is_slow(stub: _RecordingStub) -> None: + runtime_server._history_store = _SlowHistory(write_delay=0.4) + kinds, _ = _bridge_kinds(stub, _FACT_PROMPT) + assert kinds[-1] == "completed" + assert "heartbeat" in kinds[-4:-1] + turns = runtime_server._history_store.history_for("sess-slow", identity=_owner()) + assert [turn.prompt for turn in turns] == [_FACT_PROMPT] + + +def test_a_history_write_past_its_deadline_still_delivers_completed( + stub: _RecordingStub, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + monkeypatch.setattr(runtime_server, "HISTORY_WRITE_DEADLINE_SECONDS", 0.1) + runtime_server._history_store = _SlowHistory(write_delay=2.0) + with caplog.at_level(logging.INFO): + kinds, elapsed = _bridge_kinds(stub, _FACT_PROMPT) + assert kinds[-1] == "completed" + assert elapsed < 1.5 + assert {"event": "history_write_failed", "reason": "TimeoutError"} in _history_events(caplog) + + +def test_a_history_read_past_its_deadline_runs_the_turn_without_history( + stub: _RecordingStub, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + monkeypatch.setattr(runtime_server, "HISTORY_READ_DEADLINE_SECONDS", 0.1) + runtime_server._history_store = _SlowHistory(read_delay=2.0) + with caplog.at_level(logging.INFO): + kinds, elapsed = _bridge_kinds(stub, _ASK_PROMPT) + assert kinds[-1] == "completed" + assert elapsed < 1.5 + assert {"event": "history_read_failed", "reason": "TimeoutError"} in _history_events(caplog) + assert [m.get("role") for m in stub.requests[-1]].count("assistant") == 0 + + +# --- the durable store end to end through the app ---------------------------------------------- + + +def test_the_dynamodb_store_carries_a_fact_across_two_turns(stub: _RecordingStub) -> None: + with mock_aws(): + client = boto3.client("dynamodb", region_name="us-east-1") + create_all_tables(client) + runtime_server._history_store = DynamoDbConversationHistory(Store(client=client)) + session = f"conv-{uuid.uuid4()}" + with TestClient(runtime_server.app) as app_client: + first = _frames( + app_client.post("/invocations", json=_gateway_body(session, _FACT_PROMPT)).text + ) + app_client.post("/invocations", json=_gateway_body(session, _ASK_PROMPT)) + answer = _completed_text(first) + assert answer is not None + assert _carries_prior_turn(stub.requests[-1], _FACT_PROMPT, answer) diff --git a/tests/unit/test_scoring.py b/tests/unit/test_scoring.py index d51086a..85b37e4 100644 --- a/tests/unit/test_scoring.py +++ b/tests/unit/test_scoring.py @@ -29,6 +29,7 @@ aggregate_scores, score_task, ) +from providers.capabilities import Tier pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning") @@ -1316,3 +1317,83 @@ def test_positive_prefixes_do_not_capture_a_negative_guard_name(store: Store) -> assert guard_names, "the real corpus emits no negative guard; the check would be vacuous" for name in guard_names: assert not name.startswith(POSITIVE_ASSERTION_NAME_PREFIXES), name + + +@pytest.mark.parametrize("tier", ["supervisor", "subagent", "tool"]) +def test_an_exhausted_outcome_carries_its_tier(tier: Tier) -> None: + outcome = TurnOutcome(tenant="eval-x", budget_exhausted=True, budget_exhausted_tier=tier) + assert outcome.budget_exhausted_tier == tier + + +def test_a_completed_outcome_has_no_exhaustion_tier() -> None: + assert TurnOutcome(tenant="eval-x").budget_exhausted_tier is None + + +def test_an_exhausted_outcome_without_a_tier_is_refused() -> None: + with pytest.raises(ValueError, match="budget_exhausted_tier"): + TurnOutcome(tenant="eval-x", budget_exhausted=True) + + +def test_a_tier_on_a_completed_outcome_is_refused() -> None: + with pytest.raises(ValueError, match="budget_exhausted_tier"): + TurnOutcome(tenant="eval-x", budget_exhausted=False, budget_exhausted_tier="supervisor") + + +def _one_real_task() -> dict[str, object]: + return _real_golden_tasks()[0] + + +@pytest.mark.parametrize("tier", ["supervisor", "subagent", "tool"]) +def test_a_task_score_carries_the_outcomes_exhaustion_tier(store: Store, tier: Tier) -> None: + outcome = TurnOutcome(tenant=_TENANT, budget_exhausted=True, budget_exhausted_tier=tier) + score = score_task(store, task=_one_real_task(), outcome=outcome) + assert score.budget_exhausted_tier == tier + assert score.to_report_fields()["budget_exhausted_tier"] == tier + + +def test_a_completed_task_score_reports_a_null_exhaustion_tier(store: Store) -> None: + score = score_task(store, task=_one_real_task(), outcome=TurnOutcome(tenant=_TENANT)) + fields = score.to_report_fields() + assert "budget_exhausted_tier" in fields + assert fields["budget_exhausted_tier"] is None + + +@pytest.mark.parametrize("repeat_index", [0, 3]) +def test_a_task_score_carries_its_repeat_index(store: Store, repeat_index: int) -> None: + score = score_task( + store, + task=_one_real_task(), + outcome=TurnOutcome(tenant=_TENANT), + repeat_index=repeat_index, + ) + assert score.repeat_index == repeat_index + assert score.to_report_fields()["repeat_index"] == repeat_index + + +def _bare_score(**overrides: object) -> TaskScore: + kwargs: dict[str, object] = { + "task_id": "gt-x", + "scoring_mode": "machine", + "correctness": 1.0, + "unscored_reason": None, + "bad_write": False, + "tool_call_correct": True, + } + kwargs.update(overrides) + return TaskScore(**kwargs) # type: ignore[arg-type] + + +def test_an_exhausted_task_score_without_a_tier_is_refused() -> None: + with pytest.raises(ValueError, match="budget_exhausted_tier"): + _bare_score(budget_exhausted=True) + + +def test_a_tier_on_a_completed_task_score_is_refused() -> None: + with pytest.raises(ValueError, match="budget_exhausted_tier"): + _bare_score(budget_exhausted_tier="tool") + + +@pytest.mark.parametrize("repeat_index", [-1, True]) +def test_a_task_score_with_an_invalid_repeat_index_is_refused(repeat_index: object) -> None: + with pytest.raises(ValueError, match="repeat_index"): + _bare_score(repeat_index=repeat_index) diff --git a/tests/unit/test_sdk_credential_surface.py b/tests/unit/test_sdk_credential_surface.py index 73c943f..ac86c55 100644 --- a/tests/unit/test_sdk_credential_surface.py +++ b/tests/unit/test_sdk_credential_surface.py @@ -51,10 +51,16 @@ #: Modules on the Anthropic Bedrock client's construction, request and signing path. ``_mantle`` #: is excluded: ``AnthropicBedrockMantle`` is never constructed, and its endpoint is refused. +#: ``anthropic.lib._env`` builds the client's default headers and ``anthropic.lib.aws._auth`` +#: signs its requests; both sit outside the ``bedrock`` package. ANTHROPIC_SCAN_PACKAGES: tuple[tuple[str, frozenset[str]], ...] = ( ("anthropic.lib.bedrock", frozenset({"_mantle"})), ) -ANTHROPIC_SCAN_MODULES: tuple[str, ...] = ("anthropic._base_client",) +ANTHROPIC_SCAN_MODULES: tuple[str, ...] = ( + "anthropic._base_client", + "anthropic.lib._env", + "anthropic.lib.aws._auth", +) #: Modules on the OpenAI Bedrock client's construction, request and signing path. OPENAI_SCAN_MODULES: tuple[str, ...] = ( @@ -86,7 +92,11 @@ #: Read on every OpenAI client; it verifies inbound webhooks and never authenticates a request. OPENAI_WEBHOOK_READS = frozenset({"OPENAI_WEBHOOK_SECRET"}) -ANTHROPIC_ENV_READS = REGION_READS | {"AWS_BEARER_TOKEN_BEDROCK", "ANTHROPIC_BEDROCK_BASE_URL"} +ANTHROPIC_ENV_READS = REGION_READS | { + "AWS_BEARER_TOKEN_BEDROCK", + "ANTHROPIC_BEDROCK_BASE_URL", + "ANTHROPIC_CUSTOM_HEADERS", +} OPENAI_ENV_READS = ( REGION_READS | {"AWS_BEARER_TOKEN_BEDROCK", "AWS_BEDROCK_BASE_URL"} diff --git a/tests/unit/test_sdk_transport.py b/tests/unit/test_sdk_transport.py index 5f647d9..c42fb19 100644 --- a/tests/unit/test_sdk_transport.py +++ b/tests/unit/test_sdk_transport.py @@ -64,11 +64,16 @@ RUNTIME_HOST = f"bedrock-runtime.{REGION}.amazonaws.com" MODEL = "global.anthropic.claude-haiku-5-5" -#: The Bedrock fallback variables, written out independently of the module's own tuple. -BEDROCK_FALLBACK_ENV_VARS = ( +#: The refused SDK variables, written out independently of the module's own tuple. +REFUSED_ENV_VARS = ( "AWS_BEARER_TOKEN_BEDROCK", "AWS_BEDROCK_BASE_URL", "ANTHROPIC_BEDROCK_BASE_URL", + "ANTHROPIC_CUSTOM_HEADERS", +) +#: A header block in the ``ANTHROPIC_CUSTOM_HEADERS`` format: one ``Name: value`` per line. +_INJECTED_HEADERS = ( + "X-Probe-Injected: yes\ntraceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01" ) QUIETED_LOGGERS = ( "anthropic", @@ -113,7 +118,7 @@ def get_credentials(self) -> Credentials: def _offline_aws_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Any) -> Iterator[None]: """Pin a fake static credential chain and clear every SDK fallback variable.""" for name in ( - *BEDROCK_FALLBACK_ENV_VARS, + *REFUSED_ENV_VARS, "AWS_PROFILE", "AWS_DEFAULT_PROFILE", "AWS_SESSION_TOKEN", @@ -131,7 +136,7 @@ def _offline_aws_env(monkeypatch: pytest.MonkeyPatch, tmp_path: Any) -> Iterator @pytest.fixture def anthropic_session(monkeypatch: pytest.MonkeyPatch) -> _StaticSession: """Replace the Anthropic SDK's cached boto3 session with a counting fake.""" - from anthropic.lib.bedrock import _auth + from anthropic.lib.aws import _auth session = _StaticSession() monkeypatch.setattr(_auth, "_get_session", lambda **_: session) @@ -337,7 +342,7 @@ def _build_openai_kwargs() -> object: ) -@pytest.mark.parametrize("name", BEDROCK_FALLBACK_ENV_VARS) +@pytest.mark.parametrize("name", REFUSED_ENV_VARS) @pytest.mark.parametrize("build", [_build_anthropic_kwargs, _build_openai_kwargs]) def test_forbidden_env_var_refuses_client_build_even_when_empty( monkeypatch: pytest.MonkeyPatch, name: str, build: Callable[[], object] @@ -362,6 +367,45 @@ def test_control_anthropic_sdk_really_adopts_the_bearer_env_var( assert raised.value.source == "api_key" +def test_custom_headers_env_var_refuses_anthropic_client_so_no_header_reaches_the_wire( + monkeypatch: pytest.MonkeyPatch, anthropic_session: _StaticSession +) -> None: + monkeypatch.setenv("ANTHROPIC_CUSTOM_HEADERS", _INJECTED_HEADERS) + handler, seen = _sequence(httpx2.Response(200, json=_MESSAGE_JSON)) + with pytest.raises(CredentialPolicyError) as raised: + _anthropic(httpx2.MockTransport(handler)) + assert raised.value.source == "ANTHROPIC_CUSTOM_HEADERS" + assert seen == [] + + +def test_control_anthropic_sdk_really_sends_env_custom_headers( + monkeypatch: pytest.MonkeyPatch, anthropic_session: _StaticSession +) -> None: + handler, seen = _sequence(httpx2.Response(200, json=_MESSAGE_JSON)) + kwargs = anthropic_client_kwargs( + region=REGION, http_client=build_http_client(transport=httpx2.MockTransport(handler)) + ) + monkeypatch.setenv("ANTHROPIC_CUSTOM_HEADERS", _INJECTED_HEADERS) + client = AsyncAnthropicBedrock(**kwargs) + + async def go() -> None: + with recording_attempts(): + await _create_message(client) + + asyncio.run(go()) + assert seen[0].headers["x-probe-injected"] == "yes" + assert seen[0].headers["traceparent"].startswith("00-") + with pytest.raises(CredentialPolicyError) as raised: + assert_runtime_client(client, region=REGION) + assert raised.value.source == "default_headers" + + +def test_anthropic_client_with_only_the_transport_headers_passes_the_header_check() -> None: + client = _anthropic(httpx2.MockTransport(lambda _: httpx2.Response(200))) + assert dict(client._custom_headers) == {"Connection": "keep-alive"} + assert_runtime_client(client, region=REGION) + + def test_control_openai_sdk_really_defaults_to_bedrock_mantle() -> None: client = AsyncBedrockOpenAI(aws_region=REGION, http_client=build_http_client()) assert client.base_url.host == f"bedrock-mantle.{REGION}.api.aws" @@ -1331,7 +1375,7 @@ async def go() -> None: def test_anthropic_sdk_surfaces_an_empty_chain_as_a_bare_runtime_error( monkeypatch: pytest.MonkeyPatch, ) -> None: - from anthropic.lib.bedrock import _auth + from anthropic.lib.aws import _auth monkeypatch.setattr(_auth, "_get_session", lambda **_: _Empty()) handler, seen = _sequence(httpx2.Response(200, json=_MESSAGE_JSON)) @@ -1341,7 +1385,9 @@ async def go() -> None: with recording_attempts(): await _create_message(client) - with pytest.raises(RuntimeError, match="could not resolve credentials") as raised: + with pytest.raises( + RuntimeError, match="Could not resolve AWS credentials from session" + ) as raised: asyncio.run(go()) assert type(raised.value) is RuntimeError assert credential_policy_cause(raised.value) is None @@ -1352,7 +1398,7 @@ async def go() -> None: def test_require_credentials_refuses_an_empty_chain_before_any_request( monkeypatch: pytest.MonkeyPatch, family: str ) -> None: - from anthropic.lib.bedrock import _auth + from anthropic.lib.aws import _auth monkeypatch.setattr(_auth, "_get_session", lambda **_: _Empty()) anthropic_handler, anthropic_seen = _sequence(httpx2.Response(200, json=_MESSAGE_JSON)) diff --git a/tests/unit/test_sfn_handlers.py b/tests/unit/test_sfn_handlers.py index a59f38d..ad3bc09 100644 --- a/tests/unit/test_sfn_handlers.py +++ b/tests/unit/test_sfn_handlers.py @@ -779,14 +779,14 @@ def _schema_1_body() -> dict[str, Any]: response = sweep.runtime.client.post("/invocations", json=request) assert response.status_code == 200 body = response.json() - assert body["schema"] == 2 + assert body["schema"] == 3 body["schema"] = 1 return {"response": io.BytesIO(json.dumps(body).encode()), "statusCode": 200} sweep.runtime.fail_with = _schema_1_body with pytest.raises(CrmError, match="did not complete") as raised: sweep.task(0, refs[0]["task_id"]) - assert raised.value.detail == "malformed turn: turn.schema must be 2, got 1" + assert raised.value.detail == "malformed turn: turn.schema must be 3, got 1" def test_classification_by_status_when_no_code_is_named() -> None: @@ -1607,3 +1607,63 @@ def _unreadable(*_args: Any, **_kwargs: Any) -> bool: assert "sweep_finalize_lock_retained" in caplog.text lock = read_lock(sweep.store) assert lock is not None and lock.holder_run_id == sweep.run_id + + +def _stored_task_score(**overrides: object) -> dict[str, object]: + fields: dict[str, object] = { + "task_id": "gt-x", + "scoring_mode": "machine", + "correctness": 1.0, + "unscored_reason": None, + "bad_write": False, + "tool_call_correct": True, + "truncated": False, + "budget_exhausted": True, + "budget_exhausted_tier": "subagent", + "repeat_index": 2, + "assertion_results": [], + } + fields.update(overrides) + return fields + + +def test_a_stored_task_score_keeps_its_exhaustion_tier_and_repeat() -> None: + stored = _stored_task_score() + score = task_score_from_fields(stored) + assert (score.budget_exhausted_tier, score.repeat_index) == ("subagent", 2) + assert score.to_report_fields() == stored + + +def test_a_completed_stored_task_score_reads_a_null_tier() -> None: + score = task_score_from_fields( + _stored_task_score(budget_exhausted=False, budget_exhausted_tier=None, repeat_index=0) + ) + assert score.budget_exhausted_tier is None + + +@pytest.mark.parametrize("key", ["budget_exhausted_tier", "repeat_index"]) +def test_a_stored_task_score_missing_a_per_run_key_is_refused(key: str) -> None: + stored = _stored_task_score() + del stored[key] + with pytest.raises(ValidationFailed) as raised: + task_score_from_fields(stored) + assert raised.value.source == f"task_score.{key}" + + +@pytest.mark.parametrize( + ("overrides", "source"), + [ + ({"budget_exhausted_tier": "planner"}, "task_score.budget_exhausted_tier"), + ({"budget_exhausted_tier": None}, "task_score.budget_exhausted_tier"), + ({"budget_exhausted": False}, "task_score.budget_exhausted_tier"), + ({"repeat_index": -1}, "task_score.repeat_index"), + ({"repeat_index": True}, "task_score.repeat_index"), + ({"repeat_index": "2"}, "task_score.repeat_index"), + ], +) +def test_a_stored_task_score_with_a_bad_per_run_key_is_refused( + overrides: dict[str, object], source: str +) -> None: + with pytest.raises(ValidationFailed) as raised: + task_score_from_fields(_stored_task_score(**overrides)) + assert raised.value.source == source diff --git a/tests/unit/test_sfn_repeat_index_wiring.py b/tests/unit/test_sfn_repeat_index_wiring.py new file mode 100644 index 0000000..bad0c93 --- /dev/null +++ b/tests/unit/test_sfn_repeat_index_wiring.py @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: MIT +"""The SFN aggregate step hands `assemble_arm` each unit under the repeat its item ran in. + +`eval.sfn_handlers._aggregate` rebuilds every `done` item's unit from its stored row and must carry +the item's `TaskRef.repeat_index` onto it. A spy over `assemble_arm` records the +`(arm_index, repeat_index, task_id)` of every unit it receives over a full two-repeat stub sweep, +and that set must equal the sweep's own refs. Harness: `test_sfn_handlers`. +""" + +from __future__ import annotations + +from collections.abc import Iterator, Sequence +from typing import Any + +import pytest + +from eval import sfn_handlers +from eval.harness import DEFAULT_ARM_SPECS +from eval.runs import require_run +from eval.sweep_units import ArmRunResult, TaskUnitResult, assemble_arm +from tests.unit.test_sfn_handlers import Sweep, make_sweep, mocked_aws + +TASKS = 2 +REPEATS = 2 + + +@pytest.fixture +def sweep(monkeypatch: pytest.MonkeyPatch) -> Iterator[Sweep]: + with mocked_aws(monkeypatch): + yield make_sweep(monkeypatch, tasks=TASKS, repeats=REPEATS) + + +def _spy_on_assemble_arm(monkeypatch: pytest.MonkeyPatch) -> list[tuple[int, int, str]]: + """Wrap `assemble_arm` as `_aggregate` calls it; return the list each unit is recorded into.""" + observed: list[tuple[int, int, str]] = [] + + def spy(units: Sequence[TaskUnitResult], **kwargs: Any) -> ArmRunResult: + observed.extend((kwargs["arm_index"], unit.repeat_index, unit.task_id) for unit in units) + return assemble_arm(units, **kwargs) + + monkeypatch.setattr(sfn_handlers, "assemble_arm", spy) + return observed + + +def test_aggregate_passes_each_units_own_repeat_index_to_assemble_arm( + sweep: Sweep, monkeypatch: pytest.MonkeyPatch +) -> None: + observed = _spy_on_assemble_arm(monkeypatch) + final = sweep.drive() + assert final["status"] == "completed" + refs = sfn_handlers._sweep_refs(require_run(sweep.store, sweep.run_id)) + expected = sorted((ref.arm_index, ref.repeat_index, ref.task_id) for ref in refs) + assert sorted(observed) == expected + assert {repeat for _arm, repeat, _task in observed} == set(range(REPEATS)) + assert len(observed) == len(DEFAULT_ARM_SPECS) * REPEATS * TASKS diff --git a/tests/unit/test_sfn_tier_task_roundtrip.py b/tests/unit/test_sfn_tier_task_roundtrip.py index cc5b1dd..8a9b879 100644 --- a/tests/unit/test_sfn_tier_task_roundtrip.py +++ b/tests/unit/test_sfn_tier_task_roundtrip.py @@ -3,12 +3,14 @@ from __future__ import annotations +import dataclasses import json from collections.abc import Callable from typing import Any import pytest +from crm.errors import ValidationFailed from eval.sfn_handlers import _unit_fields, unit_from_row from eval.sweep_units import ArmSpec, TaskUnitResult from providers.capabilities import Family @@ -24,7 +26,10 @@ def _stored_rows(units: list[TaskUnitResult]) -> list[Row]: def _from_rows(rows: list[Row], family: Family) -> list[TaskUnitResult]: - return [unit_from_row(row, task=_TASK, arm_spec=ArmSpec(family=family)) for row in rows] + return [ + unit_from_row(row, task=_TASK, arm_spec=ArmSpec(family=family), repeat_index=0) + for row in rows + ] def _tier_task_metrics(units: list[TaskUnitResult], family: Family, mode: str) -> object: @@ -75,3 +80,40 @@ def test_a_field_lost_in_storage_breaks_the_equality(mutate: Callable[[Row], Row in_process = _tier_task_metrics(units, "anthropic", "live") rows = [mutate(row) for row in _stored_rows(units)] assert _tier_task_metrics(_from_rows(rows, "anthropic"), "anthropic", "live") != in_process + + +def _exhausted_at_subagent(units: list[TaskUnitResult]) -> list[TaskUnitResult]: + first, *rest = units + outcome = dataclasses.replace( + first.turn.outcome, budget_exhausted=True, budget_exhausted_tier="subagent" + ) + return [ + dataclasses.replace(first, turn=dataclasses.replace(first.turn, outcome=outcome)), + *rest, + ] + + +def test_the_exhaustion_tier_survives_storage_into_the_tier_task_metrics() -> None: + units = _exhausted_at_subagent(units_for("anthropic")) + via_rows = _tier_task_metrics(_from_rows(_stored_rows(units), "anthropic"), "anthropic", "live") + assert via_rows == _tier_task_metrics(units, "anthropic", "live") + assert isinstance(via_rows, dict) + assert via_rows["by_tier"]["subagent"]["budget_exhausted_task_count"] == 1 + + +def test_a_lost_exhaustion_tier_breaks_the_stored_row() -> None: + units = _exhausted_at_subagent(units_for("anthropic")) + row = _stored_rows(units)[0] + outcome = json.loads(row["outcome"]) + outcome["budget_exhausted_tier"] = None + with pytest.raises(ValidationFailed, match="unreadable"): + _from_rows([{**row, "outcome": json.dumps(outcome)}], "anthropic") + + +@pytest.mark.parametrize("repeat_index", [0, 3]) +def test_a_stored_unit_takes_its_repeat_from_the_ref(repeat_index: int) -> None: + (row, *_rest) = _stored_rows(units_for("anthropic")) + unit = unit_from_row( + row, task=_TASK, arm_spec=ArmSpec(family="anthropic"), repeat_index=repeat_index + ) + assert unit.repeat_index == repeat_index diff --git a/tests/unit/test_smoke_access_log_delivery.py b/tests/unit/test_smoke_access_log_delivery.py index 687d729..4f246ed 100644 --- a/tests/unit/test_smoke_access_log_delivery.py +++ b/tests/unit/test_smoke_access_log_delivery.py @@ -13,6 +13,7 @@ from typing import Any import pytest +from botocore.exceptions import ClientError from scripts.smoke.access_log_delivery import ( CHECK_DELIVERED, CHECK_TARGET, @@ -63,6 +64,13 @@ } +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _client_error(operation: str, message: str = "no") -> ClientError: + return ClientError({"Error": {"Code": "AccessDenied", "Message": message}}, operation) + + class _FakeS3: def __init__( self, @@ -186,8 +194,8 @@ def test_the_cloudfront_prefix_defers_with_its_own_reason(self) -> None: def test_a_listing_error_is_a_failure_not_an_absence_of_evidence(self) -> None: counts = _all_delivered() - counts[(_CLOUDTRAIL_ACCESS_LOGS_BUCKET, "s3-access-logs/cloudtrail/")] = RuntimeError( - "AccessDenied" + counts[(_CLOUDTRAIL_ACCESS_LOGS_BUCKET, "s3-access-logs/cloudtrail/")] = _client_error( + "ListObjectsV2" ) results, _, _ = _run(counts) failed = [r for r in results if r.status == "fail"] @@ -274,7 +282,7 @@ def test_a_source_that_logs_nowhere_fails_rather_than_deferring(self) -> None: def test_an_unreadable_source_logging_status_fails(self) -> None: targets: dict[str, tuple[str, str] | None | Exception] = dict(_SOURCE_TARGETS) - targets[_ORIGIN_BUCKET] = RuntimeError("AccessDenied") + targets[_ORIGIN_BUCKET] = _client_error("GetBucketLogging") results, _, _ = _run(_all_delivered(), targets=targets) failed = [r for r in results if r.status == "fail"] assert len(failed) == 1, results @@ -307,7 +315,9 @@ def test_a_distribution_with_logging_disabled_fails(self) -> None: assert "Logging.Enabled false" in failed[0].detail def test_an_unreadable_distribution_config_fails(self) -> None: - results, _, _ = _run(_all_delivered(), distribution_logging=RuntimeError("AccessDenied")) + results, _, _ = _run( + _all_delivered(), distribution_logging=_client_error("GetDistributionConfig") + ) failed = [r for r in results if r.status == "fail"] assert len(failed) == 1, results assert "AccessDenied" in failed[0].detail @@ -378,3 +388,24 @@ def test_the_observability_module_exports_the_access_logs_bucket_distinctly(self "aws_s3_bucket.cloudtrail_access_logs.id" ) assert declared["cloudtrail_s3_bucket_name"] == "aws_s3_bucket.cloudtrail.id" + + +class TestAwsErrorsCarryNoMessage: + @pytest.mark.parametrize("site", ["list_objects", "get_bucket_logging", "distribution_config"]) + def test_a_planted_arn_in_an_aws_error_never_reaches_a_detail(self, site: str) -> None: + error = _client_error("Operation", f"{_PLANTED_ARN} is not authorized") + counts = _all_delivered() + targets: dict[str, tuple[str, str] | None | Exception] = dict(_SOURCE_TARGETS) + distribution: dict[str, Any] | Exception | None = None + if site == "list_objects": + counts[(_CLOUDTRAIL_ACCESS_LOGS_BUCKET, "s3-access-logs/cloudtrail/")] = error + elif site == "get_bucket_logging": + targets[_ORIGIN_BUCKET] = error + else: + distribution = error + results, _, _ = _run(counts, targets=targets, distribution_logging=distribution) + failed = [r for r in results if r.status == "fail"] + assert len(failed) == 1, results + assert "AccessDenied" in failed[0].detail + assert _PLANTED_ARN not in failed[0].detail + assert all(_PLANTED_ARN not in r.detail for r in results) diff --git a/tests/unit/test_smoke_admin_authz.py b/tests/unit/test_smoke_admin_authz.py index c106865..e64cca9 100644 --- a/tests/unit/test_smoke_admin_authz.py +++ b/tests/unit/test_smoke_admin_authz.py @@ -11,6 +11,7 @@ from typing import Any import pytest +from botocore.exceptions import ClientError from scripts.smoke import admin_authz as mod from scripts.smoke.cognito_claims import ProvisionedSmokeUser from scripts.smoke.harness import CheckResult, context_for_test @@ -565,3 +566,63 @@ def simulate_principal_policy(self, **request: Any) -> dict[str, Any]: } assert mod.simulation_result(Allowing("allowed"), row, resource="r").status == "fail" + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted(operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": "AccessDenied", "Message": f"User: {_PLANTED_ARN} denied"}}, operation + ) + + +class _DeniedIam: + def simulate_principal_policy(self, **_: Any) -> dict[str, Any]: + raise _planted("SimulatePrincipalPolicy") + + +class _DeniedIdp: + def get_group(self, **_: Any) -> dict[str, Any]: + raise _planted("GetGroup") + + +class _DeniedProvisioner: + def provision(self) -> ProvisionedSmokeUser: + raise _planted("AdminCreateUser") + + def cleanup(self) -> Iterator[CheckResult]: + return iter(()) + + +class TestNoAwsErrorMessageInDetails: + """Each AWS failure row names the operation and the code, never the error message.""" + + def test_a_failed_simulation(self) -> None: + row = mod.simulation_result( + _DeniedIam(), + mod.SimulationRow( + check="c", + role_arn="arn:aws:iam::123456789012:role/r", + action="dynamodb:Query", + resource_arn="arn:aws:dynamodb:us-east-1:123456789012:table/t", + allowed=True, + ), + resource="r", + ) + assert row.status == "fail" + assert "iam:SimulatePrincipalPolicy failed (AccessDenied)" in row.detail + assert _PLANTED_ARN not in row.detail + + def test_a_failed_group_read(self) -> None: + row = mod.check_admin_group_exists(_DeniedIdp(), user_pool_id="us-east-1_x") + assert row.status == "fail" + assert "cognito-idp:GetGroup failed (AccessDenied)" in row.detail + assert _PLANTED_ARN not in row.detail + + def test_a_failed_provisioning(self) -> None: + user, row = mod.provision_or_fail(_DeniedProvisioner(), resource="r", check="c") + assert user is None + assert row.status == "fail" + assert "provision failed (AccessDenied)" in row.detail + assert _PLANTED_ARN not in row.detail diff --git a/tests/unit/test_smoke_agents.py b/tests/unit/test_smoke_agents.py index d09afec..d9696ba 100644 --- a/tests/unit/test_smoke_agents.py +++ b/tests/unit/test_smoke_agents.py @@ -7,13 +7,14 @@ from __future__ import annotations -from collections.abc import Iterable, Iterator, Mapping +from collections.abc import Iterable, Iterator, Mapping, Sequence from dataclasses import replace -from typing import Any +from typing import Any, NamedTuple import pytest import scripts.smoke.agents as agents_smoke import scripts.smoke.three_tier_chat as three_tier_chat +from botocore.exceptions import ClientError from fixtures.demo_seed import demo_account_ids from scripts.smoke.agents import ( GRID_DEFER_REASONS, @@ -29,6 +30,7 @@ from agents.registry import tool_registry_for from agents.subagents import ALL_SUBAGENT_SPECS from agents.supervisor import SUPERVISOR_ROLE +from crm.store.keys import history_key from crm.toolspec.definitions import BY_NAME _ROLES: tuple[str, ...] = tuple(spec.role for spec in ALL_SUBAGENT_SPECS) @@ -374,17 +376,46 @@ def cleanup(self) -> Iterator[CheckResult]: ) +class _FakeHistoryItems: + """In-memory `reps` history items; records every delete and when it ran.""" + + def __init__(self, log: list[str], keys: Sequence[str] = ()) -> None: + self.items: dict[str, dict[str, Any]] = {key: {"rep_id": key} for key in keys} + self.deleted: list[str] = [] + self._log = log + + def get(self, rep_id: str) -> dict[str, Any] | None: + return self.items.get(rep_id) + + def delete(self, rep_id: str) -> None: + self._log.append("delete_history") + self.deleted.append(rep_id) + self.items.pop(rep_id, None) + + +class _Orchestrated(NamedTuple): + results: list[CheckResult] + log: list[str] + turn: Any + sessions: list[str] + history: _FakeHistoryItems + + def _orchestrate( - *, fail_provision: bool = False, runner: Any = None -) -> tuple[list[CheckResult], list[str], Any]: + *, fail_provision: bool = False, runner: Any = None, history: Any = None +) -> _Orchestrated: log: list[str] = [] store = _FakeStore() provisioner = _FakeProvisioner(store, log, fail=fail_provision) turn = runner if runner is not None else _turn(*_HEALTHY) tokens: list[str] = [] + sessions: list[str] = [] + items = history if history is not None else _FakeHistoryItems(log) - def runner_factory(_ctx: Any, token: str) -> Any: + def runner_factory(_ctx: Any, token: str, session_id: str) -> Any: tokens.append(token) + sessions.append(session_id) + items.items[history_key(provisioner.tenant(), session_id)] = {"written": True} return turn results = list( @@ -392,15 +423,16 @@ def runner_factory(_ctx: Any, token: str) -> Any: object(), # type: ignore[arg-type] provisioner_factory=lambda _ctx: provisioner, # type: ignore[arg-type,return-value] runner_factory=runner_factory, + history_items=lambda _ctx: items, ) ) - return results, log + [f"token:{t}" for t in tokens], turn + return _Orchestrated(results, log + [f"token:{t}" for t in tokens], turn, sessions, items) def test_the_pass_path_runs_one_counted_turn_and_cleans_up( capsys: pytest.CaptureFixture[str], ) -> None: - results, log, turn = _orchestrate() + results, log, turn, _sessions, _history = _orchestrate() rows = _rows(results) assert set(_turn_rows()) <= set(rows) assert not [key for key, row in rows.items() if row.status == "fail"] @@ -410,13 +442,13 @@ def test_the_pass_path_runs_one_counted_turn_and_cleans_up( assert rows[("smoke_tenant", "tenant_left_clean")].status == "pass" budget = rows[("agents", "model_backed_turns_within_envelope")] assert budget.status == "pass" and "1 model-backed turn(s)" in budget.detail - assert log == ["provision", "cleanup", "token:token-1"] + assert log == ["provision", "delete_history", "cleanup", "token:token-1"] assert len(turn.prompts) == 1 assert "model-backed turn 1/1" in capsys.readouterr().err def test_the_turn_names_a_real_demo_account_the_caller_cannot_see() -> None: - _results, _log, turn = _orchestrate() + turn = _orchestrate().turn account = out_of_book_account() assert account in demo_account_ids() assert turn.prompts == [turn_prompt(account)] @@ -424,7 +456,7 @@ def test_the_turn_names_a_real_demo_account_the_caller_cannot_see() -> None: def test_a_provisioning_failure_defers_every_turn_row_and_still_cleans_up() -> None: - results, log, turn = _orchestrate(fail_provision=True) + results, log, turn, _sessions, history = _orchestrate(fail_provision=True) rows = _rows(results) assert rows[("smoke_principal", "mfa_access_token_issued")].status == "fail" for key in _turn_rows(): @@ -434,6 +466,7 @@ def test_a_provisioning_failure_defers_every_turn_row_and_still_cleans_up() -> N assert turn.prompts == [] assert log[-1] == "cleanup" assert ("agents", "writes_only_under_smoke_tenant") not in rows + assert ("agents", "history_items_deleted") not in rows and history.deleted == [] def test_a_spent_share_refuses_the_turn(monkeypatch: pytest.MonkeyPatch) -> None: @@ -442,9 +475,11 @@ def test_a_spent_share_refuses_the_turn(monkeypatch: pytest.MonkeyPatch) -> None "MODEL_TURN_ALLOTMENTS", {**three_tier_chat.MODEL_TURN_ALLOTMENTS, "agents": 0}, ) - results, log, turn = _orchestrate() + results, log, turn, sessions, history = _orchestrate() rows = _rows(results) assert turn.prompts == [] + assert sessions == [] and history.deleted == [] + assert ("agents", "history_items_deleted") not in rows assert any( r.check == "model_backed_turns_within_envelope" and r.status == "fail" for r in results ) @@ -457,10 +492,12 @@ def test_a_transport_failure_fails_the_turn_rows_and_still_cleans_up() -> None: def _explode(prompt: str) -> list[dict[str, Any]]: raise ValueError("502 from the relay") - results, log, _turn_runner = _orchestrate(runner=_explode) + results, log, _turn_runner, sessions, history = _orchestrate(runner=_explode) rows = _rows(results) assert {rows[key].status for key in _turn_rows()} == {"fail"} assert "cleanup" in log + assert history.deleted == [history_key("eval-smoke-abc", sessions[0])] + assert rows[("agents", "history_items_deleted")].status == "pass" assert rows[("agents", "demo_tenant_untouched")].status == "pass" @@ -477,7 +514,8 @@ def writing_turn(prompt: str) -> list[dict[str, Any]]: agents_smoke.checks( object(), # type: ignore[arg-type] provisioner_factory=lambda _ctx: provisioner, # type: ignore[arg-type,return-value] - runner_factory=lambda _ctx, _token: writing_turn, + runner_factory=lambda _ctx, _token, _session: writing_turn, + history_items=lambda _ctx: _FakeHistoryItems(log), ) ) assert _rows(results)[("agents", "demo_tenant_untouched")].status == "fail" @@ -524,3 +562,95 @@ def test_the_default_principal_holds_an_empty_book(monkeypatch: pytest.MonkeyPat row = rep_row_written_by(factory(ctx), monkeypatch) assert row["book"] == [] assert row["full_visibility"] is False + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted(operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, operation + ) + + +class _DeniedProvisioner(_FakeProvisioner): + def provision(self) -> str: + raise _planted("AdminCreateUser") + + +def test_a_failed_turn_names_the_aws_code_never_the_message() -> None: + def denied(prompt: str) -> list[dict[str, Any]]: + raise _planted("InvokeAgentRuntime") + + rows = relay_turn_checks(denied, prompt=_PROMPT, out_of_book_account=_OUT_OF_BOOK) + assert rows + for row in rows: + assert row.status == "fail" + assert "InvokeAgentRuntime failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail + + +def test_a_failed_provisioning_names_the_aws_code_never_the_message() -> None: + log: list[str] = [] + provisioner = _DeniedProvisioner(_FakeStore(), log) + results = list( + agents_smoke.checks( + object(), # type: ignore[arg-type] + provisioner_factory=lambda _ctx: provisioner, # type: ignore[arg-type,return-value] + runner_factory=lambda _ctx, _token, _session: _turn(*_HEALTHY), + ) + ) + row = _rows(results)[("smoke_principal", "mfa_access_token_issued")] + assert row.status == "fail" + assert "AdminCreateUser failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail + + +# -- the turn's history item --------------------------------------------------------------------- + + +def test_the_turn_history_item_is_deleted_and_proved_absent_before_cleanup() -> None: + run = _orchestrate() + (session,) = run.sessions + key = history_key("eval-smoke-abc", session) + assert session.startswith("smoke-agents-") + assert run.history.deleted == [key] + assert key not in run.history.items + row = _rows(run.results)[("agents", "history_items_deleted")] + assert row.status == "pass" and "1 history key(s) deleted, 0 still present" in row.detail + assert run.log.index("delete_history") < run.log.index("cleanup") + + +class _UndeletableHistoryItems(_FakeHistoryItems): + """A delete that succeeds but leaves the item in place.""" + + def delete(self, rep_id: str) -> None: + self._log.append("delete_history") + self.deleted.append(rep_id) + + +def test_an_item_still_present_after_the_delete_fails_the_row() -> None: + run = _orchestrate(history=_UndeletableHistoryItems([])) + row = _rows(run.results)[("agents", "history_items_deleted")] + assert row.status == "fail" and "1 still present" in row.detail + + +def test_an_unaddressable_history_table_fails_the_row_and_still_cleans_up() -> None: + log: list[str] = [] + store = _FakeStore() + provisioner = _FakeProvisioner(store, log) + + def _no_table(_ctx: Any) -> Any: + raise RuntimeError("dynamodb_table_names missing") + + results = list( + agents_smoke.checks( + object(), # type: ignore[arg-type] + provisioner_factory=lambda _ctx: provisioner, # type: ignore[arg-type,return-value] + runner_factory=lambda _ctx, _token, _session: _turn(*_HEALTHY), + history_items=_no_table, + ) + ) + row = _rows(results)[("agents", "history_items_deleted")] + assert row.status == "fail" and "could not address the history items" in row.detail + assert log[-1] == "cleanup" diff --git a/tests/unit/test_smoke_api_routes.py b/tests/unit/test_smoke_api_routes.py index d1a6538..4fc0207 100644 --- a/tests/unit/test_smoke_api_routes.py +++ b/tests/unit/test_smoke_api_routes.py @@ -1992,3 +1992,24 @@ def caller(_m: str, _u: str, headers: Mapping[str, str], _b: str) -> HttpResult: "audience_refusal_logged_with_reason", ] assert {r.check for r in rows} >= {"allowlist_parameter_value_is_spa_client"} + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def test_a_teardown_aws_failure_names_the_code_never_the_message() -> None: + from botocore.exceptions import ClientError + + from eval.tenancy import TenantTeardownError + + def _teardown(tenant: str) -> dict[str, int]: + cause = ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, + "BatchWriteItem", + ) + raise TenantTeardownError(tenant, deleted=None, cause=cause) from cause + + [row] = list(api_routes._teardown_check("eval-x", _teardown)) + assert row.status == "fail" + assert "BatchWriteItem failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail diff --git a/tests/unit/test_smoke_chat_path_iam.py b/tests/unit/test_smoke_chat_path_iam.py index a48b72f..8e4eee7 100644 --- a/tests/unit/test_smoke_chat_path_iam.py +++ b/tests/unit/test_smoke_chat_path_iam.py @@ -11,6 +11,7 @@ from typing import Any import pytest +from botocore.exceptions import ClientError from scripts.smoke import chat_path_iam as mod from scripts.smoke.harness import CheckResult, context_for_test @@ -352,3 +353,26 @@ def test_the_other_table_denies_hold_under_the_permitted_conversation_key() -> N extra = (_CT_ROLE, "dynamodb:GetItem", "table/crm-agent-eval-accounts") by_check = _run(iam=FakeIam(frozenset({extra}))) assert by_check["ct_denies_GetItem@accounts"].status == "fail" + + +def test_a_failed_policy_read_names_the_code_never_the_message() -> None: + planted_arn = "arn:aws:sts::123456789012:assumed-role/x/y" + + class _Denied: + def get_policy(self, **_: Any) -> dict[str, Any]: + raise ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {planted_arn}"}}, + "GetPolicy", + ) + + row = mod.check_resource_policy( + _Denied(), + function_name="f", + check="c", + gateway_role_arn="arn:aws:iam::123456789012:role/g", + gateway_arn="arn:aws:bedrock-agentcore:us-east-1:123456789012:gateway/g", + account_id="123456789012", + require_service_grant=False, + ) + assert row.status == "fail" + assert row.detail == "lambda:GetPolicy failed (AccessDeniedException)" diff --git a/tests/unit/test_smoke_chat_timeouts.py b/tests/unit/test_smoke_chat_timeouts.py index e6782cb..3efd9e6 100644 --- a/tests/unit/test_smoke_chat_timeouts.py +++ b/tests/unit/test_smoke_chat_timeouts.py @@ -11,6 +11,7 @@ from typing import Any import pytest +from botocore.exceptions import ClientError from scripts.smoke import chat_timeouts as module from scripts.smoke.harness import CheckResult, context_for_test @@ -211,3 +212,50 @@ def test_the_configured_values_equal_the_iac() -> None: relay_origin = cdn[cdn.index('origin_id = "agent-relay-origin"') :] read = re.search(r"origin_read_timeout\s*=\s*(\d+)", relay_origin) assert read is not None and int(read.group(1)) == module.RELAY_ORIGIN_READ_TIMEOUT_SECONDS + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +class _Denied: + """Every operation raises an `AccessDenied` whose message carries a planted caller ARN.""" + + def __getattr__(self, name: str) -> Any: + def _raise(**_: Any) -> Any: + raise ClientError( + {"Error": {"Code": "AccessDenied", "Message": f"User: {_PLANTED_ARN} denied"}}, + name, + ) + + return _raise + + +def test_aws_error_details_name_the_operation_and_code_never_the_message(zip_path: Path) -> None: + ctx = context_for_test( + outputs=_OUTPUTS, + clients={ + "lambda": _Denied(), + "cloudfront": _Denied(), + "bedrock-agentcore-control": _Denied(), + }, + ) + rows = {r.check: r for r in module.checks(ctx, agent_source_zip=zip_path)} + expected = { + "relay_timeout": "lambda:GetFunctionConfiguration failed (AccessDenied)", + "chat_target_timeout": "lambda:GetFunctionConfiguration failed (AccessDenied)", + "relay_origin_read_timeout": "cloudfront:GetDistributionConfig failed (AccessDenied)", + "runtime_image_is_the_built_one": ( + "bedrock-agentcore-control:GetAgentRuntime failed (AccessDenied)" + ), + } + for check, text in expected.items(): + assert rows[check].status == "fail" + assert text in rows[check].detail + assert _PLANTED_ARN not in rows[check].detail + + +def test_an_ecr_error_detail_names_the_code_never_the_message() -> None: + ctx = context_for_test(outputs=_OUTPUTS, clients={"ecr": _Denied()}) + row = module._ecr_row(ctx, repository="crm-agent-eval-agent", tag="sha-1") + assert row.status == "fail" + assert row.detail == "ecr:DescribeImages failed (AccessDenied)" diff --git a/tests/unit/test_smoke_cognito_claims.py b/tests/unit/test_smoke_cognito_claims.py index 8de58d1..d6c013d 100644 --- a/tests/unit/test_smoke_cognito_claims.py +++ b/tests/unit/test_smoke_cognito_claims.py @@ -1379,3 +1379,64 @@ def test_the_live_entry_point_supplies_the_logout_probe() -> None: source = inspect.getsource(cognito_claims.main) assert "logout_probe=_live_logout_probe" in source + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted_error(operation: str) -> ClientError: + return ClientError( + { + "Error": { + "Code": "AccessDeniedException", + "Message": f"{_PLANTED_ARN} is not authorized", + } + }, + operation, + ) + + +def test_a_self_signup_cleanup_aws_error_carries_its_code_but_never_its_message() -> None: + client, stubber = _idp_client() + _add_pool(stubber, _compliant_pool()) + stubber.add_client_error( + "admin_delete_user", + service_error_code="AccessDeniedException", + service_message=f"{_PLANTED_ARN} is not authorized", + expected_params={"UserPoolId": _USER_POOL_ID, "Username": ANY}, + ) + with stubber: + ctx = context_for_test(outputs=_outputs(), clients={"cognito-idp": client}) + results = list(checks(ctx, signup_client=_FakeSignUpClient())) + row = {r.check: r for r in results}["self_signup_user_deleted"] + assert row.status == "fail" + assert "failed (AccessDeniedException)" in row.detail + assert not [r for r in results if _PLANTED_ARN in r.detail] + + +def test_a_live_cleanup_aws_error_carries_its_code_but_never_its_message() -> None: + idp, stubber = _idp_client() + ctx = context_for_test(outputs=_outputs(), clients={"cognito-idp": idp}) + provisioner = LiveSmokeUserProvisioner(ctx) + provisioner._username = _PROVISIONED_REP # noqa: SLF001 - exercising cleanup in isolation + stubber.add_client_error( + "admin_delete_user", + service_error_code="AccessDeniedException", + service_message=f"{_PLANTED_ARN} is not authorized", + ) + with stubber: + results = list(provisioner._cleanup_cognito_user()) # noqa: SLF001 + assert results[0].status == "fail" + assert "failed (AccessDeniedException)" in results[0].detail + assert _PLANTED_ARN not in results[0].detail + + +def test_a_provisioning_aws_error_carries_its_code_but_never_its_message() -> None: + error = RuntimeError("provisioning failed") + error.__cause__ = _planted_error("AdminCreateUser") + provisioner = _FakeProvisioner(provision_error=error) + results = _checks_with_provisioner(provisioner, queue_revocation=False) + row = {r.check: r for r in results}["issue_and_decode"] + assert row.status == "fail" + assert "failed (AccessDeniedException)" in row.detail + assert not [r for r in results if _PLANTED_ARN in r.detail] diff --git a/tests/unit/test_smoke_deployed_parity.py b/tests/unit/test_smoke_deployed_parity.py index b3b815f..62ba910 100644 --- a/tests/unit/test_smoke_deployed_parity.py +++ b/tests/unit/test_smoke_deployed_parity.py @@ -11,13 +11,15 @@ import hashlib import io import os +import re import sys from pathlib import Path from typing import Any, Final from botocore.exceptions import ClientError, EndpointConnectionError -from scripts import proc_run -from scripts.smoke import deployed_parity +from scripts import check_lambda_zip_imports, proc_run +from scripts.smoke import deployed_parity, harness, lambda_actions +from scripts.smoke.eni_function_code_deny import PROBE_PREFIX from scripts.smoke.harness import context_for_test from scripts.smoke.lambda_actions import function_name_for @@ -27,17 +29,47 @@ class FakeLambdaClient: - """Minimal `lambda` client double returning canned configurations per function name.""" + """Minimal `lambda` client double returning canned configurations per function name. + + `list_functions` pages `functions` (two per page). When `functions` is omitted it lists every + configured function on the expected Python runtime plus the relay on its expected runtime. + """ def __init__( self, configurations: dict[str, dict[str, Any]], *, raises: dict[str, Exception] | None = None, + functions: list[dict[str, Any]] | None = None, + list_raises: Exception | None = None, ) -> None: self._configurations = configurations self._raises = raises or {} + self._functions = ( + functions + if functions is not None + else [ + *( + _listed(name, deployed_parity.expected_python_runtime()) + for name in configurations + ), + _listed(deployed_parity.RELAY_FUNCTION, deployed_parity.expected_relay_runtime()), + ] + ) + self._list_raises = list_raises self.calls: list[str] = [] + self.list_calls: list[str | None] = [] + + def list_functions(self, *, Marker: str | None = None) -> dict[str, Any]: # noqa: N803 + """Return one two-function page starting at `Marker`, with `NextMarker` when more remain.""" + self.list_calls.append(Marker) + if self._list_raises is not None: + raise self._list_raises + start = int(Marker) if Marker else 0 + page: dict[str, Any] = {"Functions": self._functions[start : start + 2]} + if start + 2 < len(self._functions): + page["NextMarker"] = str(start + 2) + return page def get_function_configuration(self, *, FunctionName: str) -> dict[str, Any]: # noqa: N803 """Return the canned configuration for `FunctionName`, or raise what the test declared.""" @@ -52,6 +84,21 @@ def get_function_configuration(self, *, FunctionName: str) -> dict[str, Any]: # return self._configurations[FunctionName] +#: An account-shaped id planted in listed ARNs; it must never reach any check's output. +_PLANTED_ACCOUNT: Final[str] = "111122223333" + + +def _listed(name: str, runtime: str | None) -> dict[str, Any]: + """A `ListFunctions` entry for `name`, its ARN carrying `_PLANTED_ACCOUNT`.""" + entry: dict[str, Any] = { + "FunctionName": name, + "FunctionArn": f"arn:aws:lambda:us-east-1:{_PLANTED_ACCOUNT}:function:{name}", + } + if runtime is not None: + entry["Runtime"] = runtime + return entry + + def _b64_sha256(data: bytes) -> str: return base64.b64encode(hashlib.sha256(data).digest()).decode("ascii") @@ -425,6 +472,289 @@ def test_non_tool_coverage_is_a_separate_identity_check(tmp_path: Path) -> None: ) +# --------------------------------------------------------------------------- +# Runtime: every discovered function's runtime, read from the account. +# --------------------------------------------------------------------------- + + +def _runtime_rows(results: list[Any]) -> dict[str, Any]: + return {r.resource: r for r in results if r.check == deployed_parity.RUNTIME_CHECK} + + +def _runtime_coverage(results: list[Any]) -> Any: + return next(r for r in results if r.check == deployed_parity.RUNTIME_COVERAGE_CHECK) + + +def _target_names(directory: Path) -> list[str]: + return [t.function_name for t in deployed_parity.parity_targets(directory)] + + +def _all_listed(directory: Path, **overrides: str | None) -> list[dict[str, Any]]: + """Every parity target on the Python runtime plus the relay on Node, then `overrides`.""" + runtimes: dict[str, str | None] = dict.fromkeys( + _target_names(directory), deployed_parity.expected_python_runtime() + ) + runtimes[deployed_parity.RELAY_FUNCTION] = deployed_parity.expected_relay_runtime() + runtimes.update(overrides) + return [_listed(name, runtime) for name, runtime in runtimes.items()] + + +def test_every_discovered_function_gets_a_passing_runtime_row(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + listed = _all_listed(tmp_path) + client = FakeLambdaClient(_configurations_matching(written), functions=listed) + results = _run_checks(client, tmp_path) + + rows = _runtime_rows(results) + assert set(rows) == {entry["FunctionName"] for entry in listed} + assert all(r.status == "pass" for r in rows.values()) + assert _runtime_coverage(results).status == "pass" + assert len(client.list_calls) > 1, "the fixture must page, so pagination is exercised" + assert [r for r in results if r.status == "fail"] == [] + + +def test_one_wrong_python_runtime_fails_and_names_the_function(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + wrong = function_name_for(ALL_TOOLS[0]) + client = FakeLambdaClient( + _configurations_matching(written), functions=_all_listed(tmp_path, **{wrong: "python3.12"}) + ) + results = _run_checks(client, tmp_path) + + failing = [r for r in results if r.status == "fail"] + assert [(r.resource, r.check) for r in failing] == [(wrong, deployed_parity.RUNTIME_CHECK)] + assert wrong in failing[0].detail and "python3.12" in failing[0].detail + assert deployed_parity.expected_python_runtime() in failing[0].detail + + +def test_a_function_reporting_no_runtime_fails(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + blank = deployed_parity.NON_TOOL_FUNCTIONS[0][0] + client = FakeLambdaClient( + _configurations_matching(written), functions=_all_listed(tmp_path, **{blank: None}) + ) + row = _runtime_rows(_run_checks(client, tmp_path))[blank] + assert row.status == "fail" + assert "" in row.detail + + +def test_a_missing_parity_target_fails_runtime_coverage_naming_it(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + absent = function_name_for(ALL_TOOLS[-1]) + listed = [e for e in _all_listed(tmp_path) if e["FunctionName"] != absent] + client = FakeLambdaClient(_configurations_matching(written), functions=listed) + results = _run_checks(client, tmp_path) + + coverage = _runtime_coverage(results) + assert coverage.status == "fail" + assert absent in coverage.detail + assert absent not in _runtime_rows(results) + + +def test_a_missing_relay_fails_runtime_coverage(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + listed = [ + e for e in _all_listed(tmp_path) if e["FunctionName"] != deployed_parity.RELAY_FUNCTION + ] + client = FakeLambdaClient(_configurations_matching(written), functions=listed) + coverage = _runtime_coverage(_run_checks(client, tmp_path)) + assert coverage.status == "fail" + assert deployed_parity.RELAY_FUNCTION in coverage.detail + + +def test_a_probe_named_function_is_ignored_whatever_its_runtime(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + probe = f"{PROBE_PREFIX}run-1234" + unrelated = "another-stack-function" + listed = [*_all_listed(tmp_path), _listed(probe, "python3.9"), _listed(unrelated, "java21")] + client = FakeLambdaClient(_configurations_matching(written), functions=listed) + results = _run_checks(client, tmp_path) + + rows = _runtime_rows(results) + assert probe.startswith(lambda_actions.FUNCTION_NAME_PREFIX), "control: the prefix matches" + assert probe not in rows and unrelated not in rows + assert [r for r in results if r.status == "fail"] == [] + + +def test_the_relay_is_checked_against_nodejs_not_python(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + relay = deployed_parity.RELAY_FUNCTION + client = FakeLambdaClient( + _configurations_matching(written), + functions=_all_listed(tmp_path, **{relay: deployed_parity.expected_python_runtime()}), + ) + row = _runtime_rows(_run_checks(client, tmp_path))[relay] + assert row.status == "fail" + assert deployed_parity.expected_relay_runtime() in row.detail + + +def test_a_relay_on_an_older_nodejs_fails(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + relay = deployed_parity.RELAY_FUNCTION + client = FakeLambdaClient( + _configurations_matching(written), functions=_all_listed(tmp_path, **{relay: "nodejs20.x"}) + ) + row = _runtime_rows(_run_checks(client, tmp_path))[relay] + assert row.status == "fail" + assert "nodejs20.x" in row.detail + + +def test_an_unreadable_relay_default_fails_the_relay_row(tmp_path: Path, monkeypatch: Any) -> None: + written = _write_all_zips(tmp_path) + variables_tf = tmp_path / "variables.tf" + variables_tf.write_text('variable "runtime" {\n default = "python3.14"\n}\n') + listed = _all_listed(tmp_path) + monkeypatch.setattr(deployed_parity, "RELAY_VARIABLES_TF", variables_tf) + client = FakeLambdaClient(_configurations_matching(written), functions=listed) + row = _runtime_rows(_run_checks(client, tmp_path))[deployed_parity.RELAY_FUNCTION] + assert row.status == "fail" + assert "expected runtime is unknown" in row.detail + + +def test_a_list_functions_error_fails_runtime_coverage(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + denied = ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": "denied"}}, "ListFunctions" + ) + client = FakeLambdaClient(_configurations_matching(written), list_raises=denied) + results = _run_checks(client, tmp_path) + assert _runtime_rows(results) == {} + coverage = _runtime_coverage(results) + assert coverage.status == "fail" + assert "AccessDeniedException" in coverage.detail + + +def test_no_account_id_reaches_any_check_output(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + client = FakeLambdaClient( + _configurations_matching(written), + functions=_all_listed(tmp_path, **{function_name_for(ALL_TOOLS[0]): "python3.12"}), + ) + results = _run_checks(client, tmp_path) + assert _runtime_rows(results), "control: runtime rows were emitted" + for result in results: + assert _PLANTED_ACCOUNT not in f"{result.resource} {result.detail}" + + +def test_expected_python_runtime_is_target_python_version() -> None: + major, minor = check_lambda_zip_imports.TARGET_PYTHON_VERSION + assert deployed_parity.expected_python_runtime() == f"python{major}.{minor}" + + +def test_expected_relay_runtime_is_the_agent_relay_terraform_default() -> None: + text = (REPO_ROOT / "infra" / "modules" / "agent_relay" / "variables.tf").read_text( + encoding="utf-8" + ) + match = re.search(r'(?ms)^variable\s+"runtime"\s*\{.*?default\s*=\s*"(nodejs\d+\.x)"', text) + assert match is not None + assert deployed_parity.expected_relay_runtime() == match.group(1) + + +def test_relay_function_name_is_the_one_infra_main_tf_declares() -> None: + main_tf = (REPO_ROOT / "infra" / "main.tf").read_text(encoding="utf-8") + prefix = re.search(r'(?m)^\s*name_prefix\s*=\s*"([^"]+)"', main_tf) + block = re.search(r'(?ms)^module\s+"agent_relay"\s*\{(.*?)^\}', main_tf) + assert prefix is not None and block is not None + declared = re.search(r'(?m)^\s*function_name\s*=\s*"([^"]+)"', block.group(1)) + assert declared is not None + resolved = declared.group(1).replace("${local.name_prefix}", prefix.group(1)) + assert "${" not in resolved, f"unresolved interpolation in {declared.group(1)!r}" + assert resolved == deployed_parity.RELAY_FUNCTION + + +def test_deploy_gate_emits_no_runtime_rows_and_never_lists_functions(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + client = FakeLambdaClient( + _configurations_matching(written), + functions=_all_listed(tmp_path, **{function_name_for(ALL_TOOLS[0]): "python3.12"}), + ) + exit_code, results = deployed_parity.deploy_gate( + client, directory=tmp_path, stream=io.StringIO() + ) + assert exit_code == 0 + assert client.list_calls == [] + assert {r.check for r in results}.isdisjoint( + {deployed_parity.RUNTIME_CHECK, deployed_parity.RUNTIME_COVERAGE_CHECK} + ) + + +# --------------------------------------------------------------------------- +# AWS error details carry the error code, never the message or an ARN. +# --------------------------------------------------------------------------- + +_CALLER_ARN: Final[str] = f"arn:aws:sts::{_PLANTED_ACCOUNT}:assumed-role/x/y" + + +def _denied(operation: str) -> ClientError: + return ClientError( + { + "Error": { + "Code": "AccessDeniedException", + "Message": f"User: {_CALLER_ARN} is not authorized to perform: lambda:{operation}", + } + }, + operation, + ) + + +def _assert_no_caller_identity(results: list[Any]) -> None: + for result in results: + assert _PLANTED_ACCOUNT not in result.detail, result + assert "arn:" not in result.detail, result + + +def test_a_denied_get_function_configuration_reports_only_the_error_code(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + tool = ALL_TOOLS[1] + client = FakeLambdaClient( + _configurations_matching(written), + raises={function_name_for(tool): _denied("GetFunctionConfiguration")}, + ) + results = _run_checks(client, tmp_path) + verdict = next( + r for r in results if r.resource == tool.name and r.check == deployed_parity.PARITY_CHECK + ) + assert verdict.status == "fail" + assert "AccessDeniedException" in verdict.detail + assert "lambda:GetFunctionConfiguration" in verdict.detail + _assert_no_caller_identity(results) + + +def test_a_denied_list_functions_reports_only_the_error_code(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + client = FakeLambdaClient( + _configurations_matching(written), list_raises=_denied("ListFunctions") + ) + results = _run_checks(client, tmp_path) + coverage = _runtime_coverage(results) + assert coverage.status == "fail" + assert "AccessDeniedException" in coverage.detail + assert "lambda:ListFunctions" in coverage.detail + _assert_no_caller_identity(results) + + +def test_a_response_without_code_sha256_never_echoes_its_arns(tmp_path: Path) -> None: + written = _write_all_zips(tmp_path) + configurations = _configurations_matching(written) + tool = ALL_TOOLS[2] + entry = configurations[function_name_for(tool)] + entry.pop("CodeSha256") + entry["FunctionArn"] = f"arn:aws:lambda:us-east-1:{_PLANTED_ACCOUNT}:function:x" + entry["Role"] = f"arn:aws:iam::{_PLANTED_ACCOUNT}:role/x" + results = _run_checks(FakeLambdaClient(configurations), tmp_path) + verdict = next( + r for r in results if r.resource == tool.name and r.check == deployed_parity.PARITY_CHECK + ) + assert verdict.status == "fail" + assert "no CodeSha256" in verdict.detail and "FunctionArn" in verdict.detail + _assert_no_caller_identity(results) + + +def test_aws_error_code_is_the_shared_harness_helper() -> None: + """`deployed_parity` reads error codes through `harness.aws_error_code`, holding no copy.""" + assert vars(deployed_parity)["aws_error_code"] is harness.aws_error_code + + # --------------------------------------------------------------------------- # The deploy.sh post-apply gate. # --------------------------------------------------------------------------- diff --git a/tests/unit/test_smoke_dynamodb_principal_deny.py b/tests/unit/test_smoke_dynamodb_principal_deny.py index 1c122c5..234099f 100644 --- a/tests/unit/test_smoke_dynamodb_principal_deny.py +++ b/tests/unit/test_smoke_dynamodb_principal_deny.py @@ -6,7 +6,7 @@ import io import json import zipfile -from collections.abc import Callable, Iterator +from collections.abc import Callable, Iterator, Sequence from datetime import UTC, datetime from typing import Any @@ -31,11 +31,17 @@ _CMK_ARN = f"arn:aws:kms:{_REGION}:{_ACCOUNT}:key/11111111-1111-1111-1111-111111111111" _DATA_ROLE_ARN = f"arn:aws:iam::{_ACCOUNT}:role/crm-agent-eval-accounts-get-role" _RELAY_ROLE_ARN = f"arn:aws:iam::{_ACCOUNT}:role/crm-agent-eval-agent-relay-role" +_RUNTIME_ROLE_ARN = f"arn:aws:iam::{_ACCOUNT}:role/crm-agent-eval-runtime-role" +_RUNTIME_ID = "crm_agent_eval_runtime-abc123" +_RUNTIME_ARN = f"arn:aws:bedrock-agentcore:{_REGION}:{_ACCOUNT}:runtime/{_RUNTIME_ID}" _TABLES = {name: f"crm-agent-eval-{name}" for name in sorted(TABLE_NAMES)} _OUTPUTS: dict[str, Any] = { "dynamodb_table_names": _TABLES, "crm_operator_principal_arns": [_OPERATOR_ARN], + "agentcore_runtime_arn": _RUNTIME_ARN, } +#: The data-plane allowlist the deployed policies carry: discovered roles plus the operator. +_DATA_PLANE = [_DATA_ROLE_ARN, _RUNTIME_ROLE_ARN, _OPERATOR_ARN] #: The action tables, literal here so a drift in the module constants reds. _DESIGN_TABLE_DATA_PLANE = [ @@ -90,7 +96,7 @@ def _table_arn(physical: str) -> str: def _table_policy(physical: str, **overrides: Any) -> dict[str, Any]: arn = _table_arn(physical) - data_plane = overrides.pop("data_plane", [_DATA_ROLE_ARN, _OPERATOR_ARN]) + data_plane = overrides.pop("data_plane", list(_DATA_PLANE)) return { "Version": "2012-10-17", "Statement": [ @@ -133,7 +139,7 @@ def _key_policy() -> dict[str, Any]: "Action": list(_DESIGN_KEY_USE), "Resource": "*", "Condition": { - "ArnNotEquals": {"aws:PrincipalArn": [_DATA_ROLE_ARN, _OPERATOR_ARN]}, + "ArnNotEquals": {"aws:PrincipalArn": list(_DATA_PLANE)}, "Bool": {"aws:PrincipalIsAWSService": "false"}, }, }, @@ -208,7 +214,10 @@ class Scenario: """Queues every operator and probe response `run_checks` consumes, in its call order.""" def __init__(self) -> None: - self.clients = {s: _client(s) for s in ("sts", "iam", "lambda", "dynamodb", "kms")} + self.clients = { + s: _client(s) + for s in ("sts", "iam", "lambda", "dynamodb", "kms", "bedrock-agentcore-control") + } self.stubs = {s: Stubber(c) for s, c in self.clients.items()} self.probe_clients = {s: _client(s) for s in ("dynamodb", "kms")} self.probe_stubs = {s: Stubber(c) for s, c in self.probe_clients.items()} @@ -224,8 +233,12 @@ def __init__(self) -> None: self.assume_denials = 0 self.create_role_error: str | None = None self.delete_role_error: str | None = None + self.iam_error_message: str | None = None + self.policy_error_message = "Resource-based policy not found" self.fetch_policies = True self.probe_params: dict[str, dict[str, Any]] = {} + self.runtime_role_arn: str | None = _RUNTIME_ROLE_ARN + self.runtime_error: str | None = None def _queue_identity(self) -> None: self.stubs["sts"].add_response( @@ -293,6 +306,32 @@ def _queue_discovery(self) -> None: {"RoleName": "crm-agent-eval-agent-relay-role"}, ) + def _queue_runtime(self, outputs: dict[str, Any]) -> None: + if not str(outputs.get("agentcore_runtime_arn", "")).count("/"): + return + stub = self.stubs["bedrock-agentcore-control"] + if self.runtime_error: + stub.add_client_error( + "get_agent_runtime", + service_error_code=self.runtime_error, + service_message="refused", + http_status_code=403, + ) + return + response: dict[str, Any] = { + "agentRuntimeArn": _RUNTIME_ARN, + "agentRuntimeName": "crm_agent_eval_runtime", + "agentRuntimeId": _RUNTIME_ID, + "agentRuntimeVersion": "1", + "createdAt": datetime(2026, 10, 20, tzinfo=UTC), + "lastUpdatedAt": datetime(2026, 10, 20, tzinfo=UTC), + "networkConfiguration": {"networkMode": "VPC"}, + "status": "READY", + "lifecycleConfiguration": {}, + "roleArn": self.runtime_role_arn or "not-a-role-arn", + } + stub.add_response("get_agent_runtime", response, {"agentRuntimeId": _RUNTIME_ID}) + def _queue_policies(self) -> None: if not self.fetch_policies: return @@ -302,7 +341,7 @@ def _queue_policies(self) -> None: self.stubs["dynamodb"].add_client_error( "get_resource_policy", service_error_code="PolicyNotFoundException", - service_message="Resource-based policy not found", + service_message=self.policy_error_message, http_status_code=400, ) continue @@ -334,7 +373,7 @@ def _queue_probe_setup(self) -> None: iam.add_client_error( "create_role", service_error_code=self.create_role_error, - service_message="refused", + service_message=self.iam_error_message or "refused", http_status_code=400, ) return @@ -431,7 +470,8 @@ def _queue_teardown(self) -> None: iam.add_client_error( "delete_role", service_error_code=self.delete_role_error, - service_message="Cannot delete entity, must remove roles from instance profile", + service_message=self.iam_error_message + or "Cannot delete entity, must remove roles from instance profile", http_status_code=409, ) return @@ -454,6 +494,7 @@ def run(self, outputs: dict[str, Any] | None = None) -> list[CheckResult]: self._queue_identity() self._queue_tables() self._queue_discovery() + self._queue_runtime(outputs or _OUTPUTS) self._queue_policies() self._queue_operator_get_item() self._queue_probe_setup() @@ -668,18 +709,63 @@ def test_an_explicit_deny_naming_another_principal_fails() -> None: ("ValidationException", "1 validation error detected"), ], ) -def test_any_other_error_defers_with_its_message(code: str, message: str) -> None: +def test_any_other_error_defers_with_its_code_and_not_its_message(code: str, message: str) -> None: scenario = Scenario() scenario.outcomes[smoke.PROBE_QUERY_GSI] = (code, message) row = _by_check(scenario.run())[f"probe_denied:{smoke.PROBE_QUERY_GSI}"] assert row.status == "defer" assert row.defer_reason == "probe_call_unclassified_error" - assert message in row.detail + assert code in row.detail + assert message not in row.detail -def test_the_pass_detail_quotes_the_denial() -> None: +def test_the_pass_detail_names_the_code_and_the_probe_role_but_not_the_denial_text() -> None: row = _by_check(Scenario().run())[f"probe_denied:{smoke.PROBE_GET_ITEM}"] - assert row.detail.startswith("AccessDeniedException: User: ") + assert row.detail.startswith( + "AccessDeniedException: an explicit deny in a resource-based policy" + ) + assert _PROBE_ROLE in row.detail + assert "User: " not in row.detail + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _assert_no_planted_arn(rows: Sequence[CheckResult]) -> None: + assert not any(_PLANTED_ARN in r.detail for r in rows), rows + assert not any(f"arn:aws:sts::{_ACCOUNT}:" in r.detail for r in rows), rows + + +def test_no_probe_row_carries_the_denial_message_or_its_principal_arn() -> None: + scenario = Scenario() + scenario.outcomes[smoke.PROBE_QUERY_GSI] = ("ThrottlingException", f"{_PLANTED_ARN} throttled") + scenario.outcomes[smoke.PROBE_PUT_ITEM] = ( + "AccessDeniedException", + _explicit_deny("dynamodb:PutItem", "x", principal="SomeoneElse"), + ) + scenario.outcomes[smoke.PROBE_GENERATE_DATA_KEY] = ( + "AccessDeniedException", + _implicit_deny("kms:GenerateDataKey", "x"), + ) + rows = scenario.run() + assert {r.status for r in rows if r.check.startswith("probe_denied:")} == { + "pass", + "fail", + "defer", + } + _assert_no_planted_arn(rows) + + +def test_an_operator_get_item_error_carries_its_code_but_never_its_message() -> None: + scenario = Scenario() + scenario.operator_get_item_error = ( + "AccessDeniedException", + f"{_PLANTED_ARN} is not authorized", + ) + rows = scenario.run() + failed = [r for r in rows if r.check == "operator_data_plane_admitted" and r.status == "fail"] + assert failed and all("AccessDeniedException" in r.detail for r in failed) + _assert_no_planted_arn(rows) # --------------------------------------------------------------------------- @@ -763,10 +849,10 @@ def _second(policy: dict[str, Any]) -> dict[str, Any]: "missing_action": lambda p: _first(p)["Action"].remove("dynamodb:Scan"), "extra_action": lambda p: _second(p)["Action"].append("dynamodb:DescribeTable"), "if_exists": lambda p: _first(p).update( - Condition={"ArnNotEqualsIfExists": {"aws:PrincipalArn": [_DATA_ROLE_ARN, _OPERATOR_ARN]}} + Condition={"ArnNotEqualsIfExists": {"aws:PrincipalArn": list(_DATA_PLANE)}} ), "string_not_equals": lambda p: _first(p).update( - Condition={"StringNotEquals": {"aws:PrincipalArn": [_DATA_ROLE_ARN, _OPERATOR_ARN]}} + Condition={"StringNotEquals": {"aws:PrincipalArn": list(_DATA_PLANE)}} ), "extra_via_aws_service": lambda p: _first(p)["Condition"].update( Bool={"aws:ViaAWSService": "false"} @@ -891,6 +977,70 @@ def test_discovery_keeps_only_project_roles_holding_the_dynamodb_kms_policy() -> assert row.detail.startswith("1 execution role") +def _shape_rows() -> set[str]: + return {f"table_policy_shape:{physical}" for physical in _TABLES.values()} | { + "key_policy_shape" + } + + +def test_the_runtime_role_is_discovered_from_get_agent_runtime() -> None: + rows = Scenario().run() + row = _by_check(rows)["runtime_role_discovered"] + assert row.status == "pass" + assert _RUNTIME_ROLE_ARN in row.detail + assert not [r.check for r in rows if r.status == "fail"] + + +@pytest.mark.parametrize( + ("case", "configure", "outputs"), + [ + ( + "output_absent", + lambda _s: None, + {k: v for k, v in _OUTPUTS.items() if k != "agentcore_runtime_arn"}, + ), + ("describe_refused", lambda s: setattr(s, "runtime_error", "AccessDeniedException"), None), + ("no_role_arn", lambda s: setattr(s, "runtime_role_arn", None), None), + ], +) +def test_a_runtime_role_in_the_policies_but_not_discovered_reds_every_shape_row( + case: str, configure: Callable[[Scenario], None], outputs: dict[str, Any] | None +) -> None: + scenario = Scenario() + configure(scenario) + rows = scenario.run(outputs=outputs) + failing = {r.check for r in rows if r.status == "fail"} + assert failing == _shape_rows() | {"runtime_role_discovered"}, (case, failing) + + +def test_a_discovered_runtime_role_missing_from_the_policies_reds_every_shape_row() -> None: + scenario = Scenario() + without_runtime = [_DATA_ROLE_ARN, _OPERATOR_ARN] + scenario.table_policies = { + logical: _table_policy(physical, data_plane=list(without_runtime)) + for logical, physical in _TABLES.items() + } + _first_key_use(scenario.key_policy)["Condition"]["ArnNotEquals"]["aws:PrincipalArn"] = list( + without_runtime + ) + failing = {r.check for r in scenario.run() if r.status == "fail"} + assert failing == _shape_rows(), failing + + +def test_a_different_runtime_role_reds_every_shape_row() -> None: + scenario = Scenario() + scenario.runtime_role_arn = f"arn:aws:iam::{_ACCOUNT}:role/some-other-runtime-role" + failing = {r.check for r in scenario.run() if r.status == "fail"} + assert failing == _shape_rows(), failing + + +def _first_key_use(policy: dict[str, Any]) -> dict[str, Any]: + statement: dict[str, Any] = next( + s for s in policy["Statement"] if s["Sid"] == "DenyKeyUseToNonProjectPrincipals" + ) + return statement + + # --------------------------------------------------------------------------- # Operator path, probe setup and teardown. # --------------------------------------------------------------------------- @@ -952,13 +1102,14 @@ def test_a_non_role_non_user_caller_is_refused() -> None: {"UserId": "x", "Account": _ACCOUNT, "Arn": f"arn:aws:iam::{_ACCOUNT}:root"}, ) stub.activate() - with pytest.raises(ValueError, match="neither an assumed role nor an IAM user"): + with pytest.raises(ValueError, match="neither an assumed role nor an IAM user") as raised: smoke.caller_identity(context_for_test(clients={"sts": sts})) + assert _ACCOUNT not in str(raised.value) def test_the_expected_check_count_is_derived_from_the_table_output() -> None: expected = smoke.expected_check_count(context_for_test(outputs=_OUTPUTS)) - assert expected.minimum == 2 * len(_TABLES) + 4 + 5 + assert expected.minimum == 2 * len(_TABLES) + 5 + 5 # --------------------------------------------------------------------------- @@ -1020,7 +1171,7 @@ def test_pre_apply_against_moto_writes_nothing_and_fails_every_probe_row(moto_en ) boto3.client("lambda", region_name=_REGION).create_function( FunctionName="crm-agent-eval-accounts-get", - Runtime="python3.13", + Runtime="python3.14", Role=data_role, Handler="h.h", Code={"ZipFile": _lambda_zip()}, @@ -1078,3 +1229,31 @@ def probe_factory(_ctx: Any, service: str, creds: Any) -> Any: assert ddb.scan(TableName=_TABLES["accounts"])["Count"] == 0 roles = iam.list_roles()["Roles"] assert not [r for r in roles if r["RoleName"].startswith("crm-agent-eval-probe-")] + + +def test_probe_setup_and_teardown_errors_carry_their_codes_but_never_their_messages() -> None: + setup = Scenario() + setup.create_role_error = "AccessDenied" + setup.iam_error_message = f"{_PLANTED_ARN} is not authorized to perform: iam:CreateRole" + setup_rows = _by_check(setup.run()) + assert setup_rows["probe_role_setup"].status == "fail" + assert "AccessDenied" in setup_rows["probe_role_setup"].detail + _assert_no_planted_arn(list(setup_rows.values())) + + teardown = Scenario() + teardown.delete_role_error = "DeleteConflict" + teardown.iam_error_message = f"{_PLANTED_ARN} cannot delete the role" + teardown_rows = _by_check(teardown.run()) + assert "DeleteConflict" in teardown_rows["probe_role_deleted"].detail + assert _PROBE_ROLE in teardown_rows["probe_role_deleted"].detail + _assert_no_planted_arn(list(teardown_rows.values())) + + +def test_a_policy_read_error_carries_its_code_but_never_its_message() -> None: + scenario = Scenario() + scenario.table_policies["accounts"] = None + scenario.policy_error_message = f"{_PLANTED_ARN} is not authorized" + rows = scenario.run() + failed = [r for r in rows if r.status == "fail" and "PolicyNotFoundException" in r.detail] + assert failed, rows + _assert_no_planted_arn(rows) diff --git a/tests/unit/test_smoke_dynamodb_tables.py b/tests/unit/test_smoke_dynamodb_tables.py index 9700696..f732a91 100644 --- a/tests/unit/test_smoke_dynamodb_tables.py +++ b/tests/unit/test_smoke_dynamodb_tables.py @@ -7,7 +7,9 @@ import boto3 import pytest +from botocore.exceptions import ClientError from botocore.stub import ANY, Stubber +from scripts.smoke import dynamodb_tables from scripts.smoke.dynamodb_tables import checks from scripts.smoke.harness import context_for_test @@ -706,3 +708,37 @@ def test_main_missing_outputs_fails_cleanly( assert exit_code == 1 assert '"layer": 4' in captured.out assert '"resource_class": "dynamodb_tables"' in captured.out + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +class _DeniedDynamoDb: + """Every call raises an `AccessDeniedException` whose message carries a planted ARN.""" + + def __getattr__(self, name: str) -> Any: + def _raise(**_: Any) -> Any: + raise ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, + name, + ) + + return _raise + + +def test_a_failed_describe_names_the_code_never_the_message() -> None: + ctx = context_for_test(outputs=_outputs(), clients={"dynamodb": _DeniedDynamoDb()}) + described = [r for r in checks(ctx) if r.check == "describe_table"] + assert len(described) == len(TABLE_NAMES) + for row in described: + assert row.detail == "dynamodb:DescribeTable failed (AccessDeniedException)" + + +def test_a_failed_gsi_query_names_the_code_never_the_message() -> None: + ctx = context_for_test(outputs=_outputs(), clients={"dynamodb": _DeniedDynamoDb()}) + gsi = next(iter(table_schema("accounts").gsis.values())) + row = dynamodb_tables._check_gsi_queryable(ctx, "accounts", gsi) + assert row.status == "fail" + assert "dynamodb:Query failed (AccessDeniedException)" in row.detail + assert gsi.name in row.detail + assert _PLANTED_ARN not in row.detail diff --git a/tests/unit/test_smoke_eni_function_code_deny.py b/tests/unit/test_smoke_eni_function_code_deny.py index 0171008..2d1e740 100644 --- a/tests/unit/test_smoke_eni_function_code_deny.py +++ b/tests/unit/test_smoke_eni_function_code_deny.py @@ -15,6 +15,7 @@ from typing import Any import pytest +from botocore.exceptions import ClientError from scripts.smoke import eni_function_code_deny as mod from scripts.smoke.eni_function_code_deny import ( EXPECTED_PROBE_ERROR, @@ -280,6 +281,25 @@ def test_a_probe_that_was_not_denied_fails_and_is_still_deleted( assert not fake.probe_exists +def test_a_function_error_payload_leaks_no_error_message_or_stacktrace() -> None: + """When the probe raises, the detail names only FunctionError and errorType, never the body.""" + secret_arn = "arn:aws:sts::123456789012:assumed-role/x/y" + fake = _FakeLambda( + payload={ + "errorType": "AccessDeniedException", + "errorMessage": f"User: {secret_arn} is not authorized", + "stackTrace": [f" File probe.py, caller {secret_arn}"], + }, + function_error="Unhandled", + ) + row = _by(_run(fake), "probe_code_denied_eni_actions")[0] + assert row.status == "fail" + assert "FunctionError=Unhandled" in row.detail + assert "errorType=AccessDeniedException" in row.detail + assert secret_arn not in row.detail + assert "errorMessage" not in row.detail and "stackTrace" not in row.detail + + def test_a_probe_that_never_becomes_active_fails_and_is_deleted() -> None: fake = _FakeLambda(probe_state="Pending") results = _run(fake) @@ -407,3 +427,32 @@ def test_a_deny_that_also_blocks_lambdas_own_eni_work_fails_the_service_row() -> def test_a_short_simulation_result_fails_the_service_row() -> None: results = _run(_FakeLambda(), _FakeIam(drop_from_service="xray:PutTraceSegments")) assert all(r.status == "fail" for r in _by(results, "service_path_allowed_eni_and_xray")) + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted(operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, operation + ) + + +class _DeniedLambda(_FakeLambda): + def create_function(self, **kwargs: Any) -> dict[str, Any]: + raise _planted("CreateFunction") + + def delete_function(self, *, FunctionName: str) -> None: # noqa: N803 + self.deleted.append(FunctionName) + raise _planted("DeleteFunction") + + +def test_aws_failures_name_the_code_never_the_message(capsys: pytest.CaptureFixture[str]) -> None: + results = _run(_DeniedLambda(stale={})) + [created] = _by(results, "probe_created_active") + assert created.status == "fail" + assert created.detail == "lambda:CreateFunction failed (AccessDeniedException)" + stderr = capsys.readouterr().err + assert "lambda:DeleteFunction failed (AccessDeniedException)" in stderr + assert _PLANTED_ARN not in stderr + assert all(_PLANTED_ARN not in r.detail for r in results) diff --git a/tests/unit/test_smoke_eval_sfn.py b/tests/unit/test_smoke_eval_sfn.py index 29db98d..4f6ee84 100644 --- a/tests/unit/test_smoke_eval_sfn.py +++ b/tests/unit/test_smoke_eval_sfn.py @@ -34,7 +34,7 @@ from crm.store.keys import SWEEP_LOCK_ROW_ID from crm.store.schema import TABLES from eval.harness import ArtifactAssertionError -from eval.matrix import TIER_TASK_METRICS_KEY +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY, TIER_TASK_METRICS_KEY from eval.runs import EVAL_RUNS_TABLE from eval.sweep_units import DEFAULT_ARM_EFFORT from eval.tenancy import CANARY_TENANT, unit_tenants_for_run @@ -70,24 +70,43 @@ def _configured(family: str, tier: str) -> str: return _CAPABILITIES.tiers[cast(Family, family)][cast(Tier, tier)].model_id +def _tier_task_entry(family: str, tier: str) -> dict[str, Any]: + truncation = None if tier == "subagent" else 0 + return { + "configured_model_id": _configured(family, tier), + "budget_exhausted_task_count": 0, + "truncated_tool_call_count": truncation, + "truncated_task_count": truncation, + } + + def _matrix() -> dict[str, Any]: + """A completed run's `matrix` in the current record shape, one arm per default-sweep family.""" return { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "arms": [ { + RECORD_SHAPE_VERSION_KEY: RECORD_SHAPE_VERSION, "provenance": { "model_id": _configured(family, "supervisor"), "effort": DEFAULT_ARM_EFFORT, "prompt_bundle_sha256": prompt_bundle_sha256(), + "prompt_caching": f"{family}: recorded caching method", }, - "tier_summary": {tier: {} for tier in TIERS}, - TIER_TASK_METRICS_KEY: { - "by_tier": { - tier: {"configured_model_id": _configured(family, tier)} for tier in TIERS + "tier_summary": { + tier: { + "total_prompt_tokens": 4096, + "cache_read_tokens": 1024, + "cache_write_tokens": 512, } + for tier in TIERS + }, + TIER_TASK_METRICS_KEY: { + "by_tier": {tier: _tier_task_entry(family, tier) for tier in TIERS} }, } for family in _FAMILIES - ] + ], } @@ -474,6 +493,7 @@ def _run( "unit_tenants_recorded", "unit_tenants_seeded", "run_completed_all_tasks", + "matrix_is_record_shape_3", "run_records_repeats", *(f"arm_effort_is_default:{family}" for family in _FAMILIES), *(f"arm_models_are_configured:{family}" for family in _FAMILIES), @@ -486,6 +506,7 @@ def _run( "artefact_url_plain_http_denied", "artefact_url_tampered_key_denied", "status_carries_tier_comparison_table", + "subagent_table_has_no_delegation_outcome_rows", "matrix_md_download_is_attachment", "matrix_md_download_bytes_match_artefact", "rehearsal_tenant_empty", @@ -1338,7 +1359,7 @@ def test_a_simulate_client_error_is_a_failing_row_never_a_skip() -> None: assert _failing(rows) == xray_rows for check in xray_rows: assert rows[check].status == "fail" - assert "ClientError" in rows[check].detail, rows[check].detail + assert "failed (InvalidInput)" in rows[check].detail, rows[check].detail def test_the_role_simulations_run_before_any_sweep_is_submitted() -> None: @@ -2497,3 +2518,347 @@ def _finish(self, run: dict[str, Any], status: str) -> None: def test_get_artefact_refuses_a_non_https_url() -> None: with pytest.raises(ValueError, match="non-https"): mod.get_artefact("http://bucket.s3.amazonaws.com/k") + + +# --------------------------------------------------------------------------- +# AWS failures are reported by operation and code, never by message. +# --------------------------------------------------------------------------- + +_PLANTED_ARN = "arn:aws:sts::" + "1234" + "5678" + "9012" + ":assumed-role/x/y" + + +def _planted_client_error(operation: str) -> ClientError: + """An AccessDenied `ClientError` whose message names a caller ARN.""" + exc = ClientError( + {"Error": {"Code": "AccessDenied", "Message": f"User: {_PLANTED_ARN} is not authorized"}}, + operation, + ) + assert _PLANTED_ARN in str(exc) + return exc + + +def _assert_code_not_message(detail: str) -> None: + assert "(AccessDenied)" in detail, detail + assert _PLANTED_ARN not in detail and "assumed-role" not in detail, detail + + +def test_an_unreadable_catalog_row_omits_the_aws_error_message() -> None: + api = FakeEvalApi() + store = FakeStore(api) + store.catalog_error = _planted_client_error("GetItem") + row = _run(api, store=store)["tenant_emptied_by_the_workers_own_role"] + assert row.status == "fail" + _assert_code_not_message(row.detail) + + +def test_a_raising_explicit_deny_simulation_omits_the_aws_error_message() -> None: + class DeniedIam: + def simulate_principal_policy(self, **_kwargs: Any) -> dict[str, Any]: + raise _planted_client_error("SimulatePrincipalPolicy") + + row = next(r for r in _sweep_rows() if isinstance(r, mod.ExplicitDenyRow)) + result = mod.explicit_deny_result(DeniedIam(), row, resource="eval_sweep_roles") + assert result.status == "fail" + _assert_code_not_message(result.detail) + + +def test_a_raising_reap_count_omits_the_aws_error_message(monkeypatch: pytest.MonkeyPatch) -> None: + def denied(_store: Any, _tenant: str) -> dict[str, int]: + raise _planted_client_error("Query") + + monkeypatch.setattr(mod, "tenant_row_counts", denied) + rows = list(mod._reap_tenant(object(), "eval-run0001")) + assert [r.check for r in rows] == ["leftover_tenant_counted"] + _assert_code_not_message(rows[0].detail) + + +def test_a_failed_reap_teardown_omits_the_wrapped_aws_error_message( + monkeypatch: pytest.MonkeyPatch, +) -> None: + from eval.tenancy import TenantTeardownError + + def denied_teardown(_store: Any, *, tenant: str) -> dict[str, int]: + cause = _planted_client_error("BatchWriteItem") + raise TenantTeardownError(tenant, deleted=None, cause=cause) from cause + + monkeypatch.setattr(mod, "tenant_row_counts", lambda _store, _tenant: {"accounts": 1}) + monkeypatch.setattr(mod, "teardown_tenant", denied_teardown) + rows = list(mod._reap_tenant(object(), "eval-run0001")) + assert [r.check for r in rows] == ["leftover_tenant_reaped"] and rows[0].status == "fail" + _assert_code_not_message(rows[0].detail) + + +# --------------------------------------------------------------------------- +# A run record's `error` text is classified, never re-emitted. +# --------------------------------------------------------------------------- + +_PLANTED_RUN_ERROR = ( + f"step failed: ClientError: User: {_PLANTED_ARN} is not authorized to perform: s3:PutObject" +) + + +def _assert_run_error_withheld(detail: str) -> None: + assert "present (ClientError)" in detail, detail + assert _PLANTED_ARN not in detail and "assumed-role" not in detail, detail + assert "not authorized" not in detail and "s3:PutObject" not in detail, detail + + +@pytest.mark.parametrize( + ("error", "expected"), + [ + (None, None), + ("", None), + (_PLANTED_RUN_ERROR, "present (ClientError)"), + ("step failed: States.Timeout", "present (States.Timeout)"), + ("step failed: States.Timeout; 2 task(s) failed (anthropic=2)", "present (States.Timeout)"), + (f"step failed: {_PLANTED_ARN}: denied", "present"), + (f"User: {_PLANTED_ARN} is not authorized", "present (User)"), + ("teardown failed: TenantTeardownError: rows left", "present"), + ("2 task(s) failed (openai=2)", "present"), + ("An administrator (rep r-1) released the sweep lock.", "present"), + ({"Error": "ClientError", "Cause": _PLANTED_ARN}, "present"), + ], +) +def test_error_classification_keeps_only_an_identifier_shaped_leading_token( + error: object, expected: str | None +) -> None: + assert mod.error_classification(error) == expected + + +def test_a_completed_record_check_withholds_the_run_error_text() -> None: + run: dict[str, Any] = { + "status": "failed", + "tasks_total": _TOTAL, + "tasks_done": _TOTAL, + "tasks_failed": 0, + "teardown_status": "ok", + "matrix": _matrix(), + "error": _PLANTED_RUN_ERROR, + } + row = mod.check_completed_record(run, expected_total=_TOTAL, arm_count=2) + assert row.status == "fail" + assert "error='present (ClientError)'" in row.detail + _assert_run_error_withheld(row.detail) + + +def test_a_completed_record_without_an_error_reports_none() -> None: + run: dict[str, Any] = {"status": "completed", "matrix": _matrix()} + row = mod.check_completed_record(run, expected_total=_TOTAL, arm_count=2) + assert "error=None" in row.detail + + +def test_the_artefact_checks_withhold_the_run_error_text_of_a_record_without_artefacts() -> None: + api = mod.RunApi(FakeEvalApi(), "id-token") + run = {"run_id": "run0001", "status": "failed", "error": _PLANTED_RUN_ERROR} + url_rows = list(mod.check_artefact_url(api, run)) + md_rows = list(mod.check_matrix_md_download(api, run)) + assert [r.check for r in url_rows] == ["artefact_url_issued"] + assert [r.check for r in md_rows] == [ + "matrix_md_download_is_attachment", + "matrix_md_download_bytes_match_artefact", + ] + for row in (*url_rows, *md_rows): + assert row.status == "fail" + _assert_run_error_withheld(row.detail) + + +class _ErrorRecordingApi(FakeEvalApi): + """A :class:`FakeEvalApi` whose every status answer carries `error`; with `ignore_cancel` a + cancelled run stays non-terminal.""" + + def __init__(self, *, error: str, ignore_cancel: bool = False, **kwargs: Any) -> None: + super().__init__(**kwargs) + self.error = error + self.ignore_cancel = ignore_cancel + + def _advance(self, run: dict[str, Any]) -> None: + run["error"] = self.error + if self.ignore_cancel and run["cancel_requested"]: + return + super()._advance(run) + + +def test_a_rehearsal_that_never_finishes_withholds_the_run_error_text() -> None: + row = _run(_ErrorRecordingApi(error=_PLANTED_RUN_ERROR, stuck=True))[ + "rehearsal_reached_terminal" + ] + assert row.status == "fail" + _assert_run_error_withheld(row.detail) + + +def test_a_cancel_proof_without_progress_withholds_the_run_error_text() -> None: + row = _run(_ErrorRecordingApi(error=_PLANTED_RUN_ERROR, step=_REHEARSAL_TOTAL))[ + "cancel_proof_reached_progress" + ] + assert row.status == "fail" + _assert_run_error_withheld(row.detail) + + +def test_a_cancel_proof_that_never_terminates_withholds_the_run_error_text() -> None: + row = _run(_ErrorRecordingApi(error=_PLANTED_RUN_ERROR, ignore_cancel=True))[ + "cancel_proof_reached_terminal" + ] + assert row.status == "fail" + _assert_run_error_withheld(row.detail) + + +def test_a_live_sweep_that_never_finishes_withholds_the_run_error_text() -> None: + row = _live(_ErrorRecordingApi(error=_PLANTED_RUN_ERROR, stuck=True), _retention_ok)[ + "live_sweep_reached_terminal" + ] + assert row.status == "fail" + _assert_run_error_withheld(row.detail) + + +# --- record shape 3 on the completed rehearsal --- + + +def _shape_row(matrix: Any) -> CheckResult: + return mod.check_record_shape({"matrix": matrix}) + + +def test_a_current_shape_matrix_passes_the_record_shape_row() -> None: + row = _shape_row(_matrix()) + assert (row.check, row.status) == (f"matrix_is_record_shape_{RECORD_SHAPE_VERSION}", "pass") + + +def _drop(path: tuple[Any, ...]) -> Callable[[dict[str, Any]], None]: + def mutate(matrix: dict[str, Any]) -> None: + node: Any = matrix + for key in path[:-1]: + node = node[key] + del node[path[-1]] + + return mutate + + +def _set(path: tuple[Any, ...], value: object) -> Callable[[dict[str, Any]], None]: + def mutate(matrix: dict[str, Any]) -> None: + node: Any = matrix + for key in path[:-1]: + node = node[key] + node[path[-1]] = value + + return mutate + + +_BY_TIER = (TIER_TASK_METRICS_KEY, "by_tier") +_SHAPE_MUTATIONS: dict[str, Callable[[dict[str, Any]], None]] = { + "matrix_version_absent": _drop((RECORD_SHAPE_VERSION_KEY,)), + "matrix_version_1": _set((RECORD_SHAPE_VERSION_KEY,), 1), + "matrix_version_3": _set((RECORD_SHAPE_VERSION_KEY,), RECORD_SHAPE_VERSION + 1), + "arm_version_absent": _drop(("arms", 1, RECORD_SHAPE_VERSION_KEY)), + "prompt_caching_absent": _drop(("arms", 0, "provenance", "prompt_caching")), + "prompt_caching_empty": _set(("arms", 1, "provenance", "prompt_caching"), ""), + "prompt_caching_not_str": _set(("arms", 0, "provenance", "prompt_caching"), ["x"]), + **{ + f"tier_summary_{tier}_{field}_absent": _drop(("arms", 0, "tier_summary", tier, field)) + for tier in TIERS + for field in mod.RECORD_SHAPE_TIER_SUMMARY_FIELDS + }, + "tier_summary_cache_read_null": _set( + ("arms", 1, "tier_summary", "tool", "cache_read_tokens"), None + ), + "tier_summary_total_prompt_bool": _set( + ("arms", 1, "tier_summary", "supervisor", "total_prompt_tokens"), True + ), + **{ + f"by_tier_{tier}_{field}_absent": _drop(("arms", 0, *_BY_TIER, tier, field)) + for tier in TIERS + for field in mod.RECORD_SHAPE_TIER_TASK_FIELDS + }, + "by_tier_subagent_budget_null": _set( + ("arms", 1, *_BY_TIER, "subagent", "budget_exhausted_task_count"), None + ), + "by_tier_supervisor_truncated_calls_null": _set( + ("arms", 1, *_BY_TIER, "supervisor", "truncated_tool_call_count"), None + ), + "by_tier_tool_truncated_tasks_null": _set( + ("arms", 0, *_BY_TIER, "tool", "truncated_task_count"), None + ), + "by_tier_subagent_truncated_calls_int": _set( + ("arms", 0, *_BY_TIER, "subagent", "truncated_tool_call_count"), 0 + ), + "by_tier_subagent_truncated_tasks_int": _set( + ("arms", 1, *_BY_TIER, "subagent", "truncated_task_count"), 0 + ), + "by_tier_tool_entry_absent": _drop(("arms", 0, *_BY_TIER, "tool")), + "arms_empty": _set(("arms",), []), +} + + +@pytest.mark.parametrize("name", sorted(_SHAPE_MUTATIONS)) +def test_each_missing_or_wrong_shape_field_fails_the_row_and_is_named(name: str) -> None: + matrix = _matrix() + _SHAPE_MUTATIONS[name](matrix) + row = _shape_row(matrix) + assert row.status == "fail" + assert row.detail + + +def test_the_record_shape_row_names_the_failing_field() -> None: + matrix = _matrix() + del matrix["arms"][1]["tier_summary"]["subagent"]["cache_write_tokens"] + row = _shape_row(matrix) + assert row.detail == "arms[1].tier_summary.subagent.cache_write_tokens=None" + + +@pytest.mark.parametrize("matrix", [_ABSENT, None, "matrix"], ids=["absent", "null", "string"]) +def test_a_run_without_a_matrix_fails_the_record_shape_row(matrix: object) -> None: + run: dict[str, Any] = {} if matrix is _ABSENT else {"matrix": matrix} + assert mod.check_record_shape(run).status == "fail" + + +def test_a_live_sweep_record_in_an_earlier_shape_fails_its_record_shape_row() -> None: + class _EarlierShapeApi(FakeEvalApi): + def _finish(self, run: dict[str, Any], status: str) -> None: + super()._finish(run, status) + run["matrix"].pop(RECORD_SHAPE_VERSION_KEY) + + by_check = _live(_EarlierShapeApi(step=_TOTAL), _retention_ok) + assert by_check["run_completed_all_tasks"].status == "pass" + assert by_check[f"matrix_is_record_shape_{RECORD_SHAPE_VERSION}"].status == "fail" + + +def test_a_rehearsal_whose_table_keeps_delegation_rows_fails_only_that_row() -> None: + class _DelegationRowsApi(FakeEvalApi): + def _finish(self, run: dict[str, Any], status: str) -> None: + super()._finish(run, status) + run["tier_comparison_table"]["sections"][1]["rows"].append( + ["Delegation outcome: data", "1", "1"] + ) + + by_check = _run(_DelegationRowsApi()) + failing = {c for c, r in by_check.items() if r.status != "pass"} + assert failing == {"subagent_table_has_no_delegation_outcome_rows"} + + +# --- the Subagent section carries no delegation-outcome row --- + + +def test_a_subagent_section_without_delegation_rows_passes() -> None: + row = mod.check_subagent_table_has_no_delegation_rows( + {"tier_comparison_table": _tier_table(len(_FAMILIES))} + ) + assert (row.check, row.status) == ("subagent_table_has_no_delegation_outcome_rows", "pass") + + +def _with_subagent_rows(rows: list[Any]) -> dict[str, Any]: + table = _tier_table(len(_FAMILIES)) + table["sections"][1]["rows"] = rows + return {"tier_comparison_table": table} + + +@pytest.mark.parametrize( + "run", + [ + _with_subagent_rows([["Model", "m", "m"], ["Delegation outcome: data", "1", "1"]]), + _with_subagent_rows([["Delegation outcome: none", "0", "0"]]), + _with_subagent_rows([]), + {"tier_comparison_table": {**_tier_table(len(_FAMILIES)), "sections": []}}, + {}, + ], + ids=["delegation_row", "only_delegation_row", "no_rows", "no_subagent_section", "no_table"], +) +def test_a_delegation_row_or_missing_subagent_section_fails(run: Mapping[str, Any]) -> None: + assert mod.check_subagent_table_has_no_delegation_rows(run).status == "fail" diff --git a/tests/unit/test_smoke_gateway_tools.py b/tests/unit/test_smoke_gateway_tools.py index 3bce366..bafa9bc 100644 --- a/tests/unit/test_smoke_gateway_tools.py +++ b/tests/unit/test_smoke_gateway_tools.py @@ -1983,3 +1983,67 @@ def test_the_array_body_premise_says_the_gateway_refuses_it_itself() -> None: assert "the Gateway refuses it itself" in ( _gateway_tools._check_array_body_answers_no_tool_call.__doc__ or "" ) + + +# --------------------------------------------------------------------------- +# AWS failures are reported by operation and code, never by message. +# --------------------------------------------------------------------------- + +_PLANTED_ARN = "arn:aws:sts::" + "1234" + "5678" + "9012" + ":assumed-role/x/y" + + +def _planted_client_error(operation: str) -> Exception: + """An AccessDenied `ClientError` whose message names a caller ARN.""" + from botocore.exceptions import ClientError + + exc: Exception = ClientError( + {"Error": {"Code": "AccessDenied", "Message": f"User: {_PLANTED_ARN} is not authorized"}}, + operation, + ) + assert _PLANTED_ARN in str(exc) + return exc + + +def _assert_code_not_message(detail: str) -> None: + assert "(AccessDenied)" in detail, detail + assert _PLANTED_ARN not in detail and "assumed-role" not in detail, detail + + +def test_a_denied_prior_row_read_refuses_without_the_aws_error_message( + monkeypatch: pytest.MonkeyPatch, +) -> None: + dynamo = _RawDynamo(existing=_OPERATOR_ROW) + + def denied_get(**_kw: Any) -> dict[str, Any]: + raise _planted_client_error("GetItem") + + monkeypatch.setattr(dynamo, "get_item", denied_get) + provisioner, _ = _live_provisioner(monkeypatch, dynamo) + with pytest.raises(RuntimeError, match="refusing to overwrite") as raised: + provisioner.provision() + _assert_code_not_message(str(raised.value)) + + +def test_a_denied_restore_fails_without_the_aws_error_message( + monkeypatch: pytest.MonkeyPatch, +) -> None: + dynamo = _RawDynamo(existing=_OPERATOR_ROW) + provisioner, _ = _live_provisioner(monkeypatch, dynamo) + provisioner.provision() + + def denied_put(**_kw: Any) -> dict[str, Any]: + raise _planted_client_error("PutItem") + + monkeypatch.setattr(dynamo, "put_item", denied_put) + restored = next(r for r in provisioner.cleanup() if r.resource == "service_principal") + assert (restored.check, restored.status) == ("reps_row_restored", "fail") + _assert_code_not_message(restored.detail) + + +def test_a_denied_interceptor_log_read_fails_without_the_aws_error_message() -> None: + def denied_reader(_start_ms: int) -> list[str]: + raise _planted_client_error("FilterLogEvents") + + row = _denial_row(denied_reader) + assert row.status == "fail" + _assert_code_not_message(row.detail) diff --git a/tests/unit/test_smoke_harness.py b/tests/unit/test_smoke_harness.py index a40a31e..5c334b2 100644 --- a/tests/unit/test_smoke_harness.py +++ b/tests/unit/test_smoke_harness.py @@ -2196,3 +2196,170 @@ def _raise() -> None: assert raised.value.__cause__ is None assert isinstance(raised.value.__context__, EndpointConnectionError) assert harness.is_timeout(raised.value) is False + + +# --------------------------------------------------------------------------- +# aws_error_code / aws_error_detail: AWS failures are reported by code, never by message. +# --------------------------------------------------------------------------- + +_PLANTED_ARN = f"arn:aws:sts::{_PLACEHOLDER_ACCOUNT}:assumed-role/planted-role/planted-session" + + +def _planted_client_error(operation: str = "GetCallerIdentity") -> ClientError: + """A `ClientError` whose message names a caller ARN, as a real AccessDenied does.""" + exc = ClientError( + { + "Error": { + "Code": "AccessDenied", + "Message": f"User: {_PLANTED_ARN} is not authorized to perform: sts:{operation}", + } + }, + operation, + ) + assert _PLANTED_ARN in str(exc), ( + "the fixture must carry the ARN for its absence to mean anything" + ) + return exc + + +class TestAwsErrorCode: + def test_a_client_error_yields_its_code(self) -> None: + assert harness.aws_error_code(_planted_client_error()) == "AccessDenied" + + def test_a_client_error_without_a_code_yields_the_class_name(self) -> None: + assert harness.aws_error_code(ClientError({}, "ListFunctions")) == "ClientError" + + def test_a_botocore_error_yields_its_class_name(self) -> None: + from botocore.exceptions import EndpointConnectionError + + exc = EndpointConnectionError(endpoint_url="https://x.invalid") + assert harness.aws_error_code(exc) == "EndpointConnectionError" + + def test_the_detail_names_the_operation_and_code_but_not_the_message(self) -> None: + detail = harness.aws_error_detail("sts:GetCallerIdentity", _planted_client_error()) + assert detail == "sts:GetCallerIdentity failed (AccessDenied)" + assert _PLACEHOLDER_ACCOUNT not in detail + + +class TestHarnessSitesOmitTheAwsErrorMessage: + def test_the_account_check_warning_names_the_operation_and_code_only(self) -> None: + """A failed `sts:GetCallerIdentity` warns with its code; the caller ARN is absent.""" + + class _DeniedSts: + def get_caller_identity(self) -> Any: + raise _planted_client_error() + + ctx = context_for_test( + outputs=dict(_outputs_with_arn("us-east-1").values), + clients={"sts": _DeniedSts()}, + region="us-east-1", + ) + warnings = harness.assert_target_matches_outputs(ctx) + + joined = "\n".join(warnings) + assert "sts:GetCallerIdentity failed (AccessDenied)" in joined, joined + assert _PLACEHOLDER_ACCOUNT not in joined and "planted-role" not in joined, joined + + def test_a_raising_deriver_reports_the_code_only(self) -> None: + """A deriver failing on an AWS call yields an underivable count with no message.""" + + def _deriver(_ctx: Any) -> Any: + raise _planted_client_error("ListFunctions") + + expectation = harness._resolve_expectation(context_for_test(), _deriver) + + assert isinstance(expectation, harness.UnderivableCheckCount) + assert "ListFunctions failed (AccessDenied)" in expectation.reason, expectation.reason + assert _PLACEHOLDER_ACCOUNT not in expectation.reason, expectation.reason + + def test_a_check_raising_a_client_error_reports_the_code_only( + self, tmp_path: Path, capsys: pytest.CaptureFixture[str] + ) -> None: + outputs_file = _write_outputs(tmp_path, {"api_endpoint": "https://example.test"}) + + def checks(_ctx: Any) -> list[CheckResult]: + raise _planted_client_error("DescribeTable") + + run_main( + ["--outputs", str(outputs_file), "--json"], + layer=4, + resource_class="fake", + description="test", + checks=checks, + ) + output = capsys.readouterr().out + detail = json.loads(output)["checks"][0]["detail"] + assert detail == "ClientError: DescribeTable failed (AccessDenied)", detail + assert _PLACEHOLDER_ACCOUNT not in output + + def test_a_wrapped_client_error_is_reported_by_code_not_by_the_wrapper_text( + self, tmp_path: Path, capsys: pytest.CaptureFixture[str] + ) -> None: + """A local error raised while handling an AWS error does not carry its message out.""" + outputs_file = _write_outputs(tmp_path, {"api_endpoint": "https://example.test"}) + + def checks(_ctx: Any) -> list[CheckResult]: + try: + raise _planted_client_error("GetFunction") + except ClientError as exc: + raise RuntimeError(f"lookup failed: {exc}") from exc + + run_main( + ["--outputs", str(outputs_file), "--json"], + layer=4, + resource_class="fake", + description="test", + checks=checks, + ) + output = capsys.readouterr().out + assert "RuntimeError: GetFunction failed (AccessDenied)" in output, output + assert _PLACEHOLDER_ACCOUNT not in output + + def test_a_non_aws_check_failure_keeps_its_text( + self, tmp_path: Path, capsys: pytest.CaptureFixture[str] + ) -> None: + """Control: an exception with no AWS error in its chain is reported with its message.""" + outputs_file = _write_outputs(tmp_path, {"api_endpoint": "https://example.test"}) + + def checks(_ctx: Any) -> list[CheckResult]: + raise ValueError("bad local fixture value") + + run_main( + ["--outputs", str(outputs_file), "--json"], + layer=4, + resource_class="fake", + description="test", + checks=checks, + ) + detail = json.loads(capsys.readouterr().out)["checks"][0]["detail"] + assert detail == "ValueError: bad local fixture value", detail + + +class TestExceptionDetail: + def test_a_local_error_keeps_its_text(self) -> None: + assert harness.exception_detail(ValueError("bad row")) == "ValueError: bad row" + + def test_a_client_error_yields_its_own_operation_and_code(self) -> None: + detail = harness.exception_detail(_planted_client_error("ListRoles")) + assert detail == "ClientError: ListRoles failed (AccessDenied)" + + def test_a_named_operation_replaces_the_client_errors_own(self) -> None: + detail = harness.exception_detail(_planted_client_error(), "sts:GetCallerIdentity") + assert detail == "ClientError: sts:GetCallerIdentity failed (AccessDenied)" + + def test_an_aws_error_in_the_context_chain_is_reported_by_code(self) -> None: + try: + try: + raise _planted_client_error() + except ClientError as inner: + raise RuntimeError(f"wrapped: {inner}") # noqa: B904 + except RuntimeError as outer: + detail = harness.exception_detail(outer) + assert detail == "RuntimeError: GetCallerIdentity failed (AccessDenied)" + assert _PLACEHOLDER_ACCOUNT not in detail + + def test_a_botocore_error_without_an_operation_names_an_aws_call(self) -> None: + from botocore.exceptions import NoCredentialsError + + detail = harness.exception_detail(NoCredentialsError()) + assert detail == "NoCredentialsError: an AWS call failed (NoCredentialsError)" diff --git a/tests/unit/test_smoke_iam_roles.py b/tests/unit/test_smoke_iam_roles.py index 1c6a04c..abdc446 100644 --- a/tests/unit/test_smoke_iam_roles.py +++ b/tests/unit/test_smoke_iam_roles.py @@ -518,7 +518,7 @@ def test_role_not_found_from_simulate_call_is_a_failure() -> None: for r in results if r.resource == _role("create_account") and r.status == "fail" - and "simulate_principal_policy raised" in r.detail + and "iam:SimulatePrincipalPolicy failed (NoSuchEntity)" in r.detail ] assert len(failures) == 1 # never a skip, never a silent pass @@ -5403,3 +5403,97 @@ def test_the_key_output_is_declared_in_infra() -> None: assert f'output "{iam_roles.ALLOWLIST_KEY_OUTPUT}"' in outputs source = (root / "scripts" / "smoke" / "iam_roles.py").read_text(encoding="utf-8") assert f'require_str("{iam_roles.ALLOWLIST_KEY_OUTPUT}")' in source + + +# --------------------------------------------------------------------------- +# AWS failures are reported by operation and code, never by message. +# --------------------------------------------------------------------------- + +_PLANTED_ARN = "arn:aws:sts::" + "1234" + "5678" + "9012" + ":assumed-role/x/y" + + +def _planted_client_error(operation: str) -> Exception: + """An AccessDenied `ClientError` whose message names a caller ARN.""" + from botocore.exceptions import ClientError + + exc: Exception = ClientError( + {"Error": {"Code": "AccessDenied", "Message": f"User: {_PLANTED_ARN} is not authorized"}}, + operation, + ) + assert _PLANTED_ARN in str(exc) + return exc + + +def _raiser(operation: str) -> Callable[..., Any]: + def _raise(*_args: Any, **_kwargs: Any) -> Any: + raise _planted_client_error(operation) + + return _raise + + +def _assert_code_not_message(detail: str) -> None: + assert "(AccessDenied)" in detail, detail + assert _PLANTED_ARN not in detail and "assumed-role" not in detail, detail + + +def test_denied_allowlist_reads_fail_their_rows_without_the_aws_error_message( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setattr(_AkSsm, "describe_parameters", _raiser("DescribeParameters")) + monkeypatch.setattr(_AkSsm, "get_parameter", _raiser("GetParameter")) + monkeypatch.setattr(_AkKms, "get_key_rotation_status", _raiser("GetKeyRotationStatus")) + monkeypatch.setattr(_AkKms, "list_resource_tags", _raiser("ListResourceTags")) + monkeypatch.setattr(_AkDynamo, "describe_table", _raiser("DescribeTable")) + rows, _, _ = _ak_run() + for index in (0, 1, 2, 3, 13): + row = rows[iam_roles.ALLOWLIST_KEY_CHECKS[index]] + assert row.status == "fail", row + _assert_code_not_message(row.detail) + for row in rows.values(): + assert _PLANTED_ARN not in row.detail, row + + +def test_denied_caller_identity_fails_every_allowlist_row_without_the_aws_error_message( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setattr(_SupSts, "get_caller_identity", _raiser("GetCallerIdentity")) + rows, _, _ = _ak_run() + for row in rows.values(): + assert row.status == "fail", row + _assert_code_not_message(row.detail) + + +def test_a_denied_role_listing_is_reported_without_the_aws_error_message() -> None: + class DeniedIam: + def get_paginator(self, _name: str) -> Any: + raise _planted_client_error("ListRoles") + + _, problem = iam_roles._discover_role_arns(context_for_test(clients={"iam": DeniedIam()})) + assert problem is not None + _assert_code_not_message(problem) + + +def test_an_unloadable_policy_set_is_reported_without_the_aws_error_message() -> None: + clients = _StubbedClientSet() + clients.stub.add_response("get_role", {"Role": _role_stub("create_account")}) + for other in _SORTED_FUNCTIONS: + clients.add_simulate("allowed" if other == "create_account" else "explicitDeny") + clients.stub.add_client_error( + "list_role_policies", + service_error_code="AccessDenied", + service_message=f"User: {_PLANTED_ARN} is not authorized to perform: iam:ListRolePolicies", + ) + clients.add_role_for("get_rep_self") + clients.add_role_for("update_account") + clients.activate() + results = _run_checks(clients) + clients.assert_no_pending() + unreadable = [ + r + for r in results + if r.resource == _role("create_account") + and r.check in ("no_dynamodb_wildcard", "leading_keys:policies_unreadable") + ] + assert [r.status for r in unreadable] == ["fail", "fail"] + for row in unreadable: + _assert_code_not_message(row.detail) diff --git a/tests/unit/test_smoke_lambda_actions.py b/tests/unit/test_smoke_lambda_actions.py index 10f3f54..eb218bb 100644 --- a/tests/unit/test_smoke_lambda_actions.py +++ b/tests/unit/test_smoke_lambda_actions.py @@ -911,7 +911,8 @@ def test_in_scope_function_error_fails_never_silently_passes() -> None: stubber.deactivate() assert result.status == "fail" - assert "FunctionError" in result.detail + assert "FunctionError=Unhandled" in result.detail + assert "boom" not in result.detail # --------------------------------------------------------------------------- @@ -1439,7 +1440,8 @@ def invoke(self, **kwargs: Any) -> dict[str, Any]: ctx = context_for_test(clients={"lambda": fake}, tenant=_TEST_TENANT) results = {r.check: r for r in _departed_contact_checks(ctx, tenant=_TEST_TENANT)} assert results[DEPARTED_REFUSED_CHECK].status == "fail" - assert "FunctionError" in results[DEPARTED_REFUSED_CHECK].detail + assert "FunctionError=Unhandled" in results[DEPARTED_REFUSED_CHECK].detail + assert "boom" not in results[DEPARTED_REFUSED_CHECK].detail # --------------------------------------------------------------------------- @@ -2097,3 +2099,131 @@ def test_a_refused_declared_agent_identity_fails_the_control_row() -> None: rows = _principal_type_rows(_CursorLambda(refuse_agent_channel=True)) assert rows[AGENT_PRINCIPAL_TYPE_DECLARED_CHECK].status == "fail" assert rows[AGENT_PRINCIPAL_TYPE_ABSENT_CHECK].status == "pass" + + +# --------------------------------------------------------------------------- +# AWS failures are reported by operation and code, never by message. +# --------------------------------------------------------------------------- + +_PLANTED_ARN = "arn:aws:sts::" + "1234" + "5678" + "9012" + ":assumed-role/x/y" + + +def _planted_client_error(operation: str) -> Exception: + """An AccessDenied `ClientError` whose message names a caller ARN.""" + from botocore.exceptions import ClientError + + exc: Exception = ClientError( + {"Error": {"Code": "AccessDenied", "Message": f"User: {_PLANTED_ARN} is not authorized"}}, + operation, + ) + assert _PLANTED_ARN in str(exc) + return exc + + +class _DeniedKms(_Kms): + """Every KMS read answers with a planted AccessDenied.""" + + def get_key_rotation_status(self, *, KeyId: str) -> dict[str, Any]: # noqa: N803 + raise _planted_client_error("GetKeyRotationStatus") + + def describe_key(self, *, KeyId: str) -> dict[str, Any]: # noqa: N803 + raise _planted_client_error("DescribeKey") + + def list_resource_tags(self, *, KeyId: str) -> dict[str, Any]: # noqa: N803 + raise _planted_client_error("ListResourceTags") + + def get_key_policy(self, *, KeyId: str, PolicyName: str) -> dict[str, Any]: # noqa: N803 + raise _planted_client_error("GetKeyPolicy") + + +def test_denied_kms_reads_fail_their_rows_without_the_aws_error_message() -> None: + rows = _rows(_extra_ctx(kms=_DeniedKms())) + failing = [r for r in rows if r.status == "fail"] + assert {r.check for r in failing} >= { + "cursor_key_rotation_enabled", + "cursor_key_shape", + "cursor_key_classified", + KMS_ADMIN_DENIED_CHECK, + }, sorted({r.check for r in failing}) + assert any("kms:GetKeyPolicy failed (AccessDenied)" in r.detail for r in failing) + for row in rows: + assert _PLANTED_ARN not in row.detail and "assumed-role" not in row.detail, row + + +def test_a_failed_teardown_omits_the_wrapped_aws_error_message() -> None: + from scripts.smoke import lambda_actions + + def denied_teardown(_store: Any, smoke_tenant: SmokeTenant) -> dict[str, int]: + cause = _planted_client_error("BatchWriteItem") + raise TenantTeardownError(smoke_tenant.tenant, deleted=None, cause=cause) from cause + + store: Any = object() + rows = list(lambda_actions._teardown_check(store, _TEST_SMOKE_TENANT, denied_teardown)) + assert [r.status for r in rows] == ["fail"] + assert "(AccessDenied)" in rows[0].detail, rows[0].detail + assert _PLANTED_ARN not in rows[0].detail, rows[0].detail + + +class TestFunctionErrorDetail: + """A FunctionError is reported by its type, never by the payload's message or trace.""" + + def _planted_payload(self, error_type: Any = "AccessDeniedException") -> bytes: + return json.dumps( + { + "errorType": error_type, + "errorMessage": f"User: {_PLANTED_ARN} is not authorized to perform: dynamodb:Query", + "stackTrace": [f' File "/var/task/handler.py", line 1, in {_PLANTED_ARN}'], + } + ).encode("utf-8") + + def test_the_detail_names_the_function_error_and_error_type_only(self) -> None: + from scripts.smoke.lambda_actions import _function_error_detail + + detail = _function_error_detail("Unhandled", self._planted_payload()) + assert detail == "FunctionError=Unhandled errorType=AccessDeniedException" + + @pytest.mark.parametrize( + "error_type", + [f"Denied: {_PLANTED_ARN}", 42, None, "x" * 200], + ids=["prose", "non-string", "absent", "too-long"], + ) + def test_an_unusable_error_type_is_omitted(self, error_type: Any) -> None: + from scripts.smoke.lambda_actions import _function_error_detail + + assert _function_error_detail("Unhandled", self._planted_payload(error_type)) == ( + "FunctionError=Unhandled" + ) + + @pytest.mark.parametrize("raw", [b"", b"not json", b"[1, 2]"], ids=["empty", "text", "list"]) + def test_an_unparseable_payload_yields_the_function_error_alone(self, raw: bytes) -> None: + from scripts.smoke.lambda_actions import _function_error_detail + + assert _function_error_detail("Handled", raw) == "FunctionError=Handled" + + def test_an_unrecognised_function_error_value_is_not_echoed(self) -> None: + from scripts.smoke.lambda_actions import _function_error_detail + + detail = _function_error_detail(f"weird {_PLANTED_ARN}", b"") + assert detail == "FunctionError=" + + def test_an_invoke_check_omits_the_planted_arn(self) -> None: + tool = ALL_TOOLS[0] + client = _lambda_client() + stubber = Stubber(client) + stubber.add_response( + "invoke", + { + "StatusCode": 200, + "FunctionError": "Unhandled", + "Payload": BytesIO(self._planted_payload()), + }, + ) + stubber.activate() + ctx = context_for_test(clients={"lambda": client}, tenant=_TEST_TENANT) + from scripts.smoke.lambda_actions import _check_in_scope, function_name_for + + result = _check_in_scope(ctx, tool, function_name_for(tool), tenant=_TEST_TENANT) + stubber.deactivate() + assert result.status == "fail" + assert "FunctionError=Unhandled errorType=AccessDeniedException" in result.detail + assert _PLANTED_ARN not in result.detail and "is not authorized" not in result.detail diff --git a/tests/unit/test_smoke_mcp_chat_gateway.py b/tests/unit/test_smoke_mcp_chat_gateway.py index 3618ac6..914ca77 100644 --- a/tests/unit/test_smoke_mcp_chat_gateway.py +++ b/tests/unit/test_smoke_mcp_chat_gateway.py @@ -16,6 +16,7 @@ from typing import Any import pytest +from botocore.exceptions import ClientError from scripts.smoke import mcp_chat_gateway as module from scripts.smoke.harness import CheckResult, context_for_test from scripts.smoke.three_tier_chat import MODEL_TURN_ALLOTMENTS @@ -742,3 +743,47 @@ def test_an_invoke_only_token_from_another_pool_fails_its_row(self) -> None: rows, _ = _run(_FakeGateway(), invoke_only_token=foreign) row = rows["gateway2_refuses_invoke_only_token"] assert row.status == "fail" and "iss" in row.detail + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted_error(operation: str) -> ClientError: + return ClientError( + { + "Error": { + "Code": "AccessDeniedException", + "Message": f"{_PLANTED_ARN} is not authorized", + } + }, + operation, + ) + + +def test_a_cleanup_aws_error_carries_its_code_but_never_its_message() -> None: + class _DeniedDynamo(_FakeDynamo): + def delete_item(self, *, TableName: str, Key: dict[str, Any]) -> dict[str, Any]: # noqa: N803 + raise _planted_error("DeleteItem") + + rows, _ = _run(_FakeGateway(), dynamo=_DeniedDynamo()) + row = rows["conversation_items_removed"] + assert row.status == "fail" + assert "dynamodb conversation cleanup failed (AccessDeniedException)" in row.detail + assert not [r for r in rows.values() if _PLANTED_ARN in r.detail] + + +@pytest.mark.parametrize("chained", [True, False]) +def test_a_mint_failure_masks_a_chained_aws_error_and_keeps_a_local_message(chained: bool) -> None: + def minter(_ctx: Any, _scope: str) -> str: + if chained: + raise RuntimeError("mint failed") from _planted_error("InitiateAuth") + raise RuntimeError("token endpoint returned no access_token") + + ctx = context_for_test(outputs=_OUTPUTS, clients={}) + row = module._invoke_only_token_row(ctx, _FakeGateway(), minter, lambda _t: {}) + assert row.status == "fail" + assert _PLANTED_ARN not in row.detail + if chained: + assert "failed (AccessDeniedException)" in row.detail + else: + assert "token endpoint returned no access_token" in row.detail diff --git a/tests/unit/test_smoke_mcp_client_compat.py b/tests/unit/test_smoke_mcp_client_compat.py index 5080976..b34f654 100644 --- a/tests/unit/test_smoke_mcp_client_compat.py +++ b/tests/unit/test_smoke_mcp_client_compat.py @@ -22,6 +22,7 @@ import anyio import httpx2 import pytest +from botocore.exceptions import ClientError from scripts import proc_run from scripts.smoke import mcp_client_compat as module from scripts.smoke.harness import CheckResult, InsecureSchemeError, context_for_test @@ -881,3 +882,48 @@ def test_http_status_of_does_not_follow_a_context_only_chain() -> None: assert module._http_status_of(raised) is None group = ExceptionGroup("task group", [raised]) assert module._http_status_of(group) is None + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted(operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, operation + ) + + +class _DeniedService(_FakeService): + def provision(self) -> Any: + raise _planted("GetSecretValue") + + def cleanup(self) -> Iterable[CheckResult]: + self.cleaned = True + raise _planted("DeleteItem") + + +class _DeniedUser(_FakeUser): + def provision(self) -> str: + raise _planted("AdminCreateUser") + + +def test_aws_failures_name_the_code_never_the_message( + loopback: tuple[_FakeDeployment, str], +) -> None: + rows = _run(loopback, service=_DeniedService(), user=_DeniedUser()) + expected = { + "g1_service_principal_provisioned": "GetSecretValue failed (AccessDeniedException)", + "g2_user_provisioned": "AdminCreateUser failed (AccessDeniedException)", + "principal_cleanup": "DeleteItem failed (AccessDeniedException)", + } + for check, text in expected.items(): + assert rows[check].status == "fail" + assert text in rows[check].detail + assert _PLANTED_ARN not in rows[check].detail + + +def test_an_aws_error_inside_a_group_names_the_code_never_the_message() -> None: + group = ExceptionGroup("tasks", [_planted("InvokeAgentRuntime")]) + detail = module._describe(group) + assert "InvokeAgentRuntime failed (AccessDeniedException)" in detail + assert _PLANTED_ARN not in detail diff --git a/tests/unit/test_smoke_mfa_user.py b/tests/unit/test_smoke_mfa_user.py index 7ccb6b9..78a845a 100644 --- a/tests/unit/test_smoke_mfa_user.py +++ b/tests/unit/test_smoke_mfa_user.py @@ -173,3 +173,35 @@ def test_a_pool_that_issues_no_access_token_fails_with_an_actionable_message() - with stubber, pytest.raises(RuntimeError, match="no AccessToken issued"): _provisioner_with(stubber, client).provision() + + +def test_a_failed_deletion_names_the_aws_code_never_the_message() -> None: + planted_arn = "arn:aws:sts::123456789012:assumed-role/x/y" + client = boto3.client("cognito-idp", region_name="us-east-1") + stubber = Stubber(client) + _stub_user_creation(stubber) + stubber.add_response( + "admin_initiate_auth", + {"AuthenticationResult": {"AccessToken": _ACCESS_TOKEN}}, + { + "UserPoolId": _USER_POOL_ID, + "ClientId": _SPA_CLIENT_ID, + "AuthFlow": "ADMIN_USER_PASSWORD_AUTH", + "AuthParameters": ANY, + }, + ) + stubber.add_client_error( + "admin_delete_user", + service_error_code="AccessDeniedException", + service_message=f"User: {planted_arn} is not authorized", + http_status_code=400, + ) + + with stubber: + provisioner = _provisioner_with(stubber, client) + provisioner.provision() + [row] = list(provisioner.cleanup()) + + assert row.status == "fail" + assert "AdminDeleteUser failed (AccessDeniedException)" in row.detail + assert planted_arn not in row.detail diff --git a/tests/unit/test_smoke_no_raw_aws_error.py b/tests/unit/test_smoke_no_raw_aws_error.py new file mode 100644 index 0000000..574ffdb --- /dev/null +++ b/tests/unit/test_smoke_no_raw_aws_error.py @@ -0,0 +1,311 @@ +# SPDX-License-Identifier: MIT +"""Guard: no smoke detail formats the text of an exception that can be an AWS error. + +Inside an `except` handler whose types include `ClientError`, `BotoCoreError` (or any +`botocore.exceptions` class), `Exception` or `BaseException`, the bound exception name must not be +interpolated by an f-string, `str.format`, `%` formatting, `str()` or `repr()`. Passing it to +`aws_error_code`, `aws_error_detail`, `exception_detail` or `error_code`, or reading `type(exc)`, +is allowed. Import aliases, module-level tuples of exception types, and module-local subclasses +are resolved. +""" + +from __future__ import annotations + +import ast +from dataclasses import dataclass, field +from pathlib import Path +from typing import Final + +import pytest + +REPO_ROOT: Final[Path] = Path(__file__).resolve().parents[2] +SMOKE_DIR: Final[Path] = REPO_ROOT / "scripts" / "smoke" + +BROAD_BUILTINS: Final[frozenset[str]] = frozenset({"Exception", "BaseException"}) +BOTOCORE_EXCEPTIONS_MODULE: Final[str] = "botocore.exceptions" +SAFE_CALLS: Final[frozenset[str]] = frozenset( + {"aws_error_code", "aws_error_detail", "exception_detail", "error_code"} +) + + +@dataclass +class _ModuleNames: + """Names in one module that denote AWS-capable exception types, and tuple aliases.""" + + aws_types: set[str] = field(default_factory=set) + exceptions_module_aliases: set[str] = field(default_factory=set) + botocore_aliases: set[str] = field(default_factory=set) + tuples: dict[str, ast.expr] = field(default_factory=dict) + + +@dataclass(frozen=True) +class Violation: + """One handler that formats a broad or AWS exception's text.""" + + path: str + line: int + name: str + construct: str + + def __str__(self) -> str: + return f"{self.path}:{self.line}: {self.construct} interpolates `{self.name}`" + + +def _collect_names(tree: ast.Module) -> _ModuleNames: + names = _ModuleNames() + for node in ast.walk(tree): + if isinstance(node, ast.ImportFrom) and node.module == BOTOCORE_EXCEPTIONS_MODULE: + names.aws_types.update(alias.asname or alias.name for alias in node.names) + elif isinstance(node, ast.ImportFrom) and node.module == "botocore": + for alias in node.names: + if alias.name == "exceptions": + names.exceptions_module_aliases.add(alias.asname or alias.name) + elif isinstance(node, ast.Import): + for alias in node.names: + if alias.name == BOTOCORE_EXCEPTIONS_MODULE and alias.asname: + names.exceptions_module_aliases.add(alias.asname) + elif alias.name.split(".")[0] == "botocore": + names.botocore_aliases.add(alias.asname or "botocore") + for statement in tree.body: + target: ast.expr | None = None + value: ast.expr | None = None + if isinstance(statement, ast.Assign) and len(statement.targets) == 1: + target, value = statement.targets[0], statement.value + elif isinstance(statement, ast.AnnAssign): + target, value = statement.target, statement.value + if isinstance(target, ast.Name) and isinstance(value, ast.Tuple): + names.tuples[target.id] = value + changed = True + while changed: + changed = False + for statement in tree.body: + if ( + isinstance(statement, ast.ClassDef) + and statement.name not in names.aws_types + and any(_is_aws_type(base, names, ()) for base in statement.bases) + ): + names.aws_types.add(statement.name) + changed = True + return names + + +def _is_broad_builtin(node: ast.expr) -> bool: + return isinstance(node, ast.Name) and node.id in BROAD_BUILTINS + + +def _is_aws_type(node: ast.expr, names: _ModuleNames, seen: tuple[str, ...]) -> bool: + """Whether `node` names a botocore exception (directly, via alias, or a local subclass).""" + if isinstance(node, ast.Name): + if node.id in names.aws_types: + return True + if node.id in names.tuples and node.id not in seen: + return _catches_aws_types(names.tuples[node.id], names, (*seen, node.id)) + return False + if isinstance(node, ast.Attribute): + owner = node.value + if isinstance(owner, ast.Name) and owner.id in names.exceptions_module_aliases: + return True + return ( + isinstance(owner, ast.Attribute) + and owner.attr == "exceptions" + and isinstance(owner.value, ast.Name) + and owner.value.id in names.botocore_aliases + ) + return False + + +def _catches_aws_types(node: ast.expr, names: _ModuleNames, seen: tuple[str, ...] = ()) -> bool: + if isinstance(node, ast.Tuple): + return any(_catches_aws_types(element, names, seen) for element in node.elts) + if _is_broad_builtin(node): + return True + if isinstance(node, ast.Attribute) and node.attr in BROAD_BUILTINS: + return isinstance(node.value, ast.Name) and node.value.id == "builtins" + return _is_aws_type(node, names, seen) + + +def _call_name(node: ast.Call) -> str | None: + if isinstance(node.func, ast.Name): + return node.func.id + if isinstance(node.func, ast.Attribute): + return node.func.attr + return None + + +def _mentions(node: ast.AST, name: str) -> bool: + """Whether `node` reads `name` outside a safe helper call or a `type(name)` expression.""" + if isinstance(node, ast.Call) and ( + _call_name(node) in SAFE_CALLS + or (isinstance(node.func, ast.Name) and node.func.id == "type") + ): + return False + if isinstance(node, ast.Name): + return node.id == name + return any(_mentions(child, name) for child in ast.iter_child_nodes(node)) + + +def _formatting_violations(handler: ast.ExceptHandler, path: str) -> list[Violation]: + name = handler.name + assert name is not None + found: list[Violation] = [] + + def flag(node: ast.AST, construct: str) -> None: + found.append(Violation(path, getattr(node, "lineno", handler.lineno), name, construct)) + + for statement in handler.body: + for node in ast.walk(statement): + if isinstance(node, ast.FormattedValue) and _mentions(node.value, name): + flag(node, "f-string") + elif isinstance(node, ast.Call): + callee = _call_name(node) + arguments = [*node.args, *(keyword.value for keyword in node.keywords)] + if callee in ("str", "repr") and isinstance(node.func, ast.Name): + if any(_mentions(argument, name) for argument in arguments): + flag(node, f"{callee}()") + elif ( + callee == "format" + and isinstance(node.func, ast.Attribute) + and any(_mentions(argument, name) for argument in arguments) + ): + flag(node, ".format()") + elif ( + isinstance(node, ast.BinOp) + and isinstance(node.op, ast.Mod) + and isinstance(node.left, ast.Constant) + and isinstance(node.left.value, str) + and _mentions(node.right, name) + ): + flag(node, "% formatting") + return found + + +def scan_source(source: str, path: str) -> tuple[list[Violation], int]: + """Return the violations in `source` and the number of AWS-capable named handlers examined.""" + tree = ast.parse(source) + names = _collect_names(tree) + violations: list[Violation] = [] + examined = 0 + for node in ast.walk(tree): + if ( + isinstance(node, ast.ExceptHandler) + and node.name + and node.type is not None + and _catches_aws_types(node.type, names) + ): + examined += 1 + violations.extend(_formatting_violations(node, path)) + return violations, examined + + +def _smoke_modules() -> list[Path]: + return sorted(SMOKE_DIR.glob("*.py")) + + +def test_no_smoke_module_formats_the_text_of_an_aws_capable_exception() -> None: + """Every handler that can catch an AWS error reports it through the message-free helpers.""" + modules = _smoke_modules() + assert (SMOKE_DIR / "harness.py") in modules, f"the scan read no smoke tree at {SMOKE_DIR}" + violations: list[Violation] = [] + examined = 0 + for module in modules: + found, count = scan_source( + module.read_text(encoding="utf-8"), str(module.relative_to(REPO_ROOT)) + ) + violations.extend(found) + examined += count + assert examined > 0, "no AWS-capable handler was examined, so the guard verified nothing" + assert not violations, "\n".join(str(v) for v in violations) + + +def _violations(source: str) -> list[Violation]: + return scan_source(source, "")[0] + + +@pytest.mark.parametrize( + "source", + [ + "try:\n pass\nexcept Exception as exc:\n detail = f'failed: {exc}'\n", + "try:\n pass\nexcept BaseException as exc:\n detail = str(exc)\n", + ( + "from botocore.exceptions import ClientError as CE\n" + "try:\n pass\nexcept CE as e:\n detail = f'{e!r}'\n" + ), + ( + "import botocore.exceptions as bex\n" + "try:\n pass\nexcept bex.ClientError as e:\n detail = repr(e)\n" + ), + ( + "import botocore\n" + "try:\n pass\nexcept botocore.exceptions.BotoCoreError as e:\n" + " detail = 'failed: {}'.format(e)\n" + ), + ( + "from botocore.exceptions import ClientError\n" + "_AWS = (ClientError, OSError)\n" + "try:\n pass\nexcept _AWS as exc:\n detail = 'failed: %s' % exc\n" + ), + ( + "try:\n pass\nexcept (OSError, Exception) as exc:\n" + " raise RuntimeError(f'could not read: {exc}') from exc\n" + ), + ( + "from botocore.exceptions import ClientError\n" + "try:\n pass\nexcept ClientError as exc:\n" + " detail = f\"{exc.response['Error']['Message']}\"\n" + ), + ( + "from botocore.exceptions import ClientError\n" + "class Denied(ClientError):\n pass\n" + "try:\n pass\nexcept Denied as exc:\n detail = f'{exc}'\n" + ), + ], + ids=[ + "fstring-exception", + "str-baseexception", + "repr-conversion-aliased-clienterror", + "repr-module-alias", + "format-dotted-botocore", + "percent-tuple-alias", + "raise-fstring-mixed-tuple", + "fstring-message-attribute", + "local-subclass", + ], +) +def test_a_formatted_aws_capable_exception_is_flagged(source: str) -> None: + assert len(_violations(source)) == 1, source + + +@pytest.mark.parametrize( + "source", + [ + "try:\n pass\nexcept OSError as exc:\n detail = f'read failed: {exc}'\n", + "try:\n pass\nexcept (ValueError, KeyError) as exc:\n detail = str(exc)\n", + ( + "class LocalError(Exception):\n pass\n" + "try:\n pass\nexcept LocalError as exc:\n detail = f'{exc}'\n" + ), + ( + "try:\n pass\nexcept Exception as exc:\n" + " detail = f'{aws_error_detail(\"sts:GetCallerIdentity\", exc)}'\n" + ), + "try:\n pass\nexcept Exception as exc:\n detail = exception_detail(exc)\n", + "try:\n pass\nexcept Exception as exc:\n detail = f'{type(exc).__name__}'\n", + ( + "try:\n pass\nexcept Exception as exc:\n" + " detail = f'{harness.aws_error_code(exc.__cause__ or exc)}'\n" + ), + "try:\n pass\nexcept Exception:\n detail = 'failed'\n", + ], + ids=[ + "narrow-oserror", + "narrow-tuple", + "local-exception-subclass", + "aws-error-detail", + "exception-detail", + "type-name", + "attribute-helper-on-cause", + "unbound", + ], +) +def test_a_narrow_or_helper_reported_exception_is_allowed(source: str) -> None: + assert _violations(source) == [], source diff --git a/tests/unit/test_smoke_public_exposure.py b/tests/unit/test_smoke_public_exposure.py index d209508..e7f480f 100644 --- a/tests/unit/test_smoke_public_exposure.py +++ b/tests/unit/test_smoke_public_exposure.py @@ -523,7 +523,7 @@ def test_a_get_rest_api_error_yields_a_fail_row_not_a_generator_abort() -> None: """A `get_rest_api` lookup failure emits a fail row rather than raising.""" results = list(rest_api_private_vpce_only(_rest_ctx(error=_NotFoundError("no such REST API")))) assert [r.status for r in results] == ["fail"] - assert "get_rest_api" in results[0].detail + assert "apigateway:GetRestApi failed (ResourceNotFoundException)" in results[0].detail def test_an_absent_api_id_output_fails_rather_than_using_the_hostname() -> None: @@ -882,3 +882,32 @@ def test_this_module_holds_no_second_copy_of_the_freshness_comparison() -> None: "scripts/outputs_provenance.py so the repository has one notion of it" ) assert "assess_freshness" in source + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def test_a_credential_failure_reason_carries_the_code_never_the_message() -> None: + class ClientError(Exception): + def __init__(self) -> None: + super().__init__(f"token expired for {_PLANTED_ARN}") + self.response = {"Error": {"Code": "ExpiredToken", "Message": _PLANTED_ARN}} + + class NoCredentialsError(Exception): + pass + + assert credential_failure_reason(ClientError()) == "ExpiredToken" + assert credential_failure_reason(NoCredentialsError(_PLANTED_ARN)) == "NoCredentialsError" + + +def test_a_rest_api_read_error_names_the_code_never_the_message() -> None: + from botocore.exceptions import ClientError + + error = ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, + "GetRestApi", + ) + [row] = list(rest_api_private_vpce_only(_rest_ctx(error=error))) + assert row.status == "fail" + assert "apigateway:GetRestApi failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail diff --git a/tests/unit/test_smoke_relay_iam.py b/tests/unit/test_smoke_relay_iam.py index f4bc126..c89e221 100644 --- a/tests/unit/test_smoke_relay_iam.py +++ b/tests/unit/test_smoke_relay_iam.py @@ -1064,7 +1064,8 @@ def test_a_control_that_is_denied_or_errors_fails_both_rows(self, decision: str row = results[f"D7[usage_records]{suffix}"] assert row.status == "fail", f"{row.check}: {row.detail}" if decision is None: - assert "error (ClientError" in results["D7[usage_records]_positive_control"].detail + detail = results["D7[usage_records]_positive_control"].detail + assert "error (iam:SimulateCustomPolicy failed (AccessDenied))" in detail @pytest.mark.parametrize("action", [ACTION_DYNAMODB_GET_ITEM, ACTION_DYNAMODB_PUT_ITEM]) def test_a_relay_grant_on_usage_records_reds_its_deny_row(self, action: str) -> None: @@ -1288,7 +1289,8 @@ def test_a_simulate_client_error_fails_the_row_rather_than_raising(self) -> None results = _by_check(_run(iam=iam)[0]) row = results[self._ROW] assert row.status == "fail" - assert "ClientError" in row.detail and "NoSuchEntity" in row.detail + assert "failed (NoSuchEntity)" in row.detail + assert f"{_CHAT_TARGET_ROLE_ARN} not found" not in row.detail assert results["U1_function_url_auth_type"].status == "pass" def test_chat_target_absent_from_the_invokers_fails_the_row( @@ -1486,3 +1488,60 @@ def test_the_policy_text_row_fails_when_the_grant_names_the_tool(self, pattern: ) results = _by_check(_run(iam=iam)[0]) assert results[f"R1[{_AGENT_LESS[0]}]_not_granted_to_runtime_by_policy"].status == "fail" + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted_error(operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": "AccessDenied", "Message": f"{_PLANTED_ARN} is not authorized"}}, + operation, + ) + + +class _PlantedIam(_FakeIam): + """Every simulate of a role other than the relay and the Runtime role, every synthetic Allow + and every `get_role` raise a `ClientError` whose message carries `_PLANTED_ARN`.""" + + def simulate_principal_policy( + self, + *, + PolicySourceArn: str, # noqa: N803 - boto3's own parameter names + ActionNames: list[str], # noqa: N803 + ResourceArns: list[str], # noqa: N803 + ) -> dict[str, Any]: + if PolicySourceArn not in {_RELAY_ROLE_ARN, _RUNTIME_ROLE_ARN}: + raise _planted_error("SimulatePrincipalPolicy") + return super().simulate_principal_policy( + PolicySourceArn=PolicySourceArn, ActionNames=ActionNames, ResourceArns=ResourceArns + ) + + def simulate_custom_policy(self, **kwargs: Any) -> dict[str, Any]: + raise _planted_error("SimulateCustomPolicy") + + def get_role(self, *, RoleName: str) -> dict[str, Any]: # noqa: N803 + raise _planted_error("GetRole") + + +class _PlantedLambda(_FakeLambda): + def get_function_url_config(self, *, FunctionName: str) -> dict[str, Any]: # noqa: N803 + raise _planted_error("GetFunctionUrlConfig") + + +class TestAwsErrorsCarryNoMessage: + def test_a_planted_arn_in_any_aws_error_never_reaches_a_detail(self) -> None: + iam = _PlantedIam(_compliant_decisions(), wildcard=_compliant_wildcard()) + results = _run(iam=iam, lambda_client=_PlantedLambda())[0] + by_check = _by_check(results) + assert not [r for r in results if _PLANTED_ARN in r.detail] + planted_rows = [r for r in results if "failed (AccessDenied)" in r.detail] + assert {r.check for r in planted_rows} >= { + "U1_function_url_auth_type", + "D12_target_role_resolves", + "X1_chat_target_deny_covers_actions_nobody_enumerated", + "D7[usage_records]_positive_control", + } + assert any(r.check.startswith("D15[") for r in planted_rows) + assert any(r.check.startswith("I1[") for r in planted_rows) + assert all(by_check[r.check].status == "fail" for r in planted_rows) diff --git a/tests/unit/test_smoke_resource_protection.py b/tests/unit/test_smoke_resource_protection.py index 5c34eeb..22cd203 100644 --- a/tests/unit/test_smoke_resource_protection.py +++ b/tests/unit/test_smoke_resource_protection.py @@ -595,3 +595,47 @@ def test_a_malformed_state_machine_arn_fails_discovery() -> None: outputs = {**_OUTPUTS, STATE_MACHINE_ARN_OUTPUT: "crm-agent-eval-eval-sweep"} result = _row(_results(outputs=outputs), CHECK_LOG_GROUPS_DISCOVERED) assert result.status == "fail" and STATE_MACHINE_ARN_OUTPUT in result.detail + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted_error(operation: str) -> ClientError: + return ClientError( + { + "Error": { + "Code": "AccessDeniedException", + "Message": f"{_PLANTED_ARN} is not authorized", + } + }, + operation, + ) + + +@pytest.mark.parametrize( + ("check", "kwargs"), + [ + (CHECK_TRAIL_MULTI_REGION, {"fake": _FakeCloudTrail(_planted_error("DescribeTrails"))}), + ( + CHECK_TRAIL_LOGGING, + {"fake": _FakeCloudTrail([_trail()], status=_planted_error("GetTrailStatus"))}, + ), + ( + CHECK_ALB_DELETION_PROTECTION, + {"elbv2": _FakeElbv2(_planted_error("DescribeLoadBalancerAttributes"))}, + ), + (CHECK_LOG_GROUPS_DISCOVERED, {"logs": _FakeLogs(_planted_error("DescribeLogGroups"))}), + ( + CHECK_CODEBUILD_ENCRYPTION_KEY, + {"codebuild": _FakeCodeBuild(_planted_error("BatchGetProjects"))}, + ), + ], +) +def test_an_aws_error_detail_carries_the_code_but_never_the_message( + check: str, kwargs: dict[str, Any] +) -> None: + result = _row(_results(**kwargs), check) + assert result.status == "fail" + assert "AccessDeniedException" in result.detail + assert _PLANTED_ARN not in result.detail + assert "123456789012" not in result.detail diff --git a/tests/unit/test_smoke_runtime_history_iam.py b/tests/unit/test_smoke_runtime_history_iam.py new file mode 100644 index 0000000..2021419 --- /dev/null +++ b/tests/unit/test_smoke_runtime_history_iam.py @@ -0,0 +1,332 @@ +# SPDX-License-Identifier: MIT +"""Unit tests for `scripts/smoke/runtime_history_iam.py`, against fake IAM and DynamoDB clients. + +The fake IAM client evaluates the intended Runtime history policy; each planted weakening of it +reds exactly the rows that guard that statement. +""" + +from __future__ import annotations + +from collections.abc import Callable +from typing import Any + +import botocore.session +import pytest +from scripts.smoke import runtime_history_iam as mod +from scripts.smoke.harness import CheckResult, context_for_test + +_ACCOUNT = "123456789012" +_REGION = "us-east-1" +_ROLE_ARN = f"arn:aws:iam::{_ACCOUNT}:role/crm-agent-eval-runtime-role" +_KEY_ARN = f"arn:aws:kms:{_REGION}:{_ACCOUNT}:key/fixture-dynamodb-cmk" +_TABLES = { + name: f"crm-agent-eval-{name}" + for name in ("reps", "accounts", "opportunities", "audit_records") +} + + +def _table_arn(physical: str) -> str: + return f"arn:aws:dynamodb:{_REGION}:{_ACCOUNT}:table/{physical}" + + +_REPS_ARN = _table_arn(_TABLES["reps"]) + + +def _context_values(context: list[dict[str, Any]] | None, key: str) -> list[str] | None: + for entry in context or []: + if entry["ContextKeyName"] == key: + return list(entry["ContextKeyValues"]) + return None + + +class _PolicyIam: + """Evaluates the intended policy; each flag drops one statement or condition.""" + + def __init__( + self, + *, + null_condition: bool = True, + prefix_deny: bool = True, + canary_deny: bool = True, + not_action_deny: bool = True, + other_tables_deny: bool = True, + attributes_condition: bool = True, + kms_table_condition: bool = True, + kms_via_service: bool = True, + empty_results_for: str | None = None, + ) -> None: + self.null_condition = null_condition + self.prefix_deny = prefix_deny + self.canary_deny = canary_deny + self.not_action_deny = not_action_deny + self.other_tables_deny = other_tables_deny + self.attributes_condition = attributes_condition + self.kms_table_condition = kms_table_condition + self.kms_via_service = kms_via_service + self.empty_results_for = empty_results_for + self.calls: list[dict[str, Any]] = [] + + def simulate_principal_policy(self, **kwargs: Any) -> dict[str, Any]: + self.calls.append(kwargs) + action = kwargs["ActionNames"][0] + resource = kwargs["ResourceArns"][0] + if self.empty_results_for is not None and self.empty_results_for == action: + return {"EvaluationResults": []} + decision = self._decide(action, resource, kwargs.get("ContextEntries")) + return {"EvaluationResults": [{"EvalActionName": action, "EvalDecision": decision}]} + + def _decide(self, action: str, resource: str, context: list[dict[str, Any]] | None) -> str: + if action.startswith("kms:"): + return self._decide_kms(action, context) + keys = _context_values(context, "dynamodb:LeadingKeys") + on_reps = resource == _REPS_ARN or resource.startswith(f"{_REPS_ARN}/index/") + if not on_reps: + return "explicitDeny" if self.other_tables_deny else "implicitDeny" + if action not in mod.GRANTED_ACTIONS or resource != _REPS_ARN: + return "explicitDeny" if self.not_action_deny else "implicitDeny" + if keys is not None: + if self.prefix_deny and any(not k.startswith("history#") for k in keys): + return "explicitDeny" + if self.canary_deny and any(k.startswith("history#canary#") for k in keys): + return "explicitDeny" + if keys is None and self.null_condition: + return "implicitDeny" + if keys is not None and not all(k.startswith("history#") for k in keys): + return "implicitDeny" + attributes = _context_values(context, "dynamodb:Attributes") + if ( + action == mod.PUT_ITEM + and self.attributes_condition + and attributes is not None + and not set(attributes) <= set(mod.HISTORY_ITEM_ATTRIBUTES) + ): + return "implicitDeny" + return "allowed" + + def _decide_kms(self, action: str, context: list[dict[str, Any]] | None) -> str: + if action not in mod.KMS_ACTIONS: + return "implicitDeny" + via = _context_values(context, "kms:ViaService") + table = _context_values(context, "kms:EncryptionContext:aws:dynamodb:tableName") + if self.kms_via_service and via != [f"dynamodb.{_REGION}.amazonaws.com"]: + return "implicitDeny" + if self.kms_table_condition and table != [_TABLES["reps"]]: + return "implicitDeny" + return "allowed" + + +class _FakeDynamoDb: + def __init__(self, *, ttl_status: str = "ENABLED", ttl_attribute: str = "expires_at") -> None: + self.ttl_status = ttl_status + self.ttl_attribute = ttl_attribute + + def describe_table(self, TableName: str) -> dict[str, Any]: # noqa: N803 - boto3 kwarg + table: dict[str, Any] = {"TableName": TableName, "TableArn": _table_arn(TableName)} + if TableName == _TABLES["reps"]: + table["SSEDescription"] = {"KMSMasterKeyArn": _KEY_ARN} + return {"Table": table} + + def describe_time_to_live(self, TableName: str) -> dict[str, Any]: # noqa: N803 + assert TableName == _TABLES["reps"] + return { + "TimeToLiveDescription": { + "TimeToLiveStatus": self.ttl_status, + "AttributeName": self.ttl_attribute, + } + } + + +def _run( + iam: _PolicyIam | None = None, + dynamodb: _FakeDynamoDb | None = None, + outputs: dict[str, Any] | None = None, +) -> list[CheckResult]: + ctx = context_for_test( + clients={"iam": iam or _PolicyIam(), "dynamodb": dynamodb or _FakeDynamoDb()}, + outputs=outputs + if outputs is not None + else {"agentcore_runtime_role_arn": _ROLE_ARN, "dynamodb_table_names": _TABLES}, + region=_REGION, + ) + return list(mod.checks(ctx)) + + +def _failed(results: list[CheckResult]) -> set[str]: + return {r.check for r in results if r.status == "fail"} + + +def test_the_intended_policy_passes_every_row_and_meets_the_derived_minimum() -> None: + results = _run() + assert not _failed(results), [(r.check, r.detail) for r in results if r.status == "fail"] + assert all(r.status == "pass" for r in results) + ctx = context_for_test(outputs={"dynamodb_table_names": _TABLES}, region=_REGION) + assert len(results) == mod.expected_check_count(ctx).minimum + + +def test_every_simulation_targets_the_runtime_role_from_the_output() -> None: + iam = _PolicyIam() + _run(iam=iam) + assert iam.calls + assert {call["PolicySourceArn"] for call in iam.calls} == {_ROLE_ARN} + + +def test_each_foreign_key_row_carries_a_leading_keys_context() -> None: + iam = _PolicyIam() + _run(iam=iam) + no_context = [c for c in iam.calls if not c.get("ContextEntries")] + assert len(no_context) == 1 and no_context[0]["ActionNames"] == [mod.GET_ITEM] + + +_MUTATIONS: list[tuple[str, Callable[[], _PolicyIam], set[str]]] = [ + ( + "null_condition", + lambda: _PolicyIam(null_condition=False), + {"deny_without_leading_keys:dynamodb:GetItem"}, + ), + ( + "prefix_deny", + lambda: _PolicyIam(prefix_deny=False), + { + f"explicit_deny:{action}@{label}" + for action in mod.GRANTED_ACTIONS + for label in ("usersettings#", "conversation#", "rep_id") + }, + ), + ( + "canary_deny", + lambda: _PolicyIam(canary_deny=False), + {f"explicit_deny:{action}@history#canary#" for action in mod.GRANTED_ACTIONS}, + ), + ( + "not_action_deny", + lambda: _PolicyIam(not_action_deny=False), + {f"explicit_deny:{action}@reps" for action in mod.DENIED_TABLE_ACTIONS} + | {"explicit_deny:dynamodb:Query@reps/index"}, + ), + ( + "other_tables_deny", + lambda: _PolicyIam(other_tables_deny=False), + { + f"explicit_deny:dynamodb:GetItem@{name}" + for name in ("accounts", "opportunities", "audit_records") + }, + ), + ( + "attributes_condition", + lambda: _PolicyIam(attributes_condition=False), + {"deny_tenant_attribute:dynamodb:PutItem"}, + ), + ( + "kms_table_condition", + lambda: _PolicyIam(kms_table_condition=False), + {"deny:kms:Decrypt@other_table"}, + ), + ( + "kms_via_service", + lambda: _PolicyIam(kms_via_service=False), + {"deny:kms:Decrypt@without_via_service"}, + ), +] + + +@pytest.mark.parametrize( + ("name", "make_iam", "expected"), _MUTATIONS, ids=[m[0] for m in _MUTATIONS] +) +def test_dropping_one_policy_element_reds_exactly_its_rows( + name: str, make_iam: Callable[[], _PolicyIam], expected: set[str] +) -> None: + assert _failed(_run(iam=make_iam())) == expected, name + + +def test_a_denied_grant_reds_its_allow_rows() -> None: + class _NoGrant(_PolicyIam): + def _decide(self, action: str, resource: str, context: Any) -> str: + decision = super()._decide(action, resource, context) + return "implicitDeny" if decision == "allowed" else decision + + failed = _failed(_run(iam=_NoGrant())) + assert {f"allow:{a}@history#" for a in mod.GRANTED_ACTIONS} <= failed + assert {f"allow:{a}@reps" for a in mod.KMS_ACTIONS} <= failed + + +def test_an_implicit_deny_does_not_satisfy_an_explicit_deny_row() -> None: + class _AllImplicit(_PolicyIam): + def _decide(self, action: str, resource: str, context: Any) -> str: + decision = super()._decide(action, resource, context) + return "implicitDeny" if decision == "explicitDeny" else decision + + failed = _failed(_run(iam=_AllImplicit())) + assert failed and all(check.startswith("explicit_deny:") for check in failed) + + +def test_an_empty_evaluation_is_a_defer_not_a_pass() -> None: + results = _run(iam=_PolicyIam(empty_results_for="dynamodb:Scan")) + row = next(r for r in results if r.check == "explicit_deny:dynamodb:Scan@reps") + assert row.status == "defer" + assert row.defer_reason == "simulate_returned_no_evaluation_result" + + +@pytest.mark.parametrize( + ("status", "attribute", "expected"), + [ + ("ENABLED", "expires_at", "pass"), + ("ENABLING", "expires_at", "defer"), + ("DISABLED", "expires_at", "fail"), + ("ENABLED", "ttl", "fail"), + ], +) +def test_the_ttl_row(status: str, attribute: str, expected: str) -> None: + results = _run(dynamodb=_FakeDynamoDb(ttl_status=status, ttl_attribute=attribute)) + row = next(r for r in results if r.check == "ttl_enabled:expires_at") + assert row.status == expected + + +@pytest.mark.parametrize( + "outputs", + [ + {}, + {"agentcore_runtime_role_arn": _ROLE_ARN}, + {"agentcore_runtime_role_arn": _ROLE_ARN, "dynamodb_table_names": {"reps": "x-reps"}}, + ], + ids=["no_outputs", "no_table_names", "reps_only"], +) +def test_missing_targets_are_one_failing_row_not_a_crash(outputs: dict[str, Any]) -> None: + results = _run(outputs=outputs) + assert len(results) == 1 and results[0].status == "fail" + + +def test_a_table_without_a_cmk_is_a_failure() -> None: + class _NoCmk(_FakeDynamoDb): + def describe_table(self, TableName: str) -> dict[str, Any]: # noqa: N803 + response = super().describe_table(TableName) + response["Table"].pop("SSEDescription", None) + return response + + results = _run(dynamodb=_NoCmk()) + assert [r.check for r in results] == ["history_table_cmk"] + assert results[0].status == "fail" + + +def test_the_denied_actions_are_real_dynamodb_actions() -> None: + operations = set(botocore.session.get_session().get_service_model("dynamodb").operation_names) + iam_only = {"dynamodb:PartiQLSelect", "dynamodb:ConditionCheckItem"} + for action in set(mod.DENIED_TABLE_ACTIONS) - iam_only: + assert action.removeprefix("dynamodb:") in operations, action + for action in mod.GRANTED_ACTIONS: + assert action.removeprefix("dynamodb:") in operations, action + assert {"dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:Scan"} <= set( + mod.DENIED_TABLE_ACTIONS + ) + assert {"dynamodb:BatchWriteItem", "dynamodb:UpdateItem"} <= set(mod.DENIED_TABLE_ACTIONS) + + +def test_the_history_attributes_exclude_tenant() -> None: + assert "tenant" not in mod.HISTORY_ITEM_ATTRIBUTES + assert "expires_at" in mod.HISTORY_ITEM_ATTRIBUTES + assert len(set(mod.HISTORY_ITEM_ATTRIBUTES)) == len(mod.HISTORY_ITEM_ATTRIBUTES) + + +def test_the_history_prefix_is_the_store_key_prefix() -> None: + from crm.store.keys import history_key + + assert history_key("demo", "s").startswith(mod.HISTORY_KEY_PREFIX) diff --git a/tests/unit/test_smoke_runtime_inbound_auth.py b/tests/unit/test_smoke_runtime_inbound_auth.py index 261ca8a..c3cecb2 100644 --- a/tests/unit/test_smoke_runtime_inbound_auth.py +++ b/tests/unit/test_smoke_runtime_inbound_auth.py @@ -370,10 +370,11 @@ def test_another_refusal_code_is_not_the_access_denial(self) -> None: assert row.status == "fail" assert ACCESS_DENIED_CODE in row.detail - def test_the_passing_row_quotes_the_explicit_deny_message(self) -> None: + def test_the_passing_row_names_the_code_and_not_the_deny_message(self) -> None: row = _by_check(_run(_COMPLIANT_RESPONSE))["unlisted_principal_denied_invoking_runtime"] assert row.status == "pass" - assert repr(_EXPLICIT_RESOURCE_DENY) in row.detail + assert f"-> {ACCESS_DENIED_CODE}" in row.detail + assert _EXPLICIT_RESOURCE_DENY not in row.detail def test_an_implicit_deny_is_a_failure_not_a_pass(self) -> None: """A missing identity grant refuses the call before the resource policy is read.""" @@ -384,7 +385,7 @@ def test_an_implicit_deny_is_a_failure_not_a_pass(self) -> None: ) )["unlisted_principal_denied_invoking_runtime"] assert row.status == "fail" - assert repr(_IMPLICIT_DENY) in row.detail + assert _IMPLICIT_DENY not in row.detail assert row.detail.endswith(NOT_RESOURCE_POLICY_DENY) assert OUTSIDE_VPC_BOUND not in row.detail @@ -406,7 +407,7 @@ def test_an_access_denial_not_from_the_resource_policy_fails(self, message: str) _run(_COMPLIANT_RESPONSE, data_plane=_FakeDataPlane(ACCESS_DENIED_CODE, message)) )["unlisted_principal_denied_invoking_runtime"] assert row.status == "fail" - assert repr(message) in row.detail + assert _OPERATOR_ARN not in row.detail assert row.detail.endswith(NOT_RESOURCE_POLICY_DENY) def test_a_resource_policy_deny_naming_another_runtime_fails(self) -> None: @@ -436,7 +437,7 @@ def invoke_agent_runtime(self, **kwargs: Any) -> dict[str, Any]: ] assert row.status == "fail" assert "TimeoutError" in row.detail - assert "read timed out" in row.detail + assert "read timed out" not in row.detail @pytest.mark.parametrize( "role", ["crm-agent-eval-agent-relay-role", "crm-agent-eval-chat-target-role"] @@ -720,7 +721,7 @@ def test_a_cli_read_error_fails_rather_than_deferring(self) -> None: cli = _FakeCli({_RUNTIME: denied, _ENDPOINT: (0, "not json", "")}) rows = self._rows(cli) assert [r.status for r in rows] == ["fail", "fail"] - assert "AccessDeniedException" in rows[0].detail + assert "GetResourcePolicy failed (AccessDeniedException)" in rows[0].detail def test_the_argv_carries_the_resolved_profile_and_region_and_both_arns(self) -> None: cli = _FakeCli({_RUNTIME: _cli_ok(_INVOKER_ARNS), _ENDPOINT: _cli_ok(_INVOKER_ARNS)}) @@ -819,3 +820,64 @@ def test_a_deny_with_any_principal_class_is_not_an_allow(self) -> None: deny = {"Effect": "Deny", "Action": "*", "Resource": "*", "NotPrincipal": {"AWS": "x"}} rows = _principal_rows({_RUNTIME: _policy_with(deny), _ENDPOINT: _policy(_INVOKER_ARNS)}) assert [r.status for r in rows] == ["pass", "pass"] + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted(code: str, operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": code, "Message": f"User: {_PLANTED_ARN} denied"}}, operation + ) + + +class _RaisingSts: + def get_caller_identity(self) -> dict[str, str]: + raise _planted("AccessDenied", "GetCallerIdentity") + + +class TestNoAwsErrorMessageInDetails: + """No row's detail carries an AWS error message; each names the operation and the code.""" + + def test_a_refused_invoke_names_the_code_not_the_message(self) -> None: + message = f"User: {_PLANTED_ARN} is not authorized with an explicit deny" + rows = _run(_COMPLIANT_RESPONSE, data_plane=_FakeDataPlane(ACCESS_DENIED_CODE, message)) + row = _by_check(rows)["unlisted_principal_denied_invoking_runtime"] + assert f"-> {ACCESS_DENIED_CODE}" in row.detail + assert _PLANTED_ARN not in row.detail + + def test_a_failed_caller_read_names_the_code_not_the_message(self) -> None: + ctx = context_for_test( + outputs=_OUTPUTS, + clients={ + "bedrock-agentcore-control": _FakeControlPlane(_COMPLIANT_RESPONSE), + "bedrock-agentcore": _FakeDataPlane(), + "sts": _RaisingSts(), + }, + ) + rows = [ + r + for r in checks(ctx, cli_runner=_FakeCli()) + if r.check in {"caller_is_not_a_runtime_invoker", PRINCIPAL_SET_CHECK} + ] + assert [r.status for r in rows] == ["fail", "fail"] + for row in rows: + assert "sts:GetCallerIdentity failed (AccessDenied)" in row.detail + assert _PLANTED_ARN not in row.detail + + def test_a_failed_botocore_policy_read_names_the_code_not_the_message(self) -> None: + planted = _planted("AccessDeniedException", "GetResourcePolicy") + rows = _principal_rows({_RUNTIME: planted, _ENDPOINT: planted}) + for row in rows: + assert row.status == "fail" + assert "GetResourcePolicy failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail + + def test_a_failed_cli_policy_read_names_the_code_not_the_stderr(self) -> None: + stderr = f"An error occurred (AccessDeniedException) when calling X: User: {_PLANTED_ARN}" + cli = _FakeCli({_RUNTIME: (254, "", stderr), _ENDPOINT: (254, "", "boom " + _PLANTED_ARN)}) + rows = [r for r in _run(_COMPLIANT_RESPONSE, cli=cli) if r.check == PRINCIPAL_SET_CHECK] + assert [r.status for r in rows] == ["fail", "fail"] + assert "GetResourcePolicy failed (AccessDeniedException)" in rows[0].detail + assert "GetResourcePolicy failed (CliExit254)" in rows[1].detail + assert all(_PLANTED_ARN not in r.detail for r in rows) diff --git a/tests/unit/test_smoke_runtime_network_posture.py b/tests/unit/test_smoke_runtime_network_posture.py index 4c7879f..bef69c7 100644 --- a/tests/unit/test_smoke_runtime_network_posture.py +++ b/tests/unit/test_smoke_runtime_network_posture.py @@ -13,6 +13,7 @@ from typing import Any import pytest +from botocore.exceptions import ClientError from scripts import region_map from scripts.smoke.harness import CheckResult, context_for_test from scripts.smoke.runtime_network_posture import ( @@ -717,6 +718,29 @@ def get_agent_runtime_endpoint(self, **_: Any) -> dict[str, Any]: assert [(r.check, r.status) for r in rows] == [("runtime_ready", "fail")] +def test_an_aws_status_read_error_names_the_code_never_the_message() -> None: + planted_arn = "arn:aws:sts::123456789012:assumed-role/x/y" + + class _Denied(_FakeControlPlane): + def get_agent_runtime_endpoint(self, **_: Any) -> dict[str, Any]: + raise ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {planted_arn}"}}, + "GetAgentRuntimeEndpoint", + ) + + ctx = context_for_test( + outputs=_OUTPUTS, + clients={ + "bedrock-agentcore-control": _Denied(_COMPLIANT_RUNTIME, _ALLOW_ONLY_POLICY), + "ec2": _FakeEc2(), + }, + ) + [row] = list(checks(ctx)) + assert row.status == "fail" + assert "GetAgentRuntimeEndpoint failed (AccessDeniedException)" in row.detail + assert planted_arn not in row.detail + + class _RawResponse: def __init__(self, body: dict[str, Any]) -> None: self.content = json.dumps(body).encode() diff --git a/tests/unit/test_smoke_store_principal_deny.py b/tests/unit/test_smoke_store_principal_deny.py index a2ae9ed..8c7f6c3 100644 --- a/tests/unit/test_smoke_store_principal_deny.py +++ b/tests/unit/test_smoke_store_principal_deny.py @@ -22,6 +22,7 @@ import scripts.smoke.store_principal_deny as smoke from botocore import xform_name from botocore.awsrequest import AWSResponse +from botocore.exceptions import ClientError from botocore.validate import validate_parameters from scripts.smoke.harness import DEFER, CheckResult, context_for_test @@ -1425,7 +1426,7 @@ def test_state_operator_list_must_match_the_stack_output(tmp_path: Path) -> None smoke.PROBE_GENERATE_DATA_KEY, Err("KMSInvalidStateException", "key is pending deletion"), DEFER, - "KMSInvalidStateException: key is pending deletion", + "unclassified error (KMSInvalidStateException)", ), ( smoke.STATE_LOG_BUCKET, @@ -1690,7 +1691,7 @@ def test_admin_simulation_pair_fails_when_the_deny_matches_the_operator_too( (_implicit_deny("logs:FilterLogEvents", _LOG_GROUP_ARN), "fail"), ], ) -def test_logs_probe_is_classified_and_unclassified_wording_defers_with_the_message( +def test_logs_probe_is_classified_and_unclassified_wording_defers_with_the_code( tmp_path: Path, outcome: Err, status: str ) -> None: account = FakeAccount(logs_outcome=outcome) @@ -1698,7 +1699,8 @@ def test_logs_probe_is_classified_and_unclassified_wording_defers_with_the_messa assert row.status == status if status == DEFER: assert row.defer_reason == "probe_call_unclassified_error" - assert outcome.message in row.detail + assert outcome.code in row.detail + assert outcome.message not in row.detail def test_a_successful_logs_read_defers_as_not_key_gated_and_never_passes(tmp_path: Path) -> None: @@ -2334,3 +2336,44 @@ def test_key_policy_for_simulation_rewrites_only_star_resources() -> None: ) single = json.loads(key_policy_for_simulation(untouched, _CURSOR_KEY_ARN))["Statement"] assert (single["Resource"], single["NotResource"]) == ("x", "*") + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted(code: str, operation: str, status: int = 400) -> ClientError: + return ClientError( + { + "Error": {"Code": code, "Message": f"User: {_PLANTED_ARN} is not authorized"}, + "ResponseMetadata": {"HTTPStatusCode": status}, + }, + operation, + ) + + +class _DeniedLambda: + def get_function_configuration(self, **_: Any) -> dict[str, Any]: + raise _planted("AccessDeniedException", "GetFunctionConfiguration") + + +class TestNoAwsErrorMessageInDetails: + """A raised AWS call and a reached-resource probe name the code, never the message.""" + + def test_the_raised_descriptor_carries_the_code_only(self) -> None: + detail = smoke._raised("describe-table of t", _planted("AccessDeniedException", "X")) + assert detail == "describe-table of t raised AccessDeniedException" + + def test_a_failed_discovery_call_names_the_code_only(self) -> None: + ctx = context_for_test(clients={"lambda": _DeniedLambda()}) + result = smoke.discover_cursor_key(ctx) + assert isinstance(result, smoke.Unavailable) + assert "raised AccessDeniedException" in result.detail + assert _PLANTED_ARN not in result.detail + + def test_a_reached_resource_probe_names_the_code_only(self) -> None: + row = smoke.classify_store_probe( + "s:GetObject", "bucket", _planted("NoSuchKey", "GetObject", 404), _PROBE_ROLE + ) + assert row.status == "fail" + assert "reached the resource" in row.detail and "NoSuchKey" in row.detail + assert _PLANTED_ARN not in row.detail diff --git a/tests/unit/test_smoke_three_tier_chat.py b/tests/unit/test_smoke_three_tier_chat.py index ab667cd..4f4697d 100644 --- a/tests/unit/test_smoke_three_tier_chat.py +++ b/tests/unit/test_smoke_three_tier_chat.py @@ -6,8 +6,14 @@ from __future__ import annotations +import inspect +import io import json +import re +import urllib.error from collections.abc import Iterable, Mapping +from decimal import Decimal +from email.message import Message from pathlib import Path from typing import Any @@ -16,6 +22,7 @@ from scripts.smoke import three_tier_chat from scripts.smoke.harness import CheckResult, context_for_test from scripts.smoke.three_tier_chat import ( + _CACHE_HISTORY_INSTRUCTION, _CLOUDTRAIL_MAX_PAGES, _CLOUDTRAIL_POLL_INTERVAL, _CLOUDTRAIL_POLL_SECONDS, @@ -31,7 +38,19 @@ ATTRIBUTION_CANDIDATES, ATTRIBUTION_COLLISION_CHECK, ATTRIBUTION_ROW_SUFFIX, + CACHE_HISTORY_CHECK, + CACHE_HISTORY_TOOL_CALL_REASON, + CACHE_HISTORY_TURNS, CACHE_UNREPORTED_REASON, + HISTORY_FAILURE_EVENTS, + HISTORY_ITEM_CHECK, + HISTORY_ITEMS_DELETED_CHECK, + HISTORY_LOG_CHECK, + HISTORY_OMITTED_RESUME_CHECK, + HISTORY_RECALL_CHECK, + HISTORY_RECALL_PROMPT, + HISTORY_RECALL_TURNS, + HISTORY_REPEAT_PROMPT, MIXED_FAMILIES, MODEL_TURN_ALLOTMENTS, MODEL_TURN_ENVELOPE, @@ -41,20 +60,36 @@ RESOURCE_CLASS, CloudTrailEvent, ModelTurnBudget, + ResumeCursor, + RuntimeLogLine, TurnResult, _live_cloudtrail_lookup, + _live_run_turn, + _live_runtime_log_lookup, + _LiveTurns, + _poll_history_logs, _tier_attributed, _tier_profiles, attribution_collision_row, + cache_history_prompt, checks, + delete_history_items, + evaluate_cache_history, evaluate_cache_read, evaluate_history_cross_session, + evaluate_history_item, + evaluate_history_logs, + evaluate_history_recall, + evaluate_omitted_resume_recall, evaluate_page_context_refusal, evaluate_temperature_refusal, evaluate_three_tier_attribution, evaluate_turn_cost, + expected_check_count, expected_tier_efforts, expected_tier_models, + history_code_word, + history_fact_prompt, page_context_for, refused_routes, select_attribution_mapping, @@ -62,9 +97,15 @@ tuning_block, ) +from agents.conversation_history import ( + DEFAULT_TTL_SECONDS, + HISTORY_ITEM_ATTRIBUTES, + DynamoDbConversationHistory, +) from agents.registry import tool_registry_for from agents.runtime_server import _VALIDATION_ERROR_KIND from agents.supervisor import DIRECT_TOOL_NAMES +from crm.store.keys import history_key from providers.capabilities import load_capability_matrix from providers.tier_tuning import WIRE_SCHEMA_VERSION @@ -328,6 +369,35 @@ def test_owner_control_fails_when_reuse_rejected_and_stops() -> None: # --- checks() end-to-end, fully injected --- +def _tenant_of(token: str) -> str: + """The disposable tenant `_FakeProvisioner` allocates for `token`.""" + return f"eval-smoke-{token}" + + +#: `expires_at` the fake Runtime stamps on a history item: inside `_run`'s clock window plus the TTL. +_FAKE_EXPIRES_AT = 50_000 + +#: How check 9's turn A states its fact; the fake reads the code word back out of it. +_FACT_PREFIX = history_fact_prompt("\0").split("\0")[0] + + +class _FakeHistoryItems: + """`HistoryItems` over a dict; `sticky` keys survive `delete`, as a refused delete would.""" + + def __init__(self, items: dict[str, dict[str, Any]], *, sticky: Iterable[str] = ()) -> None: + self.items = items + self.deleted: list[str] = [] + self._sticky = set(sticky) + + def get(self, rep_id: str) -> Mapping[str, Any] | None: + return self.items.get(rep_id) + + def delete(self, rep_id: str) -> None: + self.deleted.append(rep_id) + if rep_id not in self._sticky: + self.items.pop(rep_id, None) + + class _FakeProvisioner: def __init__(self, token: str) -> None: self._token = token @@ -336,6 +406,9 @@ def __init__(self, token: str) -> None: def provision(self) -> str: return self._token + def tenant(self) -> str: + return _tenant_of(self._token) + def cleanup(self) -> Iterable[CheckResult]: self.cleaned_up = True yield CheckResult( @@ -343,7 +416,9 @@ def cleanup(self) -> Iterable[CheckResult]: ) -def _priced_frame(tuning: Mapping[str, Any]) -> dict[str, Any]: +def _priced_frame( + tuning: Mapping[str, Any], *, cache_read: int = 1024, cache_write: int = 0 +) -> dict[str, Any]: """A `completed` frame priced and resolved the way the Runtime renders one for `tuning`.""" tiers = tuning["tiers"] families = {tier: tiers[tier]["family"] for tier in tiers} @@ -357,8 +432,8 @@ def _priced_frame(tuning: Mapping[str, Any]) -> dict[str, Any]: "role": tier, "model_id": model, "cost_usd": 0.01, - "cache_read_tokens": 1024, - "cache_write_tokens": 0, + "cache_read_tokens": cache_read, + "cache_write_tokens": cache_write, "long_context_calls": 0, } for tier, model in models.items() @@ -394,12 +469,22 @@ def _carries_temperature(tuning: Mapping[str, Any]) -> bool: return any("temperature" in request for request in tuning["tiers"].values()) -def _completed(text: str = "", tuning: Mapping[str, Any] | None = None) -> TurnResult: +def _completed( + text: str = "", + tuning: Mapping[str, Any] | None = None, + *, + cache_read: int = 1024, + cache_write: int = 0, +) -> TurnResult: return TurnResult( status=200, kinds=("text_delta", "completed"), answer=text, - completed=_priced_frame(tuning) if tuning is not None else None, + completed=( + _priced_frame(tuning, cache_read=cache_read, cache_write=cache_write) + if tuning is not None + else None + ), ) @@ -417,7 +502,19 @@ class _StatefulTurns: A different token reusing an owned session id gets a 400 with the generic validation message; `bad_collision` returns a completed 200 instead. A `page_context` whose route is not `_CONTROL_ROUTE` is refused with that 400; `accepts_bad_route` completes it instead and - `echoes_route` puts the route in the refusal body. + `echoes_route` puts the route in the refusal body. The n-th completed turn in a session reports + `1024 * n` cache-read and 256 cache-write tokens on every cost line, as a growing cached history + would. + + A turn stating check 9's code word is remembered for its session, and a recall prompt in that + session answers with it; `forgets_history` answers every recall without it and `leaks_history` + answers a recall in any session with the last code word stated. Each completed turn writes its + session's history item into `history` unless `records_history` is false. + + Every accepted turn appends an `invocation_started` line to `log_lines`, in the stream + `runtime-logs-`; `history_failure` adds that failure event's line to the stream of + every completed turn. `replays_omitted_resume` answers a turn sent without `resume_from` with + its session's previous result verbatim, as a Runtime that treats it as a reconnect would. """ def __init__( @@ -427,8 +524,25 @@ def __init__( honours_temperature: bool = False, accepts_bad_route: bool = False, echoes_route: bool = False, + forgets_history: bool = False, + leaks_history: bool = False, + records_history: bool = True, + history_failure: str | None = None, + replays_omitted_resume: bool = False, ) -> None: + self._history_failure = history_failure + self._replays_omitted_resume = replays_omitted_resume + self._last_by_session: dict[str, TurnResult] = {} + self.log_lines: list[RuntimeLogLine] = [] + self.omitted: list[bool] = [] + self._forgets_history = forgets_history + self._leaks_history = leaks_history + self._records_history = records_history + self._facts: dict[str, str] = {} + self._last_fact = "" + self.history: dict[str, dict[str, Any]] = {} self._owner_by_session: dict[str, str] = {} + self._turns_by_session: dict[str, int] = {} self._bad_collision = bad_collision self._honours_temperature = honours_temperature self._accepts_bad_route = accepts_bad_route @@ -446,10 +560,12 @@ def __call__( tuning: Mapping[str, Any], *, page_context: Mapping[str, Any] | None = None, + omit_resume_from: bool = False, ) -> TurnResult: self.tunings.append(tuning) self.prompts.append(prompt) self.page_contexts.append(page_context) + self.omitted.append(omit_resume_from) if _carries_temperature(tuning) and not self._honours_temperature: return _refusal() route = (page_context or {}).get("route", _CONTROL_ROUTE) @@ -460,13 +576,64 @@ def __call__( if self._bad_collision: return _completed("") # not refused at all -> should red the denial return TurnResult(status=400, kinds=(), answer="", message=_GENERIC_VALIDATION_MESSAGE) - return _completed("noted", tuning) + stream = f"runtime-logs-{session_id}" + self.log_lines.append( + RuntimeLogLine( + stream=stream, + message=json.dumps({"event": "invocation_started", "session_id": session_id}), + ) + ) + previous = self._last_by_session.get(session_id) + if omit_resume_from and self._replays_omitted_resume and previous is not None: + return previous + count = self._turns_by_session[session_id] = self._turns_by_session.get(session_id, 0) + 1 + if prompt.startswith(_FACT_PREFIX): + self._facts[session_id] = self._last_fact = prompt[len(_FACT_PREFIX) :].split(".")[0] + answer = "noted" + if prompt in (HISTORY_RECALL_PROMPT, HISTORY_REPEAT_PROMPT): + remembered = self._last_fact if self._leaks_history else self._facts.get(session_id) + answer = "I do not know." if self._forgets_history or not remembered else remembered + if self._records_history: + tenant = _tenant_of(token) + self.history[history_key(tenant, session_id)] = { + "rep_id": history_key(tenant, session_id), + "kind": "history", + "owner_rep_id": f"user-{token}", + "owner_tenant": tenant, + "turns": [{"prompt": prompt, "answer": answer}] * count, + "version": count, + "updated_at": "2026-11-15T00:00:00+00:00", + "expires_at": _FAKE_EXPIRES_AT, + } + if self._history_failure is not None: + self.log_lines.append( + RuntimeLogLine(stream=stream, message=json.dumps({"event": self._history_failure})) + ) + result = _completed(answer, tuning, cache_read=1024 * count, cache_write=256) + self._last_by_session[session_id] = result + return result + + +def _history_of(run_turn: object) -> dict[str, dict[str, Any]]: + """The history items a fake Runtime wrote, unwrapping `_CapturingTurns`.""" + inner = getattr(run_turn, "_inner", run_turn) + history: dict[str, dict[str, Any]] = getattr(inner, "history", {}) + return history + + +def _log_lines_of(run_turn: object) -> list[RuntimeLogLine]: + """The Runtime log lines a fake Runtime wrote, unwrapping `_CapturingTurns`.""" + inner = getattr(run_turn, "_inner", run_turn) + lines: list[RuntimeLogLine] = getattr(inner, "log_lines", []) + return lines def _run( *, events: list[CloudTrailEvent], run_turn: object, + history_items: _FakeHistoryItems | None = None, + runtime_logs: Any = None, ) -> tuple[dict[str, str], list[_FakeProvisioner]]: provs: list[_FakeProvisioner] = [] tokens = iter(["token-A", "token-B"]) @@ -482,6 +649,7 @@ def lookup(_ctx: object, _s: int, _e: int) -> list[CloudTrailEvent]: # Each tick exceeds the CloudTrail poll window, so the poll deadline is reached in one step. ticks = iter(range(1000, 1_000_000, 1000)) + items = history_items if history_items is not None else _FakeHistoryItems(_history_of(run_turn)) ctx = context_for_test(outputs={"agentcore_runtime_role_arn": _ROLE_ARN}, clients={}) rows = list( checks( @@ -491,6 +659,12 @@ def lookup(_ctx: object, _s: int, _e: int) -> list[CloudTrailEvent]: cloudtrail_lookup=lookup, clock=lambda: float(next(ticks)), sleeper=lambda _s: None, + history_items=lambda _ctx: items, + runtime_logs=( + runtime_logs + if runtime_logs is not None + else lambda _c, _s, _e: list(_log_lines_of(run_turn)) + ), ) ) return {r.check: r.status for r in rows}, provs @@ -526,6 +700,11 @@ def test_checks_happy_path_all_pass_and_both_users_cleaned_up() -> None: assert set(attribution_rows.values()) == {"pass"} assert by_check["stale_temperature_tuning_refused"] == "pass" assert by_check["model_backed_turns_within_envelope"] == "pass" + assert by_check[HISTORY_RECALL_CHECK] == "pass" + assert by_check[HISTORY_OMITTED_RESUME_CHECK] == "pass" + assert by_check[HISTORY_LOG_CHECK] == "pass" + assert by_check[HISTORY_ITEM_CHECK] == "pass" + assert by_check[HISTORY_ITEMS_DELETED_CHECK] == "pass" assert by_check["cleaned_up"] == "pass" assert len(provs) == 2 assert all(p.cleaned_up for p in provs) @@ -892,7 +1071,7 @@ def test_a_spent_budget_refuses_the_openai_turn_after_check_4( monkeypatch: pytest.MonkeyPatch, ) -> None: allotments = dict(MODEL_TURN_ALLOTMENTS) - allotments[RESOURCE_CLASS] -= 2 + allotments[RESOURCE_CLASS] -= CACHE_HISTORY_TURNS + HISTORY_RECALL_TURNS + 2 monkeypatch.setattr(three_tier_chat, "MODEL_TURN_ALLOTMENTS", allotments) turns = _StatefulTurns() by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=turns) @@ -1237,6 +1416,7 @@ def test_lookup_raises_rather_than_truncating_at_the_page_cap() -> None: # --- check 6: prompt-cache read on the wire --- +_TIER_NAMES = ("supervisor", "subagent", "tool") _ANTHROPIC_SUPERVISOR = expected_tier_models(MIXED_FAMILIES)["supervisor"] _OPENAI_SUPERVISOR = expected_tier_models(OPENAI_FAMILIES)["supervisor"] @@ -1361,7 +1541,7 @@ def test_a_spent_budget_refuses_the_cache_probe_and_its_page_context_rows( monkeypatch: pytest.MonkeyPatch, ) -> None: allotments = dict(MODEL_TURN_ALLOTMENTS) - allotments[RESOURCE_CLASS] -= 1 + allotments[RESOURCE_CLASS] -= CACHE_HISTORY_TURNS + HISTORY_RECALL_TURNS + 1 monkeypatch.setattr(three_tier_chat, "MODEL_TURN_ALLOTMENTS", allotments) turns = _StatefulTurns() by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=turns) @@ -1452,3 +1632,783 @@ def test_a_runtime_that_accepts_or_echoes_the_route_fails_both_rows_end_to_end( ) -> None: by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=turns) assert [by_check[row] for row in _ROUTE_ROWS] == ["fail", "fail"] + + +# --- check 8: prompt-cache reads cover session history --- + + +def _history_turn( + read: object, write: object = 0, *, kinds: tuple[str, ...] = ("text_delta", "completed") +) -> TurnResult: + """A recorded-shape tool-free turn: the one supervisor cost line a single-call turn carries.""" + lines = [ + { + "tier": "supervisor", + "role": "supervisor", + "model_id": _ANTHROPIC_SUPERVISOR, + "cost_usd": 0.01, + "cache_read_tokens": read, + "cache_write_tokens": write, + "long_context_calls": 0, + } + ] + return TurnResult( + status=200, + kinds=kinds, + answer="Ready.", + completed={"kind": "completed", "cost_lines": lines, "cost_usd": 0.01}, + ) + + +def _history_row(fresh: TurnResult, seed: TurnResult, followup: TurnResult) -> CheckResult: + return evaluate_cache_history(fresh, seed, followup, model=_ANTHROPIC_SUPERVISOR) + + +def test_a_follow_up_reading_beyond_the_fresh_prefix_passes() -> None: + row = _history_row(_history_turn(4400), _history_turn(4400, 300), _history_turn(4700)) + assert (row.check, row.status) == (CACHE_HISTORY_CHECK, "pass") + + +def test_a_follow_up_reading_only_the_fresh_prefix_fails() -> None: + row = _history_row(_history_turn(4400), _history_turn(4400), _history_turn(4400)) + assert row.status == "fail" + + +def test_a_follow_up_reading_less_than_the_fresh_prefix_fails() -> None: + assert _history_row(_history_turn(4400), _history_turn(0), _history_turn(100)).status == "fail" + + +def test_no_read_and_no_write_on_any_turn_defers() -> None: + row = _history_row(_history_turn(0), _history_turn(0), _history_turn(0)) + assert (row.status, row.defer_reason) == ("defer", CACHE_UNREPORTED_REASON) + + +def test_a_write_with_no_follow_up_read_fails_rather_than_defers() -> None: + row = _history_row(_history_turn(0, 4400), _history_turn(0), _history_turn(0)) + assert row.status == "fail" + + +@pytest.mark.parametrize("position", [0, 1, 2], ids=["C", "A", "B"]) +def test_a_tool_call_on_any_turn_defers_even_when_the_reads_would_pass(position: int) -> None: + turns = [_history_turn(4400), _history_turn(4400), _history_turn(4700)] + turns[position] = _history_turn( + turns[position].completed["cost_lines"][0]["cache_read_tokens"], # type: ignore[index] + kinds=("tool_call", "tool_result", "text_delta", "completed"), + ) + row = _history_row(*turns) + assert (row.status, row.defer_reason) == ("defer", CACHE_HISTORY_TOOL_CALL_REASON) + + +@pytest.mark.parametrize( + "followup", + [TurnResult(status=502, kinds=(), answer=""), _history_turn(None), _history_turn(True)], + ids=["no_frame", "null_read", "bool_read"], +) +def test_an_unreadable_turn_fails_rather_than_defers(followup: TurnResult) -> None: + assert _history_row(_history_turn(4400), _history_turn(4400), followup).status == "fail" + + +def _is_history_prompt(prompt: str) -> bool: + return prompt.startswith(_CACHE_HISTORY_INSTRUCTION) + + +def _history_prompts(turns: _StatefulTurns) -> list[str]: + return [p for p in turns.prompts if _is_history_prompt(p)] + + +def test_c_a_and_b_share_one_prompt_carrying_a_run_nonce() -> None: + turns = _StatefulTurns() + _run(events=_ALL_TIER_EVENTS, run_turn=turns) + prompts = _history_prompts(turns) + assert len(prompts) == CACHE_HISTORY_TURNS + assert len(set(prompts)) == 1 + assert re.search(r"Ignore this cache-busting nonce: [0-9a-f]{32}\.$", prompts[0]) + + +def test_two_runs_send_different_check_8_prompts() -> None: + first, second = _StatefulTurns(), _StatefulTurns() + _run(events=_ALL_TIER_EVENTS, run_turn=first) + _run(events=_ALL_TIER_EVENTS, run_turn=second) + assert _history_prompts(first)[0] != _history_prompts(second)[0] + + +def test_the_prompt_nonce_leaves_the_instruction_unchanged() -> None: + assert cache_history_prompt("abc") == ( + f"{_CACHE_HISTORY_INSTRUCTION} Ignore this cache-busting nonce: abc." + ) + assert cache_history_prompt("abc") != cache_history_prompt("abd") + + +def test_check_8_sends_c_fresh_then_a_and_b_in_one_session_as_anthropic() -> None: + turns = _CapturingTurns() + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=turns) + prompts, tunings = turns._inner.prompts, turns._inner.tunings + indices = [i for i, p in enumerate(prompts) if _is_history_prompt(p)] + assert len(indices) == CACHE_HISTORY_TURNS + fresh, seed, followup = (turns.session_ids[i] for i in indices) + assert seed == followup and fresh != seed + assert fresh not in turns.session_ids[: indices[0]] + assert seed not in turns.session_ids[: indices[1]] + anthropic = tuning_block(dict.fromkeys(_TIER_NAMES, "anthropic")) + assert all(tunings[i] == anthropic for i in indices) + assert expected_tier_models(dict.fromkeys(_TIER_NAMES, "anthropic"))["supervisor"] == ( + _ANTHROPIC_SUPERVISOR + ) + assert by_check[CACHE_HISTORY_CHECK] == "pass" + + +def test_the_happy_path_fake_reads_more_on_a_session_follow_up() -> None: + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns()) + assert by_check[CACHE_HISTORY_CHECK] == "pass" + + +def test_a_runtime_caching_only_the_stable_prefix_fails_check_8_end_to_end() -> None: + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_CacheTurns(4400, 0)) + assert by_check[CACHE_HISTORY_CHECK] == "fail" + + +@pytest.mark.parametrize("short", [1, CACHE_HISTORY_TURNS]) +def test_a_share_without_room_for_all_three_turns_sends_none_of_them( + monkeypatch: pytest.MonkeyPatch, short: int +) -> None: + allotments = dict(MODEL_TURN_ALLOTMENTS) + allotments[RESOURCE_CLASS] -= HISTORY_RECALL_TURNS + short + monkeypatch.setattr(three_tier_chat, "MODEL_TURN_ALLOTMENTS", allotments) + turns = _StatefulTurns() + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=turns) + assert not any(_is_history_prompt(p) for p in turns.prompts) + assert CACHE_HISTORY_CHECK not in by_check + assert all(by_check[row] == "pass" for row in _ROUTE_ROWS) + + +# --- check 9: a follow-up turn carries the session's history --- + +_WORD = "zqfeedc0ffee12" + + +def _recall_turn( + answer: str, read: object = 4400, write: object = 120, *, status: int = 200 +) -> TurnResult: + """A tool-free anthropic-supervisor turn answering `answer` with the given cache counts.""" + turn = _history_turn(read, write) + return TurnResult(status=status, kinds=turn.kinds, answer=answer, completed=turn.completed) + + +def _recall_row( + seed: TurnResult | None = None, + followup: TurnResult | None = None, + control: TurnResult | None = None, +) -> CheckResult: + return evaluate_history_recall( + seed if seed is not None else _recall_turn("OK", 0, 4400), + followup if followup is not None else _recall_turn(_WORD, 4400, 120), + control if control is not None else _recall_turn("I do not know.", 4300, 90), + code_word=_WORD, + model=_ANTHROPIC_SUPERVISOR, + ) + + +def test_a_recalled_word_with_a_new_cached_tail_and_a_clean_control_passes() -> None: + row = _recall_row() + assert (row.check, row.status) == (HISTORY_RECALL_CHECK, "pass") + + +def test_the_content_alone_without_a_new_cache_write_fails() -> None: + assert _recall_row(followup=_recall_turn(_WORD, 4400, 0)).status == "fail" + + +def test_the_tokens_alone_without_the_recalled_word_fails() -> None: + assert _recall_row(followup=_recall_turn("I do not know.", 4400, 120)).status == "fail" + + +def test_a_control_that_carries_the_word_fails() -> None: + row = _recall_row(control=_recall_turn(f"It is {_WORD}.", 4300, 90)) + assert row.status == "fail" + assert "crossed sessions" in row.detail + + +def test_a_follow_up_reading_less_than_the_seed_fails() -> None: + row = _recall_row(seed=_recall_turn("OK", 4400, 100), followup=_recall_turn(_WORD, 4000, 120)) + assert row.status == "fail" + + +def test_a_control_that_did_not_complete_fails() -> None: + assert _recall_row(control=TurnResult(status=502, kinds=(), answer="")).status == "fail" + + +@pytest.mark.parametrize( + "followup", + [ + TurnResult(status=502, kinds=(), answer=_WORD), + _recall_turn(_WORD, None), + _recall_turn(_WORD, True), + ], + ids=["no_frame", "null_read", "bool_read"], +) +def test_an_unreadable_follow_up_fails(followup: TurnResult) -> None: + assert _recall_row(followup=followup).status == "fail" + + +def test_the_code_word_is_run_unique_and_only_in_the_fact_prompt() -> None: + word = history_code_word() + assert word != history_code_word() + assert word in history_fact_prompt(word) + assert word not in HISTORY_RECALL_PROMPT + assert history_fact_prompt(word).startswith(_FACT_PREFIX) + + +_TTL = DEFAULT_TTL_SECONDS +_ABSENT = object() +_NOW = 1_000_000.0 + + +def _item(**overrides: Any) -> dict[str, Any]: + tenant = _tenant_of("token-A") + item: dict[str, Any] = { + "rep_id": history_key(tenant, "s"), + "kind": "history", + "owner_rep_id": "user-a", + "owner_tenant": tenant, + "turns": [{"prompt": "p", "answer": "a"}], + "version": 1, + "updated_at": "2026-11-15T00:00:00+00:00", + "expires_at": int(_NOW) + _TTL - 5, + } + item.update(overrides) + return {key: value for key, value in item.items() if value is not _ABSENT} + + +def _item_row(item: Mapping[str, Any] | None) -> CheckResult: + return evaluate_history_item(item, tenant=_tenant_of("token-A"), now=_NOW, ttl_seconds=_TTL) + + +def test_the_ttl_is_the_history_stores_default() -> None: + default = inspect.signature(DynamoDbConversationHistory).parameters["ttl_seconds"].default + assert default == _TTL + assert isinstance(_TTL, int) and _TTL > 0 + + +def test_the_fixture_item_carries_exactly_the_stores_attribute_set() -> None: + assert set(_item()) == HISTORY_ITEM_ATTRIBUTES + + +def test_an_owned_item_expiring_within_the_ttl_passes() -> None: + row = _item_row(_item()) + assert (row.check, row.status) == (HISTORY_ITEM_CHECK, "pass") + + +def test_a_decimal_expiry_is_read_as_a_number() -> None: + assert _item_row(_item(expires_at=Decimal(int(_NOW) + 60))).status == "pass" + + +@pytest.mark.parametrize( + "overrides", + [ + {"owner_tenant": "eval-smoke-token-B"}, + {"owner_rep_id": ""}, + {"owner_rep_id": None}, + {"kind": "conversation"}, + {"expires_at": int(_NOW)}, + {"expires_at": int(_NOW) + _TTL + 1}, + {"expires_at": True}, + {"expires_at": "9999999999"}, + {"tenant": "eval-smoke-token-A"}, + {"updated_at": _ABSENT}, + ], + ids=[ + "foreign_tenant", + "empty_owner", + "no_owner", + "wrong_kind", + "expired", + "beyond_ttl", + "bool_expiry", + "string_expiry", + "tenant_attribute", + "missing_attribute", + ], +) +def test_an_item_not_owned_or_not_expiring_in_the_ttl_fails(overrides: dict[str, Any]) -> None: + assert _item_row(_item(**overrides)).status == "fail" + + +def test_an_absent_item_fails() -> None: + assert _item_row(None).status == "fail" + + +def test_deleting_the_history_items_proves_each_absent() -> None: + items = _FakeHistoryItems({"k1": {}, "k2": {}}) + row = delete_history_items(items, ["k1", "k2", "k3"]) + assert (row.check, row.status) == (HISTORY_ITEMS_DELETED_CHECK, "pass") + assert items.items == {} + assert items.deleted == ["k1", "k2", "k3"] + + +def test_an_item_surviving_its_delete_fails_the_row() -> None: + row = delete_history_items(_FakeHistoryItems({"k1": {}}, sticky=["k1"]), ["k1"]) + assert row.status == "fail" + assert "k1" in row.detail + + +def test_a_delete_error_fails_the_row_rather_than_raising() -> None: + class _Refusing(_FakeHistoryItems): + def delete(self, rep_id: str) -> None: + raise RuntimeError("AccessDenied") + + assert delete_history_items(_Refusing({}), ["k1"]).status == "fail" + + +def _recall_indices(prompts: list[str]) -> list[int]: + return [ + i + for i, p in enumerate(prompts) + if p.startswith(_FACT_PREFIX) or p in (HISTORY_RECALL_PROMPT, HISTORY_REPEAT_PROMPT) + ] + + +def test_check_9_sends_a_b_a_fresh_control_then_an_unresumed_follow_up_as_anthropic() -> None: + turns = _CapturingTurns() + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=turns) + prompts, tunings, omitted = turns._inner.prompts, turns._inner.tunings, turns._inner.omitted + indices = _recall_indices(prompts) + assert len(indices) == HISTORY_RECALL_TURNS + seed, followup, control, repeat = (turns.session_ids[i] for i in indices) + assert seed == followup == repeat and control != seed + assert seed not in turns.session_ids[: indices[0]] + assert control not in turns.session_ids[: indices[2]] + assert prompts[indices[0]].startswith(_FACT_PREFIX) + assert prompts[indices[1]] == prompts[indices[2]] == HISTORY_RECALL_PROMPT + assert prompts[indices[3]] == HISTORY_REPEAT_PROMPT + assert [omitted[i] for i in indices] == [False, False, False, True] + assert omitted.count(True) == 1 + anthropic = tuning_block(dict.fromkeys(_TIER_NAMES, "anthropic")) + assert all(tunings[i] == anthropic for i in indices) + assert by_check[HISTORY_RECALL_CHECK] == "pass" + assert by_check[HISTORY_OMITTED_RESUME_CHECK] == "pass" + + +def test_a_runtime_that_forgets_history_fails_check_9_end_to_end() -> None: + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns(forgets_history=True)) + assert by_check[HISTORY_RECALL_CHECK] == "fail" + + +def test_a_runtime_that_leaks_history_across_sessions_fails_check_9_end_to_end() -> None: + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns(leaks_history=True)) + assert by_check[HISTORY_RECALL_CHECK] == "fail" + + +def test_a_runtime_writing_no_history_item_fails_the_item_row_end_to_end() -> None: + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns(records_history=False)) + assert by_check[HISTORY_ITEM_CHECK] == "fail" + + +def test_every_history_item_the_run_wrote_is_deleted_before_the_users_are_removed( + monkeypatch: pytest.MonkeyPatch, +) -> None: + turns = _StatefulTurns() + order: list[str] = [] + original_cleanup = _FakeProvisioner.cleanup + + def recording_cleanup(self: _FakeProvisioner) -> Iterable[CheckResult]: + order.append("cleanup") + yield from original_cleanup(self) + + monkeypatch.setattr(_FakeProvisioner, "cleanup", recording_cleanup) + + class _Ordered(_FakeHistoryItems): + def delete(self, rep_id: str) -> None: + order.append("delete") + super().delete(rep_id) + + items = _Ordered(turns.history) + by_check, provs = _run(events=_ALL_TIER_EVENTS, run_turn=turns, history_items=items) + assert by_check[HISTORY_ITEMS_DELETED_CHECK] == "pass" + written_tenants = {_tenant_of("token-A"), _tenant_of("token-B")} + assert {key.split("#")[1] for key in items.deleted} <= written_tenants + assert any( + key.startswith(f"history#{_tenant_of('token-A')}#t3-recall-") for key in items.deleted + ) + assert turns.history == {} + assert order.index("cleanup") > max(i for i, step in enumerate(order) if step == "delete") + assert all(p.cleaned_up for p in provs) + + +def test_an_unreadable_history_store_fails_the_item_and_delete_rows_and_still_cleans_up() -> None: + def broken(_ctx: object) -> _FakeHistoryItems: + raise RuntimeError("no dynamodb_table_names output") + + provs: list[_FakeProvisioner] = [] + tokens = iter(["token-A", "token-B"]) + + def factory(_ctx: object) -> _FakeProvisioner: + provs.append(_FakeProvisioner(next(tokens))) + return provs[-1] + + ticks = iter(range(1000, 1_000_000, 1000)) + rows = list( + checks( + context_for_test(outputs={"agentcore_runtime_role_arn": _ROLE_ARN}, clients={}), + provisioner_factory=factory, + run_turn=_StatefulTurns(), + cloudtrail_lookup=lambda _c, _s, _e: _ALL_TIER_EVENTS, + clock=lambda: float(next(ticks)), + sleeper=lambda _s: None, + history_items=broken, + ) + ) + by_check = {r.check: r.status for r in rows} + assert by_check[HISTORY_ITEM_CHECK] == "fail" + assert by_check[HISTORY_ITEMS_DELETED_CHECK] == "fail" + assert all(p.cleaned_up for p in provs) + + +@pytest.mark.parametrize("short", [1, HISTORY_RECALL_TURNS]) +def test_a_share_without_room_for_all_three_recall_turns_sends_none_of_them( + monkeypatch: pytest.MonkeyPatch, short: int +) -> None: + allotments = dict(MODEL_TURN_ALLOTMENTS) + allotments[RESOURCE_CLASS] -= short + monkeypatch.setattr(three_tier_chat, "MODEL_TURN_ALLOTMENTS", allotments) + turns = _StatefulTurns() + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=turns) + assert not _recall_indices(turns.prompts) + assert HISTORY_RECALL_CHECK not in by_check + assert HISTORY_ITEM_CHECK not in by_check + assert by_check[CACHE_HISTORY_CHECK] == "pass" + assert by_check[HISTORY_ITEMS_DELETED_CHECK] == "pass" + + +def test_the_share_covers_every_check_and_the_envelope_still_fits() -> None: + assert MODEL_TURN_ALLOTMENTS[RESOURCE_CLASS] == 8 + HISTORY_RECALL_TURNS + assert sum(MODEL_TURN_ALLOTMENTS.values()) <= MODEL_TURN_ENVELOPE + + +# --- resume_from: a follow-up turn sends its session's recorded-frame count --- + + +def test_the_cursor_counts_every_frame_but_heartbeats_per_session() -> None: + cursor = ResumeCursor() + assert cursor.resume_from("s") == 0 + cursor.advance("s", ("heartbeat", "text_delta", "heartbeat", "usage", "completed")) + assert cursor.resume_from("s") == 3 + cursor.advance("s", ("text_delta", "text_delta", "usage", "completed")) + assert cursor.resume_from("s") == 7 + assert cursor.resume_from("other") == 0 + cursor.advance("s", ()) + assert cursor.resume_from("s") == 7 + + +def test_the_live_runner_sends_each_sessions_cursor_as_resume_from( + monkeypatch: pytest.MonkeyPatch, +) -> None: + sent: list[tuple[str, int]] = [] + + def fake_live( + _ctx: object, _token: str, session_id: str, *_a: Any, resume_from: int, **_k: Any + ) -> TurnResult: + sent.append((session_id, resume_from)) + return TurnResult(status=200, kinds=("text_delta", "usage", "completed"), answer="ok") + + monkeypatch.setattr(three_tier_chat, "_live_run_turn", fake_live) + live = _LiveTurns() + ctx = context_for_test(outputs={}, clients={}) + tuning = tuning_block(dict.fromkeys(_TIER_NAMES, "anthropic")) + for session in ("s1", "s1", "s2", "s1"): + live(ctx, "t", session, "p", tuning) + assert sent == [("s1", 0), ("s1", 3), ("s2", 0), ("s1", 6)] + + +def test_the_default_runner_is_the_resuming_live_runner() -> None: + source = inspect.getsource(checks) + assert "_LiveTurns()" in source + assert "else _live_run_turn" not in source + + +# --- coverage floor --- + + +def test_the_check_count_floor_is_met_by_a_run_whose_every_control_fails() -> None: + floor = expected_check_count(context_for_test(outputs={}, clients={})) + turns = _StatefulTurns(forgets_history=True, records_history=False) + rows = list( + checks( + context_for_test(outputs={"agentcore_runtime_role_arn": _ROLE_ARN}, clients={}), + provisioner_factory=lambda _c: _FakeProvisioner("token-A"), + run_turn=turns, + cloudtrail_lookup=lambda _c, _s, _e: [], + clock=iter(range(1000, 1_000_000, 1000)).__next__, + sleeper=lambda _s: None, + history_items=lambda _c: _FakeHistoryItems(turns.history), + ) + ) + module_rows = [r for r in rows if r.resource == RESOURCE_CLASS] + assert len(module_rows) >= floor.minimum + assert floor.basis + + +def test_the_floor_counts_the_check_9_rows() -> None: + floor = expected_check_count(context_for_test(outputs={}, clients={})) + happy, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns()) + assert floor.minimum <= len(happy) + assert "history recall" in floor.basis + + +# --- check 9: a follow-up sent without resume_from (the MCP shape) still recalls --- + + +def _repeat_row(followup: TurnResult, repeat: TurnResult) -> CheckResult: + return evaluate_omitted_resume_recall( + followup, repeat, code_word=_WORD, model=_ANTHROPIC_SUPERVISOR + ) + + +def test_an_unresumed_follow_up_that_extends_the_session_passes() -> None: + row = _repeat_row(_recall_turn(_WORD, 4400, 120), _recall_turn(_WORD, 4520, 40)) + assert (row.check, row.status) == (HISTORY_OMITTED_RESUME_CHECK, "pass") + + +def test_a_replay_of_b_fails_although_it_carries_the_word() -> None: + b = _recall_turn(_WORD, 4400, 120) + row = _repeat_row(b, b) + assert row.status == "fail" + assert "replay" in row.detail + + +def test_an_unresumed_follow_up_without_the_word_fails() -> None: + row = _repeat_row(_recall_turn(_WORD, 4400, 120), _recall_turn("I do not know.", 4520, 40)) + assert row.status == "fail" + + +@pytest.mark.parametrize( + "repeat", + [TurnResult(status=502, kinds=(), answer=_WORD), _recall_turn(_WORD, None)], + ids=["no_frame", "null_read"], +) +def test_an_unreadable_unresumed_follow_up_fails(repeat: TurnResult) -> None: + assert _repeat_row(_recall_turn(_WORD, 4400, 120), repeat).status == "fail" + + +def test_a_runtime_replaying_an_unresumed_follow_up_fails_only_that_row_end_to_end() -> None: + by_check, _ = _run( + events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns(replays_omitted_resume=True) + ) + assert by_check[HISTORY_OMITTED_RESUME_CHECK] == "fail" + assert by_check[HISTORY_RECALL_CHECK] == "pass" + + +def _captured_body(monkeypatch: pytest.MonkeyPatch, **kwargs: Any) -> dict[str, Any]: + """The JSON body `_live_run_turn` sends, captured before any network call.""" + sent: list[bytes] = [] + + def fake_open(request: Any, timeout: float) -> Any: + sent.append(request.data) + raise urllib.error.HTTPError( + request.full_url, 400, "refused", Message(), io.BytesIO(b'{"message": "m"}') + ) + + monkeypatch.setattr(three_tier_chat, "open_https", fake_open) + ctx = context_for_test( + outputs={"cloudfront_domain_name": "d.example.test", "agentcore_runtime_arn": "arn:x"}, + clients={}, + ) + result = _live_run_turn( + ctx, "t", "s" * 40, "p", tuning_block(dict.fromkeys(_TIER_NAMES, "anthropic")), **kwargs + ) + assert result.status == 400 + body: dict[str, Any] = json.loads(sent[0]) + return body + + +def test_the_live_turn_sends_resume_from_when_given(monkeypatch: pytest.MonkeyPatch) -> None: + assert _captured_body(monkeypatch, resume_from=7)["resume_from"] == 7 + + +def test_the_live_turn_omits_resume_from_when_none(monkeypatch: pytest.MonkeyPatch) -> None: + assert "resume_from" not in _captured_body(monkeypatch, resume_from=None) + + +def test_the_live_runner_omits_resume_from_only_when_asked( + monkeypatch: pytest.MonkeyPatch, +) -> None: + sent: list[int | None] = [] + + def fake_live(*_a: Any, resume_from: int | None, **_k: Any) -> TurnResult: + sent.append(resume_from) + return TurnResult(status=200, kinds=("text_delta", "usage", "completed"), answer="ok") + + monkeypatch.setattr(three_tier_chat, "_live_run_turn", fake_live) + live = _LiveTurns() + ctx = context_for_test(outputs={}, clients={}) + tuning = tuning_block(dict.fromkeys(_TIER_NAMES, "anthropic")) + live(ctx, "t", "s1", "p", tuning) + live(ctx, "t", "s1", "p", tuning, omit_resume_from=True) + live(ctx, "t", "s1", "p", tuning) + assert sent == [0, None, 6] + + +# --- check 9: the Runtime logs show every turn and no history store failure --- + +_S = "t3-recall-" + "a" * 32 +_C = "t3-rfresh-" + "b" * 32 + + +def _started(session: str, stream: str | None = None) -> RuntimeLogLine: + return RuntimeLogLine( + stream=stream if stream is not None else f"runtime-logs-{session}", + message=json.dumps({"event": "invocation_started", "session_id": session}), + ) + + +def _failure(event: str, session: str) -> RuntimeLogLine: + return RuntimeLogLine( + stream=f"runtime-logs-{session}", message=json.dumps({"event": event, "error_kind": "x"}) + ) + + +_LOGGED = [_started(_S), _started(_S), _started(_S), _started(_C)] +_EXPECTED = {_S: 3, _C: 1} + + +def test_every_turn_logged_with_no_failure_passes() -> None: + row = evaluate_history_logs(_LOGGED, _EXPECTED) + assert (row.check, row.status) == (HISTORY_LOG_CHECK, "pass") + + +@pytest.mark.parametrize("event", HISTORY_FAILURE_EVENTS) +@pytest.mark.parametrize("session", [_S, _C]) +def test_a_history_failure_in_a_check_9_stream_fails(event: str, session: str) -> None: + row = evaluate_history_logs([*_LOGGED, _failure(event, session)], _EXPECTED) + assert row.status == "fail" + assert event in row.detail + + +def test_a_failure_in_another_sessions_stream_is_not_attributed() -> None: + other = "t3-cfresh-" + "c" * 32 + row = evaluate_history_logs( + [*_LOGGED, _started(other), _failure("history_write_failed", other)], _EXPECTED + ) + assert row.status == "pass" + + +def test_a_missing_turn_line_fails_because_the_read_is_blind() -> None: + row = evaluate_history_logs(_LOGGED[1:], _EXPECTED) + assert row.status == "fail" + assert "not evidence" in row.detail + + +def test_a_turn_logged_in_a_stream_not_naming_its_session_fails() -> None: + lines = [_started(_S), _started(_S), _started(_S, stream="runtime-logs-shared"), _started(_C)] + assert evaluate_history_logs(lines, _EXPECTED).status == "fail" + + +@pytest.mark.parametrize("event", HISTORY_FAILURE_EVENTS) +def test_a_runtime_logging_a_history_failure_fails_check_9_end_to_end(event: str) -> None: + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns(history_failure=event)) + assert by_check[HISTORY_LOG_CHECK] == "fail" + assert by_check[HISTORY_RECALL_CHECK] == "pass" + + +def test_an_unreadable_log_group_fails_the_log_row_end_to_end() -> None: + def broken(_c: object, _s: int, _e: int) -> list[RuntimeLogLine]: + raise RuntimeError("AccessDeniedException") + + by_check, _ = _run(events=_ALL_TIER_EVENTS, run_turn=_StatefulTurns(), runtime_logs=broken) + assert by_check[HISTORY_LOG_CHECK] == "fail" + + +def test_the_log_poll_waits_for_late_lines_and_stops_at_the_bound() -> None: + snapshots = iter([[], _LOGGED[:2], _LOGGED]) + clock = _FakeClock() + lines, summary = _poll_history_logs( + lambda _c, _s, _e: next(snapshots), + context_for_test(outputs={}, clients={}), + 0, + _EXPECTED, + clock=clock, + sleeper=clock.sleep, + ) + assert lines == _LOGGED + assert "polls=3" in summary + never = _FakeClock() + lines, summary = _poll_history_logs( + lambda _c, _s, _e: [], + context_for_test(outputs={}, clients={}), + 0, + _EXPECTED, + clock=never, + sleeper=never.sleep, + ) + assert lines == [] + assert never.now - 1_000.0 >= three_tier_chat._HISTORY_LOG_POLL_SECONDS + assert summary.startswith("polls=19 ") + + +class _FakeLogs: + def __init__(self, pages: list[list[dict[str, str]]]) -> None: + self._pages = pages + self.requests: list[dict[str, Any]] = [] + + def filter_log_events(self, **kwargs: Any) -> dict[str, Any]: + self.requests.append(kwargs) + index = len(self.requests) - 1 + page: dict[str, Any] = {"events": self._pages[index]} + if index + 1 < len(self._pages): + page["nextToken"] = f"t{index + 1}" + return page + + +def test_the_live_log_lookup_reads_the_runtime_group_and_every_page() -> None: + logs = _FakeLogs( + [[{"logStreamName": "a", "message": "m1"}], [{"logStreamName": "b", "message": "m2"}]] + ) + ctx = context_for_test( + outputs={"agentcore_runtime_log_group_name": "/g"}, clients={"logs": logs} + ) + lines = _live_runtime_log_lookup(ctx, 1, 2) + assert lines == [RuntimeLogLine("a", "m1"), RuntimeLogLine("b", "m2")] + assert logs.requests[0] == {"logGroupName": "/g", "startTime": 1, "endTime": 2} + assert logs.requests[1]["nextToken"] == "t1" + + +def test_a_failure_in_another_module_session_stream_fails() -> None: + other = "t3-cfresh-" + "c" * 32 + lines = [*_LOGGED, _started(other), _failure("history_read_failed", other)] + row = evaluate_history_logs(lines, _EXPECTED, module_sessions=[other]) + assert row.status == "fail" + assert other in row.detail + + +def test_the_end_to_end_log_read_attributes_every_module_session( + monkeypatch: pytest.MonkeyPatch, +) -> None: + received: list[list[str]] = [] + original = three_tier_chat.evaluate_history_logs + + def spy(*args: Any, **kwargs: Any) -> CheckResult: + received.append(list(kwargs["module_sessions"])) + return original(*args, **kwargs) + + monkeypatch.setattr(three_tier_chat, "evaluate_history_logs", spy) + turns = _CapturingTurns() + _run(events=_ALL_TIER_EVENTS, run_turn=turns) + assert received and set(received[0]) == set(turns.session_ids) + + +def test_the_failure_events_are_the_runtimes_three_history_failure_lines() -> None: + assert set(HISTORY_FAILURE_EVENTS) == { + "history_read_failed", + "history_write_failed", + "history_write_conflict", + } + + +def test_a_write_conflict_in_a_module_stream_fails_the_log_row() -> None: + row = evaluate_history_logs( + [ + *_LOGGED, + RuntimeLogLine(f"runtime-logs-{_S}", json.dumps({"event": "history_write_conflict"})), + ], + _EXPECTED, + ) + assert row.status == "fail" + assert "history_write_conflict" in row.detail diff --git a/tests/unit/test_smoke_token.py b/tests/unit/test_smoke_token.py index 8e20e3c..42a9818 100644 --- a/tests/unit/test_smoke_token.py +++ b/tests/unit/test_smoke_token.py @@ -14,12 +14,14 @@ import boto3 import pytest +from botocore.exceptions import ClientError from botocore.stub import ANY, Stubber -from scripts.smoke import verified_claims +from scripts.smoke import smoke_token, verified_claims from scripts.smoke.cognito_claims import LiveSmokeUserProvisioner from scripts.smoke.harness import context_for_test from scripts.smoke.smoke_token import ( TENANT_CLAIM, + assert_supplied_token, assert_token_tenant, mint_run_token, ) @@ -372,3 +374,21 @@ def _patch_offline_decode(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr( verified_claims, "cognito_jwks_url", lambda _region, _pool: test_key.jwks_url() ) + + +def test_an_undecodable_supplied_token_names_the_aws_code_never_the_message( + monkeypatch: pytest.MonkeyPatch, +) -> None: + planted_arn = "arn:aws:sts::123456789012:assumed-role/x/y" + + def decode(_token: str) -> dict[str, Any]: + raise ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {planted_arn}"}}, + "DescribeUserPool", + ) + + monkeypatch.setattr(smoke_token, "_live_decode_for", lambda _ctx: decode) + with pytest.raises(RuntimeError) as raised: + assert_supplied_token(context_for_test(), id_token="t", expected_tenant="eval-smoke-ab") + assert "DescribeUserPool failed (AccessDeniedException)" in str(raised.value) + assert planted_arn not in str(raised.value) diff --git a/tests/unit/test_smoke_user_settings_api.py b/tests/unit/test_smoke_user_settings_api.py index d588437..59b2ee6 100644 --- a/tests/unit/test_smoke_user_settings_api.py +++ b/tests/unit/test_smoke_user_settings_api.py @@ -15,6 +15,7 @@ import boto3 import pytest +from botocore.exceptions import ClientError from moto import mock_aws from scripts.smoke import user_settings_api as mod from scripts.smoke.admin_authz import ApiPost, SimulationRow @@ -28,6 +29,7 @@ from crm.store.keys import user_settings_key from crm.store.provisioning import create_all_tables from crm.store.store import Store +from eval.tenancy import TenantTeardownError from providers.capabilities import Family, Tier, load_capability_matrix from providers.tier_tuning import TIERS @@ -719,3 +721,62 @@ def handler(event: dict[str, Any]) -> dict[str, Any]: def test_the_other_table_row_sends_leading_keys() -> None: row = {r.check: r for r in _rows()}["role_denies_other_table"] assert row.leading_keys is not None + + +_PLANTED_ARN = "arn:aws:sts::123456789012:assumed-role/x/y" + + +def _planted(operation: str) -> ClientError: + return ClientError( + {"Error": {"Code": "AccessDeniedException", "Message": f"User: {_PLANTED_ARN}"}}, operation + ) + + +class _DeniedStore: + """Every store call raises a planted `AccessDeniedException`.""" + + def __getattr__(self, name: str) -> Any: + def _raise(*_: Any, **__: Any) -> Any: + raise _planted(name) + + return _raise + + +class TestNoAwsErrorMessageInDetails: + """Each AWS failure row names the operation and the code, never the error message.""" + + def test_a_raising_simulation(self, store: Store) -> None: + def denied(_ctx: Any) -> Iterator[CheckResult]: + yield from () + raise _planted("GetFunction") + + results = list( + mod.checks( + context_for_test(), + store=store, + post=_api(store), + get=_api_get(), + provisioner_factory=lambda _t: FakeProvisioner("rep-a"), + simulations=denied, + ) + ) + row = {r.check: r for r in results}["role_simulations"] + assert "GetFunction failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail + + def test_a_failed_settings_delete(self) -> None: + row = mod._delete_settings_item(_DeniedStore(), tenant="t", rep_id="r", who="A") + assert row.status == "fail" + assert "delete_item failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail + + def test_a_failed_teardown(self, monkeypatch: pytest.MonkeyPatch) -> None: + def denied(_store: Any, smoke_tenant: SmokeTenant) -> dict[str, int]: + cause = _planted("BatchWriteItem") + raise TenantTeardownError(smoke_tenant.tenant, deleted=None, cause=cause) from cause + + monkeypatch.setattr(mod, "teardown_smoke_tenant", denied) + row = mod._teardown(object(), SmokeTenant(run_id="smoke-ab", tenant="eval-smoke-ab")) + assert row.status == "fail" + assert "BatchWriteItem failed (AccessDeniedException)" in row.detail + assert _PLANTED_ARN not in row.detail diff --git a/tests/unit/test_store_conditional.py b/tests/unit/test_store_conditional.py index 58fa86a..393552e 100644 --- a/tests/unit/test_store_conditional.py +++ b/tests/unit/test_store_conditional.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: MIT -"""`Store.update_item`, `Store.put_if_absent`, `query_gsi` ordering, and the key builders -`user_settings_key`, `conversation_key`, `eval_result_id` and `SWEEP_LOCK_ROW_ID`. +"""`Store.update_item`, `Store.put_if_absent`, `Store.put_conditional`, `query_gsi` ordering, and +the key builders `user_settings_key`, `conversation_key`, `history_key`, `eval_result_id` and +`SWEEP_LOCK_ROW_ID`. Runs against a `moto`-mocked DynamoDB client; AWS error translation uses a client raising a real `botocore` `ClientError`. @@ -77,6 +78,18 @@ def test_conversation_key_rejects_an_empty_id() -> None: keys.conversation_key("") +def test_history_key_has_the_documented_format() -> None: + """The conversation-history item key is `history##`.""" + assert keys.history_key("demo", "s-1") == "history#demo#s-1" + + +@pytest.mark.parametrize(("tenant", "session_id"), [("", "s-1"), ("demo", "")]) +def test_history_key_rejects_an_empty_part(tenant: str, session_id: str) -> None: + """An empty tenant or session id cannot form a history key.""" + with pytest.raises(ValueError, match="non-empty"): + keys.history_key(tenant, session_id) + + def test_sweep_lock_row_id_is_the_fixed_lock_key() -> None: """The single-flight lock row is `lock#sweep`.""" assert keys.SWEEP_LOCK_ROW_ID == "lock#sweep" @@ -137,6 +150,74 @@ def test_put_if_absent_wraps_a_non_conditional_aws_error() -> None: assert isinstance(excinfo.value.__cause__, ClientError) +# -- put_conditional ------------------------------------------------------------------------------- + + +def _versioned(version: int, holder: str) -> dict[str, object]: + return {"rep_id": "history#demo#s-1", "version": version, "holder": holder} + + +def _held(store: Store) -> dict[str, object] | None: + return store.get_item("reps", {"rep_id": "history#demo#s-1"}) + + +def test_put_conditional_without_a_version_creates_a_missing_item(store: Store) -> None: + """`expected_version=None` writes when no item exists and reports `True`.""" + assert store.put_conditional("reps", _versioned(1, "a"), expected_version=None) + assert _held(store) == _versioned(1, "a") + + +def test_put_conditional_without_a_version_refuses_an_existing_item(store: Store) -> None: + """`expected_version=None` on an existing item reports `False` and leaves it unchanged.""" + store.put_conditional("reps", _versioned(1, "a"), expected_version=None) + assert not store.put_conditional("reps", _versioned(1, "b"), expected_version=None) + assert _held(store) == _versioned(1, "a") + + +def test_put_conditional_replaces_an_item_at_the_expected_version(store: Store) -> None: + """A matching stored `version` lets the write replace the item.""" + store.put_conditional("reps", _versioned(1, "a"), expected_version=None) + assert store.put_conditional("reps", _versioned(2, "b"), expected_version=1) + assert _held(store) == _versioned(2, "b") + + +@pytest.mark.parametrize("stale", [0, 2]) +def test_put_conditional_refuses_a_stale_version(store: Store, stale: int) -> None: + """A stored `version` other than the expected one reports `False` and does not overwrite.""" + store.put_conditional("reps", _versioned(1, "a"), expected_version=None) + assert not store.put_conditional("reps", _versioned(stale + 1, "b"), expected_version=stale) + assert _held(store) == _versioned(1, "a") + + +def test_put_conditional_with_a_version_refuses_a_missing_item(store: Store) -> None: + """An expected version on an absent item is a lost race, not a create.""" + assert not store.put_conditional("reps", _versioned(2, "a"), expected_version=1) + assert _held(store) is None + + +def test_put_conditional_recomputes_derived_attributes(store: Store) -> None: + """A versioned put writes the derived index attributes like `put_item` does.""" + item = {"run_id": "r1", "result_id": "00#t1", "task_id": "t1", "version": 1} + assert store.put_conditional("eval_results", item, expected_version=None) + stored = store.get_item("eval_results", {"run_id": "r1", "result_id": "00#t1"}) + assert stored is not None and stored["run_id_task_id"] == "r1#t1" + + +@pytest.mark.parametrize("expected_version", [None, 1]) +def test_put_conditional_wraps_a_non_conditional_aws_error(expected_version: int | None) -> None: + """Any AWS error other than a failed condition becomes a taxonomy error, not `False`.""" + store = Store(client=_RaisingClient("InternalServerError")) + with pytest.raises(CrmError) as excinfo: + store.put_conditional("reps", _versioned(1, "a"), expected_version=expected_version) + assert isinstance(excinfo.value.__cause__, ClientError) + + +def test_put_conditional_maps_conditional_check_failed_to_false() -> None: + """The engine's failed-condition code is the only one reported as `False`.""" + store = Store(client=_RaisingClient("ConditionalCheckFailedException")) + assert store.put_conditional("reps", _versioned(1, "a"), expected_version=1) is False + + # -- update_item ----------------------------------------------------------------------------------- diff --git a/tests/unit/test_store_method_action_parity.py b/tests/unit/test_store_method_action_parity.py index ae209a1..d35bfa6 100644 --- a/tests/unit/test_store_method_action_parity.py +++ b/tests/unit/test_store_method_action_parity.py @@ -187,6 +187,15 @@ def test_the_three_unchecked_entries_of_the_same_shape_are_correct( assert derived["query_tenant_scan"] == frozenset({"dynamodb:Query"}) assert derived["transact_write"] == _TRANSACT_WRITE_AUTHORIZED_ACTIONS + def test_put_conditional_is_mapped_to_put_item_only( + self, derived: dict[str, frozenset[str]] + ) -> None: + """`put_conditional` reaches `PutItem` alone and is declared so.""" + assert derived["put_conditional"] == frozenset({"dynamodb:PutItem"}) + assert gate.STORE_METHOD_ACTIONS["put_conditional"].actions == frozenset( + {"dynamodb:PutItem"} + ) + def test_physical_name_reaches_no_api_call_at_all( self, derived: dict[str, frozenset[str]] ) -> None: diff --git a/tests/unit/test_subagent_runner.py b/tests/unit/test_subagent_runner.py index 5487cfa..3b9a34d 100644 --- a/tests/unit/test_subagent_runner.py +++ b/tests/unit/test_subagent_runner.py @@ -13,6 +13,7 @@ import logging from collections.abc import AsyncIterator from dataclasses import dataclass, field +from typing import Any import pytest @@ -1009,3 +1010,65 @@ def test_results_under_the_ceiling_pass_unchanged() -> None: {"tool": "search_opportunities", "body": _search_body(10)}, ] assert _bounded(entries) == (entries, False) + + +# --- the shared bound on the leaf path -------------------------------------------------------- + + +def _activities_body(count: int) -> dict[str, object]: + return { + "opportunity": {"opportunity_id": "opp-0000"}, + "contacts": [{"contact_id": "cont-0000"}], + "activities": [{"activity_id": f"act-{n:04d}", "note": "x" * 700} for n in range(count)], + } + + +def _leaf_tool_results(provider: _RoundsProvider) -> list[dict[str, Any]]: + tool_messages = [m for m in provider.seen[1] if m.get("role") == "tool"] + assert len(tool_messages) == 1 + results = tool_messages[0]["tool_results"] + assert isinstance(results, list) + return [json.loads(str(entry["output"])) for entry in results] + + +def test_the_next_round_receives_the_bounded_leaf_result() -> None: + from agents.events import TOOL_OUTPUT_TRUNCATED_KEY, TOOL_RESULT_BYTE_CEILING, TRUNCATION_MARKER + + a, _ = _two_tools() + raw = {"statusCode": 200, "body": _activities_body(60)} + assert _size(raw["body"]) > TOOL_RESULT_BYTE_CEILING + _, provider = _run_rounds([[a], []], [raw]) + + (sent,) = _leaf_tool_results(provider) + body = sent["body"] + assert body[TOOL_OUTPUT_TRUNCATED_KEY] is True + assert body["activities"][-1] == {TRUNCATION_MARKER: True} + assert len(body["activities"]) < 61 + assert body["contacts"] == [{"contact_id": "cont-0000"}] + assert _size(body) <= TOOL_RESULT_BYTE_CEILING + + +def test_a_leaf_under_the_ceiling_reaches_the_next_round_unchanged() -> None: + a, _ = _two_tools() + raw = {"statusCode": 200, "body": _activities_body(3)} + _, provider = _run_rounds([[a], []], [raw]) + + assert _leaf_tool_results(provider) == [raw] + + +def test_a_byte_ceiling_bound_on_a_non_items_list_is_flagged_everywhere() -> None: + a, _ = _two_tools() + result, _ = _run_rounds([[a]], [{"statusCode": 200, "body": _activities_body(60)}]) + + assert result.tool_calls[0].truncated is True + tool_results = [e for e in result.events if e.kind == "tool_result"] + assert tool_results and tool_results[0].truncated is True + assert result.outcome.data is not None and result.outcome.data["truncated"] is True + + +def test_an_unbounded_leaf_is_not_flagged_truncated() -> None: + a, _ = _two_tools() + result, _ = _run_rounds([[a]], [{"statusCode": 200, "body": _activities_body(3)}]) + + assert result.tool_calls[0].truncated is False + assert result.outcome.data is not None and "truncated" not in result.outcome.data diff --git a/tests/unit/test_supervisor_contract.py b/tests/unit/test_supervisor_contract.py index ff36ec3..8bbc400 100644 --- a/tests/unit/test_supervisor_contract.py +++ b/tests/unit/test_supervisor_contract.py @@ -604,6 +604,45 @@ def test_provider_event_to_agent_event_truncates_an_oversized_tool_result_items_ assert event.truncated is True +def test_provider_event_to_agent_event_bounds_the_largest_list_under_a_body() -> None: + from agents.events import TOOL_OUTPUT_TRUNCATED_KEY, TRUNCATION_MARKER + + activities = [{"activity_id": f"act-{i:04d}", "note": "x" * 700} for i in range(60)] + raw: dict[str, object] = { + "statusCode": 200, + "body": {"opportunity": {"opportunity_id": "opp-0000"}, "activities": activities}, + } + event = provider_event_to_agent_event(ProviderEvent(type="tool_result", tool_output=raw)) + assert event is not None and event.truncated is True + assert event.tool_output is not None + body = event.tool_output["body"] + assert isinstance(body, dict) + assert body[TOOL_OUTPUT_TRUNCATED_KEY] is True + assert body["activities"][-1] == {TRUNCATION_MARKER: True} + assert body["activities"][:-1] == activities[: len(body["activities"]) - 1] + assert body["opportunity"] == {"opportunity_id": "opp-0000"} + assert describe_truncation(event.tool_output, event_truncated=event.truncated) is not None + + +def test_a_bound_flag_without_examined_count_reads_as_the_byte_ceiling_notice() -> None: + notice = describe_truncation({"body": {"items": [], "truncated": True}}, event_truncated=False) + assert notice == "The tool result was too large to include in full and was truncated." + + +def test_the_search_notice_needs_its_examined_count() -> None: + notice = describe_truncation( + {"body": {"items": [], "truncated": True, "examined_count": 7}}, event_truncated=True + ) + assert notice is not None and notice.startswith("Search stopped early after examining 7") + + +def test_provider_event_to_agent_event_passes_a_small_tool_result_through_unflagged() -> None: + raw: dict[str, object] = {"items": [{"opportunity_id": "opp-1"}]} + event = provider_event_to_agent_event(ProviderEvent(type="tool_result", tool_output=raw)) + assert event is not None and event.truncated is False + assert event.tool_output == raw + + def test_provider_event_to_agent_event_maps_usage_and_completed() -> None: usage_event = provider_event_to_agent_event( ProviderEvent(type="usage", input_tokens=10, output_tokens=5) diff --git a/tests/unit/test_sweep_units.py b/tests/unit/test_sweep_units.py index 2f89995..d0d2144 100644 --- a/tests/unit/test_sweep_units.py +++ b/tests/unit/test_sweep_units.py @@ -13,14 +13,22 @@ from moto import mock_aws import eval.sweep_units as sweep_units -from agents.tier_attribution import CacheCounts, InvocationAttribution, TokenCounts +from agents.tier_attribution import ( + CacheCounts, + InvocationAttribution, + TokenCounts, + ToolCallAttribution, +) from crm.store.provisioning import create_all_tables from crm.store.store import Store from crm.user_settings import save_settings from eval import harness +from eval.matrix import RECORD_SHAPE_VERSION, RECORD_SHAPE_VERSION_KEY from eval.metrics import Exclusion, ExclusionCategory from eval.scoring import ObservedToolArguments, ToolCall, TurnOutcome from eval.sweep_units import ( + UNIT_REPEAT_INDEX_KEY, + UNIT_TASK_ID_KEY, ArmSpec, TaskUnitResult, arm_turn_tuning, @@ -32,7 +40,8 @@ ) from eval.turn_observation import ObservedTurn from providers.base import ModelProvider, ProviderEvent, ResolvedInvocation -from providers.capabilities import load_capability_matrix +from providers.capabilities import Tier, load_capability_matrix +from providers.prompt_caching import CACHING from providers.stub import StubProvider from providers.tier_tuning import TierRequest, TurnTuning @@ -80,7 +89,12 @@ def _turn( def _unit(store: Store, task: dict[str, object], turn: ObservedTurn) -> TaskUnitResult: return run_task_unit( - store=store, task=task, tenant=TENANT, family="anthropic", turn_runner=lambda _t, _n: turn + store=store, + task=task, + tenant=TENANT, + family="anthropic", + turn_runner=lambda _t, _n: turn, + repeat_index=0, ) @@ -224,10 +238,16 @@ def runner(runner_task: Mapping[str, object], tenant: str) -> ObservedTurn: return _turn(stream_calls=2) unit = run_task_unit( - store=store, task=task, tenant=TENANT, family="anthropic", turn_runner=runner + store=store, + task=task, + tenant=TENANT, + family="anthropic", + turn_runner=runner, + repeat_index=3, ) assert seen == [task] assert unit.task_id == task["id"] + assert unit.repeat_index == 3 assert unit.task_score.task_id == task["id"] assert unit.tier_scores.task_id == task["id"] assert len(unit.usage_records) == 2 @@ -424,3 +444,176 @@ def test_the_bound_is_per_unit_so_another_turns_slack_cannot_absorb_a_surplus( assert sum(len(u.turn.invocations) for u in units) == sum(u.turn.stream_calls for u in units) with pytest.raises(AssertionError, match="task unit .* double-recorded usage"): _assemble(units, provider_stream_calls=6) + + +# --- per-call ids, exhaustion tier and caching provenance ------------------------------------- + + +def _tool_turn(*, exhausted_tier: Tier | None = None) -> ObservedTurn: + base = _turn(stream_calls=2) + return ObservedTurn( + outcome=TurnOutcome( + tenant=TENANT, + tool_calls=base.outcome.tool_calls, + denial_outcome="data", + budget_exhausted=exhausted_tier is not None, + budget_exhausted_tier=exhausted_tier, + ), + tool_arguments=base.tool_arguments, + invocations=base.invocations, + tool_calls=( + ToolCallAttribution( + tool_name="search_accounts", + role="supervisor", + latency_ms=None, + outcome_kind="data", + truncated=False, + ), + ), + stream_calls=base.stream_calls, + ) + + +def _unit_at( + store: Store, task: dict[str, object], repeat_index: int, turn: ObservedTurn +) -> TaskUnitResult: + return run_task_unit( + store=store, + task=task, + tenant=TENANT, + family="anthropic", + turn_runner=lambda _t, _n: turn, + repeat_index=repeat_index, + ) + + +def _captured_payload(units: list[TaskUnitResult]) -> dict[str, object]: + written: list[dict[str, object]] = [] + _assemble(units, raw_records_writer=lambda _arm, _model, payload: written.append(payload)) + (payload,) = written + return payload + + +def test_every_pre_aggregation_entry_names_its_units_task_and_repeat(store: Store) -> None: + first, second = _golden(2) + units = [ + _unit_at(store, first, 0, _tool_turn()), + _unit_at(store, second, 0, _tool_turn()), + _unit_at(store, first, 1, _tool_turn()), + _unit_at(store, second, 1, _tool_turn()), + ] + payload = _captured_payload(units) + expected = [ + (str(first["id"]), 0), + (str(second["id"]), 0), + (str(first["id"]), 1), + (str(second["id"]), 1), + ] + for key, per_unit in (("invocation_attributions", 2), ("tool_call_attributions", 1)): + entries = payload[key] + assert isinstance(entries, list) + assert [(e[UNIT_TASK_ID_KEY], e[UNIT_REPEAT_INDEX_KEY]) for e in entries] == [ + ids for ids in expected for _ in range(per_unit) + ], key + + +def test_the_pre_aggregation_payload_carries_the_record_shape_version(store: Store) -> None: + payload = _captured_payload([_unit_at(store, _golden(1)[0], 0, _tool_turn())]) + assert payload[RECORD_SHAPE_VERSION_KEY] == RECORD_SHAPE_VERSION + + +def test_the_per_call_entries_keep_every_attribution_field(store: Store) -> None: + unit = _unit_at(store, _golden(1)[0], 0, _tool_turn()) + payload = _captured_payload([unit]) + entries = payload["invocation_attributions"] + assert isinstance(entries, list) + stripped = [ + {k: v for k, v in e.items() if k not in (UNIT_TASK_ID_KEY, UNIT_REPEAT_INDEX_KEY)} + for e in entries + ] + assert ( + stripped + == [ + { + "tier": "supervisor", + "role": "supervisor", + "model_id": MATRIX.model_for("anthropic", "supervisor").model_id, + "tokens": {"input_tokens": 10, "output_tokens": 2}, + "cache": {"read_tokens": 0, "write_tokens": 0}, + "latency_ms": None, + } + ] + * 2 + ) + + +@pytest.mark.parametrize("tier", ["supervisor", "subagent", "tool"]) +def test_the_exhaustion_tier_is_counted_at_that_tier_only(store: Store, tier: Tier) -> None: + first, second = _golden(2) + units = [ + _unit_at(store, first, 0, _tool_turn(exhausted_tier=tier)), + _unit_at(store, second, 0, _tool_turn()), + ] + by_tier = _assemble(units).arm_result.tier_task_metrics_fields["by_tier"] + assert {name: entry["budget_exhausted_task_count"] for name, entry in by_tier.items()} == { + name: 1 if name == tier else 0 for name in ("supervisor", "subagent", "tool") + } + + +@pytest.mark.parametrize("family", ["anthropic", "openai"]) +def test_provenance_names_the_arms_caching_method(store: Store, family: str) -> None: + arm_spec = ArmSpec(family=family) # type: ignore[arg-type] + unit = run_task_unit( + store=store, + task=_golden(1)[0], + tenant=TENANT, + family=arm_spec.family, + turn_runner=lambda _t, _n: ObservedTurn(outcome=TurnOutcome(tenant=TENANT)), + repeat_index=0, + ) + provenance = _assemble([unit], arm_spec=arm_spec).arm_result.provenance + assert provenance.prompt_caching == CACHING[arm_spec.family] + assert provenance.to_report_fields()["prompt_caching"] == CACHING[arm_spec.family] + + +def test_each_task_score_carries_its_units_repeat_and_exhaustion_tier(store: Store) -> None: + first, second = _golden(2) + units = [ + _unit_at(store, first, 0, _tool_turn(exhausted_tier="tool")), + _unit_at(store, second, 0, _tool_turn()), + _unit_at(store, first, 1, _tool_turn()), + _unit_at(store, second, 1, _tool_turn(exhausted_tier="subagent")), + ] + expected = [ + (str(first["id"]), 0, "tool"), + (str(second["id"]), 0, None), + (str(first["id"]), 1, None), + (str(second["id"]), 1, "subagent"), + ] + reported = _assemble(units).arm_result.task_score_fields + assert [ + (s["task_id"], s["repeat_index"], s["budget_exhausted_tier"]) for s in reported + ] == expected + raw = _captured_payload(units)["task_scores"] + assert isinstance(raw, list) + assert [(s["task_id"], s["repeat_index"], s["budget_exhausted_tier"]) for s in raw] == expected + + +def test_a_raw_archive_re_render_keeps_each_task_scores_repeat_and_tier( + store: Store, tmp_path: Path +) -> None: + from eval.matrix import archive_raw_run, load_raw_archives + + task = _golden(1)[0] + units = [ + _unit_at(store, task, 0, _tool_turn(exhausted_tier="supervisor")), + _unit_at(store, task, 1, _tool_turn()), + ] + archive_raw_run(_assemble(units).arm_result, tmp_path) + (reloaded,) = load_raw_archives(tmp_path) + assert [ + (s["repeat_index"], s["budget_exhausted_tier"]) for s in reloaded.task_score_fields + ] == [ + (0, "supervisor"), + (1, None), + ] diff --git a/tests/unit/test_sweep_units_tier_task.py b/tests/unit/test_sweep_units_tier_task.py index 12d3ff4..ca4a398 100644 --- a/tests/unit/test_sweep_units_tier_task.py +++ b/tests/unit/test_sweep_units_tier_task.py @@ -68,6 +68,7 @@ def _unit( supervisor, subagent, tool = tiers return TaskUnitResult( task_id=task_id, + repeat_index=0, task_score=TaskScore( task_id=task_id, scoring_mode="machine", diff --git a/tests/unit/test_teardown_deletion_protection.py b/tests/unit/test_teardown_deletion_protection.py index 3e28f53..ba6fba7 100644 --- a/tests/unit/test_teardown_deletion_protection.py +++ b/tests/unit/test_teardown_deletion_protection.py @@ -8,6 +8,8 @@ from __future__ import annotations import os +import shutil +import sys from dataclasses import dataclass from pathlib import Path @@ -105,6 +107,7 @@ def _teardown( sandbox = tmp_path / "sandbox" scripts_dir = sandbox / "scripts" scripts_dir.mkdir(parents=True) + shutil.copy2(REPO_ROOT / "scripts" / "repo_python.sh", scripts_dir / "repo_python.sh") (sandbox / "infra").mkdir() script = scripts_dir / "teardown.sh" script.write_text(TEARDOWN_SH.read_text(encoding="utf-8"), encoding="utf-8") @@ -117,6 +120,7 @@ def _teardown( for name, body in (("aws", _FAKE_AWS), ("terraform", _FAKE_TERRAFORM)): (bin_dir / name).write_text(body, encoding="utf-8") (bin_dir / name).chmod(0o755) + (bin_dir / "python3").symlink_to(sys.executable) call_log = tmp_path / "calls.log" call_log.touch() diff --git a/tests/unit/test_temperature_removed.py b/tests/unit/test_temperature_removed.py index aa17ebb..e26dc0b 100644 --- a/tests/unit/test_temperature_removed.py +++ b/tests/unit/test_temperature_removed.py @@ -73,7 +73,6 @@ class Category(enum.Enum): "scripts/smoke/three_tier_chat.py": Category.REFUSAL, "scripts/smoke/user_settings_api.py": Category.REFUSAL, "src/agents/runtime_entrypoint.py": Category.REFUSAL, - "src/eval/matrix.py": Category.LEGACY_EVAL_HISTORY, "src/providers/capabilities.py": Category.REFUSAL, "src/providers/tier_tuning.py": Category.STORED_ROW_READER, "tests/e2e/browser/journeys/14-tier-tuning/tier-tuning.spec.ts": Category.REFUSAL, @@ -95,6 +94,7 @@ class Category(enum.Enum): "tests/unit/test_handler_capabilities.py": Category.ABSENCE_ASSERTION, "tests/unit/test_harness.py": Category.ABSENCE_ASSERTION, "tests/unit/test_matrix.py": Category.ABSENCE_ASSERTION, + "tests/unit/test_matrix_record_shape.py": Category.ABSENCE_ASSERTION, "tests/unit/test_model_capabilities.py": Category.REFUSAL, "tests/unit/test_provider_base.py": Category.ABSENCE_ASSERTION, "tests/unit/test_provider_request_tool_schema_contract.py": Category.ABSENCE_ASSERTION, @@ -118,7 +118,6 @@ class Category(enum.Enum): "scripts/smoke/three_tier_chat.py": 16, "scripts/smoke/user_settings_api.py": 15, "src/agents/runtime_entrypoint.py": 1, - "src/eval/matrix.py": 18, "src/providers/capabilities.py": 7, "src/providers/tier_tuning.py": 7, "tests/integration/fixtures/bedrock/": 27, diff --git a/tests/unit/test_truncation_key_pin.py b/tests/unit/test_truncation_key_pin.py new file mode 100644 index 0000000..a35b5d7 --- /dev/null +++ b/tests/unit/test_truncation_key_pin.py @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: MIT +"""The eval truncation reader and the agent truncation writer share one key constant.""" + +from __future__ import annotations + +import ast +from pathlib import Path + +import agents.events as agent_events +import agents.supervisor as supervisor +import eval.turn_observation as turn_observation + +_REPO = Path(__file__).resolve().parents[2] +_KEY = "TOOL_OUTPUT_TRUNCATED_KEY" + + +def _module_tree(relative: str) -> ast.Module: + return ast.parse((_REPO / relative).read_text(encoding="utf-8")) + + +def _assigns(tree: ast.Module, name: str) -> bool: + for node in ast.walk(tree): + targets: list[ast.expr] = [] + if isinstance(node, ast.Assign): + targets = list(node.targets) + elif isinstance(node, ast.AnnAssign): + targets = [node.target] + if any(isinstance(t, ast.Name) and t.id == name for t in targets): + return True + return False + + +def _imports_from(tree: ast.Module, module: str, name: str) -> bool: + return any( + isinstance(node, ast.ImportFrom) + and node.module == module + and any(alias.name == name and alias.asname is None for alias in node.names) + for node in ast.walk(tree) + ) + + +def test_the_key_is_defined_once_in_agents_events() -> None: + assert _assigns(_module_tree("src/agents/events.py"), _KEY) + assert agent_events.TOOL_OUTPUT_TRUNCATED_KEY == "truncated" + + +def test_the_eval_reader_imports_the_key_rather_than_defining_its_own() -> None: + tree = _module_tree("src/eval/turn_observation.py") + assert not _assigns(tree, _KEY) + assert _imports_from(tree, "agents.events", _KEY) + assert turn_observation.TOOL_OUTPUT_TRUNCATED_KEY is agent_events.TOOL_OUTPUT_TRUNCATED_KEY + + +def test_the_supervisor_notice_reads_the_same_key() -> None: + tree = _module_tree("src/agents/supervisor.py") + assert _imports_from(tree, "agents.events", _KEY) + assert supervisor._SEARCH_TRUNCATED_KEY is agent_events.TOOL_OUTPUT_TRUNCATED_KEY + + +def test_what_the_bound_writes_the_eval_reader_reports() -> None: + raw: dict[str, object] = {"body": {"items": [{"id": n, "pad": "x" * 700} for n in range(60)]}} + bounded, truncated = agent_events.bound_tool_output(raw) + assert truncated is True + assert turn_observation.tool_output_reports_truncation(bounded) is True + assert turn_observation.tool_output_reports_truncation(raw) is False diff --git a/tests/unit/test_turn_driver_tiers.py b/tests/unit/test_turn_driver_tiers.py index f271723..48f9b9d 100644 --- a/tests/unit/test_turn_driver_tiers.py +++ b/tests/unit/test_turn_driver_tiers.py @@ -9,7 +9,9 @@ from __future__ import annotations import asyncio -from collections.abc import AsyncIterator +import copy +import json +from collections.abc import AsyncIterator, Callable from dataclasses import dataclass, field from typing import Any @@ -47,6 +49,7 @@ class _Script: rounds: list[list[ProviderEvent]] calls: list[tuple[Family, ResolvedInvocation]] = field(default_factory=list) + seen: list[list[dict[str, object]]] = field(default_factory=list) @dataclass @@ -67,6 +70,7 @@ def stream( ) assert self.script.rounds, "provider.stream called more times than scripted" self.script.calls.append((self.family, invocation)) + self.script.seen.append(copy.deepcopy(messages)) return self._emit(self.script.rounds.pop(0)) async def _emit(self, events: list[ProviderEvent]) -> AsyncIterator[ProviderEvent]: @@ -129,6 +133,7 @@ def _drive( rounds: list[list[ProviderEvent]] | None = None, budget: TurnBudgetSpec = CHAT_BUDGET, max_rounds: int | None = None, + dispatch: Callable[[RegisteredTool, dict[str, object]], dict[str, Any]] = _dispatch, ) -> tuple[list[AgentEvent], TurnRecords, _Resolver]: script = _Script(rounds if rounds is not None else _delegating_rounds()) resolver = _Resolver(script) @@ -144,7 +149,7 @@ async def _run() -> list[AgentEvent]: matrix=MATRIX, tuning=tuning, budget=budget, - dispatch=_dispatch, + dispatch=dispatch, records=records, page_context=None, history_messages=None, @@ -260,9 +265,10 @@ def test_the_budget_spec_bounds_the_turn() -> None: ProviderEvent(type="completed", awaiting_tools=True), ], ] - events, _, _ = _drive(MIXED, rounds=rounds, budget=one_call) + events, records, _ = _drive(MIXED, rounds=rounds, budget=one_call) assert events[-1].kind == "error" assert events[-1].error_kind == "budget_exhausted" + assert records.budget_exhausted_tier == "supervisor" def test_session_turn_tuning_puts_effort_on_the_supervisor_only() -> None: @@ -280,3 +286,92 @@ def test_eval_budget_is_smaller_than_chat_budget() -> None: """The two specs a caller chooses between keep their ordering.""" assert EVAL_BUDGET.max_tool_calls < CHAT_BUDGET.max_tool_calls assert EVAL_BUDGET.max_wall_clock_seconds < CHAT_BUDGET.max_wall_clock_seconds + + +# --- the shared bound on the direct-dispatch path --------------------------------------------- + + +def _activities_dispatch( + count: int, +) -> Callable[[RegisteredTool, dict[str, object]], dict[str, Any]]: + def _dispatch_activities(tool: RegisteredTool, tool_input: dict[str, object]) -> dict[str, Any]: + del tool, tool_input + return { + "statusCode": 200, + "body": { + "items": [{"activity_id": f"act-{n:04d}", "note": "x" * 700} for n in range(count)] + }, + } + + return _dispatch_activities + + +def _direct_rounds() -> list[list[ProviderEvent]]: + return [ + [ + ProviderEvent( + type="tool_call", + tool_name="list_activities", + tool_input={"opportunity_id": "opp-0000"}, + tool_id="d1", + ), + ProviderEvent(type="usage", input_tokens=100, output_tokens=20), + ProviderEvent(type="completed", awaiting_tools=True), + ], + [ + ProviderEvent(type="text_delta", text="Here are the activities."), + ProviderEvent(type="usage", input_tokens=50, output_tokens=15), + ProviderEvent(type="completed", awaiting_tools=False), + ], + ] + + +def _direct_tool_result_sent(resolver: _Resolver) -> dict[str, Any]: + tool_messages = [m for m in resolver.script.seen[1] if m.get("role") == "tool"] + assert len(tool_messages) == 1 + results = tool_messages[0]["tool_results"] + assert isinstance(results, list) and len(results) == 1 + sent = json.loads(str(results[0]["output"])) + assert isinstance(sent, dict) + return sent + + +def test_a_direct_tool_result_over_the_ceiling_reaches_the_model_bounded() -> None: + """The supervisor model, the tool_result event and the attribution all see the bound.""" + from agents.events import TOOL_OUTPUT_TRUNCATED_KEY, TOOL_RESULT_BYTE_CEILING, TRUNCATION_MARKER + + events, records, resolver = _drive( + MIXED, rounds=_direct_rounds(), dispatch=_activities_dispatch(60) + ) + + sent = _direct_tool_result_sent(resolver) + body = sent["body"] + assert body[TOOL_OUTPUT_TRUNCATED_KEY] is True + assert body["items"][-1] == {TRUNCATION_MARKER: True} + assert len(repr(body).encode("utf-8")) <= TOOL_RESULT_BYTE_CEILING + (tool_result,) = [e for e in events if e.kind == "tool_result"] + assert tool_result.truncated is True + assert tool_result.tool_output == sent + (call,) = records.tool_calls + assert call.tool_name == "list_activities" and call.truncated is True + + +def test_a_direct_tool_result_under_the_ceiling_is_sent_unchanged_and_not_flagged() -> None: + events, records, resolver = _drive( + MIXED, rounds=_direct_rounds(), dispatch=_activities_dispatch(3) + ) + + assert _direct_tool_result_sent(resolver) == _activities_dispatch(3)( + _registered_tool("list_activities"), {} + ) + (tool_result,) = [e for e in events if e.kind == "tool_result"] + assert tool_result.truncated is False + (call,) = records.tool_calls + assert call.truncated is False + + +def _registered_tool(name: str) -> RegisteredTool: + from agents.registry import tool_registry_for + from agents.supervisor import SUPERVISOR_ROLE + + return next(tool for tool in tool_registry_for(SUPERVISOR_ROLE) if tool.name == name) diff --git a/tests/unit/test_turn_observation.py b/tests/unit/test_turn_observation.py index 2915fe9..f778bcc 100644 --- a/tests/unit/test_turn_observation.py +++ b/tests/unit/test_turn_observation.py @@ -33,7 +33,7 @@ serialise_turn, ) from providers.base import ModelProvider, ProviderEvent, ResolvedInvocation -from providers.capabilities import Family, load_capability_matrix +from providers.capabilities import Family, Tier, load_capability_matrix from providers.stub import StubProvider MATRIX = load_capability_matrix() @@ -99,7 +99,21 @@ def test_data_is_reported_only_when_nothing_else_occurred() -> None: data_only = _observe(_ok({"account_id": "a"}), calls=[("get_account", {"account_id": "a"})]) assert data_only.outcome(tenant="t", budget_exhausted=False).denial_outcome == "data" nothing = ObservingDispatch(lambda _t, _i: _ok({})) - assert nothing.outcome(tenant="t", budget_exhausted=True).denial_outcome is None + exhausted = nothing.outcome(tenant="t", budget_exhausted=True, budget_exhausted_tier="subagent") + assert exhausted.denial_outcome is None + + +def test_the_outcome_carries_the_exhaustion_tier_it_is_given() -> None: + observer = ObservingDispatch(lambda _t, _i: _ok({})) + exhausted = observer.outcome(tenant="t", budget_exhausted=True, budget_exhausted_tier="tool") + assert (exhausted.budget_exhausted, exhausted.budget_exhausted_tier) == (True, "tool") + completed = observer.outcome(tenant="t", budget_exhausted=False) + assert completed.budget_exhausted_tier is None + + +def test_an_exhausted_outcome_without_a_tier_is_refused() -> None: + with pytest.raises(ValueError, match="budget_exhausted_tier"): + ObservingDispatch(lambda _t, _i: _ok({})).outcome(tenant="t", budget_exhausted=True) def test_calls_targets_and_arguments_are_recorded_in_order() -> None: @@ -377,6 +391,7 @@ def _rich_turn() -> ObservedTurn: denial_outcome="denied", denial_missing_scope="account:acc-9", budget_exhausted=True, + budget_exhausted_tier="subagent", truncated=True, truncation_disclosed=False, observed_outcomes=frozenset({"z_label", "a_label"}), @@ -457,11 +472,17 @@ def _mutated(path: tuple[object, ...], value: object, *, delete: bool = False) - @pytest.mark.parametrize( ("path", "value", "delete"), [ - (("schema",), 3, False), + (("schema",), 4, False), + (("schema",), 2, False), (("schema",), True, False), (("outcome",), None, True), (("extra",), 1, False), (("outcome", "budget_exhausted"), "yes", False), + (("outcome", "budget_exhausted_tier"), None, True), + (("outcome", "budget_exhausted_tier"), None, False), + (("outcome", "budget_exhausted_tier"), "orchestrator", False), + (("outcome", "budget_exhausted_tier"), 1, False), + (("outcome", "budget_exhausted"), False, False), (("outcome", "tool_calls", 0, "tool_name"), 5, False), (("outcome", "observed_outcomes"), [1], False), (("outcome", "proposals", 0, "surplus"), "x", False), @@ -485,16 +506,47 @@ def test_deserialise_refuses_a_malformed_payload( deserialise_turn(_mutated(path, value, delete=delete)) -def test_the_writer_emits_schema_2() -> None: - assert serialise_turn(_rich_turn())["schema"] == 2 +def test_the_writer_emits_schema_3() -> None: + assert SERIALISED_TURN_SCHEMA == 3 + assert serialise_turn(_rich_turn())["schema"] == 3 + +def test_the_writer_emits_the_exhaustion_tier_in_the_outcome() -> None: + assert serialise_turn(_rich_turn())["outcome"]["budget_exhausted_tier"] == "subagent" + completed = ObservedTurn( + outcome=TurnOutcome(tenant="eval-abc"), + tool_arguments=(), + invocations=(), + tool_calls=(), + stream_calls=0, + exclusions=(), + turn_latency_ms=None, + ) + wire = serialise_turn(completed) + assert "budget_exhausted_tier" in wire["outcome"] + assert wire["outcome"]["budget_exhausted_tier"] is None + assert deserialise_turn(wire) == completed -def test_a_schema_1_body_from_a_skewed_runtime_is_refused_with_a_named_mismatch() -> None: - """An older Runtime body (schema 1, same shape) fails as a version skew.""" - stale = _mutated(("schema",), 1) + +@pytest.mark.parametrize("tier", ["supervisor", "subagent", "tool"]) +def test_each_exhaustion_tier_round_trips(tier: Tier) -> None: + wire = _mutated(("outcome", "budget_exhausted_tier"), tier) + assert deserialise_turn(wire).outcome.budget_exhausted_tier == tier + + +def test_a_schema_2_body_from_a_skewed_runtime_is_refused_with_a_named_mismatch() -> None: + """A schema-2 Runtime body, which carries no exhaustion tier, fails as a version skew.""" + stale = _mutated(("schema",), 2) + del stale["outcome"]["budget_exhausted_tier"] with pytest.raises(ValueError) as refused: deserialise_turn(stale) - assert str(refused.value) == "turn.schema must be 2, got 1" + assert str(refused.value) == "turn.schema must be 3, got 2" + + +def test_a_schema_3_body_without_the_exhaustion_tier_is_refused_naming_the_key() -> None: + wire = _mutated(("outcome", "budget_exhausted_tier"), None, delete=True) + with pytest.raises(ValueError, match="budget_exhausted_tier"): + deserialise_turn(wire) def test_deserialise_refuses_a_non_object() -> None: @@ -543,6 +595,7 @@ def test_a_turn_with_a_call_cut_at_the_deadline_is_observed_as_a_usage_lower_bou ) turn = asyncio.run(asyncio.wait_for(_observed_async(_StallsAfterFirstRound()), timeout=5.0)) assert turn.outcome.budget_exhausted is True + assert turn.outcome.budget_exhausted_tier == "supervisor" assert turn.usage_lower_bound is True wire = serialise_turn(turn) assert wire[USAGE_LOWER_BOUND_KEY] is True @@ -581,3 +634,33 @@ async def _observed_async(provider: ModelProvider) -> ObservedTurn: tuning=arm_turn_tuning(ArmSpec(family="anthropic")), dispatch=lambda tool, _input: _ok({"items": [], "tool": tool.name}), ) + + +def _oversized_activities() -> dict[str, Any]: + return _ok( + {"activities": [{"activity_id": f"act-{n:04d}", "note": "x" * 700} for n in range(60)]} + ) + + +def test_a_result_over_the_byte_ceiling_is_observed_as_truncated_and_disclosed() -> None: + """The observer sees the shared bound, so an oversized read without its own flag counts.""" + raw = _oversized_activities() + assert "truncated" not in raw["body"] + observed = _observe(raw, calls=[("list_activities", {"opportunity_id": "opp-0000"})]) + outcome = observed.outcome(tenant="t", budget_exhausted=False) + assert outcome.truncated is True + assert outcome.truncation_disclosed is True + + +def test_the_observer_returns_the_dispatched_output_unbounded() -> None: + raw = _oversized_activities() + observer = ObservingDispatch(lambda _tool, _input: raw) + assert observer(_tool("list_activities"), {"opportunity_id": "opp-0000"}) is raw + + +def test_a_result_under_the_byte_ceiling_is_not_observed_as_truncated() -> None: + observed = _observe( + _ok({"activities": [{"activity_id": "act-0000"}]}), + calls=[("list_activities", {"opportunity_id": "opp-0000"})], + ) + assert observed.outcome(tenant="t", budget_exhausted=False).truncated is False diff --git a/tests/unit/test_turn_observation_resolved_efforts.py b/tests/unit/test_turn_observation_resolved_efforts.py index b565c79..65e1acd 100644 --- a/tests/unit/test_turn_observation_resolved_efforts.py +++ b/tests/unit/test_turn_observation_resolved_efforts.py @@ -57,6 +57,7 @@ def _unit(turn: ObservedTurn) -> TaskUnitResult: tier = TierScore(tier="supervisor", applicable=False, passed=None) return TaskUnitResult( task_id="gt-unit", + repeat_index=0, task_score=TaskScore( task_id="gt-unit", scoring_mode="machine", diff --git a/tests/unit/test_turn_row_fixture.py b/tests/unit/test_turn_row_fixture.py index d1015e6..5d7eda0 100644 --- a/tests/unit/test_turn_row_fixture.py +++ b/tests/unit/test_turn_row_fixture.py @@ -2,7 +2,9 @@ """`eval.sfn_handlers.turn_from_row` on a frozen schema-1 `eval_results` row. `tests/fixtures/eval/turn_row_schema1.json` is a row stored while `SERIALISED_TURN_SCHEMA` was 1. -It must stay readable, and losslessly so, under every later schema. +Its outcome carries no `budget_exhausted_tier`, which the current schema requires, so the row is +refused loudly rather than read with an invented tier. With that one key supplied it rebuilds +losslessly, which pins that nothing else about the stored shape has drifted. """ from __future__ import annotations @@ -11,6 +13,9 @@ from pathlib import Path from typing import Any, Final +import pytest + +from crm.errors import ValidationFailed from eval.sfn_handlers import turn_from_row from eval.turn_observation import SERIALISED_TURN_SCHEMA, serialise_turn @@ -25,17 +30,37 @@ def _row() -> dict[str, Any]: return row +def _row_with_tier() -> dict[str, Any]: + row = _row() + outcome = json.loads(row["outcome"]) + outcome["budget_exhausted_tier"] = None + row["outcome"] = json.dumps(outcome) + return row + + def test_the_frozen_row_stores_no_schema_attribute() -> None: assert "schema" not in _row() -def test_the_schema_1_row_rebuilds_under_the_current_schema() -> None: - turn = serialise_turn(turn_from_row(_row())) +def test_the_frozen_row_stores_no_exhaustion_tier() -> None: + outcome = json.loads(_row()["outcome"]) + assert outcome["budget_exhausted"] is False + assert "budget_exhausted_tier" not in outcome + + +def test_the_schema_1_row_is_refused_naming_the_missing_tier() -> None: + with pytest.raises(ValidationFailed) as refused: + turn_from_row(_row()) + assert "budget_exhausted_tier" in str(refused.value.detail) + + +def test_the_row_with_the_tier_supplied_rebuilds_under_the_current_schema() -> None: + turn = serialise_turn(turn_from_row(_row_with_tier())) assert turn["schema"] == SERIALISED_TURN_SCHEMA -def test_the_schema_1_row_rebuilds_losslessly() -> None: - row = _row() +def test_the_row_with_the_tier_supplied_rebuilds_losslessly() -> None: + row = _row_with_tier() turn = serialise_turn(turn_from_row(row)) assert turn["outcome"] == json.loads(row["outcome"]) assert turn["tool_arguments"] == json.loads(row["tool_arguments"]) diff --git a/tests/unit/test_verify_deployment.py b/tests/unit/test_verify_deployment.py index 8c36689..467884b 100644 --- a/tests/unit/test_verify_deployment.py +++ b/tests/unit/test_verify_deployment.py @@ -1803,6 +1803,7 @@ def test_a_genuine_failure_alongside_a_skip_still_fails_the_aggregate_run( "scripts.smoke.lambda_actions", "scripts.smoke.relay_iam", "scripts.smoke.runtime_bedrock_iam", + "scripts.smoke.runtime_history_iam", "scripts.smoke.runtime_inbound_auth", "scripts.smoke.runtime_network_posture", "scripts.smoke.integration_teardown_privilege", @@ -1996,6 +1997,7 @@ def test_reproduces_the_real_modules_that_reject_an_unconditional_token( "scripts.smoke.relay_iam", "scripts.smoke.runtime_inbound_auth", "scripts.smoke.runtime_bedrock_iam", + "scripts.smoke.runtime_history_iam", "scripts.smoke.runtime_network_posture", "scripts.smoke.public_exposure", "scripts.smoke.agents", @@ -2438,6 +2440,7 @@ def test_dry_run_preview_reproduces_the_pre_fix_regression_when_forced_unconditi "scripts.smoke.relay_iam", "scripts.smoke.runtime_inbound_auth", "scripts.smoke.runtime_bedrock_iam", + "scripts.smoke.runtime_history_iam", "scripts.smoke.runtime_network_posture", "scripts.smoke.deployed_parity", "scripts.smoke.lambda_actions", @@ -2463,25 +2466,94 @@ def test_dry_run_preview_reproduces_the_pre_fix_regression_when_forced_unconditi # --------------------------------------------------------------------------- +def _stderr_logs(tmp_path: Path) -> list[Path]: + return sorted((tmp_path / "results").glob("verify_deployment_stderr.*")) + + def test_stderr_log_path_is_unique_per_run_not_a_fixed_tmp_path( stubbed: tuple[Path, dict[str, str]], outputs_file: Path, tmp_path: Path ) -> None: script_path, env = stubbed + env = {**env, "STUB_MODE": "empty_output"} result = _run( script_path, - ["--i-understand-this-is-billable", "--outputs", str(outputs_file), "--token", "jwt"], + ["--i-understand-this-is-billable", "--outputs", str(outputs_file), "--layer", "4"], env, tmp_path, ) - assert result.returncode == 0, result.stderr - results_dir = tmp_path / "results" - stderr_logs = list(results_dir.glob("verify_deployment_stderr.*")) - assert len(stderr_logs) == 1, f"expected exactly one stderr log, found {stderr_logs}" + assert result.returncode != 0 assert "/tmp/verify_deployment_stderr.log" not in result.stdout + result.stderr # nosec B108 # asserts absence + inventory = tmp_path / "results" / "verification-inventory.partial.run.json" + named = re.findall(r"verify_deployment_stderr\.[A-Za-z0-9]+", inventory.read_text("utf-8")) + assert named, result.stdout + result.stderr # BSD mktemp substitutes only a trailing `XXXXXX`; assert the path is not the literal template. - assert "XXXXXX" not in stderr_logs[0].name, ( - f"mktemp template was not substituted -- path is still fixed: {stderr_logs[0]}" + assert all(name != "verify_deployment_stderr.XXXXXX" for name in named), named + + +def test_stderr_log_is_removed_after_a_passing_run( + stubbed: tuple[Path, dict[str, str]], outputs_file: Path, tmp_path: Path +) -> None: + script_path, env = stubbed + result = _run( + script_path, + ["--i-understand-this-is-billable", "--outputs", str(outputs_file), "--token", "jwt"], + env, + tmp_path, ) + assert result.returncode == 0, result.stderr + assert _stderr_logs(tmp_path) == [] + + +@pytest.mark.parametrize( + "stub_env", + [{"STUB_MODE": "empty_output"}, {"STUB_FAIL_MODULES": "lambda_actions"}], + ids=["module_without_output", "failing_module"], +) +def test_stderr_log_is_replayed_and_removed_after_a_failing_run( + stubbed: tuple[Path, dict[str, str]], + outputs_file: Path, + tmp_path: Path, + stub_env: dict[str, str], +) -> None: + script_path, env = stubbed + result = _run( + script_path, + ["--i-understand-this-is-billable", "--outputs", str(outputs_file), "--layer", "4"], + {**env, **stub_env}, + tmp_path, + ) + assert result.returncode != 0 + assert _stderr_logs(tmp_path) == [] + if stub_env.get("STUB_MODE") == "empty_output": + assert "module stderr from this run follows" in result.stderr + assert "stub: simulated uncaught traceback" in result.stderr + + +def test_stderr_log_is_not_created_by_a_dry_run( + stubbed: tuple[Path, dict[str, str]], outputs_file: Path, tmp_path: Path +) -> None: + script_path, env = stubbed + result = _run(script_path, ["--dry-run", "--outputs", str(outputs_file)], env, tmp_path) + assert result.returncode == 0, result.stderr + assert _stderr_logs(tmp_path) == [] + + +def test_only_this_runs_stderr_log_is_removed( + stubbed: tuple[Path, dict[str, str]], outputs_file: Path, tmp_path: Path +) -> None: + """A log another run created is left alone.""" + script_path, env = stubbed + (tmp_path / "results").mkdir(exist_ok=True) + other = tmp_path / "results" / "verify_deployment_stderr.otherrun" + other.write_text("another run\n", encoding="utf-8") + result = _run( + script_path, + ["--i-understand-this-is-billable", "--outputs", str(outputs_file), "--token", "jwt"], + env, + tmp_path, + ) + assert result.returncode == 0, result.stderr + assert _stderr_logs(tmp_path) == [other] def test_script_with_no_parseable_output_appears_in_inventory_as_a_failed_class( diff --git a/tests/unit/test_verify_gate_aggregation.py b/tests/unit/test_verify_gate_aggregation.py index 19c6494..51e0271 100644 --- a/tests/unit/test_verify_gate_aggregation.py +++ b/tests/unit/test_verify_gate_aggregation.py @@ -169,9 +169,9 @@ def test_run_gates_collects_two_simultaneous_failures_in_one_report() -> None: ), "check_emitted_css": ( "The gate compiles the real stylesheet, so it needs `frontend/node_modules/@tailwindcss/postcss` " - "and a `node`. The CI `verify` job cannot have them: it installs the RELAY's Node major (22, " + "and a `node`. The CI `verify` job cannot have them: it installs the RELAY's Node major (" "derived from the relay's Lambda runtime) and runs `npm ci` only in src/relay, while " - "frontend/package.json pins `engines.node` to an exact 26.13.0 -- so the toolchain cannot exist " + "frontend/package.json pins `engines.node` to an exact Node 26 release -- so the toolchain cannot exist " "in that job and the skip there is structural, not a missing `npm ci`. " "Coverage is the SEPARATE `frontend` job in both .gitlab-ci.yml and " ".github/workflows/verify.yml, which owns the frontend Node pin, runs `npm ci` in frontend/, " @@ -226,6 +226,14 @@ def test_run_gates_collects_two_simultaneous_failures_in_one_report() -> None: "REMOVAL TRIGGER: an offline job that runs scripts/package_relay.sh before the gates, at which " "point the probe reports the zip present in CI too and the entry must go." ), + "verify_terraform_plan_with_kms_absent": ( + "The gate plans a fixture module against the cached providers in infra/.terraform/providers " + "(gitignored), so it skips where `terraform` is not on PATH or `terraform init` has not run: " + "a fresh clone or a scratch worktree. Its coverage is both CI `verify` jobs, which run " + "`terraform -chdir=infra init -backend=false` before the gates, so there the probe reports " + "the input present and the gate must not skip. " + "This entry is CONDITIONAL (see SKIP_PRECONDITION_PROBES)." + ), } @@ -282,12 +290,37 @@ def _lambda_zip_gate_module() -> Any: return check_lambda_zip_imports +def _terraform_plan_inputs_absent() -> str | None: + """Why `verify_terraform_plan_with_kms_absent` cannot plan here, or `None` if it can. + + Mirrors the gate's two skip predicates: `terraform` on PATH, and its `PLUGIN_DIR`, read from the + script so the probe follows the gate. + """ + if shutil.which("terraform") is None: + return "terraform is not on PATH" + plugin_dir = REPO_ROOT / _kms_absent_gate_plugin_relpath() + if not plugin_dir.is_dir(): + return f"no cached providers at {plugin_dir}" + return None + + +def _kms_absent_gate_plugin_relpath() -> str: + """The repo-relative `PLUGIN_DIR` of `scripts/verify_terraform_plan_with_kms_absent.sh`.""" + script = (REPO_ROOT / "scripts" / "verify_terraform_plan_with_kms_absent.sh").read_text( + encoding="utf-8" + ) + match = re.search(r'^PLUGIN_DIR="\$\{REPO_ROOT\}/([^"]+)"$', script, re.MULTILINE) + assert match is not None, "the gate no longer defines PLUGIN_DIR under REPO_ROOT" + return match.group(1) + + #: Precondition probes for conditional entries in `EXPECTED_OFFLINE_SKIPS`. `None` means the gate's #: input exists here, so it must not skip; a string means it is absent, so it must skip, and why. SKIP_PRECONDITION_PROBES: dict[str, Callable[[], str | None]] = { "check_emitted_css": _emitted_css_toolchain_absent, "check_lambda_zip_imports": _lambda_zips_absent, "check_relay_zip": _relay_zip_absent, + "verify_terraform_plan_with_kms_absent": _terraform_plan_inputs_absent, } #: Gates expected to report `[PARTIAL]` offline, each with its reason, where the deferred controls @@ -572,6 +605,42 @@ def _gate_stdout(report: list[dict[str, object]], name: str) -> str: return str(next((g["stdout"] for g in report if g["name"] == name), ""))[-400:] +def test_the_terraform_plan_probe_reads_the_gates_plugin_dir() -> None: + """The probe's provider path is the one the gate skips on.""" + assert _kms_absent_gate_plugin_relpath() == "infra/.terraform/providers" + + +@pytest.mark.parametrize( + ("terraform_on_path", "plugin_dir_present", "expected"), + [ + (False, True, "terraform is not on PATH"), + (True, False, "no cached providers"), + (True, True, None), + ], +) +def test_the_terraform_plan_probe_reports_each_absent_input( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + terraform_on_path: bool, + plugin_dir_present: bool, + expected: str | None, +) -> None: + """The probe names whichever input the gate would skip on, and `None` when both exist.""" + monkeypatch.setattr( + shutil, "which", lambda _name: "/usr/bin/terraform" if terraform_on_path else None + ) + relpath = "infra/.terraform/providers" + if plugin_dir_present: + (tmp_path / relpath).mkdir(parents=True) + monkeypatch.setattr(sys.modules[__name__], "REPO_ROOT", tmp_path) + monkeypatch.setattr(sys.modules[__name__], "_kms_absent_gate_plugin_relpath", lambda: relpath) + reason = _terraform_plan_inputs_absent() + if expected is None: + assert reason is None + else: + assert reason is not None and expected in reason + + def test_every_skip_precondition_probe_belongs_to_a_declared_skip() -> None: """Every `SKIP_PRECONDITION_PROBES` key is declared in `EXPECTED_OFFLINE_SKIPS`.""" orphans = sorted(set(SKIP_PRECONDITION_PROBES) - set(EXPECTED_OFFLINE_SKIPS))