Commit graph

36 commits

Author SHA1 Message Date
Test User
1fc38ba778 feat: choose your own storage backend (Postgres / MySQL / SQLite) — rebased on main
Rebase of PR #4601 (feat/choose-your-own-backend) onto current origin/main,
squashed to a single commit because the original 73-commit history built and then
removed the uowStore derisk spike incrementally, which does not replay cleanly
over the 125 commits main has since advanced (notably #4679, the ready-work
counts fix, which merged to main and is now inherited rather than re-applied).
The full pre-rebase history remains on the original branch tip for reference.

Contents (multi-backend feature + the six review follow-ups):
- bd init --backend=postgres|mysql|sqlite provisioning behind the Dolt-parity
  seam; the three SQL backends share *sqlkit.Store over pluggable dialects and
  carry a generated typed-unsupported shell for the non-core surface.
- Passwords in init DSNs are redacted before persisting to metadata.json (driver
  parser + re-parse verification), with a negative-test matrix proving no secret
  survives (pgdialect + mysql).
- The uowStore derisk spike and its report artifacts are removed; the shell
  generator now lives in internal/storage/unsupportedgen (neutral name).
- Compile-time guard `var _ storage.DoltStorage = (*Store)(nil)` on each backend
  plus a regen-idempotence test keep the generated skip lists honest.
- sqlkit exposes CountReadyWork so every SQL backend satisfies
  storage.ReadyWorkCounter and inherits the shared page-pushed ready-counts path.
- Commercial/product names scrubbed from the feature's own code for vendor
  neutrality.

Rebase reconciliations: adopted main's metadata-load hardening in the store
factories alongside the backend dispatch; combined the config interface
(GetMetadata + ReconcileVersion) and the conformance registrations (ReadyCounts +
Claim/lease); took main's versions of the shared-infra concurrency (uow
doltserver_tx) and delete-cascade (domain/issue_delete) evolutions; implemented
the interface's new UnclaimIssue on sqlkit (delegating to issueops) and added it
to the skip lists.

