Files
boshu2__agentops/scripts/validate-bd-closeout-contract.sh
T
Bo 15d2e089a2 docs(governance): fix broken bd-command references in governance docs (ag-55m0 #bd-command-doc-fixes) (#706)
## What

Two verified bd-command doc/contract bugs discovered while executing the
ag-lk80 doc-staleness epic.

| Bead | Fix |
|---|---|
| ag-55m0 | `bd worktree create --branch <branch>` (4 sites: CLAUDE.md
×2, AGENTS-WORKFLOW.md ×2) omits bd 1.0.5's **required positional
`<name>`** — the documented form prints help and creates nothing. Now
`bd worktree create wt-<bead-id> --branch <branch>`. |
| ag-6jzv | `validate-bd-closeout-contract.sh` required the `bd dolt
push` conditional wording in **AGENTS.md**, but the tiered split
(soc-vuu6.3) moved that content to **AGENTS-WORKFLOW.md** (lines
150/277). Repointed the validator where the wording actually lives. |

## Verification
- `bd worktree create --help` → confirms the positional `<name>`
requirement (hit live this session)
- `scripts/validate-bd-closeout-contract.sh` → **PASS** (was failing on
AGENTS.md on pristine main)
- No `bd worktree create --branch` without a positional name remains in
CLAUDE.md / AGENTS-WORKFLOW.md

Closes-scenario: ag-55m0#bd-command-doc-fixes
Closes-scenario: ag-6jzv#validator-repoint
Bounded-context: BC2-Validation
Evidence: scripts/validate-bd-closeout-contract.sh
2026-06-03 21:14:24 -04:00

69 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd "$script_dir/.." && pwd)"
failures=0
fail() {
echo "BD_CLOSEOUT_CONTRACT: FAIL: $*" >&2
failures=$((failures + 1))
}
require_file() {
local path="$1"
if [[ ! -f "$repo_root/$path" ]]; then
fail "missing required file: $path"
return 1
fi
return 0
}
require_conditional_push_wording() {
local path="$1"
local bare_push_matches
require_file "$path" || return 0
if ! grep -Eq 'bd dolt push.*(only if|only when|remote is configured|remote configured)' "$repo_root/$path"; then
fail "$path must describe bd dolt push as conditional on a configured remote"
fi
bare_push_matches="$(
grep -nE '^[[:space:]]*bd dolt push[[:space:]]*$' "$repo_root/$path" || true
)"
if [[ -n "$bare_push_matches" ]]; then
fail "$path contains a bare bd dolt push command without the conditional remote note: ${bare_push_matches//$'\n'/; }"
fi
}
# The bd-closeout conditional-push wording lives in AGENTS-WORKFLOW.md after the
# AGENTS.md tiered split (soc-vuu6.3); the thin root AGENTS.md only points to it.
require_conditional_push_wording "AGENTS-WORKFLOW.md"
require_conditional_push_wording "cli/AGENTS.md"
if require_file "docs/runbooks/bd-server-mode-closeout.md"; then
grep -q 'Server-mode direct-write' "$repo_root/docs/runbooks/bd-server-mode-closeout.md" \
|| fail "runbook must name server-mode direct-write trackers"
grep -q 'bd dolt remote list' "$repo_root/docs/runbooks/bd-server-mode-closeout.md" \
|| fail "runbook must include bd dolt remote list"
grep -q 'no remote is configured' "$repo_root/docs/runbooks/bd-server-mode-closeout.md" \
|| fail "runbook must explain the no-remote case"
grep -q 'bd_timeout' "$repo_root/docs/runbooks/bd-server-mode-closeout.md" \
|| fail "runbook must include the bd_timeout bounded-command wrapper"
grep -q 'timed out after emitting JSON' "$repo_root/docs/runbooks/bd-server-mode-closeout.md" \
|| fail "runbook must explain hung-after-output bd write behavior"
fi
if require_file "docs/documentation-index.md"; then
grep -q 'runbooks/bd-server-mode-closeout.md' "$repo_root/docs/documentation-index.md" \
|| fail "documentation index must link bd server-mode closeout runbook"
fi
if (( failures > 0 )); then
exit 1
fi
echo "BD_CLOSEOUT_CONTRACT: PASS"