TestExportMemoryDeterminism (GH#3474) proves only memory lines are
stable. This generalizes the invariant from gh beads 3787: running
`bd export` repeatedly over unchanged data must produce byte-identical
output for every record type, not just memories.
The new test seeds issues at the same priority and creation time (so the
export ORDER BY must fall through to the id tiebreaker — the total-order
property the determinism guarantee depends on), each with multiple
labels, parent-child dependencies, and comments, plus several memories
keyed out of sorted order. It exports five times and asserts every run
is byte-identical, then sanity-checks that each record type was actually
present so a future change can't make the stability assertion pass
vacuously.
Catches any future collection serialized without a stable total order
(Go's randomized map iteration being the usual culprit) before it ships,
rather than spot-fixing per record type.
_claude-opus-4-7-medium on behalf of matt wilkie_
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Skip auto-export before writing when the current export would contain no issue records but the target JSONL already contains issues. This prevents an opt-in auto-export from deleting the only visible issue export in empty-DB migration/recovery scenarios.
Add JSONL issue counting coverage and a subprocess regression that preserves a populated export target when a memory-only write triggers auto-export.
Fixes GH#4033.
_codex-gpt-5.5-medium on behalf of matt wilkie_
* fix(init): make JSONL auto-export opt-in
Default export.auto and export.git-add to false for new repos, make the init prompt opt-in, and update docs/tests to describe JSONL as an optional viewer/interchange/backup export rather than core sync behavior.
Fixes GH#4062
* refactor(auto-export): check commit before throttle
Move cheap Dolt commit change detection ahead of the auto-export throttle and extract the throttle decision into a tested helper. This keeps the default-off design while carrying the compatible part of Jeremy Longshore's GH#4061 refactor.
Based-on: 313e1f8258
Co-authored-by: jeremylongshore <jeremylongshore@users.noreply.github.com>
* docs: regenerate versioned CLI references
* docs: call out JSONL export opt-in change
---------
_codex-gpt-5.5-medium on behalf of CI Bot_
_codex-gpt-5.5-high on behalf of matt wilkie_
Co-authored-by: CI Bot <ci@beads.test>
* test: prevent Cobra command flag cache races
* chore: release gate PASS for be-psutr9 (cobra/pflag race-fix)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs(gate): update be-psutr9 gate — re-review PASS (be-mouz), fix stale file list
Re-review be-mouz confirmed PASS on current HEAD 1b5536624. Correct files
changed: stdio_race_guard_test.go + test_helpers_pure_test.go only (earlier
version listed notion_test.go/stale_test.go which are no longer in the diff).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: address PR review findings (bd-wrntbm)
---------
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(dolt): adopt git origin on first push
bd dolt push now wires an existing git origin when no Dolt remote is configured, while init without origin stays local and doctor shows the concrete adoption command. This keeps refs/dolt/data sync discoverable without treating plain remotes as existing Dolt history.\n\n_kilocode-openai/gpt-5.5- on behalf of maphew_
* fix(dolt): address origin adoption review nits
Share Dolt remote URL normalization between the push adoption path and doctor guidance, fail before mutating Dolt state when no beads workspace is selected, and cover CheckRemoteConsistency's adoption detail.
_codex-gpt-5-medium on behalf of maphew_
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>
Capture stdout and stderr separately in the embedded update JSON-output test.
Validate only stdout as JSON so post-run stderr advisories do not contaminate the parsed output.
`bd update <id> --external-ref ""` was writing an empty string into the
`external_ref` column instead of SQL NULL. The CLI builds an `updates`
map with `updates["external_ref"] = ""` and passes it straight through
to the storage layer, where `args = append(args, value)` sends the
empty string to the SQL driver verbatim.
`bd create` already handles this correctly: `buildCreateIssue` converts
an empty `ExternalRef` string to a nil `*string`, so newly created
issues round-trip as NULL when no ref is given. The update path didn't
mirror that conversion, leaving the database with two semantically
different "no external ref" states.
Downstream consequences:
- `internal/tracker/engine.go` treats `localIssue.ExternalRef == nil`
as "not linked" but compares the empty string as a real value, so a
cleared ref looked like a link to a non-existent record.
- `types.Issue.ExternalRef` is `*string` with `json:",omitempty"`, so
cleared issues emitted `"external_ref":""` while never-set issues
omitted the field entirely.
- The historical UNIQUE-constraint repro in #3902 only didn't fire
today because the SQLite backend that had the constraint was
removed; the empty-string semantic mismatch was the durable bug.
Fix in `cmd/bd/update.go`: when `--external-ref` is set to "", store
nil in the updates map, which the SQL driver translates to NULL.
Defensive fix in `internal/storage/dolt/ephemeral_routing.go`:
`applyUpdatesToIssueStruct` (used on wisp/no_history flips) previously
ignored a nil value because the `value.(string)` type assertion failed
silently, leaving the in-memory `ExternalRef` at its prior value.
Handle nil explicitly so the wisp-flip path agrees with the regular
update path.
Test: new `update_external_ref_clear` subtest in
`cmd/bd/update_embedded_test.go` verifies that clearing two refs in a
row succeeds (the historical UNIQUE repro), that `ExternalRef` reads
back as nil, and that the JSON output omits the field rather than
emitting `"external_ref":""`.
Refs #3902
Co-authored-by: Cursor <cursoragent@cursor.com>
Before this fix, `runWispCreate` unconditionally forced `rootOnly = true`
whenever the formula didn't set `pour=true`:
if !rootOnly && subgraph != nil && !subgraph.Pour {
rootOnly = true
}
Since vapor-phase formulas (the natural fit for wisps) don't set
`pour=true`, every reasonable `bd mol wisp <formula>` call collapsed to
root-only — making the advertised `--root-only` opt-out flag a no-op and
breaking ephemeral lifecycle testing of multi-step formulas, as reported
in #3872.
The plumbing for ephemeral children was already in place:
`spawnMoleculeWithOptions` propagates `opts.Ephemeral` to every child
issue (template.go:596). The fix is just deleting the override so the
CLI flag flows through unchanged.
Behavior delta:
- `bd mol wisp <vapor-formula>` now materializes the full DAG
ephemerally (the bug fix)
- `bd mol wisp <vapor-formula> --root-only` unchanged (still root only)
- `bd mol wisp <pour=true formula>` unchanged (still full DAG)
Also adjusts the dry-run printout: when `--root-only` is set, the skip
hint now points at the flag instead of the obsolete `set pour=true in
formula` suggestion.
Adds wisp_test.go with three regression tests covering the default
fanout, `--root-only` opt-out, and dry-run messaging on both branches.
Follow-up: `subgraph.Pour` is now write-only dead code (set in
cook.go:800, no longer read anywhere). Will be cleaned up in a separate
chore PR to keep this fix minimal.
Co-authored-by: Cursor <cursoragent@cursor.com>
`bd create --graph <plan>` had two related bugs reported in GH#3367:
1. Unknown node/edge/plan fields were silently dropped by encoding/json.
The reporter's plan placed `parent` (a string) and `blocks` (an array)
directly on nodes, expecting them to wire hierarchy and dependencies.
The accepted schema is `parent_key` / `parent_id` and a top-level
`edges` array, so the input parsed cleanly but produced a flat set of
orphaned issues with no warning. There was no signal to the operator
that the plan's intent did not survive import.
2. `--dry-run` was wired up on `bd create` but ignored by the --graph
path: `createIssuesFromGraph` did not consult the flag and went
straight to `executeGraphApply`. The --file path already fails fast
when --dry-run is passed; --graph silently created issues regardless.
Changes:
- cmd/bd/graph_apply.go:
- Add `detectUnknownGraphFields` and `warnUnknownGraphFields` helpers
that scan the raw plan JSON before unmarshalling and emit warnings
to stderr listing unknown fields by location (plan, node[<key>],
edge[<i>]). Both are pure, easy to unit test, and have no effect
on the parse result — the legacy lenient behavior is preserved.
- Per-field hints for the two highest-friction reporter fields:
`parent` -> use `parent_key` / `parent_id`; `blocks` -> use the
top-level `edges` array. Plus `depends` and `children` for the
next-most-likely typos.
- Keep `knownGraphPlanFields` / `knownGraphNodeFields` /
`knownGraphEdgeFields` in sync with json tags via a reflection
test that fails on schema drift.
- `createIssuesFromGraph` now takes a `dryRun bool` and emits a
`GraphApplyDryRun` preview (JSON when --json, otherwise human-
readable) instead of calling `executeGraphApply`. The plan is
still parsed and validated so the operator sees the same errors
they would see on a real run, just without writes.
- cmd/bd/create.go: pass --dry-run through to createIssuesFromGraph,
matching the existing wiring on the --file path.
- cmd/bd/graph_apply_test.go: 8 new tests covering the reporter's
exact JSON, the canonical-schema clean path, plan/edge level
unknowns, malformed JSON, hint emission, schema-drift guardrail,
and dry-run preview counts/contents.
Smoke-tested with the reporter's plan against a fresh `bd init`:
- `--dry-run`: warns + previews, leaves the database empty.
- live: warns + creates issues exactly as before (no behavior change
for any plan that doesn't use unknown fields).
Tests: full `make test` clean; focused tests pass.
Fixes#3367
Made-with: Cursor
When dolt_mode=server is configured but the Dolt server is unreachable
(TCP refused, TLS mismatch, auth failure), CheckFreshClone previously
fell through to the legacy "Fresh clone detected (N issues in
issues.jsonl, no database)" warning and recommended bd bootstrap.
In server mode the absence of a local Dolt directory is expected, so
the warning is a false positive and the recommended fix is wrong:
bd bootstrap won't help when the actual problem is connectivity or
credentials. The "fall through (FR-030)" comment misread FR-030, which
only requires that an unreachable server not panic the caller — not
that we silently degrade to a misleading message.
This change adds freshCloneServerUnreachableResult, which:
- identifies that we're in server mode and points at host:port,
- surfaces the underlying connection error in Detail for diagnostics,
- and recommends verifying server health, host/port, TLS, and
credentials rather than bd bootstrap.
CheckFreshClone now routes the unreachable branch through this helper
instead of falling through. The existing
TestCheckFreshClone_ServerModeUnreachable is updated to assert the new
behavior, and a new TestFreshCloneServerUnreachableResult adds direct
unit coverage for the helper, including a nil-error path.
Embedded count and swarm tests parsed JSON / IDs from CombinedOutput,
which mixes the new auto-export warnings (emitted on stderr) into the
buffer callers parse. The failing CI shards on upstream/main were
TestEmbeddedCount/filter_by_id (shard 5/20) and
TestEmbeddedSwarm/create_coordinator (shard 11/20).
This applies the same stdout/stderr separation pattern already used by
the close/create/gate/init/list/quick/update embedded test helpers
(landed via PR #3909) to:
- bdCount, bdCountJSON
- TestEmbeddedCountConcurrent worker
- bdSwarm, bdSwarmJSON
- TestEmbeddedSwarm/list_json subtest
bdCountFail and bdSwarmFail keep CombinedOutput because they are only
used to assert non-zero exit and surface diagnostics; no parsing.
TestEmbeddedSwarmConcurrent worker keeps CombinedOutput because it only
matches against expected error strings.
Verified locally with BEADS_TEST_EMBEDDED_DOLT=1 CGO_ENABLED=1
go test -tags gms_pure_go -run
'^TestEmbeddedCount$|^TestEmbeddedCountConcurrent$|^TestEmbeddedSwarm$|^TestEmbeddedSwarmConcurrent$'
_amp-claude-sonnet-4.5 on behalf of CI Bot_
Amp-Thread-ID: https://ampcode.com/threads/T-019e22c8-5e13-70b2-a240-564b70597651
Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Amp <amp@ampcode.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>
Remove gastown-specific language. Replace the formula command's Rig/Cook/Run lifecycle wording with existing beads verbs: define formulas, cook them into protos, then pour or wisp them into work. Describe GT_ROOT formulas as a shared workspace root instead of an orchestrator path. Update generated CLI references and add a regression check for the help text.
_codex-gpt-5-medium on behalf of matt wilkie_