An adversarial fable red-team of the multi-backend PR surfaced 19 findings; the
verified, non-regressing subset is fixed here (two were confirmed intentional and
left as-is with clarified comments).
Dolt-parity (high):
- sqlkit tx AddLabel/RemoveLabel/CloseIssue recorded no audit event, unlike both
Dolt references, so bd label add/remove and bd batch / mol squash close lost
their EventLabel*/EventClosed rows on Postgres/MySQL/SQLite. Delegate to the
same issueops with-event helpers the embedded oracle uses.
- Heartbeat left updated_at stale on Postgres/SQLite (no ON UPDATE trigger;
MySQL/Dolt auto-bump), so bd stale diverged. Stamp updated_at on the heartbeat
UPDATE (claim already stamps it, so no double-assign).
Correctness / hardening:
- postgres/mysql/sqlite stampSchemaVersion: idempotent insert (ON CONFLICT /
INSERT IGNORE / INSERT OR IGNORE) + re-read, so concurrent first provisions do
not fail one opener with a duplicate-key error.
- sqlkit tx SetConfig now syncs custom_statuses/custom_types like the oracle.
- pgdialect INSTR->POSITION leaves the call loud when both args carry a
placeholder, preventing a silent parameter swap.
- creds command runner uses cmd.exe on Windows (sh is POSIX-only).
- Dolt gateway credential command is gated on the Dolt backend, not just
shared-server mode (was failing closed for SQL workspaces).
- Scrub pg/mysql URL passwords from the bd.args telemetry span.
Conformance rigor:
- E2E normalize() maps zero/epoch timestamps to <ZERO-TS> so a lost timestamp no
longer reads as byte-identical to a real one.
- E2E logs its candidate set and honors BEADS_CONFORMANCE_REQUIRE so a
sqlite-only run cannot masquerade as full coverage.
Docs/hygiene:
- Scrub dev-machine paths (/data/tmp/pg-recon, proposal_2.md, "proof-wedge") from
the Postgres schema DDL comment; clarify the SQLite timestamp comment.
Deliberately not changed (would regress): sqlkit UpdateIssue uses the without-event
variant to MATCH dolt-server (only embedded differs); sub-second timestamp
precision is an intentional per-backend waiver (whole-second round-trip is the
portable contract) — forcing round-down would discard PG/SQLite fidelity.
Verified: embedded + postgres + mysql + sqlite + server-dolt TestConformance and
the pg/mysql/sqlite E2E differential all pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Maintainer fixup for the choose-your-own-storage-backend PR, amended across the
pre-review CI-repair and the review-loop apply-fixes iterations so contributor
commits stay intact under one maintainer commit.
CI repair (pre-review):
- default.nix: bump vendorHash for the added Postgres/MySQL driver deps.
- conformance.yml: provision the Postgres service DB with a C-locale cluster so
text ORDER BY sorts by code point, matching Dolt's utf8mb4_0900_bin oracle.
Review fixes — blockers:
- uow/doltserver_tx: on a non-serialization DOLT_COMMIT failure, ROLLBACK on the
pinned session before releasing it, and poison (pool-discard via driver.ErrBadConn)
the connection when the rollback also fails, so a later borrower can't inherit an
open transaction and implicitly commit orphaned writes. Satisfies the existing
doltserver_tx_test rollback/poison cases.
- sqlitedialect: translate GREATEST/LEAST to SQLite scalar max/min so the
ReconcileChildCounters upsert (GREATEST(last_child, ?)) no longer aborts creation
or import of hierarchical dotted issue IDs (e.g. x-1.2) on the SQLite backend.
Review fixes — majors:
- conformance: add a portable dotted hierarchical child-ID scenario (x-1, x-1.1,
x-1.2, x-1.2.1) exercising the ReconcileChildCounters GREATEST path on every
backend — the coverage hole that let the SQLite blocker ship green. Verified
against the embedded-Dolt oracle and the real SQLite driver.
- postgres: warn at provision/open when the database collation is not code-point
ordered (C/POSIX/C.*), since text ORDER BY otherwise diverges from Dolt silently.
- sqlite: pin the pool to one connection and add busy_timeout + WAL to the DSN so
overlapping operations wait instead of surfacing a raw "database is locked"
(matches the Dolt backend's single-connection posture). Adds a concurrency guard.
- cmd/bd: gate explicit `bd dolt commit` / `bd vc commit` with a typed
storage.ErrUnsupported on non-Dolt backends instead of the no-op Commit printing
"Committed."; internal opportunistic auto-commit is untouched.
Review fixes — attempt 2 (stale init backend-flag test contract):
- cmd/bd/init_test, init_embedded_test: the init backend-flag tests still asserted
the pre-#3151 one-backend contract (--backend=sqlite must fail "SQLite backend
has been removed"; --backend=postgres is an "unknown backend"), so
`go test ./cmd/bd -run '^TestInitBackendFlag$'` failed in a clean environment now
that sqlite/postgres/mysql are supported pluggable backends. Rewrite
TestInitBackendFlag and the cgo TestEmbeddedInit sibling (rejected_backends →
sql_backend_flags) for the new contract: --backend=sqlite initializes and
persists backend=sqlite; --backend=postgres is recognized and fails only on
missing connection config (not "unknown backend"); a genuinely unknown backend
is still rejected. Pin BEADS_DIR and scrub BEADS_*/BD_* so the subtests are
hermetic against an ambient .beads or Dolt server.
Cleanups (non-gating):
- cmd/bd/init: extract checkExistingSQLBackend so the added SQL-backend branches
don't inflate checkExistingBeadsDataAt's complexity, and load config once.
- configfile: correct the stale "Deprecated: always dolt" Backend field comment.
Review fixes -- attempt 3 (SQLite datetime parity blocker + conformance/rewrite
hardening of the storage-parity gate):
- sqlite/dsn: add _time_format=datetime. Without it modernc binds time.Time via
t.String() ("2026-07-09 12:34:56.123 +0000 UTC"), a shape SQLite's date functions
cannot parse, so the counts mega-query's DATE_FORMAT(created_at,...) (strftime on
SQLite) returns NULL and deps_json exposes a zero created_at while Dolt emits the
real timestamp. datetime stores whole-second "2026-07-09 12:34:56", matching
Dolt/MySQL datetime(0). Verified end-to-end against the real modernc driver.
- conformance: add ReadyWorkDepCreatedAtParity -- imports a dependency with a known
created_at (the bd import / CreateIssuesWithFullOptions bound-time.Time path) and
asserts the counts-rendered deps_json created_at equals it, closing the blind spot
that let the SQLite blocker ship green (the counts tests only checked DependencyCount).
Proven to fail on the pre-fix DSN and pass on both the fixed SQLite backend and the
embedded-Dolt oracle.
- conformance: add ClaimReadyIssueConcurrentExclusivity -- races 24 workers over 8
ready issues and asserts each is claimed exactly once, exercising the SQL backends'
multi-writer claim property that was previously only asserted, never raced. Gated to
the multi-connection dialects (postgres/mysql) via DialectName; SQLite (single-conn
pool) and embedded-Dolt skip.
- conformance.sh: run the embedded-Dolt reference conformance with
BEADS_TEST_EMBEDDED_DOLT=1 and fail loudly if it skips. It self-skips without the env
var, so the parity gate was reporting success while never running the reference oracle.
- mysqldialect: drive the is_blocked-recompute error-1093 rewrite test from the real
issueops templates (new issueops.SelfReferentialRecomputeTemplates) instead of a
hand-copied fixture, so template drift fails a non-gated test rather than only the
env-gated MySQL conformance suite. All four mark/unmark x issue/wisp templates
verified rewritten into the materialized derived-table form.
Note: the review re-flagged TestInitBackendFlag as failing, but it passes in a clean run
(plain and gms_pure_go, matching the scorecard's own rerun); the only cmd/bd failure in
this sandbox is an unrelated pre-existing embedded-Dolt/CGO test not in this PR's diff.
Review fixes -- attempt 4 (conformance-gate self-brick + all-wisps inline-dependency
drop blockers; Postgres error-log password-leak major):
- conformance.sh: anchor the embedded-Dolt reference skip/pass guards to top-level
result lines (^--- SKIP/PASS: TestConformance). The attempt-3 loud-fail guard used
an unanchored grep, so the indented, legitimate subtest skip of
ClaimReadyIssueConcurrentExclusivity (embedded-Dolt is single-writer) matched it and
false-failed the entire storage-parity gate on every run even when the top-level
suite passed. Whole-suite-skip protection is preserved.
- sqlkit/portable + embeddeddolt/create_issue: the all-wisps arm looped the
single-issue issueops.CreateIssueInTx, which runs no batch dependency-persist pass,
so an all-wisps batch carrying inline dependencies (e.g. importing no-history beads
with inter-bead edges -- export DOES include no-history beads, GH#2619) silently
dropped every edge (not even reported via OnSkippedDependency) and, one transaction
per issue, forfeited batch atomicity. Both now mark ephemeral, then run the whole
batch in ONE transaction through issueops.CreateIssuesInTx, matching the server-mode
DoltStore all-wisps arm. The embedded-Dolt reference oracle had the same latent drop,
so the oracle and the new SQL backends were corrected together to keep conformance
parity (the finding compared sqlkit against the server-mode DoltStore, which already
persisted these edges).
- conformance: add CreateAllWispsInlineDependencies -- an all-wisp batch with one valid
inter-wisp edge and one unresolvable edge; asserts the valid edge persists and the
unresolvable one is reported via OnSkippedDependency. Fails on the pre-fix per-issue
loop, passes on the batch path; verified on SQLite and the embedded-Dolt oracle, with
a full embedded-Dolt conformance re-run clean.
- pgdialect: scrub query-param/sslpassword secrets from pgx ParseConfig errors in Open
and OpenRaw (new ScrubDSNError). pgx's ParseConfigError redacts only URL userinfo, so
a postgres://u@h/db?password=SECRET DSN (the shape bd init connects with) leaked the
cleartext secret through the wrapped parse/TLS-config error into logs. Connect-time
errors were verified not to carry the password. Adds redact_error_test coverage for
the query-param, sslpassword, userinfo, and libpq-keyword shapes plus the real
Open/OpenRaw parse-failure path.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
Delete internal/storage/sqlite/ entirely (131 files, ~40K LOC). Update
factory to route all backends through Dolt registry. Rewrite SQLite
migration reader with raw database/sql. Remove to-SQLite escape hatch.
Update all production and test code to use Dolt or memory stores.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
The schema_probe.go expectedSchema map was missing 16 columns that exist
in the issues table (from schema.go CREATE TABLE and migrations):
spec_id, created_by, owner, closed_by_session, wisp_type, is_template,
crystallizes, mol_type, work_type, quality_score, source_system, metadata,
event_kind, actor, target, payload.
This caused the schema probe to not detect databases missing these columns
after a failed or incomplete migration, which meant the migration retry
logic (in store.go) would not trigger. Users upgrading from older versions
would then hit "no such column: spec_id" errors when queries referencing
these columns ran.
By including all columns in expectedSchema, the probe correctly identifies
incompatible schemas and triggers the migration retry path, fixing the
initialization failures reported in #1535 and #1516.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a parent issue has defer_until set to a future date, its children
should also be excluded from bd ready output. Previously only the parent
itself was filtered, leaving orphaned children appearing as actionable.
Adds NOT EXISTS clauses to both the GetReadyWork query and the
ready_issues views (SQLite and Dolt) to check for deferred parents via
parent-child dependencies.
Fixes#1190
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Dolt transition epic (dolt-test-woho) was executed on Feb 10, 11 days
before Phase 2 planned date of ~Feb 21, and before the upstream blocker
(dolt-test-djfr: Dolt-in-Git lands upstream) was resolved.
This reverts the premature removal of SQLite backend (42K+ lines) and JSONL
sync layer (9K+ lines) while preserving all non-transition changes merged
since the transition (PRs #1655, #1660, #1670, #1675, #1680, #1684, #1689).
Restored:
- internal/storage/sqlite/ (131 files, full SQLite storage backend)
- internal/importer/ (7 files, JSONL import engine)
- internal/storage/dolt/dirty.go (dirty tracking for Dolt)
- cmd/bd/autoflush.go, autoimport.go, export.go (JSONL sync layer)
- Storage interface dirty tracking methods
- Factory defaults to SQLite (Dolt available via registry)
- Test helpers create SQLite stores instead of Dolt
Removed transition-only files:
- cmd/bd/config_local.go, import_engine.go, jsonl_bootstrap.go, jsonl_path.go
Applied PR #1680 retry logic to restored internal/importer/importer.go.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Remove the entire internal/storage/sqlite/ package (~43K lines) and update
all 80+ files that imported it to use either the Dolt backend directly
(test files) or the storage factory (production files).
Key changes:
- Delete internal/storage/sqlite/ directory (150+ files)
- Update factory to make Dolt the sole backend, treating "sqlite" as alias for "dolt"
- Replace sqlite.New() calls with dolt.New() in tests, factory.New() in production
- Replace *sqlite.SQLiteStorage with storage.Storage interface throughout
- Replace :memory: SQLite URIs with t.TempDir() for Dolt compatibility
- Inline sqlite.GenerateIssueID() as SHA-256 content hashing where needed
- Fix import cycle in routing/routes.go (routing→factory→dolt→routing)
- Preserve backward-compatible beads.NewSQLiteStorage() wrapper in public API
228 files changed, 605 insertions, 43,821 deletions.
go vet ./... passes clean.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Post-rebase cleanup: upstream moved DeleteIssue to delete.go and added
sync_helpers.go/sync_status.go with dirty tracking calls. Remove those
references to complete the woho.4 dirty tracking strip.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
migrate-issues used UnderlyingDB() type-assertion to SQLite and raw SQL
queries, which would fail on Dolt backend. Now uses the Storage interface:
- Add SourceRepo filter to IssueFilter (types, SQLite, Dolt SearchIssues)
- Add source_repo to allowed update fields (SQLite + Dolt)
- Replace raw SQL queries with SearchIssues, GetDependencyRecords,
GetDependents, GetAllDependencyRecords, GetDependencyRecordsForIssues
- Replace raw transaction with RunInTransaction + UpdateIssue
- Remove database/sql and sqlite package imports
Closes: dolt-test-ztzb
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bd list --parent and dotted-ID naming convention now agree on what
constitutes a parent-child relationship. Updated ParentID filtering
in all storage backends to also include issues whose IDs match the
dotted naming convention (strings.HasPrefix(issue.ID, parentID+".")).
From PR #1617 by zenchantlive.
Co-Authored-By: zenchantlive <zenchantlive@users.noreply.github.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
- Fix misleading comments in dependencies.go and transaction.go that
referenced isChildOf check as a storage-layer safeguard — isChildOf
only exists in CLI/RPC layers, not in the storage layer
- Add transaction-scoped test (TestTransactionAddDependency_ParentChildCustomTypes)
covering custom type hierarchies (theme → epic → shot) to ensure both
direct and transaction code paths stay in sync
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The parent-child validation in AddDependency (both SQLiteStorage and
sqliteTxStorage) enforced that Epic types could not depend on non-Epic
types. This incorrectly rejected valid hierarchies involving custom
types like "theme" → "epic" and "epic" → "shot".
The type-based check was redundant — cycle detection and the isChildOf
check in dep.go already prevent the actual problematic cases (circular
dependencies and duplicate hierarchical links).
Fixes parent-child creation failures with custom issue types configured
via types.custom (e.g., theme, shot).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two migration files shared the 041 prefix (metadata_column and
spec_id_column). Since spec_id_column is registered after
wisp_type_column (042) in the migrations list, renumber it to 043
to match its actual execution order.
Closes dolt-test-v2c
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- errcheck: handle fmt.Scanln return value (doctor_validate.go conflict
resolved - main already has bufio.NewReader fix)
- gosec G204: nolint directive for validated exec.Command in config.go
- unparam: make maxRetries const in beginImmediateWithRetry
- test guard: exclude interactions.jsonl from watched files
Co-authored-by: turian <turian@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Single source of truth for the default AI model, replacing hardcoded
strings in compact/haiku.go and find_duplicates.go. Configurable via
`bd config set ai.model` or BD_AI_MODEL env var.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- errcheck: handle fmt.Scanln return value in validate.go
- gosec G204: add nolint directive for validated exec.Command in config.go
- unparam: make maxRetries a const inside beginImmediateWithRetry (always 5)
- test guard: exclude interactions.jsonl (legitimately created by init)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SQLiteStorage.Close() was not idempotent -- double-close triggered the WAL
checkpoint retry loop (~3.1s backoff per call). With 81 double-closes from
t.Cleanup overlapping manual Close() in tests, this added ~250s to the test
suite. Use CompareAndSwap on the closed flag so only the first call proceeds.
Also fix cleanup ordering in TestFallbackToDirectModeEnablesFlush to shut
down FlushManager before closing the store, preventing the deadlock where
the FlushManager background goroutine holds a DB connection while Close()
blocks on the sql.DB mutex.
Results: test suite 231s -> 103s, WAL checkpoint warnings 81 -> 0.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Completes the error handling consolidation started when errors.go was created:
- Wrap 10 bare error returns with wrapDBError/wrapDBErrorf for operation context
- Add missing rows.Err() checks in labels.go and epics.go
- Standardize sql.ErrNoRows checks to use errors.Is() across 14 files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Three call sites were using raw BEGIN IMMEDIATE without retry, relying
solely on busy_timeout. Replace with beginImmediateWithRetry (exponential
backoff: 10ms..160ms, 5 retries) which handles SQLITE_BUSY_SNAPSHOT and
other cases where busy_timeout alone is insufficient.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add support for filtering issues by label patterns:
- --label-pattern "tech-*" uses SQLite's GLOB for glob-style matching
- --label-regex "tech-(debt|legacy)" uses Go's regexp for full regex
Changes:
- types/types.go: Add LabelPattern and LabelRegex to IssueFilter and WorkFilter
- cmd/bd/list.go: Add CLI flags and forward to filter/RPC
- internal/rpc/protocol.go: Add fields to ListArgs
- internal/rpc/server_issues_epics.go: Forward to IssueFilter
- internal/storage/sqlite/queries.go: GLOB filtering + app-level regex
- internal/storage/sqlite/transaction.go: Same for transaction mode
- internal/storage/sqlite/ready.go: Same for GetReadyWork
Glob uses SQLite's native GLOB function for performance. Regex is done
at the application level after query results return, since SQLite lacks
built-in regex support without extensions.
Closes bd-710
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Add WAL checkpoint retry logic with exponential backoff to prevent data
loss when concurrent readers hold locks during database close.
Security fixes from SECURITY_AUDIT.md:
- Issue #8: WAL checkpoint failure silently losing data
Changes:
- Add 5-retry exponential backoff for WAL checkpoint in Close()
- Warn user if checkpoint fails after retries (potential data loss)
- Add flush_manager_race_test.go for concurrency testing
- Add wal_test.go for checkpoint with concurrent readers
Co-Authored-By: SageOx <ox@sageox.ai>
Add NormalizeMetadataValue helper that accepts string, []byte, or
json.RawMessage for metadata updates. This makes the programmatic API
more convenient for callers that already have their JSON as []byte or
json.RawMessage.
- Add internal/storage/metadata.go with NormalizeMetadataValue function
- Update SQLite and Dolt UpdateIssue to normalize metadata values
- Add comprehensive tests for all input types and error cases
Closes#1417
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: add atomic compare-and-swap semantics to bd claim
The claim operation had a race condition where concurrent callers could
both pass the pre-check and claim the same issue. This fix:
- Adds ClaimIssue method to Storage interface with atomic CAS semantics
- Uses conditional UPDATE (WHERE assignee = '') to prevent race conditions
- Returns ErrAlreadyClaimed error when issue is already assigned
- Implements the fix in SQLite, Memory, and Dolt storage backends
- Updates RPC handler and CLI to use the new atomic method
- Adds comprehensive tests including concurrent claim scenarios
Closes the race window where multiple agents could both claim an issue.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: add ClaimIssue to mockStorage in tests
The mockStorage struct used for interface compliance testing was missing
the new ClaimIssue method, causing build failures in CI.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(nix): enable proxyVendor to fix GOTOOLCHAIN in module fetch phase
The Nix build was failing because the go-modules fetching phase uses
GOTOOLCHAIN=local by default, ignoring the env.GOTOOLCHAIN=auto setting.
Adding proxyVendor=true changes how modules are fetched in a way that
should allow GOTOOLCHAIN=auto to take effect, enabling Go to download
the required 1.25.6+ toolchain automatically.
Fixes#1476
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Revert "fix(nix): enable proxyVendor to fix GOTOOLCHAIN in module fetch phase"
This reverts commit a5b758cf1ac8bbadff774f5566144c3f0b94d561.
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
The spec_id column was added to the issues schema but several SQL
SELECT statements were not updated to include it. This caused a
scan mismatch error: expected 43 destination arguments in Scan,
not 44.
Fixed queries:
- GetReadyWork (ready.go)
- GetNewlyUnblockedByClose (ready.go)
- GetIssuesByLabel (labels.go)
- TestMigrateContentHashColumn test schema (migrations_test.go)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add wisp_type as a first-class field to classify ephemeral wisps for
TTL-based compaction per the Wisp Compaction Policy (gt-9br):
- Add --wisp-type flag to bd create with validation
- Add --wisp-type filter to bd list for querying by wisp type
- Display wisp_type in bd show output for ephemeral beads
- Update IssueFilter and WorkFilter to support wisp_type filtering
- Add wisp_type to RPC protocol for daemon mode support
- Update all storage layers (sqlite, dolt) with wisp_type queries
Supported wisp types: heartbeat, ping, patrol, gc_report, recovery,
error, escalation - each with different TTLs for compaction.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: gastown/crew/dennis
Rig: gastown
Role: crew
* fix: bd ready now excludes in_progress issues
Previously `bd ready` showed both open and in_progress issues, which was
inconsistent with `bd list --ready` (which only shows open issues).
This caused confusion for agents trying to find claimable work - issues
already being worked on would appear in the "ready" list.
Changes:
- `bd ready` now passes Status="open" to GetReadyWork, matching
`bd list --ready` behavior
- Updated command description to reflect new behavior
- Added test for Status="open" filter behavior
- Clarified GetReadyWork storage layer docstring
The storage layer still supports both behaviors via the filter.Status
field for backwards compatibility with internal callers.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: also pass Status filter through RPC path
The initial fix only addressed the direct-mode path. This commit adds
the Status field to ReadyArgs and passes it through the daemon RPC path
so that `bd ready` works correctly in daemon mode as well.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Add GetCommentCounts() batch query to all storage backends (SQLite, Dolt,
Memory) and wire it into bd list, bd ready, bd search JSON output and RPC
server responses. Uses single GROUP BY query to avoid N+1.
Based on PR #1354 by bjornslib - cherry-picked the Go backend changes,
fixed bugs, and skipped problematic JSONL/lockfile/MCP changes.
Co-Authored-By: bjornslib <bjornslib@users.noreply.github.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
* feat: add optional JSON metadata field to issues
Add an optional `metadata` field to Issue for storing arbitrary JSON data.
This enables extension points for tool annotations, file lists, and
external system bridging without expanding the core schema.
Changes:
- Add `Metadata json.RawMessage` field to types.Issue
- Add metadata column to SQLite and Dolt schemas
- Add migration 041_metadata_column for existing databases
- Wire through insert/update/get/search in both backends
- Validate metadata is well-formed JSON on create/update
- Include metadata in content hash computation
The field uses json.RawMessage to preserve exact JSON and supports
omitempty for JSONL export compactness.
Closes#1406
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: add metadata to SQLite SearchIssues and scanIssues
Include metadata column in:
- SearchIssues SELECT statement (queries.go)
- scanIssues function in dependencies.go
- transaction.go GetIssue and SearchIssues SELECTs
- scanIssueRow helper function
Without this, bd list/ready and other search operations would
return issues with empty Metadata fields even when stored.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: add metadata column to remaining SELECT statements
- Add metadata to GetIssuesByLabel in labels.go
- Add metadata to GetReadyWork and GetNewlyUnblockedByClose in ready.go
- Fix TestMigrateContentHashColumn test to include metadata column
This fixes test failures from the initial metadata implementation
where some SELECT statements were missing the new metadata column.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: enable metadata updates and add round-trip tests
- Add "metadata" to SQLite allowedUpdateFields (matches Dolt)
- Add TestIssueMetadataRoundTrip test verifying:
- Create issue with metadata -> GetIssue returns it
- SearchIssues returns metadata
- UpdateIssue can modify metadata
- Issues without metadata have nil Metadata field
This ensures metadata can be updated via bd update and proves
the feature works across key code paths (GH#1406).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(dolt): handle empty metadata for JSON column type
Dolt's JSON column requires valid JSON, so empty strings cause
"Invalid JSON text" errors. Added jsonMetadata() helper that
returns "{}" when metadata is nil or empty.
This fixes TestBootstrapFromJSONL and related Dolt tests.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test: use structural JSON comparison in metadata tests
Replace string comparison with jsonEqual() helper that unmarshals
and uses reflect.DeepEqual. This prevents test brittleness if JSON
gets normalized (whitespace, key order) in the future.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* test(state): add tests for event type validation (GH#1356)
set-state creates event beads internally but event is not a built-in
type, causing validation failures. Add tests that reproduce the bug
in both types and sqlite packages.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(state): allow event type in IsValidWithCustom validation
set-state internally creates event beads for audit trail, but event
was removed from built-in types in 4f0f5744 without updating the
validation path. Add TypeEvent constant and accept it in
IsValidWithCustom and IsBuiltIn, covering all CreateIssue call sites
and multi-repo hydration trust.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(types): simplify IsValidWithCustom and improve doc comments
Replace redundant IsValid + TypeEvent checks with single IsBuiltIn
call in IsValidWithCustom. Clarify IsBuiltIn doc to distinguish core
work types from system-internal types. Remove domain jargon from test
comments.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test(types): add missing test coverage for event type validation
Add negative assertions for IsBuiltIn with custom types (molecule,
gate must return false). Add Normalize guard to prevent event being
aliased to a core type. Add dolt backend test for CreateIssue with
event type without types.custom config.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs(types): clarify TypeEvent and IsBuiltIn doc comments
Use precise language in TypeEvent doc (list specific validation
methods instead of "always accepted by validation"). Note event's
Gas Town origin to prevent confusion. Use "i.e." instead of "like"
in IsBuiltIn doc to signal TypeEvent is currently the only internal
type.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
The Dolt implementation correctly returns rows.Err() but the SQLite
implementation returned nil, which could silently swallow row iteration
errors and return partial results.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The RPC layer was directly importing storage/sqlite and doing type
assertions to *sqlite.SQLiteStorage, which broke abstraction and
prevented Dolt backend from using certain features.
Changes:
- Add CompactableStorage and BatchDeleter interfaces to storage package
- Move CompactionCandidate and DeleteIssuesResult types to internal/types
- Update RPC handlers to use interface type assertions instead of concrete types
- Update compact package to accept interface instead of concrete type
- Remove unnecessary type assertions where methods exist on Storage interface
This enables Dolt (and future backends) to implement optional features
like compaction and batch delete through proper interface extension.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/opal
Rig: beads
Role: polecat
Fixes the leaky abstraction where molecules and importer packages directly used
sqlite.BatchCreateOptions and type-asserted to *sqlite.SQLiteStorage.
Changes:
- Add storage.BatchCreateOptions and storage.OrphanHandling as backend-agnostic types
- Add CreateIssuesWithFullOptions to Storage interface
- Implement for SQLite, Dolt, and Memory backends
- Update molecules.go to use Storage interface method instead of sqlite type assertion
- Update importer.go to use storage types instead of sqlite-specific interface
- Update cook.go to use storage interface method
- Add deprecated aliases in sqlite package for backward compatibility
This enables batch create optimizations for all backends including Dolt.
Closes: bd-nrcp
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/jasper
Rig: beads
Role: polecat