Skip to content

fix: refuse --force on task/goal complete when stdin is not a terminal - #387

Merged
bborbe merged 4 commits into
masterfrom
fix/force-requires-tty
Nov 19, 2026
Merged

bborbe merged 4 commits into
masterfrom
fix/force-requires-tty

Conversation

@bborbe

@bborbe bborbe commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

vault-cli task complete --force and vault-cli goal complete --force now 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.

  • The guard runs in the CLI layer, before any vault is resolved, so a refused invocation cannot partially mutate a page.
  • It reuses the existing resolveSessionMode(ctx, "auto") TTY probe (pkg/cli/cli.go), so there is one detection path and no package-level mutable test seam. term.IsTerminal is required over os.Stdin.Stat(): /dev/null is a character device, so the ModeCharDevice check would silently report a TTY for < /dev/null.
  • topic complete deliberately 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.
  • A non-forced complete is unchanged: it still refuses an open-box page and lists the open items.

Behaviour

Invocation stdin Result
task complete X --force not a TTY (< /dev/null) exit 1, stdin is not a terminal, page unchanged
goal complete X --force not a TTY exit 1, stdin is not a terminal, page unchanged
task complete X --force a TTY (script -q /dev/null …) completes as before
task complete X (no --force) any unchanged — refuses an open-box page and lists the open items
topic complete --help any lists no --force

Tests

  • New pkg/cli/force_tty_test.go: both branches of the guard, the refusal end-to-end through cli.Run (whose stdin is the null device under go test), the unchanged non-forced path, and flag presence/absence on task/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 fail make test.
  • make precommit green.

Verification on the branch build

go build -C ~/Documents/workspaces/vault-cli-force-tty -o /tmp/vault-cli-branch ., run against a scratch vault:

Probe Result
task complete open-task --force < /dev/null exit 1, stderr stdin is not a terminal, page stays status: in_progress
goal complete open-goal --force < /dev/null exit 1, same message, page stays status: in_progress
task complete open-task (no --force) exit 1, incomplete subtasks: 1 pending, 0 in-progress — unchanged
topic complete --help | grep -c -- --force 0
script -q /dev/null … task complete open-task --force exit 0, page reads status: completed

The 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 printTaskCompleteResult extraction dropped result.Warnings on the refusal branch. Fixed in a follow-up commit, along with two hardening items (a wrapped error instead of a bare return 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.md carries a status: approved → verifying frontmatter 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

@bborbe
bborbe marked this pull request as ready for review November 19, 2026 04:52

@ben-s-pull-request-reviewer ben-s-pull-request-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bborbe
bborbe merged commit 5d0aa9d into master Nov 19, 2026
9 checks passed
@bborbe
bborbe deleted the fix/force-requires-tty branch November 19, 2026 06:52
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.

1 participant