Files
command-center/tests/kb-coverage.bats
T
Frank 4849f46eb2 feat(kb-gates): one work log per bundle, and the quarantine is not bundle content
The bundle had two work logs. `core/log.md` was created "for tracking core directory
modifications" and holds two entries of pure migration bookkeeping (file moved,
directory created, log created) — every one recoverable from `git log` — plus a date
for the OKF conversion (2026-07-15) that matches neither the bundle log (2026-01-15)
nor git history, where the OKF rebuild lands 2026-08-28. `core/index.md` was still
linking it, which is exactly how a stale page stays in circulation. kb-lint now reports
any `log.md` that is not the bundle root's; the page moved to omp-docs/core/.AGENTTRASH/
per the trash convention, and the core index points one level up.

Both gates also walked `.AGENTTRASH/`, so trashing a page turned them red: kb-lint
demanded frontmatter from a quarantined page and kb-coverage demanded an index for the
trash directory. A gate that only goes green once the quarantined copy is deleted is a
gate that deletes history, so both skip any path containing `.AGENTTRASH` — pinned by a
test in each suite, and kb-coverage finally gets its own test file.
2026-10-20 21:49:15 -07:00

50 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bats
# tests/kb-coverage.bats — black-box tests for scripts/kb-coverage.py
#
# Contract: exit 0 when every directory of a knowledge bundle has an index.md and each
# index links its siblings. Observable surface: stdout lines and exit status.
setup() {
CHECK="$BATS_TEST_DIRNAME/../scripts/kb-coverage.py"
KB="$(mktemp -d)/kb"
mkdir -p "$KB/sub"
printf '# Index\n\n* [Good](good.md)\n* [Sub](sub/)\n' > "$KB/index.md"
printf '# Sub\n\n* [Deep](deep.md)\n' > "$KB/sub/index.md"
printf 'body\n' > "$KB/good.md"
printf 'body\n' > "$KB/sub/deep.md"
}
teardown() { rm -rf "$(dirname "$KB")"; }
@test "a bundle whose directories index their contents passes" {
run python3 "$CHECK" "$KB"
[ "$status" -eq 0 ]
[[ "$output" == *"0 issue(s)"* ]]
}
@test "a directory nobody indexes is reported" {
mkdir "$KB/stray"
printf 'body\n' > "$KB/stray/thing.md"
run python3 "$CHECK" "$KB"
[ "$status" -ne 0 ]
[[ "$output" == *"stray: no index.md"* ]]
}
@test "an index that forgets a sibling page is reported" {
printf 'body\n' > "$KB/orphan.md"
run python3 "$CHECK" "$KB"
[ "$status" -ne 0 ]
[[ "$output" == *"does not link orphan.md"* ]]
}
@test "the quarantine trash directory is not part of the bundle" {
# Pages deleted from the KB wait in .AGENTTRASH/ for a pruning session with Frank.
# Requiring an index there, or listing its contents, would push an agent to delete
# the quarantined copy just to make the gate green.
mkdir -p "$KB/.AGENTTRASH"
printf 'retired page\n' > "$KB/.AGENTTRASH/old-page.md"
run python3 "$CHECK" "$KB"
[ "$status" -eq 0 ]
[[ "$output" == *"0 issue(s)"* ]]
}