Files
command-center/agent/managed-skills/dankvoice-bundle-swap-red-proof/SKILL.md
T

3.1 KiB

name, description
name description
dankvoice-bundle-swap-red-proof Prove a dankvoice behavior test is red against the pre-change bundle by pointing DV_EXT at a built old bundle; includes the source-swap fallback when the extracted bundle cannot resolve node_modules outside the repo.

Red-proofing a dankvoice behavior test against the pre-change bundle

The suite drives the built bundle (dist/index.js, rebuilt by setup() from src/), so "is this new assertion actually red-capable?" is a question about a bundle that no longer exists after the fix. Two routes; try A first, fall back to B.

Route A — DV_EXT at the old committed bundle

git show HEAD:dist/index.js > "$W/old-dist.js"
DV_EXT="$W/old-dist.js" DV_STUB=... <same env as the test> bun "$DV_DRIVER" <scenario>   # expect RED
DV_EXT="$PWD/dist/index.js" <same env> bun "$DV_DRIVER" <scenario>                        # expect GREEN

Build the driver harness by extracting the heredoc setup() writes into tests/behavior.bats:

sed -n '<first-body-line>,<last-body-line>p' tests/behavior.bats > "$W/driver.ts"

Re-check that range after every edit that adds lines to the driver (console.log census blocks included) — a stale end line silently appends the TS terminator and the driver dies after printing, which looks like a passing probe.

Copy the project's real player stub, wpctl fixture, models.yml and ompconfig.yml verbatim; a simplified stub prints a false PLAYS 0.

Trap (why A fails in a worktree): module externals resolve from the bundle's directory. A bundle extracted to /tmp cannot resolve @oh-my-pi/pi-natives and dies with a version-pinned Cannot find module .../pi-natives@<ver>/.../loader-state.js — nothing to do with the fix under test. Putting the old bundle inside the repo (next to node_modules) fixes resolution, but in a linked-worktree where node_modules is a symlink to another checkout whose installed version differs from the version baked into HEAD:dist, it still fails. Then use route B.

Route B — swap the source, rebuild, restore (private worktree only)

setup() rebuilds dist from src/, so reverting one source file reproduces the pre-fix bundle exactly:

cp src/<file>.ts /tmp/new-<file>.ts
git show HEAD:src/<file>.ts > src/<file>.ts
bun run build >/dev/null
bats tests/behavior.bats --filter '<new test names>'      # expect every new test NOT ok
cp /tmp/new-<file>.ts src/<file>.ts && bun run build >/dev/null && echo RESTORED

Always restore in the same command line that ran the red check, so an interrupted session cannot leave pre-fix source behind. bats --filter takes a regex over the @test titles; use it instead of the whole suite (the full run is ~5 min).

Read the failure lines, not just the count: a red test that fails because the driver crashed (PLAYS 0, no CALL lines) proves nothing about the fix.

Gate afterwards

bun run build and commit dist/ in the same commit as src/ — tests/packaging.bats byte-compares the committed dist (git diff --name-only -- dist must be empty), so an uncommitted rebuild shows up as a red packaging test, not as a missing fix.