Files
boshu2__agentops/scripts/validate-agents-split.sh
T
Bo 5dfe1c9194 feat(docs): tiered AGENTS.md split — orientation + 4 siblings (soc-vuu6.3 #agents-md-tiered-split) (#387)
## Summary

Split the 580-line monolithic AGENTS.md into five tiered files so
cold-start sessions pay ≤250 lines for orientation, with operational
detail one hop away.

| File | Lines | Owner area |
|---|---:|---|
| `AGENTS.md` | 97 | Orientation + Quick Reference + sibling pointer
table + 1-release deprecation footer |
| `AGENTS-WORKFLOW.md` | 292 | Workflow phases · Branch/PR shape ·
Multi-agent discipline · Provenance · Doctrine altitudes · Local
Pre-Push · Releasing · Landing the Plane · bd Tracking · Session
Completion |
| `AGENTS-CI.md` | 127 | CI intro · Advisory Triage SLAs · DEFERRED
Hardening matrix · CI Jobs table (67 rows) · Nightly |
| `AGENTS-CODEX.md` | 52 | CLI Skill-Map Refresh + Codex Skill
Maintenance |
| `AGENTS-RUNTIME.md` | 59 | Canonical Root and Worktrees + Key
Constraints |

## Mechanical enforcement

- `scripts/validate-agents-split.sh` — 14 checks: AGENTS.md exists, ≤250
lines, each sibling exists, bidirectional links.
- CI gate `validate-agents-split` (required) — wired into `validate.yml`
`needs:` arrays + summary echo + `docs/contracts/ci-jobs.yaml` manifest.
- `scripts/generate-ci-jobs-table.sh` `AGENTS_PATH` default flipped from
`AGENTS.md` to `AGENTS-CI.md`; 67-row table regenerated.
- 7-case bats coverage at `tests/scripts/validate-agents-split.bats`.

## Fitness delta

Cold-start orientation budget: **580 → 97 lines (-83%)**. Total docs
across the split: 580 → 627 lines (+47 lines of sibling pointers and
deprecation footer — the overhead of the contract).

## Deferred to follow-up beads

- **Operating-loop ASCII spine** — `docs/architecture/operating-loop.md`
12-line flowchart prefix; orthogonal authoring task.
- **Universal init prompt wiring** — `ao session bootstrap` referenced
in AGENTS.md but blocked on soc-vuu6.25.

## Verification

```bash
bash scripts/validate-agents-split.sh
# validate-agents-split: scanned 14 checks
# PASS — AGENTS.md (97 lines) + 4 siblings, links bidirectional.

bats tests/scripts/validate-agents-split.bats
# 1..7 (all pass)

bash tests/docs/validate-doc-release.sh
# PASS: doc-release gate succeeded

bash scripts/validate-ci-policy-parity.sh
# CI_JOBS_TABLE: PASS (67 rows)
```

## Sibling patterns

CI gate shape follows `scripts/check-finding-registry.sh`. Manifest
entry follows the validate-* row shape. Bats fixtures match
`tests/scripts/validate-sovereignty-proof-citations.bats`.

Closes-scenario: soc-vuu6.3#agents-md-tiered-split
Bounded-context: BC1-Corpus
Evidence: AGENTS.md
Evidence: AGENTS-WORKFLOW.md
Evidence: AGENTS-CI.md
Evidence: AGENTS-CODEX.md
Evidence: AGENTS-RUNTIME.md
Evidence: scripts/validate-agents-split.sh
Evidence: tests/scripts/validate-agents-split.bats
Evidence: .github/workflows/validate.yml
Evidence: docs/contracts/ci-jobs.yaml
2026-05-21 01:05:02 +00:00

93 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# validate-agents-split.sh
#
# Enforces the tiered AGENTS.md split (soc-vuu6.3):
# - AGENTS.md exists and is <=250 lines (orientation only)
# - AGENTS-{WORKFLOW,CI,CODEX,RUNTIME}.md exist
# - AGENTS.md contains a pointer link to each sibling
# - Each sibling links back to AGENTS.md for orientation
#
# Why: AGENTS.md was 580 lines / ~15K tokens before the split (every session
# paid the cold-start cost). The split saves cost for routine sessions while
# keeping the operational detail one hop away. This gate keeps the split
# contract honest as the docs evolve.
#
# Sibling pattern: matches scripts/check-finding-registry.sh shape —
# explicit gate with summary + nonzero exit on first contract breach.
#
# Exit codes:
# 0 — split contract satisfied
# 1 — contract broken (one or more checks failed)
# 2 — usage / setup error
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
readonly LIMIT=250
readonly SIBLINGS=(AGENTS-WORKFLOW.md AGENTS-CI.md AGENTS-CODEX.md AGENTS-RUNTIME.md)
declare -i checks=0
declare -i failed=0
failures=()
fail() {
failed=$((failed + 1))
failures+=("$1")
}
# 1. AGENTS.md exists
checks=$((checks + 1))
if [ ! -f AGENTS.md ]; then
fail "AGENTS.md does not exist"
echo "validate-agents-split: scanned $checks checks, $failed failed" >&2
printf ' - %s\n' "${failures[@]}" >&2
exit 1
fi
# 2. AGENTS.md is <=LIMIT lines
checks=$((checks + 1))
lines=$(wc -l < AGENTS.md)
if [ "$lines" -gt "$LIMIT" ]; then
fail "AGENTS.md is $lines lines, exceeds $LIMIT-line orientation budget"
fi
# 3. Each sibling exists
for sib in "${SIBLINGS[@]}"; do
checks=$((checks + 1))
if [ ! -f "$sib" ]; then
fail "missing sibling: $sib"
fi
done
# 4. AGENTS.md links to each sibling
for sib in "${SIBLINGS[@]}"; do
checks=$((checks + 1))
if ! grep -q "$sib" AGENTS.md; then
fail "AGENTS.md does not link to $sib"
fi
done
# 5. Each sibling back-links to AGENTS.md
for sib in "${SIBLINGS[@]}"; do
[ -f "$sib" ] || continue
checks=$((checks + 1))
if ! grep -q "AGENTS.md" "$sib"; then
fail "$sib does not back-link to AGENTS.md"
fi
done
echo "validate-agents-split: scanned $checks checks"
if [ "$failed" -eq 0 ]; then
echo "PASS — AGENTS.md ($lines lines) + 4 siblings, links bidirectional."
exit 0
fi
echo "FAIL — $failed contract breach(es):" >&2
for f in "${failures[@]}"; do
echo " - $f" >&2
done
exit 1