Repository navigation
feat(knowledge): add Amazon Bedrock Knowledge Base retrieval sources - #8985
jingchaodev wants to merge 1 commit into
Conversation
686d06f to
05d5325
Compare
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Every debounced command-palette query now becomes a paid Bedrock Retrieve to each KB, plus an STS subprocess, because Watch
Suggestions
[DESIGN-REVIEWED] 3567ae1 Description read[DESCRIPTION-READ] fe2ac7dd8cc728e765b7e2528d381109cf264ff26d9f4a5c07c68b478995a8b7 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check one thing before merge: Bedrock KBs can only point at one AWS account. That limit and its conflict code are interim, so the keyed-grant follow-up should be tracked somewhere. What this change shipsInventory (10 items) — 10 justifiedIntent: let knowledge search answer from a team's existing Amazon Bedrock Knowledge Base (#7947) without ingesting it locally. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 3567ae1 Description read[DESCRIPTION-READ] aac22f1d12afb102e961eebabbae62c3773f1bbdc3d88258c5ecbd497d7dfbbe That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS While the profile is being edited, the consent card says "Finish editing the profile to confirm" but the line below it still says "Confirm the AWS account above", and there's nothing to confirm. Watch
Suggestions
[UX-REVIEWED] 3567ae1 Description read[DESCRIPTION-READ] f3aaa8ef699cb65c51845b3af196041210a71086f89c449aef35e130ee5deb80 That sha256 names everything this verdict read: the PR description, plus the 17 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
05d5325 to
5eab1e8
Compare
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
|
First Principles round 1 — accepted and applied (head 5eab1e8): |
5eab1e8 to
207fb57
Compare
|
Round 3 — all findings accepted and fixed (head 207fb57):
Connector suite 21/21, black/isort/flake8/mypy/tsc green, SourcesList suites 38/38. |
207fb57 to
3798cb3
Compare
|
Round 4 — all four items fixed (head 3798cb3):
Connector suite 22/22; black gate + baseline check, flake8, mypy green. |
3798cb3 to
f519b8d
Compare
|
Round 5 — both blockers and both findings fixed (head f519b8d):
Connector suite 26/26 (74 with neighbors), black gate + new-files check, flake8, isort, mypy (1302 files) all green; single commit. |
f519b8d to
f66dc61
Compare
|
Advisory rounds (Design / UX / First Principles) — addressed (head f66dc61):
Backend 26/26, frontend SourcesList suites 52/52, i18n 19/19, tsc, black/sync-io/brand ratchets green; single commit. |
f66dc61 to
cc3794f
Compare
|
Round 7 — security finding fixed (head cc3794f): the remote query is now passed through |
cc3794f to
1459ff6
Compare
|
Round 8 — security finding fixed as prescribed (head 1459ff6): Bedrock KB retrieval is now registered with |
1459ff6 to
12438f9
Compare
|
|
|
|
|
|
|
|
Pushed
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
|
|
|
|
|
|
Pushed
|
A bedrock_kb source points at existing Bedrock Knowledge Bases in the user's own AWS account and is queried live at search time - no local ingestion, no stored credentials (profile name only, resolved through the standard AWS chain at call time). Results merge into local_knowledge_search and the dashboard's search-for-context by rank, under a 5s fail-open budget, so a slow or broken KB never breaks knowledge search. Retrieval tries vectorSearchConfiguration and falls back to managedSearchConfiguration when the ValidationException names it: MANAGED-type KBs reject the vector key. Citations come from the source_uri metadata attribute so hits link to original documents rather than S3 objects. Every string a hit keeps is clamped before the result is kept: title and source name at 200 characters and source URI at 1024 (the local knowledge path's own ceilings), content at 10,000 (the local embedder's per-chunk fold budget), and the summary is taken from the clamped content. boto3 ships as a new optional [bedrock] extra. Registering a source is an owner action, by the same rule the consent endpoints apply: add_source refuses a bedrock_kb body from a non-owner dashboard caller or an app token before validation, since validation probes the KB with the owner's credentials and the insert registers a KB against the owner's grant. Local sources keep their existing path. The bundle routes are no way around it: import_bundle refuses a bedrock_kb row, and a row of any type carrying a bedrock-kb:// uri, which would squat the handle the owner's add dedupes on (both counted and audited), and export_all leaves bedrock_kb rows out, since a bundle carries no consent, validation or target check and a live account binding with no items is not knowledge. An item that names a refused row, or an already-registered bedrock_kb source (its id is on the sources list every authenticated caller can read), is refused and counted with its locations, mentions and relations, so no local content lands under a live-only source and no crafted item fails the whole import on its FK. Only a refused row or item that carries an id joins its refused set, and a dependent is matched only when its own id is not null: str(None) is the text "None", which a bundle can also spell as a source or item id, so a local source called "None" keeps its items and an evidence-free relation is not dropped because a refused item was called "None". "No items" is enforced where an item comes to name a source: add_item and add_source_location_in_txn raise LiveSourceHoldsNoItems for a source_id naming a bedrock_kb row (one primary-key read inside the write transaction), and the agent's ingest-text route, which takes any existing source id, refuses such a target with 409 live_source_holds_no_items before reading the body. Without that rule the export filter would be the defect: an item written under a bedrock_kb row would travel while its source row does not, and a clean store's import would trip the items.source_id foreign key and roll the whole bundle back. The locked insert also requires the grant's account to be the one validation verified, which validate_registration returns: STS resolved the credentials to it, the grant read after that call named it, and every probe rechecked that grant. An account read before validation would match a grant that moved to another account and back while the probes ran. Same target is not the same account either, and a same-target confirmation for another account landing during the seconds of validation would otherwise be attested for a KB never validated there (409 bedrock_kb_grant_changed); record_source_attestation takes that expected account and refuses to pin any other. revoke_source_attestation reads the store strictly: an unreadable store raises (the route deletes nothing) instead of reading as nothing attested, which would leave the approval on disk for a row re-minted under the same id to inherit. export_all leaves out items a direct write planted under an account-bound source, with the locations, mentions and relations riding on them, so an export never names a row it dropped. The deletion paths hold the same line: delete_source_cascade and delete_items_batch_in_txn pick a surviving item's new owner from _reassignment_candidates, the holders that are not account-bound, so a planted location row never makes a bedrock_kb row own a local document (the document would survive live and vanish from every bundle); an item whose only other holders are account-bound goes with its owner, and the planted row with it. The row itself is not the registration; the attestation is. knowledge.db is agent-writable in-sandbox (the MCP server ingests into it in-process, and the sandbox seals neither workspace/knowledge nor the file), so a bedrock_kb row on its own proves nothing about who put it there: an agent could clone one, or point a clone at any KB the granted profile reaches, and the enumeration would pay to query it. The owner-gated, consent-checked insert therefore also records the row in aws_service_consent.json (aws_consent.record_source_attestation, under the bedrock-kb.sources key beside the grants, written under the same lock; the file is in the sandbox's read-only leaves, so only the gateway writes it), pinned to the row's id, uri and retained kb_ids/region/profile, and to the account the grant confirms at that moment: a profile name is not an account, and re-pointing the profile then confirming again keeps the same profile and region, so without the account the old registration would authorize paid retrieval of the same KB id in the new account. attested_sources returns only entries recorded under the current grant's account; a grant confirmed for another account leaves every earlier registration unattested until the owner removes the source and adds it again. A plain re-add is not that recovery: it dedupes on the row's uri and only a row the add creates is attested, so for this type the 409 source_exists text names the remove-then-add path. The two writes of an add and of a delete are not one transaction, so each fails in the safe direction: an attestation write that fails undoes the insert (bedrock_kb_attestation_failed, no row), and a delete revokes the attestation first (a failed revoke deletes nothing), so a failure between the two leaves at worst a dark row a retry removes, never an attestation without a row that a later row minted under the same id and values would inherit. Deleting a bedrock_kb row is owner-only like adding one; a local source's delete is not gated. Whether a row is a Bedrock row is decided from the sealed attestation under its id (has_source_attestation, read strictly before the row's type is trusted) or from its source_type, never from the type alone: that column lives in the agent-writable knowledge.db, so a registered row an agent re-labelled as a local one would otherwise skip both the owner gate and the revoke and leave its attestation for a row re-minted under the same id and values to inherit. Every retained field is bounded where it is retained: region and profile pass aws_consent.target_is_well_formed (the shapes a grant can be confirmed under) in validate_config before any probe and again in retained_properties (bedrock_kb_config_invalid). search_remote_sources reads the attestations once per enumeration and searches only rows that still match one; a row that does not (a clone, or an attested row whose stored KB set was widened afterwards) is skipped before any consent or credential work, with an aws_consent.denied SEL line naming the row id, not its KBs or the account. Registration and the enumeration share MAX_BEDROCK_KB_SOURCES (64). The owner-gated insert refuses a new registration once that many attestations are recorded under any account (409 bedrock_kb_source_limit, before either write); a full population first revokes each attestation whose row is gone, since the delete route answers 404 for a missing row. The enumeration reads at most that many rows, attested ids first, so every registration fits in its window, and an overflow written outside the insert is counted in one warning per search. It checks the search budget before any per-row work, so rows planted in knowledge.db cannot push a registered source out of the window or the budget. Both reads of bedrock_kb rows cut every column in SQL (id 64, name 200, uri 256, properties 1024 characters, each above what an insert writes), so a planted field never reaches Python whole. Only a row an attestation pins holds the one target, under any account (recorded_source_attestations), and the target lookup fetches only those rows: a row written straight into knowledge.db is never searched, so it cannot refuse the owner's grant or registration. The one-target compare is the one place a sources row's name becomes operator-facing text (both conflict refusals show it), and the attestation pins the target, not the name, so an agent can rewrite a registered row's name past the handler's name bound. The compare therefore renders it through the platform shim redact_via_context (a composed companion policy's shapes on top of the OSS baseline; never security.redact directly) before either payload is built: a credential or exfiltration URL in the name arrives as the tag, the profile and region stay readable. Both refusals are 409s: the request is well formed and the conflict is with registered state the owner can change. The consent POST's bedrock_kb_conflict_check_failed (503) covers the lookup alone; a grant write that fails propagates as the unhandled error it is, for every service, like the other consent writes. The POST names the connector only inside the worker that records the grant, and only for bedrock-kb: the module imports boto3 at its top, so naming it on the loop would stall every task for the import, and a Polly or Transcribe confirmation never loads it. The query leg, the one part of a search that leaves the host, goes out through the same shim. Its baseline runs the URL pass first: a credential inside a URL's query string blanked ahead of the URL pass leaves a placeholder the URL matcher does not recognise, and the host and the rest of the query survive. add_source checks the body's shape once, before any field is read: every text field must be a string or absent and properties an object, else 400. kb_ids is the one caller-supplied field a source retains and re-parses on every search, so it is bounded where it is parsed: at most 10 entries (also the per-search fan-out cap), each raw entry at most 128 characters, each normalized id exactly the 10-character shape the Retrieve API accepts; validate_config refuses the first violation by name before any probe, so nothing out of bounds is probed or stored. The insert stores the connector's retained_properties: exactly the three keys it reads back (kb_ids, region, profile), each in the validated form the gates judged rather than the caller's raw spelling (canonical bare ids; stripped region and profile), so the row's size follows the gates' own bounds instead of the request-body cap and it never carries a field nothing reads. The row's uri, the UNIQUE dedup key, is the server's canonical_source_uri(retained), never the caller's: a caller-chosen handle could mint a row per request for one knowledge base, each with a name up to the body cap; the derived one names the sorted full id set, so it is one per distinct set of knowledge bases: the same ids in any order dedupe to one row (one Retrieve per KB per search, not one per spelling) and a set sharing only a first id with an existing row is a different source, not a false 409. The form posts no uri for this type, and its default name is the bare first KB id (an ARN's trailing segment), since an ARN carries the account id and name is a column every authenticated caller can list. add_source bounds name itself, for every source type, at the 200 characters the rename endpoint already enforces (400 name_too_long before any branch runs): the add path must not admit what a rename would refuse, or a valid request lands an oversized row the list serves back on every read. A blank name falls back to the uri, cut to that same ceiling once for every insert. The error-code baseline is re-snapshotted for the one site the shape gate removed (knowledge.py missing_code 60 -> 59). The per-KB recheck runs immediately before every paid request and derives two facts from ONE read of the consent store (aws_consent.bedrock_authorization_snapshot): the grant is still the one the frozen credentials were verified against, and the row the search runs for is still attested under that same grant. Two separate reads would let a same-account grant for another target, published between them, pass a client frozen against the old grant: the attestation filter compares accounts only. The enumeration checks the registration once when it starts, but a delete landing during a search revokes the attestation and leaves the grant in place, so a grant-only recheck would let the rest of that search keep billing for a source the owner had just removed. A retrieve the recheck refuses writes its own SEL denied event naming the KB and which check refused, so the audit log holds every paid request that did not happen; the freeze-verify refusal in _get_client (no grant, another account, or a grant confirmed for a different profile/region) writes the same denied event naming the target and the check that refused, before any client is built. The managed fallback is checked against the search budget like every other request: a rejection slow enough to spend it leaves the fallback unissued. The identity-probe cache in aws_consent, keyed on a caller-supplied profile and region, keeps at most _PROBE_CACHE_MAX_ENTRIES entries and drops expired ones on each write. A pointer submit with an uncommitted profile is answered at pointerdown, before the input's blur can disable the button under the click. A successful add resets the committed profile with the field, so a reopened form gates on the blank profile it shows instead of the one just added. A filled form with a disabled Add always says why beside the button (region missing, region malformed, account unconfirmed); a Live row states what live means as visible text; a remove that fails shows its error on the row it restores, with the agent hand-off only while the add form is closed, since the hand-off navigates away from the form's unsaved fields; the folder branch carries visible labels too, because a placeholder disappears once the field has text; the region/profile pair stacks below the sm breakpoint instead of compressing side by side at 320px. The translated copy uses each locale guide's informal register (du, tu, ты, तुम), which the catalogs' style tests hold changed values to. The 14 keys x 13 locales grow the eager `all` catalog chunk (src/i18n/all.ts, the 13 catalogs plus the entry, with no module to split) by about 12.6 KB, under that entry's ceiling on main, so this change touches no budget. The add form's growth of SourcesList would cross the App chunk's first-party ceiling, so CapabilitiesPage loads the Knowledge tab through lazy() + Suspense, the boundary App.tsx already gives SessionsPage and MembersPage: the sources list, the ingestion controls and this form become their own chunk that only the Knowledge tab fetches, and the tab's ErrorBoundary covers that load as it covers the Graph chunk. While that chunk loads, the pane shows the ContentSkeleton the Templates tab shows for its own chunk. Closes kirodotdev#7947
|
|
|
|
|
|
Pushed
|
|
Thanks @jingchaodev for the thorough work and the per-finding dispositions. The maintainer confirmed this feature is wanted. Because this PR changes a sensitive path, the Sensitive Change Review gate cannot pass on a fork, so it continues in #26988 on a branch of this repository. Your commit is kept as-is with you as the author. That PR is rebased onto current main; main had split the knowledge store and the knowledge handlers into owner modules, so the changes were ported into those owners without changing behavior, and the temp screenshots and capture script were dropped. This PR stays open until #26988 merges. |
|
Thank you for this work, @jingchaodev. Your Bedrock Knowledge Base change has landed on main through #26988, which carried your commit over to a branch in this repo (a fork PR that touches a sensitive path cannot pass the Sensitive Change Review gate). Your authorship is kept on the merged commit. Closing this PR because #26988 supersedes it. Thanks again! |
Problem / Motivation
Goal: Let knowledge search answer from an Amazon Bedrock Knowledge Base that a team already keeps in its own AWS account, without re-ingesting it locally.
The Knowledge library can only search content KiroCrew ingests itself
(files, folders, vaults). Teams that already keep a curated Amazon Bedrock
Knowledge Base — often gigabytes of code and docs indexed in their own AWS
account — cannot point KiroCrew at it: the only options are re-ingesting the
whole corpus locally or leaving the KB unreachable from knowledge search.
Requested in #7947.
Why it matters
local embedding cost) for corpora that are already indexed.
residency), the security-orchestrator grounding use case Configurable knowledge backend: use an Amazon Bedrock Knowledge Base as a retrieval source #7947 describes.
Not a goal
Retrieve.Backwards compatibility
Compatible: every source type main has keeps main's add, import and ingest behavior. The refusals this PR adds name only a
bedrock_kbrow or abedrock-kb://uri, which no main writer creates, plus a body type check that refuses a non-string field, which no caller sends.src/kiro_crew/eval/bench/kb_retrieval.py:_build_storebuilds its own local corpus, soadd_itemnever sees a live source there.name; a non-Bedrock name is stored as sent (test_markdown_panel_file_add_keeps_a_long_basename)addName || addUri; a long typed name or folder path is stored whole (test_knowledge_tab_folder_add_keeps_a_long_name)bedrock_kbrow and nobedrock-kb://uri, so it imports as before (test_knowledge.py::TestKnowledgeStore::test_export_import_roundtrip; the refusal: test_an_account_bound_uri_is_refused_under_any_type)bedrock_kbid is refused (test_triggers_immediate_ingestion)bedrock_kbsource before the pipeline runs, and the sync never fetches one (test_ingest_text_under_a_bedrock_source_is_refused_before_the_pipeline_runs, test_source_is_never_synced)What changed (motivation → approach → change)
src/kiro_crew/knowledge/connectors/bedrock_kb.pybedrock-agent-runtime Retrieveper configured KB (kb_idstakes ids or ARNs, at most 10), merged by relevance;vectorSearchConfigurationwith amanagedSearchConfigurationfallback for MANAGED KBs; the query text leaves the host through the platform shimredact_via_context(a companion policy's shapes on top of the OSS baseline, whose URL pass runs first); citations from the document'ssource_urimetadata; every string a hit keeps is redacted whole through the same shim, then clamped (title and source name 200, source URI 1024, content 10,000; the summary from the clamped content), so a cut can never leave half a credential the redactors no longer recognisesearch_remote_sources_bounded(connector),src/kiro_crew/mcp_tools/knowledge.py,search_for_contextbedrock_kbrows (MAX_BEDROCK_KB_SOURCES, the same constant that limits registration) with the attested ids first, and cuts every column in SQL (id 64, name 200, uri 256, properties 1024 characters, each above what an insert writes; the one-target lookup uses the same SELECT and fetches only attested rows), so rows planted inknowledge.dbcannot push a registered source out of the window or the budget, or reach Python at full size, and attestations past that count, written outside the add route, are counted in one warning per search; each search checks the budget before each row's attestation check, before the consent probe and again before it builds the client, and the STS probe gets only the budget left (rounded up to whole seconds, at least 1 s; every other caller keeps 15 s), with a failure under that shorter timeout left out of the confirmation surfaces' probe cache; an install with nobedrock_kbsource pays one indexed SELECT and starts no thread; on the MCP tool anamespacescope skips the leg, since abedrock_kbsource holds no items and so no hit can fall inside a namespacesrc/kiro_crew/aws_consent.py,src/kiro_crew/dashboard/handlers/aws_consent.py,src/kiro_crew/dashboard/server.py,src/kiro_crew/security_posture.pybedrock-kbconsent grant for (profile, region) pinned to the confirmed account;record_source_attestation/attested_sources/revoke_source_attestation(strict read: an unreadable store raises, never "nothing attested") underbedrock-kb.sources;recorded_source_attestations(every entry under any account, strict read) for the one-target check and the registration limit;bedrock_authorization_snapshot(the grant and its attestations from one store read, so the per-retrieve recheck cannot pair a stale grant with its replacement's attestations); compare-and-deleterevoke_if_matches/reconcile_driftforbedrock-kbonly (every other service keeps main's key-wiserevoke, and its stored grant keeps main's shape); the identity-probe cache holds at most 64 entries (_PROBE_CACHE_MAX_ENTRIES) and drops expired ones on each write, since its (profile, region) key is caller-supplied; the consent POST imports the connector (and so boto3) only in its worker thread and only forbedrock-kb, so no confirmation loads it on the event loop and a Polly or Transcribe one never loads itsrc/kiro_crew/dashboard/handlers/knowledge.pybedrock_kbadd and delete (403 owner_only; the knowledge owner gate admits an app token and an internal-secret caller, this one does not); body shape checked before any field is read; abedrock_kbname, typed or uri-derived, is cut to 200 characters, the most a search result serves back, and every other type stores its name as sent, as on main; the retained triplekb_ids/region/profilebounded at retention (400 bedrock_kb_config_invalid); server-deriveduri(bedrock-kb://<region>/<sorted ids>); attestation written with the row and pinned to the account validation verified, which the connector'svalidate_registrationreturns (a confirmation for another account landing mid-validation, or a grant that moves to another account and back while the probes run, is409 bedrock_kb_grant_changed;500 bedrock_kb_attestation_failedundoes the insert; delete revokes first, and a failed revoke is500 bedrock_kb_attestation_revoke_failedwith "Couldn't remove this source. Nothing was deleted. Try again."); one Bedrock target at a time (409 bedrock_kb_target_conflict, the held source named throughsecurity.redact; only a row a gateway attestation pins holds the target, so a row written straight intoknowledge.dbrefuses nothing); at most 64 registrations (MAX_BEDROCK_KB_SOURCES, attestations under any account): the next add is409 bedrock_kb_source_limitbefore either write, after a full population revokes the attestations whose row is gone (the delete route 404s on a missing row), and a re-add of a registered KB still answerssource_existsat the limit;409 live_source_holds_no_itemson ingest-text under a live source; a re-add of a registered KB answers409 source_existswith text naming the remove-then-add recovery, since only a row the add creates is attested; internalremote-searchroutesrc/kiro_crew/knowledge/store.py_ACCOUNT_BOUND_SOURCE_TYPE:export_alldropsbedrock_kbrows,import_bundlerefuses them, and a row of any type carrying abedrock-kb://uri (it would squat the handle the owner's add dedupes on), with the items, locations, mentions and relations riding on them (ids compared as text);add_item/add_source_location_in_txnraiseLiveSourceHoldsNoItems, the export leaves out what a direct write planted under such a row, and the two deletion paths pick a surviving item's new owner from_reassignment_candidates(holders that are not account-bound), so a planted location row never makes abedrock_kbrow own a local document;bedrock-kb://exempt from the local-path checkwebsite/src/pages/knowledge/SourcesList.tsx,website/src/components/AwsConsentGate.tsx,website/src/api/client/security.ts,website/src/pages/CapabilitiesPage.tsx,website/src/i18n/locales/*.jsonInputandBtn, in-form consent card, submit gated on a grant for the typed profile and region, the reason always beside a dead button; while the profile field differs from the profile the card names, the card stays in place but inert, with no probe and no Confirm), the Local Folder inputs labelled the same way (the UX review on 987fa5e flagged one dialog with two labeling systems, and a placeholder disappears once the field has text), the "● Live" row with its own remove copy, a failed remove shown on the row it restores throughErrorNotice, a successful add that resets the committed profile with the field (a reopened form gates on the blank profile it shows), 14 i18n keys in 13 catalogs in each guide's informal register; the Knowledge tab loaded throughlazy()+Suspensebehind the Templates tab'sContentSkeletonsrc/kiro_crew/extras.py,setup.cfg[bedrock]extra (boto3, imported lazily)docs/system-specs/modules/knowledge.md,docs/feature-map/README.mdA registered Bedrock Knowledge Base answers through the same retrieval surfaces as local knowledge,
local_knowledge_search(MCP) and the dashboard's search-for-context, without touching the local index. Until now search reached only what was ingested locally, so a KB a team already keeps in Bedrock had to be re-ingested to be found.The new
bedrock_kbsource type holds no local items and is queried live at search time, beside the local store. It is a consent-gated paid service: the add-time probe and every retrieval need the owner's grant for (service, profile, region) and re-verify the account, so a repointed profile is refused fail-closed instead of billed, and every paid request that did not happen writes anaws_consent.deniedSEL line. Registering or deleting one is an owner action; local sources keep their existing paths. The row is not the registration, the attestation is:knowledge.dbis agent-writable in-sandbox, so the owner-gated insert also records the row inaws_service_consent.json(a read-only leaf to the agent), pinned to the row's id, uri, retained triple and the account validation ran under (the insert refuses a grant whose account moved in between, and the writer refuses to pin any other), and the enumeration searches only rows that still match one. A bundle never carries such a row in either direction, no item can name one through the gateway (add_itemandadd_source_location_in_txnrefuse it), and the export leaves out anything a direct write planted under one, so dropping the row from an export leaves nothing a clean import would trip over. Every caller-supplied value the row retains is bounded where it is parsed, and theuriis derived on the server, so one knowledge base is one row whatever its spelling.Two v1 trade-offs are flagged for maintainer sign-off: grants are keyed per service rather than per (service, profile, region), so a second Bedrock target is refused by a small conflict subsystem the keyed-grant follow-up (#14337) would delete; and every remote search runs an uncached STS consent probe, which is what closes the account-drift window. Bundle budget: the add form's growth of
SourcesListwould cross theAppchunk's first-party ceiling, soCapabilitiesPage.tsxloads the Knowledge tab throughlazy()+Suspenseinside its existingErrorBoundary; the sources list, ingestion controls and form are aKnowledgePage-*.jschunk only the Knowledge tab fetches, soAppstays under its ceiling. The 14 keys x 13 locales add ~12.6 KB to the eagerallcatalog chunk (src/i18n/all.ts, the 13 catalogs plus the entry, with no module to split); that chunk's ceiling is main's own (38610 KB since #13607), so this PR changes no budget.flowchart LR subgraph Before A1[Add Source]:::ctx --> A2[local file / folder / vault]:::ctx --> A3[local index]:::ctx end subgraph After B1[Add Source]:::ctx --> B2{type}:::ctx B2 --> B3[local file / folder / vault]:::ctx --> B4[local index]:::ctx B2 --> B5[Bedrock KB<br/>consent-gated]:::added --> B6[live Retrieve<br/>merged by rank]:::added end classDef ctx fill:#E0F2FE,stroke:#0284C7; classDef added fill:#DCFCE7,stroke:#16A34A;🟩 added · 🟦 unchanged — knowledge search now merges a live Bedrock KB beside the local index, with no local re-ingest.
Tests
test/test_bedrock_kb_connector.py(68, mocked client, no network): everystring a hit keeps stays within its bound while normal-size strings pass
through unchanged (mutation-verified against the unclamped append); the
kb_idsbounds (count, entry length, id shape: strict names the violation,lenient drops it) and that an out-of-bounds list is refused before the
client is built; the row handle names the sorted full id set (same ids in
another order dedupe, a set sharing only a first id does not, single-id
shape unchanged; mutation-verified); the
managed fallback fires only on the naming error (the fixture is the
ValidationExceptiontext a liveRetrieveagainst a MANAGED knowledgebase returned) and is not issued once the
search budget is spent (mutation-verified); a search whose budget is spent
runs no consent probe and builds no client (mutation-verified), and a
budgeted search hands the probe only the budget left while an unbounded
one keeps 15 s; multi-KB fan-out merges and
survives partial failure; citation precedence; validate_config field checks;
bounded entry's no-sources fast path, timeout fail-open, error swallowing;
rank interleave; the connector never syncs; a mid-search withdrawal and a
withdrawal between the vector attempt and the managed fallback each
write exactly one
deniedaudit event naming the refused KB and issueno Retrieve; the per-Retrieve recheck reads the row's registration too, so
a delete landing after the first KB's Retrieve stops the second before it
goes out, with the
deniedline naming the registration(mutation-verified against a grant-only recheck); each freeze-verify refusal (other account, other profile,
other region) writes exactly one
deniedevent naming the target andthe check, with no account numbers in it, and the verified path writes
none (mutation-verified); only gateway-attested rows are searched: a
clone row with no attestation and an attested row whose stored KB set
was widened are both skipped with one
deniedline naming the row id,never reach the client, and revoking the attestation stops a row too
(mutation-verified against the gate); planted rows cannot crowd out the
owner's row: with 69 planted rows ahead of it, the owner's row is still
searched inside the 64-row window, planted rows' audit writes stop once
they spend the budget, and a spent budget writes no audit line at all
(mutation-verified against the old enumeration, no ORDER BY, no LIMIT,
and the budget check after the attestation check); attestations past the
limit, written outside the add route, are counted in one warning per
search (mutation-verified); both
bedrock_kbrow reads keep every fieldbounded: with three planted rows whose every field is 100,000 characters,
the one-target lookup fetches only the attested row, and the enumeration
returns no field over 1024 while the owner's row is still searched
(mutation-verified against the old unbounded reads); an enlarged name
reads back as NULL and the result names the source
Bedrock KB <kb id>,so no clipped name prefix reaches a result (mutation-verified); a row
whose id or uri a NUL suffix or an oversized value changes under the SQL
bound is refused with its own
deniedline instead of matching theattested row it projects to (mutation-verified against the old projection
and against a silent SQL filter); every kept hit string is redacted whole
before its clamp, so a key across the cut is redacted, not halved
(mutation-verified per field);
validation reports the account of the grant it verified, and none on a
refusal (mutation-verified); an attestation is pinned to the
confirmed account, so a grant re-confirmed for another account leaves the
row skipped and audited until it is re-registered, and nothing can be
attested without a readable grant (mutation-verified against the account
filter);
regionandprofileoutside the shapes a grant can name arerefused before any probe and by
retained_propertiesitself, and passstripped at the ceilings (mutation-verified against the shape check);
the one-target compare counts only a registered row: a planted row with a
foreign target refuses nothing, and a registered row keeps its target
after its grant is revoked (mutation-verified against no attestation
filter and against a current-grant-only one); the compare renders the held
row's name redacted, so a registered row whose name was rewritten with a
key and an exfil URL reaches the
refusal as the two tags with the target still readable (mutation-verified
against the bare rendering and against a credential-first order, which
leaves the URL's host and query in place); the query leg goes out through
the same composite, so a query carrying a credential inside a URL's query
string reaches the client as the URL tag with the token, host and payload
parameters gone and the surrounding text intact (mutation-verified against
the credential-first order); both egress sites go through
kiro_crew.platform.redact_via_context, so with a companion credentialpolicy installed a companion-only shape in the query and in a planted
name is scrubbed on top of the baseline (mutation-verified against a
direct
security.redactimport).test/test_mcp_knowledge_search.py: anamespace-scopedlocal_knowledge_searchover a store with a registeredbedrock_kbrowmakes no remote call and answers from local results, and an unscoped one
keeps the remote leg (mutation-verified against the leg ignoring the
namespace).
test/test_aws_consent.py,test/test_knowledge_add_source.py,test/test_knowledge_owner_gate.py,test/test_spawn_audit.py: the grant lifecycle, compare-and-delete kept tobedrock-kb(a Polly drift and a Polly authorize mismatch revoke key-wise, a row whose ownservicefield names another service cannot redirect the revoke, only the Bedrock grant carries agrant_id, and the consent GET pins the drift check forbedrock-kbalone; mutation-verified four ways), the probe timeout (abudgeted caller's STS call gets the budget left, rounded up with a 1 s
floor, every other caller keeps 15 s, and a failure under a budget is not
cached; the probe hands the AWS runner
timeoutonly when budgeted, so anunbudgeted probe keeps its exact call; fails when
timeout=Noneispassed), the probe cache (both write sites hold it at
_PROBE_CACHE_MAX_ENTRIES, evicting the oldest; a held key refresheswithout evicting, and an expired entry leaves on the next write;
mutation-verified against no cap, no sweep and either site writing the
dict directly), a
bedrock_kbname over 200 characters is cut to 200 whilea long local file, folder or vault name is stored whole (mutation-verified
against refusing every long name, cutting every name and no Bedrock cut), a
bundle row typed
local_folderthat carries abedrock-kb://uri is refused and leaves the uri free (mutation-verified), off-loop add-time
validation, the owner gate on
bedrock_kbregistration (messagingnon-owner and app token refused 403 before validation with nothing
persisted, the owner passes, and an app token, which the knowledge owner
gate admits, still adds a local folder;
mutation-verified), the body-shape gate (a non-string
urifrom the ownerwith valid Bedrock properties is a 400 before validation with nothing
persisted, every read field is gated,
nullreads as absent;mutation-verified against the 500), the retained triple (a body with
extra
propertieskeys lands as a row carrying exactly the three readkeys, and a body whose region, profile and KB ids are whitespace-padded
and ARN-spelled lands as the stripped, canonical values the grant check
matched; a caller-chosen
uri, oversized or unique per request, neverreaches the row and a second add of the same KB is a
409 source_exists;all three mutation-verified), the registration limit (with the limit set
to 2: the next add is refused with no row and no attestation, removing a
source frees its slot, a full population reclaims an attestation whose
row was deleted outside the dashboard, and a re-add that loses the race
to the in-lock recheck still answers
source_exists; all fourmutation-verified), the attestation (the insert records exactly
the inserted row, pinned to its stored triple so a widened
kb_idsdoes notmatch, and a DELETE of the row drops the entry; mutation-verified
against no-attest and no-revoke; a retained
profileorregionoutsideits bound is a coded
400with no row even when the registeredconnector's validation passes everything; a same-target confirmation for
another account landing during validation is
409 bedrock_kb_grant_changedwith no row and nothing attested, and so is agrant that moves to another account and back while the probes run
(mutation-verified against a read taken before validation), while the
same-account one lands attested for that account, and the attestation
writer itself refuses an
expected_accountthe grant does not confirm(all three mutation-verified); an attestation write that fails
undoes the insert and answers
500 bedrock_kb_attestation_failedwith norow and nothing attested; an unreadable consent store makes the revoke
raise (bytes untouched, a missing store reads as nothing attested) and the
DELETE route answer
500 bedrock_kb_attestation_revoke_failedwith therow still present (mutation-verified against the fail-soft read); a delete revokes before the row goes, a failed
revoke deletes nothing, and the two writes run in that order; all
mutation-verified), the failed-revoke text (both paths answer "Couldn't
remove this source. Nothing was deleted. Try again."), the re-add recovery (a re-add of a KB whose
attestation went dark answers
409 source_existswith the same id and theremove-then-add text, the consent store byte-identical and still one row,
failing on the generic text; removing that row and adding again attests the
new row for the new account), the owner gate on deleting a
bedrock_kbrow (anapp token, which the knowledge owner gate admits, is refused 403 with the row still attested, the same
caller deletes a local folder row, the owner deletes the Bedrock row and
its attestation goes with it; mutation-verified), the delete gate keyed
on the sealed attestation rather than the row's type (a registered row
re-labelled
local_folderby a raw write still refuses a non-owner withits attestation kept, and the owner's delete still revokes it;
mutation-verified against the type-only gate), the conflict refusals
(the add-source and consent-POST
409s each name the held sourcethrough the redacted rendering: a planted key and exfil URL arrive as
tags, never as values; both mutation-verified), the consent-POST error
split (a failed one-account lookup is the
503 bedrock_kb_conflict_check_failed; a grant write that fails, for Polly,propagates as its own error with nothing recorded; mutation-verified
against the broad catch), the consent POST's connector import (a
Bedrock confirmation loads it off the event loop, a failed lookup is
refused unchanged, a Polly one never loads it; mutation-verified against
an on-loop import), the bundle-route rule (an app-token import and an
owner import each register no
bedrock_kbrow and report it asrefused; an export leaves a registered one out and round-trips
without touching it; an item naming a registered
bedrock_kbsource isrefused and counted while the rest of the bundle lands, and an item
riding on a refused bundle row is dropped with its location, mention and
relation instead of rolling the bundle back; a crafted bundle carrying
numeric ids is refused the same way, since ids compare as text on both
sides; a refused item with no id, beside one literally called "None",
drops neither an evidence-free relation nor anything else with a null
item id, while the relation the "None" item evidences is still dropped;
an id-less refused
bedrock_kbrow beside a local source called "None"leaves that source's item in place; all five mutation-verified against
the FOREIGN KEY failure / the planted row / the dropped relation / the
refused item; the store refuses an item insert and a location attach that
name a registered
bedrock_kbsource while writing under a local sourcestill works, and the export of that store imports whole into a clean
store that never saw the row; the ingest-text route answers
409 live_source_holds_no_itemsfor abedrock_kbtarget with the pipelinenever called; the two guards and the route gate each mutation-verified;
an item, location, mention and relation planted by raw SQL under a
bedrock_kbrow are left out of the export and a clean store imports itwhole, mutation-verified against the filter; a local item whose only
other holder is a planted
bedrock_kblocation row is destroyed with itsowner on both deletion paths, with the planted row, while a genuine local
co-holder still takes ownership, and the export imports whole into a
clean store, mutation-verified against the unfiltered holder read at
each site), the spawn allowlist, and the internal
remote-searchPOSTlisted among the owner gate's read-only routes.
error-code-baseline.json: re-snapshotted withpython test/test_error_code_contract.py --update. The body-shape gateanswers every shape violation from one uncoded 400 site where there were
two, so
dashboard/handlers/knowledge.pymissing_codemoves 60 -> 59(the ratchet only ever tightens); the
_complianttotal also absorbsmain's own drift since the last snapshot.
website/src/test/SourcesList.bedrock.test.tsx(12): the type button, submitgating, the kb properties with no
uriand nothing credential-shapedin the POST body, the default name carrying the bare first KB id and no
account id when an ARN is pasted first (mutation-verified), field reset
after add, a reopened form that gates on its blank profile after an add
with a named one, so its first Add submits (mutation-verified), that a profile the consent
gate did not probe is never POSTed — it re-targets the gate instead
(mutation-verified), the consent card kept in place but inert while the
typed profile differs from the one it names, so it never offers to
confirm a profile the field no longer reads, with the hint "Finish
editing the profile to confirm." (each mutation-verified), the
Bedrock fields and buttons rendered by the shared
InputandBtn, andthe Live row's
Databaseicon (each mutation-verified), the pointerdown answer to a submit with anuncommitted profile, the region-missing reason appearing and clearing,
the profile helper line, the Live row's removal confirm copy, the file and
folder branches staying reachable, the folder branch's visible labels,
and the Live row without sync affordances but with its meaning as
visible text and a space after the dot (fails with
inline-flex), and a failed remove that restores the row and shows theerror, with the agent hand-off hidden while the add form is open
(mutation-verified).
website/src/test/CapabilitiesPage.knowledgeChunkFallback.test.tsx: withboth lazy chunks held pending, the Knowledge pane shows the same skeleton
as the Templates pane (fails with
fallback={null}).website/src/test/SourcesList.namespace.test.tsxfinds the folder path byits visible label.
Manual verification
Verified end-to-end against a real Bedrock Managed Knowledge Base
(~45K documents) with profile-based credentials: the raw vector-config call is
rejected (confirming the fallback is load-bearing), the connector returns
scored results whose URLs are the original document links, and the add-source
live probe passes. The screenshot harness
(
website/scripts/capture-bedrock-kb-source.mjs) asserts the form's presence,submit gating, hint text, consent states, add-failure notice, and the 320px
layout (region and profile stack, same width, uncompressed) against the built
SPA.
Screenshots / video
Captured from the real built dashboard by
website/scripts/capture-bedrock-kb-source.mjs(stubbed API routes), including a failed remove. The Knowledge tab's loading skeleton only shows while its chunk loads, soCapabilitiesPage.knowledgeChunkFallback.test.tsxpins it instead of a capture. The harness also clicks the Live row's remove control and asserts the confirm message is the no-local-data copy quoted above. Headless Chromium paints no nativeconfirm(), so for the "remove confirm" shot the harness draws that exact message in an in-page stand-in: the frame is the harness's, the copy is what ships.Remove confirmation on a Live row (dark), the copy the user reads before the destructive click:

Failed remove (dark): the server refused the delete, so the row is restored with "Couldn't remove this source. Nothing was deleted. Try again." inline through

ErrorNotice, and "Ask the agent" shows because the Add form is closed (committed attemp-screenshots/bedrock-kb/bedrock-source-row-remove-failed-dark.png):Add Source dialog, Bedrock KB type (dark, empty — labelled fields, the region placeholder reads

e.g. us-east-1, submit disabled):Filled (dark), consent still ungranted — submit disabled with its adjacent reason:

Consent granted — the receipt inside the form, submit enabled:

Profile being edited — the card stays in place but inert: no account, no Confirm, and the hint "Finish editing the profile to confirm." until the field commits:

Blocked submit — the profile was edited after the grant and Add was clicked: the consent card is focused and ringed, the reason turns warn-toned, the button is disabled again:

Region missing (KB IDs typed, region empty) — the third dead-submit state, with its adjacent reason:
Region-format warning (malformed region) and add-failure notice (the server's own conflict refusal, inline):


More states
Filled (light):

Narrow viewport (320px, dark) — region and profile stack instead of compressing side by side:

Connected source row: "● Live" with a space after the dot, its meaning as visible text, and no sync, staleness or item controls (committed at

temp-screenshots/bedrock-kb/bedrock-source-row-live-dark.png):Local Folder branch, labelled like the Bedrock branch, with example-only placeholders:
Related Issues
Closes #7947
Related: #14337 (AWS consent is keyed per service; re-keying it per (service, profile, region) is the keyed-grant follow-up, which deletes this PR's one-target conflict code) and #11113 (a health state for the "● Live" row).
Pattern harvest
N/A — feature PR, not a fix/revert.