Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/scripts/check_public_hygiene.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Reject private working documents in the Git index before publication."""
from pathlib import PurePosixPath
import re
import subprocess
import sys

PRIVATE_PREFIXES = (
"docs/internal/", "docs/plans/", "docs/runtime/", "docs/superpowers/",
"research/", "notes/", "botes/", ".agents/", ".claude/", ".codex/",
"proof-artifacts/", "screen-recordings/", "reports/", "ralph_runner/results/",
)
PRIVATE_NAMES = {
"AGENTS.md", "CLAUDE.md", "HANDOFF.md", "PLAN.md", "TODO.md",
"AUDIT_CHECKLIST.md", "INVESTIGATION_LOG.md", "PROMPT.md",
}
DOC_SUFFIXES = {".md", ".rst", ".txt"}


def violations(path: str, content: bytes = b"") -> list[str]:
p = PurePosixPath(path)
reasons = []
if path.startswith(PRIVATE_PREFIXES) or p.name in PRIVATE_NAMES:
reasons.append("private document or evidence path")
if p.suffix.lower() in DOC_SUFFIXES:
text = content.decode("utf-8", errors="replace")
if re.search(r"(?im)^>?.*(?:required sub-skill|for claude:|internal only|do not publish).*$", text):
reasons.append("internal document marker")
if re.search(r"/Users/eric/|/Volumes/Erics|erics-m5-max", text):
reasons.append("maintainer-specific machine path")
return reasons


def main() -> int:
paths = subprocess.check_output(["git", "ls-files", "-z"]).split(b"\0")
failures = []
for raw in filter(None, paths):
path = raw.decode("utf-8")
# Read staged bytes, not a possibly sanitized working copy.
content = b""
if PurePosixPath(path).suffix.lower() in DOC_SUFFIXES:
content = subprocess.check_output(["git", "show", ":" + path])
reasons = violations(path, content)
if reasons:
failures.append((path, reasons))
for path, reasons in failures:
print(path + ": " + "; ".join(reasons), file=sys.stderr)
if failures:
return 1
print("Public document boundary: PASS")
return 0


if __name__ == "__main__":
raise SystemExit(main())
28 changes: 28 additions & 0 deletions .github/tests/test_public_hygiene.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import importlib.util
from pathlib import Path
import unittest

spec = importlib.util.spec_from_file_location("public_hygiene", Path(__file__).parents[1] / "scripts/check_public_hygiene.py")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)


class PublicDocumentBoundary(unittest.TestCase):
def test_rejects_private_paths_even_without_content(self):
for path in ("research/results.json", "docs/internal/notes.md", "docs/plans/work.md", "reports/run.json", "nested/HANDOFF.md"):
with self.subTest(path=path):
self.assertTrue(module.violations(path))

def test_rejects_internal_document_renamed_to_public_path(self):
for body in (b"# INTERNAL ONLY", b"> For Claude: REQUIRED SUB-SKILL", b"Run /Users/eric/model/probe.py"):
with self.subTest(body=body):
self.assertTrue(module.violations("docs/guide.md", body))

def test_accepts_public_usage_and_runtime_internal_modules(self):
for path, body in (("docs/api.md", b"Configure a private key through an environment variable."), ("jang-tools/_internal/jang_v3/encode.py", b""), ("tests/test_session_history.py", b""), ("README.md", b"python -m pip install jang")):
with self.subTest(path=path):
self.assertEqual(module.violations(path, body), [])


if __name__ == "__main__":
unittest.main()
14 changes: 14 additions & 0 deletions .github/workflows/public-hygiene.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Public document boundary
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
public-documents:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- run: python -m unittest discover -s .github/tests -p 'test_public_hygiene.py'
- run: python .github/scripts/check_public_hygiene.py
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,17 @@ verify_quant_*.py

# Internal issue/audit reports
jangtq_*_report.md

# Private working documents and proof receipts
/docs/plans/
/docs/runtime/
/docs/superpowers/
/reports/
**/HANDOFF.md
**/PLAN.md
**/AUDIT_CHECKLIST.md
**/INVESTIGATION_LOG.md
/ralph_runner/PROMPT.md

# Public repository-boundary regression tests
!.github/tests/test_public_hygiene.py
281 changes: 0 additions & 281 deletions docs/plans/2026-03-24-turboquant-integration.md

This file was deleted.

Loading
Loading