Skip to content

impl(030): live probe and smoke, recorded fixtures - #392

Merged
bartekus merged 1 commit into
mainfrom
impl/030-live
Oct 30, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/030-live

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Spec 030: the live probe and smoke against Bedrock, the recorded Converse fixtures they produced, and the two defects the live stage found. 030 joins VERIFIED_SPECS. Stacked on #391 (the 3.5 item 2 amendment, A-65).

What landed

  • Live stage (2026-10-29). us.anthropic.claude-haiku-5-5 on Converse from ca-central-1 through the us. geographic profile, synthetic content only. The probe (3.11) was reachable on 3 sequential calls; the smoke (3.14 item 4) returned a mapped output on 1. Each call answered apple for 613 input and 34 output tokens, 86,130 units estimated.
  • Defect 1, the aws-config provider panicked. The default chain builds an instance metadata client, and aws-config has no HTTP client. The provider now reads only the environment (3.5 item 2, amended by spec(030): the aws-config feature reads environment credentials only (A-65) #391). tests/credentials.rs covers it.
  • Defect 2, signatures over host:443 were refused. The host header carried the default port, and bedrock-runtime answered InvalidSignatureException. net::host_header drops the scheme's default port. A control-plane request signed both ways confirmed the cause without invoking a model. tests/signing.rs covers it.
  • Evidence capture. The probe and smoke gain --out DIR and print the journal before and after. Evidence is refused when any part carries a credential value; the first refused signature showed why (the error echoes the session token).
  • Recorded fixtures. fixtures/recorded/ holds the live binding, the policy and the four exchanges, labeled recorded, synthetic content only, AWS request ids redacted. tests/recorded.rs replays them on loopback and checks the recorded request digest, output digest and charge.
  • tests/spend.rs wrote its scratch journal above the repository root, so its feature-gated test always failed; it now uses CARGO_TARGET_TMPDIR. No command had run the feature before spec(030): the aws-config feature reads environment credentials only (A-65) #391's verification block.
  • README "Manual live calls" and the spec 030 implementation record (increment 3) are updated.

Spend (testing journal, nano-USD units)

  • Before: 12,499,578 committed (1,421,364 observed, 11,078,214 liability).
  • After: 14,767,668 committed (1,421,364 observed, 344,520 estimated, 13,001,784 liability).
  • Bedrock's share: 2,268,090 units (USD 0.002268). That is 344,520 estimated for the 4 answered calls, plus 1,923,570 liability for 3 calls whose charge is unknown: the reservation left by the panic (nothing was sent) and the 2 refused signatures.

Verified

  • Locally: make gate, spec-spine verify 030 (3 commands, including --features aws-config), cargo clippy -p rustev-bedrock --features aws-config --all-targets -D warnings, scripts/check-authored-content.sh. make code runs in CI.
  • The diff contains no account id, ARN, credential, email or AWS request id.

Not done

  • A recorded Responses exchange. Haiku 5.5 does not serve the Responses API on bedrock-runtime, so this needs another model, binding and paid run. 030 stays implementation: in-progress.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across the bedrock integration, the new evidence.rs module, net.rs, aws_config_provider.rs, the test files, the recorded fixtures, and the spec update.

net.rs — host_header
The logic correctly strips the scheme's default port from the authority and falls back to the full authority for non-default or unknown schemes. The accompanying test in signing.rs covers the HTTPS/HTTP default, a non-default port, an IPv6 address, no explicit port, and a relative URI (→ None). No defect.

evidence.rs — secret scanning
The scan operates on the raw bytes of each component (exchange_record, request_body, response_body) before any are combined into the output document. The final document is built from the same data (re-serialized through the same Serialize impl; no encoding transforms between the check and the write). The provenance string is caller-controlled from a fixed literal. The scan correctly excludes empty secrets and names only the variable, never the value, in the error. No defect.

aws_config_provider.rs — environment-only provider
The switch from the full default chain to EnvironmentVariableCredentialsProvider is consistent with spec 030 §3.5 item 2 and the A-65 note about a missing HTTP client causing a panic. The credentials.rs test confirms that a profile file that would yield credentials under the default chain is ignored. No defect.

Recorded fixtures
generation_id is "redacted:aws-request-id" in all four fixtures. No AWS account IDs, access key prefixes (AKIA*, ASIA*), or ARNs are present in any fixture file. The binding.json and policy.json contain only model identifiers, region names, pricing, and content hashes. No credential leak.

recorded.rs — loopback replay
The serve helper listens on loopback only and asserts peer.ip().is_loopback(). The request-reading loop correctly handles partial reads and uses Content-Length to determine completeness. The credential used (HOST_TEST_KEY/HOST_TEST_SECRET/HOST_TEST_TOKEN) are synthetic test values with no resemblance to real AWS credentials. The test verifies request_digest, response_digest (indirectly via members), exchange_charge, and the reconstructed request body against the fixture. No defect.

spend.rs — CARGO_TARGET_TMPDIR
Moves the scratch journal from target/ (which may not exist in all CI environments) to the per-crate temp dir. Correct.

Makefile
Adding 030 to VERIFIED_SPECS is consistent with the spec now having declared acceptance tests (recorded.rs, credentials.rs) that can be run offline.

No concrete defect found.

{"head": "35f161581bc2c984d4d53cf5f63f9b67f8fb2a5d", "verdict": "no-findings", "findings": []}

Subject: 4dcf72b...35f1615, diff digest 88573cf921df2b0dbf45fa483ca028fad3e1ba895dbdad55d4c816c8082e9bf1, 1 call(s). An AI comment is not an approval.

Base automatically changed from spec/030-env-credentials to main October 29, 2026 20:53
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for bugs, security problems, and inconsistencies.

net.rs — host_header: The logic is correct. The _ arm covers both "no port" and "non-default port" and returns authority.to_string() in both cases, which is right. The signing test covers all combinations including IPv6. No issue.

evidence.rs — secret scanning: The scan checks raw bytes of exchange_record, request_body, and response_body before the directory is created. If a secret is found the function returns early and nothing is written. Empty secrets are filtered out. The test refuses_a_document_carrying_a_secret correctly asserts !dir.exists(). Correct.

aws_config_provider.rs — credential narrowing: The switch from the full default chain to EnvironmentVariableCredentialsProvider is correct and aligns with spec 030 3.5 item 2. The secrets vector read after block_on returns captures whichever credentials were live during the call. Correct.

spend.rs: The switch from ../../../target to CARGO_TARGET_TMPDIR is an improvement. No issue.

recorded.rs: The loopback server accepts one connection per fixture and the test panics at report.result.unwrap() before reaching handle.await if the infer call errors before connecting, so no permanent hang. Replay checks binding, request_digest, requested_model, exchange_charge, members, served, and status — sufficient for a recorded-fixture verification.

Naming inconsistency in smoke fixture: The attempt_id in converse-smoke-0.json is "bedrock-probe-1793304840707676000-0". This prefix comes from run_cli always passing "bedrock-probe" as the backend name regardless of the smoke flag:

let backend = crate::BedrockBackend::new(
    "bedrock-probe".into(),   // ← same name for both probe and smoke paths
    ...

The fixture is labeled "smoke" and its provenance string says "smoke (3.14 item 4)", but the attempt ID embedded in members[0] carries the probe prefix. The recorded.rs test threads the recorded attempt_id back through AttemptCall, so the exact-equality check on members passes; the inconsistency is not caught at test time. Any future smoke recording will also receive probe-prefixed attempt IDs, making the call type unrecoverable from the recorded artifact.

{"head": "30b1791cc9558155f91f8563095890f99c068c7d", "verdict": "findings", "findings": [{"path": "integrations/rustev-bedrock/fixtures/recorded/converse-smoke-0.json", "line": 17, "summary": "Smoke fixture's attempt_id carries a 'bedrock-probe-' prefix because run_cli always names the backend 'bedrock-probe' regardless of the smoke flag, making the call type irrecoverable from the recorded artifact."}]}

Subject: bfe423c...30b1791, diff digest 88573cf921df2b0dbf45fa483ca028fad3e1ba895dbdad55d4c816c8082e9bf1, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 29, 2026 21:00 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for bugs, security issues, and inconsistencies.

Credential handling in write_evidence (evidence.rs): The secret-scanning approach is sound — it checks raw bytes before any file is written, the check is done on all three parts (exchange record, request body, response body), and the empty-secret guard prevents windows(0) panic.

host_header and IPv6 (net.rs:156, tests/signing.rs:116): In the default-port branch, the function returns authority.host().to_string(). The http crate's Authority::host() method strips the square brackets from IPv6 literals per its documented behaviour (returning e.g. ::1 for authority [::1]:443), which would produce an invalid HTTP Host header. The test at signing.rs line 116 asserts:

assert_eq!(host("https://[::1]:443/x"), "[::1]");

But the implementation yields ::1 (no brackets), so the assertion would fail and, if the assertion were adjusted to match the actual return value, the Host header sent to the server would be malformed (RFC 7230 §5.4 requires brackets for IPv6 in Host headers). AWS Bedrock does not expose IPv6 endpoints, so this does not affect any of the recorded fixtures or live calls, but the test assertion and the implementation are in contradiction: one of them is wrong. The fix is to use format!("[{}]", authority.host()) when the host is IPv6 (i.e., when authority.host() contains :) instead of calling host() directly.

No other concrete defects found. The KeepExchanges sink, credential-environment isolation in credentials.rs, the loopback replay in recorded.rs, the --out directory safety check, and the run_cli journal-before/after flow all look correct. The spend.rs scratch-path fix (CARGO_TARGET_TMPDIR instead of ../../../target) is an improvement with no regression.

{"head": "32c122d351e7e9cb2eea032dd4672b12728300b3", "verdict": "findings", "findings": [{"path": "integrations/rustev-bedrock/src/net.rs", "line": 156, "summary": "host_header calls authority.host() for the default-port IPv6 case, which strips the square brackets (returning e.g. '::1' instead of '[::1]'), producing an invalid HTTP Host header; the test assertion in tests/signing.rs expects the bracketed form, so the test and the implementation contradict each other."}]}

Subject: bfe423c...32c122d, diff digest 9f9accea50f296cf294f679363f3c33a04a164d31ac1ccc8542da1cf22cff5f6, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 29, 2026 22:05 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff carefully across all changed files.

integrations/rustev-bedrock/src/evidence.rs — partial write on I/O failure

write_evidence builds docs in full (credentials scanned, no I/O yet), calls create_dir_all, then writes each file in a loop. If std::fs::write fails on exchange i (disk full, permission error, etc.), files 0..i-1 are already on disk and are not removed. The function returns the raw I/O error, which says nothing about the partial state. The early-exit message "wrote nothing" only covers the non-empty directory check. The test refuses_a_non_empty_directory verifies that a pre-existing file is preserved on refusal, but there is no test (or cleanup) covering partial write failure.

This is not a credential-leak issue — the secret scan completes before any fs::write — but it leaves the output directory in an inconsistent state that a caller might treat as complete evidence.

Everything else reviewed:

  • host_header in net.rs: logic and edge-case handling (IPv6 brackets, non-default ports, relative URIs) are correct and match the tests in signing.rs.
  • aws_config_provider.rs: switch from the full default chain to EnvironmentVariableCredentialsProvider is correct; the --out / secrets-collection flow is sound.
  • credentials.rs: child-process isolation pattern is correct; the planted credential file with AWS_SHARED_CREDENTIALS_FILE correctly verifies that the env-only provider ignores it.
  • recorded.rs: the loopback serve function handles Content-Length correctly; response_digest is intentionally omitted from the member comparison (the test serves re-serialised JSON); request_digest and members[0].outcome.output.digest are compared and are deterministic.
  • Recorded fixtures: token math checks out (613 × 0.11 + 34 × 0.55 = 86,130 nano-USD at unit_nano_usd=1); AWS request IDs are redacted; no credential values appear.
  • spend.rs: CARGO_TARGET_TMPDIR replaces the fragile target/ relative path.
  • Makefile: adding 030 to VERIFIED_SPECS is consistent with the spec reaching a live-tested state.
  • Spec increment 3 in specs/030-bedrock-backend/spec.md: accurately records the two defects fixed, the journal numbers, and the not-done Responses fixture.
{"head": "bb6cd23a18ae012f6974902147c6cf1dda5c63fa", "verdict": "findings", "findings": [{"path": "integrations/rustev-bedrock/src/evidence.rs", "line": 76, "summary": "If std::fs::write fails on exchange i, files 0..i-1 are left on disk and not cleaned up; the returned error gives no indication of partial output."}]}

Subject: bfe423c...bb6cd23, diff digest 9024384403ac09788a33efaa1b3d40f95c55cc3a4a82e3540f698335e450854b, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 29, 2026 22:40 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the changed paths for bugs, security problems, and inconsistencies.

integrations/rustev-bedrock/src/evidence.rs

The secret scan runs on raw bytes before JSON encoding (serde_json::to_vec(record), raw request bytes, raw response bytes). AWS credential values (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN) are ASCII alphanumeric with /+=- characters that JSON does not escape, so the raw-byte scan is a correct barrier for these specific secrets. The staging-and-rename approach correctly ensures nothing is written on any error, including a mid-loop secret match. Tests cover all stated behaviors (writes, refuses secret, ignores empty secret, atomicity on write failure, non-empty directory rejection).

integrations/rustev-bedrock/src/net.rs / adapter.rs

host_header correctly strips only the scheme's default port (443 for HTTPS, 80 for HTTP) and preserves IPv6 bracket notation via suffix-strip on the authority string rather than rebuilding from host(). Test cases in signing.rs cover IPv6, non-default ports, relative URIs, and both defaults. The adapter substitution is correct.

integrations/rustev-bedrock/src/aws_config_provider.rs

Replacing the full default credential chain with EnvironmentVariableCredentialsProvider is correct per spec 030 §3.5 item 2 (environment only, no instance metadata client that would panic without an HTTP client). The child-process test in credentials.rs installs a profile credentials file via AWS_SHARED_CREDENTIALS_FILE and verifies it is not read.

integrations/rustev-bedrock/tests/recorded.rs

The loopback server is straightforward HTTP/1.1 with Content-Length parsing. The replay verifies binding, request digest, charge, members (output digest), provider extras (region, profile, raw usage) against the recorded fixture. response_digest is intentionally not checked since fixture["response_body"].to_string() re-serializes compact JSON whose bytes may differ from the original recording (metrics, toolUseId). The output result "apple" is checked, which is the semantic output.

integrations/rustev-bedrock/fixtures/recorded/

Response bodies differ in latencyMs and toolUseId across the four exchanges, consistent with four separate live calls. The identical members[0].outcome.output.digest across all four is correct (all returned {"choice":"apple"}). The converse-smoke-0.json attempt id carries the bedrock-probe prefix, documented in both the provenance string and README as a pre-fix recording.

Spec 030 increment 3

The narrative accurately reflects the two bugs fixed (panicking provider, host-header default port), the --out flag addition, and the testing journal figures. Adding 030 to VERIFIED_SPECS is consistent with the new tests/recorded.rs acceptance test.

No concrete defects found.

{"head": "fe4e003c529f63d6762507b77ef41ca3130d8b8e", "verdict": "no-findings", "findings": []}

Subject: bfe423c...fe4e003, diff digest 5427906f8897278428416ccd48ac7d91c803940bb1452a89ee2065f20d651d2b, 1 call(s). An AI comment is not an approval.

Live probe and smoke on us.anthropic.claude-haiku-5-5 from ca-central-1 (A-65); four recorded Converse fixtures replayed offline. Fixes the aws-config provider panic (environment only, 3.5 item 2) and signatures over host:443. The probe and smoke gain --out DIR for evidence and print the journal before and after. 030 joins VERIFIED_SPECS.
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the changed files for bugs, security issues, and inconsistencies.

integrations/rustev-bedrock/src/evidence.rs

The secret-scan logic operates on raw parts bytes (exchange record serialized via serde_json::to_vec, plus the raw request/response slices), while the final docs entry is produced by re-encoding through serde_json::json! + to_vec_pretty. AWS credential values are pure ASCII alphanumeric plus /+/=, so no JSON re-encoding alters their byte sequences; detection is reliable.

The directory atomicity via a sibling staging path is correct: remove_dir only removes empty directories, which matches the precondition enforced by the earlier non-empty check. A TOCTOU race that adds a file between the check and the remove_dir causes a hard error rather than silent overwrite.

integrations/rustev-bedrock/src/net.rs / host_header

The default-port stripping is correct. The decision to strip the suffix from the raw authority string (rather than reconstruct from host()) preserves IPv6 bracket literals, confirmed by the test in signing.rs ([::1]:443 → [::1]).

integrations/rustev-bedrock/src/aws_config_provider.rs

Switching from the full default chain to EnvironmentVariableCredentialsProvider correctly addresses both the panic (instance metadata client requires an HTTP client) and the boundary requirement (only environment is read). The tests/credentials.rs child-process pattern correctly sets AWS_SHARED_CREDENTIALS_FILE to a live profile file and expects failure, verifying the file is not read.

integrations/rustev-bedrock/tests/recorded.rs

The mini HTTP server accumulates bytes into a growing buffer, finds \r\n\r\n, parses Content-Length, and breaks once the full body is received or n==0. For the synthetic requests (≈600 bytes), this is reliable. The test correctly omits response_digest from the comparison (the replay response body is re-serialized JSON, not byte-identical to the live response), while asserting request_digest, exchange_charge, members, and provider_extras match the recorded values.

The smoke fixture's attempt_id carries the bedrock-probe prefix; the test passes the recorded attempt_id directly to infer, so the members comparison holds correctly.

integrations/rustev-bedrock/tests/spend.rs

Moving the scratch journal path from ../../../target (relative from the crate) to env!("CARGO_TARGET_TMPDIR") is correct and more portable.

Spec 030 / Makefile / verify.py

030 is added to VERIFIED_SPECS, to the integrations-base acceptance group, and to the spec's extends section for Makefile and scripts/acceptance/—all three changes are consistent with each other.

No concrete defects found.

{"head": "52a12d0273a8eba971a2f08244db10b6b31757dc", "verdict": "no-findings", "findings": []}

Subject: 99c7b8c...52a12d0, diff digest 79c1305d7475b6034a52d6793da3cc9397acfca54e0900a8fa3ed5e00ee95904, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge October 30, 2026 00:46
@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 3084c8d Oct 30, 2026
30 checks passed
@bartekus
bartekus deleted the impl/030-live branch October 30, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant