refactor(gates): rename the rtk-prefix opt-out marker to rtk-bare:
check-rtk-prefix now exempts a deliberately bare git command only when the line carries `rtk-bare: <reason>`. The old literal `ADR-0023` is no longer accepted: plugin content is consumed by other repos and must not cite this repo's ADRs. The test pins the new marker and adds a case showing the old string no longer exempts a line. gates.md and an ADR-0023 addendum record the rename. Refs: #177 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
b5bb0314d1
commit
435ea59e93
5 files changed
+43
-25
No files matched your search
+16
-13
@@ -1,11 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ADR-0023 clause 1, and ONLY clause 1: an executable, instructed local git
|
||||
# command in plugin skill or agent content is written `rtk git`, never bare
|
||||
# `git`.
|
||||
# Clause 1, and ONLY clause 1, of the rtk-prefix rule: an executable, instructed
|
||||
# local git command in plugin skill or agent content is written `rtk git`, never
|
||||
# bare `git`. The rule and its rationale are in
|
||||
# docs/adr/0023-rtk-prefix-marks-executable-commands-only.md.
|
||||
#
|
||||
# WHY THIS IS NARROW ON PURPOSE. ADR-0023 has three clauses, and only the first
|
||||
# WHY THIS IS NARROW ON PURPOSE. The rule has three clauses, and only the first
|
||||
# is machine-decidable:
|
||||
#
|
||||
# 1. executable + instructed -> `rtk git` <- this hook
|
||||
@@ -39,14 +40,16 @@ set -euo pipefail
|
||||
#
|
||||
# CLAUSE-3 OPT-OUT. A site that is deliberately bare because rtk rewrites the
|
||||
# output the skill parses, or because the command is interactive, is exempted by
|
||||
# putting the literal string `ADR-0023` on the SAME LINE — in a shell comment for
|
||||
# a code line, in the cell text for a table row. Per-line, never per-block: a
|
||||
# putting the literal marker `rtk-bare:` on the SAME LINE, followed by the reason
|
||||
# — in a shell comment for a code line, in the cell text for a table row. The
|
||||
# marker is neutral on purpose: plugin content is consumed by other repos, so it
|
||||
# must not cite this repo's ADRs. Per-line, never per-block: a
|
||||
# fenced block routinely mixes `rtk git` steps with one deliberately-bare
|
||||
# command (references/push.md does exactly that), and a block-level marker would
|
||||
# silently disarm the checked lines around the marked one.
|
||||
#
|
||||
# The marker is a bare substring match, so a line that merely *mentions*
|
||||
# ADR-0023 for an unrelated reason is also exempt. That is accepted: the marker
|
||||
# `rtk-bare:` for an unrelated reason is also exempt. That is accepted: the marker
|
||||
# is an author's deliberate opt-out, not a security boundary, and a stricter
|
||||
# form would only move the same trust to a different string.
|
||||
|
||||
@@ -55,7 +58,7 @@ if [[ $# -eq 0 ]]; then
|
||||
fi
|
||||
|
||||
if ! command -v python3 > /dev/null 2>&1; then
|
||||
echo "ERROR: python3 is required for the ADR-0023 rtk-prefix gate but was not found on PATH." >&2
|
||||
echo "ERROR: python3 is required for the rtk-prefix gate but was not found on PATH." >&2
|
||||
echo " Fix: install python3 (pre-commit itself is a Python application, so it is almost certainly already present)." >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -66,7 +69,7 @@ exec python3 -u - "$@" <<'PY'
|
||||
import re
|
||||
import sys
|
||||
|
||||
MARKER = "ADR-0023"
|
||||
MARKER = "rtk-bare:"
|
||||
SHELL_INFO = {"bash", "sh", "shell", "zsh", "console", "shell-session"}
|
||||
|
||||
FENCE_OPEN = re.compile(r"^\s*(?P<f>`{3,}|~{3,})\s*(?P<info>[^\s`]*)")
|
||||
@@ -182,16 +185,16 @@ for path in sys.argv[1:]:
|
||||
for line_no, text in check(path):
|
||||
failed = True
|
||||
print(
|
||||
f"ADR-0023: {path}:{line_no}: executable git command is not prefixed with `rtk`: {text}",
|
||||
f"check-rtk-prefix: {path}:{line_no}: executable git command is not prefixed with `rtk`: {text}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
if failed:
|
||||
print("", file=sys.stderr)
|
||||
print(
|
||||
"Fix: write `rtk git <subcommand>` (ADR-0023 clause 1). If this command must stay bare\n"
|
||||
"because rtk rewrites output the skill parses, or because it is interactive (clause 3),\n"
|
||||
"say so inline and put the literal string ADR-0023 on the same line to record the opt-out.",
|
||||
"Fix: write `rtk git <subcommand>`. If this command must stay bare because rtk rewrites\n"
|
||||
"output the skill parses, or because it is interactive, record the opt-out on the same\n"
|
||||
"line as `rtk-bare: <reason>` (e.g. `# rtk-bare: the output is parsed`).",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
Reference in new issue
Block a user