@bbcsoftwarefactory/skills 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.json +42 -0
- package/dist/skills/code-quality-gate/SKILL.md +59 -0
- package/dist/skills/code-quality-gate/references/gate-bigo.md +31 -0
- package/dist/skills/code-quality-gate/references/gate-earlyreturn.md +73 -0
- package/dist/skills/code-quality-gate/references/gate-typesafe.md +32 -0
- package/dist/skills/code-quality-gate/references/output-schema.yml +40 -0
- package/dist/skills/code-quality-gate/scripts/extract-diff-scope.py +225 -0
- package/dist/skills/code-quality-gate/tests/extract-diff-scope.test.sh +200 -0
- package/dist/skills/delivery-coordinator/SKILL.md +81 -0
- package/dist/skills/delivery-coordinator/references/hud-output.md +55 -0
- package/dist/skills/delivery-coordinator/references/intake.md +86 -0
- package/dist/skills/delivery-coordinator/references/issue-claim.md +143 -0
- package/dist/skills/delivery-coordinator/references/issue-dedup.md +38 -0
- package/dist/skills/delivery-coordinator/references/sleuth-regression-exercise.md +60 -0
- package/dist/skills/delivery-coordinator/references/visual-reference.md +45 -0
- package/dist/skills/delivery-coordinator/references/worktree-isolation.md +19 -0
- package/dist/skills/delivery-coordinator/scripts/check-issue-claim.py +363 -0
- package/dist/skills/delivery-coordinator/scripts/check-worktree-guard.py +220 -0
- package/dist/skills/delivery-coordinator/scripts/classify-change-lane.py +263 -0
- package/dist/skills/delivery-coordinator/tests/check-issue-claim.test.sh +221 -0
- package/dist/skills/delivery-coordinator/tests/check-worktree-guard.test.sh +123 -0
- package/dist/skills/delivery-coordinator/tests/classify-change-lane.test.sh +124 -0
- package/dist/skills/documentation-steward/SKILL.md +43 -0
- package/dist/skills/documentation-steward/references/discovery.md +17 -0
- package/dist/skills/documentation-steward/references/handoff.md +15 -0
- package/dist/skills/greptile-review-loop/SKILL.md +57 -0
- package/dist/skills/greptile-review-loop/references/review-protocol.md +37 -0
- package/dist/skills/greptile-review-loop/scripts/review-loop.py +435 -0
- package/dist/skills/greptile-review-loop/tests/review-loop.test.sh +331 -0
- package/dist/skills/issue-reviewer/SKILL.md +87 -0
- package/dist/skills/issue-reviewer/references/review-format.md +100 -0
- package/dist/skills/issue-reviewer/references/triage.md +105 -0
- package/dist/skills/issue-reviewer/scripts/fetch-issue-attachments.py +239 -0
- package/dist/skills/issue-reviewer/scripts/plan-issue-triage.py +311 -0
- package/dist/skills/issue-reviewer/tests/fetch-issue-attachments.test.sh +90 -0
- package/dist/skills/issue-reviewer/tests/plan-issue-triage.test.sh +168 -0
- package/dist/skills/question-gate/SKILL.md +66 -0
- package/dist/skills/question-gate/references/client-hooks.md +111 -0
- package/dist/skills/question-gate/references/diagram-routing.md +58 -0
- package/dist/skills/question-gate/scripts/triage-question.py +713 -0
- package/dist/skills/question-gate/tests/fixtures/question-corpus.json +481 -0
- package/dist/skills/question-gate/tests/question-corpus.test.sh +32 -0
- package/dist/skills/question-gate/tests/triage-question.test.sh +441 -0
- package/dist/skills/regression-testing/SKILL.md +49 -0
- package/dist/skills/regression-testing/references/evidence-record.md +35 -0
- package/dist/skills/requirements-spec/SKILL.md +59 -0
- package/dist/skills/risk-scout/SKILL.md +53 -0
- package/dist/skills/risk-scout/references/risk-matrix.md +49 -0
- package/dist/skills/skill-clean-architecture/SKILL.md +54 -0
- package/dist/skills/skill-clean-architecture/references/layer-rules.md +22 -0
- package/dist/skills/skill-clean-architecture/references/source-headers.md +31 -0
- package/dist/skills/skill-clean-architecture/scripts/measure-bigo.py +427 -0
- package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/bad-utf8.js +1 -0
- package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/edge-crlf.ts +6 -0
- package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/edge-mixed.ts +15 -0
- package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/empty.js +0 -0
- package/dist/skills/skill-clean-architecture/tests/fixtures/bigo/no-newline.js +1 -0
- package/dist/skills/skill-clean-architecture/tests/fixtures/bigo.expected.yml +95 -0
- package/dist/skills/skill-clean-architecture/tests/measure-bigo.test.sh +222 -0
- package/dist/skills/tool-depot/SKILL.md +47 -0
- package/dist/skills/tool-depot/references/checkout.md +29 -0
- package/dist/skills/tool-depot/references/loki-read.md +41 -0
- package/dist/skills/tool-depot/references/readonly-access.md +84 -0
- package/dist/skills/tool-depot/references/tool-catalog.json +47 -0
- package/dist/skills/tool-depot/scripts/loki-runtime-logs.py +305 -0
- package/dist/skills/tool-depot/tests/loki-runtime-logs.test.sh +101 -0
- package/dist/skills/watcher-observability/SKILL.md +73 -0
- package/dist/skills/watcher-observability/references/batch-protocol.md +44 -0
- package/dist/skills/watcher-observability/references/configuration.md +31 -0
- package/dist/skills/watcher-observability/references/error-scan.md +102 -0
- package/dist/skills/watcher-observability/references/live-protocol.md +49 -0
- package/dist/skills/watcher-observability/references/server-account.md +72 -0
- package/dist/skills/watcher-observability/scripts/error-scan.py +318 -0
- package/dist/skills/watcher-observability/scripts/resolve-containers.py +155 -0
- package/dist/skills/watcher-observability/scripts/save-counts.py +381 -0
- package/dist/skills/watcher-observability/scripts/summarize-logs.py +113 -0
- package/dist/skills/watcher-observability/scripts/watch-live.py +606 -0
- package/dist/skills/watcher-observability/server/watcher-gate.sh +51 -0
- package/dist/skills/watcher-observability/tests/error-scan.test.sh +257 -0
- package/dist/skills/watcher-observability/tests/live-windows.test.sh +177 -0
- package/dist/skills/watcher-observability/tests/resolve-containers.test.sh +87 -0
- package/dist/skills/watcher-observability/tests/save-counts.test.sh +338 -0
- package/dist/skills/watcher-observability/tests/sleuth.test.sh +176 -0
- package/dist/skills/watcher-observability/tests/summarize-logs.test.sh +105 -0
- package/dist/skills/watcher-observability/tests/watcher-config.test.sh +70 -0
- package/dist/skills/watcher-observability/tests/watcher-gate.test.sh +110 -0
- package/dist/skills/watcher-observability/watcher.json +1 -0
- package/dist/skills/workflow-auditor/SKILL.md +55 -0
- package/dist/skills/workflow-auditor/references/audit-protocol.md +49 -0
- package/dist/skills/workflow-auditor/references/ledger.md +122 -0
- package/dist/skills/workflow-auditor/scripts/audit-ledger.py +624 -0
- package/dist/skills/workflow-auditor/scripts/list-zed-commands.py +183 -0
- package/dist/skills/workflow-auditor/scripts/render-workflow.py +201 -0
- package/dist/skills/workflow-auditor/scripts/validate-skills.py +444 -0
- package/dist/skills/workflow-auditor/tests/audit-ledger.test.sh +660 -0
- package/dist/skills/workflow-auditor/tests/list-zed-commands.test.sh +93 -0
- package/dist/skills/workflow-auditor/tests/render-workflow.test.sh +135 -0
- package/dist/skills/workflow-auditor/tests/validate-skills.test.sh +190 -0
- package/package.json +27 -6
- package/README.md +0 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Suite for the Watcher's alias-prefix configuration (#60). The real scripts run
|
|
3
|
+
# against a fake ssh that records whether it was called.
|
|
4
|
+
set -u
|
|
5
|
+
cd -- "${BASH_SOURCE[0]%/*}/.."
|
|
6
|
+
SCRIPTS="$PWD/scripts"
|
|
7
|
+
PYTHON_BIN=$(command -v python3 || command -v python)
|
|
8
|
+
PYTHON_BIN=$("$PYTHON_BIN" -c 'import sys; print(sys.executable)')
|
|
9
|
+
scratch=$(mktemp -d)
|
|
10
|
+
trap 'rm -rf -- "$scratch"' EXIT
|
|
11
|
+
checks=0
|
|
12
|
+
failures=0
|
|
13
|
+
fail() { printf 'FAIL [%s]: %s\n' "$1" "$2" >&2; failures=$((failures + 1)); }
|
|
14
|
+
|
|
15
|
+
mkdir -p "$scratch/bin" "$scratch/repo/sub"
|
|
16
|
+
printf '#!/usr/bin/env bash\nprintf "called\\n" >>"%s/ssh-calls"\nprintf "2026-01-01T00:00:00Z ERROR boom\\n"\n' "$scratch" >"$scratch/bin/ssh"
|
|
17
|
+
chmod +x "$scratch/bin/ssh"
|
|
18
|
+
git -C "$scratch/repo" init -q
|
|
19
|
+
printf '/tmp_logs/\n' >"$scratch/repo/.gitignore"
|
|
20
|
+
export PATH="$scratch/bin:$PATH"
|
|
21
|
+
|
|
22
|
+
run() { # label, cwd, want rc ("0" or "fail"), want ssh called (yes/no), script args...
|
|
23
|
+
local label=$1 dir=$2 want=$3 called=$4 rc=0 out
|
|
24
|
+
shift 4
|
|
25
|
+
rm -f "$scratch/ssh-calls"
|
|
26
|
+
out=$(cd "$dir" && "$PYTHON_BIN" -I -B "$@" 2>&1) || rc=$?
|
|
27
|
+
checks=$((checks + 1))
|
|
28
|
+
if [[ $want == 0 && $rc != 0 ]] || [[ $want == fail && $rc == 0 ]]; then
|
|
29
|
+
fail "$label" "rc=$rc want=$want: $out"; return
|
|
30
|
+
fi
|
|
31
|
+
if [[ $called == no && -e $scratch/ssh-calls ]]; then fail "$label" "ssh was called: $out"; fi
|
|
32
|
+
if [[ $called == yes && ! -e $scratch/ssh-calls ]]; then fail "$label" "ssh was not called: $out"; fi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# 1. Default configuration (watcher.json in the skill): bb-/bbc- as before.
|
|
36
|
+
run 'default accepts bb-' "$scratch/repo" 0 yes "$SCRIPTS/error-scan.py" bb-prod app-1 5
|
|
37
|
+
run 'default rejects acme-' "$scratch/repo" fail no "$SCRIPTS/error-scan.py" acme-prod app-1 5
|
|
38
|
+
run 'resolver default bbc-' "$scratch/repo" 0 no "$SCRIPTS/resolve-containers.py" bbc-prod app-1
|
|
39
|
+
|
|
40
|
+
# 2. A project override in the Git root, found from a subdirectory too.
|
|
41
|
+
printf '{"alias_prefixes": ["acme", "acme2"]}\n' >"$scratch/repo/.watcher.json"
|
|
42
|
+
run 'override accepts acme-' "$scratch/repo/sub" 0 yes "$SCRIPTS/error-scan.py" acme-prod app-1 5
|
|
43
|
+
run 'override rejects bb-' "$scratch/repo/sub" fail no "$SCRIPTS/error-scan.py" bb-prod app-1 5
|
|
44
|
+
run 'resolver override acme2-' "$scratch/repo" 0 no "$SCRIPTS/resolve-containers.py" acme2-eu app-1
|
|
45
|
+
run 'resolver override rejects bbc-' "$scratch/repo" fail no "$SCRIPTS/resolve-containers.py" bbc-prod app-1
|
|
46
|
+
run 'save-counts override rejects bb-' "$scratch/repo" fail no "$SCRIPTS/save-counts.py" --no-save historical bb-prod app-1
|
|
47
|
+
run 'live override rejects bb-' "$scratch/repo" fail no "$SCRIPTS/watch-live.py" bb-prod app-1
|
|
48
|
+
# A prefix must not match a longer alias by accident: "acme" is not "acmex".
|
|
49
|
+
run 'no partial prefix match' "$scratch/repo" fail no "$SCRIPTS/error-scan.py" acmex-prod app-1 5
|
|
50
|
+
|
|
51
|
+
# 3. Invalid configuration: refuse before any connection, with a clear message.
|
|
52
|
+
for bad in '{"alias_prefixes": []}' '{"alias_prefixes": ["*"]}' '{"alias_prefixes": ["ACME"]}' \
|
|
53
|
+
'{"alias_prefixes": ["a.b"]}' '{"alias_prefixes": ["acme"], "extra": 1}' '{"alias_prefixes": "acme"}' \
|
|
54
|
+
'{"alias_prefixes": ["a","b","c","d","e","f","g","h","i"]}' '{"alias_prefixes": ["toolongprefix-abcdefgh"]}' \
|
|
55
|
+
'not json'; do
|
|
56
|
+
printf '%s\n' "$bad" >"$scratch/repo/.watcher.json"
|
|
57
|
+
rm -f "$scratch/ssh-calls"
|
|
58
|
+
out=$(cd "$scratch/repo" && "$PYTHON_BIN" -I -B "$SCRIPTS/error-scan.py" acme-prod app-1 5 2>&1); rc=$?
|
|
59
|
+
checks=$((checks + 1))
|
|
60
|
+
[[ $rc != 0 && $out == *'configuration'* && ! -e $scratch/ssh-calls ]] || fail "invalid config: $bad" "rc=$rc out=$out"
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
# 4. Outside a Git repository there is no override: the skill default applies.
|
|
64
|
+
rm -f "$scratch/repo/.watcher.json"
|
|
65
|
+
mkdir -p "$scratch/nogit"
|
|
66
|
+
printf '{"alias_prefixes": ["acme"]}\n' >"$scratch/nogit/.watcher.json"
|
|
67
|
+
run 'no git: default applies' "$scratch/nogit" 0 yes "$SCRIPTS/error-scan.py" bb-prod app-1 5
|
|
68
|
+
|
|
69
|
+
printf 'watcher-config.test.sh: %d checks, %d failed\n' "$checks" "$failures"
|
|
70
|
+
[[ $failures == 0 ]]
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Suite for server/watcher-gate.sh (#40): the SSH forced command must allow exactly
|
|
3
|
+
# the remote commands the Watcher scripts send, and refuse everything else without
|
|
4
|
+
# invoking docker.
|
|
5
|
+
set -u
|
|
6
|
+
cd -- "${BASH_SOURCE[0]%/*}/.."
|
|
7
|
+
GATE="$PWD/server/watcher-gate.sh"
|
|
8
|
+
SCRIPTS="$PWD/scripts"
|
|
9
|
+
scratch=$(mktemp -d)
|
|
10
|
+
trap 'rm -rf -- "$scratch"' EXIT
|
|
11
|
+
mkdir -p "$scratch/bin"
|
|
12
|
+
|
|
13
|
+
# Fake docker: records its argv (one per line) and emits minimal output.
|
|
14
|
+
cat >"$scratch/bin/docker" <<'EOF'
|
|
15
|
+
#!/usr/bin/env bash
|
|
16
|
+
printf '%s\n' "$@" >"$WATCHER_GATE_TEST_ARGV"
|
|
17
|
+
if [[ $1 == ps ]]; then printf 'app-1\napp-2\n'; else printf '2026-01-01T00:00:00Z ERROR connection refused\n'; fi
|
|
18
|
+
EOF
|
|
19
|
+
chmod +x "$scratch/bin/docker"
|
|
20
|
+
export WATCHER_GATE_TEST_ARGV="$scratch/argv"
|
|
21
|
+
export PATH="$scratch/bin:$PATH"
|
|
22
|
+
|
|
23
|
+
checks=0
|
|
24
|
+
failures=0
|
|
25
|
+
fail() { printf 'FAIL [%s]: %s\n' "$1" "$2" >&2; failures=$((failures + 1)); }
|
|
26
|
+
|
|
27
|
+
run_gate() {
|
|
28
|
+
rm -f "$WATCHER_GATE_TEST_ARGV"
|
|
29
|
+
SSH_ORIGINAL_COMMAND=$1 bash "$GATE" >/dev/null 2>&1
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
expect_allowed() { # label, command, expected argv joined by |
|
|
33
|
+
checks=$((checks + 1))
|
|
34
|
+
if ! run_gate "$2"; then fail "$1" "refused: $2"; return; fi
|
|
35
|
+
local got
|
|
36
|
+
got=$(paste -sd'|' "$WATCHER_GATE_TEST_ARGV" 2>/dev/null)
|
|
37
|
+
[[ $got == "$3" ]] || fail "$1" "argv '$got' != '$3'"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
expect_denied() { # label, command
|
|
41
|
+
checks=$((checks + 1))
|
|
42
|
+
run_gate "$2"
|
|
43
|
+
local code=$?
|
|
44
|
+
[[ $code == 126 ]] || fail "$1" "exit $code (want 126) for: $2"
|
|
45
|
+
[[ ! -e $WATCHER_GATE_TEST_ARGV ]] || fail "$1" "docker was invoked for: $2"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# 1. The five shapes the Watcher sends are allowed, with an exact argv.
|
|
49
|
+
expect_allowed 'live follow' 'docker logs -f --tail=0 -- app-1' 'logs|-f|--tail=0|--|app-1'
|
|
50
|
+
expect_allowed 'historical batch' 'docker logs -f --tail=1000 -- app.v2_1' 'logs|-f|--tail=1000|--|app.v2_1'
|
|
51
|
+
expect_allowed 'scan since' 'docker logs --since=120m --timestamps -- app-1' 'logs|--since=120m|--timestamps|--|app-1'
|
|
52
|
+
expect_allowed 'scan tail' 'docker logs --tail=50000 --timestamps -- app-1' 'logs|--tail=50000|--timestamps|--|app-1'
|
|
53
|
+
expect_allowed 'discovery' "docker ps --filter 'name=^/?saas-app\\.v2-.*\$' --format '{{.Names}}'" \
|
|
54
|
+
'ps|--filter|name=^/?saas-app\.v2-.*$|--format|{{.Names}}'
|
|
55
|
+
|
|
56
|
+
# 2. Everything else is refused before docker runs.
|
|
57
|
+
expect_denied 'empty (interactive login)' ''
|
|
58
|
+
expect_denied 'shell' 'bash'
|
|
59
|
+
expect_denied 'mutation' 'docker rm -f app-1'
|
|
60
|
+
expect_denied 'exec' 'docker exec app-1 sh'
|
|
61
|
+
expect_denied 'chained command' 'docker logs -f --tail=0 -- app-1; id'
|
|
62
|
+
expect_denied 'substitution' 'docker logs -f --tail=0 -- $(id)'
|
|
63
|
+
expect_denied 'newline injection' $'docker logs -f --tail=0 -- app-1\nid'
|
|
64
|
+
expect_denied 'follow with other tail' 'docker logs -f --tail=5 -- app-1'
|
|
65
|
+
expect_denied 'since above 120' 'docker logs --since=121m --timestamps -- app-1'
|
|
66
|
+
expect_denied 'since zero' 'docker logs --since=0m --timestamps -- app-1'
|
|
67
|
+
expect_denied 'since leading zero' 'docker logs --since=07m --timestamps -- app-1'
|
|
68
|
+
expect_denied 'tail above 50000' 'docker logs --tail=50001 --timestamps -- app-1'
|
|
69
|
+
expect_denied 'option as name' 'docker logs -f --tail=0 -- -app'
|
|
70
|
+
expect_denied 'missing --' 'docker logs -f --tail=0 app-1'
|
|
71
|
+
expect_denied 'bare ps' 'docker ps'
|
|
72
|
+
expect_denied 'ps empty prefix' "docker ps --filter 'name=^/?.*\$' --format '{{.Names}}'"
|
|
73
|
+
expect_denied 'ps regex in prefix' "docker ps --filter 'name=^/?a.*b.*\$' --format '{{.Names}}'"
|
|
74
|
+
expect_denied 'ps other format' "docker ps --filter 'name=^/?app-.*\$' --format '{{json .}}'"
|
|
75
|
+
|
|
76
|
+
# 3. End to end: the real scripts, through a fake ssh that forwards the remote
|
|
77
|
+
# command to the gate the way sshd does (arguments joined by single spaces).
|
|
78
|
+
cat >"$scratch/bin/ssh" <<EOF
|
|
79
|
+
#!/usr/bin/env bash
|
|
80
|
+
while [[ \$# -gt 0 ]]; do
|
|
81
|
+
case \$1 in
|
|
82
|
+
-o) shift 2 ;;
|
|
83
|
+
-*) shift ;;
|
|
84
|
+
*) shift; break ;; # host alias
|
|
85
|
+
esac
|
|
86
|
+
done
|
|
87
|
+
SSH_ORIGINAL_COMMAND="\$*" exec bash "$GATE"
|
|
88
|
+
EOF
|
|
89
|
+
chmod +x "$scratch/bin/ssh"
|
|
90
|
+
|
|
91
|
+
checks=$((checks + 1))
|
|
92
|
+
out=$(python3 -I -B "$SCRIPTS/resolve-containers.py" bb-test 'app-*' 2>&1)
|
|
93
|
+
[[ $out == $'app-1\napp-2' ]] || fail 'e2e resolve-containers' "$out"
|
|
94
|
+
|
|
95
|
+
checks=$((checks + 1))
|
|
96
|
+
out=$(cd "$scratch" && python3 -I -B "$SCRIPTS/error-scan.py" bb-test app-1 15 2>&1)
|
|
97
|
+
[[ $out == *'severity error=1'* ]] || fail 'e2e error-scan since' "$out"
|
|
98
|
+
|
|
99
|
+
checks=$((checks + 1))
|
|
100
|
+
out=$(cd "$scratch" && python3 -I -B "$SCRIPTS/error-scan.py" bb-test app-1 --tail 200 2>&1)
|
|
101
|
+
[[ $out == *'severity error=1'* ]] || fail 'e2e error-scan tail' "$out"
|
|
102
|
+
|
|
103
|
+
checks=$((checks + 1))
|
|
104
|
+
repo="$scratch/repo"
|
|
105
|
+
mkdir -p "$repo" && git -C "$repo" init -q && printf '/tmp_logs/\n' >"$repo/.gitignore"
|
|
106
|
+
out=$(cd "$repo" && python3 -I -B "$SCRIPTS/save-counts.py" historical bb-test app-1 2>&1)
|
|
107
|
+
[[ $out == *'historical status=finished'* ]] || fail 'e2e save-counts historical' "$out"
|
|
108
|
+
|
|
109
|
+
printf 'watcher-gate.test.sh: %d checks, %d failed\n' "$checks" "$failures"
|
|
110
|
+
[[ $failures == 0 ]]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"alias_prefixes": ["bb", "bbc"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workflow-auditor
|
|
3
|
+
description: "Trigger: workflow audit, process audit, diagram compliance, Tool Depot usage check, before Code Owner handoff. Run on every PR: check the delivery ledger against the skill workflow and the Tool Depot catalog, and send violations back to the stage that owns them."
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
compatibility: Requires Python 3.8+ for the bundled checker and the tool-depot catalog (installed alongside, or passed with --catalog).
|
|
6
|
+
metadata:
|
|
7
|
+
author: bbc-skill-internals
|
|
8
|
+
version: "1.4"
|
|
9
|
+
pre_hook: "python3 -I -B scripts/audit-ledger.py && python3 -I -B scripts/validate-skills.py"
|
|
10
|
+
scripts: "scripts/audit-ledger.py, scripts/validate-skills.py, scripts/list-zed-commands.py, scripts/render-workflow.py"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Activation Contract
|
|
14
|
+
|
|
15
|
+
Run on every PR the workflow opens or updates, after `greptile-review-loop` and before the human Code Owner review. Also use it when asked whether a delivery followed the workflow diagram or used Tool Depot correctly. Work independently or accept a handoff from `delivery-coordinator`.
|
|
16
|
+
|
|
17
|
+
**Company role:** Process Auditor. It checks that the workflow was followed; it does not review code, approve, merge, or deploy.
|
|
18
|
+
|
|
19
|
+
## Hard Rules
|
|
20
|
+
|
|
21
|
+
- Read-only. Never edit code, the ledger, the PR, issues, or review threads. Do not run tests or tools on the delivery's behalf; audit the evidence that exists.
|
|
22
|
+
- Route GitHub reads through `tool-depot` (`github-read`). If it is unavailable or the request is not eligible, report the affected check as unverified; do not use another channel.
|
|
23
|
+
- Never invent evidence, authorizations, or Tool Depot decisions. Missing evidence is a gap or a violation, never a pass. A `conforms` verdict grants no permission and is not an approval.
|
|
24
|
+
- Report rule IDs, stages, and record IDs. Do not copy secrets, tokens, customer data, raw logs, or full reports into findings.
|
|
25
|
+
|
|
26
|
+
## Decision Gates
|
|
27
|
+
|
|
28
|
+
| Condition | Action |
|
|
29
|
+
|---|---|
|
|
30
|
+
| Ledger or Tool Depot catalog missing or invalid | Verdict `unusable`. Reconstruct a ledger only from supplied evidence, outside the repository, and mark it `reconstructed`. |
|
|
31
|
+
| Structural or semantic violation | Verdict `violations`. Return each finding to the stage that owns it; the PR does not go to the Code Owner until the audit is rerun. |
|
|
32
|
+
| Only gaps (for example, Greptile unavailable) | Verdict `gaps`. Hand off with the gaps stated for the Code Owner. |
|
|
33
|
+
| No findings | Verdict `conforms`. Hand off. |
|
|
34
|
+
|
|
35
|
+
## Execution Steps
|
|
36
|
+
|
|
37
|
+
1. Locate the ledger and run `python -I -B <skill-root>/scripts/audit-ledger.py` from the delivery worktree, following the [audit protocol](references/audit-protocol.md).
|
|
38
|
+
2. Run the semantic pass in that protocol: RED reason, GREEN on the same command, quality on the committed diff, the current PR head through Tool Depot, every covered tool call recorded, and authorizations traceable to a person.
|
|
39
|
+
3. Merge both passes into one verdict and hand back per the protocol. After a fix, rerun the whole audit on the new ledger.
|
|
40
|
+
|
|
41
|
+
## Companion Handoffs
|
|
42
|
+
|
|
43
|
+
Return findings to `delivery-coordinator`, which routes them to `requirements-spec`, `regression-testing`, `skill-clean-architecture`, `code-quality-gate`, `greptile-review-loop`, or `tool-depot`. Missing human decisions go to the person named in the workflow's [roles and approvals](../delivery-coordinator/references/intake.md#roles-and-approvals).
|
|
44
|
+
|
|
45
|
+
Check the active skill catalog for the named companion before relying on it. If availability is unknown and its help is needed, ask whether it is available; do not ask when equivalent evidence already satisfies the handoff. Never assume installation, install automatically, or transfer permissions.
|
|
46
|
+
|
|
47
|
+
## Output Contract
|
|
48
|
+
|
|
49
|
+
In chat, lead with a 1-line traffic-light verdict (`🟢 conforms`, `🟡 gaps`, `🔴 violations`, or `🔴 unusable`), PR and short head SHA audited, plus `reconstructed` if applicable. List only active findings (`rule ID · location · owning stage`), Code Owner gaps, and unverified checks—keep full details in the audit report or on `"detalle"`.
|
|
50
|
+
|
|
51
|
+
## References
|
|
52
|
+
|
|
53
|
+
- [Delivery ledger format and rule table](references/ledger.md)
|
|
54
|
+
- [Audit protocol: structural and semantic passes, hand back](references/audit-protocol.md)
|
|
55
|
+
- [Ledger checker](scripts/audit-ledger.py)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Audit protocol
|
|
2
|
+
|
|
3
|
+
The audit has two passes. The script checks structure: stage order, required evidence fields, human authorizations, and Tool Depot records against the catalog. The auditor then checks meaning: that the recorded evidence says what the ledger claims. Neither pass edits code, the ledger, the PR, or any thread.
|
|
4
|
+
|
|
5
|
+
## 1. Locate the ledger
|
|
6
|
+
|
|
7
|
+
From the delivery worktree:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
python -I -B <workflow-auditor>/scripts/audit-ledger.py
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Without a path, the script reads `bbc-delivery-ledger.json` from the worktree's Git directory (see [ledger](ledger.md#where-it-lives)). Pass `--catalog <path>` only if the `tool-depot` skill is not installed next to this one. If the catalog cannot be found, the verdict is `unusable`: do not audit Tool Depot use from memory.
|
|
14
|
+
|
|
15
|
+
No ledger (a PR opened by someone else, or a delivery that predates the ledger): reconstruct one from supplied evidence only (the PR body, linked issue, recorded test commands, review links, and the conversation's tool calls). Write it to a temporary path outside every repository, mark the report as `reconstructed`, and record what could not be reconstructed as gaps. Never invent an authorization or a Tool Depot decision that is not in the evidence.
|
|
16
|
+
|
|
17
|
+
## 2. Run the structural pass
|
|
18
|
+
|
|
19
|
+
| Exit | Verdict | Meaning |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `0` | `conforms` | No violations and no gaps. |
|
|
22
|
+
| `0` | `gaps` | No violations; gaps (`G1`) must reach the Code Owner. |
|
|
23
|
+
| `1` | `violations` | At least one rule in [the rule table](ledger.md#rules-checked-by-the-script) failed. |
|
|
24
|
+
| `2` | `unusable` | Ledger or catalog missing, invalid, or of an unknown version. |
|
|
25
|
+
|
|
26
|
+
## 3. Run the semantic pass
|
|
27
|
+
|
|
28
|
+
Check each item against the evidence the ledger points to. Report any mismatch as a violation with the closest rule ID.
|
|
29
|
+
|
|
30
|
+
- **RED (`E1`):** the failure is the assertion for the criterion, not a setup, import, or environment error.
|
|
31
|
+
- **GREEN (`E2`):** the same command as RED passes on the resulting revision, and applicable existing checks were run or their skips recorded.
|
|
32
|
+
- **Quality (`Q1`):** the gate verdict covers the same diff that was committed, and every exception is recorded with its justification.
|
|
33
|
+
- **PR head (`R1`):** confirm that the recorded head SHA is the PR's current head. Read it through `tool-depot` (`github-read` / `read-pr-review-and-checks`) and record that request and use in your report. If the Depot does not return `eligible`, report the head as unverified; do not read it through another channel.
|
|
34
|
+
- **Issue back-link (`R2`):** when the delivery stems from a canonical GitHub issue, confirm `commit_pr.evidence.issue` and `issue_linked: true` match an eligible `github-write` (`comment-approved-issue`) comment on that issue linking the opened PR so the issue is never left orphaned.
|
|
35
|
+
- **Canonical issue & GitHub Project board:** for `change` work, confirm `specify` resolved a canonical GitHub issue (`check-duplicate-issues` → linked & commented via `comment-approved-issue` if found, reopened per `issue-dedup.md`, or created via `publish-approved-issue` if absent) and moved the issue on the GitHub Project v2 board to its active-work status (`"Trabajando"`, `"Working"`, `"In Progress"`, etc.) via `read-approved-project-board` + `update-approved-project-status` (or recorded an explicit `🟡 GAP` when no board exists or `project`/`read:project` token scopes are missing).
|
|
36
|
+
- **Search before filing (`D1`):** every issue publish or reopen follows an eligible `check-duplicate-issues` search of the same repository, and the `specify` reason names the terms, candidates, and decision. A reopened issue carries a history comment.
|
|
37
|
+
- **Issue claim (`C1`–`C4`):** apply the [semantic checks of the claim protocol](../../delivery-coordinator/references/issue-claim.md#semantic-checks-for-the-auditor-llm): the `check` and `verify` verdicts are `check-issue-claim.py` output for reads made in this delivery, the claimant is the authorizing person, a handover cites the holder's or Tech Lead's message, and a delivery that stopped before its PR released the claim.
|
|
38
|
+
- **Issue triage (`I1`–`I2`):** the [triage](../../issue-reviewer/references/triage.md) writes match the `plan-issue-triage.py` commands the person approved, the only assignee added is the issue author, and the later comment states the assignee, the label changes, the priority with its rationale, and any gap.
|
|
39
|
+
- **Visual reference (`V1`):** every issue publish, update, or comment, including the PR back-link, embeds the image recorded in `visual`, and the image is sanitized. A stated gap (`G2`) must also appear in the issue text.
|
|
40
|
+
- **Tool use (`T1`):** if the session's tool calls are visible, every covered SSH, public web, or GitHub operation in them appears in `tool_uses`. A call that is missing is `T1`. A call made after a `denied` or `needs-approval` decision for the same target, through any tool or agent, is `T2`.
|
|
41
|
+
- **Authorizations (`A1`, `A2`):** each one is traceable to a person's message or decision, and its scope covers what was done.
|
|
42
|
+
|
|
43
|
+
## 4. Hand back
|
|
44
|
+
|
|
45
|
+
- `conforms` or `gaps`: return the report to `delivery-coordinator` for the Code Owner handoff. Gaps travel with the PR.
|
|
46
|
+
- `violations`: return each one to the stage that owns it: `W1` and `K1` to Delivery Coordinator, `S*` and `E*` to the earliest missing or failing stage, `Q1` to `code-quality-gate`, `R1` to `greptile-review-loop`, `R2` to Delivery Coordinator (link PR back on canonical issue via Tool Depot), `V1` to the skill that wrote on the issue (`delivery-coordinator` or `issue-reviewer`), `D1` to Delivery Coordinator (search before filing), `I*` to `issue-reviewer` (triage), `C*` to Delivery Coordinator (claim the issue; a handover goes to the person who holds it), `A*`, `H*`, and `T5` to the person whose decision is missing, and other `T*` rules to the requesting skill and `tool-depot`. Rerun the audit after the fix.
|
|
47
|
+
- `unusable`: report what is missing. Do not issue a verdict.
|
|
48
|
+
|
|
49
|
+
A `conforms` verdict is not an approval. It does not replace Greptile, the Code Owner's review, or the Release Owner's decision, and it grants no permission.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Delivery ledger
|
|
2
|
+
|
|
3
|
+
The delivery ledger is the record of one delivery: which stages ran, in what order, with what evidence, who authorized what, and every covered external tool operation with its Tool Depot decision. `delivery-coordinator` keeps it; `workflow-auditor` reads it.
|
|
4
|
+
|
|
5
|
+
## Where it lives
|
|
6
|
+
|
|
7
|
+
One ledger per worktree, inside that worktree's private Git directory, so it is never committed or pushed:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ledger=$(git rev-parse --git-path bbc-delivery-ledger.json)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Run this from the delivery worktree. Removing the worktree removes the ledger, so hand over the audit verdict, not the file. Never put secrets, tokens, customer data, raw logs, or full reports in it; record references (issue or PR IDs, commands, SHAs, rule names) instead.
|
|
14
|
+
|
|
15
|
+
## Format (version 1)
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"version": 1,
|
|
20
|
+
"task": "C1: status filter shows only failed jobs",
|
|
21
|
+
"kind": "change",
|
|
22
|
+
"issue": "example/repo#12",
|
|
23
|
+
"worktree": {"path": "/work/example-status-filter", "branch": "feat/12-status-filter", "base_sha": "<default-branch SHA>"},
|
|
24
|
+
"authorizations": [
|
|
25
|
+
{"id": "AUTH-1", "by": "person", "role": "Tech Lead", "covers": ["implement", "commit_pr"]}
|
|
26
|
+
],
|
|
27
|
+
"stages": [
|
|
28
|
+
{"stage": "specify", "status": "reused", "actor": "requirements-spec", "reason": "Issue example#12 lists C1.", "evidence": {"issue": "example/repo#12", "issue_action": "linked_and_commented", "project_status": "Trabajando"}},
|
|
29
|
+
{"stage": "claim", "status": "done", "actor": "delivery-coordinator", "authorization": "AUTH-1", "evidence": {"issue": "example/repo#12", "claimant": "ana", "check": "free", "verify": "claimed-by-you"}},
|
|
30
|
+
{"stage": "reproduce", "status": "done", "actor": "regression-testing", "evidence": {"command": "npm test -- status-filter", "result": "fail"}},
|
|
31
|
+
{"stage": "implement", "status": "done", "actor": "skill-clean-architecture", "authorization": "AUTH-1"},
|
|
32
|
+
{"stage": "verify", "status": "done", "actor": "regression-testing", "evidence": {"command": "npm test -- status-filter", "result": "pass"}},
|
|
33
|
+
{"stage": "quality", "status": "done", "actor": "code-quality-gate", "evidence": {"typesafe": "pass", "earlyreturn": "pass", "bigo": "pass"}},
|
|
34
|
+
{"stage": "commit_pr", "status": "done", "actor": "host", "authorization": "AUTH-1", "evidence": {"pr": "example/repo#13", "head_sha": "<PR head SHA>", "issue": "example/repo#12", "issue_linked": true}},
|
|
35
|
+
{"stage": "review", "status": "done", "actor": "greptile-review-loop", "evidence": {"head_sha": "<PR head SHA>", "score": "5/5"}}
|
|
36
|
+
],
|
|
37
|
+
"tool_requests": [
|
|
38
|
+
{"id": "TD-1", "requester": "delivery-coordinator", "tool": "github-read", "purpose": "read-approved-issue-or-pr",
|
|
39
|
+
"target": "example/repo#12", "operation": "read issue", "disposition": "eligible"},
|
|
40
|
+
{"id": "TD-2", "requester": "delivery-coordinator", "tool": "github-read", "purpose": "check-issue-claim",
|
|
41
|
+
"target": "example/repo#12", "operation": "read assignees, labels, open PRs, feat/12-* branches", "disposition": "eligible"},
|
|
42
|
+
{"id": "TD-3", "requester": "delivery-coordinator", "tool": "github-write", "purpose": "claim-approved-issue",
|
|
43
|
+
"target": "example/repo#12", "operation": "assign ana, add status:in-progress", "disposition": "eligible", "authorization": "AUTH-1"}
|
|
44
|
+
],
|
|
45
|
+
"tool_uses": [
|
|
46
|
+
{"request": "TD-1", "tool": "github-read", "target": "example/repo#12"},
|
|
47
|
+
{"request": "TD-2", "tool": "github-read", "target": "example/repo#12"},
|
|
48
|
+
{"request": "TD-3", "tool": "github-write", "target": "example/repo#12"}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
| Field | Rule |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `kind` | `change` (edits repository files), `issue-only`, or `read-only`. Only `change` needs a worktree and the write stages. |
|
|
56
|
+
| `lane` | Optional risk lane from `classify-change-lane.py`: `trivial`, `standard` (default), or `high-risk`. |
|
|
57
|
+
| `issue` | Optional canonical issue this delivery implements (`owner/repo#n`). With it, or with `commit_pr.evidence.issue`, change work needs a `claim` stage ([claim the issue](../../delivery-coordinator/references/issue-claim.md)). |
|
|
58
|
+
| `authorizations` | One entry per human decision. `by` is always `person`; `covers` lists the stages it authorizes. Agents never add an entry on a person's behalf. |
|
|
59
|
+
| `stages` | Chronological. Append a new entry each time a stage runs again (a fix loop repeats `implement` through `review`). |
|
|
60
|
+
| `status` | `done`, `reused` (equivalent evidence; `reason` names its source), or `gap` (`reason` required). |
|
|
61
|
+
| `tool_requests` | Every Tool Depot request with its returned `disposition` (`eligible`, `needs-clarification`, `needs-approval`, `denied`, `unavailable`). Record non-eligible decisions too. |
|
|
62
|
+
| `tool_uses` | Every covered SSH, public web, or GitHub operation actually performed, citing the request it relied on. |
|
|
63
|
+
| `visual` | Required on each `tool_uses` entry for `publish-approved-issue`, `update-approved-issue`, or `comment-approved-issue`: the embedded `https://` image URL, or `{"gap": "<reason>"}`. See the [visual reference rule](../../delivery-coordinator/references/visual-reference.md). |
|
|
64
|
+
|
|
65
|
+
## Stages, in diagram order
|
|
66
|
+
|
|
67
|
+
| `stage` | Diagram step | Gap allowed? |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `observe` | Optional Sleuth report | Yes |
|
|
70
|
+
| `specify` | Requirements & Specification | No |
|
|
71
|
+
| `claim` | Claim the issue (only with a canonical issue) | Yes: the claimant cannot claim |
|
|
72
|
+
| `reproduce` | Regression Testing · Before (RED) | Yes, with `gap_type` |
|
|
73
|
+
| `implement` | Clean Architecture | No |
|
|
74
|
+
| `verify` | Regression Testing · After (GREEN) | Only after a `no-runnable-test` gap |
|
|
75
|
+
| `quality` | Code Quality Gate | No |
|
|
76
|
+
| `docs` | Documentation Steward | Yes |
|
|
77
|
+
| `commit_pr` | Commit & PR · CI (host) | No |
|
|
78
|
+
| `review` | Greptile Review Loop | Yes: Greptile unavailable or budget spent |
|
|
79
|
+
| `residual_risk` | Risk Scout after PR | Yes |
|
|
80
|
+
| `code_owner` | Human review & merge (`actor: person`) | No |
|
|
81
|
+
| `release_owner` | Deploy decision (`actor: person`) | No |
|
|
82
|
+
|
|
83
|
+
A reproduction gap needs `gap_type`: `not-reproducible` (the workflow stops before implementation) or `no-runnable-test` (verify proportionately without claiming RED/GREEN).
|
|
84
|
+
|
|
85
|
+
## Rules checked by the script
|
|
86
|
+
|
|
87
|
+
| Rule | Violation |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `W1` | Change work without a worktree path, a `feat/<task>` branch, or a default-branch base SHA. |
|
|
90
|
+
| `K1` | Issue-only or read-only work that includes write stages. |
|
|
91
|
+
| `S1` | A required stage for change work is missing: `specify`, `reproduce`, `implement`, `verify`, `quality`, `commit_pr`, `review`. |
|
|
92
|
+
| `S2` | A stage runs before an earlier diagram stage; loops may only return to `reproduce` or `implement`. |
|
|
93
|
+
| `S3` | Implementation started before `specify` and `reproduce`. |
|
|
94
|
+
| `S4` | `verify`, `quality`, `commit_pr`, or `review` was not rerun after the last implementation. |
|
|
95
|
+
| `S5` | A `reused` or `gap` entry without a reason, or a gap where the diagram allows none. |
|
|
96
|
+
| `E1` | RED without a command and a failing result, a reproduction gap without `gap_type`, or implementation after `not-reproducible`. |
|
|
97
|
+
| `E2` | The last verification lacks a command and a passing result, or is a gap without a `no-runnable-test` reproduction gap. |
|
|
98
|
+
| `Q1` | The last quality gate did not pass all three checks. |
|
|
99
|
+
| `R1` | Commit & PR lacks the PR or head SHA, the review lacks a score, or the Greptile review is not for the current PR head. |
|
|
100
|
+
| `R2` | Commit & PR cites a canonical `issue`, but `issue_linked: true` or the matching `comment-approved-issue` Tool Depot use is missing. |
|
|
101
|
+
| `V1` | An issue publish, update, or comment use without a `visual` image URL or a stated visual gap. |
|
|
102
|
+
| `D1` | A `publish-approved-issue` or `reopen-approved-issue` use with no earlier eligible `check-duplicate-issues` use on the same repository ([search before filing](../../delivery-coordinator/references/issue-dedup.md)). |
|
|
103
|
+
| `I1` | A `triage-approved-issue` use with no earlier eligible `check-issue-triage` use on the same issue ([triage](../../issue-reviewer/references/triage.md)). |
|
|
104
|
+
| `I2` | A `triage-approved-issue` use with no later `comment-approved-issue` use on the same issue stating the assignment, labels, and priority. |
|
|
105
|
+
| `C1` | Change work with a canonical issue and no `claim` stage. |
|
|
106
|
+
| `C2` | The claim names another issue or no claimant, its `check` is not `free` / `claimed-by-you` without a person's handover covering `claim`, or its `verify` is not `claimed-by-you`. |
|
|
107
|
+
| `C3` | No eligible `check-issue-claim` use on the issue, no `claim-approved-issue` use when the issue was not already the claimant's, or the claim written before the read. |
|
|
108
|
+
| `C4` | With a claim, the worktree branch is not `feat/<n>-<slug>` for the canonical issue. |
|
|
109
|
+
| `A1` | `claim`, `implement`, or `commit_pr` cites no authorization from a person, or one that does not cover it (`implement` also covers `claim`). |
|
|
110
|
+
| `A2` | An authorization not granted by a person. |
|
|
111
|
+
| `H1` | `code_owner` or `release_owner` recorded with an agent as actor. |
|
|
112
|
+
| `H2` | A deployment decision without a prior Code Owner review. |
|
|
113
|
+
| `L1` | A `high-risk` lane delivery missing a completed `residual_risk` stage (`risk-scout`). |
|
|
114
|
+
| `T1` | A covered tool used without a Tool Depot request. |
|
|
115
|
+
| `T2` | A tool used although the Depot did not return `eligible`. |
|
|
116
|
+
| `T3` | An eligible request whose tool or purpose is not in the catalog. |
|
|
117
|
+
| `T4` | A use whose tool or target differs from its eligible request. |
|
|
118
|
+
| `T5` | A GitHub write request without a person's authorization. |
|
|
119
|
+
| `T6` | A Tool Depot request missing its ID, requester, tool, purpose, target, operation, or disposition. |
|
|
120
|
+
| `T7` | With `--server-log`: a command the server's `watcher-gate` allowed (`allowed:` in syslog) with no matching `ssh` use in `tool_uses`. Each recorded use covers one command whose container or discovery prefix it names. Commands the gate denied never ran and are ignored. |
|
|
121
|
+
|
|
122
|
+
Gaps (`G1` for stages, `G2` for an issue write with a stated visual gap) are not violations. They go to the Code Owner with the PR.
|