Files
rustfs/scripts/check_no_planning_docs.sh
T
Zhengchao An f84ba243a1 chore(ci): guard against committed planning docs and remove re-added ones (#4777)
chore(ci): guard against committed planning docs; remove re-added ones

PR #4771 removed the docs/superpowers planning-doc archive and added a rule,
but #4765 force-added two more (git add -f bypasses .gitignore):
docs/superpowers/plans/2026-07-12-observability-single-writer.md and
docs/superpowers/specs/2026-07-12-observability-single-writer-design.md — an
agentic implementation plan and its design spec. Delete both.

Close the enforcement gap so this cannot recur:
- New scripts/check_no_planning_docs.sh fails if anything is tracked under
  docs/superpowers/, regardless of how it was added.
- Wire it into make pre-commit/pre-pr/dev-check.
- Run it in CI: ci.yml for code/mixed PRs, and ci-docs-only.yml (which was a
  green stub) so docs-only PRs can no longer slip a planning doc past the
  required 'Test and Lint' check.
- Document the guard in AGENTS.md and the arch-checks skill.
2026-07-12 20:19:06 +08:00

35 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Guard: planning-type documents must not be committed.
#
# One-shot implementation/optimization plans, migration-progress ledgers,
# design specs, and agent-generated working notes (e.g. anything a
# `superpowers`/scratch workflow produces) belong in the issue tracker or a
# local worktree, never in the repository — see AGENTS.md "Sources of Truth".
#
# .gitignore already keeps everything under docs/ out of the tree except the
# whitelisted durable subtrees (architecture/, operations/, testing/), but
# `git add -f` bypasses .gitignore. This guard closes that hole: any tracked
# file under docs/superpowers/ fails the check regardless of how it got added.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="${CHECK_NO_PLANNING_DOCS_ROOT:-$(cd "${SCRIPT_DIR}/.." && pwd)}"
cd "$ROOT_DIR"
status=0
while IFS= read -r file; do
[[ -z "$file" ]] && continue
printf '%s: planning-type document must not be committed (keep it in the issue tracker or a local worktree)\n' \
"$file" >&2
status=1
done < <(git ls-files 'docs/superpowers/*')
if [[ "$status" -ne 0 ]]; then
printf '\nRemove the file(s) above with `git rm`. See AGENTS.md "Sources of Truth".\n' >&2
fi
exit "$status"