beads/cmd/bd/protocol
Steve Yegge 45b62e47b5
test(protocol): pin §E3 exit 11 with a PTY harness (wy-vh5y8) (#4762)
* test(protocol): pin §E3 exit 11 with a PTY harness (wy-vh5y8)

Exit 11 (ExitLocalExistsRefused) is returned only from the interactive
typed-confirmation abort in `bd init --reinit-local` (cmd/bd/init.go, behind
term.IsTerminal on stdin); the non-interactive branch of the same guard returns
12, so no piped-stdin subprocess could produce 11. WP4 (wy-ge2h8) therefore
left TestProtocol_ExitCode11_LocalExistsRefused skipped.

Un-skip it with a PTY-backed run: allocate a pty (creack/pty, a test-only dep
already in go.sum), drive `bd init --reinit-local` against a workspace seeded
with one issue, answer the "Type 'destroy N issues' to confirm:" prompt with
the WRONG text, and assert exit 11 — distinct from the 12 a bad --destroy-token
yields. Also asserts the abort is a no-op (the seeded issue survives). Windows
skips (no unix PTY).

creack/pty is imported only from _test.go, so it is a test-only dependency; no
new non-test dependency enters go.mod.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(build): register github.com/creack/pty with Bazel and Nix

The exit-11 PTY test imports github.com/creack/pty, a new direct
require in go.mod. The base's generated build manifests predate it:

- Bazel (`make bazel-sync`): //cmd/bd/protocol:protocol_test failed
  "missing strict dependencies" on the import, and go_deps reported
  com_github_creack_pty missing from use_repo. The sync adds it to
  MODULE.bazel's use_repo and adds @com_github_creack_pty//:pty to
  protocol_test's deps. protocol_race_off, protocol_docker_test and
  protocol_dolt_test all wrap protocol_test, so that one deps line
  covers them. Running the same sync on the base changes nothing.
- Nix: default.nix sets proxyVendor = true, so vendorHash covers the
  module download set of go.mod's requires, and the new require
  changes it. Regenerated via the nixos/nix container: the go-modules
  fixed-output derivation now builds with no hash mismatch, and the
  unwrapped package compiles cmd/bd.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(protocol): fix exit-code header, name a skipped reinit prompt

Review fixups, adopt-pr review loop iteration 1 (synthesis approve,
scorecard 981/1000, no blocker or major findings).

Taken:
- Header (Finding 2): it said all three refusal codes (10/11/12) refuse
  before bd opens any store. That stopped being true once exit 11 ran:
  its typed confirmation fires only after --reinit-local counts the
  issues in a seeded workspace, so that test pays for a full store, as
  130 does. The header now says 10 and 12 are store-free and 11 and 130
  are not.
- Prompt-skip diagnostic (Finding 3): runInitReinitPreflight skips the
  confirmation, with no warning, when countExistingIssues errors (it
  has its own 5s timeout) or counts zero. The review expected that skip
  to exit 0 in the early-exit arm. A mutation run with the seed issue
  dropped shows it does not: the reinit goes on and blocks at init's
  next TTY prompt, "Change role? [y/N]:", so the test fails at the
  prompt deadline. The deadline arm now names the skip when the output
  lacks the "Re-initializing will destroy" warning. Failure path only.

Declined:
- Shared prompt harness (Finding 1): extracting it rewrites the
  base-owned 130 test (pipes, SIGINT, t.Parallel) into a new helper
  after review. The synthesis allows accepting the duplication in the
  reply to the reviewer instead.
- Redundant "!= 12" check (Finding 4): it mirrors the 12 test's own
  "codes must stay distinct" check, so the tests keep one idiom.

Validation: gofmt and go vet are clean. TestProtocol_ExitCode10/11/12/130
pass against the dolthub/dolt-sql-server:2.2.0 test container with
BEADS_PROTOCOL_REQUIRE_DOLT=1, so exit 11 ran rather than skipped. The
seed-dropped mutant fails with the new message.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-06 23:06:06 +00:00
..
testdata/corpus Merge release/1.3.0 into main (post-tag forward-port) 2026-09-15 22:09:13 +00:00
assignee_test.go test(protocol): pin data-model + ready-front production-scar clauses (wy-nzybu) 2026-07-13 09:46:16 -07:00
blocked_status_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
blocked_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
blocking_semantics_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
BUILD.bazel test(protocol): pin §E3 exit 11 with a PTY harness (wy-vh5y8) (#4762) 2026-10-06 23:06:06 +00:00
canonicalize_test.go test(protocol): make corpus determinism pure (bd-qq1qn) (#5281) 2026-08-02 07:14:30 -07:00
CATALOG.md Merge remote-tracking branch 'upstream/main' into pr-4232-fix 2026-07-13 20:43:10 -07:00
child_id_test.go test(protocol): pin data-model + ready-front production-scar clauses (wy-nzybu) 2026-07-13 09:46:16 -07:00
children_test.go fix(cli): implement children pretty and defer reason 2026-06-13 21:22:38 -07:00
close_guard_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
comments_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
corpus.go fix(contracts): JSON contract fixes before 1.3.0 freezes them — string revision tokens, --set-metadata scalar typing, create --json nano timestamps (#6053) 2026-08-29 05:20:27 +00:00
corpus_test.go test(protocol): make corpus determinism pure (bd-qq1qn) (#5281) 2026-08-02 07:14:30 -07:00
defer_test.go fix(cli): implement children pretty and defer reason 2026-06-13 21:22:38 -07:00
dep_identity_test.go test(protocol): pin data-model + ready-front production-scar clauses (wy-nzybu) 2026-07-13 09:46:16 -07:00
errors_contract_test.go test(protocol): pin §E/§M/§V conformance clauses at the CLI level (wy-ge2h8) 2026-07-13 10:30:24 -07:00
exit_codes_init_test.go test(protocol): pin §E3 exit 11 with a PTY harness (wy-vh5y8) (#4762) 2026-10-06 23:06:06 +00:00
exit_codes_test.go Beads #6648: report partial batch-close failure (#6740) 2026-09-26 13:55:44 -07:00
helpers_test.go test(testutil): opt-in local dolt sql-server backend for Dolt-backed tests (#6891) 2026-09-28 04:06:49 -07:00
input_validation_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
interchange_test.go test(protocol): pin the §J interchange clauses; fix the bd import header gap (wy-ltox1) 2026-07-13 11:20:06 -07:00
json_contract_test.go fix(show): flag comment_count as omitted when comments are not streamed (#4865) 2026-07-25 16:16:41 -07:00
lease_claim_test.go test: fix red main — init-cancel E2E deadline + reclaim JSON assertion (#5039) 2026-07-25 10:10:18 -07:00
lifecycle_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
memory_contract_test.go test(protocol): pin §E/§M/§V conformance clauses at the CLI level (wy-ge2h8) 2026-07-13 10:30:24 -07:00
preservation_test.go test(protocol): realign show --json contract tests with count-only payload (wy-017ry) 2026-07-13 10:08:34 -07:00
ready_front_test.go test: make ready ordering setup deterministic (bd-y9cjq) (#5238) 2026-08-01 09:55:11 -07:00
roundtrip_test.go test(protocol): realign show --json contract tests with count-only payload (wy-017ry) 2026-07-13 10:08:34 -07:00
stale_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
status_validation_test.go feat(test): parallelize protocol tests for 3x speedup (bd-dgp) 2026-02-27 20:04:00 -08:00
versioning_contract_test.go test(protocol): pin §E/§M/§V conformance clauses at the CLI level (wy-ge2h8) 2026-07-13 10:30:24 -07:00
wp4_helpers_test.go test(protocol): pin §E/§M/§V conformance clauses at the CLI level (wy-ge2h8) 2026-07-13 10:30:24 -07:00