#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>
The graph-mode fence decides a workspace's format from graph_mode in its
metadata alone. Graph-preview builds also write a
.beads/graph-preview-format marker before metadata.json (donnabox fork
commit deea8d57df, Donna Box), so that an interrupted or metadata-lost
graph workspace stays fenced. bd ignored the marker. When a bd that
predates graph_mode had rewritten metadata.json without the field, bd
opened the graph database by its recorded name and `bd list` ran Issue
schema initialization against it. When metadata.json was never written
or was lost, bd fell back to the default database name and created an
Issue database inside the graph workspace, and `bd init` initialized an
Issue workspace there.
checkWorkspaceFormat now also refuses a beadsDir that holds anything at
graph-preview-format, whatever its content and whatever the metadata
says (absent, stripped, or an explicit "dependency"). The graph_mode
check still runs first, so a normal graph workspace is still reported
by its graph_mode. The refusal is the same typed error with its own
message and a hint to restore metadata.json, so every call site, the
--json rendering and exit code 16 (ExitUnsupportedWorkspaceFormat) are
unchanged. An empty beadsDir never probes the working directory.
loadAndCheckWorkspaceFormat reads the metadata with LoadForDiscovery
and refuses metadata that cannot be parsed beside the marker as the
marker's format: the marker alone declares it. Command admission
(guardLegacyUpgradeWorkspaceForInit) uses it, and
checkDiscoveredWorkspaceFormat now delegates to it, so the paths that
check before a migrating configfile.Load (the four store factories,
create --repo's ensureBeadsDirForPath and dry-run target open, the bd
dolt loaders, bootstrap's undiscovered walk) refuse a marked workspace
too, with or without readable metadata. Other metadata load failures
are still left to the caller's own load, so a malformed legacy
config.json without the marker keeps create --repo's
auto-initialization.
bootstrap's ancestor walk (findParentConfig) refuses an ancestor that
holds the marker without metadata it can read, as it refuses one whose
metadata declares graph_mode. It used to skip a marker-only ancestor
and take a more distant workspace's metadata or the defaults, and to
report a marked ancestor with unparseable metadata as a load failure
(exit 1). With the check in checkWorkspaceFormat, bootstrap in a .beads
holding only the marker refuses it (exit 16) instead of reporting no
workspace.
validateConfiguredBackend returns early for nil metadata, so its
backstop covers the marker only when metadata was loaded; every caller
runs admission or checkDiscoveredWorkspaceFormat on the same beadsDir
first, and its comment now says so.
Tests: guard unit tests for marker-only, metadata lost, stripped
(metadata.json and legacy config.json), server, explicit dependency,
unparseable metadata, marker over a legacy Dolt root, and arbitrary
marker content; the four store factories (cgo, and the CGO_ENABLED=0
copies goreleaser ships) with stripped, missing and, for cgo,
unparseable metadata beside the marker; findParentConfig with a marked
ancestor below an ordinary workspace; the exit-code mapping;
ensureBeadsDirForPath with a malformed config.json with and without the
marker; and the subprocess e2e matrices (in-workspace commands, plain
`bd init`, and the outside entry points: create --repo, create
--dry-run, --db, BEADS_DB, init --proxied-server, bootstrap below it)
extended with four marker fixtures that must exit 16 with the marker
refusal and leave .beads byte-identical, while store-less commands
still run. The e2e subprocess timeout goes from 10s to 20s: refused
runs finish in well under a second, but an unrefused one creates or
opens a database and can approach 10s under load, so without the
fence the rows fail on their assertion rather than on the timeout.
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>
* test(list): pin orderSiblingsByDeps ready-set ordering under a sort-derived comparator
Drive orderSiblingsByDeps with compareIssuesForTree("closed", false) over
shuffled input so the caller-supplied compare at the initial ready-set sort
and the post-pop re-sort is exercised with an ordering that disagrees with
priority. Exact-order assertion: dropping or re-hardcoding the post-pop sort
only swaps pa-b and pa-v.
AC: AC-1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5c973b4ba9)
Ported-From: opus/5c973b4ba9d93def077dfabe8186622052abffd5
AC: AC-1
* test(list): pin orderSiblingsByDeps cycle fallback under a sort-derived comparator
A two-node scheduling cycle where priority and ID favor pa-x but --sort
closed favors pa-y: the cycle fallback must follow the caller's compare.
AC: AC-2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d29c4611e6)
Ported-From: opus/d29c4611e63422cee2ff9aee9cf2a9719b5dff71
AC: AC-2
* test(list): pin --deps scheduling ordering under --sort closed in the tree
Render the tree with depsMode=scheduling and sortBy=closed at both the root
level and under one parent: the blocks edge must still put dep before late,
while the requested sort (not priority) puts the unlinked free first. Covers
both orderSiblingsByDeps call sites in list_tree.go.
AC: AC-3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f434dcd5e4)
Ported-From: opus/f434dcd5e47643121c1b4f882f57c7bc68fc69a9
AC: AC-3
---------
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
* fix(configfile): carry graph_mode and graph_* binding through Save
Graph-preview builds of bd persist a per-workspace format in
metadata.json: "graph_mode": "link" plus graph_scope_url,
graph_authority_id, graph_workspace, graph_schema_version and
graph_ready, beside an ordinary Dolt backend. configfile.Config had no
such fields, so every Save, and Load's config.json -> metadata.json
migration, rewrote the file without them, turning a graph workspace's
metadata into an ordinary Issue workspace's.
Config now carries the marker and the binding as omitempty fields, so
a Save round-trips them unchanged and metadata.json written for an
ordinary workspace is byte-for-byte what it was. GetGraphMode resolves
the marker: absent or "dependency" is the historical default, "link"
is recognized, and any other value is an error rather than a fallback
to the Issue store. Nothing in this build opens a non-default mode;
the CLI refusal follows in the next commit.
Ported from the donnabox fork commit deea8d57df (graph_mode.go,
graph_mode_test.go and the configfile.go fields), without any graph
code. The binding-survives-Save and omitted-from-ordinary-metadata
tests are new.
Co-authored-by: Donna Box <dbox@boxenllc.com>
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>
* fix(cli): refuse graph_mode workspaces before opening them
A workspace whose metadata.json declares a graph_mode other than
"dependency" holds a graph database behind an ordinary Dolt backend,
and nothing else in its metadata says so. bd admitted it like any
current workspace: `bd list` ran the Issue schema initialization
against the graph database (beads_graph_<id>), `bd init --force` wrote
a .gitignore and a .beads/dolt root into it, `bd dolt start` started a
server for it, and `bd doctor` reported on it as an Issue store.
guardLegacyUpgradeWorkspace, the admission check every store-opening
command, store-less command with workspace effects, init, doctor and
bootstrap already run before touching a workspace, now refuses such a
workspace first, before the legacy classifications that would admit
it or report it as a legacy store to migrate. An unknown graph_mode
value is refused the same way. The refusal is a typed error naming the
workspace and the format, rendered with a hint (as JSON under --json)
and exit code 16, ExitUnsupportedWorkspaceFormat, so a wrapper can
tell "needs a different bd build" from a generic failure.
`bd version`, `bd --version`, `bd help` and completion stay exempt, as
they are for legacy workspaces. validateConfiguredBackend refuses the
same metadata, which covers the store-open paths that skip command
admission (routed writes, cross-repository reads, create --repo).
Tests: guard and store-factory unit tests; a subprocess e2e test that
show/list/create/context/where/dolt start/doctor/bootstrap/init are
refused with exit 16 and leave .beads byte-identical (metadata.json and
legacy config.json, link and unknown markers, embedded and server
layouts), and that store-less commands still run; an embedded test
that an ordinary workspace, with the marker absent or "dependency",
still creates and lists issues and keeps the marker through a
metadata.json rewrite.
The guard hunk and graph_mode_admission_e2e_test.go are ported from
the donnabox fork commit deea8d57df; the exit code, rendering, store
factory backstop and remaining tests are new.
Co-authored-by: Donna Box <dbox@boxenllc.com>
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>
* fix(cli): refuse graph workspaces reached outside command admission
Command admission refuses a graph_mode workspace a command runs in, but
bd also reaches workspaces before or without admission: a create --repo
target, the path --db or BEADS_DB names, and the stores the factories
open for routed and cross-repository work. On those paths a workspace
marked only by a legacy config.json was changed before anything refused
it: configfile.Load migrates config.json into metadata.json before the
format check sees the loaded metadata, and create --repo initialized
such a target as a new workspace. Where the refusal did come, create
reported it with exit 1 rather than 16.
- checkDiscoveredWorkspaceFormat checks a workspace's metadata as
configfile.LoadForDiscovery reads it, which never rewrites it.
ensureBeadsDirForPath, the dry-run target open and the four store
factories (cgo and nocgo builds) run it before their own load.
- resolveBeadsDirForDBPath and findDatabaseInBeadsDir locate a
workspace with LoadForDiscovery, so resolving --db, BEADS_DB or a
create target no longer migrates it.
- bd create renders a refused target as the workspace refusal, exit 16
with its hint, on the initializing and both dry-run paths. A dry run
without --parent opens no target, so it now checks a local one before
rendering the preview (checkRepoTargetFormat).
- bd bootstrap, when discovery finds no workspace, reads each .beads
from the working directory up to the repository root without
migrating it and refuses one in a format this build cannot open, the
way commands without a workspace already do. A .beads marked only by
config.json is passed over by discovery, so bootstrap reported "no
workspace" there instead of exit 16. The walk now returns its
candidates (undiscoveredWorkspaceCandidates) to both checks: handing
it the check as a func(string) error made gosec's G702 taint analysis
connect BEADS_DIR to every func(string) error that runs git.
- backendNameForErrorFraming reads with LoadForDiscovery, and
loadDoltBackendConfig, bd dolt status and bd dolt show refuse a graph
workspace before their migrating configfile.Load. Admission refuses
first on every path that reaches them today; this keeps a new caller
from migrating a legacy config.json before the refusal.
- The CHANGELOG entry and the configfile comment now claim what holds:
a routed read fails without touching a graph workspace but not with
code 16, and a Save keeps only the known graph_* fields, with the
tags graph-preview builds declare. workspace_gate.go no longer lists
the pre-gate discovery reads as migrating.
- New e2e rows run create --repo from a workspace and from outside one,
create --dry-run with and without --parent, --db, BEADS_DB, init
--proxied-server, bootstrap in a workspace nested in a graph one, and
the hook shim's bd hooks run pre-commit against every fixture; each
refusal must exit 16 and name the format and the hint. bootstrap in a
workspace marked only by config.json now refuses like the other
commands. The store factory test also runs on a config.json graph
workspace, TestWorkspaceMetadataReadersLeaveGraphWorkspaceUnchanged
covers the framing, bd dolt loader and diagnostic reads, and
TestNocgoStoreFactoriesRefuseGraphWorkspace covers the CGO_ENABLED=0
factories; bazel.yml's pure lane runs it by name (PURE_CMD_BD_TESTS,
pinned in scripts/ci_workflow_test.go).
Measured with gocyclo/gocognit: every function this changes stays below
the PR's worst changed function (guardLegacyUpgradeWorkspaceForInit
29/28, resolveBeadsDirForDBPath 26/36); showDoltConfig is 19/31 (was
18/30) and guardUndiscoveredLegacyWorkspace 3/3 (was 9/12).
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Donna Box <dbox@boxenllc.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
The root //:go_srcs filegroup is glob(["**/*.go"]), and a glob follows the
checkout's bazel-bin/bazel-out/bazel-testlogs/bazel-beads symlinks into the
output tree. CI's test step is the first build in a fresh checkout, so it never
sees them, but in any checkout that has built before every test that reads
//:go_srcs (bd_test, bd_embedded_test, bd_embedded_part2_test,
bd_dolt_server_test, bd_proxied_test, bd_managed_local_test) gains the output
base's .go files: their inputs differ on every run, they are never cached, and
loading grows with the output tree.
Measured on main 2563f021ed with the symlinks present, `bazel test
//cmd/bd:bd_test --config=ci --test_filter='^TestResolveCommitHash$'` twice:
both runs executed all 16 shards remotely, and the analysed graph grew from
20,773 to 56,941 configured targets (14 s, then 25 s). With this change the
second run is `(cached)` in 3.6 s. In agent worktrees the glob had reached
433,026 output-tree files, a cached re-run took 36 s to load against ~3 s
without them, and 135 of 202 blocking test minutes of the factory's beads
seats went to these six targets (formula-overhead audit 4; bead ga-ylpbsy.24).
tools/bazel/go_srcs.py gives the root block exclude = ["bazel-*/**"] (the
same pattern ROOT_REPO_FILES_EXCLUDE already uses for //:repo_files); only
the root BUILD.bazel changes. CI's action keys do not change: its checkout has
no such files. scripts/bazel_policy_test.go's
TestBazelRootGoSrcsSkipsConvenienceSymlinks fails without the exclude.
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
After a successful human-output create/show/list/ready, bd may append a
"💡 Tip:" line chosen by a probability roll whose RNG is clock-seeded
unless BEADS_TIP_SEED is set. run_scenario env_clear()s and passes only
PATH/HOME/TMPDIR + BEADS_TEST_MODE=1, so on a host with ~/.claude (claude_setup
tip eligible, p=0.6) every bd process rolled independently and out-of-scope
human-output scenarios (create_human_readable_output, show_short_mode_text,
show_multiple_short, ready_empty_no_issues_plain, ...) diverged main-vs-main.
Pass BEADS_TIP_SEED=1214 to every step for both reference and candidate.
Go math/rand's first Float64() for that seed is 0.0000159, so the
highest-priority eligible tip always wins its roll. Where the host makes a
tip eligible, it stays visible and lands on a deterministic step, so a change
to which tip prints, on which step, or to its text (including a tip leaking
into --json) still diverges instead of being normalized away. Where no tip is
eligible (no ~/.claude, beads plugin enabled, or a `bd prime` hook) none
prints and tip changes go unobserved; the README now says so.
The new unit test spawns printenv through run_scenario. That races the
existing stub-bd test, which writes its stub with std::fs::write and then
execs it: a fork while the write fd is open makes the exec fail with ETXTBSY
(rust-lang/rust#114554). Serialize both spawning tests on a SPAWN mutex.
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>
* test(cmd/bd): repair the embedded-gated tests that rotted while no lane ran them
These tests skip unless BEADS_TEST_EMBEDDED_DOLT=1 but no CI lane selected
them, so they rotted unseen. Running them shows:
- TestEventsTailFollowReportsTruncationOnTheStream raced on a plain
bytes.Buffer that os/exec's copy goroutine writes while the test polls it.
Use the package's syncBuffer.
- TestCorruptMetadataDiagnosticsRunAndDataFailsLoud still asserted that
doctor and init run on a corrupt metadata.json. #4857 deliberately made
every workspace command refuse instead (pinned for doctor by
TestDoctorRejectsCorruptMetadataBeforeSharedServerChecks). Rewrite it to
the shipped contract as TestEmbeddedCorruptMetadataFailsLoudUntilRestored:
version warns, doctor/list/init refuse naming the file without touching
it, and restoring the file brings the data back.
- dolt_remote_origin_guard_embedded_test.go was tagged
`embeddeddolt && cgo`, a tag no lane sets, so it never compiled in CI
(gazelle left it out of bd_test srcs). Retag it `cgo`, as #4153 did for
its dolt_local_only sibling, and add it to srcs. Drop its four bd doctor
git-origin tests: bd doctor runs no checks on an embedded workspace
(GH#3794), so two could never pass and two passed vacuously on empty
output. Rename the surviving tests into the TestEmbedded* prefix.
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>
* ci(embedded): run every BEADS_TEST_EMBEDDED_DOLT-gated cmd/bd test in the embedded lane
The embedded-Dolt cmd lane selected tests with
grep '^func TestEmbedded' cmd/bd/*_embedded_test.go, and only its two
Bazel targets set BEADS_TEST_EMBEDDED_DOLT. A test that skips without the
variable but missed the name prefix or the file suffix skipped in every
lane and reported green: 92 of them, including #7203's --if-revision CLI
coverage (TestIfRevisionMatchAndMismatch, TestReassignFenceCLI, ...).
- embedded-test-shard.sh and gen_embedded_cmd_shard_manifest.py select
TestEmbedded* by name across cmd/bd/*_test.go, as proxied-test-shard.sh
does, leaving authors one rule.
- Rename the gated tests into the TestEmbedded* prefix
(TestDoctorEmbedded<X> -> TestEmbeddedDoctor<X>) and update every
reference.
- Place the new names with gen_embedded_cmd_shard_manifest.py 100
--weights=duration --write (incremental).
- Add TestEmbeddedGatedTestsRunInTheEmbeddedLane: it walks cmd/bd's tests
for any that reach os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" and fails
if a shard of the lane never lists one. The proxied guard's helpers now
take the variable and the script; a fixture test pins the walk.
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>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(httpclient): remember the server's external-dependency policy across processes
Every bd ready over an HTTP workspace fetched GET /v0/beads/context before
its listing. listReadyWork itself needs no handshake; the fetch came from the
external-dependency decorator asking ServerEnforcesExternalDependencyPolicy
whether the server already applies the policy. In a one-shot CLI that is one
extra round trip per process (about 54 ms at a 52 ms RTT) to relearn a bit
that only changes when the server is restarted with a different composition.
The store opened from a workspace now keeps that answer in the user cache
directory (beads/http-policy/), keyed by the server URL and the project the
workspace pinned at bd connect, for BEADS_HTTP_POLICY_CACHE_TTL (5 minutes by
default; off disables it). A fresh entry answers the probe without dialing; a
handshake this process already holds wins and refreshes the entry. A
workspace with no project pin, and a store an embedder opens through
OpenWith, are not cached. Writing the entry is best effort.
The staleness this allows is bounded by the TTL: a server restarted without
the policy within the window is still trusted to enforce it until the entry
ages out. Carrying the policy on every response would close that window but
needs a server change and does nothing for servers already deployed.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(httpclient): claims and closes ask the server for the policy, never the cache
Review follow-up to the policy cache. The claim and close guards (direct
claim, claim-next, batch close, the lifecycle close and claim, and the legacy
ClaimReadyIssue and CloseIssueChecked) handshake anyway, and a stale cached
"the server enforces it" would stand down their client-side refusal of
externally blocked work. Those entry points now mark their context with
storage.WithLivePolicyProbe, and httpclient.Store answers such a probe from
the server, refreshing the cache entry. Reads keep the cached answer.
Tests: externaldeps TestClaimsAndClosesAskForALivePolicyProbe and
TestRemoteClaimsAndClosesAskForALivePolicyProbe pin which entry points probe
live (every claim and close) and which do not (ready listings), over a local
and a remote store; httpclient TestALiveProbeSkipsThePolicyCache pins the
store side; TestPolicyCacheRefusesEntriesItCannotTrust now also covers an
entry written for another server URL.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(ready): skip the countReadyWork request when bd ready --json prints no total
Over a remote backend, bd ready --json sent GET /v0/beads/ready and then,
whenever the page came back with has_more, GET /v0/beads/ready:count, only to
put "of N" into the stderr hint. Without BD_JSON_ENVELOPE nothing else prints
the total, so that second request (about 120 ms at a 52 ms RTT) bought a
number no caller reads.
On a remote backend without the envelope, bd ready --json now lists one row
past the limit and says whether more exist without saying how many, in the
wording the proxied route already uses. A local store keeps the in-band total
it takes in the page's own transaction, and the envelope keeps
pagination.total. A --max-rows cap at or below the limit keeps the counted
listing, so the extra row never trips the cap.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(ready): say "1 ready issue", not "1 ready issues", in the no-total hint
Review follow-up. The hint the remote --json path shares with the proxied
route now agrees in number; both routes take it from readyHiddenHint, so
they stay one wording.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(startup): initialize packages on four Ps, not every CPU
bd links several thousand packages whose init functions allocate about
20 MB before main runs, which triggers four or five garbage collections.
Each one starts mark workers and stops the world across every P, and on a
large host that costs more than the collection itself: on a 192-CPU machine
`bd version` spent about 20 of its 110 ms there, paid again by every bd
process a script or an orchestrator starts.
internal/initprocs lowers GOMAXPROCS to 4 for the duration of package
initialization. It imports only runtime and syscall, so it initializes
ahead of the heavy packages, and main hands GOMAXPROCS back first thing:
to the GOMAXPROCS environment value when one is set, else to the runtime
default, which keeps tracking the CPU limit.
cmd/bd's TestMain does the same hand-back, since tests never run main, and
resets the -test.parallel default testing derived from the capped count.
Measured on that host (40 runs each, `bd version`): p50 103 -> 86 ms.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(initprocs): tell an explicit GOMAXPROCS hand-back from the runtime default
Review follow-up. TestDoneHonorsAnExplicitGOMAXPROCS swaps the two runtime
calls for recorders and pins that Done restores the exact value when
GOMAXPROCS is set and calls SetDefaultGOMAXPROCS when it is not; the earlier
test only saw the resulting count, which is the same either way on a host
whose default equals the saved value.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(httpclient): name the connect failure when bd serve cannot be reached
A workspace whose server does not answer reported the transport's text:
`cannot reach bd serve at https://host:30699: Get "https://host:30699/v0/beads/context":
dial tcp 100.85.56.42:30699: i/o timeout`. It names the request rather than
the address that failed, and says nothing about what a dial timeout usually
means. An operator chasing an unreachable store had to know that "i/o
timeout" on a dial means the SYN went unanswered.
A request whose connection could not be opened now fails with a
*wire.DialError inside the *ConnectError: a refused connect names the
address and says nothing is listening there; a connect that times out names
the address that never answered, how long the attempt waited, and that a
firewall dropping the connection or a down host is the usual cause; a host
name that does not resolve is named as such. The transport's error stays
reachable through Unwrap, so errors.Is checks (ECONNREFUSED, timeouts) and
*ConnectError classification are unchanged, and a dial the caller canceled
keeps its own error. The events:watch connect gets the same classification.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(httpclient): keep the transport's dial text in connect errors
Review follow-up. The refused and DNS messages dropped "connection refused"
and "dial tcp", the vocabulary gc's text classifier matches to tell an
unavailable store from other failures; without it the dispatcher's serve
loop exits and control beads are quarantined. Every DialError message now
ends with the transport's own *net.OpError text in brackets, after the
explanation.
TestACanceledDialIsTheCallersOwn now actually reaches the ctx.Err() guard:
its round tripper cancels and hands back a genuine refused dial, which the
guard alone keeps from becoming a DialError (removing the guard fails it).
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(agents): bazel test is authoritative; agents never run go test
Agents run tests only with `bazel test`, also while iterating on one
behavior: AGENTS.md shows the focused form
(`bazel test //cmd/bd:bd_test --config=ci --test_filter='^TestName$'`), the
target naming, that one --test_filter covers every target, that a cached
result for unchanged inputs is the same evidence, and that a new test file
needs `make bazel-sync` before Bazel runs it. `go test` (`./scripts/test.sh`,
`make test-go`) stays a convenience for humans working offline. TESTING.md's
focused red/green row and its plain-go-test section say the same.
Why: on the maintainer-city factory host, seats' own uncached `go test`
reruns of the same packages are the largest tool cost in adopt-pr, while
`bazel test` there executes on rbe-west and returns an unchanged target's
cached result in seconds.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(agents): check that a focused test ran; exempt golden regeneration
Review fixes for #7695 (iterations 1 and 2).
The focused form exits 0 with "1 test passes" when the test never ran: a
filter that matches nothing, an integration-tagged file --config=ci does not
compile, the TestEmbedded* name skip, a -short skip, and a parent test whose
every subtest skipped (Go still prints "--- PASS" for the parent). It now
adds --test_output=all, and a run counts only when its log shows
"--- PASS: <TestName>" and no "--- SKIP" for the test or a <TestName>/...
subtest; a subtest that skips by design is left out with a subtest filter.
engdocs/TESTING.md gains "Check That the Test Ran"; AGENTS.md links there
instead of restating it. The section names the tests --config=ci does not
run and the way into each:
- Dolt-backed: the three --test_env flags, or the test's Dolt lane.
- -short-gated: --test_arg=-test.short=false.
- integration-tagged: --config=integration; the Dolt-backed ones of cmd/bd,
tests/regression and internal/storage/dolt run in their Dolt-server lane
target, whose env the suite needs. No lane runs those of other packages
with Dolt, so a failure there is compared with the base commit first.
- TestEmbedded*: --test_arg=-test.skip= lifts the name skip; a test that
then still skips for BEADS_TEST_EMBEDDED_DOLT=1 runs in its package's
embedded-tagged target under --config=embedded (the cmd/bd and
internal/storage/embeddeddolt targets are named).
- files BUILD.bazel does not list: make bazel-sync.
A lane's sh_test can hand the test binary its own -test.run, which
overrides --test_filter, so a trailing --test_arg=-test.run with sharding
disabled selects the test there. In a sharded target the other shards print
"testing: warning: no tests to run". The section also gives the
target-naming rule.
Golden regeneration (make corpus-regen, make githooks-regen,
BD_UPDATE_GOLDEN=1 ... go test, -update-ledger-doc) writes the source tree,
which a Bazel test cannot do: it runs from its runfiles tree, and on
rbe-west update mode fails with "permission denied". AGENTS.md and the new
"Regenerating Golden Files" section exempt these go test runs; where a host
refuses go test even for them, a maintainer regenerates. The factory seat
shim (gastownhall/workflows#102, scripts/seat-bin/go) still refuses update
mode and needs the same carve-out there.
Also: the plain-go-test opener scopes "humans working offline" to the
runner and its go test targets, so the Dolt-backend, fixture and
testing.Short() rules still bind agents; make ci-pr-core is marked plain go
test; the beads-docs skill's docsync gate is the Bazel target; RELEASING.md
and engdocs/RELEASE-STABILITY-GATE.md name the regression suite's Bazel
target (//tests/regression:regression_test under --config=doltserver-cmd)
in place of make test-regression, which is plain go test.
Measured on rbe-west (exit 0 unless noted). Iteration 1, at c4d5409895:
- a mistyped filter, and //internal/compact TestNew (integration-tagged)
under --config=ci: "testing: warning: no tests to run"
- TestNew under --config=integration: "--- SKIP" (BEADS_TEST_SKIP=dolt);
with the Dolt flags added it runs (and fails, exit 3, on the local
backend: its store finds no "beads" database; outside this PR)
- TestConcurrentHeartbeatReclaimClose with the Dolt flags: "--- SKIP"
(short mode); plus --test_arg=-test.short=false: "--- PASS"
- //cmd/bd:bd_embedded_test, sharding disabled: --test_filter alone ran
TestEmbeddedUpdateConcurrent (manifest shard 1's test); the trailing
-test.run ran "--- PASS: TestEmbeddedShowBasicsAndJSON"
- //scripts:go_test_sources_test
TestEmbeddedCmdShardManifestBareWriteIsIdempotent: --config=ci "no tests
to run"; plus --test_arg=-test.skip=: "--- PASS"
Iteration 2, at b1d25543aa (the same Go inputs):
- //internal/storage/dolt:dolt_test TestMoveIssuePersistenceInTxTransitions
under --config=ci: "--- PASS" for the parent and "--- SKIP" for all 6
subtests (BEADS_TEST_SKIP=dolt), "1 test passes"; with the Dolt flags and
--test_filter='^TestMoveIssuePersistenceInTxTransitions$/^persistent-to-ephemeral$'
"--- PASS" for the parent and that subtest only, no "--- SKIP"
- //internal/storage/embeddeddolt:embeddeddolt_test
TestEmbeddedRemoteMigrateGate_BlocksReopen under --config=ci plus
--test_arg=-test.skip=: "--- SKIP" (BEADS_TEST_EMBEDDED_DOLT unset);
//internal/storage/embeddeddolt:embeddeddolt_embedded_test under
--config=embedded, sharding disabled, trailing -test.run: "--- PASS"
(the shard script listed 433 tests; only the named one ran)
- --config=ci plus --test_arg=-test.skip=: "--- PASS" for //tools/nogo
TestEmbeddedConfigIsTheRepositoryConfig and //internal/tracker
TestEmbeddedDoltExternalRefChangedAfterUsesHistoryFastPath
- sharding disabled, trailing -test.run: "--- PASS" for
//internal/storage/dolt:dolt_server_full_test
TestWispDeleteCascade_TransactionDeleteIssue under
--config=doltserver-integration, and for //cmd/bd:bd_dolt_server_test
TestCLI_ReopenClearsDeferUntil under --config=doltserver-cmd
- make check-docs: exit 0 (docsync: 10 test cases ran, none skipped)
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>
---------
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(setup): keep bd setup claude --global's section in ~/.claude/CLAUDE.md
bd setup claude --global put its hook in ~/.claude/settings.json but wrote
the managed beads section into the current directory's CLAUDE.md, and
--remove --global stripped it from there. Run from $HOME it created
~/CLAUDE.md with project scaffolding, which stops Claude Code reading
AGENTS.md in projects below it; run inside a project it removed the
section that project's own install had written, leaving its hooks.
A global install and removal now manage the section in Claude Code's
user-level ~/.claude/CLAUDE.md (created holding only the section, no
project scaffolding), with hints naming bd setup claude --global. With
global or plugin hooks, --check reports that file when the project's
instructions have no beads section; a project install is still judged
on the project's file alone. Project installs are 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>
* fix(setup): render the user-level CLAUDE.md section independently of the project
~/.claude/CLAUDE.md is shared by every project, but bd setup claude --global
rendered and --check judged its section with the current directory's beads
config (sync.remote, sync.git-remote, no-push). From a project with a remote
and one without, --check called the other's install stale and its hint
flipped the file back. The user-level file now always renders with the
default options, so install and --check agree across projects.
Also pin --check's fallback to the project's file and project hint when
neither file has a section, tell existing --global users to re-run it, and
name ~/.claude/CLAUDE.md in the ide-setup recipe table.
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>
* fix(setup): judge the user-level Claude files from $HOME and ~/.claude
Run from the home directory, the project's .claude/settings.json is the
global one, so bd setup claude --check reported a global install as project
hooks and judged ~/CLAUDE.md; its "Run: bd setup claude" hint then created
the ~/CLAUDE.md a global install exists to avoid. Run from ~/.claude, the
project's CLAUDE.md is the user-level file, and --check judged it with that
directory's render options and the project hint.
--check now reports hooks as global from $HOME and judges the user-level
file there and from ~/.claude with the fixed options and the --global hint.
With user-level hooks and no section in either file it names --global
unless the project has its own CLAUDE.md. A --remove run from $HOME, which
removes the global hooks, also removes the user-level section.
The init agent-artifact test ran bd setup claude with HOME at the project,
so its checks would now see a home directory; it gets a separate HOME and
its goldens are unchanged.
Rebase note (maintainer): rebased onto main after #7678 merged; main's
agent-artifact harness already runs bd with a separate HOME, so this
commit's harness edits to cmd/bd/agent_artifacts_embedded_test.go were
dropped.
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>
* test(setup): pin --check's user-level choice beside project instructions
With global hooks, --check judges ~/.claude/CLAUDE.md when the project's
own CLAUDE.md has no beads section but the user-level file has one, and
when run from the home directory whose ~/CLAUDE.md has no section. Nothing
exercised either half of that condition: replacing it with false left the
suite and goldens green. Add a subtest for each; each now fails when its
half of the condition is dropped.
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>
* fix(setup): name --global when --check finds no hooks from $HOME
From the home directory --check with no hooks said 'Run: bd setup claude'.
Following it runs a project install there, which creates ~/CLAUDE.md with
project scaffolding, the file that stops Claude Code reading AGENTS.md in
the projects below it. The missing-section hint at home already names
--global; make the missing-hooks hint match, with a subtest.
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>
* docs(setup): qualify the --global CHANGELOG entry; watch ~/.claude/CLAUDE.md
The CHANGELOG said --check from the home directory judges the user-level
files, but a beads section still in ~/CLAUDE.md is judged instead, and
the --global hint for a missing section applies only when the project has
no CLAUDE.md of its own. Say both, mention the new missing-hooks hint at
home, and re-wrap the paragraph.
The embedded agent-artifact harness comment said a global install writes
$HOME/CLAUDE.md; it now writes $HOME/.claude/CLAUDE.md. Track that path
too and reword the comment. The bd init goldens do not change.
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>
* fix(setup): word the user-level CLAUDE.md section for repositories that use beads
bd setup claude --global writes its section to ~/.claude/CLAUDE.md, which
Claude Code loads in every project, but rendered it with the project
wording: "This project uses bd (beads)" and "Use bd for ALL task tracking —
do NOT use TodoWrite". In a repository without beads that told the agent to
give up its own task tools and pointed it at bd, whose answer there is
"run 'bd init'", while the global hook, bd prime, stays silent outside a
workspace.
RenderOpts.UserLevel rewords the opening line and the task-tracking rules of
both profiles so they apply only in beads repositories. The global env fixes
it through agents.UserLevelRenderOpts, so install, in-place update and
--check agree on the hash from every directory, and a project-worded section
left in ~/.claude/CLAUDE.md reads as stale and is reworded by --global. The
new minimal-user and full-user variants are pinned by golden and hash; the
project rendering is unchanged.
Also pin sameDir's symlink following: --check from a symlink to $HOME or to
~/.claude still judges the user-level files.
Refreshed onto main past #7692, whose --remove takes the blank lines
around the section with it and whose setup appends a section after one
blank line: claude-setup-global-beside-project-install.golden no longer
records the old hole (an extra blank line before the appended section,
two left behind by --remove --global).
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>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
run_scenario always ran `bd init -p <prefix> --quiet` before a scenario's
steps. 43 deterministic catalog scenarios start with their own
`init --prefix X --non-interactive ...`; in 40 of them that step always hit
"This workspace is already initialized" (exit 1), pinning the double-init
refusal instead of a real init. The other 3 fail flag validation first,
which is what they test, and are unchanged. Their later steps (the commands
they are named for) ran against the harness's own pre-init and are
unaffected.
A scenario whose first step's command token is `init` now owns
initialization (Scenario::owns_init) and starts in an empty workspace; every
other scenario keeps the pre-init, and a later `init` step stays a re-init.
The pre-init decision is the pure harness_init() helper, and the step loop
is run_steps(), which takes the command runner as a closure.
normalize() now collapses the `Repository ID`/`Clone ID` values a real init
prints (hashed from the random workspace path) to <REPO_ID>/<CLONE_ID>.
init_proxied_server_not_implemented is marked deterministic:false: its
premise is stale and, un-masked, it starts a managed dolt sql-server.
New tests cover the owns_init rule, the harness_init decision, the
run_steps argv sequence (via a recording closure) and the fingerprint
normalization. None spawns a process, so none can hit the write-then-exec
ETXTBSY race against the suite's process-spawning tests.
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>
A new AGENTS.md written by bd init rendered its managed section with the
HasRemote/NoPush rule, but wrote the template text around it verbatim, so
the Quick Reference still listed `bd dolt push` in workspaces with no Dolt
remote or declared no-push. Add EmbeddedDefaultWithOpts, sharing one
omitsDoltPush predicate with the managed-section renderer, and use it for
new AGENTS.md files. Managed-section bytes and hashes are unchanged; an
existing AGENTS.md and a custom --agents-template are written as before.
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>
* refactor(timeparsing): export IsCompactDuration
The query lexer keeps its own copy of the compact-duration unit set, and
that copy has drifted from the grammar: it accepts the uppercase units
H D W M Y, which ParseCompactDuration rejects. Export the classifier so
the lexer can ask timeparsing instead of keeping a copy, and pin that it
agrees with ParseCompactDuration on every row, uppercase spellings
included.
AC: AC-1
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(query): classify durations with timeparsing.IsCompactDuration
The query lexer kept its own copy of the compact-duration unit set:
isDurationSuffix for single runes and durationWords for "min". The copy
had drifted. It accepted H D W M Y, which the case-sensitive grammar
rejects, so "created>30M" reached the evaluator as a duration and failed
with the internal error `not a compact duration: "-30M"`, quoting a value
the user never typed.
Classify the whole digit-led lexeme with timeparsing.IsCompactDuration
and delete the copy (isDurationSuffix, durationWords, acceptDurationWord).
Uppercase units now lex as identifiers and fail as an unparseable time;
every lowercase input lexes as before. A unit added to compactDurationRe
now reaches the lexer with no edit here: with "sec" added to the regex
alone, TestCompactDurationGrammarReachesQueryPlane fails on the old lexer
and passes on this one. Retire that test's text naming the deleted copy.
AC: AC-2
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(query): pin that uppercase duration units lex as identifiers
"updated>30M", "updated>30H" and "label=30D" lex the value as one
TokenIdent with the text as typed; "updated>30m" and "updated>+30d"
still lex as TokenDuration. On the base lexer the three uppercase rows
fail (typed DURATION).
AC: AC-3
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(query): pin the error for an uppercase duration unit
created>, updated<, closed>= and started<= compared to 30M, 30D, 30W,
30Y, 30H or 1H, alone or in "... OR status=open", fail with
`cannot parse time expression: "<value as typed>"`, never with the
internal `not a compact duration` error and never quoting the negated
"-<value>". 30MIN and 30Min, which always took this path, are the
controls. On the base lexer 30 of the 40 subtests fail; the 10 controls
pass.
AC: AC-4
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(query): bind the lexer's duration grammar to timeparsing both ways
TestCompactDurationGrammarReachesQueryPlane asserted only that every
suffix ParseCompactDuration accepts lexes as a duration. Assert the
reverse too: a suffix it rejects must not lex as TokenDuration, or the
evaluator fails on it with ParseCompactDuration's internal error about a
negated value. Widen the candidates to every one- and two-letter ASCII
suffix in either case, every three-letter lowercase one, and every case
spelling of an accepted three-letter unit.
On the base lexer the reverse sweep fails on exactly [D H M W Y]. A
mutant that case-folds before classifying fails it on those plus the
seven other spellings of "min".
AC: AC-5
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(query): pin that a signed uppercase unit stops at the parser
"created>+30M" and "created>-30M" fail Parse and EvaluateAt with
`unexpected token "M" at position 11 (expected end of query)`, as
"created>+30x" already does: a signed digit run has no identifier
fallback, so "+30" is a number and "M" a stray token. On the base lexer
both parsed as a duration and failed in the evaluator with
`not a compact duration: "-30M"` and `"--30M"`; the +30x control passes
on both.
AC: AC-6
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(query): pin the values rejecting uppercase units leaves alone
At a fixed now, created>+30d is still 30 days ago, updated>5pm still
17:00 that day, and label=30M / title=30M still filter the literal
"30M". TestQueryMinutesUnitResolvesAgo already pins created>30m (30
months ago) and created>30min (30 minutes ago). These rows pass on the
base lexer as well, which is the point; a lexer mutant that stops typing
signed lexemes as durations fails the +30d row.
AC: AC-7
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(config): stop bd config set truncating config.yaml at a 64 KiB line
updateYamlKey's flat-key path reads config.yaml through a default
bufio.Scanner and never checked scanner.Err(). A line of
bufio.MaxScanTokenSize (65,536) bytes or more makes Scan return false
partway through the document, so the function returned the lines read
so far with a nil error and setYamlConfigAtPath wrote them over the
file, dropping the long line and everything after it. Measured at
5c9c02ab77: a 65,550-byte document came back as the 8-byte
`k1: "zz"` when the key was present, and as 16 bytes when it was absent
(the new key appended onto the truncated prefix).
Check scanner.Err() after the loop and refuse with an error that wraps
bufio.ErrTooLong. It is returned before setYamlConfigAtPath's
os.WriteFile, so `bd config set` and `set-many` now fail and leave the
file as it was. The guard returns only on a scan error, so a document
whose lines all fit gets the same rewrite as before. Unset
(commentOutYamlKey) already splits instead of scanning, and dotted keys
rewrite through yaml.Node, so neither needs it.
TestUpdateYamlKeyRejectsOversizeLine fails at the base (nil error, 8-
and 16-byte results) and passes with the guard. Adds a CHANGELOG
Fixed entry.
AC: AC-1
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin that a line just under the scanner limit still rewrites
The oversize-line refusal must fire only at the bufio.Scanner cliff. The
default scanner buffer holds bufio.MaxScanTokenSize (65,536) bytes, so a
line of 65,535 bytes still fits with its newline, and updateYamlKey has
to give a document with such a line the same rewrite a short document
gets: the key replaced in place when present, appended when absent.
Adds both rows to TestUpdateYamlKeyRejectsOversizeLine. They pass at the
base and with the AC-1 guard, which returns only on a scan error. Two
over-eager variants of the guard pass the existing yaml tests and the
AC-1 rows but fail these rows: capping the scanner buffer at
MaxScanTokenSize-1, and a pre-scan length check that refuses a line of
MaxScanTokenSize-1 bytes.
AC: AC-2
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin that a refused bd config set leaves config.yaml unchanged
setYamlConfigAtPath reads config.yaml, rewrites it through
updateYamlKey, and writes the result back. The AC-1 guard makes
updateYamlKey refuse a document with a line of bufio.MaxScanTokenSize
bytes or more, and setYamlConfigAtPath returns that error before its
os.WriteFile, so the file is never touched. No test covered that order.
TestSetYamlConfigAtPathOversizeLineLeavesFileUntouched writes a
config.yaml with a 65,538-byte comment line, sets no-db, and checks that
the error wraps bufio.ErrTooLong and that the file still holds all
65,563 of its bytes. At 5c9c02ab77 it fails both checks: a nil error,
and the file cut to the 11-byte `no-db: true`. It passes with the AC-1
guard and needs no code change of its own. A variant that writes the
file before returning the error fails the byte check (0 bytes left), and
one that swallows the error fails the error check.
AC: AC-3
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(changelog): say set-many keeps keys it wrote before a refused one
The entry said `bd config set` and `set-many` both fail and leave
config.yaml as it was. That holds for `set`, and for a `set-many` whose
first config.yaml key is the refused one. But `set-many` writes its
config.yaml pairs one at a time, in argument order, and returns on the
first error with no rollback, so a key listed before the refused
undotted key (a dotted `sync.remote`, say) is already on disk when the
command exits 1.
Measured at 0d3aa63761 with a 70,000-byte comment line in config.yaml:
`bd config set-many sync.remote=git@example.com:o/r.git actor=bob`
exits 1 and adds the `sync:` block (70,039 -> 70,083 bytes);
`set-many actor=bob sync.remote=...` and `bd config set actor bob` exit
1 and leave the file byte-identical.
de330c3e7f's message makes the same claim; this commit does not rewrite
it.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
outputDotFormat declared nodes and edges in the order of the list page it
was handed. The default page order breaks priority ties by created_at at
one-second precision, so two equal-priority issues swapped places depending
on whether they were created in the same second, and the proxied route's
edge query orders by source only. The same graph printed different bytes
(Oracle A list_dot_format_dependency_edges flipped between runs).
Declare nodes in byte order of id and each node's edges in byte order of
(target, type), on copies of the caller's slices. --sort and --limit still
choose which issues are listed.
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>
* test(bazel): pin vet policy to module toolchain (wy-kk1b9a)
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Steve Yegge
* test(bazel): report an unavailable pinned toolchain as a missing host tool
Review fixes for #7668 (adopt-pr iterations 1-2).
The GOTOOLCHAIN pin added a failure path that base did not have. A host
that runs another Go release and cannot fetch go.mod's toolchain
(offline, GOPROXY=off, empty module cache) failed
TestPRRunsGoTestsBazelSkips with a bare "exit status 1": cmd.Output()
keeps the go command's stderr in the ExitError, and t.Fatal printed
only the status.
- Report the failure through skipOrFailWithoutHostTool, naming the
pinned version and the go command's stderr when it printed any.
Plain go test skips; Bazel still fails, and there the registered SDK
is go.mod's toolchain, so nothing is fetched.
- Compare VET_PASSES in a subtest, so the skip covers only the check
that needs the toolchain. Given the parent's t, it skipped the whole
test, and with it the six checks after it that read only the
checkout. A failed subtest still fails the parent, so Bazel stays
fail-closed.
- Pad a two-component version ("go 1.26" with no toolchain line) to
go1.26.0 in goToolchainName, as scripts/ci/gofmt-bin.sh does.
GOTOOLCHAIN=go1.26 is rejected as a language version, not a
toolchain version. A table test pins 1.26, 1.26.7 and 1.26rc1.
- Say in the helper comment that the pin overrides an ambient
GOTOOLCHAIN, local included, and may download into GOMODCACHE.
Validated with go1.26.7-built test binaries under env -i, GOPROXY=off,
with an empty HOME and module cache unless noted:
- go1.26.9 host: the VET_PASSES subtest skips, naming go1.26.7 and
"toolchain not available", and the parent passes. With a planted
scripts/ci/go-test-vet.sh the parent fails, as on base; iteration 1
skipped the whole test there (rc 0). Same on go1.26.5 with
GOTOOLCHAIN=local.
- go1.27.1 host with go1.26.7 cached: passes; base fails on
stdversion. go1.26.7 host: passes.
- Bazel branch (TEST_SRCDIR, BEADS_TEST_GO): SDK go1.26.7 passes. SDK
go1.26.9 fails the subtest and the parent with "executor lacks a
host tool". A non-executable SDK path ends the message with the exec
error, with no dangling ": ".
- go.mod "go 1.26" without a toolchain line: passes on go1.26.0 and
under Bazel with SDK go1.26.0; a go1.26.9 host skips, naming
go1.26.0. Iteration 1's unpadded mutant only skipped under plain go
test (it failed under Bazel); the table test now fails it, and fails
mutants that count dots or drop the regex anchors.
- go test ./scripts on go1.26.7: 306 pass, 0 fail, 1 skip; the only
outcomes not on iteration 1 (305/0/1) are the two new tests passing.
go vet ./scripts and the pinned gofmt -l are clean.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(config): keep config.yaml's trailing newline on bd config set
updateYamlKey's flat-key path, which `bd config set` takes for every
single-segment key, read the document with bufio.Scanner and joined the
lines back with "\n". ScanLines drops the final terminator, so the result
was exactly one newline short of any terminated config.yaml:
"issue_prefix: vp\ndolt.mode: server\n" came back without its final
newline, a spurious no-newline-at-end-of-file change in a git-tracked file.
Re-attach the input's own trailing run at the return, the tail
commentOutYamlKey got for the unset side in #6749. One statement covers
both the in-place and the appended branch, and a document without a
trailing newline still does not acquire one. The TODO that recorded the
defect is removed in the next commit.
The test file's header now covers both verbs; the set test follows the
unset ones.
AC: AC-1
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(config): drop the TODO that deferred the bd config set newline fix
The TODO above updateYamlKey's return recorded that `bd config set` was
knowingly left one newline short, as a scope call in #6749. The previous
commit fixed that, so the TODO now describes a defect that no longer exists.
Check: searching internal/config/yaml_config.go for the phrase
"`bd config set` is knowingly left unfixed" finds one match at the base
and none after this commit.
AC: AC-11
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin a set's blank-line trailing run, not just a final newline
A config.yaml that ends in one or two blank lines came back from
`bd config set` one newline short, so the output still ended in "\n".
Compare the exact trailing run, as the unset table does, so that loss
stays visible. Both rows fail on the base code (run "\n" vs "\n\n", and
"\n\n" vs "\n\n\n") and pass with the tail fix.
AC: AC-2
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin the appended key's terminator on bd config set
When the key is absent, updateYamlKey appends it as the new last line,
and the old join left that line unterminated: "x\n" came back
"x\n\nnewkey: \"v\"". Pin the exact output for "x\n", where the separator
blank line is kept and the newline follows the new key, plus a table row
for the trailing run. Both fail on the base code and pass with the tail
fix.
AC: AC-3
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin a set appended over a blank-line tail
For "x\n\n" without the key, the existing blank line already separates,
so updateYamlKey adds no second one and the document's own two-newline
run now follows the new key: "x\n\nnewkey: \"v\"\n\n". Restoring a single
newline would leave this exact shape one short again, so pin it exactly,
plus the matching table row. Both fail on the base code, which returned
"x\n\nnewkey: \"v\"", and pass with the tail fix.
AC: AC-4
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin that a set does not invent a trailing newline
The repair re-attaches the document's own trailing run instead of appending
a newline, so a config.yaml that ends without one still ends without one
after `bd config set`. Pin that for both branches: a present key rewritten
in place, and an absent key appended as the new last line.
This passes on the base as well; it is a pin on "preserve, not append".
The always-append mutant (`return out + "\n", nil`) turns both inputs red.
AC: AC-5
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin a set's output on a CRLF config.yaml
A set of a single-segment key has always rewritten a CRLF document to LF,
because the scan drops each line's "\r". What the old join added on top was
a missing terminator: "actor: a\r\nother: x\r\n" came back
"actor: \"b\"\nother: x". With the restored tail it comes back
"actor: \"b\"\nother: x\n", which is also how an unset of the same document
ends.
Pin the exact output, and check the trailing run against commentOutYamlKey
on the same input, in a subtest named after unset's CRLF subtest. It fails
on the base (exact and parity) and passes with the tail from AC-1.
AC: AC-6
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(config): keep a CRLF config.yaml's blank-line tail on bd config set
The restored tail measures the trailing run on the raw content, where
strings.TrimRight(content, "\n") stops at the last "\r". On a CRLF file the
re-attached run was therefore always a bare "\n", however many blank lines
followed: "actor: a\r\nother: x\r\n\r\n\r\n" came back "…x\n", one newline
shorter than even the base's "…x\n\n".
Normalize CRLF the way commentOutYamlKey does before the scan, so the run is
the LF run and a set ends the file exactly as an unset of the same document
does. The scan output is unchanged, since ScanLines already drops each
line's "\r". The line sits below the nested dispatch, not at the top: some
updateNestedYamlKey branches carry "\r" through on untouched lines, and
this fix leaves that path alone.
Also correct the comment on unset's CRLF subtest, which still blamed a
leftover "\r" for the bare-"\n" tail; commentOutYamlKey normalizes up front,
so that mechanism no longer exists and the new set cases contradict it.
AC: AC-7
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin the trailing newline through SetYamlConfig
setYamlConfigAtPath writes updateYamlKey's output verbatim, so the dropped
newline reached the git-tracked config.yaml. Add the writer-level twin of
TestUnsetThroughTheFileKeepsTheTrailingNewline: a .beads/config.yaml ending
in a blank line, BEADS_DIR pointed at it, SetYamlConfig("actor", "bob"),
and the re-read file must keep its "\n\n" run. It first checks that the
value landed, so an untouched file cannot pass.
On the base the run comes back "\n"; with the tail from AC-1 it is "\n\n".
AC: AC-8
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(config): pin that a set of a dotted key bypasses the CRLF normalization
The CRLF normalization in updateYamlKey sits below the nested dispatch on
purpose. replaceFlatKeyLine and appendNestedYamlKey keep "\r" on the lines
they leave alone, so hoisting the line above the dispatch would silently
change what a dotted-key set writes:
"issue_prefix: vp\r\ndolt.mode: server\r\n" comes back
"issue_prefix: vp\r\ndolt.mode: \"embedded\"\n" today and would lose the
first "\r".
Compare updateYamlKey with updateNestedYamlKey on four CRLF documents for
dolt.mode: a literal dotted key, a nested block, an absent key, and a
comment-only document. This passes on the base as well; it pins the
boundary, not the nested writer's outputs. The hoisted mutant turns the
literal-dotted-key and comment-only rows red; the other two are re-marshalled
to LF either way.
AC: AC-9
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(config): append an absent key after a blank-line tail as one line
updateYamlKey's flat path appends an absent key after the scan's empty
tokens for the file's trailing blank lines, so those blank lines already
sit ahead of the new line; the tail rule then re-attached content's whole
run after it as well. A set of a new single-segment key on a file ending
in blank lines therefore repeated them at EOF: "x\n\n" came back
"x\n\nnewkey: \"v\"\n\n", "x\n\n\n" came back
"x\n\n\nnewkey: \"v\"\n\n\n", and CRLF "x\r\n\r\n" came back
"x\n\nnewkey: \"v\"\n\n" -- the diff noise this PR exists to remove.
The appended branch now re-attaches only the one terminator
bufio.Scanner dropped, and only when content had it; the in-place branch
keeps the TrimRight + content's-run rule it shares with
commentOutYamlKey. The appended-key subtest now wants
"x\n\nnewkey: \"v\"\n", adds "x\n\n\n" and CRLF rows, and drops the
comment claiming a single terminator would leave it one newline short.
The suffix-run table drops its blank-tail append row, whose expectation
assumed the file's run follows the key, and
TestSetOfAnAbsentKeyThroughTheFileAddsOneLine pins the shape through
SetYamlConfig. The doc comment states the nested boundary and the tail
rule.
Not changed here: the unchecked scanner.Err() is #7670's fix (its guard
lands right after this scan loop, and ./internal/config/ is green on the
union of both PRs). The stale bufio.Scanner narration in
commentOutYamlKey's comment stays a follow-up, since #7613 edits that
function.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* fix(cli): refuse backup init/sync/remove and import under --readonly
Strict --readonly is meant to refuse every command that writes, with
"Error: operation '<op>' is not allowed in read-only mode" and exit 1.
bd backup init, backup sync, backup remove and bd import never called
CheckReadonly, so that gate never refused them:
- On a server-mode store they ran to completion under --readonly:
backup init and backup remove rewrote or emptied the server's
dolt_backups registry, backup sync wrote the backup destination, and
import wrote issues.
- On an embedded store they failed only because the store was opened
read-only, with the storage layer's "store is read-only" text, and
backup sync took the backup lock first and left .beads/backup.lock
behind.
The three backup verbs now call CheckReadonly first in their RunE, as
the other write commands do. Its migration-freeze half is redundant for
them: their leaf names are not on the read-only list and they have no
preview flag, so PersistentPreRunE's early freeze gate refuses them
first.
bd import calls it only when --readonly is set. CheckReadonly also
answers a migration freeze, and does so by exiting the process, while
runImport answers a freeze by returning the error so cleanup still
runs; guarding the call leaves that path exactly as it was.
bd import --dry-run is refused too. The preview opens the store
read-only and writes nothing, so this is a policy choice. It matches
create --dry-run (also refused under --readonly) and import's own
freeze posture: a migration freeze already refuses import --dry-run
(TestImportBlockedDuringMigrationFreeze), and CheckReadonly treats the
two gates as one. The cost is small, since the same preview runs
without --readonly. bd backup status and bd backup itself (a command
group that only prints help) stay allowed.
TestBackupAndImportBlockedInReadonlyMode runs each command, plus
import --dry-run, under --readonly and --readonly --sandbox against an
embedded workspace and one on the Dolt test server. Each row expects
exit 1, exactly the standard refusal on stderr, an empty stdout, and
nothing changed: the .beads tree, the backup destination, the issue
count, and, in server mode, the dolt_backups registry.
TestBackupStatusAndListWorkInReadonlyMode is the control showing that
backup status and list still run.
Ported from the versioned-beads fork: b86df6a9eb (test) and
5a067acc56 (fix). The comment on TestImportBlockedDuringMigrationFreeze
is updated, since runImport now calls CheckReadonly under --readonly.
Co-authored-by: Jim Wordelman <jim@wordelman.name>
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>
* fix(backup): refuse --readonly backup restore before the exclusive gate
A restore replaces the store, so strict --readonly must refuse it.
Nothing did:
- In server mode no storage layer stops the connection, so
`bd --readonly backup restore --force` ran to the end: exit 0,
"Restore complete", and the store was replaced.
- In embedded mode the command took the EXCLUSIVE workspace gate first,
leaving the holder sidecars (.beads.gate.lock.info,
.beads/embeddeddolt.gate.lock.info) behind, and was stopped only
later by the storage layer's "store is read-only".
acquireCommandWorkspaceGates now calls CheckReadonly("backup restore")
first for the exclusive (restore) case when readonlyMode is set. That
is before any gate file is created or the store is opened, so nothing
is held and the exit skips no release. The guard checks readonlyMode
alone, so a restore without --readonly, including one refused by a
migration freeze, keeps its existing order. The restore RunE also calls
CheckReadonly first, as every write command does.
This does not depend on the strict-readonly SHARED-gate change
(workspacegate.Options.ReadOnly): the refusal comes before any gate is
built.
The one visible change in proxied-server mode, where every --readonly
command is already refused: `bd --readonly backup restore` now gets
this standard refusal (plain text, exit 1). Before, the proxy
capability refusal answered it (exit 1, typed JSON under --json), and
only after the exclusive gate had been taken.
TestEmbeddedBackupRestoreStrictReadonly and
TestBackupRestoreStrictReadonlyServerMode run the built bd as a
subprocess, because CheckReadonly exits. The workspace's live store
holds three issues and its backup holds two. Each test asserts the
standard refusal with exit 1 and an empty stdout, no storage-layer
message, an unchanged project directory and .beads tree, and an
unchanged issue count. Each runs under --readonly and under
--readonly --sandbox. A control restores without --readonly and
expects two issues, so "unchanged" cannot be vacuous.
Ported from the versioned-beads fork: 1cd5f1c202 (test) and
6ac79d6207 (fix). The fork's test used a dirEntryNames helper that
belongs to its separate SHARED-gate change. It is inlined here so this
change compiles and lands on its own in either order. The server test's
comment is corrected too: the fixture's backup and the restore both run
inside the server at the same path, so it passes against a
containerized test server as well as a local one.
Co-authored-by: Jim Wordelman <jim@wordelman.name>
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>
---------
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(setup): leave a current agents-file beads section untouched
installAgents rewrote the instructions file whenever it found a beads
marker, discarding ReplaceSectionWithOpts' changed flag and error. A rerun
of `bd setup claude` (and `bd init`, which runs it) replaced a byte-identical
CLAUDE.md with a new file (new inode, fresh mtime, mode reset to 0644) and
reported "Updated existing beads section", while bd init's updateAgentFile
reported AGENTS.md current in the same run. A section whose END marker was
lost or came before BEGIN was likewise "updated" without change.
Mirror updateAgentFile: write only when the section changes, report
"<file> already has the current beads section" otherwise, and return
ErrMalformedMarkers instead of rewriting. claude/gemini warn and continue;
factory/opencode/mux fail (mux before installing its .mux hooks), per their
existing error policies. Tests pin inode, mode and mtime of the untouched
file and the claude/mux policies for both malformed-marker shapes. Goldens
updated for the new rerun message.
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>
* fix(setup): keep CLAUDE.md's beads block when the AGENTS.md update fails
When CLAUDE.md is an @AGENTS.md stub that still holds a beads block,
installClaude strips that block once the redirect is active, gated only on
installAgents not having skipped a symlinked AGENTS.md. It ignored
installAgents' error, so now that installAgents returns ErrMalformedMarkers
instead of writing a malformed AGENTS.md back, the strip deleted the stub's
block while AGENTS.md kept no usable section, and the warning named
CLAUDE.md. Base had the same end state behind a false "Updated" report; the
new error is what makes the failure detectable, so the gate belongs here.
Gate the strip on a nil installAgents error too, so it runs only once
AGENTS.md holds the current section (written now or already current), and
name the file that failed in the warning (AGENTS.md when redirected). A
redirect subtest in TestInstallClaudeWarnsOnMalformedMarkers pins both, for
both malformed shapes: dropping the gate reds it on CLAUDE.md's content,
inode, mtime and mode, and naming CLAUDE.md again reds it on the warning.
Also correct updateBeadsSectionWithProfile's doc comment, which claimed an
error string it never returned: it returns the content unchanged when the
section cannot be replaced. The CHANGELOG entry notes the redirect case.
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>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* test(cmd/bd): pin mixed-case dep tree --format Mermaid through the CLI
TestDepTreeFormatMermaidCaseInsensitive calls isMermaidTreeFormat directly,
so reverting the runDepTree dispatch to formatStr == "mermaid" (the PR #6646
bug) kept every test green. Add a --format Mermaid call to the embedded
tree_format_mermaid subtest so the flag-to-renderer wiring is pinned.
AC: AC-1
AC: AC-2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c325246d4a)
Ported-From: opus/c325246d4a8e4cd5f60f9548053b5385e20a4d2e
AC: AC-1
* test(cmd/bd): record AC-2 mutant evidence for the mixed-case pin
No code change: AC-2 is the mutant-killing property of the row added in
the AC-1 commit. Evidence (bazel test //cmd/bd:bd_test --config=ci
--test_filter='TestDepTreeFormat|TestEmbeddedDepBTreeAndCycles/tree_format_mermaid'
--test_arg=-test.skip= --test_env=BEADS_TEST_EMBEDDED_DOLT=1
--test_output=all):
- Mutant M1 (cmd/bd/dep_tree.go:153 changed to formatStr == "mermaid",
isMermaidTreeFormat left intact), row absent: all targeted tests pass —
the hole.
- M1 applied, row present: TestEmbeddedDepBTreeAndCycles/tree_format_mermaid
FAILS with the plain-text fall-through header ("Dependency tree for"),
while TestDepTreeFormatMermaidCaseInsensitive, TestDepTreeFormatFlag and
the lowercase e2e row stay green.
- M1 reverted, row kept: all pass; no SKIPs in any run.
AC: AC-2
Agent-Signature: claude-code-glm-5.3-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Code <noreply@anthropic.com>
(cherry picked from commit 38df0c5b22)
Ported-From: glm/38df0c5b224c41fa312dd130b8e7fe378d74b0b4
AC: AC-2
---------
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
* test(cmd/bd): pin comments_omitted on the embedded wisp count-only view
show_json_wisp_comment_count asserted comment_count and the absent
comments slice but never read comments_omitted, the flag the GH#5565
fix unlocks. A regression that stops setting it stayed green here.
AC: AC-1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9b5be54bdf)
Ported-From: opus/9b5be54bdf3c4ef69f5b8eaf68770b26b102ff35
AC: AC-1
* test(cmd/bd): add the embedded --include-comments wisp twin
The proxied plane pins a wisp's comment behavior with a pair of
subtests; the embedded plane had only the count-only half. Add
show_json_wisp_comments_include_streams, which asserts that
--include-comments streams both of a wisp's comments, and let
bdShowDetails carry extra flags after --json.
AC: AC-2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d1795e55f1)
Ported-From: opus/d1795e55f15710e3112a37852361f577d42eeff9
AC: AC-2
* test(cmd/bd): pin count and omitted flag on the embedded wisp include view
GH#5565's symptom was --include-comments returning rows the count said
did not exist. Assert the include payload's comment_count matches the
streamed rows and that comments_omitted stays absent (omitempty) when
rows are present.
AC: AC-3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ae43c79065)
Ported-From: opus/ae43c790652261e5d004bdc1b23b768a391ce8a9
AC: AC-3
---------
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
`bd setup claude --remove` (and the factory, mux, opencode and gemini
recipes that share removeBeadsSection) cut exactly the managed section
and kept the blank lines that set it off, leaving a 3-line hole in the
CLAUDE.md bd init writes. installAgents then appended a re-added section
after two blank lines, so every remove/re-add cycle grew the file.
removeBeadsSection now drops the line breaks next to the section (never
text): the surrounding text is rejoined with one blank line, or none if
the section had none; a section at the top leaves no leading blank
lines and one at the bottom leaves a single final line break. CRLF is
preserved, and a marker sharing its line with text is still cut
exactly. installAgents appends like bd init's updateAgentFile: ensure a
final newline, then one blank line. remove(add(x)) == x for a file
ending in a newline, and after the first remove, setup and --remove
toggle between the same two files; a re-added section goes at the end.
Goldens regenerated with BD_UPDATE_GOLDEN=1.
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>
bd init --quiet still printed "✓ Removed SessionStart hook" and
"✓ Removed PreCompact hook" when the project's .claude/settings.json (or
the legacy settings.local.json) carried the bare `bd prime` hooks an older
bd registered. removeHookCommand printed with fmt.Printf straight to the
process stdout, bypassing the discarding writer that --quiet hands the
project installers.
removeHookCommand now takes the caller's writer; Claude and Gemini pass
env.stdout at every call site. bd setup claude/gemini print the same
lines in the same order; quiet init drops them while still migrating the
hooks. This is the removal half of the #7186 class; #7195 covers
addHookCommand and the two changes merge cleanly in either order.
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>
The scoreboard dumped every in-scope failure to the host-global
/tmp/oracle-a-failures.txt, and run-oracle-a.sh copied it into its scratch
dir only after scoring finished. A concurrent scoreboard (another worktree,
a shard, another user) finishing in between overwrote or swapped the
detail, so a failing run could print nothing or another run's divergence.
The scoreboard now honors ORACLE_FAILURES_FILE (unset or empty keeps the
historical /tmp default for standalone use), and run-oracle-a.sh points it
at $SCRATCH/oracle-a-failures.txt and prints that file directly. The cp
and the /tmp fallback are gone.
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>
run-oracle-a.sh's EXIT trap removed its reference worktree only when
`git worktree list --porcelain | grep -qF "$REF_SRC"` matched. Under
pipefail that check reported a registered worktree as absent in two ways:
grep -q exits on its first match while git is still writing a large
listing, so git dies of SIGPIPE (141) and the pipeline fails; and git
lists the resolved path, which $REF_SRC never matches when $TMPDIR has a
trailing slash or runs through a symlink (both macOS defaults). Either
way the ref-src registration leaked as a prunable worktree.
Run `git worktree remove --force` unconditionally. It resolves the path
itself and fails harmlessly (silenced, `|| true`) when nothing is
registered, so cleanup is idempotent and exit codes are unchanged.
TestOracleAScriptRemovesItsReferenceWorktree runs the real script in a
fixture repo with a stand-in go that fails the reference build, covering
a >3 MB listing, a trailing-slash TMPDIR, a symlinked TMPDIR, and a run
that dies before the worktree is added.
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>
* fix(http): bd link over a connected HTTP workspace, through the DependencyEditor role
bd link wrote through the store's raw AddDependencyWithOptions, which the
HTTP client refuses by design (D8), so every bd link failed on an HTTP
workspace whatever the type. Its direct route now writes through the
DependencyEditor role with the helper bd dep add uses
(addDependencyEdgesDirect), which serves local stores and HTTP workspaces
alike: over HTTP one dependencies:add request, and the server already takes
any 1-32 character type.
link keeps its own checks before the write (and before the dial): the
dotted-child rule and the type's length only, never bd dep add's
well-known-type list. The proxied-server route is unchanged.
backend/http TestE2E_LinkOverHTTP covers owned-by and the other roadmap
types, the empty and over-long type refusals (no write reaches the server),
and the typed conflict for an edge of another type.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* build(bazel): auto-sync BUILD files
Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/39201892756
(`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.
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
showIssueAsOf reported each failed AS OF lookup on stderr and continued, but never counted what it read and returned nil, so a bad ref (an instant or a versioned-history address the Dolt AS OF read does not take, an unknown branch or commit) or an issue absent at the ref exited 0 with an empty stdout, under --json too. Its proxied-server twin, runShowProxiedAsOf, returned nothing and its dispatcher returned nil.
Both now count the issues they read and, when that is zero, end the way plain bd show ends a batch that found nothing: show's JSON error envelope on stdout under --json, a bare exit 1 otherwise, with the per-id reasons still on stderr. A batch that reads at least one issue still exits 0, as plain show's does. The read itself is unchanged (Dolt AS OF).
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>
* test(cmd/bd): pin the command tree and representative --help output
Add two in-process goldens for the bd command surface, so any added,
removed, hidden or reworded command or flag fails until the goldens are
regenerated and shows up as a reviewed testdata diff:
- TestCommandTreeGolden walks the whole cobra tree (hidden commands
included) and records, per command, Use, Aliases, Short, Long, Example,
group, hidden/deprecated state, runnability and annotations, plus every
local and persistent flag it defines (name, shorthand, type, default,
usage, hidden, deprecation, annotations). Output is sorted and rendered
twice to prove it is deterministic.
- TestCommandHelpGolden runs `bd <cmd> --help` through rootCmd for root,
create, show, list, update, close, version, versions, config and serve.
--help returns before the root pre-run, so no store is opened; color
escapes are stripped. The snapshots are byte-identical to a built bd
binary's --help output.
Both run from a fresh ordinary (dependency-mode) workspace: a
.beads/metadata.json with no graph marker and no database behind it.
The tree is primed the way the binary is (main()'s help command and its
--all/--doc/--list/--docs-root flags, ExecuteC's completion command), and
cobra's history-dependent pieces (the lazily added per-command --help flag,
the __complete request commands) are excluded, so the result does not
depend on which in-process tests ran first. The help runs reset every flag
afterwards so a later in-process command does not inherit --help.
docs/cli-docs.pin holds check-doc-flags at the v1.2.2 release, so drift on
main is not caught there; these goldens are the live guard. They pin the
cgo build (the !cgo build swaps in a federation stub). Regenerate with
BD_UPDATE_GOLDEN=1 go test -tags gms_pure_go ./cmd/bd -run '^TestCommand(Tree|Help)Golden$'.
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>
* test(cmd/bd): keep the command goldens from merging flags into the shared tree
TestCommandTreeGolden read each command's flags through
LocalNonPersistentFlags, and TestCommandHelpGolden dispatches
`bd serve --help`. Both run cobra's mergePersistentFlags, which copies
every inherited persistent flag (--json, --db, ...) into the command's
own flag set for the rest of the process. TestServeFlags pins serveCmd's
exact flag set, so it failed whenever a golden test ran before it in the
same test binary: tree then serve flags, help then serve flags, and
-test.shuffle seeds 2 and 3, on the PR head and on its merge with main.
CI passes only because bd_test's 16 Bazel shards happen to run them in
different processes. Of 37 candidate tests, TestServeFlags is the only
one affected.
- goldenLocalFlags reads the set LocalNonPersistentFlags reports without
calling it: c.Flags() minus c's own persistent flags and minus
inherited copies. Like cobra, it treats a flag as inherited only if it
is the nearest ancestor's own *pflag.Flag, so copies left by an
earlier in-process execution are skipped and a flag that shadows an
inherited one still renders.
- TestCommandTreeGolden fails if rendering changes the number of flags
in any command's flag set.
- TestCommandHelpGolden calls restoreServeGlobals, which re-registers
serveCmd's flags after the `bd serve --help` dispatch.
Review minors:
- The regeneration command (doc comment, failure-message constant,
tree.golden header) sets CGO_ENABLED=1. Without cgo the file does not
build, so the command matches no test and exits 0.
- enterOrdinaryWorkspaceForGolden calls isolateBeadsDirForTest.
- renderCommandHelpGolden's comment says when the ANSI strip matters.
- cmd/bd/AGENTS.md lists the goldens under "Adding a command" and
"Guard tests".
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* test(setup): pin the Claude agent artifacts bd init and bd setup claude write
Before-parity pin P11. Nothing pinned the agent artifacts byte for byte, so
a change to them -- a new hook event in .claude/settings.json, new text in
the minimal CLAUDE.md/AGENTS.md template and with it a new marker hash that
marks every installed section stale -- could land without anyone seeing
the user-visible diff. These goldens make any such change a reviewed diff.
- internal/templates/agents: TestManagedSectionGolden pins each managed
section (minimal and full profile, with and without a Dolt remote)
markers included; TestManagedSectionHashes pins their marker hashes as
hand-maintained literals; NoPush is pinned to render the no-remote bytes.
- cmd/bd/setup: TestClaudeSetupArtifactsGolden records transcripts of
bd setup claude, --check and --remove (project, --stealth, --global, a
user's own settings and CLAUDE.md, a stale section, a legacy
settings.local.json install, a CLAUDE.md that imports AGENTS.md): each
step's result and output, and the settings and instruction files it
creates, changes or deletes. TestClaudePluginManifestHookEvents pins the
hook events and commands the beads Claude plugin declares.
- cmd/bd: TestEmbeddedInitAgentArtifactsGolden runs a real bd init (default
and --agents-profile full) and then bd setup claude --check, --remove and
a reinstall through the binary, with exit codes.
A managed section in a transcript is shown by its marker line and a
pointer to the template golden it is checked to match byte for byte, so a
template change shows up once in full and as a hash bump wherever it lands.
Regenerate with BD_UPDATE_GOLDEN=1.
CI companions: the new test files and testdata in BUILD.bazel (bd_test
gains its internal/templates/agents dep), and the new TestEmbedded* in the
100-shard embedded cmd manifest (incremental --write).
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>
* test(setup): drop BD_OTEL_* and split HOME in the agent artifact golden
TestEmbeddedInitAgentArtifactsGolden pins bd's stderr byte for byte, but
bdEnv passes the caller's BD_OTEL_* variables through, and bd prints a
deprecation warning on stderr for a legacy one (BD_OTEL_METRICS_URL,
BD_OTEL_LOGS_URL, BD_OTEL_STDOUT=true) before it checks whether
telemetry is on. On a host that exports them (agent hosts do; CI does
not), both scenarios failed at the first stderr block with no code
drift.
The test now runs bd init and every bd setup claude step with
agentArtifactEnv: bdEnv(dir) without BD_OTEL_* and OTEL_*. It filters
the env slice instead of calling clearTelemetryEnv, which uses t.Setenv
and so cannot run in these parallel tests.
The same helper gives bd a HOME of its own instead of bdEnv's HOME ==
project. With the two equal, a bd that wrote the hook and CLAUDE.md into
the home directory instead of the project passed every pin. The
transcript now also records $HOME/.claude/settings.json and
$HOME/CLAUDE.md, and output paths under HOME read $HOME. bd init runs
the steps bdInit does (git repo, seeded schema) with that env.
The test doc now names what it does not pin: a proxied-server bd init
(no Codex section, HasRemote from its own remote URL), a bd init with a
remote, and the Cursor files. It also says a change to AGENTS.md's
wrapper text or Codex section can fail only here.
The goldens are unchanged.
Validation (env -i, go1.26.7, GOFLAGS=-mod=readonly, GOPROXY=off,
BEADS_TEST_EMBEDDED_DOLT=1, -tags gms_pure_go):
- the golden passes in a clean env; with BD_OTEL_METRICS_URL=x
BD_OTEL_LOGS_URL=y; with every legacy selector plus BD_OTEL_ENABLED
and OTEL_EXPORTER_OTLP_ENDPOINT; and under -race;
- the previous test with BD_OTEL_METRICS_URL=x BD_OTEL_LOGS_URL=y fails
at golden line 132 on the deprecation warning;
- swapping homeDir and projectDir in setup's defaultClaudeEnv passes the
previous test and fails this one at golden line 5 (the transcript
shows created $HOME/.claude/settings.json).
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* test(cmd/bd): pin workspace discovery refusal text and exit codes
Add before-parity pins for what an ordinary bd prints, and with which
exit code, when workspace discovery cannot select a usable workspace:
- no .beads, an empty .beads, or a .beads with config.yaml but no
metadata.json and no database ("no beads database found", and bd
where's text and --json refusals);
- a corrupt metadata.json, for list, create, where (all refuse) and
version (warns, exits 0);
- an exported BEADS_DIR naming a missing path, an empty directory, a
regular file or a corrupt workspace, run from a corrupt workspace so a
fallback to cwd discovery would show;
- .beads/.env: BEADS_DIR routing, an exported BEADS_DIR winning, BEADS_DB
routing bd where but not a data command, BD_JSON applying only in the
selected workspace, and a .env BD_BACKEND not being refused;
- .beads/redirect: missing and non-workspace targets (warning, then the
source), a corrupt target, a chain, and a redirect behind BEADS_DIR;
- --db paths and names, and BEADS_DB / BD_DB, including the two
inconsistencies main has today (a data command ignores BD_DB, and lets
a discoverable cwd workspace shadow BEADS_DB, while bd where honors
both);
- BD_BACKEND / BD_DATABASE_BACKEND being refused before any of the
above, for store-less commands too.
The cases use workspaces with a corrupt metadata.json as sentinels: the
refusal names the metadata.json it failed to parse, which shows the
directory discovery selected without opening a store, so the store-less
pins need neither Dolt nor cgo. One embedded-Dolt pin covers the
store-backed .env case: BD_READONLY=true in .beads/.env refuses a write
with the read-only text and exit 1, reads still run, and an exported
BD_READONLY wins over the file.
These pin today's origin/main, not an ideal. A change that reorders
admission, discovery or checkBlockedEnvVars in the root PersistentPreRunE
now has to change an expectation here and is reviewed as a test diff.
Built from the merge base with the graph fork (46aa59cc65), bd passes
every store-less pin; the fork tip fails two (a BEADS_DIR naming a
regular file exits 5 with graph_not_initialized instead of exit 1, also
when BD_BACKEND is set).
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>
* test(cmd/bd): keep the discovery pins independent of PATH and cgo
The version case under TestDiscoveryRefusalPinsCorruptMetadata pinned
bd version's full stderr. bd version also appends a "Warning: multiple
'bd' binaries found in PATH" block when the caller's PATH holds more
than one distinct bd binary (a release install plus a dev build, or
Homebrew plus go install), and the fixture passes the caller's PATH
through. Such a machine failed the pin spuriously. normalize now drops
that block from stderr, as it already drops the sandbox auto-detection
notice, so the rest of the case is still pinned exactly.
The file also said the store-less pins need no cgo. They need a cgo bd.
A CGO_ENABLED=0 bd is server-only, and its no-database hints add "run
'bd doctor' to diagnose", so a CGO_ENABLED=0 go test of the package
failed 16 cases on the hint wording alone. The file now builds only
with cgo, and its header says why. CI runs none of these in its
CGO_ENABLED=0 lane, whose -run subset is fixed by PURE_CMD_BD_TESTS.
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>
* test(cmd/bd): pin a working-directory .beads that is a regular file
The ExplicitBeadsDir pins cover a BEADS_DIR that names a regular file.
This adds the same case reached by the working-directory walk instead:
a project whose .beads is a regular file. bd list and bd where both exit
1 with "Error: loading config: reading config: open
$ROOT/p/.beads/metadata.json: not a directory".
bd built from the fork merge base 46aa59cc65 passes both cases. The
fork tip b9eebc31f8 fails both: it exits 5 with "graph_not_initialized:
open $ROOT/p/.beads/graph-preview-format: not a directory", the same
reorder the BEADS_DIR pin already catches.
A .beads that is an unreadable directory (chmod 000) splits main and
the fork the same way, but it is not pinned: a test run as root can
still read the directory.
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>
* test(cmd/bd): close the embedded discovery pin's environment
Maintainer fixup from the adoption review of #7677.
TestEmbeddedDiscoveryPinsEnvFileReadonly compares bd's output exactly,
but its run helper started from bdEnv, which drops only BEADS_* and
BD_ROUTING_MODE. Every other BD_* the caller exported reached bd: with
BD_OTEL_METRICS_URL/BD_OTEL_LOGS_URL set (as on agent hosts) the
deprecation warning lands in front of the read-only refusal, with
BD_JSON_ENVELOPE=1 the empty list is printed as an envelope, and in a
sandbox the "Sandbox detected" notice precedes the refusal; each failed
the pin. The run helper now uses the store-less pins' closed environment,
factored out of discoveryPinFixture.baseEnv as discoveryPinEnv (HOME stays
the directory bd init used), and drops the sandbox notice from stderr
with the same discoveryPinSandboxNotice pattern normalize now uses.
normalize collapsed every consecutive repeat of a stderr line, which also
hid a doubled "Error:" line. It now folds only repeated
"Warning: redirect" lines, the ones discovery prints once per re-resolve.
blocked-backend-not-checked used a corrupt-metadata sentinel, whose
bind-time refusal comes before the legacy guard, so a blocked-variable
check added after .env loading would not have changed its output. It now
uses a config.yaml-only workspace and pins discovery's no-database
refusal.
Measured with the PR head's bd and test binaries under env -i:
- the embedded pin passes on a clean environment and failed with
BD_OTEL_*, BD_JSON_ENVELOPE=1, or kill(2) returning EPERM (strace
inject); with this change it passes in all of them, plus an exported
XDG_CONFIG_HOME, an existing BD_MIGRATION_FREEZE_FILE and the agent
host's BD_*/BEADS_* set;
- it still fails when .beads/.env overrides the caller (gotenv.OverLoad)
or is not loaded;
- the store-less suite passes 54/54 subtests; a bd that prints the
legacy-guard error twice now fails 12 of them, and a bd that checks
the blocked variables again after the legacy guard now fails
blocked-backend-not-checked; both passed the suite before.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* fix(workspacegate): strict --readonly never creates workspace gate files
Strict --readonly is mutation-free by policy (effectiveRootStorePolicy),
but the command chokepoint took its SHARED workspace gates with
O_CREATE|O_RDWR. On a workspace no bd command had gated yet, a strict
readonly command therefore left <project>/.beads.gate.lock and the
physical-root gate file (.beads/embeddeddolt.gate.lock or
.beads/dolt.gate.lock) behind.
Add workspacegate.Options.ReadOnly. A Shared acquisition with it opens
the gate file O_RDONLY (the idiom ExclusiveHolder already uses) and never
creates it. A gate file that does not exist means nothing has ever been
gated there, so Acquire succeeds with an empty handle whose Release is a
no-op. An existing gate file is held SHARED as before, so maintenance
still sees the command and a live exclusive holder still makes it wait
and then refuses it. The option is ignored for Exclusive: maintenance has
to be able to create the file it locks.
ReadOnly composes with the fair, bounded waiting from #7225 without
changes to it: the writer-fairness probe (ExclusiveQueued) already opens
the intent file read-only and treats a missing one as nothing queued, so
a waiting ReadOnly acquisition creates no .intent or .info file either.
readonly_wait_test.go pins that seam.
The chokepoint passes ReadOnly: readonlyMode in the SHARED branch. Every
other command keeps creating the gate files, which is what makes it
visible to maintenance. Residual, documented at the chokepoint: on a
workspace that has never been gated, a strict readonly command is
invisible to a maintenance operation that starts while it runs.
Ported from the versioned-beads integration fork (donnabox):
0c86e2b205 (red tests), bac6ff95dc (fix), b7a4f96a5a (fair-wait tests),
2af5a664dc (BUILD.bazel registration), and the #7225 conflict resolution
in 9d128f8c51. The fork's `--readonly backup restore` refusal
(6ac79d6207) is a separate change and is not included.
Co-authored-by: Jim Wordelman <jim@wordelman.name>
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>
* fix(cli): release the previous command's workspace gate before acquiring
acquireCommandWorkspaceGates stored its new handle over whatever
workspaceGateHandle already held. cobra skips PersistentPostRunE when
RunE fails, so in a process that runs more than one command (tests,
embedders) a command could start with the previous command's handle
still set. Two things then went wrong:
- on the paths that take no new gate (no .beads on disk, a failed or
fail-open acquisition) the stale handle stayed set, so the previous
workspace stayed held for the whole command;
- on a successful acquisition the stale handle was overwritten without
being released, so its flock stayed held on the previous workspace
until the garbage collector closed the file, and a maintenance
operation there was turned away by a command that had finished.
Release any held handle first. In a single-command bd process the handle
is always nil at that point, so this is a no-op there.
Ported from the versioned-beads integration fork (donnabox): 3a25b42ed1
(cherry-pick of ad87442c92). The test
TestAcquireCommandWorkspaceGatesReleasesThePreviousCommandsHold is new
here and covers the successful-acquisition case the fork's tests do not.
Co-authored-by: Donna Box <dbox@boxenllc.com>
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>
* fix(cli): close a stale store before the leading gate release
Review fixups for #7672, apply-fixes iteration 1.
The leading releaseWorkspaceGates() that the second commit added to the
chokepoint was the only production release without a
closeStoreBeforeGateRelease() first. When an in-process command's RunE
fails, Cobra skips PersistentPostRunE. The next command in the same
process then dropped that command's gates while its store and provider
were still open, and later overwrote and leaked them. Close them first,
as every other release path does. The current command assigns
store/uowProvider only after the chokepoint, so anything set there
belongs to the previous command. Only multi-command processes (tests,
embedders) are affected; production runs one command per process.
A strict --readonly hold on a never-gated workspace locks nothing. The
chokepoint still exported this PID in BEADS_GATE_SHARED_HOLDER_PID, so bd
children skipped the writer-fairness queue behind a parent that blocks
no exclusive acquirer. Add Handle.Empty and MultiHandle.Empty, and
advertise only when at least one gate is actually locked.
Tests:
- A regression test runs the chokepoint over a stub store and provider.
It pins that both close while the previous command's gate is still
held.
- A marker test forces advertiseSharedHoldEnabled on. It pins that a
hold of nothing is not advertised, and that the hold is advertised
once the gate files exist.
- The strict-readonly chokepoint subtests now require a handle that
holds nothing. SHARED fail-open leaves no handle, so these subtests
now fail the review's W2 mutant, which passed them before.
- A package test covers Empty.
The posture comment now says the gate follows the strict flag only.
Allowlisted reads and --dry-run/--inspect previews still create the gate
files.
Not changed: `bd --readonly backup restore` still creates gate files on
its exclusive acquisition. This PR covers shared gates only. Sibling #7673
refuses a strict-readonly restore before it takes the exclusive gate.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Donna Box <dbox@boxenllc.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* test(oracle-a): normalize the per-write revision token so main-vs-main is clean
Since #5535, `bd show --json` publishes `"revision"`, the decimal spelling
of the row's row_lock. Every create and status/ownership write remints that
token from crypto/rand (issueops.freshRowLock), so it differs between any
two runs of the same scenario. The harness did not normalize it, so Oracle A
failed against itself: on the curated tier, origin/main vs origin/main scored
31 pass / 13 fail in scope, and each failure was a `show --json` step that
differed only in `"revision"`.
normalize() now collapses a non-zero decimal `"revision"` string to `<REV>`.
It keeps everything else literal: the member name, its presence and its
string type, "0" (a row that was never stamped), number-typed values, other
`*_revision` members, and escaped text inside a JSON string. A new unit test
covers each of these cases.
Curated tier, REF_REF=origin/main, run against itself: before 31 pass /
13 fail in scope (0/1 out of scope); after 44 pass / 0 fail (1/0).
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>
* test(oracle-a): normalize the per-run workspace path
Each scenario runs in a fresh tempfile::tempdir(), so any bd output that
echoes the workspace path differs on every run. When origin/main's bd was
captured twice with the deep tier (ORACLE_CATALOG=1, 546 scenarios), 40
catalog scenarios differed only in that path. All 40 start with their own
`init --prefix X --non-interactive` step, which runs in a workspace the
harness already initialized and fails with "Found existing Dolt database:
/tmp/.tmpXXXXXX/.beads/embeddeddolt/X".
run_scenario now hands normalize_in_workspace() the exact workspace path
and its symlink-resolved spelling, and that function replaces only those
strings with <WORKSPACE>, longest first. Other paths stay literal, so no
stable value is collapsed. All 40 scenarios are out of scope, so in-scope
counts do not change.
Deep tier, origin/main's bd against itself, scored by the scoreboard:
- base harness: 256 pass / 67 fail in scope, 154 / 69 out of scope.
- with both normalizers: 323 / 0 in scope, 219 / 4 out of scope.
The out-of-scope remainder changes from run to run and none of it is a
field value. It comes from randomized "Tip:" lines in human output and one
unordered `list --format dot`.
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>
* test(oracle-a): document and pin the <REV> match scope and the workspace wiring (mc-ro9kg)
Review fixes for #7680, iteration 1.
revision_regex runs over the raw stdout/stderr text before any JSON
parse, so it collapses every "revision" member holding a non-zero
decimal string, at any depth and in plain text, not only the
bd show --json issue token. That includes a user metadata key named
revision, which the in-scope --set-metadata/--metadata flags can set,
so a change to its value passes the gate. The regex comment and a new
README "What green does NOT prove" bullet now say so, and
normalize_collapses_revision_by_member_name_at_any_depth pins the
scope: a nested metadata member and plain text are collapsed, while a
metadata key with any other name still gates. The old test name said
nothing else was collapsed; it is now
normalize_collapses_non_zero_revision_strings.
run_scenario_collapses_the_workspace_in_both_step_streams runs
run_scenario against a stub bd that prints its cwd on stdout and its
resolved path on stderr, and expects <WORKSPACE> in both. Before, the
two normalize_in_workspace calls in run_scenario could be reverted with
every unit test and the curated tier still green.
The remint wording in the comment and the README now names every
writer (create, update, close, reopen, claim and unclaim) instead of
only status/ownership writes.
Tests: cargo test --locked --offline (7 passed), clippy clean, no new
rustfmt hunks. Mutants, each in its own copy and target dir: reverting
either or both normalize_in_workspace calls fails the run_scenario
test; skipping a nested metadata member, or matching only after { or
",", fails the scope test.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* test(domain/db): pin the statements the history-off upsert Insert issues
The participation_generation write fence (#6943) gave domain/db Insert's
upsert path (CreateOnly unset: the quick, todo, gate and batch proxied
servers' create) an existence probe ahead of the upsert, skipped while
versioned history is off. Pin that skip with a sqlmock statement-sequence
test: with history off, the upsert into issues and into wisps issues
exactly the three statements the pre-stack code (4a67d0d028) issues --
the upsert, the created event's same-content scan and its insert -- and
nothing else.
The mock is reached through internal/storage/sqlcount, and the pin also
requires exactly three statements to reach the driver. sqlmock alone
answers an unscripted statement with an error and fails only if the
caller returns it, so a best-effort read whose error Insert dropped would
pass its checks; the count catches it. The history-on run of the same
script is the control: the probe (and the mint after it) must make the
pin refuse it, which shows the script is exhaustive and that Insert reads
the transaction's scope.
Passes on 4a67d0d028 and on main; main issues no extra read with history
off. Before-parity pin P2 (Insert half) from the fork gap analysis, for
gastownhall/beads#6132 / #6135.
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>
* test(issueops): pin the statements the history-off defer-wake sweep issues
Port the fork's sqlmock pin of WakeExpiredDefersInTx with versioned
history off (donnabox/codex/preview3-source-catchup-46aa 11c74cb575):
a one-row sweep issues exactly the expired-row SELECT, the UPDATE, the
event's same-content SELECT and INSERT, and the empty wisps pass, so any
read added before or after waking a row while history is off fails the
pin. It passes on main unchanged and guards the fork's wake-skip change,
which checks each expired row against the mint before waking it and must
keep that check free with history off.
Adapted for main: the doc no longer describes the fork's pre-wake check
as existing; a history-on run of the same script is added as the control
(the mint's read must make the pin refuse it), so the pin cannot pass
vacuously; and the mock is reached through internal/storage/sqlcount, so
the pin also requires exactly five statements to reach the driver. That
catches a read whose error the sweep swallowed, which sqlmock alone does
not see. Passes on 4a67d0d028 and on main. Before-parity pin P2 (wake
half), for gastownhall/beads#6132 / #6135.
Co-authored-by: Jim Wordelman <jim@wordelman.name>
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>
* test(storage): versioned-history flag-off differential against pre-stack goldens
gastownhall/beads#6132 and #6135 require a differential test proving that
with versioned history off (the default) storage behaves byte-identically
to before the feature. Existing coverage stops short of that:
TestDualWriteContractFlagOff only counts version rows, the
participation-generation contracts check one column, and createbatchequiv
runs its batch with history on over a column subset.
Add internal/storage/historyoffequiv. Each leg (embedded Dolt, Dolt
server, unit of work) runs one scripted mutation set through its own
front doors on a store whose history was never turned on:
- on the issues plane, every write role: creates, batch create, apply
batch, updates, the no-op update, reparent, dependency add/remove,
comments, claim/heartbeat/release, lease reclaim, metadata CAS,
close/reopen, batch close with a refused item, defer and wake, delete;
- the persistence moves in both directions;
- on the wisps plane, the roles again: create, update and the no-op
update, dependency add/remove, comment, metadata CAS, close/reopen,
apply batch, batch close, release, defer and wake (the sweep's wisps
pass), delete, a forced close of a no-history wisp, and the refusals
the lease roles' contracts give a wisp (Claim, Heartbeat; Reclaim finds
nothing);
- each leg's own surface: the store legs' DoltStorage methods (import
upsert, promotion, RunInTransaction, ...) and the uow leg's
CreateOnly-unset domain upsert and importer.
Neither reclaim sweep finds an expired lease, since no role can age one.
The harness then dumps every column of every base table, plus the
scenario's Dolt commit messages and the final dolt_status, and compares
per-table SHA-256 digests with goldens recorded by running the same
harness against origin/main 4a67d0d028, the commit before the stack
(#6943, #6661, #6664).
The only tolerated differences are listed in schemaAdditions: the stack's
new columns (issues/wisps.participation_generation,
issue_versions.removed_restriction) must be NULL in every row and are
then left out of the digest; its new table (epoch_minted_addresses) must
be empty; its own migration bookkeeping rows (0070-0072, ignored/0028)
may each be there once. Recording and checking apply that rule the same
way, so a golden re-recorded from main is byte-identical to the
pre-stack one (verified on all three legs). The package doc says how the
goldens are kept: a later migration whose schema flag-off leaves
untouched adds its own schemaAdditions entry; a deliberate flag-off
change, a scenario change or an engine rendering change re-records them
and shows the dump diff. Wall-clock instants, wall-clock-derived ids and
random tokens are masked by explicit, documented rules found by diffing
two runs; instants the scenario supplies stay verbatim, so a write that
starts overwriting one still shows.
All three legs pass on main. Before-parity pin P1 from the fork gap
analysis; the new embedded test is placed in the 40-shard storage block.
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>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Jim Wordelman <jim@wordelman.name>
* test(cli): pin --format json == --json on show, list, ready and memories
Before-parity pin P7 (gap analysis 2026-10-17, section 5a). The hidden
root --format flag is an alias for --json (GH#2612). It is a root
persistent flag, so a subcommand that registers a --format of its own
shadows it (the GH#6278 hazard): `bd list` already does and passes `json`
through by hand, and a graph-preview fork that added a local --format to
`bd show` made `bd show ID --format json` exit nonzero.
TestEmbeddedFormatJSONAliasMatchesJSON runs show, list, ready and memories
with --json and then with `--format json`, `--format=json` and a leading
`bd --format json <verb>`, and requires exit 0 and byte-identical stdout.
It adds bdRunStreams, a small helper returning stdout, stderr and the exit
status separately, which the following pins reuse.
The new TestEmbedded* function is listed in the bd_test srcs and placed in
the 100-shard embedded cmd manifest by
gen_embedded_cmd_shard_manifest.py --write (incremental).
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>
* test(cli): pin the ordinary --if-revision compare-and-swap contract
Before-parity pin P8 (gap analysis 2026-10-17, section 5a). --if-revision
is the decimal int64 compare-and-swap merged in #7203, and gascity's
bdstore_conditional.go classifier reads both its exit status and its
machine body. A second, opaque-token meaning for the same flag in another
kind of workspace must leave the ordinary one unchanged.
TestEmbeddedIfRevisionOrdinaryCAS pins, through the real binary:
- a stale decimal token on update, close, assign and delete (preview
and --force) exits 13, prints nothing on stdout, writes nothing, and
ends stderr with a precondition_failed body naming the id and the
expected and current revisions as exact JSON integers;
- a non-decimal token exits 1 with the "invalid --if-revision" refusal
in text and --json modes, never 13, and writes nothing;
- the current token applies on update, close, assign and delete.
It is the ordinary-workspace half of
TestGraphPreviewIfRevisionOutsideLinkModeIsUpstreamCAS from the
donnabox/codex/preview3-source-catchup-46aa branch (added in 3d16d826be,
revised in 1640940fa9, 3ff2fe73ce, 55dbb61156, 653369305a and
97446d1f08), ported onto this package's embedded helpers. The port drops
the graph-only forget refusal, extends the stale and non-decimal cases
from update/delete to close and assign, and compares revisions as
json.Number rather than float64, since they are int64 values past 2^53.
It is named TestEmbedded* so the bazel-embedded lane, which discovers
`^func TestEmbedded` in *_embedded_test.go, runs it; the existing
TestIfRevisionMatchAndMismatch is not discovered there. The file is
listed in the bd_test srcs and placed in the 100-shard embedded cmd
manifest by gen_embedded_cmd_shard_manifest.py --write (incremental).
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Donna Box <dbox@boxenllc.com>
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>
* test(cli): pin version, config set, history and show --as-of shapes
Before-parity pin P10 (gap analysis 2026-10-17, section 5a): the
store-less and history-adjacent commands a later versioned-history or
graph slice could change by accident.
- TestEmbeddedVersionOutputShape: `bd version` with no arguments exits
0 and prints one "bd version <version> (<build>...)" line, in a
workspace and outside one; --json is one object with version, build
and schema_version (plus commit and branch when known) agreeing with
the text line, and --format json prints the same document; an
argument exits 1 and points at `bd versions <arg>` (#6661), on stderr
or as the --json error, through the real binary rather than RunE.
- TestEmbeddedConfigSetOtherKeysSkipTheVersionedHistoryScan: in a store
holding a row the pre-enable scan refuses over, `bd config set` and
`bd config set-many` of another key with the value "true" exit 0,
store it, print no refusal and leave the switch off; the switch
itself is still refused afterwards, as a control.
- TestEmbeddedHistoryAndShowAsOfReadDoltCommits: with versioned history
recording, `bd history <id> --json` is still the Dolt-commit history
(an array of CommitHash/Committer/CommitDate/Issue entries with full
32-character Dolt hashes, no recorded-version fields, and the same
hashes in the text output), and `bd show <id> --as-of <hash>` with a
hash from it is the Dolt AS OF read in show's JSON shape, not the
R7.1 as-of read over issue_versions; `--as-of main` reads the branch
head.
The three TestEmbedded* functions are placed in the 100-shard embedded
cmd manifest by gen_embedded_cmd_shard_manifest.py --write (incremental).
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>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Donna Box <dbox@boxenllc.com>
* test(httpapi): pin the startup event's capabilities and database source
TestStartupLines and TestStartupNamesTheDatabaseSource check the
event=startup line by substring, and neither reads its capabilities
field. A server could print one capability list and advertise another
on GET /v0/beads/context, or a new kind of database source could
relabel the line, and both tests would stay green.
TestStartupEventPublishesTheAdvertisedCapabilitiesAndSource parses the
line back into its fields and pins, for the provider and roles sources
with and without the external-dependency policy: the exact field
sequence, db=provider|roles, and a capabilities value equal to the
handshake's list joined with commas. It is a before-parity pin: a
future alternative source on the same server must leave this line
unchanged for the Issue API's two sources.
Test-only; no behavior change.
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>
* test(serve): pin ordinary-workspace bd serve under BD_GRAPH_MODE=dependency
bd reads no BD_GRAPH_MODE today. "dependency" names the format every
existing workspace already has, so any later reader of that variable
(a graph-mode serve dispatch, for example) has to keep serving an
ordinary workspace through runServe exactly as it does now. These
tests pin that before such a reader exists.
Each test runs bd serve twice in one workspace, once with the variable
unset and once with BD_GRAPH_MODE=dependency. It requires the
event=startup and event=limits lines to match byte for byte apart
from the ephemeral port, and the GET /v0/beads/context bodies to be
equal. Each run is also checked against what runServe builds: the
serveResolvedMode label, the db source, and a startup capabilities
field equal to the handshake's list. Two runs that were both routed
somewhere else therefore cannot pass by agreeing with each other.
- TestServeOrdinaryWorkspaceIgnoresGraphModeDependency: in-process
through rootCmd (PersistentPreRunE included), on the store source of
a registered-backend workspace. Runs in bd_test.
- TestServerModeServeIgnoresGraphModeDependency: a real bd on a
`bd init --server` workspace, which uses the provider source. Gated
on BEADS_TEST_PROXIED_SERVER like the other TestServerMode* tests,
and placed in the proxied 34-shard manifest by
gen_proxied_shard_manifest.py --write (incremental).
The new file is listed in cmd/bd/BUILD.bazel's bd_test srcs.
Test-only; no behavior change.
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>
* test(serve): stop the in-process graph-mode pin hanging when serve fails
serveInProcessSnapshot's cleanup decided whether the server was still
running by looking at rootCancel. That holds for a clean run, which
clears rootCancel in PersistentPostRunE. A run whose RunE returns an
error skips PersistentPostRunE, so rootCancel stays set even though the
main flow has already read the run's only result from done. The
cleanup then called rootCancel and blocked on done for good, and the
failure surfaced as a test-binary timeout panic that takes the whole
bd_test shard with it instead of a FAIL for this test.
The cleanup now keys on whether done has been read. A serve that binds,
answers, and then returns an error (one way a future graph-serve
dispatch could regress) now fails in about 5s with "bd serve returned
<err>, want a clean shutdown". A failure before done is read (a bad
GET, say) still cancels the server and waits for it.
Test-only; no behavior change.
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>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(init): admit a retried `bd init --server` over an empty .beads/dolt
A first `bd init --server` that cannot reach its server fails after
creating the local Dolt root, leaving an empty .beads/dolt, no
.local_version witness, and no config.yaml/metadata.json recording the
server choice. The legacy-upgrade guard runs before init writes that
choice, so it saw an embedded-looking workspace with a local Dolt root
and refused every retry as a "legacy Dolt workspace"; no bd command could
repair it.
guardLegacyUpgradeWorkspaceForInit(beadsDir, initSelectsServer) carries
init's already-resolved server intent into the guard. It is consulted
for exactly one decision: an empty, witness-less .beads/dolt is admitted,
the same admission a workspace that records server mode already gets
(#6935). It is deliberately not folded into the workspace's own server
mode, so a non-empty root with an unreadable witness and an embedded
repository beside a non-empty root keep their current outcomes.
guardLegacyUpgradeWorkspace is now the initSelectsServer=false wrapper,
and only init's main guard call passes the flag; the proxied-server
init path keeps the plain wrapper.
Ported from the versioned-beads fork (donnabox/codex/preview3-source-
catchup-46aa), commits bc8d72182a (red) and 5bdfbfe5e2 (green). The
fork's graph_mode refusal in the same function is graph-preview-only
and is not carried here.
Tests: TestLegacyUpgradeGuardForInitAdmitsEmptyDoltRoot and
TestLegacyUpgradeGuardForInitAdmissionStaysNarrow pin the admission and
its narrowness at the guard; TestInitServerFlagAdmitsEmptyDoltRootWithoutConfig
and TestInitServerFlagRetryAfterFailedFirstAttempt run the real binary
against the test Dolt server and fail on main with the legacy refusal.
Co-authored-by: Jim Wordelman <jim@wordelman.name>
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>
* fix(init): `bd init --server --external` must not auto-start a server
`--external` declares the Dolt server managed outside bd ("skip server
startup", per its help), but init builds its dolt.Config by hand with
`AutoStart: initServerMode && BEADS_DOLT_AUTO_START != "0"`, so the flag
never reached the auto-start decision. A `bd init --server --external`
that named no port therefore ran dolt and tried to start a repo-local
sql-server. A named port was already declared external by rule 2c
(#5934), but its failure still advised `bd dolt start`, the one thing
--external says bd must not do, and each route (host:port, socket,
shared server, auto-start pinned off) worded the failure differently.
- AutoStart is now `initServerMode && !externalServer && ...`.
- externalServerUnreachableMessage rewrites only a failed dial
(*net.OpError with Op "dial") under --external: it names the endpoint
that was dialed and says bd did not start a server. A dial to port 0
means no port was named, so that message asks for --server-port or
BEADS_DOLT_SERVER_PORT and offers no default (GH#2098, GH#2372). Any
other open failure keeps its own text.
Ported from the versioned-beads fork (donnabox/codex/preview3-source-
catchup-46aa), commits 234ca3d502 and a601a80e77 (red/green), 03a64a1aba
(socket helper rename), and a6ca0536c9 and 397fc4c69e (red/green: no-port
arm and wording). The fork's graph-preview dispatch at the top of init
and its --skip-hooks help text change are graph-only and not carried.
The TestInitExternalProvisionerShape doc comment is corrected: on main
every provisioner cell is a control (a named port is already external),
not a reproduction.
Tests: TestInitServerExternalDeadPortStartsNoServer,
TestInitServerExternalNoPortStartsNoServer and
TestInitExternalUnreachableMessage run the real binary against a dolt
shim that records every launch and fail on main;
TestInitSharedServerExternalDeadPortStillFails,
TestInitServerWithoutNamedPortStillStartsServer and
TestInitExternalProvisionerShape are controls; and
TestExternalServerUnreachableMessage pins which errors are rewritten.
Co-authored-by: Jim Wordelman <jim@wordelman.name>
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>
---------
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(conformance): un-skip R16 CAS + R20 epoch tests with honest not-implemented stubs
Wires all 10 ExpectedRevisionFixture-gated Run* functions and both
EpochFixture-gated Run* functions to real (non-nil) hooks on all three
storage legs (dolt, embeddeddolt, uow), replacing the Phase 0 all-nil
fixtures that made these cases t.Skip.
Every wired hook is an unconditional "not implemented yet" stub rather
than a partial-real implementation. This is deliberate: every Run*
function under test calls its primary hook (CompareAndSetVersion, or
CurrentEpoch/MintUnderEpoch) first, before any other hook, so a stub
that errors unconditionally on that first call guarantees deterministic
RED with zero risk of an accidental pass -- a concern that's concrete,
not hypothetical, since at least one case
(RunExpectedRevisionAcceptsAWriteNamingNoVersion) would go green under
a partially-real read/unconditional-write strategy backed by Phase 1's
already-persisted current_revision/store_epoch columns.
Each case now fails for its documented reason: most via a direct
t.Fatalf quoting the stub's "not implemented" error, and two
(RefusalIsDistinguishableFromNotFound,
RefusalIsDistinguishableFromValidationFailure) via a clean want/got
mismatch against the sentinel errors they expect.
Explicitly out of scope and untouched: CrossRecordInvariantFixture
(R16.1) and the non-epoch RetentionFixture cases (R17) -- confirmed via
test run that TestRetentionContract still reports PASS with all 13
subtests SKIP on every leg.
TestEveryLegWiresEveryRoleContract (internal/storage/leg_contract_wiring_test.go)
is a source-level AST naming check independent of hook nil-ness; all 12
entrypoints were already called by every leg pre-change, so this lock
was satisfied before and remains satisfied after.
Sentinel error messages reference be-x5jqd.3 (R16 CAS implementation)
and be-x5jqd.4 (R20 epoch enforcement implementation), the two builder
children this un-skip unblocks.
Verified via go build ./..., go vet ./..., and go test -tags cgo across
all three legs: all 10 R16 + 2 R20 subtests FAIL for the documented
reason, TestRetentionContract unaffected.
Bead: be-x5jqd.1
* feat: green — Implement R20 epoch-transition enforcement (refs be-x5jqd.4)
* fix(epoch): honor R20-n's retained-mapping exception in StillServes/Resolve
StillServesInTx and ResolveEpochInTx only ever checked whether the
literal queried address's own row matched the current epoch. Per R20-n
(#5898 rev 9), a version that survives an epoch transition keeps its
prior-epoch address resolving once its id has been carried forward into
the current epoch (via CurrentAddressForInTx or a fresh
MintUnderEpochInTx) — that carried-forward row wasn't being consulted,
so a legitimately retained address would wrongly stop resolving.
Add mintedIDHasAddressAtEpochInTx and consult it as a fallback in both
functions when the queried address's own row is stale. Addresses whose
id was never carried forward are unaffected (row.mintedID has no row
at the current epoch, same false/GoneReorganization answer as before).
Round-2 response to be-rskwc's causal_disproof finding: the merge-base
commit FAILed honestly on this defect, this branch's tdd_green SKIPped
instead (attribution_evidence). This fix is real and verified via a new
sqlmock unit test (TestStillServesInTxHonorsARetainedMapping et al.),
but does not by itself flip
TestEpochContract/EpochBumpVoidsOnlyAddressesOfVersionsNoLongerServed
from SKIP to PASS: that test's own construction mints two records
identically and never carries either forward before comparing
StillServes on both, so no backend implementation can make them differ
(escalation follows on a needs-mayor bead).
refs be-x5jqd.4, be-rskwc round 2
* test(feat): red — harden EpochBumpVoidsOnlyAddressesOfVersionsNoLongerServed (refs be-9fiaw)
Per mayor ruling on be-9fiaw: fix the test rather than waive it. The
fixture already lets record-a survive an epoch bump by minting it again
under the new epoch; record-b, never re-minted, does not survive. That
asymmetry was previously only discovered after the fact (skip if
StillServes agreed for both addresses), which meant the case could pass
by observing either polarity. Assert the concrete expected values
instead: servesA must be true, servesB must be false. This makes the
case deterministically exercise both halves of R20-n, and closes a
latent gap where a backend with the polarity reversed could have
silently passed via the old discover-then-swap logic.
* fix(schema): renumber epoch_minted_addresses to 0070, linearizing our own slot collision (refs be-hs42e.7)
R20's epoch_minted_addresses and R7.1's removed_restriction both claimed
migration slot 0069 on parallel sibling branches. Neither contained the
other, so nothing in either branch's own CI could see the union: each was
green alone, and the second to merge would panic checkNoDuplicateVersions at
store open -- before any command's RunE, so every bd invocation bricks rather
than one package reddening. Same hazard bee reproduced for #6358 vs #6008.
This linearizes them instead of leaving it to merge order. R7.1 keeps 0069:
it is published beneath #6661 and cannot move without rewriting a branch a
reviewer is reading. R20 stops being a sibling, rebases onto R7.1, and takes
the next contiguous slot.
Contiguity is why the renumber could not be done pre-emptively in either
branch alone: TestAllMigrationsSQLAppliesThroughDoltCLIAndRecordsLatestVersion
asserts COUNT(*) == LatestVersion(), so a jump to a far slot fails until the
gap is filled. The order had to be settled first.
- migrations/0069_add_epoch_minted_addresses.{up,down}.sql -> 0070_*
- migration_0069_add_epoch_minted_addresses_test.go -> migration_0070_*, with
TestLatestVersionIncludesMigration0069 -> ...0070 (want 70)
- 0069_add_removed_restriction_test.go retires its own LatestVersion pin in
favour of 0070's, keeping the one-pin-at-a-time chain 0068 -> 0069 -> 0070
cli_migrations.go needs no change: its only override is R7.1's guarded
PREPARE, which keeps 0069. The epoch migration is a plain unguarded
CREATE TABLE IF NOT EXISTS and needs none.
Verified: TestEmbeddedMigrationSourcesHaveNoDuplicateVersions,
TestLatestVersionIncludesMigration0070,
TestAllMigrationsSQLAppliesThroughDoltCLIAndRecordsLatestVersion (applies the
full 0001..0070 chain through the dolt CLI),
TestBundleMigrationsWithPreparedALTERAreOverriddenOrJustified and
TestAllMigrationsSQLUsesDirectDDLForKnownCLIIncompatibilities all pass.
go build ./... and go vet ./... clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(feat): red — Fix PR #6664: restore R16 honest-skip (stale be-x5jqd.3 premise) + address bee's 2 blockers on epoch_cas.go (refs be-ah0jf)
* feat: green — Fix PR #6664: restore R16 honest-skip (stale be-x5jqd.3 premise) + address bee's 2 blockers on epoch_cas.go (refs be-ah0jf)
* test(feat): red — Review: Fix PR #6664: restore R16 honest-skip (stale be-x5jqd.3 premise) + address bee's 2 blockers on epoch_cas.go (refs be-yj55d)
* feat: green — Review: Fix PR #6664: restore R16 honest-skip (stale be-x5jqd.3 premise) + address bee's 2 blockers on epoch_cas.go (refs be-yj55d)
* docs(epoch): cite epoch_minted_addresses as migration 0071
Upstream's 0069_widen_issue_versions_datetime_precision (#6675) took slot
0069 first, so removed_restriction moved to 0070 and epoch_minted_addresses
to 0071. The three epoch_cas.go headers still named 0070.
Rebase note (maintainer): the migration is now 0072, per the landing-order
ruling (#6943's participation_generation is 0070 and #6661's
removed_restriction is 0071); the commit "chore(schema): renumber
epoch_minted_addresses to 0072 after #6661's 0071" updates these three
headers.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(feat): red — move #6664's Dolt server leg to post-transaction publish for store_epoch and epoch_minted_addresses (latent lost-update pattern)
Tests only. On the commit before this one they fail for these reasons:
- the server leg publishes store_epoch / epoch_minted_addresses inside the open
SQL transaction (DOLT_ADD before COMMIT) for BumpEpoch, MintUnderEpoch and
CurrentAddressFor: the lost-update hazard documented on doltAddAndCommitInTx
- MintUnderEpoch and CurrentAddressFor stage only epoch_minted_addresses, so the
first mint leaves store_epoch modified in the working set, on both legs
(#6664 Major 2, reproduced with Status() on a real server and embedded)
- BumpEpoch must surface a Dolt commit that fails after its SQL commit, while
the mint paths keep their rows
- ensureStoreEpochRow seeds with INSERT IGNORE and reads the row back
TestMintOverlappingABumpCommitsAnAddressThatIsAlreadyGone characterizes current
behaviour and passes now: a mint overlapping a bump commits an address the bump
already voided. Its doc comment records why that is left as it is.
* feat: green — move #6664's Dolt server leg to post-transaction publish for store_epoch and epoch_minted_addresses (latent lost-update pattern)
Server leg (internal/storage/dolt/epoch_cas.go): BumpEpoch, MintUnderEpoch and
CurrentAddressFor no longer stage and Dolt-commit inside the open SQL
transaction. The two mint paths publish through runIssueOperationTxWithMessage,
which commits the SQL transaction first. BumpEpoch commits it, then publishes
with doltAddAndCommitPostTx and RETURNS a failed Dolt commit: a bump that is
committed but unpublished must not read as success.
Both legs: a mint stages store_epoch with epoch_minted_addresses, because the
first mint inserts the singleton row (#6664 Major 2). The set lives in
issueops.EpochMintDirtyTables so the legs cannot drift from what the body writes.
issueops: ensureStoreEpochRow seeds with INSERT IGNORE and reads the row back,
as version_history.go does for the same row.
Not changed, on purpose: a mint overlapping a concurrent bump can still commit an
address the bump already voided. Dolt has no lock for it and the only conflicting
write would overwrite bumped_at/bumped_reason; see the doc comment on
TestMintOverlappingABumpCommitsAnAddressThatIsAlreadyGone. One comment in that
test file is reworded; no test logic changed since the red commit.
* chore(bazel): bazel-sync (gazelle) for the two new epoch test files
Only the two go_test srcs entries for the test files this branch adds:
epoch_cas_publish_test.go (dolt) and epoch_cas_status_test.go (embeddeddolt).
gazelle wanted nothing else for them (no deps change).
* test(conformance): add the optional EpochFixture.LoseVersion capability
Record survival explicitly instead of inferring it (gastownhall/beads#6664,
review 5360880888, Major 1). Once an address stays served unless its own row
says the store lost it, the only way for the contract to produce a Gone
address is an explicit loss, so the contract needs a way to say "the store
lost this Version".
LoseVersion is additive and optional: no existing field changes signature,
and a nil LoseVersion makes the cases that need one skip with a named reason.
It is its own commit so that it can be judged, or replaced, on its own: the
same semantics could ride on BumpEpoch taking a lost set, and only the
plumbing would differ. Nothing uses it yet.
* chore(epoch): add signature-only stubs for the survival rework
The tests that follow exercise BumpEpochCarryingInTx, LoseVersionInTx,
ErrEpochAddressNotServed and the BumpEpochCarrying and LoseVersion store
methods (gastownhall/beads#6664, review 5360880888). Stubs give those names
so the tree builds and the tests fail for their real, behavioural reasons
instead of failing to compile.
No logic: ErrEpochAddressNotServed is a sentinel, BumpEpochCarrying advances
the counter exactly as BumpEpoch does and carries nothing, and LoseVersion
returns "not implemented". The next commit adds the tests; the one after
replaces these bodies.
* test(feat): red — record survival explicitly in epoch_minted_addresses, make CurrentAddressFor read-only, carry on a token-scheme change
Tests for the survival rework of gastownhall/beads#6664 (review 5360880888:
Major 1, Minors 3 and 4). Every test is written before any production change.
- Contract: the earlier mint-driven R20-n case is restated as three named
phases (a survivor and a lost Version, loss is terminal, survival needs no
upkeep), plus three new cases for a token-scheme change (carry the live
lineages and only those, a carried address keeps resolving across later
bumps, a lost address stays Gone across a scheme change). All three legs
register them and wire LoseVersion and the carrying bump.
- Shared body: unit tests for the row-based resolver (exactly the address's
row and the epoch, fail closed on a row from a future epoch), a read-only
CurrentAddressFor with typed errors, LoseVersion, a bump that writes only
store_epoch, a mint that never hands back a lost address, and the
per-database counter (Minor 3). Minor 4 gets a guard that no address in the
test file is written by hand.
- Real engine: the carry on the embedded leg (one carry row per live id, the
lineage root, the collision rule, a row from a future epoch, a rewound
counter, database-wide, lost lineages), the publication sets of every
writer, and on the server leg the overlap of a mint with a bump (now a Live
survivor) and a deterministic mint-after-loss interleaving that must not
revive the lost address.
- Migration 0071 byte pin and a real-dolt shape check for carried_from,
gone_at_epoch, the carried_from index and the gone-not-before-mint CHECK.
These fail on the current code, and some do not build yet because
BumpEpochCarryingInTx, LoseVersionInTx, ErrEpochAddressNotServed and the store
methods they exercise do not exist.
* feat: green — record survival explicitly in epoch_minted_addresses, make CurrentAddressFor read-only, carry on a token-scheme change
The survival rework of gastownhall/beads#6664 (review 5360880888: Major 1,
Minors 3 and 4). An address's status is now a function of its own row and the
current epoch, never inferred from other rows.
- Migration 0071 (edited in place; no new slot, no ALTER): the table gains
carried_from, gone_at_epoch, an index on carried_from and a CHECK that a loss
epoch is not before the mint epoch.
- Shared body: Live unless gone_at_epoch is set, and a row from an epoch that
has not happened yet fails closed; the chain query is deleted. CurrentAddressFor
only reads and returns typed errors. LoseVersion marks a whole lineage lost,
once, guarded by gone_at_epoch IS NULL. BumpEpochCarrying (token-scheme change)
writes one carry row per live lineage naming the lineage root, resolves a
shared-id collision by carrying the newest and losing the rest, and fails if a
row already sits at the new epoch. A mint only inserts its own root row and
never hands back an address that is not served. A restore or reinit bump
still writes only store_epoch.
- Both Dolt legs: BumpEpochCarrying publishes store_epoch and
epoch_minted_addresses, LoseVersion publishes epoch_minted_addresses and
returns a failed publication, and CurrentAddressFor runs on the read path and
publishes nothing. The per-database epoch counter (Minor 3) and the
requirement that a caller of the carrying bump hold the workspace gate
exclusively are documented where they apply.
One change to tests written in the previous commit: the three real-server
publication probes that only need a clean working set now open a database of
their own, as the overlap tests do, instead of queueing on the shared test
database's schema-init lock. Its five-second acquire timeout ran out under load
and failed two of them; no assertion changed.
* test(dolt): run the epoch contract on a database of its own
TestEpochContract set up through setupTestStore, which puts every parallel
test on the shared test database and queues their schema initialization on one
lock with a five-second acquire timeout. Under host load a setup that waits
behind another parallel test's runs out of it and fails at its first line with
"schema migration lock unavailable: timeout". That failed the unchanged
first-mint test twice in the dolt lane once this change had added tests to it,
and the contract's own setup is exposed to the same timeout.
The contract now opens a database of its own, the way the overlap tests and the
publication probes already do, so this change adds no contention on the shared
database's lock. No assertion changed.
* docs: replace internal tracker ids in the epoch comments and test names with plain descriptions
Comment and text edits only; no behavior changes and no line is added or
removed (21 lines are replaced one for one). Each replaced line named an
internal tracker id in a header, a test comment, a failure message or the
migration header; it now says what it meant in plain words or cites the
upstream issue or pull request. The EpochFixture API lines and the already
published commit messages are left as they were.
* ci: list this PR's embedded storage tests in the embedded shard manifest
#7156 made the embedded-Dolt tier's shard manifests exact-once (50 cmd
shards, 15 storage shards), so every embedded test must be listed. This PR
adds eleven embedded storage tests and no embedded cmd tests; this commit is
exactly what the generators write for them:
python3 scripts/ci/gen_embedded_cmd_shard_manifest.py 50 --weights=duration --write
python3 scripts/ci/gen_embedded_storage_shard_manifest.py 15 --weights=duration --write
Incremental: 11 lines added, none moved; the cmd manifest is unchanged.
Rebase note (maintainer): regenerated on current main, whose embedded storage
manifest uses a 40-shard block; the generator's incremental output placed
these tests at shards 7, 9, 11, 20, 21, 28, 31, 32, 33, 34 and 36 of 40, one
test per shard (gen_embedded_storage_shard_manifest.py 40 --weights=duration
--write; --check passes).
* chore(bazel): bazel-sync for the epoch sources and migration 0071
The BUILD files did not list epoch_cas.go in the dolt, embeddeddolt and
issueops libraries, issueops' epoch_cas_test.go, or migration 0071 and its
test, so Bazel could not compile those packages' tests. This is exactly the
patch make bazel-sync writes (gazelle plus go_srcs.py; the PR's BUILD-sync
CI step printed it): 4 files, 6 lines, nothing else.
Rebase note (maintainer): the migration is now 0072, per the landing-order
ruling (#6943's participation_generation is 0070 and #6661's
removed_restriction is 0071); the commit "chore(schema): renumber
epoch_minted_addresses to 0072 after #6661's 0071" renames these BUILD
entries. On the rebased base, this commit's internal/storage/schema/BUILD.bazel
hunk is merged with the base's 0070 and 0071 entries.
* chore(schema): renumber epoch_minted_addresses to 0072 after #6661's 0071
Migrations are numbered by landing order. #6943 (participation_generation,
the versioned-history write fence) owns main-plane 0070 and #6661
(removed_restriction) owns 0071, so this PR's epoch_minted_addresses
migration moves to the next free slot, 0072. The rename is done here, as one
maintainer commit, rather than inside the replayed commits, so the history
shows exactly what changed relative to the PR as reviewed.
- migrations/0071_add_epoch_minted_addresses.{up,down}.sql become 0072_*.
Neither header names its own number, so the SQL and its comments are
unchanged. Neither file exists on main, #6943 or #6661, so this is not an
edit to a shipped migration.
- cli_migrations.go needs nothing: the migration is a plain CREATE TABLE IF
NOT EXISTS with no CLI-bundle override.
- migration_0071_add_epoch_minted_addresses_test.go becomes
migration_0072_add_epoch_minted_addresses_test.go; its consts, tests and
messages say 0072, it owns the one LatestVersion pin (72), and its slot
history now records the move past #6943's 0070.
TestLatestVersionIncludesMigration0071 in #6661's removed_restriction test
was already retired to a pointer comment by the rebase's resolution of
"renumber epoch_minted_addresses to 0070"; that comment now names
TestLatestVersionIncludesMigration0072 and its file.
- BUILD.bazel embedsrcs/srcs, and the three epoch_cas.go headers (dolt,
embeddeddolt, issueops) that cite the migration number.
The intermediate commits of the rebase are not expected to build, for two
reasons:
- a duplicate migration version: the PR's epoch_minted_addresses migration
shares 0069 with main's 0069_widen_issue_versions_datetime_precision until
the PR's own "renumber epoch_minted_addresses to 0070", and from there
shares 0071 with #6661's removed_restriction until this commit;
- a helper-name collision: from the PR's "feat: green — Fix PR #6664: restore
R16 honest-skip ... (refs be-ah0jf)" on, internal/storage/issueops declares
readStoreEpochInTx twice, once in #6943's version_history.go and once in
this PR's epoch_cas.go, until "fix(epoch): rename #6664's read-only
store_epoch read past #6943's readStoreEpochInTx" later in this stack.
This commit ends the duplicate version, but it still does not compile on its
own because of the collision; the stack builds from the rename commit on.
Checked at the tip of the stack, where the rename has landed: go test
./internal/storage/schema/... with the dolt CLI lane
(including TestAllMigrationsSQLAppliesThroughDoltCLIAndRecordsLatestVersion
and TestMigration0072RecordsSurvivalInTheAddressTableThroughDoltCLI), and
scripts/check-migration-hygiene.sh with BASE_SHA=origin/main and
BASE_SHA=vh/6661-rebase.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(epoch): waive #6664's three new epoch contracts on main's http leg
main gained an HTTP storage leg (#7247) after this PR's base, and
TestEveryLegWiresEveryRoleContract requires every leg to name or waive every
role contract. This PR adds three EpochFixture cases
(RunTokenSchemeChangeCarriesLiveAddressesAndOnlyThose,
RunACarriedAddressKeepsResolvingAcrossLaterBumps and
RunALostAddressStaysGoneAcrossASchemeChange); dolt, embeddeddolt and uow wire
them, and the http leg did not name them.
They are waived on the http leg with the existing
retentionEpochNoRoleWaiverReason, which already covers every other
RetentionFixture/EpochFixture case there: EpochFixture is raw storage hooks
(CurrentEpoch, BumpEpoch, MintUnderEpoch, StillServes, Resolve,
CurrentAddressFor, LoseVersion) with no publicops role behind them,
and internal/httpclient is a remote client with no epoch counter or address
table of its own. The constant's doc comment now counts eighteen cases.
Test-only; no production code changes. After this, the http leg's only
unnamed entrypoints are #6943's seven RunParticipationGeneration* contracts,
whose waivers belong to #6943.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(epoch): rename #6664's read-only store_epoch read past #6943's readStoreEpochInTx
#6943's "a create stamps participation even when the row is flagged
no-history" (7c00d65fa6) adds readStoreEpochInTx to version_history.go: the
mint's read of store_epoch, which SEEDS the singleton row when it is absent.
This PR's epoch_cas.go already declared a readStoreEpochInTx of its own, so
the package stopped compiling once #6664 was stacked on that commit.
The two cannot be folded into one. This PR's helper is deliberately
read-only: an absent row answers epoch 1 without writing, so
CurrentEpochInTx, StillServesInTx, ResolveEpochInTx, CurrentAddressForInTx and
LoseVersionInTx never write from a read (review item B4, pinned by
TestCurrentAddressForNeverReseedsAnAbsentStoreEpochRow and
TestCurrentAddressForWritesAndPublishesNothing). Calling #6943's seeding read
from those paths would break that.
So #6664's helper becomes readStoreEpochWithoutSeedingInTx, and its doc
comment says why it is not readStoreEpochInTx. The five call sites and the
ensureStoreEpochRow comment that names it follow. No behavior changes on
either side: #6943's mint path keeps its seeding read, and this PR's read-only
paths keep theirs. (ensureStoreEpochRow, which BumpEpochInTx and
MintUnderEpochInTx use, now has the same body as #6943's readStoreEpochInTx;
it is left as it is rather than folded in here.)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(storage): say exactly why the retention and epoch contracts stay waived on http
All but four of the participation-generation contracts (#6943's write
fence) now run over the served wire
(internal/httpclient/served_participation_generation_test.go): their subject
is a create or an update, which the client can send, and the fixture reads
the reference store's raw columns. The four stay waived, because the
mutation each needs has no form on the wire. This checked whether the
eighteen RetentionFixture/EpochFixture cases waived on the http leg,
including the three this PR adds, can be wired the same way. They cannot,
cheaply or otherwise, without a new wire operation:
- every EpochFixture hook (CurrentEpoch, BumpEpoch, MintUnderEpoch,
StillServes, Resolve, CurrentAddressFor, LoseVersion) is the operation
under test, not a seed or a raw read. Those operations are methods on the
concrete *DoltStore and *EmbeddedDoltStore over issueops' *InTx bodies, on
no storage interface, no publicops role and no wire operation. Every call
path into them starts in a test: the methods are called only from each
store leg's own _test.go files (its EpochFixture, which the conformance
contracts drive, and its epoch tests), and the *InTx bodies only from those
methods, from each other and from tests (the uow leg's fixture through a
test-only type assertion, and issueops' and the dolt leg's own tests). No
command, role or server handler reaches them, so no client mutation
touches epoch state either;
- RetentionFixture's hooks (Resolve, Remove, Hold, ForceRemove, Erase, Mint)
are implemented by no backend yet (every store leg wires them nil and its
cases skip), and the wire has no removal, hold, erasure or gone/unknown
resolve to bind them to.
Binding the epoch hooks to the reference store behind the served env would
pass, but as a property of that store, which the store legs already pin,
never of the client. So the waivers stay; retentionEpochNoRoleWaiverReason's
comment and reason string now say the above, in the shape #6661 gave
asOfReadNoHTTPWireWaiverReason, instead of the earlier general "raw storage
hooks with no publicops role" wording.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(epoch): report applied-but-unpublished epoch writes as indeterminate, bound address length, verify dup-key mints
Maintainer fixup for the #6664 review (adopt-pr attempt 1, iteration 1).
Major 1, applied writes reported as failed. An epoch writer whose SQL
commit has landed, or may have, now wraps storage.ErrCommitIndeterminate
on both legs and hands back what it applied, so nothing replays a bump
that has already advanced the counter:
- embedded BumpEpoch and BumpEpochCarrying return the new epoch with the
error (failedBump), and MintUnderEpoch its address;
- server bumps wrap the sentinel on every Dolt failure after the SQL
commit, including a failed staged-set read (unpublishedBump), and so
does LoseVersion; an indeterminate SQL commit returns the epoch or
address it may have committed, and a definite (typed MySQL) commit
error returns neither.
Tests: TestEpochWritesReportAnUnpublishedCommitAsIndeterminate (new,
embedded, through an afterSQLCommit seam in runTransactionWithMessage);
on the server leg TestEpochWritesMarkAFailedStagedReadIndeterminate,
TestEpochWritesReturnWhatAnIndeterminateSQLCommitMayHaveApplied and
TestEpochWritesReturnNothingWhenTheSQLCommitFailsDefinitely, and the
sentinel asserted in every publication-failure test.
Major 2, address overflow. MintUnderEpochInTx refuses a pair whose
address would outgrow epoch_minted_addresses.address (VARCHAR(255)) at
the widest epoch the counter can reach, with a typed
ErrEpochAddressTooLong, so a carry can never fail on a lineage that
gained an epoch digit.
Major 3, duplicate-key mint. A duplicate key from the mint's INSERT is
no longer success: the row is read again and the mint stands only if
this transaction sees it served; a Gone row fails the mint with
ErrEpochAddressNotServed, an unreadable one with the duplicate-key
error. Measured on dolt-sql-server 2.2.0, the stale-snapshot INSERT does
not report a duplicate key at all: its COMMIT fails with Error 1213 and
the retried mint answers ErrEpochAddressNotServed
(TestAMintRacingTheMintAndLossOfItsAddressConflictsAtCommit).
Minors:
- absent store_epoch row: sqlmock cases pin that CurrentEpoch,
StillServes, Resolve, CurrentAddressFor and LoseVersion never seed it;
switching any of the five to the seeding reader now fails the test;
- the server publication tests mint their address instead of writing it
by hand, and TestEpochCASTestsBuildEveryAddressWithEpochAddress scans
that file too (issueops_test gains //internal/storage/dolt:go_srcs as
data);
- stale text: the duplicate-key and carry comments, the issueops
header's CompareAndSetVersionInTx citation, the embedded header's
parity claim, and the 0072 header's "upserts the same row" (0072 is
past the frozen floor).
Declined, for the owner:
- a scheme-change carry voids an older live lineage re-minted after a
restore: rule (a), document and pin it, or rule (b), resolve the loser
to the winner's carry, is a design call about R20-n, not a review fix;
- the uow epoch fixtures' in-transaction DOLT_COMMIT('-Am'): test-only
fixtures with no production caller; routing them through RunTxScoped
is follow-up work.
Validation: go build ./...; go vet; nogo (bazel --config=nogo) on
issueops, dolt and embeddeddolt; issueops epoch tests; the dolt epoch
tests against a real dolt-sql-server (56 pass) and the fake-backed
publication tests; embedded epoch tests with BEADS_TEST_EMBEDDED_DOLT=1;
uow epoch contract; the schema package; the address guard under bazel
in the local sandbox. All 14 overlay mutants of the fixes are killed.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Jim Wordelman <mayor@quad341.uk>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* test(conformance): author R7.1 as-of-read conformance contract
Adds a new Phase 0 conformance contract for R7.1 (as-of reads,
gastownhall/beads#6136, design doc #5898 rev 9) -- no fixture existed for
this anywhere in backend/conformance/, so this is authored from scratch,
not un-skipped.
AsOfReadFixture supplies three hooks: Resolve (the read under test),
MintAt (seeds a version at a controlled accept-time), and
MakeUnanswerable (arranges a Gone/Unknown refusal independently of
RetentionFixture/EpochFixture's own removal machinery, since R7.1's
refusal is a sibling contract to R17/R20, not a dependent of them).
Five Run* functions cover the bead's five required-coverage points
verbatim:
- selector accepts either an instant or a version address, and both name
the same answer when they resolve to the same version;
- resolution returns the latest version at-or-before T, with a version
accepted after T strictly excluded even when close by;
- a served result reports the exact address it served;
- an unanswerable read refuses as a typed Gone*/Unknown outcome with a
reason, and never substitutes a neighboring version, the nearest
surviving version, or current state -- asserted directly by requiring
Address == "" on every refusal;
- local completeness only (TC3): a lineage minted into one of two stores
resolves there and refuses Unknown (FR-06) on the store that never
received it, asserting nothing about agreement between the two.
The file's doc comment states the Memory-plane-consumer-policy non-goal
explicitly (closed-before-T boundary, sibling exclusion, supersession
exclusion are consumer policy per #5877, not part of this primitive) so
the gap reads as deliberate scope, not an oversight.
Wired onto all three storage legs (dolt, embeddeddolt, uow) with
unconditional "not implemented" stubs rather than partial-real hooks, so
every case fails via MintAt on its first fixture call -- deterministic
RED with no risk of an accidental pass, per the precedent set by
be-x5jqd.1. Sentinel error messages reference be-x5jqd.5, the
implementation child this suite is written ahead of.
TestEveryLegWiresEveryRoleContract requires zero waivers: all 5 new
entrypoints are fully wired (not nil) on all three legs.
Branch cut from the rebased be-2h167 head (5fdfb92fe5).
Verified via go build ./..., go vet ./..., gofmt -l, and go test -tags
cgo across all three legs: all 5 new subtests (8 counting the 4-way
Gone/Unknown table) FAIL for the documented reason,
TestEveryLegWiresEveryRoleContract passes cleanly on all three legs, and
TestVersionedHistoryPhase0RunsInFullSkipMode is unaffected.
Bead: be-x5jqd.2
* fix(history): refuse metadata integers binary64 cannot hold exactly (refs be-wdlod, #6358 follow-up)
canonicalDurableState canonicalizes numbers per RFC 8785 (JCS), which
renders every number as an IEEE-754 binary64 double regardless of
magnitude. An integer-valued metadata literal past 2^53-1 therefore
rounds to a DIFFERENT VALUE on the way into durable_state -- not a
formatting change, a value change -- which can collapse two distinct
issue states onto one durable_state and therefore one content token.
refuseUnrepresentableIntegers is the fix: an admission gate, one layer
above the JCS step, that parses each JSON number literal exactly with
math/big (never float64 -- float64 rounding is the exact thing being
guarded against) and refuses whenever the literal's VALUE, not its
spelling, is an integer whose magnitude exceeds 2^53-1. Value-not-form
matters because the first cut of this gate skipped any literal
containing '.', 'e', or 'E' outright, reasoning that non-integer forms
round-trip losslessly -- true for genuinely fractional literals, but
not for an integer VALUE spelled in decimal or exponential form: QA
found that 9007199254740993.0 and 9.007199254740993e15 walked straight
past that first gate and canonicalized to the same colliding target as
the bare literal. The predicate now inspects the value via
big.Rat.SetString/.IsInt, so all three spellings are refused alike.
1e300 is refused too, no notation carve-out: it denotes the integer
10^300, and binary64 spacing near that magnitude is roughly 2^248 --
vastly wider than the collision window at the 2^53 boundary this gate
exists to close. Admitting that spelling while refusing 9007199254740993
would be the same defect with a bigger window (mayor's ruling, citing
this collision-window argument as decisive). Non-integer values stay
admissible past the bound (1.5e300 is fine): ES6 shortest-round-trip
formatting is a bijection on doubles, so two non-integer literals
collide only if they already denoted the same double before this gate
ever ran, and a fractional literal never carried a promise of exact
decimal storage the way an integer -- an id, a count, a timestamp --
carries a promise of exactness that silent rounding would corrupt.
jcsCanonicalize is canonicalDurableState's RFC 8785 step pulled out on
its own, below the gate rather than behind it, because refusing 1e300
puts the admission policy at odds with one of this store's own spec-
conformance fixtures: testdata/jcs/input/values.json, one of the 10
official RFC 8785 vectors shipped verbatim from the spec's reference
suite (not authored here), itself contains 1E30. RFC 8785 conformance
is a claim about the canonicalizer, not about this store's admission
policy, so TestCanonicalDurableStateIsJCS now runs all 10 shipped
vectors -- values.json included, still asserting 1E30 folds to 1e+30
per spec -- through the ungated jcsCanonicalize, while its two local ad
hoc cases keep exercising the full gated canonicalDurableState, since
neither conflicts and both are more faithful to production traffic that
way. The gate's own refusal of that magnitude is pinned separately, on
its own terms, in version_history_integer_admission_test.go.
Severity is MINOR, not MAJOR: Dolt's JSON column type already
renormalizes metadata to float64 on every read regardless of this gate
(measured on dolt 2.2.3: 9007199254740993 reads back as
9007199254740992, 1e300 as 1e+300), which converges two distinct
in-memory states to one stored state before any version row is minted.
The collision this gate closes is therefore unreachable through normal
bd update traffic on this backend; it stays real for off-path writes --
bd sql, a hand-written JSONL import, or a TEXT-column backend -- which
is why this landed as a follow-up rather than gating Phase 2 itself.
Verified clean: a full module compile; static analysis over the
storage tree; the complete issueops package suite (260 subtests); the
schema package suite; and the broader storage tree, apart from one
dolt-package test that fails identically against the pre-this-diff
baseline (a Dolt server port collision with a concurrent session's
process on this host) -- confirmed pre-existing and environmental, not
caused by this change.
* feat(issueops): implement R7.1 as-of read's store-layer primitive (be-x5jqd.5)
Turns backend/conformance/versioned_read_contract.go (authored RED in
6aefdce60, gastownhall/beads#5898 rev 9, #6136) towards GREEN. This
commit lands the shared production seam; wiring the three per-leg
fixtures (dolt, embeddeddolt, uow) onto it is a follow-up commit.
asof_read.go (new): AsOfReadInTx resolves an AsOfSelector (an instant
or a previously-served version address) to one issue_versions row --
the latest version accepted at or before T, everything later strictly
excluded -- and reports either its state and address, or a typed
refusal (gone-retention/gone-erasure/gone-reorganization/unknown) with
a reason. storeID is accepted only for signature parity with the
fixture hook shape (Design D: the conformance suite's own ad hoc
dispatch string selects among per-leg isolated test stores; issue_versions
carries no store_id column, matching CurrentEpochInTx's precedent).
AsOfRestriction is string-backed, unlike R20's int-backed
EpochRestriction, because it round-trips directly through the new
removed_restriction column with a plain cast.
Migration 0069 adds issue_versions.removed_restriction VARCHAR(30),
nullable (NULL = live, never a stored value). Sits alongside removed_at/
removed_reason (migration 0067, virgin until this slice); AsOfReadInTx
only READS all three -- a future R17 is the real writer via hold/remove/
erase primitives, no collision. Guarded PREPARE + CLI direct-DDL
override + schema_test.go hygiene entries, all modeled on 0068's
pattern; TestLatestVersionIncludesMigration0068 is superseded per the
one-pin-at-a-time convention.
version_history.go: splits RecordVersionInTx into a versionedHistoryEnabled-
gated wrapper and a new exported RecordVersionAtInTx, both delegating to
a shared recordVersionAtInTx(..., at time.Time) body. RecordVersionAtInTx
is test-support only -- ungated, caller-chosen timestamp -- so an as-of-
read fixture's MintAt hook can mint version rows dated in the past
without flipping a store's history-enabled flag. No behavior change for
existing RecordVersionInTx callers.
The new/moved code shifted which function each completeness guard sees
as the enclosing write site, so all three needed updating, not bypassing:
- row_lock_guard_test.go's funcNameExemptions key moves from
RecordVersionInTx to recordVersionAtInTx (the write's new actual
enclosing function), reasoning extended to cover both callers.
- journal_completeness_test.go's beadDMLExemptions and
version_completeness_test.go's versionExemptions each gain a
RecordVersionAtInTx entry mirroring RecordVersionInTx's own (test-
support twin, no production caller, no mutation of its own to
journal/mint beyond the seam itself).
Also fixed a latent test-helper gotcha found while writing the 0069
Dolt-CLI test: queryDoltCSV trims the whole `dolt sql -r csv` output
before parsing, so a row whose ONLY selected column is NULL renders as
a bare blank line that strings.TrimSpace silently swallows when it's
the trailing line, collapsing "one row, NULL value" into "zero rows".
Fixed by selecting a non-NULL anchor column (issue_id) alongside the
column under test.
Verification performed: full module compile and static analysis, gofmt
clean; the complete internal/storage/schema suite with the real-Dolt-CLI
lane enabled; and the complete internal/storage/issueops suite,
including every completeness/row-lock structural guard -- all clean.
* feat(issueops): wire dolt, embeddeddolt, and uow onto R7.1 as-of read (be-x5jqd.5)
Turns backend/conformance/versioned_read_contract.go fully GREEN
(authored RED in 6aefdce60, gastownhall/beads#5898 rev 9, #6136): this
follows up on 4da98a9a8's shared production seam by wiring all three
storage legs' AsOfReadFixture (Resolve/MintAt/MakeUnanswerable) onto
issueops.AsOfReadInTx, per that commit's own stated plan.
Each leg's asOfReadHarness is Design D's dispatch table: the
conformance suite invents storeID strings to select among N isolated
stores, and isolating them is entirely the harness's job --
AsOfReadInTx itself stays storeID-oblivious. The three legs differ
only in how they get that isolation cheaply:
- dolt: one shared testcontainer, N randomly-named databases
- embeddeddolt: N fully independent on-disk databases
- uow: one shared dolt sql-server subprocess (NewDoltServerUOWProvider's
adoption semantics collapse repeat calls against the same root dir
onto the same process), N randomly-named databases
All three harnesses are Fatalf/Skip-free below their own
TestAsOfReadContract body: AsOfReadFixture's hooks carry no *testing.T
of their own and run from inside t.Run subtest closures (sometimes
nested two deep), where FailNow/SkipNow would panic with "subtest may
have called FailNow on a parent test". Failures instead flow back as a
plain error into conformance.RunAsOfReadXXX, which Fatalfs correctly
on the subtest's own goroutine.
Two small companion fixes surfaced while wiring the legs on:
- issueops.asOfVersionAddress -> AsOfVersionAddress (exported): each
leg's MintAt needs to build the exact token its own
RecordVersionAtInTx write will resolve against, from a different
package than issueops.
- recordVersionAtInTx now truncates `at` to whole seconds before
writing it to issue_versions.change_at (DATETIME, migration 0067).
Measured on dolt 2.2.3: the column ROUNDS a sub-second value rather
than truncating it, so a change_at of 13:32:04.77 lands at 13:32:05
-- strictly later than the instant it was meant to record. That
breaks resolveAsOfRevisionInTx's "at or before T" comparison
(asof_read.go) for any T between the true instant and the rounded-
up one. This is a production correctness fix, not test-only:
RecordVersionInTx hits the identical hazard on every real
time.Now().UTC() call whose nanosecond component rounds up.
Verification performed:
- uow: TestAsOfReadContract green standalone (5 subtests, 4 nested
restriction variants) and the full uow package green in isolation
(673s, includes pre-existing TestReleaserContract and everything
else). A `go test ./internal/storage/...` full-tree sweep flagged
uow FAIL via a 600s hang inside TestReleaserContract's migration
lock -- traced to cross-package parallel resource contention from
running the whole storage tree's dolt-sql-server-spinning suites
concurrently, not a regression: the same test is clean when the
package runs alone.
- embeddeddolt: TestAsOfReadContract green (22.89s, all subtests and
all 4 restriction variants).
- dolt: skipped on this host -- no Docker for the leg's testcontainer,
the same pre-existing skipIfNoDolt gate the whole dolt package
already runs under, unrelated to this change.
- TestEveryLegWiresEveryRoleContract and
TestEveryContractImporterInTheStorageTreeIsRegistered both pass for
all three legs.
- gofmt clean; whole-module build and vet clean.
Bead: be-x5jqd.5
* feat(versions): bd versions + a config switch for versioned history (refs be-hs42e.6.2)
Versioned history has been buildable but not usable: migrations 0067+ create
issue_versions, and the Phase 2 writer fills it, but SetVersionedHistoryEnabled
was a Go method nothing in cmd/bd ever called. There was no supported way for a
person to turn the feature on, and no way at all to read it back without raw
Dolt SQL. This adds the switch and a reader.
- versioned-history.enabled (env BD_VERSIONED_HISTORY_ENABLED), default off,
applied at the top of wireStorageDecorators. It MUST run on the raw store:
the capability is a type assertion and no decorator forwards it, so applying
it after a wrap would silently leave history off while the config said it was
on. TestVersionedHistoryConfigAppliesToTheRawStore pins the ordering, and
fails rather than skips if a decorator ever starts forwarding.
- storage.VersionLister + issueops.ListVersionsInTx over issue_versions, on the
dolt and embeddeddolt legs. A narrow capability rather than a Storage method,
following ExternalRefHistoryQuerier: a backend that cannot know must be able
to say so instead of answering "none".
- bd versions <id>, with three distinguishable outcomes rather than two. Off,
unsupported, and empty are different answers with different fixes; an empty
list is a claim about the bead, and returning it for the other two would be a
wrong answer rather than an empty one. The four removal restrictions render
as four sentences, and unknown (no lineage knowledge here) is not gone.
- REV is printed as a local ordinal with a footer saying so. It is deliberately
NOT presented as a citable address: AsOfVersionAddress mints over the ordinal,
two clones can both hold revision 8 of the same bead, and the durable
version_id primary key has not landed. An address printed now would break
every citation once it does.
- bd version <id> now points at bd versions <id> instead of printing bd's own
build and looking like the bead has no history. Bare bd version is unchanged.
No migration: 0067/0068/0069 already carry every column this reads.
Verified on a scratch store: create + 2 updates + close with the flag on lists
4 attributed versions; with the flag off, 0 rows in issue_versions and the
command refuses naming the key.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(versions): emit local_revision, not revision, in --json (bee's #5898 consumer read)
types.Issue already ships `json:"revision"` (types.go:1206) and it is the
row-lock CAS token — an unrelated value, and a string where this one is an
int64. Emitting "revision" from the versions payload would put two meanings
and two types on one key in the place machines read: the `bd version`
collision again, with worse consequences, since a script that learned one
shape gets the other and cannot tell.
local_revision also carries the non-citability with the value rather than
only in a footer no script parses, and needs no rename when version_id lands
beside it.
Raised by @bee-ghosttrack's consumer read on #5898, who reported a couple of
hundred script files parsing `bd … --json` — this is the part of the surface
they would actually touch. Pinned by
TestVersionsJSONDoesNotCollideWithIssueRevision.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(versions): make the advertised switch actually switch it on (#6661 review)
@bee-ghosttrack's blocking finding: the help text and the off-refusal both
told the user to run `bd config set versioned-history.enabled true`, and that
command did not turn the feature on. The key is not yaml-only, so `bd config
set` routed it to the workspace DATABASE; both readers called config.GetBool,
which is viper (yaml + env) only. The user ran exactly what they were told,
was told it was set, and recording stayed off — configured on, actually off,
one layer up from the decorator-ordering hazard this command already guards.
Takes bee's option (b): read the switch from the store's own config, where
`bd config set` already writes it. That also makes recording a property of
the STORE rather than of whoever is calling, which is what closes finding 2 —
two clients of one sql-server can no longer disagree about whether a write is
recorded.
The two planes are OR'd rather than ranked. The hazard is a write that fails
to record, never one that records when it needn't, so either saying yes is
enough and neither can silently switch the other off. BD_VERSIONED_HISTORY_ENABLED
still works for a one-off run. A store with no settings plane (proxied, no-db)
falls back to viper instead of failing the command.
Also from that review:
- finding 3: the read no longer refuses just because recording is off. A store
that recorded for a month and was switched off HAS versions; refusing made a
claim about the store from a fact about this invocation's config, which
VersionLister's own doc says are independent. Rows are listed either way,
with a note when recording is currently off; refuse-with-remedy only when
off AND empty.
- finding 4: an unresolved id with no versions is "no such bead", not "none
yet". Falling through on an unresolved id stays right — a deleted bead can
still have versions — but only until the answer is empty.
- finding 5: the ordering test's escape hatch is t.Fatal, not t.Skip; a skip
returned before the assertion that actually guards the ordering. The
storage_chain.go doc cited a test name that never existed. version_lister.go
promised a list of compile-time assertions that was not there; the
assertions now exist in each leg's own package, where they can compile.
- `versioned-history.` is a recognized config prefix, so the set no longer
prints "not a recognized config key" immediately before confirming the set.
Test: TestVersionedHistorySwitchRoundTrip_Embedded drives the real
`bd config set` through to a real `bd versions` against a real store, with
BD_VERSIONED_HISTORY_ENABLED cleared so a pass proves the store setting
carried it alone. This is the round trip bee asked for, and it is the only
shape that could have caught the original defect — a fake-backed unit test
cannot see a disagreement between two real planes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* docs(versions): name what the OR'd switch planes cost (#6661 review)
@bee-ghosttrack, round 2: with the two planes OR'd rather than ranked, the
consequence worth naming is that once the store setting says on,
BD_VERSIONED_HISTORY_ENABLED=0 cannot countermand it for a single run. The
help now says so, and says where to turn it off instead.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(versions): gate the wiring store read on the capability, not a recover (#6661 review)
@bee-ghosttrack's round-3 blocking finding. wireStorageDecorators reads the
versioned-history switch off the raw store on every bd invocation, and did so
before anything established that the store could use the answer. cmd/bd's own
fakeProbingDoltStore embeds a nil storage.DoltStorage, so the promoted
WorkspaceConfig SIGSEGV'd at wiring time -- and a panic takes the whole test
binary down, which is why one unguarded read showed up as two red CI steps
(Test (macos-latest), PR Core (wrapper timing)) rather than one failed test.
Takes the fix bee prescribed: assert storage.VersionedHistoryConfigurer first
and read the store plane only when the store could act on the answer.
The previous round fixed this with a recover plus a WorkspaceConfig on the
fake, and left a comment arguing that no capability assertion could work. That
argument was wrong, and wrong in a specific way worth recording: it reasoned
about asserting WorkspaceConfig, which IS declared on storage.DoltStorage and
so matches every store including the nil-embedding fake. bee proposed
asserting VersionedHistoryConfigurer, which is a different interface --
SetVersionedHistoryEnabled is NOT part of DoltStorage, so the fake does not
promote it and does not satisfy it. The comment rebutted a fix that had not
been proposed. It now states what is actually true.
So the fake goes back to byte-identical with the pushed head: the wiring fix
fixes that test without touching it, as bee said it would, and the fake keeps
the "only the methods below may be called" constraint its own doc asserts.
The recover stays, as a backstop rather than the guard. It covers what the
assertion does not: versionedHistoryEnabled is also called from `bd versions`,
where the read is the point and no capability gate precedes it, and a store
that DOES implement the capability can still have a half-built settings plane.
The viper plane is still read first and unconditionally, so a set-but-unsupported
store still reaches applyVersionedHistoryConfig and still gets its warning. Only
the store-plane read is gated. The one case that loses a warning is a store whose
own settings plane says true but which lacks the capability -- and `bd config
set` could not have written that plane on such a store to begin with.
Tests, split so each layer fails for its own reason:
- TestWireStorageDecoratorsSkipsTheStoreReadForANonConfigurer asserts calls == 0,
not merely that it survived. "It survived" is what the recover delivers too,
which is how this regressed the first time.
- TestWireStorageDecoratorsSurvivesAStoreThatCannotAnswer keeps the recover's
case, now on a store that IS a configurer so the guard lets it through.
- TestVersionedHistoryEnabledForWiringReadsTheStoreWhenItCanRecord pins that the
guard did not stop reading the plane finding 1 existed to start reading.
Mutation-verified both ways: removing the guard fails the first test on
calls=1/want=0 while everything still "passes" by surviving; removing the
recover leaves the first test green and fails only the second.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(versions): name the embedded round-trip so CI selects it (#6661 review)
@bee-ghosttrack's round-3 finding 2. The round-trip test that proves the two
config planes agree ran only on the author's machine.
.github/scripts/embedded-test-shard.sh discovers what to run with
`grep -rh '^func TestEmbedded' cmd/bd/*_embedded_test.go` and validates
manifest entries against ^TestEmbedded[A-Za-z0-9_]+$.
TestVersionedHistorySwitchRoundTrip_Embedded matched neither, so the only
lane that sets BEADS_TEST_EMBEDDED_DOLT=1 for cmd/bd never selected it; the
generic Test jobs run without that env, where the test's own guard skipped it.
Skipped and passed look alike from outside, which is what made it invisible.
Renaming is the whole fix -- a test absent from the shard manifest still gets
a shard from the fallback distribution. Verified by running the script's own
selector over the tree and confirming the new name is discovered.
The rationale is now a comment on the test, because the old name reads more
naturally and nothing else in the file explains why the prefix is load-bearing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(versions): drop the dead fixture, name the empty arm (#6661 review)
@bee-ghosttrack's round-3 finding 3. TestVersionsRefusesWhenFlagOff built a
backend holding one recorded version, handed it to nothing, and ended in
`_ = backend`.
The fixture was load-bearing for the assertion the test was named after --
that the read was refused BEFORE the backend was consulted. Finding 3 removed
that behaviour on purpose, so the assertion went with it; the fixture stayed
behind, unused, under a name still promising the old contract.
Renamed to TestVersionsOffAndEmptyRefusesWithRemedy for what it actually pins,
moved beside TestVersionsOffButRecordedStillLists so the two read as the pair
they are -- recording off decides the FOOTER, never whether to read; off with
rows lists them, off and empty is the one case that refuses -- and the dead
fixture is gone.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(proxy): give bd versions a capability row, a typed refusal (#6661)
main's proxied-server capability registry (#6582) requires every command
path to carry a row, and TestProxyCapabilityRegistryCoversCommandTree
fails for `bd versions`, which this PR adds.
It is refused, reason unimplemented, rather than permitted. It is a pure
read (issueops.ListVersionsInTx in one read transaction), so nothing
about it is unsafe on a shared backend and "design" would be wrong. But
it reaches the backend only through the optional storage.VersionLister,
which the dolt and embedded stores implement and the uow provider does
not. Permitting it would open the proxied provider in the root pre-run
(starting the proxy and dolt) and then fail untyped at
errVersionsUnsupported. The row refuses with proxy.versions.unsupported
before any side effect, and its tracking names the missing piece: a
VersionLister over the proxied uow provider (tracker #6132).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(uow): register verified shutdown cleanup in TestAsOfReadContract (#6661)
main's TestEveryServerFixtureRegistersVerifiedCleanup (#6441) requires
every server fixture to use verifiedShutdownCleanup(t, storeRootDir)
instead of calling proxy.Shutdown directly, so a shutdown that refuses
cannot leave a live dolt sql-server behind a green run. TestAsOfReadContract
still had its own proxy.Shutdown cleanup that only logged the error.
The cleanup is registered at the same point, so the LIFO ordering the
harness relies on (every provider closed before the shared server stops)
is unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* style(schema): gofmt cli_migrations.go after the 0070 renumber
The rebase onto upstream's 0069_widen_issue_versions_datetime_precision
(#6675) joined its const and the renumbered 0070 comment without the
separating blank line, which make fmt-check rejects.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(history): stop flooring change_at now that 0069 widened it (refs be-hs42e.10)
recordVersionAtInTx carried `at = at.Truncate(time.Second)`. That was correct
while 0067's plain DATETIME was in force: Dolt's datetime(0) does not truncate
sub-second input, it ROUNDS half-up, so a change_at could be stored strictly
LATER than the instant it recorded and break AsOfReadInTx's "latest version
accepted at or before T". Flooring first left nothing to round.
Migration 0069 widened change_at and removed_at to DATETIME(6), which removes
the rounding entirely and makes the floor actively harmful — it threw away the
microseconds the widening exists to keep. Two versions minted in the same
second collapsed onto one stored value and stopped being distinguishable by
change_at, which defeats --at, the only PORTABLE selector the read surface
offers while revision stays a per-store ordinal and no durable version address
has shipped.
This was measured, not inferred. On a store carrying both the widening and the
floor, four versions minted inside one second all read back 15:40:38.000000:
the column could hold microseconds and the writer refused to supply them. Two
correct fixes cancelling each other, and only the second one was visible.
removed_at needs no matching change: MarkLatestVersionRemovedInTx already
passes time.Now().UTC() straight through and was never floored. Audited rather
than assumed.
Pinned by TestRecordVersionKeepsSubSecondChangeAt (embeddeddolt), which mints
two versions 500ms apart inside one second and asserts both that the
fractional part survives and that the two differ. Verified it FAILS with the
floor restored — reporting exactly the 11:04:07.000000 collapse — and passes
without it, so it is a real guard rather than a test that passes either way.
The column's own half of the contract stays pinned by
TestMigration0069ChangeAtSurvivesSubSecondPrecisionThroughDoltCLI.
Also drops this branch's own tx-minting guard commit, which upstream landed
independently as #6833.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(feat): red — Activate versioned history in every store and provider factory, each store reading its own #6661 switch (stacked on #6661) (refs be-qxq70)
Tests first, all failing on the right reasons at fb6e219d6a (#6661's head):
- D1: on real embedded stores a routed update, a routed close and
`bd create --repo` into a rig whose OWN row is on each gain 0
issue_versions rows, want 1; the control (a write inside the rig) gains 1.
- D3: BD_VERSIONED_HISTORY_ENABLED=1 records into no routed store, and =0 is
shown not to switch off a store whose row is on.
- D4: TestEveryStoreConstructionActivatesVersionedHistory flags all 9 store and
provider factories, and its mutation probe reports "probed 0 of 9".
- wiring: wireStorageDecorators still reads the store's row (1 read) and
switches it on; activation belongs to the factories.
- internal/versionedhistory (does not exist yet) and the doctor repair opener:
the resolver, the provider read (K1), the error-vs-absent diagnostics and the
shared-activation requirement.
* feat: green — Activate versioned history in every store and provider factory, each store reading its own #6661 switch (stacked on #6661) (refs be-qxq70)
Stacked on #6661 (fb6e219d6a). #6661's plane and approved commits are
unchanged: the switch stays a row of the store's own config table, OR'd with
viper, and `bd config set versioned-history.enabled true` still writes that
row and not config.yaml.
The defect: applyVersionedHistoryConfig ran only from wireStorageDecorators, so
the one store a command opens for its own workspace was activated and every
store built by newDoltStoreFromConfig (prefix-routed update/close, `bd create
--repo`, the direct-mode open) was not. With the switch on they recorded no
issue_versions row while the command reported success.
- Activation moves to where a store or unit-of-work provider is constructed
(the store_factory.go/_nocgo.go twins, uow_factory.go's two provider
constructors, the personal-migration planning store, and bd doctor's repair
opener), on the raw store, before anything can wrap it. wireStorageDecorators
no longer activates, so each store's row is read once per open.
- One resolver, in internal/versionedhistory, reachable from doctor/fix which
cannot import package main. #6661's semantics are preserved: one key
spelling, viper first, then the capability check, then the row read, with
the recover backstop. The behavior-preserving refactor of #6661's
versioned_history_switch.go / storage_chain.go is the only edit to files
#6661 introduced; the resolver tests moved with the code, assertions
unchanged.
- K1: a provider has no DoltStorage, so its row is read through a unit of work
(NewUOW + ConfigUseCase().GetConfig) at construction: a pooled connection,
one SELECT, rolled back. The constructors have already run initSchema, so
this starts no server and creates nothing. It does not fall back to viper
alone.
- A row read that errors resolves to off but is reported under BD_DEBUG; an
absent row stays silent.
- Docs (configuration.md), a CHANGELOG entry, and a hint at `bd config set ...
true` time that the setting replicates and is single-writer only.
The bazel-sync run also wanted unrelated BUILD entries for files that already
exist at #6661's head (versions.go, versioned_read_contract.go, ...); they are
not part of this change and are left out.
* test(feat): green — a served mutation records from the provider's own row, on a real server (refs be-qxq70)
K1 is the one place the resolver cannot ask a DoltStorage: `bd serve` against a
server-mode workspace writes through a unit-of-work provider, so its flag is
read through NewUOW + ConfigUseCase().GetConfig at construction. The fakes in
internal/versionedhistory prove the read; this proves it WORKS against a real
Dolt server at that moment (pool open, database selected, schema migrated).
Two server-mode workspaces on the shared test container: the one whose own row
says on records a served HTTP mutation (+1 issue_versions row), the one with no
row records none.
Measured both ways: passes with the provider activation in place, and fails
("added 0 issue_versions row(s), want 1") with it deleted from both provider
constructors in uow_factory.go.
Proxied lane only (BEADS_TEST_PROXIED_SERVER=1 BEADS_TEST_ENV_RUN_DOLT=1
TESTCONTAINERS_RYUK_DISABLED=true), like TestServeActivatesTheEventsJournal, so
it skips in a plain make test.
* test(feat): red — #6661 review round, small items: findings 2, 4, 5, 6 and 8
Tests for the small findings in the second review round on #6661.
- 2: `bd versions` must decide "recording" from the store's own setting.
BD_VERSIONED_HISTORY_ENABLED=1 with the store's row unset and nothing
recorded must refuse, not answer "none yet"; the help text must not offer
the variable as a per-run switch for a read.
- 4: `bd versions --json` is one object, {"versions": [...], "recording":
bool}, with [] rather than null when nothing is recorded.
- 5: AsOfReadInTx reports any stored removed_restriction outside its four
values, "live" included, as unknown.
- 6: the 0070 header spells the restriction vocabulary with the underscore
spellings the code stores and compares.
- 8: `bd version <arg>` exits 1 and points at `bd versions <arg>`. This one
pins behaviour the branch already has, so it passes at red; it was shown
to fail with the guard removed.
Item 7 is a comment-only fix and has no test.
* feat: green — #6661 review round, small items: findings 2, 4, 5, 6 and 7
- 2: `bd versions` reports the store's own setting. It read the environment
and config.yaml as well, so BD_VERSIONED_HISTORY_ENABLED=1 made a store that
never recorded answer "No versions recorded yet" instead of refusing with
the remedy. It only reads, so those planes cannot make the store record.
The "for one run" hint is dropped from the help and the refusal, since it
could only ever produce the wrong answer.
- 4: `bd versions --json` is always {"versions": [...], "recording": bool},
with [] rather than null when nothing is recorded. Previously a bare array,
or null, and no recording flag.
- 5: AsOfReadInTx reports a stored removed_restriction outside its four
values, "live" included, as unknown instead of passing it through.
- 6: the 0070 header and its test use the underscore spellings the code
stores and compares. 0070 is unreleased, and this changes its content hash.
- 7: comment only. DATETIME(6) still rounds to the microsecond; the comment
said 0069 removed the rounding entirely.
* test(fix): red — #6661 number admission: fractions past the bound, exponent cost, pre-enable scan
Tests for the review round on the number-admission gate, written before the change:
- a fraction whose nearest double is at or past 2^53 is refused (9007199254740993.5,
9007199254740994.5, 9007199254740991.5), and the gate is closed under its own
canonicalization, checked as a property over a corpus
- classification depends on magnitude, not on the size of an exponent: 1e100000000 and
-1e400 are refusals, 1e-100000000 and 1e-400 are admitted, and allocation does not grow
with the exponent
- the sentinel's text names the I-JSON exact-integer range
- CheckMetadataVersionable agrees with the mint, and FindUnversionableMetadata finds what
the mint would refuse and skips what it never versions
- bd config set versioned-history.enabled true refuses, writing nothing, over rows the mint
would refuse, and false never scans
Guards that pass before and after by design: the verdict on every literal as the store
returns it, the mint's refusal writing nothing, and, on the server and embedded legs, the
store-level property that no two literals reading back as different numbers share a canonical
form. Those store tests also log what each Dolt holds for a number outside the range when
history is off, and pin that a later write to such a row is refused once history is on.
* fix: green — #6661 number admission: the nearest-double rule, ParseFloat classification, a pre-enable scan at the switch
The admission gate now refuses a JSON number literal if and only if the binary64 nearest to it
has magnitude above 2^53-1, or it overflows, whatever the literal's spelling:
- a fraction that rounds to or past 2^53 (9007199254740993.5, 9007199254740994.5,
9007199254740991.5) is refused, so the gate is closed under its own canonicalization
- literals are classified with strconv.ParseFloat, linear in their length, so 1e1000000 no
longer builds a million-digit integer inside the writer's transaction; an overflow is the
sentinel and a magnitude too small for binary64 is admitted; math/big is gone
- the sentinel reads "number is outside the I-JSON exact-integer range (magnitude above
2^53-1)"; ErrIntegerNotRepresentable keeps its name, with a comment saying why
- ordinary fractions such as 0.1 stay admitted; no verdict on a value the store hands back
changes
The header now says what the mint's refusal is: an integrity backstop inside the writer's
transaction, not an admission policy for metadata.
bd config set versioned-history.enabled true now checks the store first. It reads every issue
the mint would version, runs the mint's own function over each one's metadata
(issueops.CheckMetadataVersionable, through issueops.FindUnversionableMetadata), and refuses,
writing nothing, while any is refused, printing the count, the ids and the fix. There is no
override; setting it false never scans. The environment and config.yaml planes do not pass
through the command and rely on the refusal at write time.
Also: docs and a CHANGELOG entry, and comments in the existing admission tests that described
the old rule.
* test(fix): keep the exponent-cost allocation test stable under the race detector
TestNumberAdmissionAllocationsDoNotGrowWithTheExponent compared two
independently averaged allocation counts with a strict >. Under -race
sync.Pool drops one Put in four at random, and the refusal's fmt.Errorf
takes its printer from a pool, so a call now and then allocates one more
than it would. The test failed on most runs of `go test -race -short`, the
flag set of the required lane, and never without -race.
That noise only ever adds allocations, so compare the fewest allocations
over many single-call samples instead. The comparison stays strict, and it
still fails on the exact big.Rat gate this test exists to keep out (49
allocations for 1e1000000 against 36 for 1e400). The doc comment no longer
claims the count is deterministic under -race.
* test(fix): red — set-many skips the pre-enable scan; pin what the scan reads
bd config set-many versioned-history.enabled=true switches versioned history
on with no pre-enable scan: only bd config set makes it. With a row holding a
number outside the I-JSON exact-integer range the setting is turned on and the
next write to that row fails. The new embedded test drives the real verb over
such a row and expects the whole batch to be refused, writing nothing.
The scan's own embedded test only used open issues, so deleting AllFlag or
IncludeAllTypes, or replacing the unlimited Limit, left it green. It now adds a
closed, a pinned and a gate offender, and a second test imports more rows than
one default page and expects every one of them counted.
* fix: green — bd config set-many runs the pre-enable scan for versioned-history.enabled
bd config set refuses to turn versioned history on while an issue holds
metadata a version could not record. bd config set-many writes the same
setting through a validation loop of its own and made no such check, so it
switched history on over a row whose next write then failed. It now runs the
same check for that one key inside its validation loop, before any pair of
the batch is written, so a refusal stores nothing. The check reads through
the accessor it already used on both routes: the store the command has
opened on the direct route, the provider on the proxied one.
* chore: strip internal tracker ids from the comments and tests across #6661's range
Comment and test-text changes only; no behaviour changes. Across every commit from the
merge-base with upstream main to here, the comments and tests named internal tracker ids
(one bead id in eleven comments and in one test failure message, an example id in the
`bd version` guard's comment, and an internal decision's attribution in the huge-exponent
admission test). They now cite gastownhall/beads#5898 and #6136 only, which is what a reader
of the public branch can follow.
The 0070 migration's header comment is one of the edits. That migration is new on this branch
(it does not exist on upstream main), so the change is not an edit to a shipped migration, but
it does change the file's content hash; the schema tests that compute hashes are self-consistent.
Text that already exists on upstream main is left as it is, even where it mentions an id: this
commit does not rewrite lines the range did not add.
* chore(bazel): bazel-sync (gazelle) for the #6661 range
* fix(bazel): give fix_test the store.go its activation guard parses
TestVersionedHistoryDoctorRepairOpenerUsesTheSharedActivation parses
store.go from its working directory. `go test` runs in the package
directory, so the file is there. A Bazel test only sees its declared
runfiles, so the test failed with
parse store.go: open store.go: no such file or directory
in //cmd/bd/doctor/fix:fix_test (--config=ci) and in shard 1 of
//cmd/bd/doctor/fix:fix_dolt_test (--config=doltserver), which runs the
same binary through data = [":fix_test"].
Declare store.go as data on fix_test.
* test(fix): red — the pre-enable scan must check the whole issue, as the mint does
bd config set versioned-history.enabled true runs a check over every issue
before it turns history on. The check looked at each issue's metadata alone,
while the mint canonicalizes the whole issue. A gate's timeout is a
time.Duration that a version holds as nanoseconds, so a gate whose timeout is
past 2^53-1 ns (about 104.25 days) holds a number outside the I-JSON
exact-integer range: the mint refuses every write to it, the scan never
looked, and the switch could be turned on over it.
- The agreement test's domain widens from metadata documents to whole issues:
the metadata corpus, plus timeouts at 2500h (admitted), 2600h, 8760h and
-2600h (refused), exactly 2^53-1 ns (admitted) and 2^53 ns (refused).
- The scan test covers a gate over 105 days and expects the verdict to name
the field, "timeout".
- The mint-level refusal test covers the same gate and expects the refusal to
name the field as well as the literal, for a number in metadata too.
- An end-to-end test on the direct route and one on the proxied route create
gates with bd gate create --timeout, expect the enable to refuse and name
them, and expect the issues the scan names to be exactly the issues whose
next write the mint refuses.
- Three guards keep the scan's lite read from hiding a number: every column it
leaves out is a string or a list of strings, nothing the mint adds and the
scan does not load can hold a number, and no exported check over part of an
issue exists beside the one the mint runs. Each guard is also run against
shapes it must refuse, so it cannot pass by finding nothing.
The new symbols (CheckIssueVersionable, FindUnversionable and the Field of
UnversionableIssue) do not exist yet, so the issueops tests do not build.
* fix: green — the pre-enable scan runs the mint's own check over the whole issue
The check behind bd config set versioned-history.enabled true looked at each
issue's metadata alone. The mint canonicalizes the whole issue, and a gate's
timeout, a time.Duration held as nanoseconds, is a number outside the I-JSON
exact-integer range once it is past 2^53-1 ns (about 104.25 days). The mint
refuses every write to such a gate, the scan cleared the switch over it, and
the first write after that failed.
CheckIssueVersionable is now exactly canonicalDurableState's refusal over the
whole issue, and FindUnversionable runs it over every issue the mint would
version. It replaces FindUnversionableMetadata, and CheckMetadataVersionable
is gone, so no check over part of an issue is exported beside the one the mint
runs. A refusal names the top-level field it found the value in ("metadata",
"timeout") as well as the literal, on the mint and on the scan; the field is
located only after a refusal, so a write that is admitted still reads the
document once. A gate timeout above 2^53-1 ns is unrecordable by policy: it is
refused at the write, named by field and documented, not re-encoded.
The refusal at the switch gives the fix for each field. For a number in
metadata that is bd update --metadata or --unset-metadata, which works with
history on or off because a version is recorded from the state after the write.
For a gate timeout, which bd update cannot change, it is removing the gate with
bd delete, or setting the timeout_ns column with bd sql while history is off;
bd sql needs a server-backed store, and the text says so. It also says the
check runs once, now: a writer that does not record (an older bd, bd sql, a
pull from a clone that had history off) can add such a row afterwards, and the
first write to it then fails with the same refusal. Making the check and the
write of the setting one transaction would narrow that window, not close it.
Corrected in the comments, the docs and the changelog as well: an import is not
a path that skips the mint, since it goes through the same batch create; and
Dolt's JSON column collapses duplicate keys when it stores a document, so on a
Dolt store neither the scan nor the mint can see one, and the duplicate-key
refusal is a defence for a backend that keeps them.
* test(fix): red — the listing must answer as the as-of read does; the SDK opens must be accounted for
Three review findings on the versioned-history change and one wording fix,
tests first.
- A removed version's restriction. AsOfReadInTx answers a stored value outside
the four-value vocabulary (a NULL or empty column, "live", a hyphenated or
arbitrary string) as unknown, but ListVersionsInTx hands the column back as
stored, for every row, and the label bd versions prints passes such a string
through. A table test runs the listing and the as-of read on the same stored
value, for a version that was removed and one that was not, and expects the
same answer, and none for a version that was never removed. The label gets
the same out-of-vocabulary values and is expected to render what unknown
renders.
- The SDK's store opens. The shared construction guard now scans the repository
root as well, so the Go SDK's five opens (Open, OpenFromConfig and OpenGated,
and OpenBestAvailable in each build-tag twin) are noticed. Nothing accounts
for them yet, so both guards fail on exactly those five sites.
- A bytes bound beside the allocation-count bound on the number admission
gate. A classifier that builds the number it is asked about makes one
allocation whatever the exponent, so the count bound passes it, and the bytes
grow. The fewest bytes one call allocates for a literal with a huge exponent
must be no more than for a small one plus a margin. It passes today, because
the gate never builds the number; it fails for a gate that does.
- The refusal at the switch names the gate remedy as bd delete <id> --force,
says that without --force bd only previews, and says that removing the gate
unblocks anything it was blocking. The embedded and proxied end-to-end tests
expect all three.
* fix: green — the listing answers as the as-of read does; the SDK opens are accounted for
Three review findings on the versioned-history change and one wording fix.
A removed version's restriction. A stored removed_restriction is a free string,
and only the four values of the vocabulary are answers. The as-of read already
reported anything else (a NULL or empty column, "live", a hyphenated or
arbitrary string) as unknown, but the listing handed the column back as stored,
for every row, and the label bd versions prints passed it through.
NormalizeRemovedRestriction is now the one place that decision is made.
AsOfReadInTx calls it; ListVersionsInTx calls it for a version that was removed
and gives a version that was not removed no restriction; and restrictionLabel
renders through it. The listing, its JSON and the label now say what the as-of
read says for the same row.
The SDK's store opens. The Go SDK's five opens (Open, OpenFromConfig and
OpenGated, and OpenBestAvailable in each build-tag twin) apply neither per-store
switch, the events journal's or versioned history's, and they still do not.
Applying them would change the library's behavior for every embedder, so that
is a separate change; this one declares the boundary. The shared construction
guard now accounts for the five with one exemption reason that is true of both
switches, so a new SDK open is noticed rather than missed, and its staleness
check keeps the exemptions honest. The docs gain one bullet saying that writers
built on the SDK do not apply the switch.
The bytes bound on the number admission gate needs no production change: the
gate never builds the number, which is what the bound pins.
The refusal at the switch now names the gate remedy as bd delete <id> --force,
says that without --force bd only previews, and says that removing the gate
also unblocks anything it was blocking. The docs line says the same. For a gate
that blocks an issue, bd delete without --force prints a preview and exits 1,
and with --force the gate is removed and what it blocked is ready again.
* test(bazel): declare the root package's Go source as data for //cmd/bd:bd_test
The shared store-construction scan now reads the repository root, where the Go
SDK's opens live, but //cmd/bd:bd_test declared none of the root package's
source. Under bazel test the scan therefore saw an empty directory, reported
the five SDK exemptions as no longer matching a store construction site, and
failed the events-journal guard, while go test, which sees the whole checkout,
passed.
List the root in tools/bazel/go_srcs.py so the generator emits its managed
go_srcs filegroup there, and add that filegroup to bd_test's data. The new
block is the generator's own output and nothing else changes.
* ci: list the switch scan's proxied gate-timeout test in the 30-shard manifest
Upstream main (#7129) moved the proxied-server tier to 30 duration-balanced
shards, and TestProxiedShardManifestGeneratorNotStale requires every
TestProxiedServer*/TestServerMode* test exactly once in that block. This
branch adds TestProxiedServerVersionedHistorySwitchRefusesAnUnrecordableGateTimeout
(cmd/bd/versioned_history_switch_scan_proxied_integration_test.go), so the
block needs its line. Written by the generator itself:
python3 scripts/ci/gen_proxied_shard_manifest.py 30 --weights=duration --write
(one line, shard 8); --check exits 0 afterwards.
Rebase note (maintainer): regenerated on current main, whose proxied-server
tier uses 34 shards; the generator's incremental output
(gen_proxied_shard_manifest.py 34 --weights=duration --write) placed this
test at shard 6 of the 34-shard block.
* ci: list the PR's embedded versioned-history tests in the embedded shard manifests
#7156 made the embedded-Dolt tier's shard manifests exact-once (50 cmd
shards, 15 storage shards), so every embedded test must be listed. This PR
adds five embedded cmd tests and three embedded storage tests; this commit is
exactly what the generators write for them:
python3 scripts/ci/gen_embedded_cmd_shard_manifest.py 50 --weights=duration --write
python3 scripts/ci/gen_embedded_storage_shard_manifest.py 15 --weights=duration --write
Incremental: 8 lines added, none moved.
Rebase note (maintainer): regenerated on current main, whose embedded
manifests use 100 cmd shards and 40 storage shards; the generator's
incremental output placed these tests at cmd shards 55
(TestEmbeddedVersionedHistorySwitchScansEveryRowNotOnePage), 56
(...SwitchRoundTrip), 57 (...SwitchRefusesUnversionableMetadata), 58
(...SwitchRefusesAnUnrecordableGateTimeout) and 59
(...SetManyRefusesUnversionableMetadata) of the 100-shard block, and at
storage shards 5 (TestRecordVersionKeepsSubSecondChangeAt), 6
(TestVersionedHistoryKeepsNumbersTheStoreDistinguishesApart) and 23
(TestAsOfReadContract) of the 40-shard block.
* test: exempt OpenBestAvailableWith, where #7188 moved the SDK's store construction
Upstream #7188 split beads.OpenBestAvailable: it now delegates to the new
OpenBestAvailableWith, which builds the store. This PR's two construction
guards (TestEveryStoreConstructionActivatesTheEventsJournal and
TestEveryStoreConstructionActivatesVersionedHistory) share one exemption
list keyed by function, so after merging main they flagged
OpenBestAvailableWith as an unexempted construction site and reported the
OpenBestAvailable entries as stale. The two build-tag twins' keys now name
OpenBestAvailableWith. The reason is unchanged: it is the SDK's library
surface for embedders, and no code in the bd binary calls it. gofmt
realigned the three neighbouring entries.
* chore(schema): renumber removed_restriction to 0071 after #6943's 0070
Migrations are numbered by landing order. #6943 (participation_generation,
the versioned-history write fence) lands first and owns main-plane 0070 and
ignored/0028, so this PR's removed_restriction migration moves to the next
free slot, 0071. The rename is done here, as one maintainer commit, rather
than inside the replayed commits, so the history shows exactly what changed
relative to the PR as reviewed; the intermediate commits of the rebase carry
a duplicate 0070 and are not expected to build.
- migrations/0070_add_removed_restriction.{up,down}.sql become 0071_*, with
their header comments updated (the SQL itself is unchanged). Neither file
exists on main or on #6943, so this is not an edit to a shipped migration.
- cli_migrations.go: the CLI-bundle override is keyed to the new file name
and renamed cliMigration0071AddRemovedRestriction, and its const now sits
after 0070's.
- migration_0070_add_removed_restriction_test.go becomes
migration_0071_add_removed_restriction_test.go; its tests and messages say
0071, and it now owns the one LatestVersion pin (71).
TestLatestVersionIncludesMigration0070 in #6943's participation_generation
test is superseded by it and replaced by the usual pointer comment, and
0069's pointer comment now names the 0070 file that superseded it.
- schema_test.go hygiene comments, BUILD.bazel embedsrcs/srcs, and the
asof_read.go comment that cited the migration number.
Checked: go test ./internal/storage/schema/... (with the dolt CLI lane,
including TestAllMigrationsSQLAppliesThroughDoltCLIAndRecordsLatestVersion)
and scripts/check-migration-hygiene.sh against origin/main and against
#6943's tip.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(versions): reconcile #6661's tests and docs with #6943's write fence
#6943's write fence (design §16.2b) makes an update-shaped write to a legacy
record -- one whose participation_generation is NULL because it was created
while versioned history was off -- a skip, not a refusal: the fence returns
before the snapshot is canonicalized, so nothing is versioned and the mint's
admission gate never runs. Several of #6661's tests seed rows with history
off and then expect a later write to them to be versioned or refused, and
several comments say every later write to an offending row fails. On a tree
that carries both PRs those tests fail and those comments are wrong.
This ports, without changing their substance, the fence-integration commits
Jim Wordelman wrote for the donnabox integration fork, where both PRs were
already folded together:
- eff898db80 / 5d2e5a2ac4 (issueops, dolt, embeddeddolt): the mocked mint
sequence scripts the fence's participation_generation read; the number
fidelity test splits phase 2 into 2a (a legacy row is written, not
versioned, not refused, stays NULL) and 2b (a participating row is
refused and left untouched); TestRecordVersionInTxSkipsALegacyRowBefore-
TheAdmissionGate pins the fence's order against the gate.
- e0ad9d1e3c / 1528022dfa (cmd/bd): the switch round trip and the routing/env
end-to-end tests build the rows they expect a version for after the setting
is on, and assert that the pre-setting seeds gain nothing.
- 18b9015bf5 (cmd/bd): the embedded and proxied gate-timeout scan tests assert
the whole scan-vs-mint truth table (legacy offenders are named by the scan
but not refused by the mint; participating offenders are both).
- 5929ebd50c / 8ce872be03 (comments, CHANGELOG, configuration reference): the
mint's refusal binds rows that participate in history; the pre-enable scan
cannot see participation, so it over-approximates in the safe direction.
Left out on purpose: the fork's mintSkipsRow helper and defer-wake sweep
change, and its bd doctor "Versionable Issues" check and the docs that point
at it; none of those are part of #6661 or #6943.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Jim Wordelman <jim@wordelman.name>
* test(versions): adapt #6661's guards to what main changed under it
Three test-side adjustments for code that landed on main after #6661's last
merge of it; no production code changes.
- internal/storage/leg_contract_wiring_test.go: main gained an HTTP storage
leg, and TestEveryLegWiresEveryRoleContract requires every leg to name or
waive every role contract. The five R7.1 as-of read contracts this PR adds
are a storage capability the HTTP client does not serve (internal/httpclient
answers AsOf with an explicit unsupported error, and the wire has no
instant/address selector or gone/unknown refusal), so they are waived on
the http leg with that reason, as the donnabox integration fork does.
- cmd/bd/versioned_history_construction_test.go: main split
newDoltStoreFromConfig into two thin wrappers over openDoltStoreFromConfig,
which is where the activation defer now lives (this rebase's resolution of
the activation commit), so the factory guard keys on that body.
- cmd/bd/versioned_history_serve_e2e_test.go: main's
TestProxiedGatedTestsRunInTheProxiedLane requires a test that skips unless
BEADS_TEST_PROXIED_SERVER=1 to be one the proxied lane selects, so
TestVersionedHistoryServeActivatesTheProviderFromItsOwnRow becomes
TestProxiedServerVersionedHistoryServeActivatesTheProviderFromItsOwnRow,
and the 34-shard proxied manifest gains its line (written by
gen_proxied_shard_manifest.py 34 --weights=duration --write, incremental;
--check passes).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* chore(bazel): emit go_srcs.py's managed blocks for internal/versionedhistory
Main's tools/bazel/go_srcs.py now manages a repo_files filegroup block in
every package BUILD file, lists those filegroups in the root BUILD.bazel's
aggregates, and lists every go_library in tools/bazel's release_cross_build
target. internal/versionedhistory is a package this PR adds, so after the
rebase those managed blocks were stale and TestBazelGoSrcsBlocksCurrent
(go test ./scripts/...) failed. This is the generator's own output
(python3 tools/bazel/go_srcs.py) and nothing else; --check passes
afterwards.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(versions): don't publish change_agent in bd versions --json
`bd versions <id> --json` prints storage.IssueVersion as-is, so every JSON
tag on that struct is part of a public contract. Provenance V2
(gastownhall/beads#7510, as ruled by the maintainer) removes the ad hoc
agent field in favour of an actor chain; shipping a "change_agent" key now
would make a public contract out of a field that is on its way out.
IssueVersion.ChangeAgent is now tagged json:"-". Nothing else changes: the
issue_versions.change_agent column (migration 0067) stays, ListVersionsInTx
still reads it, change_actor and change_message are still published, and
the human listing never showed the agent. No doc or golden named the key.
TestVersionsJSONDoesNotPublishChangeAgent pins the absence with a non-empty
value, so an omitempty-style regression would still fail, and pins that
change_actor and change_message are still there.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(issueops): pin what the unfenced test-support mint does on #6943's new paths
#6943's two fixes to the shared mint body -- (a) no issues row means no
mint and no error, and (b) a create-shaped call on a new issues-table row
flagged no-history stamps participation_generation without minting -- were
written for its two kinds. This PR's shared body has a third,
mintUnfenced, behind RecordVersionAtInTx (the R7.1 as-of fixtures'
controlled-timestamp mint). The rebase resolution decided what (a) and (b)
mean for it; this pins that decision:
- (a) applies. It is the plane rule (FR-8: the table that holds the row
decides its plane), not the fence, and the unfenced kind already honoured
the flag-based form of the same rule (IsWisp). Without it, an unfenced
mint for an unflagged wisps-table row would insert a version row that no
issues row points at. The shared body's issues-table read now runs for
all three kinds; only the update kind acts on the value it reads.
- (b) does not apply. The unfenced mint never declares participation, so a
flagged row returns right after the snapshot, as before: no read, no
stamp.
- The fence still does not apply: a legacy row is minted, and the closing
UPDATE advances current_revision alone.
TestRecordVersionAtInTxKeepsThePlaneRuleButNotTheFence scripts each of
those three sequences exactly with sqlmock.
TestTestSupportMintsStayOutsideTheShapeSplit places RecordVersionAtInTx
outside #6943's create / dual-shape / update classification explicitly (it
is the seam's exempt twin, not a mutation entry point or mint site): it must
be in none of the shape lists, stay in versionExemptions, and reach neither
RecordVersionForCreateInTx (it never stamps) nor RecordVersionInTx (whose
gate and fence would stop the as-of fixtures minting history-off rows). The
row-lock guard's exemption comment for recordVersionAtInTx already names the
stamp-only UPDATE: #6943's own wording of it (all three UPDATE issues
statements) was carried into that exemption when the as-of read commit was
replayed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(storage): say exactly why the as-of read contracts stay waived on http
#6943 now runs most of its participation-generation contracts over the
served wire (internal/httpclient/served_participation_generation_test.go):
their subject is a create or an update, which the client can send, and the
fixture reads the reference store's raw columns. This checked whether the
five R7.1 as-of read contracts can be wired the same way. They cannot,
cheaply or otherwise, without a new wire operation:
- their subject is the read itself (AsOfReadFixture.Resolve), and R7.1's
read, issueops.AsOfReadInTx, is reached by no publicops role and served
by no wire operation;
- the wire carries neither selector (an instant or a served version
address) nor the gone/unknown refusal the read answers with;
- the client's only point-in-time read, DoltStorage.AsOf, is a Dolt
commit-ref read, not R7.1, and is on the client's D8 unsupported
allowlist.
Binding Resolve to the reference store behind the served env would pass,
but as a property of that store, which the store legs already pin, never
of the client. So the waiver stays; its comment and reason string now say
the above instead of the earlier shorthand ("HTTP AsOf is explicitly
unsupported"), which conflated the client's commit-ref AsOf with R7.1.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(versions): describe what the write fence does to beads that predate recording
With #6943's write fence (design §16.2b) a bead that existed before
versioned history was turned on (participation_generation NULL) is legacy:
an update-shaped write to it is skipped, so it is never versioned however
often it is edited. Several user-facing strings from #6661 still described
the behaviour before the fence, and an independent review reproduced each
with a built bd (a legacy bead edited twice after enabling still lists no
versions; a legacy bead the switch refuses over is written without refusal
under BD_VERSIONED_HISTORY_ENABLED=1). Text only; no behaviour changes.
- bd versions help: only beads created while recording is on are versioned;
a bead that already existed is legacy and editing it records nothing; no
backfill. (Was: "a bead edited yesterday shows nothing until it is
edited again".)
- bd versions empty listing: drops "yet" and says why the list is empty -- a
bead created while recording is on always has its create version, so an
empty list means the bead predates recording (or was made by a writer
that was not recording), or is no-history or a wisp. The line still
starts "No versions recorded for <id>", which the switch round-trip test
pins.
- bd versions with recording off: only beads created after it is turned on
are versioned.
- bd config set versioned-history.enabled true refusal: Jim's scan stays as
conservative as he made it -- it cannot see participation, and a legacy
row can still be minted create-shaped if it re-enters the issues plane --
but the text now says a listed issue's writes are refused only if it
participates (created while history was on, or entered the issues plane
while it was on), and that legacy issues are listed because the check
cannot tell. The closing line says the same of a value a non-recording
writer adds later.
- docs/reference/configuration.md: the section opener says every accepted
change to an issue created while history is on is snapshotted, and that a
pre-existing issue is legacy; the "participates" parenthetical drops "or
written" (a write never stamps participation; only a create-shaped mint
does) and names entering the issues plane, matching the refusal text.
CHANGELOG already says "if it participates in history" and is unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(versions): keep updated_at across update-shaped version mints
The update-shaped mint ended with UPDATE issues SET current_revision = ?
WHERE id = ?. current_revision always changes there, so the column's
ON UPDATE CURRENT_TIMESTAMP clause fired: with versioned history on, every
label, dependency or import write moved issues.updated_at to the session's
wall clock (local time, read back as UTC). An import with
RejectStaleUpserts then stored the wall clock instead of the source's
updated_at, and the source's next genuine edit was rejected as stale. The
statement now assigns updated_at to itself, the rule #4298, blocked_state.go's
mark/unmark templates and the create-shaped mint statements already follow,
so history on leaves updated_at exactly where history off does. It is the
one statement every production update-shaped mint ends with.
Tests:
- TestEmbeddedMintLeavesUpdatedAtWhereHistoryOffDoes (embeddeddolt) ages a
bead, adds and removes a label and a dependency, and runs two
RejectStaleUpserts imports, with history off first as the control. With
the fix reverted, history on fails all six arms (updated_at reads the
wall clock, and the later source edit is rejected as stale); history off
passes either way.
- RunParticipationGenerationFlagOffSkipsUpdateOnParticipatingRecord, wired
on the dolt, embeddeddolt, uow and http legs: a record created with the
flag on and updated with it off mints nothing and keeps its
current_revision. Every other flag-off case uses a legacy record, which
the fence stops first, so with RecordVersionInTx's gate removed this is
the only case that fails, on all four legs. That gate is the single entry
for every production update-shaped mint, so the one update arm covers
label and close writes too.
- The sqlmock pin of the statement (version_history_preenable_scan_test.go)
and the journal-completeness exemption comment follow the new SQL.
- The createbatchequiv issues_updated_at goldens of small, depadd,
import458 and import458-reject-stale are re-recorded. They pinned the
wall-clock bump, so each row minted a second time (eq-n2; eq-db1 and
eq-dl; eq-b3 and eq-b250) had dropped out of the compared set; CI's
embedded and server legs both printed the new digests. Recorded on
embedded Dolt, the fix-reverted tree reproduces every committed golden
byte for byte, HEAD moves only these four digests, and its rows equal
the history-off rows in every scenario. GoldenDirEnv's comment lists it
as the goldens' third deliberate change.
- The new embedded test has its line in the storage shard manifest
(gen_embedded_storage_shard_manifest.py 40 --weights=duration --write),
so TestStorageEmbeddedShardManifestGeneratorNotStale stays green. It sits
after TestEmbeddedEveryAcceptedLifecycleMutationMintsOneVersion rather
than at the end of the file, where #7646 appends its own test, so the two
PRs still merge without a conflict in that file.
Docs:
- CHANGELOG: the feature's two entries under ### Fixed described fixes to a
switch no released bd has. One ### Added entry replaces them, covering
bd versions, the versioned-history.enabled switch and its per-store
semantics, the pre-enable check, the single-writer caveat, migration 0071
and the bd version <arg> refusal.
- The bd versions help, its recording-off refusal and empty-listing note,
and the opening paragraph of the configuration doc's Versioned Issue
History section now state the rule the pre-enable refusal prints: a bead
participates if it was created, or entered the issues plane (a wisp
promoted or made persistent), while recording was on.
bd version: the "did you mean bd versions" refusal now runs after the
command's metrics event is created, like the other in-RunE argument
refusals, so a mistyped bd version <id> is counted as a version invocation
instead of going uncounted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
---------
Co-authored-by: Jim Wordelman <mayor@quad341.uk>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* schema+storage: restore 0068, move participation_generation to 0070 (be-blvmg)
MAYOR RULING 2026-09-29 on tracker be-waare: migration 0068 shipped to
origin/main as attribution_status-only (be-v33pa). be-h89oq's lineage had
appended participation_generation steps 4-5 to that same file while it was
still unmerged, which check-migration-hygiene.sh Check C correctly rejects
once 0068 is frozen on main. This restores 0068 to origin/main's exact
content and re-homes the participation_generation column (issues + wisps,
design section 16.3 steps 4-5, be-dt74u amendment) in a new migration 0070,
with its clone-local ignored/0028 twin for wisps. Ports back the
participation_generation write-fence consumer code (RecordVersionInTx in
internal/storage/issueops/version_history.go and its callers) and the
dualwrite contract tests that exercise it.
RED: the CLI-bundle direct-DDL override for 0070's guarded PREPARE/ALTER
pair is not yet registered in cli_migrations.go, so
TestBundleMigrationsWithPreparedALTERAreOverriddenOrJustified,
TestMigration0070AddsParticipationGeneration, and
TestAllMigrationsSQLUsesDirectDDLForKnownCLIIncompatibilities fail --
correctly: a fresh CLI-built bundle would silently omit the column
(dolthub/dolt#11345) while a runtime-migrated store has it.
git diff origin/main -- internal/storage/schema/migrations/0068_*.sql is
empty, confirming 0068 is untouched.
Agent-Signature: model=claude-sonnet-5; reasoning=high
* schema: register CLI-bundle direct-DDL override for migration 0070 (be-blvmg)
GREEN: adds cliMigration0070AddParticipationGeneration and its dispatch
entries (cliCompatibleMigrationSQL, cliSubstituteAssumesWispTables), the
same pre-2.3 Dolt CLI PREPARE/ALTER escape hatch 0067's wisps.current_revision
and 0068's attribution_status already use (dolthub/dolt#11345). Makes
TestBundleMigrationsWithPreparedALTERAreOverriddenOrJustified,
TestMigration0070AddsParticipationGeneration, and
TestAllMigrationsSQLUsesDirectDDLForKnownCLIIncompatibilities pass: a
fresh CLI-built bundle now carries participation_generation on both
issues and wisps, matching what a runtime-migrated store gets.
scripts/check-migration-hygiene.sh checks A-D pass; 0068 remains
byte-identical to origin/main.
Agent-Signature: model=claude-sonnet-5; reasoning=high
* build: bazel-sync BUILD.bazel for migration 0070 files (be-blvmg)
make bazel-sync (gazelle) picked up two files the RED commit added that
the hand-ported BUILD.bazel hadn't listed yet: 0070's embedded .up.sql in
the go_library embedsrcs and migration_0070_add_participation_generation_test.go
in the go_test srcs.
Agent-Signature: model=claude-sonnet-5; reasoning=high
* test(feat): red — Fix: enable history before fixtures in TestDualWriteDeleteNeighborRewriteRidesTheDeletesDoltCommit — PR #6943's §16.2b write fence leaves its flag-off neighbor legacy, so the delete mints 0 rows (stacked on 44418b3) (refs be-fyaja)
* feat: green — Fix: enable history before fixtures in TestDualWriteDeleteNeighborRewriteRidesTheDeletesDoltCommit — PR #6943's §16.2b write fence leaves its flag-off neighbor legacy, so the delete mints 0 rows (stacked on 44418b3)
(refs be-fyaja)
* test(conformance): pin that a wisp reaching the issues plane begins its history (be-31mnz)
Review feedback on #6943, blocker 1: with the flag on, a promoted wisp is
never versioned. None of the five RunParticipationGeneration* cases reaches
a promotion, so nothing caught it.
Two contract cases, wired on all three legs:
- RunParticipationGenerationWispPromotionBeginsHistory: create a wisp with
the flag on, promote it, and require a stamped participation_generation,
one version row, and +1 on the next update.
- RunParticipationGenerationWispPersistenceMoveBeginsHistory: the same
check for a persistence-mode update (bd update --persistent). This mints
at a different site than promotion on every leg: the guarded update's one
end-of-update mint on dolt and embeddeddolt, and
MoveIssuePersistenceInTx's own on uow.
"Wisp" is in the names because this contract already says "promoted" in
R2.3's sense (ProceedsForPromotedRecord), which is a different operation.
The fixture gains CreateWisp, PromoteWisp and MovePersistent closures, and
each leg's FixtureKitIsWired checks them.
Red at this commit on the embedded leg: after the arrival there are 0 rows
and participation_generation is NULL, and after the update there are still
0 rows. A flag-on durable create goes 1 -> 2 in the same store.
* fix(issueops): mint a wisp's first issues-plane version create-shaped (be-31mnz)
Review feedback on #6943, blocker 1. A promotion, or a persistence move out
of the wisps table, inserts a new issues row. A wisp never declares
participation (FR-8), so that row's participation_generation is NULL. Both
sites minted through the update-shaped RecordVersionInTx, and the section
16.2b fence read the NULL as legacy and skipped the mint. Nothing stamps the
column later, so every later update skipped too, and a record created with
versioned history on was never versioned.
These sites now use RecordVersionForCreateInTx, which stamps the column and
mints version 1, as a create on the issues plane does:
- PromoteFromEphemeralInTx (promote.go).
- MoveIssuePersistenceInTx's move out of the wisps table.
- ExecuteUpdate's one end-of-update mint (execution.go), when its
persistence patch did that move. This is the site bd update --persistent
reaches on the dolt and embeddeddolt legs, and the review did not list
it. PersistenceMoveResult.EnteredIssuesPlane tells ExecuteUpdate which
entry point to use.
One site the review named stays update-shaped on purpose:
MoveIssuePersistenceInTx's same-plane repair, which clears a stray wisp
flag on a row already in issues. That row keeps its own
participation_generation. A row created with the flag on still mints. A
legacy row stays legacy, because a repair is an ordinary write and R2.3
says an ordinary write does not promote it. A create-shaped mint there
would stamp the legacy row and start versioning it.
* docs(schema): 0070 must precede turning versioned history on (be-31mnz)
Review note on #6943 (schema skew). The write fence reads
participation_generation on every flag-on mint of an issues-plane row. On a
store that has not applied 0070 the read fails, and the mutation fails with
it instead of skipping. The migration header now says so, and says that the
flag-off path (the default) returns before the read, so a store below 0070
writes exactly as before.
Comment only. 0070 is not on main, so check-migration-hygiene's frozen-file
check does not apply to it, and no test pins its bytes.
* test(dolt): a persistence repair keeps the row's own participation (be-31mnz)
Pins why MoveIssuePersistenceInTx's same-plane repair stays update-shaped
while promotion and a move out of the wisps table became create-shaped (the
previous commit). The repair clears a stray wisp flag on a row that already
lives in issues, so the row keeps its own participation_generation.
TestPersistenceRepairKeepsTheRowsOwnParticipation runs the repair with
versioned history on for a legacy row (created with the flag off) and a
participating row (created with it on), through both repair entry points:
MoveIssuePersistenceInTx and a guarded update with a persistence patch. They
mint at different sites. The legacy row must stay NULL and mint nothing,
since R2.3 says an ordinary write does not promote it. The participating row
must mint one version. participation_generation must not change in either
case.
It fails if the repair mint is create-shaped, which would stamp and start
versioning the legacy row.
* test(dolt): a delete's rewrite of a legacy neighbor mints nothing (be-31mnz)
Folded in from bee's R1 on #6961, note 1. Once
TestDualWriteDeleteNeighborRewriteRidesTheDeletesDoltCommit started creating
its neighbor with history on, nothing covered a delete whose neighbor was
created with history off. Under the section 16.2b fence, the expected result
for that case is different: the rewrite still runs, but it mints nothing.
TestDualWriteDeleteSkipsALegacyNeighborsRewrite creates the fixtures with
history off, turns history on, and force-deletes the cited target. It then
checks four things: the rewrite ran (ReferencesUpdated=1), the neighbor has
no issue_versions rows, its participation_generation is still NULL, and
dolt_status is clean for issue_versions, store_epoch and issues.
* test(embeddeddolt): batch-created rows are stamped with the participation generation
A batch create writes its rows first and mints each created row's first
version last, after the creation-time edges land. The mint has to stay
create-shaped for rows the batch inserted (stamping participation_generation
from the store epoch) and update-shaped for rows it only upserted over
(skipped while the row is a legacy row), so the per-row isNew has to survive
the deferral to the batch's final mint pass.
Pin that on the embedded engine:
- brand-new explicit-id rows are stamped with the store epoch and get one
version row each, and match the same input run one row at a time with the
batch-create fast paths off (5 rows, and 250 rows across three INSERT
statements);
- a legacy row the batch upserts over keeps a NULL participation_generation
and gets no version row, while the new rows beside it are stamped;
- with versioned history off, no row is stamped and no version row is written.
* ci(bazel): enroll the participation-generation tests in the embedded shards
The embedded-Dolt shard manifest has to name every top-level Test* in
internal/storage/embeddeddolt, or the exact-once coverage check fails.
The two participation-generation fence tests were written before that
check landed on main, and the batch-create stamping test is new, so none
of the three is listed yet. Add them to the 15-shard block as the
generator's incremental output: three inserted lines, no existing
assignment moves.
Also list the new batch-create test file in the embeddeddolt_test srcs,
in sorted position, so the Bazel target compiles it alongside the Go
build. Its imports are already among that target's deps.
Rebase note (maintainer): on current main the embedded storage manifest
uses a 40-shard block; the generator's incremental output placed these
three tests in shards 18, 19 and 39 and re-sorted one existing shard-12
line.
* fix(issueops): keep a created row's updated_at when its first version is minted
Minting a version is bookkeeping. It must not change a user-visible column
of the row it versions.
The create-shaped mint stamps participation_generation with an UPDATE of the
issues row. issues.updated_at is ON UPDATE CURRENT_TIMESTAMP, so an UPDATE
that changes any other column and does not name updated_at rewrites it with
the clock. Before the stamp, a row's first mint left current_revision at its
column default of 1, so the UPDATE changed nothing and the clause never
fired. The stamp moves participation_generation from NULL to the store
epoch, so the clause fires on every row whose first version is minted and
replaces the updated_at an import supplies.
Set updated_at to itself in the stamp, as the blocked-state recompute in
issueops/blocked_state.go already does, so the timestamp the row was created
with survives. Add a regression that batch-creates rows with a supplied
updated_at and requires both the stamp and the unchanged timestamp.
* test(createbatchequiv): re-record the digests the participation-generation fence moves
The fence does not re-mint rows that predate the stamp: a row whose
participation_generation is still NULL gets no new version when a batch
touches it. Main mints one, so six recorded entries move.
The issue_versions entry of five scenarios loses the versions main mints
for rows that predate the stamp: three rows in small, all eleven in
depadd, all fifteen in waitsfor, four in import458 and two in
import458-reject-stale. In depadd, eq-db1 and eq-dl are the only rows
main mints more than once, and each of those mints moves their updated_at
off the fixture date. The fence skips them, so the two rows keep the
fixture date and join the issues_updated_at entry.
No other table, list or counter digest changes, and the fast and per-row
bodies already agree in every scenario. The digests were recorded with
the embedded backend. The doc comment on GoldenDirEnv now says which
entries were re-recorded.
* test(storage): waive the participation-generation contracts on the http leg
main's #7247 (6d21d337ad, "a served http conformance leg") registered a
fourth leg, http, after this PR's original base. The PR's seven
RunParticipationGeneration* entrypoints are neither wired nor waived there,
so TestEveryLegWiresEveryRoleContract/http fails on the rebased branch.
ParticipationGenerationFixture toggles the store's own versioned-history
write flag and reads the raw participation_generation column back: store
write-fence bookkeeping (design §16.2b), not a publicops role the HTTP
client serves. Waive the seven cases on http with a named reason, the same
waiver the donnabox fork carries (09e7ce05af), and keep the gap visible
until a supported HTTP surface is designed and tested.
go test ./internal/storage/ -run TestEveryLegWiresEveryRoleContract now
passes on dolt, embeddeddolt, http and uow.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(issueops): decide the fence's plane by the table that holds the row
recordVersionInTx chose the plane from the row's flags (IsWisp: Ephemeral
|| NoHistory) and then read participation_generation from the issues table
only. A wisps-TABLE row can carry neither flag, so it passed the IsWisp
return and the issues read failed with sql.ErrNoRows, aborting the whole
mutation whenever versioned history is on. Two producers:
- bd mol squash clears an ephemeral root's flag in place
(UpdateIssue {"wisp": false}, after the root's close, in the squash's
one transaction); update.go and the uow repository's Update both mint
after it unconditionally.
- import's "wisp_plane" marker (WispPlaneOverride = &true, flags false)
routes the row to wisps, and the batch create mints it create-shaped.
On origin/main the same paths do not fail but mint a stray issue_versions
row for a wisps-table row, an FR-8 leak (wisps are never versioned).
Fix: no issues row means nothing to version. ErrNoRows on the
participation_generation read now returns nil (no version, no error) for
update- and create-shaped calls alike. That read is the right signal and
IsActiveWispInTx is not: GetIssueInTx has already resolved the row, so
ErrNoRows on the issues read can only mean "not in issues", which is
exactly the question the fence has to answer before it stamps or advances
an issues row. It costs no extra query. IsActiveWispInTx asks the inverse
question ("is it in wisps?") with one more query per mint, and it folds
every error, including a transient one, into "not a wisp".
Tests come first, as three new conformance contracts with three new
ParticipationGenerationFixture hooks (ClearWispFlag, SquashWispRoot,
CreateUnflaggedWisp). They are wired on the dolt, embeddeddolt and uow legs
as subtests of each leg's TestParticipationGenerationFence (no new
top-level test, so the shard manifests do not change) and waived on http
with participationGenerationRawStoreWaiverReason:
RunParticipationGenerationWispFlagClearMintsNothing (create wisp,
UpdateIssue {"wisp": false}: no error, 0 versions)
RunParticipationGenerationWispRootSquashMintsNothing (close +
UpdateIssue {"wisp": false} in one transaction: no error, 0 versions)
RunParticipationGenerationUnflaggedWispCreateMintsNothing (CreateIssues
with WispPlaneOverride=&true, flags false: no error, 0 versions)
Red before the fix, green after, run both ways:
embeddeddolt (BEADS_TEST_EMBEDDED_DOLT=1): all three FAIL with
"versioned history: read participation_generation for pg-...: sql: no
rows in result set"; all three PASS after.
uow: all three FAIL with the same error; all three PASS after.
dolt (BEADS_TEST_DOLT_SERVER=local): WispRootSquash and UnflaggedWispCreate
FAIL with the same error; both PASS after. WispFlagClear passes both
ways on this leg. The store-level wisp update (updateWisp) runs in a
transaction versioned history never scopes, so it never reaches the
mint. For the same reason the leg's SquashWispRoot hook turns the events
journal on for its one transaction: that pins the wisp writes to the
scoped regular transaction, as in a journal-enabled workspace, so that
case does reach the seam.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(issueops): a create stamps participation even when the row is flagged no-history
A create-shaped mint (RecordVersionForCreateInTx) of a brand-new
ISSUES-TABLE row that carries NoHistory or Ephemeral returned at the IsWisp
check before the isCreate stamp, so participation_generation stayed NULL
although the row was created with versioned history on.
Import produces exactly that row: bd-r9uce keeps a promoted no-history
wisp's durable row on the issues plane with its stray no_history=true
(import_shared.go applyImportWispPlane: WispPlaneOverride = &false). When
bd update --persistent later repairs the flag, it is a same-plane normalize
whose mint is update-shaped by design (persistence.go: "A row created with
the flag on proceeds; a legacy row stays legacy"). The NULL column made the
fence read the row as legacy, so the repair and every later update were
fenced and the row was never versioned. origin/main versions it after the
repair (0, then 1, then 2 rows).
Fix: on a create-shaped call, a flagged row that the issues table holds
gets participation_generation stamped from store_epoch.epoch, the same
source the minting stamp uses, read in the same transaction. No version is
minted and updated_at is kept (SET ..., updated_at = updated_at), then the
call returns. Update-shaped calls on flagged rows still return before any
read. The table check from the previous commit now runs ahead of the IsWisp
branch for create-shaped calls, so a flagged wisps-table row (the common
wisp create) still mints and stamps nothing. That costs a create-shaped
call on a flagged wisp one primary-key miss on issues, and only while
versioned history is on. The store_epoch read/seed moves into
readStoreEpochInTx so both stamps share it.
Tests first:
- New conformance contract
RunParticipationGenerationNoHistoryIssueCreateDeclaresParticipation and
hook CreateNoHistoryIssue. Wired on dolt, embeddeddolt and uow as a
TestParticipationGenerationFence subtest and waived on http. With
history on: create {NoHistory: true, WispPlaneOverride: &false} gives
participation_generation non-NULL and 0 versions. The persistent repair
(MovePersistent) then gives 1 version, and an update-shaped edit
(MutateExisting, a title edit) gives 2.
- New subtest
TestCreateBatchParticipationGeneration/NoHistoryRowIsStampedUnversionedAndKeepsTheCallersUpdatedAt
(embeddeddolt): a batch of such rows with a supplied updated_at comes
out stamped, unversioned, and with updated_at unchanged.
Red before the fix, green after, run both ways:
dolt (BEADS_TEST_DOLT_SERVER=local), embeddeddolt
(BEADS_TEST_EMBEDDED_DOLT=1), uow: the contract FAILS on all three legs
("participation_generation for pg-no-history-create is NULL ...", then
"= 0 after the persistent repair, want 1", then "went from 0 to 0 ...
want exactly +1"). It PASSES on all three after.
embeddeddolt subtest: FAILS before the fix ("store_epoch has no row after
the batch, so nothing stamped the 5 rows"). With the fix minus the
updated_at = updated_at clause it FAILS on every row's updated_at. It
PASSES with the full fix.
No new top-level Test*, so the shard manifests do not change. The
createbatchequiv goldens are unchanged: the dolt and embeddeddolt
equivalence tests pass.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs: fix comments the rebase left stale
Comment-only.
- createbatchequiv.GoldenDirEnv said "One deliberate behavior change since
... nothing else moved" and then listed a second re-record, the
participation-generation fence's. It now says there are two deliberate
changes, puts each in its own paragraph, and scopes "nothing else moved"
to apply.json, the only golden the first change touched.
- issueops CreateIssueResult.isNew and deferredVersion still described one
write path. After main's #7205, a row written by deferredCreates'
multi-row INSERT reaches finishCreateIssueInTx(..., true) directly
(create_batch_cache.go flush) and never passes through InsertIssueIfNew
or CreateIssueInTxWithResult. isNew is InsertIssueIfNew's result on the
per-row path and always true for a multi-row-INSERT row. deferredVersion
is filled from both paths.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(issueops): pin the create/update shape split in the version guard
TestEveryVersionedEntryPointMints counts RecordVersionInTx and
RecordVersionForCreateInTx as one seam. A create-shaped site that fell back
to the update-shaped entry therefore stayed green, though the fence then
reads the new row's NULL participation_generation as legacy and the record
is never versioned. The reverse case also stayed green: an update path that
reached the create-shaped entry would stamp an existing legacy row and
promote it, which R2.3 forbids.
Add the split to the structural guard. It is two small tests over the same
journalscan fixpoint and mintVersion edge discipline, with no AST changes:
- TestCreateShapedEntryPointsMintCreateShaped: the create-shaped mint sites
(finishCreateIssueInTx, CreateIssuesInTxWithContext,
PromoteFromEphemeralInTx, moveIssuePersistenceInTx, executeUpdate) must
each call RecordVersionForCreateInTx themselves. A delegate is not enough
here, because executeUpdate runs its move with mintVersion=false and a
batch switches finishCreateIssueInTx's mint off at run time. Every
create-shaped entry point, the delegates and #7205's
deferredCreates.flush included, must reach it.
- TestUpdateShapedEntryPointsNeverMintCreateShaped: every other
versionedEntryPoint must not reach RecordVersionForCreateInTx. The
exception is ApplyBatchInTx, which runs create and update items together
and is listed as mixed with a reason.
Mutation-checked, each probe reverted afterwards. executeUpdate's
EnteredIssuesPlane mint, PromoteFromEphemeralInTx's mint, or the batch's
deferred create-shaped mint switched to RecordVersionInTx: each fails the
create half. update.go's end-of-update mint switched to
RecordVersionForCreateInTx: fails the update half for UpdateIssueInTx and
every entry point that writes through it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(issueops): hold the dual-shape mint sites to both halves of the split
f006c871c5 listed executeUpdate, moveIssuePersistenceInTx,
finishCreateIssueInTx and CreateIssuesInTxWithContext (and the
ExecuteUpdate/MoveIssuePersistenceInTx/create wrappers that delegate to
them) as create-shaped, so TestUpdateShapedEntryPointsNeverMintCreateShaped
skipped them. Each one also mints update-shaped, on its existing-row or
same-plane branch, which is the common path: a guarded update of an
existing row, the bd update --persistent repair of an issues-plane row's
flags, a create or batch create that resolved to a row already there.
Switching that branch to RecordVersionForCreateInTx stamped a legacy row
out of legacy (R2.3), and every guard stayed green.
Split the lists by what each function actually mints:
- versionCreateShapedMintSites keeps only the pure create-shaped site,
PromoteFromEphemeralInTx. It must call RecordVersionForCreateInTx and
must not call RecordVersionInTx.
- versionDualShapeMintSites names the four, each with its two branches.
TestDualShapeMintSitesCallBothEntries requires each to call BOTH entries
directly. A delegate does not count, for the same mintVersion=false and
DeferVersionMint reasons as before.
- versionCreateShapedEntryPoints keeps PromoteFromEphemeralInTx and
deferredCreates.flush, which passes isNew=true for every row.
- versionDualShapeEntryPoints replaces versionMixedShapeEntryPoints. It
holds ApplyBatchInTx and the create, persistence-move and guarded-update
entries that delegate to a dual-shape site, each with a reason. Each must
reach both entries transitively.
The update half skips the create-shaped and dual-shape entry points, as
before. The update-shaped branch inside a dual-shape site is now the new
test's to pin.
Mutation-checked in a throwaway worktree. Switching the update-shaped mint
to RecordVersionForCreateInTx at execution.go:301, persistence.go:97,
create.go:260 or create.go:499 now fails
TestDualShapeMintSitesCallBothEntries for that site. Before this commit,
the whole issueops package stayed green under each of these switches.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(httpclient): run the participation-generation fence over the served wire
edd3b72a1a waived all eleven ParticipationGeneration contracts on the http
leg, saying the client had "no write flag to toggle and no raw column to
read". That reason was wrong. served_dualwrite_history_test.go already
flips the reference store's VersionedHistoryConfigurer and reads its raw
columns, with the client driving the mutation. The waiver also hid the
one harness that runs the fence behind the update a connected workspace
actually sends. Every store leg's MutateExisting is store.UpdateIssue,
but the served Lifecycle.Update reaches the guarded update,
ExecuteUpdate.
Add served_participation_generation_test.go on the same pattern:
- Bound to the client: Mutate is Lifecycle.Create, MutateExisting is
Lifecycle.Update, MovePersistent is the persistence-mode
Lifecycle.Update that bd update --persistent sends, and PromoteWisp is
issueops.Promote over the client's Reader/Lifecycle/Commenter, the
entry bd promote dials over http.
- Bound to the reference store, as before: SetFlag, the CreateWisp seed,
and the raw reads.
TestServedParticipationGenerationFence runs seven cases:
CreateWithFlagOnStampsAValue, CreateWithFlagOffLeavesLegacyNull,
SkipsUpdateOnLegacyRecord, ProceedsForPromotedRecord,
FenceIgnoresSchemaSkewHatch, WispPromotionBeginsHistory and
WispPersistenceMoveBeginsHistory. All seven pass, and no case turned up a
server-side fence bug.
Four cases stay waived, now with a reason that names the actual wire gap
(participationGenerationWireGapWaiverReason):
- WispFlagClearMintsNothing: the in-place {"wisp": false} is an untyped
UpdateIssue, and IssuePatch.Persistence moves the row instead.
- WispRootSquashMintsNothing: it needs RunInTransaction. That and
UpdateIssue are both on the client's unsupported allowlist (D8).
- UnflaggedWispCreateMintsNothing and
NoHistoryIssueCreateDeclaresParticipation: both need WispPlaneOverride,
which every create shape on the wire drops
(roleIgnoredCreateIssueMembers).
The new file is listed in httpclient_test's srcs. The served lane deals
unpinned tests round-robin, so no shard manifest names it.
Mutation-checked in a throwaway worktree. With execution.go:301 (the
guarded update's update-shaped mint) switched to
RecordVersionForCreateInTx, SkipsUpdateOnLegacyRecord and
FenceIgnoresSchemaSkewHatch fail here ("version row count for
hpg-legacy-skip went from 0 to 1"). The embeddeddolt and uow
Participation|DualWrite|Version suites stay green under the same probe.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(conformance): an update never stamps a legacy no-history row
7c00d65fa6 made the seam write participation_generation on a flagged
(NoHistory or Ephemeral) issues-table row when the call is create-shaped.
Only the early `if IsWisp(issue) && !isCreate { return nil }` keeps an
update-shaped call out of that branch, and nothing pinned it. The new
contract and its subtest covered only the positive, create-shaped side.
With the early return dropped, an ordinary update stamped a legacy
no-history row out of legacy (R2.3), and every suite stayed green.
Add RunParticipationGenerationLegacyNoHistoryIssueStaysLegacy beside
NoHistoryIssueCreateDeclaresParticipation as its negative twin:
1. Create the no-history issues-table row with the flag OFF.
2. Turn the flag on and run MutateExisting. participation_generation must
stay NULL, with 0 versions and current_revision unchanged.
3. Run MovePersistent, the bd update --persistent repair that clears the
flag in place. The repair is update-shaped too, so the same three
things must still hold.
Wired on all four legs: dolt, embeddeddolt, uow and http. On http the
case exercises the client's Lifecycle.Update and persistence update.
Their precondition, the flag-off no-history create, is seeded through
the reference store, because no client create can land that row in the
issues table. That gap is also why the case whose SUBJECT is that create
stays waived on http.
Mutation-checked in a throwaway worktree, with the early return made
`if false && IsWisp(issue) && !isCreate`. The new case fails on all four
legs and is the only case that fails:
"participation_generation for pg-no-history-legacy = 1 after an
update-shaped mutation with the flag on, want NULL" (dolt server leg,
embeddeddolt, uow and http). At tip it passes on all four.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(issueops): say which table and which mint the fence comments mean
Comment and doc corrections. No code changes.
- RecordVersionForCreateInTx's doc comment covered a flagged issues-table
row but not a wisps-table row. A row the wisps table holds mints and
stamps nothing, whatever its flags say: there is no issues row to stamp
(FR-8). That holds for an ordinary wisp create and for import's
unflagged "wisp_plane" row.
- The no-history stamp branch said the bd update --persistent repair mints
update-shaped "(MoveIssuePersistenceInTx)". That is true only on the
unit-of-work path. On dolt and embeddeddolt the repair goes through the
guarded update: executeUpdate runs moveIssuePersistenceInTx with
mintVersion=false and mints once at its own end. The fixture's
MovePersistent doc already says this.
- VERSIONED-BEADS-WRITE-PATHS.md row 13 still credited the whole wisp
exclusion to `RecordVersionInTx returns on IsWisp` and called every case
a NO-OP. After ec52d29030, the table holding the row decides its plane:
only an update-shaped call on a flagged wisp returns on IsWisp. Every
other wisps-table row, including an unflagged one, is excluded by the
issues-table participation_generation read, which finds no row. After
7c00d65fa6, a create-shaped call on a flagged issues-table row is
stamped but not versioned, so the row says that too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(conformance): the wisps-table cases check the row is still a wisp
runWispTableRowMintsNothing asserted 0 versions but never checked its own
precondition, that the wisps table still holds the row. Suppose a step
moved the row onto the issues plane through an update-shaped mint. That
mint would hit the new row's NULL participation_generation and be fenced,
so the count stayed 0 and the case passed without saying anything about
a wisps-table row.
- Add an InWispsTable hook to ParticipationGenerationFixture and bind it
on dolt, embeddeddolt and uow as a raw wisps-table count. The
wisps-table body now Fatals if the row is not in the wisps table after
its steps. Each leg's KitIsWired test checks the hook. On http it
stays nil with the other wisps-table hooks, whose cases are waived
there.
- The dolt ClearWispFlag hook now bites. A bare store.UpdateIssue on a
wisp goes through updateWisp, whose transaction versioned history never
scopes. So WispFlagClearMintsNothing passed on dolt with or without the
ec52d29030 fix, as that commit's message admits. The hook now runs the
lone flag clear in a RunInTransaction with the events journal on: the
journal-enabled shape the SquashWispRoot hook already uses.
- Both hooks go through a new withEventsJournal helper. It restores the
store's previous journal setting rather than unconditionally setting it
to false afterwards, which assumed the store started with the journal
off.
Mutation-checked in throwaway worktrees:
- With version_history.go at ec52d29030^, dolt's WispFlagClearMintsNothing
now fails ("read participation_generation for pg-flag-clear: sql: no
rows in result set"). It used to pass there.
- Embedded ClearWispFlag rerouted as a flag-off persistence move followed
by a flag-on title update: the case fails on the new precondition ("is
not in the wisps table after flag-clear"). With the precondition
disabled, the same probe passes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(storage): review fixups for the participation_generation fence
The review of d17b716115 approved the PR with no required changes and
raised four minors and three nits. Each one below says what changed and
why, or why it did not.
Minor 1, the upsert create's new-or-existing choice was untested. The
unit-of-work create that is not CreateOnly (bd batch, bd todo, tracker
sync and mol port) inserts through an upsert, and db.Insert's existed
probe picks the mint's shape; forcing it either way shipped green. The
new uow TestParticipationGenerationUpsertCreate pins all three outcomes:
a new row is stamped and begins its history, a legacy row the upsert
resolves to stays legacy with no version, and a participating row mints
exactly one more. No served-route case is added because every served
create is CreateOnly (uow createParams), so the http wire cannot reach
this branch. The cmd/bd proxied-server batch and todo creates call this
same use-case method.
Minor 2, an update-shaped mint still lets issues.updated_at move
through ON UPDATE CURRENT_TIMESTAMP. Not changed here. The maintainer
listed it on the PR as follow-up (2), and the approving review of
d17b716115 accepted carrying it as a follow-up. It does not change
the fence's contract as pinned.
Minor 3, the depadd and waitsfor goldens had been re-recorded to zero
issue_versions rows. Their seeds run with history off, so every seeded
row was legacy and the harness stopped checking the dependency-add,
close and reopen mints. Both scenarios now stamp their seeded
issues-table rows after the seed (stampParticipation; wisps stay
unstamped). Their goldens are back to main's pre-fence files byte for
byte: depadd mints 11 version rows and waitsfor 15. The fenced legacy
outcome stays pinned by small, import458 and import458-reject-stale. A
run scenario that mints no version row now fails rather than recording
an empty digest.
Minor 4, PromoteFromEphemeralInTx always minted create-shaped. When the
issues plane already held the id (the dual presence GH#4455 records),
its upsert resolved to that row and the create-shaped mint stamped a
legacy record (R2.3). It now keeps InsertIssueIfNew's isNew and mints
update-shaped for an existing row, as finishCreateIssueInTx does. The
version guard lists it as a dual-shape mint site and entry point, and
PromoteOverDualPresenceKeepsLegacy pins the behavior at run time.
Nit 1: with versioned history off, db.Insert skips the existed probe,
since both mint entries return before reading anything. A create costs
the round trips it did before the fence.
Nit 2: the MINT COST comment now counts the fence read (about 6 to 7
round trips) and no longer says the snapshot reads current_revision;
the fence read can select it for #6379's ordinal seed. Moving that read
now would only add a column nothing consumes yet.
Nit 3: the http leg's participation-generation wire-gap waiver opens as
PENDING and names the wire mutation that would retire each case.
Validation, in a scrubbed env with -tags=gms_pure_go on embedded and
server Dolt (all pass, none skipped):
- uow: TestParticipationGenerationFence, its FixtureKitIsWired check
and TestParticipationGenerationUpsertCreate with its 4 subtests.
- embeddeddolt: the create-batch equivalence parts (small/depadd,
apply/waitsfor), the parts-coverage guard, the large scenarios, and
the fence and kit.
- dolt: TestCreateBatchFastPathsMatchPerRow_Dolt, the fence,
FenceIgnoresSchemaSkewHatch and the kit.
- httpclient: TestServedParticipationGenerationFence.
- TestEveryLegWiresEveryRoleContract, the issueops structural guards,
and the issueops, storage and domain/db packages.
Eleven mutants, graded in 13 runs, each fail the test meant to catch
them:
- upsert always create-shaped or always update-shaped;
- the probe guard inverted;
- promote always create-shaped or always update-shaped;
- the seed left unstamped;
- the dependency-add, close or reopen mint dropped;
- two on-disk single-entry promotes.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(storage): a wisp upsert must not stamp a legacy issues twin
domain/db's Insert chose the mint shape of its upsert (the create that
is not CreateOnly) from an existence probe of the target table. For a
wisps-table insert that probe asks the wrong plane: the seam snapshots
the issues table first (GetIssueInTx), so when the issues plane already
held the id as a legacy row, the wisp create took the create-shaped
mint and stamped and versioned that untouched twin. An ordinary wisp
write promoted a legacy record, which R2.3 forbids. bd mol port and the
proxied mol and wisp writers call CreateWisp this way. It is latent
until versioned history is enabled (#6661).
A wisps-table insert never creates an issues row, so it now mints
update-shaped, without the probe. The fence leaves a legacy twin alone,
a wisp-only id still mints nothing through either entry (FR-8), and a
participating twin mints the one version main already minted for it.
Insert's comment now records that last case: the dual presence
predates the fence, and this upsert does not refuse it the way
issueops' create path does.
TestParticipationGenerationUpsertCreate gains
WispOverLegacyIssuesRowKeepsItLegacy, which fails against the previous
dispatch (twin stamped, one version row). Also from review: the version
shape guard names the dual-shape site its parse cannot see, and the
row-lock exemption comment counts all three of the seam's UPDATE issues
statements.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* fix(bootstrap): cut the host part before stripping userinfo (mc-gcmer)
urlHostname stripped userinfo through the first "@" anywhere in the URL,
before cutting out the host part, so an "@" in a path, query or fragment
picked the host: https://my-dolt.example.com/x@github.com/path read as
github.com. isGitCodeRepoURL then called it a forge, and doltRemoteURL
rewrote what is really a Dolt remotesapi URL to git+https:// (the GH#3339
class). The SCP branch made the same split, so both
my-dolt.example.com:org/x@github.com:db and the local path
./backups/me@github.com:db read as github.com too.
Cut the host part first, then strip userinfo through its last "@":
- scheme URLs: the authority, ending at the first "/", "?" or "#". That is
the host net/url dials, and Dolt's earl.Parse hands scheme URLs to
net/url. Taking the last "@" matches net/url too, so
https://a@b@github.com/org/db is now a forge, as Dolt would dial it,
instead of going raw to the remotesapi client (the #4421 class).
- SCP: everything before the first ":", unless a "/" comes first (a local
path) - the split doltremote.FromGitURL makes.
TestIsGitCodeRepoURL gains the path/query/fragment-@, SCP path-@,
local-path-@ and last-@ cases, 7 of them red before this change, plus
userinfo controls in both URL forms that stay green.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(bootstrap): scrub credentials from the Bootstrap failed message (mc-gcmer)
An unencoded "#" or "?" in a sync.remote password ends the URL's
authority early, so urlHostname no longer reads the remote as a forge and
bootstrap clones it as configured. The clone error then carries the URL,
password included, twice: sanitizeURL passes through a URL net/url cannot
parse, and Dolt's "invalid remote url:" repeats it. Scrub the error with
scrubURLCredentials where "Bootstrap failed:" prints it.
TestEmbeddedBootstrapCloneFailureScrubsCredentials pins this; it fails
against the pre-fix binary for both "pa#ss" and "pa?ss", and the new test
is registered in the embedded shard manifest.
Also add a forgeSyncRemoteForms row for multi-@ userinfo without a .git
suffix, so the routing pin covers a URL only its host can make a forge.
The row fails with the base urlHostname.
Review: PR #7616 synthesis F1 (minor) and F5 (nit).
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(sqlbuild): bind time bounds as their UTC instant
BuildIssueFilterClauses bound every time bound (created/updated/closed/
started/defer/due, after and before) as tc.v.Format(time.RFC3339), which
keeps the value's offset. The columns hold UTC wall clock, and an engine
whose timestamp column carries no zone reads a literal's wall clock and
drops the offset, so a bound spelled +02:00 would compare two hours late.
Bind tc.v.UTC().Format(time.RFC3339): the same instant, spelled in UTC, at
whole seconds. Dolt already converts an offset literal to UTC and bd's
client resolves bounds to UTC, so no answer changes on any backend here;
this keeps the shared builder correct for every engine.
TestTimeBoundsBindTheUTCInstant pins all twelve bounds to the UTC spelling
of a +02:00 instant with a sub-second remainder.
Also correct the AfterCreatedAt comment, which justified the time.Time
cursor binding by a SQLite backend that no longer exists.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(sqlbuild): bind the keyset cursor as its UTC instant too
Review fixups on #7655.
BuildIssueFilterClauses bound IssueFilter.AfterCreatedAt as the caller's
time.Time, unconverted. The embedded Dolt driver sends a time.Time as its
wall clock with no zone (vitess BuildBindVariable formats it as
"2006-01-02 15:04:05.000000"), and the columns hold UTC wall clock, so a
cursor in another zone paged from the wrong position there: the keyset
walk with +02:00 cursors re-delivers rows on embedded Dolt.
go-sql-driver/mysql converts to the connection's zone (UTC) first, so
server Dolt was unaffected. Bind filter.AfterCreatedAt.UTC(), still a
time.Time, and reword the comment, which claimed the driver carries the
instant. TestKeysetCursorBindsTheUTCInstant pins the cursor args of both
orders.
The httpapi query.timestamp comment and the
TestListFilterTimeBoundsAreNormalizedToUTC doc justified the route's UTC
normalization by the old sink behavior (formatting a bound in its own
zone). They now say sqlbuild binds every range bound in UTC and the
route's normalization is its own guard in front of that.
The CHANGELOG bullet gets a bold lead, covers the cursor, and drops the
blank line that made the Fixed list loose.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* wy-qlvlmf: test(cmd/bd): stop tests from mutating the host checkout's .git; guard it in TestMain
On 2026-10-16 a 'go test ./cmd/bd' run from a linked worktree rewrote the
host rig's shared .git/config (core.bare=true, extensions.worktreeConfig,
remote.origin.url replaced by metadata_test's fixture URL, user identity,
core.hooksPath) and its hooks dir, leaving every worktree of that clone
answering 'fatal: this operation must be run in a work tree' (r880).
Root causes, all one class — fixture git commands routed at the repository
the test process itself lives in instead of a fixture the test owns:
- TestRunApplyAllOK ran runApply(false) (a LIVE apply: hook reinstall,
hooksPath mkdir) with no fixture, against the package cwd's repo.
- runGitForBootstrapTest treated dir=="" as 'inherit package cwd'.
- doctor/fix setupGitRepoInDir swallowed git config failures non-fatally
and ran with whatever git routing env (GIT_DIR, GIT_WORK_TREE) leaked in.
Fixes:
- TestRunApplyAllOK / TestRunApplyDryRun now chdir into an isolated
git+.beads fixture (isolatedApplyFixture + runInDir).
- runGitForBootstrapTest: empty dir gets a neutral t.TempDir() cwd, never
the package cwd; env scrubbed of git routing vars.
- initGitRepoAt / doctor setupGitRepoInDir / doctor-fix setupGitRepoInDir:
refuse an empty dir, fail on ANY git error, scrub routing env.
- testMainInner scrubs git routing env process-wide at startup.
- TestMain's repo guard now also snapshots the checkout's own git state
(common .git/config, config.worktree, common hooks dir) and reddens the
run on any diff, naming the mutated file.
Guard vacuity check: a probe test writing one key into the checkout's
.git/config passes individually and reddens the suite via the guard.
Co-Authored-By: Claude Fable 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/39013861275
(`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.
* test(cmd/bd): scrub doctor suites, keep git fences, key-level config guard (wy-qlvlmf)
Maintainer fixup on top of #7650 by cat, for the first review's three
majors, minor and nit, and three of the second review's minors.
- Doctor suites: the leaked-GIT_DIR vector was still open in
cmd/bd/doctor and cmd/bd/doctor/fix. Their four TestMains now unset
the repository-location env first (testutil.UnsetGitRepoLocationEnv),
and the three initGitTemplate copies plus
testutil.ForceRepoLocalHooksPath run git with a filtered env. With
GIT_DIR/GIT_WORK_TREE leaked at a decoy repo, the PR head wrote
core.hooksPath into the decoy and failed 120 doctor tests; with this
commit all three packages pass and the decoy stays byte-identical.
- Narrower scrub: the process-wide scrub also removed
GIT_CEILING_DIRECTORIES and the GIT_CONFIG_* fences that
tools/bazel/test_env.sh and scripts/ci/lib/test-env.sh set on purpose.
testutil.WithoutGitRepoLocationEnv removes only GIT_DIR, GIT_WORK_TREE,
GIT_COMMON_DIR, GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY,
GIT_ALTERNATE_OBJECT_DIRECTORIES, GIT_NAMESPACE and the legacy
GIT_CONFIG (which sends `git config` reads and writes to the file it
names, even under -C). Keys match exactly, so GIT_CEILING_DIRECTORIES,
GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM stay. Every helper that
built its own scrubbed env now uses it.
- Guard false reds: the TestMain guard compared the shared common config
byte for byte, so a sibling worktree's routine branch write failed a
passing run. It now diffs `git config --list -z` key by key.
branch.<name>.* keys, and a remote other than origin added or removed
whole, print a NOTE and leave the exit code alone. Any other key
(including origin appearing or disappearing, and a changed key of a
remote that exists before and after), any config.worktree change, any
hook file change or an unparseable config still fails the run.
- config.worktree: the guard also snapshots a main checkout's own
config.worktree, which sits in the common dir. With
extensions.worktreeConfig set its keys override the shared config, and
before this an escaped `git config --worktree` write there went
unreported.
- Report: changed keys are named with values redacted, deleted and new
files are reported as such, pre-run copies of the changed files are
saved (0700 dir, 0600 files) and their path printed, and a failure to
locate the checkout's git dirs prints a warning instead of disarming
the guard silently.
- doctor setupGitRepoInDir stat-checks its dir like the doctor/fix copy.
New tests: internal/testutil/git_env_test.go, and
cmd/bd/test_repo_git_guard_test.go (real-git fixtures for locating the
git dirs, classifying writes, config parsing and the report).
Validation: ./scripts/test.sh ./cmd/bd in a scratch clone with GIT_DIR
leaked at a decoy (ok; decoy and the clone's .git unchanged; guard
quiet); bazel test --config=ci for testutil, doctor, doctor/fix,
fmt_test and the new bd_test guard tests; make ci-pr-lint;
tools/bazel/go_srcs.py --check.
Second review: leaving GIT_CONFIG out of the scrub fails
TestWithoutGitRepoLocationEnvKeepsWrapperGitControls and
TestForceRepoLocalHooksPathIgnoresLeakedGitDir; the old main-checkout
config.worktree path fails TestLocateRepoGitDirs/main_checkout and the
new config.worktree case; treating origin like any other remote fails
the new origin added and removed cases. In a scratch main-checkout clone
with extensions.worktreeConfig set, a test that wrote
`git config --worktree user.email` into the checkout now fails the
suite (exit 1, an ERROR naming .git/config.worktree). bazel test
--config=ci passes for testutil, fmt_test and the bd_test guard tests.
Not in this commit: the same scrub in beads_test_env_enter
(scripts/ci/lib/test-env.sh) and tools/bazel/test_env.sh, which would
cover the packages outside cmd/bd that still write to the clone under a
hook-leaked GIT_DIR. That predates this PR and is left to a follow-up.
Co-authored-by: cat <cino@ghosttrack.com>
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: cat <cino@ghosttrack.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* feat(http): bd blocked over bd serve (blocked.list) through issueops.BlockedLister
`bd blocked` refused against an HTTP workspace: it called the legacy
GetBlockedIssues, which the HTTP backend stubs as unsupported. It now runs
one role on every route, and bd serve publishes that role.
- Role: issueops.BlockedLister.ListBlocked(BlockedRequest{ParentID, Labels,
LabelsAny, ExcludeLabels}) -> BlockedResult{Items}. One body,
internal/storage/issueops.ExecuteListBlockedInTx over the unchanged
GetBlockedIssuesInTx; labels normalized in the role (BlockedFilter);
Items never nil and in a total order (priority, created_at desc, id).
- Legs: DoltStore (read tx), EmbeddedDoltStore (read conn), uow (read unit
of work through the use case's GetBlockedIssues, so the
external-dependency uow decorator applies). Census: storage.DoltStorage
gains BlockedLister(); HookFiringStore passes it through (a read),
telemetry wraps it, uow.notifyingProvider, externaldeps.uowProvider and
httpapi.timedProvider build it.
- externaldeps.Store.BlockedLister is built over its own GetBlockedIssues,
so local `bd blocked` output is unchanged. Over a remote store it takes
the server's listing when the server advertises
policy.external_dependencies, else decorates the server's listing here
through EdgeReader and BatchGetter (decorateBlocked, factored out of
GetBlockedIssues).
- Wire: GET /v0/beads/blocked (listBlockedIssues; parent, label,
label_any, exclude_label) answering BlockedPage {items, has_more} with
the new x-go-type-pinned BlockedIssue schema, behind the new
blocked.list token. apigen and the wire-shape golden regenerated; the
golden diff is additive only, so wire_revision stays 2.
Config.BlockedLister is a required role, wired in bd serve.
- Client: httpclient.Store.BlockedLister dials through Store.dispatch, so
an older server is refused BEFORE the dial with *wire.CapabilityError
naming blocked.list. The legacy Store.GetBlockedIssues rides the role
(page and row cap applied to its answer) and leaves the unsupported
shell. Divergence ledger row F-blocked retired.
- CLI: `bd blocked` takes BlockedLister() from the store on the direct
routes and from the provider's BlockedListerSource on the proxied route;
runBlockedProxiedServer is deleted. --json output is the same rows in
the same order, [] when empty.
Tests: backend/conformance RunBlockedLister (10 cases: direct blocker,
child attributed to its blocked parent, closed blocker, wisp plane, pinned
status, parent filter, label filters with normalization, order, empty
slice, request not mutated) on dolt, embedded, uow and the served HTTP
client; httpapi handler tests (mapping, unknown/repeated params,
projection, capability); httpclient stub tests (pre-dial refusal naming
the token, encoding, projection, legacy door paging); skew and vocabulary
counts; TestE2E_BlockedOverHTTP (served `bd blocked --json` equals the
local command's after mapping ids and timestamps, member order included,
external blocker named, older-server refusal with no dial); corpus
gc-blocked re-marked and gc-blocked-parent added, both pending until the
reference server advertises blocked.list.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(blocked): pin server-side external decoration, refuse has_more, serve the legacy door over http
Review fixes for the blocked.list slice.
- Server-side external decoration is now pinned on the compositions bd
serve answers from. TestWrapUOWProviderBlockedListerNamesExternalBlockers
lists through the wrapped unit-of-work provider's own BlockedLister
accessor (the bd serve provider path) and requires an external-only row
and a mixed row to carry their external: refs; building that lister over
the inner provider fails it. TestServedBlockedListerCarriesExternalRefs-
WhenTheServerEnforces serves the store-shaped composition
(externaldeps.Store.BlockedLister, policy advertised) and requires the
operation's own answer, through the undecorated client role, to carry the
refs, and the client's decorated chain to return it unchanged; serving
the inner store's lister fails it.
- The client refuses an answer reporting has_more with the new typed
httpclient.TruncatedListingError instead of returning a short listing:
the operation has no cursor, and a caller reads a missing row as
unblocked. The legacy door inherits it.
- externaldeps.Store.GetBlockedIssues over an http store reads the extra
sources through the served roles (EdgeReader, BatchGetter) instead of the
raw GetIssuesByIDs / GetDependencyRecordsForIssues the http backend
refuses, and the decoration skips the source read when there is nothing
to load. The legacy door on the CLI chain (bd mol stale, the wisp
commands) now answers over http in both policy modes;
TestServedLegacyGetBlockedIssuesThroughTheDecorator pins it, paging
included. bd ready --explain still refuses on its other raw reads; the
CHANGELOG says so.
- Docs: the spec and the retired F-blocked ledger row state that the
listing is unpaged, bounded by the client's 32 MiB response limit
(refused, never read in part), and that has_more is refused.
- Contract: new cases for waits-for and conditional-blocks blockers, no
type exclusions (gate, epic), and a stale flag with no nameable blocker
(on the legs that can write the column: dolt, embedded; skipped
elsewhere with the reason). Order seeds explicit created_at values with
five rows tied on priority and created_at, two of them wisps, so only the
id tiebreak orders them; dropping the tiebreak now fails every run.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(blocked): bd blocked --flags, the blocked flag per id from stdin
`bd blocked --flags [--json]` reads ids from stdin, one per line (blank
lines and repeats ignored), and prints the blocked flag bd holds for each:
with --json, [{"id","is_blocked"}] in the order the ids were first given,
omitting an id that names no row on either plane, [] for no input. It is
the readiness column a consumer otherwise had to read with `bd sql`, so no
such consumer needs a local-only command.
It is the FLAG, not the listing: `bd blocked` narrows the stored flag to
rows it can name a blocker for, and --flags does not, so a row whose flag
is set with no nameable blocker reads true here and is absent from the
listing. Where the external-dependency policy applies, an unsatisfied
external: blocker sets the flag, as it keeps the row out of `bd ready`.
One library entry on every route: issueops.BlockedFlags over the route's
BlockingAnnotator (the store's accessor on dolt, embedded and HTTP, the
provider's on the proxied route). Over HTTP that is listBlockingAnnotations
with is_blocked behind dependencies.blocking.isBlocked; a server without
that token is refused before the dial, naming it. No wire change. The
listing's filter flags are refused with --flags rather than ignored.
Tests: TestE2E_BlockedFlagsOverHTTP (served JSON equals the local command's
after mapping ids to titles, unknown id omitted, repeat collapsed, [] on
empty stdin, filters refused; a stale-flagged row with no blocker reads
true and is absent from `bd blocked --json`, which fails if --flags is
derived from the listing; an older server's handshake refused naming the
token with no dial); TestProxiedServerBlocked/flags_reads_ids_from_stdin on
the proxied route; corpus gc-blocked-flags, pending until the reference
server advertises the token. CHANGELOG entry.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(blocked): bd blocked --flags --raw, the stored is_blocked column
`bd blocked --flags --raw [--json]` answers the stored is_blocked column
for each id read from stdin, exactly what reading is_blocked from the issues
and wisps tables returns, without the external-dependency policy: a row
blocked only by an unsatisfied external: ref reads false (the policy-aware
--flags reads true), and a stale flag reads true either way. Same output
shape as --flags. This lets a consumer move off a `bd sql` read of the
column with no change in what it reads. The default --flags is unchanged.
The role is taken from beneath every decorator: storage.UnwrapStore on the
direct routes, uow.UnwrapProvider on the proxied route. Over HTTP the
innermost store is the http client, whose annotation read is the server's
answer: against a server that does not advertise
policy.external_dependencies that answer is the column, and --raw is
served. A server that advertises it decorates the flag it answers, the v0
wire has no member asking it for the column, and the decorated flag cannot
be turned back into the column client-side, so --raw against such a server
is refused before the annotation read, naming the token, rather than
answered with the decorated flag. --raw without --flags is refused.
Tests: TestE2E_BlockedFlagsOverHTTP/raw_is_the_stored_column (served --raw
equals local --raw; the externally-blocked-only row reads true with --flags
and false with --raw on both; locally blocked rows agree; a stale-flagged
row reads true in both modes; --raw without --flags exits 1; a server
advertising the policy refuses --raw with no annotation request);
TestProxiedServerBlocked/flags_raw_is_the_stored_column; corpus
gc-blocked-flags-raw (pending until the reference server advertises
dependencies.blocking.isBlocked). Routing --raw through the decorated
annotator fails the e2e. CHANGELOG entry.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(changelog): bd blocked --flags --raw is for the local and proxied routes
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(blocked): give the e2e gate-kid its own priority; document --flags answers closed ids
TestE2E_BlockedOverHTTP seeded gate-parent and gate-kid at one priority, so
when both landed in the same second their order fell to the generated ids,
which differ between the local and the served workspace: the comparison
failed intermittently. gate-kid now has its own priority. Ten runs on the
embedded lane pass.
bd blocked --flags answers a closed id too, with its stored flag; a SQL read
of the column filtered on status <> 'closed' leaves it out. Said in the
command's doc and the CHANGELOG.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(blocked): apply label filters to external-only blocked rows
The external-dependency policy appends a row blocked only by an
unsatisfied external: ref after the label query has run, so --label,
--label-any and --exclude-label never judged it: bd blocked and
GET /v0/beads/blocked listed it whatever its labels, on every route.
Both decorators now filter those rows by the request's labels. The uow
decorator reads them through GetMany, chunked at MaxGetManyIDs, so their
labels are hydrated; GetIssuesByIDs left them empty, which also printed
them unlabelled on the proxied route.
Review fixes (adopt-pr apply-fixes, iteration 1):
- major #1: label filters on external-only rows in the store and uow
decorators, with absence-asserting arms in the unit, served httpclient
(server- and client-enforced policy), e2e and proxied tiers; the spec
and the role doc say such rows are narrowed like every other row.
- minor #2: the policy.external_dependencies token prose names the
blocked listing (spec, routes.go, regenerated types.gen.go).
- minor #6: SERVE_RUNBOOK and the allowUnlimited comment record the
blocked listing's unbounded whole-set answer and why.
- minor #10: BlockedLister telemetry-outermost and typed-unsupported pins
beside the ReadyCounter pair, plus the externaldeps wrap pin.
- nit #9: F-blocked names --flags --raw's refusal against a server that
applies the policy (ledger.go and the regenerated ledger doc).
- nit #11: the remote BlockedLister no longer builds a local lister it
then discards.
Review fixes (adopt-pr apply-fixes, iteration 2; the review approved at
940 with one minor and two nits, none gating):
- minor (the --flags refusal list was unpinned): the new
TestBlockedFlagsRefusesEveryListingFilter pins blockedFlagFilterFlags
to the flags blockedCmd registers, in both directions. Every
registered flag except --flags and --raw must be refused, and every
entry must name a registered flag. The test walks Flags() rather than
LocalFlags(), so it does not merge the root's persistent flags into
blockedCmd, and it skips inherited root flags and cobra's --help.
Mutants:
- four fail it: a new filter flag left off the list, a dropped
entry, a misspelled entry, and --raw added to the list;
- a simulated earlier in-process run (merged root flags plus --help)
stays green, and fails once either skip is removed.
- nit (the remote branch's span): the remote BlockedLister comment now
says why that lister is not wrapped again. The inner lister already
carries telemetry's span, so wrapping would nest a second span of the
same name. The comment also says what runs outside that span.
- nit (duplicated order comparator): left as is. finishBlockedIssues
predates this PR, so merging the two sorts would refactor existing
code with no review pass left after this one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* feat(list): bd list's remaining filters over http behind issues.list.filters
Over http every `bd list` filter beyond the created bounds and the title,
id and no-assignee scope refused (time bounds, priority range, text and external-ref
matches, spec, label pattern/regex, exclude-type, no-parent, no-labels,
empty-description, pinned/no-pinned, deferred, overdue, mol/wisp type).
The library entry already applied all of them: issueops.Reader.List via
workapi.BuildListFilter, shared by the CLI and the handler. This adds
only the wire.
- Server: GET /v0/beads/issues decodes 29 new optional parameters
(listFilterParams, decode only; countIssues' names where it already
spells the filter) into the existing ListRequest, behind one new
behavior token, issues.list.filters. mol_type/wisp_type are closed
enums refused by name (an empty value too). wire_revision stays 2;
apigen and the wireshape golden are regenerated (additive only).
- Every RFC 3339 bound the listing and count decode is normalized to UTC,
so an offset-bearing bound selects what its Z twin does on a zone-less
timestamp column.
- workapi.BuildListFilter refuses PinnedFlag with NoPinnedFlag
(ErrValidation, the CLI's own sentence) instead of letting PinnedFlag
win; over http that is a 400 on no_pinned.
- Client: the encoder sends the members (encode.ListFiltersMembers, one
list read by the encoder, the pre-dial gate and a spec-parity test).
Against a server not advertising the token, httpReader.List refuses
before dialing with ErrUnsupported naming issues.list.filters. The 29
E-ListRequest ledger refusal rows retire; the ledger doc is updated;
skew flag mappings added.
- Tests: handler decode/parity/enum/UTC/malformed/pinned-pair tests;
encode member/gate/spec parity and bound encoding; per-member
ride-behind-token and pre-dial skew refusal; two new Reader contract
cases on every leg (dolt, embedded, uow, served): the eight time
bounds at exact boundaries (strict, whole-second truncation, NULL never
matches, +02:00 equals UTC) and one in/out row per remaining family;
three served Reader cases unparked; TestE2E_ListFilterParityOverHTTP
(served == embedded, masked server refuses naming the token, no dial);
five corpus shapes marked pending until the reference server profile
advertises the token.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(list): exclude_status on listIssues, the 30th issues.list.filters member
issueops.ListRequest gains ExcludeStatus: statuses to leave out of a
listing, appended to the default exclusions (never re-admitting what they
hide), comma-separated or repeated, and validated against the workspace's
statuses by the same rule CountRequest.ExcludeStatus uses (an unknown name
is ErrValidation). The rule moves into one shared function,
workapi.ParseExcludeStatus, called by both builders. With AllFlag it reads
the active set without enumerating every status, so an http-backed caller
can list O(active) rows instead of the whole history.
- Server: listIssues decodes a repeatable `exclude_status` under the same
issues.list.filters token (no new token); an unknown name is a 400 on
exclude_status. apigen and the wireshape golden are regenerated
(additive).
- Client: the encoder sends it and it joins encode.ListFiltersMembers, so
the pre-dial gate asks for the token.
- It is refused together with ReadyFlag, like the other members the ready
query cannot carry.
- No `bd list --exclude-status` flag yet (it would need the CLI docs
regenerated); the member is reachable through the library and the wire.
Tests: builder unit test (append, AllFlag, comma split, unknown name);
handler decode and 400; encoder, round-trip and gate; Reader contract
cases on every leg (active set under AllFlag, repeated and comma values,
adds to the defaults, narrows an explicit Status, unknown name refused).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(list): label_regex compile errors are 400s; review polish for list filters
- An invalid `label_regex` on GET /v0/beads/issues, /v0/beads/ready and
/v0/beads/ready:count is now `400 invalid_argument` (`invalid_value` on
`label_regex`) instead of `500 internal`. The database still compiles
the pattern in its own dialect; a request that sent a regex and earned
the engine's "regular expression is invalid" refusal is attributed to
the parameter (failRegexReadErr). The same text on a request with no
regex stays a server fault.
- mol_type and wisp_type refuse each other's vocabulary (tests pin
`mol_type=heartbeat` and `wisp_type=swarm`), so the call-site
allowlist, not just the spec enum, is covered.
- exclude_status with a workspace custom status: leg tests on the
embedded store and over the served wire (accepted and applied; a name in
no vocabulary refused). ReaderFixture cannot configure custom statuses,
so these sit beside the count's twin rather than in the contract.
- The search e2e gains a positive arm: --desc-contains returns exactly the
row whose description carries the token.
- Docs: `all` plus `exclude_status` keeps every status not named (pinned,
hooked and custom done/frozen included unless named), not "the active
set"; label_regex documents its 400. A corpus source line is made
neutral; a test message says 30.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(list): compose issues.list.filters with the --title-contains fold
#7631, now on main, folds `bd list --title-contains` onto listIssues
`title` and refuses the TitleContains left over from a --title and
--title-contains pair that differs, because the listing then had one
title parameter. This branch publishes `title_contains` behind
issues.list.filters, so that leftover now rides it beside `title` and
the server applies both. Neither half is dropped, and against a server
without the token the pre-dial gate refuses, naming issues.list.filters.
- encode.FoldTitleContains still runs first; its doc now says where a
differing pair goes.
- Tests: the fold table expects `title` plus `title_contains` for a
differing pair, including the ſ/s pair strings.EqualFold would match;
the differing-pair refusal names issues.list.filters; the
list_filters_test sweep pairs its TitleContains probe with a differing
TitleSearch, since a lone one asks only for issues.list.title; the e2e
differing-pair refusal becomes a listFilterShapes row that answers
exactly child-a over http and embedded, and refuses before dialing
without the token.
- The gc-polecat-closed-after corpus shape's pending reason also names
issues.list.title. The CHANGELOG --title-contains entry no longer
lists the differing pair and --closed-after as refused.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.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/39013611268
(`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(list): serve --priority-max in search parity, refuse the parent pair
The proxied tier's search parity table still expected a remote
`bd search --priority-max 1` to refuse, because listIssues could not
carry it. This branch serves priority_max behind issues.list.filters,
so the remote route answered and the dolt-race shard went red in
TestProxiedServerSearchRoutesAgree. The row now expects the answer on
every route. It was the last wireCan=false row; the branch stays, with
a comment, for the next flag listIssues cannot carry.
- ParentID with NoParent: a served listing now carries no_parent beside
parent, and ANDing the two answered only the edge-less rows under the
parent's dotted id. BuildListFilter refuses the pair with
ErrValidation, in the sentence bd list and BuildCountFilter already
use, so issueops.Reader.List refuses it on every backend and the
listing answers 400 on no_parent. Pinned by a builder test, a reader
conformance case (dolt, embedded, uow, served http) and two httpapi
tests.
- POST /v0/beads/issues:claimNext shares the ready listing's
label_regex but answered a pattern the database cannot compile with
500. It now gives the listing's 400 invalid_value on label_regex,
through the helper the listing's mapping is split into.
- The descendant walk's ledger rows said listIssues publishes no
parameter for members it now serves behind issues.list.filters. They
now say the walk does not send them yet, and that --flat or --json
asks listIssues directly. The ExcludeStatus, Pinned and ExcludeTypes
rows, the parentwalk.go header, the walk table's doc and two walk test
comments are corrected the same way, and the ledger doc is
regenerated. parentWalkRefusals notes that a member moved off the list
must check issues.list.filters itself, because the walk dials past
the listing's pre-dial gate.
- Spec: the listing's no_parent documents the pair's 400, the count's
exclude_status no longer says it has no listing counterpart, and
claimNext's label_regex documents its 400. types.gen.go is
regenerated. Comment-only: countFilters, and readyScopeFields'
ExcludeStatus entry.
- CHANGELOG and README say the default `bd list --parent` tree view
does not carry the new filters yet; the label_regex entry names
claimNext, and a Changed entry records the parent-pair refusal.
Second review pass: docs and comments only, no behavior change.
- The prose copies of the issues.list.filters member set now match
ListFiltersMembers: CapIssuesListFilters and wire.CapListFilters name
the status exclusion, and the spec's capabilities text names
label-regex.
- Every time bound on the listing and the count goes through
q.timestamp, which normalizes it to UTC, and sqlbuild compares it
strictly at whole-second precision. listIssues' created_before and
created_after, and countIssues' created, updated and closed bounds,
now say so in the words the new listing bounds use. The count's
updated bounds also say what they filter, and its closed bounds say
that a NULL closed_at never matches. types.gen.go is regenerated.
- README and CHANGELOG: `--flat` or `--json` applies the filters to the
parent's direct children, not its whole subtree.
- The 29 listRefusal rows this branch serves stay deleted rather than
kept as retired rows, as #7550 deleted its TitleSearch, IDFilter and
NoAssignee rows when it served them. The CHANGELOG now says the rows
are removed, not retired.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix(gate): add-waiter retries contention the store gave up replaying
bd gate add-waiter writes the whole waiter list guarded by the version it
read and retried only ErrVersionMismatch. A convoy adder therefore failed
when its write ended in contention the backend stopped replaying: a
serialization failure or deadlock (Dolt/MySQL 1213/1205, Postgres
40001/40P01, uow.IsSerializationError) on a direct route, or a 503 busy
(wire.ErrBusy) over HTTP, which bd serve sends when its admission limiter
refuses or its transaction retry budget is spent.
gateAddWaiterLostRound now retries those like a version miss, under the
same jittered backoff and 20-write bound, and a busy answer's Retry-After
raises that round's wait, capped at 2s (gateAddWaiterRetryWait).
The retry is safe because of how a round is built, not because a 503 means
nothing was written: the client maps any 503 to wire.ErrBusy, and a gateway
can answer 503 after the write committed. Each round re-reads the gate,
deduplicates and writes the whole list guarded by the version it read, so a
landed write is found on the re-read (the waiter is never added twice) and a
stale list never overwrites a newer one. A server fault (500, e.g. an
indeterminate commit) and an unreachable database are still returned at
once.
TestAddGateWaiterRetriesTransientContention pins the three retried
spellings, the bound, busy-after-commit (one write, the waiter once), the
500 / db-unavailable / other-SQLSTATE non-retries, and the capped
Retry-After. It is red without the fix.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(gate): bound add-waiter's contention retries and honor Retry-After
Review fixups for #7648.
- A write lost to contention reaches addGateWaiter only after the store or
bd serve has spent a whole replay budget on it (withRetryTx: 5s, 15s in
server mode; bd serve's: 15s), so retrying it under the 20-write bound a
version miss gets could hold an adder for minutes (about five on the
direct server-mode route). Contended writes now get their own bound,
gateAddWaiterContentionRetries = 2, like the HTTP client's for a busy
read. They still count against gateAddWaiterMaxAttempts, and version
misses keep the 20. The const doc states the worst case: three 15s
budgets and two 5s waits, about a minute.
- A busy answer's Retry-After is waited out as sent, plus the jittered
backoff, instead of being capped at 2s. bd serve asks for 5s after a
spent budget because a convoy back sooner holds slots and starves reads,
and the wire client already bounds the header. The jitter keeps adders
answered busy together from retrying together.
- When the last write the bounds allow is answered busy, one more read
checks the gate before the command fails, with no wait first. A 503 (a
gateway's, say) can answer a write that committed, and every earlier
round's re-read would have found it; the last write has no round left.
A waiter found there is reported as already registered, and a read that
fails confirms nothing.
- The exhaustion error says "changed on every one of N attempts" only when
no write was contended. Otherwise it reads "no write to X was confirmed
in N attempts (K answered busy or lost to write contention)": it names
the contention, so the operator of a busy server is not sent looking for
a concurrent writer, and it does not claim that nothing landed.
- gateAddWaiterContended names what maps to each class: Dolt/MySQL
1213/1205 and SQLSTATE 40001/40P01 on the direct route, and wire.ErrBusy
from bd serve's busy answer or from a 503 with no code or an unknown one
(db_unavailable and events_watch_saturated map to their own sentinels).
It also says why Dolt's 1105 "@autocommit transaction rolled back" is
not admitted: Dolt raises it for conflicts that a merge inside the
transaction left behind, while a write lost to a concurrent writer comes
back as 1213.
- Tests: 1213 and 1205 rows built as *mysql.MySQLError (the default Dolt
route's shape), the contention bound for busy and for 1213 with no wait
after the last contended write, version misses not spending it, the
three exhaustion wordings, a 5s Retry-After waited whole plus the
jitter, a busy answer to the last write at either bound that landed and
is found by the extra read, and a failed extra read that confirms
nothing. Thirteen mutants each fail at least one subtest: no bound, busy
only counted, version misses counted, no jitter, the 2s cap, the old
wording, an off-by-one bound, no extra read, an extra read that ignores
the waiter, one that takes a failed read as landed, a wait before it, a
wait at the end of each round, and the bound checked after the wait.
- CHANGELOG entry updated to match.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* fix(http): serve bd list --title-contains by folding it onto title
`bd list --title-contains X` refused against an HTTP workspace because
listIssues publishes no title_contains parameter. The store compiles
TitleContains and TitleSearch to the same predicate (LOWER(title) LIKE
'%v%'), so the client now folds TitleContains onto TitleSearch before the
pre-dial gate (encode.FoldTitleContains) when TitleSearch is empty or equal.
The request then rides the existing `title` parameter behind
issues.list.title, and against a server without that token it refuses before
dialing, naming the token. A --title and --title-contains that differ still
refuse: the listing has one title parameter and dropping either value would
widen the answer.
No wire change. The ledger row E-ListRequest.TitleContains narrows to the
differing pair.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(http): fold case-only title pairs and qualify the CHANGELOG
Review fixups for #7631.
- FoldTitleContains also folds a pair that differs only in letter case.
The store binds each value as '%' + strings.ToLower(v) + '%', so a pair
equal under strings.ToLower is one predicate. It does not use
strings.EqualFold, which matches pairs such as "ſ" and "s" that lower to
different patterns. Unit cases pin both directions, and the served test
answers a case-only pair like the single flags.
- CHANGELOG: name what still refuses over HTTP: a pair that differs other
than in case, either flag with --parent in the default tree view, and
--closed-after, which gascity's polecat pre-flight lookup of recently
closed beads (step 3d) uses.
- Corpus: add gc-polecat-title-contains-closed-after, the 3d lookup,
pending until the reference server advertises issues.list.title and
listIssues carries closed_after (E-ListRequest.ClosedAfter).
- Drop two assertions that could not fail (a request passed by value
cannot be mutated), and bring the e2e shape header, the
tokenedListFilters comment, the encoder table comment and the
E-ListRequest.TitleContains ledger row (doc regenerated) up to date.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* fix(http): gate create, add-waiter and discover through the library roles
bd gate create, bd gate add-waiter and bd gate discover wrote through the
legacy CreateIssue, AddDependency and map-based UpdateIssue, which the http
store does not implement, so over a connected HTTP workspace each failed
before any gate member reached the wire. They now run through the roles on
every route (direct, proxied server, http):
- gate create is ONE Lifecycle.Create carrying the gate members and a
reverse blocks edge from the blocked issue to the new gate: atomic on
every route, one createIssue over http behind issues.create.gates. The
proxied-server route's private unit of work is gone; it uses the same
role.
- gate add-waiter reads through Reader.Get, deduplicates, and writes the
whole waiter list through Lifecycle.Update guarded by the row version it
read, retrying up to three times on ErrVersionMismatch, so concurrent
adders cannot lose each other's waiter. Over http: issues.update.gates.
- gate discover lists through issueops.ListGates and records the run ID
through the same Lifecycle await_id patch gate check makes; bd close's
gh:run persist (updateGateAwaitID) takes the same path.
- Against a server without the token, each refuses before any write,
naming the token.
- gate discover skips template gates, as gate check already does, instead
of recording a run ID on a proto every later pour copies.
Tests: unit tests for the one-Create shape, the refusal, the add-waiter CAS
retry, and discover over ListGates with its template skip;
backend/http TestE2E_GatesOverHTTP (advertised and masked); four served
corpus shapes, pending until the reference server advertises the gate
tokens (verified to pass against a profile that does). CHANGELOG.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(gate): add-waiter backs off under contention; discover fails on a failed write
Review follow-ups to the gate CLI port.
- gate add-waiter's guarded write retried three times with no wait, so a
convoy of workers registering on one gate at once failed all but a few
(the proxied route's old unit of work had served them all). Each retry
now waits a jittered, doubling backoff (10 ms to 400 ms, drawn from
[d/2, d)), for at most 20 writes. The bound is attempts, not wall time:
under a loaded server one round takes seconds, and a wall-clock budget
failed the convoy after two or three rounds. A cancelled wait stops the
loop. TestProxiedServerGateAddWaiterConvoy (direct SQL and
proxied, real Dolt server) and TestE2E_GatesOverHTTP's concurrent case
run 11 simultaneous adders (one duplicate): all exit 0, every waiter
present once.
- gate discover counts only the gates whose run ID was recorded and exits
non-zero when any matched gate's write failed; it used to print the
refused gate as updated and exit 0. TestE2E_GatesOverHTTP covers
discover with and without issues.update.gates (fake gh).
- TestServedGateCheckOverAwaitTypedGates masks issues.update.gates itself,
so upgrading reference_server.json does not turn its gh:run case into a
different test.
- The discover listing test asserts closed gates are not listed.
- CHANGELOG: discover's template skip and add-waiter's template refusal
are behavior changes on the local routes; gate create refuses
a negative --timeout; gate create/add-waiter follow dolt.auto-commit and
use the role's commit messages; the proxied create no longer journals
dependency_added.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(import): tolerate only typed dependency refusals, not walk-query errors
With SkipDependencyValidationErrors set (the import mode), the dependency
pass recorded ANY error from checkHierarchy/checkCycle as a skipped edge
and continued. That included failed walk queries (an untranslated
statement, a statement timeout, a dropped connection), so an import could
commit without the edge and report the SQL error only as a skip reason;
on a backend whose transaction aborts on a failed statement, the import
failed later at an unrelated statement with the real cause hidden.
Tolerate only the typed refusals (ErrSelfDependency, ErrDependencyCycle,
*DependencyHierarchyConflictError) via isDependencyValidationRefusal and
return every other error, keeping the %w chain so serialization retry and
error classification apply.
Tests: sqlmock cases where the hierarchy and cycle walks fail under import
mode, on both the per-edge statements and the batch graph, must abort the
pass; typed refusals on both shapes are still skipped. Removing the
predicate fails both error tests.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(import): record the dependency-check fix in the CHANGELOG; tidy two test comments
Review fixups for #7630.
- CHANGELOG (Unreleased, Fixed): bd import now fails when a dependency
check's own query fails, instead of reporting the SQL error as a skipped
dependency and, on Dolt, committing without the edge. Refused edges (a
self-dependency, a cycle, a hierarchy conflict) are still skipped. docs/
is left alone because it tracks the pinned release (v1.2.2).
- create_test.go: two doc comments kept the line breaks left where the
internal tracker IDs were removed. They are reflowed into sentences; no
test logic changes.
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>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(roles): issueops.Heartbeater role on the dolt, embedded and uow legs
Adds issueops.Heartbeater.Heartbeat(HeartbeatRequest{Actor, IssueID}) ->
HeartbeatResult{IssueID, Holder, HeartbeatAt, LeaseExpiresAt, Rearmed},
the lease refresh behind `bd heartbeat`, as its own role with its own
accessor.
- One body: internal/storage/issueops.ExecuteHeartbeatInTx validates
(*HeartbeatFieldError for a blank/over-long actor or empty id), refuses
a wisp, then runs RenewLeaseInTx, which is HeartbeatIssueInTx's body
reporting the renewal. HeartbeatIssueInTx is now a wrapper, so the legacy
HeartbeatIssue legs answer the same text and sentinels.
- The refresh is fenced on the holder AND on the live claim: after the
holder-fenced UPDATE, a read in the same transaction requires the issue
to be in_progress under the holder (the `update leases set` prefix and
the one IF() the Postgres dialect rewrites are unchanged; a Postgres port
should expect more serialization retries from that read). A refusal deletes the caller's orphaned lease
row, and the legs commit that refusal.
- A refresh writes only the lease row: no row_lock, version, updated_at,
event, journal entry, Dolt commit or hook. A re-arm (a live hand-doled
claim with no lease row the caller holds) is recorded as a mutation:
row_lock reminted, updated_at stamped, a lease_rearmed event, a journal
entry, a version, a Dolt commit (LeaseRearmVersionCommit) and on_update.
The remint makes a re-arm collide with a racing release or close instead
of leaving an orphaned lease on an open or closed issue (a pre-existing
race on every Dolt route). Rearmed is true only when a row was created:
a same-second refresh (0 changed rows on embedded Dolt) or a holder
spelled differently refreshes the existing row in place and keeps its
granted_at/granted_node. Reported times are rounded to whole seconds,
the stored values; the binds stay unrounded so a same-second refresh is
never a 0-row UPDATE on Dolt.
- Typed refusals: an absent id is ErrNotFound; a foreign holder is
*LeaseConflictError{Holder} wrapping ErrAlreadyClaimed; a wisp
(Ephemeral) or no live claim is *LeaseConflictError wrapping the new
ErrLeaseNotHeld, which also matches ErrNotClaimable.
- Legs: DoltStore and EmbeddedDoltStore through the issue-operation
funnel (DOLT_ADD of the named tables, then DOLT_COMMIT -m, after the SQL
commit); uow.NewHeartbeater through the new uow.RunTxScoped: a refresh or
a refusal commits with the plain SQL COMMIT (no working-set scan, no Dolt
commit, nothing another writer left uncommitted is swept), and a re-arm
commits through the new ScopedCommitter (DOLT_ADD of exactly its tables,
DOLT_COMMIT -m, never -Am). The legacy HeartbeatIssue doors commit a
re-arm the same way and keep a refusal's orphan delete, and the
proxied-server `bd heartbeat` route runs the role's body with the same
scoped commit.
- Census: storage.Storage gains Heartbeater(); HookFiringStore wraps it
(fires on_update for a re-arm only, RoleFiresHooks knows it), telemetry
wraps it, httpapi.timedProvider, uow.notifyingProvider (records a re-arm)
and externaldeps.uowProvider build it; the journal and version guards
list the heartbeat family as entry points; the httpclient unsupported
shell is regenerated and Heartbeater sits on its unsupported allowlist
until the wire lands.
Conformance: RunHeartbeater* (18 cases) on dolt, embedded dolt and uow:
refresh post-state with the stored times pinned to the result; no
row_lock/current_revision/updated_at/events/journal/issue_versions/
version-control/hook change; a guarded write with the pre-heartbeat
revision still lands; foreign holder refused against an aged lease;
refused after close/release/reclaim/status move; wisp refused; hand-doled
claim re-armed as a mutation; same-second heartbeat is not a re-arm;
orphaned leases on released, closed and reassigned issues refused and
deleted; a refresh and a refusal against a dirty working set make no
commit and leave the other writer's change uncommitted, and a re-arm
commits only its own tables; absent id; request rules; no request mutation. The http leg is
waived until the wire lands.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(httpapi): POST /v0/beads/issues/{id}:heartbeat behind issues.heartbeat
Publishes issueops.Heartbeater on bd serve as heartbeatIssue, the served
lease refresh behind `bd heartbeat`.
- Spec: the operation, HeartbeatIssueRequest {actor} and
HeartbeatIssueResponse {id, holder, heartbeat_at, lease_expires_at,
rearmed}; no `revision` (a refresh writes nothing to the row) and no
expected_version (the fence is the holder and the live claim).
issues.heartbeat joins the capability vocabulary and lease_not_held
(409) the Problem.code list; `reason: ephemeral` qualifies it for a
wisp. apigen and the wire-shape golden are regenerated; the golden diff
is additive only, so wire_revision stays 2.
- Server: route row on the custom-method dispatcher, handleHeartbeat in
heartbeat.go (claim's actor rules via bodyActor, unknown member and
query refusals), Config.Heartbeater as a required role (sourceRoles,
roleSourceNames, the per-request uow.HeartbeaterSource accessor).
failHeartbeat maps *LeaseConflictError typed fields: a foreign holder
is the claim's conflict shape (already_claimed + assignee +
issue_status); no live claim, a wisp included, is the new
lease_not_held (+ issue_status, + reason: ephemeral for a wisp), matched
before the generic arms so ErrLeaseNotHeld's ErrNotClaimable never
surfaces as not_claimable. Its detail names the one state the refusing
transaction found (closed, open and not claimed, an ephemeral wisp, ...).
- bd serve wires the role from its peeled store (serveRoleSource gains
Heartbeater); the serve stub stores, the corpus and e2e harnesses, the
served harness and the encode oracle bind it.
- Wire client vocabulary: OpHeartbeatIssue/issues.heartbeat and
MethodHeartbeat are CLASSIFIED (the capability set-equality gate),
ReasonEphemeral is pinned to the server's, and lease_not_held rebuilds
*LeaseConflictError{Status, Ephemeral} wrapping ErrLeaseNotHeld in the
native words (the code-table set-equality gate). No accessor yet.
Tests: heartbeat_test.go (request mapping and projection, edge refusals,
every role refusal with its code, members and state-specific detail, the
code row, the capability). The served-http Heartbeater leg
(served_heartbeater_test.go, 18 cases) runs the contract against a real
bd serve through a test-local dial over the store's own dispatch, and the
http-leg waivers are deleted.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(http): bd heartbeat over http through httpclient.Heartbeater
The client leg of the served lease refresh, and `bd heartbeat` on the
role for every route.
- httpclient.Store.Heartbeater (heartbeater.go) dials POST
/v0/beads/issues/{id}:heartbeat through Store.dispatch, so
issues.heartbeat is preflighted: an older server is refused BEFORE the
dial with *wire.CapabilityError naming the token (unwraps to
*storage.ErrUnsupported{Capability: "issues.heartbeat"}); it never falls
back to a re-claim or a metadata stamp.
- The role's request rules are restated before the dial
(validateHeartbeatRequest, pinned to
storeops.ValidateHeartbeatRequest): blank/over-long actor, empty id, each
a *HeartbeatFieldError.
- Problem mapping: already_claimed (which the shared table rebuilds as the
claim's ClaimConflictError) becomes *issueops.LeaseConflictError naming
the holder and wrapping ErrAlreadyClaimed, in the native words ("issue
already claimed by <holder>"); lease_not_held already arrives as
LeaseConflictError (Ephemeral from `reason`); not_found is ErrNotFound;
invalid_argument on `actor` is the role's field error.
- Idempotent: true, the one write this client marks replayable (a repeat
only moves the expiry later; a replay after a reclaim fails the fence).
- Legacy Store.HeartbeatIssue rides the role. Both leave the generated
shell and completeness_test's unsupported allowlist.
- `bd heartbeat` takes Heartbeater() from the resolved store on the direct
routes (dolt, embedded, http) and from the provider's HeartbeaterSource
on the proxied route (exact id resolution in a read unit of work, then
the role); runHeartbeatProxiedServer and heartbeat_proxied_server.go are
deleted. Success output and exit codes are unchanged; refusal text
changes per route (see CHANGELOG).
Tests: heartbeater_test.go (stub server: preflight refusal naming the
token with no POST, request/answer projection, each refusal's typed
mapping including the wisp's reason, the 503 replay, pre-dial validation,
validator parity, the legacy door). served_heartbeater_test.go runs the
18-case contract through env.subject.Heartbeater(), with
HookedHeartbeater wired off a HookFiringStore. TestE2E_HeartbeatOverHTTP:
real bd against an in-process serve: holder ok with revision and
updated_at unchanged and a guarded write with the pre-heartbeat revision
landing; a non-holder refused against an aged lease that stays untouched;
closed, wisp and unclaimed refused, each naming its own state; an older
server's handshake refused naming issues.heartbeat with no write. Corpus
shapes gc-heartbeat, -non-holder, -closed, -wisp pending until
reference_server.json advertises the token. CHANGELOG entry for the whole
track, including the orphaned-lease race fix.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* build(bazel): auto-sync BUILD files
Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/38875641041
(`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(heartbeat): roll back a no-issue refusal; restate refresh vs re-arm
Review fixes for #7600 (adopt-pr apply-fixes, iterations 1-2).
Legacy HeartbeatIssue doors commit a refusal only when it read the issue.
The dolt and embedded HeartbeatIssue callbacks committed every
LeaseRenewalRefusal, including Found=false (the issue read failed). That
refusal deletes nothing, but it can follow a fast-path UPDATE that
already extended an orphan lease row's expiry, so committing it kept the
extension. issueops.LeaseRenewalRefusalCommits now gates the commit on
Found, the rule the Heartbeater role's HeartbeatRefusalCommits applies.
New tests on both legs pin both arms: a no-issue orphan's expiry is
unchanged, and a released issue's orphan is deleted.
Refresh vs re-arm contract docs. Comments, Long help, the OpenAPI spec
and the generated apigen still said every heartbeat writes only the
lease row, makes no Dolt commit and fires no hook. A re-arm is recorded
as a mutation: it remints the revision, records an event and a version
entry, commits once (LeaseRearmVersionCommit) and fires on_update
through the wrapping hook decorator. Restated in domain, uow, issueops,
storage.go (why RoleFiresHooks answers true, so bd serve takes the
heartbeater off a peeled store), cmd/bd heartbeat and serve, httpapi,
httpclient, the spec (apigen regenerated), and the conformance and
contract-test docs.
Minor review findings:
- The 409 already_claimed and lease_not_held details now end "nothing
on the issue was written": the refusal may have deleted and committed
the caller's orphan lease row.
- docs/multi-agent/federation.md and the CHANGELOG entry describe the
spelling-mismatch heartbeat: the row is refreshed in place and keeps
granted_at and granted_node; only a re-arm stamps this node. The
embedded spelling test pins both columns, and the lease.go comments
say "refreshed in place" instead of "re-arms".
- The refusal's orphan delete judges the holder under actorMatches, as
the in-place refresh does (iteration 2). It matched holder = ? on the
actor as sent, so a dead claim's orphan held under another spelling
of the caller (gastown.mayor, heartbeat as gastown__mayor) survived
the refusal until TTL. The refused closure now reads the row's holder
and deletes that stored holder only when actorMatches(holder, actor).
Both TestHeartbeatIssueCommitsARefusalOnlyWhenItReadTheIssue twins
gain a cross-spelling arm (row deleted) and a control: another
identity's row (gastown.dog-3) survives.
Not changed: `bd heartbeat --json` still omits `rearmed`, since adding
it changes a CLI JSON contract (follow-up). The federation.md paragraph
post-dates the v1.2.2 docs pin, so documenting this main-only behaviour
there is a maintainer call under
engdocs/decisions/2026-07-17-docs-release-pin.md section 1.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(uow): run the scoped re-arm's Dolt commit after the SQL commit
The proxied-server heartbeat commits a re-arm with doltServerTx.CommitScoped,
which ran DOLT_ADD per table and DOLT_COMMIT('-m') INSIDE the open
transaction, before the SQL COMMIT. DOLT_ADD stages whole tables from the
session's transaction root, so that Dolt commit was built from the re-arm's
start snapshot: an issues row another session changed while the re-arm was
open (a write still only in the working set, as in batch mode or before that
writer's own Dolt commit) was staged at its old value, and HEAD disagreed
with the rows every reader sees. This is the LatentLabsSpace/NEXUS#92
ordering the DoltStore funnel (runIssueOperationTxWithMessage) already
avoids, and the review's major finding on this PR.
CommitScoped now commits the SQL transaction first, then stages exactly the
named tables (plus the versioned-history tables) and makes the Dolt commit on
the same pinned connection, the uow twin of doltAddAndCommitPostTx:
- a serialization failure of the SQL COMMIT is still returned, so
RunTxScoped replays the unit of work;
- the Dolt commit runs detached on its own budget and replays only conflicts
that leave nothing behind: serialization failures and Dolt's 1105
"@autocommit transaction rolled back" (new isDoltAutocommitRollbackError,
mirroring the DoltStore classifier of the same name);
- nothing staged, or "nothing to commit", is not an error: a concurrent
writer's Dolt commit already took the row. A "nothing to commit" past the
staged check is logged, as the funnel logs it, so the missing audit line
is explicable;
- any other failure is logged, never returned. The data is committed, and
returning it would make RunTxScoped replay a committed re-arm, which would
then report a refresh. The session is poisoned rather than pooled, since
its state is unknown. uow records no metrics, so that log line is the
drop's only signal; bd.db.post_tx_commit_dropped counts only the funnel's.
Statements go through schema.DrainCall, retiring the local drainCall fork
(review nit).
Tests: five sqlmock tests pin the order (SQL COMMIT before any DOLT_ADD),
the swallow-and-poison path, the 1105 retry, the returned serialization
failure and the empty-commit tolerance; each fails against the previous
CommitScoped. TestIsDoltAutocommitRollbackError carries the DoltStore
classifier's table over to the uow copy, plus the prefix boundary; dropping
the prefix branch, the prefix's period, the 1105 check or the type check
each fails a case. TestHeartbeaterRearmKeepsAConcurrentWrite is the
real-Dolt regression: a change to another issues row made while the
re-arm's transaction is open must be at HEAD after the re-arm's Dolt
commit. Its working-set-only writer fails on the old ordering (dolt
2.1.8); the writer that Dolt-commits its own change passes on both and is
kept as coverage.
Review follow-ups folded in (comments, a file move and a test; the
absorption log line above is the only behaviour change among them):
- the freshRowLock invariant and its row_lock_guard_test.go mirror name the
re-arm as the one deliberate remint without a lifecycle-field change,
load-bearing for the release/close collision;
- httpclient: "a write is never retried" (wire/client.go, stall_retry.go)
and "only a read's answer is yes" (dispatch.go) now allow for the
Idempotent heartbeat, and httpHeartbeater and issueops.HeartbeatResult
document that a replayed heartbeat can report Rearmed false after a
committed re-arm, with the guarded write's revision check as the backstop;
- the proxied route moves back to cmd/bd/heartbeat_proxied_server.go, the
file family cmd/bd/AGENTS.md prescribes;
- the ScopedCommitter and RunTxScoped docs no longer say every other
writer's uncommitted change stays out of the commit: a staged table is
committed whole, so such a change to a named table rides in the re-arm's
commit, as it does in the funnel, and only other tables keep theirs;
- commitStagedTables says its drop is log-only, the absorption is logged,
and the uow classifier gets its table test (see Tests).
Not folded in: the base-owned IssueUseCase.Heartbeat /
IssueSQLRepository.HeartbeatIssue door, dead in production since the
proxied route moved to the Heartbeater role. Its one caller is the
notifying hook-parity test (uow/notifying_test.go), and moving that case
onto the Heartbeater means re-deriving its RenewLease hook semantics, so it
is left for a follow-up.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* fix(mol): route bond operand resolution like show/update/close (closes#4714)
bd mol bond resolved operands with utils.ResolvePartialID against the local
store only, so a bead that lived in a routed store failed with
"'<id>' not found (not an issue ID or formula name)" — even though bd show
resolved the same ID. This broke `gt sling <bead> <rig>`, which cooks the
default formula and bonds it to a rig-routed bead.
- Resolve operands through resolveAndGetIssueForMutation, the same routing
fallback bd show/update/close use (local, then prefix-routed rig via
routes.jsonl, then contributor auto-routing). Write-intent so a prefix-routed
target opens writable and the bond commits where the bead lives.
- Run the bond mutation against the store that owns the resolved issue instead
of the global local store; reject a bond whose two operands resolve to
different stores rather than writing to the wrong database.
- Route the --dry-run preview read-only so it previews routed operands too.
- Add TestResolveMolBondOperandRouting covering local and routed resolution.
Same routing-parity fix as #3608/#3609 for bd close.
* fix(mol): fail fast on read-only routed stores, share same-rig bond handles
Address the two structural issues from the #4720 review beyond the rebase
itself (the rebase already preserves main's unconditional formula fallback
from #3874 instead of reintroducing the looksLikeFormulaName gate):
- Routed operands resolve but couldn't be bonded: contributor auto-routing
deliberately opens stores read-only (they hydrate foreign projects that
must never be mutated), yet the bond selected that store and dispatched
mutations that only failed at the store layer. Operand resolution now
mirrors resolveCloseTargets explicitly (local, then prefix-routed
write-intent, then the shared auto-routed read-only handle) and records
writability per operand; pickBondStore rejects a bond pinned to a
read-only store with a clear message before any mutation is attempted.
TestMolBondPrefixRoutedWriteThrough now verifies the actual dependency
write commits in the routed database, not just resolution, and
TestMolBondAutoRoutedReadOnlyFailsFast covers the fail-fast path.
- Same routed database compared as two different stores: pickBondStore
compared Go handle identity, but each route-open constructs a fresh store
in server mode, so two operands in the same routed rig were wrongly
rejected as cross-store. Both operands of a bond now share one routed
handle (an already-opened routed store is tried before opening another),
and sameBondStore falls back to StoreLocator identity (CLIDir pins the
concrete database) for separately-opened handles onto the same database.
TestSameBondStoreSeparateHandles covers the two-handle case directly.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mol): validate routed bond homes before mutation
Discover bond operands read-only, enforce dry-run parity and cross-store policy before writable reopen, unwrap decorated store identities, preserve actionable route failures, and verify the accepted home after reopen.
Co-authored-by: Johan Snyman <johan.snyman@orange.com>
Agent-Signature: codex-gpt-5.6-sol-high on behalf of matt wilkie
* fix(mol): reconcile routed bond discovery with #5253 var validation
The rebase onto current main carried two silent regressions the Aug 16
review named: the discovery-based resolution (which replaced
resolveOrDescribe on the direct-store path) never validated --var values,
so `bd mol bond --dry-run <formula> <x> --var bad=...` previewed success
for a bond execution refuses — exactly the false preview #5253 fixed —
and materializeMolBondOperand wrapped every cook error as
"'%s' not found as issue or formula", re-introducing the ErrVarValidation
double-wrap #5253 removed from resolveOrCookToSubgraph.
discoverMolBondOperand now takes the provided vars and runs
formula.ValidateProvidedVars on its formula fallback, so --dry-run and
execution reject the bond identically, before any writable reopen.
materializeMolBondOperand passes formula.ErrVarValidation through
unwrapped, matching resolveOrCookToSubgraph and pour/wisp.
Agent-Signature: claude-fable-5 on behalf of R0SEWT
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mol): review polish — fs.ErrNotExist, hook-isolated test repos, auto-route coverage
Three non-blocking notes from the Aug 16 review:
- routed.go: errors.Is(err, fs.ErrNotExist) instead of the legacy
os.IsNotExist, so the not-found check keeps working if loadPrefixRoutes
ever starts wrapping its open error.
- mol_bond_routing_test.go: pin core.hooksPath to .git/hooks after each
git init (the initGitRepoAt convention), so a developer or CI box with a
global hooksPath override never runs foreign hooks inside test repos.
- The widened openAutoRoutedStore behavior (maintainer/default auto-routes
open writable for any validated write-intent resolver, not just mol bond)
now has both the CHANGELOG sentence and a write-through test:
TestMaintainerAutoRouteMutationWritesThrough drives
resolveAndGetIssueForMutation — the bd update resolver — through a
maintainer auto-route, commits a real update there, and re-reads it via a
fresh routed read.
Agent-Signature: claude-fable-5 on behalf of R0SEWT
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mol): carry main's #5761 formula validation into routed bond discovery
Rebase adaptation for #4720 onto main b303d494df. The PR moved the direct
(non-proxied) `bd mol bond` path off resolveOrDescribe and
resolveOrCookToSubgraph onto discoverMolBondOperand and
materializeMolBondOperand. Main's #5761 meanwhile fixed the old pair so a
--dry-run fails on exactly what the real bond fails on; the new pair did not
have that fix:
- discoverMolBondOperand loaded the formula with parser.LoadByName, which
never runs Formula.Validate, so a --dry-run previewed a successful bond for
a formula the cook rejects (e.g. a waits_for gate with no spawner). It also
validated --var values against the unmerged formula, so a var whose enum is
declared only in a parent went unchecked. Discovery now resolves the
formula with parser.Resolve first, the way resolveAndCookFormulaWithVars
does, and wraps both failures the way the cook does, so --dry-run and
execution report the same message.
- materializeMolBondOperand passed only formula.ErrVarValidation through
unwrapped. A formula that fails validation was reported as "not found as
issue or formula". formula.ErrValidation now passes through too, as in
main's resolveOrCookToSubgraph.
TestDiscoverMolBondOperandRejectsWhatMaterializeRejects and
TestDiscoverMolBondOperandValidatesVarsAgainstTheMergedFormula assert the two
phases against each other, like main's TestBondDryRun* pair does for the
proxied route.
Also:
- The PR's routing tests now pass the `exact` argument that main's #5393
added to resolveViaPrefixRoutingWithAccess. They pass false, which keeps
the partial-ID resolution the tests were written against.
- The PR's three new cgo test files are added to the bd_test srcs. This is
`make bazel-sync` output on the merged tree, and it touches nothing else.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Rody Vilchez <102562850+R0SEWT@users.noreply.github.com>
* test(mol): rebuild the RepoContext cache in the PR's role-routing tests
Rebase adaptation for #4720 onto main b303d494df. Main's #5243 moved
auto-routing role detection onto beads.GetRepoContext(), which caches the
repo context once per process; before it, role detection ran
routing.DetectUserRole(".") on every call. The PR's auto-routing tests chdir
into a fresh repo and set beads.role there, so after the rebase they read
the context an earlier test built for its own, now-deleted repo. There
beads.role is unset, and the remote-URL fallback finds no origin and answers
maintainer:
- TestMolBondAutoRoutedReadOnlyFailsFast fails whenever a role-routing test
ran before it in the same binary (reproducible alone with -count=2):
discovery looks for the contributor operand in the local store and reports
it not found.
- TestDiscoverMolBondOperandRouting/maintainer_routed_issue and
TestMaintainerAutoRouteMutationWritesThrough still pass, but only because
that fallback is also maintainer; they never read the beads.role they
configure.
Each test now calls resetRepoContextCachesForTest after its chdir, as #5243
did for main's own role-routing tests (TestResolveCloseTargets, which
TestDiscoverMolBondOperandRouting mirrors, and the routing_read tests).
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Rody Vilchez <102562850+R0SEWT@users.noreply.github.com>
* fix(routing): open maintainer auto-routes writable for exact-match writes
#5393 landed after this PR was written. It moved `bd comment` and
`bd comments add` off resolveAndGetIssueForMutation onto a new
resolveAndGetIssueForMutationExact. This PR widens the former's auto-route
tier for write intent: a maintainer/default target opens writable, while a
contributor target stays read-only and MutationForbidden. On the PR's
original base that widening covered comment writes. After the rebase the
exact resolver still opened every auto-route read-only, so comment writes
lost it and the CHANGELOG's "any validated write-intent resolver" no longer
held.
The exact resolver is meant to keep the mutation resolver's routing
fallbacks and only tighten matching (#5393: it "keeps the existing
cross-rig prefix-routing and contributor auto-routing fallbacks intact").
Its auto tier now takes the same write-intent path. Matching stays exact,
and the abbreviation-refusal precedence is unchanged.
TestMaintainerAutoRouteExactMutationWritesThrough pins the change: the
routed store must not be read-only, and a comment written through it must
commit in the planning database. Without this change the read-only check
fails. The write itself still succeeds, because a server-mode read-only
open does not refuse it.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Rody Vilchez <102562850+R0SEWT@users.noreply.github.com>
* fix(routing): harden routed writes and surface routing failures
Review fixes for #4720.
bd close resolved its batch's shared auto-route through
openRoutedReadStore, so the route opened read-only even though every
other write-intent resolver opened it writable. The shared handle now
opens through openAutoRoutedStore with write intent, so the close commits
where the issue lives.
A contributor auto-route now opens writable for write-intent callers, as
maintainer and default routes do. The refusal the previous revision added
(errContributorRouteMutationForbidden, contributorRouteRefusal,
RoutedResult.MutationForbidden) is gone. A contributor's route target is
their own planning repository, the one bd create writes to:
docs/multi-agent/multi-repo-migration.md and
examples/contributor-workflow/README.md have the contributor claim and
close planning issues from the fork, and GH#2345, beads-0km and GH#3608
made bd show, update and close reach those issues. The read-only rule
came from #4389's review fixes (e8ae7a291a), which kept "contributor
auto-routing" read-only to preserve the bd-6dnrw.32/GH#3231 guarantee
that "routed reads never mutate a foreign project's history". That
guarantee is about reads, and the planning repository is not a foreign
project. Base therefore split by backend: a server-mode bd update, close
or comment of a planning issue committed, because a read-only server
store accepts the write, while the embedded store refused it with "store
is read-only". Refusing in every resolver would have broken the
documented workflow on both backends. bd mol bond was the only command
that checked MutationForbidden, so its check goes too, and a bond of
planning issues commits in the planning repository like any other routed
write. Reads through every route stay read-only. This reverses the
previous revision's stance and is flagged here as a maintainer call.
bd unclaim now resolves its issue through resolveAndGetIssueForMutation,
as bd update --claim does, so a routed issue opens writable; with the
read resolver an embedded routed target refused the release with "store
is read-only". Like bd close, it commits a routed change itself
(commitPendingIfEmbedded), since the post-run auto-commit covers only the
local store. bd human respond and dismiss already opened their target
writable but never committed it, so on an embedded workspace the close
sat uncommitted in the routed repository's working set; they now commit
it the same way. resolveAndGetIssueWithRoutingAccess's
writablePrefixRoute parameter is renamed writable, since it now governs
auto routes too.
A routed commit that fails no longer looks like success, and a retry
commits it. bd unclaim printed "Unclaimed" (or listed the issue in its
--json output) even when the release's routed commit failed; it now
reports the commit error and leaves the issue out. The failed commit
leaves the release, or the close human respond and dismiss make, in the
routed repository's working set. There a retry finds the issue
unassigned or already closed and refuses before it reaches its commit,
and nothing else commits a routed target. On that refusal unclaim,
respond and dismiss now commit the pending write before reporting it,
through commitRoutedWrite, which their success paths share.
A routed write never creates the target's database. The routed open runs
before the lookup it serves, so an embedded open of a repository that had
not been bootstrapped yet created an empty database that outlived an id
that missed; bd bootstrap then took it for the real one and skipped the
clone from sync.remote. openRoutedTargetStore's writable branch now opens
through newExistingDoltStoreFromConfig, which refuses an embedded
workspace without a database (embeddeddolt.HasRepository) before the
sanitize migration can rewrite anything there. A server-mode open already
never creates one.
resolveAndGetIssueForMutation already returned a routing failure (an
unreadable routes.jsonl, a routed store that fails to open) as itself. The
exact resolver and bd close still fell through to "no issue found
matching", which misstates why the lookup missed. All of them now share
isRoutingFailure. The exact resolver checks its abbreviation refusal first,
so the auto tier still gets its chance at an exact match. A prefix route
whose target has no usable metadata.json now names the route and the file
and says why the file could not be used.
An auto-routed store now opens the target's own dolt_database, as a prefix
route already did. Otherwise BEADS_DOLT_SERVER_DATABASE, which names the
launching workspace's database, would point a server-mode open at the wrong
database on a shared server. openRoutedTargetStore holds that override for
both route kinds. A write refuses a target whose metadata.json cannot be
read or parsed or names no dolt_database (autoRouteTargetDatabase) instead
of falling back to that variable. A target with no metadata.json at all
opens, read or written, the only embedded database it holds
(embeddeddolt.Databases), or the default database
(configfile.DefaultDoltDatabase) when it holds none or several.
Contributor setup leaves the planning repository without one until the
first routed bd create writes it, and names its database the way any
workspace without metadata.json does, BEADS_DOLT_SERVER_DATABASE first.
The open would otherwise resolve that name again from the launcher's
variable, so when the two differed a read that missed failed with
"database not found" and a write that missed created a database beside
the one setup created. A server-mode target holds no embedded database,
so with the variable set such a route now opens the default database
rather than the launcher's, which is what it opens without the variable.
A read of a target whose metadata.json is unreadable or names no
database keeps the lenient lookup it had.
bd mol bond's routed home now gets the external-dependency policy and
nothing else, as wireExternalDependencyPolicy asks of routed stores. The
launching workspace's hooks and telemetry no longer wrap writes into
another rig. runMolBond's tail is split into planMolBond, openMolBondHome,
materializeMolBondOperands and bondMolBondOperands, which takes it from
cyclomatic 26 down to 10 or less per function. getIssueWithRouting and the
resolveViaAutoRouting wrapper had no callers left and are removed.
Tests:
- TestMaintainerAutoRouteMutationWritesThrough now checks that the routed
store is writable. Without that check it passes even against a read-only
open, because a server-mode read-only store accepts the write.
- TestAutoRouteCloseTargetWriteIntent covers bd close's write intent for a
maintainer route.
- TestContributorAutoRouteWritesThrough replaces
TestContributorAutoRouteRefusesWriteIntent: an update, a comment and a
close through a contributor route each open the target writable and
commit, a read through the same route stays read-only, and a missing id
stays a plain not-found.
- TestEmbeddedContributorRoutedWritesCommitInPlanning runs bd update
--claim, unclaim, comment, close, human respond and human dismiss
through the bd binary in a contributor checkout. Each advances the
planning database's HEAD, and the issues end up closed there and absent
from the fork's database. The embedded shard manifest gains the test.
- TestMolBondContributorAutoRoutedWriteThrough replaces
TestMolBondAutoRoutedReadOnlyFailsFast: bd mol bond's pipeline bonds two
planning issues through a contributor route, and a fresh routed read
sees the dependency; setupAutoRoute now seeds extra planning issues for
it. TestDiscoverMolBondOperandRouting's contributor case now expects the
writable reopen.
- TestResolveCloseTargets keeps base's contributor cases (beads-0km); the
previous revision had moved them to routing.maintainer.
- TestRoutedWriteDoesNotCreateTargetDatabase (in-process) and
TestEmbeddedRoutedWriteMissDoesNotCreateTargetDatabase (the bd binary)
check that a missed write through a prefix route and through a
maintainer auto-route leaves an embedded target that has not been
bootstrapped without an embeddeddolt directory. The embedded shard
manifest gains the test.
- TestRoutedMutationResolversReportRoutingFailures runs each write-intent
resolver against an auto route whose store fails to open, an auto route
whose target's metadata.json names no dolt_database while
BEADS_DOLT_SERVER_DATABASE names the launcher's, and a prefix route
whose target cannot load.
- TestAutoRouteTargetDatabase covers a write and a read of a target whose
metadata.json names a database, is missing, names none, or cannot be
parsed; a missing one yields the target's only embedded database, or
the default database when it holds none or several, either way.
TestDatabases covers the listing, which applies HasRepository's .dolt
marker probe to each database.
- TestAutoRouteMissWithoutMetadataIgnoresEnv runs a missed read and a
missed write through an auto-route to a target that has one database
but no metadata.json: the default database while
BEADS_DOLT_SERVER_DATABASE names the launcher's, and a database named
after the launcher's with the variable set and unset at use. Each miss
must report not found and leave the target holding only its database.
- TestRoutedWriteRetryCommitsFailedCommit fails the routed commit of bd
unclaim (text and --json), human respond and human dismiss with an
invalid --dolt-auto-commit. The run must fail with nothing on stdout and
leave the routed repository's HEAD as it was; a retry must report its
refusal and commit the write there.
- TestAutoRouteOpensTargetDatabaseDespiteEnv checks the target-database
change.
- The auto-routing tests clear BEADS_ROUTING_MODE and BD_ROUTING_MODE
through neutralizeRoutingModeEnv. Viper ranks them above the
routing.mode the tests write, so a host that exports either var never
routes. bdEnv, which builds the bd binary's environment in the
embedded tests, now drops BD_ROUTING_MODE as it drops BEADS_*; agent
hosts export it, and TestEmbeddedContributorRoutedWritesCommitInPlanning
failed on such a host.
TestEmbeddedRoutedWriteMissDoesNotCreateTargetDatabase no longer needs
its own envWithout.
- Reverting each fix turns its test red: the contributor read-only clamp
(the contributor tests above), unclaim's resolver or commit and the
respond and dismiss commits (the matching step of the embedded test),
and each autoRouteTargetDatabase rule. So does dropping unclaim's,
respond's or dismiss's retry commit, or unclaim's skip of a release
whose commit failed (TestRoutedWriteRetryCommitsFailedCommit); either
earlier no-metadata.json rule, the variable, which leaves the stray
database the review reported, or a fixed default database, which fails
the read of a target setup named after the variable
(TestAutoRouteMissWithoutMetadataIgnoresEnv and
TestAutoRouteTargetDatabase), and taking the first of several databases
(TestAutoRouteTargetDatabase); and bdEnv's BD_ROUTING_MODE drop, on a
host that exports BD_ROUTING_MODE=off (both embedded tests).
The CHANGELOG entry now records that every auto-route opens writable for
the commands that change an existing issue, the unclaim and human
respond/dismiss commits, that a routed write never creates the target's
database, and the target-database and routing-failure changes.
docs/multi-agent/routing.md says that write commands follow every route,
contributor, maintainer and default alike, never create the routed
repository's database, and refuse a target whose metadata.json is
unreadable or names no dolt_database. Both say that an auto-route opens
a target with no metadata.json at the one embedded database it holds, or
its default database when it holds none or several, while a prefix route
always needs the target's dolt_database. That page documents
behavior that is not in a release yet, which the docs release-pin
decision (engdocs/decisions/2026-07-17-docs-release-pin.md §1) would
leave undocumented. The review asked for docs that match the behavior,
as feature PRs #6508, #5855, #5997 and #5092 also did, so it is flagged
here as a maintainer call.
Open, and not changed here. bd close has the same retry gap on base: a
re-close of an issue that a failed routed commit left closed counts as
already closed and never commits that store (mutatedStores).
commitPendingIfEmbedded gates on the launcher's mode (isEmbeddedMode),
not the routed store's, so a server-mode launcher that opens an embedded
routed repository would leave the write uncommitted there. That gate is
shared by every routed write command and is not exercised here.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Rody Vilchez <102562850+R0SEWT@users.noreply.github.com>
* ci(shards): list TestDatabases in the 40-shard embedded storage manifest
The routed-write hardening added TestDatabases to
internal/storage/embeddeddolt/detection_test.go without a slot in the
Bazel-only 40-shard block of .github/scripts/embedded-storage-test-shards.txt,
so gen_embedded_storage_shard_manifest.py 40 --weights=duration --check
reported it missing and TestStorageEmbeddedShardManifestGeneratorNotStale
(go test ./scripts) failed.
Regenerated with the repository command
(gen_embedded_storage_shard_manifest.py 40 --weights=duration --write);
the incremental pack adds exactly one line, on shard 25.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Rody Vilchez <102562850+R0SEWT@users.noreply.github.com>
---------
Co-authored-by: Rody Vilchez <102562850+R0SEWT@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
* perf(dolt): sweep the circuit-breaker dir once per process and age out closed files
CleanStaleCircuitBreakerFiles is documented as an init-time cleanup that
is "fast — typically 0-2 files", but it reads every breaker file in the
live directory on every server-mode store open. Two things made that the
dominant fixed cost of a bd write on a busy dev host:
- Every host:port:db a process opens leaves a closed-state file behind,
and ephemeral test-server ports mint a new name each time. Closed files
in the live directory were never removed, so one host's
$TMPDIR/beads-circuit held 2335 of them.
- A write command opens its store twice — the non-mutating preview open
for the workspace-identity check (be-0gfcs), then the writable open —
and each open ran the full sweep. One `bd update` opened 4755 breaker
files.
The store-open path now sweeps at most once per process
(cleanStaleCircuitBreakerFilesOnce); bd doctor --fix still calls the
sweep directly. And the live directory ages out closed files untouched
for 24 h exactly as the legacy /tmp/beads-circuit sweep already did
(legacyClosedSweepTTL becomes closedSweepTTL for both). A closed file
that old is indistinguishable from no file: readState reads an absent
file as closed, and a closed state's failure count only matters inside
circuitFailureWindow. A breaker in use is rewritten on every successful
open, so its mtime stays fresh and it is kept.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(dolt): pin closedSweepTTL's 24h width; document what the sweep removes
Maintainer fixup for the PR #7593 review (iteration 1; all non-gating):
- TestCleanStaleCircuitBreakerFiles_AgesOutClosedLiveFiles stamps its closed
files at literal ages instead of ones derived from closedSweepTTL: a file
idle 25h must go and one idle 23h must survive. A TTL lowered to
5m/61s/30s/22h or raised to 26h/48h, or a use site compared against
circuitStaleTTL, now fails the test; every one of them passed before.
- CleanStaleCircuitBreakerFiles' godoc lists the closed-file age-out and the
corrupt-file removal it already does, which directories it sweeps, and that
store open reaches it once per process while bd doctor --fix calls it
directly.
- The cleanServerCircuitState seam notes that a test driving the real sweep
through it must start a fresh staleCircuitSweep.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(issueops): gate members on create and update, one bounds validator
The library half of serving gate await fields. Every local leg already
stores await_type, await_id, timeout and waiters on create, and await_id
on update; this adds the two missing pieces.
- IssuePatch.Waiters: a whole-value replacement of the waiter list (nil
or empty clears, stored as []), mapped by UpdateFields and by the
unit-of-work updateSpec, deep-copied by CloneUpdateRequest, and
classified as a non-coordination signal on the dolt leg. Duplicates are
stored as given; dedup stays the CLI's.
- ValidateGateFields / ValidateGatePatch with *issueops.GateFieldError
{Field, Detail} wrapping ErrValidation, mirroring ReclaimFieldError so a
front door can name the member. The rules are the columns' only:
await_type <= 32 characters, await_id <= 255 characters, the JSON
waiter list <= one TEXT column (65535 bytes), and timeout >= 0. No
await_type allowlist, no gate-type-only rule, no timer-needs-timeout
rule. Run from ValidatePublicCreateRequest (every create shape on every
backend) and ValidateUpdateRequest (await_id, waiters).
- Conformance: LifecycleCreate WritesTheGateMembers / BoundsTheGateMembers,
LifecycleUpdate PatchesTheGateMembers / BoundsTheGateMembers and
BatchApply CarriesTheGateMembers, each bound asserted from both sides,
wired on the dolt, embedded and uow legs and parked on the http leg on
the live refusal rows until the wire slices land.
- httpclient: IssuePatch.Waiters is refused before the dial on both patch
documents under a new W-IssuePatch.Waiters row (refuse-not-drop), until
the wire publishes it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(httpapi): publish the gate members on create and update
The wire half of serving gate await fields, over the library slice.
- createIssue and the issues:batchApply create item publish await_type,
await_id, timeout (nanoseconds, the encoding Issue.timeout reads back)
and waiters, behind the new behavior token issues.create.gates (one token
for both create shapes, the issues.create.defaultPriority precedent).
- updateIssue's patch and the batchApply update item's patch publish
await_id and waiters (whole-value replacement; [] clears), behind
issues.update.gates. await_type and timeout are not patch members: no
local update route changes them. Neither is nullable; null is refused
naming the member, as on title.
- The handlers only decode and project (createGateMembers,
patchGateMembers). The wire is no stricter than the library: every bound
is the role's *issueops.GateFieldError (await_type <= 32, await_id <=
255, the JSON waiter list <= one TEXT column, timeout >= 0), mapped to the
existing 400 invalid_argument with param naming the member at its level
(await_type, patch.waiters, items[i].create.timeout,
items[i].update.patch.await_id). The spec mirrors exactly that:
maxLength 32/255 and minimum 0, and no minLength/maxLength/maxItems on
waiters. Blank and duplicate waiters and any await_type reach the role
untouched.
- Spec: the four schemas, the capability prose, and the stale sentences
(createIssue's "await_* publishes on no operation, read or write" and the
patch's "spec_id and await_id publish nowhere yet"). apigen regenerated
(from the remote drift test's diff), wireshape golden regenerated:
additive entries and sides only, wire_revision stays 2.
- Client: the two tokens are mirrored in wire.behaviorCapabilities so the
vocabulary stays set-equal with the server's. The client still refuses
every gate member before the dial (the client slice flips that); the write-ledger
pending sets name the newly published members under their live refusal
rows, and the W-CreateRequest.Issue / W-IssuePatch.AwaitID /
W-IssuePatch.Waiters reasons, the served-leg park reasons and the S4b
waiver now say the server publishes them and this client does not send
them yet.
Tests: internal/httpapi/gate_fields_test.go pins member mapping on all four
bodies, clear-by-empty on both patches, null and unpublished-member refusal,
GateFieldError -> param at every nesting level, and both tokens advertised.
Mutating the handlers (dropping the mapping, the GateFieldError arms or the
tokens) turns them red.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(httpclient): send the gate members behind their tokens
The client half of serving gate await fields, over the wire slice.
- Create: await_type, await_id, timeout (nanoseconds) and waiters join the
create vocabulary on createIssue and batchApply create items (now
twenty-four members), sent verbatim when populated. Patch: await_id (by
presence; "" clears) and waiters (whole-value; nil/empty travels as [])
are encoded on both updateIssue's and the batchApply update item's patch.
- Token gate before the dial: a create naming any gate member needs
issues.create.gates, a patch naming one needs issues.update.gates. Without
the token the request refuses with wire.NewCapabilityError naming it
(typed ErrUnsupported{Capability}), never a dropped member. batchApply
checks the whole plan once, so no partial plan is sent. A request naming
no gate member never reads either token. Store.requireCapabilityBeforeDial
is the shared helper; requirePersistenceMove now uses it.
- Bounds read back typed: the server's 400 invalid_argument/invalid_value
whose param names a gate member at any level (await_type, patch.waiters,
items[i].create.timeout, items[i].update.patch.await_id) is rebuilt as the
role's *issueops.GateFieldError, the problem kept in the chain (and a batch
refusal still becomes its *ItemError). Without this the served bounds
contracts could not pass.
- Ledger: W-IssuePatch.AwaitID RETIRED; the library slice's W-IssuePatch.Waiters row
deleted (it never shipped outside this branch); W-CreateRequest.Issue and
W-CreateItem.Issue no longer cover the gate members; new
W-CreateRequest.Gates (refuse, Capability issues.create.gates) records the
token-gated late refusal for both create shapes. engdocs ledger
regenerated from Ledger() (262 rows: 201 refuse, 34 degrade, 27 retired).
- Write-ledger table: the wire slice's pending sets are flipped into carried.
- Served leg: the five gate cases (LifecycleCreate Writes/Bounds,
LifecycleUpdate Patches/Bounds, BatchApply Carries) are un-parked and run;
the S4b waiver and served comments now say await_id is sent.
Tests: internal/httpclient/gate_fields_test.go (encode on all four bodies,
clears, old-server refusal per member naming the token with no dial, no
partial batchApply plan, plain requests unaffected on old and new servers,
GateFieldError rebuilt from the problem). Disabling the three pre-dial
checks turns the refusal tests red.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* build(bazel): auto-sync BUILD files
Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/38841144413
(`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.
* docs(issueops): say the gate timeout rule is no column's
The gate validator's doc said its rules were the stored columns' and that
no command line can produce a negative timeout. The widths are the
columns' (VARCHAR(32), VARCHAR(255), TEXT), but timeout_ns is a BIGINT,
so a non-negative timeout is a rule no column enforces; the wire
publishes it as minimum 0. The raw store creates (CreateIssue,
CreateIssues) and import do not run the validator, so bd gate create
--timeout=-5m, a formula step's gate.timeout and a template clone still
store a negative timeout until they move onto the role.
Also say that GateFieldError.Detail is prose whose HTTP copy ends with
the server's own clause, so a caller dispatches on Field, and why a
create omits an empty waiter list while a patch sends [] to clear it.
Comments only; no behaviour change.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(corpus): gh:run await_id persist refuses by the missing gate token
#7604 (now on main) made bd gate check persist a gh:run gate's discovered
run ID through Lifecycle.Update. Its served test expected the HTTP
client's W-IssuePatch.AwaitID refusal, which persistGateCheckAwaitID
rewords to name await_id. This PR retires that row: the patch carries
await_id behind issues.update.gates. Through the reference proxy, whose
server advertises no gate token, the persist is now refused before the
dial by the capability error ("bd serve at ... does not advertise
capability "issues.update.gates", which updateIssue requires"), so the
merged tree failed the subtest's await_id and updateIssue assertions.
The subtest now expects that refusal: no writes, the error names the
gate, the missing token and the server, no role or store method leaks,
and await_id is untouched. persistGateCheckAwaitID already returns a
capability error as the role raised it (#7604 pins that), so no code
changes. Against a server that advertises the token the persist goes
through: a scratch probe against the in-process server recorded
await_id=4242 and closed the gate.
Also correct the gate.go comment and the CHANGELOG entry that still said
the HTTP client refuses every await_id patch.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <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>
* perf(list): read only the listed issues' dependency edges
`bd list`'s text renderings (the default tree, --deps, --parent, --format
and --watch) loaded every dependency record in the workspace through
GetAllDependencyRecords to draw one page. On a local store that is one
query. Over a connected HTTP workspace it is a walk of the whole workspace:
every issue id at 200 per request, then every id's edges at 100 per
request. `bd list --limit 20` against the ~3.8k-issue maintainer-city
workspace made 62 sequential requests and took ~5.7 s at ~50 ms a round
trip, where `bd list --json` makes 5.
Every rendering reads only edges a listed issue owns. The tree nests a
child under a parent only when both are listed, and looks the edge up
under the child. Sibling ordering, the --deps annotations and the gate
decoration read the listed node's own edges, and --format prints edges
between listed issues. An unlisted issue's edge onto a listed one, or a
parent off the page, is never read. listDependencyRecords reads exactly
those edges through the EdgeReader role, which every backend serves (the
http store refuses the raw GetDependencyRecordsForIssues batch method).
Over http that is one anchored listDependencies request per 100 listed
ids.
Through a logging proxy in front of the production bd serve, list
--limit 20 goes from 62 requests / 5.7 s to 6 / 0.49 s with
byte-identical output; every changed mode (--deps, --deps=all, --format
digraph/dot, --sort, --status, --ready, --limit 200, --limit 0, --parent)
prints the same bytes as before. On a local store a default page is as
fast or faster; a listing that covers most of a large durable store pays
batched reads instead of one table scan (+0.07 s at 1,000 rows, +0.46 s
at 4,000 on embedded Dolt).
Tests:
- backend/http TestE2E_ListTextRenderingsReadOnlyTheListedIssuesEdges:
over a served workspace, the tree, --deps=all, a --limit cut, the
--parent tree and --format digraph each make one listDependencies
request naming exactly the listed ids, and at most one request more
than the --json page. Failing first: the old read enumerated every id
(all=true) and anchored the hidden closed issue too.
- cmd/bd: the page read equals GetAllDependencyRecords restricted to the
page on Dolt server and embedded stores (both planes, every edge type,
gates, external refs), and every text rendering prints the same bytes
from either map; a runListCore spy pins one page read and no
store-wide read; pure tests over an adversarial fixture (edges unlisted
issues own pointing at listed ones, parents off the page, dotted
children, a parent-child cycle) guard the renderers.
Refs: ga-nrnrlr.5
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(http): seed the list page-edges e2e with one graph apply
TestE2E_ListTextRenderingsReadOnlyTheListedIssuesEdges ran 26 s on
http_served_test's round-robin shard in CI, which made that shard the
embedded lane's longest test action (172 s). Most of it was subprocesses:
five creates and a close to seed, plus a --json budget run per case.
The fixture is now one `bd create --graph` plus the close (the batch
create cannot carry a closed row's closed_at over the wire), and one
`bd list --json` run is the budget for every page case, since its request
count does not depend on the page size. 16 subprocesses become 9. All
five cases still fail against the old GetAllDependencyRecords call
sites: each edge read anchors the hidden closed issue, and the four page
cases make 7 requests against the --json page's 5.
Refs: ga-nrnrlr.5
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(http): gate check's bead sighting goes through Lifecycle.Update (issues.update)
The bead-gate sighting was written through the legacy map-based
UpdateIssue, which the http store does not implement, so the refusal
happened client-side and no issues.update was ever sent: every open bead
gate with an open target failed on every sweep over HTTP.
- recordSeen and the gh:run await_id persist now go through the Lifecycle
role (updateGateThroughLifecycle): a single-key metadata set for the
sighting, an AwaitID patch for the run. The http client still refuses the
await_id patch before the dial (W-IssuePatch.AwaitID); the gate's error now
names the await_id update instead of a Go method.
- backend/http/corpus TestServedGateCheckOverAwaitTypedGates seeds
await-typed gates in the served store and proves, through the reference
proxy: --dry-run writes nothing, timers close, the bead sighting persists,
merged gh:pr gates close, and the gh:run persist refuses by name with
await_id untouched.
- CHANGELOG corrected.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(cmd/bd): gate check skips template gates; narrow the await_id reword
Review fixes for the gate-check sighting change.
- A persisted proto's gates (bd cook --persist) are templates, and
issueops.ListGates lists them with the open gates. bd gate check now
leaves them out of its listing's query: GateListRequest gains
ExcludeTemplates, which only listOpenGatesWith sets, and it adds
`template=false` to the expression, so the cut at --limit counts only
the gates that remain. bd gate list leaves it unset and still lists
templates. Dropping them from the page after the cut would let a page
of a proto's gates (newer than the live ones at the same priority)
fill --limit: the sweep would print "No open gates found." and exit 0
with the live gates unchecked. filterCheckableGates, which both the
direct and the proxied-server routes select through, keeps the skip
as a backstop. Before this, each route mishandled templates in its
own way:
- Direct route: the Lifecycle role refused the sighting and await_id
writes, so the sweep failed every time, after a gh:run template had
already queried GitHub. In a local workspace, an expired template
timer gate was closed in the proto.
- Over HTTP: bd serve refused the close with 409 template_read_only.
- Proxied-server route: the template timer gate was closed and a
sighting was stamped on the template bead gate, silently.
- persistGateCheckAwaitID rewords only the HTTP wire's
W-IssuePatch.AwaitID refusal. The new message names the run, await_id
and the bd serve URL, and advises checking the gate in a local
workspace: giving it a numeric run ID would be the same await_id edit
the wire refuses. The error chain is kept, so *storage.ErrUnsupported
and the ledger row stay reachable. Every other error comes back as the
role raised it, including a capability the server does not advertise
(#7589's issues.update.gates) and a local backend's ErrUnsupported.
Before, every ErrUnsupported got the same sentence.
- Tests:
- Unit: the template skip for every type filter; a sweep over template
gates beside a live one; ListGates putting `template=false` in the
query under ExcludeTemplates, and gate check's listing setting it;
the reword and its chain; the pass-through cases; the sighting patch
matching its map form.
- Embedded: a cooked proto's gh:run, bead and timer gates are
untouched, and gh is never run. With --limit 1 behind that proto's
gates, a live expired timer gate is checked and closed.
- Proxied-server: template timer and bead gates stay open and
unstamped. With --limit 1 behind two newer template timer gates, the
live one is checked and closed.
- Served: the template gates are untouched, and the gh:run error names
the server. --dry-run --limit 3 behind three template gates checks
three live gates.
- Each --limit case first shows, through bd gate list, that a template
leads the listing.
- Against the PR-head bd, the embedded, proxied and served template
cases fail. Against a bd that skips templates after the cut, the
three --limit cases fail, printing "No open gates found." and
exiting 0.
- bd_test gains the //internal/httpclient{,/encode} deps (gazelle-checked).
The embedded shard manifest lists both TestEmbeddedGateCheck* tests.
The CHANGELOG notes the template skip, that templates take no row of
--limit, and the new wording.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
* fix(init): refuse to initialize directly in the home directory
`bd init` in a directory that isn't a git repo (and has no explicit
BEADS_DIR) unconditionally `git init`s the directory, writes agent
scaffolding (CLAUDE.md, AGENTS.md, .gitignore, .agents/, .codex/,
.claude/settings.json), and commits — with no confirmation. Run in the
home directory this silently turns $HOME into a git repository and can
clobber an existing ~/CLAUDE.md. It's worse under --non-interactive
(auto-engaged whenever stdin isn't a TTY, i.e. whenever an agent runs
`bd init`): all of it happens with zero prompt (GH#4635).
Refuse the init when the current directory is the user's home directory
and it isn't already a git repo (and no explicit BEADS_DIR was given),
with a clear error pointing at the alternatives (cd into a project, or
set BEADS_DIR). The common fresh-project flow (mkdir proj && cd proj &&
bd init) and already-git-tracked homes are unaffected.
The guard runs as the first statement in init's RunE, ahead of every
path that has an effect. Position is the whole fix: --reinit-local /
--force reach countExistingIssues, which opens a real store (creating
the data directory, able to run migrations), and --proxied-server
dispatches to runInitProxiedServer -> EnsureGitRepo, i.e. a `git init`
in the current directory. Both run long before the point where a guard
placed with the rest of the path validation would fire.
Home is resolved from the OS account database (user.Current) in
preference to $HOME, so the guard keys off the real account home even
when $HOME is repointed — which this repo's own tests do constantly.
Both sources are best-effort: a CGO-free build's user.Current() falls
back to os.UserHomeDir() (i.e. $HOME on Unix) when the account is absent
from the passwd database, so this is a preference, not a guarantee of
$HOME-independence. Mirrors the home resolution in internal/beads'
isPathInSafeBoundary.
Tests: TestIsUserHomeDir and TestGuardInitInHomeDir cover the decision
(resolver stubbed, so the real home is never touched);
TestInitCommand_RefusesInHomeDirBeforeAnySideEffect runs the actual
command for plain / --reinit-local / --force / --proxied-server and
asserts not just the refusal but that nothing — .git, .beads, CLAUDE.md,
AGENTS.md, .gitignore, .agents, .codex, .claude — exists afterwards.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(init): key the home guard on caller intent, and give it a named exit code
Three blocking items, two reviewers converging on the first.
1. The guard read os.Getenv("BEADS_DIR") as "the user explicitly opted in".
It is not. Cobra's root PersistentPreRunE runs before RunE and, for a
no-DB command like init, resolves a beads dir and exports it
(selectedNoDBBeadsDir -> prepareSelectedNoDBContext ->
prepareSelectedCommandContext). That resolution bottoms out in
beads.FindBeadsDir(), which accepts any ancestor .beads/ for which
hasBeadsProjectFiles is true - and a config.yaml alone is enough. That is
the shape of this project's own legacy user-level ~/.beads/config.yaml,
so anyone carrying it got BEADS_DIR set for them and the guard failed
open. `bd -C <dir> init` opened the same hole, and that one does not even
move the working directory the scaffolding lands in.
The damage is not self-cancelling. The `git init` half is separately
gated on the same env so it stayed skipped, but the agent scaffolding is
not gated at all: addAgentsInstructions, InstallClaudeProject,
InstallCodexProject and InstallCursorProject all write relative to CWD.
So the bypass still clobbered ~/CLAUDE.md, ~/AGENTS.md and
~/.claude/settings.json - the files the guard exists to protect.
beadsDirFromCaller captures BEADS_DIR as the process INHERITED it, at
package initialization, which the language guarantees runs before main
and therefore before any bd code exports one of its own. The guard
consults that snapshot, so the question it asks is "did the caller name a
beads dir", not "does the process env happen to have one".
2. The refusal skipped all three of init's refusal conventions.
ExitHomeDirRefused = 13 joins 10/11/12, the message is printed and the
error carries only the code (the ExitLocalExistsRefused pattern), and
docs/recovery/init-safety.md gains an init-home-refused anchor - TOC
entry, symptom, why, three recovery paths, and the script-branching
snippet - which the message points at. `bd help init-safety` lists it.
NOT added: a cmd/bd/protocol case. That corpus states that §E3 freezes
10/11/12/130 and that a new stable code requires a spec revision, so
asserting 13 there would be claiming wire status the spec has not
granted. The constant plus the docs anchor give the refusal the same
in-repo scriptability without that claim; say the word if the spec should
be revised and I will add the corpus case too.
3. CHANGELOG [Unreleased] entry, citing #4635 and stating the scope limits.
Also from review: the message's BEADS_DIR escape hatch said "set BEADS_DIR
if you really mean to initialize here", which is not what happens - an
explicit BEADS_DIR makes hasExplicitBeadsDir true, skipping the git init and
the CWD-local .beads. It now says so.
Test coverage answers the point both reviewers made about the RunE-only
tests. TestInitThroughRootCmd_RefusesInHomeDirWithDiscoveredBeadsDir runs
through rootCmd.Execute, in a home carrying only .beads/config.yaml, and
asserts the precondition (pre-run really does discover it) before asserting
the refusal and that no scaffolding landed. --backend names a backend that
cannot exist as a circuit breaker, so a future fail-open stops there instead
of building a store in someone's home directory. Against the old code it
reproduces maphew's observation verbatim:
init ran past the home guard and got as far as backend selection:
unknown backend "review4795-home-guard-sentinel"
plus a unit case pinning that a bd-exported BEADS_DIR is not caller opt-in.
Reported-by: maphew, bee-ghosttrack
Agent-Signature: claude-code-opus-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(init): harden the home-dir guard (opt-out, git probe, exit 15)
Maintainer fixup on top of #4795 by harry-miller-trimble, for the three
majors and three of the minors from the adopt-pr review, the major, the
minor and the nit from its second round, and two of the minors from its
third. The contributor's commits are unchanged.
The BEADS_DIR opt-out still set up $HOME (major). The refusal said
`BEADS_DIR=<path>/.beads bd init` writes nothing in the home directory,
but an explicit BEADS_DIR only skips the git init. The agent files
(CLAUDE.md, AGENTS.md, .claude/, .codex/, .cursor/, .agents/) are
written relative to the working directory whatever BEADS_DIR says, and a
BEADS_DIR under $HOME counts as local, so ~/.gitignore was appended to
as well. guardInitInHomeDir now returns keepHomeClean for that case.
RunE forces skipAgents, which the proxied route also reads from its
input, and both routes gate the project .gitignore on keepHomeClean.
Init prints a note saying so, with a `bd setup <recipe> --global`
pointer for anyone who wanted an integration everywhere.
The refusal text, the CHANGELOG entry and the recovery playbook now say
what the opt-out does: it sets up only the named workspace, after a
`mkdir -p`, because init refuses a BEADS_DIR whose parent does not
exist. They no longer say nothing else is written, because Dolt and
metrics keep their own state under $HOME. The refusal's Why also stops
saying init overwrites existing files: it installs into them, and in
$HOME those are user-wide agent settings.
TestInitInUntrackedHomeWithCallerBeadsDir_SetsUpOnlyTheWorkspace runs
the direct route end to end against a Dolt server, once with the
workspace outside the home and once under it. Every seeded file must
come out unchanged, with nothing added. The proxied route's agent-file
and .gitignore gates are not covered by a test: there is no in-process
proxied init fixture to drive them.
The tracked-home probe trusted git's routing environment (major).
isGitRepo() is a plain `git rev-parse --git-dir`, so an inherited
GIT_DIR, or a home that only sits inside an enclosing work tree, stood
the guard down. Init's own git-init decision scrubs that environment,
then runs git init in the home and installs agent files into it. The
guard now asks isGitWorkTreeRoot(cwd), which runs
`rev-parse --show-toplevel` through initArtifactGitCommand and matches
the result against the home itself. Two new subtests pin both false
positives. Each asserts that isGitRepo() still reports true, so the
subtests keep reproducing the old probe.
Exit 13 was already taken (major). It is ExitGuardMismatch, "racer won,
skip gracefully", and 14 is ExitMigrationFrozen, so a wrapper branching
on exit codes would read this refusal as a benign skip. The refusal now
exits 15. The change is in init_safety.go, `bd help init-safety`,
ADR 0002, the playbook and the CHANGELOG. ADR 0002 also notes that 15
sits outside the protocol v0 §E3 freeze pinned in
cmd/bd/protocol/exit_codes_init_test.go.
The opt-out still set up a repository around the home (second round,
major). The tracked-home probe sends a home that only sits inside an
enclosing work tree, such as a dotfiles or monorepo checkout above it,
to the BEADS_DIR opt-out. Git finds that repository from the home, so
init set it up as the project: core.hooksPath, beads.role, fork routing
and the fork exclude, its origin as the workspace's Dolt remote, and a
bootstrap commit. That commit staged the home's legacy ~/.beads and then
whatever agent files the home holds, ~/.codex/auth.json among them, and
committed them with --no-verify. The proxied route did the same from its
tail.
keepHomeClean now also means "outside every repository". It is only
true when the home is not a work-tree root, so no repository git finds
from there is the home's own. On the direct route, RunE forces skipHooks
beside skipAgents; projectRoleRepo holds the six isInitRoleGitRepo
gates (the role prompt and pins, the GH#2950 safety net, fork routing,
the fork exclude) to keepHomeClean; and both origin-as-remote gates, the
bootstrap commit and the upstream advice are gated on it. On the proxied
route, the tail's isRepo probe, which gates the role, the fork exclude,
the commit and the upstream advice, and resolveProxiedInitRemoteURL are
gated on it; skipHooks reaches the tail through its input. What a flag
asks for still happens: --stealth and --setup-exclude write their
exclude, and an explicit --remote or a configured sync remote is still
used. The note, the refusal text, the CHANGELOG entry and the playbook
say what the opt-out leaves alone. Gating the commit also drops the
"skipped bootstrap commit" note the opt-out printed from an untracked
home.
Tests for it:
- The end-to-end test gains home_inside_a_repository. The home sits in
a repository with one commit and an origin, and holds a legacy
~/.beads; init runs without --quiet. The repository must keep its one
commit, nothing staged and its .git/config byte for byte (so no
core.hooksPath or beads.role). The workspace must not take its origin
as its Dolt remote, and init must print the note and no upstream
advice. The repository has no upstream remote, because fork routing
would create ~/.beads-planning under the suite's real HOME.
- TestProxiedInitTailKeepHomeCleanLeavesEnclosingRepoAlone runs the
proxied tail from a home inside a repository with an origin and an
upstream, so the fork exclude would fire. It requires no fork
exclude, no commit, nothing staged and the same .git/config.
- TestProxiedInitRemoteURLUsesSelectedProject gains a keep_home_clean
row (the origin is not used) and a configured_keep_home_clean row (a
configured remote still is).
- The guard's enclosing-repository subtest also checks that a caller
BEADS_DIR there returns keepHomeClean.
Second-round minor and nit:
- beadsDirFromCaller's comment and the playbook say why a BEADS_DIR read
from a .beads/.env does not count as the caller's, although
beadsDirProvidedAtStartup counts it for role detection. From the home
that file is the legacy ~/.beads/.env, so counting it would let the
same discovered ~/.beads opt out of the guard.
- The guard tests use t.Chdir, and the hand-rolled chdir helper is gone.
Validation: the init, home-guard and proxied-init tests pass against
the Dolt test container, as do the embedded init lane and the
proxied-server init integration tests. Mutation checks:
- Dropping the forced skipAgents fails both workspace subtests.
- Dropping the .gitignore gate fails the under-home subtest.
- Restoring the plain isGitRepo() probe fails both new false-positive
subtests.
- Disabling the guard fails every refusal test at the sentinel backend.
- Second round: dropping the forced skipHooks, the projectRoleRepo
gate, the commit gate, the late origin gate, the upstream advice gate
or the note each fails home_inside_a_repository on its own check.
Dropping the proxied tail's gate fails the tail test, and dropping the
proxied remote gate fails the keep_home_clean row. The third round
pins the early origin gate (below).
Third-round minors:
- The early origin gate picks the remote the early remote-safety check
probes, and a failed probe counts as Dolt history. The end-to-end
test gains unreachable_origin_reinit_local and
unreachable_origin_force: the home sits in a repository whose origin
path holds nothing, and init runs with --reinit-local or with --force.
Both must succeed and leave the repository as it was. Dropping the
early gate makes init probe that origin and refuse both rows with
exit 10.
- The playbook, the CHANGELOG entry and guardInitInHomeDir's comment
name the flags that still change the repository around the home:
--stealth and --setup-exclude write its .git/info/exclude, and the
interactive --contributor and --team wizards work in it (beads.role,
and possibly a sync branch). The opt-out's note is unchanged: none of
those writes is on its list.
Left for a follow-up:
- The proxied route's .gitignore gate is still unpinned. It needs an
in-process proxied init fixture, or the
`useLocalBeads && beadsDirIsLocal && !keepHomeClean` predicate pulled
out into a table-tested helper.
- Both routes still record the enclosing repository's origin-derived
repo_id, and its clone_id, on an opt-out workspace. That predates this
PR for every explicit-BEADS_DIR init and writes nothing to the
repository; skipping it is a behavior change of its own.
Third-round validation: the home-guard, init-tail and proxied-remote
tests pass in a hermetic env -i run against the Dolt 2.2.0 CI pin (41
tests and subtests, none skipped). Dropping !keepHomeClean from the
early origin gate fails both new rows with exit 10 and leaves the other
three rows passing. go vet, gofmt, the docsync test and the doc
freshness check pass.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Harry Miller <harry_miller@trimble.com>
---------
Co-authored-by: Harry Miller <harry_miller@trimble.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
* feat(storage): add CommitConfigOnly — scoped config-table commit (GH#4078)
Generic Commit() excludes the config table by design (GH#2455) and
CommitWithConfig stages everything via '-Am' — neither can commit an
intentional config write without sweeping concurrent operations' dirty
tables in server mode. CommitConfigOnly stages ONLY config (via the
existing doltAddAndCommit helper) and commits it.
- VersionControl interface method with GH#4078/GH#2455 rationale
- DoltStore: scoped DOLT_ADD('config') + DOLT_COMMIT
- EmbeddedDoltStore: aliases Commit — single-process, so '-Am' cannot
sweep concurrent work (same rationale as its CommitWithConfig alias)
- Tests against a real dolt-sql-server container: scoped commit lands,
concurrent dirty issues row survives uncommitted, and generic
Commit()'s config exclusion is pinned as a regression guard
(cherry picked from commit 61ba8f05c9)
Carry note: rebased onto b1bee123b. The two version_control.go conflicts
were additive (upstream added CommitMergeResolution/CommitAll in the same
spot); resolved by keeping both sides, no change to this commit's code.
* feat(storage): CommitConfigUserKVOnly — screen memory commits to kv.* rows (GH#4078)
Carry reconciliation for the #4383 review: CommitConfigOnly stages the whole
config table, so a memory write's commit in server mode could sweep a
concurrent writer's half-applied internal key (issue_prefix above all), the
row-level form of the GH#2455 hazard. The review asked for #4412's kv.*
screen at the remember/forget sites.
CommitConfigUserKVOnly applies that screen before the scoped commit: if any
dirty config row is outside kv.*, it commits nothing and names the keys,
pointing at `bd dolt commit` (CommitAll), the same remedy the pre-pull
refusal gives. User kv.* rows already dirty are committed with the memory,
as the pre-pull auto-commit would. The screen query moves out of
assertDirtyConfigUserKVOnly into dirtyInternalConfigKeys so both paths share
it; the pre-pull refusal text is unchanged. Embedded aliases Commit, as its
CommitConfigOnly does.
Also softens the CommitConfigOnly interface doc (review nit): embedded mode
commits the whole working set, not only config.
Tests (server container): user kv.* rows commit; a dirty internal key is
refused with HEAD and the working set untouched.
* fix(storage): stage config's lookup-table projections with CommitConfigOnly (GH#4078)
Carry reconciliation for a change on main since #4383 was written:
SetConfig now writes status.custom into custom_statuses and types.custom into
custom_types in the same transaction as the config row (SyncConfigTables),
and reads of those sets are table-first. CommitConfigOnly staged config
alone, so `bd config set status.custom ...` in server mode would commit the
row and leave its projection dirty: HEAD would carry the new string with the
old lookup set, the split the projection exists to prevent. The
transactional SetConfig already marks the synced table dirty for this reason.
CommitConfigOnly now stages config plus issueops.ConfigProjectionTables(),
a list kept next to SyncConfigTables. Clean tables stage nothing, and the
projections are written only from config, so no other kind of work is
swept. CommitConfigUserKVOnly keeps staging config alone: memory rows have
no projection.
Test (server container): status.custom and types.custom writes leave
config, custom_statuses and custom_types all clean after CommitConfigOnly.
* fix(cli): commit config writes in server mode — remember/forget/config set (GH#4078)
In server mode nothing ever commits config-table writes: maybeAutoCommit
skips SQL-server modes entirely, and the explicit flush commands call
Commit(), which excludes config (GH#2455) and silently no-ops on a
config-only working set. Every bd remember / bd config set then strands
the working set dirty and the next 'bd dolt pull' fails with 'cannot
merge with uncommitted changes' until a manual raw-SQL flush.
commitConfigWrite commits the config table immediately after an
intentional config write, scoped via CommitConfigOnly so concurrent
operations' dirty tables are never swept. Server modes only — embedded
'-Am' auto-commit and the unflagged-writes sweep already cover config.
This restores the v1.0.1 always-commit behavior from PR #3052 that the
unified-PostRun refactor regressed.
Wired sites: bd remember, bd forget, bd config set, bd config unset,
bd config set-many (one commit for the whole batch). Commit failures
surface loudly per each site's error convention.
(cherry picked from commit 64f77a1963)
Carry note: rebased onto b1bee123b. config set/unset now write through the
WorkspaceConfig role and remember/forget through the memoryops role, so the
conflict resolution re-anchors each commitConfigWrite call right after that
site's noteDirectConfigWrite/noteDirectMemoryWrite (set-many: after its
direct-route store.SetConfig loop) and uses each RunE's current error
convention (return HandleError / HandleErrorRespectJSON instead of os.Exit).
No change to commitConfigWrite or its tests in this commit.
* fix(cli): reconcile commitConfigWrite with current main (GH#4078)
Carry reconciliation on top of the cherry-picked commit, for two things
that changed on main since #4383 was written:
- Proxied route: proxied mode never opens a store, and its WorkspaceConfig
and memory roles commit each write inside their own unit of work
(noteDirectConfigWrite / noteDirectMemoryWrite say so). commitConfigWrite
now returns early on usesProxiedServer() instead of relying on the nil
store, and the proxied test asserts the no-op.
- dolt.auto-commit: bd-4wamg made batch/off real deferral in server mode,
and #5830 made `bd dolt commit` commit config (CommitAll). A config write
under batch/off now defers with every other server-mode write instead of
committing regardless; mode on (the default) commits as before. This
matches embedded mode, where the PersistentPostRun auto-commit honors the
same setting.
The doc comment drops the stale "-Am auto-commit and unflagged-writes
sweep" wording and says why rename-prefix and migrate are not wired.
* fix(cli): commit remember/forget through the kv.*-screened variant (GH#4078)
Carry reconciliation for the #4383 review: bd remember and bd forget write
user kv.* data, so their server-mode commit now goes through
CommitConfigUserKVOnly via a new commitMemoryWrite helper. A dirty internal
config key from another writer is refused with the keys named and the
`bd dolt commit` remedy, instead of being swept into the memory's commit.
bd config set/unset/set-many keep CommitConfigOnly: the operator is writing
config deliberately there, the same trust level as `bd dolt commit`.
commitConfigWrite and commitMemoryWrite share one guard path
(commitConfigTable), so both no-op on embedded, proxied, and batch/off.
* docs: changelog entries for the GH#4078 config-commit fixes
Server-mode config writes (bd remember/forget, config set/unset/set-many)
now commit immediately via the scoped CommitConfigOnly, and the explicit
'bd dolt commit'/'bd vc commit' are config-inclusive and truthful.
(cherry picked from commit c412b96b96)
Carry note: rebased onto b1bee123b. The hunk's old context now sits in a
released section, so it is moved under [Unreleased] > Fixed. The second
entry (bd dolt commit / bd vc commit) is dropped: that fix landed separately
as #5830 (CommitAll) and is already in the changelog.
* docs(changelog): update the GH#4078 entry for the carried fix
Rewords the cherry-picked entry for what the fix does on today's main:
batch/off defer config writes like every other server-mode write, the
commit stages config's lookup-table projections, remember/forget are
screened to kv.*, and #4412's pre-pull commit now absorbs dirty kv.* rows,
so the pull-side symptom is a refusal on internal keys rather than the
merge error. Drops the #2455 link, which does not resolve in this repo
(the number is a source-comment reference).
* test(cli): pin server-mode config writes leave no config dirt (GH#4078)
User-level regression test for the carried fix, on the direct SQL-server
route against the suite's Dolt server: bd remember, bd config set
(status.custom), bd config set-many (types.custom + status.custom), bd
config unset and bd forget must each leave config, custom_statuses and
custom_types clean in dolt_status. A final step dirties an internal config
key out of band and checks that bd remember refuses, names the key, and
leaves config dirty for bd dolt commit.
On b1bee123b (without the fix) it fails at its first step:
after bd remember --key gh4078 server-mode memory: config left
uncommitted in the working set (GH#4078)
With memory writes routed through the unscreened commit, it fails at the
last step: bd remember committed over a dirty internal config key.
* docs(cli): say why config writes skip the kv.* screen (GH#4078)
commitConfigWrite stages every dirty config row, while commitMemoryWrite
refuses internal keys. Record the reason in the code, not only in the
commit history: bd config set/unset/set-many are deliberate config
writes, the same trust level as bd dolt commit.
* build(bazel): list the GH#4078 test files in BUILD srcs
The rows the Bazel / test job's 'BUILD files in sync' check printed at ec27abd1d. Without them the Bazel tiers never run config_commit_write_test.go, config_commit_server_integration_test.go or commit_config_test.go, and the server-Dolt storage tier fails its shard check for the six storage tests.
* fix(storage): say the kv.* write is already saved when the screen refuses (GH#4078)
When CommitConfigUserKVOnly refuses, the memory row's SQL transaction has already committed, so exit 1 read as 'not stored'. The refusal now says the write is in the working set and that bd dolt commit publishes it with those keys.
* fix(httpclient): add the scoped config commits to the no-op commit family
The PR adds CommitConfigOnly and CommitConfigUserKVOnly to
storage.VersionControl. Since the PR's merge base, main added
internal/httpclient, whose Store asserts storage.DoltStorage, so the
tree merged with main did not build (*Store does not implement
storage.DoltStorage: missing method CommitConfigOnly).
Add both methods to httpclient's commit family as no-ops, for that
family's D3 reason: a write over this client is durable once the server
answers, so there is nothing to flush, and refusing would fail a command
whose write already landed. Regenerate unsupported_gen.go: only its
trailer count moves (201 -> 203 methods), because both methods are
hand-written rather than stubbed. Extend the two tests that pin the
family by name, TestCommitFamilyIsNoOp and
TestCommitFamilyIsNotOnTheUnsupportedMap, to cover both methods.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Eddie the Engineer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: sms <114885497+seanmartinsmith@users.noreply.github.com>
* fix(config): screen the staged set, warn on refused memory commits (GH#4078)
Review fixes for the adopted PR, iterations 1 and 2.
CommitConfigUserKVOnly screened the working set on one pooled
connection and staged config on another, so an internal key written in
between (issue_prefix above all) was committed with a memory: the
GH#2455 hazard the screen exists to refuse. The screen, DOLT_ADD and
DOLT_COMMIT now share one pinned connection (stageAndCommit), and the
screen runs twice: on the working set before DOLT_ADD, and on what
DOLT_ADD actually staged after it, because sessions on one branch share
the working set. A refusal after staging unstages config again with
DOLT_RESET, so the refused rows are not left staged for the next commit
on the branch. Two residuals are documented at the code: another commit
path's own DOLT_ADD of config landing between the second screen and
DOLT_COMMIT is absorbed, as for every scoped commit, and the table-wide
reset can unstage such a commit's config staging. The refusal is now a
*storage.ConfigCommitRefusedError carrying the keys.
The two config-table commits also stop widening their staging list
with the versioned-history tables: a config write mints no version
rows, and that list's issues table swept concurrent issue work into a
config or memory commit.
bd remember and bd forget exited 1 after their write had landed
whenever a non-kv.* config key was dirty, including keys bd's own
unwired writers leave, such as the issue_prefix of bd rename-prefix.
They now warn on stderr with the keys named and exit 0, as v1.0.1
(#3052) did on a failed memory commit. Under --json they add
committed: false, commit_error and dirty_config_keys, only when the
commit did not happen, so a committed write's payload keeps its shape.
The CHANGELOG entry now says so instead of claiming that the refusal
restores the v1.0.1 behavior.
bd config unset of a yaml-only secret key deleted the credential row an
older bd had stored, but never committed the delete, so HEAD, which
bd dolt push publishes, kept the credential while --json reported
database_row_removed. The delete is now committed like any other config
write. A failed commit is a warning, and database_commit_failed under
--json, because the delete and the YAML unset both landed.
A commit error the store marks storage.ErrCommitIndeterminate, such as
a connection lost during DOLT_COMMIT, may have landed, so neither
surface reports it as a definite non-commit any more. --json adds
commit_indeterminate (remember, forget) or
database_commit_indeterminate (the secret-row unset) beside
committed: false and database_commit_failed, which stay, so a consumer
that reads only those is still told to commit; the secret-row warning
and the note a failed YAML unset carries say the removal may not be
committed and point at bd dolt commit.
commitConfigWrite's doc now says why a failed commit fails the config
verbs while the memory verbs only warn, and names bd kv set/clear and
the kv.memory rows bd import writes as config writes it does not wire
yet. CommitWithConfig's interface doc drops bd config set, which on
the SQL-server route now commits through CommitConfigOnly, and points a
command committing only its own config write at the scoped commits.
Tests: a live-store test writes an internal key between the screen and
DOLT_ADD and requires a refusal that moves no HEAD and leaves nothing
staged; a sqlmock test pins the refusal SQL, including a failed
unstage; a versioned-history-on test requires a dirty issues table to
stay dirty through both scoped commits; cmd/bd fakes pin the
warn-and-succeed contract, the JSON fields, the secret-row commit, and
the indeterminate qualifiers in both payloads and both texts; and the
server E2E gains a secret-row step plus a bd rename-prefix step ahead
of bd remember and bd forget.
Pre-approval CI repair: tools/nogo/unvalidated_integration_tests.txt
now lists the PR's integration-tagged
cmd/bd/config_commit_server_integration_test.go. Since #7486 no nogo
lane analyzes integration-tagged test files, and
TestUnvalidatedIntegrationTestsFileIsExact requires the list to name
every one of them, so the new file failed //scripts:nogo_integration_scan_test
in the Bazel test and integration lanes.
Left for follow-ups, both pre-existing and not changed here: the
review's projection minor (config delete paths do not reconcile
custom_statuses/custom_types), and committing bd kv set/clear and
bd import's kv.memory rows on the SQL-server route.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: sms <114885497+seanmartinsmith@users.noreply.github.com>
---------
Co-authored-by: Aaron Lippold <lippold@gmail.com>
Co-authored-by: sms <114885497+seanmartinsmith@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
* fix(doctor): detect parent→child hierarchy-blocking deps
checkChildParentDependenciesDB and --fix-child-parent only matched
child→parent blocks edges. parent→child blocks (bd dep add parent child)
deadlocks ready-work the same way but was invisible to doctor (GH#4814).
Extend the SQL predicate and fix to both directions; reword messages.
Fixes#4814
* fix(doctor): require real parent-child edge for reversed-direction detection
Addresses bee-ghosttrack's CHANGES_REQUESTED review on PR #5131:
- The parent->child arm added for GH#4814 flagged/deleted any dotted-ID
pair regardless of whether a real parent-child edge existed, so a
healthy "epic blocks on an orphaned-dotted subtask" edge (no
structural link, e.g. after a reparent or import) was misclassified
as a deadlock and deleted alongside genuine ones. Both the checker
(cmd/bd/doctor/validation.go) and the fixer
(cmd/bd/doctor/fix/validation.go) now require an EXISTS parent-child
edge for that arm; the legacy child->parent arm stays prefix-based
since it's already write-time-guarded.
- Added a reversed-direction destructive test (real parent-child edge +
waits-for deadlock, since blocks/conditional-blocks in this direction
are already rejected at write time once a real edge exists) and a
survivor test (dotted ID, no real edge). Both were verified to fail
against the pre-fix query and pass against the fix.
- Tagged detected rows with their direction (child->parent /
parent->child) in doctor output, and reworded the agent/CLI-facing
messages that only described the child->parent direction.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(doctor): keep Child-Parent scoped to child→parent edges
This PR taught the Child-Parent check and `bd doctor --fix
--fix-child-parent` to also match a parent that blocks on, or waits
for, its own child (#4814: "either direction deadlocks"). Since #6602
(gastownhall/beads#6506) the parent-child cascade propagates only
exogenous blockedness, so that edge holds back the parent, not the
child: it is a close gate. On a base with #6602 the new arm warned
"may cause deadlock" on working gates, and the fixer deleted them,
after which the parent could close before its children.
That holds while every parent-child chain up from the gated child
reaches the parent within the cascade's four-level walk (issueops
subtreeWalkDepth). A gated child that also has a parent outside the
gating parent's subtree is still locked out of bd ready while doctor
reports OK. That is a cascade defect, tracked as bd-eoxqs0, not a
reason for doctor to delete the gate, so this change refers to #4814
rather than fixing it.
Restore cmd/bd/doctor.go, doctor/agent.go, doctor_fix.go,
doctor/validation.go and doctor/fix/validation.go to main. The check,
its fixer, the flag help and the agent enrichment keep their
child→parent scope and wording, and the generated CLI docs match again.
Parent Close Gates (checkParentBlocksOwnChildDB) stays the one owner of
the parent→own-descendant shape. A comment at both query sites says why
the reverse shape is not matched and names the cascade's two limits.
Replace the two tests that encoded the expired premise with behavioral
ones, built the way `bd create --parent` writes a tree (dotted ids and
real parent-child edges): a live waits-for gate onto one child and a
legacy raw blocks row onto another. With the is_blocked flags inverted
first, a full recompute leaves the children ready and the parent
blocked; Child-Parent stays OK; Parent Close Gates lists the blocks row;
and the --fix-child-parent pass, through the blocked-state recompute
that runs last, keeps every edge and restores every flag. Against the
PR's previous code both tests fail: the check warns on both gates, and
the fixer deletes both rows and leaves the parent ready. The
dotted-id-only tests from this PR stay as scope pins.
Refs #4814
Refs #5131
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Vishnu Jayavel <vishnuj81093@gmail.com>
---------
Co-authored-by: Vishnu Jayavel <vishnuj81093@gmail.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
* fix(federation): treat missing peer row as credential-free remote
federation status/fetch failed with "failed to get peer credentials:
not found: federation peer origin" when the Dolt remote existed but no
federation_peers credential row was stored (add-peer without --user, or
sync.remote bootstrap). That made status report Reachable=false while
bd dolt pull/push succeeded (GH#4837).
withPeerCredentials now treats storage.ErrNotFound as empty credentials
so normal Dolt credential discovery applies. Decryption and other errors
remain fatal.
Fixes#4837
* test(federation): cover withPeerCredentials missing-row path; expect Dolt unknown-remote error
TestFilteredPushUsesDedicatedLongTimeoutConnection asserted the pre-fix
"failed to get peer credentials" error for "nonexistent-peer". Under this
PR a name with no federation_peers row is a credential-free remote, so the
push proceeds to Dolt and fails there with "remote 'nonexistent-peer' not
found". Assert that instead; waitForPoolWait and
assertFederationStagingBranchAbsent are unchanged.
Add TestWithPeerCredentialsMissingPeerRow (server mode, skipIfNoServer):
withPeerCredentials on a name with no row invokes fn exactly once with nil
credentials and returns fn's result; a peer stored with credentials still
delivers them to fn. Deleting the new branch in withPeerCredentials now
fails the test.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* test(federation): build credentials_peer_test.go under Bazel; e2e row-less remote test (#5128 review)
Maintainer fixup on top of the contributor's two commits, from the
adopt-pr review of #5128 (iterations 1 and 2).
- internal/storage/dolt/BUILD.bazel: list credentials_peer_test.go in the
dolt_test srcs. The target lists its srcs explicitly, so the new file
was never compiled into the Bazel test binary, and the required "BUILD
files in sync" step (make bazel-sync, then git status) would red
BAZEL_TEST and the CI Gate. The step body now reports no drift.
- TestFederationVerbsWithoutPeerRow: the end-to-end case #4837 reported.
The remote is registered with AddRemote alone (no federation_peers row);
PushTo, Fetch and PullFrom must succeed against it, Fetch must move
remotes/peer/main to the peer's HEAD, the pull must merge the peer's
issue, and no peer row may appear. With the fix reverted it fails at
PushTo with "failed to get peer credentials: not found: federation peer
peer"; with Fetch made a no-op it fails at the tracking-ref check.
- withPeerCredentials doc comment: record the mistyped --peer trade-off
(the name reaches Dolt, which rejects it), and that a name check added
in front must consult PersistedRemoteInfos as well as ListRemotes so
the GH#2118 cold-start window is not rejected.
- CHANGELOG [Unreleased] Fixed entry for #4837. It names the bd
federation verbs only: bd dolt push/pull --remote go through
PushRemote/PullRemote, which never look up a peer row, so they were
not affected.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Vishnu Jayavel <vishnuj81093@gmail.com>
---------
Co-authored-by: Vishnu Jayavel <vishnuj81093@gmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
* test(delete): pin that a stale id never deletes the issue it prefixes (be-ksd)
bd delete resolves each id through the abbreviation-tolerant resolver
(resolveAndGetIssueForMutation -> utils.ResolvePartialID). When the exact
id is absent, that resolver falls through to leading-prefix abbreviation,
so an id that was already deleted resolves to a different issue whose id
it happens to begin, and --force deletes that issue.
The shape is ordinary: hash length is adaptive (3 to 8 characters) so a
grown store holds short ids beside longer ones, --id makes any shape, and
a hierarchical child's id always extends its parent's. On a fixture, after
fx-t00003 was deleted, bd delete fx-t00003 resolved to fx-t000031; a
re-run of a finished --from-file list with --force --quiet deleted two
issues it never named, silently.
The test drives deleteCmd in-process against a stub DoltStorage (no cgo,
no Dolt server) and records every request handed to the Deleter role. It
covers the single-id --force path, the preview, a deleted parent's id with
an orphaned child, the --from-file batch path, and an abbreviation of one
and of two live issues; each refusal must say delete needs the full id
and name the ids the input matches. An over-refusal guard checks that
exact ids (full, bare hash, child, batch) still delete exactly what they
name. The six refusal cases fail at this commit; the guard passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5-5 on behalf of A3Ackerman
* fix(delete): resolve ids exactly, never by prefix abbreviation (be-ksd)
bd delete's direct route resolved each id with the abbreviation-tolerant
resolver, so an id that no longer exists resolved to the surviving issue
whose id it begins, and --force deleted that issue. Both of its resolution
sites now use resolveAndGetIssueForMutationExact (#5393's exact sibling,
until now used only by bd comment): the inline single-id path and
deleteBatch, which --from-file, multiple ids and --cascade take.
The resolver cannot tell a stale full id from an abbreviation. Hash length
is adaptive with store size, so one store holds 3- to 8-character ids side
by side and "fx-t00003" is both a valid full id and a valid abbreviation
of "fx-t000031". The rule therefore has to be per command, the way #5393
made it for bd comment. Delete is exact on both preview and --force: the
preview prints the next command to run ("To proceed, run: bd delete
fx-t000031 --force"), so a tolerant preview hands the caller the wrong
deletion to confirm.
This matches the team-server route, which passes ids to issueops.Deleter
unresolved, and DeleteRequest.IDs' own contract ("IDs ARE EXACT"). The
partial-ID notice (#6302) did not protect this path: --quiet silences it,
and a --force --quiet re-run of a finished --from-file list deleted two
issues it never named.
The refusal says what to do: "bd delete needs the full issue id: no issue
has the id "t000", which is the start of fx-t000031". To name the matches,
ResolvePartialIDExact now returns *utils.AbbreviatedIDError, which carries
the input and the sorted matches, wraps ErrAbbreviatedIDNotAllowed and
keeps the old error text, so bd comment's errors.Is checks and messages
are unchanged.
Cost: bd delete <abbreviation> is refused, naming the full ids, so the
caller retypes one. Exact ids, bare full hashes, child, cross-prefix and
routed ids resolve as before. The other deleteBatch callers (cleanup, wisp
gc, mol burn) pass full ids read from the store, so nothing changes for
them except under a race, where they now refuse instead of reaching a
neighbor. Reads and other writes keep abbreviation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5-5 on behalf of A3Ackerman
* docs(ids): say bd delete requires the full id, like bd comment (be-ksd)
The Working with IDs section named bd comment as the one command that
refuses abbreviations and said every other mutation keeps them. bd delete
now requires the exact id too, so the section covers both, says why a
delete reaches the wrong issue so easily (an already-deleted id is still
the start of its child's id, or of a longer hash), and adds the bd delete
lines to the example block. Best Practices #1 names both commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5-5 on behalf of A3Ackerman
* docs(changelog): link the bd delete exact-id entry to #7375 (be-ksd)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5-5 on behalf of A3Ackerman
* fix(delete): report a gone parent's id as a lost race under --if-revision (be-ksd)
Review-loop iteration 1 for #7375: a maintainer fixup on top of the
contributor's branch.
Major (codex+claude): a guarded `bd delete --if-revision` whose target
was deleted, and whose id is still the start of a surviving id (a gone
parent with a live <parent>.1 child), exited 1 with the abbreviation
refusal. Any other gone target gets the documented lost race
(precondition_failed, exit 13), and gascity's conditional deletes
switch on that code, so a benign race read as a hard failure.
- reportIfRevisionTargetGone (the single-id path) also takes
utils.ErrAbbreviatedIDNotAllowed as a gone target: under delete's
exact resolution that id names no row either.
- The refusal is a typed error, deleteAbbreviationError, that unwraps
to storage.ErrNotFound beside the *utils.AbbreviatedIDError, so the
--cascade caller of deleteBatch classifies it through
reportIfRevisionFailure the same way. errors.New(msg) dropped every
sentinel.
Minor (claude), taken: the refusal leads with the not-found fact,
`issue "t000" not found: bd delete needs the full issue id, and "t000"
is only the start of fx-t000031`, so gascity's isBdNotFound reads an
already-gone full id that begins a survivor's id as the idempotent
not-found it reads for any other gone id. The CHANGELOG entry quotes
the new text and the --if-revision outcome.
Minor (gemini), declined: threading the source command into the
refusal's wording. deleteBatch's other callers (bd cleanup, wisp gc,
mol burn) pass store-minted full ids that no user retypes, and the text
now leads with "issue X not found", which holds for every caller.
Tests:
- TestDeleteIfRevisionGoneIDThatPrefixesAnotherIssue: single id,
--json, --cascade and --cascade --json each exit 13 with "precondition
failed: issue no longer exists" and the precondition_failed body,
never the refusal text, and the guarded write never runs. Two
no-survivor rows are the plain gone id they must match.
- TestReportIfRevisionTargetGone: abbreviation rows, guarded and not.
- TestDeleteRefusesStaleIDThatPrefixesAnotherIssue also asserts the
refusal says "not found".
- TestEmbeddedIfRevisionDeletePreflightGoneParentIsPreconditionFailed,
end to end on embedded Dolt: delete a parent, its child survives and
`bd show <parent>` resolves to it; a guarded delete of the parent
exits 13 on the single-id and --cascade paths and leaves the child.
The TestEmbedded name is what puts it in a CI lane; its line in
embedded-cmd-test-shards.txt is the generator's incremental --write.
Mutation checks, each reverted afterwards: dropping the
ErrAbbreviatedIDNotAllowed match fails the single-id cases and the
abbreviation_guarded row; dropping ErrNotFound from Unwrap fails the
--cascade cases; dropping "not found" from the text fails every
refusal case; reverting both fixes fails both embedded legs (exit 1,
the refusal text, no "precondition failed").
Validation: the focused delete and if-revision tests; the embedded pair
under BEADS_TEST_EMBEDDED_DOLT=1; the scripts shard-manifest policy
tests and the generator's --check; gofmt; git diff --check. The full
./cmd/bd and ./internal/utils packages (-short, BEADS_TEST_SKIP=dolt)
pass but for TestRunApplyAllOK, which fails only because this worktree
sets core.hooksPath=/dev/null ("mkdir /dev/null: not a directory") and
passes with core.hooksPath overridden.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
* fix(resolver): use last-segment prefix match to prevent wisp substring collision
When two beads share overlapping hash fragments (e.g. gcy-oqf and
gcy-wisp-goqfo), the previous strings.Contains check incorrectly matched
"goqfo" as containing "oqf" and silently returned the wrong bead.
The fix changes the fuzzy match from substring containment to a
last-dash-segment prefix comparison:
lastSegment("wisp-goqfo") = "goqfo" → HasPrefix("goqfo","oqf") = false
lastSegment("wisp-t3st") = "t3st" → HasPrefix("t3st","t3st") = true
This preserves the intended use case (resolving wisps by their trailing
segment, e.g. "t3st" → "bd-wisp-t3st") while eliminating false
substring hits.
Also adds BD_NO_FUZZY env var: when set, partial resolution is skipped
and only the exact-ID fast path runs. This lets callers opt out of all
fuzzy matching when they need strict lookups (e.g. to avoid cache-lag
ambiguity).
Fixes: gcy-g4o (fuzzy short-ID resolver silently redirects to wrong bead)
* test(resolver): pin prefix-only semantics for plain-hash partial match
* fix(resolver): restore leading-prefix ID matching, pin gcy-g4o cases
#4939 already made partial matching leading-prefix only (strings.HasPrefix
in place of strings.Contains at both call sites), which is what fixed the
gcy-g4o collision: gcy-oqf can no longer resolve to gcy-wisp-goqfo through
the substring "oqf".
The last-dash-segment matcher added on top of that compared only the text
after each id's last dash, so inputs naming no issue resolved to unrelated
beads: hr-8wnq to a local bd-8wnq2 (which also pre-empts its hr- prefix
route), gcy-wisp-g4o to gcy-g4oab, and a trailing dash to any hash. The
first loop also began claiming wisps as abbreviations, so an exact bare
wisp hash turned ambiguous beside a longer sibling. Restore main's matcher
and remove hashSegmentPrefixMatch and lastDashSegment.
Drop BD_NO_FUZZY and its test. The gate returned before prefix
normalization, so documented exact forms such as a bare hash failed, and
it skipped the ErrAbbreviatedIDNotAllowed sentinel that callers branch on.
Exact-only resolution already exists as ResolvePartialIDExact; a
user-facing strict mode is left as a follow-up.
Keep the gcy-g4o regression tests, reworked so they reach the partial
matcher:
- TestResolvePartialID_WispSubstringCollision stores only the wisp, so
gcy-oqf and oqf must miss instead of hitting the exact fast path.
- TestResolvePartialID_WispLastSegment adds a longer wisp sibling, so the
wisp fallback's exact branch is what resolves t3st.
Add Docker-free and routed coverage:
- TestResolvePartialID_FakeStore_QualifiedInputsNeverResolveToAnotherBead:
hr-8wnq, gcy-wisp-g4o, bd-wisp-t3, abc, bd-ol-, aap- and - stay
not-found on both resolvers, each beside a control abbreviation that
resolves.
- TestResolvePartialIDMatchesLeadingPrefixOnly,
TestResolvePartialIDSilentOnExactWispHash and
TestResolvePartialIDNotifiesOnWispHashAbbreviation replace the
helper-level tests.
- TestRoutedResolutionLooksPastLocalNearMiss: hr-8wnq reaches its hr-
route despite a local bd-8wnq2, on the read and mutation paths.
With the last-segment matcher swapped back in, the table test (7 of 8
cases), the routed test, TestResolvePartialIDSilentOnExactWispHash and
TestResolvePartialID_WispLastSegment fail. With strings.Contains, the
table test (4 cases), TestResolvePartialIDMatchesLeadingPrefixOnly,
TestResolvePartialIDSilentOnExactWispHash and
TestResolvePartialID_WispSubstringCollision fail.
Co-authored-by: Saren <saren@dumstruck.com>
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Saren <saren@dumstruck.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* perf(schema): probe per-open sentinel tables with SHOW TABLES, not INFORMATION_SCHEMA.TABLES
Every bd open runs cursorRealityFloor and the ignored-cursor gate, and both
asked INFORMATION_SCHEMA.TABLES whether a table exists: the sentinel tables
(wisps, wisp_dependencies) and the untrack scratch table. Dolt does not push
the TABLES predicate down any more than the COLUMNS one, so each probe walks
the catalog of every database on the server.
Measured 2026-10-08 on a shared dolt sql-server (dolt 2.1.10, 9 databases,
about 12 to 17 bd opens a second, on a v1.3.1 line that also carries three
floored sentinel tables): the server ran at 365 per cent CPU and these
existence probes were the largest single class of running statements. A
debug query log of one `bd list`, `bd ready` and `bd show` against a warm
proxied server shows 10 INFORMATION_SCHEMA statements per open before; with
this change and the sentinel-column change (#7297), 3. The statement count
per command is unchanged.
showTableExists reads SHOW TABLES LIKE with an exact name compare ('_' is a
LIKE wildcard). SHOW TABLES errors when no database is selected, so it is
used only where the session is already on the target database: the
sentinels run after the cursor probe has found the cursor table, and
readIgnoredCursorState runs after selectTargetDatabase or MigrateUp's
preparation. The cursor-existence probe in currentVersion keeps the
INFORMATION_SCHEMA form, because it must succeed on any session (be-bv7x).
Repair paths keep schemaTableExists; they run once per migration.
TestShowTableExistsMatchesInformationSchemaOnDolt checks the two forms agree
on a real Dolt for a present table, an absent one, a dolt_ignored
working-set table and a LIKE lookalike; the sqlmock helpers move to the SHOW
TABLES form. Stacked on #7297 (the sentinel-column change), which it depends on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebased onto #7592 (which carries #7297): main has since added the floored
sentinel tables (events, bd_events_journal, bd_events_seq) and #7592 the
leases carrier read, all through sentinelTableExists, so their ordered
sqlmock expectations move to expectShowTable too; lock_test.go conflicted
only on expectIgnoredSentinelProbes.
(cherry picked from commit ca0e921348)
* test(schema): pin the per-open table probes to INFORMATION_SCHEMA's answers
Red half of finishing the per-open INFORMATION_SCHEMA.TABLES removal on
top of #7409. Two gaps against the count the probes replace, both
measured on dolt 2.1.8 and 2.2.0:
- Case. INFORMATION_SCHEMA (like every table reference) matches table
names case-insensitively, but Dolt's SHOW TABLES LIKE filter does not:
a sentinel stored as BD_EVENTS_SEQ reads as absent, so the ignored
cursor clamps to 21 and the tail replays on every open (its creators
are INFORMATION_SCHEMA-guarded, so the replay never heals it).
- The cursor-existence probe in currentVersion is still an
INFORMATION_SCHEMA.TABLES read, issued six times per bd update (~25-30
ms each on a server hosting 28 databases). It must succeed on any
session (be-bv7x), and SHOW TABLES fails with no database selected
(1105) or on a session whose database was dropped (1049).
Tests:
- TestShowTableExistsAnswersLikeInformationSchema: the unfiltered listing,
names compared case-insensitively; a '_' lookalike is not the table.
- TestCurrentVersionWithoutAUsableDatabaseIssuesNoFailingStatement: the
schemata read answers 0 and nothing follows it.
- TestShowTableExistsMatchesInformationSchemaOnDolt (from #7409) now
covers every per-open probe name under bd's own dolt_ignore patterns,
a LIKE lookalike and a table stored in another case.
- Real sql-server: TestShowTablesProbes_SeeIgnoredTablesInAnyCase (a
migrated store's cursors are believed on a fresh session, also with
bd_events_seq stored as BD_EVENTS_SEQ) and
TestCursorProbe_NoDatabaseSessionStaysUsable.
- The cursor-probe sqlmock helpers (schema, uow, cmd/bd) expect the
schemata read and the SHOW TABLES listing.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(schema): drop the last per-open INFORMATION_SCHEMA.TABLES reads
Finishes what #7409 starts. After it, every bd write still made six
INFORMATION_SCHEMA.TABLES point reads, all of them the cursor-existence
probe in currentVersion (5x schema_migrations, 1x
ignored_schema_migrations). Dolt does not push that predicate down: each
costs 25-30 ms on a sql-server hosting 28 databases, against ~0.6 ms for
SHOW TABLES or the schemata read (dolt 2.1.8; same on the shared server).
- currentVersion probes the cursor through tableInCurrentDatabase: an
information_schema.schemata read for DATABASE(), then SHOW TABLES. The
probe must succeed on any session (be-bv7x), and SHOW TABLES fails with
no database selected (1105) or on a session whose database was dropped
(1049); the schemata read answers 0 in both cases, which reads the
cursor as absent exactly as the TABLES count with
TABLE_SCHEMA = DATABASE() did.
- showTableExists reads the unfiltered SHOW TABLES listing and compares
names case-insensitively. Dolt's LIKE filter on SHOW TABLES is
case-sensitive while the INFORMATION_SCHEMA count (and every table
reference) is not, so the LIKE form read a sentinel stored as
BD_EVENTS_SEQ as absent and replayed the ignored tail on every open.
Without a LIKE pattern the '_' wildcard concern goes away too; the
listing is one round trip either way (34 rows, ~0.6 ms).
Verified equal to the INFORMATION_SCHEMA count on dolt 2.1.8 and 2.2.0
for every per-open probe name under bd's dolt_ignore patterns, on a
fresh session, after DOLT_CHECKOUT, on a revision database, with the
DSN database name in another case, with no database selected and on a
dropped database. The unit test gains a name-containing-the-table case
(events vs bd_events_journal).
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(schema): state the probes' preconditions; pin the 1049 cursor case
Review fixups for the per-open SHOW TABLES probes.
- readIgnoredCursorState and its alreadyConverged call site still
described the scratch probe as an always-succeeding information_schema
read bounded to one row. It is now an unfiltered SHOW TABLES listing,
which fails with no database selected (1105) or on a dropped database
(1049), so the doc states the precondition both callers meet: the
session is already on the target database. The HEAD half's dolt_ignore
read is named too; it runs only when the cursor is tracked at HEAD.
- tableInCurrentDatabase documents that its guard is check-then-act: a
DROP DATABASE between the schemata read and SHOW TABLES still pins the
session, and on a *sql.DB the two reads can land on different pooled
connections, so every connection in the pool must be on one database.
- TestCursorProbe_DroppedDatabaseSessionStaysUsable is the 1049 half of
the no-database server test: USE a database, drop it from another
connection, then CurrentVersion must answer 0 without an error and the
session must still see a database and table created afterwards.
Probing the cursor with the bare SHOW TABLES prober fails it with
"Error 1049 (HY000): database not found" (dolt 2.1.8).
- expectRemoteBackedSharedProbe uses `for range 2`, like its twin in
migrate_consent_test.go.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Sauer <csauer02@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(storage): carry closed_by_session through the domain/UOW writer
Rebased onto current main, which changed what this PR needs to be.
The original diff added closed_by_session to the shared select/scan/
insert column sets (sqlbuild.IssueSelectColumns, issueops.ScanIssueFrom,
insertIssueIntoTable, issueUpsertColumns). All of that landed upstream
independently in #5191, so those hunks are dropped rather than
mechanically re-resolved against the lease-overlay refactor (0055) and
the row_lock/RowVersion hydration that arrived with it.
What is still missing on main is the second writer: db.insertIssueRow,
the domain/UOW statement behind proxied create, batch create and import,
whose column list contains no closed_by_session — not in the INSERT, not
in the ON DUPLICATE KEY UPDATE. The schema defaults the column to '' and
the now-shared scanner faithfully reads back whatever was stored, so a
proxied create silently discards the closing session while the same
issue created through the classic path keeps it. That is the GH#4662
data loss, still live, just relocated.
Add the column to insertIssueRow's insert, values and upsert
assignments, and note at the chokepoint why the two writers' column
lists have to stay in step.
Tests:
- Three new cases in the domain/db suite (real Dolt): insert -> get
preserves closed_by_session on the issues table and on the wisps
table, and the upsert rewrites it rather than keeping a stale value.
All three fail against main and pass with the fix.
- The conformance case PromoteClosedWispPreservesSession from the
original commit is kept: it runs on every backend and is the
end-to-end GH#4662 regression (close a wisp with a session, promote,
assert the session survives).
The nit about test comments asserting closed_by_session is absent from
IssueSelectColumns no longer applies — those comments are gone from
main, and the scan-parity fixture already counts 52 columns including
closed_by_session.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(storage): name insertIssueRow's real callers and pin the upsert clear
Only Insert without CreateOnly reaches insertIssueRow: the CreateIssue
callers that leave CreateOnly unset, such as the quick, todo and gate
proxied servers and the create op of a proxied `bd batch` script.
Proxied create and the unit-of-work batch creator and applier set
CreateOnly, so they insert through the classic writer, and import and
promotion use the classic writer too. That writer and the shared scanner
have carried closed_by_session since #5191.
So the previous commit closes a latent gap in the second writer rather
than a loss on proxied create or import, and GH#4662's closed-wisp
promotion loss was already fixed by #5191. The conformance case is that
issue's regression test: it passes without the domain writer change,
which the domain/db Insert tests pin instead.
- Reword the insertIssueRow comment and the domain/db test docs to name
the callers that reach the statement and its upsert half.
- Say in the PromoteClosedWispPreservesSession header that it guards the
classic path only.
- Add UpsertClearsClosedBySession: rewriting a closed row with an open
one must clear the stored session, not leave an open row with a stale
closing session. It fails if the upsert keeps the stored value when
the incoming one is empty.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Harry Miller <harry_miller@trimble.com>
---------
Co-authored-by: Harry Miller <harry_miller@trimble.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
* fix(wisp gc): apply the --age test to cascade children
`bd mol wisp gc --age` promised, in its own help text, that a wisp counts as
abandoned when it "has not been updated within --age AND is not closed".
Parents were held to that contract; children reached through the cascade were
not. A child was deleted purely because something it transitively depended on
was old, so `--age` meant nothing for children at all.
Raising the threshold is not a workaround: with `--age 720h`, a step created a
moment ago is still destroyed when its parent is older than 720 hours.
Observed blast radius: a molecule slung seconds earlier went down with all nine
of its steps — 43 beads in a single run — and the agent's hook emptied
instantly. Two rigs of three were hit; the third survived only because a stop
order reached it first.
Steps already picked up have been covered by `isProtectedWisp` since #4430, but
a freshly created step is still `open`, and `open` maps to CategoryActive, which
that guard deliberately does not protect. This closes the remaining path.
Tests: cascade deletion of a stale parent no longer takes a fresh child, and
raising --age does not save one either.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(wisp gc): stop re-cascading at delete time; pin the age contract in the proxied test
The integration test update Steve asked for surfaced that the selection fix
alone was incomplete: findAbandonedWisps now respects --age for cascade
children, but both delete paths re-derived the cascade at delete time and
swept fresh children past that filter anyway:
- embedded path: deleteBatch was called with cascade=true
- proxied-server path: DeleteIssuesParams{Cascade: true} re-expanded via
FindAllDependents in the domain layer
Both now delete exactly the set findAbandonedWisps selected — the selection
is the single place the --age contract lives.
Test cascade_sweeps_dependent_step_wisps is reshaped per review into
cascade_respects_age_for_dependent_step_wisps: a second child backdated past
the threshold IS swept (cascade still collects genuinely abandoned children),
the fresh child is absent from deleted AND still present in the wisps table
(the table-level check is what caught the delete-time re-cascade).
Verified against the shared dolt container (BEADS_TEST_PROXIED_SERVER=1):
TestProxiedServerWispGC all four subtests pass; TestWispGC* unit tests pass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(wisp gc): age cascade children with wispIsAbandoned
Adopting #5219 onto main, which landed two changes after this PR was
written:
- #7246 (fixes#7236) moved the parents' age check onto
wispIsAbandoned, so --age 0s still collects a wisp whose DATETIME(0)
updated_at rounded up to half a second into the future. The PR's child
check kept the raw now.Sub(updated_at) <= threshold skip, which
re-opens #7236 for cascade children: under --age 0s a step closed in
the same second as the gc was left behind, orphaned, while its
abandoned parent was deleted. Children now take the parents'
predicate, so "the same --age contract as parents" holds; positive
thresholds behave exactly as before.
TestWispGCCascadeChildAgesAtStoragePrecision pins it at storage
precision and fails on the raw comparison.
- #5735 had already turned the delete-time cascade off on both gc
routes (GH#4394), so the PR's second commit now carries only its
proxied-test reshape. Main's delete-site comments gain that commit's
reason alongside GH#4394: a cascade there would also sweep fresh
children past the --age filter.
Also lists the PR's new wisp_gc_cascade_age_test.go in cmd/bd/BUILD.bazel,
which gazelle requires.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: mayor <6847071@gmail.com>
Co-authored-by: AB <6847071@gmail.com>
* docs(wisp gc): document the cascade's age policy; test it with a closed child
Review fixes for #5219, apply-fixes iteration 1.
- The 'bd mol wisp gc' help and the CHANGELOG now say what happens to
the dependents of an abandoned wisp. They are deleted with it only if
they meet --age themselves and are not live work, closed ones included
even without --all. A dependent that is too young is spared, and both
delete routes drop its edge to the deleted wisp, so an open one is
collected once it ages out and a closed one is left for --all,
--closed or bd purge: without --all the parent scan skips closed
wisps.
- A comment by the child loop in findAbandonedWisps says dependents are
exempt from the parent scan's not-closed clause, so a change that
aligns the two loops does not quietly leave an abandoned molecule's
finished steps behind.
- TestWispGCCascadeRespectsAge and the proxied subtest
cascade_respects_age_for_dependent_step_wisps close their stale child.
An open one was collected by the parent scan, so both passed with the
cascade disabled. With the child closed, a mutant that skips every
cascade child fails both.
docs/CLI_REFERENCE.md and docs/cli-reference/ are not regenerated: they
are built from the v1.2.2 pin in docs/cli-docs.pin.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: mayor <6847071@gmail.com>
Co-authored-by: AB <6847071@gmail.com>
---------
Co-authored-by: mayor <6847071@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
* fix(http): bd gate check over http through issueops.ListGates
gate check listed its open gates with a raw SearchIssues filter (gate type,
closed excluded, --limit), which the HTTP backend refuses, so the command
failed before reading a gate on a remote scope and gc's core gate-sweep order
(bd gate check --type=timer --escalate) failed every tick there.
The listing now goes through issueops.ListGates over openQuerier on the
direct and proxied routes, the same entry bd gate list took in S20 (#7549):
the same question, served as queryIssues by every deployed server. The close,
the bead-gate target read and sighting, the pure timer arm and the gh/gt execs
are unchanged. The gh:run discovery's await_id persist still refuses on the
wire and counts as that gate's error.
The served corpus gains mc-gate-check-timer, mc-gate-check-gh (gate-sweep's
argv) and gate-check-all. No seeded gate carries an await type, since no wire
create accepts await_*, so these prove the listing is served.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(gate): name both refused gate check writes; close gate's filter hole
Review fixes for #7578 (apply-fixes, iteration 1).
CHANGELOG, minor (taken): the entry said a bead gate's sighting was
already served over HTTP. It is not. evaluateBeadGate records the first
sighting (await_seen) through recordSeen, which calls the raw
store.UpdateIssue (cmd/bd/gate.go:675). The HTTP Store has no UpdateIssue
override, so its embedded unsupportedDoltStorage refuses the call in the
client before any request is sent (internal/httpclient/unsupported_gen.go),
exactly as it refuses the gh:run discovery's await_id persist. "Refuses on
the wire" was wrong for the same reason. The entry now names both writes
and keeps "counts as that gate's error" (applyGateCheckResults counts
r.err). The sighting is written only when the check finds the awaited
bead, not yet closed, in the gate's own store; inspectBeadGate sets
seenHere only there.
CHANGELOG, nit (taken): `bd gate check --limit -1` used to list every
open gate on the direct and proxied routes, because the raw search
emitted no LIMIT clause for a negative limit. The listing now goes
through issueops.ListGates, whose Querier rejects a negative limit as
ErrValidation, and the HTTP server rejects it too
(internal/httpapi/query.go). The entry says so.
.golangci.yml, minor (taken): at this head cmd/bd/gate.go and
gate_proxied_server.go name no filter type (one each at the base), so
their slot in the cmd/bd forbidigo family only kept a hole open. `gate`
leaves the alternation, with a "LEFT this list" note like the ones for
search, status and count. gate_discover keeps its own hole:
findPendingGates still builds the raw filter.
Declined:
- bd gate discover still refuses over HTTP in findPendingGates (minor):
the synthesis' first remedy is no change in this PR, and the file is
not in this PR's diff. Finalize files the follow-up to move it onto
ListGates.
- the proxied listing is not pinned on its own (nit): it calls the same
listOpenGatesForCheck as the direct route (gate_proxied_server.go:106),
and the synthesis calls accepting the gap defensible.
- listOpenGatesForCheck/listOpenGatesWith naming (nit): the remedy is
"leave as is".
Verified:
- git diff --check: clean.
- bazel build --config=nogo -- //cmd/bd:all on the edited config: 16
targets, exit 0.
- Probe, then reverted: a types.IssueFilter literal in gate.go and a
types.WorkFilter literal in gate_proxied_server.go each failed nogo
with forbidigo's "do not write a filter here", so the hole is shut.
- git merge-tree against the heads of all 102 other open PRs that touch
CHANGELOG.md or .golangci.yml (today's census): this commit changes
no conflict count in either file. 43 PR/file pairs already conflict
with or without it.
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
daysAge only checked the upper bound (maxOlderThanDays) before
multiplying by 24h. A day count negative enough overflows the
int64-nanosecond multiplication into a small positive duration, so
positiveAge's own check never sees the sign flip: `bd purge
--older-than=-213503d --force` purged every closed row older than a
day instead of being refused. Reject non-positive counts before the
multiplication can run.
Fixesgastownhall/beads#7524.
Separately: `bd purge ... --limit N` (no --force) previews N
deletions, but the confirmation's suggested --force command dropped
--limit, so following it literally deleted every eligible row instead
of the N the preview showed. Threaded limit through to the hint
builder (now its own function, sweepConfirmHint, for a direct unit
test) so the suggested command always matches the selection it
previewed.
Fixesgastownhall/beads#7534.
Verified the overflow fix catches the regression directly: temporarily
reverted just daysAge and confirmed the new -213503d/-213503 test rows
fail without it, pass with it. go build/vet clean, golangci-lint's two
findings are pre-existing in main.go, untouched by this change.
Claude-Session: https://claude.ai/code/session_01VN2SgXAHW1eTB1izwWwmyr
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Claude Code merges a project's hook settings into every session started in that
checkout, including an orchestrator's agent sessions, which get their own
briefing. A higher-precedence settings file cannot remove a lower one's hook, so
such sessions run `bd prime` whether it helps them or not. The only per-session
channel their host controls is the environment.
prime.disabled (BD_PRIME_DISABLED) makes bd prime print nothing, the same as
outside a workspace (an empty envelope under --hook-json), whatever its other
flags. It returns before any workspace or store access. Like the prime memory
caps it is a yaml-only key, and it is validated with strconv.ParseBool, the set
that viper's GetBool reads.
Measured on a copy of a 751-memory store, bytes a hook injects:
- bd prime: 1,251,189 (the default is unchanged);
- BD_PRIME_DISABLED=true bd prime, --full, --memories-only: 0;
- BD_PRIME_DISABLED=true bd prime --hook-json: the empty envelope.
In the Gas City deployment that owns that store, 637 agent sessions in 48 hours
fired the inherited hook 1,271 times. Each firing injected a 2.3 KB preview after
host truncation. On top of that, the sessions read 1.81 MB of the persisted
output. That is about 4.8 MB of context these sessions do not use.
Tests:
- TestPrimeDisabledReadsTheConfigKey.
- TestPrimeDisabledPrintsNothingInAWorkspace. A staged workspace's briefing
prints when the key is off; the test fails if the early return is removed.
- TestValidateYamlConfigValue_PrimeDisabled.
- The embedded TestEmbeddedPrime/prime_disabled_env and
/prime_disabled_config subtests.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(schema): probe sentinel columns with SHOW COLUMNS, not INFORMATION_SCHEMA.COLUMNS
cursorRealityFloor runs on every store open. Its column sentinel used
INFORMATION_SCHEMA.COLUMNS, whose predicate Dolt does not push down: on a
sql-server hosting ~30 databases the probe scanned every database and took
5-6 s per open (measured 2026-09-17, dolt 2.3.x). A 15-store federated
gc ready spent ~80 s of its 90 s there. SHOW COLUMNS on the same server
answers in 0.15 s.
The existing content_hash prober is generalised into showColumnExists and
the open-path sentinel points at it; the repair paths keep
schemaColumnExists as is (they run once per migration, not per open). Mocks
pinned to the old form are moved to the SHOW COLUMNS form.
Rebased onto current main: lock_test.go conflicted only on context
(newer tests above expectIgnoredSentinelProbes); kept, helper comment
taken from this change.
(cherry picked from commit f02fff7bb5e1483cc8650afd20323d779db57334)
Claude-Session: https://claude.ai/code/session_01Ww5wAw2ybpByzduNHo5UYB
(cherry picked from commit e012f3a605)
* test(schema): pin the column sentinel probe to a never-failing carrier read
Red half of guarding #7297's SHOW COLUMNS sentinel probe (be-bv7x).
SHOW COLUMNS fails on a missing table, and on the store's multiStatements
DSN a failing statement pins the pooled Dolt session to its pre-statement
catalog: a table another connection creates afterwards stays "table not
found" on that session (reproduced on dolt 2.1.8 and on the 2.2.0 the
test harness pins). leases, the column sentinel's carrier table, is
exactly what every release-lineage store lacks.
- TestSentinelColumnProbeNeverAsksAMissingTable,
TestSentinelColumnProbeReadsAPresentTableExactly and
TestSentinelColumnCarrierProbeErrorIsNotTreatedAsContradicted pin the
probe through the sentinelTableExists seam.
- TestIgnoredCursorReadWithLeasesAbsentIssuesNoFailingStatement walks the
guarded cursor read with a strict ordered mock (currentVersion surfaces
an unexpected statement; atLatest would swallow it).
- TestSentinelColumnProbe_PoolSeesLaterTables reproduces the pin on a real
sql-server: a one-connection pool reads the ignored cursor with leases
dropped, leases is re-created on another connection, and the pool must
see it.
All of them fail against the unguarded probe. The ordered sentinel mocks
now expect the carrier read ahead of SHOW COLUMNS.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(schema): read the column sentinel's carrier table before SHOW COLUMNS
#7297 moves the per-open column sentinel (leases.granted_node) from
INFORMATION_SCHEMA.COLUMNS, which Dolt does not push down, to SHOW
COLUMNS: on a sql-server hosting 28 databases that is 372 ms against
0.9 ms per write-capable open. But SHOW COLUMNS fails on a missing table,
and the carrier table is exactly what a release-lineage store lacks (no
leases before ignored/0012). On the store's multiStatements DSN a failing
statement pins the pooled Dolt session to its pre-statement catalog, so
the leases table the ignored replay then creates on another connection
stays "table not found" on that session (be-bv7x; dolt 2.1.8 and 2.2.0).
sentinelColumnExists now reads the carrier's existence through
sentinelTableExists, whose read succeeds whether or not the table is
there, and only sends SHOW COLUMNS to a table that exists. A missing
table still reads as a missing column, so the floors, the short-circuit
order and the decision in cursorRealityFloor are unchanged; a failed
existence read surfaces instead of reading as a contradiction.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Eric Cestari <eric@escapevelocity.fr>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(http): answer a command's repeated reads from one response (port of bd-enterprise e626072b8)
Over an http workspace, bd show <id> --json made three identical
GET /v0/beads/issues/<id> requests: the id resolver's exact probe,
routed.go's GetIssue and show's detail read all build the same URL. Text
show made six. Over a gateway each one is a sequential round trip, so the
request count is the command's latency floor (mc-5dkzp).
This ports bd-enterprise e626072b8 (bts-xpw.3.14.6, #217) verbatim, except
cmd/bd/main.go, where OSS still opens the identity preview inline, and
bd-enterprise's httpgw dialer test, which has no OSS counterpart:
- httpclient.WithSharedConnections: the identity-gate preview and the real
open share one transport, so a write makes one handshake.
- httpclient.WithReadMemo and a wire.Client read memo, for one-shot
commands only (not bd serve, --watch or --follow): identical getIssue,
getSetting and listSettings reads are answered from the response already
received. An entry ages from the server's answer (5 s), any write clears
the memo, a read that overlapped a write is not stored, and expired
entries are swept.
- bd list's three vocabulary reads come from one memoized listSettings.
- bd update --status / --if-status skips the custom-status read for a
built-in status.
- The hook decorator skips its post-write re-reads when no executable hook
exists for the event.
- bd dep add reads its confirmation titles before the write, from the memo.
Against a loopback bd serve: show --json goes from 3 requests to 1, text
show 6 to 3, update 5 to 3, close 6 to 4. Dolt and the other registered
backends receive the same ctx and ignore it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(http): BD_HTTP_READ_MEMO=0 turns the per-command read memo off
An operator who suspects a stale read can rule the memo out without a
rebuild. Any other value, or none, leaves the default.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(http): pin bd show to one fetch per issue (mc-5dkzp)
TestE2E_PerCommandRequestBudget allowed show two requests, and a read
that drifts to a URL of its own (a mutant whose reader spells
brief_deps=false) fits that ceiling on both handshake shapes. These guards
pin the single fetch instead:
- TestE2E_ShowFetchesTheIssueOnce: the exact requests, path and query, of
show --json, show --json --id, show --short, show of two ids and text
show, against both handshake shapes, plus a BD_HTTP_READ_MEMO=0 step
that must read the row more than once.
- TestDefaultIssueReadsShareOneMemoKey: the resolver's exact probe,
GetIssue, GetDependenciesWithMetadata, GetLabels and IssueReader().Get
build one URL, checked without a server.
- TestE2E_CloseRereadsItsOwnWrite: against the MC handshake, closing a
lone molecule re-reads its own closed row from the server after the
write, and prints no false "completed molecule" note.
- Corpus shapes can pin `requests:`, counted on the served run alone (not
setup, verify or {rev:ID} reads). The seven gc and mc show shapes pin
1, 4, 1, 1, 3, 1 and 3.
Also: TestReadMemoOptInReadsTheRealPollingFlags holds the opt-in to the
real show/list --watch and -w, events tail --follow and bd serve; the
show budget drops from 2 to 1; requestCounter records each request's
query; and ledger row L-read-memo records the memo's bounded difference
from local reads.
Mutation runs against this tree: brief_deps=true on GetIssue and
brief_deps=false on the reader's Get each fail the e2e list and the unit
test; show opting out of the memo fails the e2e list; writes that leave
the memo standing fail the read-your-own-write e2e; a memo keyed by path
alone fails the e2e list; dropping the kill switch fails its unit test
and the e2e step.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(config): list BD_HTTP_READ_MEMO
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(http): memoize a read's answer only once it has decoded
wire.Client.Do stored a memoable read's 2xx before it checked the body,
so an empty or undecodable 200 would have answered every identical read
in the command for the memo's whole TTL with the same failure, instead
of asking the server again. The answer is now stored only after it
decodes; a read that decodes nothing (out == nil) is not stored, and
every memoable read in this package decodes its answer.
TestReadMemoKeepsOnlyAnswersThatDecoded pins it (empty body, truncated
body, undecoded answer). Ledger row L-read-memo says so.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(http): pin the read memo's 5xx, write-method, per-client, in-flight-write and hook-gate behavior
Review follow-ups for the per-command read memo (mc-5dkzp):
- TestReadMemoNeverKeepsA5xx: a 503, 500 or 502 is not memoized and the
2xx after it is. TestDispatchRetryOfABusyMemoizedReadAsksTheServer
holds the same through dispatch's retry loop over a real wire.Client:
the retry reaches the server instead of replaying the 503.
- TestReadMemoIsDroppedByAnyWrite covers POST, PUT and DELETE, not just
PATCH.
- TestReadMemoIsPerClient: in either order, one client's read is never
answered from another's memo, and opting one client in opts in no
other. (A shared memo was otherwise caught only by test-order
pollution.)
- TestReadMemoDropsAnAnswerReadWhileAWriteWasInFlight pins the clear on
the write's way back: a read that starts and ends while the write is
on the wire is not answered again once the write has returned.
- TestHookFiringStoreReReadsOnlyForAnEventWithAHook pins hookConfigured's
probe: the decorator asks the runner about the event it fires, and
re-reads the row to build a payload only when a hook for that event
exists, through a probing double and through a real hooks.Runner.
Each was run against a mutant of the code it pins and fails there:
5xx stored before the status check; only PATCH clearing; one memo
shared by every client; no clear after the write returns;
hookConfigured answering true, false, or about the wrong event.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* docs(changelog): note the per-command http read memo
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(httpclient): dial a large batchApply under the server's extended budget
bd serve runs an issues:batchApply over largeApplyItemThreshold (100) items
under DefaultLargeApplyCeiling (5m) on a context detached from the client,
but the wire client capped every request at DefaultTimeout (60s). A large
apply on a slow or loaded server therefore failed client-side with
"Client.Timeout exceeded while awaiting headers" while the server went on
to commit it: an error for an apply that landed.
wire.Request.Timeout now raises (never lowers) a bounded client's
per-request ceiling for one request, through a shallow copy of the
*http.Client that shares its Transport and forced CheckRedirect. ApplyBatch
sets it to LargeApplyTimeout (6m) once the plan exceeds
LargeApplyItemThreshold. The stall-retry deadline uses the same per-request
ceiling.
Tests:
- wire: a slow fake server times out an at-threshold apply under a short
ceiling and completes an over-threshold one; httpClientFor only raises a
bounded client and keeps its Transport and CheckRedirect.
- httpapi: TestTheClientLargeApplyBudgetCoversTheServer pins the redeclared
threshold to the server's and holds LargeApplyTimeout above request read
+ large-slot wait + ceiling + drain grace (5m45s).
- httpclient (served tier): a 101-item apply against a BatchApplier delayed
DefaultTimeout+5s, dialed through DialWith + DialOptionsForTarget like
the product, commits and returns success (71s). With the raise disabled
it fails at 60.03s with Client.Timeout.
Ported from bd-enterprise (gascity/bd-enterprise#195).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(httpclient): pin the raised stall-retry deadline; document the 6m large-apply ceiling
Review fixups for #7582.
- wire: TestARaisedRequestTimeoutAlsoBoundsTheStallRetry pins the one
OSS-only hunk of the port, the stall-retry deadline read through
httpClientFor(r). Reverting that line to c.hc.Timeout left the whole wire
package green; the new case fails on it, because the retry then runs out
at the client's own ceiling instead of the request's raised one.
- backend/http: Options.HTTPClient said the client is used as given except
for redirect handling. A batch apply over 100 items now raises a Timeout
shorter than 6 minutes for that request, so the public doc says so.
- README and CHANGELOG: the HTTP backend's write bound is no longer 60s for
every request. A batch apply over 100 items gets 6 minutes, and a server
whose --large-apply-ceiling is raised past about 5m15s can still outlast
it.
- engdocs/SERVE_RUNBOOK.md: the same limit, next to the stop-grace sizing
an operator reads before raising --large-apply-ceiling.
- served_batch_apply_test: the race-build comment blamed the client's 60s
timeout for shrinking the 1000-item apply. A plan that size now gets
wire.LargeApplyTimeout; it stays shrunk because the embedded tier measured
it at 903-945s under -race.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-15 23:43:54 +00:00
684 changed files with 75698 additions and 4758 deletions
@ -19,7 +19,7 @@ Row numbers are the historical table's. Line numbers in this table are against t
| # | Path | Version seam at this head | Disposition | Mechanism |
|---|---|---|---|---|
| 13 | any of rows 1-8 whose target row is a wisp **or a promoted no-history bead** | no | NO-OP | `RecordVersionInTx` returns on `IsWisp`, which is `Ephemeral \|\| NoHistory` (helpers.go:36-41): wisps per FR-8, and a promoted no-history bead — a durable issues-plane row with `NoHistory=true` — because no-history means no history. Wording only; the code did not change. |
| 13 | any of rows 1-8 whose target row is a wisp **or a promoted no-history bead** | no | NO-OP (a flagged issues-table create is stamped, not versioned) | The table that holds the row decides its plane, not its flags. A row in the wisps table mints and stamps nothing, whatever its flags say (FR-8). An update-shaped call on a flagged wisp returns on `IsWisp`, which is `Ephemeral \|\| NoHistory` (helpers.go:36-41). Every other wisps-table row is excluded by the seam's read of `participation_generation` from the issues table, which finds no row and returns: a flagged wisp's create-shaped call, and an unflagged row (bd mol squash's in-place flag clear, import's `wisp_plane` marker), which passes `IsWisp`. An issues-table row carrying `NoHistory` (a promoted no-history bead, bd-r9uce) is never versioned while it says so, because no-history means no history: an update-shaped call returns on `IsWisp`. A create-shaped call on such a row, with the flag on, still stamps `participation_generation` and mints nothing, so the row is not legacy once `bd update --persistent` repairs the flag in place. |
| 14 | dependencies.go:`addDependencyInTx` via `AddDependencyInTx` from the store verbs, `ApplyParentPatch`, `applyBatchRun.applyDepAdd` | yes | VERSIONED | mint moved into `addDependencyInTx` (`mintDependencyVersion`, dependencies.go:393), gated on the row insert rather than on `eventWritten`; the publicops editor's own mint call was removed so no leg double-mints |
| 15 | domain/db/dependency.go:`dependencySQLRepositoryImpl.Insert` (uow `AddDependencies`, create-time edges) | yes | VERSIONED | seam at dependency.go:228 and :240 after the insert |
| 16 | dependencies.go:`removeDependencyInTx` via `RemoveDependencyInTx` and domain/db/dependency.go:`Delete` | yes | VERSIONED | gated on the row delete; dependency.go:409 on the uow leg |
Query:"UPDATE leases SET lease_expires_at = ?, heartbeat_at = ? WHERE issue_id = ?",
Args:[]any{aged,aged,id},
}});err!=nil{
t.Fatalf("age the lease on %s: %v",id,err)
}
lease:=heartbeaterScalar[string](t,ctx,fixture,"SELECT CONCAT(CAST(lease_expires_at AS CHAR), '|', CAST(heartbeat_at AS CHAR), '|', holder) FROM leases WHERE issue_id = ?",id)
ifgot:=heartbeaterScalar[string](t,ctx,fixture,"SELECT CONCAT(CAST(lease_expires_at AS CHAR), '|', CAST(heartbeat_at AS CHAR), '|', holder) FROM leases WHERE issue_id = ?",id);got!=lease{
t.Fatalf("a refused heartbeat moved the holder's lease from %s to %s",lease,got)
}
}
// RunHeartbeaterCommitsOnlyItsOwnTables pins the commit discipline against a
// DIRTY working set (Heartbeater: "A REFRESH WRITES ONLY THE LEASE ROW"; "A
// RE-ARM IS RECORDED AS A MUTATION"): another writer has left an uncommitted
// versioned change (a batch-mode edit, here a config row). A refresh and a
// refusal make no version-control commit and leave that change uncommitted;
// a re-arm makes exactly one commit, of its own tables, and still leaves the
// other writer's change uncommitted rather than sweeping it in under the
{"Priority is exact",with(scoped(p0,p2,p4),func(r*publicops.ListRequest){r.Priority=intp(2)}),[]string{p2}},
{"Priority 0 is a value, not unset",with(scoped(p0,p2,p4),func(r*publicops.ListRequest){r.Priority=intp(0)}),[]string{p0}},
{"PriorityMin is inclusive",with(scoped(p0,p2,p4),func(r*publicops.ListRequest){r.PriorityMin=intp(2)}),[]string{p2,p4}},
{"PriorityMax is inclusive",with(scoped(p0,p2,p4),func(r*publicops.ListRequest){r.PriorityMax=intp(2)}),[]string{p0,p2}},
{"PriorityMin and PriorityMax compose",with(scoped(p0,p2,p4),func(r*publicops.ListRequest){r.PriorityMin,r.PriorityMax=intp(1),intp(3)}),[]string{p2}},
{"TitleContains is a case-insensitive substring",with(scoped(textT,textD,textN),func(r*publicops.ListRequest){r.TitleContains="TTOK-LFF"}),[]string{textT}},
{"DescContains reads the description only",with(scoped(textT,textD,textN),func(r*publicops.ListRequest){r.DescContains="dtok-lff"}),[]string{textD}},
{"NotesContains reads the notes only",with(scoped(textT,textD,textN),func(r*publicops.ListRequest){r.NotesContains="ntok-lff"}),[]string{textN}},
{"EmptyDesc keeps the rows with no description",with(scoped(textT,textD,textN),func(r*publicops.ListRequest){r.EmptyDesc=true}),[]string{textT,textN}},
{"NoLabels keeps the unlabeled row",with(scoped(labeled,unlabeled),func(r*publicops.ListRequest){r.NoLabels=true}),[]string{unlabeled}},
{"LabelPattern is a glob",with(scoped(labeled,unlabeled),func(r*publicops.ListRequest){r.LabelPattern=fixture.IssuePrefix+"-scope-lff*"}),[]string{labeled}},
{"LabelRegex is a regular expression",with(scoped(labeled,unlabeled),func(r*publicops.ListRequest){r.LabelRegex="-scope-lffp.t$"}),[]string{labeled}},
{"NoParent keeps the top-level rows",with(scoped(parent,child,loose),func(r*publicops.ListRequest){r.NoParent=true}),[]string{parent,loose}},
{"ExcludeTypes drops the named type",with(scoped(typeTask,typeBug,typeChore),func(r*publicops.ListRequest){r.ExcludeTypes=[]string{"bug"}}),[]string{typeTask,typeChore}},
{"ExcludeTypes takes a comma-separated value",with(scoped(typeTask,typeBug,typeChore),func(r*publicops.ListRequest){r.ExcludeTypes=[]string{"bug,chore"}}),[]string{typeTask}},
{"SpecPrefix is a prefix",with(scoped(specced,unspecced),func(r*publicops.ListRequest){r.SpecPrefix=spec}),[]string{specced}},
{"ExternalContains is a case-insensitive substring",with(scoped(extRow,extOther),func(r*publicops.ListRequest){r.ExternalContains="lff-EXT"}),[]string{extRow}},
{"ExternalRef is exact",with(scoped(extRow,extOther),func(r*publicops.ListRequest){r.ExternalRef=external}),[]string{extRow}},
{"AllFlag alone admits both pinned-flag states",scoped(pinned,unpinned),[]string{pinned,unpinned}},
{"PinnedFlag selects the flagged row",publicops.ListRequest{IDFilter:readerIDFilter(pinned,unpinned),PinnedFlag:true},[]string{pinned}},
{"NoPinnedFlag holds the unflagged predicate under AllFlag",with(scoped(pinned,unpinned),func(r*publicops.ListRequest){r.NoPinnedFlag=true}),[]string{unpinned}},
{"DeferredFlag keeps the deferred row",with(scoped(deferred,undeferred),func(r*publicops.ListRequest){r.DeferredFlag=true}),[]string{deferred}},
{"OverdueFlag keeps the open row past its due date",with(scoped(overdue,dueLater,closedOverdue,noDue),func(r*publicops.ListRequest){r.OverdueFlag=true}),[]string{overdue}},
{"ExcludeStatus under AllFlag keeps every status not named",with(scoped(stOpen,stProgress,stBlocked,stClosed),func(r*publicops.ListRequest){r.ExcludeStatus=[]string{"closed"}}),[]string{stOpen,stProgress,stBlocked}},
{"ExcludeStatus takes repeated and comma-separated values",with(scoped(stOpen,stProgress,stBlocked,stClosed),func(r*publicops.ListRequest){r.ExcludeStatus=[]string{"blocked,in_progress"," closed "}}),[]string{stOpen}},
{"ExcludeStatus adds to the default exclusions rather than replacing them",publicops.ListRequest{IDFilter:statusScope,ExcludeStatus:[]string{"blocked"}},[]string{stOpen,stProgress}},
{"ExcludeStatus narrows an explicit Status",publicops.ListRequest{IDFilter:statusScope,Status:"open,blocked,closed",ExcludeStatus:[]string{"blocked"}},[]string{stOpen,stClosed}},
{"MolType is exact",with(scoped(swarm,patrol),func(r*publicops.ListRequest){r.MolType=molType(types.MolTypeSwarm)}),[]string{swarm}},
t.Errorf("CurrentAddressFor(a lost address) = %s with no error, want an error: asking where a lost address resolves must not mint a replacement",replacement)
t.Errorf("CurrentAddressFor(%s) = the same address after a token-scheme change, want a new one: a scheme change re-encodes every served address, which is what tells a carry from a no-op",addrA)
"every address of a carried Version must resolve after a second scheme change")
}
ifservesA==servesB{
t.Skip("this scenario needs one still-served and one no-longer-served address to exercise both halves of R20-n; StillServes reported the same answer for both, so this fixture gives this case nothing to contrast")
t.Fatal("Resolve(a prior-epoch Address no longer served).Epoch = nil, want the current epoch populated (R20-n: the answer must name the current epoch, not just Restriction alone)")
}elseif*voidedAnswer.Epoch!=newEpoch{
t.Errorf("Resolve(a prior-epoch Address no longer served).Epoch = %d, want the current epoch %d",*voidedAnswer.Epoch,newEpoch)
t.Fatalf("Resolve(selector=version address) = %+v, want a served result",byVersion)
}
ifbyInstant.Address!=second{
t.Errorf("Resolve(selector=instant matching a version's own accept-time).Address = %s, want %s",byInstant.Address,second)
}
ifbyVersion.Address!=second{
t.Errorf("Resolve(selector=version address).Address = %s, want the same address named %s",byVersion.Address,second)
}
ifbyInstant.Address!=byVersion.Address{
t.Errorf("an instant selector (served %s) and a version-address selector naming the same version (served %s) resolved to different addresses; R7.1 accepts either as a name for the same answer",byInstant.Address,byVersion.Address)
t.Errorf("Resolve(T strictly between two versions) = %+v, want the latest version at-or-before T (%s); the version accepted after T must be strictly excluded",betweenResult,middle)
}
}
// RunAsOfReadReportsTheAddressItServed pins R7.1's "marking the address it
// served": a served result names the exact Address of the version it
t.Error("Refusal.Reason is empty, want a reason (R8)")
}
ifresult.Address!=""{
t.Errorf("Resolve on a refusal returned Address = %s, want empty: R8 forbids silently substituting a neighboring version, the nearest surviving version, or current state (the pre-refusal address was %s)",result.Address,address)
t.Fatalf("Resolve on a store that never received this lineage: %v",err)
}
ifremote.Refusal==nil{
t.Fatalf("Resolve on a store that never received this lineage = %+v, want a Refusal: an as-of answer is complete for the answering store's own holdings, not a sibling's (TC3)",remote)
}
ifremote.Refusal.Restriction!=RestrictionUnknown{
t.Errorf("Refusal.Restriction on the never-synced store = %s, want RestrictionUnknown: no lineage knowledge is Unknown, not Gone (FR-06)",remote.Refusal.Restriction)
@ -117,6 +117,7 @@ Each shape in `corpus.yaml` has these fields:
| `ignore_fields` | JSON keys dropped, at any depth, before a `json` comparison and before `verify` output is compared; for example comment ids, which each workspace mints itself |
| `expect_exit`, `expect_stderr` | expected outcome on both sides (exit 0 by default). An allowlisted shape must state `expect_exit`; only its embedded run is held to these |
| `pending` | a known failure |
| `requests` | exactly how many requests the served run of `args` makes through the reference proxy, not counting `setup`, `verify` or `{rev:ID}` reads. Each request is a sequential round trip, so the count is the shape's latency floor over a gateway. A change that makes the shape cheaper updates the pin |
`pending: {slice, reason}` marks a known failure and names the slice or
slices that fix it, for example `S6c+S15`. A pending shape **still runs**:
pending:{slice:"SRV-1", reason:"S15b sends --id as listIssues id behind issues.list.ids, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListScopeFiltersOverHTTP); remove the mark when reference_server.json is upgraded"}
pending:{slice:"SRV-1", reason:"--title-contains folds onto listIssues title behind issues.list.title, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListScopeFiltersOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:gc-polecat-title-contains-closed-after
source:gascity core formulas/mol-polecat-base.toml (pre-flight 3d, list --title-contains --status closed --closed-after DATE --json)
pending:{slice:"SRV-1", reason:"needs issues.list.title (--title-contains folds onto listIssues title) and issues.list.filters (closed_after), which the reference server does not advertise, so the client refuses before dialing; remove the mark when reference_server.json is upgraded"}
pending:{slice:"SRV-1", reason:"needs issues.list.title (--title-contains folds onto listIssues title) and issues.list.filters (closed_after), which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListFilterParityOverHTTP); remove the mark when reference_server.json is upgraded"}
pending:{slice:"SRV-1", reason:"needs issues.list.filters, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListFilterParityOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:list-filter-priority-range
source:bd list --priority-min/--priority-max (listing filter parity)
pending:{slice:"SRV-1", reason:"needs issues.list.filters, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListFilterParityOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:list-filter-exclude-type-no-parent
source:bd list --exclude-type --no-parent (listing filter parity)
pending:{slice:"SRV-1", reason:"needs issues.list.filters, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListFilterParityOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:list-filter-updated-after
source:bd list --updated-after (listing filter parity)
pending:{slice:"SRV-1", reason:"needs issues.list.filters, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListFilterParityOverHTTP); remove the mark when reference_server.json is upgraded"}
pending:{slice:"S18", reason:"bd blocked hits the GetBlockedIssues stub (B3 #10)"}
pending:{slice:"SRV-1", reason:"bd blocked dials listBlockedIssues behind blocked.list, which the reference server does not advertise, so the client refuses at its capability preflight (pinned passing against the current server by backend/http TestE2E_BlockedOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:gc-blocked-flags
source:gc bdstore_ready_projection.go readiness door (bd blocked --flags --json, ids on stdin)
pending:{slice:"SRV-1", reason:"bd blocked --flags reads listBlockingAnnotations is_blocked behind dependencies.blocking.isBlocked, which the reference server does not advertise, so the client refuses at its capability preflight (pinned passing against the current server by backend/http TestE2E_BlockedFlagsOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:gc-blocked-flags-raw
source:gc bdstore_ready_projection.go readiness door (the stored is_blocked column, bd blocked --flags --raw --json, ids on stdin)
pending:{slice:"SRV-1", reason:"bd blocked --flags reads listBlockingAnnotations is_blocked behind dependencies.blocking.isBlocked, which the reference server does not advertise, so the client refuses at its capability preflight (pinned passing against the current server by backend/http TestE2E_BlockedFlagsOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:gc-blocked-parent
source:bd blocked --parent (the molecule-scoped blocked listing)
args:[blocked, --json, --parent, e2e-mol]
pending:{slice:"SRV-1", reason:"bd blocked dials listBlockedIssues behind blocked.list, which the reference server does not advertise, so the client refuses at its capability preflight (pinned passing against the current server by backend/http TestE2E_BlockedOverHTTP); remove the mark when reference_server.json is upgraded"}
pending:{slice:"reference-server-heartbeat", reason:"the reference server does not advertise issues.heartbeat, so the client refuses at its capability preflight; pinned passing by backend/http TestE2E_HeartbeatOverHTTP; remove the mark when reference_server.json is upgraded"}
- id:gc-heartbeat-non-holder
source:gc formulas/mol-do-work.toml:47 (a worker heartbeating a bead another actor holds)
pending:{slice:"reference-server-heartbeat", reason:"the reference server does not advertise issues.heartbeat, so the client refuses at its capability preflight; pinned passing by backend/http TestE2E_HeartbeatOverHTTP; remove the mark when reference_server.json is upgraded"}
- id:gc-heartbeat-closed
source:gc formulas/mol-do-work.toml:47 (a worker heartbeating a bead that was closed under it)
pending:{slice:"reference-server-heartbeat", reason:"the reference server does not advertise issues.heartbeat, so the client refuses at its capability preflight; pinned passing by backend/http TestE2E_HeartbeatOverHTTP; remove the mark when reference_server.json is upgraded"}
- id:gc-heartbeat-wisp
source:gc formulas/mol-do-work.toml:47 (a heartbeat on a wisp, which is never leased)
args:[heartbeat, e2e-wisp-2]
expect_exit:1
expect_stderr:"(?i)ephemeral"
compare:exit
pending:{slice:"reference-server-heartbeat", reason:"the reference server does not advertise issues.heartbeat, so the client refuses at its capability preflight; pinned passing by backend/http TestE2E_HeartbeatOverHTTP; remove the mark when reference_server.json is upgraded"}
ignore_fields:[id] # each side mints its own gate id
pending:{slice:"SRV-1", reason:"bd gate create sends the gate members on createIssue behind issues.create.gates, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_GatesOverHTTP); remove the mark when reference_server.json is upgraded"}
- id:mc-gate-check-timer-resolves
source:core gate-sweep.sh (gate check --type=timer --escalate) over a real timer gate
verify:[[ready, --json, --limit, "0"]] # e2e-t-gct is ready on both sides
ignore_fields:[depends_on_id] # its (closed) gate's id is minted per workspace
pending:{slice:"SRV-1", reason:"the setup bd gate create sends the gate members on createIssue behind issues.create.gates, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_GatesOverHTTP); remove the mark when reference_server.json is upgraded"}
pending:{slice:"SRV-1", reason:"bd gate add-waiter sends waiters on updateIssue behind issues.update.gates, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_GatesOverHTTP); remove the mark when reference_server.json is upgraded"}
pending:{slice:"SRV-1", reason:"bd update --await-id sends await_id on updateIssue behind issues.update.gates, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_GatesOverHTTP); remove the mark when reference_server.json is upgraded"}
t.Fatalf("bd close %s did not re-read the row from the server after closing it (%q): a read after the command's own write was answered from before it",mol,uris)
fmt.Fprintf(&transcript,"# Regenerate with BEADS_TEST_EMBEDDED_DOLT=1 BD_UPDATE_GOLDEN=1 go test -tags gms_pure_go ./cmd/bd/ -run TestEmbeddedInitAgentArtifactsGolden\n")
t.Errorf("bd init agent artifacts drifted from %s (regenerate with BD_UPDATE_GOLDEN=1 if intended)\nfirst difference at line %d:\n want: %s\n got: %s\n--- got ---\n%s",path,i+1,line(wantLines,i),line(gotLines,i),got)
t.Errorf("--%s is registered on blockedCmd but --flags does not refuse it: add it to blockedFlagFilterFlags, or to this test's mode flags if --flags reads it",name)
}
}
for_,name:=rangeblockedFlagFilterFlags{
ifslices.Contains(modeFlags,name){
t.Errorf("blockedFlagFilterFlags refuses --%s, which --flags itself reads",name)
}
if!slices.Contains(registered,name){
t.Errorf("blockedFlagFilterFlags names --%s, which blockedCmd does not register",name)
// Load config from .beads/metadata.json. When the beadsDir was
@ -234,7 +240,9 @@ Examples:
}
ifcfg==nil{
cfg,err=findParentConfig(beadsDir)
iferr!=nil{
ifisUnsupportedWorkspaceFormat(err){
returnhandleWorkspaceGuardError(err)
}elseiferr!=nil{
returnHandleError("failed to load ancestor storage metadata: %v; no storage database was opened or modified; fix or restore metadata.json and retry",err)
fmt.Printf("Also removed a stored %s row from the database, left by a bd that predates the key moving to %s.\n",key,location)
fmt.Printf("⚠ Rotate this credential: the row was replicated to every Dolt remote this workspace pushed to, and deleting it here does not unpublish it.\n")
switch{
casec.commitIndeterminate():
fmt.Fprintf(os.Stderr,"⚠ The removal may not be committed (%v): if it is not, HEAD still carries the row and `bd dolt push` keeps publishing it. Run `bd dolt commit` to be sure.\n",c.commitErr)
casec.commitErr!=nil:
fmt.Fprintf(os.Stderr,"⚠ The removal is not committed (%v): HEAD still carries the row and `bd dolt push` keeps publishing it until `bd dolt commit` records the delete.\n",c.commitErr)
}
casec.err!=nil&&c.present:
// The one case that is not a maybe: the read found the row and the
// delete failed, so bd knows a live credential is still in the table.
// goes on stderr with that error rather than to stdout, which `--json` owns.
func(csecretRowCleanup)rowNote(keystring)string{
switch{
casec.removed&&c.commitIndeterminate():
returnfmt.Sprintf("\nA stored %s row WAS removed from the database, but the removal may not be committed (%v); run `bd dolt commit` to be sure, and rotate that credential — it was replicated to every Dolt remote this workspace pushed to.",key,c.commitErr)
casec.removed&&c.commitErr!=nil:
returnfmt.Sprintf("\nA stored %s row WAS removed from the database, but the removal is not committed (%v); run `bd dolt commit`, and rotate that credential — it was replicated to every Dolt remote this workspace pushed to.",key,c.commitErr)
casec.removed:
returnfmt.Sprintf("\nA stored %s row WAS removed from the database; rotate that credential — it was replicated to every Dolt remote this workspace pushed to.",key)
Message:"Versioned history now records for this store. The setting replicates on 'bd dolt push' and 'bd dolt pull', so every clone that pulls it records too, and it is safe with a single writer only: keep one writer at a time per store (docs/reference/configuration.md#versioned-issue-history).",
stderr:"Warning: ignoring redirect from $ROOT/p/.beads to $ROOT/bare/.beads because the target has no database or metadata.json; fix or delete the redirect file\n"+