dsh-doc-gates
Six deterministic gates for documents that agents edit — each one exists because a real failure got through review. Stdlib-only Python 3.10+, no dependencies, 31 selftest cases.
| Gate | Catches | Failure class it kills |
|---|---|---|
scripts/check_public_clean.py |
internal version stamps (> 🕒 vN · …), local absolute paths (C:\Users\…), .bak residue in a public repo |
private context leaking into public repos |
scripts/check_md_tables.py |
missing trailing |, column-count mismatch, missing alignment row |
a one-character edit silently breaking a whole table |
scripts/check_anchor.py |
missing control value / stale (cross-day) control / missing threshold or MDE | judging an experiment against yesterday's baseline |
scripts/check_doc_size.py |
files over 64 KB, no index beside oversized docs, status files over 120 lines, Deprecated sections left in live docs |
agents re-writing a doc from memory instead of re-reading it |
scripts/check_edit_target.py |
a target string that occurs 0 or >1 times before an edit | old_string matched 6 times / old_string was not found loops |
scripts/next_id.py |
— (allocator) | duplicate or gapped ledger IDs |
Why these exist
An agent editing documentation hits a specific failure class: a table row loses its closing
pipe and falls out of the table; a public repo inherits an internal version stamp and a .bak
backup; a ledger grows to 338 KB and the agent starts paraphrasing it from memory; a verdict is
compared against yesterday's control value and a good configuration is marked as a regression.
Each checker converts one "remember to be careful" rule into a deterministic gate with an
exit code — 0 clean, 1 violation — so the rule survives model changes, long sessions, and
context compaction.
Quick start
python scripts/check_public_clean.py <public-repo-dir> --strict
python scripts/check_md_tables.py <dir-or-file.md>
python scripts/check_doc_size.py <dir> [--max-kb 64] [--max-lines 120]
python scripts/check_anchor.py anchors.json --today 2026-11-27
python scripts/check_edit_target.py <file> "<target string>"
python scripts/next_id.py ledger.md --claim 3
Gate outputs are in Chinese (this project grew in a Chinese-language workflow); exit codes and
rule IDs (P1, T1, D1, …) are language-independent.
Selftests
for t in scripts/*_selftest.py scripts/tools3_selftest.py; do python "$t"; done
Each selftest builds throwaway cases in a temp directory, asserts the expected rule fires, and cleans up. No network, no external packages.
Files
scripts/
check_public_clean.py P1 stamps · P2 local paths · P3 backup residue · P4 internal identity (--strict)
check_md_tables.py T1 trailing pipe · T2 column count · T3 alignment row
check_anchor.py structured verdict anchors: ctrl/threshold/MDE/guards
check_doc_size.py D1 size · D2 missing index · D3 status length · D4 live-doc deprecated
check_edit_target.py pre-edit occurrence count (0 or >1 = unsafe)
next_id.py ledger ID allocator (e.g. C-285 → C-290, --claim N)
*_selftest.py self-verifying cases
SKILL.md skill packaging (frontmatter + usage protocol)
LICENSE MIT
Unofficial community project, not affiliated with DeepSeek.
No comments yet. Be the first to write one.