Repository navigation
fix(bub): keep recognized credentials out of automatic recall and capture - #2820
Conversation
…ture Bub was the last in-process adapter with automatic recall and capture that did not apply the shared prompt-privacy rule. The plugin now ships a generated copy of src/powercontext_integration_lifecycle/prompt_privacy.py and, like Pydantic AI after oceanbase#2703: - scrubs recognized credentials from the recall query before bounding it, so recall still runs with [REDACTED] in place of each value; - skips the user_prompt event when the initial task contains a recognized credential, and records the skip in the capture log with the reason sensitive_content and without the text; - leaves llm_result and tool_result events to their existing key-based and known-credential redaction. The configured API token counts as a known credential. A new harness test drives a Bub turn for every case in automatic_prompt_privacy.json.
NeverENG
left a comment
There was a problem hiding this comment.
Reviewed 9c55119. The sensitive-prompt skip behavior conflicts with the existing Bub service-chain acceptance test, which fails the required bub-host job. Please align that case with the new behavior while retaining its credential-leak and flush assertions; details inline.
hidb4ai
left a comment
There was a problem hiding this comment.
Confirmed the existing service-chain finding against the code and the bub-host CI log: test_bub_capture_removes_known_credential_values still expects one user_prompt Source, while this change correctly skips it (0 == 1). Please update that acceptance case to the skip contract while preserving the original-model-input, credential-exclusion, and flush checks, then rerun bub-host. The shared scrubber and scrub-before-bounding approach are reasonable; the failing acceptance gate prevents approval.
The Bub service-chain case still expected a redacted user_prompt Source for a prompt that carries Bub's own provider key. That prompt now holds a recognized credential, so the plugin skips the event. The case now asserts that no user_prompt Source is sent and that the capture log records the skip without the prompt text. It keeps the checks that the model receives the prompt as written, that no captured Source, stored Source, generation request or log line carries the credential, and that the turn flushes. The replay harness reads the same capture log into CaptureRecord, which forbids unknown fields and rejected the skip record's reason. It now accepts the field, and the plugin privacy test validates every record against it.
Re-reviewed f08ad37. The previously reported service-chain assertion is corrected while retaining credential-exclusion and flush checks; bub-host and CI result now pass. CaptureRecord also accepts the new skip reason. Withdrawing my obsolete change request. This is not an approval: the PR extends the capture-log/evidence contract with reason=sensitive_content, which falls outside the requested no-new-interface automatic-approval condition.
Addressed in f08ad37; the service-chain acceptance test now follows the skip contract and bub-host CI passes.
Which issue or RFC does this PR close?
Part of #2250. #2703 applied the shared prompt-privacy rule to Hermes, LangChain, LangGraph, and Pydantic AI. This PR applies it to Bub, the last in-process adapter with automatic recall and capture.
Rationale for this change
The integrations guide's automatic prompt privacy policy (#2174,
tests/fixtures/automatic_prompt_privacy.json) says that an automatic recall query must not carry a recognized credential, and that a prompt containing one is not captured. Every hook host and, since #2703, every Python SDK adapter follows it.On master, the Bub plugin applies neither half of the rule:
prepare_contextquery;capture_eventson, it stores the initial task as auser_promptSource with only the key-based and known-environment redaction ofrender_capture_event.Bub's
SecretStrprotects only the plugin's own API token in its settings.Bub is the evaluation harness, not a supported Agent framework. Its runs still send prompts to a real Server, and harness tasks and paired evaluations can contain configuration text.
What changes are included in this PR?
What reaches the Server, before and after
before_llm_callrecall queryapi_token, replaced by[REDACTED], then boundeduser_promptcapture event (capture_events=true)llm_result/tool_resulteventsThe behavior follows #2703's Pydantic AI treatment:
prompt_capturedis still set when the event is skipped, so later model calls in the same turn do not retry it. A query with no UTF-8 form still skips recall, as in #2666.Code
integrations/bub/src/powercontext_bub/_prompt_privacy.py: a generated copy ofsrc/powercontext_integration_lifecycle/prompt_privacy.py. It is registered inscripts/generate_integration_lifecycle.py, with a py39 per-file target inpyproject.tomllike the other copies. Bub keeps a private copy for the same reason as the SDK adapters: it also supports released cores, as itsContextAssemblyimport fallback shows.plugin.py: appliesscrub_secretsto the recall query in_prepare_contextand to theuser_promptcheck inbefore_llm_call. The authorization value isBearer <api_token>when a token is set.e2e/bub/src/powercontext_e2e/models.py: the replay harness'sCaptureRecordaccepts the skip record'sreason. The model forbids unknown fields, so without it a harness task whose initial task carries a recognized credential would lose its capture evidence.Where Bub differs from #2703, and why
POWERCONTEXT_BUB_CAPTURE_LOG) as{"event": "user_prompt", "status": "skipped", "reason": "sensitive_content"}, without the text. The plugin logs nothing throughloggingand reports its other skips and failures only in that log, so this adds no logger.e2e/bub/tests, not intests/inprocess_adapter_turns.py. Bub andrepublicinstall only in the harness environment (e2e/bub, Python 3.12+), which the root test environment cannot import.integrations/evaluation.md, not inintegrations/index.md, which lists only the supported hosts and framework adapters._bounded_recall_queryinstead of a generatedprepared_contextcopy; this PR does not change it.Docs
integrations/bub/README.md: describes the recall query, the skippeduser_promptevent, and the capture-log record, and links to the automatic prompt privacy policy.docs/en/docs/integrations/evaluation.mdanddocs/zh/docs/integrations/evaluation.md: one paragraph each with the same rule.integrations/capabilities.toml: Bub's test evidence now listse2e/bub/tests/test_bub_prompt_privacy.py.CI path selection needs no change:
integrations/bub/**selectstests,bub, andharness, ande2e/bub/tests/**selectsharness. Checked withci_changes.select_suitesagainst.github/ci-paths.toml.src/**selectsbubandharness.integrations/bub/**, which does.Are there any user-facing changes?
Yes, for Bub runs:
capture_eventson, an initial task that contains one is no longer stored as auser_promptSource; the model's reply and tool events are still captured.Recognition is best effort; see the automatic prompt privacy section of the integrations guide. There are no API, settings, or persisted-format changes. Existing Sources are not rewritten.
How was this change tested?
New
e2e/bub/tests/test_bub_prompt_privacy.pydrives one Bub turn throughBubFramework.process_inboundfor every case inautomatic_prompt_privacy.json(66 cases, 53 sensitive). The turn uses Bub's builtin hooks, a stub model over a mock transport, and a recording PowerContext client, withcapture_events=trueand the case's token asapi_token. For each case it checks:CaptureRecord;llm_resultcaptured; the skip record present;user_promptandllm_resultare both captured.Before the source change, the new test failed for all 53 sensitive cases (53 failed, 13 passed). Making
_authorizationreturnNonefails theknown-server-tokencase. The harness'sCaptureRecordforbids unknown fields and rejected the skip record'sreason(53extra_forbiddenfailures), which would have dropped a task's capture evidence in a harness run; it now acceptsreason.tests/e2e/test_bub_service_chain.py::test_bub_capture_removes_known_credential_valuesrunsbub runwith the plugin against a real in-process Server. Its prompt carries Bub's own provider key, which the rule recognizes, so the case now expects the skip:user_promptSource is sent, and the turn's other events still are;user_promptrecord with statusskippedand reasonsensitive_content, and none of the prompt text;It keeps the earlier checks: Bub's model receives the prompt as written; no captured Source, stored Source, Server generation request, or capture-log line carries the credential; and the turn flushes. The other Bub service-chain cases that capture
user_promptuse prompts without a recognized credential, and none of the replay harness's committed workload and scenario text contains one.Commands, run on f08ad37 (on master eb695a1), offline. Bub ran from an existing harness venv with bub 0.6.1, republic 0.6.1, and pytest 9.1.1, matching
e2e/bub/uv.lock. It was pointed at this checkout withPYTHONPATH, and module paths were verified first.POWERCONTEXT_TEST_BUB_HOST=1 pytest tests/e2e/test_bub_service_chain.py(thebub-hostjob's command): 5 passed. Before the test update, on 9c55119, it failed as in CI (assert 0 == 1at theuser_promptcount; 1 failed, 4 passed).python -m pytest e2e/bub/tests(themake harness-testsuite): 414 passed, including the 66 new cases.ruff checkandruff format --checkone2e/bub,integrations/bub, the generator, and the service-chain test: passed.ty check --project e2e/bub --python-version 3.12 --extra-search-path src e2e/bub/src integrations/bub/src: passed.python -m powercontext_e2e --help: passed.python scripts/generate_integration_lifecycle.py --check(make integration-lifecycle-check): passed; it failed with "is missing" before the copy was generated.pytest tests/test_integration_lifecycle.py tests/test_integration_shared_files.py tests/test_automatic_prompt_privacy.py tests/test_recall_query_bound.py tests/test_ci_changes.py tests/test_integration_manifest.py: 926 passed (on 9c55119; the follow-up commit changes none of their inputs).generate_integration_manifest_docs.py --check(make integration-manifest-check): passed.prek run --files <changed files>: every hook passed exceptty-check, which was skipped because it needs a synced environment. Run directly,ty check: passed.Not run:
make harness-acceptance);make docs-test(website build);make check.AI usage statement
This PR was written with Claude Code (Claude Opus 5.5), which read the code, implemented the change, wrote the tests and docs, and ran the checks above. No human has reviewed the change yet.