Skip to content

fix(board): translate the shim's --backlog-file for promote - #444

Open
hieuphq wants to merge 1 commit into
masterfrom
fix/board-promote-backlog-file
Open

hieuphq wants to merge 1 commit into
masterfrom
fix/board-promote-backlog-file

Conversation

@hieuphq

@hieuphq hieuphq commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #443.

What was broken

Consumer shims scaffolded by board init always append --backlog-file, and bin/add-backlog understands no flags at all — it resolves its targets from BACKLOG_STAGE_BACKLOG / BACKLOG_STAGE_STAGING with a cwd-derived fallback. promote forwarded argv verbatim, and that broke twice over.

1. Numeric selection always failed. The flag reached the engine's int(x) selection parse, so int("--backlog-file") raised and every promote <n> / promote reject <n> exited 2 with a usage message about candidate numbers — pointing the operator at the wrong thing entirely.

list returns before that parse and all short-circuits past it, so exactly those two kept working. That is the worst shape this failure could take: the only surviving path is the one that promotes everything, and promote is documented as "the human gate". Someone wanting 2 of 5 candidates had no working way to say so, and the obvious workaround promotes the three they meant to leave staged.

2. The addressed board was ignored. The operator's explicit --backlog-file was discarded, so promote resolved its write target from cwd:

$ cd repoB && bash /abs/path/repoA/_meta/board promote all
promoted ID-001: repoB own candidate

$ grep -c '^| ID-' repoA/_meta/BACKLOG.md    # unchanged
$ grep -c '^| ID-' repoB/_meta/BACKLOG.md    # repoB's candidate landed here

repoA's shim, repoA's flag, repoB's board. In the cross-repo cockpit this kit exists to provide (boards.txt, board all, board mirror), that is a silent write to the wrong repo.

The fix

cmd_sync already documents and handles this exact shim behaviour — "Consumer shims append --backlog-file; translate it to the engine's --backlog". promote now gets the same treatment: a cmd_promote that parses the flag out, exports BACKLOG_STAGE_BACKLOG, derives BACKLOG_STAGE_STAGING as its sibling (both are scaffolded into _meta/ by cmd_init, so deriving beats adding a second flag to every shim), and execs the engine with the remaining args.

Defence in depth: add-backlog now names an unrecognised flag explicitly instead of feeding it to int() and reporting a selection error. That misdirection is most of why #443 was hard to read.

Kit-side on purpose. Shims already scaffolded in consumer repos are fixed without those repos regenerating anything.

Verification

bash tests/test-board.sh → TOTAL 42, PASS 41, FAIL 0, SKIP 1. The skip is the pre-existing NC-e ops-toolkit render comparison, absent on this machine.

Five new assertions, run from inside repoB while addressing repoA's board:

AC7a  numeric selection works through the shim's --backlog-file (was: usage error)
AC7b  the addressed repo is written, not the cwd repo
AC7c  promoted the SELECTED candidate, not all of them
AC7d  unselected candidate stays staged -- the review gate is not all-or-nothing
NC-f  unrecognised flag is named explicitly, not reported as a bad candidate number

Negative control: fix stashed, same suite re-run → FAIL 3, sources restored and byte-compared.

Honest limit, worth a reviewer's attention: AC7b and AC7d pass on the unfixed code too. When promote <n> dies at the usage error nothing is written anywhere, so "repoB gained no rows" and "A-second is still staged" are vacuously true. They do not discriminate this defect. They are kept because they do discriminate a plausible wrong fix — one that makes selection work but still resolves the target from cwd, or that promotes the whole staging file. AC7a, AC7c and NC-f are the three that actually go red.

Proof-of-done with both runs: docs/verification/board-promote-backlog-file.md.

Rollback

Revert the commit. Confined to a dispatch branch, a new cmd_promote, and a flag guard — no state, no migration, no on-disk format change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GnGEYYtrsV3iTY1VXc7tvW

Consumer shims scaffolded by `board init` always append `--backlog-file`, and
`bin/add-backlog` understands no flags at all -- it resolves its targets from
BACKLOG_STAGE_BACKLOG / BACKLOG_STAGE_STAGING with a cwd-derived fallback.
`promote` forwarded argv verbatim, which broke twice over.

The flag reached the engine's int() selection parse, so every `promote <n>` and
`promote reject <n>` died with a usage message about candidate numbers. `list`
returns before that parse and `all` short-circuits past it, so those two kept
working -- the worst shape this failure could take, since the only surviving
path is the one that promotes everything, and promote is documented as the human
review gate.

Separately the operator's explicit target was discarded, so promote resolved its
write target from cwd. Running repoA's shim from inside repoB promoted repoB's
staged candidate into repoB's board while repoA's was untouched. In the
cross-repo cockpit this kit exists to provide, that is a silent write to the
wrong board.

cmd_sync already documents and handles this exact shim behaviour; promote now
gets the same translation. Defence in depth: add-backlog names an unrecognised
flag instead of feeding it to int() and reporting a selection error.

The fix is deliberately kit-side, so shims already scaffolded in consumer repos
are corrected without those repos regenerating anything.

Proof of done, including the negative control and an honest note on which two of
the five new assertions do not discriminate this defect:
docs/verification/board-promote-backlog-file.md

Fixes #443

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GnGEYYtrsV3iTY1VXc7tvW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

board promote: consumer shim's --backlog-file breaks numeric selection and silently retargets the wrong repo

1 participant