Repository navigation
fix(dsh): apply the shared prompt-privacy rule to automatic recall and capture - #2625
Conversation
…d capture
DSH sent the prompt to /v1/context/prepare without removing credentials,
and decided whether to capture a prompt by substring markers ('sk-',
'api_key', 'BEGIN PRIVATE'). The markers missed most credential shapes the
other prompt adapters recognize (Authorization and Cookie headers, password
and token assignments, bearer and GitHub tokens, the configured Server
token) and skipped ordinary prompts such as "Fix the task-runner timeout".
The automatic path now uses the rule from "Automatic prompt privacy" in the
integrations guide (tests/fixtures/automatic_prompt_privacy.json): the
recall query is scrubbed before it is bounded, and a prompt that contains a
recognized credential is not captured. The guide lists DSH in the policy
table. Explicit tool writes keep their existing secret_rejected markers.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed a65b25e; no blocking findings. The automatic recall/capture path applies the shared credential policy before dispatch, preserves explicit-write behavior, and adds no database tables or public interfaces.
Verified the built plugin in real DSH 0.1.2-rc.1 against a local PowerContext Server with a scripted model, including capture enabled/disabled and the configured Server token. Full CI is still pending.
… peak memory and recall cost (#2449) * perf(atomic-memory): bound related recall candidates in SQL Bound related recall with a max_candidates limit pushed into eligibility, over-fetch one RRF window per channel, and trim fused hits and heads to the cap. SQLite and OceanBase enforce the cap in SQL; OceanBase uses one snapshot with a readiness CTE and an explicit sentinel row. Runtime configuration defaults to 100 candidates, and explicit null keeps complete enumeration. Closes: #2448 * test(atomic-memory): cover bounded related recall Cover SQLite channel caps, filter-before-limit ordering, the hybrid over-fetch window, OceanBase bindings and UNION widths, sentinel handling, runtime configuration validation, and the flush-to-reconciler chain. Closes: #2448 * docs(atomic-memory): document the default related candidate limit Document that related recall is bounded to 100 candidates by default in both locales. Closes: #2448 * perf(atomic-memory): enumerate complete related recall in pages Closes: #2448 * style(atomic-memory): format related pagination tests Closes: #2448 * fix(atomic-memory): freeze the related ranking across pages Take one complete lightweight ranking per related enumeration and slice it by offset, so corpus changes in another Scope can no longer reorder or truncate later pages. A ranked memory that leaves the index before its page is read reports stale recall instead of raising a bare KeyError. * fix(atomic-memory): keep compared reads until the window commits Release only page-local bodies from a workset and retain every compared read, so an artifact revision published mid-window conflicts and retries instead of committing against stale evidence. * docs(atomic-memory): describe related recall paging and commit checks Document the frozen lightweight ranking, what the page size bounds, and that a revision published after ranking conflicts and retries the window. * perf(atomic-memory): raise the default related page size to 250 The inherited 100 came from the retired candidate cap, where it bounded the result set. Paging only batches bodies and authorization, so the same number now multiplies a fixed per-page cost across a complete enumeration. At 50k rows, 250 turns 500 page transactions into 200: Sys 3.77s -> 0.69s, User 8.63s -> 5.15s, Wall 10.48s -> 4.81s, with the peak delta unchanged at 159.7 MB. 250 is where the gains stop (250/500/1000 stay within noise) and it leaves headroom below the 1000 validation limit. * fix(atomic-memory): skip impossible lexical admission in related paging Related recall pages no longer issue a rank query when the admission floor exceeds the query's distinct terms; whole-word coverage can never reach it. Refresh the persistence review digest for the resulting tree. * fix(atomic-memory): batch SQLite page bodies within the bind limit One page can hold up to 1000 identities, and expanding body_ids bound one variable per identity plus scope_id, past SQLite's legacy 999-variable limit. Read bodies in 900-identity batches and assemble the page from the combined rows. Refs #2449 * fix(atomic-memory): keep native FTS for related recall Related-page ranking built the legacy LOCATE/MATCH ... AGAINST query even when the tenant supports native MATCH, so one recall emitted both paths. Select the channel from _supports_native_fts() and keep the coverage query as the fallback for unsupported queries. Refs #2449 * fix(atomic-memory): compare each recalled identity once per window A paginated recall can return a published origin that an earlier comparison already revised. workset.add() resolves it to the same working item, and the empty related list still invoked the reconciler, letting a later create response rewrite the decided revision. Drop pending identities that resolve to the current proposal or to an already compared item, and re-resolve them after every batch because a noop target can turn a remaining candidate into the current proposal. Refs #2449 * test(atomic-memory): satisfy lint and typing in the batching regression The fake connection indexed a nullable parameter map and the file needed ruff formatting, which failed the quality gate. Refs #2449 * test(dsh): surface setup CLI output when the runtime fixture fails The include-tree test only reports `exit code 1` because `powercontext setup dsh --json` writes the failure detail to stdout and the fixture discards it. Print both streams so the next CI run identifies the step that fails. This is temporary diagnostic scaffolding and will be reverted. * chore(build): regenerate plugin artifacts left stale by #2625 * chore(release): refresh the persistence review digest
… sources (#2637) Three pull requests merged on 11-13 within four minutes. #2608 added the committed DSH pet bundle. #2516 added the `X-PowerContext-Resolve-Target` header parameter to `check_context` in the generated operation table. #2625 changed `containsSecret` in the DSH plugin's `src/secrets.ts`. The Cindy worker and the DSH pet bundle include those modules, and neither committed bundle was rebuilt for the combination. So `make cindy-test` and `make js-test` fail their freshness checks on master and on every pull request that selects those suites. Only the two bundles are regenerated, with the existing builds. Their credential checks now follow the shared prompt-privacy rule, as their sources have since #2625. The pet does not call `check_context`.
Which issue or RFC does this PR close?
Part of #2250.
Rationale for this change
The prompt adapters listed under "Automatic prompt privacy" in the integrations guide follow one rule, defined by
tests/fixtures/automatic_prompt_privacy.json:Claude Code, Codex, WorkBuddy, Kimi Code, ZCode, OpenCode, and Pi test against that fixture. DSH did not, and it diverged in two ways:
POST /v1/context/preparewithout removing credentials.sk-,api_key,BEGIN PRIVATE). These miss most credential shapes the other hosts recognize, such asAuthorizationandCookieheaders,password=andaccess_token=assignments, bearer and GitHub tokens, and the configured Server token. They also skip ordinary prompts that merely contain a marker, such as "Fix the task-runner timeout".What changes are included in this PR?
What reaches the Server, before and after
POST /v1/context/preparequery[REDACTED], then bounded as beforePOST /v1/sources/contentsk-,api_key, orBEGIN PRIVATEsensitive_content, as beforesecret_rejected)Code
src/secrets.tsaddsscrubSecretsand the sharedcontainsSecret(text, authorization), with the same patterns as the Pi and OpenCode plugins.src/recall.tsscrubs the query with the configured authorization beforeboundedRecallQuery.src/capture.tsuses the shared rule.lib/index.jsis rebuilt; it changes only in these functions.Tests and fixture
tests/prompt-privacy.spec.tsreadsautomatic_prompt_privacy.jsonand checks two things:runRecallPreStepend to end. For each case it asserts that no request carries the synthetic credential and nothing is captured when the case is sensitive, and that query and capture are unchanged when it is not.containsSecretassertions intests/invoke.spec.tsmoved into the new spec. Explicit-write rejection stays covered byinvoke.spec.tsandmcp.spec.ts;invoke.spec.tsgains a private-key case, because the removed assertions were the only ones pinning theBEGIN PRIVATEmarker.marker-inside-wordcase ("Fix the task-runner timeout before the release.", not sensitive). Every host that reads the fixture passes it, because they already share the rule.integrations/capabilities.tomllists the new spec as DSH evidence, as OpenCode and Pi do.Docs
docs/{en,zh}/docs/integrations/dsh.mddescribe the rule under "Understand what the plugin does" and link to the policy section.docs/{en,zh}/docs/integrations/index.mdadd DSH to the "Automatic prompt privacy" table, withPOWERCONTEXT_DSH_CAPTURE_PROMPTS=falseto disable capture.Not included, as follow-ups:
password=value is not. Aligning them with the shared rule changes which explicit writes are rejected, so it gets its own PR.Are there any user-facing changes?
Yes, for DSH's automatic path only:
Explicit tools are unchanged. Sources already stored are not changed.
How was this change tested?
make js-test: 575 unit tests, build withlib/freshness, and 8 e2e tests.make check, andgit diff --check.uv run pytest tests/test_automatic_prompt_privacy.py(99 passed), andtests/test_integration_manifest.py,tests/test_ci_changes.py, andtests/test_dsh*.py.The fixture's other readers pass with the new case:
prompt-privacy.spec.ts;tests/plugin.test.mjs;tests/plugin.test.mjs. One loopback-alias test there fails on macOS because the host has no127.0.0.2; it is unrelated.No real DSH host was run.
make dsh-runtime-testdownloads the pinned host and was not run locally.Self-review against
REVIEW.md, plus an independent review pass, found nothing blocking. Fixed:Confirmed by execution:
lib/matches a rebuild;Left as a design note: a short configured Server token is redacted wherever it occurs, which matches Pi and OpenCode.
AI usage statement
Claude Code (Claude Opus 5.5) found the gap, wrote the change, tests, and this description, and ran the checks above. I reviewed the result.