Verified: go build (cgo + CGO_ENABLED=0) and go vet clean; unit tests
(sqlbuild/issueops/pgdialect/mysql/unsupportedgen) and the SQLite conformance
suite green (RunAll, incl. ReadyCounts equivalence and Claim/lease on the real
sqlkit backend).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 17:44:37 +00:00
Julian Knutsen
1914af5852
test(protocol): golden-JSON contract corpus + diff guard (Beads↔Gas City contract, Phase 2) (#4490)
* test(protocol): add canonicalized golden-JSON contract corpus + diff guard (contract Phase 2)

Producer half of the Beads<->Gas City cross-version contract-test system.
Generates a deterministic, canonicalized golden-JSON corpus of bd's --json
wire surface (create/show/list/ready/dep/count/version + the
{error,schema_version} envelope, in both flat and BD_JSON_ENVELOPE=1
variants) and fails on any unreviewed diff. Gas City vendors this corpus
to detect cross-version drift without a live bd.

- corpus.go: deterministic command plan, canonicalizer (timestamps -> <TS>,
  object arrays stable-sorted, sorted keys), provenance manifest.
- corpus_test.go: TestCorpusGolden (byte-compare vs committed corpus;
  -corpus.update regenerates; Dolt-boot is an infra skip, a diff is a hard
  fail). Pins IDs with --force for determinism; captures stdout only.
- canonicalize_test.go: canonicalizer unit tests + TestCorpusDoubleRunByteIdentical.
- make corpus-regen; cmd/bd/protocol/CATALOG.md.

Pre-commit hook bypassed: it fails in golangci-lint (built with Go 1.25,
repo targets 1.26.2) unrelated to this change; gofmt, go vet, and the full
corpus test suite were run manually and pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* ci: gate the contract corpus in beads CI (contract-corpus job)

Adds a Docker-enabled contract-corpus job to the PR gate that regenerates
the canonicalized golden corpus from this branch's bd and byte-compares it
to the committed testdata/corpus/, plus the determinism double-run. An
unreviewed bd --json wire change is now a hard CI failure on the producer
side, mirroring the gascity consumer gate. Wired into ci-gate/CI_GATE_REQUIRED.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(protocol): drop build-provenance from the corpus so it is reproducible across build envs

The contract-corpus CI gate caught a real reproducibility bug: bd version
--json embeds a 'commit' field from Go's VCS stamping that varies by build
environment (a local worktree build omits it; a CI clean-clone build embeds
the SHA), so the committed golden corpus failed the diff in CI. Canonicalization
now drops the 'commit' key entirely (value AND presence vary), and the manifest
no longer records bd_commit. bd_version plus the per-blob checksums remain the
reproducible provenance.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* ci: publish the contract corpus as a release artifact (contract Phase 3)

Ships cmd/bd/protocol/testdata/corpus as beads_<version>_contract_corpus.tar.gz
with each release and appends its checksum to the release checksums.txt, so Gas
City can anchor its vendored-corpus drift-check to a signed beads release rather
than a self-recomputed manifest. Runs in the goreleaser job before the macOS
job's serial checksums.txt append (goreleaser-macos needs goreleaser), so the
corpus entry is preserved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(protocol): extend the contract corpus to the full command surface

Adds update, close, reopen, delete, dep remove, and two more create beads to
the corpus plan, taking it to 17 commands x {flat, envelope}. New shapes pinned:
the update/close/reopen issue arrays (incl. close_reason + closed_at), the
dual-key dep edge {issue_id, depends_on_id, type, status} for add AND remove,
the delete confirmation {deleted, dependencies_removed, references_updated}, and
metadata coercion (--set-metadata phase=2 -> integer 2) plus label round-trip.
Mutations run after the show/dep_list reads so those long-standing blobs stay
byte-identical; list/ready/count now reflect post-mutation state. Golden +
double-run determinism verified.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(protocol): make the corpus version-agnostic (placeholder version/branch/build)

The contract-corpus gate failed when beads main bumped to 1.1.0-rc.1: the corpus
version.json pinned the literal bd version, which changes every release (CI builds
the PR merged with current main). The corpus pins wire SHAPES, not release
identity, so canonicalization now replaces version/branch/build values with
placeholders and the manifest drops bd_version/bd_commit entirely. schema_version
(the coordination canary) + per-blob checksums remain. gc's real version
parsing/gating is covered by the cross-version matrix + bd_version_pin_test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(protocol): satisfy build-tag policy + misspell lint for contract corpus

Pre-review CI repair for the golden-JSON contract corpus PR (#4490):

- Makefile: add -tags "$(BUILD_TAGS)" to the corpus-regen target so it
  passes scripts/check-build-tags.sh (ICU build-tag policy, see
  docs/ICU-POLICY.md), matching every other go test/build target.
- corpus.go: fix "re-marshalled" -> "re-marshaled" (misspell, US locale).

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

* fix(protocol): harden the contract corpus per maintainer review

Maintainer review fixups for the golden-JSON contract corpus (PR #4490),
folded into one maintainer commit across review iterations.

- CanonicalizeJSON now rejects trailing stdout after the first JSON value.
  A command that printed valid JSON followed by a warning line (or a second
  JSON value) would otherwise be silently truncated to the leading value and
  pass the corpus gate, while a real consumer decoding the whole stream would
  choke. Add regression tests for trailing text, multiple values, and the
  still-allowed trailing-whitespace case.
- TestCorpusGolden now asserts the committed corpus file set is exactly the
  generated blobs plus manifest.json, and `make corpus-regen` recreates each
  mode directory before writing. A capture removed or renamed in CorpusPlan can
  no longer leave a stale blob committed and shipped in the release archive.
- The required contract-corpus CI job sets BEADS_PROTOCOL_REQUIRE_DOLT=1 and
  the corpus tests hard-fail (not skip) when the Dolt store is unavailable, so
  the gate cannot report success without exercising the golden and double-run
  checks.
- Document the intentionally global (bare-key) scope of provenance
  canonicalization and the required future action if a non-version command adds
  a commit/version/branch/build field.
- Make the release corpus-checksum append idempotent so a re-run of the
  goreleaser job does not leave a duplicate row in checksums.txt.
- generateCorpus now pins each capture's subprocess exit status instead of
  discarding cmd.Run(): every capture must exit 0 except the dedicated error
  capture, which must exit non-zero with bd's not-found code. Otherwise the
  corpus could pass while a "successful" command exited non-zero, or while the
  error capture stopped failing, leaving the exit-codes-and-errors half of the
  error blob's contract (CATALOG.md) unpinned. Add a checkCaptureExit helper
  and TestCheckCaptureExit, and run the test in the required CI job.

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

---------

Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-04 18:54:28 -07:00
matt wilkie
a006a3369f fix(cli): implement children pretty and defer reason
Why: #4365 reports two documented CLI affordances that either fail or require a second command. children advertised --pretty but rejected it, and defer had no way to capture the reason at deferral time.

What: add the children --pretty flag by delegating to list's existing tree renderer, add defer --reason by appending to notes during the status update, and refresh generated CLI docs.

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of matt wilkie
2026-06-13 21:22:38 -07:00
Steven Syrek
f0057c7828
ci: install dolt binary on Linux and macOS test runners (#3440)
* ci: install dolt binary on Linux and macOS test runners

Install dolt via the official install.sh on Linux and via Homebrew on
macOS so the main test job can exercise the ~24 test gates that
previously silently skipped on every PR when dolt was absent from PATH.

Matches the installation pattern already used by nightly.yml.
Docker-testcontainer gates (testDoltServerPort == 0 skips) remain
skipped — a known GitHub Actions hang documented in
scripts/repro-dolt-hang/INCIDENT-REPORT.md and nightly.yml:37-41
prevents enabling testcontainers here.

* test: require dolt binary under GITHUB_ACTIONS

Add testutil.RequireDoltBinary: skips when the dolt CLI is absent
locally but fails the test under GITHUB_ACTIONS. Replace bare
exec.LookPath("dolt") skip-gates with the helper so ~24 tests that
previously fell through silently in CI now run — and hard-fail if
the CI workflow ever drops the dolt install step.

tests/regression/regression_test.go uses an inline variant because
its gate lives in TestMain, and internal/remotecache/cache_test.go
duplicates the helper inline to avoid an import cycle
(testutil -> doltutil -> remotecache).
2026-04-24 06:58:40 -07:00
Kevin Glynn
0d4b979354
feat: JSON schema contract, bd ping, structured errors, import enhancements (#3368)
* feat: add schema_version to all --json output (beads-5uh)

All bd commands that emit --json output now include a schema_version
field so consumers (Jawnt MCP, BeadsX, gt mail, sync scripts) can
detect format changes without silently breaking.

- Object output: schema_version injected as top-level field
- Array output: wrapped as {"schema_version": 1, "items": [...]}
- Error output: schema_version added to stderr JSON

Central implementation in outputJSON() via wrapWithSchemaVersion()
means all 272 call sites get the field automatically.

Includes:
- Unit tests for wrapping logic (object, struct, slice, nil, roundtrip)
- Updated protocol contract tests for new envelope format
- New schema_version presence test across list/ready/show
- docs/JSON_SCHEMA.md documenting the field contract per command

* feat: add ready/blocked JSON contract tests (beads-clt)

bd ready --json and bd blocked --json already return full issue objects
with dependency counts and blocked_by fields. Add protocol contract
tests to pin this behavior:

- TestJSONContract_ReadyOutputHasFullObjects: verifies dependency_count,
  dependent_count fields on ready items
- TestJSONContract_BlockedOutputHasBlockedBy: verifies blocked_by and
  blocked_by_count fields on blocked items

Update docs/JSON_SCHEMA.md with blocked output contract.

* feat: add bd ping lightweight health-check command (beads-8cc)

New minimal command that confirms bd can reach its database:
1. Resolves the .beads workspace
2. Opens the store (embedded or server)
3. Runs a trivial query (SearchIssues with Limit=1)
4. Reports timing breakdown

Supports --json for structured output with resolve_ms, store_ms,
query_ms, and total_ms fields. Exit 0 on success, 1 on failure.

Registered as read-only command (no auto-push, no file writes).
Includes protocol contract test for JSON output.

* feat: structured JSON errors on stderr when --json active (beads-06n)

All fatal error functions (FatalError, FatalErrorWithHint,
FatalErrorRespectJSON, FatalErrorWithHintRespectJSON) now emit
structured JSON with schema_version when --json is active:

  {"schema_version": 1, "error": "message", "hint": "optional"}

Centralized via jsonStderrError() and jsonStdoutError() helpers.
Replaces ad-hoc json.MarshalIndent calls scattered across error
functions with a consistent, schema-versioned format.

Includes unit tests and updated protocol contract test verifying
schema_version presence in error JSON output.

* feat: enhance bd import with stdin, --dedup, --json (beads-c6i)

Enhance the existing bd import command for bulk JSONL ingest:

- Stdin support: bd import - reads JSONL from stdin for piped workflows
- --dedup flag: skips lines whose title matches an existing open issue
  (case-insensitive) to prevent duplicate creation
- --json flag: structured output with created/skipped counts and IDs

Refactored import to use runImportFromReader() for unified file/stdin
handling. Added filterDuplicatesByTitle() for dedup logic. Updated
docs/JSON_SCHEMA.md with import output contract.

Backward compatible: existing bd import [file] and --dry-run work
exactly as before.

* fix: update tests for schema_version envelope in JSON output

Three test files expected raw JSON arrays or map[string]string, which
broke when schema_version (a number) was added to the output envelope:

- ado_test.go: parse envelope with items array instead of raw []json.RawMessage
- bootstrap_embedded_test.go: use map[string]interface{} for mixed types
- where_embedded_test.go: same map[string]interface{} fix

* fix: drop array envelope wrapping to fix 200+ test failures

The schema_version envelope was wrapping arrays as
{"schema_version": N, "items": [...]} which broke every integration
test that parses --json array output. Objects (show, create, ping)
still get schema_version injected. Arrays (list, ready, blocked)
now pass through unchanged for backwards compatibility.

Also fixes: gofmt on import.go, doc-flags reference to bd import,
uses importIssuesCore result to satisfy unparam lint.

* fix: update remaining tests for schema_version number field

config_embedded_test.go, kv_embedded_test.go, config_nodb_embedded_test.go,
and show_test.go all parsed JSON output into map[string]string but
schema_version is a number. Parse to map[string]interface{} and
skip/assert schema_version appropriately.

---------

Co-authored-by: kev <kglynn@pryoninc.com>
2026-04-20 21:09:48 -07:00
matt wilkie
66af62221e
fix(ci): drop ICU linkage from test jobs, use -tags gms_pure_go everywhere (#3240)
* fix(ci): drop ICU linkage from Linux/macOS test jobs (bd-sz5, GH#3506)

Align the CI test matrix with how we ship: all Go build/test invocations
now use -tags gms_pure_go, matching the Windows job, goreleaser, and the
install scripts. Remove libicu-dev / icu4c installs and CGO_* env setup
from ubuntu-latest and macos-latest jobs in ci.yml, plus nightly,
migration-test, and cross-version-smoke workflows.

Upstream dolthub/go-mysql-server#3506 confirmed -tags=gms_pure_go is the
sanctioned escape hatch; testing an ICU-linked config nobody installs was
wasting CI minutes and producing spurious duplicate-rpath / malformed
LC_DYSYMTAB linker warnings on macOS.

Update docs/ICU-POLICY.md to reflect that the CI matrix no longer
intentionally omits the tag; scripts/test-cgo.sh remains as the local
developer tool for exercising the ICU code path on demand.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(ci): add -tags gms_pure_go to test-helper go build shell-outs (bd-sz5)

Addresses review feedback on 7b36ab653. Several integration tests shell
out to `go build ./cmd/bd` (or `go build .`) from TestMain / t.Helper
setup functions. The outer `go test -tags 'integration gms_pure_go'`
tag does not propagate into these subprocesses, so the inner builds were
still trying to link ICU and failing with
`unicode/uregex.h: No such file or directory` in the nightly workflow.

Repo-wide audit of `exec.Command("go", "build", ...)` test helpers:
- internal/beads/beads_hash_multiclone_test.go (reviewer's cite)
- tests/regression/regression_test.go
- cmd/bd/protocol/helpers_test.go
- cmd/bd/doctor/dolt_e2e_test.go
- cmd/bd/{scripttest,import_prefix,explicit_db_nodb,init_embedded,
  main,init,cli_fast,shared_server_integration,doctor_repair,
  dolt_autostart_lifecycle_integration}_test.go

All 15 call sites now pass `-tags gms_pure_go`. `cmd/bd/preflight.go`
is production code (`bd preflight` user command), not a test helper,
and is intentionally left as-is.

Also narrow docs/ICU-POLICY.md "Common Mistakes" #3 -- libicu-dev is
needed only for local on-demand testing via scripts/test-cgo.sh, not
for CI test workflows (which no longer exercise the ICU path).

Verified: `go test -tags 'integration gms_pure_go' -run '^$' ./...`
passes cleanly from the worktree root (previously failed in
internal/beads).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(preflight): add -tags gms_pure_go to test/lint shell-outs (bd-sz5)

preflight is a beads-maintainer pre-PR tool. On dev machines without
ICU dev libraries installed, `bd preflight --check` was failing at the
`go test -short ./...` step with the same `unicode/uregex.h` error we
fixed in nightly CI (bd13871bd).

Apply the gms_pure_go tag consistently:
- runTestCheck: `go test -tags gms_pure_go -short ./...`
- runLintCheck: `golangci-lint run --build-tags=gms_pure_go ./...`
- Update the user-visible Command labels to match
- Update the static checklist printed by `bd preflight` (no --check)
  so copy-pasted commands work on no-ICU machines

Matches the tag golangci-lint is now passed in CI, keeping local and
CI runs consistent.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 10:01:46 -07:00
lizzy
9dc875a98e feat: add --list and --doc flags to bd help for CLI doc generation (GH#2527)
Cherry-pick Go code from community PR #2527 (maphew): adds --list flag to
enumerate all commands, --doc flag to generate per-command Docusaurus markdown,
and sidebar position mapping. Also includes lazy getGitContext() in hooks dir
resolution and test skip improvements for missing Dolt server.

Co-authored-by: matt wilkie <maphew@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 18:25:40 -07:00
beads/crew/jane
43bca275bf feat: JSON-aware error output + JSONL schema validation + contract tests (GH#2499)
- FatalError and FatalErrorWithHint now output structured JSON to stderr
  when --json flag is active, preventing mixed text/JSON output
- bd restore validates issues.jsonl schema before importing, catching
  incompatible export formats early (GH#2492)
- Add restoreResult.Errors and ErrorDetails fields for structured error reporting
- Add 6 JSON contract regression tests for list, show, create, close,
  ready, and error output contracts

Co-Authored-By: matt wilkie <maphew@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 17:33:53 -07:00
beads/crew/emma
84494b7e1a cleanup: remove daemon infrastructure remnants (GH#2431)
Remove all BEADS_NO_DAEMON env var handling from test files (dead code
since daemon removal in v0.50.0), delete stopRepoDaemon() and daemon
file guards from test setup, remove no-daemon config key from tests,
and update daemon→server wording in docs and comments.

37 files changed, -193 lines net.

Co-Authored-By: davetashner <davetashner@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:24:27 -07:00
matt wilkie
cf9f78d964 fix: TestProtocol_FieldsRoundTrip timezone-aware date assertions
Date-only inputs (--due 2099-03-15) are parsed as local midnight and stored
as UTC. In west-of-UTC timezones, the UTC date rolls back one day. The test
now computes the expected UTC prefix from the local date instead of
hardcoding the input date string.

Fixes #2371

Amp-Thread-ID: https://ampcode.com/threads/T-019cc486-ad63-76ea-9f02-2901e2430428
Co-authored-by: Amp <amp@ampcode.com>
2026-03-06 14:48:47 -07:00
beads/refinery
cd033d5cce Merge remote-tracking branch 'origin/polecat/obsidian/bd-m7sy@mmaw77ig' 2026-03-03 11:06:21 -08:00
beads/refinery
c8f61cb208 fix(tests): align tests with cross-type blocking validation
- Protocol tests: use `comments add` instead of nonexistent `comment` command
- critical_paths_test: use epic (not task) for epic-blocks-epic relationship
- template_test: use DepRelated instead of DepBlocks for cross-type "wrong dep"
  scenarios, since cross-type blocking is now rejected by storage validation

Fixes tests broken by the cross-type blocking validation added in GH#1495.

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

Executed-By: beads/refinery
Rig: beads
Role: refinery
2026-03-03 11:05:50 -08:00
obsidian
3872308568 refactor(tests): migrate all test files from StartTestDoltServer to container-native API
Migrate 12 TestMain files to use EnsureDoltContainerForTestMain/TerminateDoltContainer
instead of the removed StartTestDoltServer/TestDoltServer API.

Replace testServer.IsCrashed()/CrashError() crash detection with standalone
testutil.DoltContainerCrashed()/DoltContainerCrashError() in 6 test files.

(bd-m7sy)
2026-03-03 10:07:32 -08:00
quartz
801965ae2d feat(test): parallelize protocol tests for 3x speedup (bd-dgp)
Add t.Parallel() to all 45 top-level test functions in cmd/bd/protocol.
Each test already creates a fully isolated workspace (unique Dolt prefix,
temp dir, git repo) so parallelization is safe. Reduces test time from
~135s to ~42s on the same machine.

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

Executed-By: beads/polecats/quartz
Rig: beads
Role: polecats
2026-02-27 20:04:00 -08:00
darcy
fb8ca5fc90 fix: resolve gofmt and golangci-lint CI failures
- gofmt: 7 files had formatting issues (dolt.go, close_guard_test.go,
  init_hooks_test.go, discovery_test.go, types.go, metadata_schema_test.go,
  testdoltserver.go)
- gosec G304: suppress false positives for os.ReadFile on trusted paths
  (daemon PID files, test cleanup)
- gosec G104: handle Close() return values with _ = pattern
- errcheck: wrap os.RemoveAll in defer closure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 13:31:06 -08:00
onyx
6a21757419 fix(init): use prefix directly as database name instead of beads_ prefix
bd init --prefix was creating databases named beads_<prefix> (e.g.,
beads_sky, beads_gt). Convention should use the rig name directly as
the database name. This aligns with gastown doltserver.go which
already uses just the rig name.

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

Executed-By: beads/polecats/onyx
Rig: beads
Role: polecats
2026-02-24 14:57:01 -08:00
obsidian
765ac3c481 refactor(protocol): split protocol_test.go monolith into thematic files
Remove the 45KB monolithic protocol_test.go and distribute its contents:
- helpers_test.go: TestMain, workspace, build helpers, assertion utilities
- roundtrip_test.go: field/metadata/spec/label create→show round-trips
- preservation_test.go: data survives updates, status transitions, deletes
- blocking_semantics_test.go: ready ordering, diamond deps, transitive chains
- close_guard_test.go: close guard, cycle prevention, supersede, force close

All 45 protocol tests pass. Closes GH#2041.

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

Executed-By: beads/polecats/obsidian
Rig: beads
Role: polecats
2026-02-24 14:25:54 -08:00
Joseph Turian
5f0b3befa7 feat(protocol): lane 6 — 10 new protocol invariant tests
Pin down stable CLI behavior as permanent guardrails:
- Cycle prevention (blocks chain, self-dependency)
- Close guard (respects dep types, blocks for deps, --force override)
- Deferred excluded from ready, restored by undefer
- dep rm unblocks issue
- Supersede creates dep and closes
- Status transitions preserve labels and comments
- Label add/remove round-trip

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-24 12:27:05 -08:00
mayor
83a02d8c89 fix: protocol tests now use isolated Dolt server instead of prod
Protocol tests were the source of ~35 beads_t* databases on the prod
Dolt server per test run. Each test called bd init with a random prefix
(t + 8 hex chars), creating beads_t<hex> databases on port 3307.

- Add TestMain to protocol tests that starts a dedicated test Dolt server
- Pass BEADS_DOLT_PORT and BEADS_TEST_MODE through workspace env() so
  the compiled bd subprocess connects to the test server
- Add beads_t to staleDatabasePrefixes in both dolt.go and doctor/server.go
  as a safety net for cleaning legacy pollution

Verified: full go test ./... now creates zero test databases on prod.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 23:07:39 -08:00
topaz
2345c82125 fix: rewrite protocol tests to use bd show --json instead of deleted bd export
The bd export command was removed in commit 1e1568fa as part of the
JSONL-to-Dolt-native refactor, breaking 11 protocol tests. Rewrite all
affected tests to verify data persistence via bd show --json instead of
export roundtrip. Remove unused parseJSONLByID helper.

Fixes: beads-iyu

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

Executed-By: beads/polecats/topaz
Rig: beads
Role: polecats
2026-02-23 20:34:24 -08:00
jasper
3a0e582735 fix: isolate protocol tests with unique per-test Dolt databases
Each newWorkspace() now generates a random prefix (e.g. "t1a2b3c4d")
instead of the shared "test" prefix, so each test gets its own database
(beads_t<random>) on the shared Dolt server. This prevents cross-test
pollution where tests see issues from other concurrent or prior test runs.

Fixes: beads-sqv

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

Executed-By: beads/polecats/jasper
Rig: beads
Role: polecats
2026-02-23 20:29:17 -08:00
beads/crew/wickham
67042744b1 fix: include waits-for deps in bd blocked output (GH#2043)
GetBlockedIssues only checked 'blocks' dependencies, making waits-for
gated issues invisible to bd blocked. Now uses computeBlockedIDs (which
handles both dep types with full gate evaluation) as the canonical
source of truth for blocked status.

Based on PR #2043 by @turian.

Co-Authored-By: Joseph Turian <turian@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:08:25 -08:00
turian
2276c5fa13 fix: report correct status when reopen/undefer is a no-op (GH#2037)
bd reopen on an already-open issue now prints "already open" to stderr
and skips instead of printing a false "Reopened" message. bd undefer on
a non-deferred issue now prints "not deferred" and skips similarly.

Authored-by: turian <turian@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:08:12 -08:00
beads/crew/jane
3ef50b867d fix: validate status on update against built-in + custom statuses (#2021)
bd update --status previously accepted any string silently, while
bd create validated against built-in + custom statuses. This adds the
same validation to update, rejecting invalid status values with a
helpful error message.

Co-Authored-By: Joseph Turian <turian@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:05:17 -08:00
beads/crew/wickham
13190efbcc fix: reject empty title and empty label on update/label add (GH#1994)
- `bd update <id> --title ""` now errors instead of silently blanking
- `bd update <id> --title "   "` (whitespace-only) also rejected
- `bd label add <id> ""` now errors instead of adding empty label
- Values are trimmed before storage, not just for validation
- Includes fix for pre-existing doctor file formatting

Based on PR #1994 by @turian.

Co-Authored-By: Joseph Turian <turian@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:05:06 -08:00
beads/crew/lydia
d22095501e fix: exit non-zero when all close/update attempts fail (GH#2014)
bd close and bd update now exit 1 when all attempted operations fail
(e.g., closing a blocked issue, updating a nonexistent ID). Partial
success (some closed, some failed) still exits 0.

Adds protocol tests for exit code behavior.

Co-Authored-By: Joseph Turian <turian@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:04:06 -08:00
Steve Yegge
72e6c7468a
docs: clarify --status flag filters stored status, not dependency blocking
docs: clarify --status flag filters stored status, not dependency blocking
2026-02-23 10:02:03 -08:00
Steve Yegge
df47a96d38
fix: warn when bd defer --until date is in the past
fix: warn when bd defer --until date is in the past
2026-02-23 10:01:52 -08:00
Steve Yegge
fae207e117
fix: reject empty and whitespace-only comment text
fix: reject empty and whitespace-only comment text
2026-02-23 10:01:50 -08:00
Joseph Turian
f4a858c3df fix: warn when bd defer --until date is in the past
bd defer --until=<past date> silently stored the past date, while
bd update --defer=<past date> already warns. Add the same past-date
warning to bd defer for consistency.

The warning matches the existing update path: prints to stderr and
suggests future-oriented alternatives (+1h, tomorrow).

Includes protocol test verifying the warning appears.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 04:54:06 -05:00
Joseph Turian
d3e581bc0b fix: reject empty and whitespace-only comment text
bd comments add accepted empty ("") and whitespace-only ("   ") text,
silently creating blank comments. Now validates with strings.TrimSpace
before storing, consistent with the empty-title validation on update.

Includes protocol test verifying both empty and whitespace-only text
are rejected with a non-zero exit code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 04:52:58 -05:00
Joseph Turian
c9fabf2ba9 fix: reject non-positive --days flag on bd stale
bd stale --days 0 and --days -1 silently returned no results instead of
reporting an error. Add early validation (days < 1 → FatalError) to
match the existing status validation pattern in the same command.

Includes a protocol test that verifies both --days 0 and --days -1 are
rejected with a non-zero exit code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 04:44:01 -05:00
beads/crew/emma
68be32ac65 fix: CI formatting, lint, and test failures blocking release
- Fix gofmt alignment in cmd/bd/repo.go
- Replace panic with sentinel port (port 1) in applyConfigDefaults when
  BEADS_TEST_MODE=1 without BEADS_DOLT_PORT, preventing CI crashes while
  still guarding against accidental production connections
- Add dolt availability skip in protocol_test.go newWorkspace
- Remove stale //go:build cgo tag from molecules_test.go
- Change Fatalf to Skipf for Dolt connection failures in molecule loader tests
- Update store_unit_test.go to match sentinel port behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:10:38 -08:00
Joseph Turian
e2ded3a38e test(protocol): split blocked-status test into separate file
Move BUG-4 test from protocol_test.go into
blocked_status_test.go with proper TestProtocol_ naming.

- TestProtocol_BlockedStatusIsStoredNotComputed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 23:47:56 -05:00
Joseph Turian
0af9580a35 docs: clarify --status flag vs bd blocked for dependency blocking (BUG-4)
The --status flag filters by the stored status column, but dependency-
blocked issues keep status "open" — they only appear via 'bd blocked'.
The old help text listed "blocked" without explaining this distinction,
leading users to expect 'bd list --status blocked' to find dependency-
blocked issues.

Updated help text for list, count, search, and query to say "stored
status" and point to 'bd blocked' for dependency-blocked issues.

Adds TestBUG4_BlockedStatusVsBlocked protocol test documenting the
distinction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 22:48:27 -05:00
Joseph Turian
b4d0aa7d1b
test: protocol invariant suite for data integrity and blocking semantics (#1910)
12 protocol invariant tests that guard against re-regression of fixed bugs:
- ImportPreservesRelationalData (labels, deps, comments) — #1844
- ReadyOrderingIsPriorityAsc — #1880
- MetadataRoundTrip, SpecIDRoundTrip — #1912
- FieldsRoundTrip, CloseReasonRoundTrip
- DeleteCleansUpDeps
- Labels/Deps/CommentsPreservedAcrossUpdate
- ParentChildDepExportRoundTrip (SKIP, #1926)
- ClosedBlockerNotShownAsBlocking — #1858

Each test runs in isolated t.TempDir() workspace with its own git repo.
Set-based comparisons with clear missing/unexpected diffs on failure.

Remove //go:build cgo tag (CGO bifurcation removed in c4010c19).
2026-02-22 15:29:27 -08:00