Files
boshu2__agentops/tests/scripts/cross-runtime-hook-baseline.bats
Bo 5145b37e3a fix: restore green GitHub backlog baseline (#913)
## Summary

- replace removed nightly retrieval commands with the maintained smoke
fixture and focused retrieval coverage
- repair Windows smoke, workflow/actionlint, skill projections,
installer fixtures, and stale Cathedral Cut tests
- refactor verdict validation below the complexity budget while
preserving its error contract
- incorporate the pending cross-runtime hook projection already
represented in the repository manifest

## Validation

- `go test -race -shuffle=on ./...`
- full Bats suite: 874/874 passed
- `scripts/ci-local-release.sh --quick`
- `ao gate check --full --json --workflow-coverage
--require-workflow-parity`: 65/65
- `ao gate check --fast --json`: 43/43

This PR repairs the common causes represented by open nightly issues
#900, #901, #903, #909, #910, and #912. Those issues will be closed only
after the corresponding workflows pass on `main`.

---------

Co-authored-by: boshu <241868352+boshu2@users.noreply.github.com>
Co-authored-by: Test <test@test.com>
2026-07-16 10:26:34 -04:00

72 lines
1.8 KiB
Bash

#!/usr/bin/env bats
setup() {
HOOK="$BATS_TEST_DIRNAME/../../skills/cc-hooks/hooks/skill-first-coord-guard.sh"
TEST_TMPDIR="$(mktemp -d)"
}
teardown() {
rm -rf "$TEST_TMPDIR"
}
run_hook() {
local payload="$1"
run env TMPDIR="$TEST_TMPDIR" bash -c \
'printf "%s" "$1" | bash "$2"' _ "$payload" "$HOOK"
}
@test "allows an ordinary Claude Bash command silently" {
run_hook '{"session_id":"claude-allow","tool_input":{"command":"git status --short"}}'
[ "$status" -eq 0 ]
[ -z "$output" ]
}
@test "blocks a Claude NTM command once per session" {
local payload='{"session_id":"claude-block","tool_input":{"command":"ntm --robot-status"}}'
run_hook "$payload"
[ "$status" -eq 2 ]
[[ "$output" == *'load the `agent-mail` or `ntm` skill contract'* ]]
run_hook "$payload"
[ "$status" -eq 0 ]
[ -z "$output" ]
}
@test "accepts Codex command-line and thread-id fields" {
run_hook '{"thread_id":"codex-block","tool_input":{"command_line":"/Users/bo/.local/bin/ntm --robot-status"}}'
[ "$status" -eq 2 ]
}
@test "accepts AGY top-level command and conversation-id fields" {
run_hook '{"conversation_id":"agy-block","command":"tmux send-keys -t agentops:1.0 audit Enter"}'
[ "$status" -eq 2 ]
}
@test "does not match coordination words inside quoted prose" {
run_hook '{"session_id":"quoted","tool_input":{"command":"br create --body \"run ntm --robot-status later\""}}'
[ "$status" -eq 0 ]
[ -z "$output" ]
}
@test "fails open on malformed JSON" {
run_hook '{'
[ "$status" -eq 0 ]
[ -z "$output" ]
}
@test "kill switch disables the hook silently" {
local payload='{"session_id":"disabled","tool_input":{"command":"ntm --robot-status"}}'
run env AGENTOPS_HOOKS_DISABLED=1 TMPDIR="$TEST_TMPDIR" bash -c \
'printf "%s" "$1" | bash "$2"' _ "$payload" "$HOOK"
[ "$status" -eq 0 ]
[ -z "$output" ]
}