Compaction integrity: directive lines (never/must/必须 style markers) extracted from the compacted range are verified against the summary — verbatim or by content-word coverage — and every constraint the session silently forgot is reported and written to a JSONL ledger; pinned constraints from config are checked on every compaction.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-compaction-guard
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:zhengqiuyang/dsh-compaction-guard
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
dsh-compaction-guard
Compaction integrity — what the agent was told to remember and silently forgot is reported loudly
dsh plugin --profile default add github:zhengqiuyang/dsh-compaction-guard
If this helps you, please give it a star — it helps others find it.
Part of the DSH trust layer — ten deterministic checks, no LLM in the trust path.
Compaction integrity for DeepSeek Harness (dsh).
Long sessions compact; the compacted range takes constraints with it — "never
commit to main", "必须先跑测试" — and the agent silently forgets rules it was
told to keep. This plugin watches compaction/summary session events: it
extracts directive lines from the user-authored events being shadowed,
verifies each against the summary (verbatim, whitespace-normalized, or
in substance — a coverage threshold on content words), and reports every
constraint the agent just forgot — console plus a durable JSONL ledger.
Pinned constraints from config are verified on every compaction. Zero LLM
calls in the trust path.
Family channel #9: read / write / do / call / leave-behind / egress / told / running / remembered — what the agent forgets.
Why now (checked 2026-10-17)
The awesome list has 209 memory plugins and an entire compaction package
family in dsh itself — and not one verifies that constraints survive
compaction. Memory plugins add recall; this audits loss. The
compaction/summary event even ships shadowedSeqs (exactly what was
compact away) — the integrity check is deterministic by construction.
How it works
compaction/summary event
├── shadowedSeqs → session.eventAt(seq) → user/message directive lines
├── pinned constraints from config (always verified)
├── verify against the summary text:
│ verbatim (whitespace-normalized substring) → kept
│ best-matching summary sentence:
│ content-word coverage ≥ 0.6 AND same polarity → kept
│ polarity flip (negation dropped/added) → LOST-polarity
│ otherwise → LOST (reported + ledgered)
└── ledger: .dsh-compaction-guard/ledger.jsonl (CI-consumable)
Honest limitations, on purpose:
- Word coverage tracks words, not meaning — a paraphrase with no shared vocabulary counts as lost (conservative direction: false alarm, not silent loss). Synonym-aware matching would need embeddings or an LLM, which this family refuses to put in the trust path.
- Coverage is judged against the single best-matching summary sentence, never pooled across the whole summary — an unrelated sentence's 'never' cannot vouch for a directive it never carried (external review C03).
- Polarity is bound per candidate: a negative directive whose best sentence dropped the negation — or a positive directive flipped negative — is judged lost-polarity, not kept.
- This guard reports and ledgers; it does not re-inject lost constraints or block compaction.
Install
dsh plugin --profile default add github:zhengqiuyang/dsh-compaction-guard
Prebuilt lib/ ships in the repo — no build step, no allowBuilds.
Configure
- id: dsh-compaction-guard
name: dsh-compaction-guard
config:
pinned: ["Never force-push to main"] # always verified, verbatim
coverage: 0.6
ledgerPath: .dsh-compaction-guard/ledger.jsonl
Compatibility
- DSH: verified against the 0.2.x line (source snapshot 0.2.1-alpha.2); installs on any profile via
dsh plugin add(prebuiltlib/, no build approval). - Node: >= 20 (CI matrix: Node 20/22/24 on Ubuntu and Windows).
- Disposable-profile evidence (2026-10-19):
dsh plugin --profile <fresh> add github:zhengqiuyang/dsh-compaction-guard→ installed in 30s; boot shows[dsh-compaction-guard] active: …;dsh plugin --profile <fresh> remove dsh-compaction-guard→ dependencies cleared, bundles restored.
Develop
npm install && npm test
Roadmap
reinjectmode: steer the lost constraints back into the session after compaction (default stays observe — auto-injection deserves live testing first)- Post-compaction reassertion listener (a constraint restated after the summary also counts as survived)
- Turn-boundary constraints (task briefs in the first turn pinned per-turn)
Kill criteria
If dsh ships first-party compaction-integrity verification, this freezes at its last working version with a postmortem here.
Known limitations
- Word coverage tracks words, not meaning. A paraphrase with no shared vocabulary counts as lost (conservative: false alarm, not silent loss). As of this release, a negative directive ("never…") whose summary drops the negation is explicitly judged
lost-negationinstead of silently surviving coverage. - This guard reports and ledgers — it does not re-inject lost constraints or block compaction. Restating the rule to the agent is your call; the report exists so you know you should.
- Directive extraction is marker-based (must/never/必须/…). Directives phrased without any marker are not collected.
Links
More in this category
kenryu42/cc-safety-net★ 2161
Pre-execution guard that blocks destructive Git and filesystem commands and access to secrets such as SSH keys and .env files before a tool call runs.
ADWMC/helm-d#helmd★ 1654
Security-analysis plugin for DeepSeek Harness: 33 tools spanning six security domains, evidence/reporting and toolbox, plus the case lifecycle, routing and tool ledger; a session-bound case workflow with an evidence chain, E-id validation and reproducible findings; 362 on-demand references; three hot-swappable persona profiles; and a four-tab workbench (armor / case / intercept / about) with case-state recovery after context compaction.
SeaOf0/dsh-redteam-model★ 945
Authorized-security DSH collection: nine work modes (redteam coordinator, pentest, code audit, binary analysis, attack-defense, AV evasion, incident response, cloud security, CTF solving) and fifteen runtime plugins, managed from a settings page with one-click deploy, install, update and uninstall.
toby-bridges/api-relay-audit★ 939
Runs local security audits of AI API relays and LLM proxies from DeepSeek Harness, producing Markdown reports for prompt injection, model substitution signals, tool-call rewriting, error leakage, stream integrity, and profile-gated Web3 risks.
howmp/dsh-pentest★ 625
Authorized pentest mode for DeepSeek Harness — exploration chain, assets and findings with a Web view.
Jueze-2019/dsh-redteam-mode#packages/redteam-bundle★ 320
Red-team engagement mode: send one target organization name; a planner session runs five execution roles (recon, asset triage, vulnerability discovery, exploitation, internal pivot) with configurable concurrency; preflight checks skills/resources; scoring uses four stages (recon, internet, boundary, internal) with server-side caps and privilege-wins dedup; findings stay in a local SQLite fact base. The persistent right-side console has nine pages and includes asset mapping, agents, sessions/tunnels, findings, score targets, reports, POC knowledge base and skill library. v0.15.2 adds automatic HTTP evidence/action records, batch ingest, scope check, tunnel pivot probe, data proof, cleanup ledger and T0-T3 asset admission to prevent scope drift. 59 redteam_* tools; 38 bundled skills.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.