PureYAML/docs/rules-swift/scripts/leak-gate.sh
Mihaela M 5f3892f2c1 chore(rules): vendor the rules-swift canon into docs/rules-swift
Mirror the shared Swift rules canon (rules-swift, commit 4ebb892) into
docs/rules-swift/ as a read-only reference alongside the repo's tailored
docs/rules/. PROVENANCE.md records the source, commit, and what was
included or excluded; the upstream repo's own VCS, CI, and lint tooling
is omitted as machinery rather than rule content.

Exclude the vendored tree from the style gate (scripts/check-style.sh)
and the pre-commit hook: the canon's enforcement docs quote the
forbidden attribution phrases to define them, the same reason the
repo's own enforcement files are already excluded.
2026-06-26 05:36:12 +02:00

29 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# Public-safe leak gate for this repository.
# Runs on every commit (.githooks/pre-commit) and in CI (.github/workflows/leak-gate.yml).
# It enforces only what is safe in a PUBLIC repo: no AI/tool vendor names (outside the
# two attribution rules that discuss them), no machine-absolute paths, no em dashes.
# The private project-name scrub lives in a separate private repository, listing those
# names here would itself be the leak.
set -eu
ROOT=$(cd "$(dirname "$0")/.." && pwd)
fail=0
# AI/tool vendor names are allowed ONLY in the attribution rules that discuss them.
VEND='\bclaude\b|anthropic|\bopenai\b|chatgpt|\bcopilot\b|\bgemini\b|antigravity'
v=$(grep -rniE "$VEND" "$ROOT" --include='*.md' 2>/dev/null | grep -vE '/\.git/' \
| grep -vE '(^|[./])(commits|git-discipline)\.md:' || true)
[ -n "$v" ] && { echo "LEAK GATE FAIL (vendor name outside attribution rules):"; echo "$v" | head; fail=1; }
# Machine-absolute paths leak a local filesystem layout.
p=$(grep -rnE '/Users/|/Volumes/' "$ROOT" --include='*.md' 2>/dev/null | grep -vE '/\.git/' || true)
[ -n "$p" ] && { echo "LEAK GATE FAIL (machine-absolute path):"; echo "$p" | head; fail=1; }
# No em dashes in any tracked markdown.
e=$(grep -rlF "$(printf '\xe2\x80\x94')" "$ROOT" --include='*.md' 2>/dev/null | grep -vE '/\.git/' || true)
[ -n "$e" ] && { echo "LEAK GATE FAIL (em dash):"; echo "$e"; fail=1; }
[ "$fail" = 0 ] || { echo "LEAK GATE FAILED for $ROOT" >&2; exit 1; }
echo "leak gate clean ($(find "$ROOT" -name '*.md' -not -path '*/.git/*' | wc -l | tr -d ' ') md files)"