#7671 fences graph workspaces in cmd/bd: command admission, the store
factories and the other CLI paths refuse one, and #7722 extends that
fence to a .beads holding the graph-preview-format marker whatever its
metadata says. But the public library opens (beads.OpenBestAvailable,
OpenBestAvailableWith, OpenFromConfig, OpenGated) and the Dolt store's
metadata-driven constructors (NewFromConfig, NewFromConfigWithOptions,
NewFromConfigWithCLIOptions) still opened either kind of graph workspace
as an Issue store and ran Issue schema migrations into the graph
database (or, with no metadata beside the marker, created an Issue
database inside the graph workspace).
- Move the typed refusal into internal/configfile
(UnsupportedWorkspaceFormatError with BeadsDir, GraphMode and
FormatMarker; CheckWorkspaceFormat; GraphFormatMarkerFile;
HasGraphFormatMarker) with byte-identical text and hints for both the
graph_mode and the marker refusal, and move cmd/bd's discovery
pre-checks there as LoadAndCheckWorkspaceFormat and
CheckDiscoveredWorkspaceFormat (LoadForDiscovery, which never migrates
a legacy config.json; unreadable metadata beside the marker is refused
as the marker's format). cmd/bd's checkWorkspaceFormat,
loadAndCheckWorkspaceFormat, hasGraphFormatMarker and
checkDiscoveredWorkspaceFormat become thin delegates, so the CLI keeps
its behaviour (exit 16 with the same hints) and every caller of them is
unchanged; bootstrap's ancestor walk builds the configfile type.
- Every public metadata-driven open runs CheckDiscoveredWorkspaceFormat
as its first statement: before OpenGated takes its gates and before
OpenBestAvailableWith's Load can migrate config.json. A refused open
leaves the workspace byte-identical. The type is exported as
beads.UnsupportedWorkspaceFormatError.
- The Dolt constructors run CheckDiscoveredWorkspaceFormat before
configfile.Load, so a graph workspace marked only by a legacy
config.json, or by the marker beside stripped, missing or unparseable
metadata, is refused before Load can migrate it into metadata.json
(and drop graph_* keys this build does not know). requireDoltBackend
re-checks the loaded config as a backstop, so they also refuse before
resolving a server or writing a port file or Dolt root.
Tests: configfile unit tests for both refusals (exact marker text and
hint, graph_mode winning over the marker, unparseable metadata with and
without the marker); the public opens and the three Dolt constructors
against graph_mode workspaces and against marker-only, stripped
(metadata.json and legacy config.json), server, explicit dependency and
unparseable-metadata marker workspaces, each refused with the typed
error and the workspace left unchanged.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(backends): registry Remote + optional OpenWith(ctx, dir, OpenOptions)
Slice S1: backends.Backend gains Remote bool and an optional
OpenWith(ctx, beadsDir, OpenOptions{Credential, HTTPClient, UserAgent}) so a
registered extension backend can honor a per-open credential instead of
dialing with a process-global client — the motivating case is one embedder
process serving many workspaces with distinct credentials. Open keeps
working unmodified for every existing backend: Backend.OpenWithOptions calls
OpenWith when present, otherwise falls back to Open and ignores
HTTPClient/UserAgent, but refuses (ErrCredentialWithoutOpenWith) rather than
silently dropping a non-nil Credential.
Public beads.OpenBestAvailableWith(ctx, beadsDir, opts) carries this through
the SDK surface (mirrored in beads_nocgo.go and aliased in backend/backend.go
and beads.go); OpenBestAvailable is now that call with a zero OpenOptions,
identical to its prior behavior for Dolt, embedded Dolt, and every registered
backend. The plain-Dolt path (no registered backend) applies the same
Credential refusal, since Dolt has no per-open credential seam either.
doltserver.ResolvePhysicalRoots now checks backends.IsRemote(cfg.GetBackend())
before every Dolt-mode branch, including the shared-server check (which reads
only env/config.yaml and never consults cfg) — without this ordering, a global
BEADS_DOLT_SHARED_SERVER=1 would hijack a remote-backend workspace into
reporting a bogus local Dolt root it will never open.
Tests: backends_test new file open_with_test.go covers OpenWithOptions
dispatch/back-compat/Credential refusal and Remote/IsRemote; root package
open_backend_selection_test.go adds a fake OpenWith registrant proving
dispatch and option pass-through through OpenBestAvailableWith, zero-options
back-compat for every path (registered w/ and w/o OpenWith, plain Dolt), and
the Credential-without-OpenWith refusal on both paths; doltserver
physical_root_test.go adds the registered-remote-backend case including the
shared-server-override ordering regression test. Verified under both cgo and
nocgo builds. Live-mutated each new guard (the Credential refusal, the
OpenWith dispatch, the ResolvePhysicalRoots remote-backend case, and the
plain-Dolt Credential refusal) one at a time and confirmed RED before
reverting to GREEN.
No HTTP client code added; that is a later slice.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fixup(backends): address Opus review findings on OpenWith (M1-M3, L1-L2)
- M1: frame cmd/bd store-open errors for remote backends as unreachable
server failures instead of Dolt-shaped "failed to open database"
advice (openStoreErrorMessage, backendNameForErrorFraming), with tests.
- M2: rewrite the OpenBestAvailable/OpenBestAvailableWith back-compat
subtest to assert fixed expected outcomes (error identity/message,
returned store behavior) now that the two functions are identical,
instead of comparing them to each other.
- M3: document and enforce the OpenWith contract: an implementation that
receives a non-nil Credential it cannot type-assert to its expected
type must refuse with the new ErrUnsupportedCredential sentinel,
verified with a fake registrant.
- L1: document that a nil OpenOptions.Credential means the backend's
default/ambient auth, and that multi-tenant embedders must pass a
non-nil Credential (RequireCredential deferred to S2).
- L2: fail closed on HTTPClient/UserAgent passed to a backend without
OpenWith, mirroring the existing Credential refusal, via new
ErrHTTPClientWithoutOpenWith/ErrUserAgentWithoutOpenWith sentinels.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* build(bazel): auto-sync BUILD files
Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/37195230844
(`make bazel-sync`: gazelle, tools/bazel/go_srcs.py, bazel mod tidy).
Only BUILD.bazel, MODULE.bazel and MODULE.bazel.lock are ever pushed; see
scripts/bazel-autofix-push.sh.
* fix(backends): keep the store-open error chain through the remote framing
Maintainer review fixes for the adopted PR (iteration 1).
openStoreErrorMessage returned a string, so ensureStoreActiveWithContext
rebuilt its error from text (%s) where base wrapped the open error with %w,
and the chain ended at the CLI's framing. Prime tells a store-open timeout
apart from a generic "storage unavailable" only through
errors.Is(err, context.DeadlineExceeded) on what ensureStoreActiveWithContext
returns (cmd/bd/prime.go), so the flattening silently downgraded that
diagnostic for every backend, Dolt included, not just the new Remote ones.
Replace the helper with openStoreError, which returns an error wrapping err
with %w on both arms. The message text is unchanged: "failed to open
database: <err>" for Dolt and any registered backend that is not Remote,
"failed to reach remote backend %q: <err>" for a Remote one. direct_mode.go
wraps the result with %w ahead of its Hint line; main.go keeps printing it
through HandleError("%v", ...), which only formats.
Tests:
- TestOpenStoreErrorFramesRemoteBackends (renamed from
TestOpenStoreErrorMessageFramesRemoteBackends) now also asserts errors.Is
on every arm, and the exact original text for the non-Remote arms.
- TestEnsureStoreActiveKeepsOpenErrorChain drives the real
ensureStoreActiveWithContext against a registered backend whose open
outlives its context, for a local and a Remote backend, and requires
errors.Is(err, context.DeadlineExceeded) plus the framing prefix and the
Hint line.
- TestFormatMemoriesForPrimeTimesOutOpeningRegisteredBackend is the
unstubbed twin of TestFormatMemoriesForPrimeTimesOutOpeningStore and
requires the timeout banner, not the "storage unavailable" one.
Measured at this head: turning direct_mode.go's outer %w into %v reddens
both chain-test rows and the prime test; turning the helper's %w into %v
reddens the framing test as well.
Non-gating cleanup in the same area:
- beads_cgo.go, beads_nocgo.go: OpenBestAvailableWith's doc and dispatch
comments said only a non-nil Credential is refused. The code also refuses
a non-nil HTTPClient and a non-empty UserAgent, each with its own
ErrXWithoutOpenWith sentinel.
- internal/doltserver/physical_root.go: the Mode doc lists "remote-backend",
and the RemoteBackend doc covers a registered Remote backend as well as a
Dolt server on a non-local host.
- open_backend_selection_test.go: the plain-Dolt refusal test is a table
over Credential, HTTPClient and UserAgent (renamed
TestOpenBestAvailableWithRefusesPerOpenOptionsOnPlainDolt). Disabling the
nocgo HTTPClient arm or the cgo UserAgent arm reddens only that row. The
zero-options test's comment had the delegation backwards and pointed at
beads.go; OpenBestAvailable delegates to OpenBestAvailableWith in
beads_cgo.go and beads_nocgo.go.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
* feat(schema): add the shared-store migration gate and a locked migration gate hook
Grows checkRemoteMigrateGate with a `shared` flag, exposed as
CheckSharedStoreMigrateGate. On a shared store (a database served to
co-resident bd clients) the gate:
- refuses a version-bump migration when there is NO remote and the
operator has not consented, with the new "shared-no-remote" decision
on the existing RemoteMigrateGateError. Promoting the schema cursor
on a shared server locks out every client still on an older bd —
gastownhall/beads#5920;
- suppresses the smart gate's two auto-EXECUTE arms with a remote
configured. The safe-first-mover argument is about clones, not
clients; it firing on a shared server IS the #5920 mechanism.
A fresh database (current == 0) still migrates: creating a database is
consent for its schema. Consent surfaces are the migrate verb (new
process-local SetSharedMigrateConsent, unlocking only the no-remote arm),
--force, and the reused BD_ALLOW_REMOTE_MIGRATE.
schema.WithMigrationGate gives MigrateUpWithLock a pre-migration hook for
callers whose migration runs entirely inside it. It sits after locked
preparation and before MigrateUp, so the 4a3c02abc converged fast path
still costs it zero statements.
No call site changes behavior yet: every existing exported variant passes
shared=false, so embedded recompiles untouched.
* fix(storage): refuse version-bump migration on shared dolt sql-server stores
Switches internal/storage/dolt's writable-open gate to the shared variant.
A DoltStore is always a sql-server client, and a sql-server accepts
co-resident clients by construction — the property that distinguishes it
from the flock-guarded single-writer embedded store — so this open must
never promote the schema cursor on its own.
This closesgastownhall/beads#5920 at its mechanism: the version-bump
reconciliation (autoMigrateOnVersionBump) opens its OWN writable store for
every non-preview command, including read-only ones, and that open is what
migrated a shared database out from under a team of co-resident v1.2.2
clients. It now refuses, and the refusal — previously swallowed to
debug.Logf with everything else — prints a one-shot stderr notice saying
nothing was applied and what to run instead.
`bd migrate` / `bd migrate schema` set the new verb consent in the root
pre-run (withheld under a preview flag), so the typed verb still migrates.
Tests: a full-CLI #5920 regression (server mode, no remote, stale
.local_version, `bd list` must not promote MAX(version) — it does promote
it, 65 -> 66, with this commit's one-line gate swap reverted), the
server-mode open matrix on a real sql-server (writable refuses, read-only
succeeds, verb consent migrates), refusal permanence in the retry loop,
and the agent-facing JSON block.
* docs(upgrading): document the shared-server upgrade path
Adds a "Shared servers" section: a version bump never auto-migrates a
database served to co-resident clients, upgrade every client first, then
consent once with `bd migrate schema`, and `bd serve` refuses to start
until the schema is reconciled.
Two corrections to what was already there:
- the smart gate's "auto-migrates as a safe first-mover" arm is now
embedded-only, so the bullet says so and links to the new section;
- the literal `BD_ALLOW_REMOTE_MIGRATE=1 bd migrate` recipe is removed
in favor of "run bd migrate as an explicit step in exactly one job; if
the gate blocks a run it prints the options and the scripted
override". Per settled decision 4
(engdocs/decisions/2026-07-17-docs-release-pin.md), the escape hatch
is not documented as a recipe — the gate prints its own guidance and
the docs defer to it. This brings the page back into compliance
rather than amending the decision.
* fix(storage): address review of the shared-store migration gate
CI blocker: cmd/bd/shared_store_migrate_gate_test.go uses cgo-tagged
helpers but carried no build tag, so the required pure-Go compile lane
(CGO_ENABLED=0 go test -tags gms_pure_go -c ./cmd/bd) failed on undefined
symbols. Tagged //go:build cgo, like every sibling Dolt-server test.
Truth at the merge point. This PR gates the sql-server store; the proxied /
`bd serve` plane is #6055. So its text no longer claims that plane: the
shared-no-remote body, the gate's doc comment, the decision constant, and
WithMigrationGate's doc all describe a dolt sql-server, and upgrading.md
drops the `bd serve` paragraph. #6055 adds them back with the code.
Remedies now match the refusal they are attached to:
- the one-shot version-bump notice keyed only on the error TYPE, so an
"adopt" refusal (another clone already migrated) told the operator to
run `bd migrate schema` — a command the verb consent deliberately does
not unlock for that arm. It now picks the line per Decision, and stays
silent under --json, where it was corrupting the gate's own JSON block
on the same stream;
- a new Shared flag marks refusals that came from a shared store, so the
adopt and adopt-ff options can say that adopting promotes the schema
for every co-resident client. adopt-ff previously advertised
"Risk: none", which is true only of local data;
- handleRemoteMigrateGateJSON gains the missing adopt-ff case (now a
routine outcome, since the auto-execute arm is suppressed), and
shared-no-remote points at the #shared-servers docs anchor instead of
inheriting the migrate-or-adopt one;
- `bd init` joining a behind shared server exits before writing
metadata.json, so its refusal now says where the prescribed command
can actually be run;
- the beads_global refusal names `bd migrate schema --global`, in the
init warning and under --global at the store open — the unflagged
command migrates the project database and leaves the refusal in place;
- a consented `bd migrate schema` that hits the dirty-table guard names
the recovery that terminates, instead of pointing at `bd dolt commit`,
which is itself gated in server mode and points back.
Behavior: consent is now scoped to `bd migrate schema` alone. Bare
`bd migrate` never applies a schema migration itself, and
`bd migrate --update-repo-id` is repo-fingerprint surgery — neither should
promote the schema for a whole server as a side effect. A consented
`bd migrate schema` now also stamps the version marker the refused
reconciliation could not, so `bd doctor` stops reporting a permanent
mismatch after the operator has done exactly what the refusal asked.
Library API: beads.AllowSharedSchemaMigration is the programmatic consent
embedders had no way to give except os.Setenv, which is process-global and
inherited by every child.
Cleanup: the force/env consent ladder was hand-copied into both arms; it is
now one helper that also names the surface that granted consent, so the
warning can stop hardcoding a command the operator may not have typed. Two
gate wrappers left with no callers at all are deleted.
* fix(cli): make --json shared-store migrate gate --global-aware
The shared-no-remote refusal's JSON gate block hardcoded the project-scoped
`bd migrate schema` consent command, so a --json/agent consumer operating on
the global database (--global) was handed a command that consents the wrong
database and leaves the refusal in place. The human/text path was already
--global-aware (printGlobalDatabaseConsentHint, noticeSharedMigrateRefusal),
but the notice self-suppresses under --json, making the gate block the sole
channel for that consumer.
Mirror the human-path consent idiom in handleRemoteMigrateGateJSON: retarget
both the top-level `expected` directive and the runnable migrate-shared option
command to `bd migrate schema --global` when the refused open targeted the
global database, scoped strictly to the shared-no-remote decision. Add a JSON
--global regression test at parity with TestPrintGlobalDatabaseConsentHint.
Also tighten the AllowSharedSchemaMigration doc to state it authorizes only the
no-remote shared arm (a remote-backed shared store still needs --force /
AllowRemoteMigrateEnv), matching the exported API's actual reach.
Maintainer review fixup for PR #6048.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* fix(configfile): detect present Dolt data and give the exact metadata heal (D-8)
A workspace whose metadata.json names sqlite/postgres/mysql stays fail-closed,
but the rejection text was not truthful for the common case. bd v1.2.x opened
those workspaces as Dolt regardless of the "backend" value, so for them the
stale field is the only problem — and the old remedy sent the user to export
and reinitialize, destroying a database that is one JSON edit from healthy.
ExistingDoltDataDir stats the embedded (.beads/embeddeddolt) and server-mode
(.beads/dolt, dolt_data_dir, BEADS_DOLT_DATA_DIR) layouts for a .dolt directory,
either at the root or one level down. Detection is stat/readdir only — every
caller is on a path that has promised not to touch storage. The detection
approach is ported from the obsolete PR #4740.
The removed- and unknown-backend messages now branch on it: with Dolt data
present they name metadata.json and the exact edit ("backend": "dolt", or drop
the field); without it they keep today's export/reinitialize path, so the
substrings existing tests pin are unchanged. GetDoltDataDir becomes nil-safe
like GetBackend, since rejection paths resolve it for configs that may be nil.
Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
* fix(storage): thread beadsDir into every legacy-backend rejection (D-8)
All three rejection surfaces now branch on whether the workspace actually holds
a Dolt database: cmd/bd's validateConfiguredBackend (12 call sites, every one
already had beadsDir in scope), internal/storage/dolt's requireDoltBackend, and
the public beads.OpenBestAvailable path. Widening the signatures rather than
adding parallel *At helpers is deliberate — it makes each site state which
workspace it is rejecting, so none can silently keep the generic message.
Behavior is unchanged for workspaces with no Dolt data; test call sites take the
new argument but no assertion changes.
* test(storage): cover the tombstone heal branch and its round-trip (D-8)
The headline test is the round-trip: init a real Dolt workspace, hand-edit
metadata.json to backend:"sqlite", watch bd list exit 1 with the heal message,
apply exactly the edit that message prescribes, and confirm bd list opens the
workspace with its issue intact. The message's stated alternative — deleting the
"backend" field — is exercised too, so both remedies it offers are proven rather
than asserted.
The same test pins the fail-closed guarantee at a level a stat loop could not:
metadata.json stays byte-identical and the whole embedded Dolt tree is unchanged
in paths and sizes after the refusal.
Around it: the ExistingDoltDataDir layout matrix (embedded and server layouts at
both depths, relative and absolute dolt_data_dir, BEADS_DOLT_DATA_DIR, decoys, no
workspace dir), string-level branch coverage in internal/configfile, a public
OpenBestAvailable case proving beadsDir reaches the library refusal, and an
explicit assertion that the no-Dolt-data branch still refuses to suggest a heal
that would open an empty store.
---------
Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
DependencyEditor.AddDependencies refuses an edge whose SOURCE names no row,
and one whose TARGET names no row this database can see the absence of. Every
other refusal the role can raise hands a caller something to branch on —
ErrSelfDependency, ErrDependencyCycle, *DependencyTypeConflictError,
*DependencyHierarchyConflictError — and these two handed back "an error", with
different text on each backend. A programmatic consumer could not tell a ghost
endpoint from an infrastructure failure, and the role's own doc said so rather
than promising the anonymity would last.
Both now carry an identity: ErrDependencySourceNotFound and
ErrDependencyTargetNotFound, wrapped by a *DependencyEndpointNotFoundError that
names the refused edge and which of its endpoints was absent. Two sentinels
rather than one because the two are separate answers — a ghost source is always
a bad id, while a target is refused only where this database would have held
it. What is NOT refused is unchanged: an "external:" reference and another
repository's id are still stored as external targets.
The store-backed body and the cross-tier target precheck mint the refusal where
they already read the row. The domain repository has no such read: it learns of
the absence from a foreign-key violation, so it reads both endpoints back on
the transaction that refused, only on the refusal path, and never downgrades
the refusal to a probe's failure. Taking the identity out of the driver's
constraint name would have been the thing a typed refusal exists to avoid. One
user-visible consequence: the proxied-server path now renders "issue <id> not
found" where it used to render a raw foreign-key violation, which is what the
embedded path has always said.
The guarded create classifies the new type where it classified the raw
foreign-key signal, so a missing dependency, parent or waits-for target is
still ErrValidation wrapping ErrNotFound on every backend.
RemoveDependency is deliberately untouched. A removal that finds no edge is
Removed false with a nil error, so there is no refusal there to name.
The shared contract asserts the sentinel and the typed fields for each endpoint
in TWO POSITIONS: alone in a request, and mid-batch where the refusal competes
with the rollback of an edge already written, the half that also reads the
graph back at zero edges. Both cases were verified red on all three backends
before the production change — "issue <id> not found" untyped on the two store
paths, "Error 1452 ... Foreign key violation" on the unit-of-work path.
Agent-Signature: claude-code-claude-opus-5-unknown-reasoning on behalf of CI Bot
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fixup! fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fixup! fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fixup! fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fixup! fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fixup! fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fixup! fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fixup! fix(dolt): preserve transaction outcome boundary (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): retain indeterminate mixed claim updates (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): retain indeterminate guarded update errors (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): prevent lifecycle callback replay (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): classify publication commit ambiguity (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(embeddeddolt): mark commit response loss indeterminate (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): retain indeterminate claim outcomes (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): retry rollback-safe transaction setup (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): surface working-set staging failures (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): account direct commit publication failures (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(embeddeddolt): mark commit call response loss indeterminate (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): account indeterminate transaction commits (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): restore transaction circuit accounting (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(storage): preserve settlement commit boundaries (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): guard direct write circuit boundaries (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): close remaining circuit write gaps (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): account wisp dependency commits (ga-f7v2ft.79.1)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
* fix(dolt): record circuit success only after claim verify; cut retry/patch complexity
Maintainer review fixups for PR #5341 (three majors):
- Correctness: verify-gated claim paths (ClaimReadyIssue, UnclaimIssue,
UnclaimIssueIfAssignee, readyClaimer.ClaimNext, issueClaimer.Claim) now wrap
verify+write in withCircuitWrite, so the circuit breaker records success only
at the boundary after post-write verification returns nil — never on the bare
SQL commit ahead of verification. Adds a regression test proving a
committed-but-unverified claim does not reset the breaker.
- Maintainability: replace hasNonCoordinationPatch's 25-branch || chain with a
straight-line nonCoordinationPatchSignals []bool enumeration (cyclomatic
25 -> 3). Adds reflective exhaustiveness and count-guard tests so a new
IssuePatch/LabelPatch/MetadataPatch field fails until it is classified.
- Readability: split withRetryClassified (cognitive 33) into classifyManagedRetry
and recordRetryFailure (cognitive 3/3), preserving retry, indeterminate-commit,
and breaker-trip behavior for both callers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(dolt): record circuit success after facade update verify; skip ignored tables in commit
Maintainer review fixup for PR #5341 (attempt 2).
Major: IssueLifecycle.Update ran its write on an unmanaged context, so
withCircuitWrite recorded RecordSuccess when the SQL commit landed --
before verifiedClaimWrite's re-read could contradict it, laundering a
phantom claim into breaker optimism. Wrap the verify path in
withCircuitWrite and invoke write with the circuit-managed context so
terminal success is recorded once at the boundary, only after verify
returns nil (matching issueClaimer.Claim). The ordinary patch path keeps
its original context and eager accounting.
Minor: commitWorkingSet fed every dolt_status row into a fail-hard
DOLT_ADD loop, so an ordinary Commit's success depended on Dolt's
version-specific handling of DOLT_ADD on a dolt_ignore'd table. Filter
ignored tables with the same anti-join HasCommittablePending uses.
Nit: drop the dead nested-error branch in verifiedClaimWrite (err is
already nil there).
Regressions: facade claim and guarded-update verify failures must not
reset the circuit breaker; a dirty ignored wisp is non-committable and
Commit tolerates it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(dolt/test): match commitWorkingSet dolt_ignore anti-join in sqlmock expectations
commitWorkingSet selects dirty tables with the dolt_ignore anti-join
(`SELECT s.table_name FROM dolt_status s WHERE NOT EXISTS (...)`) so ignored
wisp/lease tables stay out of fail-hard staging, but the draincall and
settlement sqlmock regression tests still expected the pre-anti-join
`SELECT table_name FROM dolt_status`. Under QueryMatcherRegexp the status query
no longer matched, so the commit path returned "could not match actual sql"
before reaching the indeterminate-commit / staging-cause / circuit-trip
assertions, failing the macOS Test job.
Update the six status-query expectations to the anti-join form. Behavioral
assertions are unchanged; this only realigns the mock's expected SQL with the
production query the review validated.
---------
Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* bd-h3dib.2: move storage conformance suite to public backend/conformance
Relocate internal/storage/conformance to backend/conformance so external
Go modules can import and run the suite against out-of-tree storage
backends (the conformance-gated external-backend path promised on #4415).
Pure move: package name, entry points, and assertions are unchanged; the
seven in-tree test importers are rewritten and path references in doc
comments updated. The package doc now states the external usage and the
experimental stability terms.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* bd-h3dib.2: add public backend package exporting the storage backend contract
The alias facade an external Go module implements a storage backend
against: the engine interface (storage.DoltStorage) and its capability
sub-interfaces, every named type reachable from their method signatures
(measured by type-closure walk: 24 storage types, 36 domain types, plus
the already-public issueops request/response surface), the sentinel
errors and message fragments the contract requires by identity, the
Iter/SliceIter kit, and thin wrappers over the internal/storage/backends
registry. Aliases only - the internal packages remain the source of
truth and no behavior changes.
TestPublicSurfaceComplete is the drift guard: it reflects over the
public contract's type closure and fails if any reachable internal type
lacks an alias here, so a future signature change cannot silently
re-lock the external-backend door. It already caught two types a static
signature scan missed (IssueDetails via issueops.Reader's page results,
PersistenceMode via wisp fields).
Follows the established public-facade convention of the root beads
package and issueops. Stability: documented EXPERIMENTAL.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* bd-h3dib.2: changelog for the public external-backend surface
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* bd-h3dib.2: point the root beads package doc at the backend implementer surface
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Adds issueops.Lifecycle — Create, Update, Close, Reopen — reached from the storage handle via
store.IssueLifecycle(), implemented once and shared by the CLI and linked library consumers. Three backends
implement it and a shared conformance suite asserts them against one spec. The bd CLI's create, update,
close and reopen now route through it.
Fixes several defects that predate this change and became visible once the write paths were forced to
agree: swallowed metadata-edit failures, a claim applied before field validation, missing value validation
on title/priority/estimate, silently dropped create edges to missing targets, infra-typed creates landing in
the wrong table, a dropped SourceRepo, closed_by_session written but never read, and a compound update
writing twice.
Behavior changes needing release notes: create with an occupied explicit id now fails instead of silently
overwriting; a compound update is one atomic operation with one hook and one version commit; reparenting
replaces all parent edges; reopening something not closed reports nothing to do.
* feat(workspacegate): wire the gate through a shared physical-root resolver, OpenGated, and the CLI (part 2)
Part 2 of the workspace-gate work started in #5046, which landed the
internal/workspacegate primitive and deliberately held back OpenGated
because its private physical-root derivation was wrong in exactly the
ways review found: it skipped the store's real mode resolution and
silently skipped the physical gate on metadata-less workspaces.
internal/doltserver.ResolvePhysicalRoots is now the one shared answer
to 'which local directory will this workspace's store actually open':
side-effect free (never triggers configfile.Load's legacy-migration
write, never mkdirs the shared-server tree), central-config aware
(the dolt_mode inheritance that previously existed only inside
storage/dolt/open.go), correct for embedded (embeddeddolt, where
ResolveDoltDir answers dolt/), proxied (env > client-info sidecar >
default, hoisted out of package main so it cannot diverge), shared
(no-mkdir path), remote backends (workspace gate only), and the
supported no-metadata layouts (embeddeddolt-then-dolt stat probe).
beads.OpenGated gives library consumers a store that holds SHARED
workspace+physical gates for its lifetime. The CLI acquires at one
chokepoint after workspace resolution - SHARED for store-opening
commands, EXCLUSIVE for backup restore - and in-command for the
noDbCommands that replace state: init, migrate from-*-to-* (both
source and destination roots, ahead of migrate.lock per the normative
lock order), and bootstrap.
Posture is deliberate and asymmetric: SHARED acquisition failures that
are not contention warn once and continue ungated (the gate is
cooperative; normal commands must not brick existing deployments),
while contention aborts with the holder's identity, and EXCLUSIVE
failures of any kind refuse - maintenance must not pretend to a fence
it does not hold. Known residual: discovery-path config loads before
the chokepoint can still fire the legacy-migration write; deferring
that is follow-up scope alongside doctor, secondary-target opens, and
bd dolt set.
Agent-Signature: claude-fable-5-medium on behalf of matt wilkie
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AQHiBWVPSXDCcUSG9EGw9d
* fix(workspacegate): nil store on failed factory open before gate-release cleanup
newDoltStore's concrete factory branches (e.g. server-mode dolt.New) return
a typed-nil pointer on error; assigning it to the storage.DoltStorage
interface makes 'store != nil' true in closeStoreBeforeGateRelease, which
then calls Close on a nil receiver and panics (SIGSEGV observed in
TestPersistentPreRunHonorsSkipStoreAnnotation, verify run 20260727T000727Z).
No store was opened on that path, so drop the value before the error return.
Agent-Signature: claude-fable-5-high on behalf of maphew
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P3JtQ3ukoVmfg6LCKcKBBh
* fix(workspacegate): address review — unparam, gate-busy lock classification, bootstrap dolt-dir gating
Three fixes from the adversarial review of gastownhall/beads#5093
(see reports/2026-07-26-reviewer-dispatch-sweep.md, "#5093" section):
- unparam (CI lint fail): drop the dead PhysicalRoots return value from
buildWorkspaceGateSet; both call sites already discarded it, and the
code comments already document that provenance is deliberately not
surfaced in user-facing errors. Updated both callers.
- TestEmbeddedInitConcurrent regression (CI test fail): the new EXCLUSIVE
workspace gate in cmd/bd/init.go short-circuits before the embedded
Dolt flock is ever attempted, so a losing concurrent `bd init` now
reports gate-busy output that isEmbeddedLockOutput did not recognize.
Taught isEmbeddedLockOutput to also match workspacegate.ErrBusy's
"workspace gate busy" text, and added a deterministic
TestInitGateBusyClassifiedAsLockContention that holds the gate
in-process and exercises the exact classification path, independent of
subprocess race timing.
- Bootstrap dolt-dir gating gap: executeBootstrapPlan gated
plan.BeadsDir's resolved physical roots but not
doltserver.ResolveDoltDir(plan.BeadsDir), the directory
executeInitAction/executeRestoreAction/executeJSONLImportAction
actually open. Pass it as an extraRoot, mirroring how bd init passes
its own resolved db path.
Also fixes a locally-discovered flake in
TestChokepointSharedExcludesMigrateExclusive: acquireMigrateGates now
threads the package-global rootCtx into acquireExclusiveWorkspaceGates,
so a prior in-process test that ran the full command path (which sets
rootCtx via setupGracefulShutdown and cancels it via rootCancel() without
resetting the var) can leak an already-canceled context into this test.
Pin rootCtx to nil for the test's duration, matching the isolation
pattern already used elsewhere in this file. Reproduced deterministically
by injecting a canceled context before the fix, confirmed neutralized
after.
TestEmbeddedInitConcurrent itself still does not reproduce the CI
gate-busy symptom on this dev machine (10/10 processes succeed within
the 5s exclusive-gate wait, so the test's own "at least 1 lock error"
assertion still fails locally) — that is a machine-speed-dependent
property of the test's contention window, not the classification bug;
the classification fix is independently verified by the new deterministic
test and by code inspection of workspacegate.ErrBusy's text.
Agent-Signature: claude-fable-5-high on behalf of matt wilkie
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat(storage): engine reads — EventsSince, GetDependentRecords, EventClaimed
`bd activity`/`bd show` render event history, and the library's own callers
need a durable, resumable feed of what changed — but the storage surface had
only the time-granular GetAllEventsSince, no keyset cursor, and no raw
target-keyed dependents read. Add both as additive extension interfaces plus
backend methods; no wire, schema, CLI, or existing-signature changes. Each new
read delegates its SQL to the shared issueops helpers the backends already use.
- Extract the raw "claimed" event literal into a typed EventClaimed constant
(types) and use it at the single write site (issueops/claim.go). The on-disk
value is byte-identical.
- EventsSince(cursor{created_at,id}, limit) — a durable-only keyset read over
the events table, for a change feed that pages forward without dropping or
duplicating same-second ties. New EventQueryStore extension interface +
EventCursor, composed into DoltStorage and implemented on the Dolt backends.
- GetDependentRecords(targetID, depType, limit, afterID) on
DependencyQueryStore — a raw target-keyed dependents read (the inbound edges)
that returns edges from dangling/cross-project/wisp sources rather than
dropping them, so `bd dep list`-style dependents views see the whole set.
Real-Dolt tests cover direction correctness, type filter, keyset paging,
same-second id tie-break, cursor exclusivity, durable-only scope, and the
claimed-constant write path.
(cherry picked from commit 35ae4d186047d99bef6d492132f5767ef2db5d7d)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(storage): make EventsSince sargable + add a per-bead scope
The EventsSince cursor predicate `(created_at > ?) OR (created_at = ? AND id > ?)`
full-scans on Dolt (EXPLAIN: Filter over a bare Table + TopN). Rewrite it to the
logically-equivalent, SARGABLE form
created_at >= ? AND ((created_at > ?) OR (id > ?))
The redundant `created_at >= ?` lower bound flips the plan to
IndexedTableAccess(events) on [events.created_at] (verified by a new
EXPLAIN FORMAT=TREE regression test). The composite (created_at, id) row-value
form is deliberately NOT used: the events table has only single-column
idx_events_created_at (no composite index) on every backend, so the >= lower
bound is the seeking form; the shared issueops query serves each backend.
Also give EventsSince an optional issueID filter ("" = all) implemented off the
same keyset with `issue_id = ?`, so `bd show`'s per-bead event history is one
scoped read of the same primitive rather than a second one. The signature is
changed while unmerged across the interface + dolt/embeddeddolt backends.
Coverage/docs: dolt suite gains issue-filter, limit-clamp (default 100 / cap
500), and the EXPLAIN sargability guard; embeddeddolt gains a mirrored feed
test; the interface doc names idx_events_created_at and states the
commit-visibility-lag caveat (a resuming consumer overlaps a ~45s slack window
and de-duplicates by id).
(cherry picked from commit 3b7903290fad76e15ece171dcf6bdfd5f0f584b8)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(storage): single-source the EventsSince sargability guard from production SQL
The EXPLAIN sargability guard asserted a hand-copied literal of the EventsSince
query, so it could pass while the production predicate silently drifted.
Single-source it: export issueops.EventsSinceQuery(issueID, limit) — the exact
SQL EventsSinceInTx runs — and have the durable-events plan guard EXPLAIN that
string (placeholders literalized) instead of a copy. A change to the SARGABLE
predicate now breaks the guard.
Adds a literalizeParams test helper that binds ? placeholders to literals in
order and panics on arity drift, so a drifted placeholder count fails loudly
rather than EXPLAINing malformed SQL.
(cherry picked from commit dda19e737ac17ae4387c6abc4a1acca287b85494)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(storage): dependents reads — total id cursor, sargable target, + CountDependentRecords
Three coupled fixes to the target-keyed dependents read behind `bd dep list`'s
dependents views and the library's own callers:
TOTAL KEYSET. The old cursor paged on source issue_id, which is not a total key
for a fixed target: a source can appear across the durable and wisp dependency
tables, so paging on it could drop or duplicate rows (the Type tie-break was
dead code and the "issue_id is unique" comment was false). Cursor instead on the
dependency row's own primary id (depid.New(issue_id, target), a UUIDv5 that is
stable and globally unique across both tables): ORDER BY id ASC, afterID = last
row's id. types.Dependency gains an additive ID field, scanned by a dedicated
scanDependentRow (the shared scanDependencyRow is left untouched so no
source-keyed read has to select id). The two per-table pages merge by id and
truncate — total, no drop, no dup, proven by a page-size-1 walk across a
boundary that spans both tables (durable + wisp sources).
SARGABLE TARGET. Replace COALESCE(target...)=? (an expression no index can
match) with an explicit per-column OR, depTargetEqualsOr. On an index-merging
planner it plans as a BitmapOr index-merge over the three idx_dep_*_target
indexes where COALESCE was a full scan; on Dolt it is at worst no worse than
COALESCE, and the type-filtered path seeks the (type, target) composite on both.
CountDependentRecords(ctx, targetID, depType): the same sargable predicate,
COUNT only, summed across both tables — callers need a true total membership
count without paging to exhaustion. Implemented once in issueops and wired onto
the DependencyQueryStore interface + the dolt/embeddeddolt backends.
Coverage: dolt + embeddeddolt tests for both reads (two-table span, type filter,
keyset boundary, limit clamp default 100). Method docs name the cursor key and
the two-table raw-read / policy-at-hydration contract.
(cherry picked from commit 16db364d94f8525b9800483dc5ddcdccf94593f8)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(storage): de-dup cross-table depid collisions in dependents reads
depid.New keys a dependency row's id on (issue_id, target) and omits the table,
so the SAME edge present in BOTH dependencies and wisp_dependencies — a wisp
promoted to durable, or two Dolt clones merged — carries one id in both tables.
GetDependentRecordsInTx appended both per-table pages and sorted by id, so a
colliding edge produced a duplicate id in a merged page (and, at a page
boundary, a dropped row on the next `id > afterID`). CountDependentRecordsInTx
summed two raw COUNT(*)s, over-counting the collision beyond the distinct keyset
row count.
De-dup the paged read by id, iterating durable first and keeping the durable
(authoritative, non-ephemeral) row. Make the count agree with that de-dup:
durable rows plus wisp rows whose depid is not already a durable row for the same
target/type (an uncorrelated, bounded NOT IN over the sargable per-column OR
target predicate), so the total is distinct-by-id.
Adds a dolt regression test that seeds the same edge in both tables (FK checks
relaxed to reproduce the post-merge state) and asserts one row per id in pages,
Count == distinct total (3, not the sum 4), and stable keyset paging across the
collision. Fails before this change (id appears twice), passes after.
(cherry picked from commit c6825f8513cd38967fb73856253bd99a5eb65fc2)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(storage): batched target-keyed dependents read (GetDependentRecordsForIssues)
Adds GetDependentRecordsForIssues(ctx, targetIDs) → map[targetID][]*Dependency:
for a SET of target ids in ONE batched read, each id's INCOMING dependency rows
(its dependents), spanning BOTH the durable and wisp dependency tables, ALL dep
types (the caller filters), de-duped by row id. It is the target-keyed mirror of
the source-keyed GetDependencyRecordsForIssues — the whole-page read that lets
`bd dep list`-style dependents views and the library's own callers render every
id's inbound blocking edges without a per-id fan-out, and unlike
GetBlockingInfoForIssues's blocksMap it keeps the full type set (waits-for /
conditional-blocks are not dropped) and each row's real dep_type.
Cross-table de-dup matches GetDependentRecordsInTx: a wisp promoted to durable
carries one depid in both tables, so the durable table is scanned first and a
repeat id is skipped. The target is matched by the coalesced target expression
(depTargetIn), the same predicate the batched blocks/counts reads use.
Wired through issueops + the DependencyQueryStore interface + the dolt /
embeddeddolt backends. (The public-root re-export via beads.DependentQuerier
lands with the narrow public query-interface work.)
Tests: dolt + embeddeddolt batched-read regressions (multi-target keying, both
tables, full type set incl conditional-blocks/waits-for, decoy exclusion, absent
leaf, empty input).
(cherry picked from commit 1f69cedf282471d474ac5b1be633c7a9b18990c8)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(storage): batch transitive is_blocked read on DependencyQueryStore
`bd`'s discovery/ready-list views and the library's own callers need the
denormalized transitive is_blocked value for a PAGE of up to ~200 issues; the
surface only had the single IsBlocked(ctx, id), so a page cost N per-row calls.
Add IsBlockedBatch(ctx, ids) (map[string]bool) to the DependencyQueryStore
interface and implement it once in issueops.IsBlockedBatchInTx: a batched
SELECT id, is_blocked FROM {issues,wisps} WHERE id IN (...) at queryBatchSize=200
— the same denormalized column IsBlocked reads, NOT a recompute — so it returns
the identical transitive value per id, reflecting inherited/ancestor blockedness
(a child of a blocked parent is blocked with no direct blocking edge). ids
present in neither table are absent from the map; cross-table dups prefer the
wisps row, matching loadStatusByIDInTx and the search wisp-merge.
Wired onto the dolt and embeddeddolt backends via the same pattern as
CountDependentRecords (each delegates through its read tx).
Test: a dolt parity suite seeding a direct blocker, an inherited parent-child
block (transitive is_blocked with an EMPTY direct-blocker set), and an unblocked
control, asserting IsBlockedBatch agrees with per-row IsBlocked for every id and
that a missing id is absent from the map.
(cherry picked from commit 1cd441231e2c5a2b45064db01a03bb06de9009b9)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(issueops): IsBlockedBatch issues-wins on cross-table id collision, matching IsBlocked
IsBlockedInTx (per-row) scans issues→wisps and breaks on the first table that
has the id, so ISSUES wins the shared denormalized is_blocked field on a
cross-table (issues vs wisps) id collision. IsBlockedBatchInTx preferred the
wisps row, so the two reads disagreed on the same stored flag for an id present
in BOTH tables.
Make the batch keep the first-seen (issues) value and skip any later (wisps)
duplicate, mirroring the single read's precedence exactly. Both the dolt and
embeddeddolt backends delegate to this shared function, so they stay consistent.
Add a dolt regression seeding the same id in issues (is_blocked=1) and wisps
(is_blocked=0) and asserting IsBlocked(id) == IsBlockedBatch([id])[id] == the
issues value. Verified it fails before the fix (true vs false).
(cherry picked from commit 7dbd4f849d589acb15f8168532fcf8874aa87c99)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(embeddeddolt): IsBlockedBatch parity regression on the embedded backend
Mirror the dolt IsBlockedBatch coverage on the embedded Dolt backend: assert the
batched transitive is_blocked read agrees with per-row IsBlocked for every id and
reflects an inherited parent-child block (is_blocked true with an empty
direct-blocker set). Complements the already-present embedded keyset regression.
(cherry picked from commit 414e7eaf8de43eb1786088c2851c18763f6724ba)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(beads): re-export claim surface, error taxonomy, and query interfaces on public root
Public root-package surface for the claim/error/query reads consumers reach by
type-assertion. Pure re-export + a string-coupled conflict shim; no engine
behavior changes.
- IssueClaimer interface (ClaimIssue/ClaimReadyIssue, which live on the
storage.BulkIssueStore extension, not the base Storage) + AsIssueClaimer
type-assertion helper. Callers assert once at startup and fail loud, per the
decorator note.
- Re-export ErrCircuitOpen (storage/dolt) as an aliased root sentinel so
errors.Is works across the boundary (the claim sentinels ErrAlreadyClaimed /
ErrNotClaimable are already re-exported with the other sentinels); a
wrap-preservation test pins this against errors wrapped the way the engine
wraps them.
- Typed conflict detail: the conditional-UPDATE claim path returns no typed
result on conflict — the current assignee/status remains embedded in the
error string. Rather than change that internal signature, expose
ClaimConflict + ParseClaimConflict (with its own test) to recover it.
- Re-export DependencyQueryStore, EventQueryStore, EventCursor aliases and the
EventClaimed constant so consumers reach the new reads by type-assertion.
(cherry picked from commit 70f443ad941117a74f3143f8570f91a0f721ece4)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(beads): derive claim-conflict markers from a storage source of truth
ParseClaimConflict hardcoded the message literals "issue already claimed by "
and "issue not claimable: status ", coupling the root parser to the engine's
fmt.Errorf format three layers away with nothing to catch drift.
- Export the two format fragments next to the sentinels: storage.ClaimedByFragment
(" by ") and storage.NotClaimableStatusFragment (": status "). issueops/claim.go
now wraps with "%w%s%s" using them (on-disk/message bytes unchanged), and
ParseClaimConflict reconstructs its markers as ErrAlreadyClaimed.Error()+fragment
rather than hardcoding — producer and parser can no longer drift independently.
- Harden tailAfter: recover the assignee/status only as the trailing run; if the
tail still contains a known marker (an appended wrap corrupted it) return "".
Documents the repo convention that claim-error wraps PREPEND context.
- Producer-tied tripwires: a dolt-suite round-trip (real ClaimIssue → both
conflict branches, recovered via the storage fragments) and a root external
round-trip (real Dolt store via beads.Open → AsIssueClaimer → ParseClaimConflict
recovers assignee/status). The latter also exercises AsIssueClaimer against a
live Storage.
(cherry picked from commit aced93f3d93c3fb779702df0549fab58369af997)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(beads): bound the claim-conflict token so an appended wrap can't leak garbage
tailAfter took the entire trailing run after the fragment, guarding only against
a further embedded full marker. A plain appended wrap — fmt.Errorf("%w (ctx)",
claimErr) — sailed past that guard and returned "alice (ctx)" as the assignee.
Bound the token to a single whitespace-free run: a status never contains
whitespace and an assignee is a whitespace-free actor id by convention, so if the
tail carries trailing content (whitespace or an appended "(...)" wrap) we return
"" — the documented best-effort empty-field outcome, with ParseClaimConflict
still reporting ok=true on the errors.Is match. A prepended wrap (the repo
convention) and a clean conflict are unaffected.
Tests: a direct tailAfter table (clean, prepended, appended-paren, appended-space,
absent, empty) and a ParseClaimConflict appended-wrap case asserting empty field
with ok=true.
(cherry picked from commit 181f47c7b7b4bb397c5f16992d1e33b75982eb04)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(beads): narrow public query interfaces + claim-surface drift guards
Public-surface hardening for the library's consumers, done while unmerged
(cheap now, expensive later).
Stop aliasing whole internal engine interfaces on the root. Replace the
`DependencyQueryStore = storage.DependencyQueryStore` / `EventQueryStore =
storage.EventQueryStore` aliases with NARROW, hand-declared root interfaces that
expose exactly what consumers use:
- EventQuerier { EventsSince(...) }
- DependentQuerier { GetDependentRecords(...); CountDependentRecords(...) }
plus AsEventQuerier / AsDependentQuerier helpers mirroring AsIssueClaimer. Every
As* helper now first tries the direct assertion, then storage.UnwrapStore, so a
HookFiringStore-decorated store keeps its capability (AsIssueClaimer gains the
same unwrap; previously it would return false for a decorated store).
Drift guards: compile-time assertions tie each narrow interface to the full
engine interface storage.DoltStorage (in beads.go) AND to both concrete stores —
*dolt.DoltStore and *embeddeddolt.EmbeddedDoltStore (in tests) — so a signature
change to the claim/event/dependents surface breaks the build instead of
silently making As* return false. A live-Dolt test exercises AsEventQuerier /
AsDependentQuerier and their methods end to end.
(cherry picked from commit ddf7b2ab8a2fa41e36f13ccf701983d0bcd01faa)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(beads): drop the dead UnwrapStore fallback from the As* accessors
The storage.UnwrapStore fallback in AsIssueClaimer/AsEventQuerier/
AsDependentQuerier was provably unreachable. ClaimIssue/ClaimReadyIssue,
EventsSince, and the dependents reads all live on the engine interface
storage.DoltStorage (via BulkIssueStore / EventQueryStore /
DependencyQueryStore), and the compile-time drift guards prove
storage.DoltStorage satisfies each narrow surface. So whenever the fallback's
`s.(storage.DoltStorage)` succeeds, `s` already satisfies the narrow surface and
the leading direct assertion has already returned — branch 2 can only run when
branch 1 failed, and branch 1 failing implies s is not a DoltStorage, so branch 2
fails too. The only decorator, HookFiringStore, embeds storage.DoltStorage and
overrides none of these methods, so it forwards them by promotion and resolves on
the direct assertion.
Reduce the three accessors to a single direct type-assertion and document the
decorator contract (a decorator MUST embed storage.DoltStorage — unlike the
cmd/bd optional interfaces such as StoreLocator/BackupStore, which are not part
of DoltStorage and so genuinely need UnwrapStore, which is unchanged and still
used there). Adds a test that a HookFiringStore-decorated live store resolves
through all three accessors — the guard that would catch a future decorator that
stops forwarding.
(cherry picked from commit 0d9d0500edd3c165f101bbb590dcea7147f3530b)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(beads): re-export the batch transitive-blocked surface on the public root
Add BlockedQuerier (IsBlocked + IsBlockedBatch) and AsBlockedQuerier to the public
beads package, following the established narrow-interface + As* accessor style
(EventQuerier/DependentQuerier): a hand-declared root interface exposing only the
transitive-blocked reads consumers use, reachable via a single direct type
assertion, with a compile-time drift guard (var _ BlockedQuerier =
(storage.DoltStorage)(nil)) so a signature change on the engine breaks the build
here instead of silently making the accessor return false.
The (created_at, id) keyset needs no new re-export: it is additive fields on the
already-re-exported beads.IssueFilter, honored by the already-exported
Storage.SearchIssues / SearchIssuesWithCounts.
query_interfaces tests gain the concrete-store conformance assertions (server +
embedded Dolt), a live-Dolt exercise of AsBlockedQuerier proving IsBlockedBatch
agrees with per-row IsBlocked through the public surface, and the decorator-
contract check that AsBlockedQuerier resolves through a HookFiringStore.
(cherry picked from commit e8b87b6acf601bc2b323d92fbe863c4be7a99386)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(beads): re-export GetDependentRecordsForIssues on the public DependentQuerier
Surface the batched target-keyed dependents read (GetDependentRecordsForIssues,
landed at the storage layer earlier in the dependents-reads work) on the public
root DependentQuerier interface, so a consumer reaching the dependents surface
via AsDependentQuerier can fetch a whole page of inbound edges for a SET of
target ids in one call — the batched mirror of GetDependencyRecordsForIssues —
without a per-id fan-out. A live-Dolt query_interfaces assertion exercises it
through the public surface.
(cherry picked from commit 1f69cedf282471d474ac5b1be633c7a9b18990c8)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(storage): transactional snapshot reads on storage.Transaction
Composite views (bd show-style assemblies of counts, relations, comments, and
history) previously issued each read as its own store call with no shared
snapshot, so related numbers could disagree. Widen storage.Transaction with
the read subset those views need — CountIssuesByGroup, GetIssueCommentsPage,
GetDependentRecords/GetDependentRecordsForIssues/CountDependentRecords,
IsBlocked/IsBlockedBatch, EventsSince — so a caller can assemble the whole
view inside one transaction. Pure surface addition: every method delegates to
the existing InTx implementation; no new SQL, no semantics changes.
On the server backend the transaction spans two sessions (durable + clone-
local). Single-tier reads route by wispness and see this transaction's own
uncommitted writes on both tiers (comments page, blocked checks — including
mixed batches via tier partitioning). Reads that union both tables in one
query (dependents family, grouped counts) run on the durable session and see
uncommitted durable writes plus committed clone-local state; that limitation
is documented per method on the interface and asserted per backend in the
tests. The embedded backend is single-handle and fully read-your-writes.
Conformance adds a snapshot test that mutates inside the transaction and
asserts exact deltas across all the new reads (a non-transactional delegation
fails it), a read-your-writes test covering every method, and wisp-bearing
fixtures; the server backend adds a clone-local-tier read-your-writes test
pinning both the routed reads and the documented spanning-read behavior.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(issueops): drop depTargetEqualsOr's dead alias parameter
Every caller on this branch passes "" — the aliased form's only consumer
lived in a backend package that does not exist here — so golangci-lint's
unparam check rejects the parameter. Inline the bare-column form.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(storage): wrap ErrAlreadyClaimed for open foreign-assignee; split tx conformance tests
Maintainer review fixes for PR #4926 (iteration 1).
Contract (major): issueops.ClaimIssueInTx's open-but-assigned refusal branch
returned a plain error, so the public IssueClaimer contract (wrapped conflict
sentinels, classified by errors.Is / ParseClaimConflict) was false for the
common "open issue pre-assigned to another actor" case. Wrap
storage.ErrAlreadyClaimed while preserving the holder-focused wording, matching
the already-correct domain-stack twin. Adds a conformance test
(ClaimOpenForeignAssignee) and a ParseClaimConflict subtest for the wrapped
open-assigned form.
Complexity (major): split testTransactionSnapshotReads and
testTransactionReadYourWrites into named read + assertion helpers
(readSnapView/assertSnapBaseline/assertSnapDelta and
seedReadYourWritesGraph/assertInTxDependentReads/assertInTxCountsAndEvents) with
equivalent coverage, dropping the worst changed function out of the major
cyclomatic/cognitive band (39/73 -> 11/17 and 23/38 -> 4/5).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(issueops): extract per-table read to cut IsBlockedBatchInTx complexity
Review fix for #4926. IsBlockedBatchInTx inlined the whole two-table batched
scan (gocognit 29, gocyclo 12), which the quality scorecard flagged as a major
readability finding. Extract the per-table batched read into
readIsBlockedIntoFromTable, mirroring the sibling
GetDependentRecordsForIssuesInTx / getDependentRecordsIntoFromTable split, so the
outer function only dispatches the issues+wisps read and nesting resets at the
function boundary.
Behavior-preserving: the issues-win cross-table de-dup and the optional-wisps
table-not-exist skip are unchanged -- same helper-wraps / outer-classifies idiom
as the sibling, and isTableNotExistError unwraps the %w wrap. The embedded
TestIsBlockedBatchEmbedded parity test still passes against a real Dolt backend.
gocognit 29 -> helper 15; gocyclo 12 -> 6.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: CI Bot <ci@beads.test>
* feat(comments): keyset-paged comments read (GetIssueCommentsPage)
The comments read surface was whole-thread only: GetIssueComments materializes
every comment, so a consumer that wants a page of a long thread must load it
all and page in memory (and cap it, serving long threads incomplete). Add a
keyset-paged read with a stable order and an index-backed resume predicate.
- Storage.GetIssueCommentsPage(ctx, issueID, after CommentPageCursor, limit):
(created_at ASC, id ASC) order; resume via the sargable predicate
created_at >= ? AND ((created_at > ?) OR (id > ?)); limit defaults to 100 and
caps at 500 (documented, with the len(page)<limit idiom hazard called out —
terminate on an empty page). Cursor comes from a previously read row; the
forward-only-walk semantics for backdated inserts are documented. Wisp-routed
like the whole-thread read. Page-walk equals the full read exactly, including
same-second id tie-breaks (comment ids are lowercase UUIDv7, so the CHAR(36)
collation cannot reorder them).
- Migration 0056 adds idx_comments_issue_created_id (issue_id, created_at, id)
on comments and — table-guarded, since wisp tables are clone-local and main
migrations run before the ignored chain materializes them (the 0035/0037/0053
precedent, with a matching no-op pin test) — on wisp_comments. Fresh clones
get the wisp index from the canonical clone-local schema (ignored/0001), the
same two-path design earlier wisp indexes use. An EXPLAIN guard pins the
composite index by its column-list signature, single-sourced from the exported
production query.
- AddIssueCommentInTx now truncates the returned CreatedAt to seconds so the
returned comment matches what the DATETIME(0) column stored and is usable as
a page cursor (the stored value is unchanged).
- Implemented on DoltStore and EmbeddedDoltStore; InstrumentedStorage wraps it;
beads re-exports the cursor type. Tests: page-walk==full-read (same-second
groups), tie-break, first/past-end/empty/default-limit, wisp routing, the
migration no-op pin, and the EXPLAIN guard — on both stores.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(storage): (created_at, id) keyset issue-list predicate on IssueFilter
`bd list` and the library's own callers over the public Storage surface need
true keyset paging over issues with second-granularity timestamps, which the
surface lacked: IssueFilter had CreatedBefore + Limit but no (created_at, id)
tuple cursor, so a same-second group larger than one page could not page without
dropping or duplicating its overflow.
Add an additive keyset to types.IssueFilter — AfterCreatedAt *time.Time +
AfterID string — meaning "rows strictly after the (created_at DESC, id ASC)
position (AfterCreatedAt, AfterID)". id is the primary key, so the tie-break is
total. It composes with every existing filter (CreatedBefore keeps working) and
is honored by BOTH SearchIssues and SearchIssuesWithCounts on every backend,
because it is emitted through the shared sqlbuild.BuildIssueFilterClauses path
that every storage backend goes through. Pair it with SortBy="created" for the
matching ORDER BY created_at DESC, id ASC.
The predicate is single-sourced as sqlbuild.KeysetCreatedAtIDPredicate:
(created_at <= ? AND ((created_at < ?) OR (id > ?))). This is the keyset
form the planner can drive through an index seek rather than a scan; a dolt
EXPLAIN guard pins the plan against the exact production constant, a sqlbuild
unit test pins clause/args emission, and same-second-overflow paging
regressions run on both the server and embedded Dolt backends through the
public SearchIssues.
(cherry picked from commit 167e25b3af3002939fe27d4bbfc1598fff21c586)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(storage): IssueFilter.IsBlocked filter — index-backed on every backend
`bd list`/`bd ready` and the library's own callers could not filter on the
denormalized is_blocked column server-side: the column and the
idx_issues_is_blocked(is_blocked, status) index already exist, but the
projection column was not a filter — callers had to over-fetch and post-filter
in Go. Make it one.
Purely additive: an optional IssueFilter.IsBlocked *bool (nil = any; no
signature change, no new interface method). Wired into the shared sqlbuild
filter clause as `is_blocked = ?` (bound int 0/1; the column is NOT NULL
DEFAULT 0 so no IS NULL arm), so BOTH SearchIssues(WithCounts) AND
CountIssues/CountIssuesByGroup honor it on every backend (dolt, embeddeddolt)
through the one BuildIssueFilterClauses path.
Tests: clause/arg unit test (true→1, false→0, nil→no clause); multi-backend
conformance — CountIssuesByGroup(IsBlocked=true) returns only blocked beads per
status, false the complement, nil the whole population; and a dolt EXPLAIN
guard that the filter drives the is_blocked index.
(cherry picked from commit 96c0b03024f0df08fcada9f312669f970500eea8)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(schema): move the wisp comments keyset index to a new ignored-chain migration
CI's migration-hygiene gate froze ignored/0001 (it exists on main; clones have
recorded its content hash), so the wisp twin of the 0056 comments keyset index
cannot be baked into the canonical wisp schema there. Add it as ignored/0014
instead — guarded exactly like ignored/0006 (table exists AND index absent) —
which is strictly better: the ignored chain runs per clone with its own
cursor, so fresh clones AND already-materialized workspaces both pick the
index up; 0056's guarded half remains for workspaces whose wisp tables
existed when the main chain ran. ignored/0001 reverts to its main content.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Test User <test@test.com>
* feat(metadata): MergeMetadata — atomic single-key metadata merge
SlotSet did a read-modify-write across TWO transactions: GetIssue (tx 1),
metadata[key]=value in memory, then UpdateIssue (tx 2). Two concurrent SlotSet
calls — even on DIFFERENT keys — both read the same base metadata and each
wrote back its whole blob, so the second clobbered the first's key. SlotClear
had the same bug. Add MergeMetadata, which does the read-modify-write inside
ONE transaction (so a concurrent conflict is retried and re-reads), stores a
JSON value (nested objects/arrays, not just strings), and reimplement SlotSet
and SlotClear on top of it so they inherit the atomicity.
- issueops.MergeMetadataInTx / DeleteMetadataInTx: read the metadata (routed
issues/wisps; missing issue -> ErrNotFound), merge/delete the one key, and
write the whole object back THROUGH UpdateIssueInTx — so the operation keeps
everything the old SlotSet got from UpdateIssue (the EventUpdated history
event with actor attribution, the configured metadata-schema validation, and
updated_at), now atomic. The read and write share the caller's transaction,
so a concurrent merge of a different key is retried and re-read, never
clobbered.
- Storage.MergeMetadata implemented on DoltStore (perm withRetryTx +
DOLT_ADD(issues,events) + DOLT_COMMIT; wisp path no commit) and
EmbeddedDoltStore (withConn); forwarded on InstrumentedStorage; auto-promoted
on HookFiringStore; no-op on the configStore mock. SlotSet/SlotClear rebuilt
on it (a string value marshals to a JSON string, byte-compatible with the
historical rewrite).
- Cross-backend conformance covers MergeMetadata + atomic SlotClear; the
8-goroutine concurrent-no-clobber test proves the B1 fix on real Dolt, and
a test asserts the EventUpdated event and schema validation are preserved.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(concurrency): expose a per-row version on Issue reads (RowVersion)
The engine's internal row_lock column — a random non-zero int64 the engine
rewrites on every status/ownership-mutating write and on the generic update
path — was not surfaced on the public types.Issue. Consumers that wanted a
fine-grained optimistic-concurrency token had only updated_at, which is stored
at second granularity, so two same-second writes were indistinguishable. Expose
row_lock read-only as types.Issue.RowVersion so a caller can tell same-second
writes apart.
- types.Issue gains RowVersion int64 (json:"-": a Go-only concurrency token,
never on the CLI/export JSON wire — it is opaque and equality-only). Added
row_lock to the canonical sqlbuild.IssueBaseColumns and a matching scan target
in issueops.ScanIssueFrom; both engine write stacks, wisps, and the counts /
dependents parallel scans share those, so the field hydrates everywhere from a
single-point change. Read-only — no CAS/write behavior (that is a follow-up).
- Doc is precise about coverage: RowVersion changes on claim/close/unclaim and
the generic update path; it does NOT change on some direct-UPDATE paths
(restore, compaction text), which bump updated_at — so a complete change key
combines RowVersion with updated_at, status, and labels. A created row is
already non-zero (create stamps row_lock); 0 only appears on legacy rows
backfilled by migration 0054's DEFAULT 0.
- Tests: RowVersion hydrates on read and on the list path, changes on a mutating
write, distinguishes two same-second writes (identical updated_at, distinct
RowVersion), and never appears on any JSON surface.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(deps): return a typed error on dependency type-conflict
Adding a dependency between a pair that already has an edge of a different type
is a deterministic rejection, but the two engine write paths disagreed on how
they surfaced it: one returned a typed *DependencyTypeConflictError, the other a
plain fmt.Errorf string. So a caller could errors.As the conflict on one path
but had to string-match the message on the other. Make both paths return the
same typed error, and re-export the two dependency-conflict types on the public
beads package so `bd` (and the library's own call sites) classify by errors.As
instead of parsing message text.
- issueops.AddDependencyInTx now returns *domain.DependencyTypeConflictError for
the type-conflict case (byte-identical message — the struct's Error() is the
exact former string, so no string-matcher changes). The hierarchy/cross-type
case already returned *domain.DependencyHierarchyConflictError on both paths;
self-dependency and cycle are already typed sentinels.
- beads.go re-exports DependencyTypeConflictError and
DependencyHierarchyConflictError as type aliases, so errors.As against the
public type matches the value the engine returns.
- Tests assert errors.As + the four fields + the byte-identical message on both
write paths (permanent issues->issues and the wisp-source BeginTx/Commit seam),
and lock the re-exports; the deterministic conflict is returned immediately
(never retried as a transient serialization error).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(deps): emit dependency_added / dependency_removed events
`bd dep add` and `bd dep remove` recorded no event, so the events feed never
surfaced dependency changes even though the event types (types.EventDependencyAdded
/ EventDependencyRemoved) have existed since the original SQLite backend, which
emitted them on every add/remove. The emission was dropped when that backend was
removed for the Dolt-only migration and never ported to the current write paths.
Restore it on both Dolt write plumbings, matching the original shape (an events
row on the source issue: "Added dependency: <src> <type> <target>" /
"Removed dependency on <target>").
- issueops.AddDependencyInTx / RemoveDependencyInTx record the event via
RecordEventInTable on the source's event table (wisp-routed), on the genuine
add/remove only — the idempotent same-type re-add and the no-op remove of a
missing edge record nothing.
- The event is committed with the edge: DoltStore.AddDependency/RemoveDependency
DOLT_ADD `events`, and the transaction-path (RunInTransaction / batch /
graph-apply) methods mark the source's event table dirty (events or wisp_events)
so StageAndCommit commits it — without this the event row would dangle in the
working set.
- Emission is gated to the explicit dep-add/remove verb on both plumbings: the
proxied-server repo only records when the use-case sets DepInsertOpts.EmitEvent,
which create-with-deps (implicit parent-child / --deps / waits-for, via a direct
repo Insert) does not — so `bd create --parent` produces the same history on
either backend (the embedded create path via PersistDependencies likewise emits
nothing).
- Tests on both plumbings: add/remove emit exactly once and commit (verified via
`events AS OF 'HEAD'`), idempotent re-add and no-op remove emit nothing, wisp
sources route to wisp_events, and create-with-deps emits no dependency_added.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(close): optional ExpectedVersion CAS on CloseIssueChecked
CloseIssueChecked guards a close on is_blocked in-transaction, but a caller that
read an issue and then closes it has no way to say "only if it hasn't changed
since I read it" — a lost-update window. Add an optional compare-and-swap on the
row's version (the RowVersion / row_lock token): when the caller supplies an
ExpectedVersion, the close proceeds only if the row still has that version, else
it refuses with a typed ErrVersionMismatch. The version read and the close share
one transaction, so it is a true CAS with no read-then-write gap.
- storage.ErrVersionMismatch (re-exported as beads.ErrVersionMismatch) and
CloseIssueOptions.ExpectedVersion *int64 (nil disables the check; a pointer so
nil "no check" is distinct from "require version 0").
- issueops.CheckVersionInTx reads row_lock (wisp-routed; ErrNotFound on a missing
row) and returns ErrVersionMismatch on divergence. CloseIssueCheckedInTx runs
it FIRST — before the is_blocked guard and before the Force short-circuit, so
Force bypasses only the guard, never the CAS (the version check is an
orthogonal precondition). A mismatch returns before any write, so the tx rolls
back leaving the issue open with no `closed` event (atomic refuse).
- The CAS has two limbs: the read-side check catches a writer that committed
before the close began, and on the retry-wrapped permanent path a commit-time
row_lock conflict is replayed by withRetryTx so the re-read refuses.
- Tests on both stores: match closes, stale refuses atomically (still open, zero
closed events), a committed concurrent write invalidates a captured version,
nil is unchanged behavior, Force does not bypass, missing id → ErrNotFound,
wisp sources route to the wisps table, and an already-closed re-close with the
post-close version stays idempotent (Unchanged).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs(close): document RowVersion CAS coverage boundary on ExpectedVersion
Both adoption reviewers flagged that the public ExpectedVersion godoc and the
shared CloseIssueCheckedInTx doc could be misread as a full-row "unchanged"
check. RowVersion (row_lock) only tracks lifecycle/ownership writes
(status/assignee/started_at), so concurrent label, dependency, rename, or
is_blocked writes leave it untouched and are intentionally outside this CAS
boundary. Document that on both sites, grounded in the freshRowLock invariant.
Doc-only; no behavior change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(cli): bd close delegates to the engine's guarded close
The embedded `bd close` path ran its own is_blocked pre-check and then closed in
a separate call — a read-then-write TOCTOU that duplicated a guard the engine
provides atomically. The verb now builds CloseIssueOptions and delegates to
CloseIssueChecked, which runs the guard and the close in ONE transaction; the
CLI's duplicated guard is deleted. --force maps to Options.Force; a blocked
close refuses with the blockers named and the --force hint.
Behavior-preserving on purpose (verified against the previous binary):
- The engine guard now uses the exact historical CLI predicate — refuse only on
a LIVE direct blocker (blocked && len(blockers) > 0), not on the bare
denormalized is_blocked column. A transitively-blocked child (is_blocked
inherited from a blocked parent, zero direct blockers) still closes without
--force, and a stale is_blocked with since-closed blockers self-heals, exactly
as before.
- An already-closed issue stays an idempotent success: it still appears in the
--json array and the text report (same output shape), still exits 0, but no
longer produces a spurious closed->closed audit entry, a no-op commit, or the
real-close side effects (molecule auto-close, newly-unblocked, claim-next).
Tests cover: direct blocker refuses atomically (still open) and closes with
--force; transitively-blocked and stale-is_blocked beads close without --force;
already-closed emits in --json alone and in a mixed batch; idempotent exit 0 —
on the engine (both stores) and through the bd binary.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(update): UpdateIssueChecked — optional ExpectedVersion CAS on the update
UpdateIssue applies a field-map update with no optimistic-concurrency option, so
a caller that wants "update only if unchanged since I read it" had to
read-then-write — a lost-update window. Add UpdateIssueChecked: when the caller
supplies an ExpectedVersion (the RowVersion / row_lock token), the version read
and the update share ONE transaction, refusing with the typed ErrVersionMismatch
if the row has moved — a true compare-and-swap. Nil disables the check and is
byte-identical to UpdateIssue, which is left untouched on the hot path.
- storage.UpdateIssueOptions{ExpectedVersion *int64} (aliased as
beads.UpdateIssueOptions) + Storage.UpdateIssueChecked, mirroring the
CloseIssueChecked pattern: CheckVersionInTx runs first inside the same
transaction on every route — the permanent withRetryTx path, the wisp path,
AND the demote route (an update carrying no_history/wisp routes through the
demote flow; a pure demoteToWispInTx extraction lets the check compose
atomically with the row move — verified byte-identical to the old
DemoteToWisp).
- Implemented on DoltStore and EmbeddedDoltStore; InstrumentedStorage wraps it;
HookFiringStore fires on_update only on success (never on a refused update).
- Tests on both stores: match updates and bumps RowVersion; stale refuses
atomically (field unchanged, zero updated events); a committed concurrent
write invalidates a captured version; nil behaves exactly like UpdateIssue;
wisp match/stale; demote-route match (migrates + applies) and stale (still in
issues, unchanged); missing id → ErrNotFound; the hook decorator fires once on
success and never on refusal.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(cli): proxied bd close delegates to a library checked close
The proxied-server `bd close` path duplicated the close guard in the CLI:
it queried blockers via the dependency use-case, refused with its own message,
and then closed in a separate use-case call. Move the guard into the library —
IssueUseCase gains CloseIssueChecked / CloseWispChecked, which run the same
live-direct-blocker predicate (refuse only on blocked && len(blockers) > 0)
and then the untouched unchecked close — and thin the CLI verb to a single
delegated call. Both `bd close` paths now enforce the guard in the library and
emit the byte-identical refusal: the same storage.ErrCloseBlocked sentinel
("cannot close blocked issue: <id> is blocked by [...]") plus the
"(use --force to override)" hint.
- Guard and close run on the one pinned unit-of-work connection (the whole
close batch is a single transaction), and the guard is read-only and refuses
before any write — a refused id leaves the shared batch transaction clean,
and an all-refused batch skips the commit entirely, exactly as before.
- The unchecked CloseIssue / CloseWisp are untouched: internal closes (molecule
auto-close, gate closes, bd todo done) intentionally stay unguarded.
- Behavior-parity preserved: guard ordering (validate → epic-child → gate →
blocked), exit codes, JSON/batch shape, already-closed handling, audit fields,
and commit-message contents are unchanged; a transitively-blocked bead
(is_blocked with no direct open blocker) still closes without --force, and
--force still bypasses. The guard-failure diagnostic now uses the embedded
path's generic wording (further convergence; nothing matched the old text).
- Tests: use-case level on real Dolt (direct blocker refuses with blockers
named + still open, transitive-only closes, force closes, already-closed
parity, wisp refuse/force) plus the proxied CLI integration suite.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(review): cross-backend dependency-event + RowVersion parity
Maintainer review fixups for PR #4911 (adopt-pr review loop):
- RowVersion: the proxied/domain create (insertIssueRow) and generic Update
paths never stamped or rewrote row_lock, so an issue written through the
proxied-server backend read back RowVersion 0 on create and unchanged on
update -- a stale CAS token that violated the types.Issue.RowVersion
contract on that backend. Stamp a fresh non-zero row_lock on insert (and the
duplicate-key rewrite) and append RowLockClause() to the generic update,
mirroring the classic issueops insert/update invariant. Adds domain/db
regression tests proving CreateIssue/CreateWisp are non-zero and
UpdateIssue/UpdateWisp change it.
- Dependency events: embedded issueops AddDependencyInTx/RemoveDependencyInTx
recorded history unconditionally, so structural create-with-deps
(bd create --parent/--deps/--waits-for) and reparent (bd update --parent)
emitted dependency_added/removed on embedded but were silent on the proxied
backend, diverging issue history for identical commands. Gate the embedded
emit on EmitEvent and thread it through AddDependencyWithOptions /
RemoveDependencyWithOptions on both the store and transaction interfaces:
the plain AddDependency/RemoveDependency are the no-event structural default
(create-with-deps, reparent), while the explicit dep verbs (bd dep add/remove,
bd link, bd relate/unrelate) pass EmitEvent -- matching the proxied
DepInsertOpts.EmitEvent gate. DoltStore stages the events table only when an
event was actually written (GH#2455). Corrects the false
"parity with PersistDependencies" comments and adds symmetric embedded/proxied
dep-event coverage for create-with-parent/deps and structural removal.
- Retain iteration-1 fixups: heal molecules on already-closed re-close,
idempotent proxied checked-close, and documented public Storage growth.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(storage): drop always-constant event param from fireDependencyHookByID (unparam)
golangci-lint (latest, v2.12.2 in CI) unparam flags fireDependencyHookByID:
its `event` parameter always receives hooks.EventUpdate. The parameter was
already effectively constant before this PR (both base call sites passed
EventUpdate); this PR adds two more call sites, all EventUpdate. Remove the
dead parameter and hardcode hooks.EventUpdate at the single runner.Run call.
All four call sites pass hooks.EventUpdate, so behavior is unchanged; go
build, go vet, and a scoped golangci-lint run pass clean.
Maintainer fixup during adoption finalize (PR #4911).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <ci@beads.test>
The assignee, owner, and label columns are VARCHAR(255), but the engine never
validated their length: an over-255 assignee/owner made the row INSERT/UPDATE
fail with a raw backend "data too long" error, and an over-255 label went
through INSERT IGNORE and was SILENTLY TRUNCATED — storing a label the caller
never sent. Validate these three fields up front and return a typed
ErrFieldTooLong so `bd` (and the library's own call sites) get a clean, typed
rejection instead of a raw SQL error or silent corruption.
- types.MaxFieldLen (255), types.ErrFieldTooLong (re-exported as
beads.ErrFieldTooLong), and types.CheckFieldLen using utf8.RuneCountInString
— rune count, not bytes, so a multibyte value up to 255 characters fits the
VARCHAR(255) column and passes while a 256-rune value fails.
- Guard every raw assignee/owner/label write on BOTH engine write stacks:
the embedded issueops/DoltStore path (ValidateWithCustom + ValidateForImport
for assignee/owner, UpdateIssueInTx pre-pass, AddLabelInTx and PersistLabels
for labels, ClaimIssueInTx for the actor written as assignee) AND the
proxied-server domain/db (uow) path (issue insertIssueRow + Update + Claim,
label Insert) — which a first pass missed, so the silent-truncation bug
persisted there.
- Tests on both stacks: over-length create/update/label/claim reject with
ErrFieldTooLong and persist nothing (single and bulk); a 255-rune multibyte
value round-trips unchanged and a 256-rune one is rejected (rune-count proof
end to end); a 255-char value stores intact.
Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat(close): CloseIssueChecked — atomic guarded close in the engine
`bd close` reads blockers (store.IsBlocked) and then closes in a SEPARATE
transaction — a TOCTOU where a blocker can clear (or the bead can be closed)
between the check and the close. Add CloseIssueChecked, which runs the
is_blocked guard AND the close inside ONE transaction, so the guard is atomic.
A Force option bypasses it (mirrors `bd close --force`). This lets the `bd`
CLI delegate its close guard to the engine instead of hand-rolling the
check-then-close dance.
- storage.ErrCloseBlocked sentinel + re-export beads.ErrCloseBlocked;
storage.CloseIssueOptions{Reason,Session,Force} and CloseIssueResult{Unchanged}.
- issueops.CloseIssueCheckedInTx: IsBlockedInTx guard (denormalized transitive
is_blocked — an open blocking dependency or an open blocking gate) then
CloseIssueInTx, sharing the transaction. Force skips the guard. A blocked
refusal returns ErrCloseBlocked and rolls back — no close, no closed event.
- Storage-interface method CloseIssueChecked implemented on DoltStore (perm +
wisp paths, mirroring CloseIssue's DOLT_COMMIT/wisp handling) and forwarded
on EmbeddedDoltStore, HookFiringStore (fires on_close on success like
CloseIssue), and InstrumentedStorage.
- Integration tests for the atomic-refuse property on the perm, wisp, and
embeddeddolt paths (blocked → refused + still open + zero closed events;
Force → closes; non-blocking dep does not trip; already-closed → Unchanged;
missing id → ErrNotFound).
Scope is one concern: category-aware reopen and the open-children close guard
are deliberately split into follow-ups. Builds under cgo and CGO_ENABLED=0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(close): short-circuit already-closed before the is_blocked guard
CloseIssueCheckedInTx ran the is_blocked guard before the already-closed
detection, so a row that is already closed but still carries a stale
is_blocked=1 was refused with ErrCloseBlocked instead of the documented
idempotent Unchanged=true. A closed row can carry a stale flag after a
cross-clone Dolt merge — a state the schema explicitly models (GetStatistics
filters `is_blocked = 1 AND status <> 'closed'`) and a hand-resolved merge
conflict can leave indefinitely.
Detect the already-closed row before consulting is_blocked; the guard only
has meaning for an open->closed transition. This makes the non-force path
symmetric with Force, which already reached Unchanged=true on such a row by
skipping the guard.
Add a regression fixture that seeds a closed row with a stale is_blocked=1
(direct SQL + DOLT_COMMIT, mirroring blocked_merge_test.go's merge-staleness
seeding) and asserts non-force CloseIssueChecked returns Unchanged=true, not
ErrCloseBlocked.
Maintainer review fixup for PR #4893.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <ci@beads.test>
* feat(errors): typed dependency error taxonomy on the public beads package
S1 of the guarded-ops initiative: let the bd CLI (and the library's own call
sites) classify dependency-write failures with errors.Is instead of
string-matching message text, without changing any message (wrap-preserving),
so existing string matchers keep working during the migration.
- Add ErrSelfDependency / ErrDependencyCycle sentinels in
internal/storage/domain and route EVERY production self-dep/cycle emitter
through them: issueops.CheckDependencyCycleInTx, the dolt cross-tier
scheduling-cycle check, the domain use-case add + bulk-add paths, and the
db SQL repository. Canonical-message sites stay byte-identical (sentinel as
the static prefix via %w, or a bare sentinel return); already-divergent
sites (bulk, db) append the sentinel with %w.
- Re-export ErrNotFound, ErrAlreadyClaimed, ErrNotClaimable, ErrSelfDependency,
ErrDependencyCycle as var aliases on the root beads package, so beads.ErrX is
identity-equal to the internal sentinel and errors.Is composes across the
boundary.
- Contract tests: wrap-preserving assertions with EXACT message byte-identity;
a real-production-return test through the domain use case; errors.Is
regression assertions on the dolt cross-tier cycle path and the db self-dep
path. The pre-existing self-dependency test passes unchanged, proving the
canonical messages stayed byte-identical.
A red-team review caught that an earlier draft converted only the same-tier
issueops path, leaving the dolt cross-tier check (which sets SkipCycleCheck and
bypasses issueops) returning an untyped string — errors.Is was false for
cross-tier cycles on the same public DoltStore. All plumbings are now uniform.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(errors): type bulk dependency self-dep and cycle rejections without changing their text
The dependency-add bulk path (proxied `bd dep add` / `bd link`, and the embedded
bulk CLI) surfaces its error verbatim via HandleErrorRespectJSON("%v", err).
Wrapping a rejection with a plain "%w" appends the sentinel's own text to an
already-complete message and changes user-facing output, so the bulk family was
left partially untyped and a scheduling self-edge was misreported as a cycle.
Type every dependency-add bulk rejection so callers can errors.Is it while the
rendered message stays byte-for-byte identical to the pre-taxonomy text:
- Route the per-edge and final domain cycle rejections through a small
string-preserving cycleError wrapper (Error() returns the legacy text,
Unwrap() returns ErrDependencyCycle).
- Guard IssueID==DependsOnID in domain addBulk for all dep types before the
cycle probe, so a scheduling self-edge is ErrSelfDependency instead of
tripping HasCycle (or the final CycleThroughEdges gate) and surfacing as a
cycle; the message matches every other self-dep site.
- Type the embedded bulk CLI final gate (cmd/bd addBulkDependenciesInTx) via the
exported domain.NewCycleError helper, so errors.Is(ErrDependencyCycle) holds
regardless of backend/plumbing.
- Lead the defensive repo-layer self-dep guard with the sentinel like every
other self-dep site instead of appending it.
Add exact-message + errors.Is assertions for the bulk cycle paths (per-edge,
final SkipPerEdgeCycleCheck, embedded final gate) and new bulk self-edge tests
(default, SkipPerEdgeCycleCheck, non-scheduling). Scope ErrDependencyCycle's doc
to the dependency-add family.
---------
Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat: export DependencyAddOptions from the root package
Transaction.AddDependencyWithOptions and Transaction.CycleThroughEdges
are both on the public Transaction interface, but the options type lived
only in internal/storage — so the designed bulk path (SkipCycleCheck per
edge + one whole-graph CycleThroughEdges pass before commit, bd-6dnrw.8)
was uncallable by embedders. Gas City's native graph-apply pours
molecule-sized batches (67 nodes / ~100 blocking edges) whose per-edge
recursive cycle queries cannot finish inside a 120s per-command budget
(observed 2026-07-17: the batch died at the deadline mid-edges twice,
then fell back to per-bead creates — a 9-minute pour).
Root-alias the type, with a compile-time proof that the alias satisfies
the Transaction method.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs(beads): mirror SkipCycleCheck whole-graph guardrail on public alias
The exported beads.DependencyAddOptions alias documented only the happy path,
dropping the imperative guardrail carried on the internal
storage.DependencyAddOptions it aliases. Mirror that contract on the public
surface: callers setting SkipCycleCheck MUST run Transaction.CycleThroughEdges
before commit and fail on new blocks/conditional-blocks/parent-child cycles, so
embedders reading the root-package doc do not skip the per-edge check with
nothing replacing it and silently commit cycles.
Maintainer review fixup for adopt-pr of PR #4870 (minor Contract & Interface
Fidelity finding). No behavior change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Extend #4847's rollback to the last alternative backend: bd now ships a
single storage engine (Dolt, embedded and server mode).
- Delete internal/storage/{sqlite,sqlitedialect} and the packages the
removal orphans: sqlkit (sole importer was the sqlite store),
unsupportedgen (sole go:generate consumer), the NonCommitGraphBackend
marker and its two dead consumer checks, and the domain-db parity test
that used sqlite as its harness. Drop modernc.org/sqlite from go.mod
and regenerate the nix vendorHash.
- Tombstone backend="sqlite" exactly like postgres/mysql: recognized in
metadata (never silently aliased to a fresh Dolt DB), rejected before
any open with its own rationale and the export -> re-init -> import
guidance. The fail-closed guarantee now also covers never creating the
beads.db file the removed backend would have provisioned.
- bd init: --backend=sqlite reaches removed-backend guidance;
--sqlite-path becomes a hidden parser tombstone like the pg/mysql
flags; help text and supported-backend enumerations say Dolt only.
- Doctor: sqlite workspaces fail closed like the other tombstones; the
modern sqlite stub payloads are gone. The legacy pre-Dolt surface
(artifact scans, migration validation, migrate-sqlite-to-current.sh,
the migration-test harness) is untouched; genuine pre-Dolt workspaces
carry no backend field and never hit the tombstone.
- Conformance: drop the sqlite profile; the CLI differential runner
idles (skip, not fail) until another backend profile is registered,
and the export/import round-trip keeps running against the embedded
Dolt reference. Tier-1 oracle legs are unchanged.
Backend selection has never shipped in a release (v1.1.0 predates it),
so released workflows are unaffected and the pinned CLI docs already
describe the resulting behavior.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The fail-closed removed-backend message existed as near-verbatim copies in
cmd/bd/backend_support.go, the root beads package, and the Dolt store's
requireDoltBackend, with shortened variants in bd init; the unknown-backend
message was duplicated byte-for-byte between beads.go and backend_support.go.
Wording drift had already crept in: beads.go said "export with a bd version"
where every other copy said "export it with".
Centralize the text in internal/configfile (already imported by every call
site; configfile depends only on internal/config, so no cycle):
- RemovedBackendError / UnknownBackendError: the standard fail-closed errors
- RemovedBackendDetail: the shared rationale + untouched-data guarantee +
migration-path body, so the Dolt "cannot be opened as Dolt" lead-in
composes from the same core text
- RemovedBackendRationale / BackendNotOpenedGuarantee consts for the
shortened bd init messages and the Dolt unknown-backend variant
All produced strings are byte-identical to the previous ones except the
beads.go drift, resolved to "export it with". The message framing is
user-facing and pending a separate maintainer decision; the new file says
so and is now the one place to reword it. Substring-pinning tests
(open_backend_selection, store_selection_removed_backend,
bootstrap_backend_guard, dolt open_test) pass unmodified.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Roll back the direct adapters, dialect layers, credential handling, dependencies, CI services, and conformance profiles for general-purpose server databases. That support adds operational and testing complexity at odds with our goal of keeping Beads as simple as possible and consuming as few resources as possible.
Keep the Storage and DoltStorage interfaces unchanged. Embedded Dolt, Dolt server, and SQLite remain supported; the MySQL wire driver remains because Dolt server uses it.
Retain legacy metadata identifiers and hidden init flags only as compatibility tombstones. Removed, unknown, or corrupt backend metadata now fails safely across CLI, SDK, bootstrap, doctor, factories, and Dolt administration before storage is opened or modified, with guidance to export using a supporting build and reinitialize via bd help init-safety.
Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Test User
* docs: fix broken xref to docs/EXTENDING.md in extension example
The extension example README referenced docs/EXTENDING.md in three
places, but that file was deliberately deleted in the SQLite -> Dolt
migration (see CHANGELOG entry "Deleted deprecated docs - removed
EXTENDING.md and MULTI_REPO_HYDRATION.md (SQLite-era, no longer
applicable)"). Anyone following the example hits a broken link.
Removed all three references. The example README is itself the
canonical reference for the extension pattern, so no redirect target
is needed.
Note: other docs in the repo still reference the deleted EXTENDING.md
(docs/ADVANCED.md, docs/CONFIG.md, examples/library-usage/README.md,
website/docs/reference/advanced.md). Those are out of scope for this
fix and should be addressed in follow-up issues.
Tracking bead: mybd-q71
GH: #3683
PR: builds on follow-up audit from PR #3706
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs: fix remaining broken xrefs to deleted EXTENDING.md across repo
Round 1 (commit ddeff314c) only fixed the extension example README
because the original prompt scoped that PR narrowly. The bead
(mybd-q71) acceptance is repo-wide ("no broken xrefs anywhere"), so
this follow-up sweeps the rest in the same PR per the project's
"one issue per PR" rule.
Per-file treatment (EXTENDING.md was deleted in commit 508387377
before v1.0.0 was tagged, so even the v1.0.0 versioned snapshot has
been broken since release):
- docs/ADVANCED.md (3 refs):
* Note in Extensible Database section: drop trailing "See
EXTENDING.md for details" — the surrounding sentence about
Dolt-era alternatives stands on its own.
* Bold "See EXTENDING.md for complete documentation" line:
redirect to the canonical working example
(examples/bd-example-extension-go).
* Next Steps bullet: same redirect.
- docs/CONFIG.md (2 refs):
* Namespace doc for compact_*: replace "(see EXTENDING.md)" with
"(used by `bd admin compact`)" — the doc itself describes the
keys, no external reference needed.
* See Also bullet: replace with link to docs/ADVANCED.md
(Extensible Database section).
- examples/library-usage/README.md (1 ref):
* See Also bullet: replace EXTENDING.md link with link to the
sibling bd-example-extension-go example.
- website/docs/reference/advanced.md (1 ref):
* Custom Tables section: replace EXTENDING.md link with link to
the bd-example-extension-go README on GitHub.
- website/versioned_docs/version-1.0.0/reference/advanced.md (1 ref):
* Same fix as the live docs. EXTENDING.md was deleted before
v1.0.0 release (commit 508387377 is an ancestor of tag v1.0.0),
so this versioned snapshot has been broken since cut and a fix
here doesn't violate frozen-in-time correctness — the link was
never valid in the v1.0.0 release.
- website/static/llms-full.txt (1 ref, auto-generated artifact):
* Updated to match the corrected source so the on-disk artifact
isn't broken until next regeneration.
- beads.go and internal/beads/beads.go (package doc comments):
* Replaced "see docs/EXTENDING.md" / "see EXTENDING.md" with a
pointer to examples/bd-example-extension-go. These were real
broken pointers in published Go source comments.
CHANGELOG.md historical entries left untouched (intentional history).
cmd/bd/info.go:747 left untouched (it's a programmatic CHANGELOG
entry rendered by `bd info`, equivalent to a CHANGELOG line).
Verification:
grep -rn 'EXTENDING\.md' --include='*.md' .
returns only CHANGELOG.md hits.
Tracking bead: mybd-q71
GH: #3683
PR: #3713 (round 2)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gt (PR steveyegge/gastown#3166) needs WispFilter to call ListWisps
via the Go module. The type already exists in internal/types —
this adds a type alias to the root package for public consumption.
Co-authored-by: mayor <jim@wordelman.name>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bd unconditionally ran CREATE DATABASE IF NOT EXISTS on every connection.
When connecting to the wrong server (auto-started from .beads/dolt/ or
Homebrew default), this created an empty shadow database hiding real data.
Changes:
- Add CreateIfMissing field to Config — only bd init sets it true
- SHOW DATABASES LIKE check before CREATE (with underscore escaping)
- Network error handling for SHOW DATABASES failure
- Suppress auto-start when metadata.json has explicit dolt_server_port
- Fix backup git push across .beads/redirect (findGitRoot)
- Fix macOS CanonicalizePath case resolution (walk dirs, not realpath)
- Add CreateIfMissing to all migration and create paths
- 10 regression tests covering guard, auto-start, ReadOnly, underscore
- CHANGELOG and TROUBLESHOOTING docs
Authored by: Aaron Lippold<lippold@gmail.com>
Remove FindJSONLPath, FindJSONLInDir, JSONLExport config field, JSONL
bootstrap detection, post-merge JSONL import hook, and findActualJSONLFile.
Update hasBeadsProjectFiles to check for dolt/ directory instead of JSONL
files. Simplify error messages and hook descriptions to remove JSONL
references. Update comments across types, storage, and doctor subsystem.
29 files changed, -882/+79 lines.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix release workflow YAML broken by heredoc in zig wrapper step,
fix marketplace.json version missed in v0.55.0, run gofmt on 8 files,
fix unused parameter and dead code lint in config.go.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Exposes 4 DoltStore methods on the Storage interface so SDK consumers
(e.g. gastown daemon convoy manager) can use them without type-asserting
to the concrete type. Also exports IssueWithDependencyMetadata type.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds OpenFromConfig(ctx, beadsDir) to the public API, delegating to
dolt.NewFromConfig. This allows SDK consumers (e.g., gastown daemon)
to open the beads store respecting dolt_mode from metadata.json,
connecting to the Dolt SQL server when configured instead of always
using embedded mode.
Without this, programs using beadsdk.Open() silently create a separate
embedded database that never sees events written through the server.
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Delete migrate_hash_ids.go (760 lines) and remove hash-ids subcommand,
doctor checks, and readonly test cases. Relocate copyFile to migrate.go
for migrate_dolt.go and repair.go. Rename public API beads.NewStorage()
to beads.Open() across code, tests, examples, and docs. Clean up
transitional SQLite-era comments in store.go and context.go. Add server
mode watchdog with TCP+SQL health probes, auto-restart with stale PID
cleanup, exponential backoff, and clean shutdown.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Phase 3 of Dolt-Native Pruning. Removed ~1,855 lines:
- Deleted migrate_dolt_cmd.go, migrate_dolt_cmd_nocgo.go, migration_hint.go
- Gutted migrate_dolt.go to just listMigrations()
- Removed SQLite codepaths from migrate.go (detectDatabases, getDBVersion, etc.)
- Removed BackendSQLite constant from configfile
- Removed GetConfiguredBackend, LegacyDatabaseNames from beads.go
- Removed NewSQLiteStorage from public API
- Simplified findDatabaseInBeadsDir (no more .db file scanning)
- Simplified backend_migration doctor check (always Dolt)
- Removed SQLite migration hint from main.go
WIP: Need to restore bd migrate --to-dolt as user migration path,
and fix remaining test failures in configfile, beads, cmd/bd packages.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Phase 7 (a5da57e3) deleted internal/storage/factory/ and internal/storage/memory/
but left 30+ files still importing them. This commit fixes all broken references:
- Created internal/storage/dolt/open.go with NewFromConfig/NewFromConfigWithOptions
- Replaced all factory.New/NewFromConfig/NewWithOptions with dolt equivalents
- Broke import cycles in dolt/bootstrap.go (routing/utils/audit → local types)
- Removed dead storage.Config struct
- Converted all test files from memory.New() to dolt.New() test stores
- Removed tests that depended on deleted detectPrefix/LoadFromIssues/mockRemoteStore
46 files changed, 249 insertions(+), 851 deletions(-)
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>
Addresses leaky abstraction where beads.go creates sqlite.New directly,
bypassing backend configuration. Changes:
- Document that NewSQLiteStorage explicitly uses SQLite regardless of config
- Add GetConfiguredBackend helper to read backend type from metadata.json
- Make FindAllDatabases check backend before trying to open database,
avoiding incorrect SQLite usage on Dolt-configured directories
Closes: bd-7cjc
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Executed-By: beads/quartz
Rig: beads
Role: polecat
When beads is redirected (e.g., in Gas Town crew clones), bd prime now
shows a notice about the redirect. This helps agents understand why
they share issues with other clones.
CLI mode shows:
> ⚠️ **Redirected**: Local .beads → /path/to/target/.beads
> You share issues with other clones using this redirect.
MCP mode shows:
**Note**: Beads redirected to /path/to/target/.beads (shared with other clones)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Conditional bonds now work as documented: "B runs only if A fails".
Implementation:
- Add DepConditionalBlocks dependency type to types.go
- Add IsFailureClose() helper to detect failure keywords in close_reason
- Update blocked cache to handle conditional-blocks:
- B is blocked while A is open
- B stays blocked if A closes with success
- B becomes unblocked if A closes with failure
Failure keywords: failed, rejected, wontfix, cancelled, abandoned,
blocked, error, timeout, aborted (case-insensitive)
Updated bondProtoProto, bondProtoMol, bondMolMol to use
DepConditionalBlocks for conditional bond type.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 'deferred' as a valid issue status for issues that are deliberately
put on ice - not blocked by dependencies, just postponed for later.
Changes:
- Add StatusDeferred constant and update IsValid() validation
- Add DeferredIssues to Statistics struct with counting in both SQLite
and memory storage
- Add 'bd defer' command to set status to deferred
- Add 'bd undefer' command to restore status to open
- Update help text across list, search, count, dep, stale, and config
- Update MCP server models and tools to accept deferred status
- Add deferred to blocker status checks (schema, cache, ready, compact)
- Add StatusDeferred to public API exports (beads.go, internal/beads)
- Add snowflake styling for deferred in dep tree and graph views
Semantics:
- deferred vs blocked: deferred is a choice, blocked is forced
- deferred vs closed: deferred will be revisited, closed is done
- Deferred issues excluded from 'bd ready' (already works since
default filter only includes open/in_progress)
- Deferred issues still block dependents (they are not done!)
- Deferred issues visible in 'bd list' and 'bd stale'
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Transaction type alias to both internal/beads and public beads packages.
This allows extensions like VC to use RunInTransaction() with the proper
Transaction interface type for atomic issue creation.
bd-m73k
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Complete implementation of signal-aware context propagation for graceful
cancellation across all commands and storage operations.
Key changes:
1. Signal-aware contexts (bd-rtp):
- Added rootCtx/rootCancel in main.go using signal.NotifyContext()
- Set up in PersistentPreRun, cancelled in PersistentPostRun
- Daemon uses same pattern in runDaemonLoop()
- Handles SIGINT/SIGTERM for graceful shutdown
2. Context propagation (bd-yb8):
- All commands now use rootCtx instead of context.Background()
- sqlite.New() receives context for cancellable operations
- Database operations respect context cancellation
- Storage layer propagates context through all queries
3. Cancellation tests (bd-2o2):
- Added import_cancellation_test.go with comprehensive tests
- Added export cancellation test in export_test.go
- Tests verify database integrity after cancellation
- All cancellation tests passing
Fixes applied during review:
- Fixed rootCtx lifecycle (removed premature defer from PersistentPreRun)
- Fixed test context contamination (reset rootCtx in test cleanup)
- Fixed export tests missing context setup
Impact:
- Pressing Ctrl+C during import/export now cancels gracefully
- No database corruption or hanging transactions
- Clean shutdown of all operations
Tested:
- go build ./cmd/bd ✓
- go test ./cmd/bd -run TestImportCancellation ✓
- go test ./cmd/bd -run TestExportCommand ✓
- Manual Ctrl+C testing verified
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Created root-level beads.go that re-exports types and functions from
internal packages. This allows external projects (like VC) to import
from github.com/steveyegge/beads without violating Go's internal
package restrictions.
Exports:
- Storage interface and NewSQLiteStorage()
- Core types (Issue, Dependency, Label, etc.)
- Filter types (IssueFilter, WorkFilter)
- All relevant constants (Status, IssueType, DependencyType, etc.)
This matches the usage shown in docs/EXTENDING.md.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Resolve symlinks in working directory before walking up the tree
to find .beads directory. This ensures consistent path handling
when repositories are accessed via symlinks.
Without this fix, daemon operations can fail with 'operation not
permitted' errors when trying to export to JSONL, because the
daemon resolves paths differently than the CLI commands.
Example issue: /Users/user/Code -> /Users/user/Documents/Code
The daemon would try to write to the symlinked path while the
file system expects operations on the resolved path.
Extracts duplicated path canonicalization logic (filepath.Abs + EvalSymlinks)
into a reusable helper function utils.CanonicalizePath() in internal/utils/path.go.
Changes:
- Add internal/utils/path.go with CanonicalizePath() function
- Add comprehensive tests in internal/utils/path_test.go
- Replace inline canonicalization in beads.go:131-140
- Replace inline canonicalization in cmd/bd/main.go:446-454
- Replace inline canonicalization in cmd/bd/nodb.go:25-33
The new helper maintains identical behavior:
1. Converts path to absolute form via filepath.Abs
2. Resolves symlinks via filepath.EvalSymlinks
3. Falls back gracefully on errors (returns absPath if EvalSymlinks fails,
returns original path if Abs fails)
Fixes bd-efe8
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add BEADS_DIR as a replacement for BEADS_DB to point to the .beads
directory instead of the database file directly.
Rationale:
- With --no-db mode, there's no .db file to point to
- The .beads directory is the logical unit (contains config.yaml, db
files, jsonl files)
- More intuitive: point to the beads directory not the database file
Implementation:
- Add BEADS_DIR environment variable support to FindDatabasePath()
- Priority order: BEADS_DIR > BEADS_DB > auto-discovery
- Maintain backward compatibility with BEADS_DB (now deprecated)
- Update --no-db mode to respect BEADS_DIR
- Update MCP integration (config.py, bd_client.py)
- Update documentation to show BEADS_DIR as preferred method
Testing:
- Backward compatibility: BEADS_DB still works
- BEADS_DIR works with regular database mode
- BEADS_DIR works with --no-db mode
- Priority: BEADS_DIR takes precedence over BEADS_DB
Follow-up issues for refactoring:
- bd-efe8: Refactor path canonicalization into helper function
- bd-c362: Extract database search logic into helper function
Closes bd-e16b
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Changed backup file filtering from checking file extension (.backup) to checking if filename contains '.backup'
- This now properly filters files like 'beads.backup-pre-hash-20251030-171258.db'
- Also exclude vc.db from database detection
- Add strings import to beads.go
- Improve error message to suggest manual removal
Fixes bd-373c
- Added CanonicalDatabaseName constant (beads.db) and LegacyDatabaseNames list
- Updated bd init to use canonical name via constant
- Added daemon validation to reject non-canonical database names
- Updated bd migrate to use canonical name constant
- Enhanced FindDatabasePath to warn when using legacy database names
- All database discovery now prefers beads.db with backward compatibility
Closes bd-165