Files
boshu2__agentops/tests/scripts/append-codex-override-entry.bats
Bo 0023aa5acf feat(skills): skill-builder scaffolds codex override-catalog entry (ag-cw2y item 4) (#611)
## What
**ag-cw2y item 4** — the 4th and last new-skill gate that cost
`/burndown` #600 a CI round. A new skill previously tripped
`validate-codex-override-coverage` ("source skill missing from Codex
catalog"). skill-builder now adds the catalog entry automatically.

## How
- **`scripts/append-codex-override-entry.sh`** — idempotent, JSON-aware:
appends a `parity_only` entry
(`name`/`treatment`/`wave=catalog-parity`/`reason`) to
`skills-codex-overrides/catalog.json` if the skill is absent.
`parity_only` is correct for skill-builder's canonical-derived codex
form; author flips to `bespoke` + scaffolds the override dir only if a
Codex-only divergence is needed. Repo-root-injectable.
- **`init.sh`** — calls it in the new-skill plumbing block alongside the
dispositions row (#609/#610) and `--fix-counts` (#610). All three gates
now pre-empted at scaffold time.

## Tests (TDD, red→green)
`tests/scripts/append-codex-override-entry.bats` — appends parity_only /
stays valid JSON / idempotent / no-dup-on-existing. 4/4 green.
shellcheck clean.

## Codex artifact
Refreshed **only skill-builder's** hash (6 unrelated pre-existing `main`
drifts untouched). PR-scope codex validation passes.

## ag-cw2y status after this
Item 1 (#609 check + #610 scaffold) ✅ · Item 2 (#610) ✅ · **Item 4
(here)** ✅ · **Item 3** (codex desc token budget / `ag-vzbt`) is the
only remaining piece. Once item 3 lands, a new skill — and therefore
`ag-hdqu0.8` + `/burndown` #600 — is fully one-shot-green.

Closes-scenario: ag-cw2y#override-catalog-scaffold
Bounded-context: BC4-factory
Evidence: tests/scripts/append-codex-override-entry.bats
2026-05-29 20:03:37 -04:00

52 lines
2.0 KiB
Bash

#!/usr/bin/env bats
# ag-cw2y item 4: skill-builder must add a skills-codex-overrides/catalog.json
# entry for a new skill so it is one-shot-green against
# validate-codex-override-coverage ("source skill missing from Codex catalog").
# Default treatment is parity_only (canonical-derived codex form). Idempotent +
# repo-root-injectable.
setup() {
HELPER="$BATS_TEST_DIRNAME/../../scripts/append-codex-override-entry.sh"
FIX="$(mktemp -d)"
mkdir -p "$FIX/skills-codex-overrides"
cat > "$FIX/skills-codex-overrides/catalog.json" <<'EOF'
{
"version": 1,
"description": "fixture",
"waves": [ { "id": "catalog-parity", "title": "Catalog parity" } ],
"skills": [
{ "name": "existing", "treatment": "parity_only", "wave": "catalog-parity", "reason": "already here" }
]
}
EOF
}
teardown() { rm -rf "$FIX"; }
@test "appends a parity_only catalog entry for a new skill" {
run bash "$HELPER" newskill "$FIX"
[ "$status" -eq 0 ]
run python3 -c "import json,sys; d=json.load(open('$FIX/skills-codex-overrides/catalog.json')); e=[s for s in d['skills'] if s['name']=='newskill']; assert len(e)==1; assert e[0]['treatment']=='parity_only'; assert e[0]['wave']=='catalog-parity'; print('ok')"
[[ "$output" == *"ok"* ]]
}
@test "produced catalog remains valid JSON" {
bash "$HELPER" newskill "$FIX"
run python3 -c "import json; json.load(open('$FIX/skills-codex-overrides/catalog.json')); print('valid')"
[[ "$output" == *"valid"* ]]
}
@test "is idempotent — no duplicate entry" {
bash "$HELPER" newskill "$FIX"
bash "$HELPER" newskill "$FIX"
run python3 -c "import json; d=json.load(open('$FIX/skills-codex-overrides/catalog.json')); print(sum(1 for s in d['skills'] if s['name']=='newskill'))"
[[ "$output" == *"1"* ]]
}
@test "does not duplicate an already-cataloged skill" {
run bash "$HELPER" existing "$FIX"
[ "$status" -eq 0 ]
run python3 -c "import json; d=json.load(open('$FIX/skills-codex-overrides/catalog.json')); print(sum(1 for s in d['skills'] if s['name']=='existing'))"
[[ "$output" == *"1"* ]]
}