Repository navigation
refactor(integrations): generate the TypeScript prompt-privacy copies from one source - #2644
Conversation
… from one source DSH, OpenCode, and Pi each kept their own copy of the automatic prompt-privacy rule (SECRET_PATTERNS, scrubSecrets, containsSecret). The copies matched in patterns and behavior; OpenCode's lacked the doc comments and named one variable differently. integrations/lifecycle/prompt-privacy.ts is now the source, and scripts/generate_integration_lifecycle.py writes it to src/prompt-privacy.ts in each of the three plugins, so `make check` rejects a copy that drifts. The file is named after the rule, like the Kimi Code and ZCode shared/prompt-privacy.mjs: DSH's src/secrets.ts keeps its own explicit-write check, which is not part of the shared rule, and a shared secrets.ts copy would have displaced it. Pi and OpenCode drop src/secrets.ts and import the rule from src/prompt-privacy.ts. DSH's src/secrets.ts keeps only the explicit-write check; capture, recall, the DSH pet, and the Cindy worker import the rule from prompt-privacy.ts. Behavior does not change. The DSH, DSH pet, Cindy, and OpenCode bundles are rebuilt.
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed b91159a. No correctness issues found. Generating the existing prompt-privacy rules from one source prevents copy drift while preserving behavior and the shipped package interfaces; no database tables or APIs are added.
Validated old/new behavior equivalence, generator rejection of missing/stale/unlisted copies, plugin tests and type checks, rebuilt bundle freshness, live-Server DSH call-through, and Pi CLI package loading. The DSH startup timeout passed when rerun alone with locked dependencies. Full model conversations were not exercised.
hireview001
left a comment
There was a problem hiding this comment.
- Resolve merge conflicts with the target branch.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed bf3ef53 against fd16583. No blocking findings. The merge resolution preserves the DSH explicit-write privacy fix, including configured-credential checks, and retains both flush-progress and prompt-privacy generation. No database tables or interfaces are added relative to master.
Behavior comparisons, generator failure-mode probes, affected plugin tests, type checks, and bundle freshness checks passed. Live-Server DSH tests also passed after rerunning the cases affected by startup/shutdown timeouts. Full host/model conversations were not exercised.
…source (#2704) #2636 gave the OpenClaw plugin the automatic prompt-privacy rule as a hand-written src/secrets.ts, and #2644 made integrations/lifecycle/prompt-privacy.ts the source of the DSH, OpenCode, and Pi copies. OpenClaw's copy was the only one the generator did not write or check. scripts/generate_integration_lifecycle.py now also writes src/prompt-privacy.ts into the OpenClaw plugin, so `make check` rejects it if it drifts. src/secrets.ts is removed, and src/lifecycle.ts and its privacy test import the rule from ./prompt-privacy.js. The generated copy differs from the removed file only in comments, so behavior does not change.
Which issue or RFC does this PR close?
Part of #2250. Follows #2623, which made
integrations/lifecycle/the source of the TypeScript helpers that host plugins ship and generated the transport copies from it.Rationale for this change
DSH, OpenCode, and Pi each kept a hand-maintained copy of the automatic prompt-privacy rule: the credential patterns,
scrubSecrets, andcontainsSecret. The copies currently match, but nothing checks them, so a fix to the rule in one plugin can miss the others. This PR generates them from one source, as #2623 did for the transport.Before the move the copies were compared:
scrubSecretsandcontainsSecretbehave the same. OpenCode's copy only lacked the doc comments and named one callback variable differently.shared/prompt-privacy.mjscopies use the same patterns.What changes are included in this PR?
Source and copies
integrations/lifecycle/prompt-privacy.tsholds the patterns,scrubSecrets, andcontainsSecret, taken unchanged from the Pi copy.scripts/generate_integration_lifecycle.pywrites it tosrc/prompt-privacy.tsin the DSH, OpenCode, and Pi plugins.make checkandtests/test_integration_lifecycle.pyreject a copy that drifts, andmake integration-lifecyclerewrites them.Why
prompt-privacy.tsand notsecrets.tssrc/secrets.tsalso holds the DSH-only explicit-write check (hasSecretContentand the tables of operations and fields it inspects), which is not part of the shared rule.secrets.tswould have meant moving that DSH code to another file.tests/fixtures/automatic_prompt_privacy.json, the plugins'prompt-privacy.spec.tstests, and the Kimi Code and ZCodeshared/prompt-privacy.mjs.Plugins
src/secrets.tsis removed. Capture, recall, invoke, and the tests import the rule fromsrc/prompt-privacy.ts.src/secrets.ts, which keeps the explicit-write check and importscontainsSecretfor it fromsrc/prompt-privacy.ts(fix(dsh): apply the shared prompt-privacy rule to explicit writes #2643 made that check use the shared rule); the check itself does not change. Capture, recall, and the prompt-privacy tests import the rule fromsrc/prompt-privacy.ts, as do the DSH pet plugin and the Cindy worker, which build from DSH sources.lib/index.js, the DSH petlib/index.js, the Cindynode/worker.cjs, and the OpenCodelib/index.jsandlib/tui.js. Only the module comments and the OpenCode doc comments and variable name change.Not included
src/secrets.tsto the OpenClaw plugin as another copy of this rule. After fix(openclaw): apply the shared prompt-privacy rule to automatic recall and capture #2636 merges, a follow-up replaces it with a generatedsrc/prompt-privacy.ts. Until then the generator does not check the OpenClaw copy, because its name differs.shared/prompt-privacy.mjscopies stay as they are, still checked against each other bytests/test_integration_shared_files.py. Generating them needs a single-file JavaScript build, which can follow once the TypeScript module is settled.Are there any user-facing changes?
No. The rule, its exports, and every plugin's behavior are unchanged.
How was this change tested?
make js-test: DSH unit and e2e tests, DSH pet adapter tests, and freshness of the DSH and DSH pet bundles.make cindy-test: Cindy hook tests, worker freshness, and packaging.make opencode-test: tests, type check, and bundle freshness.make pi-test: tests and type check.make check, includingscripts/generate_integration_lifecycle.py --check, andgit diff --check.uv run pytest tests/test_integration_lifecycle.py tests/test_integration_shared_files.py tests/test_ci_changes.py tests/test_automatic_prompt_privacy.py tests/test_integration_manifest.py tests/test_dsh*.py.No real host was run; the change does not alter behavior.
Self-review against
REVIEW.md, plus an independent review pass. Neither found anything to change.Confirmed:
src/secrets.tsimporters in DSH use onlyhasSecretContent;prompt-privacy.tsin another plugin;src/prompt-privacy.ts, and in the DSH bundle it comes before the capture and recall code that uses it.Left as notes:
src/secrets.tsbecomes the generatedsrc/prompt-privacy.ts, and its two imports change from./secrets.jsto./prompt-privacy.js..mjscopies are checked against each other and against the shared fixture, not against this source.AI usage statement
Claude Code (Claude Opus 5.5) wrote the change and this description, and ran the checks above.