beads/default.nix
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

44 lines
1 KiB
Nix

{
lib,
self,
buildGoModule,
git,
...
}:
buildGoModule {
pname = "beads";
version = "1.3.0";
src = self;
# Point to the main Go package
subPackages = [ "cmd/bd" ];
tags = [ "gms_pure_go" ];
doCheck = false;
# proxyVendor avoids vendor/modules.txt consistency checks when the vendored
# tree lags go.mod/go.sum.
proxyVendor = true;
vendorHash = "sha256-9OqMZK3wL838RGOXuOsKZvcyqk43tCmv75EUo+iqSVQ=";
# Match go.mod to the selected Nix Go toolchain. buildGoModule also builds
# vendored dependencies in the Nix sandbox, where toolchain downloads are not
# available.
postPatch = ''
goVer="$(go env GOVERSION | sed 's/^go//')"
go mod edit -go="$goVer"
'';
env.GOTOOLCHAIN = "local";
# Git is required for tests
nativeBuildInputs = [ git ];
meta = with lib; {
description = "beads (bd) - An issue tracker designed for AI-supervised coding workflows";
homepage = "https://github.com/gastownhall/beads";
license = licenses.mit;
mainProgram = "bd";
maintainers = [ ];
};
}