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
@@ -273,8 +273,8 @@ repos:
|
|||||||
|
|
||||||
- id: check-rtk-prefix
|
- id: check-rtk-prefix
|
||||||
stages: ['pre-commit']
|
stages: ['pre-commit']
|
||||||
name: ADR-0023 rtk prefix on executable git commands
|
name: rtk prefix on executable git commands (ADR-0023)
|
||||||
description: Enforce ADR-0023 clause 1 -- an executable, instructed git command in a shell code fence or a dispatch-table Run cell is written `rtk git`. Clauses 2 and 3 are not machine-decidable; a deliberately bare command opts out with the literal string ADR-0023 on its own line
|
description: Enforce ADR-0023 clause 1 -- an executable, instructed git command in a shell code fence or a dispatch-table Run cell is written `rtk git`. Clauses 2 and 3 are not machine-decidable; a deliberately bare command opts out with the rtk-bare marker and its reason on the same line
|
||||||
entry: scripts/check-rtk-prefix.sh
|
entry: scripts/check-rtk-prefix.sh
|
||||||
language: script
|
language: script
|
||||||
files: '^plugins/[^/]+/\.apm/(skills/.*\.md|agents/.*\.agent\.md)$'
|
files: '^plugins/[^/]+/\.apm/(skills/.*\.md|agents/.*\.agent\.md)$'
|
||||||
|
|||||||
@@ -166,3 +166,12 @@ that was false about the `gitea-*` skills and a citation to a file that does not
|
|||||||
A `check-rtk-prefix` pre-commit hook and `tests/test-check-rtk-prefix.sh` land with it; the test runs
|
A `check-rtk-prefix` pre-commit hook and `tests/test-check-rtk-prefix.sh` land with it; the test runs
|
||||||
the gate against the pre-sweep corpus on `main` and asserts it fails there, because a gate that only
|
the gate against the pre-sweep corpus on `main` and asserts it fails there, because a gate that only
|
||||||
passes on the fixed tree proves nothing about the drift it was written for.
|
passes on the fixed tree proves nothing about the drift it was written for.
|
||||||
|
|
||||||
|
## Addendum (2026-12-06): the opt-out marker is `rtk-bare:`
|
||||||
|
|
||||||
|
The clause-3 opt-out marker that `check-rtk-prefix` accepts is now `rtk-bare:`, written on the same
|
||||||
|
line as the bare command and followed by its reason (`# rtk-bare: the output is parsed`). It replaces
|
||||||
|
the literal string `ADR-0023`, which the gate no longer accepts. The cause is issue #177: plugin
|
||||||
|
content is consumed by other repos, and a marker that cites this repo's ADR leaks a reference those
|
||||||
|
consumers cannot follow. The decision itself is unchanged — the three clauses, the per-line scope and
|
||||||
|
the inline-reason requirement all stand; only the marker string moved.
|
||||||
+7
-5
@@ -734,16 +734,18 @@ checking only a leading span flags neither, and still catches the ordinary
|
|||||||
### The clause-3 opt-out
|
### The clause-3 opt-out
|
||||||
|
|
||||||
A command that is deliberately bare — because rtk rewrites the output the skill parses, or because
|
A command 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
|
the command is interactive — is exempted by putting the marker `rtk-bare:` and its reason **on the
|
||||||
line**: in a shell comment for a code line, in the cell text for a table row.
|
same line**: in a shell comment for a code line, in the cell text for a table row. The marker was
|
||||||
|
`ADR-0023` until issue #177; it is neutral because plugin content is consumed by other repos and must
|
||||||
|
not cite this repo's ADRs. The old string no longer exempts a line.
|
||||||
|
|
||||||
Per line, never per block. A fenced procedure routinely mixes `rtk git` steps with one deliberately
|
Per line, never per block. A fenced procedure routinely mixes `rtk git` steps with one deliberately
|
||||||
bare command (`git-remotes/references/push.md` does exactly that), and a block-level marker would
|
bare command (`git-remotes/references/push.md` does exactly that), and a block-level marker would
|
||||||
silently disarm every checked line around the marked one. The cost is a repeated `# bare per
|
silently disarm every checked line around the marked one. The cost is a repeated `# rtk-bare:` in
|
||||||
ADR-0023` in the three blocks of `git-log-format.md` where every line is deliberately bare; that
|
the three blocks of `git-log-format.md` where every line is deliberately bare; that
|
||||||
repetition is the price of the marked line being the only line the marker speaks for.
|
repetition is the price of the marked line being the only line the marker speaks for.
|
||||||
|
|
||||||
The marker is a plain substring match, so a line that mentions `ADR-0023` for an unrelated reason is
|
The marker is a plain substring match, so a line that mentions `rtk-bare:` for an unrelated reason is
|
||||||
also exempt. Accepted deliberately: the marker records an author's opt-out, it is not a security
|
also exempt. Accepted deliberately: the marker records an author's opt-out, it is not a security
|
||||||
boundary, and a stricter form would only move the same trust to a different string.
|
boundary, and a stricter form would only move the same trust to a different string.
|
||||||
|
|
||||||
|
|||||||
+16
-13
@@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# ADR-0023 clause 1, and ONLY clause 1: an executable, instructed local git
|
# Clause 1, and ONLY clause 1, of the rtk-prefix rule: an executable, instructed
|
||||||
# command in plugin skill or agent content is written `rtk git`, never bare
|
# local git command in plugin skill or agent content is written `rtk git`, never
|
||||||
# `git`.
|
# 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:
|
# is machine-decidable:
|
||||||
#
|
#
|
||||||
# 1. executable + instructed -> `rtk git` <- this hook
|
# 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
|
# 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
|
# 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
|
# putting the literal marker `rtk-bare:` on the SAME LINE, followed by the reason
|
||||||
# a code line, in the cell text for a table row. Per-line, never per-block: a
|
# — 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
|
# fenced block routinely mixes `rtk git` steps with one deliberately-bare
|
||||||
# command (references/push.md does exactly that), and a block-level marker would
|
# command (references/push.md does exactly that), and a block-level marker would
|
||||||
# silently disarm the checked lines around the marked one.
|
# silently disarm the checked lines around the marked one.
|
||||||
#
|
#
|
||||||
# The marker is a bare substring match, so a line that merely *mentions*
|
# 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
|
# 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.
|
# form would only move the same trust to a different string.
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ if [[ $# -eq 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v python3 > /dev/null 2>&1; then
|
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
|
echo " Fix: install python3 (pre-commit itself is a Python application, so it is almost certainly already present)." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -66,7 +69,7 @@ exec python3 -u - "$@" <<'PY'
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
MARKER = "ADR-0023"
|
MARKER = "rtk-bare:"
|
||||||
SHELL_INFO = {"bash", "sh", "shell", "zsh", "console", "shell-session"}
|
SHELL_INFO = {"bash", "sh", "shell", "zsh", "console", "shell-session"}
|
||||||
|
|
||||||
FENCE_OPEN = re.compile(r"^\s*(?P<f>`{3,}|~{3,})\s*(?P<info>[^\s`]*)")
|
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):
|
for line_no, text in check(path):
|
||||||
failed = True
|
failed = True
|
||||||
print(
|
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,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
print("", file=sys.stderr)
|
print("", file=sys.stderr)
|
||||||
print(
|
print(
|
||||||
"Fix: write `rtk git <subcommand>` (ADR-0023 clause 1). If this command must stay bare\n"
|
"Fix: write `rtk git <subcommand>`. If this command must stay bare because rtk rewrites\n"
|
||||||
"because rtk rewrites output the skill parses, or because it is interactive (clause 3),\n"
|
"output the skill parses, or because it is interactive, record the opt-out on the same\n"
|
||||||
"say so inline and put the literal string ADR-0023 on the same line to record the opt-out.",
|
"line as `rtk-bare: <reason>` (e.g. `# rtk-bare: the output is parsed`).",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Tests for scripts/check-rtk-prefix.sh — ADR-0023 clause 1.
|
# Tests for scripts/check-rtk-prefix.sh — clause 1 of the rtk-prefix rule (ADR-0023).
|
||||||
#
|
#
|
||||||
# Case 1 is the one that earns the rest: it runs the gate against the corpus as
|
# Case 1 is the one that earns the rest: it runs the gate against the corpus as
|
||||||
# it stood BEFORE the #113 sweep, and asserts it fails there. A gate that only
|
# it stood BEFORE the #113 sweep, and asserts it fails there. A gate that only
|
||||||
@@ -91,7 +91,7 @@ else
|
|||||||
if bash "$SCRIPT" ${PRE_PATHS[@]+"${PRE_PATHS[@]}"} > "$RUN_TMP/pre.out" 2>&1; then
|
if bash "$SCRIPT" ${PRE_PATHS[@]+"${PRE_PATHS[@]}"} > "$RUN_TMP/pre.out" 2>&1; then
|
||||||
fail "the pre-sweep corpus passed — the gate would not have caught the #113 drift"
|
fail "the pre-sweep corpus passed — the gate would not have caught the #113 drift"
|
||||||
else
|
else
|
||||||
hits="$(grep -c '^ADR-0023: ' "$RUN_TMP/pre.out" || true)"
|
hits="$(grep -c '^check-rtk-prefix: ' "$RUN_TMP/pre.out" || true)"
|
||||||
if [[ "$hits" -lt 20 ]]; then
|
if [[ "$hits" -lt 20 ]]; then
|
||||||
fail "the pre-sweep corpus produced only $hits findings — too few to be the known drift"
|
fail "the pre-sweep corpus produced only $hits findings — too few to be the known drift"
|
||||||
elif ! grep -q 'gitea-issues/SKILL.md.*git remote get-url origin' "$RUN_TMP/pre.out"; then
|
elif ! grep -q 'gitea-issues/SKILL.md.*git remote get-url origin' "$RUN_TMP/pre.out"; then
|
||||||
@@ -135,8 +135,12 @@ rtk git push
|
|||||||
```' "prefixed commands"
|
```' "prefixed commands"
|
||||||
|
|
||||||
expect clean '```bash
|
expect clean '```bash
|
||||||
|
git stash list # rtk-bare: rtk prints "No stashes" where git prints nothing
|
||||||
|
```' "a bare command carrying the rtk-bare: opt-out marker"
|
||||||
|
|
||||||
|
expect dirty '```bash
|
||||||
git stash list # bare per ADR-0023: rtk prints "No stashes" where git prints nothing
|
git stash list # bare per ADR-0023: rtk prints "No stashes" where git prints nothing
|
||||||
```' "a bare command carrying the ADR-0023 opt-out marker"
|
```' "the retired ADR-0023 marker no longer exempts a bare command"
|
||||||
|
|
||||||
expect clean '```text
|
expect clean '```text
|
||||||
git worktree list --porcelain -z
|
git worktree list --porcelain -z
|
||||||
@@ -167,7 +171,7 @@ expect clean '| Operation | Run |
|
|||||||
|
|
||||||
expect clean '| Operation | Run |
|
expect clean '| Operation | Run |
|
||||||
|---|---|
|
|---|---|
|
||||||
| List | `git worktree list -v` — bare per ADR-0023 |' \
|
| List | `git worktree list -v` — rtk-bare: the output is parsed |' \
|
||||||
"a bare Run cell carrying the opt-out marker"
|
"a bare Run cell carrying the opt-out marker"
|
||||||
|
|
||||||
# The clause-2 shapes that made an every-span check unusable. Both are real rows
|
# The clause-2 shapes that made an every-span check unusable. Both are real rows
|
||||||
@@ -225,7 +229,7 @@ if [[ ${#LIVE[@]} -eq 0 ]]; then
|
|||||||
elif (cd "$REPO_ROOT" && bash "$SCRIPT" ${LIVE[@]+"${LIVE[@]}"} > "$RUN_TMP/live.out" 2>&1); then
|
elif (cd "$REPO_ROOT" && bash "$SCRIPT" ${LIVE[@]+"${LIVE[@]}"} > "$RUN_TMP/live.out" 2>&1); then
|
||||||
pass "the ${#LIVE[@]} in-scope corpus files pass"
|
pass "the ${#LIVE[@]} in-scope corpus files pass"
|
||||||
else
|
else
|
||||||
fail "the live corpus has ADR-0023 clause-1 violations"
|
fail "the live corpus has clause-1 violations"
|
||||||
sed 's/^/ /' "$RUN_TMP/live.out"
|
sed 's/^/ /' "$RUN_TMP/live.out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user