diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b9310b..a68ad7b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -273,8 +273,8 @@ repos: - id: check-rtk-prefix stages: ['pre-commit'] - name: ADR-0023 rtk prefix on executable git commands - 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 + 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 rtk-bare marker and its reason on the same line entry: scripts/check-rtk-prefix.sh language: script files: '^plugins/[^/]+/\.apm/(skills/.*\.md|agents/.*\.agent\.md)$' diff --git a/docs/adr/0023-rtk-prefix-marks-executable-commands-only.md b/docs/adr/0023-rtk-prefix-marks-executable-commands-only.md index 3fa666f..4754403 100644 --- a/docs/adr/0023-rtk-prefix-marks-executable-commands-only.md +++ b/docs/adr/0023-rtk-prefix-marks-executable-commands-only.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 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. + +## 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. diff --git a/docs/spec/gates.md b/docs/spec/gates.md index c157063..5878053 100644 --- a/docs/spec/gates.md +++ b/docs/spec/gates.md @@ -734,16 +734,18 @@ checking only a leading span flags neither, and still catches the ordinary ### The clause-3 opt-out 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 -line**: in a shell comment for a code line, in the cell text for a table row. +the command is interactive — is exempted by putting the marker `rtk-bare:` and its reason **on the +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 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 -ADR-0023` in the three blocks of `git-log-format.md` where every line is deliberately bare; that +silently disarm every checked line around the marked one. The cost is a repeated `# rtk-bare:` in +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. -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 boundary, and a stricter form would only move the same trust to a different string. diff --git a/scripts/check-rtk-prefix.sh b/scripts/check-rtk-prefix.sh index 7b2ca2c..0b0a830 100755 --- a/scripts/check-rtk-prefix.sh +++ b/scripts/check-rtk-prefix.sh @@ -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`{3,}|~{3,})\s*(?P[^\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 ` (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 `. 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: ` (e.g. `# rtk-bare: the output is parsed`).", file=sys.stderr, ) sys.exit(1) diff --git a/tests/test-check-rtk-prefix.sh b/tests/test-check-rtk-prefix.sh index fa18022..affea28 100644 --- a/tests/test-check-rtk-prefix.sh +++ b/tests/test-check-rtk-prefix.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash 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 # 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 fail "the pre-sweep corpus passed — the gate would not have caught the #113 drift" 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 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 @@ -135,8 +135,12 @@ rtk git push ```' "prefixed commands" 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 -```' "a bare command carrying the ADR-0023 opt-out marker" +```' "the retired ADR-0023 marker no longer exempts a bare command" expect clean '```text git worktree list --porcelain -z @@ -167,7 +171,7 @@ 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" # 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 pass "the ${#LIVE[@]} in-scope corpus files pass" 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" fi