Add a shared runCommandBuffers helper for embedded subprocess tests so the PR keeps stdout/stderr separation without repeating buffer setup in every JSON-output test.
_codex-gpt-5- on behalf of matt wilkie_
The stdout/stderr split in 88e13542e applied uniformly to every helper
and inline call site, but bd commands write user-facing status messages
to stderr, not stdout:
- cmd/bd/bootstrap.go:543: "Created fresh database" -> stderr
- cmd/bd/bootstrap.go:610: "Imported %d issues" -> stderr
- cmd/bd/import.go:270: "Imported %d issues" -> stderr
After the split, bdImport and the bootstrap inline tests returned only
stdout, so `strings.Contains(out, "Imported 2 issues")` and friends saw
empty (or plan-only) output. CI shard 5 (TestEmbeddedBootstrap) and
shard 11 (TestEmbeddedImport) failed for this reason.
Fix: have bdImport return stdout+stderr concatenated (matches its
"Returns combined output" docstring) and have the two inline subtests
in TestEmbeddedBootstrap grep a combined buffer. JSON-parsing helpers
keep returning stdout-only as the original PR intended; this only
restores the prior CombinedOutput contract for non-JSON text greps.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR #3909 introduced an auto-export warning written to stderr. Tests that
called CombinedOutput() and then parsed the result as JSON would choke
on the warning text mixed into stdout.
Apply the pattern already established in list_embedded_test.go: for every
helper or inline call site that parses JSON or an ID from stdout, capture
stdout and stderr in separate bytes.Buffers and parse only stdout.
Covers 66 test files including duplicates, update, lint, todo, label,
count, swarm, close, list, status, types, find-duplicates, and more.
Closes TestEmbeddedDuplicates/dry_run and TestEmbeddedUpdate/update_json_output
failures from CI run 25967558419 and 25962887732.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(init): wire git origin as Dolt remote
Default bd init now treats a git origin as the Dolt remote, persists sync.remote, and still skips synthesis in --stealth. JSONL auto-export/import paths now warn or skip based on sync.remote so exports do not masquerade as cross-machine sync.
Docs and generated agent/CLI references now state that Dolt is canonical, refs/dolt/data is the sync channel, and .beads/issues.jsonl is export/interchange/backup only.
_codex-gpt-5-xhigh on behalf of maphew_
* test: keep embedded command stderr out of parsed stdout
Embedded command tests parse IDs and JSON from command output. The new auto-export warnings correctly go to stderr, but several tests used CombinedOutput and treated warnings as stdout, which broke CI shards that parse issue IDs or JSON lists. Capture stdout separately on success while preserving combined output for error diagnostics.\n\n_codex-gpt-5-medium on behalf of CI Bot_
---------
Co-authored-by: CI Bot <ci@beads.test>
* 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>
* fix(workspace): align resolved workspace messaging and config lookup
intent(workspace): pure worktrees and external BEADS_DIR setups should work without implying a local .beads directory is required
decision(config): derive config repo roots from FindBeadsDir-backed workspace resolution instead of a local-only .beads walk
constraint(workspace-detection): keep FindBeadsDir ordering and storage behavior unchanged while making bd where the primary diagnostic hint
learned(testing): shared-server env and global .beads ignore rules can distort CGO suites, so regression coverage now normalizes those test paths
* fix(bootstrap): align no-workspace JSON wording
intent(bootstrap): machine-readable no-workspace output should match the resolved-workspace guidance used elsewhere on this branch
decision(bootstrap-json): reuse the shared workspace error helpers through a dedicated payload builder so tests can lock the JSON contract
constraint(review-loop): keep the bootstrap CLI flow unchanged outside the no-workspace JSON branch while adding a focused regression test
* fix(where): allow no-workspace diagnostics without db (beads-9f74-5l1)
intent(where): no-workspace guidance should point to a command that actually runs when workspace resolution fails
decision(startup): treat top-level where as a no-db command so it reaches its own handler before database preflight
constraint(where-tests): subprocess mode can change the exact hint text, so the regression test locks the JSON contract and stable guidance fragments instead
* fix(bootstrap): restore bd where guidance for no-workspace output (beads-9f74-3c3)
intent(bootstrap): no-workspace bootstrap guidance should match the resolved-workspace diagnostics introduced on this branch
decision(no-workspace-hints): reuse the shared hint that mentions bd where instead of the bootstrap-specific fallback text
constraint(bootstrap-tests): cover both the payload helper and subprocess CLI path so wording regressions are caught before release
* fix(workspace): remove no-workspace .beads fallbacks (beads-9f74-gr1)
intent(workspace-resolution): finish the GH#3124 follow-up for runtime paths that still fabricated local .beads state
rejected(no-workspace-fallback): inventing ./ .beads paths outside an active workspace hid shared-worktree resolution and created stray files
decision(setup-recipes): keep built-in bd setup recipes usable without a workspace but require an active workspace for custom recipe state
constraint(worktree-support): completion and backup helpers still need to resolve shared main-repo workspaces from a git worktree
* fix(config): skip no-workspace store init for store-free commands
intent(config): review-fix-loop found no-workspace config commands should reach their own graceful paths instead of failing in PersistentPreRun
decision(config-preflight): detect store-free config subcommands before DB synthesis so config.yaml, git-backed, and diagnostic flows can run without an opened store
constraint(json-contract): keep bd config validate --json machine-readable on stdout once pre-run stops short-circuiting into low-level DB errors
learned(config-preflight): the parent config command not being in noDbCommands leaked store init into show, validate, drift, apply, and yaml-only config helpers
* fix(ci): restore init prefix normalization and formatting
intent(ci): clear the current PR failures instead of leaving the branch blocked behind known red checks
decision(init-prefix): normalize dotted prefixes before persisting issue_prefix so config, metadata.json, and Dolt database naming stay aligned for Julia-style repos
constraint(fmt-check): CI runs gofmt over the whole repo, so the existing spacing drift in internal/jira/tracker_test.go had to be cleaned up on this branch to get a green run
learned(ci): the latest main CI was already red on the same formatting file and the same embedded shard, so rebasing surfaced pre-existing blockers rather than introducing a new shard-only regression
* fix: resolve CI failures from flock, version bump, and lint
Three categories of CI failure on main after the v1.0.0 release:
1. rules.go lint/format: Fix gofmt alignment, errcheck on tw.Flush(),
gosec G304 (add nosec comment), gosec G306 (use 0o600 perms).
2. doctor_test.go version tracking: The 'slightly outdated version'
test used 0.55.0 which now has a major version diff from 1.0.0,
correctly triggering a warning. Update expected status to match.
3. Embedded Dolt concurrent tests: The exclusive flock from #2571
causes concurrent bd processes to fail with 'one writer at a time'.
Update 58 concurrent test files to tolerate this expected error
while still failing on unexpected errors and panics.
Amp-Thread-ID: https://ampcode.com/threads/T-019d5386-b41e-7138-bc81-6ea331b80760
Co-authored-by: Amp <amp@ampcode.com>
* fix: concurrent test post-conditions tolerate flock contention
With exclusive flock (commit 543e1943), only some workers can acquire
the lock in concurrent tests. Update post-conditions in 5 tests to:
- Only verify side effects from workers that succeeded (r.err == nil)
- Require at least 1 worker succeeds (fail if all hit flock)
- Log success/failure counts for visibility
- Still verify correct behavior for successful operations
Tests fixed:
- TestEmbeddedCloseConcurrent: remove Fatalf on failures, skip total count check
- TestEmbeddedDeferConcurrent: only check deferred status for successful workers
- TestEmbeddedUndeferConcurrent: only check open status for successful workers
- TestEmbeddedReopenConcurrent: only check open status for successful workers
- TestEmbeddedPromoteCLIConcurrent: only check permanent for successful workers
Amp-Thread-ID: https://ampcode.com/threads/T-019d5386-b41e-7138-bc81-6ea331b80760
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d5386-b41e-7138-bc81-6ea331b80760
Co-authored-by: Amp <amp@ampcode.com>
---------
Co-authored-by: Amp <amp@ampcode.com>