Skip to content

feat(knowledge): add Amazon Bedrock Knowledge Base retrieval sources - #26988

Merged
kyleseaman merged 1 commit into
mainfrom
greener/pr-8985
Nov 2, 2026
Merged

kyleseaman merged 1 commit into
mainfrom
greener/pr-8985

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #8985. Maintainer takeover of @jingchaodev's PR on a branch of this repository, because the Sensitive Change Review gate refuses every fork PR that touches a sensitive path (here src/kiro_crew/security_posture_sinks_gateway.py, one new redaction-sink row). The author's commit is kept as-is (author: Jingchao Cao).

What changed in the takeover, on top of #8985's head 3567ae1f8:

  • Rebased onto current main (about 3,700 commits later). main split knowledge/store.py into store_parts/* and dashboard/handlers/knowledge.py into knowledge_*.py owners, so the PR's changes were ported into those owners unchanged in behavior: the live-source guards and bundle refusals now live in store_parts/item_ownership.py, item_rows.py, maintenance_sweeps.py, bundle_transfer.py and source_rows.py; the add/delete gates in knowledge_sources.py (the locked Bedrock insert is now the helper _insert_bedrock_source); the remote-search route in knowledge_agent_context.py; the lazy connector in knowledge_lifecycle.py; the redaction-sink row in security_posture_sinks_gateway.py; the internal path in server_internal_paths.py.
  • main replaced the Add Source tabs with Files and folders / Web Page; Bedrock Knowledge Base is now the third tab. The PR's relabelling of the folder form was dropped (main rebuilt that form), along with its folder_path_example_placeholder key and the test for it.
  • Dropped temp-screenshots/bedrock-kb/*.png and website/scripts/capture-bedrock-kb-source.mjs from the diff, as asked in review.
  • Two test files went over the 2,000-line cap and were split by whole classes: test/test_aws_consent_bedrock.py and test/test_knowledge_bedrock_bundles.py.
  • The maintainer confirmed on 2026-11-01 that this feature is wanted. feat(knowledge): add Amazon Bedrock Knowledge Base retrieval sources #8985's two open design questions (the knowledge.db row as the readers' record with the attestation as the authority, and the one-AWS-account-at-a-time interim code whose removal aws-control: consent is stored per service but presented per account, so only one account can use a paid service #14337 tracks) still need a maintainer's explicit ruling.

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

Not a goal

  • Keying AWS consent grants per (service, profile, region). v1 allows one Bedrock account at a time; the keyed-grant change is a follow-up that also deletes the one-target conflict code.
  • Caching the STS consent probe, or telling the caller when the remote leg was skipped.
  • A failure state on the "● Live" row for a revoked grant or broken credentials (tracked in knowledge: Bedrock KB Live row should reflect grant and retrieval health #11113).
  • Storing Bedrock content locally, or carrying a Bedrock source through a bundle export or import.
  • Writing to a Knowledge Base: the connector only calls 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_kb row or a bedrock-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_store builds its own local corpus, so add_item never sees a live source there.

  • Reader: website/src/components/MarkdownPanel.tsx:useFileKnowledgeState -- crew page -- posts the file's basename as name; a non-Bedrock name is stored as sent (test_markdown_panel_file_add_keeps_a_long_basename)
  • Reader: website/src/pages/knowledge/SourcesList.tsx:handleAdd -- crew page -- posts addName || addUri; a long typed name or folder path is stored whole (test_knowledge_tab_folder_add_keeps_a_long_name)
  • Reader: website/src/apps/md-notebook/api.ts:knowledgeRegister -- app -- posts the vault name, stored as sent (test_md_notebook_vault_add_keeps_a_long_vault_name)
  • Reader: src/kiro_crew/dashboard/handlers/knowledge.py:import_bundle -- crew page -- a bundle main exports has no bedrock_kb row and no bedrock-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)
  • Reader: src/kiro_crew/knowledge/ingestion.py:IngestionPipeline._ingest_file_body -- crew page -- every caller passes a local source it created or synced; only a bedrock_kb id is refused (test_triggers_immediate_ingestion)
  • Reader: src/kiro_crew/knowledge/ingestion.py:IngestionPipeline._ingest_text_impl -- crew page -- the ingest-text route refuses a bedrock_kb source 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)

Part What it does
src/kiro_crew/knowledge/connectors/bedrock_kb.py one bedrock-agent-runtime Retrieve per configured KB (kb_ids takes ids or ARNs, at most 10), merged by relevance; vectorSearchConfiguration with a managedSearchConfiguration fallback for MANAGED KBs; the query text leaves the host through the platform shim redact_via_context (a companion policy's shapes on top of the OSS baseline, whose URL pass runs first); citations from the document's source_uri metadata; 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 recognise
search_remote_sources_bounded (connector), src/kiro_crew/mcp_tools/knowledge.py, search_for_context a shared worker pool under a wall-clock budget over bounded timeouts, failing OPEN to local-only results, interleaved by rank; the enumeration reads at most 64 bedrock_kb rows (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 in knowledge.db cannot 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 no bedrock_kb source pays one indexed SELECT and starts no thread; on the MCP tool a namespace scope skips the leg, since a bedrock_kb source holds no items and so no hit can fall inside a namespace
src/kiro_crew/aws_consent.py, src/kiro_crew/dashboard/handlers/aws_consent.py, src/kiro_crew/dashboard/server.py, src/kiro_crew/security_posture.py the bedrock-kb consent 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") under bedrock-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-delete revoke_if_matches / reconcile_drift for bedrock-kb only (every other service keeps main's key-wise revoke, 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 for bedrock-kb, so no confirmation loads it on the event loop and a Polly or Transcribe one never loads it
src/kiro_crew/dashboard/handlers/knowledge.py owner-only bedrock_kb add 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; a bedrock_kb name, typed or uri-derived, is redacted whole through redact_via_context and then cut to 200 characters (so a credential across the cut is never stored as an unrecognisable fragment), the most a search result serves back, and every other type stores its name as sent, as on main; the retained triple kb_ids / region / profile bounded at retention (400 bedrock_kb_config_invalid); server-derived uri (bedrock-kb://<region>/<sorted ids>); attestation written with the row and pinned to the account validation verified, which the connector's validate_registration returns (a confirmation for another account landing mid-validation, or a grant that moves to another account and back while the probes run, is 409 bedrock_kb_grant_changed; 500 bedrock_kb_attestation_failed undoes the insert; delete revokes first, and a failed revoke is 500 bedrock_kb_attestation_revoke_failed with "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 through security.redact; only a row a gateway attestation pins holds the target, so a row written straight into knowledge.db refuses nothing); at most 64 registrations (MAX_BEDROCK_KB_SOURCES, attestations under any account): the next add is 409 bedrock_kb_source_limit before 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 answers source_exists at the limit; 409 live_source_holds_no_items on ingest-text under a live source; a re-add of a registered KB answers 409 source_exists with text naming the remove-then-add recovery, since only a row the add creates is attested; internal remote-search route
src/kiro_crew/knowledge/store.py _ACCOUNT_BOUND_SOURCE_TYPE: export_all drops bedrock_kb rows, import_bundle refuses them, and a row of any type carrying a bedrock-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_txn raise LiveSourceHoldsNoItems, 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 a bedrock_kb row own a local document; bedrock-kb:// exempt from the local-path check
website/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/*.json the Bedrock KB add form (labelled fields built from the shared Input and Btn, 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 through ErrorNotice, 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 through lazy() + Suspense behind the Templates tab's ContentSkeleton
src/kiro_crew/extras.py, setup.cfg the optional [bedrock] extra (boto3, imported lazily)
docs/system-specs/modules/knowledge.md, docs/feature-map/README.md every rule above, in the same commit; the feature-map entry

A 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_kb source 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 an aws_consent.denied SEL 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.db is agent-writable in-sandbox, so the owner-gated insert also records the row in aws_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_item and add_source_location_in_txn refuse 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 the uri is 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 SourcesList would cross the App chunk's first-party ceiling, so CapabilitiesPage.tsx loads the Knowledge tab through lazy() + Suspense inside its existing ErrorBoundary; the sources list, ingestion controls and form are a KnowledgePage-*.js chunk only the Knowledge tab fetches, so App stays under its ceiling. The 14 keys x 13 locales add ~12.6 KB to the eager all catalog 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;
Loading

🟩 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): every
    string a hit keeps stays within its bound while normal-size strings pass
    through unchanged (mutation-verified against the unclamped append); the
    kb_ids bounds (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
    ValidationException text a live Retrieve against a MANAGED knowledge
    base 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 denied audit event naming the refused KB and issue
    no 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 denied line naming the registration
    (mutation-verified against a grant-only recheck); each freeze-verify refusal (other account, other profile,
    other region) writes exactly one denied event naming the target and
    the 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 denied line 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_kb row reads keep every field
    bounded: 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 denied line instead of matching the
    attested 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); region and profile outside the shapes a grant can name are
    refused before any probe and by retained_properties itself, and pass
    stripped 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 credential
    policy 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.redact import).
  • test/test_mcp_knowledge_search.py: a namespace-scoped
    local_knowledge_search over a store with a registered bedrock_kb row
    makes 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 to bedrock-kb (a Polly drift and a Polly authorize mismatch revoke key-wise, a row whose own service field names another service cannot redirect the revoke, only the Bedrock grant carries a grant_id, and the consent GET pins the drift check for bedrock-kb alone; mutation-verified four ways), the probe timeout (a
    budgeted 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 timeout only when budgeted, so an
    unbudgeted probe keeps its exact call; fails when timeout=None is
    passed), the probe cache (both write sites hold it at
    _PROBE_CACHE_MAX_ENTRIES, evicting the oldest; a held key refreshes
    without 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_kb name with a secret straddling the cap is redacted before the cut (test_a_long_name_is_redacted_whole_before_the_cut), a bedrock_kb name over 200 characters is cut to 200 while
    a 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_folder that carries a bedrock-kb://
    uri is refused and leaves the uri free (mutation-verified), off-loop add-time
    validation, the owner gate on bedrock_kb registration (messaging
    non-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 uri from the owner
    with valid Bedrock properties is a 400 before validation with nothing
    persisted, every read field is gated, null reads as absent;
    mutation-verified against the 500), the retained triple (a body with
    extra properties keys lands as a row carrying exactly the three read
    keys, 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, never
    reaches 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 four
    mutation-verified), the attestation (the insert records exactly
    the inserted row, pinned to its stored triple so a widened kb_ids does not
    match, and a DELETE of the row drops the entry; mutation-verified
    against no-attest and no-revoke; a retained profile or region outside
    its bound is a coded 400 with no row even when the registered
    connector's validation passes everything; a same-target confirmation for
    another account landing during validation is 409 bedrock_kb_grant_changed with no row and nothing attested, and so is a
    grant 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_account the grant does not confirm
    (all three mutation-verified); an attestation write that fails
    undoes the insert and answers 500 bedrock_kb_attestation_failed with no
    row 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_failed with the
    row 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_exists with the same id and the
    remove-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_kb row (an
    app 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_folder by a raw write still refuses a non-owner with
    its 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 source
    through 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_kb row and report it as
    refused; an export leaves a registered one out and round-trips
    without touching it; an item naming a registered bedrock_kb source is
    refused 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_kb row 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_kb source while writing under a local source
    still 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_items for a bedrock_kb target with the pipeline
    never called; the two guards and the route gate each mutation-verified;
    an item, location, mention and relation planted by raw SQL under a
    bedrock_kb row are left out of the export and a clean store imports it
    whole, mutation-verified against the filter; a local item whose only
    other holder is a planted bedrock_kb location row is destroyed with its
    owner 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-search POST
    listed among the owner gate's read-only routes.
  • error-code-baseline.json: re-snapshotted with
    python test/test_error_code_contract.py --update. The body-shape gate
    answers every shape violation from one uncoded 400 site where there were
    two, so dashboard/handlers/knowledge.py missing_code moves 60 -> 59
    (the ratchet only ever tightens); the _compliant total also absorbs
    main's own drift since the last snapshot.
  • website/src/test/SourcesList.bedrock.test.tsx (12): the type button, submit
    gating, the kb properties with no uri and nothing credential-shaped
    in 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 Input and Btn, and
    the Live row's Database icon (each mutation-verified), the pointerdown answer to a submit with an
    uncommitted 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 with no status dot (a grey dot read as "off"); the consent ask names the billed call and links AWS pricing; after a bedrock_kb_target_conflict refusal Add stays disabled until region or profile changes, and a failed remove that restores the row and shows the
    error, with the agent hand-off hidden while the add form is open
    (mutation-verified).
  • website/src/test/CapabilitiesPage.knowledgeChunkFallback.test.tsx: with
    both 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.tsx finds the folder path by
    its visible label.

Review fixes on 40c8120

  • GPT 6.1 F1: the add handler redacts the whole Bedrock name before the 200-character cut, and _row_is_attested logs source=<clipped id> instead of the SQL-clipped projection when identity_exact is 0 (test_an_oversized_planted_id_never_logs_its_clipped_credential).
  • UX: billing detail + AWS pricing link on the bedrock-kb consent ask; Add disabled while a one-account conflict holds for the typed target; region hint reworded; no dot on the Live label.
  • CI: restored sourcesList.folder_path_e_g_home_user_notes in 11 locales (lost in an earlier merge); revoke_if_matches and record_source_attestation listed in the lenient-read ratchet (an unreadable store reads as {} so the compare-and-delete writes nothing; the attestation write preserves an unreadable store first).

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

Re-captured on head db9cdbf with stubbed /api routes (capture script not committed). Every frame comes from this head. The remove-confirmation copy is a native window.confirm, which a headless capture cannot draw; its wording is pinned by SourcesList.bedrock.test.tsx.

Add Source, Bedrock Knowledge Base tab beside Files and folders / Web Page (dark, empty)

Filled, consent not yet confirmed: the row says what is billed and labels the AWS account; AWS pricing as follow-up link; Add disabled with its reason (dark)

Consent confirmed: labelled AWS account, Add enabled (dark)

Profile being edited: same card title, inert until the field commits (dark)

Blocked submit: the consent card is focused and ringed (dark)

Region missing (dark)

Malformed region warning (dark)

One-account conflict refusal: Add stays disabled for this target; the conflicting Team design KB row is listed below (dark)

Filled, consent ask with billing line and labelled account (light)

Narrow 320px viewport (dark)

Connected row: plain Live label, no status dot, no sync, item count or staleness (dark)

Failed remove: row restored with an inline notice (dark)

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.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture_sinks_gateway.py

  • @iamwhatever posted a complete reasoning template for 30f375c.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 30f375c1f7f420c636c9a57f897f82eff939a7df — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The new refusals only touch bedrock_kb rows and bedrock-kb:// URIs, and the attestation lives in the read-only aws_service_consent.json leaf, so a row the agent plants in knowledge.db is never searched.

Notes

[DESIGN-REVIEWED] 30f375c

Description read

[DESCRIPTION-READ] b9e86b4c4e9b3ee84a89de9dc1d885d99943eac6570e4945c040cf279dbe0613

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 30f375c1f7f420c636c9a57f897f82eff939a7df — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The feature is a new opt-in source type added beside the existing ones, so no default changes. It builds on mechanisms the repo already has: BaseConnector, aws_consent gating, the redaction shim and mcp_core._post.

What this change ships

Inventory (9 items) — 9 justified

Intent: let knowledge search answer from a team's existing Amazon Bedrock Knowledge Base without ingesting it locally (#7947). ADDITION.

  1. The Add Source dialog gets a third tab, "Bedrock Knowledge Base", which registers a live source — justified
  2. Knowledge search (dashboard context and the MCP knowledge_search tool) merges live Bedrock results with local ones by rank, and falls back to local-only results if the Bedrock leg fails or runs out of time — justified
  3. A new paid-service consent card, "Amazon Bedrock (knowledge base retrieval)", that checks the profile and region typed into the form — justified
  4. The gateway keeps a record of each Bedrock source it registered, and only those sources are searched, because knowledge.db is agent-writable — justified
  5. Confirming a second AWS account while a Bedrock source is registered is refused with a 409 (interim; its removal is tracked in aws-control: consent is stored per service but presented per account, so only one account can use a paid service #14337) — justified
  6. A Bedrock source is refused as a target for items, ingest, sync, orphan reclaim and bundle import/export — justified
  7. New optional bedrock extra (boto3) — justified
  8. New internal route /api/knowledge/remote-search and a redaction-sink row for Bedrock queries — justified
  9. The Knowledge tab now loads as its own lazy chunk with a skeleton while it loads — justified

[FIRST-PRINCIPLES-REVIEWED] 30f375c

Description read

[DESCRIPTION-READ] abda66c917a2d93fe1e0965482ebc8174f0da7da123d493e08e801ecc9af7bbe

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d7e2aec
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. test/test_bedrock_kb_connector.py exercises the query redaction before the client call, and the security posture tests pass with the row.
  • No regression:
    • Tools still work (which tools/commands were run, result): local_knowledge_search MCP tests (test_mcp_knowledge_search.py) and the knowledge add/delete/import routes (test_knowledge_add_source.py, test_knowledge_bedrock_bundles.py) pass locally.
    • Backward compatible (old config / old data / old callers still work, how checked): The row is additive; existing sink rows are unchanged, and the security_posture test files pass on this head.
    • Existing tests (which suites passed on this head): 90 knowledge, store, spawn-audit, security-posture, internal-path and error-code test files (2912 tests) plus the bedrock/aws-consent files (527 tests) passed locally; flake8, isort, pinned black and mypy are clean.
  • How to undo: Revert commit d7e2aec, or delete the one Bedrock row from _REDACTION_SINKS in security_posture_sinks_gateway.py.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 30f375c1f7f420c636c9a57f897f82eff939a7df and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 30f375c

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 30f375c1f7f420c636c9a57f897f82eff939a7df false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 30f375c1f7f420c636c9a57f897f82eff939a7df — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

The screenshots cover every new control, and the blind reader understood the main path: the Bedrock tab, the ID and region fields, "Confirm and enable" and "Add Knowledge Base".

Notes

  • pending_profile_hint "Finish editing the profile to confirm." left the reader asking "Do I click away? Press Enter?", and it reuses "confirm" from "Confirm and enable". The profile is only applied when the field loses focus, so say that: "Click outside the profile field to check this account."
  • Shot 12's red band shows the test mock's text "Unreadable attestation store", which the reader could not understand. The real delete message is "Couldn't remove this source. Nothing was deleted. Try again." Retake the shot with that message so the attached evidence matches what users will see.
  • kb_ids_comma_separated_id_or_arn tells the reader the format but not where to find the ID ("no idea where I'd find the code"). Add a pointer, e.g. "Find it in the Bedrock console under Knowledge Bases."

[UX-REVIEWED] 30f375c

Description read

[DESCRIPTION-READ] 386bc3070ba4018c96e2c4fab86d8abfd590779f4ca677a52b67290f67403791

That sha256 names everything this verdict read: the PR description, plus the 15 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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 30f375c1f7f420c636c9a57f897f82eff939a7df — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 30f375c

Verdict parsed from the review's SHA-scoped output markers for commit 30f375c1f7f420c636c9a57f897f82eff939a7df.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 30f375c1f7f420c636c9a57f897f82eff939a7df false-positive: <reason, 20 to 500 characters>

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 4b1e79e
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. test/test_bedrock_kb_connector.py exercises the query redaction before the client call, and the security posture tests pass with the row.
  • No regression:
    • Tools still work (which tools/commands were run, result): local_knowledge_search MCP tests (test_mcp_knowledge_search.py) and the knowledge add/delete/import routes (test_knowledge_add_source.py, test_knowledge_bedrock_bundles.py) pass locally on this head.
    • Backward compatible (old config / old data / old callers still work, how checked): The row is additive; existing sink rows are unchanged, and the security_posture test files pass.
    • Existing tests (which suites passed on this head): the knowledge, aws-consent, bedrock connector and handler-facade suites pass locally; the change since d7e2aec only moves the bedrock_kb import in add_source onto a worker thread. flake8, isort, pinned black and mypy are clean.
  • How to undo: Revert commit 4b1e79e, or delete the one Bedrock row from _REDACTION_SINKS in security_posture_sinks_gateway.py.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 1, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 40c8120
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call. This head also redacts a Bedrock source name whole before its 200-character cut, and logs a fixed placeholder instead of a SQL-clipped source id in the denied audit line.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. test/test_bedrock_kb_connector.py exercises the query redaction before the client call and the clipped-id placeholder; test/test_knowledge_add_source.py proves the name is redacted before the cut.
  • No regression:
    • Tools still work (which tools/commands were run, result): test_bedrock_kb_connector.py, test_knowledge_add_source.py, test_mcp_knowledge_search.py, test_knowledge_bedrock_bundles.py, test_aws_consent.py, test_aws_consent_bedrock.py and test_lenient_read_rewrite_ratchet.py pass locally on this head (344 tests).
    • Backward compatible (old config / old data / old callers still work, how checked): The row is additive; existing sink rows are unchanged. A stored name without a credential is stored exactly as before (existing cut test still passes).
    • Existing tests (which suites passed on this head): the suites above, plus the frontend SourcesList.bedrock, AwsConsentGate and i18n catalog parity tests.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8039f02
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call. This head also runs the Bedrock consent probe and client STS verify once per (profile, region) per search instead of once per source; every Retrieve still rechecks the grant and its source's attestation.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. test/test_bedrock_kb_connector.py exercises the query redaction before the client call; test/test_bedrock_kb_shared_authorization.py proves one probe per target, that a refused target bills nothing, and that a spent budget is not recorded as a refusal.
  • No regression:
    • Tools still work (which tools/commands were run, result): test_bedrock_kb_connector.py, test_bedrock_kb_shared_authorization.py, test_mcp_knowledge_search.py and test_knowledge_add_source.py pass locally on this head.
    • Backward compatible (old config / old data / old callers still work, how checked): The row is additive; existing sink rows are unchanged. BedrockKBConnector.search keeps its old signature; the shared-authorization argument is optional.
    • Existing tests (which suites passed on this head): the suites above, plus flake-pattern ratchet, file line cap, comment-history and brand gates.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8039f02
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. test/test_bedrock_kb_connector.py exercises the query redaction before the client call.
  • No regression:
    • Tools still work (which tools/commands were run, result): test_bedrock_kb_connector.py, test_bedrock_kb_shared_authorization.py, test_mcp_knowledge_search.py and test_knowledge_add_source.py pass locally on this head.
    • Backward compatible (old config / old data / old callers still work, how checked): The row is additive; existing sink rows are unchanged.
    • Existing tests (which suites passed on this head): the suites above, plus the flake-pattern ratchet, file line cap, comment-history and brand gates.
  • How to undo: Revert this PR's commit. The registry row is additive and nothing else reads it, so removing it only drops the Bedrock line from the posture page.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: f0ad9cb
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. test/test_bedrock_kb_connector.py exercises the query redaction before the client call; test/test_bedrock_kb_shared_authorization.py proves no warning or audit line prints a SQL-clipped row id.
  • No regression:
    • Tools still work (which tools/commands were run, result): test_bedrock_kb_connector.py, test_bedrock_kb_shared_authorization.py, test_mcp_knowledge_search.py and test_knowledge_add_source.py pass locally on this head (260 tests with the flake ratchet).
    • Backward compatible (old config / old data / old callers still work, how checked): The row is additive; existing sink rows are unchanged.
    • Existing tests (which suites passed on this head): the suites above, plus the flake-pattern ratchet, file line cap and comment-history gates.
  • How to undo: Revert this PR's commit. The registry row is additive and nothing else reads it, so removing it only drops the Bedrock line from the posture page.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 4815175
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call. Since f0ad9cb this head only changes two Hindi UI strings (pages.knowledge.sourcesList.confirm_account_to_enable, enter_region_to_add) from the formal करें to the informal करो imperative required by style/hi.md §4.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. test/test_bedrock_kb_connector.py exercises the query redaction before the client call; test/test_bedrock_kb_shared_authorization.py proves no warning or audit line prints a SQL-clipped row id.
  • No regression:
    • Tools still work (which tools/commands were run, result): the Python side is byte-identical to f0ad9cb, where test_bedrock_kb_connector.py, test_bedrock_kb_shared_authorization.py, test_mcp_knowledge_search.py and test_knowledge_add_source.py passed. The two new Hindi values no longer match FORMAL_IMPERATIVE in website/src/i18n/style/hiStyle.test.ts.
    • Backward compatible (old config / old data / old callers still work, how checked): The row is additive; existing sink rows are unchanged.
    • Existing tests (which suites passed on this head): CI on this head re-runs the full suite; the only red on f0ad9cb besides rate-limit glitches was hiStyle.test.ts, fixed here.
  • How to undo: Revert this PR's commit. The registry row is additive and nothing else reads it, so removing it only drops the Bedrock line from the posture page.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 2, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 2, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: db9cdbf
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call. Since 4815175 this head only changes UI copy in AwsConsentGate: the compact rows label the account ("AWS account …"), the bedrock-kb confirm row states the cost (bedrock_kb_billing_short replaces bedrock_kb_billing_detail in every locale), and the pending row keeps the service label as its title.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked by this file; the consent grant/withdraw logic is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The row itself cannot break commands or lock a user out; the redaction call it describes lives in bedrock_kb.py and is covered by its own tests.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes in this file, so no sandbox run applies. The Python side is byte-identical to f0ad9cb, where test_bedrock_kb_connector.py and test_bedrock_kb_shared_authorization.py passed.
  • No regression:
    • Tools still work (which tools/commands were run, result): locally on this head, vitest for AwsConsentGate.test.tsx, SourcesList.bedrock.test.tsx, aws-control, SttSettings, SettingsVoicePanelCoverage and all of src/i18n (with I18N_BASE_REF=origin/main, so every locale style test ran on the changed values) pass; i18n:check, lint:i18n, tsc and eslint are clean.
    • Backward compatible (old config / old data / old callers still work, how checked): The aws-consent-account element still holds the bare account, so the Polly, Transcribe and S3 hosts and their tests are unchanged; the generic billing notice still shows for every non-bedrock service.
    • Existing tests (which suites passed on this head): the suites above; CI re-runs the full suite on this head.
  • How to undo: Revert this PR's commit. The registry row is additive and nothing else reads it, so removing it only drops the Bedrock line from the posture page.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 2, 2026
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 #7947
@iamwhatever

iamwhatever commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 30f375c
  • What rule changed: No rule changed. security_posture_sinks_gateway.py gains one registry row naming knowledge/connectors/bedrock_kb.py as a redaction sink: the Bedrock Retrieve query text runs the shared credential and exfiltration-URL redaction chain before the AWS call. Since db9cdbf this head changes only the frontend: SourcesList clears a stale add error (addMutation.reset) when a source is removed, when the add form closes, and when bedrock-kb consent is confirmed again, so a one-account conflict refusal no longer keeps Add disabled; and a test line no longer carries an account-id-shaped literal.
  • Before -> after (what was allowed/blocked, now): Before, the posture page listed no Bedrock sink because no Bedrock code existed. After, it lists the new egress point. No command, path or tool is newly allowed or blocked. The backend one-account conflict check is unchanged and stays the authority: a retry is rechecked against current registrations.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): The posture page would describe a sink inaccurately. The UI change can at worst let a user retry an add that the backend refuses again with the same conflict message.
  • Evidence checked (which sandbox result proves it): No sandbox behavior changes, so no sandbox run applies. The Python side is byte-identical to f0ad9cb, where test_bedrock_kb_connector.py and test_bedrock_kb_shared_authorization.py passed. New test in SourcesList.bedrock.test.tsx: conflict, then remove the other source, then Add is enabled again for the same target.
  • No regression:
    • Tools still work (which tools/commands were run, result): vitest for src/test/SourcesList*, src/pages/knowledge and AwsConsentGate.test.tsx pass locally (136 tests); tsc and eslint are clean.
    • Backward compatible (old config / old data / old callers still work, how checked): The same-target conflict test still passes: a second click on the same target without any change stays disabled.
    • Existing tests (which suites passed on this head): the suites above; CI re-runs the full suite on this head.
  • How to undo: Revert this PR's commit. The registry row is additive and nothing else reads it, so removing it only drops the Bedrock line from the posture page.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 2, 2026
@iamwhatever iamwhatever self-assigned this Nov 2, 2026
@kyleseaman
kyleseaman merged commit 359161e into main Nov 2, 2026
101 of 104 checks passed
@kyleseaman
kyleseaman deleted the greener/pr-8985 branch November 2, 2026 15:14
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 2, 2026
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.

Configurable knowledge backend: use an Amazon Bedrock Knowledge Base as a retrieval source

2 participants