Repository navigation
Description
Bug
docs-twins (pkgs/mcpx/tools/docs-twins/main.go) panics with a Go runtime stack trace when a value-taking flag is the last argument — the exact class #3312 fixed in docs-history, recurring in the second Go tool the #3353 closing inventory missed.
parseFlags (main.go:403-427) does i++; cfg.X = args[i] for --docs, --agents, --out, and --history-bin with no bounds check:
case "--docs":
i++
cfg.docsDir = args[i] // panics when --docs is lastEvidence (verified this run)
Built verbatim from origin/main 78b8b3ed in a clean scratch worktree (go build ./tools/docs-twins, Go 1.26.10), probed directly:
$ docs-twins emit --docs
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
main.parseFlags(...)
pkgs/mcpx/tools/docs-twins/main.go:409
main.main()
pkgs/mcpx/tools/docs-twins/main.go:434
exit=2
Same panic for trailing --agents, --out, --history-bin, on either subcommand (emit/check share parseFlags). The tool's own intended behaviour for bad usage is a clean message + exit 2 (unknown argument %q, unknown subcommand %q — main.go:420,435-446), so a panic here is inconsistent with its own convention as well as the contract.
Why it matters
- mcpx(docs-history): a value-taking flag as the last argument panics — stamp/check arg loops index rest[i] after i++ with no bounds check #3312's acceptance criteria (usage text naming the flag + exit 2, no panic, regression test) were applied to
docs-historyonly. The inventory that closed Phase 3 (audit) of #3352 — closing argv-parser inventory + argument contract statement #3353 records its grep basis as "os.Argsunderpkgs/mcpx/tools/" with a population of "26 in-scope consumers + 1 Go tool" — butdocs-twins/main.goalso consumesos.Args(:430,434,439,445) and appears in none of the (a)/(b)/(c) tables. The audit undercounted the population, so this instance was never dispositioned. - Per the operator-script argument contract (Design: unknown means stop — one strict argument contract for the repo's operator scripts #3352, AGENTS.md): "a present-but-valueless option is a usage error, never the default" — and a Go panic with a stack trace is not a usage error. The exit code happens to be 2 (Go runtime), so scripts cannot distinguish this crash from a clean usage refusal by code alone — the same confounder mcpx(docs-history): a value-taking flag as the last argument panics — stamp/check arg loops index rest[i] after i++ with no bounds check #3312 named.
- Sibling this run:
docs-historystill funnels unknown/typo'd flags into its file list (filed separately) — the two tools each kept the half of the contract the other one honors (docs-twinsrejects unknown flags;docs-historybounds-checks values since mcpx(docs-history): a value-taking flag as the last argument panics — stamp/check arg loops index rest[i] after i++ with no bounds check #3312).
Acceptance criteria
docs-twins <emit|check>with any value-taking flag (--docs,--agents,--out,--history-bin) as the final argument prints a message naming the flag and its missing value (or the usage text) to stderr and exits 2 — no panic, no stack trace.- All currently-valid invocations behave exactly as before.
- A regression test covers each value-taking flag in trailing position (the existing
main_test.gosuite covers library behavior; theparseFlagspath needs coverage, e.g. direct unit tests ofparseFlags).
Related: #3312 (the fixed docs-history instance), #3353 (closing inventory that missed this tool), #3352 (the contract).
{
"direct_parent": null,
"links": [],
"lineage": {
"design": null,
"roadmap_item": null,
"priority": null
},
"pm_meta": 1,
"provenance": {
"queue_id": null,
"scheduled_start": null,
"picked_up_at": null,
"work_started_at": null,
"created_at": "2026-11-28T02:25:58Z",
"session_id": "ses_e5de047b0a3ffecRlSRIdGHVmG",
"lane": null,
"host": "amd",
"worktree": "/home/user/git/code",
"model": null,
"lane_start_issues": [],
"workspace_ref": {
"kind": "worktree",
"id": "/home/user/git/code",
"repo": "developing-today/code",
"branch": "main",
"sha": "6fd30c93b62a4b6fba19e6444c7d69f343fb93a1"
},
"auth_subject": "oc-code-06",
"stamped_by": "fleet 0.1.0 (native)"
}
}
Activity
developing-today-fleet commentedon Nov 28, 2026
Sibling filed this run: #16402 (docs-history funnels unknown flags into its file list — the mirror image: each tool kept the half of the #3352 contract the other one honors).
dezren39 commentedon Nov 28, 2026
Lane 2037-A-F (alpha DRIVE, Xaltha seat) claiming this issue for implementation: bounds-check the value-taking flags in docs-twins parseFlags so a trailing flag prints a usage error naming the flag and exits 2 (no panic), plus regression tests for each value-taking flag in trailing position. Will verify by remote dispatch only and open a PR saying Closes #16401.
fix(mcpx): docs-twins trailing value flag is a usage error, not a panic
dezren39 commentedon Nov 28, 2026
Progress (lane 2037-A-F): PR #16406 open at head 8231e91 — parseFlags bounds-check + regression test for every value-taking flag in trailing position. Verifying by remote dispatch (fleet-command) on the exact head; will merge on SUCCESS.