Summary
scripts/worker-preflight.sh is an operator script invoked at the start of worker tasks (see root AGENTS.md, "Worker Git preflight"). It takes no arguments, but it does not declare or enforce that contract: extra positional arguments are silently ignored and the script proceeds as if invoked correctly.
Evidence
On origin/main (e77ed212644298222326837e36c5771d3a05d0e2 at time of check), in /home/user/git/code:
$ bash scripts/worker-preflight.sh extra-arg
worker-preflight: clean (/home/user/git/code; no local refs/heads/origin/main)
$ echo $?
0
scripts/worker-preflight.sh (24 lines) performs its checks and exits 0/1/2 based on repo state, but never validates $#. Any stray or misspelled argument is accepted without notice.
Why it matters
doc/agents/operator-script-argument-contract.md and root AGENTS.md ("Operator script argument contract #3352") require every operator script to declare its whole command line and parse strictly against that declaration before any subprocess, network, file write, lock, or deploy step; anything unaccounted for is a usage error with a non-zero exit. Worker preflight is a guardrail script workers run before relying on Git names — silently accepting unexpected arguments weakens that contract and can hide invocation mistakes.
Suggested fix / acceptance criteria
- Reject any unaccounted argument(s) with a clear usage error on stderr and exit code 2 (usage error), before performing preflight checks or emitting the success/clean message.
- Document the accepted command line in the script header comment (no arguments).
- Preserve existing behavior and exit codes for valid invocations: exit 0 when clean, exit 1 when
refs/heads/origin/main shadows the remote-tracking ref, exit 2 when not in a Git worktree or ref verification cannot be completed.
- Add/adjust a small regression check (shell test or existing test harness convention for
scripts/worker-preflight.sh, if present) asserting that an extra argument is rejected with non-zero/usage status and does not print the clean success message.
References