Repository navigation
fix(hermes): keep recognized credentials out of the pre-compression checkpoint - #2821
Merged
hidb4ai merged 1 commit intoNov 25, 2026
Merged
Conversation
…heckpoint Pre-compression capture redacted each message only with the plugin's own rule, so an Authorization Bearer value or a prefixed key name such as DB_PASSWORD= reached the Server. Each message is now redacted with the shared prompt-privacy rule and then the plugin's rule, the same order the evaluation trace uses. The message stays in the window, so a credential never fails a required checkpoint, and fingerprints, Source IDs and coverage are unchanged.
Fengzdadi
requested review from
Alanxtl,
PsiACE and
zhanghuidinah
as code owners
November 24, 2026 20:29
16 of 17 tasks
hidb4ai
approved these changes
Nov 25, 2026
hidb4ai
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 90668d5. No blocking findings. Applying the shared scrubber before plugin redaction closes the pre-compression credential leak while preserving original-message fingerprints, overlap detection, and required-checkpoint behavior. No new database tables or external interfaces; the optional helper callback is internal. Merge score: 90/100. Local focused validation reached 461 passed and 1 skipped after rerunning a Server startup timeout and fixing review-checkout Git metadata. Real Hermes host acceptance was not exercised.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue or RFC does this PR close?
Part of #2250. Builds on #2703 (merged), which applied the shared automatic prompt privacy rule to the Hermes recall query, completed-turn capture and evaluation trace; this PR extends it to the Hermes pre-compression checkpoint.
Rationale for this change
Hermes pre-compression capture (
on_pre_compress) redacted each message only with the plugin's ownredact_secrets. That rule recognizes fewer credential formats than the shared rule insrc/powercontext_integration_lifecycle/prompt_privacy.py, and its assignment pattern consumes the scheme word of an Authorization header. As a result:Authorization: Bearer <token>reached the Server as[REDACTED] <token>;DB_PASSWORD=<value>and other prefixed key names reached it unchanged.A turn that completed-turn capture skips could therefore still reach the Server, with its credential, in a pre-compression window, and
hermes.mddocumented that gap.What changes are included in this PR?
Behavior
[REDACTED]. It is not left out.hermes-precompress-text.v1already defines its projection as the window after secret redaction, and coverage reports only capacity losses.evidence_messagespreference;Leaving flagged messages out, as completed-turn capture does with whole turns, would break the existing checkpoint contract.
test_pre_compress_filters_roles_and_redacts_secretsand the Hermes boundary conformance case (test_private_display_fields_do_not_cross_adapter_boundaries,on_pre_compress) both require that a message holdingapi_key=<value>keeps its other text with[REDACTED]in place of the value.Code
helpers.precompress_entriestakes the redaction function as a keyword argument. It defaults toredact_secrets, so the helper's behavior on its own is unchanged.provider.pyrenames_trace_redactionto_redact_credentials, now used by the trace and the checkpoint, and passes it toprecompress_entries.Tests (
tests/integrations/test_hermes_provider.py, next to the existing pre-compression tests)tests/fixtures/automatic_prompt_privacy.jsonruns through a required checkpoint, as a user message and as an assistant message, after a clean user message. The configured Authorization value is set for the known-Server-token case.completecoverage, and no value marker appears in the captured content, its metadata or any log record.Authorization: Bearer <value>commits once, does not raise, is not retried on the next call with the same window, and a later window captures only its new message.Docs
docs/{en,zh}/docs/integrations/hermes.md: the "Before compression" row and the paragraph after the table describe the shared-rule redaction and that the message stays in the window.docs/{en,zh}/docs/integrations/index.md: "Automatic prompt privacy" no longer says that Hermes pre-compression capture keeps only its own redaction.Are there any user-facing changes?
Yes, for Hermes with
capture_pre_compress=true:Authorization:header, and prefixed key names such asDB_PASSWORD=.Capture defaults, checkpoint behavior and Source IDs are unchanged. Sources already stored are not changed. No API, coverage or persisted-format changes.
A window that an earlier plugin version already stored, and that is retried unchanged after the upgrade, keeps its Source ID but now carries different content. The Server can then reject the retry as a conflict, and a required checkpoint fails for that attempt. The next window has new messages and a new Source ID.
How was this change tested?
All commands ran offline (
UV_OFFLINE=1 UV_NO_SYNC=1) on commit 90668d5, which is based onmastereb695a1.uv run pytest tests/integrations/test_hermes_provider.py: 317 passed, including the 133 new tests (66 cases × 2 roles, plus the required-checkpoint test). Without the source change, the new tests failed 85 of 133: every sensitive case that the plugin rule alone misses (42 cases × 2 roles) and the required-checkpoint test. The 11 sensitive cases that the plugin rule already caught and all 13 ordinary cases passed. This was measured on 90668d5 withprovider.pyandhelpers.pyrestored tomaster.uv run pytest tests/integrations/test_hermes_provider.py tests/test_hermes_cli.py tests/integration_conformance tests/test_automatic_prompt_privacy.py -k "hermes or Hermes": 461 passed, 1 skipped.python scripts/generate_integration_lifecycle.py --checkandprek run --files <changed files>pass.make unit-test: 10,412 passed, 449 skipped, 13 failed, 120 errors, none in a changed file. Running those 133 failing and erroring test IDs on unmodifiedmastereb695a1 gives the same 13 failures and 120 errors.test_hook_characterization,test_session_start_shells,test_user_prompt_submit_shells) come from auv syncin their fixtures that cannot complete offline, and thetest_system_cliCodex setup failure also needs packages that are not cached locally.test_jev_rerank_comparisonand 4 intest_ci_installation_roles.AI usage statement
Claude Code (Claude Opus 5.5) wrote the change, the tests and this description, ran the checks above, and reviewed its own diff. No human has reviewed it yet.