feat(provider): native AWS Bedrock (Converse API, hand-rolled SigV4) - #143
Merged
Conversation
Implement Bedrock natively against the Bedrock Runtime Converse API, replacing the stub. Run Bedrock-hosted models through RiskKernel with the same budgets, approvals, audit, and OTel as any other provider — set the standard AWS env vars (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, optional AWS_SESSION_TOKEN, AWS_REGION) and RISKKERNEL_DEFAULT_PROVIDER=bedrock, then call with a Bedrock model id. Requests are signed with a hand-rolled AWS SigV4 signer — no AWS SDK dependency, keeping the dependency graph minimal. The signer is verified against AWS's published SigV4 'get-vanilla' known-answer test vector. Model ids contain ':' (e.g. ...-v1:0), so the path is AWS-encoded (%3A) for both the wire request and the signed canonical URI so they match. Bedrock is registered only when AWS credentials are present (the daemon refuses to start with a clear error if RISKKERNEL_DEFAULT_PROVIDER=bedrock but no creds); RISKKERNEL_BEDROCK_BASE_URL overrides the endpoint for a VPC/PrivateLink setup. Credentials come from the environment, never stored or logged. Removes the old stub provider and the now-unused ErrNotImplemented; updates the provider/stream package docs (no stubs remain — Anthropic, OpenAI, Ollama, and Bedrock are all native). Tests: the SigV4 known-answer vector, the AWS URI path encoding, and the Bedrock provider against a mock (request shape + well-formed SigV4 auth header + session token in signed headers + response parsing + error/missing-creds/missing-region/ context-cancel paths). Verified end-to-end: 'riskkernel chat --provider bedrock' against a mock that validates the SigV4 Authorization header. Docs: docs/PROVIDERS.md gains a native AWS Bedrock section (routing, the pricing caveat); README + ROADMAP updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements native AWS Bedrock (#24), replacing the stub. Run Bedrock-hosted models through RiskKernel with the same budgets / approvals / audit / OTel as any other provider.
Approach — minimal deps
aws-sdk-go-v2dependency (it pulls dozens of modules; this is ~120 lines). Keeps the dependency graph minimal per the project's posture.get-vanillaknown-answer vector — I independently reproduced that vector's signature withopensslbefore encoding it as the test oracle, so the test isn't circular.:(e.g.…-v1:0); the path is AWS-encoded (%3A) for both the wire request and the signed canonical URI so they match (verified Go'sPath/RawPathround-trip).Wiring
AWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEYare set; withRISKKERNEL_DEFAULT_PROVIDER=bedrockand no creds, the daemon refuses to start with a clear error.RISKKERNEL_BEDROCK_BASE_URLoverrides the endpoint (VPC/PrivateLink or a mock).AWS_SESSION_TOKENsupported for STS temp creds. Creds from env only, never stored/logged.claude-*/gpt-*prefixes), which is why you setRISKKERNEL_DEFAULT_PROVIDER=bedrock— documented.ErrNotImplemented; no stubs remain.Honesty
Long-tail Bedrock model ids meter
priced:false(cost$0, token budget only) until aRISKKERNEL_PRICING_FILErate is added — same caveat as the LiteLLM path, documented indocs/PROVIDERS.md.Tests / verification
…/bedrock/aws4_requestauth header,content-type;host;x-amz-datesigned headers, session token in signed headers, response parsing, API-error / missing-creds / missing-region / context-cancel).go test -race ./...green;go vet/gofmtclean.riskkernel chat --provider bedrockagainst a mock that validates the SigV4Authorizationheader returnedsigned-okand parsed usage — proving the env→config→register→sign→call path.Docs: native AWS Bedrock section in
docs/PROVIDERS.md; README + ROADMAP updated (Bedrock moves to Shipped).Closes #24