Repository navigation
fix: refuse --force on task/goal complete when stdin is not a terminal - #387
Conversation
There was a problem hiding this comment.
The guard is implemented as specified: requireForceFromTerminal runs before getVaults in both task complete and goal complete, is bound to the --force flag closure, derives interactivity solely from term.IsTerminal(os.Stdin.Fd()) (no env/config/--mode influence), refuses fail-closed, and leaves the vault untouched; the printTaskCompleteResult extraction preserves warnings in both branches with os.Stdout as the sole call site. No blocking defect found — remaining items are a stale plugin-command doc that still advertises --force for an agent (which has no TTY), a lost end-to-end accept-at-TTY spec, an overstated doc comment, and one bare return err.
Judgment tier: selector ran (52 candidates, 12 applicable, 40 skipped; mechanical funnel findings all refuted on inspection).
Intent: unavailable — gh is not permitted in this sandbox and no --intent/--pr argument was supplied; scope was cross-checked against the repo's own prompts/completed/284-* and 285-* records instead.
Summary
vault-cli task complete --forceandvault-cli goal complete --forcenow refuse to run when stdin is not a terminal: exit 1, a message naming "stdin is not a terminal", and the page left byte-identical. An operator at a terminal keeps the override.resolveSessionMode(ctx, "auto")TTY probe (pkg/cli/cli.go), so there is one detection path and no package-level mutable test seam.term.IsTerminalis required overos.Stdin.Stat():/dev/nullis a character device, so theModeCharDevicecheck would silently report a TTY for< /dev/null.topic completedeliberately gains no--force: it has no close-out gate for the flag to override, and a placeholder flag would be worse than none. A spec asserts the flag stays absent.completeis unchanged: it still refuses an open-box page and lists the open items.Behaviour
task complete X --force< /dev/null)stdin is not a terminal, page unchangedgoal complete X --forcestdin is not a terminal, page unchangedtask complete X --forcescript -q /dev/null …)task complete X(no--force)topic complete --help--forceTests
pkg/cli/force_tty_test.go: both branches of the guard, the refusal end-to-end throughcli.Run(whose stdin is the null device undergo test), the unchanged non-forced path, and flag presence/absence ontask/goal/topic complete.integration/cli_test.go: the existing spec that asserted a forced complete exits 0 is replaced by one asserting the refusal and that the task file is left byte-identical — it would otherwise failmake test.make precommitgreen.Verification on the branch build
go build -C ~/Documents/workspaces/vault-cli-force-tty -o /tmp/vault-cli-branch ., run against a scratch vault:task complete open-task --force < /dev/nullstdin is not a terminal, page staysstatus: in_progressgoal complete open-goal --force < /dev/nullstatus: in_progresstask complete open-task(no--force)incomplete subtasks: 1 pending, 0 in-progress— unchangedtopic complete --help | grep -c -- --force0script -q /dev/null … task complete open-task --forcestatus: completedThe pty row is the one branch no unit test covers (a pty is not allocated in
go test); it is verified here and again on the installed binary after release.Review round
Local pre-PR review found one real defect in the first commit: the
printTaskCompleteResultextraction droppedresult.Warningson the refusal branch. Fixed in a follow-up commit, along with two hardening items (a wrapped error instead of a barereturn err, and a non-forced test that now asserts unconditionally). The reviewer also flagged the plugin command docs still advertising--force— that is out of scope for this task and tracked separately.Out of scope
The plugin command docs (
commands/complete-task.md,commands/complete-goal.md) still advertise--force; that is tracked separately in "Managers and Goal Commands Close Through the vault-cli Verb Only".Unrelated line in the diff
specs/in-progress/067-bug-parked-exit-requires-registered-watch.mdcarries astatus: approved → verifyingfrontmatter transition written by dark-factory's own spec sweep at daemon startup, not by this change. Left in rather than reverted so the pipeline's state stays consistent with what the daemon recorded.Task: 0c6d9e9d-0cec-4ffe-9cba-878f65160aa0