Compare commits

..

213 commits

Author SHA1 Message Date
Julian Knutsen
f3c47390e7
fix(storage): refuse graph_mode workspaces on library opens (#7721)
#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>
2026-10-20 09:29:54 +00:00
Julian Knutsen
bc1cd64c78
fix(cli): refuse graph workspaces marked by graph-preview-format (#7722)
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>
2026-10-20 07:25:38 +00:00
gascity-eddie[bot]
d0d9aa2145
test(list): pin --deps scheduling ordering under --sort closed in the tree (#7703)
* 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>
2026-10-20 02:19:13 +00:00
Julian Knutsen
1fcd715e75
fix(cli): refuse graph_mode workspaces and keep their metadata marker on save (#7671)
* 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>
2026-10-20 00:05:39 +00:00
gascity-eddie[bot]
4df395698b
fix(bazel): the root go_srcs glob skips Bazel's convenience symlinks, so //cmd/bd tests cache (#7714)
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>
2026-10-19 23:30:10 +00:00
Julian Knutsen
c86a87bb20
test(oracle-a): pin BEADS_TIP_SEED so human-output scenarios stop flaking (#7707)
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>
2026-10-19 22:02:44 +00:00
Julian Knutsen
8988340994
ci(embedded): run every BEADS_TEST_EMBEDDED_DOLT-gated cmd/bd test in the embedded lane (#7708)
* 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>
2026-10-19 22:02:22 +00:00
Julian Knutsen
2563f021ed
perf(httpclient): remember the server's external-dependency policy across processes (#7700)
* 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>
2026-10-19 19:05:55 +00:00
Julian Knutsen
d097b6c8a4
perf(ready): skip the countReadyWork request when bd ready --json prints no total (#7699)
* 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>
2026-10-19 18:15:57 +00:00
Julian Knutsen
d28f56cd46
perf(startup): initialize packages on four Ps, not every CPU (#7701)
* 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>
2026-10-19 17:15:54 +00:00
Julian Knutsen
18b5c3cc39
fix(httpclient): name the connect failure when bd serve cannot be reached (#7702)
* 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>
2026-10-19 16:54:25 +00:00
gascity-eddie[bot]
4f9174e6ba
docs(agents): bazel test is authoritative; agents never run go test (#7695)
* 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>
2026-10-19 14:04:30 +00:00
Julian Knutsen
1de9b59324
fix(setup): bd setup claude --global manages the section in ~/.claude/CLAUDE.md, not the current directory (#7696)
* 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>
2026-10-19 12:22:04 +00:00
Julian Knutsen
2829d22192
test(oracle-a): let scenarios that start with init own initialization (#7704)
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>
2026-10-19 10:57:02 +00:00
Julian Knutsen
21dac62a4c
fix(init): drop bd dolt push from AGENTS.md Quick Reference without a remote (#7694)
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>
2026-10-19 10:36:59 +00:00
gascity-eddie[bot]
4c473b4580
fix(query): report an uppercase duration unit as an unparseable time, not a negated internal error (#7683)
* 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>
2026-10-19 09:18:13 +00:00
gascity-eddie[bot]
994f5b82dd
fix(config): stop bd config set truncating config.yaml at a 64 KiB line (#7670)
* 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>
2026-10-19 09:15:48 +00:00
Julian Knutsen
4c48829c07
fix(list): print bd list --format dot in a deterministic order (#7688)
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>
2026-10-19 08:59:23 +00:00
Steve Yegge
d855ac6c88
test(bazel): pin vet policy to module toolchain (#7668)
* 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>
2026-10-19 08:52:30 +00:00
gascity-eddie[bot]
395e7beec0
fix(config): stop bd config set dropping the file's trailing newline (#7669)
* 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>
2026-10-19 08:49:00 +00:00
Julian Knutsen
c67a36e5e7
fix(cli): refuse backup init/sync/remove/restore and import under strict --readonly (#7673)
* 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>
2026-10-19 08:48:37 +00:00
Julian Knutsen
9893f9020d
fix(setup): leave a current agents-file beads section untouched (#7693)
* 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>
2026-10-19 08:45:04 +00:00
gascity-eddie[bot]
6db46664da
test(cmd/bd): pin mixed-case dep tree --format Mermaid through the CLI (#7697)
* 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>
2026-10-19 08:36:16 +00:00
gascity-eddie[bot]
8f960b1b6e
test(cmd/bd): pin count and omitted flag on the embedded wisp include view (#7698)
* 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>
2026-10-19 08:31:05 +00:00
Julian Knutsen
ee441fdc73
fix(setup): stop leaving a blank-line hole on --remove (#7692)
`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>
2026-10-19 08:28:18 +00:00
Julian Knutsen
5e2158ea08
fix(setup): route Claude hook-removal lines through the installer output (#7691)
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>
2026-10-19 07:44:30 +00:00
Julian Knutsen
fb912f2438
fix(oracle-a): write scoreboard failure detail per run, not to shared /tmp (#7690)
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>
2026-10-19 07:34:17 +00:00
Julian Knutsen
e3efb3107a
test(oracle-a): always remove the reference worktree on exit (#7689)
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>
2026-10-19 07:29:55 +00:00
Julian Knutsen
9e2f25c322
fix(http): bd link over a connected HTTP workspace, through the DependencyEditor role (#7685)
* 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>
2026-10-19 07:15:13 +00:00
Julian Knutsen
786ed8a4b0
fix(show): exit 1 when bd show --as-of reads no issue (#7687)
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>
2026-10-19 07:10:26 +00:00
Julian Knutsen
36f81bab1c
test(cmd/bd): pin the command tree and representative --help output (#7675)
* 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>
2026-10-19 05:56:15 +00:00
Julian Knutsen
eb5ab48950
test(setup): pin the Claude agent artifacts bd init and bd setup claude write (#7678)
* 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>
2026-10-19 05:19:28 +00:00
Julian Knutsen
3a5ade3a76
test(cmd/bd): pin workspace discovery refusal text and exit codes (#7677)
* 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>
2026-10-19 04:51:18 +00:00
Julian Knutsen
e24940e0c1
fix(workspacegate): strict --readonly never creates workspace gate files (#7672)
* 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>
2026-10-19 04:31:00 +00:00
Julian Knutsen
8fac20a7f1
test(oracle-a): normalize per-run revision token and workspace path so main-vs-main is clean (#7680)
* 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>
2026-10-19 04:27:28 +00:00
Julian Knutsen
05fffb1e11
test(storage): versioned-history flag-off differential and statement pins (#6132, #6135) (#7681)
* 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>
2026-10-19 03:47:00 +00:00
Julian Knutsen
f142cc2ffd
test(cli): before-parity pins for --format json, ordinary --if-revision, and version/config/history/as-of shapes (P7, P8, P10) (#7676)
* 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>
2026-10-19 03:41:08 +00:00
Julian Knutsen
f6f122894f
test(serve): before-parity pins for the httpapi startup event and ordinary-workspace bd serve (P13, P14) (#7679)
* 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>
2026-10-19 03:26:45 +00:00
Julian Knutsen
3488dc4536
fix(init): bd init --server --external starts no server; a failed bd init --server can be retried (#7674)
* 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>
2026-10-19 03:11:14 +00:00
Jim Wordelman
5c9c02ab77
Phase 3 (R20): epoch-transition enforcement + minted-address CAS - gastownhall/beads#6136 (#6664)
* 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>
2026-10-18 21:20:57 +00:00
Jim Wordelman
9c6f6e15cd
bd versions + a config switch for versioned history — the minimum cut that makes versioned beads usable (#6138) (#6661)
* 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>
2026-10-18 17:28:16 +00:00
Jim Wordelman
ce70b261c5
storage: add participation_generation (migration 0070) and the versioned-history write fence (#6943)
* 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>
2026-10-18 13:10:57 +00:00
gascity-eddie[bot]
4a67d0d028
fix(bootstrap): cut the host part before stripping userinfo (mc-gcmer) (#7616)
* 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>
2026-10-17 18:07:50 +00:00
Julian Knutsen
bdd16d6383
fix(sqlbuild): bind time bounds as their UTC instant (#7655)
* 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>
2026-10-17 16:19:50 +00:00
Steve Yegge
46aa59cc65
test(cmd/bd): stop tests from mutating the host checkout's .git; guard it in TestMain (wy-qlvlmf) (#7650)
* 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>
2026-10-17 12:36:48 +00:00
Julian Knutsen
4450fe99bb
feat(http): bd blocked over bd serve (blocked.list), plus bd blocked --flags [--raw] (#7649)
* 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>
2026-10-17 12:29:13 +00:00
Julian Knutsen
601be8a6bf
feat(list): bd list's remaining filters over http behind issues.list.filters (#7647)
* 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>
2026-10-17 11:21:18 +00:00
Julian Knutsen
b2d5cff6c0
fix(gate): add-waiter retries contention the store gave up replaying (#7648)
* 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>
2026-10-17 10:08:48 +00:00
Julian Knutsen
925e26bc48
fix(http): serve bd list --title-contains by folding it onto title (#7631)
* 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>
2026-10-17 06:00:33 +00:00
Julian Knutsen
ae693ef7cc
fix(http): bd gate create, add-waiter and discover over a connected HTTP workspace (#7621)
* 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>
2026-10-17 02:15:07 +00:00
Julian Knutsen
a3e1b24e2b
fix(import): tolerate only typed dependency refusals, not walk-query errors (#7630)
* 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>
2026-10-16 23:55:53 +00:00
Julian Knutsen
47d5db39ff
feat(http): bd heartbeat over bd serve (issues.heartbeat), and close the re-arm orphan-lease race (#7600)
* 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>
2026-10-16 22:38:23 +00:00
gascity-eddie[bot]
91a72ef7b5
fix(mol): route bond operand resolution like show/update/close (closes #4714) (follow-up to #4720) (#7622)
* 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>
2026-10-16 21:10:12 +00:00
Julian Knutsen
babf8d7ed7
perf(dolt): sweep the circuit-breaker dir once per process and age out closed files (#7593)
* 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>
2026-10-16 17:05:11 +00:00
Julian Knutsen
3862b03ff5
feat(http): gate await members on create and update over bd serve (#7589)
* 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>
2026-10-16 17:02:27 +00:00
Julian Knutsen
169c5fc499
perf(list): read only the listed issues' dependency edges (#7591)
* 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>
2026-10-16 16:05:24 +00:00
Julian Knutsen
dff9492c61
fix(http): gate check records a bead gate's sighting through Lifecycle.Update (#7604)
* 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>
2026-10-16 15:14:53 +00:00
gascity-eddie[bot]
d2748411c4
fix(init): refuse to initialize directly in the home directory (#4635) (follow-up to #4795) (#7609)
* 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>
2026-10-16 13:52:00 +00:00
gascity-eddie[bot]
8d2b4152f7
fix: commit server-mode config and memory writes (GH#4078, carries #4383) (follow-up to #7299) (#7608)
* 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>
2026-10-16 13:48:30 +00:00
gascity-eddie[bot]
0d440f8b7f
test(doctor): keep parent close gates out of Child-Parent and --fix-child-parent (follow-up to #5131) (#7607)
* 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>
2026-10-16 12:40:43 +00:00
gascity-eddie[bot]
cfadcde8f4
fix(federation): treat missing peer row as credential-free remote (follow-up to #5128) (#7606)
* 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>
2026-10-16 12:07:30 +00:00
Alex
fefcdf6533
fix(delete): resolve ids exactly, never by prefix abbreviation (#7375)
* 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>
2026-10-16 11:25:54 +00:00
gascity-eddie[bot]
3a79fbad4c
test(resolver): pin leading-prefix partial-ID matching for gcy-g4o (follow-up to #4376) (#7605)
* 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>
2026-10-16 11:25:14 +00:00
Julian Knutsen
fdec61870c
perf(schema): drop the per-open INFORMATION_SCHEMA.TABLES probes (builds on #7409) (#7596)
* 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>
2026-10-16 10:37:52 +00:00
gascity-eddie[bot]
9c5f897247
fix(storage): carry closed_by_session through the domain/UOW writer (#4662) (follow-up to #4798) (#7602)
* 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>
2026-10-16 10:07:12 +00:00
gascity-eddie[bot]
b17005ad14
fix(wisp gc): apply the --age test to cascade children (follow-up to #5219) (#7599)
* 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>
2026-10-16 09:49:28 +00:00
Julian Knutsen
b126a7d1d2
fix(http): bd gate check over HTTP through issueops.ListGates (#7578)
* 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>
2026-10-16 09:20:24 +00:00
Rongjun GENG
d82c82d965
fix(cmd/bd): purge/prune reject negative --older-than overflow, carry --limit in confirm hint (#7540)
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.

Fixes gastownhall/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.

Fixes gastownhall/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>
2026-10-16 08:56:26 +00:00
Julian Knutsen
74a67c3c27
feat(prime): add prime.disabled so a session can turn off an inherited bd prime hook (#7595)
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>
2026-10-16 08:31:08 +00:00
Julian Knutsen
de01b0f3e8
perf(schema): probe the column sentinel with SHOW COLUMNS, behind a carrier-table read (#7592)
* 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>
2026-10-16 07:19:24 +00:00
Julian Knutsen
b303d494df
perf(http): answer a command's repeated reads from one response; bd show --json makes 1 request (port of bd-enterprise e626072b8) (#7588)
* 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>
2026-10-16 04:26:37 +00:00
Julian Knutsen
773b537c75
fix(httpclient): dial a large batchApply under the server's extended budget (#7582)
* 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
Bee
b911ed28cd
fix(blocked): climb through a blocked parent with no reason row of its own (#7420)
* fix(blocked): climb through a blocked parent with no reason row of its own

A blocked parent the explained-parent walk meets that neither read returned
was treated as a final unexplained ancestor. That is right for a parent with
a reason row of its own (the complete read decided it), but a parent with
none carries only an inherited bit, and the walk had nothing to decide it
from. In a malformed parent-child cycle (SkipCycleCheck, import, merge
replay) a stale is_blocked = 1 on such a parent held itself up: it dropped
the explained parent below it, which darkened it back, so full repair
converged on the stale state and the doctor check counted 0.

climbBlockedParentsInTx now sorts each unmet blocked parent: explained by its
own subtree (climb on), carrying a reason row and not explained (final), or
carrying no reason row (transparent: entered as explained and climbed
through, and dropBlockedFromAbove decides it from what is above it). The new
read, withoutReasonAmongInTx, uses blockingReasonSQL, the same predicate the
explained-parent reads aggregate.

Closes gastownhall/beads#7386.

Tests: TestParentChildCascade_CycleStaleBitSelfSustains (the issue's repro;
FAIL at 5a5b7cfd66 before the fix, PASS after) and
TestParentChildCascade_InheritedBitStillCascades (a no-reason parent under an
exogenously blocked one still cascades, before and after the fix). Ran the
dolt package's blocked/cascade set and internal/storage/issueops locally
against a dolt 2.2.0 server; golangci-lint 0 issues on both packages.

Agent-Signature: claude-code-claude-fable-5-1-unknown-reasoning on behalf of bee
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(blocked): pin the scoped climb through a no-reason parent

Review fixes for #7420 (fixes #7386). All are minors from the adopt-pr
review; no blocker or major was raised, and blocked-state behavior is
unchanged.

- Test evidence: the PR's tests drive only the complete read (recomputeAll
  and the doctor count). The scoped half of the climb, which the per-write
  recompute and merge replay reach through batchExogeneity, had no pin: a
  mutant that skips withoutReasonAmongInTx on a scoped read
  (if !complete { undecided = nil }) passed every blocked test. Add
  TestParentChildCascade_CycleStaleBitScopedRecompute, the same malformed
  cycle driven through RecomputeIsBlockedInTx. It fails at the base and
  under that mutant, and passes here.
- Comment truth in blocked_consistency.go: the set bullet now names every
  parent the walk enters as explained (the read's, those a scoped walk
  finds explained, and the no-reason parents it climbs through) and says
  only the read's are returned; COST counts an edge read per level the
  walk climbs and the reason-row read by id on both paths; the explained
  map's doc covers climbed-through parents; blockingReasonSQL names both
  of its callers.
- Scope of the claim: the CHANGELOG entry and the cycle test's doc now
  say what is fixed, a stale bit that holds itself up THROUGH a parent
  that blocks on its own child, on both the full repair and the per-write
  recompute. A no-reason cycle that holds itself up without running
  through such a parent keeps its stale bits with a doctor count of 0,
  as it did before this change: one above such a parent (Q<->D over P),
  and one with no close gate at all, which an ordinary close can leave
  behind. Those are left to a follow-up, not claimed here.

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 Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-10-15 10:41:35 +00:00
Bee
70b44da7cc
docs(ci): finish the retired-shard-job comment sweep after #7478 (wy-wqq7c1) (#7456)
#7478 deleted the frozen 15-shard proxied and 20-shard embedded manifest
blocks and refreshed most comments that described pr-risk.yml's retired
fork/push jobs as still running. Finish the #7382 adoption follow-ups on
what survived: the Close3/Close4 split is cited as #7173 (bd-ojckcg), and
the remaining present-tense references to the legacy jobs (bazel.yml's
embedded-lane rationale and cmd-dolt lane note, BUILD.bazel's socat note,
TESTING.md's socat paragraph) now say the jobs are retired (bd-g2w5rp).
bd-3lht (the hand-held 15-shard header round-trip) is moot: the block no
longer exists.

Comments and docs only; no shard assignment, workflow step or BUILD
setting changes.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-15 06:50:08 +00:00
Rongjun GENG
7838c4b449
fix(scripts): update-nix-vendorhash no longer reports a build failure as success (#7504)
* fix(scripts): update-nix-vendorhash no longer reports a build failure as success

scripts/update-nix-vendorhash.sh treated the absence of a "got:" hash
line as proof the vendorHash was already correct, so a build failure
unrelated to a hash mismatch (e.g. a Go toolchain too old for a
dependency) was misreported as success and the workflow went green on
a broken build (#7496). Fixed by capturing the intentional-failure
build's real exit status instead of discarding it with `|| true`, and
using that exit status (not a "hash mismatch" string grep) to tell a
genuine no-op apart from an unrelated build break.

The step-5 verification build had the same shape of bug: piping
through `tee` without pipefail meant the if-condition tested tee's
exit status, not the build's, so a failing verification build still
printed "Build successful!". Scoped `set -o pipefail` to just that one
line rather than the whole script, since the earlier hash-extraction
step legitimately relies on `grep -o` returning non-zero on no match.

Fixes gastownhall/beads#7498.

Added an independent `nix build .#default` step to
update-vendor-hash.yml so the workflow no longer trusts the script's
exit status alone, even if a future bug in the script reintroduces a
false-success path.

Fixes gastownhall/beads#7499.

Added TestPinnedDoltCLIAtLeastRecommendedMin, asserting the pinned
Dolt CLI version (scripts/ci/install-dolt.sh) is at least
doltversion.RecommendedMin, so the two policies can't silently drift
apart — RecommendedMin's own doc comment already claims this alignment
but nothing enforced it.

Fixes gastownhall/beads#7500.

Verified by reproducing both update-nix-vendorhash.sh failure modes
with a stub `nix` binary (a non-hash build failure, and a step-5
verification build failure) and confirming the intended successful
hash-update path still works end to end. go build/vet clean,
golangci-lint 0 issues, go test ./scripts/... passes except a
pre-existing unrelated failure (TestControlQueryScriptPreservesReadyProbeFailure,
tracked separately as beads#7293 and untouched by this change).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VN2SgXAHW1eTB1izwWwmyr

* chore: empty commit to retrigger CI -- retrying after a 3-hour quota recovery window

* chore: empty commit to retrigger CI -- isolated single retry after real-bug fixes landed on sibling PRs

* fix(scripts): add missing BUILD.bazel dep, sharpen vendorhash diagnostics

scripts_test now imports internal/doltversion (for
TestPinnedDoltCLIAtLeastRecommendedMin) but scripts/BUILD.bazel had no
matching dep row, which would fail the target's compile under
rules_go once Bazel actually runs against this branch (the Bazel /
jobs failing so far died in bazel.fork-cert, unrelated to this).

Also, per review: scope set -o pipefail to just the step-5 verify
block (turn it back off after, rather than leaving it on for the rest
of the script with a comment claiming it's scoped when it isn't), and
keep the old "hash mismatch" string check as a sub-case in the
ACTUAL_HASH-empty branch, so a hash mismatch whose got: line fails to
parse (e.g. a future Nix output-format change) is diagnosed
differently from a build that failed for an unrelated reason.

Re-verified all four failure/success paths with a stub nix binary
(non-hash failure, hash-mismatch-with-unparseable-got-line,
step-5-verify failure, and the genuine happy path). go build/vet
clean, golangci-lint 0 issues.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VN2SgXAHW1eTB1izwWwmyr

* fix(scripts): update-nix-vendorhash preserves operator backups, restores on any handled failure

The script backed up default.nix to a fixed name in the repo root,
default.nix.backup, before editing it -- but that is also the
conventional name an operator gives their own manual backup. Running
the script unconditionally overwrote (then later deleted) any such
file. A failed step-5 verification build also left the candidate hash
in default.nix with no backup at all to restore from, since the
backup had already been deleted right after step 4 applied the real
hash.

Moved the backup into a private per-run scratch directory
(mktemp -d, cleaned on every exit via an EXIT trap) instead of a
fixed repo-root name, so it can never collide with an operator's own
default.nix.backup. Copy with cp -p so a restore brings back the
exact original bytes AND mode, not just content. Kept the backup
around through step 5 instead of deleting it right after step 4, and
added a restore on the step-5 verification-failure path, which
previously left the unverified candidate hash in place.

Also: the "no hash mismatch, already correct" exit-0 path previously
inferred correctness purely from the fake-hash probe build's
unexpected success, without ever building the real, restored file.
It now runs a second build against the restored file and only exits 0
if that succeeds too, surfacing a diagnostic log if it doesn't.

Fixes gastownhall/beads#7529.

Verified with a stub nix binary across five scenarios: a pre-existing
operator default.nix.backup (distinct content + mode 600) survives
untouched in every one; a non-hash build failure restores the
original (content + mode 640); the already-correct path now runs two
builds and only succeeds if both do; the core bug repro (hash
extracted, step-5 verify fails) now restores the original instead of
leaving the unverified candidate hash with no backup; the genuine
happy path still updates the hash correctly. No leftover scratch
directories in any case. go build unaffected (shell-only change).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VN2SgXAHW1eTB1izwWwmyr

* fix(scripts): update-nix-vendorhash restores the original on an interrupted run

A SIGINT/SIGTERM during the probe build (the long step) reaches this
script and its nix child as one process group; the child dies, this
script exits through the EXIT trap with the placeholder hash still in
default.nix. The plain `rm -rf "$SCRATCH_DIR"` trap deleted the only
backup at that point, leaving no way back except `git checkout
default.nix` -- which also discards any uncommitted operator edits.
Worse than every handled failure case this file already restores
from.

The placeholder is never a valid end state, so the EXIT trap now
checks for it and restores first, before dropping the scratch
directory. Every handled exit path has already restored or verified
default.nix by the time it runs, so this is a no-op there -- it only
fires on an interrupted run.

Found by review on PR #7504 (beads#7529's own follow-up): reproduced
and confirmed with a stub nix that signals its own parent process
group, matching a real Ctrl-C mid-build. Confirmed the bug first
(plain trap: placeholder left in place, backup gone, matching the
report exactly), then confirmed the fix (original hash and mode
restored, operator backup untouched, no leftover scratch dir). Also
re-ran the full existing scenario matrix (non-hash failure, hash
mismatch with step-5 verify failure, genuine happy path) to confirm no
regression.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VN2SgXAHW1eTB1izwWwmyr

* fix(scripts): restore default.nix if vendorhash verification is interrupted

The EXIT trap restored default.nix only while it still held the placeholder
hash. A SIGINT/SIGTERM during the step-5 verification build therefore left
the unverified candidate hash in place and deleted the only backup with the
scratch dir. Track VERIFIED instead: until a build has verified default.nix
as it stands, any exit restores the original. On handled paths this is a
no-op, since they have already restored or verified the file.

Write the build logs under ${TMPDIR:-/tmp} with per-run names. The
verification log had a fixed /tmp name shared by every run and every user.

Add the regression tests the #7498/#7499/#7529 fixes lacked:
- TestUpdateNixVendorHashReportsTheRealBuildResult runs the script with a
  stub nix over a non-hash build failure, an unparseable mismatch, a failed
  verification, a half-parsed got: hash, a real update, and a probe that
  accepts the placeholder (restored file builds, or not). Every failure
  exits 1 with default.nix restored byte for byte and mode for mode, the
  operator's own default.nix.backup untouched and the named logs kept.
  Against main's script it reproduces each false success.
- TestUpdateNixVendorHashInterruptRestoresOriginal signals the script's
  process group during the probe build and during verification.
- TestUpdateVendorHashWorkflowBuildsIndependently pins the workflow's
  unconditional `nix build .#default` between the script and the
  match-report and push steps.

The scenario matrix, operator-backup and file-mode fixture, and workflow
ordering check are adapted from BlueboxC's correction of this PR in their
fork (62e7718e), as described on #7498 and #7529.

Refs #7504, #7496, #7498, #7499, #7500, #7529

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-authored-by: BlueboxC <david@blueboxcomputers.es>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: BlueboxC <david@blueboxcomputers.es>
2026-10-14 22:18:15 +00:00
Julian Knutsen
9c4b3d8bab
perf(externaldeps): annotate a page's blocking state in one pass, not one IsBlocked per id (#7556)
* perf(externaldeps): annotate a page's blocking state in one pass, not one IsBlocked per id

The external-dependency BlockingAnnotator overlaid IsBlocked on the
backend's answer one item at a time. Each IsBlocked made several reads
(the stored flag, both edge tables, the blockers' statuses), read the
item's own edges again, and resolved its external refs on its own, so a
foreign project was opened once per item. Over a remote serve,
listBlockingAnnotations cost 9-20 ms per id, and a 1,400-id refresh took
about 12 s.

The annotator now reads the whole page once:
- the local half through a new optional storage.BlockersBatchStore,
  IsBlockedWithBlockersBatch, backed by
  issueops.IsBlockedWithBlockersBatchInTx (the stored flags, the blocked
  ids' blocking edges from both tables, one status read). The dolt and
  embedded dolt stores implement it, and a store without it still gets
  one IsBlocked per id;
- the external half from ONE read of the page's own edges, whose refs
  are resolved together, so each foreign project is opened at most once
  per request.

The answer per id is IsBlocked's, unchanged: a blocked item's BlockedBy
is the local live blockers, then the unsatisfied refs. Both reads now
order a source's blocking edges by (depends_on_id, type). The single
read had no ORDER BY, so its order was the table's, which is a UUID key
on these tables.

Tests:
- TestBlockingAnnotatorReadsAPageOnce pins 1 own-edge read, 1 foreign
  open, 1 batch read and 0 per-id reads for 40 ids. On the old body it
  failed with 40, 30, 0 and 40.
- TestBlockingAnnotatorFallsBackPerIDWithoutTheBatchRead covers a store
  without the batch read.
- TestPolicyBlockingAnnotatorBatchEqualsPerItem (embedded dolt) compares
  the batched answer, and IsBlockedWithBlockersBatch, against the
  per-item path by deep equality. It covers local blockers of every
  blocking type, closed and pinned blockers, parent-chain blocking,
  waits-for and conditional-blocks gates on both planes, satisfied,
  unsatisfied and unconfigured external refs, a non-blocking external
  edge, local plus external, a free row and a missing id.
- TestPolicyBlockingAnnotatorForeignOpensAreSublinear logs N=10 at 1.9 s
  per-item vs 0.26 s batched, and N=40 at 7.5 s vs 0.29 s. Foreign opens
  go from N to 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(dolt): pin server-mode IsBlockedWithBlockersBatch against IsBlocked

Review apply-fixes for #7556, iteration 1. Two minors are taken here, the
merge conflict is left to the pre-approval rebase, and two items are
declined. All changes are a test and a doc comment; no runtime code moves.

Taken: server-Dolt test for the batch arm (Test Evidence Quality)
- TestIsBlockedWithBlockersBatchMatchesPerRow runs the DoltStore arm that
  bd serve and server-backed bd list take, which no test executed before.
  It compares each id's entry with IsBlocked through reflect.DeepEqual.
  The fixture reuses the embedded fixture's shapes as the raw store sees
  them: blocks, a parent-child chain (the list is nil), waits-for,
  conditional-blocks, a wisp source and a wisp blocker, closed and pinned
  blockers, and external refs (blocks and related), which the raw store
  drops. It also covers a free row, a missing id and repeated ids. Two more
  cases reach code the embedded test does not:
  - one id that exists in both issues and wisps, with an edge in each table;
  - 210 blocked ids with 210 distinct blockers, more than queryBatchSize
    (200).
- Mutants were applied to the PR's code with the test binaries rebuilt.
  Five fail the new test and pass the existing embedded
  TestPolicyBlockingAnnotator* tests:
  - edge-chunk: read only the first edge chunk;
  - status-chunk: read only the first status chunk;
  - no-dedup: drop the repeated-id check;
  - table-order: read wisp_dependencies first;
  - server-wrapper: the DoltStore wrapper returns an empty map.
  A sixth mutant, no-order (drop ORDER BY), fails both the new test and the
  existing embedded batch-equals-per-item test.

Taken: BlockersBatchStore doc (Contract and Interface Fidelity)
- The doc now says the interface answers for the raw store alone, with no
  external-dependency policy applied. It is meant to be called from inside
  that policy's decorator, not probed through UnwrapStore by a caller that
  holds the decorated store.

Deferred to the pre-approval rebase: conflict with #7552 (role_accessors.go)
- This change does not rebase. On a scratch merge with main 70887e708a,
  this resolution was validated:
  - keep this PR's
    state := states[id]; if state.blocked { BlockedBy = state.blockers };
  - nest #7552's IncludeIsBlocked flag (IsBlocked = boolPtr(true)) inside
    that branch;
  - keep boolPtr.
- Results on that merged tree:
  - go vet: clean;
  - go test ./internal/storage/externaldeps/: 66 pass, including
    TestBlockingAnnotatorFlagsUnsatisfiedExternalRef;
  - embedded BlockingAnnotator|IsBlocked tests: 22 pass;
  - served httpclient Blocking|Blocked|ExternalDependency|Ready tests with
    BEADS_HTTP_TEST_REQUIRED=1: 96 pass, plus 4 known-divergence skips that
    predate this change.

Declined
- Duplication (route blockedStates' external half through
  blockingStateFromRecords): this refactors contributor code, adds the
  "external dependencies: resolve blockers:" error prefix, and is not
  test-only. Recorded as a follow-up.
- Pattern Drift nit (move the guards next to their methods, rewrap the
  AnnotateBlocking comment): optional churn next to the conflict region.
  Recorded as 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 <noreply@anthropic.com>
2026-10-14 11:52:37 +00:00
Julian Knutsen
ea0f6e1a46
feat(http): advertise issues.update.claim and route claims by it (S24a/b) (#7555)
* feat(http): advertise issues.update.claim and route claims by it (S24a/b)

updateIssue has served `claim` (upstream #6890), resolved on both planes so
a wisp is claimable, with no capability token: a client could only find it
by eating the skew 400, and gc's wire_compat preflight (which lists
issues.update.claim as an optional token) never saw it, so gc claimed every
wisp through claimIssue, whose Claimer role excludes the wisp plane.

Server: CapIssuesUpdateClaim ("issues.update.claim") joins
behaviorCapabilities. The spec names it on UpdateIssueRequest.claim and in
the context capabilities prose (apigen regenerated, descriptions only). No
request or response member changes; wire_revision stays 2.

Client: Lifecycle.Update reads the token from the cached handshake before
the dial. With it, every claim is one updateIssue call and its answer is
final (no fallback on any error). Without it, a claim alone goes straight to
claimIssue (no doomed 400 first; a wisp still refuses by name,
W-ClaimRequest.Wisp, whose Why now names the token), and a claim beside a
patch, a guard or a force override is refused before the dial with
ErrUnsupported{Capability: issues.update.claim}. serverPredatesUpdateClaim
(the error-sniffing fallback) is gone.

Tests: the four capability lists (routes.go, wire/handshake.go,
server_test, wire vocabulary_test) move together; unit tests for both
routes (pre-dial refusal dials nothing; with the token nothing falls back);
served tests claim a wisp through updateIssue with the token (zero claimIssue
dials, post-claim revision stitched), refuse it by name without it (zero
updateIssue claims, one claimIssue), and refuse a claim beside a patch
without the token while the same request claims and patches the wisp with
it. Live-mutated: ignoring the token fails the unit test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(http): count only ready --claim's requests in the claim-next check

TestE2E_AdvertisedExternalPolicyIsPassedThrough counted every request
since counter.reset(), so its "no by-id claim" check also saw the earlier
`update <other> --claim` step. The MC handshake mask does not advertise
issues.update.claim, so this PR routes that claim to claimIssue
(POST /v0/beads/issues/<id>:claim) by design, and the check failed in
Bazel / embedded Dolt tier (//backend/http:http_served_test shard 6 of
7), turning CI Gate / Required red.

Count from the snapshot length taken just before `ready --claim`, so the
check covers only the requests that command issues. The counter is not
reset: the close-policy check below scans the same history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(http): refuse a token-less template claim on the client's pre-read

Against a server without issues.update.claim, Lifecycle.Update sends a
claim alone to claimIssue (claimWithoutUpdateClaim) and returns before
applyTemplateGuardForServer runs. claimIssue's role has no template check
(bd-jkp9v3), so `bd update <template> --claim` against every server
without the token claimed the template. The base refused it before any
write: on the client's pre-read against a server without
issues.update.allowTemplate, and in updateIssue's own guard against one
with it.

claimWithoutUpdateClaim now pre-reads the row and returns
AuthorizeTemplateUpdate's refusal before the claimIssue dial, whatever the
handshake says about allowTemplate: that token means updateIssue guards
templates, and this route never dials updateIssue. Any other row goes on
to claimIssue as before (a wisp to its refusal by name), and so does an id
the pre-read cannot find, so claimIssue's not-found stays the one reported.

TestUpdateClaimRefusesATemplateWithoutTheToken (stub wire) and
TestServedUpdateClaimRefusesATemplateWithoutTheToken (served tier) pin it
under an allowTemplate-only and a neither-token handshake. Both go red
without the pre-read; the allowTemplate-only legs also go red if the
existing guard is only moved above the claim branch.

TestUpdateClaimFailsClosedWhenThePreReadFails pins the pre-read's third
arm under the same two handshakes: a read that fails other than as
not-found returns that failure and never dials claimIssue, since the
row's template bit is unknown then. A best-effort pre-read (that failure
falling through to the claim) passed go test ./internal/httpclient/ and
its served Claim|Template tier before this test, and goes red on both
legs with it.

A claim beside AllowTemplate is refused before the dial with
ErrUnsupported naming the token, like a claim beside a patch, a guard or
a force override (isClaimOnlyUpdate already excluded it), but no prose
said so: claimWithoutUpdateClaim's doc, CapIssuesUpdateClaim's doc, the
test doc and the CHANGELOG entry now list it, and a
TestUpdateClaimAgainstAServerWithoutTheToken row pins it. Dropping
!req.AllowTemplate from isClaimOnlyUpdate passed the same unit and served
runs without that row and goes red with it.

The prose now follows the handshake rule too: the W-UpdateRequest.Claim
ledger row (and its re-rendered md) no longer calls claimIssue the
fallback for a server that 400s the member, Update's doc names
claimWithoutUpdateClaim instead of the nonexistent claimRouteForServer,
wire.UpdateFlags.Claim drops the "safe to read as skew" rationale no
caller relies on anymore, and the CHANGELOG entry says a template is still
refused on the token-less route.

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: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 11:47:45 +00:00
Julian Knutsen
70887e708a
feat(http): serve IsBlockedBatch through the BlockingAnnotator role behind dependencies.blocking.isBlocked (#7552)
* feat(http): serve IsBlockedBatch through the BlockingAnnotator role behind dependencies.blocking.isBlocked

gc's native ready cache needs bd's stored, transitive is_blocked column for
the active set (beads.BlockedQuerier.IsBlockedBatch). Over http the client
answered it with the generated stub, so every reconcile logged
`operation "IsBlockedBatch" not supported by the http backend`, the
projection stayed disabled and native Ready took ~5 s on the MC shadow.

No read a deployed (1.3.0) server serves can answer the column exactly:
the /v0 reads hydrate issues without is_blocked, the blocking decoration is
direct and two edge types only, and the flag also propagates down
parent-child edges and reads waits-for / conditional-blocks gates. So this
is an additive server behaviour plus a token, not a client-side
composition.

- issueops: BlockingRequest.IncludeIsBlocked asks for, and
  IssueBlocking.IsBlocked carries, each answered id's stored flag (nil =
  no row, never "free"). issueops.BlockedFlags is the one library entry
  for the batched read over the role, chunked at BlockedFlagsChunk (100,
  held equal to the served issue_id bound by an httpapi test).
- Bodies: storage/issueops.ExecuteBlockingAnnotation reads the flag with
  IsBlockedBatchInTx in the same read transaction (dolt, embeddeddolt and
  every sqlkit-style store that calls it); the unit-of-work body asks the
  new DependencyUseCase/Repository IsBlockedBatch (same shared SQL body).
  externaldeps keeps IsBlockedBatch's external-blocker invariant on the
  local and remote annotators, and its Store.IsBlockedBatch no longer makes
  the raw edge read over a role-served store.
- Wire: GET /v0/beads/dependencies/blocking accepts `is_blocked` behind the
  new behaviour token dependencies.blocking.isBlocked (spec, apigen,
  wire-shape golden). wire_revision stays 2.
- Client: httpBlockingAnnotator forwards IncludeIsBlocked and refuses it
  BEFORE dialing with *ErrUnsupported{Capability:
  dependencies.blocking.isBlocked} against a server that does not
  advertise it; Store.IsBlockedBatch is issueops.BlockedFlags over that
  annotator, so gc's errors.As latch still sees the typed refusal on an
  old server, now naming the token that lifts it.

Tests: conformance case RunBlockingAnnotatorReportsTheTransitiveBlockedFlag
(child of a blocked parent is blocked, free is false, a ghost has no flag,
unasked carries none, BlockedFlags agrees) on the dolt, embedded, uow and
served legs; httpapi handler and chunk-bound tests; client tests for
chunking, the wire shape and the zero-dial refusal; vocabulary/capability
gates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(externaldeps): keep the external blocker on the unit-of-work IsBlockedBatch

bd serve on a server or proxied-server workspace serves through the
unit-of-work arm (WrapUOWProvider) and advertises
policy.external_dependencies, so a client trusts the server's answers and
adds no external term of its own. That arm's dependency use case did not
override IsBlockedBatch, so the new dependencies.blocking.isBlocked flag
answered the stored is_blocked column, which has no external term. An issue
blocked only by an unsatisfied external: ref came back is_blocked=false,
with that ref listed in its own blocked_by, while GET /v0/beads/ready
excluded it.

dependencyUseCase.IsBlockedBatch now raises every id that has an
unsatisfied external blocker, deciding by the edges and resolver
GetReadyWork excludes by, read through the same unit of work. Unlike Ready
it resolves only the refs of the ids the column answered: a client asks in
chunks, and no chunk should reopen every foreign project the workspace
names. An id naming no row stays absent.

Also correct the store decorator's IsBlockedBatch doc (the served flag now
comes from the annotator role), add the CHANGELOG entry for the new
capability, and pin the flag against Ready on every arm: WrapUOWProvider,
directly and through its BlockingAnnotator (an absent id stays absent), the
local annotator, and the served test, which now asserts the flag and the
batched read. A counting opener pins that the unit-of-work read opens only
the foreign projects its asked rows name.

Checked against a real bd serve on a proxied-server workspace. At
97bcb57738 an issue blocked by external:remote:payments answered
is_blocked=false while /ready excluded it. With this change it answers
true, and once the capability ships /ready includes the issue and
is_blocked is false. Asked about a free issue alone, the server resolves
no external project; asked about the remote-blocked issue, it resolves
remote and leaves alone the unconfigured project another issue names.

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(externaldeps): pin that a satisfied external blocker leaves the unit-of-work is_blocked false

Review of 192b73676 (bee-ghosttrack): the two new IsBlockedBatch tests only
had unsatisfied external refs, so a body that raised every answered id with
any external record (ignoring the resolver) stayed green.

TestWrapUOWProviderBlockedFlagResolvesOnlyTheAskedRefs's opener now
returns a foreign store whose labelled index carries a CLOSED provider of
provides:payments (the decorator_test.go shape). be-shipped blocks on
external:remote:payments (satisfied) and must read false; be-blocked moves
to external:remote:invoices (still unsatisfied) and reads true; both still
open /projects/remote once. With the reviewer's mutant applied
(`if _, ok := answered[id]; ok && len(state.refsByIssue) >= 0 {`) the test
fails on be-shipped in both new cases; restored, it passes
(bazel test //internal/storage/externaldeps:externaldeps_test).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(externaldeps): pin the store arm's satisfied external ref and the unasked is_blocked flag

The store arm decides an external blocker in two places: IsBlockedBatch's
local loop skips a ref the resolver reports satisfied, and the
BlockingAnnotator role folds IsBlocked's verdict, which applies the same
filter, into the served flag. Both annotators, store and remote, add that
flag only when the request asks for it. No test checked either store answer
for a ref whose project had shipped the capability, or that an unasked
annotation carries no flag, so dropping any of those checks left the
package green.

Pin them: IsBlockedBatch and the store annotator answer false for a row
whose only blocker is external:remote:payments once remote has closed its
provides:payments issue, and neither annotator flags a row unasked, even
one an external ref blocks. This is the store half of bd-yewju3; the
previous commit pinned the unit-of-work half.

Each mutant below survives the package at the previous commit and fails
exactly one test here (go test -tags=gms_pure_go
./internal/storage/externaldeps/; unmutated, bazel test
//internal/storage/externaldeps:externaldeps_test passes):
- decorator.go IsBlockedBatch: `&& !satisfied[dep.DependsOnID]` made
  `&& len(satisfied) >= 0` fails TestIsBlockedBatchHonorsShippedExternalRef.
- decorator.go IsBlocked: `if !satisfied[ref.raw] {` made always true fails
  TestBlockingAnnotatorLeavesShippedExternalRefUnblocked.
- role_accessors.go: `if req.IncludeIsBlocked {` made `if true {` fails
  TestBlockingAnnotatorAddsNoFlagUnasked.
- remote_roles.go: dropping `req.IncludeIsBlocked &&` fails
  TestRemoteBlockingAnnotatorMergesExternalBlockers.

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>
2026-10-14 08:46:13 +00:00
Julian Knutsen
eaed71fbba
fix(http): bd promote over http through issueops.Promote and issues.update.persistence (S21b) (#7554)
* fix(http): bd promote over http through issueops.Promote and issues.update.persistence (S21b)

`bd promote` refused over a connected HTTP workspace: it called the raw
PromoteFromEphemeral, which the http backend stubs, and updateIssue's patch
did not publish persistence. MC's PR-intake formula
(mol-normalized-issue-pr-v1) runs `gc bd promote <id> --reason ...`, so this
blocked the HTTP cutover.

- One library entry, issueops.Promote(ctx, PromoteRoles{Reader, Lifecycle,
  Commenter}, PromoteRequest{Actor, IssueID, Reason, Provenance}): read the
  row, refuse a non-wisp (*NotAWispError, the sentence bd promote always
  printed), move it with ONE Lifecycle.Update whose patch is Persistence =
  persistent (the role's atomic plane move: same id, labels, deps, events and
  comments carried), then write the promotion comment (a comment failure is
  reported, the promotion stands). A no-op move is a lost race and reports
  NotAWispError without a second comment.
- cmd/bd: the direct route runs it over the store's own role accessors, so a
  connected http workspace and a local one take the same entry. The history
  label is "bd: promote <id>" where the store carries caller labels.
- bd serve: IssuePatchBody.persistence (persistent|ephemeral|no_history,
  anything else a 400 naming patch.persistence) on PATCH
  /v0/beads/issues/{id}, behind the new additive behavior token
  issues.update.persistence. wire_revision unchanged. Spec, apigen and the
  wire-shape golden regenerated; the handler only decodes and passes it to
  the role.
- httpclient: Lifecycle.Update sends patch.persistence only to a server
  advertising the token, and otherwise refuses BEFORE the dial with
  *wire.CapabilityError naming it (unwraps to *storage.ErrUnsupported with
  Capability set). The batchApply item still refuses it
  (W-IssuePatch.Persistence now reads "ON issues:batchApply").
- Conformance: RunLifecycleUpdatePersistentPromotesAWisp on dolt, embedded,
  uow and the served http leg; the served
  PersistentPreservesUnversionedClass case is unparked.
- Served e2e TestE2E_PromoteOverHTTP: the mc-promote shape end to end
  (label kept, comment written, one PATCH, re-promote refused), and under
  the MC server mask a pre-dial refusal naming the token with no write.
- Corpus: mc-promote stays pending, relabelled SRV-1 with the reference
  profile's exact refusal (the 1.3.0 server lacks issues.update.persistence).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(promote): run the proxied-server route through issueops.Promote (bd-4y73m9)

The adoption review found (major) that the proxied-server route still
promoted through the old engine, IssueUseCase.PromoteWisp in one
transaction with the comment, while the PR's docs said every route runs
issueops.Promote. Converge rather than reword: runPromoteProxiedServer
resolves the id, then runs issueops.Promote over the provider's own
notifying role accessors (proxiedIssueReader, proxiedIssueLifecycle,
proxiedCommenter), the entry the direct route runs. Both routes now share
promoteFailure (the error mapping) and reportPromotion (the comment
warning and the output), so neither contract can drift.

What a script sees change on the proxied-server route:
- the move is the persistence branch of Lifecycle.Update, so the child
  counter moves with the row: a promoted parent's next
  `bd create --parent` mints .3 after .1/.2 instead of failing with
  "issue already exists";
- on_update fires twice, for the move and for the comment, as on the
  direct route (it fired once, for the comment);
- a promotion is two Dolt commits, "bd: promote <id>" and
  "bd: comment <id>" (it was one);
- a comment that cannot be written leaves the promotion standing behind
  a warning, as on every other route, instead of rolling it back;
- a dual-plane id is refused rather than merged, the update role's
  template guard applies, and a lost race reads "<id> is not a wisp
  (already persistent)".

The PromoteWisp exemption in TestRecordingIssueUseCaseCoversItsSurface
stays, with its reason corrected: no route calls PromoteWisp now, and
its DoltStorage twin fires no hook either. The doc comments on the old
engine (PromoteFromEphemeral on DoltStore and the db layer, PromoteWisp)
no longer say bd promote uses it.

CHANGELOG: the promote entry now names what a script can see on the
direct and proxied-server routes: the hook firings, the comment row
`bd comments` lists, the child-counter carry, the two-commit shape, and
a comment failure that warns instead of rolling back.

Tests:
- TestEmbeddedPromoteMovesAWispParent promotes a wisp parent with .1/.2
  children, a dependency and a comment under a counting on_update hook:
  the hook fires twice, the dependency and the children's parent edge
  survive, `bd comments` lists the old comment and the promotion reason,
  and the next child is .3. At the pre-PR base it fails (the hook fired
  0 times).
- The proxied journey pins the two commits, and new subtests pin the
  child counter (the child_counters row, next child .3) and the two hook
  firings. Against the contributor head each fails: one commit, no
  counter row and a failing create, one firing.

Review iteration 2:
- TestEmbeddedPromoteMovesAWispParent gets its row in the embedded cmd
  shard manifest (shard 64 of 100, from the generator's incremental
  --write). Without it //scripts:go_test_sources_test fails both the
  NotStale and the bare-write guard, and the generator's --check fails.
- notifying.go no longer lists the promotion comment as a divergence.
  The direct route now writes that comment through st.Commenter(),
  which HookFiringStore wraps, so an embedded promote fires on_update
  for it (TestEmbeddedPromoteMovesAWispParent counts both firings). The
  list counts four, and the empty-commit note becomes the fifth item.
- batchapplier.go no longer says persistence is absent from both patch
  bodies: the update body publishes it behind issues.update.persistence,
  and only batchApply refuses it (W-IssuePatch.Persistence).
- Three comments still tied promotion to the old engine: the
  conformance fixture's PromoteWisp no longer claims to do what
  `bd promote` does, the CLI differential's promote scenario names
  issueops.Promote, and export_source's wisp-relations note names
  issueops.MoveIssuePersistenceInTx.
- The Promote unit test compares the whole update patch with
  reflect.DeepEqual. The helper it replaces checked 9 of the patch's 22
  members, so a Promote that also set Description passed it.

Review iteration 3:
- A refused persistence move answered 500 `internal` over http and
  emitted request_error, though the caller could fix the request. The
  role now returns two refusals as ErrValidation, so bd serve answers
  400 invalid_argument and the client maps that back to ErrValidation:
  an unversioned row asked for ephemeral or no_history (the role wraps
  types.ErrUnversionedWispMove, a new sentinel NormalizePersistenceMode
  returns for that case alone, with its message unchanged), and a
  demotion of a row with retained snapshots. A row that breaks its own
  persistence invariants still answers 500.
- RunLifecycleUpdateWispModesRefuseAnUnversionedRow pins the refusal on
  every leg (dolt, embedded dolt, the unit of work, served http): both
  wisp modes match ErrValidation and leave the row durable, unversioned
  and off the wisp plane. Without the wrap the dolt leg fails, and the
  served leg fails on "answered 500 internal".
- TestMoveIssuePersistenceInTxRefusesDemotionWithRetainedSnapshots is
  the first test of the snapshot refusal, and fails without its wrap.
  The unversioned unit test now requires both sentinels. The types tests
  pin the sentinel, its unchanged message, and that no row-invariant
  error matches it: checking the unversioned class ahead of the
  invariant checks fails them.
- CHANGELOG: the promote entry counts five script-visible changes, the
  fifth being the lost-race refusal sentence, and says the two refusals
  now answer 400 over bd serve and gain a `validation failed: ` prefix
  locally.
- NotAWispError's doc comment records that a no-history wisp is refused
  too: the gate reads the Ephemeral flag, as bd promote always has, and
  `bd update --persistent` is the move for that row.

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>
2026-10-14 05:51:53 +00:00
Julian Knutsen
048f5e5192
fix(httpclient): bound response-header waits and retry stalled reads on another connection (#7553)
* fix(httpclient): bound response-header waits and retry stalled reads on a new connection

The maintainer-city shadow run saw 22 requests sit out the full 60s client
timeout, each on one silent HTTP/1.1 connection while other connections to
the same serve kept answering.

wire.Client now bounds an idempotent request's wait for response headers
(15s default; BEADS_HTTP_RESPONSE_HEADER_TIMEOUT or
DialOptions.ResponseHeaderTimeout; "off" disables), separately from the 60s
overall timeout, and stops the timer once headers arrive so a streaming body
is never cut. A read (GET/HEAD/OPTIONS, or a Request marked Idempotent: the
POST batch get) that stalls or has its connection reset is retried once: the
stalled attempt's cancellation closes its connection and idle connections are
dropped, so the retry dials fresh. Every retry is counted
(wire.StallRetryCount) and reported (OnStallRetry; the dialer's default logs
one stderr line with the count).

Writes are never retried and get no header timer, because bd serve answers
a write only after it commits (a large batch apply can legitimately take
tens of seconds). A write whose overall timeout fires before its headers
fails with a typed *wire.ResponseHeaderTimeoutError (inside *ConnectError)
naming the host and saying the outcome is unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(httpclient): retry a stalled read within the overall timeout (bd-p1wzpi)

Adoption review of #7553 found three defects in the header timer and its
retry. This maintainer fixup sits on top of the contributor commit and
supersedes three of its claims: that the timer bounds a read's every
attempt, that idle connections are dropped before the retry, and that any
write whose overall timeout fires before its headers is typed.

A slow but healthy read is no longer cut short. The 15s timer cannot tell
a silent connection from a serve still working on the read (serve writes a
read's headers only after waiting up to 10s for a database slot and running
the query), and the retry ran under a fresh 15s timer, so a read slower
than 15s failed at about 30s after sending two requests where it used to
succeed within 60s. The timer now bounds only the first attempt. The retry
has no header timer and runs under a deadline of when the first attempt was
sent plus the client's overall Timeout, the moment that Timeout itself
counts from, so it finishes such a read and no read waits longer than the
60s it could before. The request is built and stamped once and each
attempt sends a copy of it, so the credential source is consulted once,
before any clock starts, and a cold token command costs the retry none of
its budget. What is left: a read whose headers take longer than the timer,
and whose retry then needs more than what remains of the 60s (about 45s)
for its headers and body together, now fails at 60s where it used to
succeed, and the server also gets the abandoned first request. A read whose
first attempt already spent the whole Timeout (the timer off) is not
retried at all and keeps its typed timeout.

A request is typed *ResponseHeaderTimeoutError only once it was written.
Any Timeout() error on a write used to be typed, including the baseline
transport's dial and TLS handshake timeouts where nothing reached the
server, and the message then said the write "may or may not have been
applied", gave the overall timeout as the wait, dropped the transport's
error, and Temporary() was true. The timer is now armed from httptrace's
WroteRequest (where http.Transport.ResponseHeaderTimeout starts its own
clock), which also records that the request went out. A timeout is typed
only for a written request whose caller's context is still alive; a dial
or TLS timeout stays a plain *ConnectError. After is the measured wait,
Err is printed, Temporary() reports Replayable (false for a write), and a
retried read says why its first attempt was abandoned (Reason). Arming at
the write also stops a slow credential source (BEADS_HTTP_TOKEN_COMMAND may
take 30s) from being reported, counted and retried as a server stall.

No idle-connection flush. CloseIdleConnections ran on a transport shared
by every no-CA dial in the process (baselineTransport), so one stalled read
dropped idle keep-alives to every host. Canceling the stalled attempt
already closes its connection (net/http never pools a canceled HTTP/1.1
connection), so the retry rides another one.

Also:
- wire.Request.Replayable (GET/HEAD/OPTIONS, or Idempotent) is now the one
  predicate behind both the wire's stall retry and dispatch's bounded 503
  retry, so the batch get, a read on POST, is retried on a 503 too.
  dispatch's doc comment no longer says the wire never resends.
- The docs, the error and the stall line say the retry goes out on
  "another connection", not a "new" one: the idle pool may hand it one
  already open. dialStream's doc says the events:watch connect gets
  neither the timer nor the retry.
- BEADS_HTTP_RESPONSE_HEADER_TIMEOUT takes bare seconds ("30") as
  BEADS_GATE_WAIT_TIMEOUT does, and "off" in any case. "off" or 0 turns off
  only the timer: a reset connection is still retried and a written request
  that times out is still typed.
- README says "each read" and spells out the above, bounding the retry by
  its headers and body together; it no longer says a streaming body is
  never cut off (the header timer never does, the 60s bound still does).
  The CHANGELOG entry moves from Added to Fixed and states the same bound.
- CredentialProvider's doc, in wire and on the public bdhttp alias, says
  Authorize runs once per request, not once per attempt: the stall retry
  resends the stamped headers up to the overall timeout later, so a
  single-use or short-lived credential may draw a 401 there, which reaches
  Refresh like any other.

Tests: a read queued behind a LimitListener backlog finishes once a slot
frees; a read slower than the timer on every connection finishes on its
retry; a slow credential source is not a stall, and one that takes the
whole Timeout to resolve still leaves the retry its budget (starting the
deadline before the stamp, or re-stamping the retry, fails it); a write
whose dial times out is a plain *ConnectError; a stall leaves another
server's idle connection on a shared transport alone; a retry after a
reset names the reset; the stall-twice case is bounded by the overall
timeout and pins After, Reason and the message; dispatch retries a read
on POST on a 503, and GetMany's batch get is sent as one (dropping its
Idempotent fails that); the env knob takes "30", " 1.5 " and "OFF" and
refuses "-3". A read whose first attempt spent the whole Timeout is not
retried and keeps its typed error (dropping the spent-budget check fails
it; no other test did). A stall retry that draws a 401 refreshes once and
authorizes only the re-issued request, so Authorize runs twice, not three
times (re-stamping the retry fails it).

Not covered, as before, and now said in README and the CHANGELOG: the
events:watch stream's connect (dialStream) has no header timer or retry.
Nor is a reset on Windows: stallReason matches syscall.ECONNRESET, which a
Windows reset (WSAECONNRESET) is not, so there a reset connection is
retried only when it surfaces as EOF.

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 <adopt-pr@gascity.com>
2026-10-14 05:04:19 +00:00
Julian Knutsen
e7ad85bcff
fix(http): bd export over http through issueops.ReadExport (S21) (#7551)
* fix(http): bd export over http through issueops.ReadExport (S21)

bd export read through raw SearchIssues and the bulk label, dependency and
comment reads, which the HTTP backend refuses (B3 #16), so gc's JSONL export
order (gc bd export --all) failed on every remote scope.

issueops.ReadExport composes role reads every deployed server publishes: an
unlimited Reader.List for rows, labels and counts, EdgeReader.ReadEdges for
dependency records, and Reader.Get with comments for rows that have any. The
remote route feeds it into the same runExportFromSource the direct and
proxied routes use. A failed read fails the export. gc-export-all passes
against the reference profile; mc-promote stays pending (S21b) with its exact
reason: it needs a new server capability.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(export): read remote memories from the memory plane, pin unmarked no-history rows (bd-o4qlui)

Review fixes for #7551, attempts 1 to 3.

Attempt 3. No test reached roleExportSource.ExportMemories's error
path. A unit test now drives it with a fake store: a memory role that
cannot be reached, and a listMemories that fails, each end the export
with that error and no map. Rewriting either branch to degrade to an
empty map would bring back a remote `bd export --all` that exits 0 with
no memory in it.

Declined in attempt 3, for finalize to file: an unlimited HTTP listing
that stops on a has_more page with no next_cursor returns the rows it
has with HasMore false, so ReadExport's refusal cannot fire over HTTP.
Only a server that breaks the spec's has_more/next_cursor pairing gets
there; this repo's server always sends a cursor with a non-empty
has_more page. The walker (fetchIssuePages) is unchanged since #7247
and shared with bd list, so the fix needs its own PR that checks bd
list's callers first. The remote route also has no single snapshot: a
comment changed between List and Get can make the written count
disagree with the bodies kept. That belongs in one follow-up with the
bounded retry declined in attempt 1, as a count/body consistency check.
The --include-infra e2e leg stays declined. The wire does carry the
knob: the client sends include_infra and include_templates on
listIssues, and the server decodes both. The GetInfraTypes nil-store
guard stays declined, and auto-export's own GetAllConfig memory read
predates this PR.

Attempt 2. A remote export dropped every memory. Over HTTP, `bd export
--all` and `--include-memories` exited 0 without a memory record, where
the base refused with exit 1. The memory lines came from GetAllConfig,
which over HTTP is listSettings, and the server's settings enumeration
withholds every kv.* row, memories included. gc's JSONL export runs
`gc bd export --all`, so its archive lost them without a word.

The exportSource seam now asks each source for its memories
(ExportMemories), not for the whole config table. The local and proxied
sources still take them from their config table. The remote source reads
the served memory plane, store.Memories().List (listMemories), which the
deployed bd 1.3.0 server advertises as memories.list. httpMemories.List
refuses a page that reports has_more: ListResult has no cursor, so a
truncated plane would pass for the whole one. The memory error now says
"failed to read memories"; nothing in beads or gascity matches the old
text.

TestE2E_ExportOverHTTP seeds two memories with `bd remember` over HTTP.
It requires exactly those two in --all, in --include-memories and in the
local re-export of the imported file, and none in the default export. A
unit case pins the has_more refusal. The CHANGELOG entry says where
remote memories come from, so its "Nothing is dropped" holds. The
WispPlaneIDs doc no longer says the listing refuses an id set, which
stops being true once a server advertises issues.list.ids (#7550).

Attempt 1. The remote route's WispPlaneIDs doc and the CHANGELOG had the
effect of the missing wisp_plane marker backwards. They said import then
routes a no-history row by its flags. A current import does the
opposite: it pins an unmarked no-history row to the durable plane
(applyImportWispPlane). So a genuine no-history wisp in a remote export,
which gc's session, wait and order beads are by default, re-imports onto
the Dolt-versioned issues plane, and gc's JSONL archive keeps it.

The route still stamps nothing. No served read publishes plane
membership: listIssues rows carry no plane field, however the listing is
scoped. Inferring the marker from the flags would re-plane a durable row
that still carries the flag and drop its relations (bd-r9uce), and
refusing the export would re-break gc's remote JSONL export. The doc and
the CHANGELOG now state the real consequence, and serving the membership
is bd-1lbvas. TestE2E_ExportOverHTTP pins it. A no-history row is
exported without the marker by --all and by the default export. A fresh
local workspace imports it onto the durable plane, against a locally
created control row that the local route does mark.

Attempt 1 minors and nits: ReadExport refuses a listing page marked
HasMore, as the uow source does, and unit cases pin that and a failed
comment read. The exportSource interface doc names ExportIssues and its
contract. The export error now says "failed to read the export set"
rather than "failed to search issues"; nothing in beads or gascity
matches the old text. roleExportSource.GetInfraTypes says it is unused
on this route.

Declined, for finalize to file: a bounded retry of ReadExport when a row
vanishes between the reads (a design change; today's fatal behavior is
pinned), and e2e rows for pinned, gate, template and infra-typed issues,
including an --include-infra leg over HTTP. Also declined: a nil-store
guard on roleExportSource.GetInfraTypes. The method is dead on this
route, and the source's other store readers (ExportIssues, GetConfig,
ExportMemories) dereference the store unguarded too.

Validation, attempt 3: git diff --check, the go.mod-pinned gofmt, go
vet, gazelle (no change) and the go_srcs check. The new test passed with
no skips. Three mutants were killed. An empty map with no error on a
failed listing, and the same on an unreachable role, each fail their own
subtest. An empty map returned beside the listing error fails the no-map
assertion; export.go discards the map on error today, so that case pins
the interface's "fail rather than return a partial set" contract, not
visible output.

Validation, attempt 2: git diff --check, gofmt and go vet. The
httpclient memory tests passed, 23 of them: 4 units and 19 served. So
did TestE2E_ExportOverHTTP on embedded Dolt with
BEADS_HTTP_TEST_REQUIRED=1 and no skips. Two mutants were killed: a
remote source that reads the settings listing fails 3 e2e assertions,
and dropping the has_more refusal fails the unit case. Export parity
passed with no skips on the classic (memory determinism, byte
stability), embedded and proxied tiers, including the proxied-versus-
classic byte identity with memories. The PR is now behind main, which
added #7549 and #7550, and conflicts with it textually in CHANGELOG.md,
backend/http/BUILD.bazel and issueops/BUILD.bazel. With those resolved
by union, the merge with main e6a891b900 builds and vets. On that merge,
in CI's pinned-shard layout, the served http tier passed 49 of 49,
including #7550's list-scope e2e. The command corpus ran 128 shapes: 113
pass, 3 allowed, 12 pending and 0 fail. gc-export-all passes without its
pending mark, the one shape that moved. The issueops ReadExport and
ListGates tests passed, as did the embedded and proxied export tiers.

Validation, attempt 1: the issueops ReadExport tests, with two mutants
killed; TestE2E_ExportOverHTTP with a flag-stamping WispPlaneIDs mutant
killed on three assertions; the cmd/bd export tests in a scrubbed env.

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>
2026-10-14 03:59:35 +00:00
Julian Knutsen
e6a891b900
feat(list): bd list --no-assignee, --title and --id over http behind per-parameter tokens (S15b) (#7550)
* feat(list): bd list --no-assignee, --title and --id over http behind per-parameter tokens (S15b)

Over http `bd list --no-assignee`, `--title` and `--id` refused: the list
encoder had no listIssues parameter for ListRequest.NoAssignee,
TitleSearch or IDFilter (B3 #11). All three are maintainer-city cutover
blockers: gc's default on_boot hook runs
`bd list --no-assignee --status=in_progress ...` on every agent boot, the
PR-intake formula lists by `--title "$SUBJECT"`, and the pr-review skill
by `--id <ids>`.

The library entry is unchanged: issueops.Reader.List, whose bodies
already apply all three through workapi.BuildListFilter, the same entry
the local route reads through.
- Server: GET /v0/beads/issues decodes `no_assignee`, `title` and `id`
  into those ListRequest members (`id` handed over as written; the role
  splits, trims and de-duplicates, as countIssues already does). Each is
  behind its own new behavior token, issues.list.noAssignee,
  issues.list.title and issues.list.id (additive, wire_revision stays 2):
  each is a separate caller's dependency, and a refusal names exactly the
  one it needed. The spec parameters cite their tokens; apigen and the
  wire-shape golden are regenerated.
- Client: the encoder maps the three members to their parameters, and
  httpReader.List refuses a request carrying one BEFORE dialing, with
  ErrUnsupported{Capability: <token>}, unless the handshake advertises
  that token (refuseUnservedSearch generalised to one table,
  tokenedListFilters, with bd search's `q`). Never a round trip an older
  server answers unknown_parameter, never a wider listing.
- ErrHTTPUnsupported's text names the capability when it has one, as the
  portable sentinel does, so `bd list` says which token the server lacks.
- The three E-ListRequest ledger rows retire; the ledger is re-rendered.

The id scope unparks the served Reader contract: the sixteen cases parked
on E-ListRequest.IDFilter now run against the in-process server. Twelve
pass as written; four still park, each now on the member it actually
needs (Offset twice, PinnedFlag, ExcludeTypes). The served refusal sweep
asserts SpecPrefix where it asserted IDFilter.

Tests (failing first): handler test that each parameter reaches the
storage filter; client tests that each member rides its parameter behind
its token and refuses pre-dial, zero dials, naming its token, against a
server lacking it; round-trip and vocabulary gates; capability lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http): the four maintainer-city list shapes end to end; corpus marks relabelled SRV-1 (S15b)

TestE2E_ListScopeFiltersOverHTTP runs the corpus shapes gc-list-on-boot,
gc-list-on-boot-workflow, mc-list-title and mc-list-id through the real
bd against the in-process server (which advertises the three new tokens)
and requires each to answer an embedded workspace's rows and exactly the
rows it names: --no-assignee leaves out an assigned in-progress row on
the same lane, --title is case-insensitive, --id lists a closed id under
--all. Against the MC production server's handshake shape each shape
exits non-zero naming its token and never dials listIssues.

The corpus suite masks the served side to reference_server.json, the
deployed bd 1.3.0 surface, which advertises none of the tokens, so the
four shapes now get the named pre-dial refusal there. Their marks move
from S6c+S15b to SRV-1 with that reason, like mc-search. With a scratch
profile that adds the three tokens and parameters (not committed) exactly
these four shapes report "now passes; remove the pending mark" and
nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(list): adopt bd-enterprise's listIssues `id` contract: repeatable, issues.list.ids (S15b)

bd-enterprise already publishes listIssues `id` (E9-S2): a REPEATABLE
parameter, one id per value, behind `issues.list.ids`, with its client
sending IDFilter split into one value per member. The first cut of S15b
took ONE comma-separated `id` behind `issues.list.id`, so the same
parameter name had two incompatible meanings: an OSS client's "a,b" is a
400 on an enterprise server, and the enterprise rebase onto main would
collide. OSS now publishes enterprise's contract unchanged:
- Server: listIDFilter (ported verbatim) decodes the repeated `id` into
  ListRequest.IDFilter's comma set; more than 200 values, an empty value,
  a comma, leading or trailing whitespace, a control character or an
  over-long id is a 400 `invalid_argument` on `id`. The spec parameter is
  enterprise's (array, maxItems 200); apigen and the wireshape golden are
  regenerated.
- Token: CapListIDs = "issues.list.ids", the enterprise spelling and name
  on both sides.
- Client: the encoder splits the set the way the role does (splitIDSet)
  and sends one `id` per member; the pre-dial gate fires only when the set
  names an id.
- Tests: list_ids_test.go is enterprise's id cases (the exact set reaches
  storage, the 200 bound is served, every refusal beside its control, the
  spec bound matches the constant); the handler, client, round-trip and
  e2e cases move to the repeated shape and the new token.

`no_assignee` and `title` are unchanged. Served tier, http e2e (including
TestE2E_ListScopeFiltersOverHTTP) and corpus_served_test pass; with a
scratch reference profile advertising the three tokens exactly the four
S15b shapes report "now passes".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 00:18:00 +00:00
Julian Knutsen
d4ca89369f
fix(http): bd gate list over http through issueops.ListGates (S20) (#7549)
The workspace-wide gate listing built a raw SearchIssues filter, which the
HTTP backend refuses (B3 #15), so gc's renudge-stale-human-gates order
(gc bd gate list --limit 0 --json) failed on every remote scope.

issueops.ListGates asks the Querier role (queryIssues, served by every
deployed server) for type=gate, closed hidden unless --all: the rows the raw
filter selected, on both planes. The direct, proxied and remote routes all
call it through openQuerier. The corpus seed gains an open, a closed and an
ephemeral gate, and mc-gate-list (the order's argv) plus mc-gate-list-all
pass on the served side.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 23:13:29 +00:00
Julian Knutsen
55aac47176
test(bazel): pin the item-5 one-wave rule for dolt-race/dolt-int budgets (#7545)
* test(bazel): pin the item-5 one-wave rule for dolt-race and dolt-int budgets

Closed PR #7542 found that a union with more test actions than its
effective --jobs can regress wall clock by up to +575s, because Bazel
does not schedule the longest action first and a second-wave test adds
its full duration to the critical path instead of overlapping it.
Compute the effective --jobs from .bazelrc (remote-exec's baseline,
overridden by a --jobs line on the union's own config, last one
winning, matching Bazel's BEP cmdLine semantics from #7542) instead of
reading remote-exec's line alone, and explain the second-wave tail in
the budget tests' failure messages.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(bazel): clarify why the union's --jobs wins (comment only)

Command-line config outranks rc-file config; the BEP cmdLine ordering
PR #7542 observed is a consequence of that rank, not "last one wins"
by position, so reordering .bazelrc's lines cannot change precedence.

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-13 15:43:37 +00:00
Julian Knutsen
308fd38ca2
test(corpus): seed served/embedded sides concurrently; size served shards from CI timings (#7538)
* test(bazel): shard http_served_test and corpus_served_test (embedded lane critical path)

Both served targets ran as one shard each (235-597s) and were the embedded
lane's longest action in most executing runs; every other embedded shard
ends by ~90-155s.

- http_served_test runs through go_test_pinned_shard.sh like
  httpclient_served_test: the 19 TestE2E_* cases >= 3s are pinned onto 6
  shards (pin_shards.py from three lane runs' test.xml plus one local run,
  <= ~88 measured seconds each), the ~28 fast tests round-robin in a 7th.
- corpus_served_test: TestServedCorpus becomes TestServedCorpusPart1..4.
  Shapes are dealt round robin in corpus order; each part starts its own
  server and seeds its own pair of workspaces. The shapes are independent:
  every check is served-vs-embedded parity after the same commands, each
  write owns its target ids, and order preservation keeps each part's reads
  ahead of its writes. TestCorpusPartsDealEveryShapeOnce checks the deal
  (every shape once, in order, no empty part); the manifest pins part k to
  shard k, with a 5th round-robin shard for the engine-free tests, and
  scripts TestCorpusPartsArePinnedOnePerShard ties corpusParts, the
  manifest and shard_count together. BEADS_CORPUS_REPORT now accumulates
  every part the process ran.
- pinnedShardTargets and the retired-lane args pins list both targets;
  go_test_sources_test gets the two packages' manifests as data.

Embedded goes from 172 to 182 test actions; the dolt-race/dolt-int union
budgets do not include the embedded tag and are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(corpus): seed the served and embedded sides concurrently in each part

Each TestServedCorpusPartN paid the server start and both seeds serially
(about 100-150s of a 190-220s shard in #7537's CI). The embedded side now
runs bd init and the seed on a goroutine while the test goroutine starts
the server and proxy and seeds the served side.

- prepareSide attaches one side (connect or init), writes its assets and
  runs the seed in order, returning failures as errors (execBD, runBD
  without the testing.T) so it is safe off the test goroutine; a failing
  side cancels the other, and a deferred cancel+Wait keeps the goroutine
  from outliving the test or its TempDirs.
- The sides share no directory, env or bd process; shapes, their order and
  every assertion are unchanged. Each part logs its setup time.
- bazel.yml's embedded lane uploads the served targets' test.xml on every
  run (bazel-embedded-served-testxml), so their pinned shards can be sized
  from a sharded run of the lane.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(bazel): corpus in 3 parts; re-pin http_served_test from a sharded CI run

Measured on this PR's first embedded-lane run (test.xml from the new
bazel-embedded-served-testxml artifact):

- corpus_served_test with concurrent seeding: parts 1-4 ran 135/140/144/114s,
  of which setup (part time minus its shapes) was 76/76/76/62s and the 127
  shapes 242s together. The setup floor is still ~70s+, so corpusParts goes
  from 4 to 3 (round robin; the measured split is 85/81/76s of shapes) and
  the manifest and shard_count follow (4 shards: 3 parts + round-robin).
- http_served_test: #7537's pins were sized from single-shard runs, and the
  sharded shards ran 73-184s against ~88s estimated. served_pinned_shards.txt
  is regenerated with pin_shards.py from that sharded run's per-test
  durations: 119/118/120/128/132/123 measured seconds per pinned shard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(bazel): pin http_served_test on the max over two sharded CI runs

The second run of the lane on this PR ran the same tests at 0.2-1x their
first-run times (executor load, not the tests), and its re-pinned shards
came out 36-118s against 118-132s estimated. pin_shards.py now takes each
test's maximum over both runs' test.xml, the same rule the other pinned
targets use: 123-135 measured seconds per pinned shard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(corpus): guard part wiring; seed metadata on e2e-t-ifa (review of #7537)

- testServedCorpus fails (before the engine gate, so in every lane) unless
  the test's name is TestServedCorpusPart<part>: a TestServedCorpusPart3
  calling testServedCorpus(t, 2) would run part 2 twice and silently drop
  part 3's shapes. TestCorpusPartNameMustMatchItsPart covers the check and
  that servedCorpusParts lists Part1..N in order. Mutation (Part3 -> 2)
  fails //backend/http/corpus:corpus_test with "TestServedCorpusPart3 runs
  corpus part 2; only TestServedCorpusPart2 may".
- e2e-t-ifa is seeded with metadata seeded=keep. The parts seed separately,
  so the two refused (exit 13) conditional updates no longer always follow
  gc-update-if-assignment's k=v; their verify show again holds that a
  refusal keeps existing metadata. Mutation (served verify output's
  seeded=keep rewritten) fails both stale shapes at
  $[0].metadata.seeded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(bazel): back to 4 corpus parts (served long pole over test-seconds)

maintainer-city-c3's call on the measured trade-off. With concurrent
seeding, 4 parts ran 114-146s each (run A) and 3 parts ran 170-180s (run D).
3 parts save one ~75s setup, about 75 test-seconds per executing run, but
the longest part is the embedded lane's served long pole. That pole is on
the gate's critical path (forks' above all), and 4 parts cut it by ~34s.

corpusParts=4, TestServedCorpusPart4, manifest part 4 on shard 4,
shard_count=5. The part-name guard is unchanged and covers Part4.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): served-timings upload is telemetry; corpus part bounds and ctx

Review of #7538 (maintainer-city-c3):
- "Upload served test timings" gets continue-on-error: true and
  timeout-minutes: 2, like the CI analytics upload. An artifact-service 5xx
  or stall no longer fails the required embedded lane or holds it until the
  job timeout. TestBazelWorkflowSecretsAndFailureSurface allows that
  continue-on-error only on this exact step
  (bazelServedTimingsContinueOnErrorPath, which also pins its name,
  artifact, path and timeout; TestBazelEmbeddedServedTimingsUploadIsTelemetry).
- corpusPartNameErr also refuses a part outside 1..corpusParts, so a stray
  TestServedCorpusPart5 fails instead of running no shapes. Two new cases.
- expand takes ctx: prepareSide's {rev:} lookups run under the seeding
  context, so a cancel stops them as well.

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-13 12:30:52 +00:00
Julian Knutsen
4e27523c0b
test(bazel): shard http_served_test and corpus_served_test (embedded lane critical path) (#7537)
* test(bazel): shard http_served_test and corpus_served_test (embedded lane critical path)

Both served targets ran as one shard each (235-597s) and were the embedded
lane's longest action in most executing runs; every other embedded shard
ends by ~90-155s.

- http_served_test runs through go_test_pinned_shard.sh like
  httpclient_served_test: the 19 TestE2E_* cases >= 3s are pinned onto 6
  shards (pin_shards.py from three lane runs' test.xml plus one local run,
  <= ~88 measured seconds each), the ~28 fast tests round-robin in a 7th.
- corpus_served_test: TestServedCorpus becomes TestServedCorpusPart1..4.
  Shapes are dealt round robin in corpus order; each part starts its own
  server and seeds its own pair of workspaces. The shapes are independent:
  every check is served-vs-embedded parity after the same commands, each
  write owns its target ids, and order preservation keeps each part's reads
  ahead of its writes. TestCorpusPartsDealEveryShapeOnce checks the deal
  (every shape once, in order, no empty part); the manifest pins part k to
  shard k, with a 5th round-robin shard for the engine-free tests, and
  scripts TestCorpusPartsArePinnedOnePerShard ties corpusParts, the
  manifest and shard_count together. BEADS_CORPUS_REPORT now accumulates
  every part the process ran.
- pinnedShardTargets and the retired-lane args pins list both targets;
  go_test_sources_test gets the two packages' manifests as data.

Embedded goes from 172 to 182 test actions; the dolt-race/dolt-int union
budgets do not include the embedded tag and are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(corpus): guard part wiring; seed metadata on e2e-t-ifa (review of #7537)

- testServedCorpus fails (before the engine gate, so in every lane) unless
  the test's name is TestServedCorpusPart<part>: a TestServedCorpusPart3
  calling testServedCorpus(t, 2) would run part 2 twice and silently drop
  part 3's shapes. TestCorpusPartNameMustMatchItsPart covers the check and
  that servedCorpusParts lists Part1..N in order. Mutation (Part3 -> 2)
  fails //backend/http/corpus:corpus_test with "TestServedCorpusPart3 runs
  corpus part 2; only TestServedCorpusPart2 may".
- e2e-t-ifa is seeded with metadata seeded=keep. The parts seed separately,
  so the two refused (exit 13) conditional updates no longer always follow
  gc-update-if-assignment's k=v; their verify show again holds that a
  refusal keeps existing metadata. Mutation (served verify output's
  seeded=keep rewritten) fails both stale shapes at
  $[0].metadata.seeded.

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-13 11:35:34 +00:00
Julian Knutsen
e0a32676ff
test(bazel): pin dolt-int's moved cmd-dolt args/env + omitted-status BEP case (#7536)
PR #7535 review nits (bee-ghosttrack, julianknutsen):

- The -test.timeout=19m arg and BEADS_TEST_REQUIRE_EXCLUDE_PERMISSION env
  var moved off --config=doltserver-cmd onto cmd/bd:bd_dolt_server_test and
  tests/regression:regression_test directly. Nothing pinned either line
  once it lived on the target instead of in .bazelrc, so TestBazelDoltIntCmdDoltTimeoutAndEnvPinned
  now fails if either is dropped or altered on either target.
- classify_tier_results.py already fails closed on a BEP testResult whose
  "status" field is omitted (proto3's NO_STATUS encoding), but no test
  exercised that path through read_test_statuses()/classify() -- only
  tier_result() with a pre-built status set. Add coverage for the real
  shape (an event whose testResult body has no "status" key at all).

Verified against rv7535's mutate.py: E5, E6 and G4 now CAUGHT (previously
SURVIVED on main); the other 38 mutants are unaffected.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 09:54:41 +00:00
Julian Knutsen
873162dafa
ci(bazel): dolt-int gates server-storage + cmd-dolt in mode remote (item 5 A2) (#7535)
* ci(bazel): dolt-int gates the server-storage and cmd-dolt tiers in mode remote (item 5 A2)

In mode remote, folds bazel-server-storage (--config=doltserver-integration)
and bazel-cmd-dolt (--config=doltserver-cmd) into one bazel-dolt-int job
(--config=dolt-int), following the dolt-race pattern from #7514. The
members have different gating categories (server-storage plain-gated,
cmd-dolt flag-gated/advisory), so the union carries continue-on-error: true
and a bespoke --label-scoped Shard balance step. All other modes keep the
two lanes running unchanged. Action keys are byte-identical between the
member configs and the union (17 + 46 = 63 TestRunner actions), so cached
results carry over either direction and a revert is a safe rollback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): dolt-int per-tier results, integration gating, key-parity wording (review)

Coordinator review of #7535 found three must-fixes: integration:"off" was
ignored in remote mode (the union's members already honor it); job-level
continue-on-error made a server-storage-only failure read success on
push/nightly/dispatch, where main stays red; and the PR's key-parity claim
overstated byte-identical actionKeys when only the remote action digest
(not the local actionKey) is unaffected by moving --test_env/--test_arg
onto the targets' own env/args.

Fixes:
- bazel-dolt-int's if now adds `&& inputs.integration != 'off'`, matching
  the members (#7491's review); bazelLaneRunModes and
  TestBazelDoltIntArmsExactlyOnePerMode cover the "off" case.
- Job-level continue-on-error removed; only the `bazel test` step carries
  it, and a new always() "Classify tier results" step
  (tools/bazel/classify_tier_results.py, with its own unit tests and a Go
  wrapper) computes server_storage_result/cmd_dolt_result from the BEP and
  decides job.status per-tier. Confirmed with bazel-gate.sh/ci-gate.sh on
  synthetic empty-output inputs that a dead job still fails the gate.
- Corrected the local-actionKey-vs-remote-digest wording in .bazelrc,
  bazel.yml's job comment and CI_REQUIRED_CHECK_TOPOLOGY.md.
- Should-fix: test step 23->25 / job 58 minutes with reasoning; --label
  coverage added to shard_budget_test.py; stale lane comment fixed in
  tests/regression/BUILD.bazel:46; TestBazelDoltIntSoleRunIsInTheUnion's
  docstring corrected (members bake sole-run's line in directly, never via
  --config=sole-run).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): fail-closed classify, per-tier check_testcases, pinned argv (review)

Final review round for PR #7535 (maintainer-city-c3, bee-ghosttrack,
julianknutsen):

- classify_tier_results.py now fails every tier shut (exit 1) on a
  non-PASSED label outside every --tier list, so a newly tagged target
  added without updating the step's --tier args cannot silently read as
  success (must-fix 1). Its --tier/--check label sets are policy-tied to
  the BUILD files' own tag sets by a new
  TestBazelDoltIntTierLabelsMatchTheTags.
- A missing or non-integer --rc (a timed-out or cancelled test step)
  takes the same fail-everything-shut branch instead of crashing argparse
  with no outputs written (bee-ghosttrack's should-fix 2).
- check_testcases.py gained a repeatable --label flag, and bazel.yml's
  shared "Every target and shard ran tests" step is split into check-ss
  and check-cd, each continue-on-error and folded into its own tier via
  classify's new --check NAME=OUTCOME, so a zero-testcase cmd-dolt shard
  no longer reddens the job on push/nightly (must-fix 2).
- classify's run: argv is now pinned by exact equality
  (bazelDoltIntClassifyRun), and every flag except --tier/--check is
  --StoreOnce; a repeated --tier/--check name or an unrecognized flag is
  now a hard parser error (must-fix 3).
- "Upload test logs" now also fires on steps.test.outcome == 'failure',
  not just failure() (must-fix 4).
- shard_budget.py --label now fails closed (::error, exit 1) on a label
  with no executed shard in the BEP at all, instead of silently reporting
  "no sharded test target executed two or more shards" (should-fix 3,
  carried across both review rounds).
- Updated engdocs/TESTING.md, CI_REQUIRED_CHECK_TOPOLOGY.md, .bazelrc and
  scripts/bazel_dolt_int_test.go/ci_workflow_test.go comments for the
  nits: stale "Advisory (continue-on-error: true)" wording, the
  bazelUnionHasFlagGatedMember comment's stale claim about bazel-dolt-int,
  "byte-identical" without specifying remote action digest vs. local
  actionKey, and "is unset" vs. ci-gate.sh's actual "was skipped" branch
  for an empty union output.

Verified: python3 -I on all four tools/bazel/*_test.py (classify 29,
check_testcases 7, shard_budget 19) green; GOTOOLCHAIN=go1.26.7 go test
./scripts/... green; bazel --nohome_rc test //scripts:scripts_test
--config=ci green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): shard_budget --label fail-closed only on a truly unknown label

The previous commit's fail-closed --label check compared against
read_shard_durations, which only records executed (non-cached) shards, so
a target whose every shard was a cache hit this run had zero entries and
was wrongly treated the same as a --label typo. This was not caught by
the new tests (none exercised an all-cached target) and broke this PR's
own dolt-int CI run: bazel-dolt-int's Shard balance step went red on
//internal/storage/dolt:dolt_server_full_test with "no executed shard for
it", even though that target was correctly, fully cache-hit.

Fix: a new read_tested_labels() reads every label with any testResult
event (cached or executed), and --label's fail-closed check now tests
against that set instead of read_shard_durations. A fully-cached target
still legitimately reports "nothing to judge" through evaluate(); only a
label absent from the BEP altogether is now an error. Added the missing
test row (every shard cached) that would have caught this before push.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(bazel): pin bazel-dolt-int's Upload test logs if-condition

A full 42-mutation re-run for PR #7535's second review round found that
nothing pinned this job's own "Upload test logs" if-condition (must-fix 4):
the other lanes' upload-logs steps are each pinned, but bazel-dolt-int's
(unlike dolt-race, a brand-new job) had no equivalent assertion, so a future
accidental revert to the old failure()-only condition would go uncaught.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-13 09:17:54 +00:00
Julian Knutsen
85464f567a
ci(bazel): dolt-race gates the dolt-server and proxied tiers in mode remote (item 5 A1b) (#7514)
* ci(bazel): dolt-race gates the dolt-server and proxied tiers in mode remote (item 5 A1b)

In mode remote, bazel-dolt-race (`bazel test //... --config=dolt-race`, the
union of --config=doltserver and --config=doltserver-proxied) runs both tiers
in place of bazel-doltserver and bazel-proxied, and is no longer advisory:
its job.status is both the bazel-doltserver and the bazel-proxied
workflow_call output (union result first, member's otherwise). In the fork
modes, cache and local, the two member jobs run exactly as before: there one
client does both tiers' work without in-flight deduplication, so a union
would cost the sum of the tiers rather than the max. Exactly one arm runs in
any mode, so gate ids, pr.yml, ci-gate.sh and bazel-gate.sh are unchanged.

- bazel.yml: dolt-race if: mode == 'remote' (every event that reaches it);
  no continue-on-error; result output and always() recorder; test step
  timeout 25 -> 20 (job 55 >= step sum 46 + 5, < 60). Members' if: their old
  rule && mode != 'remote'.
- scripts/bazel_dolt_race_test.go (was bazel_dolt_race_shadow_test.go):
  union-of-members config, sole-run lines in the union, gating shape, step
  and job timeouts, exactly one arm per mode x event with the call outputs
  evaluated as GitHub does, and the union's 62 test actions within
  --config=remote-exec's --jobs=64.
- Gate simulations evaluate the workflow_call output expressions, and a
  gated lane's reporter is the lane or its union lane.
- aquery: all 62 TestRunner actions under --config=dolt-race are
  byte-identical (key, argv, env, outputs) to --config=doltserver (with and
  without sole-run) and --config=doltserver-proxied on origin/main.
- Docs: CI_REQUIRED_CHECK_TOPOLOGY.md "dolt-race Union Lane", TESTING.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): dolt-race test step 23 min so Bazel logs a 1200 s TIMEOUT first

The proxied tier caps each test at 1200 s; a 20-minute step let GitHub
kill a hung shard before Bazel wrote its TIMEOUT test.log and goroutine
dump. Step 23, job 56 (step sum + 5, under the merge queue's 60).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): say the dolt-race job timeout bounds the job, not the run

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-13 04:35:17 +00:00
Julian Knutsen
ec55baa425
fix(http): bd show --current, recompute-blocked and search over http through issueops entries (S6e/S25/S26) (#7528)
* fix(show): --current through issueops.FindCurrentIssue over the Querier role; no swallowed refusal (S6e)

Over http `bd show --current` printed the WRONG issue, exit 0.
resolveCurrentIssueID asked the raw SearchIssues method for the actor's
in_progress and then hooked work; the http backend refuses that method, the
refusal was taken for "nothing found", and the command fell back to the
last-touched issue. The proxied route had its own copy of the lookup, read
inside its unit of work, with the same swallow.

One library entry now: issueops.FindCurrentIssue(ctx, Querier, actor). It
asks the Querier role (queryIssues over http, which every deployed server
publishes) for `status=<s> AND assignee="<actor>"`, limit 1 — exactly the
raw filter, answered in the store's default order, so the same row comes
first on every backend — in_progress, then hooked. A failed read is an
error; "" (two reads that answered and found nothing) is the only miss. The
actor is a quoted, escaped query value; the query language reads
`assignee=none`/`null` as "unassigned", so such an actor (or an empty one)
is not asked about.

Both CLI routes call it with their route's Querier (store.Querier() or the
proxied provider's) through one cmd/bd helper; what stays in the CLI is the
actor and the last-touched fallback (a workspace file). The proxied route
resolves --current before it opens its unit of work, and its duplicate
in-transaction lookup is deleted.

Tests: issueops unit tests (order, failure is an error on either read,
quoting, unaskable actors, each expression evaluates to exactly the raw
filter); cmd/bd fallback tests; served e2e TestE2E_ShowCurrentOverHTTP
(in-progress beats a later-touched issue, hooked when nothing is in
progress, last-touched only when neither). Against the old code the e2e
fails with exactly the reported bug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(recompute-blocked): one library entry, storage.RecomputeBlocked; a no-op on a remote backend (S25)

`bd recompute-blocked` refused over http ("storage backend does not support
is_blocked recompute"), and gc's BdStore.RecomputeBlocked issues it.

is_blocked is server-derived. Every write a remote client makes is committed
by the server's own store, which keeps the flag under
issueops.BlockedStateInvariant's local-write clause (targeted, inside the
write's transaction; a Postgres-family server has no full recompute at all
and runs a no-op readiness strategy for the same reason). A client cannot
leave the flag stale and holds no copy of it. The invariant's merge clause
(a recompute skipped after a pull, bd-6dnrw.37; a migration that over-set
it, beads#7037) happens to the SERVER's database, and its repair is this
command in the server's workspace.

So the decision is in the library, not the CLI: storage.RecomputeBlocked
(internal/storage/blocked_recomputer.go) is the one entry every backend goes
through. A local store (storage.BlockedRecomputer) recomputes its column; a
store implementing storage.ServerMaintainedBlockedState — the http client,
whose BlockedStateMaintainedByServer answers true — recomputes nothing and
reports MaintainedBy "server". No wire operation: a whole-column rewrite any
bearer of a workspace credential could trigger, for state no client can have
caused, is not one to publish. The proxied route keeps its pinned-connection
plumbing around the same versioncontrolops body the stores run.

--json keeps rows_corrected (gc requires the member; wh-bridge-sync reads the
exit code) as 0 and adds maintained_by: "server"; the text says where the
repair runs.

Tests: storage unit tests (local repair runs, server-maintained wins even
over a local repair and runs none, neither refuses); served e2e
TestE2E_RecomputeBlockedOverHTTP (exit 0, JSON shape, text, ready set
unchanged). With the server-maintained branch disabled the e2e fails with
the old refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(search): every bd search route through Reader.List with issueops.SearchListRequest; listIssues `q` behind issues.list.search (S26)

`bd search` called the raw SearchIssues method with its text, which the http
backend refuses ("partial-id search is not available over HTTP"), and its
direct and proxied routes each mapped the flags onto a storage filter by
hand. No served operation could carry search's meaning (title OR id contains
the text, case-insensitively; an id-shaped text also matches exact id, id
prefix and external ref): TitleSearch is title-only and the query language
has no title-or-id predicate.

The library entry is issueops.Reader.List:
- issueops.ListRequest gains Query, SearchIssues' free-text argument as a
  member. Both Reader bodies (workapi/storereader and the uow reader) pass it
  to SearchIssuesWithCounts where they passed "". It narrows and lifts no
  default exclusion; the ready arm refuses it (readyScopeFields).
- issueops.SearchListRequest(query) is search's scope as a request: Query,
  every status (AllFlag), every kind of row (the four Include*), and the
  store's default order (SortBy priority), so --limit keeps the rows a raw
  read kept.
- CLI: ONE runSearch for the direct, proxied and remote routes. One builder
  (searchListRequest) maps the flags onto SearchListRequest; the route only
  picks the reader (store.IssueReader() or the proxied provider's).
  --sort/--reverse reorder the page as before. search_proxied_server.go and
  its hand-built filter are deleted, and search leaves the forbidigo
  filter-writing exemption.
- Server: GET /v0/beads/issues decodes `q` into ListRequest.Query and calls
  the same Reader role, behind the new issues.list.search behavior token
  (spec parameter cites it; additive, no wire_revision bump; apigen and the
  wire-shape digest regenerated).
- Client: the encoder maps Query to `q`; httpReader.List refuses a request
  carrying Query BEFORE dialing, with ErrUnsupported{Capability:
  issues.list.search}, unless the handshake advertises it — never a round
  trip an old server would 400, never the unsearched listing passed off as
  the search. CapListSearch mirrors the server token. Flags listIssues
  publishes nothing for are put on the request so the encoder refuses them
  rather than widening the search.

Tests: Reader contract case RunReaderListQueryMatchesTheTitleOrTheID (also
pins SearchListRequest's scope) on all four legs — dolt, embedded dolt, uow,
served http (label-scoped, so the served leg runs it as written); handler
test that `q` reaches the seam as the search text, not TitleSearch; client
tests for `q` and the pre-dial refusal (zero dials); round-trip and
vocabulary gates; TestSearchRoutesAgree runs the same twelve flag sets on
the direct, proxied and remote routes and requires identical answers
(remote is bd serve over the proxied database, so ids and order too); served
e2e TestE2E_SearchOverHTTP. The remote legs skip with the
SearchIssuesWithCounts refusal until S6c's externaldeps reader passthrough is
underneath (loud refusal, never an empty or wrong answer); with S6c
cherry-picked all three routes agree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: resync BUILD srcs and the embedded storage shard manifest for S6e/S25/S26

gazelle picks up cmd/bd/show_current.go, cmd/bd/search_remote.go, the three
backend/http e2e files and internal/httpclient/list_search_test.go; the
embedded storage shard manifest gains
TestEmbeddedReaderListQueryMatchesTheTitleOrTheID
(scripts/ci/gen_embedded_storage_shard_manifest.py 15 --weights=duration
--write).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style: gofmt list_show_filter_modes.go (trailing blank line)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http/corpus): drop the show --current and recompute-blocked marks S6e and S25 retire

With S26 folded in, `bd show --current` resolves through
issueops.FindCurrentIssue over the Querier role and `bd recompute-blocked`
goes through storage.RecomputeBlocked (a no-op on a remote backend), so
gc-show-current and gc-recompute-blocked lose their pending marks.
mc-search stays pending, relabelled S6c+SRV-1: bd search now asks listIssues
with q behind issues.list.search, which the reference server profile does
not advertise, so the client refuses before dialing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(cmd/bd): split the bd search route agreement into the embedded and proxied lanes

TestSearchRoutesAgree skipped unless BEADS_TEST_EMBEDDED_DOLT=1, then ran
its proxied and remote legs only under BEADS_TEST_PROXIED_SERVER=1, and
its name matched neither lane's discovery (TestEmbedded* in
*_embedded_test.go, TestProxiedServer*/TestServerMode*). No CI lane ran
it, which main's #7468 guard (TestProxiedGatedTestsRunInTheProxiedLane)
now fails on.

Split it:
- TestEmbeddedSearchRoutesAgree (search_routes_embedded_test.go): the
  direct route, embedded lane.
- TestProxiedServerSearchRoutesAgree (search_routes_proxied_test.go): the
  proxied route and the remote route (bd serve over the proxied
  workspace), gated only on BEADS_TEST_PROXIED_SERVER. The remote route
  must still answer the proxied one row for row, ids and order included,
  and refuse the flag listIssues cannot carry.

Neither lane can run the other's workspace, so the shared helper
(search_routes_parity_test.go: the seed, the twelve flag sets, and
checkSearchRoute) holds every route to one expected answer per flag set;
agreeing with it is agreeing with each other. The remote leg's "needs
S6c" skip is gone: S6c is on main, so a refusal now fails.

Both manifests regenerated incrementally (embedded 100-shard block, shard
71; proxied 34-shard block, shard 23). Bazel: bd_embedded_part2_test
(--config=embedded) and bd_proxied_test (--config=doltserver-proxied)
pass and run the new tests; //scripts:go_test_sources_test passes.
Swapping the title-sort expectation fails both routes of the proxied
test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(search): keep an infra type's durable rows, expand --type aliases, fail the S26 e2e on refusal (bd-1ejjv6)

Review fixes for #7528, attempt 1: the three majors and three minors of
the synthesis.

`bd search --type <infra type>` dropped the type's durable rows (a
promoted wisp, an issue retyped after it was created), exit 0. The shared
listing (workapi.BuildListFilter) narrowed an infra --type to its
ephemeral rows unconditionally, so SearchListRequest's IncludeEphemeral
did not bring back what raw SearchIssues used to return. The narrowing
now applies only without IncludeEphemeral, in BuildListFilter and in the
count lockstep (applyCountIncludeInfra), and the http parent-walk
recognizer reads an infra type's Ephemeral back as the include_ephemeral
intent. This also fixes `bd list --type <infra type> --include-ephemeral`
and GET /v0/beads/issues, which shipped the narrowing in v1.3.1. Pinned by
workapi tests and by template, gate, wisp and promoted-message rows in the
Reader conformance Query case (new ReaderFixture.PromoteWisp) on the
dolt, embedded, uow and served backends; the issueops Reader/Counter docs
and the openapi descriptions say the same.

`bd search --type` handed the raw string to the Reader: an alias (feat,
mol, mr, ...) answered nothing and an unknown type an empty result. It is
now expanded with utils.NormalizeIssueType as `bd list` does, and an
unknown type exits 1. The help text and the CHANGELOG say so, and the
CHANGELOG also records the additive comments_omitted field in
`bd search --json` rows.

TestE2E_SearchOverHTTP skipped on the very SearchIssuesWithCounts refusal
it exists to catch; it now fails. The route agreement seeds "kinded"
template, gate, wisp and promoted-message rows and pins the alias, the
unknown-type refusal and the infra rows on the direct, proxied and remote
routes.

Minors: the CHANGELOG states the proxied `bd show --current` miss
fallback; the CommentsOmitted contract names `bd search --json`; the
storage.RecomputeBlocked and `bd recompute-blocked` comments name the
deliberate --proxied-server bypass.

Validation: go vet and gofmt on every changed package; make api-check;
workapi, issueops, httpclient/encode, types and storage unit tests; the
Reader conformance on dolt, embedded, uow and served; the embedded and
proxied route agreements (remote included), the embedded search tests,
TestProxiedServerSearch, TestProxiedServerRecomputeBlocked, the http e2e
search/show/recompute tests; docs flag, freshness and docsync checks; and
a hand-run bd search/list/count against a scratch workspace.

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>
2026-10-13 04:12:54 +00:00
Julian Knutsen
a2d43e6792
fix(mol): molecule reads, auto-close and close --continue over http through issueops entries (S16) (#7513)
* fix(create): let a remote backend mint the --parent child id

`bd create --parent` always called the raw GetNextChildID first, which the
http backend does not serve, so every child create on a remote workspace
refused before writing anything. The Lifecycle role already mints
<parent>.<n> for a create that carries a ParentID and no id of its own, on
every backend and inside the create's own transaction; conformance
RunIssueOperationsCreateUnderAParentMintsTheNextChildID pins it on every leg,
the served one included (and the bd-enterprise postgres leg the MC server
runs). So the create route needs no new capability token: on a registered
Remote backend the client skips the raw reservation and lets the server mint.
The local route keeps its reservation so its Dolt commit staging is
unchanged, and an explicit --id beside --parent is still refused up front.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mol): molecule reads, auto-close and close --continue over issueops roles

Over the http backend three molecule paths failed, and two of them
silently:

- `bd mol current` / `bd mol progress` without an id answered "no molecules"
  because the in_progress listing (a raw SearchIssues shape) and the parent
  walk (raw GetDependencyRecordsForIssues) were refused and the refusal was
  swallowed; with an id they refused on raw GetMoleculeProgress.
- The molecule auto-close after `bd close` never ran: findParentMolecules
  swallowed the same refused edge read into "not part of a molecule".
- `bd close --continue` claimed the next step in a raw RunInTransaction.

The direct route now reads molecules through roleMolStore, which answers
through roles every backend serves: EdgeReader (batched at the wire's 100
anchors) for the parent walk, BatchGetter for the roots (Get per id where a
server does not publish issues.batchGet), Relations for the step rows (full
rows; the raw dependents read over http is getIssue's shallow projection,
which zeroed step assignees) and the progress counts, and Reader.List for the
in_progress/hooked listings. The auto-close closes the root through
Lifecycle.Close, and the --continue claim is one Lifecycle.Update guarded by
ExpectedStatus=open.

No refusal is swallowed any more: findParentMolecules, the molecule finders
and the hooked scan return their errors; `mol current/progress` report them;
the auto-close stays best effort but warns on stderr; AdvanceToNextStep only
moves on to the next ready step when the claim LOST a race (status mismatch,
not claimable, already claimed) and returns anything else. The one heuristic
still skipped is the id-pattern heal in loadDescendants, and only for an
ErrUnsupported backend that cannot express an id-prefix search; other
failures now surface. `mol current`/`mol progress` leave the
types.IssueFilter forbidigo hole, since they no longer build a filter.

gc does not depend on bd's molecule auto-close: it runs its own
(cmd/gc/molecule_autoclose.go, from the bd on_close hook and the
controller's bead-close events). Its worker prompts do run `bd mol current`.

Served e2e (TestE2E_MoleculesOverHTTP): create --parent mints <root>.1/.2,
mol current <id> is non-empty with the full in-progress step, mol progress
counts, close --continue auto-advances, closing the last step auto-closes
the root. `mol current` without an id now refuses out loud on this stack
(asserted: never an empty list); its non-empty assertion is skipped until
S6c (externaldeps reader passthrough) is underneath.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(mol): list molecule candidates with the four wire knobs, drop the S6c skip

On top of S6c the in_progress listing behind 'bd mol current' (no id)
reaches the v0 wire encoder, which refuses ListRequest.IncludeAllTypes.
Ask for templates, gates, infra and ephemeral rows explicitly, which the
wire publishes, and run the 'mol current without an id' served case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(issueops): one library entry each for molecule auto-close, advance and reads

The molecule rules lived only in cmd/bd, in copies that disagreed: two
auto-close implementations that closed the root through different
library entries outside the step close's transaction, a `close
--continue` claim that set no assignee and could take a step another
agent held on the direct and http routes, and three progress counts.
Every molecule rule now has one implementation in the public issueops
package, composed over three roles every backend serves (BatchGetter,
Relations, EdgeReader): MoleculeRoots, LoadMolecule, AnalyzeMolecule,
ViewMolecule, ReadMoleculeProgress, ActiveMoleculeIDs,
CompletedMolecule. Membership is the parent-child edge.

Auto-close: CloseRequest.AutoCloseMolecule and
CloseBatchRequest.AutoCloseMolecule (opt-in, so gc's own auto-close is
not doubled) close the molecule root a close completed IN THE SAME
TRANSACTION, unforced and guarded on the root revision read there:
storageissueops.CloseCompletedMoleculeInTx on the store backends (the
role bodies bound to the caller's tx, TxMoleculeReader) and
uow.CloseCompletedMoleculeInUOW on the unit of work. It replays on an
idempotent re-close, reports the root on CloseResult/CloseOutcome
.AutoClosedMolecule, and a root its own close policy refuses stays open
and is reported (MoleculeAutoCloseRefusal) without failing the step.

Advance: a new MoleculeStepper role (storage.DoltStorage accessor,
uow.MoleculeStepperSource) whose one implementation,
issueops.NewMoleculeStepper, claims the next ready step through the
Claimer (Lifecycle.Update's Claim for a wisp step): assignee set, a step
another actor holds skipped, never taken.

HTTP: closeIssue/batchCloseIssues carry auto_close_molecule behind the
issues.close.autoCloseMolecule behavior token, and POST
/v0/beads/issues/{id}:advanceMolecule (issues.advanceMolecule) serves
the stepper. Handlers only decode, call the role and encode. The client
sends the member and dials the operation only where advertised; against
an older server it DEGRADES rather than refuses — it runs the same
library rule over its own roles (issueops.CloseCompletedMolecule after
the close, NewMoleculeStepper for the advance), so the outcome is the
same in more round trips. The capability fallbacks that lived in
cmd/bd move into the client: BatchGetter answers one getIssue per id
without issues.batchGet, and EdgeReader splits past the operation's 100
anchors.

Conformance: RunMolecule* on dolt, embedded, uow and http (the http leg
twice: served, and against a server with the tokens struck out).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(cmd/bd): molecule commands and create --parent through the library entries

`bd close`, `bd close --continue`, `bd mol current`, `bd mol progress`,
`bd ready --mol` and `bd create --parent` now call the one library entry
for each rule on every route (direct, proxied server, remote):

- close (batch, --if-revision, proxied) sets CloseRequest/
  CloseBatchRequest.AutoCloseMolecule and only reports what the library
  closed in the step close's transaction. autoCloseCompletedMolecule,
  autoCloseProxiedCompletedMolecule and closeCompletedMoleculeRoot are
  gone, and so is the separate post-close write.
- --continue is the route's MoleculeStepper role: a real claim (the
  assignee is set) that skips a step another actor holds. Before, the
  direct and http routes flipped the status only and could take it.
  AdvanceToNextStep, ClaimStepIfOpen and its two implementations are
  gone.
- mol current / mol progress / ready --mol read through
  issueops.ViewMolecule, ReadMoleculeProgress, ActiveMoleculeIDs and
  LoadMolecule/AnalyzeMolecule over the route's roles. Over http this
  fixes the missing step assignee on `ready --mol` (corpus mark
  mc-ready-mol). The proxied route's SearchIssues fallback, the role
  store, the third progress count and the cmd/bd copy of the readiness
  analysis are deleted; only presentation stays here.
- create --parent asks the create role to mint the child id on every
  route (the local CLI reservation is gone) and to inherit the parent's
  labels (InheritLabelsFromParent) inside the create. The dry-run
  preview still shows the labels, and a failed label read there is
  reported, not swallowed.

TestProxiedServerMoleculeLifecycleAgreesOnEveryRoute runs one molecule
lifecycle through the real binary on the direct, proxied and remote
(`bd connect` to `bd serve`) routes and requires the same rows and the
same JSON on all three. The served e2e now also pins the held-step skip,
the claimed step's assignee and the full rows of `ready --mol`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(httpclient): refuse molecule auto-close and advance before dialing an older server

The client used to DEGRADE against a server without
issues.close.autoCloseMolecule / issues.advanceMolecule: it closed the step
without the member and ran a second, client-side copy of the auto-close
(issueops.CloseCompletedMolecule) in its own transactions, and composed the
stepper over its own roles. That kept two executions of each rule alive.
Now the rule runs in ONE place, the server's library: a close or batch close
that sets AutoCloseMolecule, and an Advance, refuse before anything is dialed
with the typed capability error (storage.ErrUnsupported, Capability naming the
token). The composed single-item batch leg now carries the member too.

- issueops.CloseCompletedMolecule (the role-composed form) is gone.
  MoleculeRootClose is the one root close request (unforced, the auto-close
  reason, the session, guarded on the root revision read), and both
  in-transaction bodies (storage issueops CloseCompletedMoleculeInTx, uow
  CloseCompletedMoleculeInUOW) build from it.
- MoleculeView.Ready is `bd ready --mol`'s list (every analysis-ready node,
  hydrated), so ready --mol and mol current derive from ViewMolecule alone.

Tests: unit pre-dial refusal and member pins (httpclient molecule_test.go),
TestServedMoleculeRefusesAgainstAnOlderServer (step stays open, nothing
claimed) replacing the degraded contract arm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cmd/bd): ask for the molecule auto-close only where the route serves it

The refuse-before-dialing client made every `bd close` over http fail
against a server that does not advertise issues.close.autoCloseMolecule
(an older bd serve, or the MC server shape, whose orchestrator owns the
molecule lifecycle): the CLI always set AutoCloseMolecule.
storage.ServesMoleculeAutoClose answers, through every decorator, whether a
store's closes may carry the flag (MoleculeAutoCloseProber, implemented by
httpclient.Store from its handshake; every local backend serves it). The
direct batch close and the --if-revision close set the flag from it; the
proxied route always serves it. Against a silent server the close goes out
without the member and the server's side owns the auto-close.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http): scope the advertised-policy check to reads before the close

The close policy check is the client-side policy's last chance: it runs
before the close request, so only the reads up to that request count. A
read after the close (the old-server molecule notice reads the closed
step's edges) is not the external-dependency policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http/corpus): drop the six marks S16 and S19 retire

With the molecule library entries underneath, mol current (with and
without an id, json and text), mol progress and ready --mol read through
issueops.LoadMolecule over the roles, and create --parent lets the server
mint the child id. Those six shapes pass on the reference profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cmd/bd): never silent against a server without the molecule tokens

Against a server that advertises neither issues.close.autoCloseMolecule
nor issues.advanceMolecule (an older bd serve, or one whose orchestrator
owns the molecule lifecycle):

- `bd close --continue` closed the step and only then found the advance
  refused, leaving the step closed and the next step unclaimed. It now
  asks storage.ServesMoleculeAdvance (a MoleculeAdvanceProber the http
  store answers from its handshake; local backends always serve it)
  BEFORE the close and refuses up front, saying nothing was closed.
- `bd close` went out without auto_close_molecule and said nothing. When
  the closed step belongs to a molecule (issueops.MoleculeRoot), a notice
  on stderr now names the molecule and the missing token: its auto-close
  is the server's to run. The batch and --if-revision closes both say it.

The served e2e masks both tokens out of the handshake and checks the
up-front refusal (the step stays open) and the notice; the httpclient
unit test pins ServesMoleculeAdvance to the handshake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(cmd/bd): mol show through issueops.LoadMolecule on every route

`bd mol show` still loaded the molecule through cmd/bd's
loadTemplateSubgraph (raw GetIssue, GetDependentsWithMetadata and
GetDependencyRecords, plus an id-pattern child probe), while mol current,
mol progress and ready --mol read through the library. It now loads
through issueops.LoadMolecule over the route's molecule roles (the direct
store's, or the proxied provider's), so membership is the parent-child
edge everywhere and the http route reads through roles the server serves.
The served e2e checks mol show's root and step count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: the molecule auto-close fails the step's close on a non-policy error; stale comments

CloseRequest.AutoCloseMolecule and CloseCompletedMoleculeInTx now say what
changed when the auto-close moved into the close's transaction: a root
close the close policy refuses still leaves the root open and is reported,
but any other failure (a storage error, a lost race on the root's revision)
fails the step's close with it, where the CLI used to close the root
afterwards and only warn.

Stale: the advanceMolecule vocabulary entry said the client composes the
stepper over its own roles when unserved (it refuses before dialing), and
the graph-create collision probe called itself best-effort by transport
(the http GetIssue miss is storage.ErrNotFound like every other store's).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): the molecule tokens and the S16/S19 behaviours

Entries for issues.close.autoCloseMolecule and issues.advanceMolecule, the
issueops molecule entries, the auto-close inside the step's close (and a
non-policy failure of it failing the close), the real claim behind
close --continue, the molecule reads on every route, the notice and the
up-front --continue refusal against a server without the tokens, and
create --parent / mol reads over http.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(httpclient): regenerate unsupported_gen.go for MoleculeStepper

The PR adds MoleculeStepper() to storage.DoltStorage (200 -> 201
methods). httpclient implements it by hand, but the generated shell's
trailer still counted 200, so
//internal/storage/unsupportedgen:unsupportedgen_test
(TestGeneratedShellIsFresh) failed in Bazel / test and
Bazel / integration, turning CI Gate / Required red.

Regenerated with `go generate ./internal/httpclient`; the only change
is the trailer count (143 of 201 methods generated; 58 left).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(molecule): auto-close refusals, write skew, close --json, docs

Review fixes for #7513, numbered as in each iteration's review
synthesis.

Iteration 1:

F1: a close guard's refusal of the root (TemplateReadOnlyError,
PinnedError, CloseNotAssigneeError) is an auto-close refusal, like the
close policy's: the root stays open and is reported, and the step's
close stands. Pinned by the new conformance case
RunMoleculeGuardedRootKeepsTheStepClose on dolt, embedded, uow and the
served http client.

F2: two closes that finish a molecule's last two steps in concurrent
transactions each read the other's step as open, so neither closed the
root and both committed. Every auto-close now rewrites the root's
coordination cell before it decides the root (local_metadata
molecule-coordination/v1/<shard>, the dependency coordination idiom and
sharding with a FreshRowLock value), in both twins
(CloseCompletedMoleculesInTx and CloseCompletedMoleculesInUOW). Two
deciders of one root now conflict at commit (1213), and the retry reads
the winner's close and closes the root. This is the synthesis's option
(c), applied through a coordination cell instead of the root row; it
needs no post-commit second transaction and no engine lock. The
deterministic two-transaction regression fails without the touch and
passes with it on dolt and uow; the concurrent-close tests end with the
root closed in every round, reported by exactly one close.

F3: the auto-close checks the root's eligibility before walking any
step, MoleculeStepsClosed stops at the first open step, and a batch
decides each root once and reports it on the first item under it.

F4: ErrVersionMismatch on the root is not a refusal; it fails the
step's close with it. The classifier unit test pins this. A conformance
case cannot stage that race deterministically through the public roles.

F5: storage.ServesMoleculeAdvance answers (bool, error), and bd close
--continue refuses before closing anything when the handshake cannot be
read.

F6: the CHANGELOG and the stepper and batch-closer doc comments say
what the code does.

F7: the unserved-auto-close notice fires only when the close left an
auto-closing molecule with every step closed and its root open
(issueops.CompletedMolecule): again on a re-close, once per root in a
batch, never for a step under an ordinary epic or an unfinished
molecule. Proxied mol show, mol current and mol progress again report a
read unit of work that cannot be opened as itself, not as a molecule
that was not found.

F8: the write-ledger comment says the close is refused before dialing.
The dead FirstClosed/LastClosed guards in mol progress pre-exist on main
and are left as they are.

Iteration 2:

F1: on the proxied route, bd ready --mol reported a read unit
of work it could not open twice: once as itself, then as "molecule
'<id>' not found", which under --json is a second error document on
stdout. It now returns moleculeNotResolved, as mol show, mol current and
mol progress do. TestProxiedReadyMolReportsAnUnopenableReadOnce drives
runMoleculeReady with a provider whose NewUOW fails and wants one Error:
line, or one JSON document; both subtests fail with the old return.

F2: the coordination cell serializes every concurrent close of a step
under an open auto-closing root, not only the closes that finish the
molecule. That is the price of deciding the root in the step's
transaction, so it is documented (TouchMoleculeCoordinationInTx, the
UOW twin, CloseRequest.AutoCloseMolecule, the CHANGELOG) and pinned on
dolt and uow: two sibling closes with a third step still open conflict
(both commit when the touch is removed, on either twin), and a six-step
fan-out closes every step through the store's retry, with the root
closed and reported by exactly one close. The synthesis's alternative,
a post-commit recheck by any close that read a step open, is not taken:
it is a second, best-effort transaction after the step's commit, the
shape this PR exists to remove.

F3: MoleculeRootClose's doc no longer promises that a step reopened
between the completion read and the root close fails the step's close.
The guard is the root's RowVersion, which a step reopen never writes;
the doc now says what the guard covers and that this race goes
undetected (it is inherited from the CLI's old post-commit auto-close).

F4: the user docs describe the auto-close. docs/workflows/molecules.md
replaces "Closing the last child does not close the molecule root"
with which roots close and which stay open, the refusal warning, the
unserved-server note and the --json members, and documents the claiming
--continue and parent-child step membership;
docs/reference/json-schema.md gains a bd close --json section. These
are main-only behaviors on pages pinned to v1.2.2 (docs/cli-docs.pin):
a maintainer call against §1 of
engdocs/decisions/2026-07-17-docs-release-pin.md, as in #6508, #5855,
#5997 and #5092. The auto-close itself shipped in v1.2.2
(cmd/bd/close.go autoCloseCompletedMolecule), so the old sentence was
already wrong at the pin. docs/cli-reference/ is generated from the
pinned release and is not hand-edited; the bd close and bd mol show
help texts carry the same facts and reach it at the next pin bump.

F5: bd close --json reports the auto-close. The entry of a close that
completed a molecule gains auto_closed_molecule (the root it closed) or
molecule_auto_close_refusal (why the root stayed open), the HTTP API's
names, on the direct, proxied and --if-revision routes. The members sit
beside the issue's own rather than wrapping the output in an object the
way --suggest-next does: an object would change the output's shape
exactly when a close completes a molecule and break every consumer that
reads an array, while members leave each entry decoding as the closed
issue, compose with `closed` under the flag objects, and leave a plain
close's bytes unchanged. Pinned on the embedded and proxied tiers
(TestEmbeddedCloseJSONReportsMoleculeAutoClose, TestProxiedServerClose2B
json_reports_*, and both --if-revision replay tests), all red without
the change.

F6: cmd/bd's BeadsTemplateLabel is issueops.MoleculeTemplateLabel, so
the template commands and molecule membership cannot drift apart.

F7: the UOW twin's revision probe says that it writes nothing,
and the BatchCloseRequest.auto_close_molecule spec description has its
verb back (apigen regenerated, no drift).

Iteration 3:

F1: on the unit-of-work route (bd serve, the proxied CLI), a refused
root's molecule_auto_close_refusal and warning carried the use case's
and repository's wrapping ("close <id>: db:
IssueSQLRepository.CloseChecked <id>: ...") around the refusal, where
the tx twin and the docs give the refusal alone. Both twins now report
it through RefusedMoleculeAutoClose, which answers the refusing guard's
or policy's own sentence. RunMoleculeRefusedRootKeepsTheStepClose,
RunMoleculeGuardedRootKeepsTheStepClose and the embedded and proxied
close --json tests want that exact sentence; the uow conformance leg
and the proxied test fail without the unwrap.

F2: the docs no longer promise ErrVersionMismatch for a write to the
root that races its auto-close. The root's read and its revision check
share one transaction snapshot, so that write conflicts with the root
close at commit and the retry decides the root again; the close fails
only if it still conflicts when its retry budget runs out
(MoleculeRootClose, IsMoleculeAutoCloseRefusal,
CloseRequest.AutoCloseMolecule, the tx twin's comment, the CHANGELOG
and the OpenAPI description, apigen regenerated).

F3: TestEmbeddedCloseJSONReportsMoleculeAutoClose moves above
TestEmbeddedCloseConcurrent's doc comment, which documents its own test
again.

F4: bd mol progress counting direct steps while the auto-close counts
every descendant predates this PR; it is left for a follow-up.

F5: cmd/bd's molReader drops GetMoleculeProgress, which nothing called
once mol progress read through issueops.ReadMoleculeProgress.

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: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 19:50:34 +00:00
Stephanie Jarmak
559b5de1e2
fix(memory): preserve presence for empty values (#5964)
* fix(memory): preserve presence for empty values (#5963)

Recall and Forget now distinguish an existing empty memory row from an absent key across direct, embedded, and UOW storage paths.

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of sjarmak

* fix(memory): make bd recall report presence from row existence

printRecallResult (and the recallCmd caller) derived "found" from
value != "", so a memory stored as the empty string still printed
"No memory with key" and exited 1 even though the role's
RecallResult.Found was true and bd forget would delete the row.
Thread result.Found through instead: an empty-valued memory now
recalls cleanly (exit 0, empty value; JSON reports found: true), and
only an absent key is a miss.

Addresses maintainer review on #5964 (fixes #5963).

* test(httpapi): pin GET /v0/beads/memories/{key} as 200 for an empty value

TestGetMemoryAnswersAMissWithA404 pinned a RecallResult{Value: ""}
case (Found defaulting to its zero value, false) as a 404, a shape no
backend can produce since Found now comes from row existence rather
than value truthiness. Move that case into its own
TestGetMemoryAnswersAnEmptyValueWith200, which recalls Found: true
and asserts a 200 with an empty value. Also updates the handler's
doc comment, which still described the retired 404-on-empty
behavior.

Addresses maintainer review on #5964 (fixes #5963).

* docs(httpapi): fix openapi spec to say memory presence is row existence

The published spec still said an empty-valued memory is a 404 on
GET /v0/beads/memories/{key} and DELETE /v0/beads/memories/{key},
contradicting the role's RecallResult.Found (row existence). Rewrite
the operation descriptions, both 404 response bodies, Memory.value
and RememberedMemory.replaced to say presence is row existence
everywhere: an empty-string memory is a 200 (or is removed by
forget) with an empty value, matching what GET /v0/beads/memories
already enumerated. Regenerate types.gen.go via `make api-gen` so
the generated doc comments match.

Addresses maintainer review on #5964 (fixes #5963).

* docs(changelog): note the empty-valued memory presence fix

Add an Unreleased/Fixed entry for #5964 (fixes #5963): bd recall,
bd forget and GET /v0/beads/memories/{key} now treat an empty-valued
memory as present everywhere, instead of only on GET
/v0/beads/memories.

* fix(memory): make bd remember <bare-key> recall an empty-valued memory

rememberBareKeyPath decided presence from existing != "", so a bare slug
naming a memory stored as the empty string was refused as "no memory
named" instead of recalled. It now takes the role's Found, matching
printRecallResult, bd forget and the HTTP door.

* test(memory): pin empty-value presence through the real commands

TestPrintRecallResult and TestRememberBareKeyPath call the helpers directly,
so a RunE that went back to deciding presence from value != "" would leave
them green. TestEmbeddedMemory/empty_valued_memory_is_present empties a
memory row beneath bd and runs bd recall, bd remember <bare-key> and
bd forget against it, checking first that bd no longer sees the placeholder.

Two comments in problem.go and one in memories_test.go still said an
empty-valued memory is a 404. The CHANGELOG line now says a key with no row
is a miss, since a forgotten key was once stored.

* build(bazel): add the memoryops dep to the bd_test go_test (make bazel-sync)

memory_embedded_test.go now imports internal/storage/memoryops directly
(storagememoryops.StorageKey, to overwrite a memory row out of band), so
gazelle emits //internal/storage/memoryops on bd_test. cmd/bd/BUILD.bazel
landed on main after this PR branched, so the PR could not carry the dep;
without it, bazel.yml's "BUILD files in sync" step fails in the required
bazel-test lane. Generated by `make bazel-sync`.

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>

* test(memory): maintainer fixup — adoption review nits

Maintainer fixup for the adopt-pr iteration-1 review of #5964. Both review
lanes approved and the quality scorecard approved at 981; these are its four
non-gating nits, each confined to lines this PR already adds.

- internal/httpapi: TestForgetMemoryOfAnEmptyValuedKeyIs200 pins the DELETE
  door's empty-value 200 the way TestGetMemoryAnswersAnEmptyValueWith200
  pins the read. Guarding the handler's 404 on Value == "" reddens exactly
  this test and nothing else.
- CHANGELOG: the bullet names DELETE /v0/beads/memories/{key} beside GET,
  whose answer changed the same way (404 with the row left standing -> 200
  with the row removed).
- uow: the two new GetAllConfig presence probes in Recall and Forget say why
  they read the whole table, by pointing at Remember's rationale.
- conformance: RunMemoriesEmptyRowIsPresentUntilForgotten runs its
  no-history-on-retry leg last and SKIPs it with a reason when a fixture has
  no CountHistory, as the MemoriesFixture doc promises, instead of passing
  quietly. All three in-tree fixtures wire the hook, so every in-tree run
  is unchanged (19/19 on dolt, embeddeddolt and uow, 0 SKIP).

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>

* fix(httpclient): report an empty-valued memory as present (base-refresh repair)

Maintainer repair from refreshing #5964 onto main b630f96f5b. Main's #7247
added the HTTP client store (internal/httpclient) after this PR branched,
and its memory role and served conformance leg still treated a memory
stored as the empty string as absent:

- Recall set Found from Value != "".
- The RecallMemory doc said an empty-valued row was a 404.
- TestServedMemoriesRecallConflatesStoredEmptyWithAbsent called
  conformance.RunMemoriesRecallConflatesStoredEmptyWithAbsent, which this
  PR deletes.

The rebase applied cleanly, but the merged tree did not compile.

- internal/httpclient/memories.go: Recall reports Found true on any 200.
  With this PR the wire returns a 404 only for a key with no row; an
  empty-valued row comes back as a 200 with an empty value. Setting Found
  from Value would hide that row again on the HTTP backend. Forget already
  reported Found true on a 200.
- internal/httpclient/wire/writes.go: the RecallMemory doc now says the
  same.
- internal/httpclient/served_memories_deps_test.go: the hm10 served case
  now runs RunMemoriesEmptyRowIsPresentUntilForgotten, the contract case
  this PR adds in place of the one it deletes.

With BEADS_TEST_EMBEDDED_DOLT=1 the served memory tests pass with 0 SKIP.
Reverting the Recall line makes hm10 fail with
`Recall("hm10-stored-empty") = value "" found false, want value "" found
true`.

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: sjarmak <t@t.co>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 19:28:54 +00:00
Julian Knutsen
b630f96f5b
fix(httpclient): unlimited ready/query/list reads over http, client-capped (S15) (#7497)
* fix(httpclient): unlimited ready/query/list reads over http, client-capped

An unlimited read never puts limit=0 on the wire, which a non-loopback
bd serve refuses ("unlimited reads are loopback-only"):

- bd ready --limit 0 (the WorkFilter bridge) sent no limit at all, so the
  server's 100-row ready default silently capped every routed-pool queue.
- Reader.Ready and Querier.Query with Limit 0 sent limit=0 and got a 400
  from a non-loopback server.

listReadyWork and queryIssues publish no cursor, so an unlimited read is
one request bounded at the client cap plus one (one server read, so one
snapshot). listIssues keeps its cursor walk, now bounded by the same cap
(per-page reads; the snapshot semantics are documented in
unlimited_read.go). Past BEADS_HTTP_UNLIMITED_READ_CAP (default 10000) the
read is refused with *UnlimitedReadCapError, never truncated; a server that
reports has_more below the requested bound is refused the same way. A
dispatch tripwire refuses limit=0 on the three listing operations, so a new
path that forgets fails loudly instead of only off loopback.

Served tests run against a server in --allow-non-loopback mode with 150
rows: ready (role, bridge, bridge+total), query and list at limit 0 return
every row with a bounded limit on every request, and the cap refuses with
the typed error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http/corpus): drop the three marks S15 retires

With unlimited reads served (one request bounded at the cap plus one for
ready and query), gc-ready-unlimited, gc-ready-pool-demand-unlimited and
gc-query-wisps-unlimited return every row on the reference profile instead
of the server's default page or the loopback-only refusal. mc-list-id stays
pending on S15b (--id).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): unlimited reads over http and BEADS_HTTP_UNLIMITED_READ_CAP

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(httpclient): uncap the list walk and bound the ready-count fallback

Review fixes for #7497 (review loop iterations 1 and 2).

F1 (major): the client cap no longer applies to an unlimited list.
listIssues publishes a keyset cursor, so no response is larger than a
page; the walk is back to base, bounded only by --max-rows /
BEADS_MAX_ROWS as on every local backend. The cap stays on the
cursorless reads (ready, query), whose whole answer is one response the
server buffers. The CHANGELOG, unlimited_read.go and the env doc say so.

F2 (major): externaldeps.CountReadyWork's no-counter fallback, which an
http store reaches whenever its server does not apply the
external-dependency policy (every released server), asked for the whole
ready set to report one number: over http, up to the cap's full rows,
and a refusal past it that text `bd ready` swallows into a missing
footer. It now asks for a one-row Lite page; the bridge pairs it with
the server's countReadyWork, and refetchedReadyTotal still sizes the
externally blocked case.

F3: TestCheckUnlimitedPage pins a full cap+1 page that also reports
has_more as the cap's refusal, not a truncation, and the env test
accepts the inclusive 1000000 bound. Served: the cap test adds the
unlimitedRows-2 case (the server's 149 rows with has_more), the list is
pinned as uncapped with MaxRows its only bound, and the bridge's
MaxRows-vs-cap precedence is pinned with the limit on the wire.

F5: readyBridgePage sends MaxRows+1 rather than cap+1 when MaxRows is
the tighter bound (tightenUnlimitedPage). The MaxRows check still runs
first, so an answer past it keeps its *ErrTooManyRows attribution.

F6: the decorator and test comments describe the cap+1 bound; the
refusal reads "narrow the query or raise BEADS_HTTP_UNLIMITED_READ_CAP";
the Ready and Query Limit contracts name the http exception; mc-list-id's
pending reason drops the S15 --limit 0 clause and keeps the --id refusal.

F7: unlimited_read.go states that the tripwire guards Store.dispatch
only, so a direct wire.Client caller (readyClaimPage) must send a
positive limit itself.

Not taken: F4 (an unlimited walk that meets has_more with no cursor ends
as a success rather than a ServerTruncated refusal). After F1 the walk
is base code again, the shape needs a skewed or older peer, and the
change would land in fetchIssuePages (cyclomatic 21, cognitive 34),
turning an untouched base function into a changed one in the major
complexity band. Left as a follow-up.

Iteration 2, N1: F5 reached only the raw bridge. `bd ready` reads
through the external-dependency decorator, and against a server that
leaves that policy to the client, one externally blocked issue made
readyExclusion take MaxRows off the unlimited inner query. The bridge
then asked for cap+1 rows: past the cap it refused with the read cap's
error (exit 1, "raise BEADS_HTTP_UNLIMITED_READ_CAP") rather than
--max-rows' (exit 2), and under it fetched the whole ready set to refuse
on the rows kept. An unlimited inner query now keeps MaxRows plus one
row per blocked issue: past that many rows more than MaxRows are kept
whatever the drop takes, so the bridge sizes the request by it under the
cap, and innerCapError hands the refusal back as the caller's own cap.
The suggested inner Limit of MaxRows+blocked+1 was not taken: a bounded
request skips the cap and its server-truncation check, so with any
external blocker a --max-rows above the cap would fetch past it.
TestServedReadyBridgeMaxRowsSizesTheRequest pins the request and the
refusal through externaldeps.New with one blocker, the cap still in
force past MaxRows plus the blocked rows;
TestServedReadyMaxRowsCountsTheRowsKept adds an unlimited case whose
refusal names the caller's cap on all three decorator reads.

N4: QueryRequest.Limit's "NOTHING BACKSTOPS IT" names the http
exception in its lead, as ReadyRequest.Limit does.

Not taken in iteration 2, as non-gating follow-ups: N2
(refetchedReadyTotal's Limit = total+blocked read sits outside the cap;
pre-existing), N3 (the list walk's has_more-without-cursor end, the
deferred F4), N5 (prefixing the malformed-cap error with its operation;
it already names the variable and its value).

Validation: the served tier (BEADS_TEST_EMBEDDED_DOLT=1
BEADS_HTTP_TEST_REQUIRED=1) for internal/httpclient and the command
corpus; go test for externaldeps, issueops and workapi. Each new test
was mutation-checked red: the zero-limit count, the tightening removed,
the MaxRows check removed, the PR's list cap restored, and a cap+1
has_more page read as a truncation. Iteration 2: the served
internal/httpclient ready, unlimited-read and external-policy tests (34
PASS, 0 SKIP) and go test for externaldeps, issueops and workapi; the
new pins go red with MaxRows taken off again (the pre-fix code), with no
re-attribution, with no growth by the blocked rows, with the suggested
inner Limit, and with Found left unadjusted.

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 <noreply@anthropic.com>
2026-10-12 09:02:22 +00:00
Rongjun GENG
bf7c19ccc4
fix(wisp): bd mol wisp gc --age 0s no longer misses a just-created wisp (#7246)
* fix(wisp): --age 0s treats every wisp as abandoned, even one Dolt rounded into the future (#7236)

findAbandonedWisps compared now.Sub(issue.UpdatedAt) > ageThreshold
unconditionally. Dolt's DATETIME(0) column rounds fractional seconds
half-up on write rather than truncating: a wisp created in the second
half of a wall-clock second can read back with updated_at up to 0.5s
in the future, making the comparison negative and failing the check
for a wisp that is, by definition, not yet one second old.

--age 0s's own documented contract ("hasn't been updated in --age
duration") means every wisp qualifies trivially -- nothing has been
updated in the last zero seconds. Extracted the comparison into
wispIsAbandoned(now, updatedAt, ageThreshold), which short-circuits
true whenever ageThreshold <= 0, bypassing the clock comparison (and
its rounding exposure) entirely for that case.

New TestWispIsAbandoned is a pure, deterministic unit test -- the
original TestCLI_WispGCExcludeType needs a live Dolt test container
and the reporter's own 60 real runs against one could not reliably
reproduce the race, so a timing-dependent regression test would be
exactly as unreliable. Confirmed red against the old inline
comparison (the two age-0s cases failed) before extracting the fix,
green after. go build/vet/gofmt clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185qSpS74AbkmHoKRPf2yDD

* chore: empty commit to retrigger mergeability recompute

GitHub's mergeStateStatus has shown DIRTY/CONFLICTING since 2026-10-06,
but a real `git merge --no-commit --no-ff` against current upstream/main
auto-merges cleanly on all 3 touched files -- no actual conflict. This
commit forces GitHub to recompute.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(wisp): pin the gc call site and drop the 1ms age from the embedded test

Folds the tests from #7472 into the #7236 fix.

TestWispIsAbandoned pins the predicate. It cannot see whether
findAbandonedWisps still decides age through it. TestFindAbandonedWisps
AgesAtStoragePrecision drives findAbandonedWisps through a new wispGCNow
clock seam with a wisp stored rounded into the future (written 12:00:00.7,
stored 12:00:01):
- --age 0s at 12:00:00.9 reclaims it. This fails against the old inline
  now.Sub(updated_at) > threshold.
- --age 1h leaves it alone at that instant and reclaims it two hours later.
- --age 1s at 12:00:01.5 leaves it alone: a positive threshold does not
  credit idle time that has not passed.

TestWispGCProtectsActiveWisps ran gc with --age 1ms and relied on creation
order to keep the most recently touched reclaimable wisp out of the
rounding window. --age 0s states the intent ("every wisp is old enough")
and is immune to the half-second rounding, so the ordering caveat goes.

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: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <bd-7x9c69@gascity.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
2026-10-12 05:37:54 +00:00
gascityinc-randy[bot]
7477ec1352
fix(deps): bump grpc to 1.83.2 and thrift to 0.24.0 (#7495)
Resolve Dependabot alerts #146 (apache/thrift < 0.24.0) and #151
(google.golang.org/grpc <= 1.83.1) on the root module with the minimal
bump: no other module moves, and both need only go 1.25, so the Nix
flake stays on its current nixpkgs. Recompute default.nix vendorHash
for the new go.sum.

This lands the security fix independently of the Dolt 2.4.1 upgrade
in #7441, which carries the same two bumps.

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 09:58:58 +00:00
Julian Knutsen
225ed7f7bb
test(backend/http/corpus): served MC command corpus against the reference server profile (S23) (#7483)
* test(backend/http/corpus): served command corpus against the reference server profile

Add the S23 suite: every distinct bd command shape gc and its packs and
formulas issue against a work store (124 shapes in testdata/corpus.yaml),
run by the real bd binary against an in-process bd serve and compared
with the same command on an embedded workspace.

The server is bound in non-loopback mode with bearer auth. A reference
proxy masks it to a deployed bd 1.3.0 server's wire surface
(testdata/reference_server.json): exactly that server's capabilities and
handshake members (no wire_revision), a 404 for operations it does not
publish, and a 400 unknown_parameter for query parameters and request
members it does not declare. Every bd run sets BEADS_ACTOR and
CLAUDE_SESSION_ID.

A shape passes when the served run exits like the embedded run, carries
no refusal, and matches its output (json/ids/count/text) and its verify
reads. Known gaps are marked `pending` with the slice that fixes them.
A pending shape still runs, and it fails once it passes, so removing the
mark is how a slice proves itself. Permanent refusals are listed in
testdata/allowlist.yaml with reasons.

A limited listing that cuts through a tie set (same priority, created_at in
one second) lands on different rows on two workspaces seeded seconds apart;
such a shape names its unlimited form in `prefix_of`, and each side's
limited rows must be an ordered prefix of that side's own unlimited listing.

//backend/http/corpus:corpus_test takes //cmd/bd:bd_for_tests (size large,
timeout long), so under bazel the suite runs instead of skipping on a
missing BEADS_TEST_BD_BINARY.

Stacked on S6b/c/d, whose marks this file no longer carries: besides the
S6b/S6c/S6d marks, seven list shapes once marked S6c+S15 (their --limit 0
list walks the keyset cursor without S15) and the S6c+S16 last-step close
(an ordinary epic root never auto-closes) already pass on it.

On S6b/c/d (bazel, BEADS_TEST_EMBEDDED_DOLT=1): 97 pass, 25 pending,
3 allowlisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http/corpus): hand the corpus server the LeaseReclaimer role

main gained the LeaseReclaimer role (issues.reclaim) after S23 was written,
and httpapi.Config needs it when built from roles rather than a Provider, so on the restacked
S6bcd TestServedCorpus could not bind its in-process server ("no database
source"). The harness now passes s.LeaseReclaimer() with the rest, as
backend/http's e2e harness does. The reference proxy still masks the
issues.reclaim token, so gc-reclaim stays pending.

On the restacked S6bcd (bazel, BEADS_TEST_EMBEDDED_DOLT=1): 97 pass,
25 pending, 3 allowed, unchanged from before the restack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http/corpus): run the corpus in CI, hold allowlisted shapes

Review fixes for #7483 (review attempt 1): both majors, and four of the
seven minors and nits.

No CI lane ran TestServedCorpus. corpus_test sets neither
BEADS_TEST_EMBEDDED_DOLT nor BEADS_HTTP_TEST_REQUIRED, so the suite
skipped everywhere. corpus_served_test, an embedded-tagged sh_test over
go_test_variant.sh like http_served_test, runs it with both set and with
Bazel's prebuilt bd, and pr_risk_bazel_coverage_test pins its args and
env. Every other file in the package builds only under cgo, so a new
cgo-free test fails a BEADS_HTTP_TEST_REQUIRED=1 run that would otherwise
pass having run nothing. README.md and engdocs/TESTING.md say which lane
runs the suite.

The allowlist branch returned before the embedded exit check, so an
allowlisted shape was never held to what it says on the embedded
backend. The embedded run is now checked against the shape's expect_exit
and expect_stderr before the allowlist branch, and an embedded mismatch
fails as a corpus bug whatever the shape's pending mark or allowlist
entry. TestCorpusFileIsWellFormed requires an allowlisted shape to state
expect_exit and to carry nothing the allowlist would skip (compare: exit,
no verify). The three allowlisted shapes now pin their embedded refusals,
and the bd sql reasons say the command needs a sql-server workspace
instead of calling it local-only.

Minors and nits taken:
- two stale-guard shapes (--if-assignee nobody, --if-status open) expect
  exit 13 on both sides; each kills a client that drops that guard;
- defer_until and due_at are compared as given instead of scrubbed to
  <ts>, which kills a client that shifts --defer;
- gc-reclaim's pending mark names SRV-1 alone: the reference profile
  does not advertise issues.reclaim, so the client refuses at its
  capability preflight;
- refusalMarkers matches "does not advertise capability" unquoted, which
  also catches the JSON-escaped preflight error.

Declined:
- a failure on empty-vs-empty comparisons, which needs an allow_empty
  opt-in. Review attempt 2 seeded rows for two of the three ready shapes
  that compared two empty lists (below); gc-ready-graph-anchor still
  does;
- the context route's query check in the reference proxy: the server
  already answers an unknown query parameter there with a 400
  unknown_parameter, which the proxy passes through, so the served run
  still fails; only the proxy's own refusal note is missing;
- a shared server constructor for the two e2e harnesses, which the review
  marks optional.

Review attempt 2: four of its six minors and nits.
- gc-ready-ephemeral-assignee-unlimited and gc-ready-assigned-tier
  compared two empty lists, so a client that sent the wrong assignee or
  dropped --include-ephemeral passed both. Two seed rows assigned to the
  worker, an open task (P2) and an open wisp (P1), give them
  [e2e-wisp-wr e2e-wr] and [e2e-wisp-wr]. The priorities differ, so
  --limit=1 cuts no tie. A client that rewrites the assignee, or drops
  include_ephemeral, now fails both shapes; without the rows it passed
  them.
- templatePattern looped forever on a profile path with an unclosed "{",
  growing its pattern without bound. It now returns an error, which
  loadReferenceProfile reports with the operation and path, and
  TestCorpusFileIsWellFormed loads the profile, so corpus_test catches a
  bad edit without the embedded engine.
- TestCorpusFileIsWellFormed compiles every expect_stderr and every
  allowlist refusal, and runShape compiles expect_stderr once and fails
  the shape as a corpus bug instead of panicking on a bad pattern.
- README.md documents the stdin, setup, ordered and ignore_fields
  fields.

Not in this commit:
- the PR description (shape counts, allowlist reasons, gc-reclaim's
  SRV-1 mark, the Bazel run line) is brought up to date when this commit
  is pushed;
- hoisting runBD, minimalBDEnv, buildBD and the skip gate into
  internal/testutil, or cross-reference comments in their three copies,
  which the review marks optional and which reaches outside this
  package.

The full corpus gives 127 shapes: 99 pass, 25 pending, 3 allowed, with
no shape changing status from the attempt 1 fixup, on this tree and
merged with main at 0a163ca285.

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 <noreply@anthropic.com>
2026-10-11 05:34:51 +00:00
Bee
4c4ba275c4
test(show): tighten the --comments-tail off-state check; share the --watch start/stop choreography (#7383 follow-ups) (#7454)
Follow-up to #7383: the three non-blocking items its adoption review
filed (bd-m9pl8x, bd-zi2dko, bd-5qz7fa). Tests and release notes only.

- bd-m9pl8x: stripShowTips dropped every tip line and normalized trailing
  newlines on both routes, so a stray trailing blank line printed only
  under --comments-tail passed every route test. stripTrailingShowTip
  removes exactly one trailing "\n💡 Tip: …\n" block and nothing else;
  assertCommentsTailOff strips it only on the direct route (tips=true) and
  compares the proxied route byte for byte. Table test added.
- bd-zi2dko: the bd show --watch start / first-render / SIGINT /
  bounded-exit sequence now lives once, as startShowWatch +
  (*showWatch).interrupt; TestProxiedServerShowWatch and runShowWatchOnce
  both use it. Assertions unchanged.
- bd-5qz7fa: drop the blank line that made the CHANGELOG "### Added" list
  loose; direct_json_untouched goes through bdShowRaw.

Mutant check: a go build -overlay mutant printing one extra newline after
printComments only when --comments-tail > 0 passes the test on main (5/5)
and fails exactly direct_off_state_matches_absence here; the control
binary passes 5/5.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-11 03:51:58 +00:00
Steve Yegge
43b1fb2e4f
fix(build): pair Darwin SDKs with the native Apple linker (#7460)
* fix(build): use native Darwin linker (wy-6fric6)

Keep pinned LLVM Clang and Linux toolchain inputs; pair Darwin SDKs with the native Apple linker to support macOS 27 TAPI targets.

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Steve Yegge

* fix(build): canonicalize LLVM attributes (wy-6fric6)

Apply bazel mod tidy ordering; linker/compiler settings are unchanged.

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Steve Yegge
2026-10-11 03:51:25 +00:00
Julian Knutsen
22c0faaaf9
test: fix the three causes of Main's Test (macOS) failures (#7494)
* test(dbproxy/server): disable dolt event flush so send-metrics cannot race TempDir cleanup

Every dolt sql-server this suite stops cleanly forks a detached
`dolt send-metrics` child on exit. It outlives the test, rewrites
<HOME>/.dolt/eventsData (HOME is a t.TempDir()), and races t.TempDir's
RemoveAll: "TempDir RemoveAll cleanup: ... 001/.dolt: directory not empty".
main.yml's Test (macOS) job (plain go test) failed on this in about half
of the pushes since 2026-10-09; Bazel never did because
tools/bazel/test_env.sh exports DOLT_DISABLE_EVENT_FLUSH=1. TestMain now
exports it too, guarded by TestSuiteDisablesDoltEventFlush.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(scripts): skip Linux-CI-only rrc and worker-env-sync script tests off Linux

TestRRCRunLanes runs .github/scripts/rrc-run-lanes.sh, which uses bash 4's
`mapfile` (exit 127 under macOS /bin/bash 3.2). TestWorkerEnvSyncCopyAgainstFixture
runs tools/rbe/worker-env-sync-copy, whose GNU `sed -i -E` becomes
"-i with backup suffix -E" plus a basic regex under BSD sed, so the pin is
never rewritten. Both scripts run only on Linux runners (bazel.yml
rrc-seed/rrc-verify, worker-env-autosync.yml); per their owner they stay
Linux-only and the tests skip elsewhere with the reason.

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-11 02:31:35 +00:00
Julian Knutsen
0a163ca285
fix(ci-policy): close M19/M21 scanner gaps from #7491 review (#7492)
The host-tool-exec policy scanner (scripts/host_tool_exec_policy_test.go)
had two remaining soundness gaps flagged in gastownhall/beads#7491's
review:

- M19: a discarded PrebuiltBD()/findPrebuiltBDBinary() error (e.g.
  `bd, _ := PrebuiltBD()`) kept the "never empty under Bazel" invariant
  trusted for `bd`, even though a real lookup failure under Bazel also
  returns "" there. prebuiltResultVars now only trusts the result when
  the error is bound to a named variable that is itself checked with an
  aborting `if err != nil`.

- M21: an abort-style gate (`if bazeltest.IsBazel() { return }`) counted
  as gating an exec that ran before it, in source order, within the same
  block. The abort-style check now requires the gate to dominate the
  exec (ifStmt.End() <= pos); containment-style gating is unaffected
  since nesting already guarantees order.

Flips the two tests that pinned these as documented limitations into
mutation fixtures that must fail, adds three new M19 fixtures (discarded
error, bound-but-unchecked error, and the fixed/checked shape), and
updates the package and gated() doc comments. TestNoUngatedHostToolExecs
UnderBazel confirms no real call site in the tree regresses.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 01:53:00 +00:00
Julian Knutsen
17127ee544
fix(ci-policy): close review leftovers from #7485/#7486 (#7491)
* fix(ci-policy): close review leftovers from #7485/#7486

Follow-ups from maintainer review on the host-tool exec/shell policy
tests and the bazel.yml integration gate:

- host_tool_shell_policy_test.go: recognize indented function headers
  and `function name {` forms when finding a function's closing brace,
  so scripts/test.sh's indented cleanup_shared_server() no longer
  mis-attributes its trailing lines to the wrong function; classify
  same-line `command -v gofmt && gofmt` (and `go`) as the guarded
  presence-check idiom instead of flagging it.
- host_tool_exec_policy_test.go: make condPolarity reject mixed-polarity
  && / || compounds (one recognized side, one not) instead of guessing
  at the recognized side's polarity, which was unsound in both
  directions; add pinning tests documenting the exec-before-gate and
  function-value-helper cases as known, safety-conservative limitations
  rather than bugs. Fixing this exposed a real ungated fallback in
  cmd/bd/scripttest_test.go (a `go build` that could still run under
  Bazel on a prebuilt-binary basename mismatch); fixed by symlinking the
  prebuilt binary under the expected name instead of rebuilding it.
- bazel.yml: bazel-server-storage now honors the `integration` input
  like bazel-integration/bazel-cmd-dolt do, so an explicit "off" skips
  it too (latent today: no caller passes "off"). Updated
  ci_workflow_test.go's policy tests to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(ci-policy): close should-fix B (go command -v guard evasion) on #7491

shellCommandVGuard previously excused go the same as gofmt, but under an
exit-127 host-tool stub `command -v` finds the stub and the guarded exec
still runs, and on a worker genuinely lacking go the exec was silently
skipped -- the worker-dependent behavior this policy exists to ban. Drop
go from the guard entirely, require the guarded exec to sit directly after
the guard's own `&&` (no intervening `;`, `||`, `|`, or leading `!`), and
require an exact gofmt match so a same-prefixed sibling like `gofmt-foo`/
`go-junit-report` can't borrow the guard. Add every should-fix B shape as
a fixture that must still be flagged, plus the generalized gofmt-side
cases (leading `!`, exact-name, post-`;` exec).

Also: correct host_tool_exec_policy_test.go's doc claim that a
function-value helper call site is "not a soundness hole" -- mixed with
one gated direct call site, the invisible function-value call site's
ungated-ness is silently lost and the combined verdict flips to gated;
pinned as review M22. And recognize a function closed by `} >&2` as
ended, so abort-style safety computed inside it does not leak into the
rest of the file (no scoped script has this shape today, but a bare `}`
equality check would silently miss it the moment one does).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 01:22:48 +00:00
Julian Knutsen
a4c47ccfdf
fix(schema,uow): route the proxied data-behind open to the #6575 stop (port of #6695 to main) (#7481)
* fix(schema,uow): route the proxied data-behind open to the #6575 stop with topology-correct guidance (port of #6695)

Port of the release/1.3.x commit bb03a310a9 (PR #6695) to main, where it
never landed: v1.3.1 is cut from a release branch that is not an ancestor
of main.

The proxied / `bd serve` open path never reached the #6575 data-behind
stop. doltSQLProvider.initSchemaAttempt passed a nil adopter to
CheckSharedStoreMigrateGate, so localDataBehind short-circuited and the
router could never emit smartDataBehind. A proxied store that was level
on schema and behind in data reported `shared-store` instead, whose body
is the designated-migrator recipe -- `bd migrate --force` then
`bd dolt push` -- which in that state is exactly the #6368 wedge the
stop exists to prevent. The refusal was always safe (the shared arm
suppresses the auto-migrate either way); the guidance was not.

- uow: wire a dataBehindAdopter with AheadBehind only
  (versioncontrolops.LocalAheadBehind). IsStrictAncestor/WorkingSetClean
  stay nil so the remote-ahead arm keeps its plain adopt directive, and
  FastForward stays nil because it would promote the schema for every
  co-resident client. Read-only proxied opens print the pull-first block
  instead of the shared-consent template.
- uow.WithProxiedServerMode(), set only by openProxiedServerUOWProvider,
  marks the refusal Proxied: the same provider serves `bd serve` on a
  SERVER-mode workspace, where `bd dolt pull` works.
- schema: a Proxied refusal names the server host as where the pull runs
  (`bd dolt pull` is refused at the proxied front door,
  proxy.dolt_pull.unsupported), the option id becomes
  pull-first-on-server-host, and the guidance says the forced
  `bd migrate schema --force` consent step IS runnable from the proxied
  workspace (the capability registry permits `migrate schema`), so it must
  wait for the pull, and that BD_ALLOW_REMOTE_MIGRATE=1 is reachable too.
- cmd/bd: the --json `expected` field carries the same location
  qualifier (dataBehindExpectedField).

Not ported, because main already has it: the release PR's F-B half (the
shared data-behind consent step naming `bd migrate schema --force` and
its --global twin, the printGlobalDatabaseConsentHint retarget, and the
shared_migrate_consent_test.go changes) landed on main as #6692.
Adapted to main: the release line's proxyMaintenanceRefusals table is
main's capability registry, so TestProxyMaintenanceAllowsTheSharedConsentVerb
drives validateProxyRegistryBeforeProvider for every proxied topology and
also pins that `bd dolt pull` and the bare `bd migrate` are refused; the
CHANGELOG paragraph is appended to main's existing #6575 entry.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(upgrading): where the proxied data-behind pull runs; pin its plumbing

Review fixes for the proxied data-behind stop: the one major of review
attempt 1, the cheap minors, and the nit, plus the wording minor of
attempt 2.

- Clone behind the remote, the docs section the gate's payload links
  to, prescribed `bd dolt pull` with no topology qualifier: the remedy a
  proxied-server workspace refuses at its front door. Its intro now says
  so, and a proxied-server step pair puts the pull (and any conflict
  resolution) on the server host, from a workspace with direct database
  access, then `bd migrate schema --force` in the proxied workspace. It
  also warns that nothing there enforces that order: `--force` and
  BD_ALLOW_REMOTE_MIGRATE=1 are honored before the stop is reached, so
  the stop never sees them. The warning ends on the payload's own
  instruction, not to reach for either to get past the stop, rather than
  a negation ("neither is a way past it") that read as the topology
  blocking the wedge. The pending-migration exception above the section,
  the proxied-server list under Shared servers (now three differences)
  and the init-safety ordering rule say the same. The heading, and with
  it the anchor the gate links, is unchanged.
- The option plumbing that carries the fix is pinned link by link.
  TestApplyProviderOptions covers WithProxiedServerMode (it sets that
  field and no open posture). The cmd/bd append moves into
  proxiedProviderOptions, which TestProxiedProviderOptions holds to
  exactly one added option on a fresh slice. And
  TestNewDoltServerUOWProvider_CarriesProxiedServerMode opens two real
  providers on one server, with and without the option, and reads the
  field the gate copies; openAndInitSchema's provider literal and the
  shared test open helpers are left as they were.
- TestProxyMaintenanceAllowsTheSharedConsentVerb also pins `bd dolt
  push` and `bd conflicts resolve` as refused, the rest of the list the
  proxied refusal body recites. `dolt push` is refused as unimplemented,
  the kind of row that flips to allowed once a route lands.
- localDataBehind's doc comment is re-wrapped so the IsStrictAncestor
  sentence no longer breaks across the inserted parenthetical.
- The CHANGELOG entry notes the docs change.

Each new pin is red with its link reverted: the option dropped from the
cmd/bd append, the append made in place, the field copy deleted from
the provider literal, the constructor dropping its options, the option
also setting preview, and the push and conflicts codes changed. Still
unpinned: which option the cmd/bd append adds (options are opaque
outside uow) and that `bd serve`'s server-mode open passes none; both
need a seam in cmd/bd.

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 <noreply@anthropic.com>
2026-10-11 00:23:25 +00:00
Julian Knutsen
b7dba4d4e4
test: ban ungated host go/gofmt execs under Bazel; pin compact_gc_fixture pure/norace (#7485)
* test: ban ungated host go/gofmt execs under Bazel; pin compact_gc_fixture pure/norace

Follow-up to #7478. Adds two policy tests on //scripts:go_sources_test:

- host_tool_exec_policy_test.go: an AST scan of every *_test.go file and
  internal/testutil's non-test .go files for exec.Command/CommandContext/
  LookPath("go"/"gofmt") that isn't gated by bazeltest.IsBazel()/TEST_SRCDIR
  in its enclosing function, with an explicit, justified allowlist for the
  handful of sites gated by caller dataflow instead (bazeltest.PrebuiltBD()
  checked before calling a separate helper). "dolt" is out of scope: the
  hermetic copy resolves first on Bazel's PATH, unlike go/gofmt.
- host_tool_shell_policy_test.go: the same policy for the shell scripts
  under scripts/ that Bazel sh_test/go_test targets actually execute
  (fmt-check.sh, the repochecks guards, gofmt-bin.sh, the migration-test
  harness), matching the gating pattern #7478 added to fmt-check.sh and
  scripts/ci/lib/test-env.sh.

Both are mutation-verified (an added ungated exec.Command("go","version")/
`go build` is detected, then reverted cleanly).

Also sets pure = "on" and race = "off" on cmd/bd/BUILD.bazel's
compact_gc_fixture go_binary, matching :bd_for_tests/:cmd_norace: it is a
testonly, stdlib-only fixture, so neither cgo nor the race detector buys it
anything, under any --config. Verified TestRunCompactDoltTargetsOnlyAuthorizedActiveDatabase
still passes via `bazel --nohome_rc test` under both --config=prcore and
--config=doltserver-cmd.

Known pre-existing issue, out of scope here: gosec's GoVersion() call still
execs a host `go` from third-party code this policy doesn't reach.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(scripts): address review of host-tool exec/shell policy (#7485)

Fixes all 6 maintainer-city-c3 review items against the ban-ungated-go/
gofmt-exec policy, each with a mutation test proving the fix catches
the described regression:

1. Shell scan now gates per-branch/per-call-site (shellLineGating),
   not by any TEST_SRCDIR mention anywhere in the whole file.
2. Shell scanner adds gofmt and `go tool` detection, fixes the
   heredoc-start regex (no longer swallows the rest of the script on an
   arithmetic `<<` shift or a `<<<` here-string), and replaces the
   blanket printf/echo/git-grep line skip with a quoted-span/command-
   substitution-aware check that still catches a real exec joined onto
   a message line with `&&`.
3. shellPolicyScope gains pr-lint.sh, check-versions.sh,
   upgrade-smoke-test.sh and the 4 .github/scripts shard fallbacks,
   each cited against its real BUILD.bazel/.bzl wiring; corrects two
   factually wrong "not executed" doc-comment claims (pr-lint.sh and
   upgrade-smoke-test.sh ARE Bazel-executed); and adds
   TestShellPolicyScopeCoversBazelShellData, a mechanical backstop that
   fails on a Bazel-referenced .sh under scripts/ or .github/scripts/
   missing from scope.
4. hostToolExecAllowlist no longer exempts goBuildBDCommand's 9 call
   sites by helper name; helperIsGatedByAllCallers checks every real
   call site is itself gated.
5. Both allowlists are keyed by file + enclosing function + exact
   snippet, not line number.
6. gated()/shellLineGating understand condition polarity, so an
   inverted `if !IsBazel() { t.Skip() }` (or its shell equivalent) is
   correctly NOT counted as a gate.

Also extends the Go scanner's condPolarity to recognize
findPrebuiltBDBinary()/bazeltest.PrebuiltBD() result variables as a
TEST_SRCDIR-equivalent gate (proven safe by reading their
implementation), and the shell scanner's analogous shellBazelSetVars
for CANDIDATE_BIN/SOURCE_TAG_SQLITE_BIN/BEADS_TEST_*_BINARY, including
through a script's own default-value variable alias
(`VAR="${BAZEL_VAR:-default}"`).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(scripts): give go_sources_test runfiles access to the new shell scope

The shell-policy rewrite (host_tool_shell_policy_test.go) added
shellPolicyScope entries for scripts/ci/pr-lint.sh,
scripts/check-versions.sh, scripts/upgrade-smoke-test.sh, and the four
.github/scripts/*-test-shard.sh files, plus a scope-coverage guard
(TestShellPolicyScopeCoversBazelShellData) that walks every tracked
BUILD.bazel file. None of those were runfiles of
//scripts:go_sources_test, so bazel test passed locally under plain
`go test` but failed in CI's hermetic Bazel sandbox with "no such file
or directory" for the new scope entries and "found only 0 BUILD.bazel
files" for the guard's walk.

Add //:repo_other_files (every tracked non-Go, non-Markdown file,
including every BUILD/.bzl file) to go_sources_test's data, mirroring
the same pattern already used by //scripts:scripts_test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(scripts): rename AST-fixture function so it isn't counted as a real test

tools/bazel/equivalence.py compares `go test`'s discovered top-level
tests against what Bazel actually ran, using a raw-text regex
(`^func\s+(Test\w*)\s*\(\s*\w+\s+\*testing\.T\s*\)`) rather than
compiling the file. The "inverted IsBazel skip" fixture in
host_tool_exec_policy_test.go embeds a column-0
`func TestSomething(t *testing.T) {` inside a backtick string used to
build an AST for findHostToolExecCalls, which the regex scan counted
as a real top-level test that Bazel's go_sources_test then "failed to
run" (CI's Bazel / test leg: EQUIVALENCE: FAIL on "scripts
TestSomething"). Rename the fixture's inner function to
bazelOnlyFixture; the test's behavior is unchanged since the name was
never semantically significant to the scan being exercised.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(scripts): close host-go-policy gaps from PR #7485 re-review

Four fixes from the final review round:

1. test.sh/conformance.sh/release.sh ARE in scope (they run under Bazel
   via scripts/** data globs); drop the false "not in scope" claims and
   add justified fn-keyed allowlist entries for their 8 flagged execs.
2. Go AST: an exec inside the Bazel-true branch, before its own abort,
   is no longer wrongly counted as gated (M17); a gate inside a sibling
   closure no longer covers execs outside it.
3. Shell scanner: abort/skip gate state now resets at function-scope end
   (a top-level `go build` after build_candidate in
   upgrade-smoke-test.sh is correctly flagged), and `bash -c 'go build'`
   is detected again.
4. Split host_tool_shell_policy_test.go into its own go_test
   (shell_host_tool_policy_test) with narrow, curated data instead of
   riding go_sources_test's //:repo_other_files; restored
   go_sources_test's data to its pre-PR scope. Dropped
   TestShellPolicyScopeCoversBazelShellData: its regex backstop could
   not see Starlark labels/.bzl/globs and still missed real in-scope
   scripts, so it wasn't earning its cache-rerun cost. The new target
   carries no tags, so it still runs in the required "Bazel / test"
   lane.

Each of 1-3 ships with a mutation-proof fixture that fails on the prior
code and passes on the fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(scripts): rename sibling-closure fixture to avoid false test-equivalence hit

tools/bazel/equivalence.py line-scans *_test.go files for a column-0
`func Test\w*(t *testing.T)` to build its "what go test runs" list; it
reads raw text, not compiled Go, so the fixture's embedded raw-string
Go source (used to feed findHostToolExecCalls a parseable AST) was
mistaken for a real top-level test the package defines, and the
equivalence check failed because no go_test target "ran" it. Rename
the fixture function from TestX to siblingClosureFixture, matching the
existing convention a few lines down (bazelOnlyFixture) that documents
the same pitfall.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 23:51:34 +00:00
Julian Knutsen
c18db4ebbd
feat(storage): add events/bd_events_journal/bd_events_seq to cursorRealityFloor sentinel set (port of #6547 to main) (#7480)
* feat(storage): add events/bd_events_journal/bd_events_seq to cursorRealityFloor sentinel set (port of #6547)

Port of the release/1.3.x commit aa3c43b6bd (PR #6547) to main, where it
never landed: v1.3.1 is cut from a release branch that is not an ancestor
of main.

events (ignored/0019) and bd_events_journal/bd_events_seq (ignored/0022)
are dolt_ignored, so they are never part of committed history and a fresh
clone can arrive with the ignored-plane cursor at-latest but without them.
cursorRealityFloor only knew about wisps/wisp_dependencies (floor 0) and
leases.granted_node (floor 11), so such a clone believed its cursor and
never re-created the missing tables.

A new sentinelFlooredTables list clamps the believable cursor to each
table's own replayFloor (18 for events, 21 for the journal pair) instead
of 0, so the replay re-runs the creating migration without re-running
ignored/0007's unguarded `UPDATE wisps SET is_blocked = 0`. Floored
tables are probed after the floor-0 tables and together with the column
sentinels, taking the minimum across everything found absent.

Tests: TestCursorRealityFloor and TestCurrentVersionClampsToSentinelFloor
gain the three single-absence cases, a two-floored-table case pinning the
intra-loop minimum, and a table+column case pinning the cross-loop
minimum; TestSentinelFlooredTablesAreCreatedByTheSeries asserts each
floored table is created strictly above its floor and that the floor
excludes ignored/0007. The sqlmock probe sequences in lock_test.go and
cursor_reality_test.go expect the extra INFORMATION_SCHEMA.TABLES probes.

The commit applied to main without conflicts; main's ignored series still
creates the three tables at 0019 and 0022.

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(schema): pin cursorRealityFloor's floored-table probe error

cursorRealityFloor returns a floored-table probe error instead of
reading the table as absent or skipping it, but no test reached that
return. TestCursorProbeErrorIsNotTreatedAsContradicted fails every
table probe, so it returns at the floor-0 wisps probe first. Turning
the return into `continue`, or into "absent", left the whole schema
package green.

TestFlooredTableProbeErrorIsNotTreatedAsContradicted fails exactly one
floored table per subtest (events, bd_events_journal, bd_events_seq),
with every other sentinel table present. It asserts that the error
propagates, that the cursor is not reported as contradicted, and that
no column sentinel is probed afterwards. stubSentinelTables applies one
error to every probe, so the test stubs sentinelTableExists inline
rather than widening a helper the other tests share.

Mutated under a go test -overlay, each of `continue`, "absent", and
returning limited=true alongside the error fails only this test's
three subtests. The unmutated package passes 474 of 474 tests and
subtests, none skipped.

The test is additive and sits between two existing tests. It adds no
conflict hunk to #7213, #7297, or #7409, and #7050's duplicate port
commit still replays as empty on top of this PR, so a rebase drops it.
For that reason the review's suggested rewording of the floored-table
rationale comments is left for after #7050 lands. The comments stay
identical to release commit aa3c43b6bd.

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 <jim@wordelman.name>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 23:25:58 +00:00
Julian Knutsen
38c0f24adb
ci: F5 S2 Variant A — nogo ownership for the integration configuration group (#7486)
* ci: F5 S2 Variant A nogo ownership for the integration configuration group

No full Bazel lane validates the integration / doltserver-integration /
doltserver-cmd configurations anymore (all three now pass
--norun_validations). Instead bazel-integration gains a narrow "Nogo:
integration library files" step that keeps full nogo (vet + golangci-lint)
on the configuration's one non-test library package,
//internal/testutil/integration, via
`bazel build --config=integration --@rules_go//go/config:race --keep_going
--output_groups=nogo_fix -- //internal/testutil/integration:integration`.

This accepts a scoped coverage loss (f5-spec.md §3/§5 S2, Variant A): the 56
integration-tagged _test.go files (listed in
tools/nogo/unvalidated_integration_tests.txt, derived from source by the new
T4 test) no longer get a vet pass in any lane, since golangci-lint already
skips all _test.go files repo-wide (.golangci.yml's run.tests: false) and no
lane builds those test binaries with validations on. Verified directly with
real `bazel build` runs: a planted vet finding in the library package still
fails the new step; the same finding in an integration-tagged _test.go file
no longer fails anything; a planted finding in a plain race-configuration
library still fails bazel-test; and GoCompilePkg action keys for the
integration configuration are identical with and without
--norun_validations (it is a build-request option, not a configuration
flag, so no farm cache invalidation).

scripts/nogo_lint_policy_test.go: the nogoConfigurations table gains a
"integ" row with an ownerIsNogoOnlyStep flag and a dedicated
checkNogoOnlyStepRow, generalizing T1/T2/T5/T6 to cover an owner that is a
narrow build step rather than a full lane; adds T4
(TestNogoIntegrationStepCoversItsConfiguration), which derives the step's
expected target set from source via go/build's own tag matching instead of
a hardcoded list.

Also fixes four should-fix items from julianknutsen's review of #7482:
1. expandBazelrcConfig now follows `common:` lines and --config= tokens
   anywhere on a line, not just a first-position `build:`/`test:` one.
2. TestNogoRaceOwnerBuildsEverything now expands every config the owner job
   can reach (including shell-variable-gated ones like sole-run), not just
   the statically-named "ci".
3. The package-gate check now compares full key-flag fingerprints instead
   of substring-matching --@rules_go//go/config:race / --norun_validations.
4. tools/bazel/nogo_ownership.py now fails loudly (exit 2) when both the
   owner's and non-owners' action-key sets are empty, instead of reporting
   a vacuous pass.

Each fix has new mutation-test coverage in TestNogoPolicyRejectsMutations
(should-fixes 1-3) or nogo_ownership_test.py (should-fix 4).

engdocs/LINTING.md and engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md updated to
remove the stale "integration still validates in all three lanes" claim and
document the Variant A trade-off.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(ci): make T4's source scan work under Bazel, not just plain go test

scripts:scripts_test only declares //:repo_other_files as data (every
tracked file but Go and Markdown source, by design: a Go-only change
should not re-run the CI/workflow policy tests). TestNogoIntegrationStep
CoversItsConfiguration's source scan needs every non-test .go file, so
under `bazel test //scripts:scripts_test` its runfiles tree had none and
the scan always came back empty.

Fixes:
- scripts/BUILD.bazel: add //:repo_go_srcs to scripts_test's data, with a
  comment explaining why (this is the one test in the target that needs it).
- integrationOnlyLibraryPackages: use bazelPolicyRoot(t) + repoFiles(t, ...)
  (the existing Bazel-safe, runfiles-aware file listing other policy tests
  in this package already use) instead of sourceRepoRoot(t) +
  filepath.WalkDir, which only sees what //scripts's own go_test target
  declares.

Verified with real `bazel test --config=integration --@rules_go//go/config:race`
and `--config=ci --@rules_go//go/config:race` runs of //scripts:scripts_test
(both pass); CI caught the original gap (PR #7486's first push failed
Bazel / integration and Bazel / test with exactly this).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): address independent review + bee-ghosttrack findings on F5 S2 Variant A

Independent review of #7486, must-fixes 1-7: pipefail on the nogo-only
step's tee pipeline; exact source-scan equality check for
tools/nogo/unvalidated_integration_tests.txt; expandBazelrcConfig
follows common:-lines and non-first-position --config= tokens in both
the Go policy test and nogo_ownership.py; mirrored
nogo_ownership.py should-fix guarding against a non-owner action-key
query silently matching nothing.

Cost fix: split T4/T6's whole-repo .go source scan into its own
go_test target (//scripts:nogo_integration_scan_test) so a Go-only
change no longer re-runs all of scripts_test; extracted the shared
bazelInvocations and ciWorkflow helpers into helper-only files so
both targets can depend on them without violating the
one-target-per-test-file partition rule.

bee-ghosttrack review: checkNogoOnlyStepRow's own fingerprint now
excludes test:-sourced .bazelrc lines pulled in via --config=X
(buildOrCommonLines), since the nogo-only step is a `bazel build`
invocation that never reads a test: line; added mutation s2i
reproducing the gap this closes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(nogo): pin integration nogo-only step's target, fingerprint its lane, add behavioral test

Addresses the remaining should-fixes from the independent review of #7486:

1. TestNogoIntegrationStepScriptFailsWithoutMaskingBazelsExitCode
   (scripts/nogo_integration_step_script_test.go) extracts the real
   "Nogo: integration library files" step script from bazel.yml and runs it
   under plain `bash -e` (GitHub's actual run: semantics, no pipefail added)
   against a stub bazel, closing the gap a text-only pin can't: it catches
   rc=0 before `exit "$rc"`, `|| :`/`|| true` on the tee pipeline, or a
   missing/negated `set -o pipefail`, regardless of how the mutation is
   spelled.

2. The nogo-only step's target set is now pinned by exact go_library
   label, not just package: nogo_integration_scan_test.go derives the
   label(s) from source + BUILD.bazel and nogo_lint_policy_test.go pins
   them literally (its own go_test target has no //:repo_go_srcs). Both
   reject a `-//` exclusion pattern outright.

3. checkNonOwnerCommandLineAddsNoKeyFlag is now also applied to the
   integ row's owner's own full lane: under Variant A that lane validates
   nothing, so it is effectively a non-owner for this check's purpose, and
   must not override a key-affecting flag on its command line either.

4. Latent items: TestNoUnconditionalValidationOff now also scans
   .github/actions/setup-bazel/write-bazelrc.sh for run_validations (every
   line it emits lacks a :config suffix, so any occurrence would turn
   validation off everywhere with no owner lane to catch it).
   tools/bazel/nogo_ownership.py's docstring is corrected: it had said S2
   was simply "out of scope," which is now stale since S2 has its own
   validating lane (the nogo-only step, checked statically); the script's
   dynamic aquery-based cross-check remains S1-only because S2's owner has
   no non-owner test lane building the same configuration to compare
   actions against.

Skipped (not cheap / not reachable):
- bazel-server-storage's `if:` not modeling an "integration" input: no such
  input exists to model; the gate is RBE-enabled-only by design, and
  resolving this requires understanding pr.yml's broader gating semantics,
  not a textual fix.
- defaults.run.shell parsing: bazel.yml has no `defaults:` block today
  (confirmed by grep), so there is nothing to parse; the gap is latent only
  for a future change, not a live bug.
- race-off scan's future-wrong-fix edge case: the review itself
  characterizes this as not reachable with today's file set.

New mutation cases s2j/s2k/s2l in TestNogoPolicyRejectsMutations cover
items 2 and 3. All mutation-verifications performed by hand-editing the
real files, confirming FAIL, and reverting via Edit (never git
stash/checkout).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 23:19:16 +00:00
Julian Knutsen
76d5bf61ef
ci: harden F5 S1 nogo ownership checks (follow-up to #7479) (#7482)
* test(nogo): reject F5 S1 ownership mutations the policy tests missed

Follow-up to #7479's independent review.

- nogoKeyFlags parses whole tokens instead of a prefix regex, so
  --@rules_go//go/config:race=false on a non-owner no longer fingerprints
  as the owner's race build (1f).
- The owner's run_validations check expands every --config its bazel
  commands select (including BAZEL_SOLE_RUN/BAZEL_FRESH) recursively, so
  e.g. `test:sole-run --config=doltserver` is caught (1e).
- T3 scans every argument of the owner's `bazel test`, including
  backslash-continued lines, for negative target patterns (1g).
- T1 pairs each non-owner job with the --config its own bazel command
  selects instead of by list index (2).
- TestNogoPolicyRejectsMutations feeds T1/T3/T5/T6 each mutation 1a-1g
  and 2 and requires a rejection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(bazel): nogo_ownership.py compares nogo actions by action key

Owner and non-owner nogo coverage was compared by target label, which
treats one label compiled in two configurations as covered. Compare
RunNogo and ValidateNogo actions by Bazel action key instead. Non-owner
universes drop manual-tagged tests (bazel test //... never builds them)
and add //cmd/bd:bd_for_tests, the package gates' target. The
fingerprint mirrors nogoKeyFlags' whole-token parsing.

nogo_ownership_test.py covers this with a fake bazel.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): correct nogo lane-sharing and one-required-lane claims

- CI_REQUIRED_CHECK_TOPOLOGY.md: only the nogoConfigurations rows
  (race, pure, js/wasm) validate in exactly one required lane; the
  integration configuration still validates in its three required lanes
  until F5 S2.
- .bazelrc: --norun_validations lanes share compile, link and nogo
  actions with `test`, not test PASS results (each lane's test actions
  have their own env and args). Comment only.

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-10 19:54:13 +00:00
Julian Knutsen
3e7705a2cd
fix(bazel): remove host-go dep from compact GC test; drop frozen shard blocks (#7478)
* fix(bazel): remove host-go dep from compact GC test; drop frozen shard blocks

Replace the ungated `go build` in compact_gc_target_test.go's dolt-stand-in
fixture with a Bazel-built go_binary (cmd/bd:compact_gc_fixture) wired via
rlocationpath env + data, mirroring the existing preflight_go_fixture
pattern. Falls back to `go build` only when not running under Bazel
(bazeltest.IsBazel()). Also gate test_repo_beads_guard_test.go's `go env
GOCACHE`/`GOMODCACHE` probes on !bazeltest.IsBazel(), since they previously
ran unconditionally in every cmd/bd TestMain.

Separately, delete the legacy 20-shard embedded-cmd and 15-shard
proxied-cmd "frozen" manifest blocks in .github/scripts/*-test-shards.txt:
their only consumers were pr-risk.yml fork/push jobs that have since
migrated to bazel.yml. Update gen_embedded_cmd_shard_manifest.py and
gen_proxied_shard_manifest.py to drop the frozen-block rendering/guard
logic and default to the live Bazel-only shard counts (100 and 34),
and refresh stale comments/docs (cmd/bd/BUILD.bazel,
scripts/shard_manifest_test.go, engdocs/TESTING.md,
engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md) that still described the deleted
blocks. Verified no other BUILD/.github/scripts references read them.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): auto-sync BUILD files

Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/38069936930
(`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(bazel): gate remaining host-go calls; fix shard-manifest --weights footgun

Address PR #7478 review findings (bee-ghosttrack):

- scripts/ci/lib/test-env.sh: skip the GOCACHE/GOMODCACHE `go env` probes
  when TEST_SRCDIR is set, so scripts/test.sh's beads_test_env_enter never
  shells out to a bare `go` when reached from a Bazel-run go_test (e.g.
  //scripts:shell_scripts_test's TestTestScriptPrebuiltTestBinaryContract),
  where a farm masks host go/dolt to exit 127. Nothing on that path needs a
  cache directory.
- scripts/ci/fmt-check.sh: describe_gofmt() no longer calls a PATH `go`
  under Bazel. It now resolves BEADS_TEST_GO (the hermetic SDK go already
  wired into scripts/prlintmake:prlintmake_test's env) via TEST_SRCDIR, and
  skips the version-reporting arm entirely when that isn't set (e.g.
  scripts/repochecks:fmt_test), rather than ever touching a possibly-masked
  PATH `go`.
- Verified with a PATH stub (go/dolt scripts that log and exit 127) via
  `bazel --nohome_rc test --config=prcore //scripts/... //cmd/bd:bd_test
  --test_env=PATH=<stubdir>:/usr/bin:/bin:/usr/local/bin`: 26/26 targets
  pass, zero stub invocations logged.
- gen_proxied_shard_manifest.py / gen_embedded_cmd_shard_manifest.py:
  default --weights to duration now that the manifests' only remaining
  blocks are duration-packed (the legacy inits-packed blocks were deleted
  alongside the PR Risk fork/push jobs that read them). Previously the bare
  `--write` default (inits) silently clobbered the live block's duration
  header and repacked with the wrong cost model; --check couldn't see it.
  Added TestProxiedShardManifestBareWriteIsIdempotent and
  TestEmbeddedCmdShardManifestBareWriteIsIdempotent to pin a bare --write
  as a no-op against the committed files.
- cmd/bd/compact_gc_target_test.go: resolve the non-Bazel fallback fixture
  path from this file's own directory (runtime.Caller) instead of the test
  binary's working directory.
- Refresh stale comments in .github/workflows/bazel.yml,
  scripts/shard_manifest_test.go, scripts/pr_risk_bazel_coverage_test.go,
  and scripts/embedded_shard_count_test.go that still described the deleted
  legacy 20/15-shard blocks and their retired fork/push jobs in the present
  tense.
- Confirmed cmd/bd/BUILD.bazel's compact_gc_fixture go_binary (implicit
  pure/race defaults) still passes TestRunCompactDoltTargetsOnlyAuthorizedActiveDatabase
  under `bazel test //cmd/bd:bd_test`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-10 19:24:21 +00:00
Julian Knutsen
c4e667cb14
feat(http): list/show counts/dep tree/ping over http, the advertised external-dependency policy, one-lookup not-found (S6b/S6c/S6d) (#7471)
* feat(http): serve list/show counts/dep tree/ping, close+reopen under a session, one-lookup not-found (S6b/S6c/S6d)

S6c. The external-dependency decorator rebuilt its role views from the
legacy DoltStorage seam (storereader over itself, IsBlocked,
GetDependencyTree, ClaimReadyIssue), which a remote store only partly
serves: `bd list`/`bd children` refused on the SearchIssuesWithCounts stub,
`bd show --json` printed zero counts, the default `bd dep tree` refused,
`bd ready --claim` and `bd close` of an externally blocked issue reached
unsupported paths. For a storage.RemoteBackendStore each view now passes the
inner role through and lays the policy over it in role terms
(externaldeps/remote_roles.go): ready reads and the ready claim exclude the
workspace-wide blocked set over a widened window; per-issue checks (claim,
close, batch close, list annotations, tree leaves) read only the named
issues' edges through EdgeReader instead of every edge in the workspace. A
server advertising policy.external_dependencies (MC's does) gets a plain
passthrough. `bd ping` uses a new storage.Pinger, which the http store
answers with its authenticated context read.

S6d. A store reporting storage.CallerAttributionLimitedStore (http) cannot
carry a Provenance label or a patch's closed_by_session. The library still
refuses both; the CLI omits them where nothing is lost: `bd reopen`'s fixed
"bd: reopen <id>" label (the server labels the same entry), and the
closed_by_session of `bd update -s closed` (attribution only, usually the
ambient CLAUDE_SESSION_ID; an explicit --session prints a notice; `bd close`
still records it). See cmd/bd/remote_backend.go.

S6b. utils.ExactIDLookupStore: the resolver stops at exact lookups for a
store with no substring search, so a missing prefixed id is a not-found
(beadserrors.ErrNotFound, "no issue found matching") after one getIssue.
The general resolver no longer repeats an identical normalized probe. The
http SearchIssueIDs answers D11's partial-id refusal, which now unwraps to
ErrNotFound. Contributor auto-routing for a remote workspace reads local
config only, so the not-found fallback pays no settings round trip.
`bd update <absent> --claim` (gc's hook claim) answers a gc-classifiable
not-found in at most two requests.

Served e2e (backend/http/e2e_remote_roles_test.go): every gc list shape and
`bd children` against embedded, `show --json` count parity, default dep
tree parity, external blocking still enforced, close/reopen under
CLAUDE_SESSION_ID, missing-id request counts, absent-id claim against the
current server and the MC handshake mask, policy passthrough under the MC
mask, ping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(externaldeps): role-level remote reader and claimer cases

bd ready and bd update --claim reach the policy through the legacy seam and
the lifecycle guard, so the remote Reader.Ready exclusion and the remote
Claimer guard (what bd serve and library callers reach) are pinned at the
role level with a fake remote store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(http): bd serve advertises policy.external_dependencies; clients pass through

bd serve composes every ready, claim, claim-next, close, blocking and tree
role through the external-dependency policy, but never said so. Every
client therefore ran the policy a second time, with the CLIENT machine's
external-project config, and claim-next became a non-atomic read-then-claim
loop on the client.

The server now advertises the token exactly when the roles it serves were
composed through the policy: httpapi.Config.ExternalDependencyPolicy, which
bd serve derives from its actual chain (externaldeps.Applied for the store
arm, externaldeps.AppliedToProvider for the provider arm). A server handed
raw roles still withholds it, so the token stays truthful.

Against a server that advertises it, every remote role view hands the
request to the server's own role untouched: no client validation, no edge
reads, claim-next is the server's one atomic call, and the ready count is
the server's countReadyWork (new remoteReadyCounter). The client-side
policy remains only for servers that do not advertise the token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(create): default created_by to the request's actor in the create role

created_by was stamped in two front doors and never in the library: the
CLI (creationActorStamp, with a remote-workspace special case) and the
three httpapi create handlers. A library caller of Lifecycle.Create or
BatchCreator with an empty CreatedBy stored "" locally and the actor over
http.

PreparePublicCreateRequest, which every create shape prepares through
(Lifecycle.Create, BatchCreator items, batch-apply create items), now
defaults an empty CreatedBy to request.Actor; an explicit value is kept.
The handlers no longer stamp, `bd create` and the state event create pass
only the actor, and creationActorStamp/isRemoteBackendWorkspace are gone.

The CLI sites that still create through the raw CreateIssue seam (swarm,
todo, gate, the create form) keep stamping currentActor(): that seam is
shared with import, where defaulting would re-attribute imported rows, and
the http store refuses it anyway, so the remote special case was never
reachable there.

Conformance: the lifecycle-create, batch-creator and batch-apply contracts
now pin created_by == actor for an item that names none, on every leg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(httpclient): GetIssue answers a miss with storage.ErrNotFound, like the local stores

The http store's raw GetIssue answered a missing id with (nil, nil), where
DoltStore and the embedded store return a wrapped storage.ErrNotFound. A
caller written against the backend contract read the http miss as a hit:
`bd create --graph` refused every explicit-id plan over http (patched in
cmd/bd on feat/http-mc-corpus; that workaround is reverted there).

GetIssue now returns the miss (and the empty id) as storage.ErrNotFound,
spelled as issueops.GetIssueInTx spells it. GetLabels, which reads through
GetIssue, keeps the local read's "no labels" answer for a missing id; the
`bd list --parent` walk reads the typed miss as "parent issue not found".

The served bridge test now holds the local reference store and the http
store to the same miss: ErrNotFound with the same text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(createbatchequiv): re-record the apply golden for the created_by default

c2866ea7fe made the create role default an empty CreatedBy to the
request's actor, so every create item of the apply scenario's batch
(actor "apply-writer") now stores created_by "apply-writer" instead of "".
TestCreateBatchFastPathsMatchPerRow_*/apply compared the stored rows to a
digest recorded before that change and failed on exactly the three tables
the column reaches: issues and wisps (the row) and events (the update
event's old-value snapshot). Fast and per-row bodies still agree; the
batch-apply conformance contract pins the same value.

Bisected with bazel: passes at be92efe40f's integ twin 696f7acc8e, fails
from the created_by commit on. Only apply.json's three digests move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style: gofmt ledger.go and the externaldeps remote-roles test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cmd/bd): bd create reads routing settings local-only on a remote backend too

determineAutoRoutedRepoPath skipped a remote backend's settings document
(routing targets are local paths that one shared document cannot name for
every client), but getRoutingConfigValue, which `bd create` and
migrate-personal read routing.* and contributor.* through, still asked it.
The same workspace could route a create one way and a lookup another, and
every create paid a settings round trip per key.

Both now go through routingSettingsStore: nil for a remote backend, so
routing comes from config.yaml / the environment only there, and a local
store is still consulted. A unit test holds both reads to the rule with a
store that counts settings reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(cmd/bd): say so when update -s closed drops an ambient CLAUDE_SESSION_ID

Over http `bd update -s closed` cannot carry closed_by_session, so the CLI
drops it rather than refusing the close. An explicit --session printed a
notice; the ambient CLAUDE_SESSION_ID every agent under Claude Code exports
was dropped without a word, a silent data difference from a local backend
(the served corpus's mc-update-meta-status-closed). The drop is now named
on stderr in both cases, once per command, pointing at `bd close`, whose
wire operation records the session. The served e2e asserts the notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http): hold bd list --limit 2 to each side's own unlimited order

TestE2E_ListWithGCFiltersMatchesEmbedded compared the --limit 2 rows of
the served and embedded workspaces as sets. The seed has four P2 rows, so
the limit cuts a priority tie whose created_at order differs between two
workspaces seeded seconds apart: a test-only flake, the order itself being
total. Each side's two rows must now be, in order, the first two of that
same side's --limit 0 listing; the unlimited listings are still compared
across sides by the shape loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: unit-tier pins for the created_by default, the policy token and the GetIssue miss

Three review mutations were caught only by a heavier tier (the uow
conformance legs, the served httpclient tier) or by one package's test
alone. Each now has a unit test where its rule lives:

- issueops: PreparePublicCreateRequest defaults an empty CreatedBy to the
  actor and keeps an explicit one, without mutating the caller's request.
- externaldeps: the policy layer AppliedToProvider finds becomes the
  handshake's policy.external_dependencies through httpapi.Listen, the
  composition bd serve performs, and a raw provider's handshake lacks it.
- httpclient (no embedded engine): GetIssue over the real wire client
  against a stub server answers a 404 not_found, and the empty id without
  dialing, as storage.ErrNotFound spelled like the local stores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): S6b/c/d entries match the code

The S6 entry still said `bd create` suppresses created_by on a remote
workspace and that the external-dependency policy runs client-side. Since
S6b/c/d, created_by defaults to the actor in the library on every backend,
and every bd serve composed through the policy advertises
policy.external_dependencies, so clients pass those operations through;
the client-side policy (now in role terms) runs only against a server that
does not advertise it.

New entries: the advertised policy token, bd ping over http, the created_by
library default, closed_by_session dropped by an http `bd update -s closed`
(with a notice, typed or ambient), reopen without a Provenance label over
http, local-only routing.* / contributor.* on a remote backend, GetIssue's
miss as storage.ErrNotFound, and list/children/show counts/dep tree over
http.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(externaldeps): keep S6's list --ready, --claim-next refusal and lost-race error on the S6c composition

The re-adopted S6 head (#7288) carries the review fixup's remote role
composition; S6c replaces it with its own (rolesAreRemote, the widened
ready window, the policy passthrough). Two behaviours S6 shipped and its
reviews pinned would otherwise go:

- bd close --claim-next against a server that does not apply the policy
  is refused whole, before anything is read or closed, with "the served
  batch close cannot carry a next claim, so nothing was closed; close
  without --claim-next, then run `bd ready --claim`". S6c passed the batch
  to the http closer, whose W-CloseBatchRequest.ClaimNext refusal drops the
  remedy, so TestE2E_BDOverHTTP's two refuseClaimNext steps went red. A
  request invalid on every backend is still ErrValidation first, and a
  server that applies the policy still gets the request untouched.
- remoteReadyClaimer.ClaimNext reports a page on which every candidate was
  lost to another actor as "claim ready: lost N races ...", not as the
  empty answer that means there is no work.

- `bd list --ready` (List with ReadyFlag) is answered by the policy
  store's own reader over the served ready reads, as S6 does. S6c passed
  it to the served listing, which cannot carry ReadyFlag (httpclient
  ledger row E-ListRequest.ReadyFlag), so it exited 1 over http with or
  without external refs; TestE2E_BDOverHTTP and
  TestServedRolesKeepTheExternalDependencyPolicy were red on it.
  TestRemoteReaderAnswersAReadyListingWithoutTheWireFlag pins it, with the
  fake's served List refusing ReadyFlag as the wire does.

S6's composition tests now run against S6c as remote_roles_composition_test.go.
Their fake serves Ready the way a server does (the S6 composition read
ready work through the legacy policy reader instead), and two call logs
gain that Ready. TestRemoteBatchCloserRefusesANextClaim,
TestRemoteBatchCloserValidatesANextClaimFirst and
TestRemoteReadyClaimerReportsLostRaces were red on S6c before this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(externaldeps): unassigned claim-next and fail-closed close reads

Review fixes for the S6c composition against a server that does not
advertise policy.external_dependencies: the two majors of review
attempt 1, plus the minors on the same code.

- ReadyClaimer: the composed claim-next reads only open, unassigned
  ready rows (Unassigned=true, Assignee cleared), the candidates the
  local ClaimReadyIssueInTx selects. A row another actor holds, or one
  already assigned to the caller, is no longer taken or counted as a
  lost race. Each pass reads 25 candidates past the blocked rows, as
  httpclient's composed claim does, and a full window lost end to end
  is read once more: claimed rows leave the unassigned set. Only a
  claim that tried candidates and won none is an error.
- BatchCloser: an externally blocked item travels to the server only
  when its status read finds it closed or not found (liveRefusal). Any
  other read error is that item's outcome, so a transient or auth
  failure no longer forwards a refused close to a server that will not
  refuse it.
- TreeWalker: a failed capability probe renders the external leaves
  over the walked tree instead of failing a walk the server already
  answered. appendTreeExternalReferences skips an id the tree holds,
  so an enforcing server's own leaves are not doubled.
- remoteEdges names each anchor once and skips an empty one, which the
  http EdgeReader refuses with ErrValidation.

The composition fakes now honor Unassigned/Assignee as
workapi.BuildReadyFilter does, model a rival claim landing first and a
failing GetIssue, and refuse an empty edge anchor as httpclient does.
New: TestRemoteReadyClaimerTakesOnlyUnassignedWork,
TestRemoteReadyClaimerWalksAContendedFront,
TestRemoteBatchCloserAnswersAFailedReadWithIt,
TestRemoteEdgesNamesEachAnchorOnce, and the probe-failure cases of
TestRemoteTreeWalkerAddsExternalLeaves. Each is red with its fix
reverted.

From review attempt 2, three nearby cleanups:

- TestServedRolesKeepTheExternalDependencyPolicy seeds open rows held
  by another actor and by the claimant ahead of the free work, then
  claims with and without an assignee filter. The unassigned-only claim
  is now pinned over a real served server, not only through the fakes:
  red with the pre-fixup remote_roles.go, with filter.Unassigned
  dropped, and (the filtered claim) with an explicit assignee honored.
- The capabilities description in openapi.v0.yaml (and the regenerated
  types.gen.go comment) no longer calls the whole list build-level:
  policy.external_dependencies depends on how the server composed its
  roles, as the paragraph above it says.
- createbatchequiv's golden note names
  issueops.PreparePublicCreateRequest instead of a commit id that is
  not on this branch.

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(backend/http): count a not_found read as reaching the remote in #7469's credential doors

main's #7469 added TestExplicitCredentialIgnoresTheEnvPlaintextGrant. Its
OpenWith and Open doors read bd-1 from plaintextRemote, which answers
every issue read not_found, and the granted leg needs that read to return
a nil error. That held while the http client answered a miss with
(nil, nil). This branch's "fix(httpclient): GetIssue answers a miss with
storage.ErrNotFound, like the local stores" makes the same read return
storage.ErrNotFound. So on main plus this branch both doors fail at
per_open_credential_test.go:392 ("with Target.AllowInsecureCredential:
not found: issue bd-1") under plain go test. The merge is textually
clean, so only a build of the merge shows it.

The two store doors now count storage.ErrNotFound as success, since that
answer came off the wire. The assertions are unchanged. The refused leg
still needs the "refusing to send a credential" error and no request on
the transport. The granted leg still needs exactly one request carrying
"Bearer explicit-token": a granted read that never reaches the wire still
fails at :408.

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>
2026-10-10 18:11:56 +00:00
Julian Knutsen
b8e6ba1791
fix(bazel): one nogo-validating lane per race configuration (F5 S1) (#7479)
* fix(bazel): one nogo-validating lane per race configuration (F5 S1)

The race configuration (--@rules_go//go/config:race) is built by five
lanes that duplicate the same RunNogo/ValidateNogo work: bazel-test
(--config=ci), bazel-embedded, bazel-doltserver, bazel-proxied, and
the advisory bazel-dolt-race shadow, plus the package-mcp/package-npm
gates' explicit race build. --norun_validations is a build-request
option, not a configuration flag (proven here by aquery: GoCompilePkg/
GoLink/RunNogo/ValidateNogo action keys are byte-identical with and
without it), so passing it on every lane but bazel-test removes the
duplicate work without touching a single action key or dropping any
lint coverage: bazel-test's --config=ci already validates every file
any of the others compiles.

scripts/nogo_lint_policy_test.go replaces the old blanket
"--norun_validations never appears in .bazelrc" check with
TestNogoConfigurationsHaveOneValidatingLane (T1: one owner per
configuration fingerprint), TestNogoOwnersAreRequired (T2: the owner
is a required CI Gate check whose `if:` covers every non-owner's),
TestNogoRaceOwnerBuildsEverything (T3: the owner builds //... whole,
no exclusions) and TestNoUnconditionalValidationOff (T5: nothing else
may disable validation). tools/bazel/nogo_ownership.py (make
nogo-ownership) is a dynamic, advisory aquery cross-check of the same
property, run on demand rather than from inside a Bazel action.

Verified locally: aquery shows identical action keys for the affected
lanes with/without --norun_validations; a planted printf-format vet
finding in internal/idgen/hash.go failed the owner build and passed
the non-owner build (then reverted, never committed);
scripts/bazel_dolt_race_shadow_test.go and the full //scripts suite
stay green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): close S1 nogo-ownership review gaps (allowlist, owner pin, real aquery)

Addresses maintainer-city-c3's review of #7479:

1. T6 TestRunValidationsOnlyOnAllowlistedLines replaces the coverage gap
   left when main's blanket run_validations ban was dropped: only the four
   race-group non-owners' "test:<cfg> --norun_validations" lines in
   .bazelrc, and the two package-gate bazel-build steps in bazel.yml, are
   permitted. A later test:integration/doltserver-cmd --norun_validations
   (out of T1's table, S2) now fails here instead of landing silently.
   Verified by mutation: adding test:integration --norun_validations fails
   the new test; reverting passes.

3. TestNogoRaceOwnerBuildsEverything (T3) now also pins that the race
   owner's "bazel test //... --config=ci" step has no step-level if: or
   continue-on-error, and that its job has none either. Verified by
   mutation: adding if: ${{ always() }} to that step fails; reverting
   passes.

2. tools/bazel/nogo_ownership.py's aquery comparison was querying the
   identical mnemonic("RunNogo", //...) for the owner and every non-owner,
   so `missing` could never be non-empty. It now derives each non-owner's
   actual built target set the way --build_tests_only + --test_tag_filters
   does: the deps closure of tests(//...) filtered to targets carrying one
   of the lane's tags, read exactly from `query --output=xml` (not attr()'s
   substring regex match, which would wrongly fold "dolt-server-proxied"
   and "dolt-server-cmd" into a "dolt-server" filter). Confirmed against a
   real (offline, --nohome_rc) bazel run: reports OK at head, and reports
   100+ missing targets when the owner's query is artificially narrowed to
   a subpackage -- it can now actually fail.

Also: refreshed a stale .bazelrc comment claiming nogo runs beside every
lane's compile, which S1 made untrue for race-group non-owners.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 18:05:17 +00:00
Julian Knutsen
c1ccb728ec
ci(bazel): mode-cache readers use the remote repo contents cache via rbe-cache (#7476)
* ci(bazel): mode cache reads the remote repo contents cache through rbe-cache

Mode cache (fork and Dependabot PRs while rbe-fork is closed, rbe=cache
dispatches) now reads Bazel's remote repo contents cache: the trees rrc-seed
writes on main pushes, served by rbe-cache's anonymous GetActionResult and
ByteStream.Read (Caddy :8443 -> nativelink-anon -> AC_OSS, read only).
setup-bazel's write-bazelrc.sh adds the trusted readers' two lines to its
fork-cache rc (passed with --bazelrc, so the startup line applies):

  startup --experimental_remote_repo_contents_cache
  common --loading_phase_threads=64

The committed .bazelrc stays untouched (design R2): the flag is a startup
option and cannot live in build:fork-cache, and developer and macOS
machines never read.

Gated on the new .github/actions/setup-bazel/cache-rrc-probe.sh (a copy of
gascity's tools/rbe/cache-rrc-probe.sh): one GetCapabilities to rbe-cache
(connect 3s, total 5s). Only an answer (gRPC 0, cache_capabilities present)
writes the lines; anything else writes none and logs a ::notice:: with the
reason, and the script never fails on it. Kill switch: fork_rrc_read=on in
that script; set it to off in a one-line PR to stop mode cache reading.

Measured (scratch origin/main, no credentials, 8 CPUs, cold output base,
`build --nobuild //...`): repository rules 665-672 -> 38-41 (the rest are
bd_releases/dolt_release and local or toolchain repos, not reproducible),
analysis 26.5-26.7s -> 12.1-14.8s, wall about 36s -> 25-32s.

Tests: TestSetupBazelRCWriter runs the writer against a stand-in rbe-cache
(answers, answers with zstd, PERMISSION_DENIED, refused): exactly the
reader's lines after --config=fork-cache and any zstd line only when it
answers, a notice otherwise; remote-exec and rbe-fork never get them nor
probe. TestBazelCacheModeReachesTheRC checks no simulated mode carries them
with the probe refused. TestCacheRRCProbe runs the real probe (errors,
malformed, timeout, refused, untrusted cert, kill switch off without a
request).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): mode cache rrc review fixes: reader opt-in, containment, AC probe

Scope. write-bazelrc.sh enabled the remote repo contents cache for every
mode cache job, bazel-release-cross included, whose configs
rrc-lane-commands.txt does not seed. setup-bazel now takes BAZEL_RRC_READ
("true" or empty, anything else fails): only with it does mode cache probe
rbe-cache and add the reader's lines. The 8 trusted reader jobs pass it,
and nothing else. TestBazelRRCOptInMirrorsTheTrustedReaders pins that set
to bazelRRCReadLanes; TestBazelRRCLaneCommandsCoverEveryReader now checks
every job that enables the flag either way (reader step or opt-in) is a
reading lane whose bazel configs are all seeded. TestSetupBazelRCWriter
covers a job without the opt-in (no probe, no lines) and bad values.

Runner. The 5 readers that run in mode cache (test, pure, integration,
doltserver, cmd-dolt) fall back to ubuntu-24.04 instead of ubuntu-latest:
one runs-on line each; mode remote stays Blacksmith, and the remote-only
readers and every other job are unchanged.

Visibility. write-bazelrc.sh writes one step-summary line in mode cache:
whether the job reads, and why (the probe's reason, with rbe-cache's
GetCapabilities TCP connect time, DNS excluded).

Probe. cache-rrc-probe.sh is re-copied from gascity: it also asks
GetActionResult for a fixed key no action has and a ByteStream Read of
that digest as a blob, and passes only if both answer NOT_FOUND (gRPC 5),
proving Caddy, nativelink-anon, the action cache and the CAS answer; it
reports the TCP connect time minus the DNS lookup. serveCapabilities
answers both; TestCacheRRCProbe adds their failure answers.

Containment and limits. The rrc-verify issue body and
CI_REQUIRED_CHECK_TOPOLOGY.md no longer say to set RBE_REPO_CONTENTS_CACHE
off (mode cache never sees it, and off also stops rrc-verify): commit
fork_rrc_read=off in both probe scripts (beads has no fresh-merge, so an
open fork PR keeps its old switch until it is pushed again); for immediate
server-side containment, rbe-cache-gate close on core; and, because the
mode remote readers read the same oss action cache entries, set the
variable to seed on a mismatch (no lane reads, rrc-seed and
rrc-verify keep running), off only to stop seeding too, and leave it as
it is when the run only could not check. The doc also says a
closed or down cache only falls back at probe time (after loading, files
are fetched lazily and losing rbe-cache fails the command, bazel#30218),
and notes the 512 MiB anonymous CAS limit under gascity's R4.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): bazel-dolt-race opts in to the rrc read like the other trusted readers

#7464 added bazel-dolt-race as a trusted reader after this branch was cut, so
TestBazelRRCOptInMirrorsTheTrustedReaders now covers it: pass BAZEL_RRC_READ
(it runs only in mode remote, so this changes nothing today). It never runs in
mode cache, so it keeps the lanes' ubuntu-latest fallback: the cache-reader
runner rule (ubuntu-24.04) excludes it.

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-10 17:42:12 +00:00
Julian Knutsen
1b7bf9b191
fix(cmd/bd): guarded close/update/assign that lose to a delete at pre-flight report precondition_failed (#7465)
* fix(cmd/bd): guarded close/update/assign that lose to a delete at pre-flight report precondition_failed

A --if-revision close, update or assign racing a `bd delete` can observe
the winning delete at two points: inside its guarded write (classified
precondition_failed / exit 13 via classifyIfRevisionFailure's
storage.ErrNotFound branch) or at its pre-flight resolution
(resolveAndGetIssueForMutation on the direct route, the advisory pre-read
on the proxied update/assign routes), which returned an unclassified
"no issue found matching" exit 1. Which one a loser hits depends only on
whether the delete commits before or after it resolves the id, so
TestSharedServerDeleteIfRevisionSingleWinner/delete_vs_close and
delete_vs_update flaked under load. mc-zndi7.81 (#7256) closed the same
gap for delete's own pre-flight only.

reportIfRevisionTargetGone now maps a pre-flight not-found under an active
--if-revision guard to the guard envelope on every verb and route (delete
refactored onto it); unguarded commands keep their not-found exit 1.

Fixes ga-vnycm2.10.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(cmd/bd): name the proxied target-gone test into the proxied lane's TestProxiedServer* prefix

TestProxiedIfRevisionTargetGoneIsPreconditionFailed skips unless
BEADS_TEST_PROXIED_SERVER=1, which only the proxied lane sets, and that
lane selects TestProxiedServer*/TestServerMode* by name: as named it ran in
no CI lane (ga-vnycm2.43). Renamed and placed in the 34-shard manifest block.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(cmd/bd): classify pre-flight-gone reopen and cascade-delete targets

Review fixes for #7465, review-loop iteration 1.

The PR makes a guarded write whose pre-flight resolution finds the row
already deleted report precondition_failed (exit 13) on close, update and
assign, and documents that rule for every guarded verb. Two guarded paths
still turned the lost delete race into an unclassified exit 1:

- `bd reopen --if-revision`, on both routes. The direct loop's
  resolveAndGetIssueForMutation failure and the proxied
  reopenProxiedResolve pre-read now go through reportIfRevisionTargetGone,
  as the other verbs do. The proxied caller returns the already-reported
  exit error unchanged (isReportedExit), so the outcome prints once.
- `bd delete --cascade --if-revision` on the direct route. deleteBatch
  built its missing-id error with fmt.Errorf("issues not found: ..."),
  which carries no sentinel, so the caller's reportIfRevisionFailure could
  not classify it. It now returns issueops.NotFoundError, the error the
  delete role's own existence probe returns (delete_role.go). The text is
  identical, and the error unwraps to storage.ErrNotFound. This reuses the
  existing typed error instead of adding a guarded-only wrap.

ifRevisionFlagHelp's comment and reportIfRevisionTargetGone's doc now name
all five guarded verbs and the cascade path.

Tests:

- Rename TestIfRevisionPreflightGoneIsPreconditionFailedOnEveryVerb to
  TestEmbeddedIfRevisionPreflightGoneIsPreconditionFailedOnEveryVerb. The
  embedded lane only discovers `func TestEmbedded*`
  (.github/scripts/embedded-test-shard.sh), so under the old name it
  skipped in every CI lane. It is added to embedded-cmd-test-shards.txt
  (100 65), and the manifest generator's --check passes at 100.
- The embedded table and its proxied twin,
  TestProxiedServerIfRevisionTargetGoneIsPreconditionFailed, gain reopen,
  delete and delete_cascade rows. The embedded table also gains an
  unguarded cascade-delete row that pins the unchanged "issues not found:
  <id>" text at exit 1. The deterministic cascade case lives in this
  CI-run table rather than in TestIfRevisionCascadeDelete, which the
  embedded lane does not discover; that test's doc points here.
- The proxied table now asserts that no raw "not found" text leaks past
  the guard envelope. A new unguarded_assign_still_not_found subtest pins
  the proxied assign pre-read's unguarded wording and exit 1.

Each code fix was mutation-checked. Reverting reopen.go,
reopen_proxied_server.go or delete.go to the PR head fails exactly one
row of its table (embedded reopen, proxied reopen and embedded
delete_cascade respectively), and every other row still passes. The fixed
build passes both full tables locally, the proxied one against a local
dolt 2.2.0 sql-server. A manual --json smoke of the direct reopen and
cascade-delete paths exits 13 with the standard precondition_failed body,
expected_revision included.

PR body corrections for finalize (description only, no code):
- The rule now covers five verbs (delete, close, update, assign, reopen)
  plus delete --cascade, not four.
- The embedded test is now
  TestEmbeddedIfRevisionPreflightGoneIsPreconditionFailedOnEveryVerb.
- The proxied test is
  TestProxiedServerIfRevisionTargetGoneIsPreconditionFailed (renamed in
  009b9b629b), and it runs in //cmd/bd:bd_proxied_test shard 7 of 34. The
  coverage-gap note's "(the new test included)" no longer applies to 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>
2026-10-10 16:33:19 +00:00
Julian Knutsen
a945619b5e
fix(bazel): re-vendor the BEP test-timing clamp from gascity (extractor 1.1.1) (#7477)
#7374 re-vendored gascity's signed-duration fix for exec-log spawns, but
build_tests() still kept the sign of BEP testResult timings. rbe-west
scheduler/worker clock skew makes a remotely executed test report
queueTime -1 ms (-24 ms at worst), and the collector rejected the whole
artifact on tests[].results[].queue_ms: about 19% of beads artifacts,
holding 52% of beads' CI worker time.

Byte copy of gascity 2ddde0d94be15d95086cc2bcb169303ea1243456: clamp
duration_ms and every timingBreakdown child with _clamp_duration_ms.
Updates the two sha256 pins; testdata/ci_analytics is unchanged.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 16:20:37 +00:00
Julian Knutsen
6c1848a77e
feat(backend/http): per-open credential is the only credential (S6f) (#7469)
* feat(backend/http): per-open credential is the only credential (S6f)

One process may open several beads HTTP projects, on one server or many,
each with its own credential (gc G7: per-city/per-rig credentials). The
ambient ladder is keyed by host[:port] and read from process-global env,
so two projects behind one host would share a token.

- bdhttp.Options gains Credential (CredentialProvider). Open, Handshake
  and Connect with it set go through the new httpclient.DialWithCredential
  / HandshakeWithCredential: no bearer ladder (BEADS_HTTP_TOKEN,
  BEADS_HTTP_TOKEN_COMMAND, credentials file), CA pinned to Target.CAFile
  (never BEADS_HTTP_CA_FILE), and the plaintext grant only from
  Target/DialOptions (never BEADS_HTTP_ALLOW_INSECURE).
- httpclient.OpenWith takes the same explicit path for a
  ProvidedCredential in backends.OpenOptions.
- Register panics on a non-nil Options.Credential: its dialer is
  process-wide.
- All package env reads go through one getenv seam so a test can prove
  the explicit door reads none. No process-wide credential cache exists;
  the provider lives on the store's own wire client.
- Package doc gains a "Credentials: one per open, never one per host"
  section.

Tests: two stores on one host (direct door and registry OpenWith) each
send their own token; explicit credential overrides poisoned ambient
token/command/credentials file; explicit open and handshake survive a
broken ambient env; Handshake with a Credential; getenv spy sees no reads
on the explicit door; Register refuses a credential.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(httpclient): S6f review fixups for the explicit door's plaintext refusal

Apply the two minor findings and two nits from the review of #7469:

- The explicit-credential door (DialWithCredential: OpenWith with a
  ProvidedCredential, and backend/http's Open and Handshake with
  Options.Credential) never reads BEADS_HTTP_ALLOW_INSECURE, but its
  plaintext refusal still said to set it. That refusal now names
  Target.AllowInsecureCredential (what `bd connect --allow-plaintext`
  records) and says an explicit credential takes no plaintext grant from
  the environment. The ambient ladder's refusal is unchanged.
- Pin that property at each production door. Every explicit-door test
  dialed loopback, where the guard returns before it reads the variable,
  so a door reverted to the env-consulting DialWith left them all green.
  TestExplicitCredentialIgnoresTheEnvPlaintextGrant drives OpenWith, Open
  and Handshake against a plain-http, non-loopback stand-in with
  BEADS_HTTP_ALLOW_INSECURE=1: each refuses before the wire and names the
  grant it honors, each sends its token once with
  Target.AllowInsecureCredential, and an ambient control shows the same
  environment does grant the built-in ladder. Reverting any one door to
  DialWith now fails that door's subtest, and the guard unit test checks
  the refusal text.
- Narrow the "reads no environment" docs to what holds: getenv is the
  reader for the variables that choose or grant a credential, and the
  explicit door reads none of them. The proxy variables, and on !unix with
  a CA file BEADS_ALLOW_INSECURE_CA_FILE_PERMISSIONS, are still read on
  every door; neither chooses a credential or grants plaintext.
- TestExplicitCredentialReadsNoEnvironment checked GetMetadata's error,
  which is nil on a failed handshake; it now checks the project id.

Behaviour change against main: OpenWith with a ProvidedCredential to a
plain-http, non-loopback server is refused even with
BEADS_HTTP_ALLOW_INSECURE=1, which main honored there. Grant it per
target with Target.AllowInsecureCredential (`bd connect --allow-plaintext`
records it in the workspace sidecar).

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>
2026-10-10 15:16:14 +00:00
Julian Knutsen
3b0aa1be58
ci(bazel): run every BEADS_TEST_PROXIED_SERVER-gated cmd/bd test in the proxied lane (+ guard) (#7468)
* ci(bazel): run every BEADS_TEST_PROXIED_SERVER-gated cmd/bd test in the proxied lane

proxied-test-shard.sh selects the proxied lane's tests by name prefix
(TestProxiedServer*/TestServerMode*), and BEADS_TEST_PROXIED_SERVER=1 is set
only by //cmd/bd:bd_proxied_test. Seven cmd/bd tests skip without that
variable but are named outside the prefix, so they ran in no CI lane:

  TestProxiedDeleteIfRevisionSingleWinner
  TestProxiedIfRevision{CloseMismatchRefuses,CloseReplaysMoleculeAutoClose,
    CloseWarnsOnForcedOpenChildren,DeleteMatchAndMismatch,
    OutranksReassignFence}
  TestHistoryRemoteSupportedDirectAndProxiedParity

Rename them into the TestProxiedServer* prefix (the repo's existing
convention, see if_revision_proxied_integration_test.go) and place them
incrementally in the 34-shard manifest block. The prefix stays the
selection rather than widening to TestProxied*, which would pull ~33
ungated unit tests into the lane as duplicates.

Running them exposed real rot: the history parity test had been broken
since #7436 scoped shared-server projects to a per-database user, because
its `bd dolt remote remove` needs DOLT_REMOTE. It now uses
newSharedProxiedRootProject, like the other remote-removing tests #7436
moved.

Guard: TestProxiedGatedTestsRunInTheProxiedLane (//scripts:
go_test_sources_test) walks cmd/bd's test call graph for any top-level test
that reaches an `os.Getenv("BEADS_TEST_PROXIED_SERVER") != "1"` gate and
fails unless proxied-test-shard.sh lists it in some shard;
TestProxiedGatedTestsDetector pins the walk against a fixture.

Fixes ga-vnycm2.43.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(scripts): indent the gated-test detector's fixture so equivalence.py does not count it

tools/bazel/equivalence.py finds a package's tests with a line-anchored
^func TestX(t *testing.T) scan, so the fixture's TestDirect..TestUngated
read as scripts tests Bazel never ran (EQUIVALENCE: FAIL on Bazel / test).

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-10 13:51:34 +00:00
gascityinc-randy[bot]
fb09d9f3e4
fix(beads-mcp): bump pyjwt to 2.15.1 and urllib3 to 2.8.0 for security advisories (#7466)
Lockfile-only update via uv lock --upgrade-package. Resolves Dependabot
alerts #157-#173 (PyJWT and urllib3 advisories).

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 12:36:14 +00:00
gascityinc-randy[bot]
2917fa8579
fix(examples): bump grpc to 1.83.2 and thrift to 0.24.0 in example modules (#7467)
The example modules replace github.com/steveyegge/beads with ../.. but
their go.mod files had drifted behind the root module, pinning
vulnerable grpc v1.83.0 and thrift v0.23.0. Bump both past their
advisories and re-tidy, which also aligns the remaining indirect
requirements with the versions the root module already selects.

Resolves Dependabot alerts #144, #145, #147, #148, #152, #153, #154, #155.

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 12:15:33 +00:00
Julian Knutsen
eb204363c9
ci(bazel): add advisory dolt-race shadow lane (item 5 phase 1) (#7464)
* ci(bazel): add advisory dolt-race shadow lane (item 5 phase 1)

Add --config=dolt-race, the union of --config=doltserver and
--config=doltserver-proxied with one tag filter for both tiers, and an
advisory bazel-dolt-race job that runs it beside bazel-doltserver and
bazel-proxied. The shadow measures one client per group of lanes against
the two lanes it would replace before any cutover (item 5 slice A1a).

The job runs in mode remote on pull_request and merge_group events only.
It has job-level continue-on-error, no job or workflow_call output, and no
gate names it, so it cannot change CI Gate or PR Risk Gate. Its
ci-analytics step is copied verbatim with LANE=dolt-race, and rrc seeds
the new config.

Policy tests pin the config as the exact union of its members' lines (tag
filter aside), the job's run modes and events, its advisory shape, the
analytics lane map and the rrc command list. aquery shows every member
target's TestRunner action (actionKey, argv, env, inputs, outputs) is
unchanged under the union config.

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(bazel): give the dolt-race shadow timeout headroom; fix gate-wait wording

Review follow-up on the advisory bazel-dolt-race job (maintainer-city-c3,
findings 1, 2 and 5):

- Raise the job's timeout-minutes from 30 to 35. continue-on-error covers
  a failed or timed-out step, but not a job GitHub cancels at its own
  timeout, which could make the bazel call non-success and turn CI Gate
  red. TestBazelDoltRaceShadowIsAdvisory now reads both timeouts from the
  workflow and requires job >= test step + 10 (and a step timeout at all).
- Correct the docs and comments: the shadow cannot fail the gate, but
  CI Gate still waits for it, because its needs on the bazel call
  completes only when every job in it has finished.
- Correct the checks comment: check_testcases covers every target in the
  union, including the dolt-server tier its own lane never checked.

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(bazel): bound every dolt-race shadow step; job timeout covers their sum

Review follow-up (S1): a hang in any bazel-dolt-race step without a
timeout would run into the job's own timeout, and a job GitHub cancels
there is not covered by continue-on-error. Every step now has a
timeout-minutes, and the job's timeout covers their sum:

- checkout 5, rrc read 1, setup-bazel 10, flaky query 5, checks 3 each,
  test-log upload 3. The test step (25) and the analytics steps (3, 2)
  keep bazel-proxied's values; bazel-proxied sets no timeout on the
  others, so these bound them.
- The step timeouts sum to 60 minutes, so the job timeout goes from 35 to
  65.
- TestBazelDoltRaceShadowIsAdvisory now requires a timeout on every step
  and job >= sum(step timeouts) + 5, read from the workflow, alongside the
  existing job >= test step + 10.

Also cite the farm maintainer's confirmation of NativeLink 1.7.1's
in-flight Execute dedupe in the job comment.

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(bazel): keep dolt-race shadow timeout under the merge queue's

Tighten the shadow's non-test step budgets so the job timeout (step sum
+ 5) is 55 minutes, and pin that it stays below the 60-minute merge
queue check timeout: CI Gate waits for the shadow, so a hung shadow
must not drop a group from the queue.

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-10 10:13:49 +00:00
Julian Knutsen
8dbbe78e9a
feat(backend/http): public HTTP backend door, OSS registration, and bd connect (S6) (#7288)
* feat(backend/http): add the public HTTP backend door, cmd/bd registration, and bd connect

internal/httpclient (S1-S5) had no production caller for the per-open
backends.OpenOptions.Credential seam and no way for a workspace to actually
select it. This slice (S6) closes both gaps in OSS's own idiom, without
carrying over anything from bd-enterprise's gateway/box-login/storage-profile
machinery:

- backend/http (bdhttp) is the public, out-of-tree extension door: Register
  adds "http" to the backend registry and installs its transport, Open/
  Handshake dial a server directly with no workspace on disk, and the
  registered OpenWith hook threads a per-call credential through
  beads.OpenBestAvailableWith for a multi-tenant embedder.
- internal/httpclient/open_with.go is the backends.Backend.OpenWith hook
  itself: a fresh dial per open (opts.Credential/HTTPClient/UserAgent),
  distinct from the process-wide registered dialer Open/OpenReadOnly use.
- cmd/bd/http_backend.go registers the backend for the OSS binary, so a
  workspace whose metadata.json names "http" opens through the ordinary
  OpenBestAvailable path; any other unregistered backend name still refuses.
- cmd/bd/connect.go adds the minimal `bd connect <url>` command: a handshake
  that must succeed before anything is written, a per-user activation
  sidecar (.beads/http_target.json, never git-tracked), a plaintext-to-
  non-loopback refusal without --allow-plaintext, and a backend-switch
  refusal without --force. No credential is ever accepted on the command
  line or written to disk.
- cmd/bd/doctor/gitignore.go requires the new http_target.json /
  http_local_metadata.json sidecars be git-ignored, the same way the
  proxied-server client info already is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): keep external-dependency blocking over http unless the server enforces it

bd ready / bd close / claim hard-failed against the new http backend with
"GetAllDependencyRecords not supported by the http backend": cmd/bd's
storage chain wraps every opened store in the externaldeps policy
decorator, which needs either the narrow ExternalDependencyQueryStore
interface or the broad GetAllDependencyRecords fallback to resolve
blocking state, and the http client implemented neither.

The decorator now stays on for a remote store. It is skipped only when the
server's handshake advertises policy.external_dependencies (the server
enforces the policy before answering). Without that capability the client
resolves blocking itself from the listing and chunked dependency reads, so
an issue with an unresolvable external: dependency stays out of bd ready
exactly as it does on a local backend; it is never silently skipped
(DESIGN 3.6). Server-side enforcement is slice S10.

storage.RemoteBackendStore marks a DoltStorage that is a pure network
client of a remote bd serve; the http backend's Store satisfies it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cmd/bd): suppress the CreatedBy stamp on create against a remote backend

bd create failed against the http backend with "Issue.CreatedBy: ... is not
expressible on the v0 wire": the http client's create role deliberately
refuses any POPULATED CreatedBy/CreatedAt (the creation stamp belongs to the
server's own journal entry, not a value the caller supplies), but
cmd/bd/create.go unconditionally stamped getActorWithGit() onto every
created issue regardless of backend. The refusal only fires on a non-zero
field, so suppressing the stamp for a registered remote backend is wire-
compatible by construction, not a workaround.

Add isRemoteBackendWorkspace()/creationActorStamp() to backend_support.go,
reusing the existing resolveCommandBeadsDir(dbPath) +
backendNameForErrorFraming(beadsDir) + backends.IsRemote(name) pattern
already used elsewhere in that file, and use creationActorStamp() at both
create.go call sites (the dry-run preview and the real create).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(backend/http): add an embedder linkage test over public packages only

Prove the one promise S6 makes to an out-of-tree embedder (gc is the
motivating case): importing nothing but github.com/steveyegge/beads,
.../backend, and .../backend/http is enough to register the http backend,
open a workspace through it with a per-call credential
(beads.OpenBestAvailableWith), and read through the role-accessor surface
(IssueReader().Ready) against a stand-in server — with no internal/...
import in the test file, which is itself the thing under test.

Written fresh for OSS beads S6; no bd-enterprise source copied.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs: document the HTTP backend, bd connect, and the public backend/http door

Add a README section with bd connect usage, the credential ladder, and the
plaintext/force refusals, plus a CHANGELOG entry for the new cmd/bd
registration, bd connect command, and the public backend/http package.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): address bee-ghosttrack review on #7288 (connect --clear restore, persisted --allow-plaintext)

Closes the CHANGES_REQUESTED items on the HTTP backend door PR:

- Must-fix: `bd connect --force` over a workspace with its own local
  (dolt) identity now has writes succeed instead of tripping "workspace
  identity mismatch detected" — validateWorkspaceIdentity (cmd/bd/main.go)
  and the sidecar (internal/httpclient/metadata.go) now compare against
  the http backend's own pinned project id. New e2e regression test
  TestE2E_ForceConnectWritesSucceedDespiteDifferingLocalProjectID
  (backend/http/e2e_cli_test.go), confirmed to fail without the fix.

- Should-fix 1: `bd connect --clear` now restores metadata.json's
  backend selection to whatever it was before this workspace connected,
  instead of leaving it pinned to "http" with no sidecar to dial.
  Target.PreviousBackend (internal/httpclient/target.go) is recorded by
  Attach (backend/http/attach.go) and round-tripped through the sidecar;
  connect.go reads it back on --clear. New tests in
  backend/http/attach_test.go and internal/httpclient/target_test.go.

- Should-fix 2: `bd connect --allow-plaintext` is now remembered in the
  sidecar (Target.AllowInsecureCredential), scoped to the target it was
  granted for, so every later ordinary command's dial honors the grant
  without also needing BEADS_HTTP_ALLOW_INSECURE=1 set
  (internal/httpclient/dial.go). Fixed BearerProvider.warnInsecure's
  wording (internal/httpclient/credential.go), which used to assert a
  token was being sent immediately above a refusal saying the opposite.
  New test TestDialWithWiresTargetAllowInsecureCredentialThroughToTheGuard.

- Should-fix 3: README no longer claims HTTP mode works "exactly as
  with a local database" — it lists what round-trips and points at the
  divergence ledger (engdocs/design/http-divergence-ledger.md) for what
  differs.

- Verified, no code change needed: Attach already handles an existing
  metadata.json project_id coherently (only cfg.Backend is touched); bd
  show's isNotFoundErr already matches a http 404 (issueops.ErrNotFound
  is storage.ErrNotFound, the same sentinel a local miss uses), so it
  reads as "not found" rather than an unsupported-operation error.

- Doc fix: guardInsecureCredential's doc comment and refusal message
  were stale against should-fix 2's own change — they named only
  DialOptions.AllowInsecureCredential and the env var as ways to get
  past the guard, not the newly-persisted target.AllowInsecureCredential
  or `bd connect --allow-plaintext` itself.

Gates run clean on this branch: go build/vet, go test over
internal/httpclient, backend/http (including the full e2e suite under
BEADS_TEST_EMBEDDED_DOLT=1) and cmd/bd, make api-check, make
ci-pr-lint, make bazel-sync-check, bazel run //:gazelle -- -mode=diff,
and internal/storage's TestEveryLegWiresEveryRoleContract.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(backend/http): give the e2e server the BatchGetter role #7248 added to the required set

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: exact http ready totals, connect capability row, doc corrections

Ready totals over http (review major). externaldeps drops externally
blocked rows client-side for a store that cannot express ExcludeIDs
(today httpclient.Store). dropBlockedIssuesWithCounts compacted the
fetched rows in place (`kept := rows[:0]`), and
readyWorkWithCountsAndTotal then re-scanned `rows` to count the blocked
rows it had dropped. By then the compaction had overwritten them, so
whenever a blocked row came back ahead of a kept one the re-scan
undercounted the drops: `bd ready --json`'s total and text-mode `bd
ready`'s count (CountReadyWork) overstated ready work against any server
that does not advertise policy.external_dependencies. Both drop helpers
now copy into a fresh slice, and dropBlockedIssuesWithCounts reports how
many rows it dropped, so nothing re-scans `rows`.

fakeStore gains an excludeIDsUnsupported switch that, like
httpclient.Store, refuses any ExcludeIDs. The new
TestReadyTotalsWhenStoreCannotExpressExcludeIDs puts the blocked issue
first and checks the page and total for an unlimited filter, a Limit
whose bumped window holds the whole set, and one the set outgrows, then
CountReadyWork. TestServedReadyExcludesUnsatisfiedExternalDependencyWithoutServerCapability
now also checks the total and count against a real in-process bd serve.
Against the previous decorator the unit test's unlimited case reports
total and count 3 beside a 2-row page, and the served test 2 beside a
1-row page.

Review minors, all wording:
- `bd connect --clear` pointed at `bd config set backend dolt`, which
  writes the database's config table rather than metadata.json and, in
  the state that prints the advice (metadata.json says http, sidecar
  gone), fails the pre-open identity check. It now says to reconnect, or
  to set "backend" in metadata.json.
- CHANGELOG described the superseded skip-at-wrap design; it now
  describes the always-wrap decorator with its capability probe and
  client-side drop.
- RemoteBackendStore's docs no longer name a consumer; nothing in-tree
  checks it.
- creationActorStamp's comment pointed at backend/http/lifecycle.go; the
  refusal lives in internal/httpclient/lifecycle.go.

Capability row. TestProxyCapabilityRegistryCoversCommandTree fails at
60b7128204: the command tree walk finds `connect`, which this PR adds,
with no row in cmd/bd/capability_registry.go ("1 command(s) have no
proxied-server capability row: connect"). The test predates the PR
(#6582 is an ancestor of its base) and passes at the base dabf20ef07.

connect opts out of store init (skipStoreAnnotation) and never reaches
the store factory, so it belongs in proxyPermittedPaths beside init and
setup. The row is runtime-neutral: validateProxyRegistryBeforeProvider
returns nil both for a permitted row and for a path with no row, so
this only records the policy decision the coverage test asks for.

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>

* docs(httpclient): regenerate the divergence ledger doc after the S5 rebase

The rebase onto feat/http-client-batch-apply's rebased head (S3/S4 merged to
main) left the ledger doc's summary line at a conflict-resolution placeholder
count. Regenerate it from internal/httpclient/encode.Ledger() so
TestDivergenceLedgerDocMatchesLedger passes against the merged ledger.go.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(backend/http): host-scope S6's test BEADS_HTTP_TOKEN values

Rebasing onto feat/http-client-batch-apply's rebased head pulled in main's
#7247 review-fix round, which made BEADS_HTTP_TOKEN/BEADS_HTTP_TOKEN_COMMAND
host-scoped (host[:port]=value, scopedEnvValue/parseScopedEnv in
internal/httpclient/credential.go) after S6's own tests were written against
the unscoped form. Five S6 tests across backend/http/open_test.go,
backend/http/register_test.go and
internal/httpclient/insecure_credential_guard_test.go set a bare token and
now hit the new ladder's "an unscoped token would be used for whatever
server..." refusal. Scope each to the test server's actual host
(127.0.0.1 for the httptest.Server-backed recording servers,
nonLoopbackTestHost for the insecure-credential-guard integration tests)
so they exercise the same ladder rung as before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): resync go_srcs/repo_files for the new backend/http and test/embedder packages

make bazel-sync-check failed after the rebase: tools/bazel/go_srcs.py's
managed repo_files filegroups for backend/http and test/embedder (new in
this slice) hadn't been generated, and the root BUILD.bazel / tools/bazel's
release_cross_build target list hadn't picked up the new package either.
Regenerate with `python3 tools/bazel/go_srcs.py`; `bazel run //:gazelle --
-mode=diff` reports no further drift.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cmd/bd): route swarm's create paths through creationActorStamp after main's currentActor change

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: police http's served roles, refuse close --claim-next, exact totals

External-dependency policy over http (review blocker). cmd/bd wraps
every store, http included, in the externaldeps decorator, and its role
accessors rebuilt each role over legacy methods httpclient.Store refuses
(SearchIssuesWithCounts, GetDependencyTree, ClaimReadyIssue, IsBlocked,
GetDependencyRecordsForIssues, BatchCloserWithPolicy). Over http `bd
list`, `bd dep tree`, `bd ready --claim` and a policed `bd close`
therefore exited 1, even in a workspace with no external dependency.
Over a store that reports storage.RemoteBackendStore, each accessor now
starts from the inner store's served role and layers the policy around
it (remote_roles.go):

- IssueReader serves List and Get from the served reader; Ready and a
  ready-flagged List go through the policy reader.
- IssueClaimer refuses an externally blocked claim before the served
  one.
- ReadyClaimer uses the served claim-next while no issue, closed ones
  included, holds an unsatisfied external ref. Otherwise it claims down
  the policy's filtered ready page through the served Claimer, because
  claimNext cannot exclude ids.
- BlockingAnnotator and TreeWalker merge external blockers into, or add
  external leaves to, the served answer. They read only the named
  issues' edges through the served EdgeReader, 100 anchors per call.
- BatchCloser refuses externally blocked open items and sends the rest
  to the served closer as one request. --force keeps the base path, and
  a next claim is refused whole (below).

RemoteBackendStore now only chooses this composition. Whether the policy
runs is still ServerEnforcesExternalDependencyPolicy's answer (design
3.6), and the storage and httpclient docs say so. remote_roles_test.go
drives each role over a store that refuses the legacy methods.
TestServedRolesKeepTheExternalDependencyPolicy runs every role over a
real http server. TestE2E_BDOverHTTP adds `bd list` (JSON, text and
--deps), `bd dep tree`, `bd ready`, `bd list --ready`, `bd ready
--claim`, a refused `bd close --claim-next`, and a refused then forced
close of an externally blocked issue. At the fixup before the
composition, the role tests then written (bar one pin of the next-claim
refusal, since replaced) and the e2e's list, dep tree, claim and close
steps of that round were red.

Close with a next claim over http (review major). batchCloseIssues has
no member for a next claim, so httpclient refuses any ClaimNext before
the dial (ledger W-CloseBatchRequest.ClaimNext). Over http `bd close
--claim-next` therefore always exited 1 and closed nothing. With an
external ref anywhere in the workspace (a closed holder or --force
included) the decorator's base path failed first, with an opaque
`BatchCloserWithPolicy` unsupported. remoteBatchCloser now refuses a
next claim whole, before it reads or closes anything, and the error
says nothing closed: close without --claim-next, then run `bd ready
--claim`. A request that is invalid on every backend is still
ErrValidation first, and a server that enforces the policy itself gets
the request unchanged.

Composing close-then-claim was not taken. The role closes and claims in
one transaction and answers with an error or with outcomes, never both,
so a claim that failed after the closes committed could not report
them; httpclient refuses the same request for that reason. A CLI-level
close then claim that can report a partial result is the follow-up.
The review also suggested leaving closed holders out of the blocking
state. They stay in, as on every backend: a closed issue is never a
claim candidate, so they change no claim, and leaving them out would
cost a status read per holder because the wire has no batch read.

TestRemoteBatchCloserRefusesANextClaim covers an open holder, a closed
one, none, --force, and a server that enforces the policy; with the
previous remote_roles.go the first four are red.
TestRemoteBatchCloserValidatesANextClaimFirst keeps ErrValidation ahead
of the refusal. Dropping the filter check, or loading the blocking
state before refusing, is each caught. TestE2E_BDOverHTTP runs `bd
close --claim-next` while the holder is open and again after it is
closed; with the previous remote_roles.go both steps are red and print
`operation "BatchCloserWithPolicy" not supported`. Ledger F-close no
longer says --claim-next is served, and no longer names a
renderEscapedHTTPRefusal that does not exist. L14 says the decorator's
claim leg applies while any issue, closed or not, holds an unsatisfied
ref. The README and CHANGELOG mention the refusal, and the decorator's
IsBlocked, IsBlockedBatch and CloseIssueChecked say they refuse over a
store that serves its roles.

Ready totals with external blockers (review majors, both rounds).
CountReadyWork asks for Limit=0, and readyWorkWithCountsAndTotal took
any Limit<=0 to mean "the window held the whole ready set". Over http a
zero limit never reaches the wire: the server answers with its default
page (workapi.DefaultReadyLimit, 100 rows) while the bridge reports the
full total, so past 100 ready issues text-mode `bd ready` kept counting
externally blocked issues beyond the first page. Exactness is now judged
from the rows that came back (total <= len(rows)). A window that holds
only part of the set no longer subtracts every externally blocked id in
the workspace either: that set includes closed issues and ones the
filter excludes, none of them in the total, so the count came out low.
It refetches the filtered ready set, ids only, and subtracts the blocked
rows in it; the old bound is left as the fallback for a refetch that
comes back truncated too.

fakeStore gains the bridge's shape: a defaultPage for a zero Limit,
with GetReadyWorkWithCountsAndTotal still totalling the whole set.
TestReadyTotalsWhenAnUnlimitedFetchComesBackAsOnePage (a blocked issue
past the first page) and
TestReadyTotalsIgnoreExternallyBlockedIssuesOutsideTheReadySet (a
blocked issue outside the ready set) have served counterparts,
TestServedReadyCountExcludesAnExternallyBlockedIssuePastTheDefaultPage
and TestServedReadyTotalIgnoresAnExternallyBlockedIssueOutsideTheFilter
(an assignee filter). The first pair is red on the Limit<=0
condition, the second on the subtract-every-blocked-id branch.

Docs: ledger L8 now says which decorator paths take the chunked
GetAllDependencyRecords scan and which read only named edges, and L14
records the decorator's composed claim leg; http-divergence-ledger.md
is regenerated. The README names the verified commands, and the README
and CHANGELOG say how cross-repo dependencies behave over http.

Minors from the reviews:

- Drop creationActorStamp/isRemoteBackendWorkspace and restore the base
  stamps at all 11 sites. The arm guarded a refusal the http create
  role does not make: since #7247 (actorStampedCreateMember) it accepts
  a CreatedBy naming the actor. Because the arm keyed on the CWD
  workspace, a create routed from an http workspace into a local one
  (--repo) stored an empty created_by. TestE2E_BDOverHTTP checks
  created_by for a direct and a routed create; the routed check is red
  with the arm restored. The CHANGELOG sentence describing the arm goes
  with it.
- bdhttp.Attach decides a reconnect from the raw metadata.json backend.
  GetBackend() reads an unregistered "http" as the dolt default, so in
  an embedder that never called Register a reconnect recorded dolt as
  the backend --clear restores. The reconnect test now seeds postgres
  (TestAttachOnAReconnectKeepsTheEarlierPreviousBackend) and is red
  with the old check.
- README, CHANGELOG and `bd connect --help` document the host-scoped
  BEADS_HTTP_TOKEN=host[:port]=<token> form (and _COMMAND), and say why
  a bare value is refused.
- bdhttp.Attach also gitignores http_local_metadata.json, the per-user
  file the store writes on first use, so an embedder activating through
  Attach alone gets the coverage `bd connect` already had.
  TestAttachGitignoresBothPerUserFiles pins it.
- ServerSnapshot.WireRevision's doc names the handshake's actual check
  instead of a comparison `bd connect` never makes.

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>

* test(backend/http): give the e2e server the LeaseReclaimer role #7412 added to the required set

main's #7412 made LeaseReclaimer part of httpapi's required role set and
updated main's own binders, but backend/http's e2eServeConfig predates it,
so every TestE2E_* that binds the in-process server failed with
"httpapi: no database source". Same shape as e63f7da36a for BatchGetter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(externaldeps): lead the --claim-next refusal with the wire fact; pin the L14 leg and connect --clear

Review i4 minors/nits on the stranded fixup, carried as a separate commit:

- remoteBatchCloser's --claim-next refusal now says the served batch close
  cannot carry a next claim (the real cause), rather than blaming
  externally blocked work a workspace may not have. The test asserts the
  reason, that nothing closed, and the remedy.
- GetDependencyTree's doc says a served store refuses its reads and that
  bd dep tree goes through remoteTreeWalker.
- README no longer gives `bd ready --claim` local semantics everywhere; it
  names when ledger row L14's two-step claim applies.
- TestE2E_BDOverHTTP claims once more after the external-ref holder is
  closed, pinning L14's composed leg (a mutant whose composed leg claims
  nothing turns only that step red).
- New TestE2E_ConnectClearRestoresThePreviousBackend: --clear restores
  the prior dolt backend with its identity intact, removes the sidecar,
  and a second --clear changes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http): run the served e2e under bazel

//backend/http:http_test declared no bd binary, so under bazel the e2e
files (bazeltest.PrebuiltBD) failed on BEADS_TEST_BD_BINARY with
BEADS_HTTP_TEST_REQUIRED=1 and only "passed" by skipping otherwise. It now
takes //cmd/bd:bd_for_tests (visibility added), size large / timeout long:
the served cases run 4-5 minutes on the farm under BEADS_TEST_EMBEDDED_DOLT=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http): run the e2e tier in the embedded lane as http_served_test

The previous commit gives //backend/http:http_test the bd binary, but no
lane sets BEADS_TEST_EMBEDDED_DOLT for it, so its TestE2E_* cases still
skipped in CI. http_served_test runs the same test binary through
//tools/bazel:go_test_variant.sh with BEADS_TEST_EMBEDDED_DOLT=1 and
BEADS_HTTP_TEST_REQUIRED=1 (a skip fails it). It is tagged embedded, so
the --config=embedded lane runs it and prcore/ci keep their current
shape, the same split as //internal/httpclient:httpclient_served_test.
Under plain --config=embedded all 8 TestE2E_* cases run, none skipped.

TestBazelRetiredLanesCannotBeNarrowed pins every embedded-lane target's
args and env; the new target is added to that pin list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(externaldeps): cap the ready rows kept, not the bumped http window

An http store cannot carry ExcludeIDs on listReadyWork, so readyExclusion
fetches the unfiltered ready set, widened by len(blocked) under a limit,
and drops the externally blocked rows client-side. The http ready bridge
enforced MaxRows on the rows it fetched rather than the rows kept. So
`bd ready --limit N --max-rows N` exited 2 whenever more than N issues
were ready and any workspace issue held an unsatisfied external blocker
(a closed one counts), even with no blocked row in the window, and a
blocked row in the page counted against the cap although the caller
never sees it. Locally neither can happen: issueops enforces the cap on
the filtered page it delivers, after the Limit trim
(finishReadyWorkWithCounts).

The client-side path now takes MaxRows off the inner query and enforces
the caller's cap on the rows it keeps, after the trim, in all three
listings. The inner query keeps the cap whenever nothing is dropped
client-side. MaxRows never rode the wire, so the fetch is the size it
was; refetchedReadyTotal already clears the cap on its own over-fetch.

TestServedReadyMaxRowsCountsTheRowsKept runs the decorator over a served
http store holding three free issues and one externally blocked one: a
cap equal to the limit, a cap under a wider limit, an unlimited listing,
and a kept page wider than the cap, which must still return
ErrTooManyRows with the caller's cap and source. Each case runs through
GetReadyWork, GetReadyWorkWithCounts and GetReadyWorkWithCountsAndTotal.
Leaving the cap on the inner query fails the first three cases in all
three methods, dropping the re-applied cap fails the fourth, and
enforcing it before the Limit trim fails the first.

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 Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-10 07:19:18 +00:00
Julian Knutsen
b3cdbf9e46
ci(rbe): auto-PR a worker-env pin sync when gascity main re-pins (mc-gv9fk) (#7455)
rbe-west's pool workers advertise gastownhall/gascity main's worker-env
pin; when gascity re-pins (a Go/dolt/OS bump, e.g. #7387) beads' copy
falls out of step and every remote-execution run stops in bazel.yml's
preflight until a human notices and copies the fix by hand (#7419 took
~100 minutes). This adds a scheduled workflow (every 15 minutes, plus
workflow_dispatch) that runs tools/rbe/worker-env-sync against gascity
main, and on a real mismatch (exit 1) copies the manifest and pin with
the new tools/rbe/worker-env-sync-copy, opens/updates a PR on a fixed
branch with status/needs-review-auto, and arms auto-merge.

GitHub never runs checks on a PR a plain GITHUB_TOKEN opens, so this
needs a GitHub App token -- but gastownhall-autofix (contents:write on
this repo) cannot open or label a PR. Two Apps split the two write
roles instead: gastownhall-autofix mints push-token (contents:write
only) and does the git push of bot/worker-env-sync via plain git;
gascity-autofix (pull-requests:write only) mints pr-token and does
everything PR-shaped -- create/update, the label, and arming
auto-merge -- via gh. peter-evans/create-pull-request takes one token
for the whole flow, so it can't honor this split; plain git and gh
replace it. Every ${{ }} is resolved into a step's env: first, never
written inside a run: script.

Both Apps' id/private-key secrets live in the same autofix environment,
gated by its deployment-branch policy to main; schedule and
workflow_dispatch are never fork events, so neither key is ever
readable by a fork.

Needs admin setup: the gascity-autofix App (id 5259233) installed on
gastownhall/beads (and gascity) with pull-requests:write and metadata
read, and its GASCITY_AUTOFIX_APP_ID / GASCITY_AUTOFIX_APP_PRIVATE_KEY
secrets added to the autofix environment alongside the existing
AUTOFIX_APP_ID / AUTOFIX_APP_PRIVATE_KEY.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 05:58:24 +00:00
Bee
11b5d3271e
docs(proxied): name the Close3/Close4 legacy pins and fix the Close3 doc comment (#7173 follow-up) (#7382)
* docs(proxied): name the Close3/Close4 legacy pins and fix the Close3 doc comment (#7173 follow-up)

Two non-blocking findings from the #7173 adoption review (bd-vrdrew,
bd-dars9p), both in bee's code, neither addressed in that PR:

- The doc comment on TestProxiedServerClose3 still called it "the second
  half of TestProxiedServerClose"; after the second split it is the middle
  of the three parents (Close, Close3, Close4). Say so, and name Close4
  as its own second half.

- In the frozen 15-shard block of .github/scripts/proxied-cmd-test-shards.txt
  the lines `15 13 TestProxiedServerClose3` and `15 2 TestProxiedServerClose4`
  sat inside the shard-1 and shard-7 groups (#7173's last commit moved the
  pins from 1 and 7 to 13 and 2 without moving the lines), and the header's
  "Deliberate exception (Oct 2026)" paragraph did not name them. The two
  lines now sit alphabetically inside their own shard groups, the header
  names them with the reason and the measured times, and the generator's
  hand-pin paragraph (scripts/ci/gen_proxied_shard_manifest.py) names them
  too so the two texts stay in step. The lines were inert either way:
  proxied-test-shard.sh matches each line by field.

No test moves shard: the 15-shard block's line set is unchanged apart from
order (sorted diff empty) and the 30-shard block is byte-identical.

Verified: gofmt -l (clean); go vet ./cmd/bd/ (exit 0);
gen_proxied_shard_manifest.py 30 --weights=duration --check (exit 0,
heaviest 435.1s est, unchanged); 15 --check reports the same 30 hashed
names missing as main (the frozen block is expected to fail it);
proxied-test-shard.sh list-only: Close3 on 13/15, Close4 on 2/15, neither
on 1/15 or 7/15; go test ./scripts/ -run 'Shard|Manifest|Coverage' ok 38.6s.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* docs(proxied): count CloseB in the Close3 comment; say why shard 5 got no pin

Maintainer fixup from the adoption review of #7382 (bd-g6pyb0), on top
of bee's commit, which stays as written. Comment and manifest-header
text only: no test body, shard assignment or routing changes.

- TestProxiedServerClose3's doc comment called it "the middle of the
  three parents TestProxiedServerClose was split into (Close, Close3,
  Close4)". That held at the PR's original base, but #7418, on main
  since, moved five of Close's eleven cases into a new
  TestProxiedServerCloseB, so the 23 bd-init subtests of the pre-#7173
  TestProxiedServerClose now sit in four parents: Close 6, CloseB 5,
  Close3 6, Close4 6 (their union is exactly the pre-#7173 set, no
  duplicates). The comment now says Close3 was split off Close, names
  all four parents, and keeps "Its own second half is
  TestProxiedServerClose4."

- The frozen 15-shard block's header said #7173 pinned Close3 and
  Close4 onto "the two lightest shards of that PR's own run (6m51s and
  7m57s)". On that run (37206446441, at 765248af5) shard 5 was lighter
  still, at 5m50s; #7173 passed over it on purpose, because it was
  light only because those 12 subtests had just left it and putting
  Close3 back would recreate most of the set that timed out. The header
  now says "other than shard 5 itself" and gives that reason.

This commit also supersedes the parts of the parent commit's message
that the rebase onto c21880105f outdated:

- "after the second split it is the middle of the three parents (Close,
  Close3, Close4)": four parents now, as above.
- "the 30-shard block is byte-identical": the Bazel-only block is 34
  shards now (#7418 made it 44, #7436 34), and that block is
  byte-identical to the base's.
- "gen_proxied_shard_manifest.py 30 --weights=duration --check (exit 0,
  heaviest 435.1s est, unchanged)": with no 30-shard block left, that
  command now exits 1 ("has no block for total_shards=30"). Its current
  form, 34 --weights=duration --check, exits 0 with the heaviest shard
  at 196.1 s est., the same before and after this commit.
- "15 --check reports the same 30 hashed names missing as main": it now
  reports 53, the same set as against the base's manifest.

Verified: git diff --check clean; gofmt -l clean (the Go change is
comment-only); with '#' lines stripped as proxied-test-shard.sh strips
them, the manifest is identical before and after;
gen_proxied_shard_manifest.py 15 --check and 34 --weights=duration
--check print the same output before and after (exit 1 with 53
missing; exit 0, heaviest 196.1 s); BEADS_TEST_SHARD_LIST_ONLY=1
proxied-test-shard.sh lists for 1, 2, 7 and 13 of 15 are unchanged
(Close3 on 13, Close4 on 2, neither on 1 or 7); go test ./scripts/ -run
'Shard|Manifest|Coverage' ok (21 top-level tests, none skipped).

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 Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-10-10 05:28:43 +00:00
Bee
9f5028c78e
test(show): run --comments-tail through every show route; CHANGELOG bullet under Added (#6618 follow-ups) (#7383)
Follow-ups from the #6618 adoption review, neither addressed there:

- bd-6gl9h7 (Test Evidence Quality): no committed test ran `bd show` with
  --comments-tail set. show_comments_tail_test.go calls printComments and
  renderWatchComments directly, so passing 0 at any of the three call
  sites (show.go direct, show_display.go --watch,
  show_proxied_server.go / show_proxied_watch.go proxied) still passed the
  suite. TestEmbeddedShowCommentsTail (direct, direct --watch) and
  TestProxiedServerShowCommentsTail (proxied, proxied --watch) now run the
  built binary through each route over the same three comments with
  --comments-tail 1, and check the elision line, the surviving newest
  comment, the absence of both hidden ones, the off state (0 and a cap
  above the count) byte-identical to the flag's absence, the negative
  usage error, and --json --include-comments untouched.

  Mutating each call site to pass 0 fails the matching route tests
  (direct: direct_tail_1 + watch_tail_1; proxied: proxied_tail_1 +
  proxied_watch_tail_1) and nothing else.

  The off-state comparison strips the "💡 Tip:" line maybeShowTip may
  append after a direct text render (a per-run probability roll behind a
  per-tip frequency gate, independent of the flag); without that, the
  first render of a fresh store can carry the tip and the comparison
  fails on it.

  The embedded half lives in a *_embedded_test.go file because
  gen_embedded_cmd_shard_manifest.py discovers TestEmbedded* only there;
  both tests are registered in their shard manifests (--write, then
  --check rc 0 at 50 and 30) and in cmd/bd's go_test srcs.

- bd-l6f1r7 (Release Safety): the CHANGELOG bullet for the flag sat under
  "### Fixed" in [Unreleased]; it is now the first bullet under the
  section's "### Added".

Ran (GOTOOLCHAIN=go1.26.7): go vet ./cmd/bd/; gofmt -l; go test ./scripts/
-run 'Shard|Manifest|Coverage'; embedded leg
(BEADS_TEST_EMBEDDED_DOLT=1) -run TestEmbeddedShowCommentsTail -count=3:
15/15 subtests PASS; proxied leg (BEADS_TEST_PROXIED_SERVER=1,
BEADS_TEST_DOLT_SERVER=local, dolt 2.2.0, -tags gms_pure_go) -run
TestProxiedServerShowCommentsTail: 5/5 PASS, 0 SKIP.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 02:50:41 +00:00
Julian Knutsen
f53010a23b
ci(bazel): remote repo contents cache: main-push seed, lane readers, nightly verify (#7453)
Port gascity's remote repo contents cache wiring (gascity #7467, #7478) to
bazel.yml, gated on the repository variable RBE_REPO_CONTENTS_CACHE
(unset/off: nothing; seed: rrc-seed on push to main; canary: + bazel-test
reads; on: + every test lane reads). Mode remote only.

- rbe job: an rrc step turns the variable into the rrc output.
- Readers: the eight test lanes append startup
  --experimental_remote_repo_contents_cache and common
  --loading_phase_threads=64 to .bazelrc.local before Set up Bazel.
- rrc-seed (push to main, id-token: write): a 30-minute
  rbe-rrc-writer-beads certificate from rbe-west's mint
  (.github/scripts/rrc-writer-credential.sh), then every lane's command
  (.github/scripts/rrc-lane-commands.txt) with --nobuild, --remote_cache
  only and --remote_upload_local_results (.github/scripts/rrc-run-lanes.sh).
- rrc-verify (schedule/dispatch, issues: write): cold fetch of every lane
  and tools/bazel/rrc_verify.py against the cache; a mismatch opens an
  rrc-verify issue.
- pr.yml, nightly.yml and bazel-farm.yml grant id-token: write and
  issues: write on their bazel.yml call (startup_failure otherwise);
  TestBazelWorkflowCallersGrantEveryRequestedPermission guards it.

rrc-writer-credential.sh, rrc_verify.py and rrc_verify_test.py are byte
copies of gascity's, pinned by sha256.

Refs ga-vnycm2.29.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 02:50:26 +00:00
Bee
1cf193bc9f
fix(testutil): sweep Dolt test containers whose owner process exited (#7028)
* fix(testutil): sweep Dolt test containers whose owner process exited (wy-4hknjt)

Every Dolt container the test harness starts now carries two labels naming
its owner: the test binary's pid and the host it runs on. Before a process
starts its first container, the harness lists the containers labelled for
this host and removes the ones whose owner pid no longer exists.

In-process cleanup (t.Cleanup, TerminateDoltContainer after m.Run) never
runs when a test binary is killed or panics on `go test -timeout`, and a box
running with TESTCONTAINERS_RYUK_DISABLED=true has no reaper either. Each
such run stranded one idle dolt-sql-server holding 100-470 MiB; 23 were
standing on one loaded box after a single evening of killed runs. The sweep
bounds the pile at "runs since the last run".

Safety under concurrent test processes on one host: a container is removed
only when kill(pid, 0) reports ESRCH. A live owner, a pid reused by another
live process, or a pid this user may not signal (EPERM) all keep the
container. Containers without the owner labels (older harnesses, other
tools) are never touched, and the host label keeps a remote DOCKER_HOST's
containers, whose pids mean nothing here, out of the sweep. The local
(BEADS_TEST_DOLT_SERVER=local) backend is unaffected.

Tests: the decision table (dead owners only; missing, non-numeric and
non-positive pids skipped without probing), pidAlive on self and on an
impossible pid, the label option stamping this process, and a Docker test
that starts a dead-owned and a live-owned container, sweeps, and checks
only the dead-owned one is gone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* build(bazel): sync BUILD files for testutil dolt sweep test

wy-4hknjt: apply the gazelle bazel-sync patch from run 36720164405
so internal/testutil/BUILD.bazel carries the testcontainers deps.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(testutil): key the Dolt container sweep on the owner's PID namespace

Maintainer fixup for #7028, review iterations 1 and 2 and pre-approval
CI.

A pid names a process only inside its PID namespace. The sweep removed a
labelled container whenever kill(owner-pid, 0) returned ESRCH, so a
sweeper in another namespace that shares the hostname and the Docker
daemon reads every live owner as dead. That is the default shape of the
maintainers' agent fleet: each session runs under bwrap --unshare-pid
without --unshare-uts. Every session therefore reports one hostname, sees
only its own handful of pids, and talks to one /var/run/docker.sock, with
the Docker backend as the test default. On one such box on 2026-10-06,
three live dolt-sql-server test containers from three test runs shared the
daemon. With the original sweep merged, the first container start of a
test binary in any other session would have removed them mid-test.

Reproduced and fixed by running the sweep from a container (its own pid
namespace, same hostname, same daemon) against a container labelled with a
pid that was alive in the labelling session:
- at 5978cedaa2: "removed stale Dolt test container ... (owner process
  exited)" while the owner was alive;
- with this change: the row is listed and kept.

Changes:
- Stamp a third owner label, owner-pidns: the /proc/self/ns/pid link on
  Linux and "" elsewhere. staleContainers considers only rows from the
  sweeper's own namespace. On Linux the sweep is skipped when that link
  cannot be read. A start-time label alone would not fix this: across
  namespaces it would turn a pid collision into "dead" as well. An owner
  whose hostname or namespace cannot be read is stamped "", which no
  sweep on the host matches, so its container leaks instead.
- docker rm -f -v: the image declares VOLUME /var/lib/dolt, and plain
  rm -f left that anonymous volume behind for every swept container, unlike
  testcontainers' own RemoveVolumes teardown.
- Bound the sweep with a 30s context, plus WaitDelay on each docker
  command. Without WaitDelay, killing the docker process on timeout does not
  unblock Output() while a child it started still holds the pipe. With a
  forking docker shim on PATH, the call returns after 3s with this change
  and is still blocked after 15s without either part.
- Extract parseOwnedRows and table-test it: empty fields, CRLF, trailing
  newline.
- TestSweepStaleDoltContainers: the dead-owned container's owner is a
  child process that lives until both containers are up and the volumes
  are read, and is then killed and reaped (a zombie still reads as
  alive). A sibling test binary's sweep (go test ./... runs them in
  parallel) removes a container as soon as its owner reads as dead, and a
  never-live owner pid exposed the container for its whole start. The
  test checks only the end state for that container and its volume,
  polled for up to sweepTimeout, because the sibling may get there first
  or still be removing it when our rm fails.

Reproduced with a second test process in the same PID namespace running
the real sweep every 100ms alongside TestSweepStaleDoltContainers:
- with a never-live owner pid: "starting Dolt container: ... No such
  container", the container removed inside dolt.Run;
- with the child owner but no poll: 1 of 4 runs failed with "dead-owned
  container ... still exists after the sweep", after the sibling's
  rm -f -v won and ours exited 1;
- with both: 6 of 6 runs pass, 2 of them through that same path.
Without the reap, or without -v, the test fails.

A container leaked from another namespace is now left to a sweep from that
namespace, or to Ryuk. That is the conservative side of the trade.

Pre-approval CI: main's //internal/testutil:testutil_dolt_test (#7328)
runs this package with BEADS_TEST_DOLT_SERVER=local and
BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 in the required dolt-server lane,
whose remote workers have no docker. Under the local backend checkDolt
reports ready once the pinned dolt CLI resolves, so
TestSweepStaleDoltContainers went on to dolt.Run and failed ("failed to
create Docker provider"). It now gates like TestDoltServerFingerprint's
container subtest: under the local backend it runs only when docker and
the image are available, and skips otherwise. On the merge with main
b1fe68e63a, with docker unreachable, that package run (race,
-parallel 4) failed only this test; with this change it passes with the
test skipped, and with docker available the test still runs and passes
under either backend.

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 Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-10-10 02:39:59 +00:00
Bee
ff4f46e137
fix(bazel): go_test_pinned_shard.sh runs under bash 3.2 (macOS Main red since #7413) (#7423)
The pinned-shard wrapper kept a `declare -A shard_of` map whose only use was
the "pinned twice" check. Apple's /bin/bash is 3.2, which has no associative
arrays, so on the main workflow's macOS Test job scripts/pinned_shards_test.go
(which runs the wrapper through the host `bash`) failed every sharded case
with `declare: -A: invalid option` (exit 2). The job has been red on every
main push since #7413 landed (runs 37890739870, 37900573128, 37902968742);
the Bazel lanes run the wrapper on Linux bash 5 and never saw it.

The check is now a membership test on the "|"-joined `all` string, which the
manifest's name pattern (^Test[A-Za-z0-9_]*$) keeps free of "|". Nothing
else changes: the pinned-twice refusal still fires
(TestPinnedShardWrapperRejectsBadManifests/test_pinned_twice).

Verified: go test -run TestPinnedShard ./scripts with PATH limited to
/usr/bin:/bin (bash 3.2.57): 5 PASS; the whole ./scripts package under
bash 5.3: ok; shellcheck -s bash and `/bin/bash -n` clean.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 02:00:02 +00:00
Julian Knutsen
1f1e82ab08
fix(issueops): one default priority for every create path (#7426)
* fix(issueops): one create priority default; HTTP absent priority is P2

The CLI defaulted `bd create` to P2, but issues:create, issues:batchCreate
and batch:apply create items left Issue.Priority at 0 when `priority` was
absent, so a gc/curl create stored P0 (critical) against the spec's "absent
means the default".

The default now lives in one place, the shared create preparation
(PreparePublicCreateRequest), behind a presence flag because Issue.Priority's
zero value is P0:
- issueops.CreateRequest.DefaultPriority, BatchCreateItem.DefaultPriority and
  CreateItem.DefaultPriority ask for issueops.DefaultCreatePriority (2);
  setting it with a non-zero priority is ErrValidation
  (ValidateCreatePriority, shared with the HTTP client);
- every Lifecycle.Create, BatchCreator and BatchApplier leg (dolt, embedded,
  uow) reaches it; CloneCreateBatchRequest now keeps scalar item members;
- the three handlers set the flag for an absent member and never make up 0;
  the HTTP client omits `priority` for it (wirePriority) only when the
  server advertises the new additive issues.create.defaultPriority token,
  read from the cached handshake before the dial; an older server reads an
  absent priority as P0, so the client sends DefaultCreatePriority (2)
  explicitly to it (pinCreateDefaultPriority). An explicit 0 is still sent;
- `bd create` without --priority, `bd create --graph` nodes without priority
  and `bd create --file` templates without ### Priority rely on the flag; the
  flag's displayed default and the dry-run previews read the library
  constant. CLI output is byte-identical (checked against origin/main).

Spec: the three priority descriptions now say the create default is P2 on
a server advertising issues.create.defaultPriority (apigen regenerated); the
wireshape golden already had priority optional, so no wire-shape change.

Conformance: RunLifecycleCreateAppliesTheDefaultPriority,
RunBatchCreatorAppliesTheDefaultPriority and
RunBatchApplyAppliesTheDefaultPriority on dolt, embedded, uow and http, plus
handler and client encoding tests, and
TestCreateSendsTheDefaultPriorityToAServerThatPredatesIt (new client,
handshake without the token: all three create roles send 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(issueops): apply review fixups for the default create priority (bd-kb61wg)

Apply the minor and nit findings from the review of #7426:

- CHANGELOG: tell out-of-tree storage backends they must honor
  DefaultPriority (store issueops.DefaultCreatePriority, refuse it with a
  non-zero priority as ErrValidation) and which conformance cases check
  it; scope "CLI output is unchanged" to the in-tree backends.
- bd create --file: pin the default-priority path. The e2e test asserts
  the printed priorities, and a buildMarkdownBatchRequest unit test pins
  the flag and priority for an absent, a 0 and a 1 `### Priority`.
  Deleting `DefaultPriority: !template.PrioritySet` now fails both.
- bd create --file: warn on stderr about a `### Priority` that does not
  parse, as the `### Type` case already does, instead of dropping it
  silently.
- httpclient: document pinCreateDefaultPriority's same-build assumption
  (the handshake is cached per Store, so a stale one is silent here), and
  test its no-context and failed-handshake branches on all three roles.
- Formula steps, `bd q` and `bd todo add` spell
  issueops.DefaultCreatePriority instead of the literal 2.
- Conformance: the batch-creator and batch-apply default-priority cases
  also pin DefaultPriority with a non-zero priority as ErrValidation with
  nothing written.

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(issueops): mark the out-of-tree DefaultPriority change BREAKING (bd-0tcn1o)

Apply the minor findings from the relaunch review of #7426:

- CHANGELOG: move the obligation on out-of-tree storage backends out of
  the `### Fixed` entry into its own `### Changed` entry, led by
  "BREAKING (out-of-tree storage backends)" as the close-guard change
  and the earlier out-of-tree contract changes are; RELEASING.md asks
  breaking changes to carry their migration. The entry says what such a
  backend used to receive from `bd create`, `--graph` and `--file`
  (priority 2), what it receives now (priority 0 with DefaultPriority
  set), the migration, and the conformance cases that check it. The
  `### Fixed` entry keeps the HTTP P2 fix, points at the new entry, and
  names the stale-handshake residual that only a code comment named: a
  create that lands on an older build behind the same URL still stores
  P0.
- bd cook: the proto root, the gate issue and the cooked formula root
  spell issueops.DefaultCreatePriority instead of the literal 2, as the
  formula steps in the same file already do. No behavior change.

Not taken:
- The literal 2s in create_form.go, gate.go and linear.go, and the
  "default 2" in todo.go's --priority help: explicit P2s outside the
  migrated paths (the help string also feeds the generated CLI
  reference). Left for a follow-up sweep.
- Reusing in.priorityDefault in the direct bd create route: that route
  builds no createInput (gatherCreateInput runs only on the proxied and
  --file routes, and each returns), so there is nothing to reuse.
- A member-level range check in the single-create HTTP decode, as the
  batch shapes have: the asymmetry predates this PR, and the role still
  refuses an out-of-range priority on all three shapes.

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>
2026-10-10 01:37:27 +00:00
Julian Knutsen
c21880105f
ci(bazel): split embedded conformance core into two targets (#7446)
//internal/storage/embeddeddolt:embeddeddolt_conformance_core_test ran
conformance.RunAll minus Audit as one unsharded action, 108-150s on
rbe-west, the embedded lane's longest after #7443. Every RunAll group builds
its own store from the factory, so the groups share no state and can run in
separate processes; about half the time was two groups,
ReadyCountsPageChunking (~33s) and Portable (~20s).

The new embeddeddolt_conformance_core_slow_test runs exactly those two
groups (-test.run=^TestConformance$/^(ReadyCountsPageChunking|Portable)$),
and the core target skips them along with Audit. The core target skips
only named groups, so any group added to or renamed in RunAll still runs
there: between them the two targets run every core group exactly once
(rbe-west: 57 + 2 groups, no overlap, the same 59 as before). No test
changed. The frozen-partition check now derives both targets' selectors
from the retired job's core selector plus conformanceCoreSlowGroups; the
retired-lane arg pins, bazel.yml's --whole list and the BUILD rules carry
the new target.

rbe-west, `bazel test //... --config=embedded --nocache_test_results`:
conformance core 148s -> 55s + 57s.

Bead: ga-vnycm2.31

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 23:29:35 +00:00
Julian Knutsen
d15958a5eb
fix(issueops): enforce the dotted-child dependency rule on every leg (#7424)
* fix(issueops): enforce the dotted-child dependency rule on every leg

The refusal of an explicit edge from a dotted-id child to its own ancestor
(bd-abc.1 -> bd-abc; only the parent-child edge to the immediate dotted
parent is allowed) lived only in cmd/bd (isDisallowedHierarchicalDependency).
HTTP dependencies:add, batch:apply dep_add items and `bd create --graph`'s own
edges skipped it.

It is now one library rule, issueops.CheckDottedChildDependency, returning
*issueops.DottedChildDependencyError (unwraps to ErrValidation, same message
the CLI printed):
- ValidateAddDependenciesRequest applies it, so DependencyEditor refuses on
  dolt, embedded, uow and the server behind httpapi (400 invalid_argument);
- both BatchApplier bodies (issueops and uow) apply it to each dep_add item on
  the resolved ids, so a key bound to a minted dotted child is refused too;
- the HTTP client checks it before the dial, as it does self-dependency, so
  the typed error survives the wire.

cmd/bd keeps no copy: single-edge dep add / dep --blocks rely on the role;
bd link (still on the store verb) and the --file bulk reporter call the
library rule. CLI output is byte-identical (checked against origin/main).

Conformance: RunDependencyEditorRefusesADottedChildGatedOnItsOwnParent and
RunBatchApplyRefusesADottedChildGatedOnItsOwnParent wired on dolt, embedded,
uow and http, plus a raw-wire served test past the client check and handler
mapping cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(batch): refuse a dotted child gated on its own ancestor in bd batch

Review fixup for PR #7424 (iterations 1 and 2).

Major: a bd batch script line `dep add bd-abc.1 bd-abc` still wrote the
edge this PR refuses everywhere else, on both backends. Neither batch
dispatch writes through the DependencyEditor role that enforces the
dotted-child rule: the classic arm calls storage.Transaction.AddDependency
and the proxied arm the unit of work's AddDependencies verb. Both arms now
build the edge with one helper, batchDepAddEdge, which keeps the default
type and the arity and type errors, and asks
publicops.CheckDottedChildDependency the way bd link does. A refused line
rolls the whole batch back.

Tests: TestBatchDepAddEdge (default and explicit types, arity and type
errors, three refusals typed *DottedChildDependencyError matching
ErrValidation, and the immediate parent-child edge allowed), and
TestProxiedServerBatchDepAddRefusesADottedChildGatedOnItsParent (classic
and proxied: the refusal names line 2, rolls back an earlier update line
and writes no edge, and `dep add C P parent-child` still lands exactly
one), registered in the proxied shard manifest. A mutant that drops the
rule from the shared helper fails both; one that bypasses the helper in
the proxied arm alone fails the proxied leg.

Minors:
- For a child whose parent-child edge is already stored (a
  `bd create --parent` child) the rule answers ahead of the hierarchy and
  type conflicts, so an HTTP caller now gets 400 invalid_argument where it
  got 409 dependency_cycle (blocking types) or dependency_exists (any
  other type). Documented in the DependencyEditor role doc, the CHANGELOG
  entry and the httpapi batch-apply test comment, and pinned by a
  stored-hierarchy phase in the DependencyEditor and BatchApplier
  dotted-child conformance contracts on every leg; a mutant that drops the
  rule gets the hierarchy conflict instead (409 dependency_cycle on the
  wire).
- The bd create --graph dry-run note now says the live create may also
  refuse an edge that gates a dotted-id child on its own ancestor.
- The DottedChildDependencyError comment says the message is kept verbatim
  and says "deadlock" whatever the type.

Not changed: bd relate (relates-to does not schedule) and the edges a
create writes with its issue (bd create --deps/--waits-for, and over
HTTP an explicit dotted id with a non-immediate ParentID) still write
through paths that skip the rule. The scheduling shapes need an explicit
dotted id or a grandparent target. Follow-up bd-25s1wh tracks moving the
rule down to the domain/store add verbs, with a structural bypass for
reparent and template edges.

Iteration 2 (minor): the CheckDottedChildDependency doc no longer implies
bd link and bd batch are the only writers outside the roles. It names
bd relate and the create edges as not applying the rule yet and cites
bd-25s1wh.

Complexity (cyclomatic/cognitive): runBatchOp 23/35 -> 21/31,
runBatchOpUOW 28/48 -> 26/44, batchDepAddEdge 5/4. Touching them brings
both pre-existing dispatch switches into the measured set; splitting them
is out of scope 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>

* docs(issueops,httpapi): document the dotted-child 400 and widen its gap list

Review fixup for PR #7424 (relaunch, iteration 1, minors).

- The OpenAPI spec now describes the wire change this PR makes. The
  dependencies:add and issues:batchApply 400 vocabularies name an edge
  from a dotted-id child to its own ancestor (anything but the
  parent-child edge to its immediate parent; param `edges` and `items`).
  dependencies:add says why that is request-intrinsic, and both 409s say
  it is never dependency_cycle or dependency_exists, even for a child
  whose parent-child edge is stored. Response descriptions only: the
  generated types and the wireshape digest are unchanged (make api-check).
- The CheckDottedChildDependency doc no longer reads as a complete list of
  the writers that skip the rule. Besides bd relate and the create edges
  it names bd duplicate, bd supersede, bd duplicates --auto-merge (its
  related link and its reparenting) and the tracker engine's
  createDependencies, and says the molecule, template and swarm writers
  are unaudited. bd-25s1wh's notes carry the widened scope, including
  `bd duplicate bd-a.1 --of bd-a`.

Declined (nit): unifying the root issueops import alias across the PR's
cmd/bd files. batch.go is the one file that imports both issueops
packages, so one of them needs an alias there; it uses publicops, the
repo's usual alias for the root package, and aliasing the other side
instead would rewrite base-owned lines.

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: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 22:56:46 +00:00
Julian Knutsen
7c47c3c0a9
ci(bazel): pin httpclient_served_test's slow tests to shards (16 -> 26 shards) (#7443)
After #7440 //internal/httpclient:httpclient_served_test set the embedded
lane (149-167s slowest shard in recent CI runs, 63-167s across PRs since
#7416). Not a regression: its top-level tests are all serial and rules_go's
round-robin put the long ones wherever its index split dropped them, so
shard times swung with load and with which tests a PR added (whole-lane
rbe-west run on main: 40-119s over 16 shards).

The target now runs through tools/bazel/go_test_pinned_shard.sh, as
bd_dolt_server_test and regression_test do: every top-level test measured
at >= 3s (max over three whole-lane runs) is pinned onto 17 shards
(served_pinned_shards.txt, tools/bazel/pin_shards.py), and the binary's own
round-robin deals the other ~620 over the remaining 9. Every test still runs
in exactly one shard (TestPinnedShardWrapperSplit), the manifest may name
only real tests, and the lane's check_testcases.py fails an empty shard.
No test changed; the heaviest single test (~52s, no subtests) stays whole.

The pinned-wrapper policy listed only dolt-server-cmd targets, since the
wrapper selects and skips; pinnedShardTargets now carries each reviewed
target's lane tag, and httpclient_served_test is reviewed in as the
embedded lane's (its args stay pinned in
TestBazelRetiredLanesCannotBeNarrowed).

rbe-west, `bazel test //... --config=embedded --nocache_test_results`:
served shards max 119s -> 77s, median 73s -> 54s; lane critical path
138-153s -> 116s.

Bead: ga-vnycm2.30

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 22:11:43 +00:00
Julian Knutsen
72a3d8039d
ci(bazel): embedded storage tier to 40 shards; split its two slowest tests (#7440)
//internal/storage/embeddeddolt:embeddeddolt_embedded_test became the
embedded lane's floor once the cmd tier was split (CI on #7438: 20 shards,
220s max, 162s median). Its tests are serial, so a shard's wall time is the
sum of its tests; measured on rbe-west with the whole lane running (as CI
runs it), its 20 shards took 110-161s.

- TestCreateBatchFastPathsMatchPerRow_Embedded (111s) runs
  createbatchequiv's scenarios as two top-level tests (small+depadd,
  apply+waitsfor) through a new createbatchequiv.RunNamed; the same
  scenarios and checks. TestCreateBatchEquivalencePartsCoverEveryScenario
  fails unless the parts name every createbatchequiv.Run scenario exactly
  once.
- TestWithPeerAuth_WarnsWhenStoredPeerSuppressesAmbientPassword (81s, eight
  cases each opening its own store) runs its table as two top-level tests,
  cases 1-4 and 5-8; cases and assertions unchanged.
- Durations re-measured on rbe-west under the whole lane's load; the
  Bazel-only block is now 40 shards (LPT heaviest = the heaviest single
  test, TestLifecycleCloseReopenContract ~71s). One target: 40 is under
  Bazel's 50-shard cap, so no offset split.

rbe-west, `bazel test //... --config=embedded --nocache_test_results`:
storage shards max 161s -> 89s, median ~118s -> 63s.

Bead: ga-vnycm2.28

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 21:21:20 +00:00
Julian Knutsen
66075be43a
ci(bazel): Bazel 9.3.0 (prerequisite for the remote repo contents cache) (#7439)
.bazelversion 9.2.0 -> 9.3.0. setup-bazel pins the 9.3.0 release
sha256s (bazel-9.3.0-linux-{x86_64,arm64}.sha256) next to 9.2.0's,
so the composite stays a valid byte copy for gascity until it bumps
too. MODULE.bazel.lock refreshed: 9.3.0's bundled module graph
resolves apple_support 2.5.2 and rules_cc 0.2.15 and changes four
extension bzlTransitiveDigests.

9.3.0 fixes bazel#30905 (the remote repo contents cache overlay
serialized getInputStream), the hard prerequisite for ga-vnycm2.25.

Refs ga-vnycm2.23

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 21:03:41 +00:00
Julian Knutsen
0d865460b1
ci(bazel): split the slow embedded cmd tests and run the cmd block as 2x50 shards (#7438)
//cmd/bd:bd_embedded_test was the embedded lane's floor: at Bazel's 50-shard
cap per rule, each shard's wall time was its slowest top-level test, and
~40 tests ran 65-130s on rbe-west.

- 34 slow TestEmbedded* functions are split into 89 smaller top-level
  functions. Subtests and table cases are moved verbatim: no assertion,
  flag or data changes, the same t.Run set per file, the same skip guard and
  t.Parallel. Subtests that read state earlier ones left stay together, in
  order; each new function repeats the shared setup it needs.
- The manifest's cmd/bd block is now 100 shards, run by two targets:
  bd_embedded_test (shards 1-50) and the new bd_embedded_part2_test
  (51-100), through go_test_manifest_shard.sh --shard-offset/--shard-total.
  check_shard_coverage.py takes SHARDS@OFFSET/TOTAL and fails unless the
  targets' ranges tile the block exactly once, so every test runs in exactly
  one shard of one target; the policy tests read both rules' ranges from
  cmd/bd/BUILD.bazel.
- Durations re-measured on rbe-west with the split tests and repacked. The
  frozen legacy 20-shard block drops the renamed names (no workflow reads
  it; new names hash-distribute as before).

Not split: the *Concurrent stress tests (their bd subprocesses queue on the
workspace's single writer lock: TestEmbeddedUpdateConcurrent is ~100
serialized bd commands), TestEmbeddedPurgeWispsPlaneRetention (one stateful
sequence), and the MaxRowsList* tests (setup is 21 sequential creates every
subtest reads).

rbe-west, both targets, --nocache_test_results: slowest shard 138-163s ->
109s (TestEmbeddedUpdateConcurrent alone; every other shard <=86s), median
80-84s -> 40s, shard-seconds 4.1-4.4k -> 4.2k, critical path 213-306s ->
113s.

Bead: ga-vnycm2.17

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 20:30:52 +00:00
Julian Knutsen
1531a31760
ci(bazel): halve the embedded cmd tier's cost (seeded bd init schema, no race exit sleep, concurrency-aware packing) (#7437)
//cmd/bd:bd_embedded_test sits at Bazel's 50-shard cap and was the embedded
lane's floor (shards 62-250s). Measured on rbe-west, every shard's wall time
was its single slowest top-level test, and most of a test's time was `bd
init` (~20s under -race: one Dolt commit per schema migration) plus a fixed
1s per bd subprocess exit (the race runtime's atexit_sleep_ms).

- bdInit seeds .beads/embeddeddolt/<db> from a per-process schema template
  (an empty database with every migration applied, made once per shard by a
  non-race build of internal/storage/embeddeddolt/cmd) before running the
  real `bd init`, which then skips the migration chain and does everything
  else itself (identity, prefix, config, hooks, agent files, git commit).
  Only for argument lists it understands (--prefix/--database plus
  --quiet/--skip-hooks/--skip-agents/--non-interactive), and it checks the
  result is the seeded embedded database. BEADS_TEST_FRESH_INIT=1 turns it
  off. The TestEmbeddedInit* tests run their own init and are unaffected.
- GORACE=atexit_sleep_ms=0 on the target: the bd subprocesses no longer
  sleep 1s before exiting. A race they hit while running still fails the
  command as before.
- TestEmbeddedInitSelectedExcludeRouting (serial, t.Setenv, 7 full inits,
  ~113s) is split into ...Stealth and ...Fork top-level functions; same
  cases, same assertions.
- The generator packs with a model of the shard process (pack_concurrent):
  tests without a top-level t.Parallel run one after another, the rest
  share -test.parallel=4. The durations are re-measured on rbe-west.

rbe-west, `bazel test //cmd/bd:bd_embedded_test --config=embedded
--nocache_test_results`: test-seconds 20.2k -> ~10.3k, shard-seconds
8.0k -> ~4.2k, slowest shard 243s -> 138s / 163s (two runs, before the
repack).

Bead: ga-vnycm2.17

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 19:20:33 +00:00
Julian Knutsen
6d27a4f96e
fix(issueops): enforce the close guards on every close leg (#7425)
* fix(issueops): enforce the close guards on every close leg

The template read-only guard, the pin guard and the assignee authority
fence (be-035) lived only in cmd/bd (validateIssueClosable), so a close
through bd serve, issues:batchClose, a batch:apply close item or a library
caller of Lifecycle.Close / BatchCloser / BatchApplier closed what bd close
refused.

They now run inside the close's own transaction in CloseIssueCheckedInTx
(enforceCloseGuardsInTx), the body every checked close shares (dolt,
embedded, uow, and the server behind httpapi), for a target that is not
already closed:
- a template refuses with *issueops.TemplateReadOnlyError (no bypass);
- unless Force (CloseRequest, CloseBatchRequest, CloseItem) is set, a pinned
  issue refuses with *issueops.PinnedError and another actor's bead with
  *issueops.CloseNotAssigneeError (matches ErrNotOwner).

Wire: 409 template_read_only, issue_pinned and not_assignee (holder in
`assignee`, also on a batch-close outcome); the client rebuilds the typed
errors. The decision is one exported pure rule over the pre-image,
issueops.CheckClosable (internal/storage/issueops), which the in-tx guard
calls; bd close's direct and proxied preflights call it too, ahead of gate
satisfaction under the same already-closed skip, so bd close output, refusal
order and exit codes are unchanged (validateIssueClosable is gone). bd close
--if-revision now applies the guards too.

Conformance: RunLifecycleCloseEnforcesTheCloseGuards,
RunBatchCloserItemsAnswerToTheCloseGuards and
RunBatchApplyCloseItemsAnswerToTheCloseGuards on dolt, embedded, uow and
http, plus handler mapping tests, a CheckClosable table test, and a cmd/bd
test pinning that the guards outrank gate satisfaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(httpclient): send force on the raw close; scope the close guards

Review fixes for #7425 (adopt-pr bd-0h0ao4, iterations 1 and 2).

The raw close keeps parity over http. httpclient.Store.CloseIssue maps the
off-role raw close onto the role's closeIssue op and sent force=false.
With the guards in the role, a pinned or claimed target then refused (409
issue_pinned / not_assignee) on http only: dolt, embedded and proxied run
the raw close as issueops.CloseIssueInTx, which applies neither the guards
nor close policy. The molecule auto-close, `bd gate resolve`,
`bd todo done` and `bd human dismiss` all make that call, and its
signature carries no force a caller could pass. It now sends force. Over
http that also stops applying close policy to the raw close, which it did
at base and no other backend does; parity is the point, so that goes too.
The template guard has no bypass on the wire, so a template still refuses
the raw close over http where the other backends close it; no raw caller
is known to close one. TestServedRawCloseKeepsParityWithTheOtherBackends
closes both pin spellings, a held bead and a parent with an open child
through Store.CloseIssue and requires the template refusal; with force
back to false it fails on 409 issue_pinned.

The close guards stay on the close verbs. A status update that crosses
into the done category (`bd update -s closed`, PATCH, a batchApply update
item) still answers to close policy only, so it closes a pinned issue or
another actor's bead on every backend, as it did before this PR. Guarding
it changes what the update legs admit and needs its own refusal mapping on
PATCH and batchApply, so it is left for a follow-up; the update.go and
domain/db comments now say the exclusion is deliberate.

CHANGELOG: the entry moves from Fixed to Changed as BREAKING, is scoped to
the close operations, names the two paths the guards do not cover, and
adds a Migration line (send force or reclaim; templates are never
closable). Docs: the OpBatchCloseIssues item codes, the CloseIssueChecked
and CloseIssueOptions.Force docs (storage, dolt, embeddeddolt), the
oracle-a scenario strings that named the retired validateIssueClosable,
and the TestCloseCheckOne_CloseGuardsOutrankGateSatisfaction doc, which
claimed a proxied route it does not drive.

Iteration 2: the wire contract says what force waives. The OpenAPI
`force` members of CloseIssueRequest, BatchCloseRequest and ApplyCloseItem
said force bypasses close policy "and nothing else"; it also waives the
pin and the assignee guard, and never the template guard. The batchClose
"only two answers" paragraph now says the same, and types.gen.go is
regenerated (`make api-gen`). "Close guards" names the close operations
instead of "every route to a close" and adds that a status update into
the done category is not one, and the PATCH done-crossing paragraph says
a patch is never refused `issue_pinned` or `not_assignee`. The conformance
comments that quoted the old Force sentence (batch_apply_contract.go,
batch_closer_contract.go, lifecycle_close_reopen_contract.go) quote the
current docs, and the batch_apply failure message no longer says Force
does nothing else. CHANGELOG: a `close` line of `bd batch` is named among
the raw closes, and "a template is never closable" becomes "the close
operations never close a template, forced or not". The storage interface
CloseIssue gains a doc that states its HTTP exception.

TestCloseGuardRefusalsPrintTheGuardSentenceOnEveryRoute pins the sentence
`bd close` prints for each guard (template, pin, assignee) through each
printer (closeDirectRefusal, closeDirectTypedRefusal, closeProxiedRefusal,
closeProxiedTypedRefusal), with the refusal bare, wrapped by the use case
and the SQL repository, or inside a served problem envelope. One pinned
refusal also goes through closeProxiedOutcomes and closeProxiedFailures,
where the stderr line and the `--json` error field must both be the
sentence. Six overlay mutants fail it: closeGuardRefusal recognizing no
guard, or not the pin, and each of the four printers skipping its call to
closeGuardRefusal.

Not done here: a CLI test that `--if-revision` exits 1 on a guard refusal,
not ExitGuardMismatch. External PR #7372 carries per-id fence tests for
that route (6 of 7 pass at this head); they are better absorbed with
credit than rewritten.

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: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 18:30:42 +00:00
Julian Knutsen
7896abbfa8
ci(bazel): scope the proxied lane's shared-server projects to their own database (44 -> 34 shards) (#7436)
* ci(bazel): scope the proxied lane's shared-server projects to their own database (44 -> 28 shards)

//cmd/bd:bd_proxied_test spends nearly all its time in `bd init
--proxied-server` against the shard's shared dolt sql-server. Measured
where that goes (dolt query log): of ~2,031 statements per init, the ~220
INFORMATION_SCHEMA queries (migration guards and pre-repair probes) are
~80% of server time at a handful of databases, the 81 DOLT_COMMITs only
~0.5s. Dolt evaluates INFORMATION_SCHEMA by walking every database the
session can see, so as root each init cost the server ~1.2 CPU-seconds
more per database already on it (locally 6.7 CPU-s with 1 database, 21
with 11): a shard's k-th init paid for the k-1 projects before it.

- proxied_shared_harness_test.go: newSharedProxiedProject now provisions
  the database server-side (root creates it plus a passwordless user of
  the same name with ALL on it and nothing else) and inits with
  --proxied-server-external-user, so each project's sessions see one
  database. newSharedProxiedRootProject keeps the old root/bd-creates-it
  shape for the four tests that need a server-wide privilege (DOLT_REMOTE
  remove, CREATE DATABASE, one compact statement); a run with the server
  log in test outputs showed no other denied statement.
- Dropping finished databases instead was tried and rejected: a DROP
  DATABASE fails other sessions' in-flight INFORMATION_SCHEMA queries
  ("no root value found in session"), ~35 init failures per run.
- No assertion changed. The bd-creates-the-database path stays covered
  by the root variant, the managed-local and non-shared init tests.
- proxied_test_durations.json re-measured (two rbe-west runs): 19,618 ->
  6,345 cost-seconds. 44 -> 28 shards, LPT-packed to ~227 per shard.

rbe-west, --nocache_test_results (BEP attempt durations): before 44
shards, sum 6,063s, max 186s; scoped users at 44 shards, sum 2,337s, max
68s; at 20 shards, sum 1,950s, max 136s.

Bead: ga-vnycm2.16

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): proxied lane 28 -> 34 shards for a <=100s slowest shard

PR CI at 28 shards (~227 packed cost each): 2,285 shard-seconds, median
78s, but max 113s; equally packed shards spread up to 1.45x the median.
34 shards (~187 each) targets a slowest shard under 100s.

Bead: ga-vnycm2.16

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-09 18:22:08 +00:00
Julian Knutsen
a945eca145
ci(bazel): fetch pinned Ubuntu debs in parallel from a gascity mirror first (#7434)
* ci(bazel): fetch pinned Ubuntu debs in parallel from a gascity mirror first

cc_sysroot_noble_amd64 downloaded its 7 pinned .debs one at a time from
snapshot.ubuntu.com, with only archive.ubuntu.com behind it. On
2026-10-09 the snapshot returned 503, and Bazel's retries against it
cost ~95 s per cold fetch before falling back (and archive.ubuntu.com
drops superseded versions, which would fail the fetch outright).

Same change as gastownhall/gascity (ga-vnycm2.11): deb_sysroot takes URL
templates ({path}, {file}, {sha256}) and starts every package download at
once (rctx.download block = False). NOBLE_DEB_URLS tries gascity's
content-addressed release mirror (toolchain-noble-debs-20261001, which
holds these exact pins; beads already takes its LLVM slice from a gascity
release), the snapshot, Launchpad's librarian, then archive.ubuntu.com.
The sha256 pins are unchanged and decide what is accepted; the unpacked
sysroot is byte-identical. The hermetic-cc guard now checks every
deb_sysroot: placeholders, the snapshot kept, two or more hosts, no
moving mirror first, no ICU.

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/37966817176
(`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>
2026-10-09 17:47:17 +00:00
Julian Knutsen
f21e3a80f7
fix(issueops): templates are read-only on every update leg (#7427)
* fix(issueops): enforce the template read-only update guard on every leg

The refusal of an update to a template (validateIssueUpdatable) lived only
in cmd/bd as a pre-read, so PATCH /v0/beads/issues/{id}, batch:apply update
items and library callers of Lifecycle.Update / BatchApplier edited
templates that `bd update` refused.

It is now one role rule, storage issueops.AuthorizeTemplateUpdate, returning
*issueops.TemplateReadOnlyError (matches ErrTemplateReadOnly; the message is
the sentence bd always printed). It runs in the update's own transaction,
after the compare-and-set preconditions (a stale guard still reports the
mismatch), and no force flag waives it:
- ExecuteUpdate (dolt, embedded) and the uow Update and batch update legs;
- the batch apply metadata splice that finishes a create item stays
  unguarded on both bodies (a template the request creates is not modified);
- httpapi maps it to 409 template_read_only on updateIssue and applyBatch
  (spec x-bd-codes and descriptions updated, apigen regenerated) and the
  client rebuilds the typed error.

UpdateRequest.AllowTemplate stands the guard down for one request: the
caller edits a template deliberately. bd label (add, remove, remove-prefix)
and bd set-state set it, so they keep editing templates on every route, as
on origin/main. Over HTTP it is the optional `allow_template` member of the
PATCH body, advertised by the issues.update.allowTemplate behavior token,
which also says the server enforces the guard. httpclient Lifecycle.Update
decides from the cached handshake before the dial: against a server without
the token (no guard, no member) it runs the same rule
(AuthorizeTemplateUpdate) on a pre-read and never sends allow_template, so a
new bd against an older bd serve still refuses template updates.

cmd/bd: bd update, bd assign and the proxied assign/tag drop their pre-read
and print the role's refusal with the same line and exit code.

Conformance: RunLifecycleUpdateRefusesATemplate,
RunLifecycleUpdateAllowTemplateEditsATemplate,
RunBatchApplyUpdateItemsRefuseATemplate and
RunBatchApplySplicesTheMetadataOfATemplateItCreates on dolt, embedded, uow
and http (the http splice case is parked: the v0 create item has no
is_template member), plus handler and CLI rendering tests, and
TestUpdateTemplateGuardAgainstAServerThatPredatesIt (new client, handshake
without the token: refused before the dial, allow_template not sent).

Skew note (CHANGELOG): an older bd label / bd set-state against a new server
cannot send allow_template and now gets 409 template_read_only on a template.
bd comment, note, priority and tag keep their CLI-only pre-read guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(issueops): scope template read-only docs to updates, test label stand-down

Review fixups for PR 7427 (adopt-pr review loop, iteration 1):

- Contract: the role guard covers updates, not every mutation. The
  CHANGELOG headline, ErrTemplateReadOnly and CodeTemplateReadOnly now
  say so, and "Not yet moved" names claim, reopen, :casMetadata and the
  served addComment, which have no template check yet (a PATCH with
  claim: true refuses a template that POST :claim still claims). Close
  is #7425's. Follow-up: bd-jkp9v3.
- Skew: the CapIssuesUpdateAllowTemplate client fallback covers
  updateIssue only. A batch update item gets no client-side check, so
  through an older bd serve it still edits a template; the CHANGELOG
  and both capability docs say so.
- Tests: a template row now goes through the CLI on both tiers
  (TestEmbeddedLabelEditReports, TestProxiedServerLabelC). bd label add,
  bd label remove --prefix and bd set-state edit it (AllowTemplate);
  bd update --title and bd assign exit 1 with the template sentence and
  leave it unchanged. Mutants: dropping AllowTemplate from label.go and
  state.go reds the three edits on both tiers; disabling
  AuthorizeTemplateUpdate reds update and assign on both tiers.
- Stale comments: runTagProxiedServer, applyUpdateProxiedOne,
  proxiedUpdateTarget, UpdateFlags (five booleans, not four) and the
  ItemUpdate notes in applyLabelEdit and bd label propagate's proxied
  route (UpdateItem has no AllowTemplate).

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>
2026-10-09 16:25:37 +00:00
Julian Knutsen
470ec832b5
feat(roles): LeaseReclaimer role, POST issues:reclaim, and bd reclaim on both routes (S9) (#7412)
* feat(roles): LeaseReclaimer role and POST issues:reclaim (S9)

Adds issueops.LeaseReclaimer.Reclaim(ReclaimRequest{Actor, OlderThan,
Filter}) -> ReclaimResult{Reclaimed []ReclaimedLease{ID, PreviousOwner,
Revision}}, the stale-lease sweep behind `bd reclaim`, on every leg:

- dolt, embedded dolt and the unit-of-work provider all run one body,
  internal/storage/issueops.ExecuteReclaimInTx over
  ReclaimExpiredLeasesInTx, and record one version commit per sweep that
  reverted anything through the issue-operation funnel (so a deferred
  version commit on the context is honored);
- each reverted row's fresh row_lock is published as its revision, so a
  former holder's guarded write fails with ErrVersionMismatch;
- an id that is not a stale lease (absent, live, unheld) is left out of
  Reclaimed, never an error; the id scope is capped at 1000
  (*TooManyReclaimIDsError, counted as sent);
- the hook decorator fires on_update once per reverted row (and the
  proxied notifying provider records one update per row); telemetry
  wraps it like every role.

bd serve publishes it as POST /v0/beads/issues:reclaim behind the new
issues.reclaim capability (httpapi.Config.LeaseReclaimer, required like
every role). Spec, apigen and the wire-shape golden are regenerated;
the change is additive and wire_revision is unchanged. The HTTP client
leg dials it (wire vocabulary, capability preflight, local validation
in the role's order).

Conformance: RunLeaseReclaimer* (12 cases: revert post-state, the
revision race, live lease, grace window, id scope with absent/live ids,
empty answer, assignee/label scopes re-homed from reclaim_scope.go,
recovery event attribution, on_update once per row, refusals, the cap
boundary, no request mutation) wired on dolt, embeddeddolt, uow and the
served http leg, and so held by the leg lock. Handler tests cover the
member mapping, the projection, every handler refusal by name and the
role's refusals reaching the wire.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(bd): bd reclaim runs the LeaseReclaimer role on both routes (S9)

`bd reclaim` takes issueops.LeaseReclaimer off the decorated store on the
direct route (so a connected HTTP workspace dials issues:reclaim instead
of refusing) and off the proxied provider's own accessor on the proxied
route, replacing the raw ReclaimExpiredLeases calls and
runReclaimProxiedServer. Visible changes: --json entries carry the
reverted row's new `revision`, the workspace's on_update hook fires once
per reverted row, and the version commit is the role's own
("bd: reclaim N expired lease(s)", honoring dolt.auto-commit through the
context the way bd prune does).

Tests: an embedded direct-route CLI test (scoped sweep with a live and an
absent id, revision, one version commit, on_update once) and the proxied
reclaim integration test now asserts the revision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(roles): S9 review LOWs: one validator, field attribution, overflow bound

- The library's ValidateReclaimRequest is the one definition of a valid
  reclaim: it now also refuses a blank assignee/label/label-any/exclude
  entry, and every refusal but the id cap is a *issueops.ReclaimFieldError
  naming its field. The httpapi handler no longer checks blank entries
  itself; failReclaimErr names the member the role's error is about
  (`ids` for the cap) instead of blaming `ids` for every validation. The
  HTTP client's restatement matches, pinned field by field.
- older_than_seconds is refused at >= MaxInt64/1e9: that float rounds to
  2^63 ns, which wrapped negative under the old > check.
- New contract case RunLeaseReclaimerRefusesABlankScopeEntry on all four
  legs; handler tests for field attribution and the overflow boundary.
- CHANGELOG names the 1000-id cap on bd reclaim --id and is rewrapped; the
  client's grace-window precision comment no longer claims exactness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(roles): S9 review: regenerate the unsupported shell, cgo-tag the embedded contract, one actor spelling

- go generate ./internal/httpclient: the new accessor moves the partial-shell
  trailer to 145 of 200.
- lease_reclaimer_contract_test.go gets //go:build cgo like its siblings, so
  the pure-Go lane compiles.
- The library trims the actor before attributing, matching the handler, so
  " alice " is attributed the same on every route.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(roles): S9 review minors: bound the reclaim actor on every leg, pin any_replica, validate before the uow

Review minors on #7412, each in code this PR adds.

- The reclaim actor lands on every reverted row's recovery event, in a
  VARCHAR(255) column, but ValidateReclaimRequest never bounded it: a
  256-character actor passed validation on the dolt, embedded-dolt and
  unit-of-work legs and failed the sweep with the backend's own
  "Error 1105: string '...' is too large for column 'actor'" on the first
  row it would have reverted (all three legs answer exactly that with the
  bound below removed). The shared validator now holds the trimmed actor to
  types.MaxFieldLen, as claimIssueInTx does, so it is a *ReclaimFieldError
  for `actor` on every leg. The HTTP client restates the rule, and the parity
  test covers both sides of it. bd serve already refused it through the
  claim's name rules. The role's Actor and REFUSALS docs name the bound, and
  the conformance case runs it on all four legs.
- ValidateReclaimRequest's doc no longer says bd serve's handler leaves every
  rule to it: it names the three wire rules the handler adds of its own.
- TestReclaimSendsAnyReplicaOnlyWhenAsked pins the one filter member that
  widens a sweep: the client sends any_replica only when the caller set it.
- The unit-of-work leg validates before opening its unit of work, as the dolt
  and embedded-dolt legs do; TestLeaseReclaimerRefusesBeforeOpeningAUOW pins
  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: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 14:56:32 +00:00
Julian Knutsen
c4c66d42a2
ci(bazel): rebalance the proxied-server tier on rbe-west measurements (30 -> 44 shards) (#7418)
//cmd/bd:bd_proxied_test's 30-shard block was packed from a local capture
of each test's <testsuite time>, which for a t.Parallel test spans the time
it sat paused behind its shard's other tests. Cheap tests that waited
looked as heavy as the shard, so the "balanced" block ran 38-286s per shard
in CI (356s on rbe-west).

- scripts/ci/proxied_test_durations.json: re-measured on rbe-west (two
  --nocache_test_results runs), each test's cost the sum of its leaf
  tests' <testcase time>, averaged over both runs.
- Measured where a test's time goes: nearly all of it is
  `bd init --proxied-server` against the shard's dolt sql-server (~2,000
  statements, 81 DOLT_COMMITs, ~6-12 server CPU-seconds per init), one per
  subtest. Top-level tests with ~20 such subtests ran up to ~350s alone,
  above any shard budget, so the fifteen heaviest are split into two or
  three top-level functions (TestProxiedServerUpdate/-UpdateB/-UpdateC,
  ...). Each subtest is moved verbatim; the split functions repeat the
  original's preamble.
- 30 -> 44 shards, LPT-packed to <=430 cost-seconds per shard.

rbe-west, --nocache_test_results: before 30 shards, max 356s, 5,671
shard-seconds; after 44 shards, max 159s (median 138s), 5,883
shard-seconds.

Bead: ga-vnycm2.3

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 08:53:35 +00:00
Julian Knutsen
f60de63a75
ci(bazel): 8 vCPU client for bazel-test, 4 vCPU for the other Bazel lanes (#7422)
Client-side loading and analysis is CPU-bound and gates every action in a
remote lane. Analysis-only measurements on Blacksmith (ga-vnycm2.8, seeded
runner cache, gazelle tools from the repository cache): bazel-test 25.6 s on
4 vCPU vs 16.3 s on 8; the other lanes 17-38 s on 2 vCPU vs 12-22 s on 4.
rbe-prewarm runs no Bazel client and stays on 2 vCPU (owner decision,
ga-vnycm2.12).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 08:45:05 +00:00
Julian Knutsen
b162e0a482
ci(bazel): cut embedded/test lane long shards (served template, bulk seed, rebalance) (#7416)
* ci(bazel): cut embedded/test lane long shards (served template, bulk seed, rebalance)

Embedded lane (bazel-embedded):
- RunBatchGetterAcceptsExactlyTheCap seeds its 1000 issues through a new
  optional BatchGetterFixture.CreateIssues hook (one write) instead of 1000
  single-row commits. Wired for the embedded, served and dolt-server legs;
  the UOW leg keeps the per-row fallback. Same rows, same GetMany
  assertions. TestBatchGetterContract 199s -> ~7s and
  TestServedBatchGetterContract 204s -> ~7s on rbe-west.
- The served-surface harness (newServedEnv) copies one per-process,
  freshly initialized reference workspace instead of initializing an
  embedded Dolt schema per case, the same pristine-template pattern
  internal/storage/embeddeddolt's tests already use (bd-7q32v).
  //internal/httpclient:httpclient_served_test: 3,713 -> ~1,200
  shard-seconds; 24 -> 16 shards; heaviest shard 390s -> ~108s.
- //internal/storage/embeddeddolt:embeddeddolt_embedded_test: re-measured
  every test on rbe-west (scripts/ci/embedded_storage_test_durations.json)
  and repacked 15 -> 20 shards (packed heaviest ~110s; was 352s in CI).

Test lane (bazel-test):
- //internal/httpclient:httpclient_test: unsharded (137-228s) -> 2 shards
  (76s / 97s measured).

Bead: ga-vnycm2.3

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(dolt): seed the BatchGetter cap case without prefix validation

The dolt-server leg's shared test store is configured with prefix "test",
so the batch CreateIssues path's prefix validation refused the fixture's
bge-* ids (the per-row CreateIssue the other seeds use does not validate).

Bead: ga-vnycm2.3

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): shard //internal/storage/embeddeddolt:embeddeddolt_test 9 ways

At 8 round-robin shards one shard drew the package's three heaviest tests
(153s on rbe-west in this PR's test lane); 9 spreads them.

Bead: ga-vnycm2.3

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-09 08:02:40 +00:00
Julian Knutsen
a13272b024
ci(bazel): serve gazelle's go_repository tools from the repository cache (#7417)
* ci(bazel): serve gazelle's go_repository tools from the repository cache

Every bazel.yml lane starts from a fresh output base, and before any go_deps
repository can be fetched gazelle compiles fetch_repo and gazelle with
`go build` in @bazel_gazelle_go_repository_tools: 18-24 s of every 2 vCPU
lane's loading phase (the top ci-analytics repo_fetch entry in the
embedded, proxied, cmd-dolt and test lanes).

tools/bazel/go_repository_tools.bzl replaces that repository (override_repo
on gazelle's non_module_deps extension). The build is reproducible, so the
three binaries are pinned by sha256 per gazelle release, Go SDK and host.
The rule asks the repository cache for the pinned digests first (Bazel
re-hashes every hit, so a restored runner cache can only yield the pinned
bytes); on a miss it builds exactly as gazelle does, inside env -i, and
stores a matching build in the repository cache. An unpinned or stale
combination still builds from source and prints the digests to pin.
scripts/bazel_go_repository_tools_test.go keeps the pins in step with
MODULE.bazel's gazelle and go_sdk versions. The runner cache key already
includes MODULE.bazel, so the first push to main after this saves them.

Analysis-only (--nobuild) per lane on Blacksmith 2 vCPU, main vs this change
with a seeded runner cache (ga-vnycm2.8): test 54.0 -> 38.3 s, embedded
53.6 -> 31.1 s, integration 49.6 -> 35.2 s, doltserver 48.5 -> 33.0 s,
proxied 46.6 -> 31.6 s, server-storage 33.5 -> 17.3 s, cmd-dolt 50.3 -> 33.0 s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): pin gazelle's go_repository tools for Go 1.26.9 too

Ready for the next go_sdk bump (gascity#7387 moves to 1.26.9 for the
2026-10-08 advisories): the same binaries keep coming from the repository
cache instead of failing the pin test.

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-09 07:57:01 +00:00
Julian Knutsen
64e585e62a
build(rbe): sync worker-env pin with gascity main (Go 1.26.9 re-pin, gastownhall/gascity#7387) (#7419)
gascity #7387 (Go 1.26.9 / x/net v0.60.0 advisories) re-pinned worker-env to
sha256:0c6c05c2...; rbe-west's pool workers advertise that, so every beads
remote-execution run since ~06:00Z stopped in the worker-env preflight.
Copied tools/rbe/worker-env.txt and the platforms/BUILD.bazel pin from
gascity main; tools/rbe/worker-env-sync main now reports in step.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 07:39:01 +00:00
Julian Knutsen
ce582394fe
build(rbe): re-pin worker-env to gascity's go1.26.9 worker host (#7411)
gastownhall/gascity bumps Go to 1.26.9 for the 2026-10-08 stdlib
advisories (GO-2026-6599..6617). The shared rbe-west pool workers install
the Go named in gascity main's go.mod, so once that merges they advertise
a new worker-env. This is the byte-for-byte copy of gascity's
tools/rbe/worker-env.txt and its pin (tools/rbe/worker-env-sync); merge it
together with the gascity change or beads' remote actions stop scheduling.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 07:38:56 +00:00
Julian Knutsen
5a5b7cfd66
ci(bazel): pin the slowest cmd/bd Dolt-server tests to their own shards (#7413)
* ci(bazel): pin the slowest cmd/bd Dolt-server tests to their own shards

The cmd-dolt lane's wall time when its tests re-run is the bd_test race
compile plus its slowest shard. rules_go shards round-robin by test index,
so whichever shard drew TestSharedServerConcurrent and the TestInit*
family ran 117-170s while the median shard ran ~55s.

tools/bazel/go_test_pinned_shard.sh runs a go_test binary with the tests a
committed manifest pins (measured >= 5s, bin-packed longest-first by
tools/bazel/pin_shards.py) in shards of their own, and every other test in
the binary's own round-robin shards with the pinned set skipped, so each
test still runs exactly once and new tests need no manifest edit.
bd_dolt_server_test goes from 16 to 32 shards (16 pinned + 16 round-robin),
regression_test from 8 to 16 (10 + 6; its go_test becomes the manual
regression_suite binary behind an sh_test of the old name).

Pinning exposed a pre-existing order dependence: TestCLI_Import failed
whenever it was the binary's first test, because runBDInProcess reused the
workspace discovery an earlier in-process execution cached and `bd init` in
a fresh directory resolved the previous one's .beads. The in-process
runners now reset beads/git discovery caches per execution.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): pin cmd/bd Dolt-server shards from two measured runs; regression in 14 shards

The bd manifest now takes each test's slowest of the 16- and 32-shard runs
(pin_shards.py over both), and regression_test drops to 10 pinned + 4
round-robin shards: its unpinned tests total ~128s, so 6 round-robin
shards were mostly fixed cost.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(scripts): place the pinned-shard tests by what they read (#7414 split)

The manifest-name scan reads every cmd/bd and tests/regression _test.go
file, so it moves to go_test_sources_test (with tests/regression's
manifest); the wrapper, generator and wiring checks stay in scripts_test.
Shared helpers live in a helpers-only file both targets compile, and
repoFiles takes #7414's minimum-file count.

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-09 05:50:09 +00:00
Julian Knutsen
d90823480a
ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414)
* ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files

//scripts:scripts_test declared //:repo_files (the whole checkout), so every
PR re-ran it, and it took ~181s on rbe-west. Most of that (60-79s) was
TestBazelGatedLanesNeverRetryFlakyTests line-regexping the --run_under
wrapper's pinned dolt binary (tools/bazel/hermetic_bin/dolt, in every
test's runfiles); it now skips binary files, as git grep -I does.

tools/bazel/go_srcs.py's per-package repo_files block now partitions each
package's files into repo_go_srcs, repo_go_test_srcs, repo_doc_files and
repo_other_files, aggregated at the root; //:repo_files is their union
(same 4679 files). The //scripts tests are split into go_test targets by
what they read (traced per test with strace over a runfiles-shaped tree):

  scripts_test          CI/Bazel policy: //:repo_other_files (+1 Go file)
  shell_scripts_test    script fixtures: //scripts files, a few root files
  go_test_sources_test  _test.go scans: //:repo_go_test_srcs + shard files
  go_sources_test       check-testing-short.sh: every .go file
  tracked_files_test    every tracked file: //:repo_files

Shared helpers move to helpers-only files; TestScriptsTestTargetsPartition-
TheTests fails on a test file in no target or in two. //test/docsync and
the //scripts/repochecks slices declare partitions or single files instead
of //:repo_files where they can.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): skip only the non-checkout hermetic_bin dir in the flaky-retry walk

Skipping every binary file also stopped scanning tracked binaries (images,
.binpb fixtures). Skip just tools/bazel/hermetic_bin, the --run_under
wrapper's runfiles directory, which is not in the checkout, so the walk's
coverage of tracked files is unchanged.

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-09 05:13:07 +00:00
Julian Knutsen
533f95295a
feat(httpclient): BatchApplier over HTTP — handshake cap, dep_add lineage on the wire, gc mappings (S5) (#7265)
* feat(httpclient): carry DepAddItem.HasSpawner/ThreadID over the wire

The http leg's batchApply wire shape dropped a dep_add item's HasSpawner
and ThreadID fields -- an edit the caller believed landed. Extend the
wire body (ApplyDepAddItem.has_spawner/thread_id), gate sending either
field on a new additive behavior capability
(issues.batchApply.depAddLineage / CapBatchApplyDepAddLineage) so a
client refuses locally before dialing an older server instead of
silently dropping graph lineage, and wire the storage-layer spawner-id
stamping (StampWaitsForSpawnerID) through both the dolt and uow legs
that already had the fields but never stamped them. wire_revision and
min_client are unchanged; the golden digest and openapi spec are
regenerated.

Also fixes three generic bijection/vocabulary gates this change was
missing: write_ledger_test.go's applyBatch/item/dep_add carriage table,
and the literal behaviorCapabilities lists in
internal/httpapi/server_test.go and
internal/httpclient/wire/vocabulary_test.go.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(httpclient/wire): pin the item-count gate at 356 items

Add TestApplyBatchAt356ItemsWithoutTheCapabilityRefusesBeforeDialing,
exercising internal/storage/batchfixtures.Shape356's exact item count
-- the design's primary measured large-batch-apply shape -- rather than
only the floor+1/ceiling+1 boundaries the existing cases pin. The gate
is content-agnostic (it never looks past len(body.Items)), so a
synthetic plan here is behaviorally identical to a real Shape356 plan
for this one check; realistic-content coverage follows in the next
commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(httpclient): prove a 356-item Shape356 plan commits atomically or leaves zero rows

Add two tests against the real served stack using
batchfixtures.Shape356's realistic, heterogeneous content (102 creates,
136 blocks edges, 102 tracks-to-root edges, 16 assign updates):

- TestServedBatchApplyShape356CommitsAtomically applies the full plan
  once and verifies every create landed with a bound key, matching the
  issues table row-for-row.
- TestServedBatchApplyShape356PlusAStaleGuardLeavesZeroRows appends a
  357th item guarding the pre-existing root issue with a deliberately
  stale ExpectedVersion. Because the root is untouched by the other 356
  items, this exercises the real server-side precondition_failed round
  trip (rather than the static same-request-row ErrValidation rule),
  asserting errors.Is(err, issueops.ErrVersionMismatch) and that none of
  the 356 creates landed -- the "never chunk" ceiling: an all-or-nothing
  request that fails on its last item must leave nothing behind.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(httpclient): close S5 review HIGH findings (lineage gate, thread_id, gc mappings)

2026-10 Opus review on the S5 batch-apply slice found the wire change
correct but coverage missing:

- HIGH-1: refuseUnservedDepAddLineage (batchapplier.go) had no coverage
  at all -- deleting it passed every existing test. Add a test pinning
  that HasSpawner or ThreadID on a server without
  issues.batchApply.depAddLineage refuses *storage.ErrUnsupported
  before dialing, and that a plan touching neither field still dials.

- HIGH-2: thread_id was never asserted end to end. Add
  RunBatchApplyCarriesThreadIDOntoTheStoredEdge to the shared
  conformance package, wire it onto the dolt, embeddeddolt and uow
  legs, and add the http leg's own case
  (TestServedBatchApplyCarriesThreadIDOntoTheStoredEdge), which is the
  one case that proves the field survives both the client's encode and
  the server's decode at once.

- HIGH-3: DESIGN Sec 3.8 ("Guarded writes: no new roles") documents two
  gc mappings onto BatchApplier that had no coverage: an update carrying
  a metadata patch plus ExpectedVersion followed by a close in one
  request (CloseWithMetadataIfMatch, atomic -- a stale version leaves
  zero changes), and a keyed create/MetadataRefs/dep_add
  (parent-child included)/trailing-update plan (ApplyGraphPlan). Document
  both compositions on the BatchApplier interface and add http-leg tests
  for each.

Mutation-verified: removing the lineage gate call, dropping thread_id on
the client's encode, and dropping it on the server's decode each now
fail a test that previously passed unconditionally.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): nil-guard snapshot consumers, fix spec wording, sync Bazel

2026-10 Opus review MED/LOW findings on the S5 batch-apply slice:

- LOW-6: Store.snapshot returns (nil, nil) when a Store has neither a
  wire nor a cached handshake. Store.Counter() does not call roleWire
  first (unlike Sweeper/BatchApplier), so this is reachable through the
  ordinary public accessor and a scoped count would panic on
  snap.Capabilities. Nil-guard every snapshot() consumer
  (batchapplier.go, counter.go, sweeper.go) so a nil snapshot is treated
  as "nothing advertised" and falls through to the capability refusal.
  Add TestCounterRefusesScopeGracefullyWithNoTransportAndNoSnapshot,
  mutation-verified to panic without the guard.

- LOW-7: the ApplyDepAddItem spec comment said an old server would
  "silently ignore" has_spawner/thread_id; it answers its own 400 for
  an unknown member. Fix the wording and regenerate apigen/types.gen.go.

- MED-4: internal/httpclient/BUILD.bazel was missing
  served_batch_apply_large_test.go, expected_revision_contract_test.go,
  served_dualwrite_history_test.go and the
  //internal/storage/batchfixtures dep. Sync with gazelle (confirmed
  idempotent) and go_srcs.py --check.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): carry thread_id on a same-type dep re-add; bound batch thread_id

A same-type re-add of an existing dependency compared and rewrote only
metadata, so on both write legs (issueops.addDependencyInTx and the uow
dependency repository) a re-add naming a new ThreadID was read as
change-free and the thread was dropped, and a metadata-plus-thread re-add
stored the metadata without the thread. Both arms now read the stored
thread_id through one shared rule, issueops.ReAddedDependencyThread: a
named thread the row does not carry is a change (UPDATE, replacement-edge
journal entry, exactly one version, #5898 leg 2), and a re-add naming no
thread keeps the stored one, so callers that never carry a thread cannot
erase it. The journal's EventDep has no thread member, so a thread-only
re-add journals the same payload as the original add; the source's version
snapshot is what records the new thread, and the comments on both arms now
say so instead of promising a complete replacement edge.

planApplyBatchDepAdd bounds DepAddItem.ThreadID with CheckFieldLen, so an
over-long thread id is ErrValidation before any database work on every
leg, as the http leg's decode already refuses it, instead of an opaque
mid-transaction "string too long" on the local legs. Only the length bound
is shared: the http leg's control-character refusal stays http-only.

The HasSpawner/ThreadID docs now name the producer that actually sets
HasSpawner (an embedder lowering a graph plan, e.g. gc's ApplyGraphPlan
mapping) instead of bd create --graph, and drop the CHANGELOG reference
that had no entry behind it.

New conformance cases, wired on dolt, embeddeddolt, uow and served:
RunBatchApplyCarriesThreadIDOntoAnExistingEdge,
RunBatchApplyRefusesAThreadIDLongerThanItsColumn and
RunDependencyEditorSameTypeReAddWithChangedThreadMintsOneVersion.

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>

* ci(shards): add the re-add thread test to the embedded storage shard manifest

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci: trigger the first PR CI run now that the base is main

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(httpclient): gate has_spawner to waits-for edges; refuse empty thread_id

Review iteration 1 fix-up for #7265 (synthesis F1, F2, F4, F5, F6, F7).

F2: the client's CapBatchApplyDepAddLineage gate refused HasSpawner on
every edge type, but the role reads the flag on a waits-for edge only
(StampWaitsForSpawnerID is a no-op off one). An embedder plan setting it
on, say, a blocks edge works against every existing server, yet this
client refused it during a mixed-version rollout. depAddNamesSpawner now
holds the role's own rule: the flag is gated and encoded on a waits-for
edge only, and dropped elsewhere, which loses nothing the role would
store. ThreadID stays gated on every edge type, since a thread is stored
on all of them. The "spawner flag on any other edge type" subtest is
restored to an unadvertising server and now also asserts the flag is
dropped from the body, and
TestApplyBatchRefusesUnservedDepAddLineageBeforeDialing gains a
ThreadID-on-blocks case. The W-DepAddItem.HasSpawner ledger row and the
regenerated engdocs/design/http-divergence-ledger.md say the same.

F5: the document gives thread_id minLength: 1, but the decoder read an
empty string as no thread. applyDepAddItem now refuses a present, empty
thread_id with 400 invalid_value naming items[i].dep_add.thread_id, as
it does an empty type; an absent one still names no thread. New
TestApplyBatchRefusesAnEmptyThreadID; the documented-body test now
forwards has_spawner and thread_id as well.

F1: bd create --graph does set HasSpawner (buildGraphApplyBatchRequest,
on the embedded and proxied legs, since #7209), so the DepAddItem doc
names both producers again and the conformance doc's CHANGELOG pointer
is restored; the [Unreleased] entry behind it is on the base.

F4: the CapBatchApplyDepAddLineage comment said an older server would
silently drop the members; it answers either one with
400 invalid_argument/unknown_parameter.

F6: the create-edge ledger comment said no operation publishes a thread
member; batch apply's dep_add item now does.

F7: TestServedBatchApplyGcApplyGraphPlan adds a waits-for item carrying
HasSpawner and ThreadID and reads the stored row back, pinning
metadata.spawner_id to the resolved spawner and the thread on the
served leg.

F3 (the journal's EventDep carries no thread member) is not addressed
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: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-09 01:05:39 +00:00
Julian Knutsen
5126de8c1a
perf(bd): no git subprocesses on read-only commands (in-process repo discovery, lazy actor, backup probe) (#7400)
* perf(git): locate the repository in-process instead of running git rev-parse

Every bd invocation resolved the process-wide git context (beads directory
discovery reads it) with `git rev-parse --git-dir --git-common-dir
--show-toplevel`: one git subprocess per bd call before any work. Tools that
call bd hundreds of times (gascity's doctor issues ~250 bd calls per run)
paid it on every call.

On Linux, initGitContext now first runs discoverGitInProcess, which mirrors
Git's discovery walk (physical cwd, .git as directory or gitfile, bare-dir
check, filesystem-boundary stop) and produces byte-for-byte what rev-parse
prints for ordinary repositories (top and subdirectories), linked worktrees
(absolute or relative gitfile, symlinked targets), submodules (core.worktree
pointing back at the gitfile's directory), nested repositories and no
repository. Both answers feed one shared normalization
(gitContextFromRevParse), so downstream values are unchanged.

It declines, and git runs exactly as before, whenever it cannot prove the
answer: GIT_DIR / GIT_WORK_TREE / GIT_COMMON_DIR / GIT_CEILING_DIRECTORIES /
GIT_DISCOVERY_ACROSS_FILESYSTEM / GIT_OBJECT_DIRECTORY / GIT_CONFIG_PARAMETERS
/ GIT_CONFIG_COUNT in the environment; a symlinked .git, an invalid gitfile
or git directory, a cwd inside a git directory; repository config with
core.worktree (other than the submodule shape), core.bare, extensions,
include directives, a format version above 1 or unmodeled syntax; any path
not owned by the effective uid (safe.directory is git's to evaluate), or
root under sudo. darwin and windows keep the subprocess (case folding and
ownership semantics).

Tests compare discoverGitFrom with real `git rev-parse` output across those
layouts, pin every decline case, and check the resulting cached context
equals the subprocess-derived one.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* perf(cli): resolve the git user.name actor fallback only when needed

PersistentPreRunE assigned `actor = getActorWithGit()` for every command,
which, with no --actor / BEADS_ACTOR / BD_ACTOR / config actor, runs
`git config user.name`: the second git subprocess of every bd call, paid
by read-only commands that never consult the actor.

The pre-run now calls deferActorGitFallback, which marks an empty actor as
pending; currentActor (and getActorWithGit, getActor) resolve it on first
use with the unchanged priority order and store it in the global and the
CommandContext copy, as the eager assignment did. Command code reads the
actor through currentActor() instead of the raw global (a mechanical
rewrite of every read site the compiler reported; writes, the flag binding
and the pre-run config binding keep the raw variable). setActor cancels a
pending fallback. The telemetry span's bd.actor attribute is still set, but
only for a recording span, so a noop span does not force the lookup.

With the in-process repository discovery from the previous commit, a
read-only `bd list` / `bd show` now starts no git process at startup, in
the main checkout and in a linked worktree; a write asks git for user.name
once (bd create previously asked once, now still once) and records the same
value. Measured on 50 sequential `bd list` calls: 100 -> 0 git execs
(embedded and proxied-server workspaces, main checkout and worktree).

TestEmbeddedReadOnlyCommandsSpawnNoGit counts git execs through a PATH shim;
TestDeferredActorGitFallback pins the deferral semantics.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(git): decline in-process discovery on any config line git might read differently

Review follow-ups to the in-process repository discovery.

- The repository config scanner was looser than git: a config starting with
  a UTF-8 BOM followed by `[core] worktree = /other` made git report /other
  while discovery returned the cwd repository, and `[ core ]` or `!!! = x`
  (which git refuses) were accepted. scanGitConfig (gitconfig_linux.go) now
  skips a leading BOM exactly as git does and accepts only a narrow grammar:
  blank/comment lines, `[section]` / `[section "sub"]` headers at column 0,
  and `key` / `key = value` lines inside a section, with values free of
  backslashes and unbalanced quotes. Any other line declines to git.
- Walk from getcwd(2) (syscall.Getwd), as git does, instead of os.Getwd,
  which trusts $PWD when it names the same inode (bind-mount aliases).
- Resolve relative gitfile and commondir targets without filepath.Join's
  lexical Clean, so "link/.." resolves physically like git's realpath.
- A mount-boundary stop reports its own reason in the not-a-repository
  error.
- Tests: every decline case (BOM + core.worktree, malformed headers and
  keys, keys before a section, escapes, continuations, bare repositories,
  a commondir inside .git, ...) now also checks that what startup derives
  equals git's answer; BOM and CRLF/comment configs are equivalence cases;
  the no-repository case must be answered in-process instead of skipping;
  a $PWD alias test pins the getcwd walk.
- The exec-count test drops every GIT_* variable except the config-file
  selectors, so a runner exporting GIT_CONFIG_PARAMETERS & co. cannot make
  it fail spuriously.
- Comment the two places that touch the raw actor before the deferral.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* perf(backup): decide embedded auto-backup's git-remote probe without git

In an embedded workspace whose backup.enabled is unset, maybeAutoBackup
asks isBackupAutoEnabled -> primeHasGitRemote after every command, reads
included. That built a RepoContext (`git -C .beads rev-parse
--git-common-dir`) and ran `git remote`: two git processes per read even
after the startup calls were gone. The throttle cannot short-circuit it:
without a remote no backup ever runs, so there is no backup state to
throttle on.

Both probes are now answered in-process when provable, and the subprocess
remains the fallback, so the decision and every warning/notice downstream
of it are unchanged:

- internal/beads getGitCommonDirForPath uses git.CommonDirInProcess (the
  discovery walk from the given directory, git's spelling).
- primeHasGitRemote uses git.HasRemoteInProcess in the same directory
  primeGitCmd would run git in (primeGitDir, factored out). It answers only
  when every config file `git remote` reads -- system (GIT_CONFIG_SYSTEM, or
  /etc/gitconfig and <prefix>/etc/gitconfig of the git on PATH), global
  (GIT_CONFIG_GLOBAL, or XDG and ~/.gitconfig) and the repository's own --
  is absent or within scanGitConfig's grammar and include-free, no
  GIT_CONFIG_PARAMETERS/COUNT/GIT_CONFIG or discovery override is set, and
  no legacy .git/remotes or .git/branches entries exist. A remote seen only
  in a system-config candidate declines. Remote names outside
  [A-Za-z0-9._-] decline.

Tests compare HasRemoteInProcess with `git remote` (no remote, local,
worktree, submodule, remote.pushDefault only, global remote, no repo) and
pin the declines (global include, malformed global, command-line config);
CommonDirInProcess is compared with `git -C dir rev-parse
--git-common-dir`. TestEmbeddedReadOnlyCommandsSpawnNoGit now runs with
backup.enabled at its default, with and without a git remote, and still
expects zero git processes for list/show.

Agent-Signature: claude-code-claude-opus-5-5-medium 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-08 20:08:24 +00:00
Bee
a6fcf915c0
fix(gate): resolve a bead gate whose awaited bead no longer exists (#6395)
* fix(gate): resolve a bead gate whose awaited bead no longer exists (wy-dgfuiu)

A gate with await_type=bead whose awaited bead has been purged could never
resolve: GetIssue returns storage.ErrNotFound (or a wrapped sql.ErrNoRows)
against real storage, checkBeadGate returned (false, "bead gate %q: %v"), the
bead arm of evaluateGates never sets r.err, and applyGateCheckResults fell to
the "pending" arm with exit 0. The gate stayed pending forever.

Treat a missing bead as resolution, reusing the existing gateProxiedNotFound
predicate so a genuine backend or transport failure still stays pending.
close.go shares checkBeadGate and inherits the fix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MjQHZQoR8qZTaNj2QTZokr

* fix(gate): resolve a deleted bead gate target only after a local sighting

Review fixes for #6395 (adopt-pr iterations 1 to 5).

The PR resolves a bead gate when its awaited bead no longer exists, but
the lookups it relies on turned a routing failure into not-found: the
direct getter (getIssueWithRouting) and the proxied getter both returned
the local miss when a prefix-routed rig could not be read, so an OPEN
bead in an unreachable rig resolved its gate and unblocked the step. An
await_id that never named a real bead (a typo, a short ID) also resolved
on the first check.

- A miss outside this rig's own store is errBeadGateTargetUnconfirmed: a
  matched routes.jsonl route whose rig fails or does not return the bead,
  an unreadable routes.jsonl, or the contributor auto-routed store. The
  gate stays pending and the reason names the cause. inspectBeadGate
  tests it before not-found, because the wrapped routing error can itself
  be a not-found. Only this rig's own absence counts as gone.
- bd gate check resolves a gone target only if an earlier check saw it in
  this rig. The first local sighting stamps await_seen=<await_id> in the
  gate's metadata (an OpSetMetadata merge, so other keys survive, and
  retargeting the gate invalidates it). A target that is gone and was
  never seen stays pending with "no earlier gate check saw it; check the
  await_id, or close the gate with bd gate resolve". A bead read through
  a route is never stamped, so a misdirected route cannot arm a later
  local miss. A failed stamp write is an error row, like a failed gh:run
  await_id persist.
- The proxied getter reads the target with workapi.GetIssueOrWisp (the
  issue use case alone never returns a wisp), stamps inside the apply
  transaction, and never auto-routes.
- bd close applies the same rule (evaluateBeadGate, recording no
  sighting): a gone bead satisfies the gate only if an earlier check saw
  it, so closing a gate on a typo'd await_id still needs --force.
- bd close reads the awaited bead from the store that owns the gate
  (RoutedResult.Store), as bd gate check in that rig would. Read from the
  launcher's store, a routed gate whose awaited bead only its own rig can
  reach (no route for it from the launcher) saw that open bead as missing
  and, its sighting recorded, closed without --force. The proxied-server
  route keeps the fresh-read getter (#5861).
- bd rename and bd rename-prefix (both the rename loop and --repair) point
  a bead gate at its bead's new ID, keeping a <rig>: prefix and carrying
  the sighting. UpdateIssueID rewrites text references but never
  await_id, so a seen bead's rename read as a deletion and resolved the
  gate on its next check.
- UpdateIssueID also commits on its own, so a retarget written after it
  left a window, or after a failure a lasting state, where the gate held
  a sighting of an ID that no longer existed and resolved while its bead
  was open under the new ID. All three paths now rename through
  renameIssueKeepingBeadGates, which orders the writes so no state in
  between resolves a gate: it moves await_id to the new ID while the
  sighting still names the old one (dropping, in the same write, a
  sighting that already names the new ID), renames the bead, and then
  records the sighting under the new ID. A check in between finds a
  never-seen ID and stays pending. If moving a gate or renaming the bead
  fails, the gates are pointed back at the old ID without a sighting,
  since a failed write may still have landed, and the rename fails:
  bd rename exits non-zero instead of warning from its text-reference
  loop. Losing only the final sighting write is a warning; the next
  check records the sighting again.
- A check lists the gate before it looks the bead up, so a rename landing
  in between left it holding a copy that still waited on the old ID with
  its sighting: the old ID was gone, and the check closed the gate while
  the bead was open under its new ID. Once the bead is found gone,
  evaluateBeadGate reads the gate back from its own store
  (rereadBeadGate) and resolves only if the stored gate still waits on
  the same await_id and still records the sighting. The rename moves the
  gate before the bead takes the new ID, so a read made after the miss
  sees the move. This covers bd gate check, its proxied route and
  bd close; a gate that cannot be read back, or is found only through a
  route, stays pending.
- checkBeadGate, the target lookup without the sighting rule, had no
  production caller left and read like the bead-gate rule, which is how
  bd close came to skip the sighting. It moves into the tests;
  inspectBeadGate carries the lookup contract and points callers at
  evaluateBeadGate.
- The gate check help, docs/workflows/gates.md and the CHANGELOG describe
  the rule, including that a rename does not read as a deletion to a
  check or bd close that read the gate before it, and that a rename that
  fails partway leaves the gate pending without a sighting; the #6404
  entry no longer says a routed read failure reads as not-found. The
  CHANGELOG also warns that a rename by an older bd does not move the
  gate, so once a check has seen the bead, the next check or bd close
  after that rename closes the gate while the bead is still open:
  upgrade the clients that rename beads together with the ones that
  check gates. docs/cli-reference is pinned to v1.2.2, so it is
  unchanged (generate-cli-docs.sh --check passes).

Tests: TestCheckBeadGate_UnconfirmedMissStaysPending,
TestEvaluateGates_BeadGateSightingRule, TestEvaluateBeadGate_*,
TestBeadGateSeenUpdate_KeepsOtherMetadata, TestBeadGateTargetSeen,
TestProxiedFreshReadGetter_LocalMissFollowsRoutes,
TestRoutedBeadGateGetter_ReportsWhereTheAnswerCameFrom,
TestCheckGateSatisfaction_BeadGateNeedsASighting,
TestCloseDirectPreflight_BeadGateReadsTheGatesOwnStore,
TestCloseBeadGateGetter_RouteSelection, TestBeadGateRetargetUpdate,
TestPlanBeadGateMoves, TestRenameIssueKeepingBeadGates and
TestRenameIssueKeepingBeadGates_FailedWritesResolveNoGate, which fails
each write of a rename in turn, landed or not, and evaluates every gate
after each write, both as stored and as a concurrent check listed it
before the rename (unit); the unreadable-rig step of
TestCheckBeadGateCrossRigPrefixRoute,
TestRepairPrefixesRetargetsBeadGates (gates renamed before and after
their bead) and TestRenameFailureLeavesBeadGatesPending (bd rename,
--repair and rename-prefix with a failing UpdateIssueID, landed or not)
(cgo);
TestEmbeddedGateCreate/check_bead_gate_resolves_only_a_missing_target_it_saw
and /rename_keeps_a_bead_gate_on_its_target (embedded);
TestProxiedServerGateCheck/bead_gate_resolves_when_seen_target_is_deleted
and /bead_gate_never_seen_target_stays_pending (proxied). Reordering the
unconfirmed case after not-found, dropping the sighting condition,
swallowing the routed error, stamping routed sightings, or matching any
stamp regardless of await_id each fails these tests, as do closing with
the sighting-blind lookup, reading the launcher's store on close,
dropping the carried sighting or the rig prefix on a retarget, dropping
the retarget from bd rename, the rename-prefix loop or --repair,
renaming the bead before moving its gates, keeping the sighting when
moving a gate back, keeping a stale sighting of the new ID, skipping
the final sighting write, resolving a gone bead without reading the gate
back or from a gate read back that moved, lost its sighting or was found
only through a route, or reporting an unconfirmed read-back as an error
or an unreadable gate as pending.

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 Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-08 17:10:33 +00:00
Julian Knutsen
2dda7052e0
feat(httpclient): write-role conformance on the http leg — ceiling to zero, sweeper extension (S4) (#7251)
* feat(httpclient): wire the S4 Sweeper extension (wisps-plane, live-dependent protection, limit)

Publish SweepRequest.ProtectLiveDependents and .Limit (plus a
wisps-plane tier and SweepResult.Remaining/.LiveDependent) on the v0
wire behind three new behavior-capability tokens
(issues.sweep.wispsPlane, issues.sweep.liveDependents,
issues.sweep.limit), and wire the client to send them once the
handshake advertises the tokens (refuseUnservedSweep otherwise).
Retire the two W-SweepRequest ledger rows that previously refused
these fields for lack of a wire member.

CurrentWireRevision stays at 2. A new wisps-plane SweepRequest.Tier
value is a request-only enum widening: it cannot cause an older
client to misdecode a response, and it is already gated by its own
capability token, so it is additive rather than a wire break. Teach
wireshape's drift gate that distinction directly: a Digest.Sides side
channel records whether each schema member is request-only,
response-only or both, and widensAdditively now treats a request-only
enum's new value as additive while still treating any response-side
widening as breaking, with tests pinning both directions and a
regenerated golden.json. min_client_wire_revision stays 0.
internal/httpapi/apigen/types.gen.go and openapi.v0.yaml's comments are
regenerated/updated to match (make api-gen).

Six served Sweeper contracts that were parked now run for real against
the in-process HTTP server; TestSweepSendsTheS4MembersOnceTheServerAdvertisesThem
pins the capability-gated encode.

Re-review fix: walk()'s side classification short-circuited on a
name-only visited set, so a node already walked from one side never
had its CHILDREN walked again when a later path promoted the parent
to "both" — children stayed classified under whichever side reached
them first, order-dependent on Go's map iteration. Side recursion is
now guarded per (schema, side) pair (sideWalked, keyed on
name+"\x00"+side) instead of per schema name alone, so a child
reachable from both sides is always walked, and therefore recorded,
from both. Added TestSidePropagatesToNestedChildren (a named grandchild
and an inline nested child both reachable from a request body and,
via a wrapper, a response, assert "both" on every level and that
widening either enum breaks instead of being classed additive),
TestEnumWideningOnSharedNestedChildIsNotAdditive, and
TestComputeFromSideAssignmentIsDeterministic (200 runs, asserts
identical Sides/Entries every time). golden.json is confirmed
unchanged by the fix (regenerated and diffed byte-for-byte). Also
removes a bd-enterprise mention introduced in this slice's own
write_ledger_test.go comment (not a provenance header) in favor of
neutral wording.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): ratchet the http leg's role-contract ceiling to zero

Classify all 42 previously-ceilinged http-leg entrypoints and clear
the ceiling:

- ExpectedRevision + Refusal (10): wire a Phase-0 all-nil fixture,
  matching every other backend's current (unbuilt-CAS-feature) state.
  Said honestly: these ten entrypoints are counted here, the hook is
  unbuilt on every leg (not just this one), and every case runs zero
  assertions until a CompareAndSetVersion wire operation exists for
  this client to bind.
- Lifecycle ExpectedVersion concurrency (4): wire the two races that
  land on Priority/Notes and on Close for real over the served HTTP
  harness (precondition_failed decodes to storage.ErrVersionMismatch
  via errors.Is, same as the local legs). The other two, which race
  IssuePatch.SpecID/.AwaitID/.Owner edits against updateIssue, stay
  waived, but PENDING rather than permanent: IssuePatchBody refuses
  those three fields outright (W-IssuePatch.SpecID/.AwaitID/.Owner,
  D8 refuse-not-drop) rather than ever sending them, so the race never
  reaches the wire today. Closing the gap means publishing those
  fields on the wire, tracked as a follow-up slice, S4b: publish
  owner/spec_id/await_id on the wire.
- DualWrite (6): wired for real instead of waived. Mutate and
  MutateAsNoOp drive the client's Lifecycle role (Create/Update)
  against an in-process served harness with its own reference store,
  so VersionedHistoryConfigurer can be toggled per fixture;
  CurrentRevision, VersionRowCount and LatestVersionAttribution read
  the reference store's raw columns the same way every other served
  fixture's postcondition hooks do. All six FR-1/FR-2/FR-3/FR-5/FR-7
  cases (one version row per accepted mutation, no-op skip, atomic
  attribution, current_revision parity, and flag-off producing no
  rows) now run and pass.
- VersionReconciler + InitVerifier (13), and the raw
  IssueOperationsUpdate seam (3): waived — unservable over a typed
  HTTP role boundary, not a wiring gap.

adoptionCeiling: 42 -> 0 for the http leg; the "adopting" field is
removed (a zero ceiling with a reason is a registry error) since every
remaining gap is now a named waiver, PENDING or permanent as stated
above, instead of a budgeted unnamed one. Also deletes the scratch
zzz_dump_missing_test.go used to enumerate the ceiling during triage.

Re-review fix: the shared conformance attribution case only asserts
change_actor is non-empty (it runs across every leg, each with a
different literal Mutate actor). The http fixture's own Mutate always
sends Actor: "writer", so this leg's AttributionIsRecordedWithTheMutation
subtest now also mutates a second, independent issue and asserts the
recorded actor equals exactly "writer", in addition to the shared
non-empty check.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(types): make ParseRevisionToken the exact inverse of FormatInt

ParseRevisionToken's doc comment already promised it accepts exactly
what RevisionToken emits, but strconv.ParseInt alone is looser than
that: besides a leading "+" that FormatInt never produces, it also
accepts a leading zero on a digit string longer than one character
("007") and the literal "-0" — none of which FormatInt ever emits
(FormatInt(0, 10) is always "0", never "-0", and it never pads a
digit run). A caller is only ever supposed to echo a token a response
carried, so any of these is a client that invented a value rather
than a server this client should follow; reject them explicitly
instead of accepting them silently.

Pins the string<->int64 boundary with
TestParseRevisionTokenRejectsMalformedTokens, covering empty strings,
fractional/exponent spellings, leading "+", surrounding whitespace,
non-decimal bases, one-past-int64-boundary values, non-ASCII digits,
and now "007", "-007" and "-0".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fixup(wireshape): guard widensAdditively against "no enum before"

bee-ghosttrack / CHANGES_REQUESTED on #7251: widensAdditively required
len(new.Enum) > len(old.Enum), which holds vacuously when the old side
has no enum at all (a free `type: string`). That let a request-only
member go from unconstrained to a fixed enum at the same wire_revision
-- the opposite of widening, since the server now 400s a value an old
client could send yesterday.

Add the guard `len(old.Enum) == 0 || len(new.Enum) <= len(old.Enum) ->
false` so the no-enum-before case falls through to the ordinary
non-additive Changed path, same as a strict narrowing. Add a pinning
case to TestEnumWideningAdditivity and extend the doc comment.

Also reword the ExpectedRevision contract file comment from "runs ZERO
assertions" to "SKIPS", per the reviewer's note that the Run* helpers
t.Skip when CompareAndSetVersion is nil -- it's a skip, not an
assertion-free run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpclient): regenerate the divergence ledger after rebasing onto #7247's review fixes

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(httpclient): Sweep Limit now refuses on the missing issues.sweep.limit capability

#7247's review round pinned Sweep{Limit} as an encoder refusal. With S4 the
wire carries limit behind issues.sweep.limit, so against a server without
the token the refusal is a pre-dial capability refusal: still
*storage.ErrUnsupported for this backend, now naming the capability.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(httpapi,httpclient): name the invalid_value refusal; add tests to Bazel

Maintainer fixup for the review of #7251 (iteration 1). There are no blocker or
major findings. This applies the three optional findings that both reviewers
reported.

- Eight comment and description sites added by this PR say that an older
  server refuses an unpublished `tier` (or S4) member with `unknown_value`.
  No such reason exists. The server refuses with ReasonInvalidValue =
  "invalid_value" (internal/httpapi/problem.go), and sweep.go uses it for a
  bad tier. The sites are in openapi.v0.yaml, apigen/types.gen.go (regenerated
  by `make api-gen`), routes.go, sweeper.go and wire/handshake.go. The base has
  none of them, so this only corrects the PR's own text. A client author now
  matches the token the server actually sends.
- wire/handshake.go said the tier member carries no ledger row because it
  "narrows" an existing enum. Adding a value widens the accepted set, so the
  word is now "widens".
- internal/httpclient/BUILD.bazel: add expected_revision_contract_test.go and
  served_dualwrite_history_test.go to the httpclient_test srcs. Both files are
  new in this PR. Without the entries, `go test` runs them but no Bazel lane
  compiles them. The srcs list now matches the package's files, and the
  existing deps already cover their imports.

Provenance: this is the residue of the stranded fixup cad1cf02a2 from the
previous adoption of this PR, replayed onto the current head. Its patch-id
(b62e7d6d5562) is identical to that reviewed residue. That fixup's
widensAdditively guard and SKIP-message nit are not repeated here. The author
already landed both in b3f1516e55 (d41f317e0a after the rebase).

Validation: git diff --check; make api-gen (no-op) and make api-check;
go build, go vet and gofmt on internal/httpapi/... and internal/httpclient/...;
go test for internal/httpclient/wire, internal/httpclient/encode and
test/docsync; the httpclient Sweep* and TestExpectedRevisionContract tests; the
served dual-write tests with BEADS_TEST_EMBEDDED_DOLT=1; and
tools/bazel/go_srcs.py --check.

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(httpclient): regenerate the divergence ledger on main after #7247 merged

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(httpclient): give encode_test the httpclient tests its pin check reads

Maintainer fixup for the pre-review CI of #7251. Bazel / test and
Bazel / integration (PR run 37781419956) each fail one target,
//internal/httpclient/encode:encode_test, which also fails CI Gate / Required.
TestLedgerRowsAreWellFormed reports that rows W-SweepRequest.ProtectLiveDependents
and W-SweepRequest.Limit are pinned by
TestSweepSendsTheS4MembersOnceTheServerAdvertisesThem, which is "neither a test
in this package nor a TODO(<bead>)".

The pin is right. The test lives in internal/httpclient/bulk_roles_test.go.
testFunctionsInThisPackage collects test names from ".", ".." and
../../../cmd/bd, but the data of encode_test declares only its own sources,
//cmd/bd:go_srcs, the ledger doc and the OpenAPI spec. Under Bazel, ".."
exists in the runfiles but holds no _test.go files, so the walk silently finds
nothing there. go test reads the real directory and passes. This PR changes
neither the walk nor the BUILD file. Every pin on main resolves from this
package or cmd/bd, which is why main is green. These two rows are the only ones
pinned to a test that exists only in internal/httpclient. The red stayed hidden
until now because the PR sat on a stacked base. PR CI, including the Bazel
lanes, runs only for PRs against main, release/** and hotfix/**.

Declare //internal/httpclient:go_srcs as data, so Bazel sees the files that
go test reads. The filegroup already exists with //:__subpackages__ visibility.
The pins stay on the test that actually covers the S4 members.

Validation: bazel test //internal/httpclient/encode:encode_test --config=ci
--nocache_test_results, run two ways. In the local processwrapper sandbox
(--remote_executor= --strategy=TestRunner=processwrapper-sandbox) the same
command fails both rows without this change and passes with it. It also passes
on the remote executor. Plus tools/bazel/go_srcs.py --check, gazelle
-mode=diff on the package (no change), git diff --check, and
go test ./internal/httpclient/encode/.

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(httpapi): pin the S4 sweep members at the wire edge, gate golden sides

The `sides` map this change adds to golden.json predates schemas main gained
since (#7248's BatchGetIssue*, BatchGetIssuesRequest* and
BatchGetIssuesResult*, plus IssueDetails.gated_by[]), so the rebase left it 9
schemas short of what gendigest writes, and goldenDrift never compared Sides,
so nothing noticed. Regenerated (+9 sides lines, no entry changes), and
goldenDrift now fails with the regenerate instruction when the golden's sides
disagree with a fresh digest; TestGoldenDrift drives that arm three ways.

The SweepSkips description still called the first two buckets protections
and the last four defenses, which filed the new live_dependent protection
under the defenses. It now names pinned, referenced and live_dependent as the
protections (apigen regenerated: the two comment copies only), and
handleSweep's comment counts eight members.

internal/httpapi's sweep pins stopped at the original six members: nothing
there sent protect_live_dependents or limit, refused a mistyped one, or read
live_dependent or remaining back. The forward, refuse and publish tests now
cover all four, and TestSweepResponseCarriesEveryRoleField, named by
sweepResponse's comment but never written, counts both projection levels and
requires every wire field populated from a fully set role result.

The httpclient Sweep defer comment described ProtectLiveDependents/Limit
refusal paths this change replaced with capability gates; it now says why
the pass-through defer stays.

Validation: go test ./internal/httpapi/... ./internal/httpclient/... (CGO,
gms_pure_go), the served sweeper tier with BEADS_TEST_EMBEDDED_DOLT=1 (19/19
pass, none skipped), make api-check, go vet, git diff --check, and bazel test
--config=ci on httpapi_test, wireshape/..., httpclient_test, encode_test and
types_gen_drift_test. Mutants, each restored: disabling the sides arm reds
three TestGoldenDrift arms; the pre-fix golden reds TestWireShapeDigest
naming the 9 schemas; dropping the live_dependent or remaining projection,
the protect_live_dependents decode, or the limit assignment each reds its
new pin.

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 Sonnet 5 <noreply@anthropic.com>
2026-10-08 16:28:56 +00:00
Julian Knutsen
6d21d337ad
feat(httpclient): OSS HTTP client store and roles + a served http conformance leg (contributed from bd-enterprise under MIT) (#7247)
* feat(httpclient): lift the HTTP client store and roles from bd-enterprise (MIT contribution)

Contributed by gascity from bd-enterprise (github.com/gascity/bd-enterprise,
internal/enterprise/httpstore @ 49d1df2f6) to OSS beads under the MIT
license, with the owner's explicit approval. Every lifted file carries a
provenance header naming its source path.

Lifted into internal/httpclient: the Store (DoltStorage over the wire), the
dial/register glue, the read roles (reader, querier, counters, edges,
relations, graph, tree, cycles, stats, config, memories, journal), the write
roles (lifecycle, claimer, releaser, deleter, dependency editor, metadata
CAS, commenter, batch closer/creator/applier, ready claimer, sweeper), and
their tests. The store transport seam (WireClient/WireDialer) and the
store-dependent tests deferred from the S2 lift are restored here.

Not lifted: the hosted gateway (httpgw/gwauth), box-login, storage profiles
and gasworks. dial.go only mentions the gateway in comments.

This commit is the mechanical lift and does NOT build yet. It references
enterprise-only APIs absent from OSS: issueops.ReadyLister,
journalops.Watcher, storage.ServerEnforcedPolicy, the
NonCommitGraphBackend/RemoteWorkspaceBackend markers, DoltStorage
differences, and BatchCloseRequest.claim_next. The following commits
reconcile it with OSS (S3/S4/S5).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(httpclient): reconcile the bd-enterprise lift's compile-time API surface against OSS

The mechanical lift (02a9dad17) carried several bd-enterprise-only shapes
that do not exist in OSS beads:

- ReadyLister, journalops.Watcher/StreamWire, and ServerEnforcedPolicy have
  no OSS wire counterpart; drop the role, its served/journal-watch tests,
  and the policy enforcement path entirely rather than leave dead code that
  cannot compile against OSS's apigen types.
- claim_hook_gate_test.go exercised a hook surface OSS does not publish.
- recordingWire/fakeWire no longer embed a StreamWire double now that no
  read role can reach a watch stream; testTarget's two conflicting
  package-scope declarations (store_test.go and helpers_test.go) are split
  apart as pinnedProjectTarget vs. the generic helper.
- unsupported_gen.go is regenerated from scratch against OSS's actual
  storage.DoltStorage via a new, from-scratch reflection-based generator
  (internal/storage/unsupportedgen) rather than hand-copied from
  bd-enterprise's generated output; completeness_test.go's
  legitimatelyUnsupported map grows the handful of OSS-only or
  previously-missed methods (AddRemoteWithRef, RenameLabel, etc.) this
  regeneration surfaces.
- write_ledger_test.go and the divergence ledger doc gain the
  force_notes_overwrite and claim pending rows OSS's apigen.UpdateRequest
  and SweepRequest actually carry, and drop the Remaining/LiveDependent
  assertions SweepResult/SweepSkips have no wire member to ever populate.

go build ./... and go vet ./... are clean after this change. No behavior
beyond the removed surfaces changes here; read-role and write-role
reconciliation land in follow-up commits.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): stop sending listIssues a reverse/sort vocabulary OSS does not publish

The bd-enterprise lift's sortedPage pushdown assumed GET /v0/beads/issues
(listIssues) shared the same sort vocabulary and a reverse parameter with
GET /v0/beads/issues:query (handleQueryIssues) -- a different operation.
OSS's openapi.v0.yaml publishes listIssues a CLOSED two-value `sort` enum
(created, priority; deliberately smaller than the nine values :query
takes) and no `reverse` parameter at all. Sending either would earn an
unknown-parameter or invalid_value refusal from the real server, not a
silently-wrong answer -- which is why this only surfaces against a served
backend, not a Go-side unit test of the request builder.

Add listSortPushdownEligible to gate the pushdown fast path to the two
keyset orders listIssues can actually page, unconditionally refusing any
reversed request (listIssues has no parameter that names a reversed
direction, so a reversed request of any order walks and sorts
client-side). Drop the unconditional `reverse` send from sortedPage.

served_list_test.go's three affected cases encoded the wrong,
enterprise-only wire shape (expecting reverse=false on the fallback path,
expecting a reversed order to push down with sort+reverse, and expecting a
Go-side/SQL-side mix in listIssues' sort enum); corrected to match OSS's
actual, provable wire contract rather than left red. list_sort_test.go's
publishedParamEnum helper now reads the OpenAPI document via the
go:embed'd spec.OpenAPIV0() accessor instead of a relative os.ReadFile, so
it no longer depends on the test's working directory (this also fixes the
same test failing under Bazel's sandbox, which does not expose arbitrary
relative-path files).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): reconcile write-role tests against OSS's BatchClose/Update shapes

OSS's apigen.BatchCloseRequest and BatchCloseResponse publish no
claim_next/claimed_next member at all (ledger row
W-CloseBatchRequest.ClaimNext) -- bd-enterprise's claim-folded-into-close
shape has no OSS wire counterpart. Replace the three tests that exercised
decoding a served claim (TestBatchCloseRefusesAServedClaimCarryingNoIssue,
TestBatchCloseRefusesAServedClaimTheRequestNeverEarned,
TestBatchCloseKeepsTheClaimItEarned) with
TestBatchCloseRefusesClaimNextUnconditionally, which pins the actual OSS
behavior: a CloseBatchRequest naming ClaimNext refuses before any dial, on
both the unserved and served legs, regardless of what a server would
otherwise answer. Drop the now-dead "claim-next" case and helper claim
variable from TestBatchCloseServesTheSingleItemShapeAndRefusesTheRest.

Also:
- Add the ForceNotesOverwrite case to
  TestUpdateRefusesEveryMemberTheWireExcludes's hand-maintained member
  map -- a ledgered-pending UpdateRequest member (see
  W-UpdateRequest.ForceNotesOverwrite) the lift's test left uncovered.
- Remove write_roles_test.go's duplicate `ptr[T]` generic helper, which
  redeclared the one already in helpers_test.go and never compiled.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(conformance): pin post-write RowVersion propagation across Update/Close/Reopen

types.Issue.RowVersion is json:"-", so an implementation that forgot to
populate it on the way back from storage would still compile and still
pass every existing content assertion in lifecycle_close_reopen_contract.go
-- none of them read RowVersion. Add
RunLifecycleResultsCarryThePostWriteRowVersion, which chains each write's
result token into the next write's ExpectedVersion (Update -> Close ->
Reopen) with no intervening read, so a dropped or stale token fails closed
on the next write's optimistic-concurrency guard rather than passing
silently.

Register it in role_bundle_cases.go's roleContractCases dispatch table at
its declaration-order position -- TestRoleContractCasesCoverEveryContractCase
was failing because the function existed with no dispatcher entry.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* chore(bazel): sync BUILD files via gazelle for the S3 reconciliation

bazel run //:gazelle after the compile/read-role/write-role reconciliation
commits:

- internal/httpclient/BUILD.bazel: regenerate srcs/deps for the files
  added, removed and newly imported above (drops the deleted
  policy/journal-watch/readylister files, adds the spec dep for
  list_sort_test.go's embedded OpenAPI read). Manually add
  `data = glob(["*.go"])` to the go_test rule, matching the idiom already
  used by //internal/httpclient/encode: completeness_test.go and
  divergence_citation_gate_test.go read their own package's .go sources at
  runtime (a regex scan of unsupported_gen.go and an AST walk of the
  package directory), and Bazel's go_test sandbox only copies in files a
  rule declares as `data` -- `srcs` are compiled away, not left readable.
  A `# keep` directive protects the attribute across future gazelle runs
  (confirmed gazelle does not manage `data` on this rule).
- internal/storage/BUILD.bazel,
  internal/storage/unsupportedgen/BUILD.bazel: pick up the new
  from-scratch unsupportedgen generator package.

bazel test //internal/httpclient/... //backend/conformance/... now passes
all 4 targets (previously 4 of the package's tests failed only under
Bazel's sandbox: TestInterfaceCompleteness,
TestTheCountGroupVocabularyMatchesTheSharedOne,
TestFlaglessListSortIsTheSameOrderNamed,
TestDivergenceParkCitationsResolveToLiveLedgerRows).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(conformance): close two pre-existing leg-wiring gaps found while registering http

- RunLifecycleResultsCarryThePostWriteRowVersion (added in 536561124) was
  never wired into dolt/embeddeddolt/uow's own lifecycle_close_reopen test
  tables, only into the http leg's. TestEveryLegWiresEveryRoleContract
  catches this once a fourth leg forces the test to actually run again;
  wire the missing t.Run into all three.
- The three StatsReporter "suppressed rows" cases (GateIssues/TemplateIssues
  breakdown) were never added to served_graph_aux_test.go even though the
  wire already carries both fields end-to-end (types.Statistics is shared
  verbatim by apigen.StatsResponse and the client's decode). Wire them; all
  three pass over HTTP with no server or client change needed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(conformance): register the http leg in the role-contract lock

Registers "http" (wiringRoot internal/httpclient) in contractLegRegistry.
The served-surface harness (served_harness_test.go + 16 served_*_test.go
files) already wired 495 of 576 role-contract entrypoints from the
bd-enterprise lift; this change:

- Waives the 3 RunCycleDetectorIncludeTracks* cases: issueops.
  DetectCyclesRequest.IncludeTracks has no plumbing on either side of the
  wire today (cycles.go always calls DetectCycles with a zero-value
  request; the client's DetectCycles ignores its request parameter). No
  slice through S13 adds one, so the waiver says a new slice is needed
  rather than pointing at an existing one.
- Sets adoptionCeiling: 75 for the remaining, not-yet-wired write-role and
  internal-plumbing entrypoints (lifecycle writes, DependencyEditor,
  MetadataCAS, Lease, Sweeper, VersionReconciler, Bootstrapper/
  InitVerifier, cross-record invariants) that S4 and later write slices
  pick up and ratchet down.
- Adds //internal/httpclient:go_srcs to storage_test's data: the leg's
  wiring root lives outside internal/storage, and the Bazel sandbox has no
  other reason to materialize those sources for a test that reads them at
  runtime.

TestEveryLegWiresEveryRoleContract, TestEveryRoleMethodHasAContractCase,
and RunUnsupportedContract (already wired pre-lift in
internal/httpclient/completeness_test.go) all pass for the http leg.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): close review's HIGH 2-5 gaps and reconcile their test doubles

HIGH 2 (BatchCloser), HIGH 3 (created_by stamping, absent-parent 404/400,
force_notes_overwrite carriage) and HIGH 4 (CapabilityError now unwraps to a
typed *storage.ErrUnsupported with Capability) were implemented in prior
commits on this branch; this change finishes HIGH 5 and the verification the
review asked for:

- role_reader.go's Reader.Get and bridge.go's raw GetIssue both now stitch
  Revision back onto Issue.RowVersion via parseRevision, so a guarded write
  built off either read carries the row's real token instead of a decoded
  zero. Both are pinned by round-trip served tests that guard a write with
  the read's token and require a stale-token replay to refuse.
- Fixed create_test.go's stale assertion that created_by must stay empty
  (contradicted the HIGH 3 stamping fix it predated).
- Fixed recordingWire's canned IssueDetails{} response (roles_test.go): it
  omitted Revision, which is a required field on every getIssue response
  per the OpenAPI spec, and the HIGH 5 stitch now reads it unconditionally.
- Synced internal/httpclient/wire/BUILD.bazel via gazelle: handshake_test.go's
  new internal/storage import had no corresponding dep.
- gofmt'd write_roles_test.go's stubWire struct tags.

Verified: served HTTP conformance tier (BEADS_TEST_EMBEDDED_DOLT=1
BEADS_HTTP_TEST_REQUIRED=1 go test ./internal/httpclient/, -timeout=40m)
600 PASS / 0 FAIL / 72 SKIP (all ledgered known-divergence waivers). One
TLS-handshake-timing test failed in that run and passed 3/3 in isolation
(unrelated file, pre-existing flake under machine load, not reproducible).
Also green: default go test (minus the pre-existing, unrelated
TestEngdocsAndRootMarkdownLinks doc-link drift and the environmental
internal/storage/uow dolt-server-spawn hang), bazel build/test for the
touched packages, make api-check, and gofmt/vet.

Live-mutated and reverted 3 guards to confirm their tests are load-bearing:
role_reader.go's RowVersion stitch, bridge.go's RowVersion stitch, and
lifecycle.go's force_notes_overwrite wiring.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(ci): add served HTTP conformance as Tier 3 of the conformance gate

The served tier (internal/httpclient's served_*_test.go corpus) never ran
in CI, so HIGH 2-5's regressions (and any future ones) would merge
undetected. Add it as Tier 3 of scripts/conformance.sh, the existing
required entrypoint conformance.yml already runs on every PR/push/merge_group
(not a new workflow, not wired through ci-gate.sh's aggregation -- this
repo's convention for this gate is a single standalone job):

  CGO_ENABLED=1 BEADS_TEST_EMBEDDED_DOLT=1 BEADS_HTTP_TEST_REQUIRED=1 \
    go test -timeout=40m ./internal/httpclient/

Left unsharded: Tier 1 and Tier 2 are themselves single unsharded
invocations, and Tier 3 is one Go package, not a multi-package corpus the
repo's existing package-sharding scripts apply to. No Bazel-lane addition:
bazel-coverage's embedded/dolt_server outputs only ever substitute for
main.yml/pr-risk.yml jobs, never for conformance.yml's own job, so there is
no existing Bazel-lane relationship for this gate to extend.

Bumped the job's timeout-minutes 45 -> 100 (30m + 10m + 40m budgeted
sub-timeouts plus checkout/setup-go overhead) and updated the three policy
tests that pin this script/workflow byte-for-byte
(TestConformanceScriptUsesExplicitTimeoutBudgets,
TestConformanceScriptPropagatesGoTestFailures,
TestConformanceWorkflowHasOuterTimeoutBudget), re-included
internal/httpclient/** in both path filters (push and pull_request, kept
identical) since served_*_test.go files are the suite itself and would
otherwise be excluded by the shared !**_test.go negation, and documented the
new filter entry in ci_f7c_advisory_test.go's own-entries map.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): root-cause and fix the Happy-Eyeballs TLS flake in store_dependent_test.go

TestTransportForSucceedsWithEnvCAFile (and 3 Handshake-based siblings that
assert on a successful dial through a configured CA: SidecarCAFile,
CAFileEnvAgreeingWithSidecarSucceeds, DialWithNilTransportHTTPClientGetsCAInjectedOnACopy)
flaked once with "tls: first record does not look like a TLS handshake".

Root cause: our code, same class S2 already fixed for TransportFor's direct
callers (forceIPv4Loopback in ca_test.go/ca_wrong_ca_test.go). Every server
these tests dial is addressed by hostname "localhost" (ca.startServer
rewrites it there deliberately, so SNI is actually sent), which Go's
default dialer races a tcp6 dial to ::1:<port> against the real tcp4 dial to
127.0.0.1:<port> for (RFC 6555). An unrelated local process already bound to
a colliding ephemeral port on ::1 can occasionally win that race before the
real dial completes, and the client speaks TLS to that unrelated process
instead -- the misleading handshake error, not a real hang or a product bug.

These four tests go through Handshake with DialOptions{} (HTTPClient left
nil deliberately, since that is itself the nil-HTTPClient branch of DialWith
under test), so they never get a *http.Transport back to mutate the way
forceIPv4Loopback's existing callers do. Fixed via warmIPv4OnlyCATransport:
pre-build the target's CA-scoped transport through the same public
TransportFor the product code itself calls (so it lands in the exact
(path, content)-keyed cache transportForFile's cache hit returns), force
tcp4-only on that cached pointer, and let Handshake's own DialWith run
unchanged -- same branch under test, same cached transport, no sleeps, no
retries. Verified with -race -count=50 on all four: 200/200 pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): refuse DetectCycles(IncludeTracks=true) instead of silently ignoring it

roles_graph.go's httpCycleDetector.DetectCycles took its request as `_`,
forwarding nothing: a caller asking for the widened (tracks-following) walk
silently got the narrower default walk back with no error. listDependencyCycles
has no include_tracks wire parameter at all, so there is no way to honor the
field — only to refuse it loudly or drop it silently. Switch to the typed,
ledger-cited refusal (encode.RefusedError via refuse(), citing new row
"L-cycles-tracks") that CountEdges' own wire bound already uses, add the
ledger row and its Op, regenerate the auto-generated ledger doc, and pin the
behavior with a unit test (no served-tier case needed: the refusal is
pre-dial by design, same reasoning as the existing edge-count bound pin).

Also fix leg_contract_wiring_test.go's cycleTracksWireGapWaiverReason, which
had gone stale: it described the http leg as silently forwarding nothing for
this field, which was true before this change and is not after. The waiver
itself (the three RunCycleDetectorIncludeTracks* contract cases stay unwired
for the http leg) is unaffected — they were never wired, and still are not —
only the reason text needed updating to describe a typed refusal instead of a
silent ignore.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): name the http leg's permanent contract gaps instead of budgeting them

The http leg's role-contract adoption ceiling (internal/storage/contract_leg_registry_test.go)
sat at a flat 75, with a prose "adopting" note that bundled every skip into
one vague bucket — including MetadataCAS, which is in fact fully wired (0
missing cases), a false claim left over from an earlier wiring pass.

Twenty-six of the 75 skips are not S4-and-later work at all: they are
PERMANENT gaps that no future slice closes, because the contract itself has
no publicops role for an HTTP client to route through:

  - Importer (4 cases): uow is Importer's one accessor, same precedent the
    dolt and embeddeddolt legs already carry (importerOneAccessorWaiverReason).
  - RetentionFixture/EpochFixture (15 cases) and CrossRecordInvariantFixture
    (7 cases): both fixtures carry raw storage hooks (Resolve, Erase, Mint,
    CurrentEpoch, GuardedWrite, EnforceCrossRecordInvariant, ...) with no
    publicops field at all. dolt, embeddeddolt and uow wire these because
    they ARE the storage engine this address/epoch/retention and
    cross-record transaction bookkeeping belongs to; the http leg is a
    remote client with none of its own to report. There is no wire surface
    for this to ever route through short of a new role being designed from
    scratch — a new slice, not a missing test line.

These 26 are now named, reasoned waivers in unwiredContractEntrypoints
(two new reason constants: retentionEpochNoRoleWaiverReason and
crossRecordInvariantNoRoleWaiverReason), and the ceiling drops from 75 to 49
to match. The "adopting" note is rewritten to correctly name every remaining
category under budget (lifecycle writes, DependencyEditor, DualWrite,
Sweeper, VersionReconciler, Bootstrapper/InitVerifier, ExpectedRevision/
Refusal) and to drop the false MetadataCAS claim.

Also documents, at conformanceEntrypointsWiredBy, why a leg wiring a
conformance.RunX reference with every hook left nil would read as "adopted"
by this lock's static source grep while actually running as a skip —
matching the loophole internal/httpclient's divergence_citation_gate_test.go
already closes for skipKnownDivergence call sites. No leg currently does
this (verified by inspection); the note sets the review expectation for
future wiring rather than papering over the gap with no record of the policy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(licensing): scrub internal program/org naming and a leaked private ID from OSS-visible text

MEDIUM 8 of the S3 ship review: remove licensing-hygiene leaks found by a
read-only repo-wide survey, while leaving every legitimate "Contributed by
gascity from bd-enterprise ... to OSS beads under the MIT license." provenance
header and every genuine public gascity/gastownhall self-reference (the real
OSS org, beads.gascity.com docs domain, RBE infra) untouched:

- Delete release-gates/ga-7psli2-3-1-baseline-cmd-bd-fix-gate.md: the only
  file in release-gates/ keyed by a private `ga-` tracker ID instead of the
  directory's established public `be-` convention (30 other files), and the
  only one leaking internal filesystem paths (/home/jaword/...,
  gc-management/.gc/artifacts) and internal routing terms (mayor/mpr,
  "deployer session"). Not referenced from anywhere else in the tree.
- .golangci.yml: drop two private `ga-2ltro.12`/`ga-26w10` history citations
  used as nolint-comment justifications; reworded to the same explanatory
  content without naming a private tracker ID.
- Reword 19 "gc native-program" occurrences (14 files, comments and one
  design doc) to drop the internal program name while keeping the "S3
  reconciliation (2026-10)" dating they were attached to.
- cmd/bd/if_revision.go, if_revision_test.go, update.go,
  update_proxied_server.go: drop literal citations of gascity's private
  bdstore_conditional.go classifier (including a test function name,
  TestIfRevisionEnvelopeGascityContract -> ...DownstreamContract) while
  keeping the substantive explanation of why this envelope's shape is
  load-bearing for a downstream consumer.
- internal/httpclient/lifecycle.go: drop a citation of gascity's private
  internal/beads/bdstore.go.
- internal/httpclient/dial.go: drop the internal/enterprise/httpgw package
  path, keeping "a gateway dialer outside this repo".
- internal/httpclient/register.go: reword away from naming "the enterprise
  distribution" while keeping the build-tag-opt-in behavior it documents.

Verified: go build ./..., go vet ./internal/httpclient/... ./cmd/bd/...,
go test ./internal/httpclient/... and ./cmd/bd/... -run TestIfRevision all
pass; TestDivergenceLedgerDocMatchesLedger still passes (ledger.go and its
doc were edited in lockstep). gofmt -l reports no diffs on any touched file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient/wire): correct the CapExternalDependencies doc's implied false claim

MEDIUM 9 of the S3 ship review. The old comment on CapExternalDependencies
said this client "has no external-dependency policy layer to gate" and that
"OSS publishes no storage.ExternalDependencyQueryStore-backed client policy
... to compose" immediately after naming bd-enterprise's removed policy.go --
easily misread as "OSS has no external-dependency decorator at all." It does:
internal/storage/externaldeps's decorator is unconditional (no build tag) and
is wired into every local storage chain by cmd/bd/storage_chain.go.

Reworded to say precisely what is and is not true: the decorator exists and
runs for local backends; what this http client lacks is a client-side
composition of that decorator around a remote store, which is moot anyway
because a server advertising this capability already applies the policy
itself before answering. (Rolled in the same "gc native-program" wording
removal from the MEDIUM 8 commit, since both edits touch this comment block.)

A second claim from the same review item -- that OSS is said somewhere not to
serve events:watch -- could not be located despite an exhaustive repo-wide
search (this file, engdocs/, docs/reference/events-journal.md,
SERVE_RUNBOOK.md, the divergence ledger, CHANGELOG.md, and a dedicated
read-only research pass). internal/httpapi/events_watch.go,
routes.go's events.watch route entry, and internal/httpclient/wire/stream.go
all confirm OSS serves it unconditionally (gated only per-workspace by the
events journal setting, not by build/distribution). No corresponding false
claim exists in this worktree to fix; noting this rather than editing
something that already reads correctly.

Verified: go build ./internal/httpclient/..., go vet, go test
./internal/httpclient/wire/... pass. gofmt -l clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(unsupportedgen): add a freshness check for the generated shell

LOW item from the S3 ship review: internal/storage/unsupportedgen had no
tests of its own, so the generator could drift from the checked-in
internal/httpclient/unsupported_gen.go (a storage.DoltStorage interface
change, or a hand-written method added/removed on Store) with nothing to
catch it short of a human noticing the diff. TestInterfaceCompleteness
(completeness_test.go) already pins which methods belong in the shell by
name, but not whether the checked-in bytes match what the generator would
produce today.

TestGeneratedShellIsFresh runs the same scan-then-generate pipeline main()
runs for the registered DoltStorage/httpclient/Store consumer and diffs the
result against the checked-in file -- mirrors the existing
TestDivergenceLedgerDocMatchesLedger pattern in
internal/httpclient/encode/ledger_render_test.go. Added
TestScanHandWrittenMethodsExcludesOwnOutput alongside it to pin the
correctness property the freshness check depends on (scanning must not see
the generator's own prior output as hand-written).

BUILD.bazel: added the go_test rule by hand (gazelle cannot infer the
cross-package `data` dependency a relative-path os.ReadFile needs under the
Bazel sandbox) with data = ["//internal/httpclient:go_srcs"], following the
existing cross-package data pattern in
internal/httpclient/encode/BUILD.bazel. Placed go_test before the
go_srcs.py-managed filegroup block, which `make bazel-sync-check` requires.
Verified: `bazel run //:gazelle` leaves the rule untouched, `bazel test
//internal/storage/unsupportedgen:unsupportedgen_test` passes, `make
bazel-sync-check` is clean, go build/vet/test ./... all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient/encode): scrub a private tracker-ID cluster from the shipped divergence-ledger doc

Follow-up to the MEDIUM 8 licensing scrub: internal/httpclient/encode's
ledger_render.go header and ledger.go's comments/pinnedElsewhere constant/two
Why strings cited "ga-b8ddd.12/.19/.23/.30" by name. These feed directly into
engdocs/design/http-divergence-ledger.md -- a shipped, generated OSS design
doc, the most visible surface this private ID cluster reached (Fork A's
MEDIUM 8 survey found ~40 occurrences of "ga-b8ddd" across the httpclient
package; this commit addresses the subset inside package encode that is
checked-in prose/doc text, not test-fixture or assertion values). Reworded to
keep the same substantive explanation (what closed, what's still deferred,
which dual run resolved L17) without naming the private ID.

The remaining ~30 occurrences of "ga-b8ddd" outside package encode
(offrole.go, metadata.go, store.go, roles_test.go, wire/*_test.go,
served_*_test.go) are left for a follow-up pass: scrubbing them individually
needs the same per-file verification this commit did, and is a larger,
separate blast radius than was practical in this pass.

Regenerated engdocs/design/http-divergence-ledger.md via
`go test ./internal/httpclient/encode -run TestDivergenceLedgerDocMatchesLedger
-update-ledger-doc`; diff confirmed only the ga-b8ddd text changed. go build
./..., go vet ./internal/httpclient/..., and go test ./internal/httpclient/...
all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpclient): drop a private host reference from a test comment

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* revert(licensing): keep the scrub to the contributed client code

The previous scrub also edited upstream files this PR doesn't otherwise
touch (.golangci.yml, cmd/bd --if-revision files from #7203) and deleted an
upstream release-gate record. Restore them; the provenance scrub applies only
to the code contributed from bd-enterprise.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(httpclient): wire S8 count-scope fields on the client

Encode ParentID/NoParent/ExcludeTypes/ExcludeStatus onto countIssues
(table.go + encode.go), add issues.count.scope to the client capability
table (wire/handshake.go, wire/vocabulary_test.go), and refuse locally
before dialing when the server hasn't advertised the token and any scope
field is set (counter.go's refuseUnservedScope), returning a typed
*storage.ErrUnsupported{Capability:"issues.count.scope"} rather than
dropping fields or taking a guaranteed-400 round trip.

Adds encoding-parity coverage (counts_test.go), a masked-token skew test
proving the pre-dial refusal and zero dials (counts_test.go), roundtrip
and skew-table fixes for the newly-encoded fields (encode/roundtrip_test.go,
encode/skew.go), and wires S8's nine shared Counter conformance cases into
the served http leg (served_counter_test.go), including AddDependency so
the wisp/compose cases run instead of skipping. List stays nil on this
fixture since listTable() has pre-existing, unrelated permanent refusals
for ListRequest.NoParent/ExcludeTypes, so the three *MatchesListCardinality
cases skip here by design.

internal/storage's TestEveryLegWiresEveryRoleContract/http ceiling check
remains red (53 skipped vs ceiling 49) after this change, but strictly
improved: before this change the inherited baseline was 62 skipped (13
over ceiling), all nine of S8's new entrypoints unwired. This change wires
all nine, closing exactly that gap; the remaining 4-over are named
RunBootstrapper*/RunDependencyEditor* cases unrelated to count-scope,
pre-existing debt from other already-merged slices whose ceiling was
never bumped for them. Left the ceiling constant alone rather than
raising it to paper over debt this change doesn't own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): close the http leg's role-contract ceiling regression

TestEveryLegWiresEveryRoleContract/http went red after the rebase (62
skipped, 13 past its ceiling of 49) before any work in this session; the
prior commit closed 9 of those (S8's Counter cases). The remaining 4-over
were RunBootstrapper* (9 entries) and RunDependencyEditor* (2 entries),
both newly-merged contracts this leg had never classified.

RunBootstrapper*: internal/httpclient/accessors.go already names
Bootstrapper PERMANENTLY UNSERVABLE over http (bd init resolves its
substrate identity entirely client-side, before any server exists to
dial) — add a new named waiver, bootstrapperPermanentlyUnservableWaiverReason,
covering all nine entrypoints. VersionReconciler and InitVerifier are
named permanently unservable by the same accessors.go comment but are
left under the ceiling for their own reviewed change, out of scope here.

RunDependencyEditor*: the OSS server already serves add/remove and the
http leg already wires nearly all of DependencyEditor's contract. The two
missing cases (SameTypeReAddWithChangedMetadataMintsOneVersion,
SameTypeReAddWithIdenticalMetadataIsANoOp) only needed
SetVersionedHistoryEnabled wired onto the fixture, the same way
SetJournalEnabled already is — wired it for real; both pass served.

With Bootstrapper waived and DependencyEditor fully wired, the leg's
unwaived-missing count drops from 53 to 42, so adoptionCeiling moves
from 49 to 42 to keep the ratchet exact, with the adopting prose updated
to match.

TestEveryLegWiresEveryRoleContract is green. Served tier (real, CGO +
embedded dolt): 611 PASS, 0 FAIL, 72 SKIP (up from 609). bazel build/test
and make api-check pass for the touched targets.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): auto-sync BUILD files

Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/37307836753
(`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(conformance): pass -tags gms_pure_go to Tier 3's served httpclient run

scripts/conformance.sh:61 ran a bare `go test -timeout=40m ./internal/httpclient/`
for Tier 3 (served HTTP client/role conformance), which `make ci-pr-policy`'s
build-tag policy check refuses ("bare go test without -tags=gms_pure_go").
Pass the same -tags Tier 1 already does, and update
TestConformanceScriptUsesExplicitTimeoutBudgets' pinned argv to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): give //internal/httpclient:httpclient_test room to run

The package takes ~350s under --config=ci (BEADS_TEST_SKIP=dolt, no
BEADS_TEST_EMBEDDED_DOLT) — mostly wall-clock wait on the CA tests'
dialer/keep-alive timeouts, not CPU — but the go_test had no size/timeout
override, so it inherited the medium default's 300s and timed out
intermittently under Bazel (and took "Go test equivalence" down with it).
Set size = "large", timeout = "long", matching
//internal/storage/embeddeddolt's go_test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): fix data race in caContextHandler test helper

TestTransportForRaisesMaxIdleConnsPerHostForBursts drives caContextHandler
with 8 concurrent requests; handler() wrote requestSeen/host/sni from every
server goroutine with no synchronization, and the other nine callers (all
single-request) never exercised the race. go test -race reproduced it as
3x DATA RACE across repeated runs.

Guard the fields with a mutex and expose them only through accessor methods
(sawRequest/seenHost/seenSNI), updating every call site in
store_dependent_test.go accordingly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(unsupportedgen): canonicalize reflect-visible stdlib aliases

TestGeneratedShellIsFresh fails on Go >= 1.27: encoding/json.RawMessage
became an alias of encoding/json/jsontext.Value, and reflect only ever sees
an alias's underlying type, so formatType rendered
storage.DoltStorage.MergeMetadata's signature with the new, non-portable
name even though the signature itself did not change. A contributor on
1.27 following the freshness test's own advice ("go generate
./internal/httpclient") would commit a shell that does not compile on the
1.26.7 SDK this repo pins.

Add reflectAliasCanonical, a table mapping a reflect-visible alias target
back to the name a human wrote in source, consulted by namedType. Add an
entry here for any future stdlib alias this generator's output needs to
stay stable across.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): claimOnlyUpdate propagates the claim's RowVersion

bridge.go's GetIssue already stitches details.Revision onto
hydrated.RowVersion when claimOnlyUpdate rehydrates labels/CreatedBy onto
the claim response, but the claim response itself (issueops.Claimer's
bare-row contract) carries no revision at all, and the copy-back only
touched Labels and CreatedBy. So Lifecycle.Update({Actor, IssueID, Claim:
true}) — `bd update X --claim` — handed back Issue.RowVersion == 0 over
http where the local leg returns the real token, and feeding that into the
next write's ExpectedVersion got a spurious mismatch instead of none.

Copy RowVersion back too. Extend
RunLifecycleResultsCarryThePostWriteRowVersion (shared lifecycle/close/reopen
conformance contract) with a claim-shaped first link in the chain: claim,
then guard the next write with the claim result's own token, proving the
claim-only path populates the real version rather than a nonzero constant.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): stitch RowVersion on SearchIssues' exact-id fast path

resolve.go's getIssuesByExactID decodes the same IssueDetails shape
bridge.go's GetIssue does, but never parsed details.Revision the way
GetIssue's own stitch does, so SearchIssues(ctx, "<exact id>") answered
RowVersion 0 — a one-line gap: Issue.RowVersion is json:"-", so the decode
left it at zero, and only the explicit parseRevision stitch recovers it from
the response's own Revision string member.

Add TestSearchIssuesExactIDPopulatesRowVersionForAGuardedWrite, pinning the
same guarded-write round trip TestBridgeGetIssuePopulatesRowVersionForAGuardedWrite
already pins for the plain GetIssue path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): route every write role's refusals through inexpressible

Review finding 7: write-side refusals were not uniformly *ErrUnsupported.
Read roles already wrap encoder refusals through Store.inexpressible, which
reaches both encode.RefusedError and encode.CapabilityError; the write side's
refuse() returned a bare *encode.RefusedError instead, so a caller doing
errors.As(err, &unsupported) caught the count-scope refusal but missed
Sweeper.Sweep(Limit), DetectCycles(IncludeTracks), ReadyClaimer.ClaimNext,
BatchApplier.ApplyBatch, BatchCloser.CloseBatch, Deleter.Delete,
DependencyEditor.AddDependencies, and BatchCreator.CreateBatch.

Give InexpressibleError a detail field that preserves the original error's
composite text (an "items[%d]..." or "Issue.%s:" prefix a deeper encoder
helper already adds) instead of collapsing the message to the bare ledger
row text, and wrap every remaining write role's exported method in a single
named-return defer calling store.inexpressible, matching the pattern
lifecycle.go's Create/Update/Reopen already use.

Add TestWriteRoleRefusalsMatchTheReadShape, pinning three write-side
refusals (Sweeper.Sweep Limit, CycleDetector.DetectCycles IncludeTracks,
ReadyClaimer.ClaimNext) now classify via errors.As(*storage.ErrUnsupported)
the same way a read-side refusal does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cmd/bd): stop spelling out Status: StatusOpen on a markdown batch create

Review nit 8: batchcreator.go's refuseUnwirableIssue refuses a populated
Status (apigen.BatchCreateItem has no wire slot for it), and
buildMarkdownBatchRequest always set Status: types.StatusOpen explicitly, so
`bd create --file` refused on every call against an http-backed store.

PreparePublicCreateRequest already defaults an empty Status to StatusOpen on
every backend, including the http client store's own server, so the explicit
assignment here was never a different outcome - only a populated member the
wire can't carry. Leave it unset; the created issue is identical on every
backend, and the http leg's role-level accounting for why Status and
CreatedBy are excluded from its allowlists is documented on
batchCreateCarriedIssueMembers (internal/httpclient/batchcreator.go).

CreatedBy is left as-is: that member genuinely has no wire slot AND the
server does not yet stamp it from Actor (a gap already tracked in this PR's
Follow-ups), so its refusal is correct, not a bug to route around.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpapi): correct create.go's CreatedBy comment to caller-asserted

Review nit 8: the comment claimed CreatedBy is stamped from the
"authenticated actor," but actor is parsed straight from the request body
(s.bodyActor) and never authenticated - exactly as this file's own doc
comment states a few lines above. Reword to "caller-asserted actor" and
cross-reference that doc comment so the two stay consistent. No behavior
change: the stamp itself and its test coverage were already correct.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): raise MaxIdleConnsPerHost for a supplied client's nil Transport

Review nit 8: DialWith's doc comment promises the raised MaxIdleConnsPerHost
ceiling on every dial, "whether or not a CA is configured," but the
opts.HTTPClient.Transport == nil arm only injected a transport when the
target's CA was configured (resolved.configured()). A caller-supplied
*http.Client with a nil Transport and no CA fell through untouched, so it
defaulted to http.DefaultTransport's own ceiling of 2 at request time instead
- silently exempting this one shape from the doc's promise and forcing a
fresh TLS handshake on most of a concurrent burst even once the pool is warm.

Route this arm through the same dialTransport helper the opts.HTTPClient ==
nil arm above already uses (the CA-scoped transport when a CA is configured,
the shared baseline otherwise), injected onto a copy so the caller's own
*http.Client fields (Timeout, CheckRedirect, Jar) stay untouched.

Add TestDialWithSuppliedClientNilTransportNoCARaisesMaxIdleConnsPerHost: an
end-to-end burst through wire.Client.Do, traced with httptrace, asserting the
connection pool settles into reuse at a burst size the default ceiling of 2
cannot sustain.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpclient): stop citing nonexistent design docs from new source files

Review nit 8: several comments added by this lift cited
engdocs/design/http-client-backend.md, "D8 row N", and beads-design/slices.json
- none of which exist in this repository (the design lived in the
bd-enterprise-internal source this code was lifted from).

Point each citation at what actually ships in-repo instead:
engdocs/design/http-divergence-ledger.md (the generated, human-readable
rendering of the divergence ledger in encode/ledger.go) for the D7/D8/D9
discipline citations in encode.go, ledger.go, bijection_test.go,
write_ledger_test.go, wire/credential.go and store.go's package doc; and a
direct description of the wire-gap it records, rather than a slices.json
scope reference, in leg_contract_wiring_test.go's cycle-tracks waiver
rationale. Regenerate http-divergence-ledger.md from ledger_render.go (which
had the same stale citation) via
`go test ./internal/httpclient/encode -run TestDivergenceLedgerDocMatchesLedger -update-ledger-doc`
so the shipped doc and its generator agree.

No behavior change; comment and generated-doc text only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(httpclient): implement issueops.BatchGetter for the HTTP client leg

The rebase onto origin/main (item 9 of PR #7247's review) brought in
upstream #7248's new issueops.BatchGetter role on storage.DoltStorage,
breaking the HTTP client leg's interface satisfaction. This wires it up
as a read role (no actor, no version guard, writes nothing — dialed as
a POST only because MaxGetManyIDs ids cannot ride a GET query string),
mirroring Counter/Querier rather than the WriteWire-wrapped roles.

- wire/paths.go: add PathIssuesBatchGet ("/v0/beads/issues:batchGet").
- batchgetter.go: httpBatchGetter.GetMany dials the server and stitches
  each resolved issue's RowVersion from apigen.BatchGetIssue.Revision
  (the role's only wire spelling of the row token, since RowVersion is
  json:"-"). checkGetManyIDs pre-validates the cap and blank-id rules,
  in the same order internal/storage/issueops.ValidateGetManyRequest
  applies them, because batch_get.go's failBatchGetErr collapses every
  validation failure into one generic, code-less InvalidArgument the
  client could never decode back into *issueops.TooManyIDsError.
- accessors.go: add the BatchGetter() accessor (26th wire-backed role).
- unsupported_gen.go: regenerated, dropping the now-implemented stub.
- completeness_test.go: move BatchGetter into wireBackedAccessors and
  bump the asserted accessor-matrix total from 28 to 29.
- served_test.go / served_harness_test.go: both package-local "by hand"
  httpapi.Config builders (serveRoles, serveConfig) now wire
  cfg.BatchGetter, fixing ~56 served-tier tests that broke once
  BatchGetter joined httpapi.Listen's required role set.
- served_batch_getter_test.go: wire the HTTP leg into all 14
  backend/conformance.RunBatchGetterXxx cases, following
  served_graph_counter_test.go's pattern. This surfaced a real bug:
  GetMany built Missing via append([]string(nil), body.Missing...),
  which stays nil when the server reports no misses, violating the
  role's "Missing is never nil on success" contract — fixed to build
  via make([]string, len(body.Missing)) + copy.

Verified: go build/vet clean; internal/httpclient suite green
(including the embedded-dolt served tier); TestEveryLegWiresEveryRoleContract
holds the http leg's adoption ceiling at exactly 42 with no change needed;
TestInterfaceCompleteness and TestAccessorMatrixMatchesDesign pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): auto-sync BUILD files

Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/37450731721
(`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(httpclient): lock contextServer.seen against concurrent handler goroutines

TestDialWithSuppliedClientNilTransportNoCARaisesMaxIdleConnsPerHost drives
the stub with bursts of 8 concurrent requests; the handler appended to
seen without a lock. Readers only look at seen after their requests return.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* build(bazel): sync go_srcs managed blocks for unsupportedgen after the main merge

The PR adds internal/storage/unsupportedgen on a base that predates #7320,
which gave every Bazel package a managed repo_files filegroup. On the merge,
`python3 tools/bazel/go_srcs.py --check` (TestBazelGoSrcsBlocksCurrent) found
3 stale blocks: the package's own repo_files block, its entry in the root
BUILD.bazel repo_files list, and its entry in tools/bazel/BUILD.bazel.
`make bazel-sync` regenerated exactly those; gazelle changed 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>

* fix(httpclient): refuse DepAddItem.HasSpawner and ThreadID on applyBatch after the main merge

Main's #7209 gave issueops.DepAddItem two members, HasSpawner and
ThreadID, and a conformance case, RunBatchApplyStampsSpawnerIDOnlyWhenNamed.
ApplyDepAddItem on the v0 wire publishes source, target, type and
metadata only, so on the merge the http leg dropped both silently and
two of the PR's gates went red:

- TestEveryWireExcludedWriteMemberCarriesALedgerRow: the reflective
  census found two wire-excluded DepAddItem members with no ledger row.
- TestEveryLegWiresEveryRoleContract/http: the new case left the leg
  at 43 unwired cases against its exact ceiling of 42.

applyDepAddItemBody now refuses each member where the role would store
something the wire cannot say, under two new KindRefuse rows,
W-DepAddItem.HasSpawner and W-DepAddItem.ThreadID. The spawner flag
refuses only on a waits-for edge, because the role ignores it on every
other type and stores the same row either way. The ledger doc is
regenerated (264 rows).

The served tier wires the new case as a park on W-DepAddItem.HasSpawner,
owned by the family's existing bead, which brings the http leg back to
its ceiling. With the skip removed the case fails on the client's
refusal; with the refusal also removed it fails on the drop the row
names: spawner_id "" where the role stamps the resolved target.

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>

* fix(httpclient): address #7247 relaunch review iteration 1

Review iteration 1 of the relaunched adoption raised six majors. This
commit fixes all six. Five are the majors the first adoption's
iteration 1 raised. Its fixup, 696803f250 (tag
adopt-pr/bd-f5illd/stranded-fixup-696803f250), fixed them but never
reached the branch. That fix is ported here onto the contributor's
current head, with its reasoning unchanged; the sixth is new.

Creates refused what the CLI sends. Every `bd create` carries
CreatedBy, a workspace whose config.yaml names a prefix also carries
IDPrefix, and the client refused both.
- The server stamps created_by from the actor on all three create
  shapes: batch_create.go and batch_apply.go now match create.go.
- The client sends a CreatedBy that names the actor and refuses any
  other value, which the server's stamp would silently replace.
  createIssue and the apply create item share
  refuseUnwirableIssueMembers.
- IDPrefix refuses only where the role would act on it: an explicit,
  unforced id.
- `bd create --file` stays refused over http. Dropping its Status was
  safe but not enough: the batch create still refuses its Provenance
  and Owner. The markdown.go and batchcreator.go comments that called
  it servable now say so.

keysetFilter ignored AfterPriority. It now compares priority first,
mirroring sqlbuild's KeysetPriorityCreatedAtIDPredicate, and a new
served case resumes a priority keyset position. AfterID or AfterPriority
without AfterCreatedAt no longer reads as a zero-instant position that
discarded every row (the AfterID minor).

Claim with a patch was refused on a false ledger claim. `claim`,
`force_assignee_transfer` and `force_close_policy` now ride updateBody
like `force_notes_overwrite`, so a claim with a patch or a version guard
is one updateIssue call. A claim ALONE sent to a server that predates
the member (#6890) falls back to claimIssue. The three ledger rows are
retired, and the served cases parked on them now run.

OpenReadOnly returns a writable store. It stays writable, as a
documented exception: backends.Backend.OpenReadOnly also serves the
root pre-run's classified reads, and `bd ready --claim` writes through
that store. The exception is named in the backends.Backend contract,
the store_factory invariant and the store doc, and
TestReadOnlyOpenServesTheClaimBdReadyMakes pins it. An OpenNonMutating
backend hook is the follow-up.

Security surface.
- http_target.json is in the doctor gitignore template and its required
  patterns.
- BEADS_HTTP_TOKEN and BEADS_HTTP_TOKEN_COMMAND are host-scoped with
  BEADS_HTTP_CA_FILE's "host[:port]=value" syntax. A value scoped to
  another server falls through to the next rung, and a command scoped
  elsewhere never runs.
- LoadTarget and SaveTarget refuse a url that carries userinfo, and
  Target.String drops userinfo.

The served Tier 3 had no CI home. The new target
//internal/httpclient:httpclient_served_test is an `embedded`-tagged
sh_test. It reruns httpclient_test's binary through
tools/bazel/go_test_variant.sh with the script's
BEADS_TEST_EMBEDDED_DOLT=1 and BEADS_HTTP_TEST_REQUIRED=1, in 24 shards
on the embedded lane's race build. bazel.yml's bazel-embedded job
already runs `bazel test //... --config=embedded`, so no workflow
changes.
- -test.timeout=19m, not the script's 40m: Go's own timeout then fires,
  and dumps every goroutine, before the action's 1200s limit.
- TestBazelRetiredLanesCannotBeNarrowed pins its args and env. The new
  TestConformanceServedTierRunsUnderBazel ties the script's Tier 3
  switches to the rule.
- The new untagged TestServedTierIsLinkedWhenRequired fails a required
  run built without cgo, which drops every served file (the sentinel
  minor).
- A first 12-shard run found two test defects; both are fixed.
  TestServedBatchApplyBoundsTheItemCount's 1000-item apply outlasts the
  client's 60s per-request timeout under -race, so a
  race_detector_{on,off}_test.go pair scales its "at bound" half to 150
  there, as embeddeddolt's TestBatchApplyContract does. And
  TestTheCompositionCatchesAWrongParameter's dropped-filter case leaned
  on rows earlier tests had seeded: run alone, or first in its shard,
  it failed. It now seeds its own row outside the scope.
- conformance.sh, its script test and
  engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md name the target.

Deviations from the review's suggested fixes:
- A bare BEADS_HTTP_TOKEN(_COMMAND) fails closed rather than falling
  back, and the error does not echo the value: a bare token split at an
  "=" would put token text into the pattern half. Dropping the bare
  syntax is safe today: the backend has no Register call site and no
  docs/ page names the variables.
- Target.String drops userinfo instead of using url.URL.Redacted, which
  masks only the password, so a token used as the username would print.
- The pre-#6890 claimIssue fallback leaves RowVersion unset instead of
  borrowing the follow-up read's token. That read is a second snapshot,
  so its token could postdate a write this claim never saw and arm a
  guard that should miss; a guard built from the unset token fails
  closed. Against a current server the claim rides updateIssue, whose
  `revision` is stitched as for any update.

Also fixed: the nit about the completeness failure message, which now
says to regenerate the shell, and the offrole.go tombstone comment that
named a skip list which no longer exists. Left for follow-up (all
latent, since httpclient.Register has no production caller): vocabOnce
latching a failed fetch, snapshot holding s.mu across the handshake
dial, unchunked graph anchors, private tracker IDs in park owners, and
the bounded journal limit above 10000.

Validation:
- git diff --check; gofmt -l; go vet over internal/httpclient/... and
  scripts
- go test -tags gms_pure_go over internal/httpapi/...,
  internal/httpclient/..., internal/storage/backends/... and
  backend/conformance/...; the doctor gitignore tests; the cmd/bd
  events-journal construction guard; ./scripts
- bazel test --config=embedded
  //internal/httpclient:httpclient_served_test on the lane's remote
  executors: 24 shards, 702 top-level tests, 632 pass, 70 skip (69
  ledgered KNOWN DIVERGENCE, plus
  TestCAFileHygieneRefusesGroupWritableFile, which finds no
  supplementary group on the executor), 0 fail, 0 data races; slowest
  shard 283s. tools/bazel/check_testcases.py --bep passes.
- each of the 702 tests run alone (go test -run '^Name$', without
  -race): 0 fail
- the whole tier under go test without -race, with the script's
  switches and -timeout=40m, before the two test fixes: 633 pass, 69
  skip, 0 fail
- removing BEADS_HTTP_TEST_REQUIRED from the rule fails both policy
  tests
- bazel test --config=ci over //internal/httpclient/...,
  //internal/httpapi/..., //scripts/..., //test/docsync/...,
  //internal/storage/backends/..., //backend/conformance/... and
  //cmd/bd/doctor/...: 32 tests pass
- make ci-pr-lint: nogo native plus windows/darwin, passes

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: 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>
2026-10-08 12:01:09 +00:00
Kenton Smeltzer
d54defc2cf
docs(schema): document the provenance invariant behind execMigrationBody (#6413)
Static analysis (Snyk Code) reports the migration executor's
ExecContext / execMigrationBody calls as tainted SQL: migration file
content flows into ExecContext verbatim.

That flow is the migration contract, not a defect: sqlText is a
compile-time embedded migration body (go:embed migrations/*.up.sql,
frozen once merged and enforced by scripts/check-migration-hygiene.sh).
There is no runtime or user-controlled path into it — migrations ship
inside the bd binary, so the file-derived input Snyk models cannot be
influenced at runtime. This is hardening-by-documentation: the
invariant is spelled out on execMigrationBody, the single choke point
every migration body passes through, so auditors and future SAST runs
have the rationale in code instead of re-deriving it from the embed
directives. No behavior change.
2026-10-08 11:46:47 +00:00
Bee
c3a97e172d
show/list: render a derived GATED decoration when an open gate holds the bead (#6606)
* wy-j2upyy: render the derived GATED decoration on bd show and bd list

A bead an open gate blocks is excluded from `bd ready` but rendered
`[P2 · OPEN]` by `bd show` and with a plain ○ by `bd list`, so the human
surfaces disagreed with the readiness query.

The decoration is DERIVED, never stored: no status write, no --status
filter change, no existing JSON field reshaped.

- internal/types/gated.go: IsActiveGate, the ONE predicate — a gate-typed
  dependency reached over a blocking edge (blocks / conditional-blocks /
  waits-for) whose status is neither closed nor pinned. That is the
  is_blocked recompute's blocking leg restricted to gates, so a rendered
  GATED and a `bd ready` exclusion cannot disagree. GateDescription /
  GateReason own the reason's round trip with `bd gate create`.
- bd show: `[P2 · OPEN · GATED]` plus one `Gated by: <id> (<type>[:
  <reason>][, awaiting <await-id>])` line per gate, beside Deferred:. The
  dependency read the DEPENDS ON section already made is hoisted, so the
  decoration costs no extra query.
- bd list: ⊘ in the glyph column (circle family, distinct from ○ and ❄),
  and a legend entry when the page carries one. Batched by id set —
  at most two extra queries per listing, one in the tree view where the
  edge map is already loaded.
- --json: additive `gated_by: [{id,type,reason}]` on the detail view,
  omitted when empty; documented in the OpenAPI IssueDetails schema.

Tests (red first): cmd/bd/gated_render_embedded_test.go drives real
bd show/list/--json over an embedded rig — gated, resolved, deferred+gated,
JSON additivity — plus pure unit tests for the predicate and formatters.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* wy-j2upyy: document the additive gated_by field in the JSON schema reference

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* wy-j2upyy: cover the flat list route's own batched gate read

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* wy-j2upyy: make GATED the readiness rule's gate clause, both halves

The adversarial review found the "one predicate shared with bd ready" claim
false on two axes, and both were reproducible by hand:

BLOCKER 1 — waits-for is not the status rule. The is_blocked recompute applies
"target not closed and not pinned" only to its blocks / conditional-blocks
legs; the waits-for leg goes through waitsForGateBlockedSQL, a fanout over the
target's open parent-child children (or an also_blocks spawner). A plain
`bd dep add X G -t waits-for` onto an open childless gate therefore leaves X
in `bd ready` while every new surface called it GATED. Mirroring that leg in
Go would be a second implementation of a rule the database owns, so the edge
clause now names the two legs it really mirrors (types.IsGateEdge) and the
test that pinned the wrong direction is flipped.

BLOCKER 2 — the subject half was missing and spelled three different ways.
unmarkAllBlockedSQL forces is_blocked=0 for a closed or pinned subject
whatever its edges say, so `bd ready` never withholds one on a gate's account;
show and workapi filtered nothing, cmd/bd/gated.go filtered closed only, and
list_format.go filtered closed at two more sites. A force-closed bead rendered
[CLOSED · GATED] with gated_by on show while list showed a plain row — show
and list disagreeing about one bead, which is the drift this was meant to
prevent. The clause is now types.SubjectCanBeGated, asked once in
types.GatesHolding (which replaces ActiveGates and takes the subject) and once
in the listing helper that has no hydrated deps; the formatters re-ask the SAME
exported predicate rather than inventing a fourth spelling.

SHOULD 3 — agent mode computed the gate reads and threw them away, in every
CLAUDE_CODE seat, i.e. the population that filed the bug. Decorating it is the
real fix, so gatesByIssueID now returns the gate IDS and formatAgentIssue
carries "gated by: <id>" in the parenthetical it already prints. A gate is
also a blocker, so its id appears under both "blocked by" and "gated by": the
first says what to wait on, the second says which of those nobody can clear by
doing more work. --long and --format render no gate and no longer pay for the
reads.

NOTE 5 — a pinned+gated row kept ⊘ instead of 📌; with the subject clause a
pinned bead is not gated at all, so the pin survives by construction.
NOTE 6 — the cost comments claimed "two queries" / "exactly ONE"; the id-set
readers are a few round trips each. The bound that is real (per page, never
per row) is what the comments now say.

Tests, red-first: the flipped waits-for case; TestGatesHoldingSubjectStatus and
TestSubjectCanBeGated (open/in_progress/deferred yes, closed/pinned/nil no);
TestFormatIssueCompactGated and TestFormatAgentIssueGated; and four embedded
arms — a waits-for edge that bd ready lists and no surface decorates, a
force-closed subject and a pinned subject that render nothing and publish no
gated_by, and the agent line naming its gate. Each was watched to fail against
the pre-fix predicate before it passed.

Ran: go test ./internal/types/ -run 'TestGateIsHolding|TestGatesHolding|
TestSubjectCanBeGated|TestGateDescriptionRoundTrip|TestGateRefsProjection';
go test ./cmd/bd/ -run 'TestFormat*Gated|TestFormatIssueCompact*|
TestFormatDependencyInfoWithParent|TestListRoles*|TestDisplayPrettyList*';
BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd/ -run TestEmbeddedGatedRendering
(11/11 subtests); gofmt -l (empty), go vet and golangci-lint on cmd/bd,
internal/types, internal/ui, internal/workapi; scripts/ci/pr-policy.sh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* wy-j2upyy: render GATED on the proxied `bd show` text route

SHOULD 4 of the review, and required for this rig: the constellation runs
proxied-server, where `bd show --json` already carried gated_by (uow
issue_reader -> workapi.BuildIssueDetails) while the TEXT renderer called the
plain formatters. The same bead read two ways from the same server disagreed.

proxiedRenderIssue now hoists the outgoing-edge read it already did for the
DEPENDS ON section above the header — the gates are the gate-typed subset of
that very set, so the decoration costs no extra query — and passes them to
formatIssueHeaderWithGates / formatIssueMetadataWithGates. The proxied LIST
routes were wired in the previous commit.

TestProxiedServerGatedRendering covers all five text surfaces plus the JSON
one beside them (header + Gated by line, pretty glyph, compact glyph + "gated
by", agent line, and a closed subject that renders nothing). Watched red first
with the proxied decoration stubbed out: four of six subtests failed, and the
--json arm passed, which is exactly the asymmetry the review reported.

Ran: BEADS_TEST_PROXIED_SERVER=1 go test ./cmd/bd/
-run TestProxiedServerGatedRendering -count=1 (6/6, 37.8s).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* wy-j2upyy: put cmd/bd/state.go on the shared "Reason:" marker

NOTE 7 of the review: types' gateReasonMarker was not gate-private —
cmd/bd/state.go wrote the same "\n\nReason: " into state-change EVENT
descriptions from its own literal. No live collision (events are not
gate-typed), but the constant's doc claimed GateReason returns "" for every
gate not made by `bd gate create`, and that is false for any description
carrying the marker.

The previous commit exported the constant as types.ReasonMarker, reworded
GateReason to say what the pair really guarantees (a round trip, not a
provenance check) and pinned the honest behavior in
TestGateDescriptionRoundTrip. This commit is the second writer: state.go now
builds its event description from the same constant, so the two cannot drift
apart by accident.

Ran: go build ./...; go test ./internal/types/ -run TestGateDescriptionRoundTrip
-count=1; gofmt -l cmd/bd/state.go (empty); go vet ./cmd/bd/.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* wy-j2upyy: alias types.GateRef in package backend

gated_by on IssueDetails makes GateRef reachable from the public backend
contract; TestPublicSurfaceComplete requires every such type to carry an
alias here.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* wy-j2upyy: build(bazel): register gated.go and its tests in cmd/bd and internal/types

The rebase onto e766da5ed carried the new source files but not their
BUILD.bazel entries, so every Bazel lane failed to compile internal/types
(undefined: GateRef). This is CI's own bazel-sync patch for 9ad7eb96c3,
applied unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* wy-j2upyy: compute gated_by AFTER the dependencies read in BuildIssueDetails

The be-lpi merge (#6352) moved src.Dependencies() below the cardinality
counts so the unresolvable-edge delta reads count-first. That hunk merged
cleanly, which left details.GatedBy computed on the still-nil slice, and
both CI shards' show_json…carries_gated_by subtests went red (PR Risk
Embedded Dolt Cmd 20/20, Proxied Dolt Cmd 4/15 at d21237f3dc).

Move the GatedBy line to directly after details.Dependencies = deps, still
before the BriefDeps trim that rewrites the slice, and pin the ordering with
a workapi unit test over both DetailSource seams and BriefDeps on/off (red
on the pre-fix code, green after).

Ran: go test ./internal/workapi; go vet ./internal/workapi;
BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd -run TestEmbeddedGatedRendering;
BEADS_TEST_PROXIED_SERVER=1 go test ./cmd/bd -run TestProxiedServerGatedRendering.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: register #6606's gated-rendering tests and gated_by wire shape with main's generated gates

Maintainer fixup for adopt-pr #6606. The adopted head merges the PR head
(c43eb567d2) into main (800d43eb8d). The PR's merge-base (02f05340f6)
predates three generated artifacts on main that every PR adding a cmd/bd
tier test or a wire member has to keep current, so the merged tree is red
on them even though the PR's own CI cannot see them:

- .github/scripts/embedded-cmd-test-shards.txt: the Bazel-only 50-shard
  block must name every TestEmbedded* test exactly once, or
  TestCmdEmbeddedShardManifestGeneratorNotStale fails `go test ./scripts/`.
  `gen_embedded_cmd_shard_manifest.py 50 --weights=duration --write`
  (incremental) placed TestEmbeddedGatedRendering on shard 16 and moved
  no existing assignment; the frozen 20-shard block is untouched.
- .github/scripts/proxied-cmd-test-shards.txt: likewise for the 30-shard
  block and TestProxiedServerGatedRendering (shard 2), via
  `gen_proxied_shard_manifest.py 30 --weights=duration --write`, so
  TestProxiedShardManifestGeneratorNotStale passes.
- internal/httpapi/wireshape/testdata/golden.json: TestWireShapeDigest
  (#7182) pins every response member. `go run
  ./internal/httpapi/wireshape/cmd/gendigest` recorded the PR's new
  IssueDetails.gated_by array and its id/type/reason members as four pure
  additions (+25/-0), so no wire_revision bump is owed.

The PR's own files are unchanged.

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>

* docs(gated): state gated_by one way, mark --watch as undecorated, fix stale refs

Review follow-ups for #6606. Comment and doc text only; no behavior change.

- gated_by is now documented in one direction. internal/types/types.go,
  internal/types/gated.go and docs/reference/json-schema.md said the list
  is nonempty EXACTLY when `bd ready` withholds the issue on a gate's
  account. Only one direction holds: the is_blocked recompute also blocks
  a child whose parent is blocked (its parent-child legs), so a child of a
  gated parent leaves `bd ready` with an empty gated_by. All three now say
  "nonempty means withheld", as the OpenAPI text already did, and name the
  parent-child case.
- bd list --watch passes a nil gated map on both routes
  (runListProxiedWatch, displayWatchedIssueList), so a bead the one-shot
  listing marks with the gated glyph keeps its plain status glyph while
  watched. Watch is out of this PR's scope; the three call sites now say
  so instead of reading as a forgotten argument.
- show_format.go named types.ActiveGates, which does not exist; the
  predicate is types.GatesHolding.
- gated.go's best-effort note compared the gate read with `bd list`'s
  blocking annotation, which only the direct route swallows. It now scopes
  that comparison to the direct route and names the proxied route's
  failing read (A-blk-1).
- proxiedGatedIssueIDsOwnUOW now notes that its unit of work is a second
  snapshot, so one render can name a just-resolved gate under "blocked by:"
  but not "gated by:".

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>

* fix(list): hydrate proxied gate candidates from both planes (bd-p8k7dm)

The proxied list resolved gate candidates through the use case's
GetIssuesByIDs, which reads the issues table only, while the edges it
resolved came from GetForIssueIDs, which reads both dependency tables.
A wisp gate (`bd mol wisp` clones a formula's gates as wisps, held to a
wisp step by a blocks edge) therefore hydrated to nothing. Its step
listed undecorated in pretty, --flat and agent output while `bd show`,
`--json` and `bd ready` called it gated.

Read the wisps beside the issues, the two-plane idiom
ready_proxied_server.go and uowMolReader already use. A failed wisps
read keeps the durable candidates. Correct the cost-bound comment that
claimed the id-set readers partition the planes on both routes.

Tests: a wisp-step + wisp-gate case in TestProxiedServerGatedRendering
and TestEmbeddedGatedRendering asserts the pretty, --flat and
CLAUDE_CODE=1 rows of `bd list --include-ephemeral`, and
TestProxiedGatedIssueIDsHydratesBothPlanes pins both planes plus the
failed-wisps-read fallback.

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: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-08 10:37:51 +00:00
ecuthiell
0ed6d47ba3
test(doctor): assert the nonexistent-path role check's N/A message (#6401)
* fix(exec): match Windows environment key identity (#5618)

Centralize os/exec-compatible environment-key comparison and use it for credential, metrics, Git-hook, trace, and repro subprocess filters. Preserve exact Unix semantics and Unicode near-collisions.

Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Ewen Cuthiell
Signed-off-by: Ewen Cuthiell <ewencuthiell@gmail.com>

* fix(worktree): scrub inherited Git routing state

Establish CWD as the worktree repository boundary before discovery can consume inherited Git routing. Fence the startup config probe, clear routing in-process before root pre-run discovery, and retain command-owned subprocess scrubbing as defense in depth without changing PID or signal semantics.

Fixes #5531

Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Ewen Cuthiell

* refactor(worktree): explain owned filtering and remove an unused shim

Document why filtering the fresh routing slice in place is safe and call
the shared routing-key classifier directly from tests. Retain the two
forwarders used by production worktree subprocess/removal paths.

Review: https://github.com/gastownhall/beads/pull/5623#pullrequestreview-5098421671
Bead: saa-cgh.23
Agent-Signature: unknown-model/unknown-reasoning

* fix(config): isolate identity and tracked-file Git probes from routing

Reuse the worktree routing owner for GetIdentity and isGitTracked so
explicit cwd/path selection is not displaced by inherited repository,
index or injected config state. Preserve identity precedence and the
tracked-secret refusal contract, with real target/decoy regressions.

Follow-up: https://github.com/gastownhall/beads/issues/6222
Dependency: https://github.com/gastownhall/beads/pull/5623
Reported-by: bee-ghosttrack
Bead: saa-cgh.93
Agent-Signature: unknown-model/unknown-reasoning

* test(execenv): exercise every environment operation under both host rules

Thread the host choice through narrow private helpers behind the existing
exported functions. Keep one normalization owner and retain native wrapper
tests; the additional table covers both host branches for equality, prefix
matching, last-wins lookup, filtering and input preservation.

Review: https://github.com/gastownhall/beads/pull/5672#pullrequestreview-5096948965
Bead: saa-cgh.78
Agent-Signature: unknown-model/unknown-reasoning

* docs(worktree): explain startup Git environment scope (saa-cgh.23)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(execenv): exercise exported host policy wiring (saa-cgh.78)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(config): share subprocess key identity for Git routing (saa-cgh.93)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(env): exercise shared key helpers on native Windows (saa-cgh.78)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* refactor(gitenv): share key parsing and normalize routing membership once (saa-cgh.93)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* fix(doctor): isolate role lookups from inherited Git routing (saa-cgh.109.2)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* test(doctor): isolate legacy role fixtures from user home config (saa-cgh.109.2)

Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell

* review: reduce to the base-relative _NonexistentPath message assertion

Iteration-2 maintainer review fix for #6401, amending the iteration-1 fixup
rather than stacking a second one.

Iteration 2 filed a blocker plus two majors: #6247 (`ced3dfe220`) landed this
PR's entire remaining residual on main - helper name included - so the previous
reduction had become unmergeable, and both obvious resolutions damage main.
Installing the head's `role_test.go` compiles and leaves a green package while
silently deleting `TestCheckBeadsRoleIgnoresInheritedRouting`, the 7-subtest
table from #6461, with no CI tripwire. Keeping main's table while carrying this
PR's `isolateGlobalGitConfig` fails to compile: the two branches added the same
helper name in the same package with divergent signatures (ours void, main's
`string`, consumed as `home := ...`), so main's is the incumbent.

The reduction is therefore expressed against the adoption base `f66375459`,
adding nothing main already has: `cmd/bd/doctor/role_test.go` is byte-identical
to base except for the `check.Message != "N/A (not a git repository)"` assertion
and the three-line comment explaining why status alone is not discriminating
("Configured as maintainer" is `StatusOK` too). This head neither defines nor
calls `isolateGlobalGitConfig` - 0 occurrences - so main's helper and its two
fixture call sites are left untouched.

Net: +6/-1 against base, down from +25/-1, and the whole PR is now this one
test file.

Note for the next review pass: a prescribed remedy that writes upstream's
content into the head is the failure mode here, not the fix. Doing that makes
ours a superset of theirs in the same region, which git UNIONS rather than
conflicts, duplicating main's table test - and `merge-tree` still reports rc 0,
so a clean merge-tree is not a compile certificate. The two gates that catch it
are vetting the EXTRACTED MERGED TREE and censusing `^func` names inside the
MERGED file; both are run below and both are clean for this arm.

---------

Signed-off-by: Ewen Cuthiell <ewencuthiell@gmail.com>
Co-authored-by: Bee <bee@ghosttrack.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-08 09:52:52 +00:00
Bee
5d2c01bd9a
feat(show): --comments-tail N renders only the last N comments in text mode (#6618)
* feat(show): --comments-tail N renders only the last N comments in text mode

Real-world beads accumulate 600+ comments and bd show renders ~800 KB of
text for them. --comments-tail N caps the text-mode COMMENTS section to
the last N comments, preceded by one elision line naming how many older
ones were hidden (singular/plural handled). This is render-only: no data
is fetched differently, and the comment count in any header still
reflects the total.

The flag absent or set to 0 is byte-identical to today's output (pinned
by a test comparing against an independent reproduction of the pre-flag
render). A negative value is a usage error, matching how --max-rows
already rejects negative values. --json is untouched; --include-comments
still streams every comment there, documented in the flag's help text.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(show): --comments-tail reaches --watch; drop two vacuous tests

Plumb --comments-tail through watchIssue / displayShowIssue /
displayShowIssueReturn to a new renderWatchComments (its own function so
tests can exercise the exact call without a real database), replacing the
third inline COMMENTS copy that ignored the flag. watchCommentFormatTime
preserves the hardcoded UTC formatting byte for byte; --local-time still
isn't threaded to --watch, unchanged by this commit.

Also drop TestPrintComments_AbsentMatchesZero and
TestPrintComments_CommentCountHeaderUnaffected (vacuous — the first called
printComments(x, 0) against itself, the second asserted len() on a
by-value slice and bd show text mode prints no comment count); folded the
absent-flag case into the legacy-comparison test instead.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: list show_comments_tail_test.go in cmd/bd BUILD.bazel

Bazel equivalence requires every test file in the go_test srcs; this is the
line CI's bazel-sync patch printed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: rerun after #7338 re-pinned the RBE worker-env (no code change)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-08 09:00:31 +00:00
Bee
2cae0c1ad8
fix(storage): a parent-child edge propagates only the parent's exogenous blockedness (#6506) (#6602)
* fix(storage): parent-child cascade propagates only exogenous blockedness (wy-3eb07b, #6506)

A parent-child edge used to cascade the parent's is_blocked bit to its
children WHATEVER set it. So the "close gate on the epic" idiom — P carries
blocks edges onto its own children C1 and C2 so P cannot close before them —
darkened the very children P was waiting for. Neither child could reach
bd ready, so neither could be worked, so neither could close: a permanent
lock, and the one direction cmd/bd/dep.go does not refuse.

The contract (#6506): a parent-child edge propagates only EXOGENOUS
blockedness. P counts as blocked FOR CHILD C iff P has a blocking reason —
an open blocks/conditional-blocks target, or a live waits-for gate — whose
target is NOT one of P's own parent-child children, or P's own parent is
(recursively) exogenously blocked. P's OWN is_blocked is unchanged: it really
does depend on open children. Only the propagation narrows.

DESIGN: a second-pass predicate on the parent row, not WITH RECURSIVE.
Both parent-child legs of shouldBeBlockedIDsUnionScopedSQL keep their
p.is_blocked = 1 conjunct and gain parentCascadesBlockedSQL, which says "p's
blockedness is not solely explained by p's own children":

    EXISTS (blocking reason of p whose target is not p's child)
      OR NOT EXISTS (blocking reason of p whose target IS p's child)

The second disjunct carries the contract's recursive clause through the
EXISTING fixpoint instead of through SQL recursion: a parent that is blocked
with no child-targeted reason of its own is dark either exogenously or
because ITS parent is, and either way its children inherit — one level per
pass, exactly as the cascade always converged.

A recursive CTE was the other candidate and is rejected on cost, not on
engine support. Its seed set is the direct-exogenous set, which includes the
waits-for gate, and the seed cannot be confined by the batch scope (%[3]s)
because a batch's ancestors are by definition outside the batch. That would
put an UNSCOPED whole-table gate evaluation into every batched mark/unmark —
the statement shape #6288 removed, now on every write instead of only on the
full repair. The predicate here is correlated to a parent that is already
known blocked, so it probes idx_dependencies_issue for a handful of rows.
The scope splice, the DISTINCT waits-for barrier and the doctor-count
lockstep are all untouched.

One gap this form does not express: a parent that is BOTH blocked by its own
open child AND darkened by an exogenously blocked ancestor is not
distinguishable from one blocked only by its children, so its children stay
bright. That is an under-propagation in a corner the contract would darken;
it needs a second stored bit (or the CTE above) to see, and it cannot
recreate the lock this commit removes.

Also: AffectedByDepChange{,ForWisp}InTx now seeds the parent's other children
on a parent-child edge change (appendSiblingsUnderParentInTx). Writing that
edge reclassifies the parent's blocking reason on the new child from
exogenous to child-derived, which flips the answer for the SIBLINGS — the
close-gate epic is built one child at a time, and the second edge is what
un-darkens the first. Without it the incremental write path and the full
repair disagree, which the new tests catch as a nonzero doctor count.

Tests (internal/storage/dolt/blocked_consistency_test.go), all four seeded
through the real write path and each verified RED against the pre-fix SQL
except the control:
  - ParentBlockedOnlyByItsOwnChildren: the repro, plus a GetReadyWork
    assertion that the children are workable again.
  - ExogenousParentStillCascades: the control — the fix narrows the cascade,
    it does not remove it. Green before and after.
  - ThreeLevelChainBothWays: GP exogenous darkens P and C; GP blocked only by
    its child P darkens neither. Repaired from an inverted plane too, since
    the chain is the case that needs more than one pass.
  - WaitsForGateOverOwnChildren: a gate whose spawner is the parent's own
    child does not darken; one on an outside spawner does.

TestRecomputeAllIsBlocked_CascadesThroughParentChild is unchanged and green,
including its single-pass lower-bound count — which is why the legs keep the
p.is_blocked = 1 conjunct rather than deriving the cascade from the graph
alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(dep): warn when a parent blocks on its own child (wy-3eb07b, #6506)

`bd dep add P C` where C is already P's parent-child child is the "close gate
on the epic" idiom: P carries a blocks edge onto its own child so P cannot
close before it. dep.go refuses the OTHER direction (a child blocking on its
dotted-ID parent, "would create a deadlock") and says nothing about this one,
which is the direction that used to deadlock for real — the cascade darkened
the child, so it could never reach bd ready, be worked, or close.

Since the cascade fix the edge is harmless, so this is an advisory, not a
refusal: it names what the edge now means (the parent stays blocked; the
child and its siblings are NOT hidden from bd ready) so an operator does not
have to rediscover the contract from a query.

It fires only for blocks/conditional-blocks, only after the edge has actually
landed and committed, and stays silent on any read error — an advisory must
not turn a successful write into an error, and must not precede a refusal for
an edge that was never written (the hierarchy and cycle guards reject this
pair whenever both edges already exist, in either order, which is why the
shape usually arrives one edge at a time or through import).

Unlike the D1 implicit-blocks warning it is NOT gated on an interactive
stderr: that one fires on the documented-default majority path, where
training callers to ignore stderr is the risk; this one fires on a rare
deliberate shape, and an agent wiring a close gate is exactly the caller who
should read what it does.

Wired into both direct paths (`bd dep add` and `bd dep --blocks`); the
proxied-server paths return earlier and are untouched.

Tests beside the existing dep-add warning tests: the predicate table
(including the two controls — right id with a blocks edge is not a child, and
the parent's other children do not match), the message content, and the type
gate proving it returns before touching the store.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(doctor): report parent-blocks-on-own-child edges (wy-3eb07b, #6506)

A new "Parent Close Gates" check lists every blocking edge from a parent onto
one of its own parent-child children — the close-gate idiom, where P blocks
on C1 and C2 so P cannot close before them.

INFORMATIONAL, with no --fix and no effect on the overall result. Before the
cascade fix these edges were a trap: the parent's blocked bit propagated to
its children whatever set it, so the gate hid the very children it was
waiting for and nothing under it could become ready. The cascade now
propagates only exogenous blockedness, so the edges are legal and usually
deliberate. What an operator wants from doctor is therefore the inventory —
which beads in this store use the idiom, and where a pre-6506 store's
mysteriously invisible children came from — not a repair, and certainly not a
warning that would train people to remove a working gate.

It is the mirror of the existing "Child-Parent Dependencies" check, which
finds a CHILD blocking on its PARENT (still a deadlock, still fixable). The
two differ in how they match: that one reads dotted-ID ancestry, this one
matches real parent-child edges, because the close gate is wired between
unrelated ids.

Tests beside the child-parent ones: the empty inventory (with an ordinary
hierarchy present, which must not be mistaken for a gate), and the reported
case with two controls in the same fixture — an exogenous blocker on the
parent and an ordinary blocker on the child, neither of which may appear.

Gate note: these live in package cmd/bd/doctor, which the brief's cmd/bd
selector does not reach; `go test ./cmd/bd/doctor/` was run in full.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* revert(dep): drop the unreachable parent-blocks-own-child warning (wy-3eb07b, #6506)

This reverts 34b7f5b42. The warning it added could never print.

Its precondition is "a blocks edge from P onto C succeeded AND C is already
P's parent-child child", and the store refuses exactly that edge.
CheckBlockingHierarchyInTx (internal/storage/issueops/dependencies.go) rejects
a blocker that is the source's own descendant, and it sits OUTSIDE the
SkipCycleCheck gate, so no caller opts out of it; batch_apply.go:533 applies it
again on the DependencyEditor path `bd dep add` actually uses. Written in the
other order, the parent-child edge that closes the pair is refused as a cycle.
So the reverted code paid a GetDependentsWithMetadata read on EVERY
blocks/conditional-blocks `bd dep add` to emit something no operator could
ever see, and its 102-line test pinned a predicate instead of a behaviour.

What an operator DOES hit is the refusal — and the cascade fix left its stated
reason false. It read "blocked status cascades to descendants, so <blocker>
would inherit the block and never close". Since #6506 a parent-child edge
propagates only the parent's exogenous blockedness, so the descendant does not
inherit and nothing deadlocks. The refusal still stands, because a blocks edge
is not how the hierarchy says "I close after my children" — so the reason now
names the form that is: a waits-for gate over the children, `bd gate`.

The same false sentence was the OpenAPI description of
Problem.blocker_is_ancestor, so it is corrected there too, with types.gen.go
regenerated by `go generate ./internal/httpapi/apigen/` to keep `make
api-check` green.

The doctor "Parent Close Gates" check from 4c5f2f77b is KEPT. A warning on a
write path that refuses the write is noise; an inventory of the edges a store
already carries — from import, from merge, from the pre-refusal past — is what
an operator can act on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(storage): the parent-child exogeneity test is over the whole SUBTREE (wy-3eb07b, #6506)

B1 of the adversarial review: 648ab0af6 tested "is this blocking reason's
target one of my own children" as a DIRECT parent-child child, but #6506's
contract is about blockedness originating outside the parent's own SUBTREE.
At depth 1 the fix worked; at depth 2 it left the permanent lock alive.

  P --blocks--> G,  pc C -> P,  pc C2 -> P,  pc G -> C

G is not P's child, so P read exogenous, so P darkened C, so C darkened G —
and G is the only row whose close can free P. Exactly the shape-1 mutual lock
the issue says no contract intends, one level down. Pinned as
TestParentChildCascade_ParentBlocksItsOwnGrandchild, verified RED at
4c5f2f77b: p/c/c2/g all blocked, all three children missing from ready work,
and the full repair changing nothing.

The test is now a real ancestor walk (subtreeWalkDepth levels of indexed
LEFT JOINs up from the reason's target), so a reason anywhere under the
blocker counts as its own.

Also B2 — the cost regression, which is the same edit, because the shape that
makes the test correct and the shape that makes it affordable are one
decision. The union's parent-child legs no longer carry a per-row correlated
EXISTS. They subtract an uncorrelated set instead:

    AND p.id NOT IN (parents explained by their own subtree)

and the UNBATCHED statements (full repair, doctor count) do not even spell
that set as a subquery: it is read ONCE per fixpoint pass and bound as ids.
A repair pass is four statements and each would otherwise derive the same set
twice; reading it once is the whole difference. The batched mark/unmark keep
the spliced subquery, where it is confined to the batch's own parents by the
existing scope splice and costs a few rows.

MEASURED, gastownhall/beads#6506 bar: full repair and doctor count <= 1.5x
origin/main, write path <= 1.2x. Committed benchmark
(internal/storage/dolt/blocked_scale_bench_test.go, -short-skipped), 1000
issues / 2870 deps / 333 blocked rows, embedded dolt 2.2.0, run INTERLEAVED
main/head to cancel machine drift, four pairs, medians:

                             origin/main 71c4cd08b   this branch   ratio
  full repair                 48 71 43 46 -> 47 ms   66 56 54 55 -> 55 ms  1.18x
  doctor count                55 62 44 53 -> 54 ms   67 61 57 57 -> 57 ms  1.06x
  write path, per CloseIssue  37 30 21 22 -> 26 ms   30 23 16 24 -> 23 ms  0.91x

All three inside the bar; the worst single PAIR is 1.38x on the repair and
1.30x on the count. The two sides disagree on blocked rows by construction
(604 on main, 333 here) — that IS the fix.

NOT inside a bar, and disclosed rather than hidden: the benchmark's fourth
timing, a 200-id RecomputeIsBlockedForIDsInTx (the bulk/import batched path,
which no metric in the review covered), is 53-63 ms on main against 400-556 ms
here — 6.9x at the medians. The cause is structural and measured: a batched
pass runs many small statements, each deriving the set twice, and the set
costs a few ms however it is written. The per-pass read that fixes the
unbatched statements makes the SMALL-batch case worse, not better (one
whole-store read costs more than the subqueries a two-id batch pays), so the
fix is a per-batch-scoped read threaded through expandBatchTemplate's
placeholder plumbing — a separate change, and the reason this timing is
committed rather than left in a scratch file.

Three shapes were built and measured before this one, all at the same scale:

  - the review's own: per-row correlated EXISTS with two more inside,
    3.3-3.7x full repair, 5.2x doctor count;
  - the set as a DISTINCT derived table LEFT JOINed on p.id, which is what B2
    recommended: ~30x. dolt plans a join operand as the inner side of a nested
    loop and rebuilds it per outer row — the correlated shape in a derived
    table's clothes. This is the one finding that contradicts the review, and
    it is why the set is subtracted with NOT IN instead;
  - WITH RECURSIVE for the ancestor walk: blew the driver read timeout on the
    full repair. A recursive CTE pays a query's overhead per ITERATION; the
    seeded walk cost 45 ms per evaluation against 6 ms for four levels of
    joins, which is why the walk has a horizon (subtreeWalkDepth = 4, epic ->
    sub-epic -> leg -> task). Past it a reason reads as exogenous, which
    propagates MORE and hides nothing the old code showed.

Seeding: AffectedByDepChange{,ForWisp}InTx now walks UP from a parent-child
edge's target, not just to it. Hanging G under C changes nothing about C and
everything about any ANCESTOR of C that blocks on G, so each such ancestor's
sibling set is reseeded — otherwise the incremental write path and the full
repair disagree, which the new test catches as a nonzero doctor count. The
walk is filtered to ancestors that carry a blocking reason at all: without
that filter a 70-deep chain reseeds every ancestor's subtree on every edge
written into it, which timed out TestGetReadyWork_ParentFilterReturnsDeepDescendants.

CHANGELOG now names the limitation the review ruled acceptable but undocumented
(a sub-epic blocked both by its own children and by an exogenously blocked
ancestor keeps its children visible), marked tracked upstream; bee files the
follow-up issue at PR time.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(doctor): rune-safe Detail truncation, Category on the N/A returns (wy-3eb07b, #6506)

The "Parent Close Gates" check joins its inventory with U+2192, three bytes
wide, and then cut the joined string at byte 200. Two of every three offsets
land mid-rune, so `bd doctor --json` could carry invalid UTF-8 in Detail — a
display nuisance in the terminal, but a value a JSON consumer has to decode.
truncateDetail walks back to a rune boundary first; the test drives every
entry count from 1 to 120 so the cut lands at all three offsets within the
arrow and asserts utf8.ValidString on each.

The same byte cut appears twice more in this file (:101, :561) on ASCII-only
details. Left alone here: they are not this bead's, and changing them would
put a behaviour change in two checks a reviewer of #6506 has no reason to be
reading.

The check's two "N/A" early returns also omitted Category, unlike its three
real returns, which drops them out of the categorised report. Both now carry
CategoryMetadata.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* perf(storage): read the batched exogeneity set once per batch, not per statement (wy-3eb07b, #6506)

D1, the PR blocker from the round-1 review. The batched mark/unmark templates
spliced parentsExplainedBySubtreeSQL — the "which blocked parents are explained
only by their own subtree" query — into both of their parent-child legs,
batch-scoped. The scope made it look cheap. It was not: dolt pays for a
`p.id NOT IN (subquery)` once per leg per STATEMENT, and a batched pass is a
mark and an unmark, so one 200-id RecomputeIsBlockedForIDsInTx derived the set
four times and measured 6.9x origin/main (53-63 ms -> 400-556 ms). That is the
bulk/import path and the cost shape #6288 removed.

The set is now READ once per batch and BOUND into both statements as ids —
the same trade the unbatched full repair already makes per pass — which is why
markBlockedTemplate/unmarkBlockedTemplate are built per batch now: the number
of bound ids is a property of the batch. In front of the read sits a cheap
indexed guard, batchParentKindsInTx: a parent KIND with no parent-child row in
the batch has an empty candidate set, hence an empty exogeneity set, so its
read is pure overhead, and the read is a ten-join walk under two CTEs that
dolt spends ~8 ms planning whether it returns rows or not. Most batches name
no wisp parent at all; a batch of roots names neither. Without the guard the
2-id case measured 1.9x, with it 0.94x.

expandBatchTemplate now WALKS the template instead of counting "%s": the batch
scope and the bound exogeneity ids alternate inside the union (leg 3's scope,
leg 3's NOT IN, leg 4's scope, leg 4's NOT IN), so only text order says where
each group goes. It returns an error on a ?/bound mismatch rather than handing
the engine an opaque argument-count failure. The %s budget is back to 6 from
8, re-pinned, with two new pins beside it: the ? group is exactly the bound
exogeneity ids (none for an empty set), and the mismatch is refused.

KEPT, on round-1's measurements: the NOT IN subtraction (the derived-table
JOIN measured ~30x in dolt) and the 4-level LEFT JOIN ancestor walk (WITH
RECURSIVE blew the driver read timeout).

MEASURED. n=1000 issues / 2870 deps / 333-604 blocked, embedded dolt 2.2.0,
TestBlockedStateScaleTiming, SIX interleaved origin/main(71c4cd08b)/head pairs,
medians, worst single pair in brackets. The bench now times three batch sizes
instead of one, because the per-statement and per-id costs pull opposite ways:

  metric                     main     head    ratio          bar
  full repair               49 ms    57 ms    1.16x [1.32x]  <= 1.5x  MET
  doctor count (consistent) 48 ms    57 ms    1.18x [1.32x]  <= 1.5x  MET
  write path, per CloseIssue 25 ms   26 ms    1.03x [2.59x]  <= 1.2x  MET
  batched recompute, 200 id 54 ms    69 ms    1.28x [1.57x]  <= 1.5x  MET
  batched recompute,  20 id 17 ms    22 ms    1.29x [1.50x]  (measured)
  batched recompute,   2 id 22 ms    21 ms    0.94x [1.03x]  (measured)

All four stated bars are met on medians. The worst-pair column is at or inside
this box's own noise: over the same six runs origin/main's OWN spread is 2.07x
on the full repair, 2.33x on the write path, 1.92x on the 2-id batch and 1.19x
on the 200-id batch, so a single pair's ratio is not evidence at this
resolution and the medians are what the bars are read off.

DISCLOSED, not a stated bar and not fixed here: the bench FIXTURE BUILD —
2870 AddDependency calls plus 240 CloseIssue through the store — is 75 s ->
102 s, 1.36x [1.61x]. That is the dependency-ADD write path, and the cost is
round 1's incremental seeding (AffectedByDepChangeInTx now walks up to every
reason-carrying ancestor and reseeds its whole sibling set), which is what
buys the incremental/full-repair agreement pinned by the lockstep test in the
next commit. Per-edge it is sub-millisecond; it shows up here because the
fixture writes the hierarchy of a 1000-issue store edge by edge.

GATE: go build ./... ; go vet ./internal/storage/issueops/ ; go test
./internal/storage/issueops/ (ok, includes the rewritten template and sqlmock
pins) ; BEADS_TEST_EMBEDDED_DOLT=1 go test ./internal/storage/dolt/ -run
'ParentChildCascade|RecomputeAllIsBlocked' (ok) ; gofmt -l clean. The full
enumerated gate is on the bead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(storage): pin both sides of the subtree-walk horizon, and the incremental/full-repair lockstep (wy-3eb07b, #6506)

D2 and D3 from the round-1 supervisor ruling.

D2 — THE HORIZON IS NOW PINNED, not commented. "Inside my own subtree" is
decided by a fixed 4-level ancestor walk (subtreeWalkDepth), because a
recursive walk cost 7.5x per evaluation and blew the driver read timeout. Two
tests that differ by ONE EDGE straddle it:

  _ReasonAtTheWalkHorizon    P blocks a descendant exactly 4 pc levels down.
                             The walk reaches P, so the reason is
                             subtree-derived and the chain comes bright.
                             RED on origin/main (4 rows dark that the fix
                             brightens) — so it is not vacuous.
  _ReasonPastTheWalkHorizon  one level further. The reason reads as EXOGENOUS,
                             so the whole chain stays dark, which is
                             origin/main's own answer — and that test PASSES
                             UNCHANGED ON origin/main (verified in a temp
                             worktree at 71c4cd08b, since removed). It also
                             asserts no row of the shape appears in
                             GetReadyWork: no new dark rows AND no new visible
                             rows past the horizon, checkable rather than
                             argued. Raising the constant makes it fail and
                             name the row that changed.

Both also repair from a fully inverted plane, which is the leg that needs the
fixpoint rather than the write path's seeding. The CHANGELOG now names the
4-level horizon beside the existing limitation sentence, and the constant's own
doc names the two pins.

CAN THE HORIZON BE RAISED? Measured, and the answer is "not on this evidence".
Same bench, same box, full repair / doctor count / 20-id batch / 200-id batch:

  depth 4   57 ms /  58 ms / 21 ms /  69 ms     (shipping)
  depth 6  126 ms / 118 ms / 52 ms / 101 ms     2.2x, TWICE reproduced
  depth 8   59 ms /  74 ms / 24 ms /  68 ms     ~= depth 4, TWICE reproduced

The curve is NON-MONOTONIC: 6 falls off a cliff and 8 comes back. That is a
dolt planner artifact, not a cost model, and raising a semantics-bearing
constant on the strength of a number nobody can explain is the wrong trade —
depth 8 also makes every past-horizon shape newly bright, which is a behavior
change and not this round's business. Left at 4, with the numbers recorded for
whoever picks the knob up.

D3 — THE LOCKSTEP. _IncrementalMatchesFullRepairAcrossEdits walks one graph
through the mutations that reclassify a blocking reason WITHOUT touching the
row that carries it, and after every one asserts both the exact flags and
assertConvergedAndStable: detection counts 0 AND a full repair changes 0 rows.
An under-seeded incremental path (the AffectedByDepChange{,ForWisp}InTx
ancestor walk round 1 added) fails here as a nonzero repair over a graph the
write path just finished maintaining. The mutations: re-parent the reason's
target INTO the blocker's subtree (which is how the shape arrives — the store
refuses a blocks edge straight onto an existing own descendant, and that
refusal's reason text is what 3a5203979 corrected), close the descendant,
reopen it, re-parent it back OUT, remove the blocks edge. The
into/out-of-subtree steps are the ones that flip rows the edge does not name
(the parent's other children), which is exactly what
appendSiblingsUnderAncestorsInTx exists to seed. RED on origin/main for the
semantic values; origin/main's own incremental/full-repair agreement holds
there, so what this pins is the agreement, not the numbers.

GATE: BEADS_TEST_EMBEDDED_DOLT=1 go test ./internal/storage/dolt/ -run
'ParentChildCascade' -count=1 — 8/8 ok; gofmt -l clean; go vet clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(doctor): the close-gate inventory walks the same four parent-child levels as the cascade (wy-3eb07b, #6506)

The "Parent Close Gates" check listed only DIRECT parent->child gates, so the
fix's own headline shape (a parent that blocks on its grandchild) never
appeared in the inventory. The check now joins a descendant-pairs set built
to the same four parent-child levels the cascade uses for "inside my own
subtree" (issueops subtreeWalkDepth), as plain joins over the dependency
union rather than a correlated subquery, which dolt declined to plan once
rows were present. Messages say "own-descendant"; the tests add a grandchild
gate (2 listed, the exogenous edge still not) and assert Category.

CHANGELOG cites the nested-gap follow-up, gastownhall/beads#6601.

Tests run: go build ./... 0; go vet ./cmd/bd/doctor/ 0; gofmt -l clean;
env -u BEADS_ACTOR go test ./cmd/bd/doctor/ -run 'ParentBlocksOwnChild|TruncateDetail' -count=1 PASS (3/3).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: allowlist TestBlockedStateScaleTiming's -short skip (wy-3eb07b, #6506)

scripts/check-testing-short.sh reserves testing.Short() for runtime, stress
and large-fixture skips and keys them by file::func. The scale-timing test
added in this PR builds a 1000-issue / ~2000-edge dolt fixture and times the
blocked-state paths over it: a large-fixture skip, and PR Core runs with
-short, so it needs the entry. One line, the same shape as the
TestUOW_ConcurrentMergeOps_NoLostUpdate row from #4732.

Local: ./scripts/ci/pr-policy.sh rc 0 (check testing.Short boundaries
succeeded; the other nine legs unchanged).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* wy-3eb07b: build(bazel): register blocked_scale_bench_test.go in internal/storage/dolt

The rebase carried the bench test but not its BUILD.bazel entry, so the
Bazel test lane's gazelle sync and Go test equivalence steps failed while
every Go lane was green. This is CI's own bazel-sync patch for 043f9c47b9,
applied unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(blocked): resolve explained parents through their ancestry; walk ancestors on hinted per-table members

Maintainer fixup for #6602 (adopt-pr review iteration 1, quality scorecard
760/1000, request_changes; amended at iteration 2, 906/1000, approve). It
fixes the review's two major findings, the doctor check's message and its
swallowed query failure, the stale core-builder doc, and the stale
test-comment names. At iteration 2 it also takes both nits and corrects a
CHANGELOG sentence this fixup had made false.

- Mixed-arm leak (major). The explained-parent read decides from a
  parent's own reason rows, and the fixpoint carries the recursive clause
  only for a parent with no reason row of its own. With Q blocked on an
  outside X, P a child of Q, and P blocking on its own child C, P read as
  explained and C came bright under an epic still gated by X, on the
  write path and in full repair alike. pruneExplainedByAncestryInTx now
  shrinks every read to the greatest set whose members' blocked parents
  are all members. A full-repair read is complete, so a blocked parent it
  did not return is unexplained. A batch-scoped read climbs instead,
  reading the blocked parents above the batch by id (explainedAmongInTx).
  The suggested one-level NOT EXISTS is not enough: put a second close
  gate between them (R blocked on X, pc Q -> R, Q blocks on P, pc P -> Q,
  P blocks on C) and P's blocked parent Q is in the set, so R's gate
  never reaches C.
- ancestorChainInTx (major) walked the derived UNION of both dependency
  tables that #7224 removed from isAncestorInTx, on every parent-child
  write and merge replay. It now walks reachabilityMembers, the hinted
  per-table recursive members split out of reachabilityQuery, with the
  reason filter kept in the outer SELECT. TestGraphWalkPlansHonorJoinHints
  (embedded) gains an ancestor-chain subtest that pins the lookup plan;
  the old walk fails it.
- New dolt tests: TestParentChildCascade_OwnGateUnderExogenousParent
  (write path, full repair, and X closed and reopened),
  _NestedGatesBothWays (the two-gate chain both ways, then a close of the
  children's own blocker, which re-evaluates them through a batch whose
  read covers nothing above their parents), and
  _WispGateUnderExogenousParent (a wisp gate under an issue epic, an
  issue gate under a wisp epic, then an explained wisp gate the walk must
  read by id above such a batch). Five mutants of the prune were each
  killed: no prune (the PR head), a one-level check, an over-prune, a
  scoped read treated as complete, and a scoped read that trusts every
  parent above it. The eight existing cascade tests pass under all five.
  Iteration 2 killed two more, each by its own section of the wisp test
  alone: dropping the lookup of a wisp parent from blockedParentEdgesInTx,
  and dropping explainedAmongInTx's wisp leg, which had survived all
  eleven cascade tests.
- The doctor check no longer says the children "stay in bd ready", and
  a failed or timed-out inventory query is now a warning carrying the
  error, as in validation.go's other checks, instead of an OK that reads
  as "no gates". TestCheckParentBlocksOwnChildDB_QueryFailureWarns pins
  it with a closed handle, and it fails with the old status. A warning
  does not touch doctor's overall result, and it can be suppressed.
- The core builder's doc no longer describes the spliced design, and
  three test comments name builders that exist.
- explainedAmongInTx says why it does not tolerate a missing table, as
  the file's wisp reads do: the prune runs only on a non-empty read,
  which came from the same core query over all four tables.
- The CHANGELOG entry no longer calls #6601's shape (a sub-epic gated on
  its own children under an exogenously blocked epic) a known limitation
  that keeps the children visible. The prune darkens them, as
  TestParentChildCascade_OwnGateUnderExogenousParent pins.

Left as-is, all non-gating: the refusal hint's "(bd gate)", an API string
pinned by the golden corpus; a parent-child add/remove timing in the
scale bench, whose 1000 issues cannot show the 50k shape (the plan pin
guards it); and hints for the explained-parent subtree walk and the
doctor query. The measured complexity major is runDiagnostics (50/66),
the same at base; the PR adds two lines to 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>

* test(storage): re-pin the classic batch-apply statement count for the parent-child cascade

The B0 statement-count pins predate this PR's parent-child cascade. The
first full run of the storage tiers on the adopted head measured the
40 (classic) shape at 835 statements on both backends, against the
pinned 786 +/- 2.

All 49 extra statements are reads, seven for each of the shape's seven
distinct parent-child dep adds (its eighth repeats a pair and is a
no-op):
- appendSiblingsUnderAncestorsInTx reseeds the parent's other children:
  one ancestorChainInTx walk and four child probes, +5.
- The batched mark/unmark reads its exogeneity set first
  (batchExogeneity): the parent-kind probe and the issue-parent read, +2.

Measured by logging every statement of the classic apply on the CI base
233d151b37 (786) and on b2b93515bf (835), then diffing the two logs by
statement shape. Those seven shapes are the whole difference, each
exactly +7, and no write changed. The 356 and 712 shapes are unchanged
on both backends.

This is the deliberate re-measure and re-pin the pins' doc comment asks
for. The per-change breakdown is in pinnedEmbeddedStatementCounts.

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 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-08 08:31:34 +00:00
Steve Yegge
70f9e2f8a3
Beads 1.2 remediation: migration-consent gate — bd never migrates an existing database without explicit consent (#5764)
* feat(schema): never migrate an existing database without explicit consent (bd-qhn8y)

Beads 1.2 release remediation. 1.2.0/1.2.1 auto-applied migrations 54-65 at
store open on ANY command, including reads; older binaries then refuse the
migrated database. MigrateUp now refuses pending main-sequence migrations on
an existing database before any write (dolt_ignore seeding included) unless
the operator consented: bd migrate / bd migrate schema (preview flags
withhold), bd migrate --force, or BD_ALLOW_MIGRATE=1
(BD_ALLOW_REMOTE_MIGRATE honored as an alias). Fresh init and at-latest
databases are unaffected; the #4259 remote gate keeps all its protections.

Also: freeze shipped migrations (hash-pin test, main 0001-0065 + ignored
0001-0024), retract v1.2.0/v1.2.1 in go.mod, agent-executable un-migrate
runbook (docs/recovery/unmigrate-schema-v65.md), and the upgrade smoke +
historical migration harnesses now model the consent contract and assert
the refusal carries guidance.

No version bump here by design: cutting the release stays with the release
owner.

Rebased onto main 800d43eb8d: the go.mod retract hunk is dropped -
main already retracts v1.2.0/v1.2.1 (and v1.1.1) since #5782. The
uow consent grant moves into the TestMain main added in #6441 (a
second TestMain no longer compiles), and the new files are listed
in the BUILD.bazel targets main now carries (gazelle).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(schema): cloned-workspace bootstrap carries creation-consent (bd-qhn8y)

The consent gate treated a workspace `bd init --remote` / `bd bootstrap`
just cloned into existence like a pre-existing database, refusing the
smart gate's provably-safe first-mover migration and stranding init in
the generic open-error path (bypassing the bd-4mpy7 finalize+guidance
ergonomics). Cloning IS creating: those paths now record consent
explicitly, and the #4259 remote-migrate gate still applies to them
unchanged (consent is not its designated-migrator override). Fixes CI
TestEmbeddedInit/remote_behind_schema_gate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(migration): consent first in main's wisp lanes too (bd-qhn8y)

The rebase onto 800d43eb8d brought in #6049's wisp-plane lanes, which
postdate this PR's harness changes. Each one makes an ordinary candidate
command the first touch on an old-schema database, and the consent gate
refuses it:

- historical-dolt-upgrade-test.sh run_wisp_plane_upgrade opens with
  `bd list` before any migrate: "candidate could not open the seeded
  wisp workspace" for v1.0.1, v1.1.0, v1.1.2 and v1.2.2 (the
  Migration Test Harness dolt-runtime shard).
- run_dirty_tracked_wisp_scenario (v1.1.2): the consent refusal stops
  the open before MigrateUp reaches the #5816 dirty tables, so the lane
  fails "without naming them".
- upgrade-smoke-test.sh "Wisp plane survives upgrade" upgrades with a
  bare cand_init, so list/ready/blocked/update all hit the refusal
  (4 failures each for v1.3.0 and v1.3.1, both in the PR smoke set).

Use the PR's own pattern: the explicit `bd migrate schema` is the first
candidate touch (cand_upgrade in the smoke script). Base 800d43eb8d
passes these lanes unchanged; with this fixup the full 14-version
historical corpus and all five PR smoke versions pass.

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>

* fix(schema): close consent-gate review findings (bd-qhn8y)

Review fixes for the migration-consent gate (adopt-pr review, attempts
1 and 2).

Majors:

- #4566 deadlock rebuilt one check earlier: on a database that is both
  behind and dirty, the consent refusal fired before the dirty-table
  guard, whose remedy (`bd dolt commit`) opens without consent. The
  working-set-reconcile opens now tolerate MigrateConsentError: embedded
  (toleratesConsentRefusal, WSR intent only) and server mode
  (LenientOpen's warnLenientOpenRefusal) print WorkingSetWarning and
  commit at the current schema; strict, read-only and RemoteSync opens
  still refuse. Covered by an embedded test (a refused open writes
  nothing: dolt_status, dolt_ignore and schema_migrations unchanged) and
  a server-mode integration subtest.
- Bare `bd migrate` consented: isMigrateConsentCommand now matches only
  the schema verb, so `bd migrate` (metadata reconcile, including
  --update-repo-id, --inspect and --dry-run) no longer consents to a
  one-way migration; `bd migrate schema` and --force do.
  TestLocalMigrateConsentScope pins the scope through the root pre-run.
  The dirty-table warnings name `bd migrate schema` accordingly.
- Runnable JSON hint: the JSON refusal follows the #4259 AgentDirective
  convention, a non-runnable hint plus a migrate_consent object
  (versions, pending, severity, human_decision_required, options) whose
  commands are retargeted with --global for the shared global database.
  The text refusal prints the same --global hint under `bd --global`.
- Freeze floor: the hash-pinned freeze now covers what v1.3.x shipped,
  main 0001-0066 and ignored 0001-0026; the CHANGELOG puts new
  migrations in 0070+ / 0028+.
- Fresh-bootstrap heal: MigrateUpWithLock with heal authority takes the
  consent-free migrate path, so a retried bd init whose first pass left
  a non-zero cursor converges; other lock callers keep the gate.

Minors: the uow team-server guards are repinned on `bd migrate schema`;
the un-migrate runbook is linked from the recovery index and
cross-linked with the 1.2.1 repair-forward doc; the CHANGELOG BREAKING
entry matches the shipped contract; harness comment grammar.

Docs: the user docs and README named bare `bd migrate` as the step that
applies schema migrations; they now say `bd migrate schema`, which also
exists in the pinned docs release (v1.2.2) and in v1.3.x. The
`bd migrate schema` help no longer claims migrations run automatically
on store open. The Go remedy that sends a remote-gate stop to bare
`bd migrate` for its migrate-or-adopt options is unchanged (pinned by
TestNoticeSharedMigrateRefusalPerDecision).

Upgrade smoke (attempt 2): the consent-gate assertion is graded only when
the old binary left a database. Releases before v1.0 have no
`init --non-interactive`, so prev_init creates nothing there and the
candidate's `bd list` fails with "no beads database found", which has no
consent guidance. Main's Bazel smoke lane (#7331) runs the newest 30
releases, 20 of them pre-1.0, under the required ci-gate; all 20 went red
on the merge. The 10 v1.x releases still take the refusal branch.

Shard manifest (pre-approval CI): the new embedded test
TestEmbeddedMigrateConsent_BehindAndDirtyWorkingSetReconcileRecovers is
listed in the Bazel 15-shard block of embedded-storage-test-shards.txt
(incremental --write; shard 15). Main's ci lane runs
TestStorageEmbeddedShardManifestGeneratorNotStale in //scripts:scripts_test,
which fails on any unlisted top-level embeddeddolt test.

Not addressed (optional): env-only consent docs for embedders, the
unparseable BD_ALLOW_REMOTE_MIGRATE alias hint, and the harness
`|| true` on `cand migrate schema`.

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: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-08 08:21:31 +00:00
Bee
75d9dabf83
docs(cursor): re-review docs/integrations/cursor.md against cmd/bd/setup/cursor.go (#7333)
The page still described the rules-file-only Cursor setup from before #4649
and the old --remove scope. Rewrite it against what bd installs today:

- project setup: .cursor/rules/beads.mdc, the shared .agents/skills/beads/
  skill, and .cursor/hooks.json with sessionStart/preCompact/postToolUse
  hooks running `bd cursor-hook <event>` (user entries left alone)
- `bd init` runs the project setup unless --skip-agents/--stealth or bare
- --global: ~/.cursor/hooks.json + ~/.agents/skills/beads/, no rules file
- hook lifecycle: sessionStart injects bd prime; preCompact arms a refresh
  marker; postToolUse re-injects once and clears it; markers live in the user
  cache dir keyed by conversation_id + workspace root
- --check scope per mode and the exit/hint on a missing piece
- --remove keeps user hooks, deletes hooks.json once only `version` remains,
  keeps the skill while the Codex integration still uses it
- a manual hooks.json fallback in the shape bd writes

README.md: `bd init` also installs the Cursor integration, not only
Claude Code and Codex (the default init route in cmd/bd/init.go).

Follow-up to #7268 (bd-gy483w, the README line from bd-erf5vx).

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 08:20:31 +00:00
Bee
b485a0975e
feat(gate): bd gate create --repo names the repository a gh:run/gh:pr gate is checked in (#7176)
* feat(gate): bd gate create --repo names the repository a gh:run/gh:pr gate is checked in

A gh:pr gate for a PR in another repository could only be pointed there
through the blocked issue's metadata.repo; with none, `bd gate check`
resolved the bare number against the current repository and escalated
"pull request not found" on every check, with nothing in the text saying
which repository it had looked in. Five gates armed that way on 2026-10-03
never released after their PRs merged.

- `--repo OWNER/REPO` (or HOST/OWNER/REPO) on `bd gate create`: an
  explicit value wins over the inherited one; it goes through the same
  validator as metadata.repo (now `validateGitHubRepo`, split out of
  `githubRepoFromIssue`); it is refused on human/timer/bead gates, where
  nothing would read it. Both create routes call one helper,
  `gateMetadataForCreate`, so the flag cannot drift between them.
- The gh:pr not-found escalation reason names the repository the number
  was resolved against ("pull request not found: #42 in owner/repo" or
  "... in the current repository").
- Help text, docs/workflows/gates.md and the plugin's ASYNC_GATES.md say
  when the flag is needed. docs/cli-reference is pinned to the release
  and regenerates on its own.

Tests: TestGateMetadataForCreateExplicitRepo, TestCheckGHPRNotFoundNamesTheRepository
(unit); TestEmbeddedGateCreate/create_gate_with_repo + /repo_flag_on_human_gate_is_refused
(embedded); TestProxiedServerGateCreateInheritsRepoMetadata/explicit_repo_flag_wins_over_inherited
(proxied).

Refs ghosttrack/wyvern wy-2jh4v5.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(gate): keep the create --repo workspace bypass off bd gate create

The root pre-run bypass for `bd create --repo` (GH#3686) matched the leaf
name "create", so `bd gate create --repo` outside a workspace took it: an
OWNER/REPO slug opened a stray ./OWNER/REPO/.beads workspace under the cwd
and failed with "issue not found", and an https:// URL skipped store wiring
and panicked on the nil store. Key the bypass on the command path, as
proxy_capability.go already does; gate create now fails with "no beads
database found" outside a workspace like every other command, and top-level
create --repo (local path and remote URL) still takes the bypass.

Also name the repository in the gh:run not-found escalation, as the gh:pr
one already does. Only stderr with a lowercase "not found" reaches that
arm: real gh reports a missing run as "HTTP 404: Not Found (<api url>)",
which takes the existing error path, and that URL already names the
repository. The match stays case-sensitive because a token without access
to the repository gets the same 404.

Tests: TestEmbeddedCreateRepoFromNonBeadsCwd/gate_create_repo_flag_is_not_a_workspace
(slug and URL forms, built binary run from an empty cwd) and the
cross_repo/current_repo subtests of TestCheckGHRunNotFoundNamesTheRepository
fail with the fixes reverted. Its real_gh_404_names_the_repository subtest
feeds gh's real 404 stderr and fails if the match is widened.

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: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-10-08 08:02:46 +00:00
Bee
3571331b50
test: fixtures commit with maintenance.auto=false before every git worktree add (wy-7ocweu) (#7358)
Fixes #7349. The same race #7314 closed in internal/beads and
internal/config, in the fixtures it did not cover: a fixture's plain
`git commit` spawns the detached `git maintenance run --auto` child, whose
worktree-prune races the fixture's next `git worktree add` and deletes
.git/worktrees/<name>/locked under it (seen on PR #7312 run 37585997441,
cmd/bd Dolt-server tier shard 4/16, TestBootstrap_WorktreeFallbackDir).

One noAutoMaintenance + gitCommand(args...) helper per test package, each
in an existing untagged shared test file (cmd/bd/helpers_test.go,
doctor/git_test_helpers_test.go, doctor/fix/common_test.go,
formula/parser_test.go, git/gitdir_test.go, storage/domain/git/git_test.go;
cmd/bd/test_helpers_test.go is //go:build cgo so unusable for the pure
lane), and every inline exec.Command("git", ...) in those six packages
swapped for it. The flags ride the command line, never env config: the
routing-key scrub drops env config. No new files, so no BUILD.bazel rows.

Proof: GIT_TRACE on `go test ./cmd/bd -run TestBootstrap_WorktreeFallbackDir`
counts 3 `maintenance run --auto` spawns at d8d8bf587b and 0 with this
change.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 08:01:46 +00:00
Bee
2e6289f9fb
fix(hooks): key the push-time suite on the remote ref, never on the local ref's shape (#7352)
Since #7348 the pre-push hook ran scripts/pre-push-suite.sh only for stdin
lines whose local ref matched refs/heads/*. For `git push origin HEAD` and
`HEAD:refs/heads/x` git passes the literal local ref HEAD, so the suite never
ran for those pushes: a Go change pushed that way landed with an empty bazel
log, while the same change pushed as `git push origin br1` was refused.

The hook now skips a line when the remote ref is refs/tags/* or the local sha
is the zero sha (a deletion); everything else is a branch push, HEAD included.

TestPrePushHookSuiteKeysOnRemoteRef feeds the real hook HEAD-sourced ref lines
from a scratch repository with a stub suite that records whether it ran: both
HEAD forms run it on a Go change; a docs-only push, a tag pushed by HEAD or by
name, and a deletion do not. On main's hook the two HEAD cases fail.

TestPrePushHookRunsSuiteOnlyForGoChanges indexed "pre-push-suite.sh", which
the hook's header comment on line 3 also contains, so the ordering assertion
held wherever the call block sat. It now indexes the call line; moving the
suite block after the managed beads section fails it.

Fixes #7351

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 07:49:57 +00:00
Bee
569ad6001c
test(scripts): the retired-lanes BUILD walk follows file symlinks, as a local runfiles tree needs (#7361)
TestBazelRetiredLanesCannotBeNarrowed skipped every ModeSymlink entry in
its two BUILD/.bzl walks. Under `bazel test` on a local executor (the
processwrapper-sandbox an unauthorized fork's PR gets for
//scripts:scripts_test, RBE_INSTANCE being empty) the runfiles tree is a
symlink forest, so the walk read no BUILD file and the pin failed with
`got map[]` on every such run (#7350). Both walks now go through
walkBazelFiles, which decides "file" with the package's isFileOrFileLink:
a regular file or a symlink to one; a symlinked directory is never
followed, a dangling link is skipped. TestBazelFileWalkFollowsFileSymlinks
mirrors the checkout's Bazel files as a symlink forest (plus a directory
link and a dangling link) and requires the same file set as the checkout.

Fixes #7350.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 07:47:37 +00:00
Bee
9b251db072
test(proxied): split TestProxiedServerClose into three parents with legacy rollback pins (#7173)
* test(proxied): split TestProxiedServerClose into Close + Close3 so legacy shard 5 clears the 15m timeout (#7151)

Shard 5 of the legacy 15-shard proxied-server block walled at 927-941s
(go test's 15m timeout) on every measured fork-PR and main run while the
other 14 shards took 337-765s. #7172 pinned the two hash-placed tests
that pushed it over; the parent that dominates the shard remains:
TestProxiedServerClose carries 23 parallel bd-init subtests at 100-130s
apiece under 4-way contention, ~2060 of the shard's ~2712 slot-seconds.

Split it the way TestProxiedServerClose2 was split before: subtests from
close_blocked_refuses_without_force onward (12 of 23) become
TestProxiedServerClose3 with the same header; no subtest body changes.

Manifest: an explicit `15 6 TestProxiedServerClose3` line in the frozen
block (shard 6 is the lightest shard by CI job time that took no #7172
pin; without the line cksum fallback could hash it back onto 5), and
`30 17 TestProxiedServerClose3` beside Close in the Bazel 30-shard block,
which keeps every 30-shard load where it was (heaviest still 372.2s
est.). proxied_test_durations.json apportions the single 174.6s Close
capture by bd-init count (83.5 / 91.1) and says so in its header; the
next sweep replaces both.

Verified: gen_proxied_shard_manifest.py 30 --weights=duration --check
(exit 0); go test ./scripts/ -run 'Shard|Manifest|Coverage'; go vet
./cmd/bd/; BEADS_TEST_PROXIED_SERVER=1 BEADS_TEST_REQUIRE_DOLT_CONTAINER=1
go test ./cmd/bd/ -run '^TestProxiedServerClose3?$' -v: both PASS
(32.24s / 30.53s, 23 subtests).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci(proxied): pin TestProxiedServerClose3 onto legacy shard 1, not 6 (#7151)

Shard 6 timed out at 15m on this PR's own run (job 111387202139) with
Close3 added: Close3 passed in 5s but TestProxiedServerClose2's
subtests, sharing the 4 parallel slots and the one proxied server with
Close3's 12 bd-init subtests, were still running at 1m18s-2m31s each
when the alarm fired. On main at b1a0690249 shard 6 runs 9m and shard 1
6m, the lightest of the 15 (15: 8m), so shard 1 has the headroom for
the ~6 min of 4-slot wall the 12 subtests cost.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(proxied): split TestProxiedServerClose3 again into Close3 + Close4 (#7151)

Shard 1 timed out at 15m on this PR's own run (job 111392255572) with
Close3 pinned there: Close3's 12 bd-init subtests finished at 3m33s, but
they held the 4 parallel slots long enough that TestProxiedServerDep2's
subtests only began at 5m35s and were still running when the alarm
fired. Shard 6 did the same before it. Meanwhile shard 5, the shard this
PR exists to relieve, ran 5m with the first 11 subtests.

So 12 inits in one parent is too much for any host shard. Close3 keeps
its first six subtests on shard 1; the last six become
TestProxiedServerClose4, pinned to shard 7 (7m on that run). The
durations file apportions the one 174.6s capture 11/6/6.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci(proxied): move the Close3 and Close4 pins off legacy shards 1 and 7 onto 13 and 2 (#7151)

The run at 765248af5 put every Proxied Dolt Cmd shard green, with shard 5
down from the 15m alarm to 5m50s. But shard 1, chosen for Close3 as "the
lightest of the 15 on main", ran 14m48s there, the heaviest of the
fifteen: TestProxiedServerDep2's 29 parallel bd-init subtests alone take
about 10.5 minutes of 4-slot wall on this lane, and Close3's six init
subtests landed on top of them. Shard 7, where Close4 went, ran 13m50s
behind TestProxiedServerReady and TestProxiedServerState.

Pin Close3 onto shard 13 (6m51s on that run) and Close4 onto shard 2
(7m57s). Not shard 5: it is light only because Close left it, and
putting Close3 back would recreate most of the set that timed out. The
30-shard Bazel block is unchanged.

Verified: BEADS_TEST_SHARD_LIST_ONLY=1 .github/scripts/proxied-test-shard.sh
13 15 lists Close3 and 2 15 lists Close4, neither on 1 or 7;
gen_proxied_shard_manifest.py 30 --weights=duration --check exit 0;
go test ./scripts/ -run 'Shard|Manifest|Coverage' ok.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 06:53:13 +00:00
Bee
8bb99b49d8
fix(close): verify bead gates on the proxied-server route (#5861 item 1) (#6962)
* fix(close): verify bead gates on the proxied-server route (wy-j48b3y)

The close pre-check built its bead-gate lookup on the local store, which
the proxied-server route never opens (the root pre-run short-circuits to
uowProvider). So `bd close <gate>` on a bead gate refused with
"no local store available" there even after the awaited bead had closed,
while `bd gate check` resolved the same gate through its fresh-read
getter. Item 1 of #5861.

The pre-check now picks the getter by route: proxied-server reads through
the same proxiedFreshReadGetter gate check uses (local read, then prefix
routes); direct and embedded keep the store-backed routed getter.

Tests: a proxied integration test covers the open-target refusal (which
now names the target's status), the closed-target close, and --force;
against the old code it fails with the exact upstream refusal. A unit
test pins the route selection. Docs and CHANGELOG drop the limitation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci(shards): list TestProxiedServerCloseBeadGate in the proxied 30-shard manifest

#7129 turned the Bazel 30-shard block of
.github/scripts/proxied-cmd-test-shards.txt into an exact-once coverage
gate (TestProxiedShardManifestGeneratorNotStale in scripts/). This PR's
merge-base predates that gate, so after the rebase onto current main the
gate fails with "missing (1): TestProxiedServerCloseBeadGate", the
proxied integration test this PR adds.

Generated with the gate's own fix command,
`python3 scripts/ci/gen_proxied_shard_manifest.py 30 --weights=duration --write`.
The write is incremental: it puts the one name on the lightest shard (2)
and moves no existing assignment. The frozen 15-shard block is untouched.

Agent-Signature: claude-code-unknown-model-max on behalf of Eddie the Engineer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-08 06:01:18 +00:00
Julian Knutsen
785f10724a
ci: bigger runners for the slowest cached-run jobs (MCP gate 8 vCPU -n16, Bazel test 4 vCPU) (#7381)
* ci: bigger runners for the slowest CI legs (MCP gate, Bazel test, Windows preflight)

Runner-size A/B against merge group 37721729916 (3m49s):

- package-mcp: 4 -> 8 vCPU with pytest -n 16 (BEADS_MCP_PYTEST_WORKERS,
  mode remote only; forks/ubuntu-latest keep package-mcp.sh's default 8).
  pytest was 70s, dominated by CPU-bound per-test `bd init` setup. Local,
  pinned with taskset: -n 8 on 4 CPUs 112s; -n 16 on 8 CPUs 60/57/58s,
  228 passed / 5 skipped in all three runs.
- bazel-test: 2 -> 4 vCPU. `bazel test //... --config=ci` spent ~63 of
  81s in client-side loading/analysis (critical path 7.65s, every action
  a remote cache hit).
- pr-preflight-platforms Windows leg: 4 -> 8 vCPU. main.yml's test-windows
  saver stays on 4 vCPU: the cache keys name runner.os/runner.arch, never
  the label, and actions/cache's version covers only paths + compression,
  so the entries are not size-specific; the other Windows consumers keep
  their exact label. TestWindowsPreflightLegReachesSaverAcrossSizes pins it.

Runner labels live in the shared constants in
scripts/ci_blacksmith_runner_test.go; TestBlacksmithBazelRunnerSizes checks
every bazel.yml lane's runs-on and the MCP worker count per rbe mode with
evalGHExpr. Revert any bump that does not save at least 15s.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(pr): keep the Windows preflight leg on 4 vCPU (A/B: 8 vCPU queued 63s)

#7381's PR run put pr-preflight-platforms' Windows leg on
blacksmith-8vcpu-windows-2025. The cache restore from main.yml's 4 vCPU
test-windows saver hit, but the job waited 63s for an 8 vCPU Windows runner
and finished at 144s against the 129s baseline on 4 vCPU, so the leg goes
back to blacksmith-4vcpu-windows-2025. With saver and consumer on one label
again, TestWindowsPreflightLegReachesSaverAcrossSizes and the separate
preflight runner map have nothing left to pin and are dropped; the result
is recorded next to platformsMatrixRunners, in pr.yml and in
CI_REQUIRED_CHECK_TOPOLOGY.md.

Agent-Signature: claude-code-claude-opus-5-5-medium 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-08 05:16:20 +00:00
Julian Knutsen
a8a0427f86
fix(dolt): skip the no-op DOLT_CHECKOUT on fresh connections (#7322)
Two fresh-connection paths ran CALL DOLT_CHECKOUT unconditionally:
beginTxOnConn (the fallback path for the ignored-tables tx) and
pinStoreBranch (used by the long-timeout versioned reads and the
blocked recompute). A fresh session is normally already on the requested
branch, so the checkout is a no-op. A least-privilege Dolt user may be
granted EXECUTE on dolt_add/dolt_commit alone, and it is denied even a
no-op checkout. For such a user:

  bd create --graph / bd mol wisp
    -> failed to checkout ignored tx branch main: Error 1105 (HY000):
       command denied to user ...
  bd history, bd recompute-blocked
    -> checkout active branch "main": ... command denied

Both sites now share checkoutBranchIfNeeded, which reads active_branch()
and checks out only when the session is on a different branch, matching
what beginBorrowedTx already does. A real switch still happens when one
is needed. pinStoreBranch now documents that conn must be a single
session.

Tests: mock-driver tests cover the skip, a real switch, and a failed
branch read. Two real-server tests run as a least-privilege user (SELECT
on the database, DML on the data tables, EXECUTE on dolt_add/dolt_commit
only, pool pinned to one connection). They cover a wisp write through the
fallback, RecomputeAllBlocked and History; each fails with the denial
before the fix.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 03:47:50 +00:00
Julian Knutsen
143c418148
ci(bazel): cut per-lane fixed cost — LLVM .tar.zst slice, release cross-compile lane, no protoc build (#7379)
* ci(bazel): fetch the LLVM toolchain as a 149 MB slice; re-key the runner cache

Port of gascity #7279. @llvm_dist_linux_x86_64 downloaded the 1.94 GB
LLVM-22.1.8-Linux-X64.tar.xz and ran a single-threaded `tar -xJf` over
11 GiB to keep a 688 MB slice. That took 94-147 s in every Bazel lane,
and every cgo, race and stdlib action waits on it.

- llvm_dist.bzl gains `sliced`: download_and_extract of a members-only
  .tar.zst, plus a missing-member check. The xz path stays.
- MODULE.bazel pins the toolchain-llvm-22.1.8-slice-1 asset by sha256
  (de614777...6bec5). The URL is gascity's release asset for now; the
  list form leaves room for a beads mirror of the same bytes.
- tools/cc_toolchain/repack_llvm.sh and llvm_members.txt rebuild the slice
  from the pinned upstream release.
- Runner cache v4, keyed on MODULE.bazel too. MODULE.bazel.lock does not
  record llvm_dist, so the v3 key never changed and kept restoring the
  2.9 GB entry that holds the xz archive.
- bazel_hermetic_cc_test: a sliced llvm_dist may only download from a
  gastownhall/beads or gastownhall/gascity release, and its members must
  equal llvm_members.txt.

Verified locally:
- Every file in the extracted slice (2009 entries: types, modes,
  symlink targets, sha256) is identical to the xz extraction.
- aquery action keys are identical, base vs head, at the same workspace
  path: 7565/7565 over deps(//cmd/bd:bd_for_tests) and 7146/7146 over
  the race deps(//internal/storage/embeddeddolt:embeddeddolt_test).
- Extraction time: 178 s (xz) vs 1.9 s (zstd).

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): run the release cross-compile as its own lane

After the LLVM slice, bazel-pure is the longest cached Bazel lane (about
170 s). Its "Cross-compile every release target" step takes 54-58 s of
that (78.9k configured targets, 25k cache-hit lookups) and shares no
analysis with the pure invocations, because release_cross is a split
transition.

The step moves, unchanged, into a new job, bazel-release-cross ("release
cross-compile"). The job uses bazel-pure's runner, `needs: rbe` and skip
rule, so it runs in every mode except skip. It reports job.status like
every lane: the workflow_call output is bazel-release-cross, and pr.yml's
CI Gate requires it as BAZEL_RELEASE_CROSS. bazel-gate.sh skips it only in
mode skip, as it does BAZEL_PURE. Merge groups use the same pr.yml gate.
Push and dispatch runs gate nothing. Existing gate ids are unchanged.

The policy test now pins the step to bazel-release-cross, requires the new
gate id, and rejects any other job that runs the script (no double runs).
The new job is listed as having no CI analytics step. It captured no BEP as
a bazel-pure step either, and the analytics steps are unchanged. Docs:
LINTING.md, TESTING.md, CI_REQUIRED_CHECK_TOPOLOGY.md.

Expected: bazel-pure about 110 s on cached runs; the new lane about 85 s,
in parallel. Cost: one more 2-vCPU Blacksmith runner per run.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* build(bazel): stop building protoc for protoc-gen-validate

github.com/envoyproxy/protoc-gen-validate ships validate/validate.pb.go,
but its own validate/BUILD makes the Go library a go_proto_library. So
every lane built protoc from source just to regenerate that file. The
module reaches the graph only through grpc xds and the cloud SDKs.

A gazelle_override now regenerates the module's BUILD files with
`gazelle:proto disable`. It sets build_file_generation = "on" and adds
`gazelle:build_file_name BUILD.bazel`, so gazelle writes BUILD.bazel
(which Bazel prefers) instead of keeping the upstream BUILD. The proto
directive alone changes nothing, because the upstream BUILD files win.
validate is now a plain go_library over validate.pb.go.

Measured locally with aquery:
- //... minus the manual release_cross target: base has 2096 CppCompile,
  612 CppArchive, 314 CppLink and 1 GoProtocGen action; head has 0.
- cquery somepath(//..., @protobuf//:protoc): base goes through
  grpc xds -> envoy core/v3 -> validate_go_proto -> protoc; head is
  empty.
- deps(//cmd/bd:bd_for_tests): 7565 actions become 3077. The race
  deps(//internal/storage/embeddeddolt:embeddeddolt_test): 7146 become
  2658.

MODULE.bazel.lock does not change. The v4 runner cache key includes
MODULE.bazel, so it still moves. Expect one cold compile of the Go
packages above validate on the first run after merge.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* build(bazel): bazel mod tidy formatting

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-08 03:13:34 +00:00
Julian Knutsen
233d151b37
ci(pr): cut the Windows PR preflight leg's fixed costs (slice W) (#7378)
PR preflight process (windows-latest) is a CI Gate input and, after the
Bazel fixed-cost work, the merge-group critical path (ends at +247..+303s).
Step timings from merge group 37710264475 and seven same-repo PR runs:
45-115s setup (setup-go, then module and build cache tar extraction),
33-71s "Exercise the real Bash process boundary", 27-58s ./cmd/bd test
compile+link, 5-9s each for three more go test relinks.

- scripts/pr_preflight_test.go: the ~29 pr-preflight.sh runs (about 1.5s
  each under Git Bash on Windows, 42.8s total in the merge group) now run
  as parallel subtests. Each run already had its own temp dir, call log
  and env; the one test that t.Setenv's stays serial. Linux: 4.8s -> 0.8s.
- pr.yml: the hook-timeout step and the bd build fallback step become one
  go test of ./cmd/bd, saving a package re-hash and test-binary relink
  (5-9s on Windows for a sub-second test). Policy tests and the allowlist
  and topology docs follow the step name.
- warm-non-race-cache.sh: on Windows also compile the three CGO_ENABLED=0
  credential-fixture test packages the Windows-only fixture step runs, so
  main.yml's test-windows seeder covers them.

No step, test or gate input is dropped; the job id, name, matrix and
runner are unchanged.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 02:42:27 +00:00
Steve Yegge
d0cc1b173f
test(protocol): pin claim refusals on the single --json batch report (wy-kxgf4) (#4756)
* fix(cli): emit claim failures as structured JSON under --json (wy-kxgf4)

Protocol v0 §E5 requires that with --json, errors are emitted as a JSON
object carrying at least "error" and schema_version: 1. bd honored that on
the not-found path but not on the claim paths: `bd update <id> --claim
--json` printed

    Error claiming t04...-qqr: issue already claimed by alice

as plain text on stderr, so an agent driving bd with --json got an
unparseable line for the single most common contended-write failure it has
to branch on. The §E4 message contract held (the class and the holder/state
are named); the §E5 structured contract did not.

Route both claim paths (the direct-store loop in update.go and the
SQL-server proxied path) through a new reportClaimFailure helper: under
--json it emits {error, schema_version:1} via jsonStderrError, otherwise the
plain-text wording is unchanged, byte for byte, since §E4 tests pin it. The
JSON object goes to stderr so a mixed batch's stdout stays the clean array
of the issues that did update; the stream split itself is proposal OQ-5 and
is not pinned.

Un-skips TestProtocol_ErrorClass_ClaimFailures_StructuredJSON, which was
written against the clause and skipped pending this fix; it now passes and
becomes the guardrail. Full cmd/bd/protocol package green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test(protocol): pin claim refusals on the single --json batch report (wy-kxgf4)

Adopt-PR review fixup for #4756, iteration 1. It takes option (a) from
the review synthesis, which is also maphew's CHANGES_REQUESTED fix: drop
the eager per-claim JSON object and pin §E4/§E5 on main's centralized
batch report instead.

Major 1 (claude+codex, maphew's blocker). Under --json, a refused claim
printed two JSON documents on stderr: the indented reportClaimFailure
object, then reportUpdateFailures' compact {error, failed,
schema_version} summary. A consumer reading the whole stream, or main's
documented "last stderr line", did not get one document. Main has
already moved on (wy-ghg0d). That summary reports every per-id refusal,
and the refused id's failed[] entry already names the class and the
holder or state:

    {"error":"1 of 1 issues failed to update","failed":[{"id":"…",
     "error":"updating issue: issue already claimed by alice"}],
     "schema_version":1}

So cmd/bd/errors.go, update.go and update_proxied_server.go go back to
base byte for byte. reportClaimFailure and its two call sites are gone,
and text output, stdout and exit codes are main's. That supersedes the
helper the contributor commit describes. The PR now changes only tests,
so its title and squash message should say so at finalize. This also
covers the commit-message nit.

Major 2 (the proxied claim arm was not gated on `claim`, so a proxied
--assignee fence refusal read "failed to claim") is moot: the object it
mislabelled no longer exists. Both routes report through the same
summary. The message-drift minor is moot too. So is the synthesis's
follow-up about the direct route's non-claim fence refusals under
--json: they already land in the same failed[] list. The remaining
"updating issue:" vs "claiming issue:" entry prefixes are pre-existing on
main.

TestProtocol_ErrorClass_ClaimFailures_StructuredJSON stays un-skipped
and is re-pinned. It now requires:
- exactly one top-level JSON error document (the new jsonErrorDocs steps
  over each decoded object, so failed[] entries are not counted);
- §E5's error and schema_version on that document;
- a failed[] entry for the refused id that names "already claimed" and
  "alice", or "not claimable" and "closed".

TestProxiedServerUpdate gains
claim_conflict_json_reports_holder_in_failed_entry, the proxied
guardrail the review found missing. Two test-gap asks are dropped
because they targeted the claim-only branch, which is gone: the
--assignee --json negative case, and --format json (which reaches the
same jsonOutput-keyed reporter).

Validation (local Dolt 2.2.0 server, scrubbed env):
- cmd/bd/protocol, whole package, with BEADS_PROTOCOL_REQUIRE_DOLT=1:
  109 pass, 1 pre-existing PTY skip.
- Mutant (this PR's original errors.go, update.go and
  update_proxied_server.go restored): the protocol test and the new
  proxied subtest both fail on "2 JSON error documents"; both pass at
  this head.
- TestProxiedServerUpdate (proxied-lane env): all subtests pass.
- TestParityUpdate* (including TestParityUpdateJSONFailureReport) and
  TestMultiIDUpdate*: pass.
- make ci-pr-lint: 0 issues (native, windows, darwin).

Follow-up, not in this PR: typed claim-conflict fields in failed[]
(issueops.ClaimConflictError's holder and status), so consumers need
not match on message text.

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: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-10-08 02:08:12 +00:00
Julian Knutsen
dff41b4bb8
fix(bazel): re-vendor signed-duration decode fix from gascity (#7374)
gascity commit 9865cc045aee1391dbcc7eac99339c26e3a5ce71 fixed a
production bug: negative protobuf durations in the compact exec log
were decoded as unsigned, so the collector rejected roughly 22% of
artifacts on remote_queue_ms. Re-vendor the extractor and its unit
test byte-identical from that commit and update the sha256 pins in
ci_analytics_extract_test.go accordingly. testdata/ci_analytics/ is
untouched by the fix; its tree-hash pin is re-verified unchanged
against gascity's tree.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-08 01:05:38 +00:00
Julian Knutsen
886ebb375a
ci(rbe): fail remote runs fast on a stale worker-env pin; nightly opens an issue (#7373)
rbe-west's pool workers run gascity main's tools/rbe/worker-env and
advertise its pin; the schedulers match //platforms:rbe_worker's pin
exactly. When gascity re-pins and beads' copy falls behind, every remote
action queues until the lanes time out, and the only check ran nightly
with no notification (review finding S1).

- bazel.yml's rbe job: after decide, only when the lanes execute remotely
  (enabled: modes remote, fork-ro, fork-rw; merge groups are remote), a
  sparse checkout of tools/rbe and platforms and tools/rbe/worker-env-sync
  main. Out of step fails the job, so every lane skips and pr.yml's gate is
  red within a minute, with the diff and the pin to commit in the summary.
  No fallback to mode cache: pr.yml's ci-gate requires a remote run
  (BAZEL_REMOTE), so it would be just as red, only slower. gascity
  unreachable warns and proceeds. The steps set no output; the job's
  outputs stay decide's.
- worker-env-sync: exit 1 only for out of step, exit 2 (warning) when it
  cannot compare (ERR trap; curl timeouts), WORKER_ENV_SYNC_REPORT copies
  the markdown report.
- nightly.yml: top-level permissions contents: read; rbe-worker-env-sync
  gets issues: write and, on exit 1, tools/rbe/worker-env-sync-issue opens
  a ci/infra issue with the report or updates the open one (body + comment
  linking the run). GITHUB_TOKEN is in that one step.
- Policy tests: TestBazelRBEWorkerEnvPreflight (shape + the step's script
  run in step / out of step / unreachable), TestNightlyWorkerEnvSyncOpensIssue
  (permissions, token scope, rc output, issue create/update via a stub gh),
  TestRBEWorkerEnvSync (exit codes, report); rbe job step and checkout
  counts updated.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 00:55:02 +00:00
Julian Knutsen
77ab980790
ci(bazel): run the hook-timeout-backends check under Bazel; test-nix stops running tests (#7357)
checks.nix's hook-timeout-backends (the tracked git hook shims against
real GNU/uutils/busybox/toybox timeout implementations, with and without
perl, under dash, bash and busybox ash: 240 cases) was the one test PR
Risk's test-nix ran on a GitHub runner, through `nix flake check`. It is
now //tests/hook_timeout_backends:hook_timeout_backends_test, an sh_test
(pr-core-only) that the bazel-test lane runs remotely on every PR: the
static uutils 0.12.0, busybox 1.35.0 and toybox 0.8.15 binaries come in
sha256-pinned through MODULE.bazel; dash, bash, perl and GNU coreutils
from the executor, failing (not skipping) when one is missing.

checks.nix goes and flake.nix declares no checks, so test-nix's
`nix run .#default` + `nix flake check` is a packaging check (build the
package Nix users install, evaluate every flake output), not a test.
TestHookTimeoutBackendsRunUnderBazel pins the target and that no flake
check comes back.

ga-96smfk.22

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 11:05:39 +00:00
Julian Knutsen
84390b03ab
ci(bazel): run every Windows/macOS job on Blacksmith; retire the Linux preflight leg and the cross-compiled Windows pair (#7355)
- pr.yml's Windows jobs and the macOS/Windows legs of pr-preflight-platforms
  and check-doc-freshness-platforms run on Blacksmith for every PR and merge
  group, forks and Dependabot included: no windows-latest/macos-latest
  fallback (Blacksmith serves this org's fork PRs). Matrix legs name their
  label (runs-on: ${{ matrix.runner }}); the same-repo "matrix marker"
  ternary and its policy plumbing are gone.
- pr-preflight-platforms drops its Linux leg: its tests run under Bazel on
  rbe-west (//scripts:scripts_test, //cmd/bd:bd_test,
  //internal/config:config_test).
- The Linux-cross-compiled Windows path is retired: windows-test-binaries,
  its two -prebuilt twins, main.yml's windows-test-binaries-cache, the
  WINDOWS_PREBUILT_REQUIRED flag and the build script/manifest. The native
  pair (test-windows-liveness, worktree-remove-windows) is the required run.
- main.yml's test-windows and blacksmith-macos-go-build-cache drop their
  GitHub-hosted venue legs (no GitHub-hosted consumer left).

Gate names unchanged. ga-96smfk.22

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 10:41:14 +00:00
Julian Knutsen
9d13485b71
ci(bazel): retire main.yml's Linux jobs, nightly's go test jobs and ci-measurements (#7354)
Push to main and the nightly schedule no longer run go test or repo checks
on GitHub runners (ga-96smfk.22, ga-96smfk.58):

- main.yml keeps only the macOS -race -short suite, the Windows smoke build
  and the push-to-main savers of the GOCACHEs pr.yml's Windows/macOS jobs
  restore. Its Linux jobs (migration hygiene, build artifacts, build tags,
  versions, duplicate migrations, doc flags, package gates, PR policy
  wrapper, gofmt, the Linux and setup-go cache seeders, the Nix flake
  check) are gated on the merge queue's pr.yml/pr-risk.yml run of the
  same commit and re-run as Bazel targets by bazel.yml's push run.
- nightly.yml is the fresh bazel.yml call plus the worker-env check; its
  Full Test Suite, PR Core go-test-json side and measure dispatch are gone,
  as are ci-measurements.yml and bazel.yml's go-test-json-artifact input.
- The non-race embedded batch-apply step becomes
  //internal/storage/embeddeddolt:embeddeddolt_batch_apply_nonrace_test
  (go_test_race_off, BEADS_TEST_EMBEDDED_DOLT=1) in the embedded tier.
- make ci-pr-policy and scripts/ci/pr-policy.sh go: every check it ran is
  a Bazel test (TestPRPolicyChecksRunAsBazelTargets).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 10:06:59 +00:00
Julian Knutsen
b4831e7250
ci(bazel): go_test_offline runs on the fork tier, where actions are already offline (#7359)
bd_managed_local_test (#7326) fails on every fork PR's proxied lane:
the rbe-west fork tier forbids nested namespaces, so unshare exits with
ENOSPC, but that tier already runs every action loopback only. When
unshare is unavailable, run the binary directly after the same outbound
probe proves the network is absent; a host with network and no
namespaces still fails.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 10:04:40 +00:00
Julian Knutsen
4f924fc161
ci(bazel): retire PR Risk's legacy Dolt tiers, pr.yml's legacy Go jobs and the D2 coverage flags (#7353)
Every pull_request and merge group already took the Bazel lanes for the
retired tiers (BAZEL_RETIRES_LEGACY_* and BAZEL_COVERS_FORKS all "true",
and pr.yml/pr-risk.yml run on no other event), so the legacy jobs those
flags stood down could never run again. Remove them with their decision:

- pr-risk.yml: build-embedded, test-embedded-{storage,conformance,cmd},
  test-proxied-cmd, test-server-storage{,-full}, detect-ci-tier (and its
  ci-embedded-tier.sh / ci-capability-selector.sh scripts) and
  bazel-coverage. PR Risk keeps the Nix packaging check (test-nix) and its
  gate, PR Risk Gate / Required.
- pr.yml: build-artifacts, check-cmd-bd-puregeo-tests, pr-core-wrapper and
  bazel-coverage; the BAZEL_RETIRES_LEGACY_* and BAZEL_COVERS_FORKS flags.
  The three BAZEL_*_RETIRED gate ids become one, BAZEL_REMOTE: the Bazel
  call must have run remotely (remote, fork-ro or fork-rw) on every PR and
  merge group, each lane's own id still required. Gate names unchanged.

Policy tests: the D2 decision matrix becomes
TestPRGateRequiresRemoteBazelLanes (bazel.yml's actual rbe step and
pr.yml's actual gate over every event/variable/secret/fork/actor/mint
fact); the parity tests that read the legacy jobs now pin the Bazel lanes
against those jobs' frozen commands.

ga-96smfk.22

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 09:31:20 +00:00
Julian Knutsen
57e86a2f0d
ci(bazel): add CI analytics extraction to all lanes (S3) (#7356)
tools/bazel/ci_analytics_extract.py turns a lane's BEP file, compact
execution log and JSON profile into a redacted ci-analytics-summary
(timing, per-mnemonic cache classes, cold actions, test results,
repo-fetch time): only validated labels, mnemonics, enums and numbers
leave the runner, never an endpoint, cert/key path, env value, token
or hostname. Every lane's "CI analytics summary" step runs the
extractor and uploads its output as ci-analytics-<lane>-<run_attempt>
(7-day retention); CHECK_RUN_ID uses the real job.check_run_id
context (requires actionlint >= 1.7.8), and both the summary and
upload steps are continue-on-error, the summary capped at
timeout-minutes: 3, and both gated on !cancelled() (not always(),
which also runs after a workflow cancellation).

The extractor, its 62-case unittest file, and testdata/ci_analytics/
(the real/* Bazel 9.2.0 fixtures, poisoned-bep.json, mismatch.bep.jsonl
and regen.sh) are vendored byte-identical from gascity's
ci/analytics-extractor slice (final squashed commit
00161373bc7bbfcef8d6a05ac5ce70409fc7f2ac), which is canonical for this
pair the same way tools/rbe/cache-zstd-probe.sh is a byte copy.
Fixtures are regenerated under env -i with every BEP field stripped
unless it's on an explicit allowlist, and the compact exec log is
committed decompressed (*.binpb) rather than as a zstd frame, so
nothing opaque reaches version control.

scripts/ci_analytics_extract_test.go is the thin Go wrapper:
TestCIAnalyticsExtractorIsPinnedToGascity pins both vendored files'
sha256 so local drift is caught, and TestCIAnalyticsExtractUnitTests
runs gascity's unittest file in place. scripts/ci_analytics_workflow_test.go's
TestCIAnalyticsStepsAreSafeAndBounded mirrors gascity's pin test,
adapted to beads' 8 separately-named lane jobs: continue-on-error,
timeout-minutes bounds, no raw ${{ }} expression in run:, !cancelled()
required in if:, correct per-lane upload artifact name/path, and
CHECK_RUN_ID == ${{ job.check_run_id }}, for every lane.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-07 09:07:24 +00:00
Julian Knutsen
d8d8bf587b
feat(cli): bd create --graph via one atomic BatchApplier request; --if-revision on bd reopen (#7209)
* feat(cli): bd create --graph via BatchApplier (spawner_id, thread_id)

Reapplies S11's graph-batch-apply half onto origin/main's post-#7203
state: `bd create --graph` now builds its plan through
issueops.BatchApplier instead of the removed buildDomainGraphPlan path
(create_proxied_server.go shrinks accordingly), spawner_id is stamped
only when a node names a spawner (RunBatchApplyStampsSpawnerIDOnlyWhenNamed
conformance case), and thread_id survives translation into
issueops.DepAddItem alongside the rest of GraphApplyEdge/GraphApplyNodeDep.

Entirely independent of #7203's --if-revision work: no file in this
commit overlaps #7203's or #7205's changed files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(cli): extend #7203's --if-revision guard to bd reopen

#7203 (37acca96d) added --if-revision to update/close/assign/delete but
not reopen, even though issueops.ReopenRequest.ExpectedVersion already
existed upstream. Wire reopen.go and reopen_proxied_server.go through
the same parseIfRevisionFlag / requireSingleIfRevisionID /
reportIfRevisionFailure / ifRevisionFlagHelp helpers #7203 introduced,
so reopen gets identical one-id-only, exit-13-on-mismatch, gascity-
compatible-body behavior as the other four verbs, with no new helper
surface of its own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(cli): gc-matcher decode pin and proxied-server --if-revision coverage

#7203 never ran its mismatch body through gc's actual decode logic (only
through bd's own JSON assertions), and it only exercises --if-revision
through the embedded/direct route -- the proxied-server path
(*_proxied_server.go's uow-backed preflight/apply) had no coverage at
all on either side.

- if_revision_gc_matcher_test.go: a faithful port of gc's
  bdstore_conditional.go decode logic, run against a real built bd for
  all five guarded verbs (including reopen). Confirms against #7203's
  actual numeric-only body that no decimal-string twins are needed:
  encoding/json decodes a JSON number straight into an int64 struct
  field with no float64 intermediate, so there is no precision loss for
  gc's matcher to lose above 2^53 the way there would be decoding into
  an untyped interface{}.
- if_revision_proxied_integration_test.go: proxied-server-leg coverage
  for all five verbs (update/close/reopen/delete/assign), using a
  numeric-only proxiedPreconditionBody matching #7203's shape exactly
  (no _str fields, since the matcher test above shows none are needed).
  reopen's case is its only --if-revision coverage on the proxied route
  at all, since #7203 did not add the flag to reopen.

Both verified for real: TestGCConditionalMatcherDecode via
BEADS_TEST_EMBEDDED_DOLT=1, the five TestIfRevisionGuardProxied* tests
via BEADS_TEST_PROXIED_SERVER=1 BEADS_TEST_DOLT_SERVER=local against the
pinned dolt 2.2.0 binary (no Docker needed).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(changelog): document graph-batch-apply and if-revision-reopen deltas

Neither #7203 (--if-revision) nor #7205 (batch create/import perf)
touched CHANGELOG.md, so document this branch's two deltas on top of
them directly: bd create --graph via BatchApplier (spawner_id/thread_id,
field-survival test, real-store hierarchy/cycle scenarios), and
--if-revision's extension to bd reopen plus its gc-matcher decode pin
and new proxied-server coverage.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cli): adapt reopen's reportIfRevisionFailure call to #7216's signature

#7216 (merged to main, landed in this rebase) added a fourth ifRevision
*int64 parameter to reportIfRevisionFailure for reassign-fence
disambiguation. Pass bd reopen's own declared --if-revision value at both
call sites (direct and proxied-server paths) to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): auto-sync BUILD files

Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/37290168028
(`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(cli): evaluate reopen's --if-revision guard before the already-open short-circuit

bd reopen's direct route checked issue.Status == StatusOpen before ever
calling ops.Reopen, so a stale --if-revision guard against an
already-open issue silently returned the "already open" no-op (exit 0)
instead of the precondition_failed refusal (exit 13) every other guarded
verb gives for a stale token. ops.Reopen itself already evaluates
ExpectedVersion first (ExecuteReopen -> CheckVersionInTx) on both the
dolt and embeddeddolt backends, and the proxied-server route already
called through unconditionally -- only the direct route's pre-check
bypassed it.

Fix: skip the already-open pre-check when --if-revision is set, letting
ops.Reopen evaluate the revision guard first. Without --if-revision,
today's behavior for already-open issues is unchanged.

Tests:
- if_revision_reopen_embedded_test.go (new): direct route, all four
  combinations (already-open/closed x stale/matching revision). Verified
  live that already_open_mismatch_refuses fails against the pre-fix
  ordering and passes against the fix.
- if_revision_proxied_integration_test.go: added the same already-open
  coverage to TestIfRevisionGuardProxiedReopen to confirm the
  proxied-server route already behaved correctly and keeps doing so.

Also documents in CHANGELOG.md that a `bd create --graph` plan over
issueops.MaxApplyBatchItems (1000) is refused outright with
GraphApplyTooLargeError (non-blocking review item).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cli): put guard tests in CI lanes; fence unguarded reopen errors

Maintainer fixup for #7209, review loop iteration 1. It replays the prior
adoption's stranded fixup (f71ac4f66) on top of the contributor's own fix
for the direct-route reopen guard (266cacfca1). The contributor's fence
and tests are kept, and the fixup's overlapping reopen fence and
open-issue pins are dropped.

CI lanes: seven env-gated tests matched no lane's discovery pattern, so
no CI job ran them, including the reopen fix's own pin. The proxied tests
are now TestProxiedServerIfRevisionGuard{Update,Close,Reopen,Delete,
Assign}. The gc matcher test moves to
if_revision_gc_matcher_embedded_test.go as
TestEmbeddedGCConditionalMatcherDecode, and the direct reopen test is
TestEmbeddedIfRevisionReopenGuardDirect. BUILD.bazel and both shard
manifests are regenerated, and each renamed test is selected by exactly
one shard of every lane.

bd reopen:
- reportIfRevisionFailure now runs only when --if-revision is set, on
  both routes, as update, assign and delete already do. Since #7256 the
  classifier maps storage.ErrNotFound to precondition_failed, so an
  unguarded reopen that lost a race with a delete reported a guard
  refusal (exit 13) for a command that carried no guard.
- The gc matcher test gains a reopen_open row: a stale guard on an open
  issue gets the same refusal body. The matching-guard no-op subtest now
  also checks the "already open" line and that the revision did not move.

bd create --graph:
- A node naming both a plan-local parent and a parent_id is parented under
  the plan key again, as both legs did before the BatchApplier translation
  and as the dry-run preview and the local cycle check assume
  (TestBuildGraphApplyBatchRequestParentKeyWinsOverParentID).
- Removed dead code: graphApplyParentDepPairs, graphApplyDepPairKey and
  GraphApplyUnsupportedFieldError, with the helper-only test.
- A path from a node's parent to the node through a waits-for hop is now
  stored, as bd dep add and bd batch apply already store it, because the
  shared end gate walks the scheduling edges only. That shape can stall
  ready work once the spawner has an open child. The acceptance is
  documented in the CHANGELOG and the buildGraphApplyBatchRequest comment
  and pinned by TestExecuteGraphApplyAcceptsParentToChildPathThroughWaitsFor.
  Refusing the shape belongs in the shared role (types.IsSchedulingEdge),
  for every front door at once; that is a follow-up.
- The deleted fake-store rejection scenarios are ported to real-store
  tests: reverse parent-to-child blocking edges, a reverse parent-child
  edge cycle, and the end gate alone with SkipPerEdgeCycleCheck set.
- The graphApplyEdgeBatchMetadata comment names the real
  issueops.StampWaitsForSpawnerID.

CHANGELOG: the spawner stamp is described as a waits-for edge's
metadata.spawner_id, and the reopen entry says a guarded reopen of an
open issue is judged against the guard on both routes.

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>

* test(cli): name #7292 in the waits-for acceptance marker

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-07 07:53:35 +00:00
Julian Knutsen
368b225eef
docs(bazel): make bazel test the primary build and test path (ga-96smfk.23) (#7348)
Bazel is beads' build and test system: bazel.yml's lanes gate every PR,
and nogo (lint + vet), gofmt and the repository guards exist only as
Bazel targets. The docs, the Makefile and the hooks now say so.

Makefile: `make test` runs bazel.yml's test lane (`bazel test //...
--config=ci`), `make check` adds the testing.Short policy and the
`make ci-pr-lint` nogo gate, and `make check-docs` runs the docsync and
doc-freshness Bazel targets before the pinned-release CLI flag check.
BAZEL_FLAGS passes --config=fork-cache or --config=remote-exec through.
The plain-Go recipes stay as explicit twins: test-go, check-go,
check-docs-go. No workflow called the primary names, and
TestWorkflowsNameTheirTestEngine keeps it that way.

Hooks: pre-push runs scripts/pre-push-suite.sh for branch pushes whose
commits change Go or Bazel inputs: the test lane with
--config=remote-exec when some rc names an executor, else
--config=fork-cache. Without bazel, or with BD_PREPUSH_SUITE=go, it runs
make test-go under a banner saying that is not what CI gates on.

Docs: AGENTS.md, CONTRIBUTING.md, engdocs/TESTING.md (a per-lane command
table and the fork-cache/remote-exec setup), README, RELEASING, the PR
template and the .bazelrc header. Bazelisk is a required prerequisite;
go test is an inner-loop convenience CI does not enforce.

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>
2026-10-07 07:46:02 +00:00
Julian Knutsen
8d7d7fef16
build(rbe): adopt gascity's toolchain-only worker-env pin; check the copy nightly (#7346)
gascity now builds the worker-env manifest from the worker's toolchain,
not the image's patch revisions. The manifest records the arch, the OS
release, Go and dolt, and the upstream releases of the libraries and
tools actions reach (major.minor; git and yq at their major). The Debian
epochs and Ubuntu revisions are gone, so the Blacksmith image's routine
security updates no longer move the hash. That is what stranded every
remote action on 2026-10-07: coreutils 9.4-3ubuntu6.1 -> 6.2 and libc6
2.39-0ubuntu8.6 -> 8.8 forced re-pins (gascity #7266, beads #7338).

- tools/rbe/worker-env.txt: byte-identical copy of gascity's new
  manifest. platforms/BUILD.bazel pins its sha256,
  sha256:6be1381cf08e7fd66684cfce6f26aca57de2561e722c505d1f2f578e9fdeafa7.
  The manifest now also measures python3, curl, openssl, unzip and yq,
  which //scripts:scripts_test runs from the executor.
- scripts/rbe_worker_env_test.go: the manifest must be a rendering of
  gascity's tools/rbe/worker-env (sorted; one arch, dolt, go, os and yq
  line; packages at most major.minor, installed). A copy of an older
  gascity manifest with dpkg revisions, a hand edit or a truncated copy
  fails here.
- tools/rbe/worker-env-sync, run by nightly.yml: compares the manifest
  and the pin with gascity's main byte for byte. If they differ, it
  prints the diff and the pin to commit, and fails.

Merge this together with the gascity change. Pool workers run gascity
main's provisioning, so they serve the new hash only once that change
lands, and beads' actions on any other pin queue. This supersedes #7338
(the old-format re-pin). The new key misses the cache once.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 23:18:24 -07:00
Julian Knutsen
d652def9db
build(rbe): re-pin worker-env to the updated Blacksmith ubuntu-24.04 image (#7338)
Blacksmith's runner image picked up Ubuntu security updates around
2026-10-07 02:28Z (coreutils 9.4-3ubuntu6.2, git 2.55.0, libc6 2.39-0ubuntu8.8,
sed, tar, util-linux). Pool workers now measure
worker-env=sha256:b2c8be1f53ba4c2f1603b1d65f31e0d4c7ddd498110b9928eda37f193c7eb674
while actions requested sha256:f4d6d0460877…, and rbe-west's oss and oss-fork
schedulers match worker-env exactly, so no action could run (pools idle,
queues growing, every pool run failing the env check). Re-pin to the
measured manifest, copied verbatim from the pool worker's report; gascity
and beads carry byte-identical copies.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 22:58:06 -07:00
Julian Knutsen
a4509deb2d
ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18) (#7341)
* ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18)

Lint and vet now run as nogo inside the Bazel build, so they gate wherever
the Bazel lanes execute (rbe-west), and the golangci-lint and go vet jobs
leave pr.yml and main.yml.

- //tools/nogo (own go.mod, joined to beads' for go_deps only through
  gazelle.go.work): go test's vet checks (cmd/go's defaultVetFlags, the set
  scripts/ci/go-test-vet.sh ran) plus the eight linters .golangci.yml
  enables, each a wrapper over the library version golangci-lint v2.10.1
  uses (depguard, errcheck, forbidigo, gosec, misspell, sloglint, unconvert,
  unparam).
- .golangci.yml stays the single lint policy: Bazel embeds it and
  tools/nogo/internal/golangci applies it as golangci-lint does (enabled
  set, settings, run.tests: false as library-unit-only analysis, lax
  generated-file detection, path/path-except/text exclusion rules), with
  strict decoding so an unimplemented key fails the build.
- gascity's rules_go //nolint-range patch and x/tools ctrlflow patch,
  byte-identical.
- Windows/darwin: cross-configured, not a golangci leg. The pure lane's
  release cross-compile (//tools/bazel:release_cross, every library and
  binary for all eight release platforms, cgo off) runs nogo on every
  compile, a superset of golangci-lint's windows and darwin legs.
  scripts/pr-lint (make ci-pr-lint, bd preflight) runs `bazel build
  --config=nogo //...` plus release_cross for windows_amd64,darwin_arm64.
  release_cross skips tools/nogo, a separate Go module `go build ./...`
  never compiled.
- pr.yml: scripts-go-checks (vet) and pr-lint-wrapper (x3) are gone, with
  their ci-gate entries; main.yml: pr-lint-wrapper (x6) and go-vet-cache.
  scripts/ci/go-test-vet.sh and install-golangci-lint.sh are deleted.
- pre-commit hook and .pre-commit-config.yaml run `make lint-changed
  LINT_CHANGED_SCOPE=staged` (nogo over the staged packages); Makefile adds
  lint, vet and lint-changed. pr-lint.sh no longer runs gofmt
  (//scripts/repochecks:fmt_test owns it; ga-96smfk.41).
- internal/testutil/integration: five gosec findings in integration-tagged
  library files golangci-lint never built, now linted by the integration
  lanes, carry reasoned //nolint directives.

Parity: with the exclusion rules removed, golangci-lint and nogo report the
same 3,916 findings natively and 3,859 each for windows and darwin (file,
line, linter, text); with .golangci.yml as committed both report none.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): equivalence.py leaves nested Go modules' tests out of go test's set

tools/nogo is its own Go module, so `go test ./...` in the root never runs
its tests; Bazel's unit lane does. Its packages are neither expected nor
extra.

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-07 05:17:22 +00:00
Julian Knutsen
ce661175ff
ci(bazel): retire the docker A/B variants and pr.yml's container jobs (#7340)
The dolt-server lane (--config=doltserver) has been the only pre-merge run
of the Dolt-backed domain, uow, tracker, doctor/fix and protocol suites
since BAZEL_COVERS_FORKS went "true": bazel-coverage reports pr_lanes=true
for every pull_request and merge_group, so pr.yml's test-domain-uow and
contract-corpus never run. An A/B run of every requires-docker target
against its dolt-server twin on the same commit shows identical test sets
and statuses (2683 testcases) except TestDoltServerFingerprint/container,
the container half of the fingerprint, which needs docker by design.

Delete the six requires-docker sh_tests, test:docker in .bazelrc, the
requires-docker tag from the taxonomy and lane filters, bazel.yml's
dolt-lane dispatch input and image pull, and pr.yml's test-domain-uow and
contract-corpus jobs with their ci-gate wiring. The testcontainers backend
in internal/testutil stays: it is plain go test's default. pull-dolt-image.sh
stays for pr-risk.yml's legacy tiers. No required check changes: the
rulesets require only CI Gate / Required and PR Risk Gate / Required.

Refs ga-96smfk.21

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 04:13:24 +00:00
Julian Knutsen
3f1c6038f0
ci: warn-only shard-balance budget for bazel-server-storage (#7339)
rbe-ci-cost-latency-study.md recommendation 4: this tier's last shard
has trailed the rest by 4.3-4.5 min in 2 of 8 runs. tools/bazel/shard_budget.py
reads the job's BEP file and prints ::warning when a sharded target's
slowest shard exceeds max(150s, 2x median); --fail-on-imbalance (not
wired in yet) switches that to ::error and a nonzero exit once the
budget has run clean for a while.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-07 04:05:33 +00:00
Julian Knutsen
5e73670866
ci(bazel): cross-compile every release target with Bazel, retire the go build job (#7332)
pr.yml's check-release-target-cross-compilation ran `CGO_ENABLED=0
GOOS/GOARCH go build -tags gms_pure_go ./...` for the eight release targets
on two GitHub/Blacksmith runners. It is now a step of bazel.yml's pure-Go
lane (BAZEL_PURE, already required by ci-gate):
scripts/ci/bazel-release-cross-compile.sh builds //tools/bazel:release_cross
once, remotely, with --//tools/bazel:release_platforms set from
scripts/ci/release-targets.txt (still the single source of truth, pinned to
.goreleaser.yml). release_cross's split transition configures every
go_library/go_binary for each rules_go platform with cgo off, so all eight
platforms build in parallel in one invocation.

- tools/bazel/release_cross.bzl: the split-transition rule and the
  string-list flag.
- tools/bazel/go_srcs.py (make bazel-sync, checked by bazel-sync-check and
  TestBazelGoSrcsBlocksCurrent) keeps the release_cross target list; the
  script checks with bazel query that every Bazel package holding Go
  targets is reached before it builds.
- //tools/bazel:pure_bd_has_no_cgo_only_deps: Bazel compiles gozstd's pure
  stubs where `go build` rejects them, so the pure bd of every platform
  must not link gozstd.
- //internal/storage/embeddeddolt/cmd:cmd (cgo-only main, skipped by
  `go build ./...` under CGO_ENABLED=0) is tagged cgo-only and incompatible
  with pure builds.
- A failed build is re-run per platform (cache hits) to name each failing
  GOOS/GOARCH.

Same cgo-off coverage boundary as the retired job. Refs ga-96smfk.20.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 03:18:37 +00:00
Julian Knutsen
bb9b9e5020
ci(bazel): run the upgrade smoke tests under Bazel; retire cross-version-smoke.yml (#7331)
cross-version-smoke.yml resolved the newest 5 GitHub releases (30 on a tag
push) with `gh release list`, then built the candidate and downloaded each
release on a GitHub runner for scripts/upgrade-smoke-test.sh.

//tests/upgrade_smoke has one target per release in the newest 30 the
release catalog pins a linux/amd64 asset for (@bd_releases//:versions.bzl):
upgrade_smoke_<release>_test runs the script against the non-race
bd_for_tests with that release pinned as PREV_BIN (sha256-verified when
Bazel fetches it; the script checks it reports the release and downloads
nothing). A release added to the catalog joins the window. Tagged
pr-core-only, so bazel-test (not the integration lane) runs them remotely
on every PR, merge group and
push, cached until the candidate, the script or the release changes.

The tested set is now reviewed rather than resolved at run time: stable
releases from the catalog, where the workflow took GitHub releases
including prereleases. cross-version-smoke.yml and the F7c checks of its
chunk fold, path filter, runners and binary cache are removed (the
path-filter and binary-cache checks had no other workflow left).

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 02:49:39 +00:00
Julian Knutsen
7e0adfd353
ci(bazel): run the historical-upgrade corpus under Bazel; retire migration-test.yml (#7330)
* chore(migration-test): extend the release catalog through v1.3.1

The catalog stopped at v1.1.2 (the v1.2 upgrade census). The migration
corpus already upgrades from v1.2.2, and the Bazel targets that replace
migration-test.yml and cross-version-smoke.yml take their pinned release
binaries from the catalog (@bd_releases), so it has to cover the releases
since. Regenerated with `catalog generate` after raising maximumVersion to
v1.3.1: five new stable versions (v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.3.1;
three with a linux/amd64 asset) and five new proxy prereleases; no existing
entry, drift record or repository-only exclusion changed. The count
constants and the identity digest are updated to match, and the README now
says how to add a release.

Refs: ga-96smfk.19

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): run the historical-upgrade corpus under Bazel; retire migration-test.yml

migration-test.yml ran scripts/migration-test/run.sh --version <release> for
14 reviewed releases in 3 shards on GitHub runners: it downloaded each
release archive, built v0.9.1 from source with Go 1.25 through the module
proxy, installed libicu74 and the dolt 2.1.8 runtime, all over the network.

//tests/migration now has one target per corpus release
(historical_upgrade_<release>_test) plus legacy_bridge_test, all hermetic:
- Published releases come from @bd_releases (the release catalog's
  sha256-verified assets) through a per-target directory
  (HISTORICAL_RELEASE_DIR); lib/binary.sh uses it instead of downloading and
  still checks each binary's self-reported version.
- v0.9.1 is //tests/migration:bd_source_tag, the same `go mod download` +
  `go build -trimpath` with CGO and Go 1.25.0, run offline as a build
  action: the module files come from tests/migration/source_tag_modules.json
  through a file:// GOPROXY tree (tools/bazel/go_module_proxy.bzl), the
  release's own zip is the catalog's source_zip, and go checks every
  dependency against the release's go.sum (SOURCE_TAG_SQLITE_BIN).
- The external Dolt runtime is @dolt_test_runtime_linux_amd64 (dolt.bzl's
  dolt_release gains a version attribute; 2.1.8 is pinned to versions.sh's
  digest), passed as DOLT_BIN to the server-Dolt and wisp-plane releases.
- The workers already provide jq, python3, sqlite3 and libicu74.

The targets are untagged, so bazel-test runs them remotely on every PR,
merge group and push; result caching replaces the path filter. Every
release also passed inside a loopback-only network namespace.
scripts/migration_corpus_bazel_test.go keeps the BUILD lists equal to
versions.sh's corpus, the catalog digests equal to STRICT_RELEASE_SHA256,
the source-tag lock equal to the catalog's source_zip, and the Dolt runtime
pin equal to versions.sh's. migration-test.yml and the policy tests that
pinned its shards, caches, apt step and runner are removed.

Refs: ga-96smfk.19

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): run the historical-upgrade targets in the PR-core lane only

The integration lane runs every untagged target too, and its
check_testcases.py requires Go testcases, which a shell test's test.xml does
not list. A new pr-core-only tag keeps //tests/migration out of
--config=integration (bazelIntegrationExcludedTags adds it), so the corpus
runs once, in bazel-test, against the release-shaped bd_for_tests (no
integration tag). build_source_tag.sh carries the build-tags opt-out: it
builds a historical release with that release's own go.mod, which predates
gms_pure_go.

Refs: ga-96smfk.19

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-07 02:16:11 +00:00
Bee
f6d9245624
test(hooks): bound the long-running bd stub so a killed run cannot leak a spinner (wy-nzeocg) (#6612)
The real-GNU-timeout and real-Perl-alarm expiry subtests stand in a bd that
never returns with a bare `while :; do :; done`. On a normal run the helper
reaps it at 1s. When the go test process is killed mid-subtest, though, the
helper has already setpgid()d itself and the stub out of the harness's group,
the tree-kill reaches the helper by pid before its child, and the orphan is
reparented to 1 and spins at 100% CPU forever: one such stub was found 2.5h
old on a shared build box after a session teardown.

The stub now paces itself with sleep and exits 97 on its own after 60 ticks,
so a killed run leaks at most a minute of idle sleep. The generated hook runs
under a controlled PATH that carries only the fixtures and the helper under
test, so the test resolves sleep once (findHookProcessSleep, the same shape as
the Perl probe) and hands it to the stub as HOOK_TEST_SLEEP by absolute path.
The sleep's stdio is detached because Perl's alarm signals only the exec'd
stub, not a group, and the orphaned sleep must not hold the test's output pipe
open past exec.Cmd.WaitDelay.

Exit 97 is outside every status the hook normalizes, so a stub that outlives
the helper still fails the expiry assertions loudly.

Tests: go test ./cmd/bd -run TestGeneratedHookTimeoutProcessBoundary -count=1
(twice, darwin/arm64, bash 5 + coreutils gtimeout + perl); go vet ./cmd/bd.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-07 01:52:04 +00:00
Julian Knutsen
9a91f0629e
ci(bazel): run the differential regression suite under Bazel; retire regression.yml (#7324)
regression.yml ran `go test -tags=regression ./tests/regression/...` on a
GitHub runner: it built the candidate with `go build`, downloaded the v0.49.6
baseline release over the network, and pulled the dolt-sql-server image.
None of that works on rbe-west workers (no network for fork lanes, no docker).

- tools/bazel/bd_releases.bzl: a module extension that reads
  scripts/migration-test/release-catalog.json and declares one repository per
  catalog release with a linux_amd64 asset digest (bd_release_<version>,
  verified against the catalog's sha256), behind the @bd_releases hub
  (@bd_releases//:<version>, plus versions.bzl). Adding a release is a
  catalog change only; nothing downloads until a test declares one.
- //tests/regression:regression_test: the suite's files build under
  `regression || integration`, so gazelle generates the target. It runs the
  injected non-race bd_for_tests (BEADS_TEST_BD_BINARY) against
  @bd_releases//:v0.49.6 (BD_REGRESSION_BASELINE_BIN), both over a hermetic
  dolt sql-server (BEADS_TEST_DOLT_SERVER=local, required), in 8 shards.
  TestMain checks the baseline reports BASELINE_VERSION, so the label and the
  file cannot drift. Tagged dolt-server-cmd: bazel.yml's bazel-cmd-dolt lane,
  which pr.yml's gate requires, runs it remotely; test result caching stands
  in for the old path detector.
- A plain `go test -tags=integration ./...` (nightly) compiles the files but
  skips the suite; only -tags=regression (make test-regression) or Bazel
  runs it.
- regression.yml, main.yml's warm-up compile for it and the policy tests that
  pinned its jobs are removed.

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 01:41:12 +00:00
Julian Knutsen
b1fe68e63a
ci(bazel): run pr.yml's repository guards as Bazel tests (#7329)
fast-checks, PR Policy, and the Linux leg of check-doc-freshness-platforms
ran repository guards on GitHub runners. They now run as Bazel tests in
bazel.yml's `test` lane (remote, cached), each over only the files it reads:

- tools/bazel/repo_subset.bzl picks a narrow, path-selected slice of
  //:repo_files at analysis time. scripts/repochecks/run_check.sh copies that
  slice into a throwaway git checkout and runs the unchanged guard there.
- //scripts/repochecks: build_tags, workflow_tags, go_install_guidance,
  winget_portable_alias, migration_hygiene (checks A and B),
  fmt (registered SDK gofmt), doc_freshness, workapi_frontend_boundary,
  types_gen_drift (`make api-check` drift, oapi-codegen from go.mod).
- //scripts:doc_freshness_required_test (integration lane, -required-suite)
  and //scripts/gitattributespolicy:gitattributespolicy_required_host_test
  cover the Linux doc-freshness leg.
- check-versions stays covered by //internal/versioncheck:versioncheck_test.
  check-testing-short stays covered by //scripts:scripts_test.

pr-policy-wrapper is deleted. fast-checks keeps only the two checks that
need the PR base: migration hygiene's delta half (MIGRATION_HYGIENE_SCOPE=
delta) and the .beads diff. check-doc-flags stays, because it builds bd from
the pinned release tag. The example Go modules leave .bazelignore so gofmt
and the grep guards see them. check_testcases.py now accepts --not-go
//pkg:all.

Refs: ga-96smfk.20

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:18 +00:00
Julian Knutsen
72534f8e57
ci(bazel): check the Dolt server fingerprint on the dolt-server lane; retire pr.yml's fingerprint job (#7328)
pr.yml's every-PR "Test (Dolt server fingerprint)" job installed dolt, pulled
the dolt-sql-server docker image and ran TestDoltServerFingerprint against
both backends. The rbe-west workers have no docker, and the container backend
is now used only by the container-backed legacy jobs, which run only where
bazel-coverage does not cover pr_lanes.

- //internal/testutil:testutil_dolt_test runs testutil_test with the local
  backend selected and required (BEADS_TEST_DOLT_SERVER=local,
  BEADS_TEST_REQUIRE_DOLT_CONTAINER=1) on the dolt-server lane, which
  pr.yml's gate requires: the fingerprint's local half against the pinned
  dolt, plus the TestLocalDoltServer_* tests every other configuration
  skips under BEADS_TEST_SKIP=dolt.
- The container half moves back to test-domain-uow's first test step (where
  it was before D2 step 3), so it runs exactly where containers are used.
  //internal/testutil:testutil_docker_test is its docker-lane A/B control.
  TestPinnedDoltCLIMatchesContainerImage still pins the image tag to the
  dolt release.
- test-dolt-server-fingerprint, its ci-gate need/result and its policy
  tests are removed; TestDoltServerFingerprintRunsWhereEachBackendRuns
  pins the new placement.

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:16 +00:00
Julian Knutsen
c292964571
ci(bazel): run the managed-local proxied lifecycle lane under Bazel; retire proxied-local-smoke.yml (#7326)
proxied-local-smoke.yml built bd and the cmd/bd test binary on a GitHub
runner, installed the pinned dolt, and ran `-test.run ^TestManagedLocalProxied`
under `sudo unshare --net` with only loopback up, to prove the managed-local
lifecycle (bd -> loopback proxy -> dolt sql-server) needs no outbound network.

//cmd/bd:bd_managed_local_test runs the same tests (BEADS_TEST_PROXIED_LOCAL=1,
BEADS_TEST_SKIP=dolt, the non-race bd_for_tests as the bd under test, the
pinned dolt from the test wrapper's PATH) through tools/bazel/go_test_offline.sh,
which enters an unprivileged user + network namespace with only loopback up
and fails if outbound network is reachable: the job's netns, without sudo,
on the rbe-west workers. Tagged dolt-server-proxied, so bazel.yml's
bazel-proxied lane (remote-only, required by pr.yml's gate) runs it; test
result caching replaces the workflow's path filter. The job's "tests are
compiled in" assertion becomes scripts/managed_local_lane_test.go, which
evaluates cmd/bd's build constraints for a linux cgo build and requires each
of the 17 pinned tests.

The target joins the pinned retired-lane targets in
TestBazelRetiredLanesCannotBeNarrowed. proxied-local-smoke.yml and the policy
tests that pinned its job and its dolt version are removed (the Bazel dolt
pin is already enforced against install-dolt.sh).

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:14 +00:00
Julian Knutsen
cb0dcbecf2
ci(bazel): hermetic LLVM C toolchain and pinned rbe_worker exec platform (#7325)
beads' MODULE.bazel registered no C toolchain, so -race and cgo builds used
the autodetected local_config_cc of the machine that ran analysis. From a
client with lld installed (cherry) every remote cgo/-race link failed with
"collect2: fatal error: cannot find 'ld'" (the workers have no lld), and the
host gcc path, lld availability and gcc-version inputs keyed every Go action
to the client machine.

Port gastownhall/gascity's design:
- toolchains_llvm 1.11.0 with a pinned LLVM 22.1.8 slice
  (third_party/cc_toolchain/llvm_dist.bzl) and a sysroot of sha256-pinned
  Ubuntu 24.04 debs (deb_sysroot.bzl), without ICU (ICU policy);
  stock toolchains_llvm LLVM on other hosts.
- .bazelrc: BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 so nothing falls back to the
  host compiler.
- //platforms:rbe_worker, selected unconditionally, whose worker-env exec
  property is the sha256 of tools/rbe/worker-env.txt (a copy of the shared
  rbe-west OSS pool's manifest, owned by gascity), so the worker host is in
  every action key.
- scripts/bazel_hermetic_cc_test.go and scripts/rbe_worker_env_test.go guard
  both.

Refs: ga-96smfk.20

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:11 +00:00
Bee
bc34f1d77c
ci: upgrade workflows also run on schema-migration changes (#7150)
#7147 gave migration-test, conformance and cross-version-smoke a shared
paths filter: non-test Go files plus build inputs. The schema migrations
are .up.sql files embedded into the binary (go:embed in
internal/storage/schema), so they match no entry. A PR that adds a
migration with only a _test.go beside it skipped all three workflows,
where before #7147 it ran all three. d26230d0d and 63a471a1e have that
shape.

Add internal/storage/schema/migrations/** to the shared base in each
paths block and in advisoryPathFilterBase, which pins the base across
the three files.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-07 00:40:04 +00:00
Bee
01eb7b83b5
docs(show): say that --json omits comments entirely without --include-comments (#7132)
bd show --json returns comment_count and comments_omitted=true and no
comments key. The --include-comments help only said it streams full bodies,
which reads as "the default is truncated". A scan that reads .comments over
plain --json sees nothing for every issue and reports each one clean, with
no error: one audit over 38 issues reported 0 adverse verdicts where the
same scan with --include-comments found 4.

Say it in the flag help, as bd list --include-comments already does. Help
text only; the JSON contract pinned in cmd/bd/protocol is unchanged, and the
generated CLI docs stay on the v1.2.2 pin.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-07 00:39:07 +00:00
Julian Knutsen
55f96b3f5e
docs(contributing): recommend issues when they add context instead of requiring one per PR (#7323)
#7223 made a linked, documented issue mandatory for every PR. That is
the right default for user-visible bugs and changes worth discussing,
but it adds ceremony to small, self-explanatory fixes without adding
context.

AGENTS.md, CONTRIBUTING.md, ROADMAP.md, the PR template and the feature
form now advise filing an issue when it adds context and let small fixes
go straight to a PR whose description explains the why. End-to-end
evidence is still required, and Closes #N is used when an issue exists.
No CI check or ruleset enforced the requirement; scripts/pr-preflight.sh
already only warns when a PR has no closing issue.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 23:29:09 +00:00
Bee
d4309098e5
fix(doltserver): prove listener ownership on darwin with lsof and ps (#7232) (#7257)
On macOS listenerOwnership always answered known=false, so once a foreign
process greeted on the port chosen for a new dolt sql-server, Start adopted
that listener as its own (the default log level emits no ready line to
disprove it). TestStart_RecoversWhenEphemeralPortIsTaken has failed on the
Main workflow's macOS job on every push since #7201 (14/14 completed runs);
PR CI has no macOS test job, so no PR saw it.

Darwin has no /proc, so the listener's processes come from lsof and the
process tree from ps, the two tools this package already uses to find a
port's holder and a server's working directory. Each pid lsof lists on the
port is walked up its parent chain; reaching the child proves the listener
is the child's (or a descendant's, for a wrapper that does not exec). Both
reads run only once a greeting has arrived, never on the bare poll.

known is false when either tool fails or lists no listener at all, and
Start then falls back to the greeting as before. A child that no longer
exists is known not to own anything, as on Linux.

The tests that were Linux-only because ownership was only provable there now
run on darwin too, and the darwin file gets its own fake-read table, parser
tests, and a real-tool test with an in-process listener and a listener in a
grandchild process. On this machine the formerly red test passes 10/10
(it failed 40/40 on main).

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 23:24:18 +00:00
Steve Yegge
45b62e47b5
test(protocol): pin §E3 exit 11 with a PTY harness (wy-vh5y8) (#4762)
* test(protocol): pin §E3 exit 11 with a PTY harness (wy-vh5y8)

Exit 11 (ExitLocalExistsRefused) is returned only from the interactive
typed-confirmation abort in `bd init --reinit-local` (cmd/bd/init.go, behind
term.IsTerminal on stdin); the non-interactive branch of the same guard returns
12, so no piped-stdin subprocess could produce 11. WP4 (wy-ge2h8) therefore
left TestProtocol_ExitCode11_LocalExistsRefused skipped.

Un-skip it with a PTY-backed run: allocate a pty (creack/pty, a test-only dep
already in go.sum), drive `bd init --reinit-local` against a workspace seeded
with one issue, answer the "Type 'destroy N issues' to confirm:" prompt with
the WRONG text, and assert exit 11 — distinct from the 12 a bad --destroy-token
yields. Also asserts the abort is a no-op (the seeded issue survives). Windows
skips (no unix PTY).

creack/pty is imported only from _test.go, so it is a test-only dependency; no
new non-test dependency enters go.mod.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(build): register github.com/creack/pty with Bazel and Nix

The exit-11 PTY test imports github.com/creack/pty, a new direct
require in go.mod. The base's generated build manifests predate it:

- Bazel (`make bazel-sync`): //cmd/bd/protocol:protocol_test failed
  "missing strict dependencies" on the import, and go_deps reported
  com_github_creack_pty missing from use_repo. The sync adds it to
  MODULE.bazel's use_repo and adds @com_github_creack_pty//:pty to
  protocol_test's deps. protocol_race_off, protocol_docker_test and
  protocol_dolt_test all wrap protocol_test, so that one deps line
  covers them. Running the same sync on the base changes nothing.
- Nix: default.nix sets proxyVendor = true, so vendorHash covers the
  module download set of go.mod's requires, and the new require
  changes it. Regenerated via the nixos/nix container: the go-modules
  fixed-output derivation now builds with no hash mismatch, and the
  unwrapped package compiles cmd/bd.

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>

* test(protocol): fix exit-code header, name a skipped reinit prompt

Review fixups, adopt-pr review loop iteration 1 (synthesis approve,
scorecard 981/1000, no blocker or major findings).

Taken:
- Header (Finding 2): it said all three refusal codes (10/11/12) refuse
  before bd opens any store. That stopped being true once exit 11 ran:
  its typed confirmation fires only after --reinit-local counts the
  issues in a seeded workspace, so that test pays for a full store, as
  130 does. The header now says 10 and 12 are store-free and 11 and 130
  are not.
- Prompt-skip diagnostic (Finding 3): runInitReinitPreflight skips the
  confirmation, with no warning, when countExistingIssues errors (it
  has its own 5s timeout) or counts zero. The review expected that skip
  to exit 0 in the early-exit arm. A mutation run with the seed issue
  dropped shows it does not: the reinit goes on and blocks at init's
  next TTY prompt, "Change role? [y/N]:", so the test fails at the
  prompt deadline. The deadline arm now names the skip when the output
  lacks the "Re-initializing will destroy" warning. Failure path only.

Declined:
- Shared prompt harness (Finding 1): extracting it rewrites the
  base-owned 130 test (pipes, SIGINT, t.Parallel) into a new helper
  after review. The synthesis allows accepting the duplication in the
  reply to the reviewer instead.
- Redundant "!= 12" check (Finding 4): it mirrors the 12 test's own
  "codes must stay distinct" check, so the tests keep one idiom.

Validation: gofmt and go vet are clean. TestProtocol_ExitCode10/11/12/130
pass against the dolthub/dolt-sql-server:2.2.0 test container with
BEADS_PROTOCOL_REQUIRE_DOLT=1, so exit 11 ran rather than skipped. The
seed-dropped mutant fails with the new message.

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: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-06 23:06:06 +00:00
Bee
9f9cfc4968
fix(gate): report an unreadable store as an error, not a pending bead gate (#6404)
* fix(gate): report an unreadable store as an error, not a pending bead gate (wy-2hz4ol)

evaluateGates assigned r.err for the gh:run, gh:pr and timer arms but never
for the bead arm, so a backend or transport failure on the awaited bead's
read fell through applyGateCheckResults' pending branch: no error row, no
error count, exit 0 — indistinguishable from a healthy gate still waiting.

checkBeadGate now returns (satisfied, reason, err). A read that fails for
any reason other than not-found (storage.ErrNotFound, sql.ErrNoRows, the
partial-id resolver's text) is an error; a missing bead stays pending with
the not-found reason as before. printGateCheckSummary returns an error when
any gate could not be checked so the command exits non-zero on both the
classic and proxied routes. bd close keeps refusing on such a gate (fail
closed, --force to override) instead of treating "could not read" as
satisfied.

Tests: TestCheckBeadGate_LocalBeadLookupError now asserts the wrapped error;
TestCheckBeadGate_LocalBeadNotFoundErrorStaysPending pins the four not-found
shapes; TestEvaluateGates_BeadStoreErrorCountsAsError and
TestPrintGateCheckSummary_ErrorsFailTheCommand pin the error row/count and
the non-zero exit. Each of the three fails against its reverted line.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PNYoASfCXUd5AeeCNiXn51

* ci: re-run the gate after a module-proxy GOAWAY on 'Check doc flags freshness' (no code change)

* fix(gate): name close failures in the exit error; test the close refusal

Maintainer fixup for #6404 (adopt-pr review iteration 1; quality scorecard
956/1000, approve). It fixes the review's three minor findings, all in code
or text this PR introduced.

- printGateCheckSummary: the exit error said "N gate(s) could not be
  checked", but errorCount also counts resolved gates whose close failed
  (the "error closing" rows) on the classic and proxied routes. It now says
  "could not be checked or closed", naming both row kinds, and the summary
  test asserts the new text.
- close_gate_test.go: add
  TestCheckGateSatisfaction_BeadGateUnreadableStoreRefuses. A store stub
  whose GetIssue fails with a non-not-found error must make
  checkGateSatisfaction refuse with "could not check bead gate", the read
  error, and --force. Checked against three mutants: the refusal
  falling through to the fail-open warning, the pre-PR reason-only refusal,
  and checkBeadGate folding the read error into the reason. The existing
  BeadGateInvalidFormat and ErrorMessageFormat tests catch only the first,
  and only through the typed-nil routedBeadGateGetter left by a nil package
  store.
- CHANGELOG: narrow the error-row claim to reads of the workspace's own
  store. A bead in a prefix-routed rig whose store cannot be read still
  reads as not found (pending): the routing fallback returns the local
  not-found and drops the routed error. That is pre-existing and left as a
  non-gating follow-up. Also say the non-zero exit covers gh, timer, and
  bead gates and close failures.

Left as-is: the nit that a typed-nil routedBeadGateGetter{localStore: nil}
gets past checkBeadGate's st == nil guard (unreachable on the classic route,
where store is set before RunE). The optional `gate check` Long-help note
was skipped so the generated CLI reference does not need regenerating.

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 Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-06 23:05:06 +00:00
Bee
1ea5145092
feat(remember): opt-in memories.budget-chars — warn at 80%, refuse a write that crosses the corpus budget (--force overrides) (#6508)
* feat(remember): opt-in memories.budget-chars — refuse a write that crosses the corpus budget (wy-2pox7y)

The wheelhouse-side tripwire only REPORTS the memory-corpus size, so the corpus
re-trips red every few days and nothing has ever stopped the write that crossed
the line. This is the stop.

New config key `memories.budget-chars` (integer, default 0 = OFF), wired exactly
like `prime.max-memory-chars`: recognized in cmd/bd/config.go, routed to yaml in
internal/config YamlOnlyKeys (it is read through viper, so a DB-backed write
would be accepted and then never read), validated non-negative at set time, and
documented in docs/reference/configuration.md.

With the budget ON, `bd remember` measures the corpus as the sum over every
memory of len(key)+len(content) — BYTES, the same unit `bd prime`'s
--max-memory-chars counts in — projected to AFTER the write would apply. An
overwrite replaces that key's old content in the sum rather than adding to it,
so a memory near the ceiling can still be edited.

  - over budget            -> refused, nothing written, exit 1, one line on stderr
  - over budget + --force  -> written, and the crossing is still announced
  - >= 80% and within      -> written, then warned
  - below 80%, or budget 0 -> silent; with the budget off the corpus is not even
                              read, so behavior is byte-identical to before

Every line goes to STDERR, so --json output is never corrupted; a --json refusal
additionally gets the normal machine-readable error object on stdout.

The whole decision is one pure function (rememberBudgetVerdict), which is what
lets the branches be pinned without a database.

Tests run (targeted, never ./...):
  go build ./...                                             rc 0
  go vet ./cmd/bd/ ./internal/config/                        rc 0
  go test ./cmd/bd/ -run 'Memor|Remember|Prime|Budget' -count=1   rc 0
  go test ./internal/config/ -count=1                        rc 0
  BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd/ \
      -run TestEmbeddedMemoryCorpusBudget -count=1 -v        rc 0 (6/6 subtests)
  golangci-lint run --config=.golangci.yml --build-tags=gms_pure_go \
      ./cmd/bd/... ./internal/config/...                     0 issues in touched
                                                             files (one
                                                             pre-existing gosec
                                                             G304 in
                                                             internal/config/permissions_open_nonlinux.go)

New tests: cmd/bd/memory_budget_pure_test.go (byte unit incl. multibyte,
overwrite delta, budget-off silence, config read + negative clamp, the
at-budget/one-over boundary, --force, the 80% warn band and its edges,
unclamped percentage, single-line contract);
cmd/bd/memory_embedded_test.go TestEmbeddedMemoryCorpusBudget (the same five
spec points end to end against a real embedded-Dolt store, through
`bd config set`, asserting the exact stderr lines, the nonzero exit, and that a
refused write leaves the old content intact);
internal/config/yaml_config_test.go validation + yaml-only routing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013XmKxqKuXTaKivDiCoBwBV

* fix(remember): one --json refusal line, ceil on the over-budget percentage (wy-2pox7y)

Review fixes on ca9f14d65d. Three items; one review item turned out to be a
false alarm and is recorded here rather than acted on.

- BLOCKER 1 (CLI docs regeneration) — NO CHANGE NEEDED, and that is the
  finding. docs/cli-reference/ and docs/CLI_REFERENCE.md are not generated
  from this checkout: docs/cli-docs.pin pins them to release tag v1.2.2, and
  scripts/generate-cli-docs.sh, check-cli-docs-drift.sh and check-doc-flags.sh
  all resolve that pin (resolve-docs-bd.sh) and build bd from the TAG, because
  the published docs site describes the latest release, not main's source. No
  CI path sets BD_DOCS_IGNORE_PIN. So changing `bd remember`'s help surface on
  main cannot move the generated docs, and it did not:
  ./scripts/generate-cli-docs.sh ran to completion ("Generated CLI docs from:
  bd version 1.2.2 (dev)") and left the tree clean — zero diff. The gate is
  green at this commit and was green at ca9f14d65d. The --force flag and the
  Corpus budget paragraph reach the docs when the pin is bumped at release.

- NIT 1: the --json refusal said the same sentence twice, prose on stderr AND
  the envelope on stdout. It now says it ONCE, the way
  HandleErrorWithHintRespectJSON does it: --json gets only the stdout
  envelope, every other route gets the bare sentence on stderr. New subtest
  TestEmbeddedMemoryCorpusBudget/json_refusal_is_said_once asserts a nonzero
  exit, EXACTLY one JSON document on stdout (a second Decode must be io.EOF),
  the refusal sentence inside the envelope, a stderr with no "memory corpus"
  in it, and that the refused write left the old content intact.

- NIT 2: floor arithmetic made the refusal at 201 of 200 read "(100%)" — the
  exactly-at-budget value this code deliberately ALLOWS, so the refusal wore
  the number of the case it is not. The percentage now CEILINGS over the
  budget (101%) and still FLOORS within it. The split is on the VALUE, not on
  --force, so one projection cannot report two different percentages
  depending on a flag; that is why the forced over-budget line moved too.
  TestRememberBudgetVerdictBoundary, TestRememberBudgetVerdictForceWrites and
  TestMemoryBudgetLinePercentIsUnclamped updated; the warn band gains a
  999-of-1000 case pinning the floor inside the budget, so "100%" can only
  ever mean at-budget.

- NIT 5: one comment at the List/Remember seam saying the budget is ADVISORY
  and not atomic — the two are separate transactions, so concurrent writers
  can both measure inside the budget and both land. No locking.

Nits 3 (primeConfigInt duplication) and 4 were left alone by instruction.

Gates run from the worktree:
  go build ./...                                                      rc 0
  go vet ./cmd/bd/ ./internal/config/                                 rc 0
  go test ./cmd/bd/ -run 'Memor|Remember|Prime|Budget' -count=1       rc 0
  go test ./internal/config/ -count=1                                 rc 0
  BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd/ \
      -run TestEmbeddedMemoryCorpusBudget -count=1 -v                 rc 0 (7/7)
  gofmt -l cmd/bd internal/config                                     no output
  golangci-lint run ./cmd/bd/ ./internal/config/                      1 issue, all
      pre-existing: gosec G304 in internal/config/permissions_open_nonlinux.go
      (last touched f4d496fed, not by this branch)
  ./scripts/check-cli-docs-drift.sh                                   rc 0
  ./scripts/check-doc-flags.sh                                        rc 0

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFSKdUYCTyuhBM97tHyoye

* ci: list the PR's tests in the embedded shard manifest and cmd/bd BUILD.bazel

#7156 made the embedded-Dolt shard manifests exact-once, and Bazel equivalence
requires every test file in the go_test srcs. Adds TestEmbeddedMemoryCorpusBudget
(generator output, incremental) and memory_budget_pure_test.go (the line CI's
bazel-sync patch printed).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(remember): budget the key ResolveKey writes; hint on stderr too

Review fixes for #6508 (apply-fixes iteration 1; all minor or nit):

- The budget credits an overwrite under memoryapi.ResolveKey's key, the
  one rule every Remember implementation writes under, instead of a
  parallel flag-else-derived copy of it. A write ResolveKey refuses
  skips the budget, so a whitespace-only --key gets the role's "memory
  key must not be empty" instead of an over-budget refusal that points
  at --force.
- The stderr refusal now carries the same hint as the --json envelope
  (raise the budget, forget a memory, or --force), printed the way
  HandleErrorWithHintRespectJSON prints one.
- The memoryCorpusChars comment and `bd remember --help` no longer
  imply that a budget equal to prime.max-memory-chars keeps prime from
  eliding memories: the unit (bytes) is the same, but prime counts each
  memory as rendered, markup included, so the budget has to sit below
  that cap for that.
- New embedded pins: a write without --key that crosses the budget is
  refused with exit 1 and writes nothing; a blank --key gets the
  validation error; the Hint line is on stderr and not under --json.
  Each pin was checked red against a mutant of the code it guards.

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 (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>
2026-10-06 23:04:06 +00:00
Bee
8ae1a2beb3
docs(ide-setup): re-review against cmd/bd/setup and refresh its marker (#7268)
The Last reviewed marker (2026-07-10) passes the 90-day limit in
scripts/check-doc-freshness.sh at 2026-10-09 00:00 UTC, when the required
"Check doc flags freshness" job would fail on every PR and merge-group
run, as it did for ERROR_HANDLING.md (#7266).

Re-reviewed against cmd/bd/setup.go, cmd/bd/setup/ and internal/recipes/
at e72cd8b31 and corrected what had drifted:

- bd setup cursor installs the agent skill and .cursor/hooks.json
  (sessionStart, preCompact, postToolUse) besides the rules file, and
  takes --global (hooks and skill only).
- bd setup claude writes its managed section to AGENTS.md when
  CLAUDE.md is an @AGENTS.md import stub.
- bd setup codex takes --global.
- bd init runs the Claude Code, Codex and Cursor project setup, not
  Codex alone.

The marker is 2026-10-05, not the UTC date, because the script rejects a
future date and a Pacific shell still reads 10-05.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 23:03:01 +00:00
Bee
2e7637757f
fix(ready): --explain sorts a ready issue's blocking edges by status instead of calling a pinned dependency resolved (#7124)
* fix(ready): --explain sorts a ready issue's blocking edges by status instead of calling a pinned dependency resolved (wy-0h6t03)

The ready query skips a pinned target exactly as it skips a closed one, so a
blocks edge onto a pinned bead never fences its dependent. The explanation
never read the target's status: every blocking edge of a ready issue was
appended to ResolvedBlockers, so a bead wired behind a long-lived pinned
bring-up reported "1 blocker(s) resolved" while its precondition was unmet.
Two trials sat on a takeable front for days that way.

BuildReadyExplanation now sorts each blocks / conditional-blocks / waits-for
edge by the target's status in blockerMap: closed stays under
ResolvedBlockers, pinned goes to PinnedDependencies (never block), any other
status to OpenDependencies (not blocking; the #6066 shape, now visible). A
target without a status in the map keeps the old treatment. Reason keeps its
"N blocker(s) resolved" lead and appends the other two counts as clauses.

Both explain routes previously fetched only the blockers of blocked issues,
so no ready target ever had a status; explainBlockerIDs now adds the ready
issues' blocking-dependency targets to that one batch fetch, once each, and
printReadyItemDependencies prints the three lines for both routes.

Pinned-never-blocks itself is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* build(bazel): list ready_explain_ids_test.go in the cmd/bd go_test srcs (wy-0h6t03)

The equivalence gate named TestExplainBlockerIDs and
TestExplainBlockerIDs_Empty as tests go test runs that Bazel did not: the
new test file was never added to BUILD.bazel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 22:46:47 +00:00
Bee
5cd171a7c0
test: pin that a gate on a parent hides existing and later-born children from bd ready (#6604)
* wy-raudbw: pin that a gate on a parent hides existing and later-born children from bd ready

Embedded-dolt test: epic + two children all ready; gate on the epic hides
all three; a child created after the gate is born hidden; resolving the
gate frees all four. Pins the read-time cascade (blocked-consistency
parent-child leg) that operator tooling downstream relies on.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: register TestEmbeddedGateInheritsDownParentChain with Bazel and the embedded shards

Maintainer fixup for adopt-pr #6604. The PR adds a new embedded test file,
cmd/bd/gate_inherit_embedded_test.go. Its merge-base (71c4cd08b9) predates
two checks on main that every new cmd/bd embedded test has to satisfy:

- cmd/bd/BUILD.bazel: bd_test's srcs list every untagged cmd/bd test file.
  Without the row, Bazel never compiles or runs the test, and bazel.yml's
  "BUILD files in sync" step in the required test job fails. The row was
  added by `bazel run //:gazelle`, which changed no other file.
- .github/scripts/embedded-cmd-test-shards.txt: the Bazel-only 50-shard
  block must name every TestEmbedded* test exactly once, or
  TestCmdEmbeddedShardManifestGeneratorNotStale fails `go test ./scripts/`.
  The entry was added by `gen_embedded_cmd_shard_manifest.py 50
  --weights=duration --write`, which is incremental: it placed the test on
  shard 16 and moved no existing assignment.

The PR's own file is unchanged.

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: match bd ready rows by exact ID in the gate-inherit pin

Maintainer fixup for adopt-pr #6604, review iteration 1.

TestEmbeddedGateInheritsDownParentChain decided whether an issue was in
`bd ready` by looking for its title anywhere in the pretty output. The
epic's two "should be ready" checks (before gate, after resolve) were
vacuous: every ready child of an epic carries a "← <epic title>"
annotation, and buildParentEpicMap fetches that parent on its own, so the
children's rows satisfied "Inherit epic" with no epic row in the list.

The review suggested matching epic.ID instead. That is vacuous too: child
IDs are hierarchical (<epic>.N, from GetNextChildIDTx), so the epic's ID is
a substring of every child row. wantReady now takes the created issue and
requires its ID as a whole whitespace-separated token of the output. The
test keeps reading the pretty route (GetReadyWork) it was written against;
--json would read through GetReadyWorkWithCountsAndTotal instead.

Evidence: `BEADS_TEST_EMBEDDED_DOLT=1 go test -tags gms_pure_go ./cmd/bd/
-run '^TestEmbeddedGateInheritsDownParentChain$'` in git-archive copies,
with BD_*/BEADS_*/GC_* unset so the bd binary is built from the copy.

- Unmutated: PASS.
- Mutant A, "epic" added to sqlbuild.ReadyWorkExcludeTypes. Ready printed
  "○ gi-83o.1 P2 Inherit child one ← Inherit epic" and no gi-83o row. The
  title check PASSED, the epic.ID substring check PASSED, and the ID-token
  check FAILED at the before-gate and after-resolve epic lines.
- Mutant B, the issues parent-child leg of
  shouldBeBlockedIDsUnionScopedSQL disabled, so a gated parent no longer
  hides its children. The ID-token check fails at exactly the three child
  lines. The title check also failed the epic's "hidden" check, although
  the epic row was absent, because the children's annotation carried its
  title.

Unchanged: the gate ID is still taken from the first "gi-" token of
`bd gate create`. renderGateCreated documents its first line, "Created
gate <id>", as parsed by downstream scripts.

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 Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-06 22:45:49 +00:00
Julian Knutsen
8761d2c40e
ci(bazel): run the conformance e2e tier under Bazel; retire conformance.yml and the docs-mintlify docsync job (#7321)
conformance.yml ran two tiers on a GitHub runner. Tier 1 (the embedded-Dolt
TestConformance) already runs as the embedded lane's
embeddeddolt_conformance_{core,audit}_test. Tier 2, the real-binary CLI
corpus (`go test -tags 'gms_pure_go e2e' ./test/conformance`), had only a
go_library under Bazel. Its two test files now build under `e2e ||
integration`, so gazelle generates //test/conformance:conformance_test
(integration-only, against the injected non-race bd_for_tests) and
--config=integration runs it remotely in bazel-integration, which pr.yml's
gate requires. PR Core's go test builds neither tag, so the --config=ci
equivalence check is unchanged; scripts/conformance.sh keeps working with
-tags e2e as the local go test entrypoint. With both tiers covered,
conformance.yml and main.yml's warm-up compiles for it are removed.

docs-mintlify.yml drops its docsync job (`go test ./test/docsync`, run by
bazel-test as //test/docsync:docsync_test on every PR) and keeps only
Mintlify's broken-link check, which needs the network (npx mint) and the
base branch's history; its path filter narrows to what that check reads.

Refs: ga-96smfk.17

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 22:42:25 +00:00
Bee
82872a81a5
fix(ci): rbe pre-warm survives a failed gh run list under bash -e, and clamps an over-long worker count (#7162) (#7163)
Actions runs the dispatch step as bash -e, so a failing gh run list ended the
step at the assignment and the could-not-read warning never printed. The
assignment now tolerates the failure. A RBE_PREWARM_WORKERS too long for the
shell's integer compare slipped past the max-4 clamp and the loop dispatched
without bound; two or more digits is now decided in the case (all zeros stays
the kill switch). The behaviour test runs the script with bash -e, as Actions
does, under a 30s deadline, and pins the clamp.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 22:35:02 +00:00
Julian Knutsen
0500fc6f40
ci(bazel): run the scripts and source-walking tests remotely; retire their go test legs (#7320)
//scripts:scripts_test and //scripts/check-versions:check-versions_test
drop their host-tools/no-remote-exec/no-remote-cache tags and run on the
rbe-west workers like every other target (the worker image ships bash, git,
python3, jq, yq, curl, openssl, unzip and coreutils; a missing tool fails the
test under Bazel rather than skipping it). Go comes in hermetically as the
registered SDK; check-versions.sh's `go build` is stood in for by the
Bazel-built checker.

The tests that walked the source checkout now get it as data:
tools/bazel/go_srcs.py keeps a managed `repo_files` filegroup in every
package and aggregates them into //:repo_files (exactly the tracked files
Bazel can see; make bazel-sync-check fails on a package without one).
scripts_test and docsync_test take it instead of hand-listed filegroups,
and every TEST_SRCDIR/IsBazel skip and go-test-only block in them is gone.
The release formula under .bazelignore'd .beads/ comes in through a
@beads_formulas local repository; npm-package/ and .claude/ are visible to
Bazel again (only their node_modules/worktrees stay ignored), so the npm
manifest release check and the AGENTS.md skill links run under Bazel too.
TestZZStdioNotLeaked falls back to TestMain's pre-run streams instead of
skipping in a shard without its baseline.

tools/bazel/equivalence_allowlist.txt shrinks from 20 skip entries to the
two cmd/bd tests of plain go test's own bd build fallback, which Bazel never
takes; pr-preflight-platforms now runs them on Linux, macOS and Windows. The
scripts-go-checks scripts-test and allowlisted legs, their scripts
(scripts-go-test.sh, allowlisted-go-tests.sh, run_allowlisted_go_tests.py)
and main.yml's --compile-only warm for them are removed. The vet leg stays
(ga-96smfk.18).

Refs: ga-96smfk.16

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 22:20:16 +00:00
Bee
ec60748605
fix(test): keep fixture commits from starting the auto maintenance that prunes a new worktree (#7314)
A fixture's "git commit" starts "git maintenance run --auto --detach"
(builtin/commit.c run_auto_maintenance). Unscheduled maintenance runs the
worktree-prune task, and should_prune_worktree removes an entry that has
neither "locked" nor "gitdir" with no expiry check. "git worktree add"
mkdirs .git/worktrees/<name>, then writes "locked", then "gitdir", so a
detached maintenance run reading .git/worktrees inside that window prunes
the entry and the add dies with

  fatal: could not open '.git/worktrees/worktree/locked' for writing: No such file or directory

Seen twice on Main's Test (ubuntu-latest), both on a fresh init + one commit
+ "git worktree add <dir> HEAD" inside the test's own t.TempDir:

- 33507469201 attempt 1 (2026-09-01): internal/config
  TestInitialize_IgnoresWorktreeFallbackConfigWhenRequested
- 37513420893 attempt 1 (2026-10-06, git 2.55.0, ubuntu-24.04 20260927.320.1):
  internal/beads TestResolveBeadsDirForRepoIgnoresInheritedRouting

The second test unsets every git routing key and resets HOME before any git
call, so no environment-level setting (GIT_CONFIG_COUNT, a global config)
can reach its fixture: the setting has to ride on the fixture's own
command line. Every fixture git command in internal/beads now goes through
gitCommand, which prepends -c maintenance.auto=false -c gc.auto=0 (the
gc.auto half covers git before 2.29, where commit ran gc --auto instead),
and the internal/config fixture's closure does the same.

Proof (git 2.55.0): GIT_TRACE over the two tests above at main shows 3
"maintenance run --auto --quiet --detach" spawns for 3 worktree adds; at
this commit 0 spawns, the same 3 adds. An empty .git/worktrees/x is removed
by "git maintenance run --auto"; with -c maintenance.auto=false a commit
starts no maintenance.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 21:51:20 +00:00
Julian Knutsen
9f60d71dae
ci(main): push to main runs the Linux test tiers under Bazel only (#7316)
bazel.yml already runs on every push to main and executes the PR Core,
pure-Go, dolt-server, embedded, proxied, server-storage, integration and
cmd/bd Dolt-server tiers on rbe-west in about five minutes. main.yml re-ran
the same tiers as legacy go test jobs (62 jobs, about 380 runner-minutes a
push), and its runs were all failing or cancelled. Remove the duplicated
Linux jobs: the ubuntu -race -short leg with its Codecov upload, PR Core,
the pure-Go compile check, domain+uow, the 6+8 integration shards, the 15
proxied shards, and the embedded build plus its storage, conformance and
cmd shards.

The macOS -race -short suite (rbe-west has no macOS workers) moves to
Blacksmith macOS and restores the macOS saver's caches. The cache savers
that fed the fork path from the removed jobs move to venue matrices: the
macOS saver gains a GitHub-hosted leg, and the Linux saver gains a
GitHub-hosted race leg (the embedded build used to seed it).

Refs ga-96smfk.14

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 20:52:01 +00:00
Julian Knutsen
68d8cf99c0
ci(bazel): cover fork and Dependabot PRs with the Bazel lanes (BAZEL_COVERS_FORKS=true) (#7315)
Fork and Dependabot PRs ran both stacks: the legacy embedded, proxied,
server-storage and PR-lane tiers plus the Bazel lanes, which rbe-fork has
executed remotely (fork-ro/fork-rw) since the canary ended. Flip the
committed flag in pr.yml and pr-risk.yml so bazel-coverage retires those
tiers for forks too. A covered run the mint does not serve (mode cache)
already turns CI Gate / Required red with a re-run message; it never falls
back silently.

Refs ga-96smfk.15

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 20:51:59 +00:00
Bee
800d43eb8d
docs(engdocs): re-review ERROR_HANDLING.md against cmd/bd and refresh its marker (#7267)
The Last reviewed marker (2026-07-07) passed the 90-day limit in
scripts/check-doc-freshness.sh at 2026-10-06 00:00 UTC, so the required
"Check doc flags freshness" job fails on every PR and merge-group run
(#7266).

Re-reviewed against cmd/bd at e72cd8b31 and corrected what had drifted:

- createConfigYaml takes three arguments.
- cmd/bd/sync.go has no warning or ignored-error sites any more; its
  citations are gone. Line-number citations into init.go and create.go
  no longer matched and are replaced by search strings.
- internal/syncbranch was removed with the sync-branch pipeline; the
  syncbranch.Set example and the sync.branch bullet are gone.
- No code writes last_import_hash; the tracking-metadata examples now
  show the bd_version write (SetLocalMetadata) and verifyMetadata as
  init.go has them.
- CheckReadonly also exits ExitMigrationFrozen under a migration freeze.
- HandleProxyCapabilityError is added to the helper list.

Fixes #7266

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 12:46:26 -07:00
Chris Sells
c33d30aa10
docs(upgrading): key the shared-server read failure to schema v53, not release 1.2.0 (#7310)
#7301 scoped the pre-migration read failure on a shared server to schemas
that "predate 1.2.0". That misses 1.2.2, the recovery re-release of the
1.1 line: its migrations stop at 0053 with no lease migrations, so a 1.2.2
server sits at v53 like 1.1.x. Upgrading such a server's clients to 1.3.1
without `bd migrate schema` makes `bd list`, `bd show` and `bd ready` fail
with `table not found: leases`.

Key the caveat to schema v53 or older, naming 1.1.x and 1.2.2, which
matches the section's own "A 1.2.2 or 1.1.x database sits at schema v53".

Refs #6929, #7284, #7301
2026-10-06 11:42:52 -07:00
Chris Sells
f05b2b0a6a
docs: scope the shared-server read failure to pre-1.2.0 schemas; add eight community tools (#7301)
* docs(upgrading): scope the shared-server read failure to pre-1.2.0 schemas

#7284 said most reads fail between upgrading a shared server's clients
and running `bd migrate schema`. That only holds for a schema older than
1.2.0: the leases table ships with main migration 0055 and ignored 0012
and 0016, all in v1.2.0. From 1.2.x, reads keep working and only writes
are refused (probed against a 1.2.1 server with 1.3.1 and main builds).

Restore the original wording and add the pre-1.2.0 caveat, naming only
the observed `bd list` failure from #6929.

Refs #6929

* docs: add beads-viewer (Paseo plugin) to community tools

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ad28cf00ba)

* Add LazyBeads (lb) to community tools

- List lesliesrussell/lazybeads under Terminal UIs
- Note that it is unrelated to the earlier lazybeads under Historical

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1aa2b645e2)

* docs(community-tools): update the beads-web entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit aa177110b3)

* docs(community-tools): mention the beads-web tree view

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QebAVaD36wUemAsdBx8wwJ
(cherry picked from commit e0eb482a11)

* Updated community tools documentation with Beads Tracker

Applied changes from BB to 1 file

Files modified:
- docs/community-tools.md

Updated community tools documentation

Applied changes from BB to 1 file

Files modified:
- docs/community-tools.md

Updated community tools documentation

Applied changes from BB to 1 file

Files modified:
- docs/community-tools.md

(cherry picked from commit 75d0f8de0c)

* docs: add b9s to community tools (TUI and web UI)

(cherry picked from commit 8bb6ab6913)

* docs: add btui to community tools (btui-bb2)

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Andreas Dellrud
(cherry picked from commit 81da372c63)

* docs: mention released btui Beads 1.3 support (btui-0fm)

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Andreas Dellrud
(cherry picked from commit 8f27445bee)

* docs: add beadside to community tools

(cherry picked from commit 2c2cb1fd5c)

* docs: add Beads for Obsidian to community tools

(cherry picked from commit cb82d067d8)

---------

Co-authored-by: cuongntr <cuongntr@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Leslie Russell <leslierussell@gmail.com>
Co-authored-by: weselow <598746@gmail.com>
Co-authored-by: Beyond Better <git@beyondbetter.app>
Co-authored-by: vanderheijden86 <vanderheijden86@gmail.com>
Co-authored-by: Andreas Dellrud <andreas.dellrud@gmail.com>
Co-authored-by: michal.psencik <misa.psencik@gmail.com>
Co-authored-by: Rome-1 <romethorstenson@gmail.com>
2026-10-06 10:56:39 -07:00
Chris Sells
b1bee123ba
docs(upgrading): reads fail too between upgrading clients and migrating a shared server (#7284)
The shared-server upgrade steps said an upgraded client keeps reading the
old schema and only has writes refused. In practice most reads fail as
well: bd list, bd show and bd ready stop with "table not found: leases"
because 1.3 reads expect tables the old schema lacks. Say so, and tell
operators to run the migration as soon as the clients are upgraded
rather than treating the window as merely degraded.

Refs #6929, #7038
2026-10-05 21:58:43 -07:00
Chris Sells
384001a22e
docs(upgrading): adopt a migrated remote without relying on bd bootstrap (#7280)
The upgrade docs told every non-migrating clone to adopt the migrated
database with `bd bootstrap`, claiming it replaces the local database.
On a clone that already has one, bootstrap prints "Nothing to do." and
exits 0, leaving the clone on the old schema (#6687).

Document the flow that works: every clone backs up with the old binary,
other clones `bd dolt pull` on the old binary after the migrator pushes
and then upgrade; a clone that already upgraded moves its local database
aside, re-clones with `bd bootstrap`, and re-imports the backup. Align
the gate description, shared-server note, and init-safety summary.

Also add a post-migration step to run `bd recompute-blocked` once per
database, since migration 0059 can over-set is_blocked and silently hide
ready work (#7037).

Refs #6687, #7037
2026-10-05 21:46:05 -07:00
1703 changed files with 220072 additions and 32127 deletions

View file

@ -1,9 +1,7 @@
examples/library-usage
examples/bd-example-extension-go
npm-package
npm-package/node_modules
website
node_modules
.claude
.claude/worktrees
.worktrees
.beads
.dolt

272
.bazelrc
View file

@ -1,8 +1,27 @@
# Bazel configuration for beads (side-by-side with the Go toolchain; `go build`
# and `go test` are unaffected). Bzlmod only; Bazel version is pinned in
# .bazelversion.
# Bazel configuration for beads. Bazel is beads' build and test system: CI
# gates on the `bazel test` lanes in .github/workflows/bazel.yml, and
# `make test`/`make check` run the same commands (engdocs/TESTING.md
# "Building and Testing"). Plain `go build`/`go test` still work as an
# inner-loop convenience but are not what CI enforces. Where actions run is
# per machine, never committed here: contributors read the anonymous,
# read-only cache with --config=fork-cache (defined below); maintainers with
# an rbe-west client certificate execute remotely with --config=remote-exec.
# Make either the default with a `build --config=...` line in the gitignored
# .bazelrc.local. Bzlmod only; Bazel version is pinned in .bazelversion.
common --enable_bzlmod
common --color=no
# C/C++ (and so cgo, -race and the Go stdlib) builds only with MODULE.bazel's
# pinned LLVM toolchain: no host-detected local_config_cc to fall back to,
# which would key actions to the client's gcc and lld and fail remote links
# on workers without lld (scripts/bazel_hermetic_cc_test.go).
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
# The pinned remote-worker host in every action key: //platforms:rbe_worker's
# worker-env exec property is the sha256 of tools/rbe/worker-env.txt, and
# rbe-west's schedulers run an action only on a worker that measured that
# host (platforms/BUILD.bazel). Key-affecting, so unconditional: local,
# fork-cache and remote runs hash alike.
build --extra_execution_platforms=//platforms:rbe_worker
# ICU policy (engdocs/ICU-POLICY.md): build go-mysql-server with its pure-Go
# regex backend so no target links libicu. MODULE.bazel carries the matching
@ -37,7 +56,7 @@ test:prcore --test_env=BEADS_TEST_REQUIRE_EXCLUDE_PERMISSION=1
# Every tag that belongs to another lane (scripts/bazel_policy_test.go
# bazelPRCoreExcludedTags). integration-only targets run zero tests outside
# --config=integration.
test:prcore --test_tag_filters=-requires-docker,-dolt-server,-dolt-server-proxied,-dolt-server-integration,-dolt-server-cmd,-embedded,-manual,-integration-only
test:prcore --test_tag_filters=-dolt-server,-dolt-server-proxied,-dolt-server-integration,-dolt-server-cmd,-embedded,-manual,-integration-only
test:ci --config=prcore
test:ci --keep_going --test_summary=terse
@ -50,29 +69,6 @@ test:ci --remote_download_regex=.*/test\.xml$
# bazel.yml publishes the non-race bd as pr.yml's ci-build-artifacts.
test:ci --remote_download_regex=.*/bin/cmd/bd/bd_for_tests/bd$
# Docker lane: only the requires-docker targets (pr.yml's container-backed
# jobs "Test (storage domain + uow)" and "Contract corpus"), on a host with a
# docker daemon. Race like the domain+uow job (//cmd/bd/protocol's variant
# opts out, like the non-race Contract corpus job), but no -short and no
# BEADS_TEST_SKIP=dolt, which would keep the containers from starting. Those
# targets are also tagged no-remote-exec, so they run on the host even with
# --config=remote-exec; their builds may still run remotely. -test.v in
# test.xml, as in test:ci, lets equivalence.py see which tests ran.
test:docker --@rules_go//go/config:race
test:docker --test_tag_filters=requires-docker
test:docker --build_tests_only
test:docker --keep_going
test:docker --test_env=GO_TEST_WRAP_TESTV=1
# Those jobs pass no -p/-parallel, so go test uses GOMAXPROCS, ubuntu-latest's
# 4 vCPUs, for both. Match that on any host: 4 test processes (hence at most
# 4 dolt containers starting at once) and -test.parallel=4.
test:docker --local_test_jobs=4
test:docker --test_arg=-test.parallel=4
# The variants depend on host state no action key sees (the docker daemon,
# the pulled dolt image, the network), so a cached result proves nothing about
# this host: always run them, like the jobs' `go test -count=1`.
test:docker --nocache_test_results
# Embedded-Dolt tier: PR Risk's embedded jobs ("Test (Embedded Dolt Cmd
# N/20)", "Test (Embedded Dolt Storage N/5)", "Test (Embedded Dolt
# Conformance - core/audit)"), as the `embedded`-tagged variants of bd_test
@ -108,41 +104,55 @@ test:embedded --remote_download_regex=.*/test\.xml$
# jobs, which never retried. Evicted inputs fail the step instead; a
# visible "Re-run failed jobs" retries it.
test:embedded --experimental_remote_cache_eviction_retries=0
# The race configuration's nogo validations run once, in bazel.yml's `test`
# lane (`bazel test //... --config=ci`), which is a strict superset of every
# race-group lane's RunNogo/ValidateNogo keys. --norun_validations is a
# build-request option, not a configuration flag: it changes no action key
# (compile, link and nogo actions are shared with `test` through the action
# cache; test results are not, since each lane's test actions carry its own
# test env and args) and discards no analysis; it only skips re-running nogo's
# validation actions that the owner lane already runs on this configuration.
# scripts/nogo_lint_policy_test.go's TestNogoConfigurationsHaveOneValidatingLane
# pins `test` as this configuration's sole validating lane.
test:embedded --norun_validations
# Dolt-server lane: the same jobs as the docker lane ("Test (storage domain +
# uow)" and "Contract corpus"), but every dolt sql-server is a child of the
# test process, started from the pinned dolt in the test wrapper's runfiles
# (BEADS_TEST_DOLT_SERVER=local, set by each dolt-server target), so the
# targets run on remote workers and need no docker. Same selection rules as
# test:docker: race (//cmd/bd/protocol's variant opts out, like its job), no
# -short, no BEADS_TEST_SKIP=dolt, -test.parallel=4, and the no--short twins
# of the job's other packages. Results are cacheable: every input (test
# binary, dolt, env) is in the action key, and a server that cannot start
# fails the target (BEADS_TEST_REQUIRE_DOLT_CONTAINER=1) instead of skipping.
# --config=docker stays as the A/B control. test.xml is downloaded for
# tools/bazel/equivalence.py --job, test.log for bazel.yml's failure artifact.
# Dolt-server lane: what pr.yml's retired container-backed jobs ("Test
# (storage domain + uow)" and "Contract corpus") ran, but every dolt
# sql-server is a child of the test process, started from the pinned dolt in
# the test wrapper's runfiles (BEADS_TEST_DOLT_SERVER=local, set by each
# dolt-server target), so the targets run on remote workers and need no
# docker. As those jobs: race (//cmd/bd/protocol's variant opts out, like its
# job), no -short, no BEADS_TEST_SKIP=dolt, -test.parallel=4, and the
# no--short twins of the job's other packages. Results are cacheable: every
# input (test binary, dolt, env) is in the action key, and a server that
# cannot start fails the target (BEADS_TEST_REQUIRE_DOLT_CONTAINER=1) instead
# of skipping. test.xml is downloaded for tools/bazel/equivalence.py --job,
# test.log for bazel.yml's failure artifact.
test:doltserver --@rules_go//go/config:race
test:doltserver --test_tag_filters=dolt-server
test:doltserver --build_tests_only
test:doltserver --keep_going
test:doltserver --test_env=GO_TEST_WRAP_TESTV=1
test:doltserver --test_arg=-test.parallel=4
# Locally (fork PRs, rbe=off, no executor): at most 4 test processes, as in
# test:docker; remote workers are not limited by it.
# Locally (rbe=off, no executor): at most 4 test processes, the jobs' 4-vCPU
# runner shape; remote workers are not limited by it.
test:doltserver --local_test_jobs=4
test:doltserver --remote_download_regex=.*/test\.(log|xml)$
# Race-group nogo is owned by the `test` lane; see test:embedded's comment
# above.
test:doltserver --norun_validations
# Proxied-server tier: PR Risk's "Test (Proxied Dolt Cmd N/15)" jobs, as
# //cmd/bd:bd_proxied_test (dolt-server-proxied tag). Kept out of
# //cmd/bd:bd_proxied_test and //cmd/bd:bd_managed_local_test (the
# managed-local lifecycle in a loopback-only network namespace) (the
# dolt-server-proxied tag). Kept out of
# --config=doltserver because bazel.yml runs that lane locally too (forks,
# rbe=off), where 30 concurrent shards, each with a dolt sql-server busy on
# ~4 cores, do not fit regardless of any single shard's wall time; bazel.yml
# runs this one only with remote execution, in a job of its own
# (bazel-proxied). The build is
# --config=doltserver's: race, like PR Risk's /tmp/bd-cmd-test (main.yml's
# twin job runs build-artifacts' non-race bd-cmd-test, so this is the
# stricter of the two); the subprocess bd is the non-race bd_for_tests, like
# the jobs'. Each shard runs its job's
# --config=doltserver's: race, like PR Risk's /tmp/bd-cmd-test; the
# subprocess bd is the non-race bd_for_tests, like the jobs'. Each shard runs its job's
# shard script, whose -test.timeout=15m is past "long": the target is
# eternal, which rbe-west caps at 1200s.
test:doltserver-proxied --@rules_go//go/config:race
@ -164,6 +174,40 @@ test:doltserver-proxied --remote_download_regex=.*/test\.(log|xml)$
# jobs, which never retried. Evicted inputs fail the step instead; a
# visible "Re-run failed jobs" retries it.
test:doltserver-proxied --experimental_remote_cache_eviction_retries=0
# Race-group nogo is owned by the `test` lane; see test:embedded's comment
# above.
test:doltserver-proxied --norun_validations
# dolt-server + proxied union (item 5): bazel.yml's bazel-dolt-race job runs
# both tiers in one invocation in mode remote, in place of the bazel-doltserver
# and bazel-proxied lanes, which still run --config=doltserver and
# --config=doltserver-proxied in every other mode. Exactly the union of the two
# member configs' lines, with one tag filter naming both tiers
# (scripts/bazel_dolt_race_test.go). Every other flag is the same in both
# members or outside any action key for the other: the race build,
# -test.parallel=4 and GO_TEST_WRAP_TESTV=1 are common; the eternal timeout
# applies to no dolt-server target; the eviction retry count is what
# doltserver gets from --config=sole-run wherever it executes remotely;
# test_summary, local_test_jobs and remote_download_regex are not in any action
# key. So each member target's test action is unchanged (aquery: all 62
# TestRunner actions byte-identical), and whichever arm the mode picks shares
# cached results with the other. The member configs stay for those modes, make
# and developers.
test:dolt-race --@rules_go//go/config:race
test:dolt-race --test_tag_filters=dolt-server,dolt-server-proxied
test:dolt-race --build_tests_only
test:dolt-race --keep_going
test:dolt-race --test_summary=terse
test:dolt-race --test_timeout=-1,-1,-1,1200
test:dolt-race --test_env=GO_TEST_WRAP_TESTV=1
test:dolt-race --test_arg=-test.parallel=4
test:dolt-race --local_test_jobs=4
test:dolt-race --remote_download_regex=.*/test\.(log|xml)$
test:dolt-race --experimental_remote_cache_eviction_retries=0
# The union carries its members' --norun_validations line
# (TestBazelDoltRaceConfigIsMemberUnion needs no change: both members and the
# union carry the same line).
test:dolt-race --norun_validations
# Server-Dolt storage tier: PR Risk's "Test (Server Dolt Conformance)" and
# "Test (Server Dolt Full Suite N/16)" jobs, as
@ -191,6 +235,21 @@ test:doltserver-integration --test_env=GO_TEST_WRAP_TESTV=1
test:doltserver-integration --test_arg=-test.parallel=4
test:doltserver-integration --local_test_jobs=4
test:doltserver-integration --remote_download_regex=.*/test\.(log|xml)$
# F5 S2 Variant A: this configuration (integration, doltserver-integration,
# doltserver-cmd -- the same fingerprint, race=true plus
# tags=gms_pure_go,integration) has no full-lane owner. Its nogo runs once,
# narrowly, in bazel.yml's bazel-integration job: a `bazel build
# --output_groups=nogo_fix` step over //internal/testutil/integration only
# (the configuration's non-test library; the 56 integration-tagged _test.go
# files this loses vet/lint coverage on are listed in
# tools/nogo/unvalidated_integration_tests.txt, f5-spec.md §3/§5 S2).
# --norun_validations is a build-request option, not a configuration flag:
# it changes no action key and discards no analysis; it only skips
# re-running nogo's validation actions, which bazel-integration's nogo-only
# step already runs for this configuration's library files.
# scripts/nogo_lint_policy_test.go's TestNogoConfigurationsHaveOneValidatingLane
# pins the nogo-only step as this configuration's sole validating lane.
test:doltserver-integration --norun_validations
# Since D2 step 2 this lane is the tier's only pre-merge run on same-repo
# PRs. Results are cached like every lane's (nightly: --config=fresh).
# No whole-invocation retry on a remote cache eviction ("Lost inputs"):
@ -203,8 +262,9 @@ test:doltserver-integration --experimental_remote_cache_eviction_retries=0
# cmd/bd Dolt-server tier: //cmd/bd:bd_dolt_server_test (dolt-server-cmd
# tag), the whole integration-tagged cmd/bd suite against a hermetic dolt
# sql-server, i.e. the Dolt-gated cmd/bd tests every other lane skips
# (BEADS_TEST_SKIP=dolt in --config=prcore/ci and --config=integration, and
# in main.yml's and nightly.yml's go test jobs). The build flags are exactly
# (BEADS_TEST_SKIP=dolt in --config=prcore/ci and --config=integration), and //tests/regression:regression_test
# (the differential regression suite, formerly regression.yml, against the
# catalog-pinned baseline in @bd_releases). The build flags are exactly
# --config=integration's, so it compiles nothing bazel-integration does not
# (shared through the remote cache). bazel.yml runs it where it runs the
# integration lane (remote, or with the read-only cache in mode cache), in a
@ -220,17 +280,72 @@ test:doltserver-cmd --keep_going
test:doltserver-cmd --test_summary=terse
test:doltserver-cmd --test_timeout=-1,-1,-1,1200
# As in --config=integration: Go's own timeout fires first and dumps every
# goroutine to test.log, which Bazel's kill at 1200s does not.
test:doltserver-cmd --test_arg=-test.timeout=19m
# goroutine to test.log, which Bazel's kill at 1200s does not. Item 5 A2: the
# -test.timeout=19m arg and the BEADS_TEST_REQUIRE_EXCLUDE_PERMISSION env moved
# onto //cmd/bd:bd_dolt_server_test's and //tests/regression:regression_test's
# own args/env (the rules), so --config=dolt-int below does not need them:
# without the move, server-storage's 15m Go timeout would become 19m under
# the union, and the env would leak into server-storage's targets. The final
# argv and environment Bazel assembles (target args, then -test.timeout=19m,
# then this config's own -test.parallel=4 test_arg; same env map either way)
# are unchanged, so the remote action digest -- what RBE's cache keys on --
# is unaffected and cached results should carry over. This IS a local
# actionKey change for these two targets' 46 actions: --test_env is part of
# the build configuration's own fingerprint, picked up by every target
# analyzed under that configuration, unlike a target's own env attribute,
# which only the target carries. To be confirmed in practice by the first
# merge group's tests_cached == tests_total in ci-analytics, not claimed here
# as already observed.
test:doltserver-cmd --test_arg=-test.parallel=4
test:doltserver-cmd --test_env=BEADS_TEST_REQUIRE_EXCLUDE_PERMISSION=1
test:doltserver-cmd --test_env=GO_TEST_WRAP_TESTV=1
test:doltserver-cmd --local_test_jobs=4
test:doltserver-cmd --remote_download_regex=.*/test\.(log|xml)$
# F5 S2 Variant A: same configuration as --config=integration /
# doltserver-integration above; see that block's comment for the owner
# (bazel-integration's nogo-only step over //internal/testutil/integration).
test:doltserver-cmd --norun_validations
# Integration lane: main.yml's "Main Linux integration packages (N/6)" and
# "Main Linux integration cmd/bd (N/8)" jobs (and nightly.yml's Full Test
# Suite, which runs the same `go test` over ./... in one job): every package
# server-storage + cmd-dolt union (item 5 A2): bazel.yml's bazel-dolt-int job
# runs both tiers in one invocation in mode remote, in place of the
# bazel-server-storage and bazel-cmd-dolt jobs, which still run
# --config=doltserver-integration and --config=doltserver-cmd in every other
# mode (fork-ro, fork-rw, cache, local): there one client does both tiers'
# work with no in-flight deduplication, so a union would cost the sum of the
# tiers instead of the max. Exactly the union of the two member configs'
# lines above, with one tag filter naming both members' tags
# (scripts/bazel_dolt_int_test.go). Every other flag is the same in both
# members: the race build, tags=gms_pure_go,integration, keep_going,
# test_summary, the eternal 1200s timeout, GO_TEST_WRAP_TESTV=1,
# -test.parallel=4, local_test_jobs, remote_download_regex and
# norun_validations. So each member target's test action is unchanged in the
# sense that matters for caching (aquery: all 63 TestRunner actions' remote
# action digests are byte-identical, the key RBE's cache lookups use), though
# each action's local actionKey differs since these flags now reach the
# target via its own env/args rather than the member's build configuration.
# Cached results carry over both ways regardless.
# New for cmd-dolt here: --experimental_remote_cache_eviction_retries=0.
# server-storage already has it (above); cmd-dolt did not (it has no
# --config=sole-run of its own, unlike doltserver). Adding it to the union is
# stricter for cmd-dolt (no whole-invocation retry on a remote cache
# eviction) and policy-conformant with sole-run semantics; the eviction
# allowlist in pr_risk_bazel_coverage_test.go records the new line.
build:dolt-int --@rules_go//go/config:tags=gms_pure_go,integration
test:dolt-int --@rules_go//go/config:race
test:dolt-int --test_tag_filters=dolt-server-integration,dolt-server-cmd
test:dolt-int --build_tests_only
test:dolt-int --keep_going
test:dolt-int --test_summary=terse
test:dolt-int --test_timeout=-1,-1,-1,1200
test:dolt-int --test_env=GO_TEST_WRAP_TESTV=1
test:dolt-int --test_arg=-test.parallel=4
test:dolt-int --local_test_jobs=4
test:dolt-int --remote_download_regex=.*/test\.(log|xml)$
test:dolt-int --norun_validations
test:dolt-int --experimental_remote_cache_eviction_retries=0
# Integration lane: the `go test` main.yml's former "Main Linux integration"
# jobs ran on push (this lane replaced them, and nightly.yml's retired Full
# Test Suite, which ran the same `go test` over ./... in one job): every package
# built with -tags=integration,gms_pure_go, race, no -short, no -skip,
# BEADS_TEST_SKIP=dolt. The tag is set for the whole build, as `go test -tags`
# does, not per target: gazelle generates srcs/deps with integration files
@ -246,7 +361,9 @@ test:integration --test_env=BEADS_TEST_SKIP=dolt
# keeps every container- or server-backed test skipped, which is what the
# untagged base targets already do. scripts/bazel_policy_test.go derives the
# required exclusions from the PR-core list, so a new lane tag lands here too.
test:integration --test_tag_filters=-requires-docker,-dolt-server,-dolt-server-proxied,-dolt-server-integration,-dolt-server-cmd,-embedded,-manual
# pr-core-only targets (the historical-release suites: shell tests against
# the release-shaped bd, which the PR-core lane already runs) stay out too.
test:integration --test_tag_filters=-dolt-server,-dolt-server-proxied,-dolt-server-integration,-dolt-server-cmd,-embedded,-manual,-pr-core-only
test:integration --build_tests_only
test:integration --keep_going
test:integration --test_summary=terse
@ -269,6 +386,13 @@ test:integration --test_env=GO_TEST_WRAP_TESTV=1
# equivalence.py / check_testcases.py right after each lane's own
# `bazel test`, before the other lane runs (or give the lanes separate jobs).
test:integration --remote_download_regex=.*/test\.xml$
# F5 S2 Variant A: same configuration as --config=doltserver-integration /
# doltserver-cmd above; see that block's comment for the owner
# (bazel-integration's nogo-only step over //internal/testutil/integration).
# The 56 integration-tagged _test.go files this configuration no longer
# validates in any full lane are the accepted loss, listed in
# tools/nogo/unvalidated_integration_tests.txt.
test:integration --norun_validations
# Pure-Go lane: pr.yml's "Check pure-Go and js/wasm boundaries
# (CGO_ENABLED=0)" job. CGO is off for every Go target (rules_go drops
@ -294,6 +418,29 @@ build:js-wasm --platforms=@rules_go//go/toolchain:js_wasm
build:js-wasm --use_target_platform_for_tests
build:js-wasm --remote_download_outputs=toplevel
# nogo (//tools/nogo: go test's vet checks plus the golangci-lint linters
# .golangci.yml enables) runs beside every Go compile, so `bazel build`/
# `bazel test` fails on a finding -- in bazel.yml's one validating (owner)
# lane per configuration (since F5 S1: a race-group non-owner lane reuses
# its owner's nogo results instead of re-running them; see
# scripts/nogo_lint_policy_test.go's nogoConfigurations table).
# --config=nogo asks for the analysis alone (the nogo_fix output group;
# nothing is linked), in the race configuration bazel.yml's unit lane
# (test:ci) builds, so a local run reuses CI's remote cache. make lint,
# scripts/pr-lint and the pre-commit hook use it.
build:nogo --@rules_go//go/config:race
build:nogo --keep_going
build:nogo --output_groups=nogo_fix
# The same analyzers over the files only other platforms compile
# (//go:build windows, darwin, !linux ...): scripts/pr-lint builds
# //tools/bazel:release_cross, every go_library and go_binary split-transitioned
# to rules_go's non-cgo platforms, for its windows/amd64 and darwin/arm64
# passes (golangci-lint's former GOOS=windows/darwin legs). bazel.yml's pure
# lane builds the same target for every release platform, which validates
# nogo there too.
build:nogo-cross --keep_going
build:nogo-cross --output_groups=nogo_fix
# D2 step 3: bazel.yml's bazel-test, bazel-pure and bazel-doltserver lanes
# add this in the remote modes, where (on same-repo PRs and merge groups)
# they are the only pre-merge run of pr.yml's legacy PR Core,
@ -304,14 +451,13 @@ build:js-wasm --remote_download_outputs=toplevel
# retry would report green.
test:sole-run --experimental_remote_cache_eviction_retries=0
# Test result caching. Every lane but docker caches its test results (read
# and write; Bazel's default): a test whose action key (test binary,
# runfiles, test env, platform) is unchanged reuses the PASS the farm
# recorded for it, on a PR (any attempt), a merge group or a push to main,
# so only what a change touched runs. Why that is safe:
# Test result caching. Every lane caches its test results (read and write;
# Bazel's default): a test whose action key (test binary, runfiles, test env,
# platform) is unchanged reuses the PASS the farm recorded for it, on a PR
# (any attempt), a merge group or a push to main, so only what a change
# touched runs. Why that is safe:
# - Identical key, identical test: these targets are hermetic (dolt and
# every input are runfiles). The docker lane depends on host state no
# key sees and keeps --nocache_test_results above.
# every input are runfiles).
# - A cached failure is never reused: Bazel treats a failed cached action
# as a miss, so whatever failed re-runs.
# - Only rbe-west's workers write the action cache (clients' writes are
@ -369,7 +515,7 @@ build:remote-exec --remote_download_minimal
build:remote-exec --remote_timeout=600
build:remote-exec --remote_retries=3
# Upload only remotely executed results. A locally executed action (a
# no-remote-exec test, a host-dependent docker-lane result) must not seed the
# no-remote-exec test, whose result depends on the host) must not seed the
# shared cache that CI and every other developer read.
build:remote-exec --noremote_upload_local_results

View file

@ -1 +1 @@
9.2.0
9.3.0

View file

@ -201,7 +201,8 @@ document what the pinned release does, never main-only features. See
## 9. Verify before you call it done
Run the gates in [references/verification.md](references/verification.md).
The short list: `go test ./test/docsync` (nav↔file sync + link conventions),
The short list: `bazel test //test/docsync:docsync_test --config=ci`
(nav↔file sync + link conventions),
`./scripts/generate-cli-docs.sh --check` (generated docs fresh),
`./scripts/check-doc-freshness.sh` (Last reviewed markers), and a live
preview with `make docs-dev` (or `./mint.sh dev`) at `localhost:3000`.

View file

@ -39,8 +39,9 @@ don't measure that work by the word delta.
*not* simplifying — it buries the real change in the diff.
4. **Loss-check** (below).
5. **Fact-check** (below).
6. **Gates:** `go test ./test/docsync`, every fence parses, no body H1, no
HTML comments (MDX), preview with `make docs-dev`.
6. **Gates:** `bazel test //test/docsync:docsync_test --config=ci`, every
fence parses, no body H1, no HTML comments (MDX), preview with
`make docs-dev`.
7. **Preview, then commit on approval** — one page or section per batch, so
the reviewer can steer before a cut compounds across the section.

View file

@ -8,7 +8,7 @@ Run these before considering docs work complete. Ordered cheapest-first.
# 1. Docs sync: docs.json nav <-> file consistency, link conventions
# (root-relative extensionless in docs/, exact paths in engdocs/ and
# curated root files), orphan detection (only CLI_REFERENCE.md is exempt).
go test ./test/docsync
bazel test //test/docsync:docsync_test --config=ci
# 2. Generated CLI docs freshness: regenerates from the live command tree
# and diffs docs/CLI_REFERENCE.md, docs/cli-reference/, and the CLI

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Pre-commit hook: auto-format with gofmt and lint with golangci-lint.
# Pre-commit hook: auto-format with gofmt, then lint and vet with nogo.
# Installed via: git config core.hooksPath .githooks
# See also: make install (sets hooksPath automatically)
@ -9,24 +9,6 @@ set -euo pipefail
# the beads section at the bottom must run for non-Go commits too.
staged_go_files=$(git diff --cached --name-only --diff-filter=ACM -- '*.go')
if [ -n "$staged_go_files" ]; then
# Build golangci-lint from source so it is never a stale global binary, and
# pin the version to the one CI uses (.github/workflows/{pr,main}.yml).
GOLANGCI_LINT="go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1"
# Build it with the repo's own Go, the way CI does. In CI, actions/setup-go
# installs the go.mod version and exports GOTOOLCHAIN=local. Locally
# GOTOOLCHAIN defaults to "auto", and for a pkg@version build that honours
# golangci-lint's own toolchain directive instead: it downgrades to
# go1.25.12, which then refuses this repo's newer go directive at config
# load ("the Go language version (go1.25) used to build golangci-lint is
# lower than the targeted Go version") and fails every Go commit. Pinning to
# the go directive reproduces CI's resolution on any host toolchain.
go_toolchain="go$(awk '$1 == "go" { print $2; exit }' go.mod)"
if [ "$go_toolchain" = "go" ]; then
echo >&2 "pre-commit: no go directive in go.mod; cannot pin the lint toolchain"
exit 1
fi
# Auto-format and re-stage, through the go.mod-pinned gofmt. A bare PATH
# gofmt belongs to the host toolchain, and on a host newer than the go
# directive it rewrites and re-stages files into a form CI's gofmt rejects
@ -35,13 +17,13 @@ if [ -n "$staged_go_files" ]; then
echo "$staged_go_files" | xargs "$gofmt_bin" -w
echo "$staged_go_files" | xargs git add
# Lint changed code with auto-fix; block on remaining issues.
# CGO_ENABLED=0 avoids typecheck failures from CGO-only dependencies
# (e.g., dolthub/go-icu-regex) that require system headers not always present.
CGO_ENABLED=0 GOTOOLCHAIN="$go_toolchain" $GOLANGCI_LINT run --new-from-rev=HEAD --fix || exit 1
# Re-stage any auto-fixes from the linter
echo "$staged_go_files" | xargs git add
# Lint and vet: nogo (//tools/nogo) over the staged files' Bazel packages,
# the analyzers bazel.yml gates on (go test's vet checks plus the
# golangci-lint linters .golangci.yml enables). Findings fail the commit;
# nogo prints a `patch -p1` command for the ones with suggested fixes.
# Needs bazel (or bazelisk) on PATH; the windows/darwin passes run in CI
# and in `make lint`.
make lint-changed LINT_CHANGED_SCOPE=staged || exit 1
fi
# --- BEGIN BEADS INTEGRATION v1.3.0 ---

View file

@ -1,8 +1,10 @@
#!/usr/bin/env bash
# Pre-push hook: when pushing a release tag (refs/tags/v*), refuse the push if
# version constants disagree. This stops a release from being tagged/published
# with drifted versions (the failure mode that left main red after the 1.0.5
# release) before it ever reaches CI.
# Pre-push hook: run the Bazel test suite for branch pushes that change Go or
# Bazel inputs (scripts/pre-push-suite.sh), and when pushing a release tag
# (refs/tags/v*), refuse the push if version constants disagree. The version
# check stops a release from being tagged/published with drifted versions (the
# failure mode that left main red after the 1.0.5 release) before it ever
# reaches CI.
#
# Installed via: git config core.hooksPath .githooks
# See also: make install (sets hooksPath automatically)
@ -55,6 +57,39 @@ if [ "$pushing_version_tag" -eq 1 ]; then
fi
fi
# The push-time test suite (scripts/pre-push-suite.sh): bazel.yml's test lane,
# `bazel test //... --config=ci`, for branch pushes whose new commits change
# Go or Bazel inputs. A tag push, a deletion, or a docs-only push skips it.
# BD_PREPUSH_SUITE=go runs plain go test instead, under a banner.
#
# The decision keys on the remote ref and the shas, never on the local ref's
# shape: for `git push origin HEAD` and `HEAD:refs/heads/x` git passes the
# literal local ref `HEAD`, which a `refs/heads/*` match would skip (#7351).
zero_sha=0000000000000000000000000000000000000000
suite_needed=0
while read -r _local_ref local_sha remote_ref remote_sha; do
case "$remote_ref" in
refs/tags/*) continue ;;
esac
if [ "$local_sha" = "$zero_sha" ] || ! git cat-file -e "$local_sha^{commit}" 2>/dev/null; then
continue
fi
base="$remote_sha"
if [ "$base" = "$zero_sha" ] || ! git cat-file -e "$base^{commit}" 2>/dev/null; then
# A new remote branch: compare against main's merge-base.
base="$(git merge-base "$local_sha" origin/main 2>/dev/null || true)"
fi
if [ -z "$base" ] || git diff --name-only "$base" "$local_sha" -- \
'*.go' 'go.mod' 'go.sum' '*.bazel' '*.bzl' '.bazelrc' '.bazelversion' 'MODULE.bazel.lock' | grep -q .; then
suite_needed=1
fi
done <<< "$push_refs"
if [ "$suite_needed" -eq 1 ]; then
repo_root="$(git rev-parse --show-toplevel)"
"$repo_root/scripts/pre-push-suite.sh" </dev/null
fi
exec < <(printf '%s\n' "$push_refs")
# --- BEGIN BEADS INTEGRATION v1.3.0 ---

View file

@ -5,7 +5,7 @@ body:
- type: markdown
attributes:
value: |
Every PR links a documented issue, and this form collects the context reviewers and future readers need. You can open your PR right after filing; no approval is needed first. Read the [project charter](https://github.com/gastownhall/beads/blob/main/engdocs/PROJECT_CHARTER.md) first — beads owns issue-tracking primitives, not orchestration policy or storage-engine behavior.
This form collects the context reviewers and future readers need for a change worth discussing. You can open your PR right after filing; no approval is needed first. Small, self-explanatory changes can skip the issue and go straight to a PR. Read the [project charter](https://github.com/gastownhall/beads/blob/main/engdocs/PROJECT_CHARTER.md) first — beads owns issue-tracking primitives, not orchestration policy or storage-engine behavior.
**Agents filling in this form:** answer each question only from evidence you have. If you cannot answer a question from the evidence, write exactly `NOT_ENOUGH_INFO` instead of guessing.

View file

@ -1,6 +1,7 @@
<!--
Every PR closes a documented issue (file it first or alongside; no approval
needed). The issue carries the motivation, impact, and risk. See
Link an issue when there is one (`Closes #123`); it is recommended for
user-visible bugs and changes worth discussing, and optional for small,
self-explanatory fixes. Either way, say why the change is needed below. See
CONTRIBUTING.md#issues-and-pull-requests.
-->
@ -17,7 +18,7 @@ Closes #
## Checklist
- [ ] The linked issue documents the problem (reproduction or motivation, impact, risk).
- [ ] Tests and lint selected per `engdocs/TESTING.md` pass locally.
- [ ] The why is documented: in a linked issue (reproduction or motivation, impact, risk) or in this description.
- [ ] `make test` (the Bazel test lane, nogo lint included) and any other lane `engdocs/TESTING.md` selects pass locally.
- [ ] User-facing behavior changes are reflected in `docs/` or the generated CLI reference.
- [ ] If an invariant or rule changed, the owning `AGENTS.md` is updated.

View file

@ -8,7 +8,9 @@ description: >
BAZEL_REMOTE_EXECUTOR, RBE_TLS_CERT and RBE_TLS_KEY in the step env, that rc
enables --config=remote-exec for every bazel command; with none of them the
job runs locally; with BAZEL_FORK_CACHE=true (and no secrets) it enables
the read-only fork cache (--config=fork-cache); with BAZEL_FORK_REMOTE=true
the read-only fork cache (--config=fork-cache), and with BAZEL_RRC_READ=true
too (the remote repo contents cache readers) Bazel's remote repo contents
cache through rbe-cache while it answers; with BAZEL_FORK_REMOTE=true
(fork and Dependabot PRs, bazel.yml modes fork-ro/fork-rw; needs
RBE_FORK_PR and RBE_FORK_TIER) it gets a short-lived certificate from
rbe-fork-mint (fork-credential.sh, proving the run with a CSR artifact) and
@ -39,15 +41,18 @@ runs:
# unverified repo contents cache is off (write-bazelrc.sh) and the Bazel
# binary is not cached, so a poisoned entry (a cache written by an
# untrusted run) cannot change what executes. v3: v2 also held Bazelisk's
# download and the contents cache.
# download and the contents cache. v4: MODULE.bazel joins the key because
# the lock does not record non-registry repository rules (llvm_dist), so
# v3 kept restoring the 1.94 GB LLVM .tar.xz after the switch to the
# 149 MB slice.
- name: Restore Bazel runner cache
id: restore
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/bazel-ci-cache
key: bazel-repo-v3-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel.lock') }}
key: bazel-repo-v4-${{ runner.os }}-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock') }}
restore-keys: |
bazel-repo-v3-${{ runner.os }}-
bazel-repo-v4-${{ runner.os }}-
- name: Install Bazelisk
shell: bash
@ -73,6 +78,8 @@ runs:
case "$bazel_version/$arch" in
9.2.0/amd64) bazel_sha=7668a95db1250f12c40407251e4e203b4ec8bf39bc495d2f485b2d8c99048694 ;;
9.2.0/arm64) bazel_sha=049dd21f40ad979db11c3ee68c96a42ce75f1185e69ac61ab20de1501427a410 ;;
9.3.0/amd64) bazel_sha=d302d22ed77ee5658b87857249baa579db84300ecebe0a1e9a357b5b20f80eb8 ;;
9.3.0/arm64) bazel_sha=615cc2509819047e4930fe6643c5f01ebd705ccadf75e8f0b85f9b83cc6a6ca0 ;;
*) echo "setup-bazel: no pinned sha256 for Bazel '$bazel_version' ($arch); add it from the release's .sha256 file" >&2; exit 1 ;;
esac
{

View file

@ -0,0 +1,151 @@
#!/usr/bin/env bash
# May this fork-cache lane read Bazel's remote repo contents cache through
# rbe-west's anonymous read-only cache (rbe-cache :8443, .bazelrc's
# fork-cache) right now? Exits 0 only when the kill switch below is on,
# rbe-cache answers a REAPI GetCapabilities for instance oss with gRPC status
# 0 and a ServerCapabilities that has cache_capabilities, and then answers a
# GetActionResult for a key no action has, and a ByteStream Read for a blob
# the CAS does not hold, each with NOT_FOUND (gRPC 5): the whole read chain
# (Caddy, nativelink-anon, the action cache and the CAS) is up. Anything else
# exits nonzero: switched off, an HTTP or gRPC error, a refused connection,
# a timeout, an answer that does not parse, no curl or python3. The caller
# then writes no repo contents cache lines, and never fails on it. The
# verdict carries the GetCapabilities TCP connect time without the DNS
# lookup (about one round trip to rbe-cache), for the lane's step summary.
#
# Why a probe: with the startup flag set and the cache unreachable (closed
# by rbe-west's kill switch, or down), Bazel retries every repository
# against it before fetching it itself (engdocs/design/
# bazel-remote-repo-contents-cache.md, R6), which costs far more than the
# cache saves. Fork pull_request runs see no repository variables, so the
# opt-out is the committed line below and the server's own answer.
#
# Three gRPC calls over curl's HTTP/2, the first answer decoded by
# python3's standard library: no grpcurl, no new action. Nothing goes to
# stdout (callers write their rc from it); one verdict line goes to stderr. A copy lives in gascity
# (tools/rbe/) and beads (.github/actions/setup-bazel/); keep in sync, except
# the kill switch, which is each repository's own.
#
# Tests only: RBE_CACHE_PROBE_URL (a stand-in server) and
# RBE_CACHE_PROBE_MAX_TIME (seconds).
set -uo pipefail
# Kill switch: off stops this repository's fork-cache lanes reading the
# remote repo contents cache (they fetch external repositories themselves),
# with a one-line pull request; on lets rbe-cache's answer decide. To stop
# every reader of rbe-cache, set it off in both copies (gascity and beads).
# It reaches a lane when the lane's checkout carries it.
fork_rrc_read=on
url=${RBE_CACHE_PROBE_URL:-https://rbe-cache.ops.gascity.com:8443}
max_time=${RBE_CACHE_PROBE_MAX_TIME:-5}
rtt=
no() {
echo "rbe-cache rrc probe: $*${rtt:+ ($rtt)}; this lane fetches external repositories itself" >&2
exit 1
}
[ "$fork_rrc_read" = on ] || no "switched off (fork_rrc_read=$fork_rrc_read in $(basename "$0"))"
command -v curl >/dev/null 2>&1 || no "no curl"
command -v python3 >/dev/null 2>&1 || no "no python3"
tmp=$(mktemp -d) || no "no temp dir"
trap 'rm -rf "$tmp"' EXIT
# call WHAT METHOD REQ: one gRPC call (METHOD: service/method); the answer's
# messages go to $tmp/body, its grpc-status to $st, and the TCP connect time
# without the DNS lookup to $tc. Fails the probe (prefixed with WHAT) on a
# transport error or a non-200 answer.
call() {
local what=$1 out code dns
out=$(curl -sS --http2 --connect-timeout 3 --max-time "$max_time" \
-H 'content-type: application/grpc' -H 'te: trailers' \
--data-binary @"$3" -D "$tmp/head" -o "$tmp/body" -w '%{http_code} %{time_namelookup} %{time_connect}' \
"$url/$2" 2>"$tmp/err") ||
no "$what$(tr '\n' ' ' <"$tmp/err")"
read -r code dns tc <<<"$out"
tc=$(awk -v d="$dns" -v c="$tc" 'BEGIN { if (c > d) printf "%.6f", c - d }' 2>/dev/null) || tc=
[ "$code" = 200 ] || no "${what}HTTP $code"
# grpc-status is a trailer; curl writes trailers after the headers.
st=$(tr -d '\r' <"$tmp/head" | sed -n 's/^grpc-status: *//Ip' | tail -1)
}
# GetCapabilitiesRequest{instance_name: "oss"} (fork-cache's
# --remote_instance_name) as one uncompressed gRPC message.
printf '\000\000\000\000\005\012\003oss' >"$tmp/req" || no "cannot write the request"
call "" build.bazel.remote.execution.v2.Capabilities/GetCapabilities "$tmp/req"
rtt=$(awk -v s="$tc" 'BEGIN { if (s > 0) printf "tcp connect %.1f ms", s * 1000 }' 2>/dev/null) || rtt=
[ "$st" = 0 ] || no "gRPC status ${st:-missing}"
why=$(python3 -I - "$tmp/body" <<'PY'
import sys
def varint(b, i):
v = s = 0
while True:
if i >= len(b) or s > 63:
raise ValueError("truncated varint")
c = b[i]
i += 1
v |= (c & 0x7F) << s
s += 7
if c < 0x80:
return v, i
def fields(b):
i = 0
while i < len(b):
key, i = varint(b, i)
num, wire = key >> 3, key & 7
if wire == 0:
v, i = varint(b, i)
elif wire == 1:
v, i = b[i:i + 8], i + 8
elif wire == 2:
n, i = varint(b, i)
v, i = b[i:i + n], i + n
elif wire == 5:
v, i = b[i:i + 4], i + 4
else:
raise ValueError("wire type %d" % wire)
if i > len(b):
raise ValueError("truncated field %d" % num)
yield num, wire, v
try:
body = open(sys.argv[1], "rb").read()
if len(body) < 5 or body[0] != 0:
raise ValueError("not an uncompressed gRPC message")
n = int.from_bytes(body[1:5], "big")
if len(body) != 5 + n:
raise ValueError("gRPC length %d, %d bytes" % (n, len(body) - 5))
# ServerCapabilities.cache_capabilities
cache = [v for num, wire, v in fields(body[5:]) if num == 1 and wire == 2]
except (OSError, ValueError) as e:
print("unreadable answer (%s)" % e)
sys.exit(2)
if not cache:
print("no cache_capabilities in the answer")
sys.exit(1)
PY
) || no "${why:-python3 failed}"
# GetActionResultRequest{instance_name: "oss", action_digest: {hash:
# sha256("cache-rrc-probe: no action has this key"), size_bytes: 1}}: a key
# no action has, so the action cache behind rbe-cache must say NOT_FOUND.
key=ad12d7a2f1dec188fc1f2c4f5535a4a65eb630fa2f309eca423695e6ec7abee7
printf '\000\000\000\000\113\012\003oss\022\104\012\100%s\020\001' "$key" >"$tmp/req" ||
no "cannot write the request"
call "GetActionResult: " build.bazel.remote.execution.v2.ActionCache/GetActionResult "$tmp/req"
[ "$st" = 5 ] || no "GetActionResult: gRPC status ${st:-missing}, want 5 (NOT_FOUND)"
# ReadRequest{resource_name: "oss/blobs/<the same hash>/1"}: a blob the CAS
# does not hold (its content would have to hash to that key), so the CAS
# behind rbe-cache must say NOT_FOUND.
printf '\000\000\000\000\116\012\114oss/blobs/%s/1' "$key" >"$tmp/req" ||
no "cannot write the request"
call "ByteStream Read: " google.bytestream.ByteStream/Read "$tmp/req"
[ "$st" = 5 ] || no "ByteStream Read: gRPC status ${st:-missing}, want 5 (NOT_FOUND)"
echo "rbe-cache rrc probe: rbe-cache answers GetCapabilities, GetActionResult and ByteStream Read${rtt:+ ($rtt)}; this lane reads the remote repo contents cache" >&2

View file

@ -32,7 +32,13 @@
# means no) it also asks for zstd transfers (--remote_cache_compression). A
# probe, not a repository variable: fork pull_request runs see no vars. No
# other mode ever asks, because only the anonymous cache can advertise zstd,
# and Bazel refuses a remote that does not.
# and Bazel refuses a remote that does not. With BAZEL_RRC_READ=true too
# (bazel.yml's remote repo contents cache readers alone: the jobs whose
# configs rrc-lane-commands.txt seeds), and while rbe-cache answers
# (cache-rrc-probe.sh, which also holds the committed kill switch), it reads
# Bazel's remote repo contents cache, as those jobs' trusted readers do: the
# trees rrc-seed wrote on main pushes, through rbe-cache's anonymous AC and
# CAS reads. The job's step summary says whether it reads, and why.
#
# RBE_FORK_CERT_FILE + RBE_FORK_KEY_FILE + RBE_FORK_ENDPOINT + RBE_FORK_INSTANCE
# (bazel.yml modes fork-ro/fork-rw: fork-credential.sh's outputs, a
@ -94,6 +100,7 @@ key="${RBE_TLS_KEY:-}"
ca="${RBE_TLS_CA:-}"
instance="${RBE_INSTANCE:-}"
fork_cache="${BAZEL_FORK_CACHE:-}"
rrc_reader="${BAZEL_RRC_READ:-}"
fork_cert="${RBE_FORK_CERT_FILE:-}"
fork_key="${RBE_FORK_KEY_FILE:-}"
fork_endpoint="${RBE_FORK_ENDPOINT:-}"
@ -116,6 +123,13 @@ case "$fork_cache" in
exit 1
;;
esac
case "$rrc_reader" in
"" | true) ;;
*)
echo "setup-bazel: BAZEL_RRC_READ must be \"true\" or empty, got \"$rrc_reader\"" >&2
exit 1
;;
esac
rc="$secret_dir/ci.bazelrc"
umask 077
@ -227,14 +241,38 @@ elif [[ "$set_fields" -ne 0 ]]; then
echo "setup-bazel: remote execution is partially configured; BAZEL_REMOTE_EXECUTOR, RBE_TLS_CERT and RBE_TLS_KEY must be set together (or none, for local execution)" >&2
exit 1
elif [[ "$fork_cache" == true ]]; then
# The remote repo contents cache, read-only, for the jobs that opt in
# (BAZEL_RRC_READ: only their configs are seeded), while rbe-cache
# answers and the probe's kill switch (fork_rrc_read) is on. With the
# startup flag set and the cache unreachable, every repository first
# fails a lookup (gascity engdocs/design/bazel-remote-repo-contents-cache.md,
# R6), so a closed or down rbe-cache gets no lines, and a notice says
# why. That holds at probe time only: after loading, Bazel fetches the
# files lazily, and losing rbe-cache then fails the command (R4). Both
# lines are key neutral, as for the trusted readers; fork-cache uploads
# nothing, and rbe-cache refuses every write.
rrc_read=false
if [[ "$rrc_reader" != true ]]; then
why="not a remote repo contents cache reader (no BAZEL_RRC_READ)"
elif why=$(bash "$(dirname "${BASH_SOURCE[0]}")/cache-rrc-probe.sh" 2>&1); then
rrc_read=true
echo "$why"
else
echo "::notice title=No remote repo contents cache::$why"
fi
echo "Fork cache remote repo contents cache read: **$([[ "$rrc_read" == true ]] && echo on || echo off)** (${why#rbe-cache rrc probe: })" >>"${GITHUB_STEP_SUMMARY:-/dev/null}"
# zstd for the anonymous cache's transfers while it advertises zstd:
# transport only, so action keys are unchanged. The probe never fails
# this script; it only decides the line.
# transport only, so action keys are unchanged. The probes never fail
# this script; they only decide the lines.
{
echo "build --config=fork-cache"
if bash "$(dirname "${BASH_SOURCE[0]}")/cache-zstd-probe.sh"; then
echo "build:fork-cache --remote_cache_compression"
fi
if [[ "$rrc_read" == true ]]; then
echo "startup --experimental_remote_repo_contents_cache"
echo "common --loading_phase_threads=64"
fi
} >>"$rc"
cache=true
echo "setup-bazel: read-only remote cache (rbe-cache); executing locally"

View file

@ -41,7 +41,7 @@ case "${1:-}" in
skips=()
if [[ "$valid" == true ]]; then
case "$mode" in
skip) skips+=(BAZEL BAZEL_TEST BAZEL_PURE BAZEL_EMBEDDED BAZEL_INTEGRATION BAZEL_DOLTSERVER BAZEL_PROXIED BAZEL_SERVER_STORAGE BAZEL_CMD_DOLT) ;;
skip) skips+=(BAZEL BAZEL_TEST BAZEL_PURE BAZEL_RELEASE_CROSS BAZEL_EMBEDDED BAZEL_INTEGRATION BAZEL_DOLTSERVER BAZEL_PROXIED BAZEL_SERVER_STORAGE BAZEL_CMD_DOLT) ;;
local) skips+=(BAZEL_EMBEDDED BAZEL_INTEGRATION BAZEL_PROXIED BAZEL_SERVER_STORAGE BAZEL_CMD_DOLT) ;;
cache) skips+=(BAZEL_EMBEDDED BAZEL_PROXIED BAZEL_SERVER_STORAGE) ;;
esac

View file

@ -1,163 +0,0 @@
#!/usr/bin/env bash
# Report candidate PR Risk capabilities without changing the current gates.
set -euo pipefail
embedded_cli=false
proxied_cli=false
embedded_storage=false
embedded_conformance=false
server_conformance=false
full=false
reason=""
diff_file=""
cleanup() {
if [[ -n "$diff_file" ]]; then
rm -f "$diff_file"
fi
}
trap cleanup EXIT
set_full() {
embedded_cli=true
proxied_cli=true
embedded_storage=true
embedded_conformance=true
server_conformance=true
full=true
reason="$1"
}
emit() {
local lines=(
"embedded_cli=$embedded_cli"
"proxied_cli=$proxied_cli"
"embedded_storage=$embedded_storage"
"embedded_conformance=$embedded_conformance"
"server_conformance=$server_conformance"
"full=$full"
"reason=$reason"
)
printf '%s\n' "${lines[@]}"
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
printf '%s\n' "${lines[@]}" >> "$GITHUB_OUTPUT"
fi
}
event_name="${GITHUB_EVENT_NAME:-}"
base_sha="${PR_BASE_SHA:-}"
head_sha="${PR_HEAD_SHA:-}"
case "$event_name" in
pull_request) ;;
push) set_full "push"; emit; exit 0 ;;
merge_group) set_full "merge_group"; emit; exit 0 ;;
*) set_full "unsupported_event"; emit; exit 0 ;;
esac
if [[ -z "$base_sha" || -z "$head_sha" ]]; then
set_full "missing_bounds"
emit
exit 0
fi
diff_file=$(mktemp)
if ! git diff --no-ext-diff --find-renames --name-status -z "$base_sha" "$head_sha" -- > "$diff_file"; then
set_full "diff_failed"
emit
exit 0
fi
saw_path=false
saw_cmd=false
saw_embedded=false
saw_server=false
saw_conformance=false
while :; do
status=""
if ! IFS= read -r -d '' status <&3; then
if [[ -n "$status" ]]; then
set_full "malformed_record"
fi
break
fi
if [[ "$status" != "A" && "$status" != "M" ]]; then
set_full "unsafe_status"
break
fi
path=""
if ! IFS= read -r -d '' path <&3; then
set_full "malformed_record"
break
fi
saw_path=true
if [[ -z "$path" || "$path" == /* || "/$path/" == *"/../"* || "$path" == . || "$path" == .. || "$path" == ./* ]]; then
set_full "unsafe_path"
break
fi
case "$path" in
.github/workflows/*|.github/scripts/*)
set_full "unsafe_control"
break
;;
.buildflags|go.mod|go.sum|Makefile|default.nix|flake.nix|flake.lock|overlay.nix|packages.nix)
set_full "build_input"
break
;;
cmd/bd/*)
embedded_cli=true
proxied_cli=true
saw_cmd=true
;;
internal/storage/embeddeddolt/*)
embedded_cli=true
embedded_storage=true
embedded_conformance=true
saw_embedded=true
;;
internal/storage/dolt/*)
proxied_cli=true
server_conformance=true
saw_server=true
;;
backend/conformance/*|test/conformance/*)
embedded_conformance=true
server_conformance=true
saw_conformance=true
;;
internal/storage/*|backend/*|schema/*)
set_full "cross_cutting_storage"
break
;;
docs/*.md|docs/*.mdx|docs/*.png|docs/*.jpg|docs/*.jpeg|docs/*.gif|docs/*.svg|docs/*.webp|docs/*.avif|engdocs/*.md|engdocs/*.mdx|engdocs/*.png|engdocs/*.jpg|engdocs/*.jpeg|engdocs/*.gif|engdocs/*.svg|engdocs/*.webp|engdocs/*.avif|README.md|CHANGELOG.md|ARTICLES.md|BENCHMARKS.md|NEWSLETTER.md)
;;
*)
set_full "unowned_path"
break
;;
esac
done 3< "$diff_file"
if [[ "$full" != true ]]; then
if [[ "$embedded_cli" == true && "$proxied_cli" == true && "$embedded_storage" == true && "$embedded_conformance" == true && "$server_conformance" == true ]]; then
full=true
reason="full"
elif [[ "$saw_path" != true ]]; then
reason="empty_diff"
elif [[ "$saw_cmd" == true && "$saw_embedded" != true && "$saw_server" != true && "$saw_conformance" != true ]]; then
reason="cmd_bd"
elif [[ "$saw_embedded" == true && "$saw_cmd" != true && "$saw_server" != true && "$saw_conformance" != true ]]; then
reason="embedded_storage"
elif [[ "$saw_server" == true && "$saw_cmd" != true && "$saw_embedded" != true && "$saw_conformance" != true ]]; then
reason="server_storage"
elif [[ "$saw_conformance" == true && "$saw_cmd" != true && "$saw_embedded" != true && "$saw_server" != true ]]; then
reason="shared_conformance"
elif [[ "$saw_cmd" == false && "$saw_embedded" == false && "$saw_server" == false && "$saw_conformance" == false ]]; then
reason="docs_only"
else
reason="mixed"
fi
fi
emit

View file

@ -1,103 +0,0 @@
#!/usr/bin/env bash
# Decide whether CI should run the full embedded Dolt build/storage/cmd matrix.
set -euo pipefail
event_name="${GITHUB_EVENT_NAME:-}"
base_sha="${PR_BASE_SHA:-}"
head_sha="${PR_HEAD_SHA:-}"
full_embedded=false
reason=""
changed_files=""
write_outputs() {
if [ -n "${GITHUB_OUTPUT:-}" ]; then
{
echo "full_embedded=$full_embedded"
echo "reason=$reason"
} >> "$GITHUB_OUTPUT"
fi
}
case "$event_name" in
push)
full_embedded=true
reason="push to main runs full embedded Dolt coverage"
write_outputs
echo "$reason"
exit 0
;;
merge_group)
full_embedded=true
reason="merge queue runs full embedded Dolt coverage"
write_outputs
echo "$reason"
exit 0
;;
esac
if [ "$event_name" != "pull_request" ]; then
full_embedded=true
reason="non-PR event runs full embedded Dolt coverage"
write_outputs
echo "$reason"
exit 0
fi
if [ -z "$base_sha" ] || [ -z "$head_sha" ]; then
full_embedded=true
reason="PR diff bounds unavailable; defaulting to full embedded Dolt coverage"
write_outputs
echo "$reason"
exit 0
fi
if ! changed_files="$(git diff --name-only "$base_sha" "$head_sha")"; then
full_embedded=true
reason="PR diff failed; defaulting to full embedded Dolt coverage"
write_outputs
echo "$reason"
exit 0
fi
if [ -z "$changed_files" ]; then
reason="no changed files detected; skipping embedded Dolt matrix"
write_outputs
echo "$reason"
exit 0
fi
while IFS= read -r path; do
case "$path" in
cmd/*|internal/*|tests/*|scripts/*|.github/scripts/*|.github/workflows/*)
full_embedded=true
reason="changed $path"
break
;;
*.go|go.mod|go.sum|Makefile|default.nix|flake.nix|flake.lock|packages.nix)
full_embedded=true
reason="changed $path"
break
;;
AGENTS.md|AGENT_INSTRUCTIONS.md|CONTRIBUTING.md|RELEASING.md)
full_embedded=true
reason="changed $path"
break
;;
esac
done <<< "$changed_files"
if [ "$full_embedded" = true ]; then
reason="risk path detected: $reason; running full embedded Dolt coverage"
else
reason="docs/metadata-only PR; skipping embedded Dolt storage/cmd matrix"
fi
write_outputs
echo "$reason"
echo "Changed files:"
while IFS= read -r path; do
printf ' %s\n' "$path"
done <<< "$changed_files"

View file

@ -1,199 +1,17 @@
# Embedded cmd test shard manifest.
#
# Format: <total_shards> <shard_number> <top_level_test_name>
#
# There is no committed recent duration artifact for these tests. This manifest
# pins a conservative even split for the 20-shard CI matrix while
# embedded-test-shard.sh continues to hash-distribute newly-added tests that are
# not listed here.
20 1 TestEmbeddedBackup
20 2 TestEmbeddedBackupConcurrent
20 3 TestEmbeddedBlocked
20 4 TestEmbeddedBlockedConcurrent
20 5 TestEmbeddedBootstrap
20 6 TestEmbeddedBootstrapConcurrent
20 7 TestEmbeddedBranch
20 8 TestEmbeddedBranchConcurrent
20 9 TestEmbeddedChildren
20 10 TestEmbeddedChildrenConcurrent
20 11 TestEmbeddedCloseBasic
20 11 TestEmbeddedCloseGuardsAndEpics
20 11 TestEmbeddedCloseAlreadyClosed
20 12 TestEmbeddedCloseConcurrent
20 13 TestEmbeddedComments
20 14 TestEmbeddedCommentsCLI
20 15 TestEmbeddedCommentsCLIConcurrent
20 16 TestEmbeddedCompact
20 17 TestEmbeddedCompactConcurrent
20 18 TestEmbeddedConfig
20 19 TestEmbeddedConfigConcurrent
20 20 TestEmbeddedConfigNoWorkspaceStoreFreeCommands
20 1 TestEmbeddedConfigValidateJSONNoWorkspaceWritesStdout
20 2 TestEmbeddedContext
20 3 TestEmbeddedContextConcurrent
20 4 TestEmbeddedContributorCreate
20 5 TestEmbeddedCount
20 6 TestEmbeddedCountConcurrent
20 7 TestEmbeddedCreateScalarAndRelationships
20 7 TestEmbeddedCreateGraphAndBulk
20 8 TestEmbeddedCreateCommitPending
20 9 TestEmbeddedCreateConcurrent
20 10 TestEmbeddedCreateCrossRepo
20 11 TestEmbeddedCreateCrossRepoUninit
20 12 TestEmbeddedCreateCrossRepoWithParent
20 13 TestEmbeddedCreateWithGitRemote
20 14 TestEmbeddedDefer
20 15 TestEmbeddedDeferConcurrent
20 16 TestEmbeddedDelete
20 17 TestEmbeddedDepA
20 17 TestEmbeddedDepB
20 18 TestEmbeddedDepConcurrent
20 19 TestEmbeddedDiff
20 20 TestEmbeddedDiffConcurrent
20 1 TestEmbeddedDoltBlockedAndCommit
20 1 TestEmbeddedDoltRemoteAndPush
20 2 TestEmbeddedDoltConcurrent
20 3 TestEmbeddedDuplicate
20 4 TestEmbeddedDuplicateConcurrent
20 5 TestEmbeddedDuplicates
20 6 TestEmbeddedDuplicatesConcurrent
20 7 TestEmbeddedEpicStatus
20 7 TestEmbeddedEpicCloseEligible
20 7 TestEmbeddedEpicCloseEligibleReasonFlag
20 7 TestEmbeddedEpicCloseEligibleReasonOutput
20 8 TestEmbeddedEpicConcurrent
20 9 TestEmbeddedExportFormats
20 9 TestEmbeddedExportFlags
20 10 TestEmbeddedExportConcurrent
20 11 TestEmbeddedFederationPeers
20 11 TestEmbeddedFederationStatus
20 12 TestEmbeddedFederationConcurrent
20 13 TestEmbeddedFindDuplicates
20 14 TestEmbeddedFindDuplicatesConcurrent
20 15 TestEmbeddedFlatten
20 16 TestEmbeddedFlattenConcurrent
20 17 TestEmbeddedGC
20 18 TestEmbeddedGCConcurrent
20 19 TestEmbeddedGate
20 20 TestEmbeddedGateConcurrent
20 1 TestEmbeddedGateCreate
20 2 TestEmbeddedGetDependencies
20 3 TestEmbeddedGraph
20 4 TestEmbeddedGraphConcurrent
20 5 TestEmbeddedHistory
20 6 TestEmbeddedHistoryConcurrent
20 7 TestEmbeddedHooks
20 8 TestEmbeddedHooksConcurrent
20 9 TestEmbeddedHuman
20 10 TestEmbeddedHumanConcurrent
20 11 TestEmbeddedImportFromSources
20 11 TestEmbeddedImportUpsertAndPrefixSync
20 12 TestEmbeddedImportConcurrent
20 13 TestEmbeddedInfo
20 14 TestEmbeddedInfoConcurrent
20 15 TestEmbeddedInitA
20 15 TestEmbeddedInitB
20 15 TestEmbeddedInitC
20 16 TestEmbeddedInitConcurrent
20 17 TestEmbeddedKV
20 18 TestEmbeddedKVConcurrent
20 19 TestEmbeddedLabelAddRemove
20 19 TestEmbeddedLabelEditReports
20 19 TestEmbeddedLabelPropagateRename
20 20 TestEmbeddedLabelConcurrent
20 1 TestEmbeddedLint
20 2 TestEmbeddedLintConcurrent
20 3 TestEmbeddedListFiltering
20 3 TestEmbeddedListSearchAndOutput
20 4 TestEmbeddedListConcurrent
20 13 TestEmbeddedMaxRowsListBasic
20 13 TestEmbeddedMaxRowsListLimitInteraction
20 11 TestEmbeddedMaxRowsDepTreeAndDuplicates
20 12 TestEmbeddedMaxRowsDoctorAndConfig
20 14 TestEmbeddedMaxRowsGraph
20 15 TestEmbeddedMaxRowsReady
20 16 TestEmbeddedMaxRowsReadyMerge
20 5 TestEmbeddedMemory
20 6 TestEmbeddedMemoryConcurrent
20 7 TestEmbeddedMigrate
20 8 TestEmbeddedMigrateConcurrent
20 9 TestEmbeddedOnboard
20 10 TestEmbeddedOnboardConcurrent
20 11 TestEmbeddedOrphans
20 12 TestEmbeddedOrphansConcurrent
20 13 TestEmbeddedPrime
20 14 TestEmbeddedPrimeConcurrent
20 15 TestEmbeddedPromote
20 16 TestEmbeddedPromoteCLI
20 17 TestEmbeddedPromoteCLIConcurrent
20 18 TestEmbeddedPruneSafetyAndScope
20 18 TestEmbeddedPruneDryRunAndFilters
20 19 TestEmbeddedPurgeBasics
20 19 TestEmbeddedPurgeFiltered
20 20 TestEmbeddedPurgeConcurrent
20 1 TestEmbeddedQuery
20 2 TestEmbeddedQueryConcurrent
20 3 TestEmbeddedQuick
20 4 TestEmbeddedQuickConcurrent
20 5 TestEmbeddedQuickstart
20 6 TestEmbeddedQuickstartConcurrent
20 7 TestEmbeddedReady
20 8 TestEmbeddedReadyConcurrent
20 9 TestEmbeddedRenamePrefixBasic
20 9 TestEmbeddedRenamePrefixEdgeCases
20 10 TestEmbeddedRenamePrefixConcurrent
20 11 TestEmbeddedReopen
20 12 TestEmbeddedReopenConcurrent
20 13 TestEmbeddedRestore
20 14 TestEmbeddedRestoreConcurrent
20 15 TestEmbeddedSearch
20 16 TestEmbeddedSearchConcurrent
20 17 TestEmbeddedSetup
20 18 TestEmbeddedSetupConcurrent
20 19 TestEmbeddedShip
20 20 TestEmbeddedShipConcurrent
20 1 TestEmbeddedShowBasicsAndJSON
20 1 TestEmbeddedShowDetailAndCurrent
20 2 TestEmbeddedShowConcurrent
20 3 TestEmbeddedStale
20 4 TestEmbeddedStaleConcurrent
20 5 TestEmbeddedState
20 6 TestEmbeddedStateConcurrent
20 7 TestEmbeddedStatus
20 8 TestEmbeddedStatusConcurrent
20 9 TestEmbeddedSupersede
20 10 TestEmbeddedSupersedeConcurrent
20 11 TestEmbeddedSwarm
20 12 TestEmbeddedSwarmConcurrent
20 13 TestEmbeddedTodo
20 14 TestEmbeddedTodoConcurrent
20 15 TestEmbeddedTypes
20 16 TestEmbeddedTypesConcurrent
20 17 TestEmbeddedUndefer
20 18 TestEmbeddedUndeferConcurrent
20 19 TestEmbeddedUpdateFields
20 19 TestEmbeddedUpdateLifecycle
20 20 TestEmbeddedUpdateConcurrent
20 1 TestEmbeddedVCStatusAndCommit
20 1 TestEmbeddedVCCommitVariantsAndMerge
20 2 TestEmbeddedVCConcurrent
20 3 TestEmbeddedVersion
20 4 TestEmbeddedVersionConcurrent
20 5 TestEmbeddedWhere
20 6 TestEmbeddedWhereConcurrent
# Embedded-Dolt cmd/bd test shard manifest.
#
# Format: <total_shards> <shard_number> <top_level_test_name>
#
# 50-shard split for the Bazel-only embedded-Dolt cmd tier
# 100-shard split for the Bazel-only embedded-Dolt cmd tier
# (bazel-embedded in .github/workflows/bazel.yml), bin-packed
# longest-processing-time-first by measured wall-time from
# longest-first by measured wall-time from
# scripts/ci/embedded_cmd_test_durations.json (see that file for provenance
# and its "relative weight, not absolute SLA" caveat).
# Regenerate with scripts/ci/gen_embedded_cmd_shard_manifest.py 50
# and its "relative weight, not absolute SLA" caveat) onto the shard
# whose estimated wall time grows least: serial tests (no top-level
# t.Parallel) add up, parallel ones share -test.parallel=4.
# Regenerate with scripts/ci/gen_embedded_cmd_shard_manifest.py 100
# --weights=duration --write after adding, splitting or removing
# TestEmbedded* functions in cmd/bd/*_embedded_test.go. --write is
# TestEmbedded* functions in cmd/bd/*_test.go. --write is
# incremental: it keeps every already-assigned test on its current shard
# and only places newly-discovered names, onto whichever shard is
# currently lightest, so two unrelated PRs that each add one test do not
@ -206,294 +24,522 @@
# This file is generated: notes added here are erased by the next
# regeneration. Add them to the generator or the durations file instead.
50 1 TestEmbeddedCommentsCLI
50 1 TestEmbeddedDepAddWispSource
50 1 TestEmbeddedListFiltering
50 1 TestEmbeddedPrimeChangeDirDefaultTemplateMatchesTarget
100 1 TestEmbeddedUpdateConcurrent
50 2 TestEmbeddedCreateRepoFromNonBeadsCwd
50 2 TestEmbeddedDeleteJSONDependencyErrorContract
50 2 TestEmbeddedDepBulkNoCycleCheckKeepsWholeGraphGate
50 2 TestEmbeddedHistoryConcurrent
50 2 TestEmbeddedInitA
100 2 TestEmbeddedShowConcurrent
50 3 TestEmbeddedAdminCompactTier2Honesty
50 3 TestEmbeddedMaxRowsListLimitInteraction
50 3 TestEmbeddedOrphans
50 3 TestEmbeddedShowUnresolvableDeps
50 3 TestEmbeddedStale
100 3 TestEmbeddedCloseConcurrent
50 4 TestEmbeddedBootstrapConcurrent
50 4 TestEmbeddedDuplicatesConcurrent
50 4 TestEmbeddedInfo
50 4 TestEmbeddedMaxRowsDoctorAndConfig
50 4 TestEmbeddedRoutedSiblingWritesCommitTargetHead
100 4 TestEmbeddedEpicConcurrent
50 5 TestEmbeddedCreateScalarAndRelationships
50 5 TestEmbeddedDefer
50 5 TestEmbeddedDoltBlockedAndCommit
50 5 TestEmbeddedGCConcurrent
50 5 TestEmbeddedPromote
100 5 TestEmbeddedConfigConcurrent
50 6 TestEmbeddedCreateStorageClassConflicts
50 6 TestEmbeddedGC
50 6 TestEmbeddedGetDependencies
50 6 TestEmbeddedQuickConcurrent
100 6 TestEmbeddedListFilteringBasicAndLabels
50 7 TestEmbeddedCreateCrossRepoDryRunWithParent
50 7 TestEmbeddedEpicStatus
50 7 TestEmbeddedGate
50 7 TestEmbeddedWhere
100 7 TestEmbeddedDepConcurrent
50 8 TestEmbeddedChangeDirOverridesInheritedBeadsDir
50 8 TestEmbeddedMemoryConcurrent
50 8 TestEmbeddedUpdateConcurrent
50 8 TestEmbeddedVCConcurrent
100 8 TestEmbeddedMaxRowsListLimitInteraction
50 9 TestEmbeddedCloseAlreadyClosed
50 9 TestEmbeddedConfigConcurrent
50 9 TestEmbeddedExternalCapabilityReadyAfterShip
50 9 TestEmbeddedPrimeConcurrent
100 9 TestEmbeddedChildrenConcurrent
50 10 TestEmbeddedDepB
50 10 TestEmbeddedHuman
50 10 TestEmbeddedInitExplicitBeadsDirIsAuthoritative
50 10 TestEmbeddedPromoteCLI
100 10 TestEmbeddedCreateScalarAndRelationships
50 11 TestEmbeddedBlockedConcurrent
50 11 TestEmbeddedDepA
50 11 TestEmbeddedMaxRowsDepTreeAndDuplicates
50 11 TestEmbeddedState
100 11 TestEmbeddedKVConcurrent
50 12 TestEmbeddedDirectCommitPathsBatchAutoCommitDoesNotAdvanceHead
50 12 TestEmbeddedPrimeChangeDirPrimesTarget
50 12 TestEmbeddedPromoteCLIConcurrent
50 12 TestEmbeddedSearchConcurrent
50 12 TestEmbeddedTypes
100 12 TestEmbeddedGatedRendering
50 13 TestEmbeddedAutoImportJSONLNoExplicitCommit
50 13 TestEmbeddedDiff
50 13 TestEmbeddedDuplicates
50 13 TestEmbeddedShipConcurrent
100 13 TestEmbeddedListFilteringStatusAndHierarchy
50 14 TestEmbeddedInitConcurrent
50 14 TestEmbeddedOrphansConcurrent
50 14 TestEmbeddedPrimeChangeDirRedirectNoticeFollowsTarget
50 14 TestEmbeddedRoutedMutatingSiblingDeleteClose
50 14 TestEmbeddedSwarm
100 14 TestEmbeddedReopenConcurrent
50 15 TestEmbeddedChildrenConcurrent
50 15 TestEmbeddedConfigValidateJSONNoWorkspaceWritesStdout
50 15 TestEmbeddedCreateDryRunCrossRepoDoesNotMigrateTarget
50 15 TestEmbeddedEpicCloseEligibleReasonFlag
50 15 TestEmbeddedExplicitHierarchicalParentEdges
50 15 TestEmbeddedVersionConcurrent
100 15 TestEmbeddedPurgeWispsPlaneRetention
50 16 TestEmbeddedBlockedLabelFilters
50 16 TestEmbeddedKV
50 16 TestEmbeddedMaxRowsReady
50 16 TestEmbeddedOpen_EmptyDatabaseRejected
50 16 TestEmbeddedRestoreConcurrent
50 16 TestEmbeddedVCCommitVariantsAndMerge
50 16 TestEmbeddedVersion
100 16 TestEmbeddedMemoryConcurrent
50 17 TestEmbeddedCloseGuardsAndEpics
50 17 TestEmbeddedCompact
50 17 TestEmbeddedGateConcurrent
50 17 TestEmbeddedListComments
100 17 TestEmbeddedReopen
50 18 TestEmbeddedContext
50 18 TestEmbeddedContributorCreate
50 18 TestEmbeddedImportClosedChildWhoseParentWasDeleted
50 18 TestEmbeddedReopen
50 18 TestEmbeddedStateConcurrent
100 18 TestEmbeddedLabelPropagateRename
100 18 TestEmbeddedPrune_protectsBeadCitedByCustomStatusBead
50 19 TestEmbeddedAdminBlocked
50 19 TestEmbeddedCreateRepoRelativeExistingWorkspaceUnaffected
50 19 TestEmbeddedDoltConcurrent
50 19 TestEmbeddedMaxRowsListBasic
50 19 TestEmbeddedPruneSafetyAndScope
100 19 TestEmbeddedLabelConcurrent
100 19 TestEmbeddedNewDoltStore_StrictReadOnlyRefusesWritesOnFreshDatabase
50 20 TestEmbeddedCreateStorageClassBatchAndMisc
50 20 TestEmbeddedDepListSingleIDWarnsOnDroppedExternalEdge
50 20 TestEmbeddedKVConcurrent
50 20 TestEmbeddedSetup
100 20 TestEmbeddedInitRoleRoutingRetainedFork
100 20 TestEmbeddedMigrateSchema_IdentityMismatchRefusesBeforeApplying
50 21 TestEmbeddedBackup
50 21 TestEmbeddedCreateCrossRepoUninit
50 21 TestEmbeddedDiffConcurrent
50 21 TestEmbeddedQuick
50 21 TestEmbeddedQuickstart
100 21 TestEmbeddedMaxRowsReady
100 21 TestEmbeddedMigratePersonal_movesIssues
50 22 TestEmbeddedAdminCompactReadOnlyAllowed
50 22 TestEmbeddedCreateRepoProxiedTargetError
50 22 TestEmbeddedDuplicateConcurrent
50 22 TestEmbeddedFlatten
50 22 TestEmbeddedTypesAgreeWithCreate
100 22 TestEmbeddedCount
100 22 TestEmbeddedIfRevisionCloseReplaysMoleculeAutoClose
50 23 TestEmbeddedExportConcurrent
50 23 TestEmbeddedHistory
50 23 TestEmbeddedMaxRowsGraph
50 23 TestEmbeddedSetupConcurrent
50 23 TestEmbeddedShip
100 23 TestEmbeddedCountConcurrent
100 23 TestEmbeddedExportExcludeOwner_flag
50 24 TestEmbeddedCloseBasic
50 24 TestEmbeddedImportUpsertAndPrefixSync
50 24 TestEmbeddedQuery
50 24 TestEmbeddedUpdateRoutedStoreCommitsTargetHead
100 24 TestEmbeddedEventsTailFollowReportsTruncationOnTheStream
100 24 TestEmbeddedUndeferConcurrent
100 24 TestEmbeddedWispGCProtectsActiveWisps
50 25 TestEmbeddedBackupConcurrent
50 25 TestEmbeddedCreateStorageClassBasic
50 25 TestEmbeddedFindDuplicatesConcurrent
50 25 TestEmbeddedInitGitBootstrapRouting
50 25 TestEmbeddedInitHooksRouting
100 25 TestEmbeddedDoltRemoteAdd_LocalOnly_FiresBeforeGuard
100 25 TestEmbeddedMaxRowsListBasic
100 25 TestEmbeddedRemovedBackendHealRejectionPerBackend
50 26 TestEmbeddedCreateCommitPending
50 26 TestEmbeddedInitC
50 26 TestEmbeddedRenamePrefixBasic
50 26 TestEmbeddedRoutedMutatingSiblingAssignTagDep
50 26 TestEmbeddedSupersedeConcurrent
100 26 TestEmbeddedDoltRemoteAdd_JSON_AllowGitOrigin_WarningOnStderr
100 26 TestEmbeddedExternalMutationPolicy
100 26 TestEmbeddedPersistentPreRunLogsAndSkipsIdentityCheckForFreshEmbeddedWorkspace
50 27 TestEmbeddedComments
50 27 TestEmbeddedMaxRowsReadyMerge
50 27 TestEmbeddedPrime
50 27 TestEmbeddedPruneDryRunAndFilters
50 27 TestEmbeddedReopenConcurrent
100 27 TestEmbeddedDoltRemoteAdd_GitOriginCollision_RefusalMessageCopy
100 27 TestEmbeddedNewDoltStoreFromConfig_DottedDBName
100 27 TestEmbeddedShipConcurrent
50 28 TestEmbeddedConfigNoWorkspaceStoreFreeCommands
50 28 TestEmbeddedEpicCloseEligibleReasonOutput
50 28 TestEmbeddedMigrate
50 28 TestEmbeddedStatus
50 28 TestEmbeddedSwarmConcurrent
100 28 TestEmbeddedDoltLocalOnly_RemoteAdd_RefusesExitOne
100 28 TestEmbeddedHistoryConcurrent
100 28 TestEmbeddedImportChunkedRealStoreResumeConverges
50 29 TestEmbeddedClaimPools
50 29 TestEmbeddedCreateGraphAndBulk
50 29 TestEmbeddedCreateJSONEchoesSubSecondTimestamps
50 29 TestEmbeddedHumanConcurrent
50 29 TestEmbeddedInitSelectedExcludeRouting
100 29 TestEmbeddedDoltLocalOnly_RemoteAdd_ErrorOnStderr
100 29 TestEmbeddedEpicCloseEligibleReasonFlag
100 29 TestEmbeddedImportChunkedNoReadyWindowWithReadinessEdgeIntoCycle
50 30 TestEmbeddedAutoImportFallback_ConflictSkip_EmptyDBImportsAll
50 30 TestEmbeddedDepConcurrent
50 30 TestEmbeddedExportFormats
50 30 TestEmbeddedReadyClaimConcurrent
50 30 TestEmbeddedStaleConcurrent
100 30 TestEmbeddedCloseGuardsAndEpics
100 30 TestEmbeddedDoltLocalOnly_Push_ExitsZeroWithMessage
100 30 TestEmbeddedImportChunkedCrossBucketBlocksEdgesResumeBackfills
50 31 TestEmbeddedAutoImportFallback_ConflictSkip_DoesNotClobber
50 31 TestEmbeddedAutoImportJSONLConcurrentWriter
50 31 TestEmbeddedDeferAutoWake
50 31 TestEmbeddedExternalMutationPolicy
50 31 TestEmbeddedShowConcurrent
100 31 TestEmbeddedDoltLocalOnly_ConfigRoundTrip
100 31 TestEmbeddedIfRevisionCloseWarnsOnForcedOpenChildren
100 31 TestEmbeddedInitSelectedExcludeRoutingForkInvalidQuiet
50 32 TestEmbeddedCreateCrossRepo
50 32 TestEmbeddedDuplicate
50 32 TestEmbeddedInitArtifactRouting
50 32 TestEmbeddedShowBasicsAndJSON
50 32 TestEmbeddedUpdateLifecycle
100 32 TestEmbeddedDoctorUnsupportedJSON
100 32 TestEmbeddedIfRevisionAdvertisedOnFourVerbs
100 32 TestEmbeddedListSearchAndOutputFormats
50 33 TestEmbeddedCreateConcurrent
50 33 TestEmbeddedCreateRepoRelativeUninitRefused
50 33 TestEmbeddedEpicCloseEligible
50 33 TestEmbeddedSearch
50 33 TestEmbeddedTodo
100 33 TestEmbeddedBootstrapJSONLAndGitOrigin
100 33 TestEmbeddedDeleteJournalsTheRequestingActor
100 33 TestEmbeddedExportExcludeOwner_verbose
50 34 TestEmbeddedCreateDryRunRepoDoesNotInitializeTarget
50 34 TestEmbeddedGateListScoped
50 34 TestEmbeddedLintConcurrent
50 34 TestEmbeddedPurgeWispsPlaneRetention
50 34 TestEmbeddedReady
100 34 TestEmbeddedCopyIssueRelations_preservesCommentWithTimestamp
100 34 TestEmbeddedEventsTailReportsTruncationToTheCLI
100 34 TestEmbeddedUnclaimBatchAndRefusals
100 34 TestEmbeddedWispGCPurgeClosedDoesNotCascadeIntoLiveSteps
50 35 TestEmbeddedCommentsCLIConcurrent
50 35 TestEmbeddedHooksConcurrent
50 35 TestEmbeddedLabelPropagateRename
50 35 TestEmbeddedListSearchAndOutput
50 35 TestEmbeddedSupersede
100 35 TestEmbeddedAutoPruneRespectsBdConfigSet
100 35 TestEmbeddedEventsReadNoticesADisabledJournal
100 35 TestEmbeddedGateCreateBeadRename
100 35 TestEmbeddedVersionedHistoryEnvIsProcessWideAndOnlyTurnsRecordingOn
50 36 TestEmbeddedDeferConcurrent
50 36 TestEmbeddedFederationPeers
50 36 TestEmbeddedFlattenConcurrent
50 36 TestEmbeddedStatusConcurrent
50 36 TestEmbeddedTodoConcurrent
100 36 TestEmbeddedAutoPruneLeavesAnUnboundedJournalAlone
100 36 TestEmbeddedDoltRemoteResetData_UnknownRemote
100 36 TestEmbeddedGateConcurrent
100 36 TestEmbeddedUnclaimIfAssigneeCLIDifferentSpelling
50 37 TestEmbeddedInfoSuppressGitHooks
50 37 TestEmbeddedInitB
50 37 TestEmbeddedQueryConcurrent
50 37 TestEmbeddedUndeferConcurrent
50 37 TestEmbeddedUpdateBatchAutoCommitDoesNotAdvanceHead
100 37 TestEmbeddedAutoPruneBoundsTheJournalAfterAMutatingCommand
100 37 TestEmbeddedDoltRemoteResetData_CloudRemoteRefused
100 37 TestEmbeddedMaxRowsDepTreeAndDuplicates
100 37 TestEmbeddedSpawnMolecule_SubstitutesTemplatedStepFields
50 38 TestEmbeddedBlocked
50 38 TestEmbeddedCreateCrossRepoWithParent
50 38 TestEmbeddedEpicConcurrent
50 38 TestEmbeddedHooks
50 38 TestEmbeddedUndefer
100 38 TestEmbeddedGraphConcurrent
100 38 TestEmbeddedRoutedCreateJournalsIntoTheTargetWorkspace
100 38 TestEmbeddedUnclaimIfAssigneeFlagValidation
50 39 TestEmbeddedBranchConcurrent
50 39 TestEmbeddedCountIncludeInfra
50 39 TestEmbeddedCreateWithGitRemote
50 39 TestEmbeddedDelete
50 39 TestEmbeddedUpdateFields
100 39 TestEmbeddedIfRevisionRejectsLabelAndParentEdits
100 39 TestEmbeddedMaxRowsGraph
100 39 TestEmbeddedNewDoltStoreFromConfig_NoMetadata
50 40 TestEmbeddedCountConcurrent
50 40 TestEmbeddedCountIncludeEphemeral
50 40 TestEmbeddedCreateFormCommitsLabelOnlyCreate
50 40 TestEmbeddedLabelEditReports
50 40 TestEmbeddedPreviewDoesNotConsumeVersionMarker
100 40 TestEmbeddedIfRevisionOutranksReassignFenceCLI
100 40 TestEmbeddedNewDoltStoreFromConfig_HyphenatedDBName
100 40 TestEmbeddedUpdateLifecycleClaimParentCommit
50 41 TestEmbeddedGateCreate
50 41 TestEmbeddedLabelAddRemove
50 41 TestEmbeddedLabelConcurrent
50 41 TestEmbeddedListConcurrent
50 41 TestEmbeddedTypesConcurrent
100 41 TestEmbeddedDuplicateConcurrent
100 41 TestEmbeddedVersionedHistoryFollowsTheStoreItWritesInto
50 42 TestEmbeddedImportFromSources
50 42 TestEmbeddedReadyConcurrent
50 42 TestEmbeddedRenamePrefixEdgeCases
50 42 TestEmbeddedRestore
50 42 TestEmbeddedSquashWispMoleculeClearsRootEphemeral
100 42 TestEmbeddedInitAForkAutoContributor
100 42 TestEmbeddedUpdateIfGuardsFlagValidation
50 43 TestEmbeddedFindDuplicates
50 43 TestEmbeddedGraph
50 43 TestEmbeddedImportPromotedWispRoundtrip
50 43 TestEmbeddedInfoConcurrent
50 43 TestEmbeddedQuickstartConcurrent
100 43 TestEmbeddedIfRevisionMultiIDRejected
100 43 TestEmbeddedInitExplicitBeadsDirIsAuthoritative
50 44 TestEmbeddedDoltRemoteAndPush
50 44 TestEmbeddedGraphConcurrent
50 44 TestEmbeddedImportConcurrent
50 44 TestEmbeddedInitRoleRouting
50 44 TestEmbeddedWhereConcurrent
100 44 TestEmbeddedIfRevisionComposesWithIfAssigneeIfStatus
100 44 TestEmbeddedStaleConcurrent
50 45 TestEmbeddedChildren
50 45 TestEmbeddedCompactConcurrent
50 45 TestEmbeddedMigrateConcurrent
50 45 TestEmbeddedShowDetailAndCurrent
50 45 TestEmbeddedVCStatusAndCommit
100 45 TestEmbeddedGraph
100 45 TestEmbeddedUpdateIfGuardsCLI
50 46 TestEmbeddedCompactMisdatedChild
50 46 TestEmbeddedCount
50 46 TestEmbeddedCreateDryRunDoesNotMigrate
50 46 TestEmbeddedFederationStatus
50 46 TestEmbeddedStaleLabelFilters
100 46 TestEmbeddedCloseAlreadyClosedClaimNextAndMolecule
100 46 TestEmbeddedIfRevisionMatchAndMismatch
50 47 TestEmbeddedBootstrap
50 47 TestEmbeddedBranch
50 47 TestEmbeddedContextConcurrent
50 47 TestEmbeddedLint
50 47 TestEmbeddedPurgeConcurrent
100 47 TestEmbeddedListSearchAndOutputSearchAndSort
100 47 TestEmbeddedRevisionRemintMatrix
50 48 TestEmbeddedCloseConcurrent
50 48 TestEmbeddedConfig
50 48 TestEmbeddedDepAndLinkBatchAutoCommitDoesNotAdvanceHead
50 48 TestEmbeddedOnboardConcurrent
50 48 TestEmbeddedQuietFlagSuppressesSuccessOutput
100 48 TestEmbeddedDeferConcurrent
100 48 TestEmbeddedReassignFenceCLI
50 49 TestEmbeddedDepNoCycleCheck
50 49 TestEmbeddedFederationConcurrent
50 49 TestEmbeddedMemory
50 49 TestEmbeddedOnboard
50 49 TestEmbeddedPurgeFiltered
100 49 TestEmbeddedBackupRestoreStrictReadonly
100 49 TestEmbeddedInitAPushConsentAndRemoteBootstrap
100 49 TestEmbeddedMigratePersonal_abortOnNoConfirm
50 50 TestEmbeddedAutoImportJSONLSkipsNonEmpty
50 50 TestEmbeddedExportFlags
50 50 TestEmbeddedPurgeBasics
50 50 TestEmbeddedRenamePrefixConcurrent
50 50 TestEmbeddedUnclaim
100 50 TestEmbeddedDiffConcurrent
100 50 TestEmbeddedDoltRemoteAdd_AllowGitOrigin_WarningOnStderr
100 50 TestEmbeddedImportChunkedWaitsForChildImportedLaterStaysBlocked
100 50 TestEmbeddedVersionOutputShape
100 51 TestEmbeddedDoltRemoteAdd_AllowGitOrigin_Exits0
100 51 TestEmbeddedHistoryAndShowAsOfReadDoltCommits
100 51 TestEmbeddedImportChunkedStaleRejectedRowKeepsDeferredDepsOut
100 51 TestEmbeddedInitGitBootstrapRoutingFreshQuiet
100 52 TestEmbeddedConfigSetOtherKeysSkipTheVersionedHistoryScan
100 52 TestEmbeddedDoltLocalOnly_Push_LocalStoreCopy
100 52 TestEmbeddedImportChunkedNoReadyWindowAtAnyFreezePoint
100 52 TestEmbeddedSwarmConcurrent
100 53 TestEmbeddedDoltLocalOnly_Push_JSON_DisabledStatus
100 53 TestEmbeddedIfRevisionOrdinaryCAS
100 53 TestEmbeddedImportChunkedMixedRegularWispCrossBucketEdgesWired
100 53 TestEmbeddedInitSelectedExcludeRoutingStealthDecoyQuiet
100 54 TestEmbeddedDiscoveryPinsEnvFileReadonly
100 54 TestEmbeddedFormatJSONAliasMatchesJSON
100 54 TestEmbeddedGraphModeDependencyWorkspaceUnaffected
100 54 TestEmbeddedInitAgentArtifactsGolden
100 54 TestEmbeddedSearchConcurrent
100 54 TestEmbeddedShowAsOfFailureExitCodes
100 55 TestEmbeddedDoltLocalOnly_Pull_JSON_DisabledStatus
100 55 TestEmbeddedImportChunkedConcurrentUpdateKeepsDeferredDeps
100 55 TestEmbeddedUndefer
100 55 TestEmbeddedVersionedHistorySwitchScansEveryRowNotOnePage
100 56 TestEmbeddedDepNoCycleCheck
100 56 TestEmbeddedDoltLocalOnly_Pull_ExitsZeroWithMessage
100 56 TestEmbeddedImportChunkedConcurrentUpdateKeepsBlockingDeps
100 56 TestEmbeddedVersionedHistorySwitchRoundTrip
100 57 TestEmbeddedDoltLocalOnly_DoltStatus_ShowsDisabled
100 57 TestEmbeddedIfRevisionDeletePreflightGoneIsPreconditionFailed
100 57 TestEmbeddedQueryConcurrent
100 57 TestEmbeddedVersionedHistorySwitchRefusesUnversionableMetadata
100 58 TestEmbeddedDepAAddRejectionsAndBulk
100 58 TestEmbeddedDoctorUnsupportedProse
100 58 TestEmbeddedIfRevisionCascadeDelete
100 58 TestEmbeddedVersionedHistorySwitchRefusesAnUnrecordableGateTimeout
100 59 TestEmbeddedDeferAutoWake
100 59 TestEmbeddedDoctorSupportedChecks
100 59 TestEmbeddedIdentityGateRendersSchemaSkewFromForwardDriftedWorkspace
100 59 TestEmbeddedVersionedHistorySetManyRefusesUnversionableMetadata
100 60 TestEmbeddedCommentsCLI
100 60 TestEmbeddedCorruptMetadataFailsLoudUntilRestored
100 60 TestEmbeddedExportExcludeOwner_config
100 60 TestEmbeddedRoutedWriteMissDoesNotCreateTargetDatabase
100 60 TestEmbeddedWispGCPurgeClosedStillPurgesFullyClosedMolecules
100 61 TestEmbeddedBootstrapCloneFailureScrubsCredentials
100 61 TestEmbeddedContributorRoutedWritesCommitInPlanning
100 61 TestEmbeddedEventsPruneHonorsRetainRowsFloorFromConfig
100 61 TestEmbeddedUpdateRoutedStoreCommitsTargetHead
100 61 TestEmbeddedVersionedHistoryConfigSetWritesTheStoreRow
100 62 TestEmbeddedAutoPruneDoesNotRunForReadOnlyCommands
100 62 TestEmbeddedDoltRemoteResetData_GitBacked
100 62 TestEmbeddedGateCheckSkipsTemplateGates
100 62 TestEmbeddedReadyBlockersAndLabels
100 62 TestEmbeddedUnclaimIfAssigneeCLI
100 63 TestEmbeddedDepAndLinkBatchAutoCommitDoesNotAdvanceHead
100 63 TestEmbeddedGateCheckLimitCountsOnlyLiveGates
100 63 TestEmbeddedIfRevisionDeletePreflightGoneParentIsPreconditionFailed
100 63 TestEmbeddedListPageEdges
100 64 TestEmbeddedAutoExportExcludeOwner_config
100 64 TestEmbeddedDoltRemoteAdd_NoGitOrigin_ProceedsNormally
100 64 TestEmbeddedGateWaiterCheckLifecycle
100 64 TestEmbeddedPromoteMovesAWispParent
100 64 TestEmbeddedSpawnMolecule_PreservesStepLabels
100 65 TestEmbeddedIfRevisionPreflightGoneIsPreconditionFailedOnEveryVerb
100 65 TestEmbeddedRemovedBackendHealRoundTrip
100 65 TestEmbeddedSupersede
100 66 TestEmbeddedCloseBasicIsolatedStores
100 66 TestEmbeddedShowCommentsTail
100 67 TestEmbeddedAdminCompactReadOnlyAllowed
100 67 TestEmbeddedAutoImportFallback_ConflictSkip_DoesNotClobber
100 67 TestEmbeddedBootstrapConcurrent
100 67 TestEmbeddedCountIncludeInfra
100 67 TestEmbeddedCreateCommitPending
100 67 TestEmbeddedCreateDryRunRepoDoesNotInitializeTarget
100 67 TestEmbeddedCreateRepoFromNonBeadsCwd
100 67 TestEmbeddedCreateRepoRelativeUninitRefused
100 67 TestEmbeddedHooks
100 67 TestEmbeddedOnboard
100 67 TestEmbeddedPrime
100 67 TestEmbeddedPromote
100 67 TestEmbeddedQuickstart
100 67 TestEmbeddedQuickstartConcurrent
100 67 TestEmbeddedWhere
100 67 TestEmbeddedWhereConcurrent
100 68 TestEmbeddedAutoImportFallback_ConflictSkip_EmptyDBImportsAll
100 68 TestEmbeddedBlocked
100 68 TestEmbeddedCompactConcurrent
100 68 TestEmbeddedContext
100 68 TestEmbeddedCreateJSONEchoesSubSecondTimestamps
100 68 TestEmbeddedDoltBlockedAndCommit
100 68 TestEmbeddedDoltConcurrent
100 68 TestEmbeddedInfo
100 68 TestEmbeddedInfoSuppressGitHooks
100 68 TestEmbeddedOrphans
100 68 TestEmbeddedRoutedMutatingSiblingDeleteCloseDelete
100 68 TestEmbeddedSetupConcurrent
100 68 TestEmbeddedTodoConcurrent
100 68 TestEmbeddedTypes
100 69 TestEmbeddedCompact
100 69 TestEmbeddedConfigValidateJSONNoWorkspaceWritesStdout
100 69 TestEmbeddedCreateConcurrent
100 69 TestEmbeddedDepBulkNoCycleCheckKeepsWholeGraphGate
100 69 TestEmbeddedDuplicatesSharedFixture
100 69 TestEmbeddedGateListScoped
100 69 TestEmbeddedGetDependencies
100 69 TestEmbeddedInfoConcurrent
100 69 TestEmbeddedRenamePrefixConcurrent
100 69 TestEmbeddedRoutedSiblingWritesCommitTargetHeadNote
100 69 TestEmbeddedTypesConcurrent
100 69 TestEmbeddedUpdateBatchAutoCommitDoesNotAdvanceHead
100 70 TestEmbeddedExportConcurrent
100 70 TestEmbeddedFlattenConcurrent
100 70 TestEmbeddedGCDryRunAndSkips
100 70 TestEmbeddedImportConcurrent
100 70 TestEmbeddedImportUpsertAndPrefixSync
100 70 TestEmbeddedLabelAddRemoveMultiAndDuplicate
100 70 TestEmbeddedMemory
100 70 TestEmbeddedMigrateConcurrent
100 70 TestEmbeddedPurgeConcurrent
100 70 TestEmbeddedRoutedMutatingSiblingAssignTagDepTag
100 71 TestEmbeddedCloseJSONReportsMoleculeAutoClose
100 71 TestEmbeddedInitRoleRoutingExplicitDefault
100 71 TestEmbeddedPrimeChangeDirRedirectNoticeFollowsTarget
100 71 TestEmbeddedRoutedCreateHonorsTheEnvOverrideOverTheTargetsConfig
100 71 TestEmbeddedSearchRoutesAgree
100 72 TestEmbeddedContributorCreateMultiple
100 72 TestEmbeddedCreateWithGitRemote
100 72 TestEmbeddedFederationConcurrent
100 72 TestEmbeddedGateCreateRepoErrorsList
100 72 TestEmbeddedHumanConcurrent
100 72 TestEmbeddedImportPromotedWispRoundtrip
100 72 TestEmbeddedPrimeChangeDirPrimesTarget
100 72 TestEmbeddedRoutedMutatingSiblingDeleteCloseClose
100 72 TestEmbeddedRoutedSiblingWritesCommitTargetHeadReopen
100 72 TestEmbeddedUpdateFieldsMappingAndRefs
100 73 TestEmbeddedCompactMisdatedChild
100 73 TestEmbeddedExportFlags
100 73 TestEmbeddedFederationPeers
100 73 TestEmbeddedGateCreateFlags
100 73 TestEmbeddedGateCreateReady
100 73 TestEmbeddedPrimeChangeDirDefaultTemplateMatchesTarget
100 73 TestEmbeddedQuickConcurrent
100 73 TestEmbeddedRenamePrefixBasic
100 73 TestEmbeddedRoutedMutatingSiblingAssignTagDepDepAdd
100 74 TestEmbeddedBlockedConcurrent
100 74 TestEmbeddedBranch
100 74 TestEmbeddedCountIncludeEphemeral
100 74 TestEmbeddedDepAddWispSource
100 74 TestEmbeddedMigrate
100 74 TestEmbeddedPrimeConcurrent
100 74 TestEmbeddedRestore
100 74 TestEmbeddedVCConcurrent
100 75 TestEmbeddedCommentsCLIConcurrent
100 75 TestEmbeddedContextConcurrent
100 75 TestEmbeddedFlatten
100 75 TestEmbeddedInitC
100 75 TestEmbeddedListComments
100 75 TestEmbeddedOpen_EmptyDatabaseRejected
100 75 TestEmbeddedReclaimRunsTheLeaseReclaimerRole
100 75 TestEmbeddedRoutedSiblingWritesCommitTargetHeadComment
100 75 TestEmbeddedVCStatusAndCommit
100 76 TestEmbeddedCloseAlreadyClosedContinue
100 76 TestEmbeddedCloseAlreadyClosedMultipleIDs
100 76 TestEmbeddedExportFormats
100 76 TestEmbeddedGCForceWithDecay
100 76 TestEmbeddedGCFullAndNoForcePrompts
100 76 TestEmbeddedInitAGitOriginRemote
100 76 TestEmbeddedLabelAddRemoveRemove
100 76 TestEmbeddedOnboardConcurrent
100 77 TestEmbeddedClaimPools
100 77 TestEmbeddedConfigNoWorkspaceStoreFreeCommands
100 77 TestEmbeddedCreateStorageClassConflicts
100 77 TestEmbeddedExternalCapabilityReadyAfterShip
100 77 TestEmbeddedHumanListStatsRespondDismiss
100 77 TestEmbeddedMemoryCorpusBudget
100 77 TestEmbeddedOrphansConcurrent
100 77 TestEmbeddedStatus
100 78 TestEmbeddedBranchConcurrent
100 78 TestEmbeddedComments
100 78 TestEmbeddedDepBRemove
100 78 TestEmbeddedLabelAddRemoveAdd
100 78 TestEmbeddedShip
100 78 TestEmbeddedUpdateFieldsNotesOverwrite
100 78 TestEmbeddedVCCommitVariantsAndMerge
100 78 TestEmbeddedVersionConcurrent
100 79 TestEmbeddedCreateCrossRepoUninit
100 79 TestEmbeddedDeleteJSONDependencyErrorContract
100 79 TestEmbeddedEpicCloseEligibleNotEligible
100 79 TestEmbeddedInitABasic
100 79 TestEmbeddedInitBRemoteSchemaAndCloneFailure
100 79 TestEmbeddedRenamePrefixEdgeCases
100 79 TestEmbeddedUpdateFieldsNotesClearAndDefer
100 80 TestEmbeddedCreateCrossRepoWithParent
100 80 TestEmbeddedCreateFormCommitsLabelOnlyCreate
100 80 TestEmbeddedCreateStorageClassBasic
100 80 TestEmbeddedRoutedMutatingSiblingAssignTagDepAssign
100 80 TestEmbeddedStatusConcurrent
100 80 TestEmbeddedSwarmCreate
100 80 TestEmbeddedSwarmValidate
100 81 TestEmbeddedAdminCompactTier2Honesty
100 81 TestEmbeddedBackup
100 81 TestEmbeddedDeleteForceAndBatch
100 81 TestEmbeddedGateCreateBeadCheck
100 81 TestEmbeddedGateList
100 81 TestEmbeddedRestoreConcurrent
100 81 TestEmbeddedStaleLabelFilters
100 81 TestEmbeddedStateConcurrent
100 82 TestEmbeddedCreateCrossRepoDryRunWithParent
100 82 TestEmbeddedDeleteBasic
100 82 TestEmbeddedDepBTreeAndCycles
100 82 TestEmbeddedDirectCommitPathsBatchAutoCommitDoesNotAdvanceHead
100 82 TestEmbeddedHooksConcurrent
100 82 TestEmbeddedImportFromSources
100 82 TestEmbeddedStale
100 83 TestEmbeddedAdminBlocked
100 83 TestEmbeddedAutoImportJSONLConcurrentWriter
100 83 TestEmbeddedInitBAutoCommitAndJSONLRemote
100 83 TestEmbeddedLabelEditReportsPrefix
100 83 TestEmbeddedMaxRowsDoctorAndConfig
100 83 TestEmbeddedPurgeFiltered
100 83 TestEmbeddedReadyConcurrent
100 84 TestEmbeddedDoltRemoteAdd_GitOriginCollision_Exits1
100 84 TestEmbeddedInitGitBootstrapRoutingDecoyInvalid
100 84 TestEmbeddedInitSelectedExcludeRoutingStealthInvalid
100 84 TestEmbeddedMigratePersonal_preservesComments
100 85 TestEmbeddedBootstrapExistingDryRunInit
100 85 TestEmbeddedChildrenBasicAndEmpty
100 85 TestEmbeddedCreateGraphAndBulk
100 85 TestEmbeddedCreateRepoRelativeExistingWorkspaceUnaffected
100 85 TestEmbeddedIfRevisionReopenGuardDirect
100 85 TestEmbeddedInitArtifactRouting
100 86 TestEmbeddedDoltRemoteAdd_DifferentURL_ProceedsNormally
100 86 TestEmbeddedExplicitHierarchicalParentEdges
100 86 TestEmbeddedInitHooksRouting
100 86 TestEmbeddedMigratePersonal_noopWhenEmpty
100 87 TestEmbeddedCreateRepoProxiedTargetError
100 87 TestEmbeddedGateInheritsDownParentChain
100 87 TestEmbeddedReadyClaimConcurrent
100 87 TestEmbeddedState
100 87 TestEmbeddedSupersedeConcurrent
100 87 TestEmbeddedSwarmCreateForceAndErrors
100 88 TestEmbeddedChangeDirOverridesInheritedBeadsDir
100 88 TestEmbeddedDepAAddAndList
100 88 TestEmbeddedKV
100 88 TestEmbeddedMaxRowsReadyMerge
100 88 TestEmbeddedPromoteCLI
100 88 TestEmbeddedUnclaimSuccess
100 89 TestEmbeddedBackupConcurrent
100 89 TestEmbeddedCreateDryRunDoesNotMigrate
100 89 TestEmbeddedGateShowResolve
100 89 TestEmbeddedInitBStealthAndForceReinit
100 89 TestEmbeddedLabelEditReportsNoop
100 89 TestEmbeddedShowBasicsAndJSON
100 90 TestEmbeddedAutoImportJSONLSkipsNonEmpty
100 90 TestEmbeddedConfig
100 90 TestEmbeddedFindDuplicatesConcurrent
100 90 TestEmbeddedLabelEditReportsListAndTemplate
100 90 TestEmbeddedLintConcurrent
100 90 TestEmbeddedUpdateLifecycleDefer
100 90 TestEmbeddedVersion
100 91 TestEmbeddedDuplicate
100 91 TestEmbeddedPreviewDoesNotConsumeVersionMarker
100 91 TestEmbeddedPruneDryRunAndFilters
100 91 TestEmbeddedReadOnlyCommandsSpawnNoGit
100 91 TestEmbeddedShowUnresolvableDeps
100 91 TestEmbeddedTypesAgreeWithCreate
100 92 TestEmbeddedAutoImportJSONLNoExplicitCommit
100 92 TestEmbeddedDefer
100 92 TestEmbeddedDepAAddTypesAndFlags
100 92 TestEmbeddedEpicCloseEligibleClosesEpics
100 92 TestEmbeddedSetup
100 92 TestEmbeddedSwarmStatusList
100 93 TestEmbeddedCreateStorageClassBatchAndMisc
100 93 TestEmbeddedDeletePreviewAndGuards
100 93 TestEmbeddedDepBRemoveOutputAndRelatesTo
100 93 TestEmbeddedListConcurrent
100 93 TestEmbeddedPruneSafetyAndScope
100 93 TestEmbeddedShowDetailAndCurrentFlags
100 94 TestEmbeddedCreateDryRunCrossRepoDoesNotMigrateTarget
100 94 TestEmbeddedDepListSingleIDWarnsOnDroppedExternalEdge
100 94 TestEmbeddedEpicCloseEligibleReasonOutput
100 94 TestEmbeddedFederationStatus
100 94 TestEmbeddedGCConcurrent
100 94 TestEmbeddedReadyDefaultJSONAndFlags
100 95 TestEmbeddedChildrenJSONAndAllStatuses
100 95 TestEmbeddedFindDuplicates
100 95 TestEmbeddedImportClosedChildWhoseParentWasDeleted
100 95 TestEmbeddedInitConcurrent
100 95 TestEmbeddedQuick
100 96 TestEmbeddedDiff
100 96 TestEmbeddedDuplicatesConcurrent
100 96 TestEmbeddedHistory
100 96 TestEmbeddedShowDetailAndCurrentHistoryAndCurrent
100 96 TestEmbeddedSquashWispMoleculeClearsRootEphemeral
100 97 TestEmbeddedDuplicatesOwnWorkspaces
100 97 TestEmbeddedHumanPositionalFileAndGuards
100 97 TestEmbeddedPurgeBasics
100 97 TestEmbeddedQuietFlagSuppressesSuccessOutput
100 97 TestEmbeddedSearchStatusLimitSortDatesMetadata
100 98 TestEmbeddedCloseBasicSharedStore
100 98 TestEmbeddedContributorCreateRoutesToPlanning
100 98 TestEmbeddedGCConditionalMatcherDecode
100 98 TestEmbeddedQuery
100 98 TestEmbeddedTodo
100 99 TestEmbeddedBlockedLabelFilters
100 99 TestEmbeddedDoltRemoteAndPush
100 99 TestEmbeddedEpicStatus
100 99 TestEmbeddedInitSelectedExcludeRoutingForkDecoyAuto
100 99 TestEmbeddedSearchQueryStatusAssigneeLabels
100 100 TestEmbeddedContributorCreateShowReadsRouted
100 100 TestEmbeddedCreateCrossRepo
100 100 TestEmbeddedInitGitBootstrapRoutingExistingExplicit
100 100 TestEmbeddedLint
100 100 TestEmbeddedPromoteCLIConcurrent

View file

@ -114,12 +114,12 @@
#
# Format: <total_shards> <shard_number> <top_level_test_name>
#
# 15-shard split for the Bazel-only embedded-Dolt storage tier
# 40-shard split for the Bazel-only embedded-Dolt storage tier
# (bazel-embedded in .github/workflows/bazel.yml), bin-packed
# longest-processing-time-first by measured wall-time from
# scripts/ci/embedded_storage_test_durations.json (see that file for provenance
# and its "relative weight, not absolute SLA" caveat).
# Regenerate with scripts/ci/gen_embedded_storage_shard_manifest.py 15
# Regenerate with scripts/ci/gen_embedded_storage_shard_manifest.py 40
# --weights=duration --write after adding or removing Test* functions in
# internal/storage/embeddeddolt/*_test.go. --write is incremental: it
# keeps every already-assigned test on its current shard and only places
@ -134,415 +134,475 @@
# This file is generated: notes added here are erased by the next
# regeneration. Add them to the generator or the durations file instead.
15 1 TestBatchApplyContract
15 1 TestEmbeddedClaimerClaimsAnUnassignedOpenIssueAndAnswersTheBareRow
15 1 TestEmbeddedClaimerReclaimsAcrossSpellingWithoutWriting
15 1 TestEmbeddedDependencyEditorWritesTheTargetIntoItsTypedColumn
15 1 TestEmbeddedIssueOperationsCreateParentChildRecomputesWaitsForClosure
15 1 TestEmbeddedIssueOperationsCreateUnderAParentMintsTheNextChildID
15 1 TestEmbeddedIssueOperationsUpdateClaimCASAndTransferMatrix
15 1 TestEmbeddedIssueOperationsUpdateClaimConflictCarriesTheLosingState
15 1 TestEmbeddedMergeAndSettleMetadataConflict
15 1 TestEmbeddedMergeAndSettleRefusesUnknownTable
15 1 TestEmbeddedMigration0047DelegatesToSplitTargetRepairAndConvergesThroughIgnoredChain
15 1 TestEmbeddedReaderListDefaultExclusionsAndTheirOverrides
15 1 TestEmbeddedReaderListSkipCountsDropsTheCardinalitiesAndNothingElse
15 1 TestEmbeddedReaderListWispTypeNarrowsTheAdmittedPlaneRatherThanAdmittingIt
15 1 TestEmbeddedReaderReadyBriefDropsTheFreeFormTextAndNothingElse
15 1 TestEmbeddedRelationsAnswersAWispTargetInTheOutDirection
15 1 TestEmbeddedRelationsLeavesAnExternalTargetOutOfTheAnswer
15 1 TestEmbeddedRoleFixtureKitHooksAreUsable
15 1 TestLifecycleCreateContract
15 1 TestMergeWithStrategy_OursKeepsLocal
40 1 TestLifecycleCloseReopenContract
15 2 TestActiveDatabaseSizeScopesToActiveEmbeddedDatabase
15 2 TestAdaptiveInsert_GciShape
15 2 TestCleanGitRemoteCacheGarbage
15 2 TestCreateBatchFastPathsMatchPerRow_Embedded
15 2 TestDepRekeyMarkerStillInIgnoredSeries
15 2 TestDescendantWalkReachesEveryTargetKindAndStopsOnCycles
15 2 TestDualWriteFixtureKitIsWired
15 2 TestEmbeddedDepRekeyAbortLeavesMarkerUnrecorded
15 2 TestEmbeddedDependencyEditorAppliesParentChildBeforeBlockingEdges
15 2 TestEmbeddedDependencyEditorRefusesACycleThroughAParentChildHop
15 2 TestEmbeddedDependencyEditorRefusesAGhostSource
15 2 TestEmbeddedDependencyEditorRoutesWispSourcedRemovalToTheWispPlane
15 2 TestEmbeddedDependencyEditorSkipPerEdgeCycleCheckDropsOnlyTheProbe
15 2 TestEmbeddedIssueOperationsCreateAggregatesRelations
15 2 TestEmbeddedIssueOperationsUpdateStatusCrossingSettlesDependers
15 2 TestEmbeddedOpenReadOnly_FreshDatabaseNoWrites
15 2 TestEmbeddedReaderListCountsAreBlocksOnlyWhereGetCountsEveryEdge
15 2 TestEmbeddedRelationsDirectionSelectsTheInverseGraph
15 2 TestEmbeddedRelationsLeavesTheCallersRequestAlone
15 2 TestEmbeddedRelationsOrdersNeighborsFromBothPlanesTogether
15 2 TestEmbeddedRemoteMigrateGate_BlocksReopen
15 2 TestGitRefPinsMatchDolt
15 2 TestHeartbeatRejectsWispEmbedded
15 2 TestHookFiringStoreCreateIssuesFiresDependencyUpdatesFromEmbeddedStore
15 2 TestIgnoredCursorHealRespectsOverrideUnderBroaderPattern
15 2 TestLeaseLifecycleEmbedded
15 2 TestLenientGateWarningBody_ShapedDecisions
15 2 TestReadEventsAutoPruneStateResolvesBothHalvesInOneQuery
15 2 TestSchemaAfterInit
15 2 TestStageAndCommitAfterSQLCommitResponseLossIsIndeterminateAndNotReplayed
15 2 TestWithPeerAuth_WarnsWhenStoredPeerSuppressesAmbientPassword
40 2 TestBatchApplyContract
15 3 TestEmbeddedBatchCloserDoesNotMutateTheCallerRequest
15 3 TestEmbeddedBatchCloserOutcomeSnapshotIsTheDocumentedShape
15 3 TestEmbeddedClaimerRefusesAWispIDAsNotFound
15 3 TestEmbeddedConfigCommitStagesConfig
15 3 TestEmbeddedDependencyEditorAcceptsBlockingAcrossIssueTypes
15 3 TestEmbeddedDependencyEditorRefusalWritesNothing
15 3 TestEmbeddedDependencyEditorRemoveIsIdempotent
15 3 TestEmbeddedDependencyEditorVersionsOnlyARealAddOrRemove
15 3 TestEmbeddedIgnoredMigration0023NoopsOnHealthyWorkspace
15 3 TestEmbeddedMergeAndSettleFKCascadeRepair
15 3 TestEmbeddedReaderListParentReachesEveryDescendantAndOnlyItsOwn
15 3 TestEmbeddedReaderListPriorityKeysetWalkOverAnOversizedEqualKeyRunLosesNothingAndRepeatsNothing
15 3 TestEmbeddedReaderReadyLimitBoundary
15 3 TestEmbeddedReadyClaimerFencesTheClaimByEveryLabelSetAndTheParentItWasGiven
15 3 TestEmbeddedRelationsRefusesATypeFilterOverTheColumnLength
15 3 TestEmbeddedRenameKeepsDependencyIDsDeterministic
15 3 TestEventsAutoPruneKeepsAnUnboundedJournalUnbounded
15 3 TestEventsJournalReadRefusesAnInteriorHole
15 3 TestForeignSkipDetailIsBounded
15 3 TestListWisps
15 3 TestMergeAndSettleWithStrategy_ResolvesDeclinedConflict
15 3 TestPushCommitsPendingChangesFirst
15 3 TestUpdateMergeOps_DoltEngine_TwoIssues
15 3 TestWithPeerAuth_RestoresAbsentEnv
40 3 TestActiveDatabaseSizeFailsForMissingEmbeddedDatabase
40 3 TestActiveDatabaseSizeScopesToActiveEmbeddedDatabase
40 3 TestBuildDSN_NoDatabase
40 3 TestBuildDSN_SpacesInPath
40 3 TestBuildDSN_WithDatabase
40 3 TestCleanGitRemoteCacheGarbage
40 3 TestCleanGitRemoteCacheGarbage_NoCacheDir
40 3 TestCleanGitRemoteCacheGarbage_Throttled
40 3 TestCommitAllOutOfBandChangeAndHonestNoOp
40 3 TestCreateBatchEquivalencePartsCoverEveryScenario
40 3 TestCreateBatchFastPathsMatchPerRowLarge_Embedded
40 3 TestCrossRecordInvariantContract
40 3 TestDepRekeyMarkerStillInIgnoredSeries
40 3 TestDoltCommitResponseLossIsIndeterminate
40 3 TestEmbeddedDependencyEditorRefusesADottedChildGatedOnItsOwnParent
40 3 TestEmbeddedDoltStoreIssueLifecycleBuildsOperations
40 3 TestEmbeddedDoltStoreIssueLifecycleRejectsNilStore
40 3 TestEmbeddedOpenReadOnly_FreshDatabaseNoWrites
40 3 TestEmbeddedSQLCommitResponseLossIsIndeterminate
40 3 TestEpochContract
40 3 TestExpectedRevisionContract
40 3 TestGitRefPinsMatchDolt
40 3 TestHasRepository
40 3 TestHelperProcess
40 3 TestLargeBatchApplyStatementCounts712_Embedded
40 3 TestLargeGraphCreateTiming_Embedded
40 3 TestLenientGateWarningBody_BluntRefusalKeepsSharedGuidance
40 3 TestLenientGateWarningBody_ShapedDecisions
40 3 TestLenientGateWarning_ComposedOutput
40 3 TestMain
40 3 TestPushCommitsPendingChangesFirst
40 3 TestRemoteEntryPointsUseVersionControlOps
40 3 TestRetentionContract
40 3 TestStageAndCommitAfterSQLCommitResponseLossIsIndeterminateAndNotReplayed
40 3 TestTransactionCleanupAfterSQLCommitIsIndeterminate
40 3 TestTransactionCleanupBeforeSQLCommitRemainsDefinite
40 3 TestUnknownProvenanceLeaseStaysReclaimable
15 4 TestCounterExcludeStatusAcceptsAWorkspaceCustomStatusWithoutIncludeInfra
15 4 TestEmbeddedBatchCloserSettlesTheDependersOfWhatItClosed
15 4 TestEmbeddedBlockedRecheckSettlesWhatTheWriteRecorded
15 4 TestEmbeddedClaimIssueWrapperClaimsTheWispPlane
15 4 TestEmbeddedClaimerRefusesABuiltInIneligibleStatusWithTheStateThatRefusedIt
15 4 TestEmbeddedClaimerTakesAPoolAssignedIssueButRefusesAForeignHolder
15 4 TestEmbeddedCommitToleratesNothingToCommit
15 4 TestEmbeddedDependencyEditorRecordsOneHistoryEntryForAMixedPlaneRequest
15 4 TestEmbeddedDependencyEditorRefusesBlockingEdgeAcrossItsOwnHierarchy
15 4 TestEmbeddedIgnoredMigration0023RepairsForkLineageJournalShape
15 4 TestEmbeddedReaderListEmptyPageIsWellFormed
15 4 TestEmbeddedRelationsFiltersByAnOpenTypeVocabulary
15 4 TestEmbeddedReopenIssueCategorySemantics
15 4 TestEmbeddedRoleFixtureKitCountHistoryMovesWithACommit
15 4 TestEventsAutoPruneThrottleSkipsTheSecondPass
15 4 TestEventsJournalRestartAndRetentionBoundary
15 4 TestIgnoredCursorHealNeverResurrectsRolledBackVersions
15 4 TestMain
15 4 TestMemoriesContract
15 4 TestMissingRequiredColumnRefusesAtOpen
15 4 TestPromoteClearsNoHistory
15 4 TestRemoteVerbPlainRemoteKeepsAmbientEnv
15 4 TestReopenIssue
15 4 TestWithPeerAuth
15 4 TestWithPeerAuth_EnvFallbackDoesNotObservePeerCredentials
40 4 TestBlockedListerContract
40 4 TestCreateBatchFastPathsMatchPerRowSmallDepAdd_Embedded
40 4 TestEmbeddedIssueOperationsUpdateLabelPatchOrdering
40 4 TestEmbeddedReaderGetMissIsNotFoundAndBackendFailureDoesNotDecay
40 4 TestEmbeddedReaderListFilterFamiliesNarrowToTheirRows
40 4 TestMergeAndSettleWithStrategy_EmptyStrategyMatchesMergeAndSettle
15 5 TestActiveDatabaseSizeFailsForMissingEmbeddedDatabase
15 5 TestAdaptiveRead_GciShape
15 5 TestBlockingAnnotatorContract
15 5 TestBootstrapperContract
15 5 TestBuildDSN_WithDatabase
15 5 TestCrossRecordInvariantContract
15 5 TestEmbeddedBatchCloserClaimNextSeesAnUnblockingFromItsOwnBatch
15 5 TestEmbeddedClaimerStampsStartedAtOnceAcrossTheTwoWritesItChoosesBetween
15 5 TestEmbeddedDepRekeyConvergesRenameChain
15 5 TestEmbeddedDependencyEditorAcceptsADiamond
15 5 TestEmbeddedDependencyEditorRemoveUnmarksItsSourceAndDescendants
15 5 TestEmbeddedDependencyEditorRetypeRefusalLeavesTheOriginalEdge
15 5 TestEmbeddedDependencyEditorValidationRefusalsWriteNothing
15 5 TestEmbeddedDoltStoreIssueLifecycleRejectsNilStore
15 5 TestEmbeddedIssueOperationsCreateReverseNonBlockingStagesConcreteTables
15 5 TestEmbeddedIssueOperationsPersistenceRollbackWispAndDetachedResults
15 5 TestEmbeddedMergeAndSettleReportsOperatorConflicts
15 5 TestEmbeddedMigration0058AddsOnlyMissingConstraintInMixedPopulation
15 5 TestEmbeddedReaderGetBriefDepsProjectsTheDependencyRows
15 5 TestEmbeddedReaderListKeysetPositionResumesTheCreatedDescIDAscOrder
15 5 TestEmbeddedReaderListMaxRowsIsHonored
15 5 TestEmbeddedReadyClaimerDoesNotMutateTheCallerRequest
15 5 TestEmbeddedRelationsAnswersInThePinnedOrder
15 5 TestEventsAutoPruneBoundsTheJournalToTheFloors
15 5 TestExpectedRevisionContract
15 5 TestGetDependentRecordsForIssuesEmbedded
15 5 TestLargeBatchApplyWallClock_Embedded
15 5 TestLargeGraphCreateTiming_Embedded
15 5 TestLenientGateWarningBody_BluntRefusalKeepsSharedGuidance
15 5 TestOpenReturnsCachedStore
15 5 TestPartitionWispIDs
15 5 TestRetentionContract
15 5 TestWithPeerAuth_KeyMismatchFailsClosed
40 5 TestEmbeddedClaimerRefusesIncompleteRequestsAndAnAbsentIDWithoutTouchingState
40 5 TestEmbeddedIssueOperationsCloseAndReopenAWisp
40 5 TestEmbeddedReaderListKeysetPositionResumesTheCreatedDescIDAscOrder
40 5 TestRecordVersionKeepsSubSecondChangeAt
40 5 TestWithPeerAuth
15 6 TestCreateIssuesRejectStaleUpserts
15 6 TestDecryptPassword_KeyMismatchNamesTheLocalKey
15 6 TestEmbeddedBatchCloserPerItemRefusalIsAResultAndSurvivorsCommit
15 6 TestEmbeddedBatchCloserWispItemClosesAndEarnsTheClaim
15 6 TestEmbeddedBatchCreateFirstVersionCarriesCreationTimeEdges
15 6 TestEmbeddedDependencyEditorClosedChildAddSatisfiesAnAnyChildrenGate
15 6 TestEmbeddedDependencyEditorMaintainsBlockedStateAcrossPlanes
15 6 TestEmbeddedDependencyEditorSameTypeReAddWithChangedMetadataMintsOneVersion
15 6 TestEmbeddedIssueOperationsUpdateClaimPatchAppliesAfterClaim
15 6 TestEmbeddedReaderGetMissIsNotFoundAndBackendFailureDoesNotDecay
15 6 TestEmbeddedReadyClaimerClaimsTheFrontRowAndReturnsThePostClaimState
15 6 TestEmbeddedReadyClaimerRecordsOneHistoryEntryForAWin
15 6 TestEmbeddedSyncCommitsConfigBeforeMerge
15 6 TestGetIssue
15 6 TestHeartbeatMatchesActorAcrossSpellingEmbedded
15 6 TestHistory_NullTextColumns
15 6 TestIsBlockedBatchEmbedded
15 6 TestLargeBatchApplyStatementCounts356_Embedded
15 6 TestRemoteGitDataRefOnEngine
15 6 TestRenameLabel
15 6 TestRenameLabelMintsOneVersionPerTouchedBead
15 6 TestRunInTransactionPostCommitStageFailureIsIndeterminate
15 6 TestStatsReporterContract
15 6 TestWithPeerAuth_ConcurrentPeersDoNotMixCredentials
15 6 TestWithPeerAuth_RestoresEnvWhenCallbackFails
40 6 TestCreateBatchFastPathsMatchPerRowApplyWaitsFor_Embedded
40 6 TestEmbeddedMergeAndSettleFKCascadeRepair
40 6 TestEmbeddedMergeAndSettleSkipsNonMemoryConfigConflict
40 6 TestEmbeddedReaderListKeysetPositionNarrowsWithoutReplacingTheOtherPredicates
40 6 TestEmbeddedRelationsAnswersAWispTargetInTheOutDirection
40 6 TestPromoteStillWorksWithCollisionGuard
40 6 TestSearchWithMissingWispPlaneTables
40 6 TestVersionedHistoryKeepsNumbersTheStoreDistinguishesApart
15 7 TestCommitAllOutOfBandChangeAndHonestNoOp
15 7 TestConcurrencyMultiProcess
15 7 TestConcurrentOpenReturnsCached
15 7 TestDualWriteContractFlagOff
15 7 TestEmbeddedBatchCloserClaimNextIsNilWhenTheFrontIsEmpty
15 7 TestEmbeddedBatchCloserForceBypassesOnlyClosePolicy
15 7 TestEmbeddedDepRekeyRepairsHalfRekeyedDuplicateEdge
15 7 TestEmbeddedDependencyEditorGateScopeFollowsTheEdgeType
15 7 TestEmbeddedDependencyEditorRoutesWispSourcedEdgeToTheWispPlane
15 7 TestEmbeddedDependencyEditorSameTypeReAddWithIdenticalMetadataIsANoOp
15 7 TestEmbeddedIssueOperationsUpdateStatusCrossingSettlesAConditionalBlocksDepender
15 7 TestEmbeddedMigration0057ConvertsTextEventsColumnsToLongtext
15 7 TestEmbeddedReaderListReadyFlagAnswersTheBlockerAwareSet
15 7 TestEmbeddedReaderReadyDefaultTypeExclusionsYieldToAnExplicitType
15 7 TestEmbeddedReaderReadySortPoliciesOrderTheSameRows
15 7 TestEmbeddedReadyClaimerAnswersTheQuestionReaderReadyLists
15 7 TestEmbeddedReadyClaimerLeasesADurableWinButNotAnEphemeralOne
15 7 TestEventsJournalAccessor
15 7 TestHistoryPresenceContract
15 7 TestJournalContract
15 7 TestLifecycleCloseReopenContract
15 7 TestReclaimAnyReplicaOverride
15 7 TestTreeWalkerContract
15 7 TestWithPeerAuth_DivergedRemoteURLFailsClosed
40 7 TestConcurrencyMultiProcess
40 7 TestEmbeddedBatchCloserRecordsOneHistoryEntryForWhatLanded
40 7 TestEmbeddedDependencyEditorAcceptsAnExternalTarget
40 7 TestEmbeddedDependencyEditorRelatesToAddLeavesItsSourceUnblocked
40 7 TestEmbeddedIssueOperationsUpdateMetadataReplaceClearsAndValidates
40 7 TestEmbeddedLenientOpenWarning_DataBehind
40 7 TestEmbeddedRelationsLeavesTheCallersRequestAlone
40 7 TestLoseVersionLeavesTheEpochTablesCommitted
40 7 TestMergeAndSettleWithStrategy_ResolvesDeclinedConflict
15 8 TestAddLabel
15 8 TestBuildDSN_NoDatabase
15 8 TestCleanGitRemoteCacheGarbage_NoCacheDir
15 8 TestCreateBatchFastPathsMatchPerRowLarge_Embedded
15 8 TestDoltCommitResponseLossIsIndeterminate
15 8 TestEmbeddedBatchCloserClaimNextHydratesWhenSomethingClosed
15 8 TestEmbeddedBatchCloserClaimNextIsNilWhenNothingClosed
15 8 TestEmbeddedBatchCloserOutcomesMirrorItemsIndexForIndex
15 8 TestEmbeddedClaimerRefusalMessagesCarryTheirFragments
15 8 TestEmbeddedDependencyEditorAddMarksItsSourceInTheSameVerb
15 8 TestEmbeddedDependencyEditorRecordsOneHistoryEntryPerLandedRequest
15 8 TestEmbeddedGuardedUpdateMintsOnceAfterItsPatches
15 8 TestEmbeddedIssueOperationsUpdateFoldsMetadataIntoOneEvent
15 8 TestEmbeddedIssueOperationsUpdateStampsStartedAtOnceOnTheFirstInProgress
15 8 TestEmbeddedLenientOpenWarning_DataBehind
15 8 TestEmbeddedMergeAndSettleSkipsNonMemoryConfigConflict
15 8 TestEmbeddedMigrateRepairedDependenciesIDColumnCommitsAtomicallyWithVersion53_4690
15 8 TestEmbeddedMigration0058HealsAlreadyAffectedDatabase
15 8 TestEmbeddedOpenReadOnly_SkipsGateAndMigrations
15 8 TestEmbeddedReaderListMaxRowsBoundaryIsLimitPlusOffset
15 8 TestEmbeddedReaderListReadyFlagCarriesTheAssigneeAndPriorityFilters
15 8 TestEmbeddedReaderReadyDeferredAndEphemeralGates
15 8 TestEmbeddedReaderReadyPageIsThePrefixOfTheUnboundedAnswerCountsIncluded
15 8 TestEmbeddedRelationsResolvesTheAnchorIDExactly
15 8 TestEmbeddedSQLCommitResponseLossIsIndeterminate
15 8 TestGetReadyWorkIncludeEphemeralAppliesWispFilters
15 8 TestHasRepository
15 8 TestLenientGateWarning_ComposedOutput
15 8 TestMergeAndSettleWithStrategy_EmptyStrategyMatchesMergeAndSettle
15 8 TestReclaimExpiredLeaseSurvivesRestartEmbedded
15 8 TestRemoteVerbPlainRemoteWithoutAuthPresentsNone
15 8 TestTransactionCleanupAfterSQLCommitIsIndeterminate
40 8 TestDeleterContract
40 8 TestEmbeddedDependencyEditorRoutesWispSourcedRemovalToTheWispPlane
40 8 TestEmbeddedMergeAndSettleDirtyWorkingSetSurvivesRefusedMerge
40 8 TestEmbeddedMintLeavesUpdatedAtWhereHistoryOffDoes
40 8 TestEmbeddedReaderGetBriefDepsProjectsTheDependencyRows
40 8 TestEmbeddedRelationsOrdersNeighborsFromBothPlanesTogether
40 8 TestEmbeddedReopenIssueCategorySemantics
40 8 TestGetIssueCommentsPageEmbedded
40 8 TestListWisps
15 9 TestBatchGetterContract
15 9 TestCommenterContract
15 9 TestEmbeddedBatchCloserBackendFailureReturnsNoOutcomes
15 9 TestEmbeddedClaimerReclaimsItsOwnInProgressIssueWithoutWriting
15 9 TestEmbeddedClaimerRefusesIncompleteRequestsAndAnAbsentIDWithoutTouchingState
15 9 TestEmbeddedDependencyEditorMixedBatchWritesBothPlanes
15 9 TestEmbeddedDependencyEditorRefusesBlockingEdgeAcrossAWispHierarchy
15 9 TestEmbeddedDependencyEditorRelatesToAddLeavesItsSourceUnblocked
15 9 TestEmbeddedDependencyEditorRemovesOnlyTheNamedEdge
15 9 TestEmbeddedIgnoredMigration0019CreatesEventsForFreshClones
15 9 TestEmbeddedIssueOperationsCloseAndReopenAWisp
15 9 TestEmbeddedIssueOperationsUpdateClosedFieldsMatchClose
15 9 TestEmbeddedIssueOperationsUpdateInvalidIssueTypePreservesValidationSentinel
15 9 TestEmbeddedOpenForRemoteSync_OtherRefusalsStayFatal
15 9 TestEmbeddedReaderListLimitBoundaryUnderASortTheDatabaseCanExpress
15 9 TestEmbeddedReaderListReadyFlagRefusesAFilterItCannotCarry
15 9 TestEmbeddedReaderOffsetSkipsTheRowsBeforeThePage
15 9 TestEmbeddedReaderReadyPageWiderThanTheHydrationBatchIsStillThatPrefix
15 9 TestEventsSinceEmbedded
15 9 TestIgnoredCursorHealConvergesFromEveryCrashState
15 9 TestLegacyTrackedIgnoredCursorUnwedgesPull
15 9 TestMetadataCASContract
15 9 TestPromoteStillWorksWithCollisionGuard
15 9 TestReadyWorkWithMissingDeferredParentTables
15 9 TestUpdateMergeOps_DoltEngine
40 9 TestBumpEpochCarryingNeitherCarriesNorServesARowFromAFutureEpoch
40 9 TestEmbeddedDependencyEditorRefusesCrossPlaneCycle
40 9 TestEmbeddedDependencyEditorSameTypeReAddIsIdempotent
40 9 TestEmbeddedDependencyEditorSnapshotsTheRequest
40 9 TestEmbeddedMigration0058AddsOnlyMissingConstraintInMixedPopulation
40 9 TestEmbeddedReaderReadyPageWiderThanTheHydrationBatchIsStillThatPrefix
40 9 TestEmbeddedReadyClaimerHydratesOnlyItsBlocksEdgesIntoTheCardinalities
40 9 TestGetReadyWorkIncludeEphemeralExcludesNonReadyWisps
40 9 TestPristineEmbeddedDoltFixtureRelocatesPrefixes
40 9 TestUpdateMergeOps_DoltEngine
15 10 TestBuildDSN_SpacesInPath
15 10 TestCleanGitRemoteCacheGarbage_Throttled
15 10 TestCreateIssues
15 10 TestCreateRejectsCrossTableIDCollision
15 10 TestDeleterContract
15 10 TestEmbeddedBatchCloserAllIdempotentBatchLandsNothing
15 10 TestEmbeddedDepRekeyMergesFreshDuplicateEdges
15 10 TestEmbeddedDependencyEditorAddedEchoesTheRequestOrder
15 10 TestEmbeddedDependencyEditorRefusesCrossPlaneCycle
15 10 TestEmbeddedDoltStoreIssueLifecycleBuildsOperations
15 10 TestEmbeddedIgnoredMigration0023NoopsWithoutItsTables
15 10 TestEmbeddedIssueOperationsCreateClosedDerivesTheClosedStamp
15 10 TestEmbeddedIssueOperationsCreateEmptyIDPreservesParentAndReverseDependencies
15 10 TestEmbeddedIssueOperationsUpdateParentStagesBlockedStateAndRollsBackFailure
15 10 TestEmbeddedIssueOperationsUpdateRawMetadataTakesTheFunnelsValueShapes
15 10 TestEmbeddedMigrateStepCommitLeavesUntouchedUserDirt_4566
15 10 TestEmbeddedReaderDoesNotMutateTheCallerRequest
15 10 TestEmbeddedReadyClaimerHydratesOnlyItsBlocksEdgesIntoTheCardinalities
15 10 TestEmbeddedReadyClaimerSkipsIneligibleFrontRows
15 10 TestEmbeddedRecomputeAllBlockedDirtyGraphIsTyped
15 10 TestEmbeddedTempRebuildIntermediatesNeverReachHistory
15 10 TestEmbeddedTransactionWispLifecyclePersistsDurableDependent
15 10 TestEpochContract
15 10 TestGetReadyWorkMoleculeFilter
15 10 TestGraphWalkPlansHonorJoinHints
15 10 TestHelperProcess
15 10 TestIgnoredCursorHealResumeRespectsOperatorOverride
15 10 TestJournalShapeProbeOncePerOpen
15 10 TestReclaimRefusesForeignReplicaLease
15 10 TestRemoteEntryPointsUseVersionControlOps
15 10 TestTransactionCleanupBeforeSQLCommitRemainsDefinite
15 10 TestVersionReconcilerContract
15 10 TestWithPeerAuth_MissingRemoteFailsClosed
40 10 TestEmbeddedClaimerStampsStartedAtOnceAcrossTheTwoWritesItChoosesBetween
40 10 TestEmbeddedDependencyEditorRemoveIsIdempotent
40 10 TestEmbeddedIssueOperationsUpdateClaimCASAndTransferMatrix
40 10 TestEmbeddedReaderGetResolvesTheExactIDAcrossBothPlanes
40 10 TestEmbeddedReaderReadyEphemeralPageKeepsBothPlanesCountsAtItsBoundary
40 10 TestGraphCounterContract
40 10 TestIgnoredCursorHealRespectsOperatorOverride
40 10 TestRunInTransactionPostCommitStageFailureIsIndeterminate
40 10 TestVersionedHistoryOffMatchesPreStackGolden_Embedded
40 10 TestWithPeerAuth_WarnsWhenStoredPeerSuppressesAmbientPasswordAmbient
15 11 TestCycleDetectorContract
15 11 TestEmbeddedBatchCloserClaimFilterValueFailureIsARequestValidationFailure
15 11 TestEmbeddedBatchCloserIdempotentRecloseIsAPerItemSuccess
15 11 TestEmbeddedCheckedWrappersRouteTheirPreconditions
15 11 TestEmbeddedDependencyEditorAcceptsAForeignRepoTarget
15 11 TestEmbeddedDependencyEditorMixedBatchRefusalRollsBackBothPlanes
15 11 TestEmbeddedDependencyEditorRefusesASamePlaneEdgeClosingACrossPlaneCycle
15 11 TestEmbeddedDependencyEditorSameTypeReAddIsIdempotent
15 11 TestEmbeddedGetMergeBlockersOnAQuietStore
15 11 TestEmbeddedIssueOperationsCreateRoutesInfraTypesToWisps
15 11 TestEmbeddedIssueOperationsUpdateNotesConflictPreservesValidationSentinel
15 11 TestEmbeddedLenientOpenWarning_OtherRefusalsKeepBluntGuidance
15 11 TestEmbeddedPre0058RepairMarchesDriftedWispDependenciesToFinalShape
15 11 TestEmbeddedReaderGetDetailShapeMatchesTheSeededIssue
15 11 TestEmbeddedReaderListNaturalNumericIDSortTrimsAfterTheFetch
15 11 TestEmbeddedReopenCustomDoneFallsBackWhenNormalizedTableMissing
15 11 TestEmbeddedTransactionStandaloneWispMutationDoesNotPublishUnrelatedDurableChanges
15 11 TestGetDependentRecordsEmbedded
15 11 TestGetLabels
15 11 TestGetNextChildID
15 11 TestGraphCounterContract
15 11 TestLargeBatchApplyStatementCountsClassic40_Embedded
15 11 TestPristineEmbeddedDoltFixtureRelocatesPrefixes
15 11 TestReadyWorkPageTotal
15 11 TestUpdateIssueType
40 11 TestABumpUnderOneStoreIDMovesTheEpochSeenThroughEveryStoreID
40 11 TestEmbeddedBatchCreateFirstVersionCarriesCreationTimeEdges
40 11 TestEmbeddedClaimerRefusalMessagesCarryTheirFragments
40 11 TestEmbeddedGuardedUpdateMintsOnceAfterItsPatches
40 11 TestEmbeddedMergeAndSettleRefusesUnknownTable
40 11 TestEmbeddedReaderListMaxRowsBoundaryIsLimitPlusOffset
40 11 TestEmbeddedReadyClaimerRecordsOneHistoryEntryForAWin
40 11 TestEventsJournal_ActorMatrixOnEmbedded
40 11 TestMemoriesContract
40 11 TestWithPeerAuth_WarnsWhenStoredPeerSuppressesAmbientPasswordStored
15 12 TestBatchCreatorContract
15 12 TestDualWriteContract
15 12 TestEmbeddedClaimerTakesAnOpenIssueTheActorAlreadyHolds
15 12 TestEmbeddedDependencyEditorAttributesItsEventsToTheActor
15 12 TestEmbeddedDependencyEditorSnapshotsTheRequest
15 12 TestEmbeddedIgnoredSeriesConvergesWithFreshInitShape
15 12 TestEmbeddedIssueOperationsCreateWithDependenciesSettlesInTheCreatingTransaction
15 12 TestEmbeddedIssueOperationsRequestValuesAreNotMutated
15 12 TestEmbeddedMergeAndSettleMemoryConfigConflict
15 12 TestEmbeddedReaderGetOptionalRowListsAreOffByDefault
15 12 TestEmbeddedReaderGetResolvesTheExactIDAcrossBothPlanes
15 12 TestEmbeddedReaderReadyEphemeralPageKeepsBothPlanesCountsAtItsBoundary
15 12 TestEmbeddedReaderReadyParentScopesToItsTransitiveDescendants
15 12 TestEmbeddedReadyClaimerLeavesEphemeralRowsOutOfTheDefaultReadySet
15 12 TestEmbeddedRecomputeAllBlockedWiring
15 12 TestEmbeddedRelationsResolvesAWispAnchor
15 12 TestEmbeddedTransactionSameStatusDoesNotPublishUnrelatedDurableChanges
15 12 TestLargeBatchApplyStatementCounts712_Embedded
15 12 TestLifecycleUpdateContract
15 12 TestPreviewStoreRefusesLocalMetadataWrite
15 12 TestQuerierContract
15 12 TestReadyWorkPageTotalFilterMatrix
15 12 TestRemoteVerbsPresentStoredPeerCredentials
15 12 TestSearchWithMissingWispPlaneTables
15 12 TestWorkspaceConfigContract
40 12 TestCounterExcludeStatusAcceptsAWorkspaceCustomStatusWithoutIncludeInfra
40 12 TestEmbeddedClaimerAcceptsAConfiguredActiveStatusAndRefusesAConfiguredWipOne
40 12 TestEmbeddedClaimerRefusesAWispIDAsNotFound
40 12 TestEmbeddedDependencyEditorVersionsOnlyARealAddOrRemove
40 12 TestEmbeddedIgnoredMigration0023RepairsForkLineageJournalShape
40 12 TestEmbeddedIssueOperationsCreateUnderAParentMintsTheNextChildID
40 12 TestEmbeddedReadyClaimerAnswersTheQuestionReaderReadyLists
40 12 TestHistoryPresenceContract
40 12 TestLifecycleUpdateContract
40 12 TestReaderListExcludeStatusAcceptsAWorkspaceCustomStatus
15 13 TestCountsIncludeWispDependencies
15 13 TestDecryptPassword_ShortCiphertextClassifiesAsKeyMismatch
15 13 TestEmbeddedBatchCloserDurableHistoryNeverNamesAWisp
15 13 TestEmbeddedBatchCloserRequestValidationReturnsZeroResultAndChangesNothing
15 13 TestEmbeddedClaimerGrantsALiveLeaseOnTheRowItWonAndLeavesARefusedOneAlone
15 13 TestEmbeddedDependencyEditorRefusesAMissingLocalTarget
15 13 TestEmbeddedIssueOperationsUpdateAllScalarAndPointerFieldsReportChanged
15 13 TestEmbeddedIssueOperationsUpdateClaimHonorsConfiguredActiveStatuses
15 13 TestEmbeddedIssueOperationsUpdateMetadataReplaceClearsAndValidates
15 13 TestEmbeddedIssueOperationsUpdateRefusesATypeOutsideTheWorkspaceVocabulary
15 13 TestEmbeddedIssueOperationsUpdateWritesEveryScalarPatchField
15 13 TestEmbeddedMigrateConvergesUnderConcurrentInterruptedRetries_4566
15 13 TestEmbeddedMigration0058CleansOrphanedAndInvalidWispDependenciesRowsBeforeAddingConstraints
15 13 TestEmbeddedMigration0062FlipsEventsToIgnoredPlane
15 13 TestEmbeddedReaderListIncludeEphemeralMergesThePlanesIntoOneOrder
15 13 TestEmbeddedReaderListKeysetPositionNarrowsWithoutReplacingTheOtherPredicates
15 13 TestEmbeddedReaderListRejectsATypeOutsideTheWorkspaceVocabulary
15 13 TestEmbeddedReaderListStatusAcceptsACommaSeparatedORSet
15 13 TestEmbeddedReaderReadySetOwnsItsStatusPinnedAndTemplateDecisions
15 13 TestEmbeddedRelationsRefusesAnUnusableTypeFilter
15 13 TestEmbeddedRelationsRefusesTheZeroDirection
15 13 TestEventsJournal_EmbeddedConcurrentGaplessNoDup
15 13 TestExternalCapabilityBlocksEmbeddedReadyAndAppearsInTree
15 13 TestIgnoredCursorHealRespectsOperatorOverride
15 13 TestLegacyTrackedIgnoredCursorHealsOnOpen
15 13 TestSweeperContract
40 13 TestEmbeddedDepRekeyConvergesRenameChain
40 13 TestEmbeddedDependencyEditorAppliesParentChildBeforeBlockingEdges
40 13 TestEmbeddedDependencyEditorRefusesAGhostSource
40 13 TestEmbeddedIssueOperationsCreateParentChildRecomputesWaitsForClosure
40 13 TestEmbeddedIssueOperationsUpdateClaimPatchAppliesAfterClaim
40 13 TestEmbeddedIssueOperationsUpdateFoldsMetadataIntoOneEvent
40 13 TestEmbeddedPre0058RepairMarchesDriftedWispDependenciesToFinalShape
40 13 TestEmbeddedRelationsDirectionSelectsTheInverseGraph
40 13 TestGraphWalkPlansHonorJoinHints
15 14 TestAddDependency
15 14 TestCounterContract
15 14 TestCountsWithMissingWispPlaneTables
15 14 TestEmbeddedBlockedRecheckFailureKeepsTheWrite
15 14 TestEmbeddedDepRekeyRefusesToWriteIntoDirtyDependencies
15 14 TestEmbeddedDependencyEditorRecordsNoHistoryForAnAllEphemeralRequest
15 14 TestEmbeddedDirtyTablesGate_BlocksReopenThenWorkingSetReconcileRecovers
15 14 TestEmbeddedEveryAcceptedLifecycleMutationMintsOneVersion
15 14 TestEmbeddedIssueOperationsClaimLeavesBlockedStateAlone
15 14 TestEmbeddedIssueOperationsUpdateIssuePlaneOnlyRefusesWisps
15 14 TestEmbeddedIssueOperationsUpdateLabelPatchValueRules
15 14 TestEmbeddedMergeAndSettleDirtyWorkingSetSurvivesRefusedMerge
15 14 TestEmbeddedOpenForReadOnlyCommand_LenientGate
15 14 TestEmbeddedReaderListBriefDropsTheFreeFormTextAndNothingElse
15 14 TestEmbeddedReaderListKeysetWalkOverAnOversizedGroupLosesNothingAndRepeatsNothing
15 14 TestEmbeddedReadyClaimerClaimsAnEphemeralRowTheFilterAdmits
15 14 TestEmbeddedReadyClaimerRejectsLimitOffsetBriefAndEmptyActor
15 14 TestEventsJournalPruneWhenEveryRowIsOlderThanTheCutoff
15 14 TestMergeWithStrategy_TheirsResolvesAndCommits
15 14 TestMerge_NoStrategyStillErrorsWithEscapeHatchHint
15 14 TestOpenAfterCloseCreatesNewStore
15 14 TestOpenDifferentDirsReturnsDifferentStores
15 14 TestPruneEventsBatchDeletesTheLowestSeqsOnly
15 14 TestReadyCounterContract
15 14 TestUnknownProvenanceLeaseStaysReclaimable
40 14 TestBatchCreatorContract
40 14 TestBlockingAnnotatorContract
40 14 TestCountsIncludeWispDependencies
40 14 TestEmbeddedIssueOperationsPersistenceRollbackWispAndDetachedResults
40 14 TestEmbeddedOpenForRemoteSync_DataBehind
40 14 TestEmbeddedReaderOffsetSkipsTheRowsBeforeThePage
40 14 TestEmbeddedReaderReadyDefaultTypeExclusionsYieldToAnExplicitType
40 14 TestEmbeddedReadyClaimerClaimsTheFrontRowAndReturnsThePostClaimState
40 14 TestEmbeddedReadyClaimerDoesNotMutateTheCallerRequest
40 14 TestHeartbeatIssueCommitsARefusalOnlyWhenItReadTheIssueEmbedded
40 14 TestHistory_NullTextColumns
15 15 TestCreateIssue
15 15 TestEdgeReaderContract
15 15 TestEmbeddedBatchCloserAllRefusedBatchRecordsNoHistory
15 15 TestEmbeddedBatchCloserDuplicateItemRecloseAtItsOwnIndex
15 15 TestEmbeddedBatchCloserRecordsOneHistoryEntryForWhatLanded
15 15 TestEmbeddedBlockedRecheckRecordsUnblockingWrites
15 15 TestEmbeddedClaimerAcceptsAConfiguredActiveStatusAndRefusesAConfiguredWipOne
15 15 TestEmbeddedDependencyEditorAcceptsATypeOutsideTheConstants
15 15 TestEmbeddedDependencyEditorAcceptsAnExternalTarget
15 15 TestEmbeddedDependencyEditorRefusesSelfDependencyWithTheProbeSkipped
15 15 TestEmbeddedDependencyEditorRepeatsWithinOneRequestCollapse
15 15 TestEmbeddedIssueOperationsUpdateLabelPatchOrdering
15 15 TestEmbeddedMigrateSelfHealsAfterMidPassFault_4566
15 15 TestEmbeddedMoveIssuePersistenceEphemeralNoHistorySmoke
15 15 TestEmbeddedOpenForRemoteSync_DataBehind
15 15 TestEmbeddedReadyClaimerEmptyFrontIsNormal
15 15 TestEmbeddedRelationsSeparatesNoNeighborsFromNoSuchIssue
15 15 TestEmbeddedTransactionStandaloneWispLifecyclePersistsWithoutDoltCommit
15 15 TestEventsJournalPruneNeverSplitsASkewedPair
15 15 TestEventsJournal_ActorMatrixOnEmbedded
15 15 TestGetIssueCommentsPageEmbedded
15 15 TestGetReadyWorkIncludeEphemeralExcludesNonReadyWisps
15 15 TestIgnoredCursorHealIsIdempotent
15 15 TestReadyWorkStatementBudget
15 15 TestReleaserContract
40 15 TestCreateIssuesRejectStaleUpserts
40 15 TestDecryptPassword_ShortCiphertextClassifiesAsKeyMismatch
40 15 TestEmbeddedGetMergeBlockersOnAQuietStore
40 15 TestEmbeddedIgnoredMigration0023NoopsWithoutItsTables
40 15 TestEmbeddedIssueOperationsRequestValuesAreNotMutated
40 15 TestEmbeddedReaderReadyBriefDropsTheFreeFormTextAndNothingElse
40 15 TestEmbeddedRelationsFiltersByAnOpenTypeVocabulary
40 15 TestGetIssue
40 15 TestLegacyTrackedIgnoredCursorHealsOnOpen
40 15 TestMoleculeContract
40 15 TestReadyWorkPageTotalFilterMatrix
40 16 TestDescendantWalkReachesEveryTargetKindAndStopsOnCycles
40 16 TestEmbeddedDependencyEditorAddedEchoesTheRequestOrder
40 16 TestEmbeddedDependencyEditorRemovesOnlyTheNamedEdge
40 16 TestEmbeddedReaderDoesNotMutateTheCallerRequest
40 16 TestEmbeddedReaderListLimitBoundaryUnderASortTheDatabaseCanExpress
40 16 TestEmbeddedRenameKeepsDependencyIDsDeterministic
40 16 TestExternalCapabilityBlocksEmbeddedReadyAndAppearsInTree
40 16 TestGetReadyWorkIncludeEphemeralAppliesWispFilters
40 16 TestMergeWithStrategy_OursKeepsLocal
40 16 TestWithPeerAuth_DivergedRemoteURLFailsClosed
40 17 TestAddDependency
40 17 TestEmbeddedBatchCloserWispItemClosesAndEarnsTheClaim
40 17 TestEmbeddedDependencyEditorSameTypeReAddWithChangedThreadMintsOneVersion
40 17 TestEmbeddedIssueOperationsUpdateIssuePlaneOnlyRefusesWisps
40 17 TestEmbeddedIssueOperationsUpdateStatusCrossingSettlesAConditionalBlocksDepender
40 17 TestEmbeddedReaderListRejectsATypeOutsideTheWorkspaceVocabulary
40 17 TestEmbeddedReadyClaimerLeasesADurableWinButNotAnEphemeralOne
40 17 TestHeartbeatMatchesActorAcrossSpellingEmbedded
40 17 TestStatsReporterContract
40 17 TestVersionReconcilerContract
40 18 TestCreateBatchParticipationGeneration
40 18 TestEmbeddedBatchCloserIdempotentRecloseIsAPerItemSuccess
40 18 TestEmbeddedDependencyEditorMixedBatchWritesBothPlanes
40 18 TestEmbeddedIssueOperationsUpdateRawMetadataTakesTheFunnelsValueShapes
40 18 TestEmbeddedMergeAndSettleMemoryConfigConflict
40 18 TestEmbeddedReaderListIncludeEphemeralMergesThePlanesIntoOneOrder
40 18 TestEmbeddedReaderListParentReachesEveryDescendantAndOnlyItsOwn
40 18 TestMetadataCASContract
40 18 TestOpenDifferentDirsReturnsDifferentStores
40 18 TestPromoteClearsNoHistory
40 18 TestRemoteVerbPlainRemoteWithoutAuthPresentsNone
40 19 TestEmbeddedDependencyEditorRetypeRefusalLeavesTheOriginalEdge
40 19 TestEmbeddedIssueOperationsUpdateInvalidIssueTypePreservesValidationSentinel
40 19 TestEmbeddedMigration0062FlipsEventsToIgnoredPlane
40 19 TestEmbeddedReaderListMaxRowsIsHonored
40 19 TestEmbeddedRelationsAnswersInThePinnedOrder
40 19 TestIgnoredCursorHealConvergesFromEveryCrashState
40 19 TestOpenAfterCloseCreatesNewStore
40 19 TestOpenReturnsCachedStore
40 19 TestParticipationGenerationFixtureKitIsWired
40 19 TestRemoteVerbsPresentStoredPeerCredentials
40 19 TestRenameLabelMintsOneVersionPerTouchedBead
40 20 TestBumpEpochCarryingCarriesOnlyTheLineageHoldingTheNewestRow
40 20 TestCreateIssue
40 20 TestEmbeddedCheckedWrappersRouteTheirPreconditions
40 20 TestEmbeddedIssueOperationsCreateRoutesInfraTypesToWisps
40 20 TestEmbeddedMigrateStepCommitLeavesUntouchedUserDirt_4566
40 20 TestEmbeddedOpenReadOnly_SkipsGateAndMigrations
40 20 TestEmbeddedReadyClaimerClaimsAnEphemeralRowTheFilterAdmits
40 20 TestEventsJournalRestartAndRetentionBoundary
40 20 TestForeignSkipDetailIsBounded
40 20 TestHeartbeatRejectsWispEmbedded
40 20 TestIgnoredCursorHealNeverResurrectsRolledBackVersions
40 21 TestBumpEpochCarryingCarriesTheLiveRowsOfEveryStoreInTheDatabase
40 21 TestCreateRejectsCrossTableIDCollision
40 21 TestEmbeddedBatchCloserItemsAnswerToTheCloseGuards
40 21 TestEmbeddedDependencyEditorAcceptsATypeOutsideTheConstants
40 21 TestEmbeddedIssueOperationsUpdateParentStagesBlockedStateAndRollsBackFailure
40 21 TestEmbeddedMigration0047DelegatesToSplitTargetRepairAndConvergesThroughIgnoredChain
40 21 TestEmbeddedRelationsLeavesAnExternalTargetOutOfTheAnswer
40 21 TestEmbeddedRemoteMigrateGate_BlocksReopen
40 21 TestEmbeddedRoleFixtureKitCountHistoryMovesWithACommit
40 21 TestEmbeddedTransactionStandaloneWispLifecyclePersistsWithoutDoltCommit
40 21 TestLargeBatchApplyWallClock_Embedded
40 22 TestEdgeReaderContract
40 22 TestEmbeddedDepRekeyAbortLeavesMarkerUnrecorded
40 22 TestEmbeddedDepRekeyRefusesToWriteIntoDirtyDependencies
40 22 TestEmbeddedDependencyEditorRefusesSelfDependencyWithTheProbeSkipped
40 22 TestEmbeddedReaderListStatusAcceptsACommaSeparatedORSet
40 22 TestEmbeddedReaderReadyLimitBoundary
40 22 TestEventsAutoPruneKeepsAnUnboundedJournalUnbounded
40 22 TestEventsJournalPruneNeverSplitsASkewedPair
40 22 TestLargeBatchApplyStatementCounts356_Embedded
40 22 TestLeaseLifecycleEmbedded
40 22 TestPolicyBlockingAnnotatorForeignOpensAreSublinear
40 23 TestAsOfReadContract
40 23 TestEmbeddedBatchCloserBackendFailureReturnsNoOutcomes
40 23 TestEmbeddedBatchCloserClaimNextHydratesWhenSomethingClosed
40 23 TestEmbeddedDependencyEditorAcceptsBlockingAcrossIssueTypes
40 23 TestEmbeddedDependencyEditorRecordsNoHistoryForAnAllEphemeralRequest
40 23 TestEmbeddedMigrateConvergesUnderConcurrentInterruptedRetries_4566
40 23 TestEmbeddedReaderListEmptyPageIsWellFormed
40 23 TestEmbeddedReadyClaimerFencesTheClaimByEveryLabelSetAndTheParentItWasGiven
40 23 TestEmbeddedRoleFixtureKitHooksAreUsable
40 23 TestEventsAutoPruneBoundsTheJournalToTheFloors
40 23 TestJournalContract
40 24 TestBootstrapperContract
40 24 TestEmbeddedBatchCloserOutcomesMirrorItemsIndexForIndex
40 24 TestEmbeddedClaimerReclaimsAcrossSpellingWithoutWriting
40 24 TestEmbeddedConfigCommitStagesConfig
40 24 TestEmbeddedIgnoredSeriesConvergesWithFreshInitShape
40 24 TestEmbeddedIssueOperationsCreateWithDependenciesSettlesInTheCreatingTransaction
40 24 TestEmbeddedMigrateSelfHealsAfterMidPassFault_4566
40 24 TestEmbeddedReaderListQueryMatchesTheTitleOrTheID
40 24 TestEmbeddedReaderListWispTypeNarrowsTheAdmittedPlaneRatherThanAdmittingIt
40 24 TestIgnoredCursorHealResumeRespectsOperatorOverride
40 24 TestLargeBatchApplyStatementCountsClassic40_Embedded
40 24 TestReopenIssue
40 25 TestBatchGetterContract
40 25 TestDatabases
40 25 TestDualWriteFixtureKitIsWired
40 25 TestEmbeddedBatchCloserClaimNextIsNilWhenNothingClosed
40 25 TestEmbeddedIssueOperationsUpdateClaimHonorsConfiguredActiveStatuses
40 25 TestEmbeddedReadyClaimerLeavesEphemeralRowsOutOfTheDefaultReadySet
40 25 TestEmbeddedReadyClaimerRejectsLimitOffsetBriefAndEmptyActor
40 25 TestGetDependentRecordsForIssuesEmbedded
40 25 TestHeartbeaterContract
40 25 TestIgnoredCursorHealIsIdempotent
40 25 TestIsBlockedBatchEmbedded
40 25 TestReadyWorkPageTotal
40 25 TestWithPeerAuth_RestoresAbsentEnv
40 26 TestEmbeddedIssueOperationsCreateClosedDerivesTheClosedStamp
40 26 TestEmbeddedMigration0058CleansOrphanedAndInvalidWispDependenciesRowsBeforeAddingConstraints
40 26 TestEmbeddedOpenForReadOnlyCommand_LenientGate
40 26 TestEmbeddedReaderListReadyFlagCarriesTheAssigneeAndPriorityFilters
40 26 TestEmbeddedReaderReadyParentScopesToItsTransitiveDescendants
40 26 TestEmbeddedReadyClaimerSkipsIneligibleFrontRows
40 26 TestEmbeddedRecomputeAllBlockedDirtyGraphIsTyped
40 26 TestEmbeddedRelationsRefusesTheZeroDirection
40 26 TestHookFiringStoreCreateIssuesFiresDependencyUpdatesFromEmbeddedStore
40 26 TestReclaimAnyReplicaOverride
40 26 TestWithPeerAuth_EnvFallbackDoesNotObservePeerCredentials
40 27 TestEmbeddedBatchCloserDurableHistoryNeverNamesAWisp
40 27 TestEmbeddedBatchCloserRequestValidationReturnsZeroResultAndChangesNothing
40 27 TestEmbeddedDependencyEditorAcceptsADiamond
40 27 TestEmbeddedDependencyEditorAddMarksItsSourceInTheSameVerb
40 27 TestEmbeddedMigration0058HealsAlreadyAffectedDatabase
40 27 TestEmbeddedReaderGetOptionalRowListsAreOffByDefault
40 27 TestEmbeddedRelationsRefusesATypeFilterOverTheColumnLength
40 27 TestEventsJournalReadRefusesAnInteriorHole
40 27 TestPartitionWispIDs
40 27 TestRemoteGitDataRefOnEngine
40 27 TestSweeperContract
40 28 TestBumpEpochCarryingDoesNotCarryALostLineage
40 28 TestEmbeddedBatchCloserForceBypassesOnlyClosePolicy
40 28 TestEmbeddedBatchCloserSettlesTheDependersOfWhatItClosed
40 28 TestEmbeddedClaimerClaimsAnUnassignedOpenIssueAndAnswersTheBareRow
40 28 TestEmbeddedClaimerReclaimsItsOwnInProgressIssueWithoutWriting
40 28 TestEmbeddedClaimerTakesAPoolAssignedIssueButRefusesAForeignHolder
40 28 TestEmbeddedIssueOperationsUpdateLabelPatchValueRules
40 28 TestEmbeddedIssueOperationsUpdateRefusesATypeOutsideTheWorkspaceVocabulary
40 28 TestEmbeddedReaderListReadyFlagAnswersTheBlockerAwareSet
40 28 TestRenameLabel
40 28 TestUpdateIssueType
40 28 TestWithPeerAuth_RestoresEnvWhenCallbackFails
40 29 TestEmbeddedBatchCloserClaimFilterValueFailureIsARequestValidationFailure
40 29 TestEmbeddedBatchCloserClaimNextIsNilWhenTheFrontIsEmpty
40 29 TestEmbeddedDepRekeyMergesFreshDuplicateEdges
40 29 TestEmbeddedDependencyEditorRecordsOneHistoryEntryPerLandedRequest
40 29 TestEmbeddedMergeAndSettleMetadataConflict
40 29 TestEmbeddedReaderListDefaultExclusionsAndTheirOverrides
40 29 TestEmbeddedReaderListTimeBoundsAreStrictAndWholeSecond
40 29 TestEmbeddedReaderReadySetOwnsItsStatusPinnedAndTemplateDecisions
40 29 TestEmbeddedTransactionSameStatusDoesNotPublishUnrelatedDurableChanges
40 29 TestEventsJournalAccessor
40 29 TestLeaseReclaimerContract
40 29 TestLifecycleCreateContract
40 30 TestCounterContract
40 30 TestCycleDetectorContract
40 30 TestEmbeddedClaimerTakesAnOpenIssueTheActorAlreadyHolds
40 30 TestEmbeddedCommitToleratesNothingToCommit
40 30 TestEmbeddedEveryAcceptedLifecycleMutationMintsOneVersion
40 30 TestEmbeddedIssueOperationsUpdateClaimConflictCarriesTheLosingState
40 30 TestEmbeddedIssueOperationsUpdateStampsStartedAtOnceOnTheFirstInProgress
40 30 TestEmbeddedReaderReadySortPoliciesOrderTheSameRows
40 30 TestEmbeddedTransactionStandaloneWispMutationDoesNotPublishUnrelatedDurableChanges
40 30 TestLegacyTrackedIgnoredCursorUnwedgesPull
40 30 TestUpdateMergeOps_DoltEngine_TwoIssues
40 31 TestBumpEpochCarryingWritesOneCarryRowPerLiveIDNamingTheLineageRoot
40 31 TestDualWriteContract
40 31 TestEmbeddedDependencyEditorAcceptsAForeignRepoTarget
40 31 TestEmbeddedDependencyEditorMaintainsBlockedStateAcrossPlanes
40 31 TestEmbeddedDependencyEditorWritesTheTargetIntoItsTypedColumn
40 31 TestEmbeddedMigrateConsent_BehindAndDirtyWorkingSetReconcileRecovers
40 31 TestEmbeddedReaderListPriorityKeysetWalkOverAnOversizedEqualKeyRunLosesNothingAndRepeatsNothing
40 31 TestEmbeddedTransactionWispLifecyclePersistsDurableDependent
40 31 TestEventsSinceEmbedded
40 31 TestGetLabels
40 31 TestReadyCounterContract
40 31 TestWithPeerAuth_KeyMismatchFailsClosed
40 32 TestCurrentAddressForNeverReseedsAnAbsentStoreEpochRow
40 32 TestEmbeddedClaimerGrantsALiveLeaseOnTheRowItWonAndLeavesARefusedOneAlone
40 32 TestEmbeddedDependencyEditorRefusesAMissingLocalTarget
40 32 TestEmbeddedDirtyTablesGate_BlocksReopenThenWorkingSetReconcileRecovers
40 32 TestEmbeddedIgnoredMigration0019CreatesEventsForFreshClones
40 32 TestEmbeddedIssueOperationsCreateReverseNonBlockingStagesConcreteTables
40 32 TestEmbeddedReadyClaimerEmptyFrontIsNormal
40 32 TestEmbeddedRecomputeAllBlockedWiring
40 32 TestEventsJournal_EmbeddedConcurrentGaplessNoDup
40 32 TestGetNextChildID
40 32 TestRemoteVerbPlainRemoteKeepsAmbientEnv
40 32 TestWithPeerAuth_MissingRemoteFailsClosed
40 33 TestEmbeddedBatchCloserDuplicateItemRecloseAtItsOwnIndex
40 33 TestEmbeddedDependencyEditorClosedChildAddSatisfiesAnAnyChildrenGate
40 33 TestEmbeddedDependencyEditorValidationRefusalsWriteNothing
40 33 TestEmbeddedIgnoredMigration0023NoopsOnHealthyWorkspace
40 33 TestEmbeddedMoveIssuePersistenceEphemeralNoHistorySmoke
40 33 TestEmbeddedRelationsResolvesTheAnchorIDExactly
40 33 TestEmbeddedSyncCommitsConfigBeforeMerge
40 33 TestEventsAutoPruneThrottleSkipsTheSecondPass
40 33 TestFirstMintLeavesTheEpochTablesCommitted
40 33 TestGetDependentRecordsEmbedded
40 33 TestPruneEventsBatchDeletesTheLowestSeqsOnly
40 33 TestTreeWalkerContract
40 34 TestAddLabel
40 34 TestBumpEpochCarryingLeavesTheEpochTablesCommitted
40 34 TestDecryptPassword_KeyMismatchNamesTheLocalKey
40 34 TestEmbeddedBlockedRecheckRecordsUnblockingWrites
40 34 TestEmbeddedDependencyEditorAttributesItsEventsToTheActor
40 34 TestEmbeddedDependencyEditorSameTypeReAddWithIdenticalMetadataIsANoOp
40 34 TestEmbeddedIssueOperationsCreateAggregatesRelations
40 34 TestEmbeddedReaderReadyDeferredAndEphemeralGates
40 34 TestEmbeddedReaderReadyPageIsThePrefixOfTheUnboundedAnswerCountsIncluded
40 34 TestMergeWithStrategy_TheirsResolvesAndCommits
40 34 TestQuerierContract
40 34 TestReadyWorkStatementBudget
40 35 TestEmbeddedBatchCloserAllIdempotentBatchLandsNothing
40 35 TestEmbeddedClaimIssueWrapperClaimsTheWispPlane
40 35 TestEmbeddedDependencyEditorGateScopeFollowsTheEdgeType
40 35 TestEmbeddedDependencyEditorRefusesASamePlaneEdgeClosingACrossPlaneCycle
40 35 TestEmbeddedDependencyEditorRepeatsWithinOneRequestCollapse
40 35 TestEmbeddedIssueOperationsUpdateAllScalarAndPointerFieldsReportChanged
40 35 TestEmbeddedIssueOperationsUpdateWritesEveryScalarPatchField
40 35 TestMerge_NoStrategyStillErrorsWithEscapeHatchHint
40 35 TestReadEventsAutoPruneStateResolvesBothHalvesInOneQuery
40 35 TestReadyWorkWithMissingDeferredParentTables
40 35 TestReclaimExpiredLeaseSurvivesRestartEmbedded
40 36 TestBumpEpochCarryingFailsAndRollsBackWhenARowAlreadyExistsAtTheNewEpoch
40 36 TestCommenterContract
40 36 TestConcurrentOpenReturnsCached
40 36 TestEmbeddedBatchCloserAllRefusedBatchRecordsNoHistory
40 36 TestEmbeddedDependencyEditorRefusalWritesNothing
40 36 TestEmbeddedDependencyEditorSkipPerEdgeCycleCheckDropsOnlyTheProbe
40 36 TestEmbeddedMigration0057ConvertsTextEventsColumnsToLongtext
40 36 TestEmbeddedReaderListReadyFlagRefusesAFilterItCannotCarry
40 36 TestEmbeddedRelationsRefusesAnUnusableTypeFilter
40 36 TestGetReadyWorkMoleculeFilter
40 36 TestReleaserContract
40 36 TestSchemaAfterInit
40 37 TestEmbeddedBatchCloserClaimNextSeesAnUnblockingFromItsOwnBatch
40 37 TestEmbeddedBatchCloserOutcomeSnapshotIsTheDocumentedShape
40 37 TestEmbeddedDependencyEditorRecordsOneHistoryEntryForAMixedPlaneRequest
40 37 TestEmbeddedDependencyEditorRefusesACycleThroughAParentChildHop
40 37 TestEmbeddedDependencyEditorRemoveUnmarksItsSourceAndDescendants
40 37 TestEmbeddedIssueOperationsCreateEmptyIDPreservesParentAndReverseDependencies
40 37 TestEmbeddedLenientOpenWarning_OtherRefusalsKeepBluntGuidance
40 37 TestEmbeddedMergeAndSettleReportsOperatorConflicts
40 37 TestEmbeddedReaderListBriefDropsTheFreeFormTextAndNothingElse
40 37 TestEmbeddedReaderListNaturalNumericIDSortTrimsAfterTheFetch
40 37 TestEpochWritesReportAnUnpublishedCommitAsIndeterminate
40 37 TestIgnoredCursorHealRespectsOverrideUnderBroaderPattern
40 38 TestCreateIssues
40 38 TestEmbeddedClaimerRefusesABuiltInIneligibleStatusWithTheStateThatRefusedIt
40 38 TestEmbeddedDependencyEditorRefusesBlockingEdgeAcrossItsOwnHierarchy
40 38 TestEmbeddedIssueOperationsUpdateClosedFieldsMatchClose
40 38 TestEmbeddedIssueOperationsUpdateNotesConflictPreservesValidationSentinel
40 38 TestEmbeddedReaderGetDetailShapeMatchesTheSeededIssue
40 38 TestEmbeddedReaderListCountsAreBlocksOnlyWhereGetCountsEveryEdge
40 38 TestEmbeddedReaderListKeysetWalkOverAnOversizedGroupLosesNothingAndRepeatsNothing
40 38 TestEmbeddedTempRebuildIntermediatesNeverReachHistory
40 38 TestEventsJournalPruneWhenEveryRowIsOlderThanTheCutoff
40 38 TestPolicyBlockingAnnotatorBatchEqualsPerItem
40 38 TestWithPeerAuth_ConcurrentPeersDoNotMixCredentials
40 39 TestDualWriteContractFlagOff
40 39 TestEmbeddedBatchCloserPerItemRefusalIsAResultAndSurvivorsCommit
40 39 TestEmbeddedBlockedRecheckFailureKeepsTheWrite
40 39 TestEmbeddedDependencyEditorMixedBatchRefusalRollsBackBothPlanes
40 39 TestEmbeddedIssueOperationsClaimLeavesBlockedStateAlone
40 39 TestEmbeddedMigrateRepairedDependenciesIDColumnCommitsAtomicallyWithVersion53_4690
40 39 TestEmbeddedReaderListSkipCountsDropsTheCardinalitiesAndNothingElse
40 39 TestEmbeddedRelationsResolvesAWispAnchor
40 39 TestParticipationGenerationFence
40 39 TestPreviewStoreRefusesLocalMetadataWrite
40 39 TestReclaimRefusesForeignReplicaLease
40 39 TestWorkspaceConfigContract
40 40 TestCountsWithMissingWispPlaneTables
40 40 TestEmbeddedBatchCloserDoesNotMutateTheCallerRequest
40 40 TestEmbeddedBlockedRecheckSettlesWhatTheWriteRecorded
40 40 TestEmbeddedDepRekeyRepairsHalfRekeyedDuplicateEdge
40 40 TestEmbeddedDependencyEditorRefusesBlockingEdgeAcrossAWispHierarchy
40 40 TestEmbeddedDependencyEditorRoutesWispSourcedEdgeToTheWispPlane
40 40 TestEmbeddedDependencyEditorSameTypeReAddWithChangedMetadataMintsOneVersion
40 40 TestEmbeddedIssueOperationsUpdateStatusCrossingSettlesDependers
40 40 TestEmbeddedOpenForRemoteSync_OtherRefusalsStayFatal
40 40 TestEmbeddedRelationsSeparatesNoNeighborsFromNoSuchIssue
40 40 TestEmbeddedReopenCustomDoneFallsBackWhenNormalizedTableMissing

View file

@ -3,7 +3,7 @@
#
# Usage: embedded-test-shard.sh <shard_number> <total_shards>
#
# Discovers all TestEmbedded* top-level functions from cmd/bd/*_embedded_test.go.
# Discovers all TestEmbedded* top-level functions in cmd/bd/*_test.go.
# Tests listed in embedded-cmd-test-shards.txt for the requested shard count use
# that committed assignment; newly-added tests fall back to hash(name) % total.
# Runs the matching subset using the pre-built test binary at
@ -33,8 +33,12 @@ fi
SHARD_INDEX=$(( SHARD_NUMBER - 1 ))
MANIFEST="${BEADS_TEST_SHARD_MANIFEST:-.github/scripts/embedded-cmd-test-shards.txt}"
# Discover all top-level TestEmbedded* functions.
ALL_TESTS=$(grep -rh '^func TestEmbedded' cmd/bd/*_embedded_test.go \
# Discover all top-level TestEmbedded* functions across every cmd/bd test
# file, by name rather than by file glob (as proxied-test-shard.sh does): a
# test gated on BEADS_TEST_EMBEDDED_DOLT runs in this lane or in none, wherever
# it lives. scripts/embedded_lane_coverage_test.go fails on a gated test this
# selection misses.
ALL_TESTS=$(grep -rh '^func TestEmbedded' cmd/bd/*_test.go \
| sed 's/func \(TestEmbedded[A-Za-z0-9_]*\).*/\1/' \
| sort -u)

View file

@ -2,233 +2,12 @@
#
# Format: <total_shards> <shard_number> <top_level_test_name>
#
# 15-shard split, bin-packed longest-processing-time-first by
# estimated cost (bd-init count; per-init migration chains dominate), as of
# the test set that existed when this block was last generated.
# Regenerating it (scripts/ci/gen_proxied_shard_manifest.py 15 --write) is
# deliberately NOT part of normal maintenance: this block is frozen for
# pr-risk.yml's/main.yml's legacy fork/push jobs (see engdocs/TESTING.md),
# so every TestProxiedServer*/TestServerMode* function added since it was
# last generated hash-distributes via proxied-test-shard.sh (cksum(name) %
# total) instead of being explicitly listed here. Only reweight it on
# purpose, and expect the shard assignments below to change substantially
# if you do (a fresh run packs every currently-discovered test, not just
# the ones already listed here).
#
# Deliberate exception (Oct 2026): four tests that had been hash-placed
# onto the two shards closest to the 15m -test.timeout are pinned here
# by hand, onto shards whose measured CI job time was lowest; nothing
# that was already listed moved. TestProxiedServerStorageClass and
# TestProxiedServerServeRefusesAStaleCheckpointWithGone (discovered
# from #7129 on) had hashed onto shard 5, which then hit the timeout on
# most Main runs; pinning them returns shard 5 to its earlier test set.
# TestProxiedServerListComments and
# TestProxiedServerServeRefusesAStreamOnADisabledJournal had hashed
# onto shard 3, which runs within about a minute of the timeout. An
# incremental --write keeps pinned lines where they are; a pin is a
# reviewed choice, not a regeneration of this block.
#
# TestProxiedServerOutageReconnectAcceptanceMatrix is pinned to shard 1
# (the lightest in recent Main runs, ~6.5 min) instead of hashing onto
# shard 14, which already runs ~13.5 min of the 15m timeout. These jobs
# have no socat, so today it skips here; the pin keeps shard 14 safe if
# socat is ever installed.
#
# This file is generated: notes added here are erased by the next
# regeneration. Add them to the generator instead. Known blind spots
# of the cost proxy (it counts inits, not the work done per init):
#
# TestProxiedServerListSortRetiresTheWalk is the most expensive
# entry and one of the cheapest-looking: off a single init it seeds
# 1400 rows and walks the listing three ways. It is the measurement
# behind the claim that sort=priority retires the client-side walk,
# so it has to run on PRs.
#
# TestProxiedServerServeReadParity is the CLI/HTTP read parity
# oracle, the behavioural half of the anti-drift claim. It being in
# this lane, and this lane being required by the PR Risk CI gate,
# is what makes that claim enforced on PRs rather than asserted in
# a doc comment.
15 1 TestProxiedServerBlocked
15 1 TestProxiedServerCompactDolt
15 1 TestProxiedServerCreate
15 1 TestProxiedServerDep2
15 1 TestProxiedServerDepConcurrent
15 1 TestProxiedServerListSortRetiresTheWalk
15 1 TestProxiedServerMolLastActivity
15 1 TestProxiedServerOutageReconnectAcceptanceMatrix
15 1 TestProxiedServerReopenConcurrent
15 1 TestProxiedServerServeReadParity
15 1 TestProxiedServerServeRefusesAStreamOnADisabledJournal
15 1 TestProxiedServerUpdateConcurrentClaim
15 2 TestProxiedServerCompactHistory
15 2 TestProxiedServerCreate2
15 2 TestProxiedServerDepListSingleIDWarnsOnDroppedExternalEdge
15 2 TestProxiedServerFindDuplicates
15 2 TestProxiedServerListWatchCountsTheOffsetIntoMaxRows
15 2 TestProxiedServerReady2
15 2 TestProxiedServerSQL
15 2 TestProxiedServerServeReadRevision
15 2 TestProxiedServerUpdateConcurrentMetadata
15 2 TestProxiedServerUpdateIfGuards
15 3 TestProxiedServerCascadeParity
15 3 TestProxiedServerDoltLifecycle
15 3 TestProxiedServerMolBurn
15 3 TestProxiedServerMolStale
15 3 TestProxiedServerMoleculeFrontDoorDirectServerProxyParity
15 3 TestProxiedServerSQLDatabaseFlag
15 3 TestProxiedServerServeRelatedIssues
15 3 TestProxiedServerTag
15 3 TestProxiedServerUpdate
15 3 TestProxiedServerWispCreateRejectsEnumViolatingVar
15 4 TestProxiedServerCreateInfraTypeRoutesToWisps
15 4 TestProxiedServerEdit
15 4 TestProxiedServerListComments
15 4 TestProxiedServerMoleculeFrontDoorWriteParity
15 4 TestProxiedServerPour
15 4 TestProxiedServerReassignFence
15 4 TestProxiedServerServeAddComment
15 4 TestProxiedServerServeRelease
15 4 TestProxiedServerUpdate2
15 4 TestProxiedServerUpdateHooks
15 5 TestProxiedServerClose
15 5 TestProxiedServerConfigConcurrent
15 5 TestProxiedServerExport
15 5 TestProxiedServerGateLifecycle
15 5 TestProxiedServerMolReadyGated
15 5 TestProxiedServerMultiStatementSQL
15 5 TestProxiedServerServeAddDependencies
15 5 TestProxiedServerServeRemoveDependency
15 5 TestProxiedServerWispCreate
15 6 TestProxiedServerClose2
15 6 TestProxiedServerContext
15 6 TestProxiedServerExternalCreate
15 6 TestProxiedServerLink
15 6 TestProxiedServerNote
15 6 TestProxiedServerRelate
15 6 TestProxiedServerServeBatchClose
15 6 TestProxiedServerServeSettingsWrites
15 6 TestProxiedServerWispList
15 7 TestProxiedServerAssign
15 7 TestProxiedServerBackupRefusedOnExternalTopology
15 7 TestProxiedServerCount
15 7 TestProxiedServerGC
15 7 TestProxiedServerList
15 7 TestProxiedServerOrphans
15 7 TestProxiedServerReady
15 7 TestProxiedServerServeClaim
15 7 TestProxiedServerServeRefusesAStaleCheckpointWithGone
15 7 TestProxiedServerServeUpdate
15 7 TestProxiedServerState
15 8 TestProxiedServerBatchParity
15 8 TestProxiedServerCountIncludeInfra
15 8 TestProxiedServerDoltRemoteRemove
15 8 TestProxiedServerGateCreateInheritsRepoMetadata
15 8 TestProxiedServerLabel
15 8 TestProxiedServerMolBond
15 8 TestProxiedServerPathHelpers
15 8 TestProxiedServerRecomputeBlocked
15 8 TestProxiedServerServeClaimNext
15 8 TestProxiedServerSetState
15 9 TestProxiedServerChildren
15 9 TestProxiedServerComment
15 9 TestProxiedServerDeferAutoWake
15 9 TestProxiedServerGateFrontDoorDirectServerProxyParity
15 9 TestProxiedServerMemory
15 9 TestProxiedServerPing
15 9 TestProxiedServerPrune
15 9 TestProxiedServerReopen
15 9 TestProxiedServerServeClose
15 9 TestProxiedServerStale
15 10 TestProxiedServerCleanDatabases
15 10 TestProxiedServerDeferUndefer
15 10 TestProxiedServerDuplicates
15 10 TestProxiedServerGraph
15 10 TestProxiedServerPourRejectsEnumViolatingVar
15 10 TestProxiedServerSearch
15 10 TestProxiedServerServeCount
15 10 TestProxiedServerShow
15 10 TestProxiedServerStatuses
15 10 TestProxiedServerUpdateWisp
15 11 TestProxiedServerDelete
15 11 TestProxiedServerDep
15 11 TestProxiedServerGateCheck
15 11 TestProxiedServerGateList
15 11 TestProxiedServerHeartbeat
15 11 TestProxiedServerMolProgress
15 11 TestProxiedServerPriority
15 11 TestProxiedServerPromote
15 11 TestProxiedServerServeCreate
15 11 TestProxiedServerSwarm
15 12 TestProxiedServerDeleteBlockedJSONSingleDoc
15 12 TestProxiedServerHistory
15 12 TestProxiedServerKV
15 12 TestProxiedServerMolShow
15 12 TestProxiedServerQuery
15 12 TestProxiedServerQuick
15 12 TestProxiedServerServeDelete
15 12 TestProxiedServerShow2
15 12 TestProxiedServerTypes
15 12 TestProxiedServerUpdateClosePolicy
15 13 TestProxiedServerDeleteConcurrent
15 13 TestProxiedServerInfo
15 13 TestProxiedServerMolSquash
15 13 TestProxiedServerReadyClaimConcurrent
15 13 TestProxiedServerReadyWisp
15 13 TestProxiedServerServeEdgeCounts
15 13 TestProxiedServerShow3
15 13 TestProxiedServerStatus
15 13 TestProxiedServerUnclaim
15 13 TestProxiedServerWispGC
15 14 TestProxiedServerCleanDatabasesPurgeDropped
15 14 TestProxiedServerConfig
15 14 TestProxiedServerConfigSetMany
15 14 TestProxiedServerDeleteForceOrphans
15 14 TestProxiedServerImport
15 14 TestProxiedServerInitIfMissing
15 14 TestProxiedServerMolDistill
15 14 TestProxiedServerPrime
15 14 TestProxiedServerReadyConcurrent
15 14 TestProxiedServerServeLifecycle
15 14 TestProxiedServerStorageClass
15 14 TestProxiedServerUnclaimIfAssigneeParity
15 15 TestProxiedServerCloseConcurrent
15 15 TestProxiedServerDeleteWisp
15 15 TestProxiedServerEpic
15 15 TestProxiedServerHuman
15 15 TestProxiedServerLint
15 15 TestProxiedServerMolCurrent
15 15 TestProxiedServerReclaim
15 15 TestProxiedServerServeModeGate
15 15 TestProxiedServerTodo
15 15 TestProxiedServerUpdate3
15 15 TestProxiedServerUpdateConcurrentAppendNotes
# Proxied-server cmd test shard manifest.
#
# Format: <total_shards> <shard_number> <top_level_test_name>
#
# 30-shard split for the Bazel-only proxied-server tier
# 34-shard split for the Bazel-only proxied-server tier
# (bazel-proxied in .github/workflows/bazel.yml), bin-packed
# longest-processing-time-first by measured wall-time from
# scripts/ci/proxied_test_durations.json (see that file for
# provenance and its "relative weight, not absolute SLA" caveat).
# Regenerate with scripts/ci/gen_proxied_shard_manifest.py 30
# Regenerate with scripts/ci/gen_proxied_shard_manifest.py 34
# --weights=duration --write after adding or removing
# TestProxiedServer*/TestServerMode* functions. --write is incremental:
# it keeps every already-assigned test on its current shard and only
@ -250,210 +29,260 @@
# regeneration. Add them to the generator or the durations file
# instead.
30 1 TestProxiedServerGateList
30 1 TestProxiedServerHuman
30 1 TestProxiedServerReclaim
30 1 TestProxiedServerSQLStatementRouting
30 1 TestProxiedServerServeLifecycle
34 1 TestProxiedServerDep2
34 1 TestProxiedServerMolProgress
34 1 TestProxiedServerReadyClaimConcurrent
34 1 TestProxiedServerServeActivatesTheEventsJournal
34 1 TestProxiedServerServeRelease
30 2 TestProxiedServerDelete
30 2 TestProxiedServerDeleteForceOrphans
30 2 TestProxiedServerListComments
30 2 TestProxiedServerPromote
30 2 TestProxiedServerTypesAgreeWithCreate
34 2 TestProxiedServerDepListSingleIDWarnsOnDroppedExternalEdge
34 2 TestProxiedServerGateList
34 2 TestProxiedServerList
34 2 TestProxiedServerServeRemoveDependency
34 2 TestProxiedServerUpdateC
30 3 TestProxiedServerDuplicates
30 3 TestProxiedServerReadyWisp
30 3 TestProxiedServerServeDelete
30 3 TestProxiedServerServeModeGate
30 3 TestProxiedServerServeReadRevision
34 3 TestProxiedServerAutoPrune
34 3 TestProxiedServerClose2B
34 3 TestProxiedServerEventsJournalOffByDefault
34 3 TestProxiedServerIfRevisionCloseMismatchRefuses
34 3 TestProxiedServerMolLastActivity
34 3 TestProxiedServerPurgeWispsPlaneRetention
34 3 TestProxiedServerServeLifecycle
34 3 TestProxiedServerStatuses
30 4 TestProxiedServerGateCreateInheritsRepoMetadata
30 4 TestProxiedServerMolBurn
30 4 TestProxiedServerReadyConcurrent
30 4 TestProxiedServerServeAddDependencies
30 4 TestProxiedServerServeRelatedIssues
34 4 TestProxiedServerMolStale
34 4 TestProxiedServerReadyConcurrent
34 4 TestProxiedServerServeRelatedIssues
34 4 TestProxiedServerServeSettingsWrites
34 4 TestProxiedServerShow2
34 4 TestServerModeServeSkipsPostRunMaintenance
30 5 TestProxiedServerCleanDatabases
30 5 TestProxiedServerCreate
30 5 TestProxiedServerEventsJournal
30 5 TestProxiedServerPour
30 5 TestProxiedServerServeUpdateClaim
30 5 TestServerModeDeferAutoWake
34 5 TestProxiedServerHistoryRemoteRefusalFrontDoorMatrix
34 5 TestProxiedServerInfo
34 5 TestProxiedServerNote
34 5 TestProxiedServerOutageReconnectAcceptanceMatrix
34 5 TestProxiedServerUpdate3
34 5 TestServerModeDeferAutoWake
30 6 TestProxiedServerBatchParity
30 6 TestProxiedServerHistoryRemoteSupportedFrontDoorParity
30 6 TestProxiedServerMolShow
30 6 TestProxiedServerMultiStatementSQL
30 6 TestProxiedServerReady
30 6 TestProxiedServerServeRemoveDependency
34 6 TestProxiedServerPing
34 6 TestProxiedServerQuick
34 6 TestProxiedServerServeReadsTheJournalItJustWrote
34 6 TestProxiedServerSwarm
34 6 TestProxiedServerUpdate2B
34 6 TestProxiedServerVersionedHistorySwitchRefusesAnUnrecordableGateTimeout
34 6 TestProxiedServerWispList
30 7 TestProxiedServerCleanDatabasesPurgeDropped
30 7 TestProxiedServerCount
30 7 TestProxiedServerCountIncludeInfra
30 7 TestProxiedServerDoltLifecycle
30 7 TestProxiedServerGC
30 7 TestProxiedServerUpdate
34 7 TestProxiedServerCloseConcurrent
34 7 TestProxiedServerCreateInfraTypeRoutesToWisps
34 7 TestProxiedServerDeleteIfRevisionSingleWinner
34 7 TestProxiedServerExternalCreate
34 7 TestProxiedServerIfRevisionGuardDelete
34 7 TestProxiedServerIfRevisionTargetGoneIsPreconditionFailed
34 7 TestProxiedServerLabelC
34 7 TestProxiedServerMoleculeLifecycleAgreesOnEveryRoute
34 7 TestProxiedServerTypesAgreeWithCreate
30 8 TestProxiedServerInitIfMissing
30 8 TestProxiedServerPathHelpers
30 8 TestProxiedServerReopenConcurrent
30 8 TestProxiedServerShow2
30 8 TestProxiedServerTypes
30 8 TestProxiedServerUpdateClosePolicy
30 8 TestServerModeSharedServeGlobalReportsTheServedDatabase
34 8 TestProxiedServerClose2
34 8 TestProxiedServerDeleteWisp
34 8 TestProxiedServerExport
34 8 TestProxiedServerFindDuplicates
34 8 TestProxiedServerGateCheck
34 8 TestProxiedServerServeReadParity
30 9 TestProxiedServerCloseConcurrent
30 9 TestProxiedServerDep2
30 9 TestProxiedServerListWatchCountsTheOffsetIntoMaxRows
30 9 TestProxiedServerMolReadyGated
30 9 TestProxiedServerSQL
34 9 TestProxiedServerCloseSiblingBlockersFanIn
34 9 TestProxiedServerGateLifecycle
34 9 TestProxiedServerHistoryRemoteSupportedFrontDoorParity
34 9 TestProxiedServerIfRevisionGuardReopen
34 9 TestProxiedServerIfRevisionOutranksReassignFence
34 9 TestProxiedServerServeRefusesTheJournalWhenItIsDisabled
34 9 TestProxiedServerUpdate
34 9 TestServerModeServe
30 10 TestProxiedServerAutoPrune
30 10 TestProxiedServerClose2
30 10 TestProxiedServerPing
30 10 TestProxiedServerServeClose
30 10 TestProxiedServerServeEdgeCounts
34 10 TestProxiedServerContext
34 10 TestProxiedServerCreate2B
34 10 TestProxiedServerGateCheckB
34 10 TestProxiedServerServeRefusesAStreamOnADisabledJournal
34 10 TestProxiedServerTypes
34 10 TestProxiedServerUpdate2C
30 11 TestProxiedServerBatchDefersThenDoltCommitAdvancesHeadOnce
30 11 TestProxiedServerOutageReconnectAcceptanceMatrix
30 11 TestProxiedServerReady2
30 11 TestProxiedServerServeReadsTheJournalItJustWrote
30 11 TestProxiedServerServeRefusesTheJournalWhenItIsDisabled
30 11 TestProxiedServerShow
34 11 TestProxiedServerBatchParity
34 11 TestProxiedServerCompactHistory
34 11 TestProxiedServerPour
34 11 TestProxiedServerQuery
34 11 TestProxiedServerReady
34 11 TestProxiedServerServeAddDependencies
30 12 TestProxiedServerAssign
30 12 TestProxiedServerConfigSetMany
30 12 TestProxiedServerContext
30 12 TestProxiedServerInitExplicitBeadsDirIsAuthoritative
30 12 TestProxiedServerReadyClaimConcurrent
30 12 TestProxiedServerServeBatchClose
34 12 TestProxiedServerBlocked
34 12 TestProxiedServerChildren
34 12 TestProxiedServerCleanDatabases
34 12 TestProxiedServerReadyB
34 12 TestProxiedServerReadyWisp
34 12 TestProxiedServerReclaim
34 12 TestProxiedServerShowCommentsTail
34 12 TestProxiedServerUnclaim
30 13 TestProxiedServerChildren
30 13 TestProxiedServerConfig
30 13 TestProxiedServerDoltRemoteRemove
30 13 TestProxiedServerExternalMutationPolicy
30 13 TestProxiedServerPriority
30 13 TestProxiedServerServeUpdate
34 13 TestProxiedServerCompactDolt
34 13 TestProxiedServerCreate2
34 13 TestProxiedServerGraph
34 13 TestProxiedServerHistoryRemoteSupportedDirectParity
34 13 TestProxiedServerMolSquash
34 13 TestProxiedServerPromote
34 13 TestProxiedServerServeRefusesAStaleCheckpointWithGone
30 14 TestProxiedServerInfo
30 14 TestProxiedServerLint
30 14 TestProxiedServerNote
30 14 TestProxiedServerQuery
30 14 TestProxiedServerUpdate3
30 14 TestProxiedServerWispCreate
34 14 TestProxiedServerAssign
34 14 TestProxiedServerCloseB
34 14 TestProxiedServerDuplicates
34 14 TestProxiedServerHeartbeat
34 14 TestProxiedServerIfRevisionCloseReplaysMoleculeAutoClose
34 14 TestProxiedServerInitIfMissing
34 14 TestProxiedServerMolReadyGated
30 15 TestProxiedServerCompactDolt
30 15 TestProxiedServerMolDistill
30 15 TestProxiedServerMolProgress
30 15 TestProxiedServerServeClaimNext
30 15 TestProxiedServerServeRefusesAStreamOnADisabledJournal
30 15 TestProxiedServerUnclaimIfAssigneeParity
34 15 TestProxiedServerDepConcurrent
34 15 TestProxiedServerImport
34 15 TestProxiedServerMoleculeFrontDoorWriteParity
34 15 TestProxiedServerReopenConcurrent
34 15 TestProxiedServerSQL
30 16 TestProxiedServerCascadeParity
30 16 TestProxiedServerExternalCreate
30 16 TestProxiedServerGraph
30 16 TestProxiedServerLabel
30 16 TestProxiedServerSwarm
30 16 TestProxiedServerTodo
30 16 TestProxiedServerUpdateConcurrentMetadata
34 16 TestProxiedServerBackupRefusedOnExternalTopology
34 16 TestProxiedServerCascadeParity
34 16 TestProxiedServerConfigSetMany
34 16 TestProxiedServerKV
34 16 TestProxiedServerServeCount
34 16 TestProxiedServerServeCreate
34 16 TestProxiedServerUpdateHooks
30 17 TestProxiedServerClose
30 17 TestProxiedServerConfigConcurrent
30 17 TestProxiedServerDeleteConcurrent
30 17 TestProxiedServerSearch
30 17 TestProxiedServerServeReadParity
30 17 TestProxiedServerStatus
34 17 TestProxiedServerDep
34 17 TestProxiedServerMultiStatementSQL
34 17 TestProxiedServerOrphans
34 17 TestProxiedServerPrime
34 17 TestProxiedServerSQLDatabaseFlag
34 17 TestProxiedServerServeModeGate
34 17 TestServerModeServeIgnoresGraphModeDependency
30 18 TestProxiedServerHeartbeat
30 18 TestProxiedServerMolBond
30 18 TestProxiedServerSQLDatabaseFlag
30 18 TestProxiedServerServeCount
30 18 TestProxiedServerUpdate2
30 18 TestServerModeTypesAgreeWithCreate
34 18 TestProxiedServerClose3
34 18 TestProxiedServerCount
34 18 TestProxiedServerCountIncludeInfra
34 18 TestProxiedServerDoltRemoteRemove
34 18 TestProxiedServerMolShow
34 18 TestProxiedServerWispCreateRejectsEnumViolatingVar
30 19 TestProxiedServerCreate2
30 19 TestProxiedServerEdit
30 19 TestProxiedServerPourRejectsEnumViolatingVar
30 19 TestProxiedServerReassignFence
30 19 TestProxiedServerUpdateWisp
30 19 TestServerModeServe
34 19 TestProxiedServerCreate
34 19 TestProxiedServerMolCurrent
34 19 TestProxiedServerServeBatchClose
34 19 TestProxiedServerShow3
34 19 TestServerModeTypesAgreeWithCreate
30 20 TestProxiedServerExternalPolicyDirectParity
30 20 TestProxiedServerHistory
30 20 TestProxiedServerImport
30 20 TestProxiedServerMemory
30 20 TestProxiedServerMolCurrent
30 20 TestProxiedServerServeStreamsTheJournalItIsWriting
34 20 TestProxiedServerDelete
34 20 TestProxiedServerLint
34 20 TestProxiedServerPriority
34 20 TestProxiedServerShow2B
34 20 TestProxiedServerWispGC
34 20 TestServerModeSharedServeGlobalReportsTheServedDatabase
30 21 TestProxiedServerDeleteWisp
30 21 TestProxiedServerDepConcurrent
30 21 TestProxiedServerListSortRetiresTheWalk
30 21 TestProxiedServerPrime
30 21 TestProxiedServerRelate
30 21 TestProxiedServerSetState
30 21 TestProxiedServerUpdateConcurrentAppendNotes
34 21 TestProxiedServerBatchDepAddRefusesADottedChildGatedOnItsParent
34 21 TestProxiedServerConfig
34 21 TestProxiedServerExternalPolicyDirectParity
34 21 TestProxiedServerMoleculeFrontDoorDirectServerProxyParity
34 21 TestProxiedServerPathHelpers
34 21 TestProxiedServerPrune
34 21 TestProxiedServerServeClose
34 21 TestProxiedServerUnclaimIfAssigneeParity
30 22 TestProxiedServerCompactHistory
30 22 TestProxiedServerGateLifecycle
30 22 TestProxiedServerKV
30 22 TestProxiedServerShow3
30 22 TestProxiedServerStale
30 22 TestProxiedServerStatuses
34 22 TestProxiedServerGateCreateInheritsRepoMetadata
34 22 TestProxiedServerRecomputeBlocked
34 22 TestProxiedServerServeEdgeCounts
34 22 TestProxiedServerTag
34 22 TestProxiedServerUpdateB
34 22 TestProxiedServerUpdateConcurrentMetadata
30 23 TestProxiedServerBackupRefusedOnExternalTopology
30 23 TestProxiedServerCloseSiblingBlockersFanIn
30 23 TestProxiedServerDeleteBlockedJSONSingleDoc
30 23 TestProxiedServerQuick
30 23 TestProxiedServerStorageClass
30 23 TestProxiedServerUpdateHooks
30 23 TestProxiedServerWispGC
34 23 TestProxiedServerDep2B
34 23 TestProxiedServerIfRevisionGuardUpdate
34 23 TestProxiedServerListWatchCountsTheOffsetIntoMaxRows
34 23 TestProxiedServerMolBurn
34 23 TestProxiedServerSearchRoutesAgree
34 23 TestProxiedServerServeUpdate
34 23 TestProxiedServerUpdateConcurrentClaim
34 23 TestProxiedServerUpdateWisp
30 24 TestProxiedServerCreateInfraTypeRoutesToWisps
30 24 TestProxiedServerEpic
30 24 TestProxiedServerLink
30 24 TestProxiedServerMoleculeFrontDoorDirectServerProxyParity
30 24 TestProxiedServerRecomputeBlocked
30 24 TestServerModeServeSkipsPostRunMaintenance
34 24 TestProxiedServerDeleteBlockedJSONSingleDoc
34 24 TestProxiedServerDeleteForceOrphans
34 24 TestProxiedServerHuman
34 24 TestProxiedServerIfRevisionDeleteMatchAndMismatch
34 24 TestProxiedServerIfRevisionGuardAssign
34 24 TestProxiedServerListComments
34 24 TestProxiedServerListSortRetiresTheWalk
34 24 TestProxiedServerShowWatch
34 24 TestProxiedServerUpdateIfGuards
30 25 TestProxiedServerDeferUndefer
30 25 TestProxiedServerOrphans
30 25 TestProxiedServerServeClaim
30 25 TestProxiedServerShowWatch
30 25 TestProxiedServerUpdateIfGuards
30 25 TestProxiedServerWispCreateRejectsEnumViolatingVar
34 25 TestProxiedServerInitExplicitBeadsDirIsAuthoritative
34 25 TestProxiedServerSetState
34 25 TestProxiedServerShow
34 25 TestProxiedServerShowB
34 25 TestProxiedServerStale
34 25 TestProxiedServerWispCreate
30 26 TestProxiedServerFindDuplicates
30 26 TestProxiedServerGateCheck
30 26 TestProxiedServerGateFrontDoorDirectServerProxyParity
30 26 TestProxiedServerServeAddComment
30 26 TestProxiedServerServeSettingsWrites
30 26 TestProxiedServerState
34 26 TestProxiedServerDeferAutoWake
34 26 TestProxiedServerExternalMutationPolicy
34 26 TestProxiedServerReopenB
34 26 TestProxiedServerSearch
34 26 TestProxiedServerServeClaim
34 26 TestProxiedServerShow3B
30 27 TestProxiedServerBlocked
30 27 TestProxiedServerMolLastActivity
30 27 TestProxiedServerMolStale
30 27 TestProxiedServerMoleculeFrontDoorWriteParity
30 27 TestProxiedServerServeActivatesTheEventsJournal
30 27 TestProxiedServerServeRefusesAStaleCheckpointWithGone
34 27 TestProxiedServerDeferUndefer
34 27 TestProxiedServerGatedRendering
34 27 TestProxiedServerHistory
34 27 TestProxiedServerLabel
34 27 TestProxiedServerLabelB
34 27 TestProxiedServerUpdateClosePolicy
30 28 TestProxiedServerComment
30 28 TestProxiedServerExport
30 28 TestProxiedServerList
30 28 TestProxiedServerReopen
30 28 TestProxiedServerServeCreate
30 28 TestProxiedServerUnclaim
34 28 TestProxiedServerDep2C
34 28 TestProxiedServerDoltLifecycle
34 28 TestProxiedServerIfRevisionCloseWarnsOnForcedOpenChildren
34 28 TestProxiedServerReady2
34 28 TestProxiedServerReassignFence
34 28 TestProxiedServerSQLStatementRouting
34 28 TestProxiedServerServeClaimNext
34 28 TestProxiedServerUpdateConcurrentAppendNotes
30 29 TestProxiedServerDeferAutoWake
30 29 TestProxiedServerDep
30 29 TestProxiedServerDepListSingleIDWarnsOnDroppedExternalEdge
30 29 TestProxiedServerHistoryRemoteRefusalFrontDoorMatrix
30 29 TestProxiedServerTag
30 29 TestProxiedServerWispList
34 29 TestProxiedServerGateFrontDoorDirectServerProxyParity
34 29 TestProxiedServerMolDistill
34 29 TestProxiedServerReopen
34 29 TestProxiedServerServeDelete
34 29 TestProxiedServerState
30 30 TestProxiedServerEventsJournalOffByDefault
30 30 TestProxiedServerMolSquash
30 30 TestProxiedServerPrune
30 30 TestProxiedServerPurgeWispsPlaneRetention
30 30 TestProxiedServerServeRelease
30 30 TestProxiedServerUpdateConcurrentClaim
34 30 TestProxiedServerDeleteConcurrent
34 30 TestProxiedServerReadyC
34 30 TestProxiedServerServeAddComment
34 30 TestProxiedServerStatus
34 30 TestProxiedServerTodo
34 30 TestProxiedServerUpdate2
34 30 TestProxiedServerVersionedHistoryServeActivatesTheProviderFromItsOwnRow
34 31 TestProxiedServerCloseBeadGate
34 31 TestProxiedServerComment
34 31 TestProxiedServerConfigB
34 31 TestProxiedServerEventsJournal
34 31 TestProxiedServerGateAddWaiterConvoy
34 31 TestProxiedServerIfRevisionGuardClose
34 31 TestProxiedServerMolBond
34 32 TestProxiedServerCleanDatabasesPurgeDropped
34 32 TestProxiedServerConfigConcurrent
34 32 TestProxiedServerDepB
34 32 TestProxiedServerServeStreamsTheJournalItIsWriting
34 32 TestProxiedServerServeUpdateClaim
34 32 TestProxiedServerStorageClass
34 33 TestProxiedServerBatchDefersThenDoltCommitAdvancesHeadOnce
34 33 TestProxiedServerClose
34 33 TestProxiedServerGC
34 33 TestProxiedServerMemory
34 33 TestProxiedServerPourRejectsEnumViolatingVar
34 33 TestProxiedServerRelate
34 34 TestProxiedServerClose4
34 34 TestProxiedServerCreate2C
34 34 TestProxiedServerEdit
34 34 TestProxiedServerEpic
34 34 TestProxiedServerLink
34 34 TestProxiedServerServeReadRevision

17
.github/scripts/rrc-lane-commands.txt vendored Normal file
View file

@ -0,0 +1,17 @@
# Every bazel.yml lane's loading and analysis, for the remote repo contents
# cache: rrc-seed runs each line with --nobuild on a push to main (uploading
# the repositories it fetches) and rrc-verify runs each cold every night.
# One `bazel` command per line (no shell quoting); # starts a comment.
# scripts/bazel_rrc_test.go checks that every --config a reading lane's
# bazel command uses appears here.
test //... --config=ci
test //... --config=embedded
test //... --config=integration
test //... --config=doltserver
test //... --config=doltserver-proxied
test //... --config=dolt-race
test //... --config=doltserver-integration
test //... --config=doltserver-cmd
test //... --config=dolt-int
build --config=pure //cmd/bd:bd //cmd/bd:bd_test //internal/storage/embeddeddolt:embeddeddolt_test //internal/tracker:tracker_test
build --config=js-wasm //internal/hooks:hooks_test

51
.github/scripts/rrc-run-lanes.sh vendored Executable file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Loading and analysis of every bazel.yml lane, for the remote repo contents
# cache (bazel.yml's rrc-seed and rrc-verify jobs).
#
# Usage: rrc-run-lanes.sh [STARTUP_FLAG...] -- [COMMAND_FLAG...]
#
# Runs `bazel STARTUP_FLAG... <line> --nobuild COMMAND_FLAG...` for each
# command line in .github/scripts/rrc-lane-commands.txt (or RRC_LANE_COMMANDS),
# in order, stopping at the first failure. --nobuild: repository rules,
# loading and analysis only, never a build or test action.
#
# Bazel exits 1 after `test --nobuild` even when loading and analysis succeed
# ("Couldn't start the build. Unable to run tests"). A command passes when it
# exits 0, or exits non-zero having printed "Build completed successfully"
# and no ERROR line but that one.
set -euo pipefail
startup=()
while [ $# -gt 0 ] && [ "$1" != -- ]; do
startup+=("$1")
shift
done
[ $# -gt 0 ] || {
echo "usage: rrc-run-lanes.sh [STARTUP_FLAG...] -- [COMMAND_FLAG...]" >&2
exit 2
}
shift
flags=("$@")
file=${RRC_LANE_COMMANDS:-$(dirname "${BASH_SOURCE[0]}")/rrc-lane-commands.txt}
mapfile -t cmds < <(sed -e 's/#.*//' -e 's/[[:space:]]*$//' "$file" | grep -v '^[[:space:]]*$' || true)
if [ "${#cmds[@]}" -eq 0 ]; then
echo "::error::no lane commands in $file"
exit 1
fi
log=$(mktemp)
trap 'rm -f "$log"' EXIT
summary=${GITHUB_STEP_SUMMARY:-/dev/null}
for cmd in "${cmds[@]}"; do
read -r -a args <<<"$cmd"
start=$(date +%s)
rc=0
bazel ${startup[@]+"${startup[@]}"} "${args[@]}" --nobuild ${flags[@]+"${flags[@]}"} </dev/null 2>&1 | tee "$log" || rc=$?
if [ "$rc" -ne 0 ] && grep -q '^INFO: Build completed successfully' "$log" &&
! grep '^ERROR:' "$log" | grep -qv "^ERROR: Couldn't start the build. Unable to run tests$"; then
rc=0
fi
echo "rrc: \`bazel $cmd\`: exit $rc, $(($(date +%s) - start))s" | tee -a "$summary"
[ "$rc" -eq 0 ] || exit "$rc"
done

113
.github/scripts/rrc-writer-credential.sh vendored Executable file
View file

@ -0,0 +1,113 @@
#!/usr/bin/env bash
# A 30-minute rbe-west client certificate for the remote repo contents cache
# writer (bazel.yml's rrc-seed job; engdocs/design/bazel-remote-repo-contents-cache.md).
#
# The job trades its GitHub Actions OIDC token (audience rbe-rrc-writer) for a
# certificate CN=rbe-rrc-writer from rbe-west's mint. The mint signs only for
# this repository's bazel.yml on a push to main (repository, ref, event_name
# and job_workflow_ref claims); pull_request, fork and Dependabot runs cannot
# get one (no OIDC token, or a refs/pull/N/merge one). On rbe-west that
# certificate reaches only GetCapabilities, the CAS and an action cache front
# (rrc-gate) that admits repo-contents entries and refuses everything else, so
# it can never write an execution result or execute anything.
#
# The key is an EC P-256 key (PKCS#8: Bazel's Netty TLS refuses a SEC1 "EC
# PRIVATE KEY") generated here in BAZEL_CI_SECRET_DIR, outside the workspace;
# it never leaves the runner. The OIDC token is masked. Outputs (to
# $GITHUB_OUTPUT when set, else stdout): cert, key, endpoint, instance; none
# when the mint answers 503 or cannot be reached (seeding switched off on
# rbe-west: infra nativelink-cas/west/README.md "Client contract"), which
# exits 0 with a warning.
#
# Tests only: RBE_RRC_MINT (a stand-in mint) and RBE_RRC_ENDPOINT_RE.
set -euo pipefail
MINT=${RBE_RRC_MINT:-https://rbe-mint.ops.gascity.com:8444}
ENDPOINT_RE=${RBE_RRC_ENDPOINT_RE:-'^grpcs://rbe-west\.ops\.gascity\.com(:443)?$'}
AUDIENCE=rbe-rrc-writer
dir=${BAZEL_CI_SECRET_DIR:?BAZEL_CI_SECRET_DIR is required}
out=${GITHUB_OUTPUT:-/dev/stdout}
if [ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" ] || [ -z "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}" ]; then
echo "::error title=rrc writer::no OIDC token request URL; the job needs permissions: id-token: write" >&2
exit 1
fi
install -d -m 0700 "$dir"
umask 077
oidc=$(curl -sS --fail --connect-timeout 5 --max-time 30 --retry 3 --retry-all-errors \
-H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=$AUDIENCE" | jq -r '.value // empty')
if [ -z "$oidc" ]; then
echo "::error title=rrc writer::GitHub returned no OIDC token" >&2
exit 1
fi
printf '::add-mask::%s\n' "$oidc"
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out "$dir/rrc-writer.key" 2>/dev/null
csr=$(openssl req -new -key "$dir/rrc-writer.key" -subj "/CN=rbe-rrc-writer-request")
body=$(jq -cn --arg csr "$csr" '{csr_pem: $csr}')
reply="$dir/rrc-mint.json"
code=000
for attempt in 1 2 3 4; do
# --connect-timeout: a closed gate drops the SYN; fail fast, not in 60 s.
code=$(curl -sS -o "$reply" -w '%{http_code}' --connect-timeout 5 --max-time 60 \
-H "Authorization: Bearer $oidc" -H 'content-type: application/json' \
--data "$body" "$MINT/v1/rrc-writer/cert") || code=000
# Retry what may pass on its own: a rate limit (429), the mint could not
# reach GitHub's JWKS (502), or the network (000). Everything else is an
# answer.
case "$code" in 429 | 502 | 000) ;; *) break ;; esac
[ "$attempt" -eq 4 ] || sleep $((attempt * 10))
done
case "$code" in
200) ;;
503 | 000)
# The mint's switch is off, its CA is not installed, or rbe-west's fork
# edge is closed: seeding is off, not broken. No outputs, so the seed
# step skips; the push to main never fails on it.
echo "::warning title=rrc writer: seeding off (HTTP $code)::$(jq -r '.error // empty' "$reply" 2>/dev/null || true)"
exit 0
;;
*)
echo "::error title=rrc writer mint refused (HTTP $code)::$(jq -r '.error // empty' "$reply" 2>/dev/null || true)"
exit 1
;;
esac
endpoint=$(jq -r '.endpoint // empty' "$reply")
instance=$(jq -r '.instance // empty' "$reply")
[[ $endpoint =~ $ENDPOINT_RE ]] || {
echo "::error::rrc writer mint returned endpoint '$endpoint'" >&2
exit 1
}
[ "$instance" = oss ] || {
echo "::error::rrc writer mint returned instance '$instance', want oss" >&2
exit 1
}
jq -r '.cert_pem // empty' "$reply" >"$dir/rrc-writer.crt"
subject=$(openssl x509 -in "$dir/rrc-writer.crt" -noout -subject -nameopt RFC2253) || {
echo "::error::rrc writer mint returned no certificate" >&2
exit 1
}
rdns=$(tr ',' '\n' <<<"${subject#subject=}")
cn=$(sed -n 's/^CN=//p' <<<"$rdns")
org=$(sed -n 's/^O=//p' <<<"$rdns")
if ! [[ $cn =~ ^rbe-rrc-writer(-[a-z0-9]+)?$ ]] || [ "$org" != gascity ]; then
echo "::error::rrc writer mint returned a certificate for '$subject'" >&2
exit 1
fi
# The certificate must belong to the key generated above.
if [ "$(openssl x509 -in "$dir/rrc-writer.crt" -noout -pubkey | openssl sha256)" != "$(openssl pkey -in "$dir/rrc-writer.key" -pubout | openssl sha256)" ]; then
echo "::error::rrc writer mint returned a certificate for another key" >&2
exit 1
fi
openssl x509 -in "$dir/rrc-writer.crt" -noout -subject -enddate
rm -f "$reply"
{
echo "cert=$dir/rrc-writer.crt"
echo "key=$dir/rrc-writer.key"
echo "endpoint=$endpoint"
echo "instance=$instance"
} >>"$out"

View file

@ -120,8 +120,18 @@ jobs:
name: Bazel Farm
needs: authorize
if: ${{ needs.authorize.outputs.allowed == 'true' }}
# A called workflow's job gets at most this call's token permissions, and
# GitHub checks them when the run starts, even for a job whose if: skips
# it (startup_failure otherwise; gascity #7478): bazel.yml's rrc-seed asks
# id-token: write (push to main only) and rrc-verify issues: write
# (schedule and dispatch only). Neither runs for this event, every other
# bazel.yml job keeps contents: read, and rbe-west's mint refuses any OIDC
# token but a main-push bazel.yml one
# (scripts/bazel_rrc_test.go, TestBazelWorkflowCallersGrantEveryRequestedPermission).
permissions:
contents: read
id-token: write
issues: write
uses: ./.github/workflows/bazel.yml
# Exactly the four RBE secrets: never the rbe-prewarm app private key
# (B1, security review of bdef342d5). This pull_request_target run is

File diff suppressed because it is too large Load diff

View file

@ -1,770 +0,0 @@
name: CI Measurements
on:
workflow_call:
inputs:
suite:
description: "Suite to measure"
required: true
type: string
smoke_version:
description: "Optional previous release for cross-version-smoke"
required: false
type: string
default: ""
workflow_dispatch:
inputs:
suite:
description: "Suite to measure"
required: true
type: choice
default: pr-linux
options:
- pr-linux
- macos-short
- macos-candidates
- linux-integration
- linux-integration-sharded
- linux-integration-hybrid-sharded
- linux-integration-hybrid-16-sharded
- linux-integration-hybrid-prebuilt-sharded
- linux-integration-coverage
- cross-version-smoke
- nix
- mcp-package
- npm-package
smoke_version:
description: "Optional previous release for cross-version-smoke"
required: false
default: ""
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.suite }}
cancel-in-progress: false
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
jobs:
pr-linux:
name: Measure PR Linux commands
if: ${{ inputs.suite == 'pr-linux' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure commands
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
source ./.buildflags
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
ci_time "install golangci-lint" -- ./scripts/ci/install-golangci-lint.sh
# install-golangci-lint.sh appends to $GITHUB_PATH, which GitHub
# Actions only applies to *later steps*, not later commands in this
# same run block. Export it here too so the "pr-lint wrapper" call
# below finds golangci-lint on PATH.
export PATH="$RUNNER_TEMP/golangci-lint:$PATH"
status=0
ci_time "pr-policy wrapper" -- make ci-pr-policy || status=$?
# -timeout=30m keeps this in step with the lane it measures
# (scripts/ci/pr-core.sh). Without it ./cmd/bd can die on `go test`'s
# 10m default and the measurement reports a panic instead of a duration.
ci_time "pr-core gotestsum" -- gotestsum --junitfile artifacts/pr-core-junit.xml --format testdox -- -race -short -timeout=30m -skip '^TestEmbedded' ./... || status=$?
ci_time "pr-lint wrapper" -- make ci-pr-lint || status=$?
exit "$status"
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-pr-linux
path: artifacts/
retention-days: 7
if-no-files-found: ignore
macos-short:
name: Measure macOS short Go tests
if: ${{ inputs.suite == 'macos-short' }}
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure commands
run: |
set -euo pipefail
source scripts/ci/lib/timing.sh
source ./.buildflags
# -timeout=30m matches the macOS lanes this measures (pr.yml, main.yml).
# This is the job that produced the ./cmd/bd duration distribution, and
# at 10m it clips its own longest samples into timeout panics.
ci_time "macos short go test" -- go test -tags=gms_pure_go -v -race -short -timeout=30m -skip '^TestEmbedded' ./...
macos-candidates:
name: Measure macOS no-short candidates
if: ${{ inputs.suite == 'macos-candidates' }}
runs-on: macos-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure commands
run: |
set -euo pipefail
source scripts/ci/lib/timing.sh
status=0
ci_time "macos no-short go test" -- go test -tags=gms_pure_go -v -race -timeout=30m -skip '^TestEmbedded' ./... || status=$?
ci_time "macos integration go test" -- go test -tags=integration,gms_pure_go -v -race -timeout=30m -skip '^TestEmbedded' ./... || status=$?
exit "$status"
linux-integration:
name: Measure Linux integration tests
if: ${{ inputs.suite == 'linux-integration' }}
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure commands
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
ci_time "linux integration go test" -- env BEADS_TEST_SKIP=dolt gotestsum --junitfile artifacts/linux-integration-junit.xml --format testdox -- -v -race -tags=integration,gms_pure_go -timeout=30m ./...
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration
path: artifacts/
retention-days: 7
if-no-files-found: ignore
linux-integration-sharded:
name: Measure Linux integration shard ${{ matrix.shard }}/6
if: ${{ inputs.suite == 'linux-integration-sharded' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure shard
env:
SHARD: ${{ matrix.shard }}
TOTAL_SHARDS: 6
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
mapfile -t packages < <(
GO_TEST_SHARD_TAGS=integration,gms_pure_go \
scripts/ci/go-test-shard-packages.sh "$SHARD" "$TOTAL_SHARDS"
)
package_manifest="artifacts/linux-integration-packages-${SHARD}-of-${TOTAL_SHARDS}.txt"
printf '%s\n' "${packages[@]}" | tee "$package_manifest"
if [[ "${#packages[@]}" -eq 0 ]]; then
echo "No packages assigned to shard ${SHARD}/${TOTAL_SHARDS}; skipping go test"
exit 0
fi
ci_time "linux integration shard ${SHARD}/${TOTAL_SHARDS} go test" -- \
env BEADS_TEST_SKIP=dolt gotestsum \
--junitfile "artifacts/linux-integration-shard-${SHARD}-of-${TOTAL_SHARDS}.xml" \
--format testdox \
-- -v -race -tags=integration,gms_pure_go -timeout=30m "${packages[@]}"
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration-shard-${{ matrix.shard }}-of-6
path: artifacts/
retention-days: 7
if-no-files-found: ignore
linux-integration-hybrid-packages:
name: Measure Linux integration package shard ${{ matrix.shard }}/6 (no cmd/bd)
if: ${{ inputs.suite == 'linux-integration-hybrid-sharded' || inputs.suite == 'linux-integration-hybrid-16-sharded' || inputs.suite == 'linux-integration-hybrid-prebuilt-sharded' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure shard
env:
SHARD: ${{ matrix.shard }}
TOTAL_SHARDS: 6
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
package_manifest="artifacts/linux-integration-hybrid-packages-${SHARD}-of-${TOTAL_SHARDS}.txt"
write_package_manifest() {
GO_TEST_SHARD_TAGS=integration,gms_pure_go \
GO_TEST_SHARD_EXCLUDE_REGEX="^github.com/steveyegge/beads/cmd/bd$" \
scripts/ci/go-test-shard-packages.sh "$SHARD" "$TOTAL_SHARDS" > "$package_manifest"
}
ci_time "list integration package shard ${SHARD}/${TOTAL_SHARDS}" -- write_package_manifest
cat "$package_manifest"
mapfile -t packages < "$package_manifest"
if [[ "${#packages[@]}" -eq 0 ]]; then
echo "No packages assigned to shard ${SHARD}/${TOTAL_SHARDS}; skipping go test"
exit 0
fi
ci_time "linux integration package shard ${SHARD}/${TOTAL_SHARDS} go test" -- \
env BEADS_TEST_SKIP=dolt gotestsum \
--junitfile "artifacts/linux-integration-hybrid-packages-${SHARD}-of-${TOTAL_SHARDS}.xml" \
--format testdox \
-- -v -race -tags=integration,gms_pure_go -timeout=30m "${packages[@]}"
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration-hybrid-packages-${{ matrix.shard }}-of-6
path: artifacts/
retention-days: 7
if-no-files-found: ignore
linux-integration-hybrid-cmd-bd:
name: Measure Linux integration cmd/bd shard ${{ matrix.shard }}/8
if: ${{ inputs.suite == 'linux-integration-hybrid-sharded' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure shard
env:
SHARD: ${{ matrix.shard }}
TOTAL_SHARDS: 8
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
test_manifest="artifacts/linux-integration-cmd-bd-tests-${SHARD}-of-${TOTAL_SHARDS}.txt"
write_test_manifest() {
GO_TEST_SHARD_TAGS=integration,gms_pure_go \
scripts/ci/go-test-shard-names.sh "$SHARD" "$TOTAL_SHARDS" ./cmd/bd > "$test_manifest"
}
ci_time "list cmd/bd test shard ${SHARD}/${TOTAL_SHARDS}" -- write_test_manifest
cat "$test_manifest"
mapfile -t tests < "$test_manifest"
if [[ "${#tests[@]}" -eq 0 ]]; then
echo "No tests assigned to shard ${SHARD}/${TOTAL_SHARDS}; skipping go test"
exit 0
fi
run_regex="^($(IFS='|'; echo "${tests[*]}"))$"
ci_time "linux integration cmd/bd shard ${SHARD}/${TOTAL_SHARDS} go test" -- \
env BEADS_TEST_SKIP=dolt gotestsum \
--junitfile "artifacts/linux-integration-cmd-bd-${SHARD}-of-${TOTAL_SHARDS}.xml" \
--format testdox \
-- -v -race -tags=integration,gms_pure_go -timeout=30m -run "$run_regex" ./cmd/bd
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration-cmd-bd-${{ matrix.shard }}-of-8
path: artifacts/
retention-days: 7
if-no-files-found: ignore
linux-integration-hybrid-16-cmd-bd:
name: Measure Linux integration cmd/bd shard ${{ matrix.shard }}/16
if: ${{ inputs.suite == 'linux-integration-hybrid-16-sharded' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure shard
env:
SHARD: ${{ matrix.shard }}
TOTAL_SHARDS: 16
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
test_manifest="artifacts/linux-integration-cmd-bd-tests-${SHARD}-of-${TOTAL_SHARDS}.txt"
write_test_manifest() {
GO_TEST_SHARD_TAGS=integration,gms_pure_go \
scripts/ci/go-test-shard-names.sh "$SHARD" "$TOTAL_SHARDS" ./cmd/bd > "$test_manifest"
}
ci_time "list cmd/bd test shard ${SHARD}/${TOTAL_SHARDS}" -- write_test_manifest
cat "$test_manifest"
mapfile -t tests < "$test_manifest"
if [[ "${#tests[@]}" -eq 0 ]]; then
echo "No tests assigned to shard ${SHARD}/${TOTAL_SHARDS}; skipping go test"
exit 0
fi
run_regex="^($(IFS='|'; echo "${tests[*]}"))$"
ci_time "linux integration cmd/bd shard ${SHARD}/${TOTAL_SHARDS} go test" -- \
env BEADS_TEST_SKIP=dolt gotestsum \
--junitfile "artifacts/linux-integration-cmd-bd-${SHARD}-of-${TOTAL_SHARDS}.xml" \
--format testdox \
-- -v -race -tags=integration,gms_pure_go -timeout=30m -run "$run_regex" ./cmd/bd
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration-cmd-bd-${{ matrix.shard }}-of-16
path: artifacts/
retention-days: 7
if-no-files-found: ignore
linux-integration-hybrid-prebuilt-bd:
name: Measure Linux integration prebuild cmd/bd binary
if: ${{ inputs.suite == 'linux-integration-hybrid-prebuilt-sharded' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Measure build
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
source ./.buildflags
ci_time "build cmd/bd subprocess binary" -- go build -tags gms_pure_go -o artifacts/bd ./cmd/bd
- name: Upload prebuilt bd
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration-prebuilt-bd
path: artifacts/bd
retention-days: 7
if-no-files-found: error
linux-integration-hybrid-prebuilt-cmd-bd:
name: Measure Linux integration prebuilt cmd/bd shard ${{ matrix.shard }}/8
if: ${{ inputs.suite == 'linux-integration-hybrid-prebuilt-sharded' }}
needs: linux-integration-hybrid-prebuilt-bd
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Download prebuilt bd
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: ci-measure-linux-integration-prebuilt-bd
path: prebuilt-bd
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure shard
env:
SHARD: ${{ matrix.shard }}
TOTAL_SHARDS: 8
BEADS_TEST_BD_BINARY: ${{ github.workspace }}/prebuilt-bd/bd
run: |
set -euo pipefail
mkdir -p artifacts
chmod +x "$BEADS_TEST_BD_BINARY"
source scripts/ci/lib/timing.sh
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
test_manifest="artifacts/linux-integration-cmd-bd-tests-${SHARD}-of-${TOTAL_SHARDS}.txt"
write_test_manifest() {
GO_TEST_SHARD_TAGS=integration,gms_pure_go \
scripts/ci/go-test-shard-names.sh "$SHARD" "$TOTAL_SHARDS" ./cmd/bd > "$test_manifest"
}
ci_time "list cmd/bd test shard ${SHARD}/${TOTAL_SHARDS}" -- write_test_manifest
cat "$test_manifest"
mapfile -t tests < "$test_manifest"
if [[ "${#tests[@]}" -eq 0 ]]; then
echo "No tests assigned to shard ${SHARD}/${TOTAL_SHARDS}; skipping go test"
exit 0
fi
run_regex="^($(IFS='|'; echo "${tests[*]}"))$"
ci_time "linux integration prebuilt cmd/bd shard ${SHARD}/${TOTAL_SHARDS} go test" -- \
env BEADS_TEST_SKIP=dolt gotestsum \
--junitfile "artifacts/linux-integration-prebuilt-cmd-bd-${SHARD}-of-${TOTAL_SHARDS}.xml" \
--format testdox \
-- -v -race -tags=integration,gms_pure_go -timeout=30m -run "$run_regex" ./cmd/bd
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration-prebuilt-cmd-bd-${{ matrix.shard }}-of-8
path: artifacts/
retention-days: 7
if-no-files-found: ignore
linux-integration-coverage:
name: Measure Linux integration coverage
if: ${{ inputs.suite == 'linux-integration-coverage' }}
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Measure commands
run: |
set -euo pipefail
mkdir -p artifacts
source scripts/ci/lib/timing.sh
ci_time "install gotestsum" -- go install gotest.tools/gotestsum@v1.13.0
status=0
ci_time "linux integration coverage go test" -- env BEADS_TEST_SKIP=dolt gotestsum --junitfile artifacts/linux-integration-coverage-junit.xml --format testdox -- -v -race -tags=integration,gms_pure_go -coverprofile=artifacts/coverage.out -timeout=30m ./... || status=$?
if [[ -f artifacts/coverage.out ]]; then
ci_time "coverage summary" -- go tool cover -func=artifacts/coverage.out || status=$?
else
echo "coverage.out was not generated; skipping coverage summary"
fi
exit "$status"
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-linux-integration-coverage
path: artifacts/
retention-days: 7
if-no-files-found: ignore
cross-version-smoke:
name: Measure cross-version smoke
if: ${{ inputs.suite == 'cross-version-smoke' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Cache previous release binaries
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ~/.cache/beads-regression
key: smoke-binaries-measure-${{ runner.os }}
- name: Measure commands
env:
GH_TOKEN: ${{ github.token }}
SMOKE_VERSION: ${{ inputs.smoke_version }}
run: |
set -euo pipefail
source scripts/ci/lib/timing.sh
source ./.buildflags
ci_time "build candidate binary" -- go build -tags gms_pure_go -o /tmp/bd-candidate ./cmd/bd
export CANDIDATE_BIN=/tmp/bd-candidate
if [[ -z "$SMOKE_VERSION" ]]; then
SMOKE_VERSION="$(gh release list --repo "$GITHUB_REPOSITORY" --limit 1 --json tagName --jq '.[0].tagName')"
fi
if [[ -z "$SMOKE_VERSION" ]]; then
echo "Could not resolve a previous release tag for cross-version smoke"
exit 1
fi
ci_time "upgrade smoke ${SMOKE_VERSION}" -- ./scripts/upgrade-smoke-test.sh "$SMOKE_VERSION"
nix:
name: Measure nix build
if: ${{ inputs.suite == 'nix' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Install Nix
uses: DeterminateSystems/determinate-nix-action@527f17dd63d2d60d3e5552934bc84b9a33a14d11 # v3
- name: Measure commands
run: |
set -euo pipefail
source scripts/ci/lib/timing.sh
ci_time "nix build .#default" -- nix build .#default --print-build-logs
mcp-package:
name: Measure MCP package checks
if: ${{ inputs.suite == 'mcp-package' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.14'
- name: Measure commands
run: |
set -euo pipefail
source scripts/ci/lib/timing.sh
ci_time "install uv" -- pip install uv==0.11.16
ci_time "mcp package gate" -- make ci-package-mcp
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-mcp-package
path: integrations/beads-mcp/dist/
retention-days: 7
if-no-files-found: ignore
npm-package:
name: Measure npm package checks
if: ${{ inputs.suite == 'npm-package' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: '24'
- name: Measure commands
run: |
set -euo pipefail
source scripts/ci/lib/timing.sh
ci_time "npm package gate" -- make ci-package-npm
- name: Upload measurement artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ci-measure-npm-package
path: artifacts/
retention-days: 7
if-no-files-found: ignore

View file

@ -1,108 +0,0 @@
name: Conformance
# Runs the same two-tier storage conformance suite developers run locally:
# the in-process store corpus and the real-binary CLI harness.
on:
pull_request:
branches: [ main, 'release/**', 'hotfix/**' ]
# "Upgrade-relevant code" allowlist (spec-f7.md §2.4): any non-test Go
# change, build input, or this workflow's own inputs. Kept byte-for-byte
# identical (modulo each workflow's own file/script entries) across
# conformance.yml, migration-test.yml and cross-version-smoke.yml, and
# pinned by TestAdvisoryWorkflowPathFilters.
paths:
- '**.go'
- '!**_test.go'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- '.buildflags'
- '.github/workflows/conformance.yml'
- 'scripts/conformance.sh'
- 'test/conformance/**'
- 'internal/storage/embeddeddolt/conformance_test.go'
# F7c review fix S4: TestMain (the fixture that builds the
# pristine embedded-Dolt databases conformance_test.go and every
# other test in this package reuse) lives here, not in
# conformance_test.go itself; a PR editing only the fixture was
# previously excluded by '!**_test.go' with nothing to re-include it.
- 'internal/storage/embeddeddolt/test_fixture_test.go'
- 'backend/conformance/**'
push:
branches: [ main ]
paths:
- '**.go'
- '!**_test.go'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- '.buildflags'
- '.github/workflows/conformance.yml'
- 'scripts/conformance.sh'
- 'test/conformance/**'
- 'internal/storage/embeddeddolt/conformance_test.go'
# F7c review fix S4: TestMain (the fixture that builds the
# pristine embedded-Dolt databases conformance_test.go and every
# other test in this package reuse) lives here, not in
# conformance_test.go itself; a PR editing only the fixture was
# previously excluded by '!**_test.go' with nothing to re-include it.
- 'internal/storage/embeddeddolt/test_fixture_test.go'
- 'backend/conformance/**'
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
jobs:
conformance:
name: Storage backend conformance (embedded Dolt oracle)
timeout-minutes: 45
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
# F7c review fix N1: fail-closed. setup-go's own implicit cache
# must stay off on Blacksmith (it would try to use a GitHub-hosted
# cache entry Blacksmith can't see, and only the self-keyed
# blacksmith-sg-v1- restore below should feed this job there); the
# prior `!= 'self-hosted'` form fails OPEN (caching turns on) if
# runner.environment is ever empty/unknown for some future runner
# class, instead of staying off until proven github-hosted.
cache: ${{ runner.environment == 'github-hosted' }}
# F7c review fix S5: this job's own key copy must match main.yml's
# seeder key byte-for-byte (TestBlacksmithSetupGoCacheKeysMatchAcrossSeederAndConsumers),
# which now keys by UTC calendar day instead of github.sha so main
# pushes don't churn a multi-GB cache entry on every commit; this step
# computes that same day value locally so the key expression below
# resolves (steps.* references only resolve within the same job).
- name: Compute cache date
id: cache-date
if: runner.environment == 'self-hosted'
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Blacksmith setup-go cache
if: runner.environment == 'self-hosted'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: |
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Run conformance (embedded Dolt oracle)
run: ./scripts/conformance.sh

View file

@ -1,172 +0,0 @@
name: Cross-Version Smoke Tests
on:
# On tag push (release gate): test the last 30 releases for broad regression coverage
push:
tags:
- 'v*'
# On PR to main or a release branch: test only the last 5 releases for fast
# feedback. Release-targeted PRs are exactly the ones where cross-version
# upgrade breakage is most expensive to discover at tag time.
pull_request:
branches: [ main, 'release/**', 'hotfix/**' ]
# "Upgrade-relevant code" allowlist (spec-f7.md §2.4): kept identical
# (modulo each workflow's own file/script entries) across conformance.yml,
# migration-test.yml and cross-version-smoke.yml, and pinned by
# TestAdvisoryWorkflowPathFilters.
paths:
- '**.go'
- '!**_test.go'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- '.buildflags'
- '.github/workflows/cross-version-smoke.yml'
- 'scripts/upgrade-smoke-test.sh'
# Allow manual trigger with custom version count
workflow_dispatch:
inputs:
version_count:
description: 'Number of previous releases to test against'
required: false
default: '5'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
jobs:
# F7c: smoke's old 1-job-per-version matrix (up to 30 on tag push) folded
# into chunks of 5 versions each, resolved by the `versions` job below. Each
# chunk builds the candidate binary once and loops over
# upgrade-smoke-test.sh's own SMOKE_VERSIONS env var (which already
# self-reinvokes per version and collects failures, so a bad version in a
# chunk does not hide the rest).
smoke:
name: Upgrade smoke (chunk ${{ strategy.job-index }})
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
chunk: ${{ fromJson(needs.versions.outputs.chunks) }}
needs: versions
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: ${{ runner.environment == 'github-hosted' }}
# F7c review fix S5: this job's own key copy must match main.yml's
# seeder key byte-for-byte (TestBlacksmithSetupGoCacheKeysMatchAcrossSeederAndConsumers),
# which now keys by UTC calendar day instead of github.sha so main
# pushes don't churn a multi-GB cache entry on every commit; this step
# computes that same day value locally so the key expression below
# resolves (steps.* references only resolve within the same job).
- name: Compute cache date
id: cache-date
if: runner.environment == 'self-hosted'
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Blacksmith setup-go cache
if: runner.environment == 'self-hosted'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: |
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Compute chunk cache key
id: chunk
env:
CHUNK_JSON: ${{ toJson(matrix.chunk) }}
run: |
versions="$(jq -r '. | join(" ")' <<<"$CHUNK_JSON")"
hash="$(printf '%s' "$versions" | sha256sum | cut -c1-16)"
echo "versions=$versions" >> "$GITHUB_OUTPUT"
echo "hash=$hash" >> "$GITHUB_OUTPUT"
# actions/cache (bare) auto-saves at job end on any key miss, which
# would let a same-repo PR that changes the chunk's version set write a
# binaries cache entry another PR (or a later run) could then read back
# without re-downloading or re-verifying it. Restore-only here; the
# matching save below is gated off pull_request so only push/dispatch
# runs can populate this cache (B2, F7c implementation report).
- name: Restore previous release binaries cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ~/.cache/beads-regression
key: smoke-binaries-${{ steps.chunk.outputs.hash }}-${{ runner.os }}
- name: Build candidate binary
run: go build -tags gms_pure_go -o /tmp/bd-candidate ./cmd/bd
- name: Run upgrade smoke tests
env:
CANDIDATE_BIN: /tmp/bd-candidate
SMOKE_VERSIONS: ${{ steps.chunk.outputs.versions }}
run: ./scripts/upgrade-smoke-test.sh
- name: Save previous release binaries cache
# Allow-list the two triggers this workflow actually intends to
# write from (push, workflow_dispatch), rather than deny-listing
# pull_request: a deny-list of `!= 'pull_request'` also admits a
# hypothetical future merge_group event, which this job's own
# runs-on expression already resolves to Blacksmith for - exactly
# the same same-repo-writer risk X1 closed for pull_request. Pinned
# by TestBlacksmithReachableAdvisoryJobsNeverSaveACache, which checks
# both the pull_request and merge_group trust contexts independently.
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ~/.cache/beads-regression
key: smoke-binaries-${{ steps.chunk.outputs.hash }}-${{ runner.os }}
versions:
name: Resolve versions to test
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 5
outputs:
chunks: ${{ steps.resolve.outputs.chunks }}
steps:
- name: Resolve release versions
id: resolve
env:
GH_TOKEN: ${{ github.token }}
# Tag push and manual dispatch test more versions; PRs test fewer for speed
VERSION_COUNT: ${{ (github.event_name == 'push' && '30') || (github.event_name == 'workflow_dispatch' && inputs.version_count) || '5' }}
run: |
VERSIONS=$(gh release list \
--repo gastownhall/beads \
--limit "$VERSION_COUNT" \
--json tagName \
--jq '[.[].tagName]')
# Chunks of 5: PRs (5 versions) get 1 chunk; tag pushes (30
# versions) get 6. Folds the old 1-job-per-version matrix down to
# one job per chunk in `smoke` above, without dropping any version.
CHUNKS=$(jq -c '[range(0; length; 5) as $i | .[$i:$i+5]]' <<<"$VERSIONS")
echo "chunks=$CHUNKS" >> "$GITHUB_OUTPUT"
echo "Testing versions: $VERSIONS"
echo "Chunks: $CHUNKS"

View file

@ -3,26 +3,15 @@ name: Docs (Mintlify) checks
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# The Mintlify site and the check itself. The docsync guard (docs nav,
# links and agent-instruction routing over docs/, engdocs/ and the root
# markdown) is //test/docsync:docsync_test, which bazel.yml's --config=ci
# lane runs on every PR; this workflow keeps only Mintlify's own
# broken-link check, which needs the network (npx mint) and the base
# branch's history.
paths:
# The docsync guard also validates engdocs/** and the curated root
# markdown files (rootDocFiles in test/docsync/docsync_test.go) — keep
# this filter in sync with that list, or a docs-breaking PR merges
# green and turns main red at the full test run.
- 'docs/**'
- 'engdocs/**'
- 'test/docsync/**'
- 'mint.sh'
- 'README.md'
- 'AGENTS.md'
- 'AGENT_INSTRUCTIONS.md'
- 'CONTRIBUTING.md'
- 'CLAUDE.md'
- 'RELEASING.md'
- 'PR_MAINTAINER_GUIDELINES.md'
- 'ROADMAP.md'
- '**/AGENTS.md'
- '**/CLAUDE.md'
- '.github/copilot-instructions.md'
- '.github/scripts/docs-render-check.sh'
- '.github/workflows/docs-mintlify.yml'
@ -34,47 +23,6 @@ concurrency:
cancel-in-progress: true
jobs:
docsync:
name: Docs nav/link sync (docsync guard)
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 10
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: ${{ runner.environment == 'github-hosted' }}
# F7c review fix S5: this job's own key copy must match main.yml's
# seeder key byte-for-byte (TestBlacksmithSetupGoCacheKeysMatchAcrossSeederAndConsumers),
# which now keys by UTC calendar day instead of github.sha so main
# pushes don't churn a multi-GB cache entry on every commit; this step
# computes that same day value locally so the key expression below
# resolves (steps.* references only resolve within the same job).
- name: Compute cache date
id: cache-date
if: runner.environment == 'self-hosted'
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Blacksmith setup-go cache
if: runner.environment == 'self-hosted'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: |
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Run docsync guard
run: go test -tags=gms_pure_go ./test/docsync
broken-links:
name: Mintlify broken-links (baseline-aware)
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}

File diff suppressed because it is too large Load diff

View file

@ -1,264 +0,0 @@
name: Migration Test Harness
on:
pull_request:
# "Upgrade-relevant code" allowlist (spec-f7.md §2.4): kept identical
# (modulo each workflow's own file/script entries) across conformance.yml,
# migration-test.yml and cross-version-smoke.yml, and pinned by
# TestAdvisoryWorkflowPathFilters.
paths:
- '**.go'
- '!**_test.go'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- '.buildflags'
- '.github/workflows/migration-test.yml'
- 'scripts/migration-test/**'
- 'scripts/migrate-legacy-to-current.sh'
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
DOLT_TEST_RUNTIME_VERSION: v2.1.8
DOLT_TEST_RUNTIME_SHA256: f66318f08ed66e409fc39363ae0fff8ce6fbf6dba9f5bac632b91527b9632a74
jobs:
historical-upgrades:
name: Historical ${{ matrix.shard }} shard → candidate
# v0.55.4 is dynamically linked against the ICU version shipped by Ubuntu
# 24.04's libicu74 package. blacksmith-*-ubuntu-2404 IS 24.04, so the pin
# holds there. The non-Blacksmith fallback below is pinned to the literal
# `ubuntu-24.04` label (NOT `ubuntu-latest`) for the same reason:
# actions/runner-images#14748 schedules `ubuntu-latest` to move from 24.04
# to 26.04 starting 2026-10-19, and 26.04 drops libicu74 entirely, which
# would break the "Install test dependencies" step below and the v0.55.4
# fixture's ICU ABI even if it didn't. Do not change this fallback to
# `ubuntu-latest`; see sameRepoBlacksmith4vcpuNoble in ci_workflow_test.go.
# F7c: 14 matrix legs (one per historical version) folded into 3 shards.
# Each shard builds the candidate once, installs its own dependencies
# once, then loops over `run.sh --version` for every version it owns,
# collecting failures so one bad version does not hide the rest (see
# "Verify explicit historical upgrades" below).
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
# src: the one version built from source against Go 1.25, instead
# of installed as a pinned binary.
- shard: src
versions: '["v0.9.1"]'
cache-hash: 453aa2e25bbad328
# pre-dolt: historical versions that predate the separate Dolt
# runtime oracle (no "Install Dolt test runtime" step needed).
- shard: pre-dolt
versions: '["v0.17.0","v0.49.6","v0.50.3","v0.63.3","v1.0.0"]'
cache-hash: 03cccab45291ead3
# dolt-runtime: versions that need the pinned Dolt runtime binary
# as a read-only oracle (the old per-version `contains(...)` list).
- shard: dolt-runtime
versions: '["v0.55.4","v0.56.1","v0.57.0","v0.62.0","v1.0.1","v1.1.0","v1.1.2","v1.2.2"]'
cache-hash: a8579bd64e9a0926
# The v1.1.2 tree re-tagged by the recovery release, so it adds no
# new storage regime — but it is the tag field upgrades actually
# start from, and it was never in this corpus.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: ${{ runner.environment == 'github-hosted' }}
# Blacksmith runners cannot see GitHub-hosted setup-go cache entries, so
# setup-go's own `cache: true` (used above on ubuntu-24.04/ubuntu-latest)
# is disabled here and this job restores from the Blacksmith-side cache
# main.yml's blacksmith-setup-go-cache job seeds on every push to main.
# Restore-only by design (see B2 in the F7c implementation report): a
# same-repo PR can read this cache but never write to it, so a PR cannot
# poison what main's seeder or other PRs read.
# F7c review fix S5: this job's own key copy must match main.yml's
# seeder key byte-for-byte (TestBlacksmithSetupGoCacheKeysMatchAcrossSeederAndConsumers),
# which now keys by UTC calendar day instead of github.sha so main
# pushes don't churn a multi-GB cache entry on every commit; this step
# computes that same day value locally so the key expression below
# resolves (steps.* references only resolve within the same job).
- name: Compute cache date
id: cache-date
if: runner.environment == 'self-hosted'
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Blacksmith setup-go cache
if: runner.environment == 'self-hosted'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: |
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Install test dependencies
# Backstop for a hang that escapes the inner `timeout` calls, so it has
# to sit ABOVE what those calls can legitimately consume: 3 update
# attempts x 120s + 2 backoffs x 10s + 180s install = 560s worst case.
# 11m leaves ~100s of headroom and stays under the job's 20m budget, so
# a stuck step fails as a step instead of cancelling the whole job.
timeout-minutes: 11
run: |
updated=""
for attempt in 1 2 3; do
if sudo timeout 120 apt-get \
-o Acquire::Retries=3 \
-o Acquire::http::Timeout=30 \
-o Acquire::https::Timeout=30 \
update; then
updated=yes
break
fi
echo "::warning::apt-get update attempt $attempt failed or timed out"
# No backoff after the final attempt - there is nothing left to wait for.
if [ "$attempt" -lt 3 ]; then
sleep 10
fi
done
# Deliberate best-effort: a stale index still installs these packages
# from the runner image cache far more often than not, and failing the
# job here would turn a transient mirror outage into a red build. The
# warning is what makes the degraded path visible in the job log.
if [ -z "$updated" ]; then
echo "::warning::apt-get update failed after 3 attempts; proceeding with cached index"
fi
sudo timeout 180 apt-get install -y jq libicu74
- name: Install Dolt test runtime
# v0.55.4-v0.62.0 host their fixture on this server; v1.0.1-v1.1.2 use
# the same pinned binary as a read-only oracle over the wisp plane,
# which has no `bd dolt sql` equivalent. This is exactly the
# dolt-runtime shard's version list.
if: matrix.shard == 'dolt-runtime'
run: |
archive="$RUNNER_TEMP/dolt-linux-amd64.tar.gz"
runtime="$RUNNER_TEMP/dolt-runtime"
install_root="$GITHUB_WORKSPACE/.tools/dolt"
curl -fsSL --retry 3 --retry-all-errors --retry-delay 2 \
"https://github.com/dolthub/dolt/releases/download/${DOLT_TEST_RUNTIME_VERSION}/dolt-linux-amd64.tar.gz" \
-o "$archive"
echo "${DOLT_TEST_RUNTIME_SHA256} $archive" | sha256sum -c -
mkdir -p "$runtime" "$install_root/bin"
tar -xzf "$archive" -C "$runtime"
install -m 0755 "$runtime/dolt-linux-amd64/bin/dolt" "$install_root/bin/dolt"
"$install_root/bin/dolt" version
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
# F7c review fix X1: a bare actions/cache here would auto-save on any
# key miss. On Blacksmith, same-repo PRs are the only ones that ever
# run this job (tag push and workflow_dispatch land on ubuntu-24.04,
# not Blacksmith), so a bare save would make every historical-dolt-*
# entry a same-repo-PR-only write - exactly what B2 forbids elsewhere.
# The checksum verification lib/binary.sh does on every extracted
# archive is not a sufficient mitigation: `tar -P` extraction plus
# `cp -f` following a planted `verified/<ver>/bd` symlink can still
# write outside ~/.cache/beads-regression (e.g. over the checked-out
# workspace or the candidate binary itself) before the checksum check
# ever runs. Restore-only here, same split as smoke-binaries-*/
# regression-baseline-* below: only push/dispatch (always GitHub-hosted
# for this job) may save.
- name: Restore pinned historical release cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/beads-regression
key: historical-dolt-${{ matrix.shard }}-${{ matrix.cache-hash }}-${{ runner.os }}-${{ runner.arch }}
- name: Build candidate
run: make build
- name: Set up Go 1.25 for v0.9.1 source build
if: matrix.shard == 'src'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.25.0'
# No Blacksmith restore step for this narrow one-off (src shard
# only, a single version): accepting a cold build here rather than
# adding a second seeded cache keyspace for one matrix leg.
cache: ${{ runner.environment == 'github-hosted' }}
# Each version runs as its own `run.sh` subprocess: the underlying
# historical-dolt-upgrade-test.sh uses `set -euo pipefail` and aborts at
# its first failure within one process, so a single multi-version
# invocation could silently hide every version queued after the first
# failure. Looping subprocess calls here, guarded by `if !`, is what
# lets "all versions run, and the job fails if any failed" (spec-f7.md
# §2.3.7) hold for shards with more than one version.
- name: Verify explicit historical upgrades
env:
CANDIDATE_BIN: ./bd
GIT_CONFIG_NOSYSTEM: "1"
DOLT_BIN: ${{ github.workspace }}/.tools/dolt/bin/dolt
SHARD_VERSIONS: ${{ matrix.versions }}
SHARD: ${{ matrix.shard }}
run: |
set -euo pipefail
mapfile -t versions < <(jq -r '.[]' <<<"$SHARD_VERSIONS")
# Fail closed: `jq -r '.[]'` over an empty array, a non-array
# scalar, or unparsable JSON all produce zero lines rather than a
# non-zero exit under process substitution, so mapfile would
# otherwise silently succeed with an empty $versions and this step
# would report green having verified nothing.
if [ "${#versions[@]}" -eq 0 ]; then
echo "::error::shard $SHARD resolved to zero versions from SHARD_VERSIONS=$SHARD_VERSIONS; failing closed instead of reporting a false pass"
exit 1
fi
failed=0
failed_versions=()
for v in "${versions[@]}"; do
echo "::group::Historical upgrade: $v"
# 8m per version plus a 30s SIGKILL grace: observed real runs take
# well under a minute, so this only trips on a genuine hang, and
# bounds the damage to one version's budget instead of a stuck
# subprocess silently consuming the rest of the job's 20m timeout
# and hiding every version queued after it.
if ! timeout --kill-after=30s 8m ./scripts/migration-test/run.sh --version "$v"; then
echo "::error::historical upgrade failed for $v"
failed=1
failed_versions+=("$v")
fi
echo "::endgroup::"
done
if [ "${#failed_versions[@]}" -gt 0 ]; then
{
echo "### Failed historical upgrades (shard $SHARD)"
printf -- '- %s\n' "${failed_versions[@]}"
} >> "$GITHUB_STEP_SUMMARY"
fi
exit "$failed"
- name: Save pinned historical release cache
# Allow-list push/workflow_dispatch rather than deny-list
# pull_request: a deny-list also admits a hypothetical future
# merge_group event, which this job's runs-on expression already
# resolves to Blacksmith for - exactly the same same-repo-writer
# risk X1 closed for pull_request. Pinned by
# TestBlacksmithReachableAdvisoryJobsNeverSaveACache (checks both the
# pull_request and merge_group trust contexts independently).
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/beads-regression
key: historical-dolt-${{ matrix.shard }}-${{ matrix.cache-hash }}-${{ runner.os }}-${{ runner.arch }}

View file

@ -1,110 +1,42 @@
name: Nightly Full Tests
name: Nightly
# Every nightly test runs under Bazel on rbe-west: the `bazel` call below is
# the full suite with no cached test results. Nothing here runs go test on a
# runner (ga-96smfk.22).
on:
schedule:
# Run at 2am UTC daily
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
suite:
description: "Nightly suite or measurement suite"
required: true
type: choice
default: full-test
options:
- full-test
- pr-linux
- macos-short
- macos-candidates
- linux-integration
- linux-integration-sharded
- linux-integration-hybrid-sharded
- linux-integration-hybrid-16-sharded
- linux-integration-hybrid-prebuilt-sharded
- linux-integration-coverage
- cross-version-smoke
- nix
- mcp-package
- npm-package
- bazel
smoke_version:
description: "Optional previous release for cross-version-smoke"
required: false
default: ""
permissions:
contents: read
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
jobs:
measure:
name: Measure selected CI suite
if: ${{ github.event_name == 'workflow_dispatch' && inputs.suite != 'full-test' && inputs.suite != 'bazel' }}
uses: ./.github/workflows/ci-measurements.yml
with:
suite: ${{ inputs.suite }}
smoke_version: ${{ inputs.smoke_version }}
# PR Core's go test (scripts/ci/pr-core.sh) with -json output, so the Bazel
# job below can compare per-test status: a test that passes here and skips
# under Bazel fails the equivalence check unless allowlisted.
bazel-go-test-json:
name: Bazel equivalence (go-test side)
if: ${{ github.event_name == 'schedule' || inputs.suite == 'bazel' }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Restore Go module cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Run PR core go-test (JSON)
env:
BEADS_PR_CORE_GO_TEST_JSON: ${{ runner.temp }}/go-test.json
run: make ci-pr-core
# Uploaded even when tests fail: the status comparison still applies.
- name: Upload go-test results
if: ${{ always() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: bazel-equivalence-go-test-json
path: ${{ runner.temp }}/go-test.json
if-no-files-found: error
retention-days: 7
# Bazel lane with the full go test equivalence listing and the skip-parity
# check (reported here; PRs gate on it through pr.yml). Remote execution
# when the repo secrets are present; bazel.yml gets the four RBE secrets
# plus rbe-prewarm's bazel-allocator app private key (same-repo/scheduled
# trigger only, so pre-warming is safe here - see bazel.yml's
# "rbe-west Pre-warm" header and engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md).
# Bazel lane with the full equivalence listing (package and test-name sets;
# PRs gate on it through pr.yml). Remote execution when the repo secrets
# are present; bazel.yml gets the four RBE secrets plus rbe-prewarm's
# bazel-allocator app private key (same-repo/scheduled trigger only, so
# pre-warming is safe here - see bazel.yml's "rbe-west Pre-warm" header and
# engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md).
bazel:
name: Bazel equivalence (full detail)
needs: bazel-go-test-json
if: ${{ !cancelled() && (github.event_name == 'schedule' || inputs.suite == 'bazel') }}
name: Bazel (fresh, full detail)
# A called workflow's job gets at most this call's token permissions, and
# GitHub checks them when the run starts, even for a job whose if: skips
# it (startup_failure otherwise; gascity #7478): bazel.yml's rrc-seed asks
# id-token: write (push to main only) and rrc-verify issues: write
# (schedule and dispatch only). rrc-verify runs here (its alert issue);
# rrc-seed never does, every other bazel.yml job keeps contents: read,
# and rbe-west's mint refuses any OIDC token but a main-push bazel.yml one
# (scripts/bazel_rrc_test.go, TestBazelWorkflowCallersGrantEveryRequestedPermission).
permissions:
contents: read
id-token: write
issues: write
uses: ./.github/workflows/bazel.yml
secrets:
RBE_WEST_EXECUTOR: ${{ secrets.RBE_WEST_EXECUTOR }}
@ -114,98 +46,46 @@ jobs:
RBE_POOL_APP_PRIVATE_KEY: ${{ secrets.RBE_POOL_APP_PRIVATE_KEY }}
with:
details: true
go-test-json-artifact: bazel-equivalence-go-test-json
# The one run that re-executes every test (no cached test results):
# PRs, merge groups and pushes to main reuse unchanged tests' PASSes,
# so this keeps sampling flaky and -race failures every night.
fresh-test-results: true
full-test:
name: Full Test Suite
if: ${{ github.event_name == 'schedule' || inputs.suite == 'full-test' }}
# rbe-west's pool workers are gascity's and advertise the sha256 of
# gascity's worker-env manifest; beads' tools/rbe/worker-env.txt is a
# byte-for-byte copy and platforms/BUILD.bazel carries the same pin. A copy
# that falls behind queues every remote action (bazel.yml's rbe job runs
# the same check before each remote run and fails it fast), so check every
# night and, out of step, open or update a ci/infra issue with the diff and
# the pin to commit (tools/rbe/worker-env-sync-issue). The only job here
# with issues: write, and only its last step uses the token. gascity
# unreachable (exit 2) fails the job without an issue.
rbe-worker-env-sync:
name: rbe worker-env in step with gascity
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 5
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
persist-credentials: false
- name: Install Dolt
run: |
./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Build
run: go build -v -tags gms_pure_go ./cmd/bd
- name: Full Test Suite (including integration tests)
- name: Compare the worker-env manifest and pin with gascity's main
id: sync
env:
# Skip Docker-based Dolt testcontainer tests — they hang in
# GitHub Actions (known issue, see scripts/repro-dolt-hang/).
# Non-Docker integration tests still run via the installed dolt binary.
BEADS_TEST_SKIP: dolt
run: go test -v -race -tags=integration,gms_pure_go -coverprofile=coverage.out -timeout=30m ./...
# The suite above never sets BEADS_TEST_EMBEDDED_DOLT, so every
# skipUnlessEmbeddedDolt-gated test in internal/storage/embeddeddolt
# (including TestBatchApplyContract, the 1000-item case of
# TestLargeBatchApplyWallClock_Embedded, and — F1 — the 712-item case of
# TestLargeBatchApplyStatementCounts712_Embedded) is skipped there, on
# every lane, not just this one. This step is their only non-race
# coverage of a real 1000-item apply through the embedded backend, and
# (F1) the only coverage at all of the 712-item shape's pinned
# statement-count regression baseline on a per-PR race lane: the race
# lanes (main.yml, pr-risk.yml) shrink/skip those cases under
# raceEnabled — see
# internal/storage/embeddeddolt/large_batch_apply_measure_test.go — and
# the PR-conditional server-Dolt full suite (full_embedded in
# .github/scripts/ci-embedded-tier.sh) covers the SAME write body
# (internal/storage/issueops.ApplyBatchInTx) through a different
# backend, not this one. Non-race here because the embedded engine's
# own goroutine/lock machinery runs inside this test binary and the
# race detector dramatically inflates its wall-clock (see
# race_detector_on_test.go), which is exactly what
# TestLargeBatchApplyWallClock_Embedded is measuring and exactly why
# TestLargeBatchApplyStatementCounts712_Embedded's 712-item case takes
# ~260-300s under -race (genuine engine-internal race overhead, not
# test logic — see that test's doc comment). The same holds for the
# 458-issue batch-create equivalence scenarios
# (TestCreateBatchFastPathsMatchPerRowLarge_Embedded).
- name: Embedded Dolt batch-apply suite (non-race)
if: ${{ !cancelled() }}
env:
BEADS_TEST_EMBEDDED_DOLT: "1"
run: go test -tags gms_pure_go -timeout 20m -run '^(TestBatchApplyContract|TestLargeBatchApplyWallClock_Embedded|TestLargeBatchApplyStatementCounts712_Embedded|TestCreateBatchFastPathsMatchPerRowLarge_Embedded)$' ./internal/storage/embeddeddolt
- name: Check coverage threshold
WORKER_ENV_SYNC_REPORT: ${{ runner.temp }}/worker-env-sync.md
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Coverage: $COVERAGE%"
# Threshold is lower (30%) because Docker-based Dolt integration
# tests are skipped in CI (BEADS_TEST_SKIP=dolt). With Docker
# tests included, coverage would be ~50%+.
if (( $(echo "$COVERAGE < 30" | bc -l) )); then
echo "❌ Coverage is below 30% threshold"
exit 1
elif (( $(echo "$COVERAGE < 40" | bc -l) )); then
echo "⚠️ Coverage is below 40% (warning threshold)"
else
echo "✅ Coverage meets threshold"
fi
rc=0
tools/rbe/worker-env-sync main || rc=$?
echo "rc=$rc" >> "$GITHUB_OUTPUT"
exit "$rc"
- name: Upload coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6
if: success()
continue-on-error: true
with:
file: ./coverage.out
fail_ci_if_error: false
- name: Open or update the out-of-step issue
if: ${{ failure() && steps.sync.outputs.rc == '1' }}
env:
GH_TOKEN: ${{ github.token }}
REPORT: ${{ runner.temp }}/worker-env-sync.md
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: tools/rbe/worker-env-sync-issue "$REPORT" "$RUN_URL"

View file

@ -20,558 +20,17 @@ concurrency:
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
# D2: "true" retires a PR Risk legacy tier on same-repo, non-Dependabot
# pull_requests and on merge groups (merge queue); pr.yml's gated Bazel lane(s) for it are then the tier's
# only pre-merge run, and pr.yml's gate goes red unless they ran remotely
# and passed. Committed, not repo variables, so a re-run can never change
# them; each must equal pr.yml's / pr-risk.yml's copy
# (scripts/pr_risk_bazel_coverage_test.go). Revert: commit "false" in both
# workflows (in-flight PRs pick it up on their next push or merge of main).
# Step 1: the embedded-Dolt test jobs (Bazel `embedded Dolt tier`).
BAZEL_RETIRES_LEGACY_EMBEDDED: "true"
# Step 2: the proxied-server and server-Dolt storage test jobs (Bazel
# `proxied-server tier` and `server-Dolt storage tier`).
BAZEL_RETIRES_LEGACY_DOLT_SERVER_TIERS: "true"
# Step 3: pr.yml's own legacy jobs whose Bazel lanes run in the same pr.yml
# run: PR Core, build-artifacts, the pure-Go/js-wasm check, domain+uow and
# contract corpus (Bazel `test`, `pure-Go and js/wasm`, `dolt-server
# lane`). pr-risk.yml retires nothing for it; its copy only keeps the
# shared bazel-coverage job identical.
BAZEL_RETIRES_LEGACY_PR_LANES: "true"
# Fork and Dependabot PRs: "true" covers them like same-repo PRs (the
# flags above then retire their legacy tiers too): rbe-west's mint
# (rbe-fork) gives their Bazel lanes remote execution, instance oss-fork
# or, for allowlisted authors, oss, and a run the mint does not serve
# (mode cache) is red. "false": they keep the legacy tiers, and the Bazel
# lanes run remotely beside them whenever rbe-fork is open (bazel.yml
# modes fork-ro/fork-rw), else locally with the read-only cache as before.
BAZEL_COVERS_FORKS: "false"
# The legacy Go test tiers this workflow used to run (embedded Dolt storage,
# conformance and cmd shards; proxied-server cmd shards; server-Dolt storage
# and full suite) are pr.yml's Bazel lanes on rbe-west now: `embedded Dolt
# tier`, `proxied-server tier` (`dolt-race`, with the dolt-server lane, in
# mode remote) and `server-Dolt storage tier` (bazel.yml), which pr.yml's `CI Gate / Required` requires to have run remotely and
# passed on every pull_request and merge group, fork and Dependabot PRs
# included (ga-96smfk.22). What remains is the Nix packaging check, which no
# Bazel target can stand in for: it builds the package Nix users install.
jobs:
detect-ci-tier:
name: Detect CI tier
# F3: same-repo PRs and merge_group get the org's Blacksmith pool; forks,
# Dependabot and any other event stay GitHub-hosted. This job restores no
# GitHub-saved cache.
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}
# F3: now on Blacksmith for same-repo PRs; a hang used to burn only the
# default 360 minutes of a free GitHub-hosted runner, now Blacksmith
# minutes too.
timeout-minutes: 10
outputs:
full_embedded: ${{ steps.tier.outputs.full_embedded }}
reason: ${{ steps.tier.outputs.reason }}
shadow_embedded_cli: ${{ steps.shadow-selector.outputs.embedded_cli }}
shadow_proxied_cli: ${{ steps.shadow-selector.outputs.proxied_cli }}
shadow_embedded_storage: ${{ steps.shadow-selector.outputs.embedded_storage }}
shadow_embedded_conformance: ${{ steps.shadow-selector.outputs.embedded_conformance }}
shadow_server_conformance: ${{ steps.shadow-selector.outputs.server_conformance }}
shadow_full: ${{ steps.shadow-selector.outputs.full }}
shadow_reason: ${{ steps.shadow-selector.outputs.reason }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
- name: Decide embedded Dolt coverage
id: tier
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: bash .github/scripts/ci-embedded-tier.sh
- name: Shadow CI capability selector
id: shadow-selector
continue-on-error: true
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -o pipefail
selection="$(bash .github/scripts/ci-capability-selector.sh)"
printf '%s\n' "$selection"
{
echo '### Shadow CI capability selector'
printf '%s\n' "$selection" | sed 's/^/- `/' | sed 's/$/`/'
} >> "$GITHUB_STEP_SUMMARY"
# D2: which legacy tiers below stand down because pr.yml's gated Bazel
# lanes run them instead: `embedded` (the test-embedded-* jobs; Bazel
# `embedded Dolt tier`) and `dolt_server` (test-proxied-cmd and the
# test-server-storage* jobs; Bazel `proxied-server tier` and `server-Dolt
# storage tier`), plus `pr_lanes`, which only pr.yml reads (its own PR
# Core, build-artifacts, pure-Go, domain+uow and contract corpus jobs).
# Each is true only with its committed BAZEL_RETIRES_LEGACY_* flag, on a
# same-repo (not fork) pull_request whose actor is not Dependabot, or on a
# merge_group (merge queue) run. pr.yml runs this same job (policy-tested
# identical) and its gate goes red unless the lanes then ran remotely and
# passed, so neither the kill switch (mode skip) nor a missing executor
# secret (mode cache) can silently drop a tier. Forks and Dependabot (no
# secrets; unless BAZEL_COVERS_FORKS) and every other event keep the
# legacy tiers. The step reads no secret or variable and runs no
# repository code.
bazel-coverage:
name: Bazel tier coverage
# F3: same-repo PRs and merge_group get the org's Blacksmith pool; forks,
# Dependabot and any other event stay GitHub-hosted. This job restores no
# GitHub-saved cache, so Blacksmith's inability to see one does not cost
# it anything. Must stay byte-identical to pr.yml's copy
# (TestPRRiskBazelCoverageJob) and to the TestSameRepoBlacksmithRunners
# pin.
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 5
outputs:
embedded: ${{ steps.decide.outputs.embedded }}
dolt_server: ${{ steps.decide.outputs.dolt_server }}
pr_lanes: ${{ steps.decide.outputs.pr_lanes }}
steps:
# GitHub's == is case-insensitive. FORK is bazel.yml's rbe job's
# expression, verbatim. Nothing mutable is read: not RBE_WEST_WORKERS
# and not the executor secret (either, evaluated per run, would let one
# workflow's re-run disagree with the other's). A same-repo PR whose run
# lacks the secret is covered anyway, so pr.yml's gate goes red (mode
# cache) instead of a tier silently moving back. Fork and Dependabot
# runs get no Actions secrets by design: they are covered only while
# BAZEL_COVERS_FORKS is "true" (rbe-fork gives their lanes remote
# execution), and then a closed rbe-fork turns them red the same way;
# it never moves them back to a legacy tier silently. github.actor
# (unlike triggering_actor) stays the PR's actor on a re-run.
- name: Decide which legacy tiers the Bazel lanes cover
id: decide
env:
RETIRED_EMBEDDED: ${{ env.BAZEL_RETIRES_LEGACY_EMBEDDED == 'true' }}
RETIRED_DOLT_SERVER: ${{ env.BAZEL_RETIRES_LEGACY_DOLT_SERVER_TIERS == 'true' }}
RETIRED_PR_LANES: ${{ env.BAZEL_RETIRES_LEGACY_PR_LANES == 'true' }}
COVERS_FORKS: ${{ env.BAZEL_COVERS_FORKS == 'true' }}
PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
FORK: ${{ github.event.pull_request.head.repo.fork == true }}
DEPENDABOT: ${{ github.actor == 'dependabot[bot]' }}
run: |
for v in RETIRED_EMBEDDED RETIRED_DOLT_SERVER RETIRED_PR_LANES COVERS_FORKS PULL_REQUEST MERGE_GROUP FORK DEPENDABOT; do
case "${!v}" in
true|false) ;;
*) echo "::error::$v is '${!v}', want true or false"; exit 1 ;;
esac
done
# Covered: the Bazel lanes are this run's only run of the retired
# tiers. Same-repo PRs (the CI secrets); fork and Dependabot PRs
# too while BAZEL_COVERS_FORKS is "true"; and every merge group: it
# runs on the queue's gh-readonly-queue/* branch of this repository
# with the CI secrets, its actor is github-merge-queue[bot] (never
# Dependabot), and bazel.yml's rbe job takes mode remote for it
# like for a same-repo PR, so a missing secret or the farm switch
# off turns pr.yml's gate red rather than dropping a tier.
covered=false
if [ "$MERGE_GROUP" = true ]; then
covered=true
elif [ "$PULL_REQUEST" = true ]; then
if [ "$FORK" = false ] && [ "$DEPENDABOT" = false ]; then
covered=true
elif [ "$COVERS_FORKS" = true ]; then
covered=true
fi
fi
embedded=false
if [ "$covered" = true ] && [ "$RETIRED_EMBEDDED" = true ]; then
embedded=true
fi
dolt_server=false
if [ "$covered" = true ] && [ "$RETIRED_DOLT_SERVER" = true ]; then
dolt_server=true
fi
pr_lanes=false
if [ "$covered" = true ] && [ "$RETIRED_PR_LANES" = true ]; then
pr_lanes=true
fi
{
echo "embedded=$embedded"
echo "dolt_server=$dolt_server"
echo "pr_lanes=$pr_lanes"
} >> "$GITHUB_OUTPUT"
echo "Legacy tiers retired in favour of the Bazel lanes: embedded Dolt **$embedded**, proxied and server Dolt **$dolt_server**, pr.yml's PR Core/build/pure-Go/domain+uow/contract jobs **$pr_lanes** (pull_request: $PULL_REQUEST, merge_group: $MERGE_GROUP, fork: $FORK, dependabot: $DEPENDABOT, forks covered: $COVERS_FORKS, retired embedded: $RETIRED_EMBEDDED, retired proxied/server: $RETIRED_DOLT_SERVER, retired pr.yml jobs: $RETIRED_PR_LANES)" | tee -a "$GITHUB_STEP_SUMMARY"
# End-to-end coverage for proxied-server CLI subcommands, sharded across the
# CI matrix. Each sub-test drives the bd CLI subprocess against a real dolt
# sql-server started via testcontainers by the shared proxied harness
# (cmd/bd/*_proxied_integration_test.go).
#
# Reuses the cmd/bd test binary compiled once by build-embedded: the proxied
# tests live in the same package and are gated at runtime by
# BEADS_TEST_PROXIED_SERVER=1, so no separate build is needed. Shard
# assignment is committed in .github/scripts/proxied-cmd-test-shards.txt;
# newly-added TestProxiedServer*/TestServerMode* tests hash-distribute until
# listed there. Stands down, with the test-server-storage* jobs, where
# bazel-coverage's dolt_server says pr.yml's gated Bazel `proxied-server
# tier` lane runs it (D2 step 2).
test-proxied-cmd:
name: Test (Proxied Dolt Cmd ${{ matrix.shard }}/${{ strategy.job-total }})
needs: [detect-ci-tier, bazel-coverage, build-embedded]
if: needs.detect-ci-tier.outputs.full_embedded == 'true' && needs.bazel-coverage.outputs.dolt_server != 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: embedded-test-binaries
path: /tmp/
- name: Fix permissions
run: chmod +x /tmp/bd-proxied /tmp/bd-cmd-test
- name: Install Dolt CLI
# TestProxiedServerExternalCreate needs the dolt binary on PATH; the
# shared harness itself uses the dolt sql-server container image.
run: ./scripts/ci/install-dolt.sh
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Pull Dolt sql-server image
# The shared proxied harness requires the image cached locally
# (isDoltImageCached); without it every proxied test self-skips. Keep the
# tag in sync with internal/testutil/testdoltcommon.go:DoltDockerImage.
run: ./scripts/ci/pull-dolt-image.sh
- name: Test proxied-server cmd shard
timeout-minutes: 16
env:
BEADS_TEST_PROXIED_SERVER: "1"
BEADS_TEST_BD_BINARY: /tmp/bd-proxied
BEADS_TEST_CMD_BINARY: /tmp/bd-cmd-test
run: bash .github/scripts/proxied-test-shard.sh ${{ matrix.shard }} 15
# Embedded Dolt tests - test the in-process Dolt engine (no server required)
#
# Split into: build → storage tests + parallel cmd test shards.
# cmd/bd embedded tests use a committed shard manifest; newly-added tests
# still auto-distribute via hash fallback until the manifest is updated.
#
# The storage, conformance and cmd test jobs stand down when
# bazel-coverage says pr.yml's gated Bazel `embedded Dolt tier` lane runs
# them instead (its `embedded` output); the proxied and server Dolt jobs
# when its Bazel `proxied-server tier` and `server-Dolt storage tier` lanes
# do (`dolt_server`). build-embedded's embedded-test-binaries artifact
# feeds all six (and nothing else), so it stands down only when both do.
build-embedded:
name: Build (Embedded Dolt)
needs: [detect-ci-tier, bazel-coverage]
if: needs.detect-ci-tier.outputs.full_embedded == 'true' && (needs.bazel-coverage.outputs.embedded != 'true' || needs.bazel-coverage.outputs.dolt_server != 'true')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: false
- name: Restore Go module cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/go/pkg/mod
key: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}
restore-keys: beads-go-mod-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Restore race Go build cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-${{ github.sha }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-race-
- name: Restore non-race Go build cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-cache/non-race
key: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-${{ github.sha }}
restore-keys: beads-go-build-v2-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-base-gms_pure_go-non-race-
- name: Build embedded bd binary
env:
GOCACHE: ${{ runner.temp }}/go-cache/race
run: go build -tags gms_pure_go -race -o /tmp/bd-embedded-test ./cmd/bd/
- name: Build embedded storage test binary
env:
GOCACHE: ${{ runner.temp }}/go-cache/race
run: go test -tags gms_pure_go -race -c -o /tmp/embeddeddolt-test ./internal/storage/embeddeddolt/
- name: Build embedded cmd test binary
env:
GOCACHE: ${{ runner.temp }}/go-cache/race
run: go test -tags gms_pure_go -race -c -o /tmp/bd-cmd-test ./cmd/bd/
# Non-race bd used as the proxied-server test subprocess. The proxied
# tests spawn bd many times per sub-test; a -race subprocess would slow
# every invocation, so build a plain binary for BEADS_TEST_BD_BINARY.
- name: Build proxied bd subprocess binary
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: go build -tags gms_pure_go -o /tmp/bd-proxied ./cmd/bd/
# Server-Dolt conformance binary. No -race: the Dolt server runs
# out-of-process in a container, and omitting it keeps the run inside the
# job's timeout. The dolt package self-skips without the docker image, so
# the binary is harmless if its job is gated off.
- name: Build server Dolt conformance test binary
env:
GOCACHE: ${{ runner.temp }}/go-cache/non-race
run: go test -tags=integration,gms_pure_go -c -o /tmp/dolt-conformance-test ./internal/storage/dolt/
- name: Upload binaries
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: embedded-test-binaries
path: |
/tmp/bd-embedded-test
/tmp/embeddeddolt-test
/tmp/bd-cmd-test
/tmp/bd-proxied
/tmp/dolt-conformance-test
retention-days: 1
test-embedded-storage:
name: Test (Embedded Dolt Storage ${{ matrix.shard }}/${{ strategy.job-total }})
needs: [detect-ci-tier, bazel-coverage, build-embedded]
if: needs.detect-ci-tier.outputs.full_embedded == 'true' && needs.bazel-coverage.outputs.embedded != 'true'
runs-on: ubuntu-latest
# The shard script's -test.timeout=20m plus setup. At 15m the 1000-item
# batch-apply cap cancelled shard 2/5: TestBatchApplyContract took 604s
# under -race (97s at the 100-item cap, main run 35862663577) and the
# shard hit 15m twice (run 36807191489). The manifest now pins the heavy
# tests apart; the heaviest shard projects to ~13m.
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: embedded-test-binaries
path: /tmp/
- name: Fix permissions
run: chmod +x /tmp/embeddeddolt-test
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Test
env:
BEADS_TEST_EMBEDDED_DOLT: "1"
BEADS_TEST_EMBEDDED_TEST_BINARY: /tmp/embeddeddolt-test
# Manifest-driven shard of the storage suite (mirrors test-embedded-cmd
# / embedded-test-shard.sh). Conformance runs separately in the
# dedicated test-embedded-conformance job; embedded-storage-test-shard.sh
# excludes TestConformance from discovery, so it never lands in one of
# these shards.
run: bash .github/scripts/embedded-storage-test-shard.sh ${{ matrix.shard }} 5
test-embedded-conformance:
name: Test (Embedded Dolt Conformance - ${{ matrix.partition }})
needs: [detect-ci-tier, bazel-coverage, build-embedded]
if: needs.detect-ci-tier.outputs.full_embedded == 'true' && needs.bazel-coverage.outputs.embedded != 'true'
runs-on: ubuntu-latest
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
partition: [core, audit]
env:
BEADS_TEST_EMBEDDED_DOLT: "1"
BEADS_TEST_EMBEDDED_TEST_BINARY: /tmp/embeddeddolt-test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: embedded-test-binaries
path: /tmp/
- name: Fix permissions
run: chmod +x /tmp/embeddeddolt-test
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Test core conformance
if: matrix.partition == 'core'
# RunAll has a natural Audit seam. Run everything except Audit in the
# core shard and Audit alone in the other shard. The combined suite has
# exceeded 30m under runner variance; each half currently takes ~15m.
# Keep the Go timeout below the job timeout so a real stall still emits
# a diagnostic goroutine dump before Actions stops the job.
run: /tmp/embeddeddolt-test -test.v -test.count=1 -test.timeout=30m -test.run '^TestConformance$' -test.skip '^TestConformance$/^Audit$'
- name: Test audit conformance
if: matrix.partition == 'audit'
run: /tmp/embeddeddolt-test -test.v -test.count=1 -test.timeout=30m -test.run '^TestConformance$/^Audit$'
test-server-storage:
name: Test (Server Dolt Conformance)
needs: [detect-ci-tier, bazel-coverage, build-embedded]
if: needs.detect-ci-tier.outputs.full_embedded == 'true' && needs.bazel-coverage.outputs.dolt_server != 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: embedded-test-binaries
path: /tmp/
- name: Fix permissions
run: chmod +x /tmp/dolt-conformance-test
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Dolt
run: |
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
dolt version
- name: Pull Dolt sql-server image
# Presence of this image flips isDoltImageCached() true, so the suite
# exercises server Dolt instead of self-skipping. Keep the tag in sync
# with internal/testutil/testdoltcommon.go:DoltDockerImage.
run: ./scripts/ci/pull-dolt-image.sh
- name: Test
# Server twin of test-embedded-conformance: same conformance.RunAll, but
# against the container-backed server-mode Dolt backend. No -short / no
# BEADS_TEST_SKIP=dolt, so TestMain starts the shared server and the
# suite runs instead of self-skipping.
run: /tmp/dolt-conformance-test -test.v -test.count=1 -test.timeout=15m -test.run '^TestConformance$'
test-server-storage-full:
name: Test (Server Dolt Full Suite ${{ matrix.shard }}/${{ strategy.job-total }})
needs: [detect-ci-tier, bazel-coverage, build-embedded]
if: needs.detect-ci-tier.outputs.full_embedded == 'true' && needs.bazel-coverage.outputs.dolt_server != 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: embedded-test-binaries
path: /tmp/
- name: Fix permissions
run: chmod +x /tmp/dolt-conformance-test
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Install Dolt
run: ./scripts/ci/install-dolt.sh
- name: Configure Dolt
run: |
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
dolt version
- name: Pull Dolt sql-server image
# Presence of this image flips isDoltImageCached() true, so the suite
# exercises server Dolt instead of self-skipping. Keep the tag in sync
# with internal/testutil/testdoltcommon.go:DoltDockerImage.
run: ./scripts/ci/pull-dolt-image.sh
- name: Test
# build-embedded's dolt-conformance-test binary compiles every
# top-level test in internal/storage/dolt, not just conformance --
# test-server-storage above only ever runs the ^TestConformance$
# subset. Everything else in that binary (TestCreateGuard_*,
# federation/create-guard/concurrent suites, and diff-owned tests such
# as TestBenchDBPurgeDoesNotLeak on PR #5792) was reached by no
# PR-triggered lane and silently SKIPped for lack of a live server.
# This sibling job reuses the same artifact and server setup and runs
# everything else instead, so a SKIP there gets a real PASS/FAIL.
#
# Manifest-driven shard of the full suite (mirrors test-embedded-storage
# / server-storage-test-shard.sh): 1126 tests in one 15m-Go-timeout job
# never finished (job 95616282508 died at 256/1126 tests, 15m28s in,
# zero failures -- it just ran out of time). server-storage-test-shard.sh
# excludes TestConformance from discovery, so it never lands in one of
# these shards.
env:
BEADS_TEST_ENV_RUN_DOLT: "1"
run: bash .github/scripts/server-storage-test-shard.sh ${{ matrix.shard }} 16
test-embedded-cmd:
name: Test (Embedded Dolt Cmd ${{ matrix.shard }}/${{ strategy.job-total }})
needs: [detect-ci-tier, bazel-coverage, build-embedded]
if: needs.detect-ci-tier.outputs.full_embedded == 'true' && needs.bazel-coverage.outputs.embedded != 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: embedded-test-binaries
path: /tmp/
- name: Fix permissions
run: chmod +x /tmp/bd-embedded-test /tmp/embeddeddolt-test /tmp/bd-cmd-test
- name: Configure Git
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Test
env:
BEADS_TEST_EMBEDDED_DOLT: "1"
BEADS_TEST_BD_BINARY: /tmp/bd-embedded-test
run: bash .github/scripts/embedded-test-shard.sh ${{ matrix.shard }} 20
test-nix:
name: Test Nix Flake
# F7a: cache-free (no GitHub-saved cache restored/saved here) same-repo
@ -586,10 +45,11 @@ jobs:
id: nix_help
run: |
nix run .#default -- --help > help.txt
# Every flake check for the runner's own system (today: hook-timeout-
# backends, checks.nix). `nix flake check` rather than a spelled-out
# `.#checks.x86_64-linux.<name>`: no hardcoded system, and a check added
# to checks.nix is run without a workflow edit.
# A packaging check, not a test: evaluates every flake output (packages,
# apps, devShells, overlay) for every system the flake declares. The
# flake has no `checks`: its one check, hook-timeout-backends, runs
# under Bazel as //tests/hook_timeout_backends:hook_timeout_backends_test
# in bazel.yml's PR-core lane.
- name: Run the flake checks
run: |
nix flake check -L
@ -619,15 +79,6 @@ jobs:
# minutes too.
timeout-minutes: 10
needs:
- detect-ci-tier
- bazel-coverage
- build-embedded
- test-embedded-storage
- test-embedded-conformance
- test-server-storage
- test-server-storage-full
- test-embedded-cmd
- test-proxied-cmd
- test-nix
if: ${{ always() }}
steps:
@ -637,47 +88,6 @@ jobs:
env:
CI_GATE_NAME: PR risk gate
CI_GATE_REQUIRED: >-
DETECT_CI_TIER
BAZEL_COVERAGE
BUILD_EMBEDDED
TEST_EMBEDDED_STORAGE
TEST_EMBEDDED_CONFORMANCE
TEST_SERVER_STORAGE
TEST_SERVER_STORAGE_FULL
TEST_EMBEDDED_CMD
TEST_PROXIED_CMD
TEST_NIX
FULL_EMBEDDED: ${{ needs.detect-ci-tier.outputs.full_embedded }}
BAZEL_COVERS_EMBEDDED: ${{ needs.bazel-coverage.outputs.embedded }}
BAZEL_COVERS_DOLT_SERVER: ${{ needs.bazel-coverage.outputs.dolt_server }}
DETECT_CI_TIER: ${{ needs.detect-ci-tier.result }}
BAZEL_COVERAGE: ${{ needs.bazel-coverage.result }}
BUILD_EMBEDDED: ${{ needs.build-embedded.result }}
TEST_EMBEDDED_STORAGE: ${{ needs.test-embedded-storage.result }}
TEST_EMBEDDED_CONFORMANCE: ${{ needs.test-embedded-conformance.result }}
TEST_SERVER_STORAGE: ${{ needs.test-server-storage.result }}
TEST_SERVER_STORAGE_FULL: ${{ needs.test-server-storage-full.result }}
TEST_EMBEDDED_CMD: ${{ needs.test-embedded-cmd.result }}
TEST_PROXIED_CMD: ${{ needs.test-proxied-cmd.result }}
TEST_NIX: ${{ needs.test-nix.result }}
run: |
skipped_ok=""
if [[ "$FULL_EMBEDDED" != "true" ]]; then
skipped_ok="BUILD_EMBEDDED TEST_EMBEDDED_STORAGE TEST_EMBEDDED_CONFORMANCE TEST_SERVER_STORAGE TEST_SERVER_STORAGE_FULL TEST_EMBEDDED_CMD TEST_PROXIED_CMD"
fi
# The legacy tiers' test jobs stand down only where pr.yml's gated
# Bazel lanes run the tier (bazel-coverage), and build-embedded,
# whose artifact only they consume, only where all of them do; any
# other skip of them, or a failed or missing decision, fails the
# gate.
if [[ "$BAZEL_COVERS_EMBEDDED" == "true" ]]; then
skipped_ok="$skipped_ok TEST_EMBEDDED_STORAGE TEST_EMBEDDED_CONFORMANCE TEST_EMBEDDED_CMD"
fi
if [[ "$BAZEL_COVERS_DOLT_SERVER" == "true" ]]; then
skipped_ok="$skipped_ok TEST_PROXIED_CMD TEST_SERVER_STORAGE TEST_SERVER_STORAGE_FULL"
fi
if [[ "$BAZEL_COVERS_EMBEDDED" == "true" ]] && [[ "$BAZEL_COVERS_DOLT_SERVER" == "true" ]]; then
skipped_ok="$skipped_ok BUILD_EMBEDDED"
fi
export CI_GATE_SKIPPED_OK="$skipped_ok"
bash .github/scripts/ci-gate.sh
run: bash .github/scripts/ci-gate.sh

1476
.github/workflows/pr.yml vendored

File diff suppressed because it is too large Load diff

View file

@ -1,189 +0,0 @@
# Managed-local proxied lifecycle lane.
#
# The proxied shards in main.yml exercise command behavior against an
# EXTERNALLY managed Dolt testcontainer. This lane covers the production
# local-first path those shards cannot: bd launches its own loopback proxy,
# the proxy launches a locally installed `dolt sql-server`, and the whole
# lifecycle (create/read, loopback-only listeners, idle shutdown,
# transparent restart with persistence), identity failures, orphan recovery,
# and start/stop convergence run INSIDE a network namespace with only
# loopback up — proving no outbound network is needed once the binaries are
# installed. Linux first; the test lane defines Windows/macOS parity but does
# not implement those OS-specific observation helpers yet.
name: Proxied Local Lifecycle
on:
workflow_dispatch:
merge_group:
push:
branches: [main]
paths:
- 'cmd/bd/proxied_local_*'
- 'cmd/bd/proxied_server*.go'
- 'cmd/bd/dolt*.go'
- 'cmd/bd/*_proxied_server.go'
- 'cmd/bd/backup*.go'
- 'cmd/bd/purge*.go'
- 'cmd/bd/*managed_local*'
- 'cmd/bd/proxied_outage_reconnect_integration_test.go'
- 'cmd/bd/db_proxy_child.go'
- 'cmd/bd/init*.go'
- 'cmd/bd/proxied_integration_helpers_test.go'
- 'cmd/bd/store_factory*.go'
- 'cmd/bd/test_dolt_server_cgo_test.go'
- 'cmd/bd/tracker_proxy_uow_conformance_integration_test.go'
- 'cmd/bd/uow_factory.go'
- 'internal/configfile/**'
- 'internal/doltserver/**'
- 'internal/storage/dbproxy/**'
- 'internal/storage/uow/**'
- 'internal/tracker/conformance/**'
- 'internal/tracker/uow_store.go'
- 'internal/tracker/engine.go'
- 'internal/tracker/store.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/proxied-local-smoke.yml'
pull_request:
paths:
- 'cmd/bd/proxied_local_*'
- 'cmd/bd/proxied_server*.go'
- 'cmd/bd/dolt*.go'
- 'cmd/bd/*_proxied_server.go'
- 'cmd/bd/backup*.go'
- 'cmd/bd/purge*.go'
- 'cmd/bd/*managed_local*'
- 'cmd/bd/proxied_outage_reconnect_integration_test.go'
- 'cmd/bd/db_proxy_child.go'
- 'cmd/bd/init*.go'
- 'cmd/bd/proxied_integration_helpers_test.go'
- 'cmd/bd/store_factory*.go'
- 'cmd/bd/test_dolt_server_cgo_test.go'
- 'cmd/bd/tracker_proxy_uow_conformance_integration_test.go'
- 'cmd/bd/uow_factory.go'
- 'internal/configfile/**'
- 'internal/doltserver/**'
- 'internal/storage/dbproxy/**'
- 'internal/storage/uow/**'
- 'internal/tracker/conformance/**'
- 'internal/tracker/uow_store.go'
- 'internal/tracker/engine.go'
- 'internal/tracker/store.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/proxied-local-smoke.yml'
permissions:
contents: read
jobs:
managed-local-smoke:
name: Managed-local proxied lifecycle (Linux, offline)
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 25
env:
CGO_ENABLED: "1"
# Pinned so the lane tests a known dolt CLI, not whatever the installer
# resolves on a given day. Bump deliberately, and only in lockstep with
# the measured pin in scripts/ci/install-dolt.sh (see "Which Dolt
# version to install" in docs/architecture/dolt.md).
DOLT_VERSION: 2.2.0
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up Go
id: setup-go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: ${{ runner.environment == 'github-hosted' }}
# F7c review fix S5: this job's own key copy must match main.yml's
# seeder key byte-for-byte (TestBlacksmithSetupGoCacheKeysMatchAcrossSeederAndConsumers),
# which now keys by UTC calendar day instead of github.sha so main
# pushes don't churn a multi-GB cache entry on every commit; this step
# computes that same day value locally so the key expression below
# resolves (steps.* references only resolve within the same job).
- name: Compute cache date
id: cache-date
if: runner.environment == 'self-hosted'
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Blacksmith setup-go cache
if: runner.environment == 'self-hosted'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: |
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Install pinned Dolt CLI
run: |
curl -fsSL "https://github.com/dolthub/dolt/releases/download/v${DOLT_VERSION}/dolt-linux-amd64.tar.gz" -o /tmp/dolt.tar.gz
tar -xzf /tmp/dolt.tar.gz -C /tmp
sudo install /tmp/dolt-linux-amd64/bin/dolt /usr/local/bin/dolt
dolt version
- name: Build bd and compile the test binary (online)
run: |
go build -tags gms_pure_go -o /tmp/bd-under-test ./cmd/bd
go test -tags gms_pure_go -c -o /tmp/proxied-local-smoke.test ./cmd/bd
- name: Assert the managed-local lifecycle tests are compiled in
run: |
listed="$(
BEADS_TEST_PROXIED_LOCAL=1 \
BEADS_TEST_SKIP=dolt \
/tmp/proxied-local-smoke.test \
-test.list '^TestManagedLocalProxied'
)"
for test_name in \
TestManagedLocalProxiedLifecycleSmoke \
TestManagedLocalProxiedForeignListenerNotAdopted \
TestManagedLocalProxiedReusedPidNeverKilled \
TestManagedLocalProxiedLegacyRecordFailClosed \
TestManagedLocalProxiedOrphanBackendReaped \
TestManagedLocalProxiedNProcessColdStartConvergence \
TestManagedLocalProxiedStopStartInterleave \
TestManagedLocalProxiedDoltStatusReportsLiveTopology \
TestManagedLocalProxiedDoltStartRefusesOverLiveProxy \
TestManagedLocalProxiedDoltStartRefusesWithProxyDown \
TestManagedLocalProxiedDoltLifecycleLeavesOtherTopologiesAlone \
TestManagedLocalProxiedTrackerUOWConformance \
TestManagedLocalProxiedBackupRoundTrip \
TestManagedLocalProxiedAutoBackup \
TestManagedLocalProxiedBackupRestoreRefusedWhileAttached \
TestManagedLocalProxiedPurgeWispsPlaneRetention \
TestManagedLocalProxiedBackendCleanExitRetiresProxy
do
if ! grep -qx "$test_name" <<<"$listed"; then
echo "managed-local lifecycle test $test_name is missing; got: '$listed'" >&2
exit 1
fi
done
- name: Run managed-local lifecycle lane offline (loopback-only netns)
run: |
sudo env \
"PATH=$PATH" \
BEADS_TEST_PROXIED_LOCAL=1 \
BEADS_TEST_SKIP=dolt \
BEADS_TEST_BD_BINARY=/tmp/bd-under-test \
unshare --net -- bash -euxc '
ip link set lo up
# Prove the namespace really has no outbound network before
# trusting anything the test reports.
if timeout 3 bash -c "exec 3<>/dev/tcp/1.1.1.1/443" 2>/dev/null; then
echo "outbound network unexpectedly available inside the netns" >&2
exit 1
fi
cd cmd/bd
/tmp/proxied-local-smoke.test \
-test.run "^TestManagedLocalProxied" \
-test.v -test.timeout 15m
'

View file

@ -1,177 +0,0 @@
name: Regression Tests
on:
# Run on merges to main
push:
branches: [main]
pull_request:
branches: [main, 'release/**', 'hotfix/**']
# Allow manual trigger
workflow_dispatch:
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
jobs:
regression:
name: Differential Regression (v0.49.6 baseline)
# F7c: detect-regression-need folded in as this job's own first step
# (id: detect). A non-applicable PR now costs one short Blacksmith-sized
# job instead of two GitHub-hosted jobs; every later step is gated on
# steps.detect.outputs.run_regression instead of a separate job's output.
runs-on: ${{ (github.event_name == 'merge_group' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
- name: Decide whether to run differential regression tests
id: detect
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
if [[ "$EVENT_NAME" != "pull_request" ]]; then
echo "run_regression=true" >> "$GITHUB_OUTPUT"
echo "reason=$EVENT_NAME event always runs regression tests" >> "$GITHUB_OUTPUT"
exit 0
fi
labels="$(jq -r '.pull_request.labels[].name // empty' "$GITHUB_EVENT_PATH")"
if grep -Fxq "run-regression" <<<"$labels"; then
echo "run_regression=true" >> "$GITHUB_OUTPUT"
echo "reason=run-regression label present" >> "$GITHUB_OUTPUT"
exit 0
fi
if grep -Fxq "skip-regression" <<<"$labels"; then
echo "run_regression=false" >> "$GITHUB_OUTPUT"
echo "reason=skip-regression label present" >> "$GITHUB_OUTPUT"
exit 0
fi
changed="$(git diff --name-only "$PR_BASE_SHA" "$PR_HEAD_SHA")"
echo "Changed files:"
printf '%s\n' "$changed"
regression_candidates="$(
printf '%s\n' "$changed" |
grep -Ev '^(cmd/bd|internal/storage|internal/types)/.*_test\.go$' ||
true
)"
risky_pattern='^(\.github/workflows/regression\.yml|Makefile|go\.(mod|sum)|cmd/bd/|internal/storage/|internal/types/|tests/regression/)'
if grep -Eq "$risky_pattern" <<<"$regression_candidates"; then
echo "run_regression=true" >> "$GITHUB_OUTPUT"
echo "reason=PR changes CLI, storage, types, regression, or build inputs" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "run_regression=false" >> "$GITHUB_OUTPUT"
echo "reason=PR does not touch regression-sensitive paths" >> "$GITHUB_OUTPUT"
- name: Show regression trigger reason
if: steps.detect.outputs.run_regression == 'true'
run: echo "${{ steps.detect.outputs.reason }}"
- name: Set up Go
id: setup-go
if: steps.detect.outputs.run_regression == 'true'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
cache: ${{ runner.environment == 'github-hosted' }}
# F7c review fix S5: this job's own key copy must match main.yml's
# seeder key byte-for-byte (TestBlacksmithSetupGoCacheKeysMatchAcrossSeederAndConsumers),
# which now keys by UTC calendar day instead of github.sha so main
# pushes don't churn a multi-GB cache entry on every commit; this step
# computes that same day value locally so the key expression below
# resolves (steps.* references only resolve within the same job).
- name: Compute cache date
id: cache-date
if: steps.detect.outputs.run_regression == 'true' && runner.environment == 'self-hosted'
run: echo "today=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- name: Restore Blacksmith setup-go cache
if: steps.detect.outputs.run_regression == 'true' && runner.environment == 'self-hosted'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.cache-date.outputs.today }}
restore-keys: |
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-
blacksmith-sg-v1-${{ runner.os }}-${{ runner.arch }}-go-${{ steps.setup-go.outputs.go-version }}-
- name: Configure Git
if: steps.detect.outputs.run_regression == 'true'
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Install Dolt
if: steps.detect.outputs.run_regression == 'true'
run: ./scripts/ci/install-dolt.sh
- name: Configure Dolt
if: steps.detect.outputs.run_regression == 'true'
run: |
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
dolt version
- name: Pull Dolt sql-server image
# Without this, isDoltImageCached() returns false in TestMain and the
# regression suite falls back to embedded Dolt with HOME=<tmpdir>, which
# has a known cleanup race (see beads issue: TestCreateWithParentFlag
# TempDir RemoveAll "directory not empty" flake). Keep the tag in sync
# with internal/testutil/testdoltcommon.go:DoltDockerImage.
if: steps.detect.outputs.run_regression == 'true'
run: ./scripts/ci/pull-dolt-image.sh
# Restore-only: actions/cache (bare) auto-saves on any key miss, which
# would let a same-repo PR that bumps BASELINE_VERSION write a baseline
# binary cache entry a later PR or main could read back unverified. The
# matching save below only runs off pull_request (B2, F7c implementation
# report).
- name: Restore baseline binary cache
if: steps.detect.outputs.run_regression == 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ~/.cache/beads-regression
key: regression-baseline-${{ hashFiles('tests/regression/BASELINE_VERSION') }}
# Passing-side wall time already overlapped the go deadline below, so
# ordinary GitHub-runner speed variance -- not a real hang -- was
# tripping this step. Measured over the 100 most recent Regression
# Tests runs (2026-09-03/04, ~29.5h): p50 593s (~10m), max passing
# 1189s (~19.8m) against the prior 1200s (20m) cap, and 5 runs in that
# window hit the identical `panic: test timed out after 20m0s` with
# zero `--- FAIL` lines -- a budget defect, not a regression. Match
# main.yml's Test job fix for the same failure mode: raise the go
# deadline to cover the observed slowdown and keep it inside a larger
# finite job budget (see timeout-minutes above), so the go deadline
# fires first and prints goroutine stacks -- a REAL hang stays
# diagnosable instead of being cut off by a bare job kill.
- name: Run regression tests
if: steps.detect.outputs.run_regression == 'true'
run: go test -tags=regression,gms_pure_go -timeout=40m -v ./tests/regression/...
- name: Save baseline binary cache
# Allow-list push/workflow_dispatch rather than deny-list
# pull_request: a deny-list also admits a hypothetical future
# merge_group event, which this job's runs-on expression already
# resolves to Blacksmith for. Pinned by
# TestBlacksmithReachableAdvisoryJobsNeverSaveACache (checks both the
# pull_request and merge_group trust contexts independently).
if: steps.detect.outputs.run_regression == 'true' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ~/.cache/beads-regression
key: regression-baseline-${{ hashFiles('tests/regression/BASELINE_VERSION') }}

View file

@ -3,8 +3,8 @@ name: Update vendorHash for dependabot Go bumps
# Dependabot bumps to go.mod/go.sum invalidate the proxyVendor FOD hash in
# default.nix, which fails the required PR Risk `test-nix` gate (F7c,
# spec-f7.md §2.4: nix-build.yml itself no longer runs on pull_request, since
# test-nix's `nix run .#default` plus `nix flake check -L` is a superset of
# plain `nix build .#default`). This workflow detects the drift, computes the
# test-nix's `nix run .#default` plus `nix flake check -L`, which evaluates
# every flake output, is a superset of plain `nix build .#default`). This workflow detects the drift, computes the
# new hash via scripts/update-nix-vendorhash.sh, and pushes the update back to
# the dependabot branch so the gate goes green without a maintainer
# round-trip.
@ -82,6 +82,14 @@ jobs:
- name: Update vendorHash
run: ./scripts/update-nix-vendorhash.sh
- name: Verify the build independently of the script's exit status
# update-nix-vendorhash.sh's own verification build (its step 5) is
# internal to the script; this step re-derives the same signal from
# a source the workflow doesn't have to trust: a plain `nix build`
# that this job step fails on if it fails, regardless of what the
# script itself reported.
run: nix build .#default
- name: Detect whether hash changed
id: changed
run: |

View file

@ -0,0 +1,196 @@
# Keep beads' rbe worker-env pin in step with gastownhall/gascity main
# without the ~100-minute wait #7419 fixed by hand.
#
# rbe-west's OSS pool is gascity's: its workers advertise the sha256 of the
# toolchain manifest gascity's tools/rbe/worker-env measures, and the
# schedulers match //platforms:rbe_worker's worker-env exec property
# exactly. beads' tools/rbe/worker-env.txt and the platforms/BUILD.bazel pin
# are a byte-for-byte copy of gascity main's; when gascity moves the pin (a
# Go, dolt, or OS/library bump -- #7387 was a Go security release), every
# beads remote-execution run stops in bazel.yml's rbe-job preflight
# (tools/rbe/worker-env-sync) until the copy catches up. nightly.yml's
# rbe-worker-env-sync job already opens a ci/infra issue for a human to fix;
# this instead opens the fix itself, every 15 minutes, so the gap is
# minutes, not until someone reads the issue.
#
# tools/rbe/worker-env-sync only detects the mismatch (exit 1) or that it
# could not compare with gascity (exit 2, e.g. GitHub is briefly
# unreachable; the next run retries). The write half, tools/rbe/worker-env-
# sync-copy, runs only after that exit-1 detection, on a checkout already in
# hand -- so a transient gascity outage can turn "in step" into "unknown",
# never into an unwanted write.
#
# TWO TOKENS, ONE JOB EACH: GitHub never runs checks on a PR a plain
# GITHUB_TOKEN opens (its loop-prevention rule), so this needs a GitHub App
# token to open the PR. The gastownhall-autofix App (contents:write only on
# this repo) mints push-token and does the git push of the fixed branch
# (bot/worker-env-sync); it cannot open, label or merge a PR. The separate
# gascity-autofix App (pull-requests:write only, no contents) mints pr-token
# and does everything PR-shaped: create/update, the status/needs-review-auto
# label, and arming auto-merge. Splitting them means a bug in the PR-shaped
# half can never push a commit, and a bug in the push half can never touch a
# PR; neither token can do the other's job even by accident. Both Apps'
# credentials are secrets of the same `autofix` environment.
#
# peter-evans/create-pull-request takes one token for the whole push+PR
# flow, so it cannot honor this split; this uses plain git for the push and
# gh for the PR instead. Every `${{ }}` is resolved into a step's `env:`,
# never written inside a `run:` script, so a value that happened to look
# like shell (a title or body containing `` ` `` or `$`) is data to the
# shell, not something GitHub's expression syntax or the shell re-parses.
#
# SECURITY: schedule and workflow_dispatch are never fork events (no
# pull_request trigger here at all), so neither App's private key -- secrets
# of the `autofix` environment, whose deployment-branch policy allows only
# main -- is ever readable by a fork. The guard on github.repository is
# defense in depth for a fork of this repo, where the secrets would not
# exist anyway. Both mint steps run only once worker-env-sync has already
# found a real mismatch, so a run that is in step or can't compare asks
# neither App for a token. gh pr merge --auto only arms GitHub's native
# auto-merge (it still waits for every required check and the branch
# protection rule); it does not merge anything itself.
name: rbe worker-env autosync
on:
schedule:
- cron: "*/15 * * * *"
workflow_dispatch:
permissions:
contents: read
jobs:
autosync:
name: Sync worker-env pin with gascity main
if: github.repository == 'gastownhall/beads'
runs-on: ubuntu-latest
timeout-minutes: 10
# Grants the job read access to this environment's secrets (both Apps'
# id and private key); its deployment-branch policy restricts that to
# jobs running on main, which schedule and workflow_dispatch on this
# repo always are.
environment: autofix
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
# Never fails the step itself: rc is the signal every later step
# gates on (1, a real mismatch; 2, gascity unreachable -- the next
# scheduled run retries; 0, in step). A run every 15 minutes failing
# red for however long a mismatch takes to review and merge would be
# noise, not signal.
- name: Compare the worker-env manifest and pin with gascity's main
id: sync
run: |
rc=0
tools/rbe/worker-env-sync main || rc=$?
echo "rc=$rc" >> "$GITHUB_OUTPUT"
- name: Copy gascity main's worker-env manifest and pin
if: steps.sync.outputs.rc == '1'
run: tools/rbe/worker-env-sync-copy main
- name: Confirm only the worker-env files moved
if: steps.sync.outputs.rc == '1'
run: |
changed="$(git diff --name-only)"
untracked="$(git ls-files --others --exclude-standard)"
want=$'platforms/BUILD.bazel\ntools/rbe/worker-env.txt'
if [ -n "$untracked" ] || [ "$(printf '%s\n' "$changed" | sort)" != "$(printf '%s\n' "$want" | sort)" ]; then
echo "::error::worker-env-sync-copy touched more than platforms/BUILD.bazel and tools/rbe/worker-env.txt:"
printf '%s\n' "$changed" "$untracked"
exit 1
fi
# contents:write only, on this repo alone: all it can do is push
# bot/worker-env-sync. Minted only once a real mismatch needs a push.
- name: Mint push token (gastownhall-autofix)
id: push-token
if: steps.sync.outputs.rc == '1'
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
app-id: ${{ secrets.AUTOFIX_APP_ID }}
private-key: ${{ secrets.AUTOFIX_APP_PRIVATE_KEY }}
owner: gastownhall
repositories: beads
permission-contents: write
# pull-requests:write only, on this repo alone: all it can do is
# open, label and arm auto-merge on a PR -- never push a commit.
- name: Mint PR token (gascity-autofix)
id: pr-token
if: steps.sync.outputs.rc == '1'
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
app-id: ${{ secrets.GASCITY_AUTOFIX_APP_ID }}
private-key: ${{ secrets.GASCITY_AUTOFIX_APP_PRIVATE_KEY }}
owner: gastownhall
repositories: beads
permission-pull-requests: write
# push-token alone; it cannot see a PR exists, let alone touch one.
# Leased to the branch: a force-with-lease scoped to refs/heads/
# bot/worker-env-sync only, so a push can never move any other ref.
- name: Commit and push the sync branch
if: steps.sync.outputs.rc == '1'
env:
PUSH_TOKEN: ${{ steps.push-token.outputs.token }}
REPO: ${{ github.repository }}
BRANCH: bot/worker-env-sync
COMMIT_SUBJECT: "build(rbe): sync worker-env pin with gascity main"
GIT_AUTHOR_NAME: gastownhall-autofix[bot]
GIT_AUTHOR_EMAIL: gastownhall-autofix[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: gastownhall-autofix[bot]
GIT_COMMITTER_EMAIL: gastownhall-autofix[bot]@users.noreply.github.com
run: |
git checkout -B "$BRANCH"
git add platforms/BUILD.bazel tools/rbe/worker-env.txt
git commit -m "$COMMIT_SUBJECT"
git push "https://x-access-token:${PUSH_TOKEN}@github.com/${REPO}.git" \
"HEAD:refs/heads/$BRANCH" "--force-with-lease=refs/heads/$BRANCH"
# pr-token alone; it cannot push a commit, only act on the PR the
# step above already pushed.
- name: Open or update the sync PR
id: pr
if: steps.sync.outputs.rc == '1'
env:
GH_TOKEN: ${{ steps.pr-token.outputs.token }}
REPO: ${{ github.repository }}
BRANCH: bot/worker-env-sync
TITLE: "build(rbe): sync worker-env pin with gascity main"
LABEL: status/needs-review-auto
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
body="$(cat <<BODY
rbe-west's pool workers advertise gastownhall/gascity main's worker-env
pin; beads' copy (\`tools/rbe/worker-env.txt\` and the
\`platforms/BUILD.bazel\` pin) had fallen out of step, so beads' remote
actions were queueing on a pin no worker serves
(\`tools/rbe/worker-env-sync main\`, run $RUN_URL).
This copies gascity main's manifest and pin byte for byte, same as
#7419. Auto-merge is armed: it lands once the automated review and the
rest of the required checks are green.
BODY
)"
number="$(gh pr list --repo "$REPO" --head "$BRANCH" --base main --state open --json number --jq '.[0].number')"
if [ -n "$number" ]; then
gh pr edit "$number" --repo "$REPO" --title "$TITLE" --body "$body"
else
gh pr create --repo "$REPO" --base main --head "$BRANCH" --title "$TITLE" --body "$body"
number="$(gh pr list --repo "$REPO" --head "$BRANCH" --base main --state open --json number --jq '.[0].number')"
fi
gh pr edit "$number" --repo "$REPO" --add-label "$LABEL"
echo "number=$number" >> "$GITHUB_OUTPUT"
- name: Enable auto-merge
if: steps.sync.outputs.rc == '1' && steps.pr.outputs.number
env:
GH_TOKEN: ${{ steps.pr-token.outputs.token }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ steps.pr.outputs.number }}
run: gh pr merge --auto --squash --repo "$REPO" "$PR_NUMBER"

View file

@ -1,3 +1,9 @@
# Lint policy for nogo (//tools/nogo), which runs these linters beside every
# Bazel Go compile: tools/nogo/internal/golangci embeds this file and applies
# it as golangci-lint v2.10.1 would (enabled linters, settings, run.tests,
# generated files, exclusion rules). Decoding is strict, so a key the nogo
# wrappers do not implement fails the build. golangci-lint itself still reads
# it (editors, ad-hoc runs), but CI gates on nogo; see engdocs/LINTING.md.
version: "2"
run:
@ -461,12 +467,28 @@ linters:
# tests: false` means forbidigo never analyzes a test file at all, so that
# entry asserts nothing either way and scoping it would be the churn this
# comment just refused to write.
- path: '^cmd/bd/(close|duplicates|find_duplicates|gate|gc|graph|info|label|orphans|purge|search|todo|wisp|human)(_proxied_server)?\.go$'
#
# `search` LEFT this list when all three of its routes moved onto
# issueops.Reader.List with issueops.SearchListRequest (cmd/bd/search.go);
# it builds no filter any more.
#
# `gate` LEFT it when `bd gate check` joined `bd gate list` on
# issueops.ListGates over the route's Querier: cmd/bd/gate.go and
# cmd/bd/gate_proxied_server.go name no filter type any more.
# `gate_discover` keeps its own hole below, since findPendingGates still
# asks SearchIssues for its gates.
- path: '^cmd/bd/(close|duplicates|find_duplicates|gc|graph|info|label|orphans|purge|todo|wisp|human)(_proxied_server)?\.go$'
text: 'do not write a filter here'
linters:
- forbidigo
# Molecule reporting: each selects the members of one molecule.
- path: '^cmd/bd/mol_(current|port|progress|ready_gated|stale)\.go$'
#
# `mol current` and `mol progress` LEFT this list when their in_progress
# and hooked listings moved onto issueops.Reader.List (cmd/bd/mol_roles.go)
# so a remote backend answers them. The proxied route's in-transaction
# port still searches through the unit of work, and that filter lives in
# mol_port.go beside the port.
- path: '^cmd/bd/mol_(port|ready_gated|stale)\.go$'
text: 'do not write a filter here'
linters:
- forbidigo

View file

@ -1,9 +1,15 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v2.10.1
# Lint and vet: nogo (//tools/nogo) over the changed files' Bazel packages,
# the analyzers CI gates on (go test's vet checks plus the golangci-lint
# linters .golangci.yml enables). Needs bazel or bazelisk on PATH.
- repo: local
hooks:
- id: golangci-lint
args: [--timeout=5m]
- id: nogo
name: nogo (bazel)
entry: make lint-changed LINT_CHANGED_SCOPE=staged
language: system
types: [go]
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0

View file

@ -13,15 +13,19 @@ end lists them. `CLAUDE.md` files are symlinks to their sibling `AGENTS.md`.
## How work flows here
GitHub Issues is the public tracker, and every PR links a documented issue.
The issue carries the context reviewers and future readers need: for a bug,
the reproduction, impact, and evidence; for a change, the motivation, impact,
risk, and verification plan.
GitHub Issues is the public tracker. Use an issue when it adds context
reviewers need: a user-visible bug, a behavior or design change worth
discussing, or work that spans several PRs. The issue carries the
reproduction, impact, and evidence for a bug, or the motivation, impact, risk,
and verification plan for a change. Small, self-explanatory changes (typos,
flaky tests, refactors, CI or docs tweaks) can go straight to a PR whose body
explains the why.
1. Find or file the issue with the bug or feature form. It does not need
maintainer approval first; file it before or alongside the PR.
2. Work on a branch, open a PR against `main` whose body says
`Closes #<issue>`, and let CI and review run.
1. If the change warrants an issue, find or file one with the bug or feature
form. It does not need maintainer approval first; file it before or
alongside the PR.
2. Work on a branch, open a PR against `main` (its body says
`Closes #<issue>` when there is one), and let CI and review run.
3. Maintainers triage issues with `status/needs-triage`, `status/needs-info`,
`status/needs-repro`, `status/needs-design`, and `status/accepted`
(confirmed); see [CONTRIBUTING.md](CONTRIBUTING.md).
@ -31,10 +35,9 @@ and not a substitute for the GitHub issue.
## Agent contribution policy
- Every PR closes a documented issue. If none exists for your change, file
one with the bug or feature form fields, filling each from evidence and
answering `NOT_ENOUGH_INFO` where the evidence runs out, then link it from
the PR.
- File an issue when the change warrants one (see above). When you do, use
the bug or feature form fields, fill each from evidence, and answer
`NOT_ENOUGH_INFO` where the evidence runs out.
- A human reviews and stands behind every issue and PR an agent drafts.
Evidence that the change works end-to-end is required; "unit tests pass"
alone is not evidence.
@ -99,33 +102,66 @@ spans layers. See
## Build, test, lint
Bazel is the build and test system: CI gates on the `bazel test` lanes in
`.github/workflows/bazel.yml`, and nogo (lint + vet), gofmt and the repository
guards exist only as Bazel targets. Install
[Bazelisk](https://github.com/bazelbuild/bazelisk) as `bazel`; the pre-commit
and pre-push hooks need it.
```bash
make install # build and install bd to ~/.local/bin (canonical)
make test # unit tests with the right build tags
make ci-pr-lint # required zero-finding formatting + lint contract
make check-docs # doc flag, freshness, and docsync checks
make test # bazel test //... --config=ci: the CI test lane (nogo, gofmt, guards, unit tests)
make check # testing.Short policy + make ci-pr-lint + make test
make ci-pr-lint # nogo lint + vet gate, native plus windows/darwin
make check-docs # bazel docsync + doc freshness, then the CLI flag check
make bazel-sync # after adding/removing/renaming Go files or changing imports/go.mod
make install # build and install bd to ~/.local/bin (canonical)
```
- Each other tier has its own lane (`--config=integration`, `doltserver`,
`embedded`, ...); [engdocs/TESTING.md](engdocs/TESTING.md) lists the exact
command per lane and is the canonical source for test selection, design,
and PR-readiness gates.
- Where actions run: contributors add `--config=fork-cache` (rbe-west's
anonymous read-only cache; nothing is uploaded), maintainers with an rbe-west
certificate `--config=remote-exec`, agent hosts whose `~/.bazelrc` names the
executor neither. Make yours the default with a `build --config=...` line in
the gitignored `.bazelrc.local`, or pass `BAZEL_FLAGS=...` to make.
- Agents run tests only with `bazel test`, also while iterating on one
behavior:
```bash
bazel test //cmd/bd:bd_test --config=ci --test_filter='^TestName$' --test_output=all
```
A target also passes when the test never ran (a filter that matches
nothing, a skip, a file the configuration does not compile), so count a run
only when its log shows `--- PASS: TestName` and no `--- SKIP` for the test
or a `TestName/...` subtest: Go prints `--- PASS` for a test whose every
subtest skipped. "Check That the Test Ran" in
[engdocs/TESTING.md](engdocs/TESTING.md) names the tests `--config=ci` does
not run (Dolt-backed, `-short`-gated, integration-tagged, `TestEmbedded*`
and embedded-Dolt, files `BUILD.bazel` does not list) and the way into
each. An unchanged target returns its cached result, which is the same
evidence. Finish with `make test`.
- Agents do not run `go test` (`./scripts/test.sh`, `make test-go`): CI does
not enforce it, it skips nogo, gofmt and the guards, and agent hosts may
refuse it. It stays a convenience for humans working offline. The exception
is regenerating golden files (`make corpus-regen`, `make githooks-regen`,
`BD_UPDATE_GOLDEN=1`), which Bazel cannot do: see "Regenerating Golden
Files" in [engdocs/TESTING.md](engdocs/TESTING.md).
- **Do NOT** use `go build -o bd ./cmd/bd`, `go install ./cmd/bd`, or raw
`go run ./cmd/bd ...`: they bypass the canonical build path, leave stale
binaries, and raw `go run` misses the `gms_pure_go` tag. Use `make install`,
`./bd`, or `go run -tags gms_pure_go ./cmd/bd ...`.
- All new features need tests. Choose them with
[engdocs/TESTING.md](engdocs/TESTING.md); it is the canonical source for
commands, test design, and PR-readiness gates.
- All new features need tests.
- **Never pollute a production database with test issues.** Use `t.TempDir()`
in Go tests and a disposable working directory for manual `bd` experiments.
- `make ci-pr-lint` must pass with zero issues; see
[engdocs/LINTING.md](engdocs/LINTING.md).
- **Optional shared Bazel cache (opt-in).** `--config=fork-cache` reads the
project's anonymous, read-only cache, so results CI already computed are
hits and nothing is uploaded. It is off by default; when setting up a dev
environment, ask your human before adding `build --config=fork-cache` to
`.bazelrc.local`.
- Without Bazel, let CI sync BUILD files: on same-repo PRs the bazel-autofix
workflow pushes the fix to your branch (pull before pushing again); fork PRs
get a comment with an apply recipe.
- If BUILD files are out of sync and you cannot run `make bazel-sync`, CI
syncs them: on same-repo PRs the bazel-autofix workflow pushes the fix to
your branch (pull before pushing again); fork PRs get a comment with an
apply recipe.
- If you changed behavior, update the user docs (`docs/`, via the
`beads-docs` skill) or README in the same PR.
@ -148,9 +184,9 @@ make bazel-sync # after adding/removing/renaming Go files or changing imports
Do not push to `main`. Before handing off:
1. Run the quality gates your change needs (`make ci-pr-lint`, the tests
[engdocs/TESTING.md](engdocs/TESTING.md) selects). If gates are broken on
`main`, report it as a P0 issue.
1. Run the quality gates your change needs (`make test`, `make ci-pr-lint`,
and the other Bazel lanes [engdocs/TESTING.md](engdocs/TESTING.md)
selects). If gates are broken on `main`, report it as a P0 issue.
2. Record follow-up work as GitHub issues (or ledger beads, for maintainers).
3. Commit, push, or open a PR only when the person you are working for asked
you to. Report changed files, validation run, and anything left open.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,11 +4,14 @@ Thank you for your interest in contributing to bd! This document provides guidel
## Issues and pull requests
GitHub Issues is the public tracker, and every pull request links a
documented issue. The issue is where the context lives: why the change is
needed, what it affects, and how we will know it works. File it with the bug
or feature form before or alongside your pull request; it does not need
maintainer approval first.
GitHub Issues is the public tracker. Use an issue when it adds context
reviewers need: a user-visible bug, a behavior or design change worth
discussing first, or work that spans several pull requests. The issue holds
why the change is needed, what it affects, and how we will know it works; file
it with the bug or feature form before or alongside your pull request, and it
does not need maintainer approval first. Small, self-explanatory changes
(typos, flaky tests, refactors, CI or docs tweaks) can go straight to a pull
request whose description explains the why.
### Triage labels
@ -50,10 +53,14 @@ area is reviewed first.
### Prerequisites
- Go (see `go.mod` for the required version; currently 1.26+)
- [Bazelisk](https://github.com/bazelbuild/bazelisk), installed as `bazel`
(it reads `.bazelversion`). **Required:** Bazel is the build and test system
CI gates on, and the pre-commit (nogo lint) and pre-push (test suite) hooks
run it.
- Go (see `go.mod` for the required version; currently 1.26+), for `make
install` and the `go test` inner loop
- Git
- A C compiler (CGO is required for the embedded Dolt database)
- golangci-lint v2.10.1 for the required local lint gate
- ICU headers are **not required** for building -- see [engdocs/ICU-POLICY.md](engdocs/ICU-POLICY.md)
### Getting Started
@ -63,21 +70,43 @@ area is reviewed first.
git clone https://github.com/gastownhall/beads
cd beads
# Build the project (uses gms_pure_go tag via Makefile)
make build
# Read rbe-west's anonymous, read-only cache: everything CI already built and
# tested is a cache hit, and nothing you build is uploaded.
echo 'build --config=fork-cache' >> .bazelrc.local
# Run tests (uses correct build tags automatically)
# Run the test suite CI gates on (bazel test //... --config=ci)
make test
# Build and install locally to ~/.local/bin
# Build and install bd to ~/.local/bin (also enables the git hooks)
make install
```
Optional: if you use Bazel, opt in to the project's anonymous, read-only
build cache by adding `build --config=fork-cache` to your gitignored
`.bazelrc.local` (or pass `--config=fork-cache` per command). Results CI
already computed become cache hits, and nothing you build is uploaded. It is
off by default.
### Building and Testing
Bazel is the gate: `.github/workflows/bazel.yml` runs every pull request's
tests as `bazel test` lanes, and nogo (lint + vet), gofmt and the repository
guards exist only as Bazel targets. The make targets run the same commands:
| Command | Runs |
|---|---|
| `make test` | `bazel test //... --config=ci`: the test lane (unit tests, nogo, gofmt, repository guards) |
| `make check` | the testing.Short policy, `make ci-pr-lint` and `make test` |
| `make ci-pr-lint` | nogo natively plus the windows/amd64 and darwin/arm64 passes |
| `make check-docs` | the Bazel docsync and doc-freshness tests, then the CLI flag check |
| `bazel test //... --config=integration` | the integration lane; [engdocs/TESTING.md](engdocs/TESTING.md) lists every other lane's command |
Where actions run is your choice, set in the gitignored `.bazelrc.local` (or
per command with `make test BAZEL_FLAGS=--config=...`):
- `--config=fork-cache` (contributors): reads the anonymous cache, runs misses
on your machine, uploads nothing.
- `--config=remote-exec` (maintainers with an rbe-west client certificate):
executes remotely; the executor and TLS lines stay in your `user.bazelrc` or
`.bazelrc.local`.
`go test` (`./scripts/test.sh`, or `make test-go` / `make check-go` /
`make check-docs-go`) still works as an inner-loop convenience, but CI does not
enforce it and it skips nogo, gofmt and the guards. Finish with `make test`.
## Project Structure
@ -88,7 +117,7 @@ beads/
│ ├── types/ # Core data types (Issue, Dependency, etc.)
│ └── storage/ # Storage interface and implementations
│ └── dolt/ # Dolt database backend
├── .golangci.yml # Linter configuration
├── .golangci.yml # Linter configuration (applied by nogo, tools/nogo)
└── .github/workflows/ # CI/CD pipelines
```
@ -111,23 +140,24 @@ We follow standard Go conventions:
### Linting
Use the same pinned golangci-lint version and repository-owned wrapper as CI:
Lint and vet run as nogo under Bazel: go test's vet checks plus the
golangci-lint linters `.golangci.yml` enables, the same analyzers CI gates on.
```bash
# Install the version pinned by CI
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1
# Run the required formatting and lint contract
# Run the required lint and vet gate (native, windows and darwin)
make ci-pr-lint
# Faster: only the Bazel packages of your changed Go files
make lint-changed
```
`make ci-pr-lint` must pass with zero issues. It checks formatting, lints the
repository's normal `gms_pure_go` build, and cross-lints Windows-only non-CGO
code. Accepted intentional patterns are encoded narrowly in `.golangci.yml`;
do not ignore a failing baseline. See [engdocs/LINTING.md](engdocs/LINTING.md)
for the full policy.
`make ci-pr-lint` must pass with zero issues. It analyzes the repository's
normal `gms_pure_go` build and cross-checks the Windows- and macOS-only
non-cgo code. Accepted intentional patterns are encoded narrowly in
`.golangci.yml`; do not ignore a failing baseline. See
[engdocs/LINTING.md](engdocs/LINTING.md) for the full policy.
CI runs the same required wrapper on all pull requests.
CI runs the same analyzers on all pull requests, in the Bazel test lane.
## Making Changes
@ -140,14 +170,14 @@ engine, or expand the database schema when issue metadata is sufficient.
### Workflow
1. Find or file a documented issue (see [Issues and pull requests](#issues-and-pull-requests))
1. If the change warrants one, find or file an issue (see [Issues and pull requests](#issues-and-pull-requests))
2. Fork the repository and create a feature branch (`git checkout -b feature/my-feature`)
3. Make your changes
4. Add tests for new functionality
5. Run tests and linter locally
6. Commit your changes with clear messages
7. Push to your fork
8. Open a pull request whose description says `Closes #<issue>`
8. Open a pull request that explains the change and says `Closes #<issue>` when there is one
### Commit Messages
@ -194,7 +224,8 @@ For test commands, test design, and PR-readiness gates, see the canonical
- Follow the proportional validation budget in
[engdocs/TESTING.md](engdocs/TESTING.md): docs-only changes use docs checks;
Go changes use focused and affected-package tests plus one final `make test`.
Go changes use focused and affected-package tests plus one final `make test`
(the Bazel test lane).
- If you hit a test failure unrelated to your change, don't silently skip
it -- check `.test-skip` and file an issue if it's not already tracked
(see [engdocs/TESTING.md](engdocs/TESTING.md#failures-skips-and-review)).
@ -337,7 +368,7 @@ docker run --rm -v $(pwd):/workspace -w /workspace nixos/nix \
If the build fails with a `vendorHash` mismatch, run `./scripts/update-nix-vendorhash.sh` to recompute and update `default.nix`, or update it manually with the `got:` hash from the error message and rebuild.
On a PR, this is covered by PR Risk's required `test-nix` job (`.github/workflows/pr-risk.yml`), which runs `nix run .#default -- --help` plus `nix flake check -L` on every PR touching `go.mod`, `go.sum`, `default.nix`, `flake.nix`, or `flake.lock` -- a superset of plain `nix build .#default`. `.github/workflows/nix-build.yml` dropped its own `pull_request` trigger as redundant (F7c, spec-f7.md §2.4) and now only runs `nix build .#default` on push to `main` and on `workflow_dispatch`, so dependabot bumps that invalidate `vendorHash` still fail loudly post-merge instead of silently breaking Nix users on main. For dependabot Go-module bumps specifically, `.github/workflows/update-vendor-hash.yml` runs the same `update-nix-vendorhash.sh` script and pushes the hash bump back to the dependabot branch automatically (note: GitHub does not retrigger `pull_request` workflows for `GITHUB_TOKEN`-authored commits, so a maintainer may need to re-run PR Risk's `test-nix` once after the auto-fix push to mark the gate green).
On a PR, this is covered by PR Risk's required `test-nix` job (`.github/workflows/pr-risk.yml`), which runs `nix run .#default -- --help` plus `nix flake check -L` (an evaluation of every flake output; the flake has no test checks) on every PR touching `go.mod`, `go.sum`, `default.nix`, `flake.nix`, or `flake.lock` -- a superset of plain `nix build .#default`. `.github/workflows/nix-build.yml` dropped its own `pull_request` trigger as redundant (F7c, spec-f7.md §2.4) and now only runs `nix build .#default` on push to `main` and on `workflow_dispatch`, so dependabot bumps that invalidate `vendorHash` still fail loudly post-merge instead of silently breaking Nix users on main. For dependabot Go-module bumps specifically, `.github/workflows/update-vendor-hash.yml` runs the same `update-nix-vendorhash.sh` script and pushes the hash bump back to the dependabot branch automatically (note: GitHub does not retrigger `pull_request` workflows for `GITHUB_TOKEN`-authored commits, so a maintainer may need to re-run PR Risk's `test-nix` once after the auto-fix push to mark the gate green).
### Debugging

View file

@ -5,8 +5,194 @@ module(
bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "rules_go", version = "0.63.0")
# nogo honors //nolint directives through ast.CommentMap ranges, which differ
# from golangci-lint's (a comment trailing `func f(...) {` attaches to the
# body's first statement). This tree's directives were written against
# golangci-lint, so the patch adds golangci-lint's ranges as well.
single_version_override(
module_name = "rules_go",
patch_strip = 1,
patches = ["//third_party/patches:rules_go_nogo_golangci_nolint.patch"],
version = "0.63.0",
)
bazel_dep(name = "gazelle", version = "0.53.0")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "toolchains_llvm", version = "1.11.0")
# Loaded by @llvm_dist_linux_x86_64's BUILD file (toolchains_llvm's template).
bazel_dep(name = "rules_cc", version = "0.2.17")
# Hermetic C/C++ toolchain, ported from gastownhall/gascity. rules_go builds
# the Go stdlib under -race and every cgo package (mattn/go-sqlite3, gozstd,
# ...) with the registered C toolchain, and every Go compile depends on the
# stdlib, so a host-detected toolchain (local_config_cc: CC=/usr/bin/gcc,
# -fuse-ld=lld only where the CLIENT has lld, gcc-version-specific generated
# inputs) keys those actions to the machine that ran the analysis and fails
# remotely on workers without lld. Instead: LLVM pinned by sha256, plus a
# sysroot of pinned Ubuntu 24.04 packages (the RBE workers' release, so
# binaries load the same glibc and libstdc++ there), byte-identical on every
# Linux x86_64 host. No ICU: beads builds go-mysql-server with its pure-Go
# regex backend (engdocs/ICU-POLICY.md), so nothing may link libicu. .bazelrc
# turns host detection off so nothing falls back to the host compiler;
# scripts/bazel_hermetic_cc_test.go guards both.
deb_sysroot = use_repo_rule("//third_party/cc_toolchain:deb_sysroot.bzl", "deb_sysroot")
# Where every pinned Ubuntu 24.04 package below comes from, tried in order
# (the sha256 pins, not the source, decide what is accepted):
# - gascity's content-addressed mirror, a release holding each pinned
# .deb as <sha256>.deb (gascity's tools/cc_toolchain/mirror_debs.sh
# publishes it; gascity pins the same packages), so a cold fetch does not
# depend on Canonical's servers;
# - the snapshot these packages were pinned from (immutable, but a single
# host that returns 503 for minutes at a time);
# - Launchpad's librarian, which keeps every file ever published to the
# primary archive, superseded versions included;
# - archive.ubuntu.com, which drops superseded versions.
NOBLE_DEB_URLS = [
"https://github.com/gastownhall/gascity/releases/download/toolchain-noble-debs-20261001/{sha256}.deb",
"https://snapshot.ubuntu.com/ubuntu/20261001T000000Z/{path}",
"https://launchpad.net/ubuntu/+archive/primary/+files/{file}",
"https://archive.ubuntu.com/ubuntu/{path}",
]
deb_sysroot(
name = "cc_sysroot_noble_amd64",
packages = {
"pool/main/g/gcc-13/libgcc-13-dev_13.3.0-6ubuntu2~24.04.1_amd64.deb": "cd689db2691edaa10f37329307292796bb599e722e0505c79e14caaa1fe9a93a",
"pool/main/g/gcc-13/libstdc++-13-dev_13.3.0-6ubuntu2~24.04.1_amd64.deb": "ee5633e863e19c3381ed97842ce35ed32ede96a3d1ae4e94c051d3036fe21347",
"pool/main/g/gcc-14/libgcc-s1_14.2.0-4ubuntu2~24.04.1_amd64.deb": "aa7fadbe33b78bcf99885318040601c550c208929565b179891d9a3cc2aa68cd",
"pool/main/g/gcc-14/libstdc++6_14.2.0-4ubuntu2~24.04.1_amd64.deb": "a51f8de7829211db961a31f02158058ad1a95f92ac6d0a5dff6350e2821c54c0",
"pool/main/g/glibc/libc6-dev_2.39-0ubuntu8.9_amd64.deb": "e13d5fcc1b2a86f75bca8e0026a8e39f24fe97ca86e92be79991f8697eb1306f",
"pool/main/g/glibc/libc6_2.39-0ubuntu8.9_amd64.deb": "ff5557d99b51f761c4b7c92368b9cc45565eda17df9bf9eb4b134d09825008be",
"pool/main/l/linux/linux-libc-dev_6.8.0-146.146_amd64.deb": "1a7bb04132d01cd14bea3d615e5861096ca1f70c4659902eb14b36c21993cadc",
},
remove = [
"etc",
"usr/bin",
"usr/sbin",
"usr/share",
"usr/lib/x86_64-linux-gnu/gconv",
"usr/lib/gcc/x86_64-linux-gnu/13/crtoffload*",
"usr/lib/gcc/x86_64-linux-gnu/13/lib*san*",
"usr/lib/gcc/x86_64-linux-gnu/13/libatomic*",
"usr/lib/gcc/x86_64-linux-gnu/13/libbacktrace*",
"usr/lib/gcc/x86_64-linux-gnu/13/libgcov*",
"usr/lib/gcc/x86_64-linux-gnu/13/libgomp*",
"usr/lib/gcc/x86_64-linux-gnu/13/libitm*",
"usr/lib/gcc/x86_64-linux-gnu/13/libquadmath*",
"usr/lib/gcc/x86_64-linux-gnu/13/libstdc++*.a",
],
urls = NOBLE_DEB_URLS,
)
LLVM_VERSION = "22.1.8"
llvm_dist = use_repo_rule("//third_party/cc_toolchain:llvm_dist.bzl", "llvm_dist")
llvm_dist(
name = "llvm_dist_linux_x86_64",
llvm_version = LLVM_VERSION,
members = [
"bin/clang",
"bin/clang++",
"bin/clang-22",
"bin/clang-cpp",
"bin/ld.lld",
"bin/ld64.lld",
"bin/lld",
"bin/llvm-ar",
"bin/llvm-as",
"bin/llvm-cov",
"bin/llvm-install-name-tool",
"bin/llvm-nm",
"bin/llvm-objcopy",
"bin/llvm-objdump",
"bin/llvm-profdata",
"bin/llvm-ranlib",
"bin/llvm-readelf",
"bin/llvm-readobj",
"bin/llvm-strip",
"bin/llvm-symbolizer",
"bin/wasm-ld",
"include/c++",
"include/x86_64-unknown-linux-gnu",
"lib/clang/22/include",
"lib/clang/22/lib/x86_64-unknown-linux-gnu/clang_rt.crtbegin.o",
"lib/clang/22/lib/x86_64-unknown-linux-gnu/clang_rt.crtend.o",
"lib/clang/22/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a",
# `bazel coverage` links cgo binaries with -fprofile-instr-generate,
# which pulls in compiler-rt's profile runtime (~170KB).
"lib/clang/22/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a",
],
# LLVM-22.1.8-Linux-X64.tar.xz (sha256 df0e1ecf...0006384), sliced to the
# members above by tools/cc_toolchain/repack_llvm.sh: 149 MB instead of
# 1.94 GB, and no single-threaded xz pass on every cold runner. The files
# are byte-identical to the release's, so no action key changes.
# tools/cc_toolchain/llvm_members.txt must list the same members.
sha256 = "de6147773999137b70ef3d7bd8ecb1e5b91f2a161d02fd09aec591b84516bec5",
sliced = True,
stub_tools = [
"clang-format",
"clang-tidy",
"clangd",
"llvm-dwp",
],
# The sha256 pin, not the host, guarantees the bytes. gascity's release
# asset for now; a beads mirror of the same bytes can be listed first.
urls = [
"https://github.com/gastownhall/gascity/releases/download/toolchain-llvm-22.1.8-slice-1/LLVM-22.1.8-Linux-X64-slice.tar.zst",
],
)
# Every other host (macOS arm64, Linux arm64) runs toolchains_llvm's stock
# LLVM_VERSION release for its platform, pinned by sha256 in toolchains_llvm's
# distribution table and fetched only there. Once any toolchain_root is set,
# toolchains_llvm creates no stock distribution of its own and fails every
# build on a host no root covers. Not hermetic there: no sysroot, so cgo
# uses the host's headers and libraries, as before.
llvm_host_dist = use_repo_rule("@toolchains_llvm//toolchain:rules.bzl", "llvm")
llvm_host_dist(
name = "llvm_dist_host",
llvm_version = LLVM_VERSION,
# The bare rule reads the per-host dict; llvm_toolchain's macro would
# fill it in from llvm_version.
llvm_versions = {"": LLVM_VERSION},
)
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
name = "llvm_toolchain",
# Pair Darwin's host SDK with its native linker. LLVM 22.1.8's ld64.lld
# cannot parse the arm64e.x1 TAPI targets in the macOS 27 SDK. Keep the
# pinned Clang compiler; Linux keeps the bundled LLD and pinned sysroot.
linker = {
"darwin-aarch64": "auto",
"darwin-x86_64": "auto",
},
llvm_version = LLVM_VERSION,
# The sysroot's libstdc++, linked dynamically as host-gcc builds did.
stdlib = {"linux-x86_64": "dynamic-stdc++"},
)
llvm.toolchain_root(
name = "llvm_toolchain",
label = "@llvm_dist_linux_x86_64//:BUILD.bazel",
targets = ["linux-x86_64"],
)
llvm.toolchain_root(
name = "llvm_toolchain",
label = "@llvm_dist_host//:BUILD.bazel",
)
llvm.sysroot(
name = "llvm_toolchain",
label = "@cc_sysroot_noble_amd64//:sysroot",
targets = ["linux-x86_64"],
)
use_repo(llvm, "llvm_toolchain")
register_toolchains("@llvm_toolchain//:all")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
@ -15,8 +201,36 @@ go_sdk.download(
)
use_repo(go_sdk, "go_sdk")
# nogo: //tools/nogo's analyzers (go test's vet checks plus the golangci-lint
# linters .golangci.yml enables) run beside every first-party Go compile, so
# a finding fails `bazel build`/`bazel test` wherever it executes (RBE
# included). External repos only feed analyzer facts; they are not validated.
go_sdk.nogo(
includes = ["//:__subpackages__"],
nogo = "//tools/nogo",
)
# gazelle compiles fetch_repo and gazelle, which every go_deps repository
# runs, with `go build` in a repository rule before any go_deps fetch can
# start (18-24 s of every CI lane's loading). This substitute serves those
# reproducible binaries from the repository cache by pinned sha256 and builds
# them from source on a miss (tools/bazel/go_repository_tools.bzl).
gazelle_non_module_deps = use_extension("@gazelle//internal/bzlmod:non_module_deps.bzl", "non_module_deps")
go_repository_tools = use_repo_rule("//tools/bazel:go_repository_tools.bzl", "go_repository_tools")
go_repository_tools(name = "gazelle_go_repository_tools")
override_repo(
gazelle_non_module_deps,
bazel_gazelle_go_repository_tools = "gazelle_go_repository_tools",
)
# gazelle.go.work joins the beads module and the nogo analyzers' module
# (tools/nogo/go.mod) into one dependency graph for Bazel only; `go build` in
# the repository root never reads it (it is not named go.work).
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
go_deps.from_file(go_work = "//:gazelle.go.work")
# beads builds go-mysql-server with its stdlib-regex backend (ICU policy):
# gazelle must see gms_pure_go as satisfied so it selects regex_pure.go and
@ -28,6 +242,23 @@ go_deps.gazelle_override(
],
path = "github.com/dolthub/go-mysql-server",
)
# protoc-gen-validate ships validate/validate.pb.go, so its Go library can
# compile from the checked-in code. Its own validate/BUILD instead makes the
# Go library a go_proto_library, so every lane built protoc from source just
# to regenerate that file: about 4.5k C++ compile, link and archive actions,
# each carrying the LLVM toolchain as inputs. The module reaches the graph
# only through grpc xds and the cloud SDKs. Gazelle regenerates its BUILD
# files with proto rules off; build_file_name makes it write BUILD.bazel (which
# Bazel prefers) rather than merge into the upstream BUILD files.
go_deps.gazelle_override(
build_file_generation = "on",
directives = [
"gazelle:build_file_name BUILD.bazel",
"gazelle:proto disable",
],
path = "github.com/envoyproxy/protoc-gen-validate",
)
go_deps.module_override(
patch_strip = 1,
patches = ["//third_party/patches:eventsapi_schema_build.patch"],
@ -50,7 +281,17 @@ go_deps.module_override(
patches = ["//third_party/patches:gozstd_nocgo.patch"],
path = "github.com/dolthub/gozstd",
)
use_repo(go_deps, "com_github_anthropics_anthropic_sdk_go", "com_github_burntsushi_toml", "com_github_cenkalti_backoff_v4", "com_github_charmbracelet_x_ansi", "com_github_data_dog_go_sqlmock", "com_github_dolthub_dolt_go", "com_github_dolthub_driver_v2", "com_github_dolthub_eventkit", "com_github_dolthub_go_mysql_server", "com_github_dolthub_vitess", "com_github_go_sql_driver_mysql", "com_github_google_uuid", "com_github_gowebpki_jcs", "com_github_invopop_jsonschema", "com_github_johanneskaufmann_html_to_markdown_v2", "com_github_mattn_go_sqlite3", "com_github_microcosm_cc_bluemonday", "com_github_oapi_codegen_oapi_codegen_v2", "com_github_olebedev_when", "com_github_spf13_cobra", "com_github_spf13_pflag", "com_github_spf13_viper", "com_github_stretchr_testify", "com_github_subosito_gotenv", "com_github_testcontainers_testcontainers_go", "com_github_testcontainers_testcontainers_go_modules_dolt", "com_github_yuin_goldmark", "in_gopkg_yaml_v3", "io_opentelemetry_go_otel", "io_opentelemetry_go_otel_exporters_otlp_otlpmetric_otlpmetrichttp", "io_opentelemetry_go_otel_exporters_stdout_stdoutmetric", "io_opentelemetry_go_otel_exporters_stdout_stdouttrace", "io_opentelemetry_go_otel_metric", "io_opentelemetry_go_otel_sdk", "io_opentelemetry_go_otel_sdk_metric", "io_opentelemetry_go_otel_trace", "io_rsc_script", "land_charm_glamour_v2", "land_charm_huh_v2", "land_charm_lipgloss_v2", "org_golang_x_mod", "org_golang_x_net", "org_golang_x_sync", "org_golang_x_sys", "org_golang_x_term")
# nogo does not analyze the standard library, so ctrlflow has no noReturn
# facts for t.Fatal, log.Fatal, os.Exit, ...; buildssa (unparam) and the vet
# passes then treat them as returning, unlike golangci-lint and go vet. The
# patch makes ctrlflow know those standard-library functions intrinsically.
go_deps.module_override(
patch_strip = 1,
patches = ["//third_party/patches:x_tools_ctrlflow_stdlib_noreturn.patch"],
path = "golang.org/x/tools",
)
use_repo(go_deps, "cc_mvdan_unparam", "com_github_anthropics_anthropic_sdk_go", "com_github_ashanbrown_forbidigo_v2", "com_github_burntsushi_toml", "com_github_cenkalti_backoff_v4", "com_github_charmbracelet_x_ansi", "com_github_creack_pty", "com_github_data_dog_go_sqlmock", "com_github_dolthub_dolt_go", "com_github_dolthub_driver_v2", "com_github_dolthub_eventkit", "com_github_dolthub_go_mysql_server", "com_github_dolthub_vitess", "com_github_go_sql_driver_mysql", "com_github_golangci_misspell", "com_github_golangci_unconvert", "com_github_google_uuid", "com_github_gowebpki_jcs", "com_github_invopop_jsonschema", "com_github_johanneskaufmann_html_to_markdown_v2", "com_github_kisielk_errcheck", "com_github_mattn_go_sqlite3", "com_github_microcosm_cc_bluemonday", "com_github_oapi_codegen_oapi_codegen_v2", "com_github_olebedev_when", "com_github_openpeedeep_depguard_v2", "com_github_securego_gosec_v2", "com_github_spf13_cobra", "com_github_spf13_pflag", "com_github_spf13_viper", "com_github_stretchr_testify", "com_github_subosito_gotenv", "com_github_testcontainers_testcontainers_go", "com_github_testcontainers_testcontainers_go_modules_dolt", "com_github_yuin_goldmark", "in_gopkg_yaml_v3", "io_opentelemetry_go_otel", "io_opentelemetry_go_otel_exporters_otlp_otlpmetric_otlpmetrichttp", "io_opentelemetry_go_otel_exporters_stdout_stdoutmetric", "io_opentelemetry_go_otel_exporters_stdout_stdouttrace", "io_opentelemetry_go_otel_metric", "io_opentelemetry_go_otel_sdk", "io_opentelemetry_go_otel_sdk_metric", "io_opentelemetry_go_otel_trace", "io_rsc_script", "land_charm_glamour_v2", "land_charm_huh_v2", "land_charm_lipgloss_v2", "org_go_simpler_sloglint", "org_golang_x_mod", "org_golang_x_net", "org_golang_x_sync", "org_golang_x_sys", "org_golang_x_term", "org_golang_x_tools")
# Hermetic Dolt CLI for tests (tools/bazel/dolt.bzl pins the release to
# scripts/ci/install-dolt.sh). //tools/bazel:dolt selects the repository for
@ -76,3 +317,101 @@ dolt_release(
name = "dolt_darwin_arm64",
platform = "darwin-arm64",
)
# The migration corpus's external Dolt runtime (scripts/migration-test/lib/
# versions.sh DOLT_TEST_RUNTIME_VERSION): an older release than DOLT_VERSION,
# deliberately, as the historical server-Dolt fixtures' host.
dolt_release(
name = "dolt_test_runtime_linux_amd64",
platform = "linux-amd64",
version = "2.1.8",
)
# The tracked release formula, for //scripts:shell_scripts_test and the
# whole-checkout guard //scripts/repochecks:go_install_guidance_test. .beads/
# also holds live bd data and is in .bazelignore, so no main-repo target can
# declare the formula; this local repository exposes only .beads/formulas.
new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
new_local_repository(
name = "beads_formulas",
build_file_content = """exports_files(
glob(["*.formula.toml"]),
visibility = [
"@@//scripts:__pkg__",
"@@//scripts/repochecks:__pkg__",
],
)
""",
path = ".beads/formulas",
)
# Historical bd releases for the regression, migration and cross-version
# suites (tools/bazel/bd_releases.bzl): one repository per release in the
# release catalog that records a linux_amd64 asset digest, behind the
# @bd_releases hub. Adding a release is a catalog change only.
bd_releases = use_extension("//tools/bazel:bd_releases.bzl", "bd_releases")
bd_releases.catalog(path = "//scripts:migration-test/release-catalog.json")
use_repo(bd_releases, "bd_releases")
# The source-tag SQLite release (v0.9.1) has no release asset: the migration
# corpus builds it from its module source with the Go release it was
# qualified on, offline (//tests/migration:bd_source_tag). The proxy files
# are pinned in tests/migration/source_tag_modules.json, the toolchain here.
go_module_proxy = use_repo_rule("//tools/bazel:go_module_proxy.bzl", "go_module_proxy")
go_module_proxy(
name = "bd_source_tag_goproxy",
lock = "//tests/migration:source_tag_modules.json",
)
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "go_1_25_0_linux_amd64",
build_file_content = """exports_files(
["go/bin/go"],
visibility = ["//visibility:public"],
)
filegroup(
name = "sdk",
srcs = glob(["go/**"]),
visibility = ["//visibility:public"],
)
""",
sha256 = "2852af0cb20a13139b3448992e69b868e50ed0f8a1e5940ee1de9e19a123b613",
urls = ["https://go.dev/dl/go1.25.0.linux-amd64.tar.gz"],
)
# The timeout implementations //tests/hook_timeout_backends runs the tracked
# git hook shims against (formerly checks.nix's hook-timeout-backends, which
# took them from nixpkgs): static x86_64 builds, so the test needs nothing
# from the executor beyond a shell, perl and GNU coreutils.
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
http_file(
name = "busybox_static",
executable = True,
sha256 = "6e123e7f3202a8c1e9b1f94d8941580a25135382b99e8d3e34fb858bba311348",
urls = ["https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox"],
)
http_file(
name = "toybox_static",
executable = True,
sha256 = "38e03ffd8aead8ca26833e1e5c90a9ea7250f3719c29d779ebff7aa55c9d2dac",
urls = ["https://landley.net/toybox/downloads/binaries/0.8.15/toybox-x86_64"],
)
http_archive(
name = "uutils_coreutils",
build_file_content = """exports_files(
["coreutils"],
visibility = ["//visibility:public"],
)
""",
sha256 = "9b555b01457279bcc3e46753f0ef324fd3d02a0535111200a4632d1297263b54",
strip_prefix = "coreutils-0.12.0-x86_64-unknown-linux-musl",
urls = ["https://github.com/uutils/coreutils/releases/download/0.12.0/coreutils-0.12.0-x86_64-unknown-linux-musl.tar.gz"],
)

69
MODULE.bazel.lock generated
View file

@ -18,9 +18,12 @@
"https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85",
"https://bcr.bazel.build/modules/apple_support/1.21.0/MODULE.bazel": "ac1824ed5edf17dee2fdd4927ada30c9f8c3b520be1b5fd02a5da15bc10bff3e",
"https://bcr.bazel.build/modules/apple_support/1.21.1/MODULE.bazel": "5809fa3efab15d1f3c3c635af6974044bac8a4919c62238cce06acee8a8c11f1",
"https://bcr.bazel.build/modules/apple_support/1.24.2/MODULE.bazel": "0e62471818affb9f0b26f128831d5c40b074d32e6dda5a0d3852847215a41ca4",
"https://bcr.bazel.build/modules/apple_support/1.24.2/source.json": "2c22c9827093250406c5568da6c54e6fdf0ef06238def3d99c71b12feb057a8d",
"https://bcr.bazel.build/modules/bazel_features/1.1.0/MODULE.bazel": "cfd42ff3b815a5f39554d97182657f8c4b9719568eb7fded2b9135f084bf760b",
"https://bcr.bazel.build/modules/apple_support/2.5.2/MODULE.bazel": "bb1b7081e390a8d3885f642cb0073dfcf8e7a36525e079fa8f5835af7079c0fe",
"https://bcr.bazel.build/modules/apple_support/2.5.2/source.json": "dd51ee925a550e92b55eb41c4c809a967da311a2d2520241252a238a48b39c4c",
"https://bcr.bazel.build/modules/aspect_bazel_lib/2.14.0/MODULE.bazel": "2b31ffcc9bdc8295b2167e07a757dbbc9ac8906e7028e5170a3708cecaac119f",
"https://bcr.bazel.build/modules/aspect_bazel_lib/2.19.3/MODULE.bazel": "253d739ba126f62a5767d832765b12b59e9f8d2bc88cc1572f4a73e46eb298ca",
"https://bcr.bazel.build/modules/aspect_bazel_lib/2.19.3/source.json": "ffab9254c65ba945f8369297ad97ca0dec213d3adc6e07877e23a48624a8b456",
"https://bcr.bazel.build/modules/aspect_bazel_lib/2.8.1/MODULE.bazel": "812d2dd42f65dca362152101fbec418029cc8fd34cbad1a2fde905383d705838",
"https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd",
"https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101",
"https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8",
@ -35,10 +38,13 @@
"https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9",
"https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87",
"https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6",
"https://bcr.bazel.build/modules/bazel_features/1.34.0/MODULE.bazel": "e8475ad7c8965542e0c7aac8af68eb48c4af904be3d614b6aa6274c092c2ea1e",
"https://bcr.bazel.build/modules/bazel_features/1.36.0/MODULE.bazel": "596cb62090b039caf1cad1d52a8bc35cf188ca9a4e279a828005e7ee49a1bec3",
"https://bcr.bazel.build/modules/bazel_features/1.38.0/MODULE.bazel": "f9b8a9c890ebd216b4049fd12a31d3c2602e3403c7af636b04fbbd7453edc9c9",
"https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7",
"https://bcr.bazel.build/modules/bazel_features/1.42.1/MODULE.bazel": "275a59b5406ff18c01739860aa70ad7ccb3cfb474579411decca11c93b951080",
"https://bcr.bazel.build/modules/bazel_features/1.42.1/source.json": "fcd4396b2df85f64f2b3bb436ad870793ecf39180f1d796f913cc9276d355309",
"https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b",
"https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a",
"https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8",
"https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e",
@ -56,10 +62,8 @@
"https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb",
"https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f",
"https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd",
"https://bcr.bazel.build/modules/gazelle/0.32.0/MODULE.bazel": "b499f58a5d0d3537f3cf5b76d8ada18242f64ec474d8391247438bf04f58c7b8",
"https://bcr.bazel.build/modules/gazelle/0.33.0/MODULE.bazel": "a13a0f279b462b784fb8dd52a4074526c4a2afe70e114c7d09066097a46b3350",
"https://bcr.bazel.build/modules/gazelle/0.34.0/MODULE.bazel": "abdd8ce4d70978933209db92e436deb3a8b737859e9354fb5fd11fb5c2004c8a",
"https://bcr.bazel.build/modules/gazelle/0.36.0/MODULE.bazel": "e375d5d6e9a6ca59b0cb38b0540bc9a05b6aa926d322f2de268ad267a2ee74c0",
"https://bcr.bazel.build/modules/gawk/5.3.2.bcr.1/MODULE.bazel": "cdf8cbe5ee750db04b78878c9633cc76e80dcf4416cbe982ac3a9222f80713c8",
"https://bcr.bazel.build/modules/gawk/5.3.2.bcr.1/source.json": "fa7b512dfcb5eafd90ce3959cf42a2a6fe96144ebbb4b3b3928054895f2afac2",
"https://bcr.bazel.build/modules/gazelle/0.51.3/MODULE.bazel": "618a729142f66de1e2cb776d026413763be5b80d5e3d29ffb9d3d90c5defde90",
"https://bcr.bazel.build/modules/gazelle/0.53.0/MODULE.bazel": "76158efbaf12e35ae17af02f4a715bc6e7b3b410c693d34f422922ff4a56a925",
"https://bcr.bazel.build/modules/gazelle/0.53.0/source.json": "1f5a4dd0399e5a20e0daeaa3ba1f42391a1b909bc3d337f7a62d3216ddbdfad0",
@ -70,12 +74,17 @@
"https://bcr.bazel.build/modules/googletest/1.15.2/MODULE.bazel": "6de1edc1d26cafb0ea1a6ab3f4d4192d91a312fd2d360b63adaa213cd00b2108",
"https://bcr.bazel.build/modules/googletest/1.17.0/MODULE.bazel": "dbec758171594a705933a29fcf69293d2468c49ec1f2ebca65c36f504d72df46",
"https://bcr.bazel.build/modules/googletest/1.17.0/source.json": "38e4454b25fc30f15439c0378e57909ab1fd0a443158aa35aec685da727cd713",
"https://bcr.bazel.build/modules/jq.bzl/0.1.0/MODULE.bazel": "2ce69b1af49952cd4121a9c3055faa679e748ce774c7f1fda9657f936cae902f",
"https://bcr.bazel.build/modules/jq.bzl/0.1.0/source.json": "746bf13cac0860f091df5e4911d0c593971cd8796b5ad4e809b2f8e133eee3d5",
"https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075",
"https://bcr.bazel.build/modules/jsoncpp/1.9.6/MODULE.bazel": "2f8d20d3b7d54143213c4dfc3d98225c42de7d666011528dc8fe91591e2e17b0",
"https://bcr.bazel.build/modules/jsoncpp/1.9.6/source.json": "a04756d367a2126c3541682864ecec52f92cdee80a35735a3cb249ce015ca000",
"https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902",
"https://bcr.bazel.build/modules/mboworks_bzl/0.5.1/MODULE.bazel": "20c921aded4f4e00a6128dad47a843371c196ba8987474c11c8ba7b9da8c16f1",
"https://bcr.bazel.build/modules/mboworks_bzl/0.5.1/source.json": "3d9086bb203475113a16afb0ca0c9b97fdb37fc6e5a62b604b60ffc2450dc8c5",
"https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74",
"https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9",
"https://bcr.bazel.build/modules/package_metadata/0.0.2/MODULE.bazel": "fb8d25550742674d63d7b250063d4580ca530499f045d70748b1b142081ebb92",
"https://bcr.bazel.build/modules/package_metadata/0.0.3/MODULE.bazel": "77890552ecea9e284b5424c9de827a58099348763a4359e975c359a83d4faa83",
"https://bcr.bazel.build/modules/package_metadata/0.0.5/MODULE.bazel": "ef4f9439e3270fdd6b9fd4dbc3d2f29d13888e44c529a1b243f7a31dfbc2e8e4",
"https://bcr.bazel.build/modules/package_metadata/0.0.5/source.json": "2326db2f6592578177751c3e1f74786b79382cd6008834c9d01ec865b9126a85",
@ -93,13 +102,11 @@
"https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7",
"https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c",
"https://bcr.bazel.build/modules/protobuf/27.1/MODULE.bazel": "703a7b614728bb06647f965264967a8ef1c39e09e8f167b3ca0bb1fd80449c0d",
"https://bcr.bazel.build/modules/protobuf/29.0-rc2.bcr.1/MODULE.bazel": "52f4126f63a2f0bbf36b99c2a87648f08467a4eaf92ba726bc7d6a500bbf770c",
"https://bcr.bazel.build/modules/protobuf/29.0-rc2/MODULE.bazel": "6241d35983510143049943fc0d57937937122baf1b287862f9dc8590fc4c37df",
"https://bcr.bazel.build/modules/protobuf/29.0-rc3/MODULE.bazel": "33c2dfa286578573afc55a7acaea3cada4122b9631007c594bf0729f41c8de92",
"https://bcr.bazel.build/modules/protobuf/29.0/MODULE.bazel": "319dc8bf4c679ff87e71b1ccfb5a6e90a6dbc4693501d471f48662ac46d04e4e",
"https://bcr.bazel.build/modules/protobuf/29.1/MODULE.bazel": "557c3457560ff49e122ed76c0bc3397a64af9574691cb8201b4e46d4ab2ecb95",
"https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0",
"https://bcr.bazel.build/modules/protobuf/3.19.2/MODULE.bazel": "532ffe5f2186b69fdde039efe6df13ba726ff338c6bc82275ad433013fa10573",
"https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858",
"https://bcr.bazel.build/modules/protobuf/32.1/MODULE.bazel": "89cd2866a9cb07fee9ff74c41ceace11554f32e0d849de4e23ac55515cfada4d",
"https://bcr.bazel.build/modules/protobuf/33.4/MODULE.bazel": "114775b816b38b6d0ca620450d6b02550c60ceedfdc8d9a229833b34a223dc42",
@ -131,19 +138,16 @@
"https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8",
"https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c",
"https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37",
"https://bcr.bazel.build/modules/rules_cc/0.2.15/MODULE.bazel": "6a0a4a75a57aa6dc888300d848053a58c6b12a29f89d4304e1c41448514ec6e8",
"https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84",
"https://bcr.bazel.build/modules/rules_cc/0.2.17/source.json": "3832f45d145354049137c0090df04629d9c2b5493dc5c2bf46f1834040133a07",
"https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642",
"https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6",
"https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8",
"https://bcr.bazel.build/modules/rules_go/0.41.0/MODULE.bazel": "55861d8e8bb0e62cbd2896f60ff303f62ffcb0eddb74ecb0e5c0cbe36fc292c8",
"https://bcr.bazel.build/modules/rules_go/0.42.0/MODULE.bazel": "8cfa875b9aa8c6fce2b2e5925e73c1388173ea3c32a0db4d2b4804b453c14270",
"https://bcr.bazel.build/modules/rules_go/0.46.0/MODULE.bazel": "3477df8bdcc49e698b9d25f734c4f3a9f5931ff34ee48a2c662be168f5f2d3fd",
"https://bcr.bazel.build/modules/rules_go/0.59.0/MODULE.bazel": "b7e43e7414a3139a7547d1b4909b29085fbe5182b6c58cbe1ed4c6272815aeae",
"https://bcr.bazel.build/modules/rules_go/0.63.0/MODULE.bazel": "a2079e783a5d2715a90e6e2970ec8ffd717a487ff2aecb5f553e3975c5294a21",
"https://bcr.bazel.build/modules/rules_go/0.63.0/source.json": "5bf37b45c440ac03abad0cbfa8b8b8dd89cc4e82bc8305f468b8436fa58bae78",
"https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74",
"https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86",
"https://bcr.bazel.build/modules/rules_java/6.3.0/MODULE.bazel": "a97c7678c19f236a956ad260d59c86e10a463badb7eb2eda787490f4c969b963",
"https://bcr.bazel.build/modules/rules_java/6.5.2/MODULE.bazel": "1d440d262d0e08453fa0c4d8f699ba81609ed0e9a9a0f02cd10b3e7942e61e31",
"https://bcr.bazel.build/modules/rules_java/7.10.0/MODULE.bazel": "530c3beb3067e870561739f1144329a21c851ff771cd752a49e06e3dc9c2e71a",
"https://bcr.bazel.build/modules/rules_java/7.12.2/MODULE.bazel": "579c505165ee757a4280ef83cda0150eea193eed3bef50b1004ba88b99da6de6",
@ -190,6 +194,7 @@
"https://bcr.bazel.build/modules/rules_python/1.7.0/source.json": "028a084b65dcf8f4dc4f82f8778dbe65df133f234b316828a82e060d81bdce32",
"https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c",
"https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b",
"https://bcr.bazel.build/modules/rules_shell/0.4.1/MODULE.bazel": "00e501db01bbf4e3e1dd1595959092c2fadf2087b2852d3f553b5370f5633592",
"https://bcr.bazel.build/modules/rules_shell/0.6.1/MODULE.bazel": "72e76b0eea4e81611ef5452aa82b3da34caca0c8b7b5c0c9584338aa93bae26b",
"https://bcr.bazel.build/modules/rules_shell/0.6.1/source.json": "20ec05cd5e592055e214b2da8ccb283c7f2a421ea0dc2acbf1aa792e11c03d0c",
"https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca",
@ -199,13 +204,21 @@
"https://bcr.bazel.build/modules/rules_swift/3.1.2/source.json": "e85761f3098a6faf40b8187695e3de6d97944e98abd0d8ce579cb2daf6319a66",
"https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8",
"https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c",
"https://bcr.bazel.build/modules/stardoc/0.6.2/MODULE.bazel": "7060193196395f5dd668eda046ccbeacebfd98efc77fed418dbe2b82ffaa39fd",
"https://bcr.bazel.build/modules/stardoc/0.7.0/MODULE.bazel": "05e3d6d30c099b6770e97da986c53bd31844d7f13d41412480ea265ac9e8079c",
"https://bcr.bazel.build/modules/stardoc/0.7.2/MODULE.bazel": "fc152419aa2ea0f51c29583fab1e8c99ddefd5b3778421845606ee628629e0e5",
"https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "75aab2373a4bbe2a1260b9bf2a1ebbdbf872d3bd36f80bff058dccd82e89422f",
"https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/source.json": "5fba48bbe0ba48761f9e9f75f92876cafb5d07c0ce059cc7a8027416de94a05b",
"https://bcr.bazel.build/modules/tar.bzl/0.2.1/MODULE.bazel": "52d1c00a80a8cc67acbd01649e83d8dd6a9dc426a6c0b754a04fe8c219c76468",
"https://bcr.bazel.build/modules/tar.bzl/0.6.0/MODULE.bazel": "a3584b4edcfafcabd9b0ef9819808f05b372957bbdff41601429d5fd0aac2e7c",
"https://bcr.bazel.build/modules/tar.bzl/0.6.0/source.json": "4a620381df075a16cb3a7ed57bd1d05f7480222394c64a20fa51bdb636fda658",
"https://bcr.bazel.build/modules/toolchains_llvm/1.11.0/MODULE.bazel": "c0b9c103deeaf0fc103934ff0a189273b4f9b82cc1622c59b67e1c3a83d6b5e6",
"https://bcr.bazel.build/modules/toolchains_llvm/1.11.0/source.json": "d06e53520101c3890a094e5849b0ff16dde3a6f6531f25c997f340ebff34d569",
"https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43",
"https://bcr.bazel.build/modules/yq.bzl/0.1.1/MODULE.bazel": "9039681f9bcb8958ee2c87ffc74bdafba9f4369096a2b5634b88abc0eaefa072",
"https://bcr.bazel.build/modules/yq.bzl/0.1.1/source.json": "2d2bad780a9f2b9195a4a370314d2c17ae95eaa745cefc2e12fbc49759b15aa3",
"https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0",
"https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27",
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "eec517b5bbe5492629466e11dae908d043364302283de25581e3eb944326c4ca",
@ -216,7 +229,7 @@
"moduleExtensions": {
"@@pybind11_bazel+//:internal_configure.bzl%internal_configure_extension": {
"general": {
"bzlTransitiveDigest": "NRXra7941UfmNUyIxnLt82V5hULluVGL2nBsijTl4j4=",
"bzlTransitiveDigest": "BsgERqYptkJeeC8wFaLj251IoTZTSy/58WA6kVp0q8I=",
"usagesDigest": "D1r3lfzMuUBFxgG8V6o0bQTLMk3GkaGOaPzw53wrwyw=",
"recordedInputs": [
"REPO_MAPPING:pybind11_bazel+,bazel_tools bazel_tools",
@ -238,7 +251,7 @@
},
"@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": {
"general": {
"bzlTransitiveDigest": "+Kp6j204mBZ3mxlIDDR0gBoP45BZ4jYRhRAcB8sU0qc=",
"bzlTransitiveDigest": "WDuVCwqV73DvcHB5Of+02lhUZgPxr9MqtpvMRyUi0eQ=",
"usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=",
"recordedInputs": [
"REPO_MAPPING:rules_kotlin+,bazel_tools bazel_tools"
@ -295,7 +308,7 @@
},
"@@rules_python+//python/extensions:config.bzl%config": {
"general": {
"bzlTransitiveDigest": "dzD8Q2YmrP3fz8saWLHPmlwPLO91ImtTmP/c9JKTStM=",
"bzlTransitiveDigest": "L+2ZCpb7GIJqvWaXpzkfk/80d916sIFVmSPzrSm6of8=",
"usagesDigest": "ZVSXMAGpD+xzVNPuvF1IoLBkty7TROO0+akMapt1pAg=",
"recordedInputs": [
"REPO_MAPPING:rules_python+,bazel_tools bazel_tools",
@ -463,7 +476,7 @@
},
"@@rules_python+//python/uv:uv.bzl%uv": {
"general": {
"bzlTransitiveDigest": "ijW9KS7qsIY+yBVvJ+Nr1mzwQox09j13DnE3iIwaeTM=",
"bzlTransitiveDigest": "IgkgxNrtlAec7OnaFrWoCC5NQhHcY/aIz4jsqcNMm8Y=",
"usagesDigest": "H8dQoNZcoqP+Mu0tHZTi4KHATzvNkM5ePuEqoQdklIU=",
"recordedInputs": [
"REPO_MAPPING:rules_python+,bazel_tools bazel_tools",
@ -490,6 +503,26 @@
}
}
}
},
"@@toolchains_llvm+//toolchain/extensions:distributions.bzl%llvm_distributions": {
"general": {
"bzlTransitiveDigest": "RfYsFLwRh0rVY8ReiYgbOEyr84zuBs7mbcHq3dPY3jI=",
"usagesDigest": "vl2VXD2E16aV3RG06i5tx7yyYASHiQFjvsiNZSDzQIg=",
"recordedInputs": [],
"generatedRepoSpecs": {
"llvm_distributions_data": {
"repoRuleId": "@@toolchains_llvm+//toolchain/internal:distributions_repo.bzl%llvm_distributions_repo",
"attributes": {
"srcs": [
"@@toolchains_llvm+//toolchain/distributions:pre_github.jsonc",
"@@toolchains_llvm+//toolchain/distributions:github_legacy.jsonc",
"@@toolchains_llvm+//toolchain/distributions:github.jsonc",
"@@toolchains_llvm+//toolchain/distributions:extra.jsonc"
]
}
}
}
}
}
},
"facts": {

123
Makefile
View file

@ -44,13 +44,32 @@ endif
endif
.PHONY: all build doctor-build test test-icu-path test-full-cgo test-regression test-upgrade test-cross-version test-migration corpus-regen githooks-regen bench bench-quick clean clean-test-tmp install install-force help check-up-to-date fmt fmt-check check-testing-short
.PHONY: ci-pr-core ci-pr-policy ci-pr-lint ci-complexity ci-complexity-diff ci-complexity-check ci-package-mcp ci-package-npm
.PHONY: lint lint-changed vet
.PHONY: check check-go test-go check-docs-go
.PHONY: ci-pr-core ci-pr-lint ci-complexity ci-complexity-diff ci-complexity-check ci-package-mcp ci-package-npm nogo-ownership
.PHONY: api-gen api-check
.PHONY: bazel-sync bazel-sync-check
# Default target
all: build
# Build and test engine. Bazel is what CI gates on: .github/workflows/bazel.yml
# runs `bazel test` lanes on rbe-west, and nogo (lint + vet), formatting and
# the repository guards are Bazel targets there. The primary targets (test,
# check, check-docs) run the same `bazel test` commands as those lanes, so a
# local run shares CI's action keys and its remote cache (engdocs/TESTING.md
# "Building and testing"). Each keeps a plain go twin under an explicit -go
# name (test-go, check-go, check-docs-go) for offline work and hosts Bazel does
# not serve; that twin is an inner-loop convenience, not what CI enforces.
# GitHub Actions jobs that still run Go-native suites call the -go names.
BAZEL ?= bazel
# Extra flags for every `bazel test` below: --config=fork-cache (contributors:
# the anonymous read-only cache) or --config=remote-exec (maintainers with an
# rbe-west client certificate). Hosts whose ~/.bazelrc names the executor need
# neither. Better: put `build --config=...` in the gitignored .bazelrc.local.
BAZEL_FLAGS ?=
BAZEL_TEST = $(BAZEL) test $(BAZEL_FLAGS)
BUILD_DIR := .
BD_BUILD_OUTPUT := $(BUILD_DIR)/bd$(if $(filter Windows_NT,$(OS)),.exe)
GIT_BUILD := $(shell git rev-parse --short HEAD)
@ -173,11 +192,27 @@ doctor-build:
echo " CGO_ENABLED=1 go build -tags gms_pure_go ./cmd/bd" ;; \
esac
# Run all tests (skips known broken tests listed in .test-skip)
# bazel.yml's test lane (`bazel test //... --config=ci`): every untagged
# go_test with PR Core's selection (race, -short, skips), plus nogo lint/vet,
# formatting and the repository guards. The other lanes' commands are in
# engdocs/TESTING.md "Building and testing".
test:
$(BAZEL_TEST) //... --config=ci
# Plain go test (skips known broken tests listed in .test-skip): an inner-loop
# convenience without Bazel; CI does not run it.
test-go:
@echo "Running tests..."
@TEST_COVER=1 ./scripts/test.sh
# Fast quality gates: the testing.Short policy, the full nogo lint gate
# (native plus the windows/darwin passes) and `make test`.
check: check-testing-short ci-pr-lint test
# The same gates without Bazel where they have a Go form: gofmt and go test.
# nogo has no go twin, so this is a convenience CI does not enforce.
check-go: fmt-check check-testing-short test-go
# Run the opt-in ICU regex path test suite (no skip list).
# This is a local developer workflow for intentionally exercising the leftover
# ICU path; it is not part of normal validation.
@ -194,12 +229,59 @@ test-full-cgo:
ci-pr-core:
@./scripts/ci/pr-core.sh
ci-pr-policy:
@./scripts/ci/pr-policy.sh
# Lint and vet are nogo (//tools/nogo): go test's vet checks plus the
# golangci-lint linters .golangci.yml enables, validated beside every Go
# compile, so any `bazel build`/`bazel test` (local or on rbe-west) fails on a
# finding. These targets ask Bazel for the analysis alone (.bazelrc's
# --config=nogo; nothing is linked).
ci-pr-lint:
@./scripts/ci/pr-lint.sh
# nogo-ownership is a dynamic, advisory cross-check (not part of the required
# //scripts static suite, which cannot shell out to Bazel): it asks real
# `bazel aquery` whether the nogo owner lane for each configuration group
# (today: race, bazel-test/--config=ci) really does validate every file a
# non-owner lane (embedded, doltserver, doltserver-proxied, dolt-race, which
# pass --norun_validations) compiles. See tools/bazel/nogo_ownership.py and
# scripts/nogo_lint_policy_test.go's nogoConfigurations table.
nogo-ownership:
@python3 tools/bazel/nogo_ownership.py
# The CI lint gate: native, plus //tools/bazel:release_cross for windows/amd64
# and darwin/arm64 (BD_LINT_TARGETS selects; scripts/pr-lint).
lint: ci-pr-lint
# go test's vet checks run inside nogo; same as lint.
vet: lint
# nogo over the Bazel packages of changed Go files, natively (the pre-commit
# hook's lint). LINT_CHANGED_SCOPE: staged, or worktree (changed against
# LINT_CHANGED_REF, staged, and untracked).
LINT_CHANGED_SCOPE ?= worktree
LINT_CHANGED_REF ?= HEAD
lint-changed:
@case "$(LINT_CHANGED_SCOPE)" in \
staged) files="$$(git diff --cached --name-only --diff-filter=ACMRT -- '*.go')" ;; \
worktree) files="$$( \
git diff --name-only --diff-filter=ACMRT "$(LINT_CHANGED_REF)" -- '*.go'; \
git diff --cached --name-only --diff-filter=ACMRT -- '*.go'; \
git ls-files --others --exclude-standard -- '*.go')" ;; \
*) echo "unknown LINT_CHANGED_SCOPE=$(LINT_CHANGED_SCOPE); expected staged or worktree" >&2; exit 2 ;; \
esac; \
packages=""; missing=""; \
for file in $$files; do \
dir="$$(dirname "$$file")"; \
case "/$$dir/" in */testdata/*) continue ;; esac; \
if [ -f "$$dir/BUILD.bazel" ]; then packages="$$packages //$${dir#.}:all"; else missing="$$missing $$dir"; fi; \
done; \
if [ -n "$$missing" ]; then \
echo "lint-changed: no BUILD.bazel in$$missing; run 'make bazel-sync'" >&2; exit 1; \
fi; \
packages="$$(printf '%s\n' $$packages | sort -u | sed 's#^///#//#; s#^//\.:#//:#')"; \
if [ -z "$$packages" ]; then echo "lint-changed: no changed Go packages"; exit 0; fi; \
echo "lint-changed:" $$packages; \
$(BAZEL) build --config=nogo -- $$packages
# Opt-in architecture experiment. Install gocyclo v0.6.0 first;
# report is advisory while check exercises the local baseline guard.
ci-complexity:
@ -220,9 +302,8 @@ api-gen:
go generate -tags "$(BUILD_TAGS)" ./internal/httpapi/apigen
# Two-part spec drift gate: regenerate and fail if regeneration CHANGED
# anything, then run the spec tests. Runs in the PR workflow's policy job
# (scripts/ci/pr-policy.sh), on every pull request, never only on
# push-to-main.
# anything, then run the spec tests. CI runs the drift half as
# //scripts/repochecks:types_gen_drift_test.
#
# The drift question is "do the checked-out types already match the checked-out
# spec", so the comparison is before-vs-after regeneration rather than
@ -380,8 +461,15 @@ fmt:
fmt-check:
@./scripts/ci/fmt-check.sh
# Validate documentation references against actual CLI flags
# Docs checks: docsync and doc freshness as bazel.yml's test lane runs them,
# then the CLI flag check, which validates against bd built from the release in
# docs/cli-docs.pin (so it stays a script, like pr.yml's check-doc-flags job).
check-docs:
$(BAZEL_TEST) //test/docsync:docsync_test //scripts/repochecks:doc_freshness_test --config=ci
@./scripts/check-doc-flags.sh
# The same docs checks with plain go test and a go-built bd.
check-docs-go:
@echo "Building bd for docs checks..."
@CGO_ENABLED=0 go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BUILD_DIR)/bd" ./cmd/bd
@./scripts/check-doc-flags.sh "$(BUILD_DIR)/bd"
@ -416,12 +504,10 @@ diagrams-excalidraw:
docs-dev:
./mint.sh dev
# Bazel (side-by-side with the Go toolchain; `go build`/`go test` do not need
# it). Regenerate BUILD.bazel files with gazelle and refresh the MODULE.bazel
# Regenerate BUILD.bazel files with gazelle and refresh the MODULE.bazel
# use_repo list + MODULE.bazel.lock, then refresh the go_srcs filegroups that
# source-scanning tests declare as data (tools/bazel/go_srcs.py). Run after
# changing Go imports, go.mod, or packages.
BAZEL ?= bazel
bazel-sync:
$(BAZEL) run //:gazelle
python3 tools/bazel/go_srcs.py
@ -457,12 +543,16 @@ help:
@echo "Beads Makefile targets:"
@echo " make build - Build the bd binary"
@echo " make doctor-build - Diagnose build env (GOFLAGS/CGO/CC) for the ICU build trap"
@echo " make test - Run all tests"
@echo " make test - bazel test //... --config=ci (bazel.yml's test lane; BAZEL_FLAGS adds flags)"
@echo " make test-go - Plain go test via scripts/test.sh (inner loop; not what CI enforces)"
@echo " make check - testing.Short policy + nogo lint gate + make test"
@echo " make check-go - gofmt + testing.Short policy + make test-go (no Bazel)"
@echo " make test-icu-path - Run opt-in ICU regex path tests (maintainer-only)"
@echo " make test-full-cgo - Deprecated alias for make test-icu-path"
@echo " make ci-pr-core - Run required PR core Go test wrapper"
@echo " make ci-pr-policy - Run required PR policy wrapper"
@echo " make ci-pr-lint - Run required PR formatting and lint wrapper"
@echo " make ci-pr-lint - Run the required lint gate: nogo (vet + golangci-lint's linters) under Bazel, native + windows/darwin"
@echo " make lint - Same as ci-pr-lint (make vet too)"
@echo " make lint-changed - nogo over the Bazel packages of changed Go files (LINT_CHANGED_SCOPE=staged|worktree)"
@echo " make ci-complexity - Report production cyclomatic complexity (advisory)"
@echo " make ci-complexity-diff - Compare complexity with COMPLEXITY_BASE_REF"
@echo " make ci-complexity-check - Check complexity against the local baseline"
@ -478,7 +568,8 @@ help:
@echo " make install-force - Install bd, skipping the origin/main update check"
@echo " make fmt - Format all Go files with gofmt"
@echo " make fmt-check - Check Go formatting (for CI)"
@echo " make check-docs - Validate docs against CLI flags"
@echo " make check-docs - Bazel docsync + doc freshness tests, then the CLI flag check"
@echo " make check-docs-go - The same docs checks with plain go test"
@echo " make api-gen - Regenerate HTTP API types from the OpenAPI spec"
@echo " make api-check - OpenAPI drift gate (regenerate, diff-or-fail, spec tests)"
@echo " make bazel-sync - Regenerate Bazel BUILD files and tidy MODULE.bazel (gazelle + mod tidy)"

155
README.md
View file

@ -42,7 +42,7 @@ bd setup factory # Factory.ai Droid - creates/updates AGENTS.md
**Note:** Beads is a CLI tool you install once and use everywhere. You don't need to clone this repository into your project.
`bd init` creates or updates `AGENTS.md` by default so agents can discover the beads workflow, and also installs project Claude/Codex integrations unless you pass `--skip-agents` or `--stealth`. Use `bd setup --list` to see supported integrations, including `bd setup codex`, `bd setup factory`, `bd setup claude`, `bd setup mux`, `bd setup cursor`, and more. See [Agent and IDE setup](docs/getting-started/ide-setup.md).
`bd init` creates or updates `AGENTS.md` by default so agents can discover the beads workflow, and also installs the project Claude Code, Codex, and Cursor integrations unless you pass `--skip-agents` or `--stealth`. Use `bd setup --list` to see supported integrations, including `bd setup codex`, `bd setup factory`, `bd setup claude`, `bd setup mux`, `bd setup cursor`, and more. See [Agent and IDE setup](docs/getting-started/ide-setup.md).
Manual copy-paste is only for unsupported agents, existing projects where you cannot rerun `bd init`/`bd setup`, or custom instruction files. In those cases, run `bd onboard` and paste the printed snippet into the file your agent reads.
@ -109,8 +109,8 @@ version: sync remote-backed databases with your current `bd`, back up with
`bd export --all`, upgrade the binary, then run `bd info --whats-new`,
`bd hooks install`, and `bd version`. If the upgrade crosses a schema
migration on a remote-backed database, exactly one designated clone runs
`bd migrate` and `bd dolt push`; other clones install the new binary
and run `bd bootstrap`. See the full
`bd migrate schema` and `bd dolt push`; other clones install the new
binary and run `bd bootstrap`. See the full
[upgrade guide](https://beads.gascity.com/getting-started/upgrading)
or [docs/getting-started/installation.md](docs/getting-started/installation.md#updating-bd).
@ -175,6 +175,153 @@ are unaffected.
the guard with a warning on stderr. Use this only if you know the forward
migrations are additive and safe for your specific workload.
## 🔌 HTTP Backend (experimental)
A workspace can also talk to a remote `bd serve` over HTTP instead of opening
a local Dolt database — useful for a thin client against a shared server, or
for embedding beads in another program as a library.
```bash
# Point this workspace at a server (verifies the server first; writes nothing on failure)
bd connect https://bd.example.com --expect-project-id my-project
# The everyday commands work the same way: create, show, list, update, close,
# dependencies (including `bd dep tree`), comments, ready/count queries, and
# batch apply all round-trip over the wire with the same semantics as a local
# database. So does `bd ready --claim`, except against an older server or while
# any issue holds an unsatisfied external ref: then it lists and claims in two
# steps rather than one transaction (ledger row L14, linked below).
bd create "Fix auth bug" -p 1 -t bug
bd ready --json
bd close bd-a1b2 "Fixed"
# Loopback needs no TLS
bd connect http://127.0.0.1:8080
# Forget the server and restore this workspace's previous backend selection
bd connect --clear
```
HTTP mode is not a byte-for-byte mirror of local mode, though: some
operations are knowingly refused (the wire has no way to express them) or
degrade to a different-but-not-misreadable behavior (for example, a few
unbounded listing shapes lose single-query snapshot isolation and instead
walk the server page by page). Every one of these is a deliberate, tested
row, never a silent gap — see
[`engdocs/design/http-divergence-ledger.md`](engdocs/design/http-divergence-ledger.md)
for the full, generated list of what differs and why before depending on an
HTTP-backed workspace for a workflow you haven't checked against it. One
refusal to know up front: `bd close --claim-next` closes nothing over HTTP,
because the wire's batch close cannot carry the claim. Close without it, then
run `bd ready --claim`.
[Cross-repo dependencies](docs/core-concepts/dependencies.md#cross-repo-dependencies)
keep their policy over HTTP. The client resolves each `external:` reference
against its own `external_projects` configuration. `bd dep tree` shows the
reference as a leaf, and while it is unsatisfied the issue stays out of
`bd ready` and `bd ready --claim`, and `bd close` refuses it without
`--force`. A server that advertises enforcing that policy itself is trusted
to do so instead.
Three CLI-level differences are worth knowing up front:
- IDs resolve exactly: an abbreviated id is not expanded (the wire has no
substring search), and a missing id is reported as not found after one
lookup.
- `bd update -s closed` does not record `closed_by_session` (from `--session`
or `CLAUDE_SESSION_ID`), because the wire's update cannot carry it; the
close itself happens as usual. `bd close` does record the session. `bd
reopen`'s history entry carries the server's own label.
- Contributor auto-routing (`routing.*` settings) is read from local
`config.yaml` / environment only, never from the server's settings: its
targets are local paths.
`bd connect` writes two things on success: `.beads/metadata.json` gets
`"backend": "http"`, and a per-user, never-git-tracked sidecar
(`.beads/http_target.json`) records the server URL and pinned project id. It
never writes a credential to disk. A bearer credential, if the server
requires one, comes from `BEADS_HTTP_TOKEN=host[:port]=<token>`, then
`BEADS_HTTP_TOKEN_COMMAND=host[:port]=<command>` (a helper that prints a
token), then the credentials file, then no credential at all. Both variables
must name the server they are for (a pattern without a port matches that
host on any port); a bare value is refused, because it would be sent to
whatever server the workspace's `http_target.json` names. Connecting to a
non-loopback server over plain `http://` is refused by default (a bearer
credential would cross the network unencrypted) — pass `--allow-plaintext` to
override, or use `https://`. Switching a workspace that already selects a
different backend needs `--force`.
Each read (a GET, or the POST batch get) gives its first attempt 15s, from
when the request is sent, to get the server's response headers
(`BEADS_HTTP_RESPONSE_HEADER_TIMEOUT`: a duration such as `30s`, a number of
seconds, or `off`). A read whose headers do not arrive in time, or whose
connection is reset, is retried once on another connection, and each retry
is logged to stderr with its count. The retry has no header timer, but it
runs on what is left of the 60s bound on the whole request, counted from
when the first attempt was sent: a slow but healthy read still finishes if
the retry's headers and body together fit in that remainder (about 45s after
a header timeout), and one that needs longer now fails at 60s. The header
timer never cuts off a body that is still streaming; the 60s bound still
does. The events:watch stream's connect gets neither the header timer nor
the retry. On Windows a reset connection is retried only when it surfaces as
an early EOF, because the check matches the Unix reset error (`ECONNRESET`),
which a Windows reset (`WSAECONNRESET`) is not. A write gets no
header timer (the server answers a write only after it commits, so a large
one can be slow and healthy) and is never retried; if the 60s bound expires
after it was sent but before its headers, it fails with an error naming the
server's host, because it may or may not have been applied. A batch apply of
more than 100 items (a large `bd create --graph` plan, say) gets 6 minutes
instead of 60s, because `bd serve` gives such a request its
`--large-apply-ceiling` (5 minutes by default) and finishes it even after the
client has given up. A server whose ceiling is raised past about 5m15s can
still outlast the client. A dial or TLS timeout stays a plain connection
error, since the server never saw the request, and a connect that fails says
so: it names the address that refused the connection (nothing listening) or
never answered (a filtered port or a down host, after the dialer's 30s), or
the host name that did not resolve. `off` turns off only the
header timer: a reset read is still retried, and a write's timeout is still
reported as above.
Whether the server applies bd's external-dependency policy itself (the
`policy.external_dependencies` capability) is remembered for 5 minutes per
server URL and pinned project, in `beads/http-policy/` under the user cache
directory, so `bd ready` does not fetch the server's context before every
listing just to learn it. `BEADS_HTTP_POLICY_CACHE_TTL` sets that window (a
duration such as `1m`, a number of seconds, or `off`); a server restarted
with a different composition is seen once it passes. Claims and closes never
use the cached answer: they ask the server, since a stale one could skip the
client-side refusal of externally blocked work. A workspace connected without
a project pin is not cached.
`bd search`, `bd show --current` and `bd recompute-blocked` work over HTTP
too, each in its own way. `bd search` asks the server's listing with its text (`q`, behind the `issues.list.search` capability) and
refuses before dialing against a server that does not advertise it. `bd list
--no-assignee`, `--title` and `--id` likewise ride the listing's
`no_assignee`, `title` and repeatable `id`, each behind its own capability
(`issues.list.noAssignee`, `issues.list.title`, `issues.list.ids`), and the
rest of `bd list`'s filters (`--updated-*`, `--closed-*`, `--defer-*`,
`--due-*`, `--priority*`, the text and external-ref matches, `--spec`,
`--label-pattern`/`--label-regex`, `--exclude-type`, `--no-parent`,
`--no-labels`, `--empty-description`, `--pinned`/`--no-pinned`,
`--deferred`, `--overdue`, `--mol-type`, `--wisp-type`) ride it behind one
capability, `issues.list.filters`. Time bounds are resolved on the client as
they are locally; `--overdue` compares against the server's clock. The
default `--parent` tree view does not carry those filters yet and refuses one
rather than drop it; `--flat` or `--json` applies them to the parent's direct
children (not its whole subtree).
`bd show --current` finds the actor's in-progress or hooked issue through the
server's boolean query. `bd recompute-blocked` is a no-op that exits 0: the
server maintains `is_blocked` on every write, and repairing a stale flag is
done in the server's own workspace (`--json` reports
`{"rows_corrected": 0, "maintained_by": "server"}`).
An embedding program that links beads as a library rather than running
`cmd/bd` registers this backend itself through the public
[`backend/http`](backend/http) package (`bdhttp.Register`), and can open a
workspace with a credential scoped to one caller via
`beads.OpenBestAvailableWith` — see that package's doc comment for the
multi-tenant case. This surface is EXPERIMENTAL: pin an exact beads version.
## 🌐 Community Tools
See [docs/community-tools.md](docs/community-tools.md) for a curated list of community-built UIs, extensions, and integrations—including terminal interfaces, web UIs, editor extensions, and native apps.
@ -212,5 +359,5 @@ This is useful for:
## 📝 Documentation
* [Documentation site](https://beads.gascity.com/) | [Installing](docs/getting-started/installation.md) | [Sync Concepts](docs/core-concepts/sync-concepts.md) | [Agent Setup](docs/getting-started/ide-setup.md) | [Copilot CLI Setup](docs/integrations/copilot-cli.md) | [Copilot VS Code MCP](docs/integrations/github-copilot.md) | [Articles](ARTICLES.md) | [Sync Branch Mode](docs/reference/protected-branches.md) | [Troubleshooting](docs/reference/troubleshooting.md) | [FAQ](docs/reference/faq.md)
* Contributing: [CONTRIBUTING.md](CONTRIBUTING.md) | [Roadmap](ROADMAP.md) | [Contributor agent instructions](AGENTS.md)
* Contributing: [CONTRIBUTING.md](CONTRIBUTING.md) (Bazel builds and tests beads: install [Bazelisk](https://github.com/bazelbuild/bazelisk), then `make test`) | [Roadmap](ROADMAP.md) | [Contributor agent instructions](AGENTS.md)
* [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/gastownhall/beads)

View file

@ -94,15 +94,19 @@ release-critical gates do not all run on every PR, so "tag the tip of main"
means tagging a SHA nobody has fully tested. A burned tag is never reused
(the v1.1.1 and v1.2.0 precedents), so that gamble is expensive.
**Cut the branch from a SHA that is green on both `Main` and
`Nightly Full Tests`.** The `Main` workflow runs on push to `main` and the
`Nightly Full Tests` workflow runs on a 2am UTC schedule, so the newest SHA
with both is usually a few hours behind the tip:
**Cut the branch from a SHA that is green on `Bazel`, `Main` and
`Nightly`.** The `Bazel` workflow (every Linux test lane, on rbe-west) and
the `Main` workflow (the macOS and Windows jobs) run on push to `main`, and
the `Nightly` workflow (the full Bazel suite with no cached test results)
runs on a 2am UTC schedule, so the newest SHA with all three is usually a
few hours behind the tip:
```bash
gh run list --workflow Bazel --branch main --event push --status success --limit 5 \
--json headSha,conclusion,createdAt
gh run list --workflow Main --branch main --status success --limit 5 \
--json headSha,conclusion,createdAt
gh run list --workflow "Nightly Full Tests" --status success --limit 3 \
gh run list --workflow Nightly --status success --limit 3 \
--json headSha,conclusion,createdAt
git fetch origin
@ -136,16 +140,17 @@ git log --oneline main..release/1.3.0
Before starting a release:
- [ ] `release/x.y.z` branch cut from a SHA green on `Main` **and**
`Nightly Full Tests` (see [Release Branches](#release-branches))
- [ ] All tests passing (`go test ./...`)
- [ ] `release/x.y.z` branch cut from a SHA green on `Bazel`, `Main` **and**
`Nightly` (see [Release Branches](#release-branches))
- [ ] All tests passing (`make test`, the Bazel test lane)
- [ ] npm package tests passing (`cd npm-package && npm run test:all`)
- [ ] **Upgrade smoke tests pass** (`make test-upgrade`) — see [Release Stability Gate](engdocs/RELEASE-STABILITY-GATE.md)
- [ ] **Regression tests pass** (`make test-regression`)
- [ ] **Regression tests pass**
(`bazel test //tests/regression:regression_test --config=doltserver-cmd`)
- [ ] **Every release target cross-compiles** — see
[Cross-compile before tagging](#cross-compile-before-tagging). PR CI does
not build them ([#5662](https://github.com/gastownhall/beads/issues/5662)),
and a target that fails at tag time burns the tag.
[Cross-compile before tagging](#cross-compile-before-tagging). PR CI
builds them only with cgo off, and a target that fails at tag time
burns the tag.
- [ ] **CHANGELOG.md updated with release notes** (see format below)
- [ ] **CHANGELOG rollup checked** — nothing left under `[Unreleased]` that
belongs in this release, and nothing filed under a *previous* release's
@ -163,12 +168,15 @@ Before starting a release:
### Cross-compile before tagging
`.goreleaser.yml` builds darwin, linux, windows **and freebsd**, but PR CI
builds none of the cross targets — the v1.2.0 tag burned on a freebsd
compilation failure that no pre-tag gate could have caught
([#5661](https://github.com/gastownhall/beads/pull/5661) fixed the break,
[#5662](https://github.com/gastownhall/beads/issues/5662) tracks the CI gap).
Until that gap is closed, build them by hand before tagging:
`.goreleaser.yml` builds darwin, linux, windows **and freebsd**; the v1.2.0
tag burned on a freebsd compilation failure no pre-tag gate caught
([#5661](https://github.com/gastownhall/beads/pull/5661),
[#5662](https://github.com/gastownhall/beads/issues/5662)). PR CI now builds
the whole tree for every target in `scripts/ci/release-targets.txt` with Bazel
(`scripts/ci/bazel-release-cross-compile.sh`, in bazel.yml's pure-Go lane),
but with cgo off, while linux/amd64, linux/arm64, windows/amd64 and the darwin
pair ship with `CGO_ENABLED=1`. Build the real release configuration by hand
before tagging:
```bash
goreleaser build --snapshot --clean

View file

@ -10,9 +10,10 @@ and the live state of each item is its tracking issue on GitHub.
- **Priority areas get expedited review.** Issues and PRs that advance a
priority area below are triaged and reviewed first.
- **Every PR links a documented issue.** To propose work — inside or
outside a priority area — open an issue with the feature form, before or
alongside your PR; see
- **Propose work with an issue when it warrants discussion.** For work
inside or outside a priority area that needs context or a design decision,
open an issue with the feature form, before or alongside your PR; small,
self-explanatory changes can go straight to a PR. See
[CONTRIBUTING.md](CONTRIBUTING.md#issues-and-pull-requests).
- **Scope.** Proposals must fit the product boundary in
[engdocs/PROJECT_CHARTER.md](engdocs/PROJECT_CHARTER.md).
@ -59,7 +60,8 @@ and the live state of each item is its tracking issue on GitHub.
- **Goal:** a new contributor, human or agent, finds the rules for the code
they are changing next to that code, understands its intent and
invariants, and lands a change with a documented issue and PR.
invariants, and lands a well-explained PR, backed by an issue when the
change warrants one.
- **This period:** contributor-only agent instructions and documented-issue
intake ([#7223](https://github.com/gastownhall/beads/pull/7223));
per-package `AGENTS.md` files for the storage packages, naming their

View file

@ -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 |

View file

@ -43,3 +43,64 @@ filegroup(
)
# --- end go_srcs ---
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
filegroup(
name = "repo_doc_files",
srcs = glob(
[
"**/*.md",
"**/*.mdx",
],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_srcs",
srcs = glob(
["**/*.go"],
allow_empty = True,
exclude = [
"**/*_test.go",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_test_srcs",
srcs = glob(
["**/*_test.go"],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_other_files",
srcs = glob(
["**"],
exclude = [
"**/*.db",
"**/*.exe",
"**/*.go",
"**/*.md",
"**/*.mdx",
"**/*.out",
"**/*.prof",
"**/*.pyc",
"**/*.test",
"**/__pycache__/**",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
# --- end repo_files ---

View file

@ -11,9 +11,11 @@ go_library(
"audit_molecule_wisp_batch_iter.go",
"audit_search-counts-stats.go",
"batch_apply_contract.go",
"batch_apply_gate_contract.go",
"batch_closer_contract.go",
"batch_creator_contract.go",
"batch_getter_contract.go",
"blocked_lister_contract.go",
"blocked_state.go",
"blocking_annotator_contract.go",
"bootstrapper_contract.go",
@ -27,19 +29,25 @@ go_library(
"deleter_contract.go",
"dependency_editor_contract.go",
"dualwrite_history_contract.go",
"dualwrite_participation_generation_contract.go",
"edge_reader_contract.go",
"expected_revision_contract.go",
"graph_counter_contract.go",
"heartbeater_contract.go",
"history_matching.go",
"importer_contract.go",
"issue_operations_contract.go",
"issue_operations_staging.go",
"journal_contract.go",
"lease_reclaimer_contract.go",
"lifecycle_close_reopen_contract.go",
"lifecycle_create_contract.go",
"lifecycle_create_gate_contract.go",
"lifecycle_update_contract.go",
"lifecycle_update_gate_contract.go",
"memories_contract.go",
"metadata_cas_contract.go",
"molecule_contract.go",
"portable.go",
"querier_contract.go",
"reader_contract.go",
@ -57,11 +65,13 @@ go_library(
"transaction_parity.go",
"tree_walker_contract.go",
"version_reconciler_contract.go",
"versioned_read_contract.go",
"workspaceconfig_contract.go",
],
importpath = "github.com/steveyegge/beads/backend/conformance",
visibility = ["//visibility:public"],
deps = [
"//internal/hooks",
"//internal/storage",
"//internal/storage/issueops",
"//internal/storage/kvkeys",
@ -111,3 +121,64 @@ filegroup(
)
# --- end go_srcs ---
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
filegroup(
name = "repo_doc_files",
srcs = glob(
[
"**/*.md",
"**/*.mdx",
],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_srcs",
srcs = glob(
["**/*.go"],
allow_empty = True,
exclude = [
"**/*_test.go",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_test_srcs",
srcs = glob(
["**/*_test.go"],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_other_files",
srcs = glob(
["**"],
exclude = [
"**/*.db",
"**/*.exe",
"**/*.go",
"**/*.md",
"**/*.mdx",
"**/*.out",
"**/*.prof",
"**/*.pyc",
"**/*.test",
"**/__pycache__/**",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
# --- end repo_files ---

View file

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"reflect"
"strings"
"testing"
"github.com/steveyegge/beads/internal/types"
@ -170,6 +171,12 @@ func RunBatchApplyAppliesEveryItemInDeclarationOrder(t *testing.T, ctx context.C
if got := batchApplyColumn(t, ctx, fixture, "status", blocked); got == string(types.StatusClosed) {
t.Errorf("%s was closed by a request that only asked to close %s", blocked, blocker)
}
// Neither create item names a creator, so each defaults to the request's actor.
for _, id := range []string{blocked, blocker} {
if got := batchApplyColumn(t, ctx, fixture, "created_by", id); got != "apply-writer" {
t.Errorf("%s created_by = %q, want the request's actor %q", id, got, "apply-writer")
}
}
}
// RunBatchApplyBindsEachNamedKeyToItsMintedID pins ApplyBatchResult.Keys: it is
@ -881,9 +888,12 @@ func RunBatchApplyEvaluatesExpectedAssigneeAsModified(t *testing.T, ctx context.
// close it. The refusal is the assertion; the rollback of the parent it created
// is what says the refusal took the request with it.
//
// POSITIVE HALF: the identical request with Force lands, which is the whole of
// what Force does ("bypasses blocker and open-child close policy, and nothing
// else") and the proof that the refusal was the policy rather than the shape.
// POSITIVE HALF: the identical request with Force lands, and that is the proof
// the refusal was the policy rather than the shape. Force "bypasses blocker and
// open-child close policy, the pin and the assignee fence, and never the
// template guard" (batchapplier.go), and the parent trips no guard — the
// unforced half reached the policy, which the guards run before — so the
// policy is the only refusal Force had to waive.
func RunBatchApplyClosePolicyEvaluatesAtTheCloseItem(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
parent := fixture.IssuePrefix + "-closepolicy-parent"
@ -923,7 +933,7 @@ func RunBatchApplyClosePolicyEvaluatesAtTheCloseItem(t *testing.T, ctx context.C
t.Errorf("%s status = %q under Force, want %q", parent, got, types.StatusClosed)
}
if got := batchApplyColumn(t, ctx, fixture, "status", child); got != string(types.StatusOpen) {
t.Errorf("%s status = %q, want %q: Force bypasses the close policy and nothing else", child, got, types.StatusOpen)
t.Errorf("%s status = %q, want %q: Force waives the parent's close policy, it does not close the child", child, got, types.StatusOpen)
}
assertBatchApplyTypedEdgeCount(t, ctx, fixture, child, parent, string(publicops.DepParentChild), 1)
}
@ -1521,6 +1531,215 @@ func RunBatchApplyNormalizesTheWaitsForGate(t *testing.T, ctx context.Context, f
})
}
// RunBatchApplyStampsSpawnerIDOnlyWhenNamed is the S11 review fix-up
// regression for HIGH-2: a waits-for DepAddItem must only acquire
// metadata.spawner_id when the caller explicitly named a spawner
// (HasSpawner=true, which bd create --graph sets when the plan declares
// edges[].spawner_key/spawner_id, as does an embedder lowering such a plan
// onto this role). An edge with no named spawner must keep its gate-only
// metadata untouched — stamping it unconditionally from the resolved target
// caused unnecessary rewrite/version churn when gc re-applies the same edge
// (see CHANGELOG.md).
func RunBatchApplyStampsSpawnerIDOnlyWhenNamed(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
spawner := fixture.IssuePrefix + "-spawner-named"
waiter := fixture.IssuePrefix + "-waiter-named"
batchApplySeedIssue(t, ctx, fixture, spawner, types.StatusOpen)
batchApplySeedIssue(t, ctx, fixture, waiter, types.StatusOpen)
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
{Kind: publicops.ItemDepAdd, DepAdd: &publicops.DepAddItem{
Source: publicops.Ref{ID: waiter},
Target: publicops.Ref{ID: spawner},
Type: publicops.DepWaitsFor,
Metadata: `{"gate":"any-children"}`,
HasSpawner: true,
}},
},
})
stored := batchApplyEdgeMetadata(t, ctx, fixture, waiter, spawner)
var meta types.WaitsForMeta
if err := json.Unmarshal([]byte(stored), &meta); err != nil {
t.Fatalf("stored named-spawner metadata %q: %v", stored, err)
}
if meta.SpawnerID != spawner {
t.Errorf("named-spawner edge spawner_id = %q, want %q (metadata %q)", meta.SpawnerID, spawner, stored)
}
spawner2 := fixture.IssuePrefix + "-spawner-unnamed"
waiter2 := fixture.IssuePrefix + "-waiter-unnamed"
batchApplySeedIssue(t, ctx, fixture, spawner2, types.StatusOpen)
batchApplySeedIssue(t, ctx, fixture, waiter2, types.StatusOpen)
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
batchApplyDepAdd(publicops.Ref{ID: waiter2}, publicops.Ref{ID: spawner2}, publicops.DepWaitsFor, `{"gate":"any-children"}`),
},
})
stored2 := batchApplyEdgeMetadata(t, ctx, fixture, waiter2, spawner2)
var meta2 types.WaitsForMeta
if err := json.Unmarshal([]byte(stored2), &meta2); err != nil {
t.Fatalf("stored unnamed-spawner metadata %q: %v", stored2, err)
}
if meta2.SpawnerID != "" {
t.Errorf("unnamed-spawner edge must not stamp spawner_id, got %q (metadata %q)", meta2.SpawnerID, stored2)
}
}
// RunBatchApplyCarriesThreadIDOntoTheStoredEdge pins DepAddItem.ThreadID
// (the 2026-10 Opus-review HIGH-2 finding): a conversation-threading id named
// on a dep_add item must land on the stored dependency row's own thread_id
// column, and an item that names none must store none. ThreadID is a plain
// column read independently of HasSpawner/Metadata, so this is its own case
// rather than a clause folded onto the spawner one above.
//
// Wired onto the http leg this exercises BOTH halves of the wire at once: the
// client's applyDepAddItemBody encode (batchapplier.go) and the server's
// applyDepAddItemMembers decode (internal/httpapi/batch_apply.go) must each
// carry the field, because either one silently dropping it leaves the stored
// column blank and fails the assertion below.
func RunBatchApplyCarriesThreadIDOntoTheStoredEdge(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
source := fixture.IssuePrefix + "-thread-source"
target := fixture.IssuePrefix + "-thread-target"
batchApplySeedIssue(t, ctx, fixture, source, types.StatusOpen)
batchApplySeedIssue(t, ctx, fixture, target, types.StatusOpen)
const thread = "thread-conv-1"
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
{Kind: publicops.ItemDepAdd, DepAdd: &publicops.DepAddItem{
Source: publicops.Ref{ID: source}, Target: publicops.Ref{ID: target},
Type: publicops.DepBlocks, ThreadID: thread,
}},
},
})
if got := batchApplyEdgeThreadID(t, ctx, fixture, source, target); got != thread {
t.Errorf("stored edge thread_id = %q, want %q", got, thread)
}
source2 := fixture.IssuePrefix + "-thread-none-source"
target2 := fixture.IssuePrefix + "-thread-none-target"
batchApplySeedIssue(t, ctx, fixture, source2, types.StatusOpen)
batchApplySeedIssue(t, ctx, fixture, target2, types.StatusOpen)
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
batchApplyDepAdd(publicops.Ref{ID: source2}, publicops.Ref{ID: target2}, publicops.DepBlocks, ""),
},
})
if got := batchApplyEdgeThreadID(t, ctx, fixture, source2, target2); got != "" {
t.Errorf("an edge naming no thread must not stamp thread_id, got %q", got)
}
}
// RunBatchApplyCarriesThreadIDOntoAnExistingEdge pins DepAddItem.ThreadID on
// the re-add arm: a dep_add naming an edge that already exists with the same
// type is the idempotent re-add, and a thread it names still has to reach the
// stored row. That arm once compared and rewrote metadata alone, so a
// thread-only re-add was a silent no-op and a re-add moving both landed the
// metadata and dropped the thread — on the very path gc re-applies its plans
// through.
//
// The steps run on ONE edge, each from the state the step before it left: a
// thread-only re-add puts a thread on an edge that had none, a re-add moving
// the gate and the thread lands both, and a re-add naming no thread keeps the
// stored one, because an empty ThreadID names no thread rather than asking for
// none.
func RunBatchApplyCarriesThreadIDOntoAnExistingEdge(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
source := fixture.IssuePrefix + "-rethread-source"
spawner := fixture.IssuePrefix + "-rethread-spawner"
batchApplySeedIssue(t, ctx, fixture, source, types.StatusOpen)
batchApplySeedIssue(t, ctx, fixture, spawner, types.StatusOpen)
add := func(gate, thread string) {
t.Helper()
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
{Kind: publicops.ItemDepAdd, DepAdd: &publicops.DepAddItem{
Source: publicops.Ref{ID: source}, Target: publicops.Ref{ID: spawner},
Type: publicops.DepWaitsFor, Metadata: `{"gate":"` + gate + `"}`, ThreadID: thread,
}},
},
})
}
assertEdge := func(step, wantGate, wantThread string) {
t.Helper()
assertBatchApplyEdgeCount(t, ctx, fixture, source, spawner, 1)
stored := batchApplyEdgeMetadata(t, ctx, fixture, source, spawner)
var meta types.WaitsForMeta
if err := json.Unmarshal([]byte(stored), &meta); err != nil {
t.Fatalf("%s: stored waits-for metadata %q is not a gate object: %v", step, stored, err)
}
if meta.Gate != wantGate {
t.Errorf("%s: stored gate = %q (metadata %q), want %q", step, meta.Gate, stored, wantGate)
}
if got := batchApplyEdgeThreadID(t, ctx, fixture, source, spawner); got != wantThread {
t.Errorf("%s: stored edge thread_id = %q, want %q", step, got, wantThread)
}
}
add(types.WaitsForAllChildren, "")
assertEdge("the first add, naming no thread", types.WaitsForAllChildren, "")
add(types.WaitsForAllChildren, "thread-conv-1")
assertEdge("a re-add moving the thread alone", types.WaitsForAllChildren, "thread-conv-1")
add(types.WaitsForAnyChildren, "thread-conv-2")
assertEdge("a re-add moving the gate and the thread", types.WaitsForAnyChildren, "thread-conv-2")
add(types.WaitsForAnyChildren, "")
assertEdge("a re-add naming no thread", types.WaitsForAnyChildren, "thread-conv-2")
}
// RunBatchApplyRefusesAThreadIDLongerThanItsColumn pins the bound on
// DepAddItem.ThreadID: one longer than the thread_id column holds is
// ErrValidation and writes no edge, on every leg alike. The http leg's decode
// refused it as a typed 400 while the local legs carried it to the write, where
// it failed as whatever storage error the column raised, mid-transaction — two
// error classes for one request. The shared plan bounds it now, before any
// database work.
//
// The positive half is the same edge with a thread exactly at the bound, which
// lands whole; without it, a role refusing every thread id satisfies the
// refusal.
func RunBatchApplyRefusesAThreadIDLongerThanItsColumn(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
source := fixture.IssuePrefix + "-longthread-source"
target := fixture.IssuePrefix + "-longthread-target"
batchApplySeedIssue(t, ctx, fixture, source, types.StatusOpen)
batchApplySeedIssue(t, ctx, fixture, target, types.StatusOpen)
request := func(thread string) publicops.ApplyBatchRequest {
return publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
{Kind: publicops.ItemDepAdd, DepAdd: &publicops.DepAddItem{
Source: publicops.Ref{ID: source}, Target: publicops.Ref{ID: target},
Type: publicops.DepBlocks, ThreadID: thread,
}},
},
}
}
tooLong := strings.Repeat("t", types.MaxFieldLen+1)
if _, err := fixture.BatchApplier.ApplyBatch(ctx, request(tooLong)); !errors.Is(err, publicops.ErrValidation) {
t.Fatalf("a %d-character thread_id: error = %v, want ErrValidation", len(tooLong), err)
}
assertBatchApplyEdgeCount(t, ctx, fixture, source, target, 0)
atBound := strings.Repeat("t", types.MaxFieldLen)
batchApplyMust(t, ctx, fixture, request(atBound))
if got := batchApplyEdgeThreadID(t, ctx, fixture, source, target); got != atBound {
t.Errorf("a %d-character thread_id stored as %d characters, want it whole", len(atBound), len(got))
}
}
// RunBatchApplySplicesAForwardMetadataRef pins the one exception to the
// backward-only rule (CreateItem.MetadataRefs): "IT IS THE ONE PLACE A KEY MAY
// REACH FORWARD … Every id is minted before any splice is applied, so the
@ -2184,6 +2403,20 @@ func batchApplyEdgeMetadata(t *testing.T, ctx context.Context, fixture BatchAppl
return blob
}
// batchApplyEdgeThreadID reads the stored thread_id column of one edge, which
// is where DepAddItem.ThreadID has to be visible — a plain column, independent
// of the type-specific Metadata blob batchApplyEdgeMetadata reads.
func batchApplyEdgeThreadID(t *testing.T, ctx context.Context, fixture BatchApplyFixture, source, target string) string {
t.Helper()
var value string
const query = "SELECT COALESCE(thread_id, '') FROM dependencies WHERE issue_id = ?" +
" AND COALESCE(depends_on_issue_id, depends_on_wisp_id, depends_on_external) = ?"
if err := fixture.QueryScalar(ctx, query, []any{source, target}, &value); err != nil {
t.Fatalf("reading edge thread_id for %s -> %s: %v", source, target, err)
}
return value
}
// batchApplyMetadataKey reads the WHOLE metadata blob off a row and reports one
// key's raw bytes. The whole blob is read rather than a JSON path extract,
// because that is what lets a case see an absent key and a null one as the
@ -2268,3 +2501,287 @@ func batchApplyHistoryMatching(t *testing.T, ctx context.Context, fixture BatchA
}
return count
}
// RunBatchApplyUpdateItemsRefuseATemplate pins that an update item answers to
// Lifecycle.Update's template guard: an item targeting a template refuses with
// an *ItemError carrying *TemplateReadOnlyError, whatever force flags it
// carries, and the request is all or nothing, so the create ahead of it does
// not land and the template is untouched.
func RunBatchApplyUpdateItemsRefuseATemplate(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
template := fixture.IssuePrefix + "-tmplupd-template"
bystander := fixture.IssuePrefix + "-tmplupd-bystander"
seeded := batchApplyIssue(template, "a template")
seeded.IsTemplate = true
if err := fixture.CreateIssue(ctx, seeded, "seed"); err != nil {
t.Fatalf("seed %s: %v", template, err)
}
update := batchApplyUpdate(publicops.Ref{ID: template}, publicops.IssuePatch{
Title: publicops.Field[string]{Set: true, Value: "edited"},
Status: publicops.Field[publicops.Status]{Set: true, Value: types.StatusClosed},
})
update.Update.ForceClosePolicy = true
_, err := fixture.BatchApplier.ApplyBatch(ctx, publicops.ApplyBatchRequest{
Actor: "apply-writer",
ForceIDPrefix: true,
Items: []publicops.ApplyItem{
batchApplyCreate("bystander", batchApplyIssue(bystander, "must not land beside a refusal")),
update,
},
})
var itemErr *publicops.ItemError
if !errors.As(err, &itemErr) {
t.Fatalf("an update item on template %s: error = %v, want an *ItemError", template, err)
}
if itemErr.Kind != publicops.ItemUpdate || itemErr.Index != 1 {
t.Errorf("ItemError = %#v, want the update item at index 1", itemErr)
}
var refusal *publicops.TemplateReadOnlyError
if !errors.As(err, &refusal) || refusal.IssueID != template {
t.Errorf("update item on template = %v, want *TemplateReadOnlyError naming %s", err, template)
}
assertBatchApplyRowCount(t, ctx, fixture, "issues", bystander, 0)
if got := batchApplyColumn(t, ctx, fixture, "title", template); got != "a template" {
t.Errorf("%s title after the refusal = %q, want it untouched", template, got)
}
if got := batchApplyColumn(t, ctx, fixture, "status", template); got != string(types.StatusOpen) {
t.Errorf("%s status after the refusal = %q, want it untouched", template, got)
}
}
// RunBatchApplySplicesTheMetadataOfATemplateItCreates is the template guard's
// boundary: the one write a template legitimately takes inside a batch is a
// CREATE item that makes it and asks for a metadata splice. The splice runs as
// an update of the row the request itself is creating, after every id exists,
// and it must land — the template is being written, not modified — so a guard
// placed where the splice reaches it would refuse a template's own creation.
func RunBatchApplySplicesTheMetadataOfATemplateItCreates(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
created := fixture.IssuePrefix + "-tmplsplice-created"
fresh := batchApplyIssue(created, "a template this request creates")
fresh.IsTemplate = true
item := batchApplyCreate("created", fresh)
item.Create.MetadataRefs = map[string]publicops.Ref{"gc.self": {Key: "created"}}
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer", ForceIDPrefix: true, Items: []publicops.ApplyItem{item},
})
if _, ok := batchApplyMetadataKey(t, ctx, fixture, created, "gc.self"); !ok {
t.Errorf("%s carries no gc.self key: the splice that finishes a template's own create must land", created)
}
}
// RunBatchApplyCloseItemsAnswerToTheCloseGuards pins that a close item answers
// to the close guards Lifecycle.Close states, under CloseRequest's rules: a
// template refuses forced or not, a pin and another actor's bead refuse unless
// the item's Force is set. A refusal is the item's *ItemError carrying the
// guard's typed error, and the request is all or nothing, so the create item
// ahead of it does not land.
//
// The assignee case is AS-MODIFIED: the holder is set by an update item of the
// same request, so a guard that read the row before the request began — or not
// at all — closes it.
func RunBatchApplyCloseItemsAnswerToTheCloseGuards(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
template := fixture.IssuePrefix + "-closeguard-template"
pinned := fixture.IssuePrefix + "-closeguard-pinned"
held := fixture.IssuePrefix + "-closeguard-held"
bystander := fixture.IssuePrefix + "-closeguard-bystander"
for _, issue := range []*types.Issue{
{ID: template, IsTemplate: true},
{ID: pinned, Pinned: true},
{ID: held},
} {
issue.Title, issue.Status, issue.Priority, issue.IssueType = issue.ID, types.StatusOpen, 2, types.TypeTask
if err := fixture.CreateIssue(ctx, issue, "seed"); err != nil {
t.Fatalf("seed %s: %v", issue.ID, err)
}
}
plan := func(target string, force bool, extra ...publicops.ApplyItem) publicops.ApplyBatchRequest {
closeItem := batchApplyClose(publicops.Ref{ID: target})
closeItem.Close.Force = force
items := []publicops.ApplyItem{batchApplyCreate("bystander", batchApplyIssue(bystander, "must not land beside a refusal"))}
items = append(items, extra...)
return publicops.ApplyBatchRequest{Actor: "apply-closer", ForceIDPrefix: true, Items: append(items, closeItem)}
}
refused := func(label string, request publicops.ApplyBatchRequest, check func(error)) {
t.Helper()
_, err := fixture.BatchApplier.ApplyBatch(ctx, request)
var itemErr *publicops.ItemError
if !errors.As(err, &itemErr) {
t.Fatalf("%s: error = %v, want an *ItemError", label, err)
}
if itemErr.Kind != publicops.ItemClose || itemErr.Index != len(request.Items)-1 {
t.Errorf("%s: ItemError = %#v, want the close item at index %d", label, itemErr, len(request.Items)-1)
}
check(err)
assertBatchApplyRowCount(t, ctx, fixture, "issues", bystander, 0)
}
for _, force := range []bool{false, true} {
refused("template close item", plan(template, force), func(err error) {
var refusal *publicops.TemplateReadOnlyError
if !errors.As(err, &refusal) || refusal.IssueID != template {
t.Errorf("template close item (force=%v) = %v, want *TemplateReadOnlyError naming %s", force, err, template)
}
})
}
refused("pinned close item", plan(pinned, false), func(err error) {
var refusal *publicops.PinnedError
if !errors.As(err, &refusal) || refusal.IssueID != pinned {
t.Errorf("pinned close item = %v, want *PinnedError naming %s", err, pinned)
}
})
assign := batchApplyUpdate(publicops.Ref{ID: held}, publicops.IssuePatch{Assignee: publicops.Field[string]{Set: true, Value: "holder"}})
refused("held close item", plan(held, false, assign), func(err error) {
var refusal *publicops.CloseNotAssigneeError
if !errors.As(err, &refusal) {
t.Errorf("close item on a bead an earlier item assigned away = %v, want *CloseNotAssigneeError", err)
return
}
if refusal.IssueID != held || refusal.Assignee != "holder" || refusal.Actor != "apply-closer" {
t.Errorf("assignee refusal = %#v, want IssueID %q, Assignee holder, Actor apply-closer", refusal, held)
}
})
for _, id := range []string{template, pinned, held} {
if got := batchApplyColumn(t, ctx, fixture, "status", id); got != string(types.StatusOpen) {
t.Errorf("%s status after the refusals = %q, want it still open", id, got)
}
}
// The item's Force waives the pin and the assignee fence.
forcedPin := plan(pinned, true)
forcedPin.Items = forcedPin.Items[1:]
batchApplyMust(t, ctx, fixture, forcedPin)
forcedHeld := plan(held, true, assign)
forcedHeld.Items = forcedHeld.Items[1:]
batchApplyMust(t, ctx, fixture, forcedHeld)
for _, id := range []string{pinned, held} {
if got := batchApplyColumn(t, ctx, fixture, "status", id); got != string(types.StatusClosed) {
t.Errorf("%s status under the item's Force = %q, want %q", id, got, types.StatusClosed)
}
}
}
// RunBatchApplyRefusesADottedChildGatedOnItsOwnParent pins the dotted-id
// hierarchy rule (publicops.CheckDottedChildDependency) on a dep_add item: an
// edge from a dotted-id child to its own ancestor is refused with an
// *ItemError naming the edge, and the whole request rolls back. The rule is
// applied to the RESOLVED ids, so a key bound to a dotted child this request
// creates — the `bd create --graph` shape — is refused like a stored id.
//
// POSITIVE HALF: the parent-child edge to the immediate dotted parent lands.
//
// WITH THE HIERARCHY STORED: once that edge exists (the shape `bd create
// --parent` leaves), a blocking edge on the same pair is still this validation
// refusal, not the hierarchy conflict the stored edge would raise (which does
// not match ErrValidation) — the rule reads only the resolved ids, so it
// answers first — and the stored edge survives.
func RunBatchApplyRefusesADottedChildGatedOnItsOwnParent(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
parent := fixture.IssuePrefix + "-dotted"
child := parent + ".1"
minted := parent + ".2"
batchApplySeedIssue(t, ctx, fixture, parent, types.StatusOpen)
batchApplySeedIssue(t, ctx, fixture, child, types.StatusOpen)
for _, refused := range []struct {
name string
items []publicops.ApplyItem
index int
}{
{"a stored child blocking on its parent", []publicops.ApplyItem{
batchApplyDepAdd(publicops.Ref{ID: child}, publicops.Ref{ID: parent}, publicops.DepBlocks, ""),
}, 0},
{"a child this request creates blocking on its parent", []publicops.ApplyItem{
batchApplyCreate("child", batchApplyIssue(minted, "the new child")),
batchApplyDepAdd(publicops.Ref{Key: "child"}, publicops.Ref{ID: parent}, publicops.DepBlocks, ""),
}, 1},
} {
_, err := fixture.BatchApplier.ApplyBatch(ctx, publicops.ApplyBatchRequest{
Actor: "apply-writer",
ForceIDPrefix: true,
Items: refused.items,
})
if !errors.Is(err, publicops.ErrValidation) {
t.Errorf("%s: error = %v, want ErrValidation", refused.name, err)
continue
}
var itemErr *publicops.ItemError
if !errors.As(err, &itemErr) {
t.Errorf("%s: error = %v, want an *ItemError naming the edge item", refused.name, err)
continue
}
if itemErr.Index != refused.index || itemErr.Kind != publicops.ItemDepAdd {
t.Errorf("%s: ItemError = %#v, want Index %d and Kind %q", refused.name, itemErr, refused.index, publicops.ItemDepAdd)
}
}
assertBatchApplyEdgeCount(t, ctx, fixture, child, parent, 0)
assertBatchApplyRowCount(t, ctx, fixture, "issues", minted, 0)
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
batchApplyDepAdd(publicops.Ref{ID: child}, publicops.Ref{ID: parent}, publicops.DepParentChild, ""),
},
})
assertBatchApplyEdgeCount(t, ctx, fixture, child, parent, 1)
_, err := fixture.BatchApplier.ApplyBatch(ctx, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
batchApplyDepAdd(publicops.Ref{ID: child}, publicops.Ref{ID: parent}, publicops.DepBlocks, ""),
},
})
var itemErr *publicops.ItemError
if !errors.Is(err, publicops.ErrValidation) || !errors.As(err, &itemErr) {
t.Errorf("blocks on a parent whose parent-child edge is stored: error = %v, want an *ItemError matching ErrValidation", err)
}
assertBatchApplyEdgeCount(t, ctx, fixture, child, parent, 1)
}
// RunBatchApplyAppliesTheDefaultPriority pins CreateItem.DefaultPriority: a
// create item that asks for the default stores publicops.DefaultCreatePriority,
// and one naming priority 0 stores P0. `bd create --graph` sends a node without
// a priority this way, and so does an HTTP batch apply create item without one.
// A create item asking for the default while naming a priority is
// ErrValidation and writes nothing, as it is for Lifecycle.Create.
func RunBatchApplyAppliesTheDefaultPriority(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
unset := batchApplyMintedIssue("defaulted")
unset.Priority = 0
zero := batchApplyMintedIssue("critical")
zero.Priority = 0
result := batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
{Kind: publicops.ItemCreate, Create: &publicops.CreateItem{Key: "d", Issue: unset, DefaultPriority: true}},
{Kind: publicops.ItemCreate, Create: &publicops.CreateItem{Key: "z", Issue: zero}},
},
})
for key, want := range map[string]int{"d": publicops.DefaultCreatePriority, "z": 0} {
id := result.Keys[key]
if id == "" {
t.Fatalf("key %q bound no id: %v", key, result.Keys)
}
if got := batchApplyCount(t, ctx, fixture, "SELECT priority FROM issues WHERE id = ?", []any{id}); got != want {
t.Errorf("stored priority of %s (%s) = %d, want %d", key, id, got, want)
}
}
conflict := fixture.IssuePrefix + "-prio-conflict"
clash := batchApplyIssue(conflict, conflict)
clash.Priority = 3
_, err := fixture.BatchApplier.ApplyBatch(ctx, publicops.ApplyBatchRequest{
Actor: "apply-writer",
ForceIDPrefix: true,
Items: []publicops.ApplyItem{
{Kind: publicops.ItemCreate, Create: &publicops.CreateItem{Key: "c", Issue: clash, DefaultPriority: true}},
},
})
if !errors.Is(err, publicops.ErrValidation) {
t.Fatalf("DefaultPriority with priority 3: err = %v, want ErrValidation", err)
}
assertBatchApplyRowCount(t, ctx, fixture, "issues", conflict, 0)
}

View file

@ -0,0 +1,145 @@
package conformance
import (
"context"
"encoding/json"
"errors"
"slices"
"testing"
"time"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// The BatchApplier half of the gate-member clauses; see
// lifecycle_create_gate_contract.go.
// RunBatchApplyCarriesTheGateMembers pins the gate members through
// BatchApplier: a create item stores all four, an update item replaces the
// waiter list of an existing row whole, a clear through an update item stores
// the empty list `[]`, and a create or update item past a bound refuses the
// WHOLE request as ErrValidation naming its member (on its *ItemError for the
// update item), so the earlier item rolls back with it.
func RunBatchApplyCarriesTheGateMembers(t *testing.T, ctx context.Context, fixture BatchApplyFixture) {
t.Helper()
gate := fixture.IssuePrefix + "-bag-gate"
existing := fixture.IssuePrefix + "-bag-existing"
batchApplySeedIssue(t, ctx, fixture, existing, types.StatusOpen)
issue := batchApplyIssue(gate, "a gate made by a plan")
issue.IssueType = types.TypeGate
issue.AwaitType = "timer"
issue.AwaitID = "await-plan"
issue.Timeout = 2 * time.Hour
issue.Waiters = []string{"a", "a", "b"}
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
ForceIDPrefix: true,
Items: []publicops.ApplyItem{
batchApplyCreate("gate", issue),
batchApplyUpdate(publicops.Ref{ID: existing}, publicops.IssuePatch{
AwaitID: publicops.Field[string]{Set: true, Value: "bead:" + gate},
Waiters: publicops.Field[[]string]{Set: true, Value: []string{"x", "y"}},
}),
},
})
assertBatchApplyGateColumns(t, ctx, fixture, gate, "timer", "await-plan", 2*time.Hour, []string{"a", "a", "b"})
assertBatchApplyGateColumns(t, ctx, fixture, existing, "", "bead:"+gate, 0, []string{"x", "y"})
// A clear through an update item stores the empty JSON list, not NULL and
// not the JSON null: the column is read raw here because every reader
// above treats the three alike.
batchApplyMust(t, ctx, fixture, publicops.ApplyBatchRequest{
Actor: "apply-writer",
Items: []publicops.ApplyItem{
batchApplyUpdate(publicops.Ref{ID: existing}, publicops.IssuePatch{
AwaitID: publicops.Field[string]{Set: true},
Waiters: publicops.Field[[]string]{Set: true},
}),
},
})
assertBatchApplyGateColumns(t, ctx, fixture, existing, "", "", 0, nil)
var clearedWaiters string
if err := fixture.QueryScalar(ctx, "SELECT COALESCE(waiters, '<NULL>') FROM issues WHERE id = ?", []any{existing}, &clearedWaiters); err != nil {
t.Fatalf("read the waiters column of %s: %v", existing, err)
}
if clearedWaiters != "[]" {
t.Errorf("%s waiters column after a clear = %q, want the stored empty list %q", existing, clearedWaiters, "[]")
}
first := fixture.IssuePrefix + "-bag-rolledback"
refused := batchApplyIssue(fixture.IssuePrefix+"-bag-refused", "past the bound")
refused.AwaitType = gateFieldAtBoundAwaitType + "x"
_, err := fixture.BatchApplier.ApplyBatch(ctx, publicops.ApplyBatchRequest{
Actor: "apply-writer",
ForceIDPrefix: true,
Items: []publicops.ApplyItem{
batchApplyCreate("first", batchApplyIssue(first, "rolls back with the refusal")),
batchApplyCreate("refused", refused),
},
})
assertGateFieldError(t, err, "a create item with await_type past its bound", publicops.GateFieldAwaitType)
assertBatchApplyRowCount(t, ctx, fixture, "issues", first, 0)
// An update item past a bound refuses the same way, named on its own
// item: the earlier create rolls back, and the target keeps its columns.
firstOfUpdate := fixture.IssuePrefix + "-bag-rolledback-upd"
_, err = fixture.BatchApplier.ApplyBatch(ctx, publicops.ApplyBatchRequest{
Actor: "apply-writer",
ForceIDPrefix: true,
Items: []publicops.ApplyItem{
batchApplyCreate("first", batchApplyIssue(firstOfUpdate, "rolls back with the refusal")),
batchApplyUpdate(publicops.Ref{ID: gate}, publicops.IssuePatch{
Title: publicops.Field[string]{Set: true, Value: "must not land"},
AwaitID: publicops.Field[string]{Set: true, Value: gateFieldAtBoundAwaitID + "x"},
}),
},
})
assertGateFieldError(t, err, "an update item with await_id past its bound", publicops.GateFieldAwaitID)
var itemErr *publicops.ItemError
if !errors.As(err, &itemErr) {
t.Fatalf("an update item with await_id past its bound: error = %v, want an *ItemError naming the item", err)
}
if itemErr.Index != 1 || itemErr.Kind != publicops.ItemUpdate {
t.Errorf("ItemError = %#v, want Index 1 and Kind %q", itemErr, publicops.ItemUpdate)
}
assertBatchApplyRowCount(t, ctx, fixture, "issues", firstOfUpdate, 0)
assertBatchApplyGateColumns(t, ctx, fixture, gate, "timer", "await-plan", 2*time.Hour, []string{"a", "a", "b"})
if got := batchApplyColumn(t, ctx, fixture, "title", gate); got != "a gate made by a plan" {
t.Errorf("%s title = %q, want the created title: a refused item writes nothing", gate, got)
}
}
// assertBatchApplyGateColumns reads the four gate columns of one durable row
// raw, so neither side of the comparison comes from the role.
func assertBatchApplyGateColumns(t *testing.T, ctx context.Context, fixture BatchApplyFixture, id, awaitType, awaitID string, timeout time.Duration, waiters []string) {
t.Helper()
var gotType, gotID, gotWaiters string
var gotTimeout int64
if err := fixture.QueryScalar(ctx,
"SELECT COALESCE(await_type, ''), COALESCE(await_id, ''), COALESCE(timeout_ns, 0), COALESCE(waiters, '') FROM issues WHERE id = ?",
[]any{id}, &gotType, &gotID, &gotTimeout, &gotWaiters); err != nil {
t.Fatalf("read the gate columns of %s: %v", id, err)
}
if gotType != awaitType || gotID != awaitID || time.Duration(gotTimeout) != timeout {
t.Errorf("%s gate columns = (%q, %q, %s), want (%q, %q, %s)", id, gotType, gotID, time.Duration(gotTimeout), awaitType, awaitID, timeout)
}
if stored := parseGateWaiters(gotWaiters); !slices.Equal(stored, waiters) {
t.Errorf("%s waiters column = %q (%q), want %q", id, gotWaiters, stored, waiters)
}
}
// parseGateWaiters reads the waiters TEXT column's JSON array, treating the
// empty string, `null` and `[]` as the one empty list they all mean.
func parseGateWaiters(raw string) []string {
if raw == "" || raw == "null" || raw == "[]" {
return nil
}
var out []string
if err := json.Unmarshal([]byte(raw), &out); err != nil {
return []string{"<unparseable: " + err.Error() + ">"}
}
return out
}

View file

@ -39,9 +39,10 @@ import (
// still reports OpenChildren (batchcloser.go:81-86); a duplicated id is one
// of those at its own index, and the first occurrence's reason is what the
// row keeps (batchcloser.go:28-33).
// - Force is request-wide and bypasses only blocker and open-child policy;
// the per-item precondition its clause also names is a category the request
// type keeps EMPTY (batchcloser.go:43-53).
// - Force is request-wide and bypasses blocker and open-child policy, the
// pin and the assignee fence, never the template guard; the per-item
// precondition its clause also names is a category the request type keeps
// EMPTY (batchcloser.go:43-55).
// - ClaimNext runs after the closes, inside the same transaction, and only
// when at least one item closed (batchcloser.go:55-70, 100-103, 143-146).
// - LANDED means CHANGED: an all-idempotent batch earns no claim and records
@ -1397,3 +1398,96 @@ func requireBatchCloserWisps(t *testing.T, fixture BatchCloserFixture) {
t.Skipf("fixture has no CreateWisp: this backend cannot seed the ephemeral plane, so the ephemeral rules are UNPINNED here")
}
}
// RunBatchCloserItemsAnswerToTheCloseGuards pins that every item of a batch
// answers to the close guards Lifecycle.Close states — template, pin, assignee
// — as a PER-ITEM refusal carrying the same typed error, while the survivors
// still commit; and that the request-wide Force waives the pin and the
// assignee fence and never the template.
//
// The guarded items sit between two plain ones, so an implementation that
// aborted the batch on a guard, or skipped the guard for items after the
// first, fails here rather than in `bd close a b c`.
func RunBatchCloserItemsAnswerToTheCloseGuards(t *testing.T, ctx context.Context, fixture BatchCloserFixture) {
t.Helper()
first := fixture.IssuePrefix + "-guard-first"
template := fixture.IssuePrefix + "-guard-template"
pinned := fixture.IssuePrefix + "-guard-pinned"
held := fixture.IssuePrefix + "-guard-held"
last := fixture.IssuePrefix + "-guard-last"
seedBatchCloserIssue(t, ctx, fixture, first)
seedBatchCloserIssue(t, ctx, fixture, last)
for _, issue := range []*types.Issue{
{ID: template, IsTemplate: true},
{ID: pinned, Status: types.StatusPinned},
{ID: held, Assignee: "holder"},
} {
issue.Title, issue.Priority, issue.IssueType = issue.ID, 2, types.TypeTask
if issue.Status == "" {
issue.Status = types.StatusOpen
}
if err := fixture.CreateIssue(ctx, issue, "seed"); err != nil {
t.Fatalf("seed %s: %v", issue.ID, err)
}
}
result, err := fixture.Closer.CloseBatch(ctx, publicops.CloseBatchRequest{
Actor: "closer",
Items: []publicops.BatchCloseItem{{IssueID: first}, {IssueID: template}, {IssueID: pinned}, {IssueID: held}, {IssueID: last}},
})
if err != nil {
t.Fatalf("CloseBatch over guarded items: %v, want per-item refusals", err)
}
if len(result.Outcomes) != 5 {
t.Fatalf("outcomes = %d, want 5", len(result.Outcomes))
}
for _, i := range []int{0, 4} {
if result.Outcomes[i].Err != nil || !result.Outcomes[i].Changed {
t.Errorf("outcome %d (%s) = %+v, want the plain item to land", i, result.Outcomes[i].IssueID, result.Outcomes[i])
}
}
var templateRefusal *publicops.TemplateReadOnlyError
if !errors.As(result.Outcomes[1].Err, &templateRefusal) || templateRefusal.IssueID != template {
t.Errorf("template item = %v, want *TemplateReadOnlyError naming %s", result.Outcomes[1].Err, template)
}
var pinRefusal *publicops.PinnedError
if !errors.As(result.Outcomes[2].Err, &pinRefusal) || pinRefusal.IssueID != pinned {
t.Errorf("pinned item = %v, want *PinnedError naming %s", result.Outcomes[2].Err, pinned)
}
var assigneeRefusal *publicops.CloseNotAssigneeError
if !errors.As(result.Outcomes[3].Err, &assigneeRefusal) {
t.Errorf("held item = %v, want *CloseNotAssigneeError", result.Outcomes[3].Err)
} else if assigneeRefusal.IssueID != held || assigneeRefusal.Assignee != "holder" || assigneeRefusal.Actor != "closer" {
t.Errorf("held item refusal = %#v, want IssueID %q, Assignee holder, Actor closer", assigneeRefusal, held)
}
for _, i := range []int{1, 2, 3} {
if result.Outcomes[i].Issue != nil {
t.Errorf("refused outcome %d carries an Issue snapshot, want nil beside Err", i)
}
}
assertBatchCloserStatus(t, ctx, fixture, first, types.StatusClosed)
assertBatchCloserStatus(t, ctx, fixture, last, types.StatusClosed)
assertBatchCloserStatus(t, ctx, fixture, template, types.StatusOpen)
assertBatchCloserStatus(t, ctx, fixture, pinned, types.StatusPinned)
assertBatchCloserStatus(t, ctx, fixture, held, types.StatusOpen)
forced, err := fixture.Closer.CloseBatch(ctx, publicops.CloseBatchRequest{
Actor: "closer",
Items: []publicops.BatchCloseItem{{IssueID: template}, {IssueID: pinned}, {IssueID: held}},
Force: true,
})
if err != nil {
t.Fatalf("forced CloseBatch over guarded items: %v", err)
}
if !errors.Is(forced.Outcomes[0].Err, publicops.ErrTemplateReadOnly) {
t.Errorf("forced template item = %v, want ErrTemplateReadOnly: force never waives read-only", forced.Outcomes[0].Err)
}
for _, i := range []int{1, 2} {
if forced.Outcomes[i].Err != nil || !forced.Outcomes[i].Changed {
t.Errorf("forced outcome %d (%s) = %+v, want force to bypass the guard", i, forced.Outcomes[i].IssueID, forced.Outcomes[i])
}
}
assertBatchCloserStatus(t, ctx, fixture, template, types.StatusOpen)
assertBatchCloserStatus(t, ctx, fixture, pinned, types.StatusClosed)
assertBatchCloserStatus(t, ctx, fixture, held, types.StatusClosed)
}

View file

@ -97,6 +97,14 @@ func RunBatchCreatorCreatesEveryItemAsOneAct(t *testing.T, ctx context.Context,
}
seen[issue.ID] = true
assertBatchCreatorRowCount(t, ctx, fixture, "issues", issue.ID, 1)
// No item names a creator, so each defaults to the batch's actor.
var createdBy string
if err := fixture.QueryScalar(ctx, "SELECT COALESCE(created_by, '') FROM issues WHERE id = ?", []any{issue.ID}, &createdBy); err != nil {
t.Fatalf("read created_by for %s: %v", issue.ID, err)
}
if createdBy != request.Actor || issue.CreatedBy != request.Actor {
t.Errorf("item %d created_by = %q (result %q), want the request's actor %q", i, createdBy, issue.CreatedBy, request.Actor)
}
}
if labels := result.Issues[0].Labels; len(labels) != 1 || labels[0] != "alpha" {
t.Errorf("result issue 0 labels = %v, want [alpha]: the snapshot is promised hydrated with labels", labels)
@ -689,3 +697,63 @@ func batchCreatorHistoryCount(t *testing.T, ctx context.Context, fixture BatchCr
}
return entries
}
// RunBatchCreatorAppliesTheDefaultPriority pins BatchCreateItem.DefaultPriority:
// an item that asks for the default stores publicops.DefaultCreatePriority, and
// an item naming priority 0 stores P0 in the same batch. The default is
// Lifecycle.Create's, applied in the shared preparation, so an HTTP
// batchCreate without `priority` and a `bd create --file` template without one
// land the same row. An item asking for the default while naming a priority is
// ErrValidation and writes nothing, as it is for Lifecycle.Create.
func RunBatchCreatorAppliesTheDefaultPriority(t *testing.T, ctx context.Context, fixture BatchCreatorFixture) {
t.Helper()
// Minted ids and an unset status, so the case asks nothing of the items
// but their priority — the http wire's batch item has no id or status slot.
unset := &types.Issue{Title: fixture.IssuePrefix + " defaulted", IssueType: types.TypeTask}
zero := &types.Issue{Title: fixture.IssuePrefix + " critical", IssueType: types.TypeTask}
result, err := fixture.BatchCreator.CreateBatch(ctx, publicops.CreateBatchRequest{
Actor: "batch-writer",
Items: []publicops.BatchCreateItem{
{Issue: unset, DefaultPriority: true},
{Issue: zero},
},
})
if err != nil {
t.Fatalf("CreateBatch: %v", err)
}
if len(result.Issues) != 2 || result.Issues[0] == nil || result.Issues[1] == nil {
t.Fatalf("result = %v, want two created issues", result.Issues)
}
for i, want := range []int{publicops.DefaultCreatePriority, 0} {
created := result.Issues[i]
if created.Priority != want {
t.Errorf("item %d result priority = %d, want %d", i, created.Priority, want)
}
var got int
if err := fixture.QueryScalar(ctx, "SELECT priority FROM issues WHERE id = ?", []any{created.ID}, &got); err != nil {
t.Fatalf("read priority of %s: %v", created.ID, err)
}
if got != want {
t.Errorf("item %d stored priority = %d, want %d", i, got, want)
}
}
conflict := fixture.IssuePrefix + " conflicting"
_, err = fixture.BatchCreator.CreateBatch(ctx, publicops.CreateBatchRequest{
Actor: "batch-writer",
Items: []publicops.BatchCreateItem{
{Issue: &types.Issue{Title: conflict, Priority: 3, IssueType: types.TypeTask}, DefaultPriority: true},
},
})
if !errors.Is(err, storage.ErrValidation) {
t.Fatalf("DefaultPriority with priority 3: err = %v, want ErrValidation", err)
}
var stored int
if err := fixture.QueryScalar(ctx, "SELECT COUNT(*) FROM issues WHERE title = ?", []any{conflict}, &stored); err != nil {
t.Fatalf("count issues titled %q: %v", conflict, err)
}
if stored != 0 {
t.Errorf("issues titled %q after the conflicting priority batch = %d, want 0", conflict, stored)
}
}

View file

@ -36,6 +36,13 @@ type BatchGetterFixture struct {
BatchGetter publicops.BatchGetter
// CreateIssue seeds a durable issue in the issues plane.
CreateIssue func(context.Context, *types.Issue, string) error
// CreateIssues seeds many durable issues in one call. Optional: only
// RunBatchGetterAcceptsExactlyTheCap uses it, to seed its MaxGetManyIDs
// issues in one write instead of MaxGetManyIDs single-row commits (about
// 200s of the embedded suites' race runs); nil falls back to CreateIssue
// per row. The seeded rows are the same either way, and the case asserts
// only on the GetMany read.
CreateIssues func(context.Context, []*types.Issue, string) error
// CreateWisp seeds an ephemeral issue in the wisps plane. It is a separate
// field rather than an Ephemeral flag on CreateIssue because the three
// adapters reach the two planes through different verbs.
@ -205,7 +212,7 @@ func RunBatchGetterAcceptsExactlyTheCap(t *testing.T, ctx context.Context, fixtu
for i := range ids {
ids[i] = fmt.Sprintf("%s-atcap-%d", fixture.IssuePrefix, i)
}
seedBatchGetterIssues(t, ctx, fixture, ids...)
seedBatchGetterIssuesInBulk(t, ctx, fixture, ids...)
result := getMany(t, ctx, fixture, publicops.GetManyRequest{IDs: ids})
if len(result.Issues) != publicops.MaxGetManyIDs {
@ -363,6 +370,23 @@ func seedBatchGetterIssues(t *testing.T, ctx context.Context, fixture BatchGette
}
}
// seedBatchGetterIssuesInBulk seeds the same rows as seedBatchGetterIssues,
// through the fixture's CreateIssues hook when it has one.
func seedBatchGetterIssuesInBulk(t *testing.T, ctx context.Context, fixture BatchGetterFixture, ids ...string) {
t.Helper()
if fixture.CreateIssues == nil {
seedBatchGetterIssues(t, ctx, fixture, ids...)
return
}
issues := make([]*types.Issue, len(ids))
for i, id := range ids {
issues[i] = batchGetterSeed(id, false)
}
if err := fixture.CreateIssues(ctx, issues, "batch-getter-seed"); err != nil {
t.Fatalf("seed %d issues: %v", len(issues), err)
}
}
func seedBatchGetterWisp(t *testing.T, ctx context.Context, fixture BatchGetterFixture, id string) {
t.Helper()
if err := fixture.CreateWisp(ctx, batchGetterSeed(id, true), "batch-getter-seed"); err != nil {

View file

@ -0,0 +1,426 @@
package conformance
import (
"context"
"fmt"
"reflect"
"slices"
"testing"
"time"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// This file holds the semantic contract every implementation of
// publicops.BlockedLister must satisfy: what issueops/blockedlister.go
// promises, asserted on every leg (dolt, embedded dolt, unit of work, and the
// served HTTP client) so `bd blocked` answers one listing whichever route it
// takes.
//
// EVERY CASE IS SCOPED BY A LABEL: the blocked set is a property of the whole
// database, not of an id prefix, so a row seeded by one case is inside the
// next one's answer unless each asks through Labels.
// BlockedListerFixture supplies adapter-specific storage access for the
// blocked-listing assertions.
type BlockedListerFixture struct {
// IssuePrefix namespaces the ids each case seeds, so several cases can
// share one database.
IssuePrefix string
// BlockedLister is the surface under test.
BlockedLister publicops.BlockedLister
// CreateIssue seeds a durable issue in the issues plane.
CreateIssue func(context.Context, *types.Issue, string) error
// CreateWisp seeds an ephemeral issue in the wisps plane.
CreateWisp func(context.Context, *types.Issue, string) error
// AddDependency seeds ONE edge, recomputing the stored blocked flag the
// way every dependency write does.
AddDependency func(context.Context, *types.Dependency, string) error
// MarkBlocked sets the stored is_blocked flag on one durable issue
// directly, without the edge that would justify it: the stale flag `bd
// recompute-blocked` exists to repair. It must fail unless exactly one row
// changed. A nil hook means this leg cannot write the column, and the case
// that needs it skips with that reason.
MarkBlocked func(context.Context, string) error
}
// RunBlockedLister runs every blocked-listing case as a subtest of t.
func RunBlockedLister(t *testing.T, ctx context.Context, fixture BlockedListerFixture) {
t.Helper()
t.Run("NamesADirectBlocker", func(t *testing.T) { runBlockedNamesADirectBlocker(t, ctx, fixture) })
t.Run("AttributesAChildToItsBlockedParent", func(t *testing.T) { runBlockedAttributesAChildToItsParent(t, ctx, fixture) })
t.Run("ClosedBlockerDoesNotBlock", func(t *testing.T) { runBlockedClosedBlockerDoesNotBlock(t, ctx, fixture) })
t.Run("IncludesTheWispPlane", func(t *testing.T) { runBlockedIncludesTheWispPlane(t, ctx, fixture) })
t.Run("ExcludesThePinnedStatus", func(t *testing.T) { runBlockedExcludesThePinnedStatus(t, ctx, fixture) })
t.Run("ParentFilter", func(t *testing.T) { runBlockedParentFilter(t, ctx, fixture) })
t.Run("LabelFilters", func(t *testing.T) { runBlockedLabelFilters(t, ctx, fixture) })
t.Run("Order", func(t *testing.T) { runBlockedOrder(t, ctx, fixture) })
t.Run("NamesWaitsForAndConditionalBlockers", func(t *testing.T) { runBlockedNamesWaitsForAndConditionalBlockers(t, ctx, fixture) })
t.Run("OmitsAStaleFlagWithNoNameableBlocker", func(t *testing.T) { runBlockedOmitsAStaleFlag(t, ctx, fixture) })
t.Run("HasNoTypeExclusions", func(t *testing.T) { runBlockedHasNoTypeExclusions(t, ctx, fixture) })
t.Run("EmptyIsAnEmptySlice", func(t *testing.T) { runBlockedEmptyIsAnEmptySlice(t, ctx, fixture) })
t.Run("DoesNotMutateTheCallerRequest", func(t *testing.T) { runBlockedDoesNotMutateTheRequest(t, ctx, fixture) })
}
// runBlockedNamesADirectBlocker: an issue with an open `blocks` target is
// listed with that target as its one blocker; the target itself is not.
func runBlockedNamesADirectBlocker(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-direct"
blocked, blocker := blListerID(f, "direct-src"), blListerID(f, "direct-dst")
blListerSeedIssue(t, ctx, f, blListerIssue(blocked, 1, label))
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, label))
blListerSeedEdge(t, ctx, f, blocked, blocker, types.DepBlocks)
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{blocked: {blocker}})
}
// runBlockedAttributesAChildToItsParent: a child of a blocked parent, with no
// blocker of its own, is listed with its parent named as the blocker.
func runBlockedAttributesAChildToItsParent(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-child"
parent, child, blocker := blListerID(f, "child-parent"), blListerID(f, "child-child"), blListerID(f, "child-blocker")
blListerSeedIssue(t, ctx, f, blListerIssue(parent, 1, label))
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, label+"-other"))
blListerSeedIssue(t, ctx, f, blListerIssue(child, 1, label))
blListerSeedEdge(t, ctx, f, child, parent, types.DepParentChild)
blListerSeedEdge(t, ctx, f, parent, blocker, types.DepBlocks)
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{parent: {blocker}, child: {parent}})
}
// runBlockedClosedBlockerDoesNotBlock: a `blocks` edge onto a closed target
// names no blocker, so the source is not listed.
func runBlockedClosedBlockerDoesNotBlock(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-closed"
src, dst := blListerID(f, "closed-src"), blListerID(f, "closed-dst")
blListerSeedIssue(t, ctx, f, blListerIssue(src, 1, label))
closed := blListerIssue(dst, 1, label)
closed.Status = types.StatusClosed
blListerSeedIssue(t, ctx, f, closed)
blListerSeedEdge(t, ctx, f, src, dst, types.DepBlocks)
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{})
}
// runBlockedIncludesTheWispPlane: a blocked wisp is listed beside the issues.
func runBlockedIncludesTheWispPlane(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-wisp"
wisp, blocker := blListerID(f, "wisp-src"), blListerID(f, "wisp-dst")
w := blListerIssue(wisp, 1, label)
w.Ephemeral = true
if err := f.CreateWisp(ctx, w, "seed"); err != nil {
t.Fatalf("seed wisp %s: %v", wisp, err)
}
b := blListerIssue(blocker, 1, label)
b.Ephemeral = true
if err := f.CreateWisp(ctx, b, "seed"); err != nil {
t.Fatalf("seed wisp %s: %v", blocker, err)
}
blListerSeedEdge(t, ctx, f, wisp, blocker, types.DepBlocks)
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{wisp: {blocker}})
}
// runBlockedExcludesThePinnedStatus: a row whose status is pinned is never
// listed, whatever blocks it.
func runBlockedExcludesThePinnedStatus(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-pinned"
pinned, open, blocker := blListerID(f, "pinned-src"), blListerID(f, "pinned-open"), blListerID(f, "pinned-dst")
p := blListerIssue(pinned, 1, label)
p.Status = types.StatusPinned
blListerSeedIssue(t, ctx, f, p)
blListerSeedIssue(t, ctx, f, blListerIssue(open, 1, label))
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, label+"-other"))
blListerSeedEdge(t, ctx, f, pinned, blocker, types.DepBlocks)
blListerSeedEdge(t, ctx, f, open, blocker, types.DepBlocks)
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{open: {blocker}})
}
// runBlockedParentFilter: ParentID narrows to the parent's direct children.
func runBlockedParentFilter(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-parent"
parent, kid, stranger, blocker := blListerID(f, "pf-parent"), blListerID(f, "pf-kid"), blListerID(f, "pf-stranger"), blListerID(f, "pf-blocker")
blListerSeedIssue(t, ctx, f, blListerIssue(parent, 1, label+"-other"))
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, label+"-other"))
blListerSeedIssue(t, ctx, f, blListerIssue(kid, 1, label))
blListerSeedIssue(t, ctx, f, blListerIssue(stranger, 1, label))
blListerSeedEdge(t, ctx, f, kid, parent, types.DepParentChild)
blListerSeedEdge(t, ctx, f, kid, blocker, types.DepBlocks)
blListerSeedEdge(t, ctx, f, stranger, blocker, types.DepBlocks)
all := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, all, map[string][]string{kid: {blocker}, stranger: {blocker}})
narrowed := blListerList(t, ctx, f, publicops.BlockedRequest{ParentID: parent, Labels: []string{label}})
blListerAssertRows(t, narrowed, map[string][]string{kid: {blocker}})
}
// runBlockedLabelFilters: Labels is AND, LabelsAny is OR, ExcludeLabels
// removes, and every value is trimmed with blanks dropped.
func runBlockedLabelFilters(t *testing.T, ctx context.Context, f BlockedListerFixture) {
base := f.IssuePrefix + "-bl-lab"
red, blue := base+"-red", base+"-blue"
both, onlyRed, onlyBlue, blocker := blListerID(f, "lab-both"), blListerID(f, "lab-red"), blListerID(f, "lab-blue"), blListerID(f, "lab-blocker")
blListerSeedIssue(t, ctx, f, blListerIssue(both, 1, base, red, blue))
blListerSeedIssue(t, ctx, f, blListerIssue(onlyRed, 1, base, red))
blListerSeedIssue(t, ctx, f, blListerIssue(onlyBlue, 1, base, blue))
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, base+"-other"))
for _, id := range []string{both, onlyRed, onlyBlue} {
blListerSeedEdge(t, ctx, f, id, blocker, types.DepBlocks)
}
want := func(ids ...string) map[string][]string {
m := map[string][]string{}
for _, id := range ids {
m[id] = []string{blocker}
}
return m
}
blListerAssertRows(t, blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{" " + red + " ", "", blue}}), want(both))
blListerAssertRows(t, blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{base}, LabelsAny: []string{red, blue}}), want(both, onlyRed, onlyBlue))
blListerAssertRows(t, blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{base}, ExcludeLabels: []string{" " + blue}}), want(onlyRed))
}
// runBlockedOrder: priority ascending, then created_at descending, then id.
//
// The created_at values are seeded explicitly, so every key decides at least
// one pair: two rows share a priority and differ in created_at (newest first),
// and five share both priority and created_at (the id breaks the tie). The
// expected order is written out rather than recomputed from the answer.
func runBlockedOrder(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-order"
blocker := blListerID(f, "order-blocker")
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, label+"-other"))
older := time.Date(2026, 1, 1, 10, 0, 0, 0, time.UTC)
newer := older.Add(time.Hour)
// Two of the five tied rows are wisps. The store body assembles rows
// issues-plane first, each plane in id order, so the ids alone would put
// the tied run in the wrong order (b, d, e, then a, c); only the id
// tiebreak puts it right.
rows := []struct {
name string
priority int
created time.Time
wisp bool
}{
{"order-p3", 3, newer, false},
{"order-p0-older", 0, older, false},
{"order-p0-newer-e", 0, newer, false},
{"order-p0-newer-c", 0, newer, true},
{"order-p0-newer-a", 0, newer, true},
{"order-p0-newer-d", 0, newer, false},
{"order-p0-newer-b", 0, newer, false},
{"order-p1", 1, older, false},
}
for _, row := range rows {
issue := blListerIssue(blListerID(f, row.name), row.priority, label)
issue.CreatedAt = row.created
issue.UpdatedAt = row.created
if row.wisp {
issue.Ephemeral = true
if err := f.CreateWisp(ctx, issue, "seed"); err != nil {
t.Fatalf("seed wisp %s: %v", issue.ID, err)
}
} else {
blListerSeedIssue(t, ctx, f, issue)
}
blListerSeedEdge(t, ctx, f, issue.ID, blocker, types.DepBlocks)
}
want := []string{
blListerID(f, "order-p0-newer-a"),
blListerID(f, "order-p0-newer-b"),
blListerID(f, "order-p0-newer-c"),
blListerID(f, "order-p0-newer-d"),
blListerID(f, "order-p0-newer-e"),
blListerID(f, "order-p0-older"),
blListerID(f, "order-p1"),
blListerID(f, "order-p3"),
}
got := blListerIDs(blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}}))
if !slices.Equal(got, want) {
t.Errorf("listing order = %v, want %v (priority ascending, created_at descending, id)", got, want)
}
}
// runBlockedNamesWaitsForAndConditionalBlockers: a waits-for onto a spawner
// whose child is still open, and a conditional-blocks onto an open target,
// each name their target, as a blocks edge does.
func runBlockedNamesWaitsForAndConditionalBlockers(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-wf"
spawner, spawned := blListerID(f, "wf-spawner"), blListerID(f, "wf-spawned")
waiter := blListerID(f, "wf-waiter")
target, conditional := blListerID(f, "cb-target"), blListerID(f, "cb-src")
blListerSeedIssue(t, ctx, f, blListerIssue(spawner, 1, label+"-other"))
blListerSeedIssue(t, ctx, f, blListerIssue(spawned, 1, label+"-other"))
blListerSeedIssue(t, ctx, f, blListerIssue(target, 1, label+"-other"))
blListerSeedIssue(t, ctx, f, blListerIssue(waiter, 1, label))
blListerSeedIssue(t, ctx, f, blListerIssue(conditional, 1, label))
blListerSeedEdge(t, ctx, f, spawned, spawner, types.DepParentChild)
blListerSeedEdge(t, ctx, f, waiter, spawner, types.DepWaitsFor)
blListerSeedEdge(t, ctx, f, conditional, target, types.DepConditionalBlocks)
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{waiter: {spawner}, conditional: {target}})
}
// runBlockedOmitsAStaleFlag: a row whose stored flag says blocked but which
// has no active blocker and no parent names no blocker, so it is not listed.
// This is the narrowing gc's readiness projection documents relying on.
func runBlockedOmitsAStaleFlag(t *testing.T, ctx context.Context, f BlockedListerFixture) {
if f.MarkBlocked == nil {
t.Skip("this leg cannot write the stored is_blocked flag directly")
}
label := f.IssuePrefix + "-bl-stale"
stale, real, blocker := blListerID(f, "stale-src"), blListerID(f, "stale-real"), blListerID(f, "stale-blocker")
blListerSeedIssue(t, ctx, f, blListerIssue(stale, 1, label))
blListerSeedIssue(t, ctx, f, blListerIssue(real, 1, label))
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, label+"-other"))
blListerSeedEdge(t, ctx, f, real, blocker, types.DepBlocks)
if err := f.MarkBlocked(ctx, stale); err != nil {
t.Fatalf("mark %s blocked: %v", stale, err)
}
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{real: {blocker}})
}
// runBlockedHasNoTypeExclusions: a gate is listed like any other row; the
// blocked door excludes no issue type (unlike the ready front).
func runBlockedHasNoTypeExclusions(t *testing.T, ctx context.Context, f BlockedListerFixture) {
label := f.IssuePrefix + "-bl-type"
gate, epic, blocker := blListerID(f, "type-gate"), blListerID(f, "type-epic"), blListerID(f, "type-blocker")
g := blListerIssue(gate, 1, label)
g.IssueType = types.TypeGate
g.AwaitType = "human"
blListerSeedIssue(t, ctx, f, g)
e := blListerIssue(epic, 1, label)
e.IssueType = types.TypeEpic
blListerSeedIssue(t, ctx, f, e)
blListerSeedIssue(t, ctx, f, blListerIssue(blocker, 1, label+"-other"))
blListerSeedEdge(t, ctx, f, gate, blocker, types.DepBlocks)
blListerSeedEdge(t, ctx, f, epic, blocker, types.DepBlocks)
items := blListerList(t, ctx, f, publicops.BlockedRequest{Labels: []string{label}})
blListerAssertRows(t, items, map[string][]string{gate: {blocker}, epic: {blocker}})
}
// runBlockedEmptyIsAnEmptySlice: nothing blocked is an empty, non-nil slice
// and a nil error.
func runBlockedEmptyIsAnEmptySlice(t *testing.T, ctx context.Context, f BlockedListerFixture) {
result, err := f.BlockedLister.ListBlocked(ctx, publicops.BlockedRequest{Labels: []string{f.IssuePrefix + "-bl-nothing"}})
if err != nil {
t.Fatalf("ListBlocked: %v", err)
}
if result.Items == nil || len(result.Items) != 0 {
t.Fatalf("Items = %#v, want an empty non-nil slice", result.Items)
}
}
// runBlockedDoesNotMutateTheRequest: the caller's label slices come back as
// they were sent, normalization notwithstanding.
func runBlockedDoesNotMutateTheRequest(t *testing.T, ctx context.Context, f BlockedListerFixture) {
req := publicops.BlockedRequest{
ParentID: " ",
Labels: []string{" a ", "", "a"},
LabelsAny: []string{" b"},
ExcludeLabels: []string{"c "},
}
before := publicops.BlockedRequest{
ParentID: req.ParentID,
Labels: slices.Clone(req.Labels),
LabelsAny: slices.Clone(req.LabelsAny),
ExcludeLabels: slices.Clone(req.ExcludeLabels),
}
if _, err := f.BlockedLister.ListBlocked(ctx, req); err != nil {
t.Fatalf("ListBlocked: %v", err)
}
if !reflect.DeepEqual(req, before) {
t.Errorf("request after = %#v, before = %#v", req, before)
}
}
func blListerID(f BlockedListerFixture, name string) string {
return fmt.Sprintf("%s-%s", f.IssuePrefix, name)
}
func blListerIssue(id string, priority int, labels ...string) *types.Issue {
return &types.Issue{
ID: id,
Title: id,
Status: types.StatusOpen,
Priority: priority,
IssueType: types.TypeTask,
Labels: labels,
}
}
func blListerSeedIssue(t *testing.T, ctx context.Context, f BlockedListerFixture, issue *types.Issue) {
t.Helper()
if err := f.CreateIssue(ctx, issue, "seed"); err != nil {
t.Fatalf("seed issue %s: %v", issue.ID, err)
}
}
func blListerSeedEdge(t *testing.T, ctx context.Context, f BlockedListerFixture, from, to string, kind types.DependencyType) {
t.Helper()
if err := f.AddDependency(ctx, &types.Dependency{IssueID: from, DependsOnID: to, Type: kind}, "seed"); err != nil {
t.Fatalf("seed %s edge %s -> %s: %v", kind, from, to, err)
}
}
func blListerList(t *testing.T, ctx context.Context, f BlockedListerFixture, req publicops.BlockedRequest) []*types.BlockedIssue {
t.Helper()
result, err := f.BlockedLister.ListBlocked(ctx, req)
if err != nil {
t.Fatalf("ListBlocked(%+v): %v", req, err)
}
if result.Items == nil {
t.Fatalf("ListBlocked(%+v) Items is nil; the role promises a non-nil slice", req)
}
return result.Items
}
func blListerIDs(items []*types.BlockedIssue) []string {
ids := make([]string, 0, len(items))
for _, item := range items {
ids = append(ids, item.ID)
}
return ids
}
// assertBlockedRows requires the listing to be exactly want: the same ids,
// each naming exactly the blockers want gives it (in any order), with
// BlockedByCount equal to their number.
func blListerAssertRows(t *testing.T, items []*types.BlockedIssue, want map[string][]string) {
t.Helper()
got := map[string][]string{}
for _, item := range items {
if item == nil {
t.Fatalf("listing carries a nil row")
}
if _, dup := got[item.ID]; dup {
t.Errorf("row %s listed twice", item.ID)
}
blockers := slices.Clone(item.BlockedBy)
slices.Sort(blockers)
got[item.ID] = blockers
if item.BlockedByCount != len(item.BlockedBy) {
t.Errorf("row %s: BlockedByCount = %d, len(BlockedBy) = %d", item.ID, item.BlockedByCount, len(item.BlockedBy))
}
}
normalized := map[string][]string{}
for id, blockers := range want {
b := slices.Clone(blockers)
slices.Sort(b)
normalized[id] = b
}
if !reflect.DeepEqual(got, normalized) {
t.Errorf("listing = %v, want %v", got, normalized)
}
}

View file

@ -546,3 +546,65 @@ func assertParent(t *testing.T, result publicops.BlockingResult, id, want string
t.Errorf("entry %s parent = %q, want %q", id, got, want)
}
}
// RunBlockingAnnotatorReportsTheTransitiveBlockedFlag pins
// BlockingRequest.IncludeIsBlocked and IssueBlocking.IsBlocked: asked, each id
// with a row carries its STORED TRANSITIVE is_blocked flag — a child of a
// blocked parent is blocked with no blocking edge of its own, which BlockedBy
// alone would read as free — and an id naming no row carries none. Unasked,
// no item carries a flag. This is the read issueops.BlockedFlags (storage's
// IsBlockedBatch on a role-served backend) is built on.
func RunBlockingAnnotatorReportsTheTransitiveBlockedFlag(t *testing.T, ctx context.Context, fixture BlockingAnnotatorFixture) {
t.Helper()
blocker := fixture.IssuePrefix + "-flag-blocker"
blocked := fixture.IssuePrefix + "-flag-blocked"
child := fixture.IssuePrefix + "-flag-child"
free := fixture.IssuePrefix + "-flag-free"
ghost := fixture.IssuePrefix + "-flag-ghost"
seedBlockingIssues(t, ctx, fixture, blocker, blocked, child, free)
seedBlockingEdge(t, ctx, fixture, child, blocked, types.DepParentChild)
seedBlockingEdge(t, ctx, fixture, blocked, blocker, types.DepBlocks)
ids := []string{blocked, child, free, ghost}
unasked := annotateBlocking(t, ctx, fixture, publicops.BlockingRequest{IDs: ids})
for _, item := range unasked.Items {
if item.IsBlocked != nil {
t.Errorf("unasked: %s carries IsBlocked=%v, want no flag", item.ID, *item.IsBlocked)
}
}
asked := annotateBlocking(t, ctx, fixture, publicops.BlockingRequest{IDs: ids, IncludeIsBlocked: true})
want := map[string]*bool{blocked: new(true), child: new(true), free: new(false), ghost: nil}
if len(asked.Items) != len(ids) {
t.Fatalf("asked: %d items, want %d", len(asked.Items), len(ids))
}
for _, item := range asked.Items {
w, ok := want[item.ID]
if !ok {
t.Errorf("asked: unexpected item %s", item.ID)
continue
}
switch {
case w == nil && item.IsBlocked != nil:
t.Errorf("asked: %s (no row) IsBlocked=%v, want no flag", item.ID, *item.IsBlocked)
case w != nil && item.IsBlocked == nil:
t.Errorf("asked: %s IsBlocked absent, want %v", item.ID, *w)
case w != nil && *item.IsBlocked != *w:
t.Errorf("asked: %s IsBlocked=%v, want %v", item.ID, *item.IsBlocked, *w)
}
}
flags, err := publicops.BlockedFlags(ctx, fixture.Annotator, append(ids, blocked, ""))
if err != nil {
t.Fatalf("BlockedFlags: %v", err)
}
wantFlags := map[string]bool{blocked: true, child: true, free: false}
if len(flags) != len(wantFlags) {
t.Errorf("BlockedFlags = %v, want %v (no entry for the ghost or the blank id)", flags, wantFlags)
}
for id, w := range wantFlags {
if got, ok := flags[id]; !ok || got != w {
t.Errorf("BlockedFlags[%s] = %v (present %v), want %v", id, got, ok, w)
}
}
}

View file

@ -531,6 +531,96 @@ func RunDependencyEditorSameTypeReAddWithIdenticalMetadataIsANoOp(t *testing.T,
}
}
// RunDependencyEditorSameTypeReAddWithChangedThreadMintsOneVersion is the
// thread_id twin of
// RunDependencyEditorSameTypeReAddWithChangedMetadataMintsOneVersion. The row
// carries a thread as well as metadata, and the source issue's version snapshot
// carries each edge's thread_id, so a same-type re-add naming a thread the row
// does not carry is a real mutation on the same terms as a metadata change:
// the leaf updates the row in place, journals the replacement edge, and mints
// EXACTLY ONE version (#5898 leg 2). The re-add arm once compared metadata
// alone, which read that re-add as change-free and dropped the thread.
//
// The metadata is identical across every write, so the thread is the only
// thing that moves. A last re-add names no thread, and is the change-free
// no-op: an empty thread names none rather than asking for none, which is
// what keeps the callers that never carry a thread from erasing one.
//
// It drives the writes through fixture.AddDependency for the reason the
// metadata case gives: publicops.DependencyEdge carries no thread either.
func RunDependencyEditorSameTypeReAddWithChangedThreadMintsOneVersion(t *testing.T, ctx context.Context, fixture DependencyEditorFixture) {
t.Helper()
if fixture.AddDependency == nil {
t.Skip("fixture has no AddDependency hook: a thread is not settable through publicops.DependencyEdge")
}
fixture.SetJournalEnabled(true)
t.Cleanup(func() { fixture.SetJournalEnabled(false) })
fixture.SetVersionedHistoryEnabled(true)
t.Cleanup(func() { fixture.SetVersionedHistoryEnabled(false) })
source := fixture.IssuePrefix + "-idemthread-source"
target := fixture.IssuePrefix + "-idemthread-target"
seedDependencyEditorIssue(t, ctx, fixture, source)
seedDependencyEditorIssue(t, ctx, fixture, target)
const metadata = `{"note":"v1"}`
add := func(thread, refusal string) {
t.Helper()
dep := &types.Dependency{IssueID: source, DependsOnID: target, Type: types.DepBlocks, Metadata: metadata, ThreadID: thread}
if err := fixture.AddDependency(ctx, dep, "writer"); err != nil {
t.Fatalf("%s: %v", refusal, err)
}
assertDependencyEdgeTypedCount(t, ctx, fixture, "dependencies", source, target, string(types.DepBlocks), 1)
assertDependencyEditorEventCount(t, ctx, fixture, "events", source, types.EventDependencyAdded, 1)
}
storedThread := func() string {
t.Helper()
var thread string
if err := fixture.QueryScalar(ctx,
"SELECT COALESCE(thread_id, '') FROM dependencies WHERE issue_id = ? AND COALESCE(depends_on_issue_id, depends_on_wisp_id, depends_on_external) = ?",
[]any{source, target}, &thread); err != nil {
t.Fatalf("read stored thread_id for %s -> %s: %v", source, target, err)
}
return thread
}
journalCount := func() int {
t.Helper()
var count int
if err := fixture.QueryScalar(ctx,
"SELECT COUNT(*) FROM bd_events_journal WHERE issue_id = ? AND op = ?",
[]any{source, string(storeops.EventDepAdd)}, &count); err != nil {
t.Fatalf("count bd_events_journal dep_add rows for %s: %v", source, err)
}
return count
}
add("", "AddDependency first")
assertDependencyEditorJournalCountIsOne(t, ctx, fixture, source, string(storeops.EventDepAdd))
versionsBefore := countDependencyEditorIssueVersions(t, ctx, fixture, source)
add("thread-conv-1", "re-adding the same edge with a new thread refused")
if got := storedThread(); got != "thread-conv-1" {
t.Errorf("stored thread_id = %q, want %q: the re-add must persist the new thread, not keep the old", got, "thread-conv-1")
}
if got := journalCount(); got != 2 {
t.Errorf("bd_events_journal dep_add rows for %s = %d, want 2: the thread-changed re-add must journal its own replacement-edge entry", source, got)
}
if delta := countDependencyEditorIssueVersions(t, ctx, fixture, source) - versionsBefore; delta != 1 {
t.Errorf("issue_versions rows for %s went %d -> %d (delta %d), want a delta of 1: the thread genuinely changed, so the re-add is a real mutation of the source issue and must mint exactly one version (#5898 leg 2)", source, versionsBefore, versionsBefore+delta, delta)
}
versionsBefore = countDependencyEditorIssueVersions(t, ctx, fixture, source)
add("", "re-adding the same edge naming no thread refused")
if got := storedThread(); got != "thread-conv-1" {
t.Errorf("stored thread_id after a re-add naming no thread = %q, want %q kept", got, "thread-conv-1")
}
if got := journalCount(); got != 2 {
t.Errorf("bd_events_journal dep_add rows for %s = %d after a change-free re-add, want 2 still", source, got)
}
if delta := countDependencyEditorIssueVersions(t, ctx, fixture, source) - versionsBefore; delta != 0 {
t.Errorf("issue_versions rows for %s went %d -> %d (delta %d) on a re-add naming no thread, want a delta of 0: it keeps the stored thread, so nothing changed (#5898 R3)", source, versionsBefore, versionsBefore+delta, delta)
}
}
// RunDependencyEditorRepeatsWithinOneRequestCollapse pins the clause that
// answers a request naming ONE PAIR TWICE. The same-type re-add rule is stated
// for the pair rather than for the call, so the second occurrence inside a
@ -2541,3 +2631,82 @@ func dependencyEditorHistoryProbe(t *testing.T, ctx context.Context, fixture Dep
assertDependencyEditorHistoryDelta(t, ctx, fixture, before, want, why)
}
}
// RunDependencyEditorRefusesADottedChildGatedOnItsOwnParent pins
// publicops.CheckDottedChildDependency on the role: an explicit edge from a
// dotted-id child to its own ancestor is refused as a
// *DottedChildDependencyError (ErrValidation) on every leg, and nothing is
// written. (It is decided before any per-edge probe, so the probe-skipped
// spelling, which the wire does not publish, adds nothing here.) It used to be
// enforced only by the CLI ahead of the role, so an HTTP or embedded caller
// could gate bd-abc.1 on bd-abc.
//
// POSITIVE HALF: the hierarchy itself — a parent-child edge to the IMMEDIATE
// dotted parent — is allowed, and so is an edge between siblings. A body that
// refused every edge touching a dotted id would satisfy the refusals alone.
//
// WITH THE HIERARCHY STORED: once that parent-child edge exists (the shape
// `bd create --parent` leaves), a blocking edge on the same pair is still this
// refusal, not the type or hierarchy conflict the stored edge would raise — the
// rule reads nothing, so it answers first — and the stored edge survives.
func RunDependencyEditorRefusesADottedChildGatedOnItsOwnParent(t *testing.T, ctx context.Context, fixture DependencyEditorFixture) {
t.Helper()
parent := fixture.IssuePrefix + "-dotted"
child := parent + ".1"
grandchild := child + ".2"
sibling := parent + ".3"
for _, id := range []string{parent, child, grandchild, sibling} {
seedDependencyEditorIssue(t, ctx, fixture, id)
}
for _, refused := range []struct {
name string
edge publicops.DependencyEdge
}{
{"child blocks on its parent", publicops.DependencyEdge{IssueID: child, DependsOnID: parent, Type: publicops.DepBlocks}},
{"grandchild blocks on its grandparent", publicops.DependencyEdge{IssueID: grandchild, DependsOnID: parent, Type: publicops.DepBlocks}},
{"grandchild parent-child to its grandparent", publicops.DependencyEdge{IssueID: grandchild, DependsOnID: parent, Type: publicops.DepParentChild}},
{"child relates to its parent", publicops.DependencyEdge{IssueID: child, DependsOnID: parent, Type: publicops.DepRelated}},
} {
_, err := fixture.Editor.AddDependencies(ctx, publicops.AddDependenciesRequest{
Actor: "writer",
Edges: []publicops.DependencyEdge{refused.edge},
})
var dotted *publicops.DottedChildDependencyError
if !errors.As(err, &dotted) {
t.Errorf("%s: error = %v, want *DottedChildDependencyError", refused.name, err)
continue
}
if !errors.Is(err, publicops.ErrValidation) {
t.Errorf("%s: error = %v, want it to match ErrValidation", refused.name, err)
}
if dotted.IssueID != refused.edge.IssueID || dotted.DependsOnID != refused.edge.DependsOnID {
t.Errorf("%s: refusal names %s -> %s, want %s -> %s", refused.name,
dotted.IssueID, dotted.DependsOnID, refused.edge.IssueID, refused.edge.DependsOnID)
}
}
assertDependencyEditorNoEdgesFrom(t, ctx, fixture, child, grandchild)
if _, err := fixture.Editor.AddDependencies(ctx, publicops.AddDependenciesRequest{
Actor: "writer",
Edges: []publicops.DependencyEdge{
{IssueID: grandchild, DependsOnID: child, Type: publicops.DepParentChild},
{IssueID: sibling, DependsOnID: child, Type: publicops.DepBlocks},
},
}); err != nil {
t.Fatalf("the immediate parent-child edge and a sibling edge: %v", err)
}
assertDependencyEdgeTypedCount(t, ctx, fixture, "dependencies", grandchild, child, string(publicops.DepParentChild), 1)
assertDependencyEdgeCount(t, ctx, fixture, "dependencies", sibling, child, 1)
_, err := fixture.Editor.AddDependencies(ctx, publicops.AddDependenciesRequest{
Actor: "writer",
Edges: []publicops.DependencyEdge{{IssueID: grandchild, DependsOnID: child, Type: publicops.DepBlocks}},
})
var dotted *publicops.DottedChildDependencyError
if !errors.As(err, &dotted) || !errors.Is(err, publicops.ErrValidation) {
t.Errorf("blocks on a parent whose parent-child edge is stored: error = %v, want *DottedChildDependencyError matching ErrValidation", err)
}
assertDependencyEdgeTypedCount(t, ctx, fixture, "dependencies", grandchild, child, string(publicops.DepParentChild), 1)
assertDependencyEdgeCount(t, ctx, fixture, "dependencies", grandchild, child, 1)
}

View file

@ -71,11 +71,13 @@ import (
// - PARTICIPATION-GENERATION GATING (design §16.2b). Whether an
// update-shaped mutation on a legacy (participation_generation IS NULL)
// row is correctly skipped is Phase 2 behavior this bead also owns, but
// it depends on migration 0068's participation_generation column, which
// does not exist when this contract is first written (0068 lands last in
// this bead's build order, by the mayor's explicit sequencing). It gets
// its own dedicated cases once 0068 lands, beside this file rather than
// inside it.
// it depends on migration 0070's participation_generation column, which
// does not exist when this contract is first written (0070 lands last in
// this bead's build order, by the mayor's explicit sequencing — steps 4-5
// of design §16.3 moved to their own migration slot when 0068 shipped as
// attribution_status-only, see that migration's header). It gets its own
// dedicated cases once 0070 lands, beside this file rather than inside
// it.
// - CONCURRENT WRITERS. Every case here is one writer, one issue, one
// mutation at a time — the same restriction journal_contract.go states
// for the same reason: a single-threaded case cannot exercise what only

View file

@ -0,0 +1,644 @@
package conformance
import (
"context"
"testing"
)
// This file holds the write-fence cases dualwrite_history_contract.go's own
// "WHAT THIS CONTRACT DELIBERATELY DOES NOT PIN" section explicitly deferred:
// "PARTICIPATION-GENERATION GATING (design §16.2b)... It gets its own
// dedicated cases once 0070 lands, beside this file rather than inside it."
// Migration 0070 now carries participation_generation on both issues and
// wisps (design §16.3 steps 4-5, be-dt74u amendment, be-h89oq), so this is
// that file.
//
// Design §16.2b, verbatim substance: the flag-on writer does not increment
// current_revision or mint an issue_versions row for an UPDATE-shaped
// mutation against a record whose participation_generation is NULL — a skip,
// not a refusal (FR-2's zero-rows no-op shape). A CREATE-shaped mutation is
// different: a brand-new row has no prior legacy state to preserve, so if the
// flag is already on at creation time, the writer stamps
// participation_generation as part of the same insert that begins its
// history. A create with the flag off leaves the column NULL, indistinguishable
// from a true legacy row (FR-7's byte-identical requirement).
//
// WHY A SEPARATE FIXTURE RATHER THAN THREE MORE DualWriteFixture CLOSURES.
// DualWriteFixture's Mutate/MutateAsNoOp pair is deliberately flag-fixed-at-
// construction (see that file's SEEDING DISCIPLINE note and each leg's
// newXxxDualWriteFixture, which calls SetVersionedHistoryEnabled exactly
// once). The legacy-record case here is inherently "created while the flag
// was OFF, then mutated after the flag turns ON" — a fixture built once with
// one flag state cannot express that sequence, so SetFlag here is a toggle
// callable more than once per fixture, not a one-time constructor argument.
//
// THE FIXTURE'S CLOSURES ARE THE OBSERVABLE SURFACE, NOT THE SCHEMA — same
// discipline as DualWriteFixture: Mutate/MutateExisting drive CreateIssue and
// UpdateIssue (or their unit-of-work equivalents), never issue_versions or
// store_epoch directly.
//
// WHAT THIS CONTRACT DELIBERATELY DOES NOT PIN:
// - THE EXACT STAMPED VALUE. That a create-shaped mutation with the flag on
// stamps SOME non-NULL participation_generation is pinned here; that the
// value equals the current store_epoch.epoch is not — reaching
// store_epoch is the same one-column, two-of-three-legs-need-white-box-
// access problem dualwrite_history_contract.go's FR-6 note describes, and
// the same resolution applies: pinned per leg, dolt-only, alongside
// TestDualWriteStampsTheCurrentStoreEpochOnEachVersionRow.
// - wisps.participation_generation. FR-8 (carried by dualwrite_history_contract.go's
// exclusion list) applies here too: this fixture's Mutate front door is
// CreateIssue against the issues table, the wisp-arrival cases read only
// the issues row a wisp becomes, and no phase reads or writes the wisps
// column regardless.
type ParticipationGenerationFixture struct {
// IssuePrefix namespaces the id each case mints, the same discipline
// DualWriteFixture uses and for the same reason.
IssuePrefix string
// SetFlag toggles versioned history for every subsequent call through
// this fixture, and may be called more than once per case — unlike
// DualWriteFixture, whose flag is fixed at construction.
SetFlag func(ctx context.Context, enabled bool) error
// Mutate creates a new issue with the given id: a CREATE-shaped mutation
// in design §16.2b's sense.
Mutate func(ctx context.Context, id string) error
// MutateExisting applies a real (non-no-op) UPDATE-shaped mutation to an
// already-existing issue — a different value than Mutate gave it, so a
// vacuous no-op skip can never be mistaken for the fence.
MutateExisting func(ctx context.Context, id string) error
// CreateWisp creates a new wisp-plane (ephemeral) issue with the given
// id: the starting point for the two ways a record reaches the issues
// plane without being created there. A wisp is never versioned (FR-8)
// and never carries a participation declaration, in either flag state.
CreateWisp func(ctx context.Context, id string) error
// PromoteWisp promotes the wisp id onto the issues plane
// (PromoteFromEphemeral, or the unit-of-work leg's PromoteWisp).
PromoteWisp func(ctx context.Context, id string) error
// MovePersistent moves the wisp id onto the issues plane through a
// persistence-mode update (bd update --persistent). It is its own
// closure rather than a second spelling of PromoteWisp because it mints at
// a different site on every leg: the guarded update's one end-of-update
// mint on dolt and embeddeddolt, MoveIssuePersistenceInTx's own on uow.
// On an issues-plane row whose flags disagree with it (see
// CreateNoHistoryIssue) the same update repairs the flags in place, a
// same-plane normalize, rather than moving the row.
MovePersistent func(ctx context.Context, id string) error
// ClearWispFlag clears the wisp id's ephemeral flag IN PLACE: the untyped
// UpdateIssue of {"wisp": false} bd mol squash makes on a squashed root
// (UpdateWisp on the unit-of-work leg, the way its molecule writer routes
// it). The row stays in the wisps table, now carrying neither Ephemeral
// nor NoHistory.
ClearWispFlag func(ctx context.Context, id string) error
// SquashWispRoot closes the wisp id and then clears its flag as
// ClearWispFlag does, both in ONE transaction: the shape bd mol squash's
// root auto-close takes, where an error from either write aborts both.
SquashWispRoot func(ctx context.Context, id string) error
// CreateUnflaggedWisp creates id in the wisps table with neither
// Ephemeral nor NoHistory set: import's "wisp_plane" marker, which pins
// the plane whatever the flags say (WispPlaneOverride = &true, through
// the batch create import runs), or on the unit-of-work leg CreateWisp,
// which routes by the call rather than by the flags.
CreateUnflaggedWisp func(ctx context.Context, id string) error
// CreateNoHistoryIssue creates id in the ISSUES table carrying
// NoHistory=true: import's promoted-no-history shape (bd-r9uce), a
// durable row whose stray flag is preserved while WispPlaneOverride =
// &false pins its plane, through the batch create import runs; or on the
// unit-of-work leg CreateIssue, which routes by the call.
CreateNoHistoryIssue func(ctx context.Context, id string) error
// CurrentRevision reads issues.current_revision for id.
CurrentRevision func(ctx context.Context, id string) (int64, error)
// VersionRowCount reads how many issue_versions rows exist for id.
VersionRowCount func(ctx context.Context, id string) (int, error)
// ParticipationGeneration reads issues.participation_generation for id,
// returning nil for SQL NULL.
ParticipationGeneration func(ctx context.Context, id string) (*int64, error)
// InWispsTable reports whether the wisps table holds a row for id: the
// precondition the wisps-table cases check, so they cannot pass on a row
// that a step moved to the issues table.
InWispsTable func(ctx context.Context, id string) (bool, error)
}
// RunParticipationGenerationCreateWithFlagOnStampsAValue pins design
// §16.2(a)/(b): a create-shaped mutation with the flag already on stamps a
// non-NULL participation_generation on the new row, as part of the same
// insert that begins its history — a brand-new row has no legacy state to
// preserve, so there is nothing to skip.
func RunParticipationGenerationCreateWithFlagOnStampsAValue(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-create-stamps"
if err := fixture.Mutate(ctx, id); err != nil {
t.Fatalf("mutating %s: %v", id, err)
}
gen, err := fixture.ParticipationGeneration(ctx, id)
if err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
}
if gen == nil {
t.Errorf("participation_generation for %s is NULL immediately after a create-shaped mutation with "+
"the flag on, want a stamped non-NULL value: design §16.2b requires the writer to declare "+
"participation at insert time, since a brand-new row has no prior legacy state to preserve", id)
}
}
// RunParticipationGenerationCreateWithFlagOffLeavesLegacyNull pins the other
// half of design §16.2(b): a create-shaped mutation with the flag off leaves
// participation_generation NULL, indistinguishable from a true legacy row —
// flag-off must stay byte-identical to pre-Phase-2 behavior (FR-7).
func RunParticipationGenerationCreateWithFlagOffLeavesLegacyNull(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
if err := fixture.SetFlag(ctx, false); err != nil {
t.Fatalf("disabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-create-flag-off"
if err := fixture.Mutate(ctx, id); err != nil {
t.Fatalf("mutating %s: %v", id, err)
}
gen, err := fixture.ParticipationGeneration(ctx, id)
if err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
}
if gen != nil {
t.Errorf("participation_generation for %s = %d with the flag off at creation, want NULL: a "+
"flag-off create must remain indistinguishable from a true legacy row (design §16.2b)", id, *gen)
}
}
// RunParticipationGenerationSkipsUpdateOnLegacyRecord pins the write fence's
// central claim, design §16.2(b): the flag-on writer does not increment
// current_revision or mint an issue_versions row for an update-shaped
// mutation against a record whose participation_generation is NULL. The
// record must be a REAL legacy record — created while the flag was off, not
// merely one the fixture asserts is NULL — so this also re-confirms that
// precondition before trusting the rest of the case.
func RunParticipationGenerationSkipsUpdateOnLegacyRecord(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
if err := fixture.SetFlag(ctx, false); err != nil {
t.Fatalf("disabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-legacy-skip"
if err := fixture.Mutate(ctx, id); err != nil {
t.Fatalf("mutating %s: %v", id, err)
}
if gen, err := fixture.ParticipationGeneration(ctx, id); err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
} else if gen != nil {
t.Fatalf("participation_generation for %s = %d before the flag was ever turned on, want NULL — "+
"this case cannot test the legacy-record fence against a record that was never actually legacy",
id, *gen)
}
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
beforeRevision, err := fixture.CurrentRevision(ctx, id)
if err != nil {
t.Fatalf("reading current_revision for %s: %v", id, err)
}
beforeCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if err := fixture.MutateExisting(ctx, id); err != nil {
t.Fatalf("mutating existing %s: %v", id, err)
}
afterRevision, err := fixture.CurrentRevision(ctx, id)
if err != nil {
t.Fatalf("reading current_revision for %s: %v", id, err)
}
afterCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if afterCount != beforeCount {
t.Errorf("version row count for %s went from %d to %d across an update-shaped mutation on a "+
"legacy (participation_generation IS NULL) record with the flag now on, want unchanged: "+
"design §16.2b requires the writer to skip minting for a record it has not positively "+
"promoted", id, beforeCount, afterCount)
}
if afterRevision != beforeRevision {
t.Errorf("current_revision for %s went from %d to %d across the same skipped mutation, want "+
"unchanged: a skip means neither half of RecordVersionInTx's write runs, not just the "+
"version-row half", id, beforeRevision, afterRevision)
}
}
// RunParticipationGenerationProceedsForPromotedRecord is the fence's
// not-vacuous check: an update-shaped mutation against a record whose
// participation_generation is ALREADY stamped (created with the flag on,
// i.e. positively declared, not legacy) must mint normally. Without this
// case, an implementation that skips every update unconditionally would
// still pass RunParticipationGenerationSkipsUpdateOnLegacyRecord.
func RunParticipationGenerationProceedsForPromotedRecord(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-promoted-proceeds"
if err := fixture.Mutate(ctx, id); err != nil {
t.Fatalf("mutating %s: %v", id, err)
}
if gen, err := fixture.ParticipationGeneration(ctx, id); err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
} else if gen == nil {
t.Fatalf("participation_generation for %s is NULL immediately after a create with the flag on — "+
"this case cannot test the promoted-record path against a record that was never actually "+
"promoted", id)
}
beforeCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if err := fixture.MutateExisting(ctx, id); err != nil {
t.Fatalf("mutating existing %s: %v", id, err)
}
afterCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if afterCount != beforeCount+1 {
t.Errorf("version row count for %s went from %d to %d across an update-shaped mutation on an "+
"already-promoted record, want exactly +1: the fence must skip only a legacy (NULL) record, "+
"not every update (design §16.2b)", id, beforeCount, afterCount)
}
}
// RunParticipationGenerationFlagOffSkipsUpdateOnParticipatingRecord pins the
// switch's off half for a record the fence would let through: created with
// the flag on (so participation_generation is stamped), then updated after
// the flag is turned back off, it must mint nothing. ProceedsForPromotedRecord
// shows the fence passes such a record, so only the flag stands between this
// update and a mint. No other case can see a writer that ignores the flag on
// updates: every other flag-off record is legacy, and the fence stops those
// first.
func RunParticipationGenerationFlagOffSkipsUpdateOnParticipatingRecord(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-flag-off-skip"
if err := fixture.Mutate(ctx, id); err != nil {
t.Fatalf("mutating %s: %v", id, err)
}
if gen, err := fixture.ParticipationGeneration(ctx, id); err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
} else if gen == nil {
t.Fatalf("participation_generation for %s is NULL immediately after a create with the flag on — "+
"this case cannot test the flag against a record the fence would have stopped anyway", id)
}
if err := fixture.SetFlag(ctx, false); err != nil {
t.Fatalf("disabling versioned history: %v", err)
}
beforeRevision, err := fixture.CurrentRevision(ctx, id)
if err != nil {
t.Fatalf("reading current_revision for %s: %v", id, err)
}
beforeCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if err := fixture.MutateExisting(ctx, id); err != nil {
t.Fatalf("mutating existing %s: %v", id, err)
}
afterRevision, err := fixture.CurrentRevision(ctx, id)
if err != nil {
t.Fatalf("reading current_revision for %s: %v", id, err)
}
afterCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if afterCount != beforeCount {
t.Errorf("version row count for %s went from %d to %d across an update-shaped mutation with the "+
"flag off, want unchanged: turning versioned history off stops minting for every record, "+
"including one that already participates", id, beforeCount, afterCount)
}
if afterRevision != beforeRevision {
t.Errorf("current_revision for %s went from %d to %d across the same update with the flag off, "+
"want unchanged", id, beforeRevision, afterRevision)
}
}
// RunParticipationGenerationWispPromotionBeginsHistory pins that promoting a
// wisp onto the issues plane is CREATE-shaped in design §16.2b's sense. (This
// is wisp promotion, PromoteFromEphemeral: not R2.3's promotion of a legacy
// record, which is what ProceedsForPromotedRecord's name refers to.) The
// issues row a promotion inserts is brand new on that plane, and the wisp
// behind it was never versioned and never declared participation (FR-8), so
// there is no legacy state to preserve: with the flag on, the promotion stamps
// participation_generation and mints the record's first version, as a create
// there would. Treated as UPDATE-shaped, the fence finds the new row NULL and
// skips, and because nothing stamps the column afterwards every later update
// skips too, so a record created with the flag on is never versioned at all.
func RunParticipationGenerationWispPromotionBeginsHistory(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
runWispArrivalBeginsHistory(t, ctx, fixture, "promote", fixture.PromoteWisp)
}
// RunParticipationGenerationWispPersistenceMoveBeginsHistory is
// RunParticipationGenerationWispPromotionBeginsHistory for the other way a
// wisp reaches the issues plane, a persistence-mode update (bd update
// --persistent). It needs its own case because it reaches a different mint
// site than promotion on every leg (see MovePersistent).
func RunParticipationGenerationWispPersistenceMoveBeginsHistory(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
runWispArrivalBeginsHistory(t, ctx, fixture, "move-persistent", fixture.MovePersistent)
}
// runWispArrivalBeginsHistory is the body the two wisp-arrival cases share:
// with the flag on, a wisp that arrives on the issues plane through arrive
// carries a stamped participation_generation and exactly one version row,
// and the next update-shaped mutation mints normally.
func runWispArrivalBeginsHistory(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture, how string, arrive func(context.Context, string) error) {
t.Helper()
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-" + how
if err := fixture.CreateWisp(ctx, id); err != nil {
t.Fatalf("creating wisp %s: %v", id, err)
}
if err := arrive(ctx, id); err != nil {
t.Fatalf("moving wisp %s onto the issues plane (%s): %v", id, how, err)
}
gen, err := fixture.ParticipationGeneration(ctx, id)
if err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
}
if gen == nil {
t.Errorf("participation_generation for %s is NULL after the wisp reached the issues plane (%s) with "+
"the flag on, want a stamped value: the issues row is new, so the arrival is create-shaped "+
"(design §16.2b), and a NULL here leaves the record fenced as legacy for good", id, how)
}
arrivedCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if arrivedCount != 1 {
t.Errorf("version row count for %s = %d after the wisp reached the issues plane (%s) with the flag "+
"on, want 1: a wisp is never versioned (FR-8), so the arrival mints the record's first version",
id, arrivedCount, how)
}
if err := fixture.MutateExisting(ctx, id); err != nil {
t.Fatalf("mutating existing %s: %v", id, err)
}
afterCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if afterCount != arrivedCount+1 {
t.Errorf("version row count for %s went from %d to %d across an update-shaped mutation after the "+
"wisp reached the issues plane (%s), want exactly +1: a record that arrived with the flag on is "+
"not legacy, so the fence must let its updates mint", id, arrivedCount, afterCount, how)
}
}
// RunParticipationGenerationWispFlagClearMintsNothing pins that the fence
// decides a row's plane by the TABLE that holds it, not by the row's flags.
// bd mol squash clears a wisp root's ephemeral flag in place, so the row
// stays in the wisps table carrying neither Ephemeral nor NoHistory, and a
// plane test read off those flags takes it for an issues-plane row. It is
// not one: a wisps-table row is never versioned (FR-8) and has no issues row
// whose participation_generation the fence could read. So the update must
// succeed and mint nothing. Read off the flags, the fence either aborts the
// whole update looking for an issues row that is not there, or, without the
// fence, mints a stray version for a wisp.
func RunParticipationGenerationWispFlagClearMintsNothing(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
runWispTableRowMintsNothing(t, ctx, fixture, "flag-clear", fixture.CreateWisp, fixture.ClearWispFlag)
}
// RunParticipationGenerationWispRootSquashMintsNothing is
// RunParticipationGenerationWispFlagClearMintsNothing in the shape bd mol
// squash actually runs it: the root's close and its flag clear in one
// transaction, so a mint that fails on the cleared row takes the close down
// with it and the squash cannot complete.
func RunParticipationGenerationWispRootSquashMintsNothing(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
runWispTableRowMintsNothing(t, ctx, fixture, "squash", fixture.CreateWisp, fixture.SquashWispRoot)
}
// RunParticipationGenerationUnflaggedWispCreateMintsNothing pins the
// create-shaped half of the same rule: a row CREATED in the wisps table
// without either flag (import's "wisp_plane" marker) reaches the
// create-shaped mint, and must come out of it with no error and no version,
// exactly as a flagged wisp does.
func RunParticipationGenerationUnflaggedWispCreateMintsNothing(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
runWispTableRowMintsNothing(t, ctx, fixture, "unflagged-create", fixture.CreateUnflaggedWisp)
}
// runWispTableRowMintsNothing is the body the three wisps-table cases share:
// with the flag on, every step succeeds on id, the wisps table still holds id
// afterwards, and id ends with no issue_versions row.
func runWispTableRowMintsNothing(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture, how string, steps ...func(context.Context, string) error) {
t.Helper()
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-" + how
for i, step := range steps {
if err := step(ctx, id); err != nil {
t.Fatalf("step %d of %s on wisps-table row %s with the flag on: %v — a row the wisps table "+
"holds is never versioned (FR-8), so its mint must be a no-op, not an error that aborts "+
"the mutation", i+1, how, id, err)
}
}
// The precondition, checked after the steps rather than assumed: a step
// that moved the row to the issues table would leave a NULL
// participation_generation there, the update-shaped mint would be fenced
// as legacy, and the zero count below would hold without saying anything
// about a wisps-table row.
if inWisps, err := fixture.InWispsTable(ctx, id); err != nil {
t.Fatalf("checking whether the wisps table holds %s: %v", id, err)
} else if !inWisps {
t.Fatalf("%s is not in the wisps table after %s — this case pins that a wisps-table row mints "+
"nothing, and cannot say so about a row a step moved out of that table", id, how)
}
count, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if count != 0 {
t.Errorf("version row count for wisps-table row %s = %d after %s with the flag on, want 0: a "+
"wisp is never versioned (FR-8), whatever its flags say", id, count, how)
}
}
// RunParticipationGenerationNoHistoryIssueCreateDeclaresParticipation pins
// that a create declares participation for every ISSUES-table row it makes
// with the flag on, a row carrying NoHistory included. Import keeps a
// promoted no-history wisp's durable row on the issues plane with its stray
// no_history=true (bd-r9uce). While the row says no-history it is not
// versioned, so the create mints nothing. But it was created with history
// on, so it is not legacy: once bd update --persistent repairs the flag in
// place (a same-plane normalize, update-shaped by design), the repair and
// every update after it must mint. Left NULL by the create, the column reads
// as legacy to the fence, and the row is never versioned at all.
func RunParticipationGenerationNoHistoryIssueCreateDeclaresParticipation(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-no-history-create"
if err := fixture.CreateNoHistoryIssue(ctx, id); err != nil {
t.Fatalf("creating no-history issues-plane row %s: %v", id, err)
}
gen, err := fixture.ParticipationGeneration(ctx, id)
if err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
}
if gen == nil {
t.Errorf("participation_generation for %s is NULL after a create with the flag on, want a stamped "+
"value: the row is new on the issues plane, so the create declares participation (design "+
"§16.2b) even though its NoHistory flag keeps it unversioned for now", id)
}
if count, err := fixture.VersionRowCount(ctx, id); err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
} else if count != 0 {
t.Errorf("version row count for %s = %d after a create carrying NoHistory, want 0: a no-history "+
"row is not versioned while it says so", id, count)
}
if err := fixture.MovePersistent(ctx, id); err != nil {
t.Fatalf("repairing %s to persistent: %v", id, err)
}
repairedCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if repairedCount != 1 {
t.Errorf("version row count for %s = %d after the persistent repair, want 1: the row was created "+
"with the flag on, so the fence must let the repair's update-shaped mint through", id, repairedCount)
}
if err := fixture.MutateExisting(ctx, id); err != nil {
t.Fatalf("mutating existing %s: %v", id, err)
}
afterCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if afterCount != repairedCount+1 {
t.Errorf("version row count for %s went from %d to %d across an update-shaped mutation after the "+
"repair, want exactly +1", id, repairedCount, afterCount)
}
}
// RunParticipationGenerationLegacyNoHistoryIssueStaysLegacy is
// RunParticipationGenerationNoHistoryIssueCreateDeclaresParticipation's
// negative twin, and pins R2.3: an ordinary write never promotes a legacy
// record. The same no-history issues-table row, created while the flag was
// OFF, is legacy. Only a create-shaped call stamps a flagged row, so once the
// flag is on, an update-shaped mutation must leave participation_generation
// NULL and mint nothing. So must the bd update --persistent repair that then
// clears the flag in place: that repair is update-shaped too (a same-plane
// normalize), so the row it leaves is an ordinary legacy row, still fenced.
func RunParticipationGenerationLegacyNoHistoryIssueStaysLegacy(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
if err := fixture.SetFlag(ctx, false); err != nil {
t.Fatalf("disabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-no-history-legacy"
if err := fixture.CreateNoHistoryIssue(ctx, id); err != nil {
t.Fatalf("creating no-history issues-plane row %s with the flag off: %v", id, err)
}
if gen, err := fixture.ParticipationGeneration(ctx, id); err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
} else if gen != nil {
t.Fatalf("participation_generation for %s = %d before the flag was ever turned on, want NULL — "+
"this case cannot test that a legacy no-history row stays legacy against a row that was never "+
"legacy", id, *gen)
}
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
beforeRevision, err := fixture.CurrentRevision(ctx, id)
if err != nil {
t.Fatalf("reading current_revision for %s: %v", id, err)
}
assertStillLegacy := func(after string) {
t.Helper()
if gen, err := fixture.ParticipationGeneration(ctx, id); err != nil {
t.Fatalf("reading participation_generation for %s: %v", id, err)
} else if gen != nil {
t.Errorf("participation_generation for %s = %d after %s with the flag on, want NULL: the row "+
"was created with the flag off, and an update-shaped write must not promote a legacy "+
"record (R2.3), whatever its no-history flag says", id, *gen, after)
}
if count, err := fixture.VersionRowCount(ctx, id); err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
} else if count != 0 {
t.Errorf("version row count for %s = %d after %s with the flag on, want 0: a legacy row's "+
"update-shaped mint is fenced (design §16.2b)", id, count, after)
}
if revision, err := fixture.CurrentRevision(ctx, id); err != nil {
t.Fatalf("reading current_revision for %s: %v", id, err)
} else if revision != beforeRevision {
t.Errorf("current_revision for %s went from %d to %d after %s, want unchanged: a fenced "+
"mint runs neither half of the seam's write", id, beforeRevision, revision, after)
}
}
if err := fixture.MutateExisting(ctx, id); err != nil {
t.Fatalf("mutating existing %s: %v", id, err)
}
assertStillLegacy("an update-shaped mutation")
if err := fixture.MovePersistent(ctx, id); err != nil {
t.Fatalf("repairing %s to persistent: %v", id, err)
}
assertStillLegacy("the persistent repair")
}
// RunParticipationGenerationFenceIgnoresSchemaSkewHatch pins design §16.2(c):
// BD_IGNORE_SCHEMA_SKEW=1 downgrades CheckForwardDrift's refusal to a warning
// (internal/storage/schema/schema.go), but it must have no effect on this
// fence — the fence keys on the participation_generation column's real data,
// not on the migration cursor the hatch is about, so a write admitted through
// that hatch is still, correctly, skipped when the record is legacy.
func RunParticipationGenerationFenceIgnoresSchemaSkewHatch(t *testing.T, ctx context.Context, fixture ParticipationGenerationFixture) {
t.Helper()
t.Setenv("BD_IGNORE_SCHEMA_SKEW", "1")
if err := fixture.SetFlag(ctx, false); err != nil {
t.Fatalf("disabling versioned history: %v", err)
}
id := fixture.IssuePrefix + "-schema-skew-hatch"
if err := fixture.Mutate(ctx, id); err != nil {
t.Fatalf("mutating %s: %v", id, err)
}
if err := fixture.SetFlag(ctx, true); err != nil {
t.Fatalf("enabling versioned history: %v", err)
}
beforeCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if err := fixture.MutateExisting(ctx, id); err != nil {
t.Fatalf("mutating existing %s: %v", id, err)
}
afterCount, err := fixture.VersionRowCount(ctx, id)
if err != nil {
t.Fatalf("counting version rows for %s: %v", id, err)
}
if afterCount != beforeCount {
t.Errorf("version row count for %s went from %d to %d with BD_IGNORE_SCHEMA_SKEW=1 set, want "+
"unchanged: the schema-skew hatch must not bypass the participation_generation fence — they "+
"key on different planes (migration cursor vs. real column data) — so a write admitted "+
"through the hatch against a legacy record must still be skipped", id, beforeCount, afterCount)
}
}

View file

@ -0,0 +1,837 @@
package conformance
import (
"context"
"errors"
"strings"
"testing"
"time"
storeops "github.com/steveyegge/beads/internal/storage/issueops"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// This file holds the contract every implementation of publicops.Heartbeater
// must satisfy. Each case asserts what issueops/heartbeater.go PROMISES, cited
// by symbol.
//
// THREE LEGS, ONE BODY. dolt, embedded dolt and the unit-of-work provider all
// reach internal/storage/issueops.ExecuteHeartbeatInTx, so a per-leg failure
// here is a wrapper's failure: a commit the leg added, a hook it fired, a
// refusal that stopped matching errors.Is.
//
// THE QUIET CASE IS THE POINT. A heartbeat is the hottest write in a fleet and
// it is cheap because it writes the lease row and nothing else. Most of what
// RunHeartbeaterChangesNothingOnTheRow asserts is an ABSENCE — no revision, no
// version, no updated_at, no event, no journal entry, no history entry, no
// hook — and each absence is something a plausible wrapper would add.
//
// THE LIVE-CLAIM FENCE IS AN INVARIANT AND A PREDICATE. The RefusesAfter*
// cases hold the invariant: each ends a claim one way and asserts both that
// the lease row is gone and that the holder's next heartbeat is refused. The
// RefusesAnOrphanedLease* cases hold the predicate: a lease row that survives
// on an issue that is no longer claimed by its holder (what a re-arm racing a
// release or close can leave on Dolt) is refused AND deleted, never refreshed.
type HeartbeaterFixture struct {
// IssuePrefix namespaces the ids each assertion seeds, so several of them
// can share one database.
IssuePrefix string
// Heartbeater is the surface under test.
Heartbeater publicops.Heartbeater
// CreateIssue seeds a durable issue in the issues plane.
CreateIssue func(context.Context, *types.Issue, string) error
// CreateWisp seeds an ephemeral issue in the wisps plane. A nil CreateWisp
// SKIPS the wisp case loudly.
CreateWisp func(context.Context, *types.Issue, string) error
// Claimer takes the claim, and with it the lease row, a heartbeat
// refreshes.
Claimer publicops.Claimer
// Lifecycle ends or moves a claim (close, a status move, a hand-doled
// claim) and performs the guarded write the revision case lands.
Lifecycle publicops.Lifecycle
// Releaser gives a claim up for the release case. Nil SKIPS that case.
Releaser publicops.Releaser
// LeaseReclaimer reverts an aged claim for the reclaim case. Nil, or a nil
// Exec, SKIPS that case.
LeaseReclaimer publicops.LeaseReclaimer
// Exec runs raw statements against the backing database: the cases use it
// to age a lease.
Exec func(ctx context.Context, statements []SQLStatement) error
// ExecUncommitted runs raw statements as ANOTHER writer that leaves its
// change uncommitted in the version-controlled working set (a batch-mode
// edit): SQL-committed, no version-control commit. Nil means Exec already
// behaves so.
ExecUncommitted func(ctx context.Context, statements []SQLStatement) error
// QueryScalar runs a single-row query and scans it, so the post-state is
// read RAW rather than through the role being tested.
QueryScalar func(context.Context, string, []any, ...any) error
// CountHistory reports how many version-control entries the fixture's
// branch has. Nil SKIPS that one assertion, loudly, in the quiet case.
CountHistory func(context.Context) (int, error)
// SetJournalEnabled turns on durable journaling, so the quiet case can
// observe that a heartbeat records nothing in bd_events_journal. Nil SKIPS
// that one assertion, loudly.
SetJournalEnabled func(enabled bool)
// SetVersionedHistoryEnabled turns on dual-write issue-version history, so
// the quiet case can observe that a heartbeat records no issue_versions
// row. Nil SKIPS that one assertion, loudly.
SetVersionedHistoryEnabled func(enabled bool)
// HookedHeartbeater is the same role taken off the leg's HOOK-FIRING chain
// (storage.HookFiringStore on the store legs, uow.NewNotifyingProvider on
// the unit-of-work leg), built over the runner FiredUpdates reads. Nil,
// with FiredUpdates, SKIPS the no-hook assertion loudly.
HookedHeartbeater publicops.Heartbeater
// FiredUpdates reports, in firing order, the issue id of every on_update
// the hooked chain ran so far.
FiredUpdates func(context.Context) ([]string, error)
}
const (
heartbeaterHolder = "hb-holder"
heartbeaterIntruder = "hb-intruder"
heartbeaterReaper = "hb-reaper"
)
// RunHeartbeaterRefreshesTheHoldersLease pins the refresh itself
// (Heartbeater: "pushes the lease the caller holds forward by the store's
// TTL") and every member of the HeartbeatResult, against the row READ RAW.
func RunHeartbeaterRefreshesTheHoldersLease(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
id := fixture.IssuePrefix + "-refresh"
heartbeaterSeedClaimed(t, ctx, fixture, id)
aged := time.Now().UTC().Add(-time.Minute).Truncate(time.Second)
if err := fixture.Exec(ctx, []SQLStatement{{
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)
}
before := time.Now().UTC().Add(-time.Second)
result := heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
after := time.Now().UTC().Add(time.Second)
if result.IssueID != id || result.Holder != heartbeaterHolder || result.Rearmed {
t.Fatalf("result = %+v, want {IssueID:%s Holder:%s Rearmed:false}", result, id, heartbeaterHolder)
}
if result.HeartbeatAt.Before(before) || result.HeartbeatAt.After(after) {
t.Fatalf("HeartbeatAt = %v, want the server clock at the call (between %v and %v)", result.HeartbeatAt, before, after)
}
if ttl := result.LeaseExpiresAt.Sub(result.HeartbeatAt); heartbeaterAbs(ttl-storeops.DefaultLeaseTTL) > time.Second {
t.Fatalf("LeaseExpiresAt - HeartbeatAt = %v, want the store's lease TTL %v", ttl, storeops.DefaultLeaseTTL)
}
if moved := heartbeaterScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM leases WHERE issue_id = ? AND holder = ? AND lease_expires_at > ? AND heartbeat_at > ?",
id, heartbeaterHolder, aged, aged); moved != 1 {
t.Fatal("the lease row's lease_expires_at and heartbeat_at did not move forward")
}
heartbeaterRequireStoredMatches(t, ctx, fixture, id, result, before, after)
}
// RunHeartbeaterASameSecondHeartbeatIsNotARearm pins HeartbeatResult.Rearmed
// against the refresh that changes no value: a heartbeat landing in the same
// second as the claim or the previous heartbeat writes values identical to the
// row's (the lease columns hold whole seconds), which some engines report as
// zero rows affected. It is still a refresh of the caller's own row: Rearmed
// is false, and the lease's granted_at and granted_node do not move.
func RunHeartbeaterASameSecondHeartbeatIsNotARearm(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
for i := 0; i < 3; i++ {
id := fixture.IssuePrefix + "-samesec-" + string(rune('a'+i))
heartbeaterSeedClaimed(t, ctx, fixture, id)
granted := heartbeaterScalar[string](t, ctx, fixture,
"SELECT CONCAT(CAST(granted_at AS CHAR), '|', COALESCE(granted_node, '')) FROM leases WHERE issue_id = ?", id)
for beat := 0; beat < 2; beat++ {
result := heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
if result.Rearmed {
t.Fatalf("heartbeat %d on %s right after the claim = %+v, want Rearmed:false: the holder's lease row existed", beat+1, id, result)
}
}
if got := heartbeaterScalar[string](t, ctx, fixture,
"SELECT CONCAT(CAST(granted_at AS CHAR), '|', COALESCE(granted_node, '')) FROM leases WHERE issue_id = ?", id); got != granted {
t.Fatalf("granted_at|granted_node on %s moved from %s to %s across refreshes; a refresh never re-grants", id, granted, got)
}
}
}
// RunHeartbeaterChangesNothingOnTheRow pins the role's quiet promise
// (Heartbeater: "A REFRESH WRITES ONLY THE LEASE ROW"): the issue row's revision
// (row_lock), its current_revision, its updated_at, its events, the events
// journal, issue_versions, the version-control history and the hooks are all
// exactly where the claim left them.
func RunHeartbeaterChangesNothingOnTheRow(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
if fixture.SetJournalEnabled != nil {
fixture.SetJournalEnabled(true)
defer fixture.SetJournalEnabled(false)
} else {
t.Log("HeartbeaterFixture.SetJournalEnabled is nil: the journal assertion is skipped on this backend")
}
if fixture.SetVersionedHistoryEnabled != nil {
fixture.SetVersionedHistoryEnabled(true)
defer fixture.SetVersionedHistoryEnabled(false)
} else {
t.Log("HeartbeaterFixture.SetVersionedHistoryEnabled is nil: the issue_versions assertion is skipped on this backend")
}
id := fixture.IssuePrefix + "-quiet"
heartbeaterSeedClaimed(t, ctx, fixture, id)
// updated_at is stored at second precision on some backends; step past
// the claim's second so a stamp the heartbeat added cannot hide in it.
time.Sleep(1100 * time.Millisecond)
snapshot := func() heartbeaterRowSnapshot {
return heartbeaterSnapshot(t, ctx, fixture, id)
}
before := snapshot()
fired := heartbeaterFired(t, ctx, fixture, id)
surface := fixture.Heartbeater
if fixture.HookedHeartbeater != nil && fixture.FiredUpdates != nil {
surface = fixture.HookedHeartbeater
} else {
t.Log("HeartbeaterFixture.HookedHeartbeater/FiredUpdates is nil: the no-hook assertion is skipped on this backend")
}
heartbeat(t, ctx, surface, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
after := snapshot()
if before != after {
t.Fatalf("a heartbeat changed the issue's durable state:\nbefore %+v\nafter %+v", before, after)
}
if got := heartbeaterFired(t, ctx, fixture, id); got != fired {
t.Fatalf("on_update fired %d time(s) for %s across a refresh, want 0: a refresh fires no hook", got-fired, id)
}
}
// RunHeartbeaterAGuardedWriteWithThePreHeartbeatRevisionStillWins is the
// reason the quiet case matters to a caller: the holder's revision token
// survives its own heartbeats, so a guarded write it composed from the claim
// still lands.
func RunHeartbeaterAGuardedWriteWithThePreHeartbeatRevisionStillWins(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
if fixture.Lifecycle == nil {
t.Skip("HeartbeaterFixture.Lifecycle is nil: this backend cannot land a guarded write")
}
id := fixture.IssuePrefix + "-guarded"
revision := heartbeaterSeedClaimed(t, ctx, fixture, id)
heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: heartbeaterHolder, IssueID: id, ExpectedVersion: &revision,
Patch: publicops.IssuePatch{Notes: publicops.Field[string]{Set: true, Value: "after two heartbeats"}},
}); err != nil {
t.Fatalf("guarded write with the claim's revision after heartbeats = %v, want it to land", err)
}
}
// RunHeartbeaterRefusesAForeignHolder pins the fence (Heartbeater REFUSALS:
// "an issue another actor holds: a *LeaseConflictError naming the Holder,
// wrapping ErrAlreadyClaimed"), and that the refusal writes nothing.
func RunHeartbeaterRefusesAForeignHolder(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
id := fixture.IssuePrefix + "-foreign"
heartbeaterSeedClaimed(t, ctx, fixture, id)
// Age the holder's lease first, so a heartbeat that ignored the holder
// fence would really CHANGE the row (some engines count only changed rows,
// and the columns hold whole seconds: an unaged row refreshed in the
// claim's second changes nothing and would hide the missing fence).
aged := time.Now().UTC().Add(-time.Minute).Truncate(time.Second)
if err := fixture.Exec(ctx, []SQLStatement{{
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)
_, err := fixture.Heartbeater.Heartbeat(ctx, publicops.HeartbeatRequest{Actor: heartbeaterIntruder, IssueID: id})
if !errors.Is(err, publicops.ErrAlreadyClaimed) {
t.Fatalf("heartbeat by a non-holder = %v, want ErrAlreadyClaimed", err)
}
if errors.Is(err, publicops.ErrLeaseNotHeld) {
t.Fatalf("heartbeat by a non-holder = %v also matches ErrLeaseNotHeld; the two refusals must stay distinct", err)
}
conflict := heartbeaterConflict(t, err)
if conflict.IssueID != id || conflict.Holder != heartbeaterHolder || conflict.Status != types.StatusInProgress {
t.Fatalf("LeaseConflictError = %+v, want {IssueID:%s Holder:%s Status:%s}", conflict, id, heartbeaterHolder, types.StatusInProgress)
}
if got := 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
// heartbeat's message.
func RunHeartbeaterCommitsOnlyItsOwnTables(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
if fixture.CountHistory == nil || fixture.Lifecycle == nil {
t.Skip("HeartbeaterFixture.CountHistory/Lifecycle is nil: this backend has no version-control history to observe")
}
refreshed := fixture.IssuePrefix + "-dirty-refresh"
heartbeaterSeedClaimed(t, ctx, fixture, refreshed)
refused := fixture.IssuePrefix + "-dirty-refused"
heartbeaterSeed(t, ctx, fixture, refused)
rearmed := fixture.IssuePrefix + "-dirty-rearm"
heartbeaterSeed(t, ctx, fixture, rearmed)
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: heartbeaterHolder, IssueID: rearmed,
Patch: publicops.IssuePatch{
Status: publicops.Field[publicops.Status]{Set: true, Value: types.StatusInProgress},
Assignee: publicops.Field[string]{Set: true, Value: heartbeaterHolder},
},
}); err != nil {
t.Fatalf("hand-dole %s: %v", rearmed, err)
}
probe := "heartbeat.dirty-probe." + fixture.IssuePrefix
dirty := fixture.Exec
if fixture.ExecUncommitted != nil {
dirty = fixture.ExecUncommitted
}
if err := dirty(ctx, []SQLStatement{{
Query: "REPLACE INTO config (`key`, value) VALUES (?, ?)", Args: []any{probe, "uncommitted"},
}}); err != nil {
t.Fatalf("dirty the working set: %v", err)
}
defer func() {
_ = dirty(ctx, []SQLStatement{{Query: "DELETE FROM config WHERE `key` = ?", Args: []any{probe}}})
}()
foreignDirty := func(when string) {
t.Helper()
if n := heartbeaterScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM dolt_status WHERE table_name = 'config'"); n == 0 {
t.Fatalf("%s: the other writer's uncommitted config change was committed; a heartbeat commits only its own tables", when)
}
}
history := func() int {
t.Helper()
n, err := fixture.CountHistory(ctx)
if err != nil {
t.Fatalf("CountHistory: %v", err)
}
return n
}
foreignDirty("before any heartbeat")
before := history()
heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: refreshed})
if got := history(); got != before {
t.Fatalf("a refresh moved the version-control history %d -> %d; a refresh makes no commit", before, got)
}
foreignDirty("after a refresh")
if _, err := fixture.Heartbeater.Heartbeat(ctx, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: refused}); err == nil {
t.Fatalf("heartbeat on unclaimed %s succeeded, want a refusal", refused)
}
if got := history(); got != before {
t.Fatalf("a refusal moved the version-control history %d -> %d; a refusal makes no commit", before, got)
}
foreignDirty("after a refusal")
if result := heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: rearmed}); !result.Rearmed {
t.Fatalf("heartbeat on hand-doled %s = %+v, want Rearmed", rearmed, result)
}
if got := history(); got != before+1 {
t.Fatalf("a re-arm moved the version-control history %d -> %d, want exactly one commit", before, got)
}
foreignDirty("after a re-arm")
}
// RunHeartbeaterRefusesAnOrphanedLeaseOnAReleasedIssue and
// ...OnAClosedIssue and ...OnAnIssueSomeoneElseHolds pin the live-claim
// predicate (Heartbeater: "THE LIVE-CLAIM FENCE IS A PREDICATE"): a lease row
// that names the caller but survives on an issue that is open, closed, or
// in_progress under another assignee is refused, never refreshed, and the
// refusal deletes it (Heartbeater: the one write a refusal makes). The row
// is planted raw: it is the state a re-arm racing a release or close leaves.
func RunHeartbeaterRefusesAnOrphanedLeaseOnAReleasedIssue(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
id := fixture.IssuePrefix + "-orphan-open"
heartbeaterSeed(t, ctx, fixture, id)
heartbeaterRefusesAnOrphan(t, ctx, fixture, id, types.StatusOpen, "")
}
func RunHeartbeaterRefusesAnOrphanedLeaseOnAClosedIssue(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
if fixture.Lifecycle == nil {
t.Skip("HeartbeaterFixture.Lifecycle is nil: this backend cannot close the claim")
}
id := fixture.IssuePrefix + "-orphan-closed"
heartbeaterSeedClaimed(t, ctx, fixture, id)
if _, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{Actor: heartbeaterHolder, IssueID: id, Reason: "done"}); err != nil {
t.Fatalf("close %s: %v", id, err)
}
heartbeaterRefusesAnOrphan(t, ctx, fixture, id, types.StatusClosed, "")
}
func RunHeartbeaterRefusesAnOrphanedLeaseOnAnIssueSomeoneElseHolds(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
requireHeartbeaterExec(t, fixture)
if fixture.Lifecycle == nil {
t.Skip("HeartbeaterFixture.Lifecycle is nil: this backend cannot hand-dole a claim")
}
id := fixture.IssuePrefix + "-orphan-moved"
heartbeaterSeed(t, ctx, fixture, id)
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: heartbeaterIntruder, IssueID: id,
Patch: publicops.IssuePatch{
Status: publicops.Field[publicops.Status]{Set: true, Value: types.StatusInProgress},
Assignee: publicops.Field[string]{Set: true, Value: heartbeaterIntruder},
},
}); err != nil {
t.Fatalf("hand-dole %s to %s: %v", id, heartbeaterIntruder, err)
}
heartbeaterRefusesAnOrphan(t, ctx, fixture, id, types.StatusInProgress, heartbeaterIntruder)
}
// heartbeaterRefusesAnOrphan plants a lease row for heartbeaterHolder on id
// (which the holder does not hold), heartbeats as the holder, and asserts the
// refusal and that the row is gone.
func heartbeaterRefusesAnOrphan(t *testing.T, ctx context.Context, fixture HeartbeaterFixture, id string, status types.Status, foreign string) {
t.Helper()
now := time.Now().UTC().Truncate(time.Second)
if err := fixture.Exec(ctx, []SQLStatement{
{Query: "DELETE FROM leases WHERE issue_id = ?", Args: []any{id}},
{
Query: "INSERT INTO leases (issue_id, holder, granted_at, lease_expires_at, heartbeat_at, granted_node) VALUES (?, ?, ?, ?, ?, '')",
Args: []any{id, heartbeaterHolder, now.Add(-time.Minute), now.Add(time.Hour), now.Add(-time.Minute)},
},
}); err != nil {
t.Fatalf("plant an orphaned lease on %s: %v", id, err)
}
_, err := fixture.Heartbeater.Heartbeat(ctx, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
conflict := heartbeaterConflict(t, err)
if foreign != "" {
if !errors.Is(err, publicops.ErrAlreadyClaimed) || conflict.Holder != foreign {
t.Fatalf("heartbeat over an orphaned lease on an issue %s holds = %v (%+v), want ErrAlreadyClaimed naming %s", foreign, err, conflict, foreign)
}
} else if !errors.Is(err, publicops.ErrLeaseNotHeld) || conflict.Holder != "" {
t.Fatalf("heartbeat over an orphaned lease on a %s issue = %v (%+v), want ErrLeaseNotHeld", status, err, conflict)
}
if conflict.IssueID != id || conflict.Status != status || conflict.Ephemeral {
t.Fatalf("LeaseConflictError = %+v, want {IssueID:%s Status:%s Ephemeral:false}", conflict, id, status)
}
if n := heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); n != 0 {
t.Fatalf("lease rows on %s after the refusal = %d, want 0: a refusal deletes the caller's orphaned lease", id, n)
}
// And it stays refused: the next heartbeat finds no row to refresh.
if _, err := fixture.Heartbeater.Heartbeat(ctx, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id}); err == nil {
t.Fatalf("a second heartbeat on %s succeeded after the orphan was refused", id)
}
}
// heartbeaterRequireStoredMatches pins the reported times to the stored row
// (LeaseRenewal: "exactly what the lease row now holds"): lease_expires_at and
// heartbeat_at as stored are the result's, within the columns' one-second
// precision, and the stored expiry is the call's clock plus the store's TTL.
func heartbeaterRequireStoredMatches(t *testing.T, ctx context.Context, fixture HeartbeaterFixture, id string, result publicops.HeartbeatResult, before, after time.Time) {
t.Helper()
window := func(at time.Time) (time.Time, time.Time) { return at.Add(-time.Second), at.Add(time.Second) }
hbLo, hbHi := window(result.HeartbeatAt)
exLo, exHi := window(result.LeaseExpiresAt)
if n := heartbeaterScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM leases WHERE issue_id = ? AND holder = ? AND heartbeat_at BETWEEN ? AND ? AND lease_expires_at BETWEEN ? AND ?",
id, result.Holder, hbLo, hbHi, exLo, exHi); n != 1 {
t.Fatalf("the stored lease row on %s does not hold the reported heartbeat_at %v and lease_expires_at %v (within 1s)",
id, result.HeartbeatAt, result.LeaseExpiresAt)
}
ttlLo, ttlHi := before.Add(storeops.DefaultLeaseTTL), after.Add(storeops.DefaultLeaseTTL)
if n := heartbeaterScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM leases WHERE issue_id = ? AND lease_expires_at BETWEEN ? AND ?",
id, ttlLo, ttlHi); n != 1 {
t.Fatalf("the stored lease_expires_at on %s is not the call's clock plus the lease TTL %v", id, storeops.DefaultLeaseTTL)
}
if !result.HeartbeatAt.Equal(result.HeartbeatAt.Truncate(time.Second)) || !result.LeaseExpiresAt.Equal(result.LeaseExpiresAt.Truncate(time.Second)) {
t.Fatalf("result times %v / %v carry sub-second digits the lease columns cannot hold", result.HeartbeatAt, result.LeaseExpiresAt)
}
}
// RunHeartbeaterRefusesAfterClose, ...AfterRelease, ...AfterReclaim and
// ...AfterStatusMovedOffInProgress pin the in_progress fence through the
// lease-row invariant (Heartbeater: "a lease row exists only while its issue
// is in_progress with that holder as assignee"): each ends the claim one way,
// asserts the lease row went with it, and that the former holder's heartbeat
// is refused with ErrLeaseNotHeld, which also matches ErrNotClaimable.
func RunHeartbeaterRefusesAfterClose(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
if fixture.Lifecycle == nil {
t.Skip("HeartbeaterFixture.Lifecycle is nil: this backend cannot close the claim")
}
heartbeaterRefusesAfter(t, ctx, fixture, "closed", types.StatusClosed, func(id string) error {
_, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{Actor: heartbeaterHolder, IssueID: id, Reason: "done"})
return err
})
}
func RunHeartbeaterRefusesAfterRelease(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
if fixture.Releaser == nil {
t.Skip("HeartbeaterFixture.Releaser is nil: this backend cannot release the claim")
}
heartbeaterRefusesAfter(t, ctx, fixture, "released", types.StatusOpen, func(id string) error {
_, err := fixture.Releaser.Release(ctx, publicops.ReleaseRequest{Actor: heartbeaterHolder, IssueID: id})
return err
})
}
func RunHeartbeaterRefusesAfterReclaim(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
if fixture.LeaseReclaimer == nil || fixture.Exec == nil {
t.Skip("HeartbeaterFixture.LeaseReclaimer/Exec is nil: this backend cannot reclaim the claim")
}
heartbeaterRefusesAfter(t, ctx, fixture, "reclaimed", types.StatusOpen, func(id string) error {
if err := fixture.Exec(ctx, []SQLStatement{{
Query: "UPDATE leases SET lease_expires_at = ? WHERE issue_id = ?",
Args: []any{time.Now().UTC().Add(-time.Hour), id},
}}); err != nil {
return err
}
result, err := fixture.LeaseReclaimer.Reclaim(ctx, publicops.ReclaimRequest{
Actor: heartbeaterReaper, Filter: publicops.ReclaimFilter{IDs: []string{id}},
})
if err == nil && len(result.Reclaimed) != 1 {
t.Fatalf("Reclaimed = %+v, want exactly %s", result.Reclaimed, id)
}
return err
})
}
func RunHeartbeaterRefusesAfterStatusMovedOffInProgress(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
if fixture.Lifecycle == nil {
t.Skip("HeartbeaterFixture.Lifecycle is nil: this backend cannot move the status")
}
heartbeaterRefusesAfter(t, ctx, fixture, "blocked", types.StatusBlocked, func(id string) error {
_, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: heartbeaterHolder, IssueID: id,
Patch: publicops.IssuePatch{Status: publicops.Field[publicops.Status]{Set: true, Value: types.StatusBlocked}},
})
return err
})
}
// RunHeartbeaterRefusesAWisp pins the plane rule (Heartbeater REFUSALS: "a
// wisp ... ErrLeaseNotHeld"): wisps are never leased, so even a wisp the
// caller holds in_progress is refused, and no lease row appears for it.
func RunHeartbeaterRefusesAWisp(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
if fixture.CreateWisp == nil || fixture.QueryScalar == nil {
t.Skip("HeartbeaterFixture.CreateWisp/QueryScalar is nil: this backend cannot seed a wisp")
}
id := fixture.IssuePrefix + "-wisp"
if err := fixture.CreateWisp(ctx, &types.Issue{
ID: id, Title: id, Status: types.StatusInProgress, Assignee: heartbeaterHolder,
Priority: 2, IssueType: types.TypeTask, Ephemeral: true,
}, "seed"); err != nil {
t.Fatalf("seed wisp %s: %v", id, err)
}
_, err := fixture.Heartbeater.Heartbeat(ctx, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
if !errors.Is(err, publicops.ErrLeaseNotHeld) || !errors.Is(err, publicops.ErrNotClaimable) {
t.Fatalf("heartbeat on a wisp = %v, want ErrLeaseNotHeld matching ErrNotClaimable", err)
}
if !strings.Contains(err.Error(), "ephemeral") {
t.Fatalf("heartbeat on a wisp = %q, want the refusal to say the issue is ephemeral", err)
}
if conflict := heartbeaterConflict(t, err); conflict.IssueID != id || conflict.Holder != "" {
t.Fatalf("LeaseConflictError = %+v, want {IssueID:%s Holder:\"\"}", conflict, id)
}
if n := heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); n != 0 {
t.Fatalf("lease rows for wisp %s = %d, want 0: wisps are never leased", id, n)
}
}
// RunHeartbeaterRearmsAHandDoledClaim pins the self-heal (HeartbeatResult.
// Rearmed): an issue put in_progress with the caller as assignee by a generic
// update holds no lease row, and the holder's heartbeat grants one rather than
// refusing. The re-arm is recorded as a mutation (Heartbeater: "A RE-ARM IS
// RECORDED AS A MUTATION"): it remints the revision, which is what makes it
// collide with a racing release or close, and records a lease_rearmed event;
// the refresh after it does neither.
func RunHeartbeaterRearmsAHandDoledClaim(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
if fixture.Lifecycle == nil || fixture.QueryScalar == nil {
t.Skip("HeartbeaterFixture.Lifecycle/QueryScalar is nil: this backend cannot hand-dole a claim")
}
id := fixture.IssuePrefix + "-doled"
heartbeaterSeed(t, ctx, fixture, id)
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: heartbeaterHolder, IssueID: id,
Patch: publicops.IssuePatch{
Status: publicops.Field[publicops.Status]{Set: true, Value: types.StatusInProgress},
Assignee: publicops.Field[string]{Set: true, Value: heartbeaterHolder},
},
}); err != nil {
t.Fatalf("hand-dole %s: %v", id, err)
}
if n := heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); n != 0 {
t.Fatalf("lease rows after a generic update = %d, want 0: the case needs a claim with no lease", n)
}
revision := heartbeaterScalar[int64](t, ctx, fixture, "SELECT row_lock FROM issues WHERE id = ?", id)
before := time.Now().UTC().Add(-time.Second)
result := heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
after := time.Now().UTC().Add(time.Second)
if !result.Rearmed || result.Holder != heartbeaterHolder {
t.Fatalf("result = %+v, want Rearmed:true Holder:%s", result, heartbeaterHolder)
}
heartbeaterRequireStoredMatches(t, ctx, fixture, id, result, before, after)
if n := heartbeaterScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM leases WHERE issue_id = ? AND holder = ? AND lease_expires_at > ?",
id, heartbeaterHolder, time.Now().UTC()); n != 1 {
t.Fatal("the re-armed heartbeat left no live lease row for the holder")
}
rearmed := heartbeaterScalar[int64](t, ctx, fixture, "SELECT row_lock FROM issues WHERE id = ?", id)
if rearmed == revision {
t.Fatalf("row_lock stayed %d across a re-arming heartbeat; a re-arm remints it so a racing release or close collides with it", revision)
}
rearmEvents := func() int {
return heartbeaterScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM events WHERE issue_id = ? AND event_type = ?", id, string(types.EventLeaseRearmed))
}
if n := rearmEvents(); n != 1 {
t.Fatalf("lease_rearmed events on %s after a re-arm = %d, want 1: a re-arm is recorded as a mutation", id, n)
}
// The next heartbeat refreshes the lease it just granted: no re-arm, and
// no revision change.
if again := heartbeat(t, ctx, fixture.Heartbeater, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id}); again.Rearmed {
t.Fatalf("second heartbeat after the re-arm = %+v, want Rearmed:false", again)
}
if got := heartbeaterScalar[int64](t, ctx, fixture, "SELECT row_lock FROM issues WHERE id = ?", id); got != rearmed {
t.Fatalf("row_lock moved from %d to %d across a refresh after the re-arm", rearmed, got)
}
if n := rearmEvents(); n != 1 {
t.Fatalf("lease_rearmed events on %s after a refresh = %d, want still 1: a refresh records nothing", id, n)
}
}
// RunHeartbeaterAnswersNotFoundForAnAbsentID pins Heartbeater REFUSALS: "an
// IssueID that names no row on either plane: ErrNotFound".
func RunHeartbeaterAnswersNotFoundForAnAbsentID(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
_, err := fixture.Heartbeater.Heartbeat(ctx, publicops.HeartbeatRequest{
Actor: heartbeaterHolder, IssueID: fixture.IssuePrefix + "-absent",
})
if !errors.Is(err, publicops.ErrNotFound) {
t.Fatalf("heartbeat on an absent id = %v, want ErrNotFound", err)
}
}
// RunHeartbeaterRefusesABlankOrOverLongActor pins the request rules
// (HeartbeatRequest.Actor, Heartbeater REFUSALS): each is a
// *HeartbeatFieldError naming its field, matching ErrValidation.
func RunHeartbeaterRefusesABlankOrOverLongActor(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
id := fixture.IssuePrefix + "-refusals"
for _, test := range []struct {
name string
request publicops.HeartbeatRequest
field string
}{
{"an empty actor", publicops.HeartbeatRequest{IssueID: id}, publicops.HeartbeatFieldActor},
{"a blank actor", publicops.HeartbeatRequest{Actor: " \t", IssueID: id}, publicops.HeartbeatFieldActor},
{"an over-long actor", publicops.HeartbeatRequest{Actor: strings.Repeat("a", types.MaxFieldLen+1), IssueID: id}, publicops.HeartbeatFieldActor},
{"an empty id", publicops.HeartbeatRequest{Actor: heartbeaterHolder}, publicops.HeartbeatFieldIssueID},
} {
t.Run(test.name, func(t *testing.T) {
_, err := fixture.Heartbeater.Heartbeat(ctx, test.request)
if !errors.Is(err, publicops.ErrValidation) {
t.Fatalf("Heartbeat(%s) = %v, want ErrValidation", test.name, err)
}
var field *publicops.HeartbeatFieldError
if !errors.As(err, &field) || field.Field != test.field {
t.Fatalf("Heartbeat(%s) = %v, want a *HeartbeatFieldError naming %q", test.name, err, test.field)
}
})
}
}
// RunHeartbeaterDoesNotMutateTheRequest pins the role's "never mutate
// caller-owned request values".
func RunHeartbeaterDoesNotMutateTheRequest(t *testing.T, ctx context.Context, fixture HeartbeaterFixture) {
t.Helper()
id := fixture.IssuePrefix + "-nomutate"
heartbeaterSeedClaimed(t, ctx, fixture, id)
request := publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id}
want := request
heartbeat(t, ctx, fixture.Heartbeater, request)
if request != want {
t.Fatalf("request after Heartbeat = %+v, want %+v", request, want)
}
}
// heartbeaterRefusesAfter seeds and claims one issue, ends the claim with end,
// and asserts the invariant and the refusal.
func heartbeaterRefusesAfter(t *testing.T, ctx context.Context, fixture HeartbeaterFixture, suffix string, status types.Status, end func(id string) error) {
t.Helper()
if fixture.QueryScalar == nil {
t.Skip("HeartbeaterFixture.QueryScalar is nil: this backend cannot read the lease row")
}
id := fixture.IssuePrefix + "-after-" + suffix
heartbeaterSeedClaimed(t, ctx, fixture, id)
if n := heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); n != 1 {
t.Fatalf("lease rows for claimed %s = %d, want 1", id, n)
}
if err := end(id); err != nil {
t.Fatalf("end the claim on %s (%s): %v", id, suffix, err)
}
if n := heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); n != 0 {
t.Fatalf("lease rows for %s %s = %d, want 0: the path that ended the claim left its lease row", suffix, id, n)
}
_, err := fixture.Heartbeater.Heartbeat(ctx, publicops.HeartbeatRequest{Actor: heartbeaterHolder, IssueID: id})
if !errors.Is(err, publicops.ErrLeaseNotHeld) || !errors.Is(err, publicops.ErrNotClaimable) {
t.Fatalf("heartbeat after the claim was %s = %v, want ErrLeaseNotHeld matching ErrNotClaimable", suffix, err)
}
if errors.Is(err, publicops.ErrAlreadyClaimed) {
t.Fatalf("heartbeat after the claim was %s = %v also matches ErrAlreadyClaimed", suffix, err)
}
conflict := heartbeaterConflict(t, err)
if conflict.IssueID != id || conflict.Holder != "" || conflict.Status != status {
t.Fatalf("LeaseConflictError = %+v, want {IssueID:%s Holder:\"\" Status:%s}", conflict, id, status)
}
if n := heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); n != 0 {
t.Fatalf("a refused heartbeat left %d lease row(s) for %s", n, id)
}
}
// heartbeaterRowSnapshot is every durable trace a heartbeat must not leave.
// A field the backend cannot observe holds -1.
type heartbeaterRowSnapshot struct {
RowLock int64
CurrentRevision int64
UpdatedAt string
Events int
JournalMaxSeq int64
IssueVersions int
History int
}
func heartbeaterSnapshot(t *testing.T, ctx context.Context, fixture HeartbeaterFixture, id string) heartbeaterRowSnapshot {
t.Helper()
snap := heartbeaterRowSnapshot{
RowLock: heartbeaterScalar[int64](t, ctx, fixture, "SELECT row_lock FROM issues WHERE id = ?", id),
CurrentRevision: heartbeaterScalar[int64](t, ctx, fixture, "SELECT current_revision FROM issues WHERE id = ?", id),
UpdatedAt: heartbeaterScalar[string](t, ctx, fixture, "SELECT CAST(updated_at AS CHAR) FROM issues WHERE id = ?", id),
Events: heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM events WHERE issue_id = ?", id),
JournalMaxSeq: -1,
IssueVersions: -1,
History: -1,
}
if fixture.SetJournalEnabled != nil {
snap.JournalMaxSeq = heartbeaterScalar[int64](t, ctx, fixture, "SELECT COALESCE(MAX(seq), 0) FROM bd_events_journal")
}
if fixture.SetVersionedHistoryEnabled != nil {
snap.IssueVersions = heartbeaterScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM issue_versions WHERE issue_id = ?", id)
}
if fixture.CountHistory != nil {
n, err := fixture.CountHistory(ctx)
if err != nil {
t.Fatalf("CountHistory: %v", err)
}
snap.History = n
}
return snap
}
func heartbeaterFired(t *testing.T, ctx context.Context, fixture HeartbeaterFixture, id string) int {
t.Helper()
if fixture.HookedHeartbeater == nil || fixture.FiredUpdates == nil {
return 0
}
ids, err := fixture.FiredUpdates(ctx)
if err != nil {
t.Fatalf("FiredUpdates: %v", err)
}
n := 0
for _, fired := range ids {
if fired == id {
n++
}
}
return n
}
func requireHeartbeaterExec(t *testing.T, fixture HeartbeaterFixture) {
t.Helper()
if fixture.Exec == nil || fixture.QueryScalar == nil {
t.Skip("HeartbeaterFixture.Exec/QueryScalar is nil: this backend cannot read or age a lease row")
}
}
func heartbeaterSeed(t *testing.T, ctx context.Context, fixture HeartbeaterFixture, id string) {
t.Helper()
if err := fixture.CreateIssue(ctx, &types.Issue{
ID: id, Title: id, Status: types.StatusOpen, Priority: 2, IssueType: types.TypeTask,
}, "seed"); err != nil {
t.Fatalf("seed %s: %v", id, err)
}
}
// heartbeaterSeedClaimed creates id and claims it as heartbeaterHolder through
// the leg's Claimer, answering the claim's row version.
func heartbeaterSeedClaimed(t *testing.T, ctx context.Context, fixture HeartbeaterFixture, id string) int64 {
t.Helper()
if fixture.Claimer == nil {
t.Skip("HeartbeaterFixture.Claimer is nil: this backend cannot take the claim a heartbeat refreshes")
}
heartbeaterSeed(t, ctx, fixture, id)
claimed, err := fixture.Claimer.Claim(ctx, publicops.ClaimRequest{Actor: heartbeaterHolder, IssueID: id})
if err != nil {
t.Fatalf("claim %s as %s: %v", id, heartbeaterHolder, err)
}
if claimed.Issue == nil {
t.Fatalf("claim %s answered no issue", id)
}
return claimed.Issue.RowVersion
}
func heartbeat(t *testing.T, ctx context.Context, surface publicops.Heartbeater, request publicops.HeartbeatRequest) publicops.HeartbeatResult {
t.Helper()
result, err := surface.Heartbeat(ctx, request)
if err != nil {
t.Fatalf("Heartbeat(%+v): %v", request, err)
}
return result
}
func heartbeaterConflict(t *testing.T, err error) *publicops.LeaseConflictError {
t.Helper()
var conflict *publicops.LeaseConflictError
if !errors.As(err, &conflict) {
t.Fatalf("refusal %v (%T) is not a *LeaseConflictError", err, err)
}
return conflict
}
func heartbeaterScalar[T any](t *testing.T, ctx context.Context, fixture HeartbeaterFixture, query string, args ...any) T {
t.Helper()
var value T
if err := fixture.QueryScalar(ctx, query, args, &value); err != nil {
t.Fatalf("%s %v: %v", query, args, err)
}
return value
}
func heartbeaterAbs(d time.Duration) time.Duration {
if d < 0 {
return -d
}
return d
}

View file

@ -0,0 +1,625 @@
package conformance
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"runtime"
"slices"
"sort"
"strings"
"testing"
"time"
"github.com/steveyegge/beads/internal/hooks"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// This file holds the contract every implementation of publicops.LeaseReclaimer
// must satisfy. Each case asserts what issueops/leasereclaimer.go PROMISES,
// cited by symbol.
//
// FOUR LEGS, ONE BODY. dolt, embedded dolt and the unit-of-work provider all
// reach internal/storage/issueops.ExecuteReclaimInTx, and the http leg reaches
// the same body on the far side of POST /v0/beads/issues:reclaim. So a per-leg
// failure here is a wrapper's failure — a lost scope, a revision that never
// reached the caller, a refusal that stopped matching errors.Is — and the
// cases are written to catch exactly those.
//
// EVERY SWEEP HERE IS SCOPED. The legs share one database per suite with every
// other role's cases, and an UNSCOPED reclaim would revert whatever stale lease
// another case left behind. Every call below names its ids, or an assignee or
// label this case alone uses, so a case can never reach outside what it seeded.
// The workspace-wide form is the same SQL with the scope clause absent, which
// sqlbuild.ReclaimScopeSQL's own tests pin.
//
// STALENESS IS MANUFACTURED, NOT WAITED FOR. The role refuses a negative
// OlderThan (the raw method's -time.Hour trick is exactly what it rules out),
// so a case claims through the leg's real Claimer — which writes the lease row
// every reclaim reads — and then moves that row's lease_expires_at into the
// past through Exec.
type LeaseReclaimerFixture struct {
// IssuePrefix namespaces the ids each assertion seeds, so several of them
// can share one database.
IssuePrefix string
// LeaseReclaimer is the surface under test.
LeaseReclaimer publicops.LeaseReclaimer
// CreateIssue seeds a durable issue in the issues plane.
CreateIssue func(context.Context, *types.Issue, string) error
// Claimer takes the claim, and with it the lease row, a reclaim reverts. It
// is the leg's own role rather than a raw insert so the lease is the shape
// a real claim leaves, granted_node included.
Claimer publicops.Claimer
// Lifecycle performs the guarded write the revision case races against the
// reclaim. A nil Lifecycle SKIPS that case loudly.
Lifecycle publicops.Lifecycle
// Exec runs raw statements against the backing database: the cases use it
// to age a lease and to attach labels. A nil Exec SKIPS every case that
// needs a stale lease, which is nearly all of them, so every leg supplies
// one.
Exec func(ctx context.Context, statements []SQLStatement) error
// QueryScalar runs a single-row query and scans it, so the post-state is
// read RAW rather than through the role being tested.
QueryScalar func(context.Context, string, []any, ...any) error
// HookedLeaseReclaimer is the same role taken off the leg's HOOK-FIRING
// chain (storage.HookFiringStore on the store legs and the http leg,
// uow.NewNotifyingProvider on the unit-of-work leg), built over the runner
// FiredUpdates reads. Nil, with FiredUpdates, SKIPS the hook case loudly.
HookedLeaseReclaimer publicops.LeaseReclaimer
// FiredUpdates reports, in firing order, the issue id of every on_update
// the hooked chain ran so far. It must not return before the hooks it is
// asked about have finished.
FiredUpdates func(context.Context) ([]string, error)
}
const (
leaseReclaimerReaper = "reaper"
leaseReclaimerHolder = "lr-holder"
)
// RunLeaseReclaimerRevertsAStaleLease pins the post-state the role names
// (issueops/leasereclaimer.go, LeaseReclaimer: "each reclaimed row moves
// in_progress -> open and the assignee is cleared") and the three members of
// the ReclaimedLease it reports, each READ RAW.
func RunLeaseReclaimerRevertsAStaleLease(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
id := fixture.IssuePrefix + "-revert"
leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, id)
result := leaseReclaim(t, ctx, fixture, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{id}},
})
if len(result.Reclaimed) != 1 {
t.Fatalf("Reclaimed = %+v, want exactly %s", result.Reclaimed, id)
}
got := result.Reclaimed[0]
if got.ID != id || got.PreviousOwner != leaseReclaimerHolder {
t.Fatalf("Reclaimed[0] = %+v, want {ID:%s PreviousOwner:%s}", got, id, leaseReclaimerHolder)
}
if status := leaseReclaimerScalar[string](t, ctx, fixture, "SELECT status FROM issues WHERE id = ?", id); status != string(types.StatusOpen) {
t.Fatalf("status after reclaim = %q, want %q", status, types.StatusOpen)
}
if held := leaseReclaimerScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM issues WHERE id = ? AND (COALESCE(assignee, '') <> '' OR started_at IS NOT NULL)", id); held != 0 {
t.Fatal("reclaim left the assignee or started_at set; the row is still held by a dead worker")
}
if leases := leaseReclaimerScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); leases != 0 {
t.Fatalf("lease rows after reclaim = %d, want 0", leases)
}
stored := leaseReclaimerScalar[int64](t, ctx, fixture, "SELECT row_lock FROM issues WHERE id = ?", id)
if got.Revision != types.RevisionToken(stored) {
t.Fatalf("Reclaimed[0].Revision = %q, want the row's own token %q", got.Revision, types.RevisionToken(stored))
}
}
// RunLeaseReclaimerMintsARevisionThatFencesTheFormerHolder is the reason the
// revision is minted at all (LeaseReclaimer: "a racing holder's guarded write
// fails with ErrVersionMismatch"). A worker that lost its lease and wakes up
// holding the token its claim handed it must NOT be able to land a guarded
// write over the issue another worker may already have taken; the token the
// reclaim reported, and only it, lands.
func RunLeaseReclaimerMintsARevisionThatFencesTheFormerHolder(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
if fixture.Lifecycle == nil {
t.Skip("LeaseReclaimerFixture.Lifecycle is nil: this backend cannot race a guarded write against the reclaim")
}
id := fixture.IssuePrefix + "-fence"
claimed := leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, id)[id]
result := leaseReclaim(t, ctx, fixture, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{id}},
})
if len(result.Reclaimed) != 1 {
t.Fatalf("Reclaimed = %+v, want exactly %s", result.Reclaimed, id)
}
minted, err := types.ParseRevisionToken(result.Reclaimed[0].Revision)
if err != nil {
t.Fatalf("Reclaimed[0].Revision %q is not a revision token: %v", result.Reclaimed[0].Revision, err)
}
if minted == claimed {
t.Fatalf("reclaim reported revision %d, the claim's own token: nothing was minted", minted)
}
stale := claimed
_, err = fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: leaseReclaimerHolder, IssueID: id, ExpectedVersion: &stale,
Patch: publicops.IssuePatch{Notes: publicops.Field[string]{Set: true, Value: "late write"}},
})
if !errors.Is(err, publicops.ErrVersionMismatch) {
t.Fatalf("guarded write with the pre-reclaim token = %v, want ErrVersionMismatch", err)
}
fresh := minted
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: leaseReclaimerReaper, IssueID: id, ExpectedVersion: &fresh,
Patch: publicops.IssuePatch{Notes: publicops.Field[string]{Set: true, Value: "after reclaim"}},
}); err != nil {
t.Fatalf("guarded write with the token the reclaim reported = %v, want it to land", err)
}
}
// RunLeaseReclaimerLeavesALiveLeaseAlone pins staleness as the gate: a lease
// that has not expired is not eligible, even when its id is named, and naming
// it is not an error (ReclaimRequest.Filter: "FILTER.IDS IS NOT AN ERROR WHEN
// IT NAMES A NON-STALE OR UNKNOWN ISSUE").
func RunLeaseReclaimerLeavesALiveLeaseAlone(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
id := fixture.IssuePrefix + "-live"
leaseReclaimerSeedClaimed(t, ctx, fixture, leaseReclaimerHolder, id)
result := leaseReclaim(t, ctx, fixture, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{id}},
})
if len(result.Reclaimed) != 0 {
t.Fatalf("Reclaimed = %+v, want nothing: the lease has not expired", result.Reclaimed)
}
leaseReclaimerRequireHeld(t, ctx, fixture, id)
}
// RunLeaseReclaimerHonorsTheGraceWindow pins ReclaimRequest.OlderThan: a lease
// expired less than OlderThan ago is left alone, and the same lease is
// reclaimed once the window is narrower than its age.
func RunLeaseReclaimerHonorsTheGraceWindow(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
id := fixture.IssuePrefix + "-grace"
leaseReclaimerSeedClaimed(t, ctx, fixture, leaseReclaimerHolder, id)
leaseReclaimerAge(t, ctx, fixture, 10*time.Minute, id)
request := publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
OlderThan: time.Hour,
Filter: publicops.ReclaimFilter{IDs: []string{id}},
}
if result := leaseReclaim(t, ctx, fixture, request); len(result.Reclaimed) != 0 {
t.Fatalf("OlderThan 1h over a lease 10m stale: Reclaimed = %+v, want nothing", result.Reclaimed)
}
leaseReclaimerRequireHeld(t, ctx, fixture, id)
request.OlderThan = time.Minute
if got := leaseReclaimerIDs(leaseReclaim(t, ctx, fixture, request)); !slices.Equal(got, []string{id}) {
t.Fatalf("OlderThan 1m over a lease 10m stale: Reclaimed = %v, want [%s]", got, id)
}
}
// RunLeaseReclaimerScopesToTheNamedIDs pins the IDs scope from both sides: an
// id that is not named is never reverted though it is stale, and an id that is
// named but absent or live is simply missing from Reclaimed — the call does
// not fail and does not report it.
func RunLeaseReclaimerScopesToTheNamedIDs(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
named := fixture.IssuePrefix + "-scope-named"
unnamed := fixture.IssuePrefix + "-scope-unnamed"
live := fixture.IssuePrefix + "-scope-live"
ghost := fixture.IssuePrefix + "-scope-ghost"
leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, named, unnamed)
leaseReclaimerSeedClaimed(t, ctx, fixture, leaseReclaimerHolder, live)
result := leaseReclaim(t, ctx, fixture, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{ghost, live, named}},
})
if got := leaseReclaimerIDs(result); !slices.Equal(got, []string{named}) {
t.Fatalf("Reclaimed = %v, want [%s]: only the named stale lease", got, named)
}
leaseReclaimerRequireHeld(t, ctx, fixture, unnamed)
leaseReclaimerRequireHeld(t, ctx, fixture, live)
}
// RunLeaseReclaimerAnswersAnAbsentIDWithAnEmptyResult pins the empty answer:
// a sweep scoped only to ids that name no row is not a refusal, and its
// Reclaimed is empty and NON-NIL (ReclaimResult.Reclaimed: "Never nil for a
// successful call").
func RunLeaseReclaimerAnswersAnAbsentIDWithAnEmptyResult(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
result, err := fixture.LeaseReclaimer.Reclaim(ctx, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{fixture.IssuePrefix + "-absent-a", fixture.IssuePrefix + "-absent-b"}},
})
if err != nil {
t.Fatalf("Reclaim scoped to absent ids = %v, want an empty answer", err)
}
if result.Reclaimed == nil {
t.Fatal("Reclaimed is nil; the role promises an empty, non-nil slice")
}
if len(result.Reclaimed) != 0 {
t.Fatalf("Reclaimed = %+v, want nothing", result.Reclaimed)
}
}
// RunLeaseReclaimerScopesToAssigneesAndLabels re-homes the raw method's scope
// cases (testReclaimScoped) onto the role: assignee, label (AND), label-any
// (OR) and exclude-label each narrow the sweep and never widen it.
func RunLeaseReclaimerScopesToAssigneesAndLabels(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
p := fixture.IssuePrefix
a1, a2, b1, c1 := p+"-lbl-a1", p+"-lbl-a2", p+"-lbl-b1", p+"-lbl-c1"
laneA, laneB, opus := p+"-lane-a", p+"-lane-b", p+"-tier-opus"
workerA, workerB, workerC := p+"-wa", p+"-wb", p+"-wc"
leaseReclaimerSeedStale(t, ctx, fixture, workerA, a1, a2)
leaseReclaimerSeedStale(t, ctx, fixture, workerB, b1)
leaseReclaimerSeedStale(t, ctx, fixture, workerC, c1)
leaseReclaimerLabel(t, ctx, fixture, a1, laneA)
leaseReclaimerLabel(t, ctx, fixture, a2, laneA)
leaseReclaimerLabel(t, ctx, fixture, a2, opus)
leaseReclaimerLabel(t, ctx, fixture, b1, laneB)
reclaim := func(filter publicops.ReclaimFilter) []string {
t.Helper()
return leaseReclaimerIDs(leaseReclaim(t, ctx, fixture, publicops.ReclaimRequest{Actor: leaseReclaimerReaper, Filter: filter}))
}
if got := reclaim(publicops.ReclaimFilter{Labels: []string{laneB}}); !slices.Equal(got, []string{b1}) {
t.Fatalf("reclaim(labels %s) = %v, want [%s]", laneB, got, b1)
}
if got := reclaim(publicops.ReclaimFilter{Assignees: []string{workerC}}); !slices.Equal(got, []string{c1}) {
t.Fatalf("reclaim(assignees %s) = %v, want [%s]", workerC, got, c1)
}
if got := reclaim(publicops.ReclaimFilter{Labels: []string{laneA}, ExcludeLabels: []string{opus}}); !slices.Equal(got, []string{a1}) {
t.Fatalf("reclaim(labels %s, exclude %s) = %v, want [%s]", laneA, opus, got, a1)
}
leaseReclaimerRequireHeld(t, ctx, fixture, a2)
if got := reclaim(publicops.ReclaimFilter{LabelsAny: []string{p + "-lane-z", opus}}); !slices.Equal(got, []string{a2}) {
t.Fatalf("reclaim(labels-any lane-z,%s) = %v, want [%s]", opus, got, a2)
}
}
// RunLeaseReclaimerAttributesTheRecoveryEvent pins ReclaimRequest.Actor: the
// recovery event each reverted row records names the actor who ran the sweep,
// with the lease's former holder beside it.
func RunLeaseReclaimerAttributesTheRecoveryEvent(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
id := fixture.IssuePrefix + "-event"
leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, id)
leaseReclaim(t, ctx, fixture, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{id}},
})
if n := leaseReclaimerScalar[int](t, ctx, fixture,
"SELECT COUNT(*) FROM events WHERE issue_id = ? AND event_type = ? AND actor = ? AND old_value = ?",
id, string(types.EventLeaseReclaimed), leaseReclaimerReaper, leaseReclaimerHolder); n != 1 {
t.Fatalf("lease_reclaimed events by %s naming %s = %d, want 1", leaseReclaimerReaper, leaseReclaimerHolder, n)
}
}
// RunLeaseReclaimerFiresOnUpdateOncePerReclaimedRow pins the hook the role
// names (LeaseReclaimer: "ITS HOOK IS on_update, once per reverted row"): each
// reverted row fires on_update exactly once, and a row the sweep did not
// revert — named but live — fires nothing.
func RunLeaseReclaimerFiresOnUpdateOncePerReclaimedRow(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
if fixture.HookedLeaseReclaimer == nil || fixture.FiredUpdates == nil {
t.Skip("LeaseReclaimerFixture.HookedLeaseReclaimer/FiredUpdates is nil: this backend cannot observe its hooks")
}
first := fixture.IssuePrefix + "-hook-a"
second := fixture.IssuePrefix + "-hook-b"
live := fixture.IssuePrefix + "-hook-live"
leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, first, second)
leaseReclaimerSeedClaimed(t, ctx, fixture, leaseReclaimerHolder, live)
before, err := fixture.FiredUpdates(ctx)
if err != nil {
t.Fatalf("FiredUpdates before: %v", err)
}
result, err := fixture.HookedLeaseReclaimer.Reclaim(ctx, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{first, second, live}},
})
if err != nil {
t.Fatalf("hooked Reclaim: %v", err)
}
if got := leaseReclaimerIDs(result); !slices.Equal(got, []string{first, second}) {
t.Fatalf("Reclaimed = %v, want [%s %s]", got, first, second)
}
after, err := fixture.FiredUpdates(ctx)
if err != nil {
t.Fatalf("FiredUpdates after: %v", err)
}
fired := map[string]int{}
for _, id := range after[len(before):] {
fired[id]++
}
for _, id := range []string{first, second} {
if fired[id] != 1 {
t.Fatalf("on_update fired %d time(s) for %s, want exactly 1 (fired: %v)", fired[id], id, after[len(before):])
}
}
if fired[live] != 0 {
t.Fatalf("on_update fired for %s, which the sweep did not revert", live)
}
}
// RunLeaseReclaimerRefusesAMalformedRequest pins every refusal the role lists,
// each as ErrValidation (the cap as *TooManyReclaimIDsError), and that a
// refusal changes nothing: the stale lease every request names survives all of
// them.
func RunLeaseReclaimerRefusesAMalformedRequest(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
id := fixture.IssuePrefix + "-malformed"
leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, id)
tooMany := make([]string, publicops.MaxReclaimIDs+1)
for i := range tooMany {
tooMany[i] = id
}
for _, test := range []struct {
name string
request publicops.ReclaimRequest
tooMany bool
}{
{"an empty actor", publicops.ReclaimRequest{Filter: publicops.ReclaimFilter{IDs: []string{id}}}, false},
// One past the column every reverted row's recovery event records it
// in: a typed refusal before the sweep, never the backend's own error
// from the first row it would have reverted.
{"an over-long actor", publicops.ReclaimRequest{Actor: strings.Repeat("r", types.MaxFieldLen+1),
Filter: publicops.ReclaimFilter{IDs: []string{id}}}, false},
{"a negative grace window", publicops.ReclaimRequest{Actor: leaseReclaimerReaper, OlderThan: -time.Second,
Filter: publicops.ReclaimFilter{IDs: []string{id}}}, false},
{"a blank scoped id", publicops.ReclaimRequest{Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: []string{id, ""}}}, false},
{"more ids than the cap", publicops.ReclaimRequest{Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: tooMany}}, true},
} {
_, err := fixture.LeaseReclaimer.Reclaim(ctx, test.request)
if !errors.Is(err, publicops.ErrValidation) {
t.Fatalf("%s: Reclaim error = %v, want ErrValidation", test.name, err)
}
if test.tooMany {
var capErr *publicops.TooManyReclaimIDsError
if !errors.As(err, &capErr) || capErr.Requested != len(tooMany) || capErr.Cap != publicops.MaxReclaimIDs {
t.Fatalf("%s: Reclaim error = %v, want *TooManyReclaimIDsError{Requested:%d Cap:%d}",
test.name, err, len(tooMany), publicops.MaxReclaimIDs)
}
}
leaseReclaimerRequireHeld(t, ctx, fixture, id)
}
}
// RunLeaseReclaimerRefusesABlankScopeEntry pins the blank-entry refusal on
// the scopes that are not ids: an empty or all-blank assignee or label is
// ErrValidation as a *ReclaimFieldError naming its field, and changes
// nothing — the stale lease every request names survives.
func RunLeaseReclaimerRefusesABlankScopeEntry(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
id := fixture.IssuePrefix + "-blankscope"
leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, id)
for _, test := range []struct {
field string
filter publicops.ReclaimFilter
}{
{publicops.ReclaimFieldAssignees, publicops.ReclaimFilter{IDs: []string{id}, Assignees: []string{leaseReclaimerHolder, " "}}},
{publicops.ReclaimFieldLabels, publicops.ReclaimFilter{IDs: []string{id}, Labels: []string{""}}},
{publicops.ReclaimFieldLabelsAny, publicops.ReclaimFilter{IDs: []string{id}, LabelsAny: []string{"\t"}}},
{publicops.ReclaimFieldExcludeLabels, publicops.ReclaimFilter{IDs: []string{id}, ExcludeLabels: []string{"x", " "}}},
} {
_, err := fixture.LeaseReclaimer.Reclaim(ctx, publicops.ReclaimRequest{Actor: leaseReclaimerReaper, Filter: test.filter})
var fieldErr *publicops.ReclaimFieldError
if !errors.Is(err, publicops.ErrValidation) || !errors.As(err, &fieldErr) || fieldErr.Field != test.field {
t.Fatalf("blank %s entry: Reclaim error = %v, want a *ReclaimFieldError naming %s", test.field, err, test.field)
}
leaseReclaimerRequireHeld(t, ctx, fixture, id)
}
}
// RunLeaseReclaimerAcceptsExactlyTheCap pins the cap's boundary: MaxReclaimIDs
// entries is a request, one more is a refusal (the case above).
func RunLeaseReclaimerAcceptsExactlyTheCap(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
ids := make([]string, publicops.MaxReclaimIDs)
for i := range ids {
ids[i] = fmt.Sprintf("%s-cap-%04d", fixture.IssuePrefix, i)
}
result, err := fixture.LeaseReclaimer.Reclaim(ctx, publicops.ReclaimRequest{
Actor: leaseReclaimerReaper, Filter: publicops.ReclaimFilter{IDs: ids},
})
if err != nil {
t.Fatalf("Reclaim with exactly MaxReclaimIDs ids = %v, want an answer", err)
}
if len(result.Reclaimed) != 0 {
t.Fatalf("Reclaimed = %+v, want nothing: none of the ids exist", result.Reclaimed)
}
}
// RunLeaseReclaimerDoesNotMutateTheCallerRequest pins the role's "never mutate
// caller-owned request values": the scope slices come back as they were sent.
func RunLeaseReclaimerDoesNotMutateTheCallerRequest(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture) {
t.Helper()
requireLeaseReclaimerExec(t, fixture)
id := fixture.IssuePrefix + "-nomut"
leaseReclaimerSeedStale(t, ctx, fixture, leaseReclaimerHolder, id)
ids := []string{fixture.IssuePrefix + "-nomut-ghost", id}
assignees := []string{leaseReclaimerHolder}
request := publicops.ReclaimRequest{
Actor: leaseReclaimerReaper,
Filter: publicops.ReclaimFilter{IDs: ids, Assignees: assignees},
}
leaseReclaim(t, ctx, fixture, request)
if !slices.Equal(ids, []string{fixture.IssuePrefix + "-nomut-ghost", id}) || !slices.Equal(assignees, []string{leaseReclaimerHolder}) {
t.Fatalf("Reclaim rewrote the caller's scope: ids=%v assignees=%v", ids, assignees)
}
}
// NewUpdateHookLog plants an on_update script that appends the id of every
// issue it fires for, and returns the runner a hook-firing chain is built over
// plus a reader for LeaseReclaimerFixture.FiredUpdates. The reader waits for
// in-flight hooks before reading, so it answers for every hook already fired.
//
// It answers (nil, nil) where a shell hook cannot run, so a fixture built from
// it leaves the hook case to skip rather than fail.
func NewUpdateHookLog(t *testing.T) (*hooks.Runner, func(context.Context) ([]string, error)) {
t.Helper()
if runtime.GOOS == "windows" {
return nil, nil
}
dir := t.TempDir()
log := filepath.Join(t.TempDir(), "on_update.log")
script := "#!/bin/sh\necho \"$1\" >> " + log + "\n"
if err := os.WriteFile(filepath.Join(dir, "on_update"), []byte(script), 0o755); err != nil { //nolint:gosec // G306: a hook must be executable to run at all
t.Fatalf("plant the on_update hook: %v", err)
}
runner := hooks.NewRunner(dir)
return runner, func(context.Context) ([]string, error) {
if !runner.Wait(30 * time.Second) {
return nil, errors.New("on_update hooks still running after 30s")
}
data, err := os.ReadFile(log) // #nosec G304 -- this helper's own temp file
if errors.Is(err, os.ErrNotExist) {
return []string{}, nil
}
if err != nil {
return nil, err
}
var ids []string
for _, line := range strings.Split(strings.TrimSpace(string(data)), "\n") {
if line = strings.TrimSpace(line); line != "" {
ids = append(ids, line)
}
}
return ids, nil
}
}
func requireLeaseReclaimerExec(t *testing.T, fixture LeaseReclaimerFixture) {
t.Helper()
if fixture.Exec == nil || fixture.Claimer == nil || fixture.QueryScalar == nil {
t.Skip("LeaseReclaimerFixture.Exec/Claimer/QueryScalar is nil: this backend cannot manufacture a stale lease")
}
}
// leaseReclaimerSeedClaimed creates each id and claims it as holder through the
// leg's Claimer, answering each claim's row version.
func leaseReclaimerSeedClaimed(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture, holder string, ids ...string) map[string]int64 {
t.Helper()
versions := map[string]int64{}
for _, id := range ids {
if err := fixture.CreateIssue(ctx, &types.Issue{
ID: id, Title: id, Status: types.StatusOpen, Priority: 2, IssueType: types.TypeTask,
}, "seed"); err != nil {
t.Fatalf("seed %s: %v", id, err)
}
claimed, err := fixture.Claimer.Claim(ctx, publicops.ClaimRequest{Actor: holder, IssueID: id})
if err != nil {
t.Fatalf("claim %s as %s: %v", id, holder, err)
}
if claimed.Issue == nil {
t.Fatalf("claim %s answered no issue", id)
}
versions[id] = claimed.Issue.RowVersion
}
return versions
}
// leaseReclaimerSeedStale claims each id and ages its lease an hour past
// expiry, far beyond any grace window a case below uses by default.
func leaseReclaimerSeedStale(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture, holder string, ids ...string) map[string]int64 {
t.Helper()
versions := leaseReclaimerSeedClaimed(t, ctx, fixture, holder, ids...)
leaseReclaimerAge(t, ctx, fixture, time.Hour, ids...)
return versions
}
// leaseReclaimerAge moves each id's lease expiry to age in the past.
func leaseReclaimerAge(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture, age time.Duration, ids ...string) {
t.Helper()
expired := time.Now().UTC().Add(-age)
statements := make([]SQLStatement, 0, len(ids))
for _, id := range ids {
statements = append(statements, SQLStatement{
Query: "UPDATE leases SET lease_expires_at = ? WHERE issue_id = ?",
Args: []any{expired, id},
})
}
if err := fixture.Exec(ctx, statements); err != nil {
t.Fatalf("age leases %v: %v", ids, err)
}
for _, id := range ids {
if n := leaseReclaimerScalar[int](t, ctx, fixture, "SELECT COUNT(*) FROM leases WHERE issue_id = ?", id); n != 1 {
t.Fatalf("lease rows for %s = %d, want 1: the claim wrote no lease to reclaim", id, n)
}
}
}
func leaseReclaimerLabel(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture, id, label string) {
t.Helper()
if err := fixture.Exec(ctx, []SQLStatement{{
Query: "INSERT INTO labels (issue_id, label) VALUES (?, ?)",
Args: []any{id, label},
}}); err != nil {
t.Fatalf("label %s %s: %v", id, label, err)
}
}
func leaseReclaimerRequireHeld(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture, id string) {
t.Helper()
if status := leaseReclaimerScalar[string](t, ctx, fixture, "SELECT status FROM issues WHERE id = ?", id); status != string(types.StatusInProgress) {
t.Fatalf("%s status = %q, want it still %q", id, status, types.StatusInProgress)
}
}
func leaseReclaim(t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture, request publicops.ReclaimRequest) publicops.ReclaimResult {
t.Helper()
result, err := fixture.LeaseReclaimer.Reclaim(ctx, request)
if err != nil {
t.Fatalf("Reclaim(%+v): %v", request.Filter, err)
}
if result.Reclaimed == nil {
t.Fatal("Reclaimed is nil; the role promises a non-nil slice for a successful call")
}
return result
}
func leaseReclaimerIDs(result publicops.ReclaimResult) []string {
ids := make([]string, 0, len(result.Reclaimed))
for _, r := range result.Reclaimed {
ids = append(ids, r.ID)
}
sort.Strings(ids)
return ids
}
func leaseReclaimerScalar[T any](t *testing.T, ctx context.Context, fixture LeaseReclaimerFixture, query string, args ...any) T {
t.Helper()
var value T
if err := fixture.QueryScalar(ctx, query, args, &value); err != nil {
t.Fatalf("%s %v: %v", query, args, err)
}
return value
}

View file

@ -846,11 +846,12 @@ func RunLifecycleCloseAndReopenSpanTheConfiguredDoneCategory(t *testing.T, ctx c
// RunLifecycleExpectedVersionIsCheckedBeforeTheNoOps pins the ORDERING clause
// both requests spell out. CloseRequest.ExpectedVersion "requires the current
// row version to match and is checked before an idempotent close"
// (issueops/issueops.go:295-300); ReopenRequest.ExpectedVersion is "checked
// before a non-done no-op" (:272-275); and Close's own doc adds "ExpectedVersion
// row version to match, and is checked BEFORE the idempotent close"
// (issueops/issueops.go:362-373); ReopenRequest.ExpectedVersion is "checked
// before a non-done no-op" (:390-391); and Close's own doc adds "ExpectedVersion
// is checked first, including for an idempotent close", with Force bypassing
// "blocker and open-child policy" and nothing else (:364-365).
// "the pin, the assignee fence, and blocker and open-child policy" and nothing
// else (:485-498).
//
// The dangerous shape is not a stale version on a live mutation — it is a stale
// version on the request that would have done nothing anyway. An implementation
@ -1092,6 +1093,87 @@ func RunLifecycleResultsAreHydratedPostStateSnapshots(t *testing.T, ctx context.
lifecycleCloseReopenAssertSnapshot(t, "reopen result", reopened.Issue, peer)
}
// RunLifecycleResultsCarryThePostWriteRowVersion pins that every write this
// role owns — Update, Close and Reopen — hands back a result whose
// Issue.RowVersion is the row's REAL post-write optimistic-concurrency token,
// not a zero value. types.Issue.RowVersion is `json:"-"`: an implementation
// that forgot to populate it on the way back from its own storage would still
// compile and would still pass every content assertion elsewhere in this
// file, because none of them read RowVersion.
//
// The assertion is a CHAIN rather than three independent zero-checks, because
// a zero-check alone cannot tell a dropped token from a WRONG one (an
// implementation could answer a nonzero constant, or the PRE-write version,
// and still clear it). Each step feeds the token the previous write answered
// with straight into the next write's ExpectedVersion, with no intervening
// read: the claim's token guards the Notes update, Update's token guards
// Close, and Close's token guards Reopen. A guard only passes if the token it
// was given equals the row's actual current version at the instant the next
// write runs, so a wrong or stale token fails closed — the next write
// refuses with ErrVersionMismatch — rather than silently succeeding. Any one
// dropped member breaks the chain at that link.
//
// The chain's first link is a CLAIM-ONLY request (Claim: true, no Patch),
// deliberately unguarded (UpdateRequest.Claim forbids combining Claim with
// ExpectedVersion — see issueops.UpdateRequest's doc): a backend that answers
// Lifecycle.Update's generic patch wire but special-cases a bare claim onto a
// different internal path (the http leg once dialed the Claimer role directly
// for one; it now folds the claim into updateIssue, keeping claimIssue only as
// the fallback for a server that predates updateIssue's `claim` member) could
// easily populate RowVersion on one path and not the other; this exercises
// the claim-only shape specifically, not just the Patch shape the rest of the
// chain already covered.
func RunLifecycleResultsCarryThePostWriteRowVersion(t *testing.T, ctx context.Context, fixture LifecycleCloseReopenFixture) {
t.Helper()
id := fixture.IssuePrefix + "-lcr-rowversion"
lifecycleCloseReopenSeedIssue(t, ctx, fixture, id, types.StatusOpen, nil)
claimed, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: "writer", IssueID: id, Claim: true,
})
if err != nil {
t.Fatalf("claim %s: %v", id, err)
}
if claimed.Issue == nil || claimed.Issue.RowVersion == 0 {
t.Fatalf("claim result RowVersion = %+v, want a nonzero post-write token", claimed.Issue)
}
claimVersion := claimed.Issue.RowVersion
updated, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: "writer", IssueID: id, ExpectedVersion: &claimVersion,
Patch: publicops.IssuePatch{Notes: publicops.Field[string]{Set: true, Value: "rowversion chain"}},
})
if err != nil {
t.Fatalf("update %s guarded by the claim's own token: %v — the claim result's RowVersion was not the row's real current version", id, err)
}
if updated.Issue == nil || updated.Issue.RowVersion == 0 {
t.Fatalf("update result RowVersion = %+v, want a nonzero post-write token", updated.Issue)
}
updateVersion := updated.Issue.RowVersion
closed, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{
Actor: "writer", IssueID: id, ExpectedVersion: &updateVersion,
})
if err != nil {
t.Fatalf("close %s guarded by the update's own token: %v — the update result's RowVersion was not the row's real current version", id, err)
}
if closed.Issue == nil || closed.Issue.RowVersion == 0 {
t.Fatalf("close result RowVersion = %+v, want a nonzero post-write token", closed.Issue)
}
closeVersion := closed.Issue.RowVersion
reopened, err := fixture.Lifecycle.Reopen(ctx, publicops.ReopenRequest{
Actor: "writer", IssueID: id, ExpectedVersion: &closeVersion,
})
if err != nil {
t.Fatalf("reopen %s guarded by the close's own token: %v — the close result's RowVersion was not the row's real current version", id, err)
}
if reopened.Issue == nil || reopened.Issue.RowVersion == 0 {
t.Fatalf("reopen result RowVersion = %+v, want a nonzero post-write token", reopened.Issue)
}
}
// RunLifecycleCloseAndReopenRequireActorAndIssueID pins the deterministic
// validation floor both verbs sit on. The Lifecycle doc states "Deterministic
// request validation failures match ErrValidation" and "Refusals and
@ -1302,13 +1384,14 @@ func RunLifecycleCloseSettlesItsTransitiveAndCrossPlaneDependers(t *testing.T, c
// RunLifecycleCloseAdmitsATransitivelyBlockedTarget uses clears the first and
// not the second, and closing the child to clear the second would take the
// second subject with it, since a closed row cannot be blocked and so has
// nothing left to flip. Force waives close policy and nothing else —
// CloseRequest.Force "bypasses only blocker and open-child close policy" and
// "never bypasses validation, ExpectedVersion, or lifecycle rules"
// (issueops/issueops.go:310-311) — so it is the shape that keeps both subjects
// observable, and it is not exotic: it is the same forced close of a
// blocked issue that RunLifecycleCloseIsIdempotentOnAClosedRowThatStillLooksBlocked
// is built on.
// nothing left to flip. Force waives close policy, the pin and the assignee
// fence, and nothing else — CloseRequest.Force "bypasses blocker and
// open-child close policy and the two close guards a force has always waived
// in bd" and "never bypasses the template guard, validation, ExpectedVersion,
// or lifecycle rules" (issueops/issueops.go:357-360) — so it is the shape that
// keeps both subjects observable, and it is not exotic: it is the same forced
// close of a blocked issue that
// RunLifecycleCloseIsIdempotentOnAClosedRowThatStillLooksBlocked is built on.
//
// All three legs reach ONE body here (internal/storage/issueops.closeIssueInTx),
// so this is a wrapper and engine check rather than a third vote, exactly as
@ -1741,3 +1824,175 @@ func (c *lifecycleCloseReopenEventCounter) assertNoneAdded(t *testing.T, label s
}
c.total = total
}
// RunLifecycleCloseEnforcesTheCloseGuards pins the three close guards
// issueops.Lifecycle.Close states before close policy — template read-only,
// the pin, and the assignee authority fence (be-035) — on the role itself, so
// every caller of it is held to them and not only `bd close`, which used to
// apply them as a CLI pre-read the served and library routes skipped.
//
// Each refusal is asserted at the level a caller acts on: the typed error with
// its fields, its sentinel, and the sentence bd prints — read off the typed
// error, because a served refusal wraps it in the problem envelope — plus the
// row and the event stream left untouched. Force is asserted as the bypass for
// exactly the two guards it has always waived, and NOT for the template.
//
// The controls are load-bearing too: an unassigned issue and one held by the
// closing actor under a different spelling both close unforced, so a guard
// that refused every assigned row, or compared verbatim, fails here. A wisp
// case proves the guard reads the plane the close writes. A pinned issue with
// an open child reads the PIN's refusal, pinning the order (guards before
// policy). And a forced close of a boolean-pinned issue leaves the pin set, so
// the plain retry must stay the idempotent no-op (ga-ktn9pe.4.8) rather than
// refuse on the residue.
func RunLifecycleCloseEnforcesTheCloseGuards(t *testing.T, ctx context.Context, fixture LifecycleCloseReopenFixture) {
t.Helper()
template := fixture.IssuePrefix + "-lcg-template"
statusPinned := fixture.IssuePrefix + "-lcg-status-pinned"
flagPinned := fixture.IssuePrefix + "-lcg-flag-pinned"
held := fixture.IssuePrefix + "-lcg-held"
respelled := fixture.IssuePrefix + "-lcg-respelled"
unassigned := fixture.IssuePrefix + "-lcg-unassigned"
pinnedParent := fixture.IssuePrefix + "-lcg-pinned-parent"
pinnedChild := fixture.IssuePrefix + "-lcg-pinned-child"
wisp := fixture.IssuePrefix + "-lcg-wisp-held"
seed := func(issue *types.Issue) {
t.Helper()
issue.Title, issue.Priority, issue.IssueType = issue.ID, 2, types.TypeTask
if issue.Status == "" {
issue.Status = types.StatusOpen
}
if err := fixture.CreateIssue(ctx, issue, "seed"); err != nil {
t.Fatalf("seed %s: %v", issue.ID, err)
}
}
seed(&types.Issue{ID: template, IsTemplate: true})
seed(&types.Issue{ID: statusPinned, Status: types.StatusPinned})
seed(&types.Issue{ID: flagPinned, Pinned: true})
seed(&types.Issue{ID: held, Assignee: "holder"})
seed(&types.Issue{ID: respelled, Assignee: "gastown.closer"})
seed(&types.Issue{ID: unassigned})
seed(&types.Issue{ID: pinnedParent, Pinned: true})
seed(&types.Issue{ID: pinnedChild})
lifecycleCloseReopenSeedEdge(t, ctx, fixture, pinnedChild, pinnedParent, types.DepParentChild)
refuses := func(id string, force bool, label string, check func(error)) {
t.Helper()
before := lifecycleCloseReopenReadRow(t, ctx, fixture, id)
events := newLifecycleCloseReopenEventCounter(t, ctx, fixture, id)
_, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{Actor: "closer", IssueID: id, Force: force})
check(err)
lifecycleCloseReopenAssertRow(t, ctx, fixture, id, "after the "+label+" refusal", before)
events.assertNoneAdded(t, label+" refusal")
}
// The template refuses, forced or not: no flag waives read-only.
for _, force := range []bool{false, true} {
refuses(template, force, "template", func(err error) {
var refusal *publicops.TemplateReadOnlyError
if !errors.As(err, &refusal) {
t.Fatalf("close of template %s (force=%v): err = %v, want *TemplateReadOnlyError", template, force, err)
}
if refusal.IssueID != template || !errors.Is(err, publicops.ErrTemplateReadOnly) {
t.Errorf("template refusal = %#v (%v), want IssueID %q matching ErrTemplateReadOnly", refusal, err, template)
}
want := "cannot modify template " + template + ": templates are read-only; use 'bd mol pour' to create a work item"
if refusal.Error() != want {
t.Errorf("template refusal reads %q, want %q", refusal.Error(), want)
}
})
}
// Both pin spellings refuse unforced (ga-z3vht).
for _, id := range []string{statusPinned, flagPinned} {
refuses(id, false, "pin", func(err error) {
var refusal *publicops.PinnedError
if !errors.As(err, &refusal) {
t.Fatalf("unforced close of pinned %s: err = %v, want *PinnedError", id, err)
}
if refusal.IssueID != id || !errors.Is(err, publicops.ErrPinned) {
t.Errorf("pin refusal = %#v (%v), want IssueID %q matching ErrPinned", refusal, err, id)
}
if want := "cannot modify pinned issue " + id + " (use --force to override)"; refusal.Error() != want {
t.Errorf("pin refusal reads %q, want %q", refusal.Error(), want)
}
})
}
// Another actor's bead refuses unforced, naming holder and actor.
refuses(held, false, "assignee", func(err error) {
var refusal *publicops.CloseNotAssigneeError
if !errors.As(err, &refusal) {
t.Fatalf("unforced close of %s held by another actor: err = %v, want *CloseNotAssigneeError", held, err)
}
if refusal.IssueID != held || refusal.Assignee != "holder" || refusal.Actor != "closer" {
t.Errorf("assignee refusal = %#v, want IssueID %q, Assignee holder, Actor closer", refusal, held)
}
if !errors.Is(err, publicops.ErrNotOwner) {
t.Errorf("assignee refusal %v does not match ErrNotOwner", err)
}
if want := `cannot close ` + held + `: assignee is "holder", actor is "closer"; reclaim or use --force to override`; refusal.Error() != want {
t.Errorf("assignee refusal reads %q, want %q", refusal.Error(), want)
}
})
// The guard runs before close policy: a pinned parent with an open child
// reads the pin, not the open children.
refuses(pinnedParent, false, "pin-before-policy", func(err error) {
if !errors.Is(err, publicops.ErrPinned) {
t.Fatalf("unforced close of pinned parent %s with an open child: err = %v, want ErrPinned first", pinnedParent, err)
}
})
// The controls: an unassigned bead and the actor's own bead under another
// spelling of its identity close unforced.
for _, tc := range []struct{ id, actor string }{{unassigned, "closer"}, {respelled, "gastown_closer"}} {
result, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{Actor: tc.actor, IssueID: tc.id})
if err != nil {
t.Fatalf("unforced close of %s by %s: %v, want it to land", tc.id, tc.actor, err)
}
if !result.Changed || result.Issue.Status != types.StatusClosed {
t.Errorf("unforced close of %s = %#v, want a committed close", tc.id, result)
}
}
// Force bypasses the pin and the assignee fence.
for _, id := range []string{statusPinned, flagPinned, held} {
result, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{Actor: "closer", IssueID: id, Force: true})
if err != nil {
t.Fatalf("forced close of %s: %v, want force to bypass the guard", id, err)
}
if !result.Changed || result.Issue.Status != types.StatusClosed {
t.Errorf("forced close of %s = %#v, want a committed close", id, result)
}
}
// The forced close left pinned=true on the flag-pinned row; the plain retry
// is the idempotent re-close, not a pin refusal.
retry, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{Actor: "closer", IssueID: flagPinned})
if err != nil {
t.Fatalf("plain re-close of the already-closed, still-pinned %s: %v, want the idempotent no-op", flagPinned, err)
}
if retry.Changed {
t.Errorf("plain re-close of %s reported Changed = true, want the no-op", flagPinned)
}
// The guard reads the plane the close writes.
if err := fixture.CreateWisp(ctx, &types.Issue{
ID: wisp, Title: wisp, Status: types.StatusOpen, Priority: 2, IssueType: types.TypeTask, Assignee: "holder", Ephemeral: true,
}, "seed"); err != nil {
t.Fatalf("seed wisp %s: %v", wisp, err)
}
if _, err := fixture.Lifecycle.Close(ctx, publicops.CloseRequest{Actor: "closer", IssueID: wisp}); !errors.As(err, new(*publicops.CloseNotAssigneeError)) {
t.Fatalf("unforced close of wisp %s held by another actor: err = %v, want *CloseNotAssigneeError", wisp, err)
}
var status string
if err := fixture.QueryScalar(ctx, "SELECT status FROM wisps WHERE id = ?", []any{wisp}, &status); err != nil {
t.Fatalf("read wisp %s status: %v", wisp, err)
}
if types.Status(status) != types.StatusOpen {
t.Errorf("wisp %s status after the refusal = %q, want it still open", wisp, status)
}
}

View file

@ -490,6 +490,12 @@ func RunLifecycleCreateWritesEveryScalarField(t *testing.T, ctx context.Context,
t.Errorf("%s created_at = %v after a create that named none, want a stamp between %v and %v — a bare non-empty check would accept the zero time",
stamped, autoStamp, lower, upper)
}
// And no created_by: the request's actor is the creator (CreateRequest.Issue),
// stamped by the role itself, so a library caller and every front door store
// the same value for the same request.
if got := lifecycleCreateRow(t, ctx, fixture, stamped).CreatedBy; got != "writer" {
t.Errorf("%s created_by = %q after a create that named none, want the request's actor %q", stamped, got, "writer")
}
want := []lifecycleCreateMember{
{"title", "created title"},
@ -804,3 +810,54 @@ func lifecycleCreatePlaneName(ephemeral bool) string {
}
return "durable"
}
// RunLifecycleCreateAppliesTheDefaultPriority pins
// CreateRequest.DefaultPriority: a create that asks for the default stores
// publicops.DefaultCreatePriority, and one that names priority 0 stores P0 —
// the zero value is a real priority, never "absent". Asking for the default
// while naming a priority is ErrValidation and writes nothing.
//
// It is the one place the default lives: `bd create` without --priority and an
// HTTP create without `priority` both reach it through this flag, so a backend
// that dropped it would store P0 (critical) for every such create.
func RunLifecycleCreateAppliesTheDefaultPriority(t *testing.T, ctx context.Context, fixture LifecycleCreateFixture) {
t.Helper()
defaulted := fixture.IssuePrefix + "-prio-default"
critical := fixture.IssuePrefix + "-prio-zero"
conflict := fixture.IssuePrefix + "-prio-conflict"
for _, tc := range []struct {
id string
priority int
useDefault bool
want int
}{
{id: defaulted, useDefault: true, want: publicops.DefaultCreatePriority},
{id: critical, priority: 0, want: 0},
} {
created, err := fixture.Lifecycle.Create(ctx, publicops.CreateRequest{
Actor: "writer",
DefaultPriority: tc.useDefault,
Issue: &types.Issue{ID: tc.id, Title: tc.id, Priority: tc.priority, IssueType: types.TypeTask},
})
if err != nil {
t.Fatalf("create %s: %v", tc.id, err)
}
if created.Issue.Priority != tc.want {
t.Errorf("create %s result priority = %d, want %d", tc.id, created.Issue.Priority, tc.want)
}
if got := lifecycleCreateRow(t, ctx, fixture, tc.id).Priority; got != tc.want {
t.Errorf("stored %s priority = %d, want %d", tc.id, got, tc.want)
}
}
_, err := fixture.Lifecycle.Create(ctx, publicops.CreateRequest{
Actor: "writer",
DefaultPriority: true,
Issue: &types.Issue{ID: conflict, Title: conflict, Priority: 3, IssueType: types.TypeTask},
})
if !errors.Is(err, storage.ErrValidation) {
t.Fatalf("DefaultPriority with priority 3: err = %v, want ErrValidation", err)
}
assertLifecycleCreateAbsent(t, ctx, fixture, conflict, "after the conflicting priority create")
}

View file

@ -0,0 +1,170 @@
package conformance
import (
"context"
"errors"
"fmt"
"strings"
"testing"
"time"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// This file and its two siblings (lifecycle_update_gate_contract.go,
// batch_apply_gate_contract.go) hold the gate-member clauses of Lifecycle.Create,
// Lifecycle.Update and BatchApplier: await_type, await_id, timeout and waiters
// on a create, await_id and waiters on a patch, and the one set of bounds every
// route refuses with a *publicops.GateFieldError.
//
// THE BOUNDS ARE THE COLUMNS', and the boundary is asserted from both sides: a
// value AT the bound lands whole, a value one past it is refused naming its
// member and writes nothing. await_type is VARCHAR(32) and await_id
// VARCHAR(255), both counted in characters, so each at-bound value is
// multi-byte — a byte count would refuse it. waiters is a TEXT column holding
// a JSON array, bounded in BYTES. A negative timeout is the one refusal that is
// not a width.
//
// NOTHING ELSE IS A RULE, and two cases say so: a gate member lands on an
// issue of any type (local `bd update --await-id` has always worked on any
// row), and waiters are stored as given, duplicates included (deduplication is
// the CLI's). A backend that grew a stricter rule fails here.
// gateFieldAtBoundAwaitType is a 32-character, 64-byte await_type.
var gateFieldAtBoundAwaitType = strings.Repeat("é", 32)
// gateFieldAtBoundAwaitID is a 255-character, 510-byte await_id.
var gateFieldAtBoundAwaitID = strings.Repeat("é", types.MaxFieldLen)
// gateFieldAtBoundWaiters is one waiter whose JSON array encoding is exactly
// types.MaxTextBytes bytes: the entry plus `["` and `"]`.
func gateFieldAtBoundWaiters() []string {
return []string{strings.Repeat("w", types.MaxTextBytes-4)}
}
// gateFieldOverBoundWaiters encodes to one byte past the TEXT column.
func gateFieldOverBoundWaiters() []string {
return []string{strings.Repeat("w", types.MaxTextBytes-3)}
}
// assertGateFieldError checks err is ErrValidation carried by a
// *publicops.GateFieldError naming field.
func assertGateFieldError(t *testing.T, err error, label, field string) {
t.Helper()
if !errors.Is(err, publicops.ErrValidation) {
t.Fatalf("%s: error = %v, want ErrValidation", label, err)
}
var fieldErr *publicops.GateFieldError
if !errors.As(err, &fieldErr) {
t.Fatalf("%s: error = %v, want a *GateFieldError naming %s", label, err, field)
}
if fieldErr.Field != field {
t.Errorf("%s: GateFieldError.Field = %q, want %q", label, fieldErr.Field, field)
}
}
// gateMembers renders the four gate members off an issue for comparison.
func gateMembers(issue *types.Issue) string {
waiters := issue.Waiters
if len(waiters) == 0 {
waiters = nil
}
return fmt.Sprintf("await_type=%q await_id=%q timeout=%s waiters=%q", issue.AwaitType, issue.AwaitID, issue.Timeout, waiters)
}
func assertGateMembers(t *testing.T, id, label string, issue *types.Issue, awaitType, awaitID string, timeout time.Duration, waiters []string) {
t.Helper()
if issue == nil {
t.Fatalf("%s %s: no issue to read the gate members off", id, label)
}
if len(waiters) == 0 {
waiters = nil
}
want := fmt.Sprintf("await_type=%q await_id=%q timeout=%s waiters=%q", awaitType, awaitID, timeout, waiters)
if got := gateMembers(issue); got != want {
// The at-bound values are long; report sizes rather than the values.
if len(got)+len(want) > 2000 {
t.Errorf("%s %s gate members differ (got %d bytes, want %d bytes; await_type %d/%d runes, await_id %d/%d runes, waiters %d/%d entries)",
id, label, len(got), len(want),
len([]rune(issue.AwaitType)), len([]rune(awaitType)), len([]rune(issue.AwaitID)), len([]rune(awaitID)),
len(issue.Waiters), len(waiters))
return
}
t.Errorf("%s %s gate members = %s, want %s", id, label, got, want)
}
}
// RunLifecycleCreateWritesTheGateMembers pins that Lifecycle.Create stores all
// four gate members (CreateRequest.Issue's "gate" fields) on the row and
// answers them on the result, with the waiter list stored as given, duplicate
// included, and on an issue that is not of the gate type.
func RunLifecycleCreateWritesTheGateMembers(t *testing.T, ctx context.Context, fixture LifecycleCreateFixture) {
t.Helper()
gate := fixture.IssuePrefix + "-lcg-gate"
issue := lifecycleCreateIssue(gate)
issue.IssueType = types.TypeGate
issue.AwaitType = "gh:run"
issue.AwaitID = "12345"
issue.Timeout = 90 * time.Minute
issue.Waiters = []string{"rig/workers/a", "rig/workers/b", "rig/workers/a"}
created, err := fixture.Lifecycle.Create(ctx, publicops.CreateRequest{Actor: "writer", ForceIDPrefix: true, Issue: issue})
if err != nil {
t.Fatalf("create gate %s: %v", gate, err)
}
want := []string{"rig/workers/a", "rig/workers/b", "rig/workers/a"}
assertGateMembers(t, gate, "in the create result", created.Issue, "gh:run", "12345", 90*time.Minute, want)
assertGateMembers(t, gate, "in the stored row", lifecycleCreateRow(t, ctx, fixture, gate), "gh:run", "12345", 90*time.Minute, want)
// Any type carries them: no gate-type-only rule.
task := fixture.IssuePrefix + "-lcg-task"
carrier := lifecycleCreateIssue(task)
carrier.AwaitType = "formula-defined"
carrier.AwaitID = "bead:" + gate
carrier.Waiters = []string{"mail:someone"}
if _, err := fixture.Lifecycle.Create(ctx, publicops.CreateRequest{Actor: "writer", ForceIDPrefix: true, Issue: carrier}); err != nil {
t.Fatalf("create task %s carrying gate members: %v", task, err)
}
assertGateMembers(t, task, "in the stored row", lifecycleCreateRow(t, ctx, fixture, task), "formula-defined", "bead:"+gate, 0, []string{"mail:someone"})
}
// RunLifecycleCreateBoundsTheGateMembers pins the four GateFieldError bounds
// on create from both sides: each at-bound value lands whole, each value one
// past it is refused as ErrValidation naming its member, and the refused
// create leaves no row.
func RunLifecycleCreateBoundsTheGateMembers(t *testing.T, ctx context.Context, fixture LifecycleCreateFixture) {
t.Helper()
atBound := fixture.IssuePrefix + "-lcg-atbound"
issue := lifecycleCreateIssue(atBound)
issue.IssueType = types.TypeGate
issue.AwaitType = gateFieldAtBoundAwaitType
issue.AwaitID = gateFieldAtBoundAwaitID
issue.Timeout = 0
issue.Waiters = gateFieldAtBoundWaiters()
if _, err := fixture.Lifecycle.Create(ctx, publicops.CreateRequest{Actor: "writer", ForceIDPrefix: true, Issue: issue}); err != nil {
t.Fatalf("create %s with every gate member at its bound: %v", atBound, err)
}
assertGateMembers(t, atBound, "in the stored row", lifecycleCreateRow(t, ctx, fixture, atBound),
gateFieldAtBoundAwaitType, gateFieldAtBoundAwaitID, 0, gateFieldAtBoundWaiters())
for _, test := range []struct {
name string
field string
mutate func(*types.Issue)
}{
{"await_type", publicops.GateFieldAwaitType, func(i *types.Issue) { i.AwaitType = gateFieldAtBoundAwaitType + "x" }},
{"await_id", publicops.GateFieldAwaitID, func(i *types.Issue) { i.AwaitID = gateFieldAtBoundAwaitID + "x" }},
{"timeout", publicops.GateFieldTimeout, func(i *types.Issue) { i.Timeout = -time.Nanosecond }},
{"waiters", publicops.GateFieldWaiters, func(i *types.Issue) { i.Waiters = gateFieldOverBoundWaiters() }},
} {
id := fixture.IssuePrefix + "-lcg-over-" + strings.ReplaceAll(test.name, "_", "")
refused := lifecycleCreateIssue(id)
refused.IssueType = types.TypeGate
test.mutate(refused)
_, err := fixture.Lifecycle.Create(ctx, publicops.CreateRequest{Actor: "writer", ForceIDPrefix: true, Issue: refused})
assertGateFieldError(t, err, "create with "+test.name+" past its bound", test.field)
assertLifecycleCreateAbsent(t, ctx, fixture, id, "after the refused "+test.name)
}
}

View file

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"reflect"
"slices"
"sort"
"sync"
"testing"
@ -1919,10 +1920,10 @@ func RunLifecycleUpdateParentIDReplacesEveryParent(t *testing.T, ctx context.Con
// RunLifecycleUpdatePersistentPreservesUnversionedClass pins the half of the
// Persistence clause nobody else asserts: "Persistent preserves an existing
// durable unversioned class" (issueops/issueops.go:135-136). The refusal beside
// it — an unversioned row cannot be demoted to a wisp mode — is pinned
// elsewhere; this clause says the legal direction is a no-op that does NOT
// normalize the row into versioned storage.
// durable unversioned class" (issueops/issueops.go:149). The refusal beside
// it — an unversioned row cannot be demoted to a wisp mode — is
// RunLifecycleUpdateWispModesRefuseAnUnversionedRow; this clause says the legal
// direction is a no-op that does NOT normalize the row into versioned storage.
//
// WHAT A PERSISTENCE RESTATEMENT MUST NOT DO is where the two observations come
// in. A persistence MOVE deletes the row from one plane and re-inserts it into
@ -1963,6 +1964,90 @@ func RunLifecycleUpdatePersistentPreservesUnversionedClass(t *testing.T, ctx con
assertLifecycleUpdateWispAbsent(t, ctx, fixture, id, "after the persistent restatement")
}
// RunLifecycleUpdateWispModesRefuseAnUnversionedRow pins the refusal beside
// that clause: Ephemeral and NoHistory "select wisp retention modes, never
// durable unversioned storage" (issueops/issueops.go:150-151), so an
// unversioned row asked for either is refused. The refusal is the request's,
// a deterministic validation failure, so it matches ErrValidation on every
// leg — over http that is the 400 naming the patch rather than a 500 that
// drops the reason and alerts the operator — and it leaves the row where it
// was: durable, still unversioned, and absent from the wisp plane.
func RunLifecycleUpdateWispModesRefuseAnUnversionedRow(t *testing.T, ctx context.Context, fixture LifecycleUpdateFixture) {
t.Helper()
id := fixture.IssuePrefix + "-lup-unversioned-wisp"
seeded := lifecycleUpdateIssue(id)
seeded.StorageClass = types.StorageClassUnversioned
seedLifecycleUpdateIssue(t, ctx, fixture, seeded)
for _, mode := range []publicops.PersistenceMode{publicops.PersistenceModeEphemeral, publicops.PersistenceModeNoHistory} {
label := "after the refused " + string(mode) + " move"
before := lifecycleUpdateRow(t, ctx, fixture, id)
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: publicops.IssuePatch{
Persistence: publicops.Field[publicops.PersistenceMode]{Set: true, Value: mode},
}}); !errors.Is(err, storage.ErrValidation) {
t.Fatalf("move unversioned %s to %s: error = %v, want ErrValidation", id, mode, err)
}
assertLifecycleUpdateRowUnchanged(t, ctx, fixture, id, label, before)
after := lifecycleUpdateRow(t, ctx, fixture, id)
if after.Ephemeral || after.NoHistory || after.StorageClass != types.StorageClassUnversioned {
t.Errorf("%s %s = {ephemeral %v, no-history %v, class %q}, want the durable unversioned row it was",
id, label, after.Ephemeral, after.NoHistory, after.StorageClass)
}
assertLifecycleUpdateWispAbsent(t, ctx, fixture, id, label)
}
}
// RunLifecycleUpdatePersistentPromotesAWisp pins the move `bd promote` makes
// (issueops.Promote): Persistence = persistent on an ephemeral wisp is a
// MUTATION that leaves the row on the durable plane under the same id, with
// its labels carried across and nothing left behind on the wisp plane. A
// second identical request is the no-op the "same current mode" clause
// promises, which is how Promote tells a lost race from a promotion.
func RunLifecycleUpdatePersistentPromotesAWisp(t *testing.T, ctx context.Context, fixture LifecycleUpdateFixture) {
t.Helper()
if fixture.CreateWisp == nil {
t.Skip("fixture has no CreateWisp: this backend has no wisp plane to promote from")
}
id := fixture.IssuePrefix + "-lup-promote"
seedLifecycleUpdateWisp(t, ctx, fixture, lifecycleUpdateIssue(id, "keep-me"))
if got := lifecycleUpdateRow(t, ctx, fixture, id); !got.Ephemeral {
t.Fatalf("seeded %s is not ephemeral; the case has nothing to promote", id)
}
promote := publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: publicops.IssuePatch{
Persistence: publicops.Field[publicops.PersistenceMode]{Set: true, Value: publicops.PersistenceModePersistent},
}}
promoted, err := fixture.Lifecycle.Update(ctx, promote)
if err != nil {
t.Fatalf("promote %s: %v", id, err)
}
if !promoted.Changed {
t.Errorf("promoting wisp %s reported Changed = false, want a mutation", id)
}
if promoted.Issue == nil || promoted.Issue.ID != id || promoted.Issue.Ephemeral {
t.Errorf("promote result issue = %+v, want %s on the durable plane", promoted.Issue, id)
}
after := lifecycleUpdateRow(t, ctx, fixture, id)
if after.Ephemeral || after.NoHistory {
t.Errorf("%s came back {ephemeral %v, no-history %v} after the promotion, want a durable-plane row", id, after.Ephemeral, after.NoHistory)
}
if !slices.Contains(after.Labels, "keep-me") {
t.Errorf("%s labels after the promotion = %v, want the wisp's label carried across", id, after.Labels)
}
assertLifecycleUpdateWispAbsent(t, ctx, fixture, id, "after the promotion")
again, err := fixture.Lifecycle.Update(ctx, promote)
if err != nil {
t.Fatalf("re-promote %s: %v", id, err)
}
if again.Changed {
t.Errorf("re-promoting durable %s reported Changed = true, want the same-mode no-op", id)
}
}
// RunLifecycleUpdateProvenanceLabelsHistory pins UpdateRequest.Provenance
// against the history the backend actually writes
// (issueops/issueops.go:261-270): the entry reads as the caller's own string,
@ -2519,3 +2604,134 @@ func lifecycleUpdateHasEdge(dependencies []*types.Dependency, wantTarget string)
}
return false
}
// RunLifecycleUpdateRefusesATemplate pins Lifecycle.Update's template guard:
// templates are read-only, so EVERY update naming one refuses with
// *TemplateReadOnlyError — a field edit, a label edit, a claim, a status
// crossing — whatever force flags ride along, and nothing is written. It is the
// guard `bd update` used to apply as a CLI pre-read, which left bd serve and
// library callers editing templates bd refused.
//
// The refusal is asserted at the level a caller acts on — the typed error, its
// sentinel and the sentence bd prints, read off the typed error because a
// served refusal wraps it — and the row is read back to prove nothing moved.
// Two controls: the same patches land on an ordinary sibling, so the guard is
// not refusing the patch shapes; and a stale ExpectedVersion on the template
// still reports the mismatch, so the guard runs after the compare-and-set
// preconditions like every other update fence.
func RunLifecycleUpdateRefusesATemplate(t *testing.T, ctx context.Context, fixture LifecycleUpdateFixture) {
t.Helper()
template := fixture.IssuePrefix + "-lut-template"
sibling := fixture.IssuePrefix + "-lut-sibling"
for _, issue := range []*types.Issue{
{ID: template, IsTemplate: true},
{ID: sibling},
} {
issue.Title, issue.Status, issue.Priority, issue.IssueType = issue.ID, types.StatusOpen, 2, types.TypeTask
if err := fixture.CreateIssue(ctx, issue, "seed"); err != nil {
t.Fatalf("seed %s: %v", issue.ID, err)
}
}
before, err := fixture.GetIssue(ctx, template)
if err != nil {
t.Fatalf("read seeded template %s: %v", template, err)
}
requests := []struct {
name string
request publicops.UpdateRequest
}{
{name: "field edit", request: publicops.UpdateRequest{
Patch: publicops.IssuePatch{Title: publicops.Field[string]{Set: true, Value: "edited"}},
}},
{name: "label edit", request: publicops.UpdateRequest{
Patch: publicops.IssuePatch{Labels: publicops.LabelPatch{Add: []string{"lut-tag"}}},
}},
{name: "claim", request: publicops.UpdateRequest{Claim: true}},
{name: "forced status crossing", request: publicops.UpdateRequest{
Patch: publicops.IssuePatch{Status: publicops.Field[publicops.Status]{Set: true, Value: types.StatusClosed}},
ForceClosePolicy: true,
}},
{name: "forced assignee transfer", request: publicops.UpdateRequest{
Patch: publicops.IssuePatch{Assignee: publicops.Field[string]{Set: true, Value: "someone"}},
ForceAssigneeTransfer: true,
}},
}
for _, tc := range requests {
request := tc.request
request.Actor, request.IssueID = "writer", template
_, err := fixture.Lifecycle.Update(ctx, request)
var refusal *publicops.TemplateReadOnlyError
if !errors.As(err, &refusal) {
t.Fatalf("%s on template %s: err = %v, want *TemplateReadOnlyError", tc.name, template, err)
}
if refusal.IssueID != template || !errors.Is(err, publicops.ErrTemplateReadOnly) {
t.Errorf("%s refusal = %#v (%v), want IssueID %q matching ErrTemplateReadOnly", tc.name, refusal, err, template)
}
if want := "cannot modify template " + template + ": templates are read-only; use 'bd mol pour' to create a work item"; refusal.Error() != want {
t.Errorf("%s refusal reads %q, want %q", tc.name, refusal.Error(), want)
}
after, err := fixture.GetIssue(ctx, template)
if err != nil {
t.Fatalf("read template %s after the %s refusal: %v", template, tc.name, err)
}
if after.RowVersion != before.RowVersion || after.Title != before.Title || after.Status != before.Status ||
after.Assignee != before.Assignee || len(after.Labels) != len(before.Labels) {
t.Errorf("template %s after the %s refusal = %+v, want it unchanged from %+v", template, tc.name, after, before)
}
control := tc.request
control.Actor, control.IssueID = "writer", sibling
if _, err := fixture.Lifecycle.Update(ctx, control); err != nil {
t.Errorf("%s on the ordinary sibling %s: %v, want it to land", tc.name, sibling, err)
}
}
stale := before.RowVersion + 1
_, err = fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: "writer", IssueID: template, ExpectedVersion: &stale,
Patch: publicops.IssuePatch{Title: publicops.Field[string]{Set: true, Value: "edited"}},
})
if !errors.Is(err, publicops.ErrVersionMismatch) {
t.Errorf("stale-guarded update of template %s: err = %v, want ErrVersionMismatch ahead of the template guard", template, err)
}
}
// RunLifecycleUpdateAllowTemplateEditsATemplate pins the template guard's one
// stand-down: an update with AllowTemplate — what bd label and bd set-state
// send, since they have always edited templates — lands on a template, and
// only that request is waived (the same patch without it still refuses).
func RunLifecycleUpdateAllowTemplateEditsATemplate(t *testing.T, ctx context.Context, fixture LifecycleUpdateFixture) {
t.Helper()
template := fixture.IssuePrefix + "-lua-template"
issue := &types.Issue{ID: template, Title: template, Status: types.StatusOpen, Priority: 2, IssueType: types.TypeTask, IsTemplate: true}
if err := fixture.CreateIssue(ctx, issue, "seed"); err != nil {
t.Fatalf("seed %s: %v", template, err)
}
result, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: "writer", IssueID: template, AllowTemplate: true,
Patch: publicops.IssuePatch{Labels: publicops.LabelPatch{Add: []string{"lua-tag"}}},
})
if err != nil {
t.Fatalf("AllowTemplate label edit on template %s: %v, want it to land", template, err)
}
if !result.Changed || result.Issue == nil || !lifecycleUpdateHasLabel(result.Issue.Labels, "lua-tag") {
t.Errorf("AllowTemplate label edit on template %s = %+v, want a change carrying lua-tag", template, result)
}
after, err := fixture.GetIssue(ctx, template)
if err != nil {
t.Fatalf("read template %s: %v", template, err)
}
if !after.IsTemplate {
t.Errorf("template %s is no longer a template after an AllowTemplate edit", template)
}
_, err = fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{
Actor: "writer", IssueID: template,
Patch: publicops.IssuePatch{Labels: publicops.LabelPatch{Add: []string{"lua-other"}}},
})
if !errors.Is(err, publicops.ErrTemplateReadOnly) {
t.Errorf("the same edit without AllowTemplate: err = %v, want ErrTemplateReadOnly", err)
}
}

View file

@ -0,0 +1,133 @@
package conformance
import (
"context"
"testing"
"time"
publicops "github.com/steveyegge/beads/issueops"
)
// The patch half of the gate-member clauses; see lifecycle_create_gate_contract.go.
// RunLifecycleUpdatePatchesTheGateMembers pins IssuePatch.AwaitID and
// IssuePatch.Waiters: a set value lands and is answered on the result, waiters
// is a WHOLE-VALUE replacement stored as given (duplicates kept), a same-value
// patch is a no-op, a clear (empty await_id, nil waiters) empties both, and a
// second clear is a no-op. await_type and timeout are not patch members, so
// they ride through every edit untouched. The row is a task: no gate-type-only
// rule.
func RunLifecycleUpdatePatchesTheGateMembers(t *testing.T, ctx context.Context, fixture LifecycleUpdateFixture) {
t.Helper()
id := fixture.IssuePrefix + "-lug-gate"
seeded := lifecycleUpdateIssue(id)
seeded.AwaitType = "timer"
seeded.AwaitID = "seeded-await"
seeded.Timeout = time.Minute
seeded.Waiters = []string{"seeded"}
seedLifecycleUpdateIssue(t, ctx, fixture, seeded)
patch := publicops.IssuePatch{
AwaitID: publicops.Field[string]{Set: true, Value: "run-42"},
Waiters: publicops.Field[[]string]{Set: true, Value: []string{"w1", "w2", "w1"}},
}
wantWaiters := []string{"w1", "w2", "w1"}
updated, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: patch})
if err != nil {
t.Fatalf("patch the gate members of %s: %v", id, err)
}
if !updated.Changed {
t.Errorf("patching the gate members of %s reported Changed = false, want a committed edit", id)
}
assertGateMembers(t, id, "in the update result", updated.Issue, "timer", "run-42", time.Minute, wantWaiters)
assertGateMembers(t, id, "in the stored row", lifecycleUpdateRow(t, ctx, fixture, id), "timer", "run-42", time.Minute, wantWaiters)
after := lifecycleUpdateRow(t, ctx, fixture, id)
again, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: patch})
if err != nil {
t.Fatalf("re-apply the same gate patch to %s: %v", id, err)
}
if again.Changed {
t.Errorf("re-applying the same gate patch to %s reported Changed = true, want false", id)
}
assertLifecycleUpdateRowUnchanged(t, ctx, fixture, id, "after the same-value gate patch", after)
clear := publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: publicops.IssuePatch{
AwaitID: publicops.Field[string]{Set: true},
Waiters: publicops.Field[[]string]{Set: true},
}}
cleared, err := fixture.Lifecycle.Update(ctx, clear)
if err != nil {
t.Fatalf("clear the gate members of %s: %v", id, err)
}
if !cleared.Changed {
t.Errorf("clearing the gate members of %s reported Changed = false, want a committed edit", id)
}
assertGateMembers(t, id, "in the clear's result", cleared.Issue, "timer", "", time.Minute, nil)
assertGateMembers(t, id, "in the cleared row", lifecycleUpdateRow(t, ctx, fixture, id), "timer", "", time.Minute, nil)
afterClear := lifecycleUpdateRow(t, ctx, fixture, id)
reclear, err := fixture.Lifecycle.Update(ctx, clear)
if err != nil {
t.Fatalf("re-clear the gate members of %s: %v", id, err)
}
if reclear.Changed {
t.Errorf("re-clearing the already-empty gate members of %s reported Changed = true, want false", id)
}
assertLifecycleUpdateRowUnchanged(t, ctx, fixture, id, "after the re-clear", afterClear)
// An explicitly empty list clears exactly as a nil one does.
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: publicops.IssuePatch{
Waiters: publicops.Field[[]string]{Set: true, Value: []string{"back"}},
}}); err != nil {
t.Fatalf("re-set the waiters of %s: %v", id, err)
}
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: publicops.IssuePatch{
Waiters: publicops.Field[[]string]{Set: true, Value: []string{}},
}}); err != nil {
t.Fatalf("clear the waiters of %s with an empty list: %v", id, err)
}
assertGateMembers(t, id, "after the empty-list clear", lifecycleUpdateRow(t, ctx, fixture, id), "timer", "", time.Minute, nil)
}
// RunLifecycleUpdateBoundsTheGateMembers pins the patch half of the
// GateFieldError bounds from both sides: at-bound await_id and waiters land
// whole, one past either is refused as ErrValidation naming its member, and
// the refusal writes nothing — not the gate member, and not an ordinary member
// riding in the same patch.
func RunLifecycleUpdateBoundsTheGateMembers(t *testing.T, ctx context.Context, fixture LifecycleUpdateFixture) {
t.Helper()
id := fixture.IssuePrefix + "-lug-bounds"
seedLifecycleUpdateIssue(t, ctx, fixture, lifecycleUpdateIssue(id))
if _, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: publicops.IssuePatch{
AwaitID: publicops.Field[string]{Set: true, Value: gateFieldAtBoundAwaitID},
Waiters: publicops.Field[[]string]{Set: true, Value: gateFieldAtBoundWaiters()},
}}); err != nil {
t.Fatalf("patch %s with await_id and waiters at their bounds: %v", id, err)
}
assertGateMembers(t, id, "in the stored row", lifecycleUpdateRow(t, ctx, fixture, id), "", gateFieldAtBoundAwaitID, 0, gateFieldAtBoundWaiters())
before := lifecycleUpdateRow(t, ctx, fixture, id)
for _, test := range []struct {
name string
field string
patch publicops.IssuePatch
}{
{"await_id", publicops.GateFieldAwaitID, publicops.IssuePatch{
Title: publicops.Field[string]{Set: true, Value: "must not land"},
AwaitID: publicops.Field[string]{Set: true, Value: gateFieldAtBoundAwaitID + "x"},
}},
{"waiters", publicops.GateFieldWaiters, publicops.IssuePatch{
Title: publicops.Field[string]{Set: true, Value: "must not land"},
Waiters: publicops.Field[[]string]{Set: true, Value: gateFieldOverBoundWaiters()},
}},
} {
_, err := fixture.Lifecycle.Update(ctx, publicops.UpdateRequest{Actor: "writer", IssueID: id, Patch: test.patch})
assertGateFieldError(t, err, "patch with "+test.name+" past its bound", test.field)
assertLifecycleUpdateRowUnchanged(t, ctx, fixture, id, "after the refused "+test.name, before)
assertGateMembers(t, id, "after the refused "+test.name, lifecycleUpdateRow(t, ctx, fixture, id), "", gateFieldAtBoundAwaitID, 0, gateFieldAtBoundWaiters())
}
}

View file

@ -233,14 +233,11 @@ func RunMemoriesRememberWithExplicitKeyStoresVerbatim(t *testing.T, ctx context.
}
// RunMemoriesRememberReplacesAndReportsIt pins
// memoryops.RememberResult.Replaced, including the leg that makes it different
// from RecallResult.Found.
// memoryops.RememberResult.Replaced against row presence.
//
// Three legs: a first write reports false, a second reports true and REPLACES
// rather than appends, and a write over an out-of-band EMPTY row reports true
// even though a Recall of that key would have reported Found false. The third
// is the divergence the leaf doc states — Replaced is about the ROW — and it is
// the one a body computing `previous != ""` gets wrong.
// rather than appends, and a write over an out-of-band EMPTY row reports true.
// The third is the one a body computing `previous != ""` gets wrong.
func RunMemoriesRememberReplacesAndReportsIt(t *testing.T, ctx context.Context, fixture MemoriesFixture) {
t.Helper()
neighbors := seedMemoriesAllFourClasses(t, ctx, fixture)
@ -262,7 +259,7 @@ func RunMemoriesRememberReplacesAndReportsIt(t *testing.T, ctx context.Context,
if err := fixture.SetConfig(ctx, "kv.memory."+emptied, ""); err != nil {
t.Fatalf("seed an empty memory row out of band: %v", err)
}
assertMemoriesRecall(t, ctx, fixture, emptied, "", false)
assertMemoriesRecall(t, ctx, fixture, emptied, "", true)
overEmpty := rememberMemory(t, ctx, fixture, memoryops.RememberRequest{Key: emptied, Content: "now it has content"})
if !overEmpty.Replaced {
t.Fatalf("Remember over a row stored EMPTY reported Replaced false: Replaced is about the row, " +
@ -374,8 +371,8 @@ func RunMemoriesRecallAnswersTheStoredValue(t *testing.T, ctx context.Context, f
}
// RunMemoriesRecallReportsAMissAsNotFoundNotAnError pins the decision recorded
// in memoryops/errors.go: there is no ErrNotFound on this role, because the
// seam beneath it cannot see the difference the error would claim.
// in memoryops/errors.go: absence is a result callers inspect, not an
// operational error they must classify.
func RunMemoriesRecallReportsAMissAsNotFoundNotAnError(t *testing.T, ctx context.Context, fixture MemoriesFixture) {
t.Helper()
seedMemoriesAllFourClasses(t, ctx, fixture)
@ -401,33 +398,70 @@ func RunMemoriesRecallReportsAMissAsNotFoundNotAnError(t *testing.T, ctx context
}
}
// RunMemoriesRecallConflatesStoredEmptyWithAbsent pins
// memoryops.RecallResult.Found's central claim, and the one asymmetry that lets
// a caller see past it: List enumerates the key, because the ROW exists.
// RunMemoriesEmptyRowIsPresentUntilForgotten pins presence to the ROW rather
// than to whether its value is non-empty. No front door creates an empty
// memory, but out-of-band config writes and older workspaces can contain one,
// and it must remain addressable through Recall and Forget.
//
// That is the same same-answer-different-row shape the settings contract pins
// for `bd config get`, and stating it is what keeps a backend from "fixing" it
// on one leg and making the answer depend on the route.
func RunMemoriesRecallConflatesStoredEmptyWithAbsent(t *testing.T, ctx context.Context, fixture MemoriesFixture) {
// The second Forget is the retry leg: after the first call deletes the row, it
// reports a genuine miss and records no further history.
func RunMemoriesEmptyRowIsPresentUntilForgotten(t *testing.T, ctx context.Context, fixture MemoriesFixture) {
t.Helper()
seedMemoriesAllFourClasses(t, ctx, fixture)
neighbors := seedMemoriesAllFourClasses(t, ctx, fixture)
emptied := fixture.IssuePrefix + "-stored-empty"
never := fixture.IssuePrefix + "-never-stored"
if err := fixture.SetConfig(ctx, "kv.memory."+emptied, ""); err != nil {
t.Fatalf("seed an empty memory row out of band: %v", err)
}
assertMemoriesRecall(t, ctx, fixture, emptied, "", false)
assertMemoriesRecall(t, ctx, fixture, emptied, "", true)
assertMemoriesRecall(t, ctx, fixture, never, "", false)
plane := listMemories(t, ctx, fixture, "")
if value, ok := plane[emptied]; !ok || value != "" {
t.Fatalf("List[%q] = %q (present=%v), want an empty value that IS enumerated: "+
"the row exists even though Recall denies it", emptied, value, ok)
t.Fatalf("List[%q] = %q (present=%v), want an enumerated empty value", emptied, value, ok)
}
if _, ok := plane[never]; ok {
t.Fatalf("List carries %q, which nothing stored", never)
}
first := forgetMemory(t, ctx, fixture, emptied)
if !first.Found || first.Value != "" {
t.Fatalf("first Forget(%q) = %+v, want Found true with the empty stored value", emptied, first)
}
assertMemoriesRawAbsent(t, ctx, fixture, "kv.memory."+emptied)
assertMemoriesNeighborsSurvived(t, ctx, fixture, neighbors)
var afterFirst int
if fixture.CountHistory != nil {
var err error
afterFirst, err = fixture.CountHistory(ctx)
if err != nil {
t.Fatalf("CountHistory after first Forget: %v", err)
}
}
second := forgetMemory(t, ctx, fixture, emptied)
if second.Found || second.Value != "" {
t.Fatalf("second Forget(%q) = %+v, want Found false with no value", emptied, second)
}
assertMemoriesRawAbsent(t, ctx, fixture, "kv.memory."+emptied)
assertMemoriesNeighborsSurvived(t, ctx, fixture, neighbors)
// The no-write half of the retry is the only leg that needs history, which
// is why it comes last: a backend that cannot observe history has run every
// other leg by here, and SKIPS this one with that reason, as the
// MemoriesFixture.CountHistory doc promises, rather than passing quietly.
if fixture.CountHistory == nil {
t.Skip("this backend cannot observe history, so the no-write half of the retry is unobservable here")
}
afterSecond, err := fixture.CountHistory(ctx)
if err != nil {
t.Fatalf("CountHistory after second Forget: %v", err)
}
if afterSecond != afterFirst {
t.Fatalf("history entries went %d -> %d across the second Forget, want no write", afterFirst, afterSecond)
}
}
// RunMemoriesForgetRemovesExactlyTheNamedRow IS THE QUADRANT CASE, and the
@ -528,13 +562,7 @@ func RunMemoriesForgetReportsTheForgottenValue(t *testing.T, ctx context.Context
// RunMemoriesForgetOfAnAbsentKeyIsNotFoundAndDeletesNothing pins that a miss is
// a RESULT and not an error, that it changes no row anywhere in the table, that
// the second call — the one a retrying caller actually makes — answers the same
// way, and that the SECOND kind of miss behaves like the first: a memory stored
// as the empty string is Found false, and its row is left standing.
//
// That last leg is memoryops.ForgetResult.Found's parenthesis, and it keeps
// Forget's answer and Recall's answer the same statement. A body that deleted
// on "the row is there" rather than on "Recall would find it" would report
// nothing removed while removing something.
// way.
//
// The whole-table row count is the assertion that matters: "the key is still
// absent" would pass on a delete that swept a neighboring plane.
@ -542,10 +570,6 @@ func RunMemoriesForgetOfAnAbsentKeyIsNotFoundAndDeletesNothing(t *testing.T, ctx
t.Helper()
neighbors := seedMemoriesAllFourClasses(t, ctx, fixture)
key := fixture.IssuePrefix + "-never-stored-forget"
emptied := fixture.IssuePrefix + "-empty-forget"
if err := fixture.SetConfig(ctx, "kv.memory."+emptied, ""); err != nil {
t.Fatalf("seed an empty memory row out of band: %v", err)
}
var before int
if err := fixture.QueryScalar(ctx, "SELECT COUNT(*) FROM config", nil, &before); err != nil {
@ -553,14 +577,12 @@ func RunMemoriesForgetOfAnAbsentKeyIsNotFoundAndDeletesNothing(t *testing.T, ctx
}
for attempt := 1; attempt <= 2; attempt++ {
for _, miss := range []string{key, emptied} {
result, err := fixture.Memories.Forget(ctx, memoryops.ForgetRequest{Key: miss})
if err != nil {
t.Fatalf("Forget(%q) attempt %d = %v, want success with Found false", miss, attempt, err)
}
if result.Found || result.Value != "" {
t.Fatalf("Forget(%q) attempt %d = %+v, want Found false and no value", miss, attempt, result)
}
result, err := fixture.Memories.Forget(ctx, memoryops.ForgetRequest{Key: key})
if err != nil {
t.Fatalf("Forget(%q) attempt %d = %v, want success with Found false", key, attempt, err)
}
if result.Found || result.Value != "" {
t.Fatalf("Forget(%q) attempt %d = %+v, want Found false and no value", key, attempt, result)
}
}
@ -569,11 +591,8 @@ func RunMemoriesForgetOfAnAbsentKeyIsNotFoundAndDeletesNothing(t *testing.T, ctx
t.Fatalf("count config rows after: %v", err)
}
if after != before {
t.Fatalf("config rows went %d -> %d across four forgets that found nothing, want no change", before, after)
t.Fatalf("config rows went %d -> %d across two forgets that found nothing, want no change", before, after)
}
// The stored-empty row is specifically still there: Found false said nothing
// was removed, and that has to be true of the row as well as of the answer.
assertMemoriesRawValue(t, ctx, fixture, "kv.memory."+emptied, "")
assertMemoriesNeighborsSurvived(t, ctx, fixture, neighbors)
// The empty key is a refusal, not a miss.

View file

@ -0,0 +1,480 @@
package conformance
import (
"context"
"errors"
"testing"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// This file holds the contract for the molecule operations every backend
// serves through one library entry each:
//
// - CloseRequest.AutoCloseMolecule / CloseBatchRequest.AutoCloseMolecule —
// the close closes the molecule root it completed IN ITS OWN TRANSACTION
// (internal/storage/issueops.CloseCompletedMoleculeInTx on the store
// backends, uow.CloseCompletedMoleculeInUOW on the unit of work, the
// server's own on http). Opt-in; unforced; guarded on the root revision.
// - issueops.MoleculeStepper — the advance behind `bd close --continue`,
// whose claim is a real claim (assignee = Actor) that never takes a step
// another actor holds.
//
// THE LEAF DOC COMMENTS ARE THE SPEC (issueops/issueops.go CloseRequest,
// issueops/batchcloser.go, issueops/moleculestepper.go, issueops/molecule.go).
// MoleculeFixture supplies adapter-specific storage access for the molecule
// assertions.
type MoleculeFixture struct {
// IssuePrefix namespaces the ids each assertion seeds.
IssuePrefix string
Lifecycle publicops.Lifecycle
BatchCloser publicops.BatchCloser
Stepper publicops.MoleculeStepper
// CreateIssue and CreateWisp seed one row in the issues and wisps plane.
CreateIssue func(context.Context, *types.Issue, string) error
CreateWisp func(context.Context, *types.Issue, string) error
// AddDependency seeds one edge.
AddDependency func(context.Context, *types.Dependency, string) error
// QueryScalar runs a single-row query and scans it.
QueryScalar func(context.Context, string, []any, ...any) error
}
const moleculeActor = "molecule-contract"
type moleculeSeed struct {
t *testing.T
ctx context.Context
fixture MoleculeFixture
}
func (s moleculeSeed) issue(id string, typ types.IssueType, status types.Status, ephemeral bool, labels ...string) {
s.t.Helper()
issue := &types.Issue{ID: id, Title: "molecule " + id, IssueType: typ, Status: status, Priority: 2, Labels: labels, Ephemeral: ephemeral}
if status == types.StatusClosed {
issue.CloseReason = "seeded closed"
}
create := s.fixture.CreateIssue
if ephemeral {
create = s.fixture.CreateWisp
}
if err := create(s.ctx, issue, moleculeActor); err != nil {
s.t.Fatalf("seed %s: %v", id, err)
}
}
func (s moleculeSeed) edge(from, to string, typ types.DependencyType) {
s.t.Helper()
if err := s.fixture.AddDependency(s.ctx, &types.Dependency{IssueID: from, DependsOnID: to, Type: typ}, moleculeActor); err != nil {
s.t.Fatalf("seed edge %s -> %s: %v", from, to, err)
}
}
// row reads id's status and assignee from whichever plane holds it.
func (s moleculeSeed) row(id string) (status, assignee string) {
s.t.Helper()
err := s.fixture.QueryScalar(s.ctx,
`SELECT status, COALESCE(assignee, '') FROM issues WHERE id = ?
UNION ALL SELECT status, COALESCE(assignee, '') FROM wisps WHERE id = ?`,
[]any{id, id}, &status, &assignee)
if err != nil {
s.t.Fatalf("read %s: %v", id, err)
}
return status, assignee
}
// molecule seeds root <- step1 (closed), step2 (open) and answers the ids.
func (s moleculeSeed) molecule(name string, rootType types.IssueType, ephemeral bool, labels ...string) (root, done, last string) {
s.t.Helper()
root = s.fixture.IssuePrefix + "-" + name
done, last = root+".1", root+".2"
s.issue(root, rootType, types.StatusOpen, ephemeral, labels...)
s.issue(done, types.TypeTask, types.StatusClosed, ephemeral)
s.issue(last, types.TypeTask, types.StatusOpen, ephemeral)
s.edge(done, root, types.DepParentChild)
s.edge(last, root, types.DepParentChild)
return root, done, last
}
func (s moleculeSeed) closeStep(id string, autoClose bool) publicops.CloseResult {
s.t.Helper()
res, err := s.fixture.Lifecycle.Close(s.ctx, publicops.CloseRequest{
Actor: moleculeActor, IssueID: id, Reason: "step done", Session: "molecule-session", AutoCloseMolecule: autoClose,
})
if err != nil {
s.t.Fatalf("close %s: %v", id, err)
}
return res
}
// RunMoleculeCloseAutoClosesTheCompletedRoot pins CloseRequest.AutoCloseMolecule:
// closing the last open step closes an auto-closing root in the same call,
// reports it, and records the auto-close reason.
func RunMoleculeCloseAutoClosesTheCompletedRoot(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
for _, shape := range []struct {
name string
rootType types.IssueType
labels []string
}{
{"poured", types.TypeMolecule, nil},
{"template", types.TypeEpic, []string{publicops.MoleculeTemplateLabel}},
} {
root, _, last := s.molecule("auto-"+shape.name, shape.rootType, false, shape.labels...)
res := s.closeStep(last, true)
if !res.Changed || res.Issue == nil || res.Issue.Status != types.StatusClosed {
t.Fatalf("%s: close %s = %+v, want the step closed", shape.name, last, res)
}
if res.AutoClosedMolecule == nil || res.AutoClosedMolecule.ID != root {
t.Fatalf("%s: AutoClosedMolecule = %+v, want %s", shape.name, res.AutoClosedMolecule, root)
}
if res.MoleculeAutoCloseRefusal != "" {
t.Errorf("%s: MoleculeAutoCloseRefusal = %q, want none", shape.name, res.MoleculeAutoCloseRefusal)
}
if status, _ := s.row(root); status != string(types.StatusClosed) {
t.Errorf("%s: root %s status = %s, want closed", shape.name, root, status)
}
var reason string
if err := fixture.QueryScalar(ctx, `SELECT close_reason FROM issues WHERE id = ?`, []any{root}, &reason); err != nil {
t.Fatalf("read %s close_reason: %v", root, err)
}
if reason != publicops.MoleculeAutoCloseReason {
t.Errorf("%s: root close_reason = %q, want %q", shape.name, reason, publicops.MoleculeAutoCloseReason)
}
}
}
// RunMoleculeAutoCloseIsOptInAndRuleBound pins the opt-in default and the
// three roots the auto-close must leave open: one a request did not ask for,
// an incomplete one, and an ordinary epic (explicit close-eligible work).
func RunMoleculeAutoCloseIsOptInAndRuleBound(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
root, _, last := s.molecule("optin", types.TypeMolecule, false)
if res := s.closeStep(last, false); res.AutoClosedMolecule != nil {
t.Errorf("close without AutoCloseMolecule reported %s auto-closed", res.AutoClosedMolecule.ID)
}
if status, _ := s.row(root); status != string(types.StatusOpen) {
t.Errorf("root %s status after an un-flagged close = %s, want open", root, status)
}
root, _, last = s.molecule("plain", types.TypeEpic, false)
if res := s.closeStep(last, true); res.AutoClosedMolecule != nil {
t.Errorf("an ordinary epic auto-closed: %s", res.AutoClosedMolecule.ID)
}
if status, _ := s.row(root); status != string(types.StatusOpen) {
t.Errorf("ordinary epic %s status = %s, want open", root, status)
}
root, done, last := s.molecule("incomplete", types.TypeMolecule, false)
if res := s.closeStep(done, true); res.AutoClosedMolecule != nil {
t.Errorf("an incomplete molecule auto-closed: %s", res.AutoClosedMolecule.ID)
}
if status, _ := s.row(root); status != string(types.StatusOpen) {
t.Errorf("incomplete molecule %s status = %s, want open (%s still open)", root, status, last)
}
}
// RunMoleculeRecloseHealsAStrandedRoot pins the replay clause: an idempotent
// re-close of the last step still closes a root left open.
func RunMoleculeRecloseHealsAStrandedRoot(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
root := fixture.IssuePrefix + "-stranded"
step := root + ".1"
s.issue(root, types.TypeMolecule, types.StatusOpen, false)
s.issue(step, types.TypeTask, types.StatusClosed, false)
s.edge(step, root, types.DepParentChild)
res := s.closeStep(step, true)
if res.Changed {
t.Errorf("re-close of %s reported Changed", step)
}
if res.AutoClosedMolecule == nil || res.AutoClosedMolecule.ID != root {
t.Fatalf("re-close AutoClosedMolecule = %+v, want %s healed", res.AutoClosedMolecule, root)
}
if status, _ := s.row(root); status != string(types.StatusClosed) {
t.Errorf("stranded root %s status = %s, want closed", root, status)
}
}
// RunMoleculeBatchCloseAutoClosesTheRootOnce pins the batch clause: a batch
// that closes the remaining steps closes the root once, on one outcome.
func RunMoleculeBatchCloseAutoClosesTheRootOnce(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
root, _, last := s.molecule("batch", types.TypeMolecule, false)
other := root + ".3"
s.issue(other, types.TypeTask, types.StatusOpen, false)
s.edge(other, root, types.DepParentChild)
res, err := fixture.BatchCloser.CloseBatch(ctx, publicops.CloseBatchRequest{
Actor: moleculeActor,
Items: []publicops.BatchCloseItem{{IssueID: last, Reason: "done"}, {IssueID: other, Reason: "done"}},
AutoCloseMolecule: true,
})
if err != nil {
t.Fatalf("CloseBatch: %v", err)
}
reported := 0
for _, outcome := range res.Outcomes {
if outcome.Err != nil {
t.Fatalf("outcome %s: %v", outcome.IssueID, outcome.Err)
}
if outcome.AutoClosedMolecule != nil {
reported++
if outcome.AutoClosedMolecule.ID != root {
t.Errorf("outcome %s auto-closed %s, want %s", outcome.IssueID, outcome.AutoClosedMolecule.ID, root)
}
}
}
if reported != 1 {
t.Errorf("the root was reported on %d outcomes, want exactly one", reported)
}
if status, _ := s.row(root); status != string(types.StatusClosed) {
t.Errorf("root %s status = %s, want closed", root, status)
}
}
// RunMoleculeRefusedRootKeepsTheStepClose pins the refusal clause: a root its
// own close policy refuses (a live blocker) stays open and is reported in the
// policy's own sentence, and the step close it followed stands.
func RunMoleculeRefusedRootKeepsTheStepClose(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
root, _, last := s.molecule("blocked", types.TypeMolecule, false)
blocker := root + "-blocker"
s.issue(blocker, types.TypeTask, types.StatusOpen, false)
s.edge(root, blocker, types.DepBlocks)
res := s.closeStep(last, true)
if res.AutoClosedMolecule != nil {
t.Errorf("a blocked root auto-closed: %s", res.AutoClosedMolecule.ID)
}
if want := publicops.NewCloseBlockedError(root, []string{blocker}).Error(); res.MoleculeAutoCloseRefusal != want {
t.Errorf("MoleculeAutoCloseRefusal = %q, want the policy's own sentence %q", res.MoleculeAutoCloseRefusal, want)
}
if status, _ := s.row(last); status != string(types.StatusClosed) {
t.Errorf("step %s status = %s, want closed (the refusal must not undo it)", last, status)
}
if status, _ := s.row(root); status != string(types.StatusOpen) {
t.Errorf("blocked root %s status = %s, want open", root, status)
}
}
// RunMoleculeGuardedRootKeepsTheStepClose pins the guard clause: the root close
// is unforced, so a root a direct close would refuse — assigned to someone
// other than Actor, pinned, or a template — stays open and is reported in the
// guard's own sentence, on a single close and on a batch, and the step's close
// (and a batch's other items) stand.
func RunMoleculeGuardedRootKeepsTheStepClose(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
for _, guard := range []struct {
name string
apply func(*types.Issue)
// refusal is the guard's own error for root, whose sentence
// MoleculeAutoCloseRefusal reports.
refusal func(root string) error
}{
{"assigned", func(root *types.Issue) { root.Assignee = "someone-else" }, func(root string) error {
return &publicops.CloseNotAssigneeError{IssueID: root, Assignee: "someone-else", Actor: moleculeActor}
}},
{"pinned", func(root *types.Issue) { root.Pinned = true }, func(root string) error {
return &publicops.PinnedError{IssueID: root}
}},
{"template", func(root *types.Issue) { root.IsTemplate = true }, func(root string) error {
return &publicops.TemplateReadOnlyError{IssueID: root}
}},
} {
for _, batch := range []bool{false, true} {
name := guard.name
if batch {
name += "-batch"
}
root := fixture.IssuePrefix + "-guarded-" + name
last := root + ".2"
rootIssue := &types.Issue{ID: root, Title: "molecule " + root, IssueType: types.TypeMolecule, Status: types.StatusOpen, Priority: 2}
guard.apply(rootIssue)
if err := fixture.CreateIssue(ctx, rootIssue, moleculeActor); err != nil {
t.Fatalf("%s: seed %s: %v", name, root, err)
}
s.issue(root+".1", types.TypeTask, types.StatusClosed, false)
s.issue(last, types.TypeTask, types.StatusOpen, false)
s.edge(root+".1", root, types.DepParentChild)
s.edge(last, root, types.DepParentChild)
var (
autoClosed *publicops.Issue
refusal string
closed = []string{last}
)
if batch {
other := root + "-other"
s.issue(other, types.TypeTask, types.StatusOpen, false)
closed = append(closed, other)
res, err := fixture.BatchCloser.CloseBatch(ctx, publicops.CloseBatchRequest{
Actor: moleculeActor,
Items: []publicops.BatchCloseItem{{IssueID: last, Reason: "done"}, {IssueID: other, Reason: "done"}},
AutoCloseMolecule: true,
})
if err != nil {
t.Fatalf("%s: CloseBatch: %v", name, err)
}
for _, outcome := range res.Outcomes {
if outcome.Err != nil {
t.Fatalf("%s: outcome %s: %v", name, outcome.IssueID, outcome.Err)
}
if outcome.IssueID == last {
autoClosed, refusal = outcome.AutoClosedMolecule, outcome.MoleculeAutoCloseRefusal
}
}
} else {
res := s.closeStep(last, true)
autoClosed, refusal = res.AutoClosedMolecule, res.MoleculeAutoCloseRefusal
}
if autoClosed != nil {
t.Errorf("%s: a guarded root auto-closed: %s", name, autoClosed.ID)
}
if want := guard.refusal(root).Error(); refusal != want {
t.Errorf("%s: MoleculeAutoCloseRefusal = %q, want the guard's own sentence %q", name, refusal, want)
}
for _, id := range closed {
if status, _ := s.row(id); status != string(types.StatusClosed) {
t.Errorf("%s: %s status = %s, want closed (the refusal must not undo it)", name, id, status)
}
}
if status, _ := s.row(root); status != string(types.StatusOpen) {
t.Errorf("%s: guarded root %s status = %s, want open", name, root, status)
}
}
}
}
// RunMoleculeStepperClaimsTheNextReadyStepForTheActor pins the advance and its
// claim: the next ready step becomes in progress AND assigned to Actor; without
// AutoClaim nothing is written.
func RunMoleculeStepperClaimsTheNextReadyStepForTheActor(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
root := fixture.IssuePrefix + "-advance"
a, b, c := root+".1", root+".2", root+".3"
s.issue(root, types.TypeMolecule, types.StatusOpen, false)
s.issue(a, types.TypeTask, types.StatusClosed, false)
s.issue(b, types.TypeTask, types.StatusOpen, false)
s.issue(c, types.TypeTask, types.StatusOpen, false)
for _, id := range []string{a, b, c} {
s.edge(id, root, types.DepParentChild)
}
s.edge(c, b, types.DepBlocks)
res, err := fixture.Stepper.Advance(ctx, publicops.AdvanceRequest{Actor: moleculeActor, ClosedStepID: a})
if err != nil {
t.Fatalf("Advance: %v", err)
}
if res.MoleculeID != root || res.Claimed || res.NextStep == nil || res.NextStep.ID != b {
t.Fatalf("Advance without a claim = %+v, want next %s in %s, unclaimed", res, b, root)
}
if status, assignee := s.row(b); status != string(types.StatusOpen) || assignee != "" {
t.Errorf("%s after an unclaimed advance = %s/%q, want open and unassigned", b, status, assignee)
}
res, err = fixture.Stepper.Advance(ctx, publicops.AdvanceRequest{Actor: moleculeActor, ClosedStepID: a, AutoClaim: true})
if err != nil {
t.Fatalf("Advance with a claim: %v", err)
}
if !res.Claimed || res.NextStep == nil || res.NextStep.ID != b || res.NextStep.Assignee != moleculeActor {
t.Fatalf("Advance with a claim = %+v, want %s claimed for %s", res, b, moleculeActor)
}
if status, assignee := s.row(b); status != string(types.StatusInProgress) || assignee != moleculeActor {
t.Errorf("%s after the claim = %s/%q, want in_progress assigned to %s", b, status, assignee, moleculeActor)
}
if status, _ := s.row(c); status != string(types.StatusOpen) {
t.Errorf("%s (blocked) status = %s, want open", c, status)
}
}
// RunMoleculeStepperNeverTakesAStepAnotherActorHolds pins the refusal the claim
// carries: a ready step assigned to someone else is skipped for the next one,
// and left exactly as it was.
func RunMoleculeStepperNeverTakesAStepAnotherActorHolds(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
root := fixture.IssuePrefix + "-held"
a, held, free := root+".1", root+".2", root+".3"
s.issue(root, types.TypeMolecule, types.StatusOpen, false)
s.issue(a, types.TypeTask, types.StatusClosed, false)
heldIssue := &types.Issue{ID: held, Title: "held", IssueType: types.TypeTask, Status: types.StatusOpen, Priority: 2, Assignee: "someone-else"}
if err := fixture.CreateIssue(ctx, heldIssue, moleculeActor); err != nil {
t.Fatalf("seed %s: %v", held, err)
}
s.issue(free, types.TypeTask, types.StatusOpen, false)
for _, id := range []string{a, held, free} {
s.edge(id, root, types.DepParentChild)
}
res, err := fixture.Stepper.Advance(ctx, publicops.AdvanceRequest{Actor: moleculeActor, ClosedStepID: a, AutoClaim: true})
if err != nil {
t.Fatalf("Advance: %v", err)
}
if !res.Claimed || res.NextStep == nil || res.NextStep.ID != free {
t.Fatalf("Advance = %+v, want %s skipped (held) and %s claimed", res, held, free)
}
if status, assignee := s.row(held); status != string(types.StatusOpen) || assignee != "someone-else" {
t.Errorf("held step %s = %s/%q, want untouched (open, someone-else)", held, status, assignee)
}
}
// RunMoleculeStepperAnswersCompleteAndOutsideAMolecule pins the two answers
// that claim nothing.
func RunMoleculeStepperAnswersCompleteAndOutsideAMolecule(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
orphan := fixture.IssuePrefix + "-orphan"
s.issue(orphan, types.TypeTask, types.StatusClosed, false)
res, err := fixture.Stepper.Advance(ctx, publicops.AdvanceRequest{Actor: moleculeActor, ClosedStepID: orphan, AutoClaim: true})
if err != nil {
t.Fatalf("Advance(orphan): %v", err)
}
if res.MoleculeID != "" || res.NextStep != nil || res.Claimed || res.ClosedStep == nil || res.ClosedStep.ID != orphan {
t.Errorf("Advance(orphan) = %+v, want the step and no molecule", res)
}
root := fixture.IssuePrefix + "-complete"
s.issue(root, types.TypeEpic, types.StatusOpen, false)
s.issue(root+".1", types.TypeTask, types.StatusClosed, false)
s.edge(root+".1", root, types.DepParentChild)
res, err = fixture.Stepper.Advance(ctx, publicops.AdvanceRequest{Actor: moleculeActor, ClosedStepID: root + ".1", AutoClaim: true})
if err != nil {
t.Fatalf("Advance(complete): %v", err)
}
if res.MoleculeID != root || !res.Complete || res.NextStep != nil || res.Claimed {
t.Errorf("Advance(complete) = %+v, want %s complete", res, root)
}
if _, err := fixture.Stepper.Advance(ctx, publicops.AdvanceRequest{Actor: moleculeActor, ClosedStepID: fixture.IssuePrefix + "-absent"}); !errors.Is(err, publicops.ErrNotFound) {
t.Errorf("Advance(absent) = %v, want ErrNotFound", err)
}
}
// RunMoleculeStepperClaimsAWispStep pins the wisp plane: a wisp molecule's next
// step is claimed for the actor too.
func RunMoleculeStepperClaimsAWispStep(t *testing.T, ctx context.Context, fixture MoleculeFixture) {
t.Helper()
s := moleculeSeed{t, ctx, fixture}
root, done, last := s.molecule("wisp", types.TypeMolecule, true)
res, err := fixture.Stepper.Advance(ctx, publicops.AdvanceRequest{Actor: moleculeActor, ClosedStepID: done, AutoClaim: true})
if err != nil {
t.Fatalf("Advance: %v", err)
}
if res.MoleculeID != root || !res.Claimed || res.NextStep == nil || res.NextStep.ID != last {
t.Fatalf("Advance over a wisp molecule = %+v, want %s claimed", res, last)
}
if status, assignee := s.row(last); status != string(types.StatusInProgress) || assignee != moleculeActor {
t.Errorf("wisp step %s = %s/%q, want in_progress assigned to %s", last, status, assignee, moleculeActor)
}
}

View file

@ -42,6 +42,7 @@ func RunPortableMethods(t *testing.T, factory Factory) {
t.Run("ImportIssueComment", func(t *testing.T) { testImportIssueComment(t, factory) })
t.Run("AddIssueCommentBurstOrder", func(t *testing.T) { testAddIssueCommentBurstOrder(t, factory) })
t.Run("PromoteFromEphemeral", func(t *testing.T) { testPromoteFromEphemeral(t, factory) })
t.Run("PromoteClosedWispPreservesSession", func(t *testing.T) { testPromoteClosedWispPreservesSession(t, factory) })
t.Run("UpdateIssueID", func(t *testing.T) { testUpdateIssueID(t, factory) })
t.Run("DeleteIssuesBySourceRepo", func(t *testing.T) { testDeleteIssuesBySourceRepo(t, factory) })
t.Run("CreateIssuesWithFullOptions", func(t *testing.T) { testCreateIssuesWithFullOptions(t, factory) })
@ -577,6 +578,36 @@ func testPromoteFromEphemeral(t *testing.T, f Factory) {
}
}
// testPromoteClosedWispPreservesSession verifies that promoting a *closed*
// ephemeral wisp preserves its closed_by_session provenance. Before the fix
// (GH#4662), closed_by_session was absent from the shared issue select/scan
// and insert column set, so promotion (read wisp -> insert issue) hydrated a
// zero value and dropped the original closing session. Promotion re-inserts
// through that shared (classic) writer, so this case guards GH#4662's path
// only; the domain writer's copy of the column (db.insertIssueRow) is pinned
// by the domain/db Insert tests.
func testPromoteClosedWispPreservesSession(t *testing.T, f Factory) {
s := f(t)
c := ctx()
must(t, s.CreateIssue(c, withDefaults(&types.Issue{ID: "test-cw", Title: "Closed wisp", Ephemeral: true}), "a"))
must(t, s.CloseIssue(c, "test-cw", "done", "a", "sess-xyz"))
must(t, s.PromoteFromEphemeral(c, "test-cw", "a"))
got, err := s.GetIssue(c, "test-cw")
must(t, err)
if got.Ephemeral {
t.Error("promoted issue still Ephemeral")
}
if got.Status != types.StatusClosed {
t.Errorf("promoted issue status = %q, want %q", got.Status, types.StatusClosed)
}
if got.ClosedBySession != "sess-xyz" {
t.Errorf("closed_by_session after promote = %q, want %q (GH#4662)", got.ClosedBySession, "sess-xyz")
}
}
// --- Id rekey / source-repo purge / batch create ---
func testUpdateIssueID(t *testing.T, f Factory) {

View file

@ -113,6 +113,10 @@ type ReaderFixture struct {
AddDependency func(context.Context, *types.Dependency, string) error
// AddComment puts one comment on a durable issue.
AddComment func(ctx context.Context, issueID, author, text string) error
// PromoteWisp moves a seeded wisp into the durable plane. It is the only
// way to seed a DURABLE row of an infra type: creating one routes it to the
// wisps plane on every backend.
PromoteWisp func(ctx context.Context, id, actor string) error
}
// RunReaderReadyDefaultTypeExclusionsYieldToAnExplicitType pins
@ -786,6 +790,112 @@ func RunReaderListReadyFlagRefusesAFilterItCannotCarry(t *testing.T, ctx context
assertReaderPageIDs(t, "List --id without --ready", page, []string{one})
}
// RunReaderListQueryMatchesTheTitleOrTheID pins ListRequest.Query: `bd
// search`'s text, which matches a row whose title OR id contains it, case
// insensitively, and which narrows without lifting a default exclusion — and
// issueops.SearchListRequest, the request every `bd search` route sends, which
// does lift them.
//
// EVERY KIND OF ROW the search scope promises is seeded with the text, because
// a scope that silently loses one kind answers every other row correctly: a
// template, a gate, a wisp of an infra type, and a DURABLE row of that type —
// a promoted wisp, which a type filter that narrows an infra type to its
// ephemeral rows drops with no error. Each must come back under the bare scope
// and under its own type.
//
// It scopes itself with a label rather than an id set, so the served leg runs
// it as written: listIssues publishes no id parameter.
func RunReaderListQueryMatchesTheTitleOrTheID(t *testing.T, ctx context.Context, fixture ReaderFixture) {
t.Helper()
if fixture.PromoteWisp == nil {
t.Fatal("fixture has no PromoteWisp: a durable row of an infra type cannot be seeded, and it is the row a narrowed type filter drops")
}
scope := readerLabel(fixture, "lsquery")
needle := strings.ToLower(fixture.IssuePrefix) + "qneedle"
titleHit := readerID(fixture, "lsquery", "title")
idHit := readerID(fixture, "lsquery", "idhit")
closedHit := readerID(fixture, "lsquery", "closed")
miss := readerID(fixture, "lsquery", "miss")
template := readerID(fixture, "lsquery", "template")
gate := readerID(fixture, "lsquery", "gate")
wispMessage := readerID(fixture, "lsquery", "wispmsg")
promotedMessage := readerID(fixture, "lsquery", "promotedmsg")
// The title carries the needle in UPPER case and the request asks in lower,
// so a case-sensitive match finds nothing.
titleIssue := readerIssue(titleHit, types.TypeTask, scope)
titleIssue.Title = "fix the " + strings.ToUpper(needle) + " path"
// The id-hit's title says nothing about it: only its id can match.
idIssue := readerIssue(idHit, types.TypeTask, scope)
idIssue.Title = "unrelated words"
closedIssue := readerIssue(closedHit, types.TypeTask, scope)
closedIssue.Title = "old " + needle
closedIssue.Status = types.StatusClosed
missIssue := readerIssue(miss, types.TypeTask, scope)
missIssue.Title = "nothing to see"
templateIssue := readerIssue(template, types.TypeTask, scope)
templateIssue.Title = needle + " template"
templateIssue.IsTemplate = true
gateIssue := readerIssue(gate, types.TypeGate, scope)
gateIssue.Title = needle + " gate"
for _, issue := range []*types.Issue{titleIssue, idIssue, closedIssue, missIssue, templateIssue, gateIssue} {
seedReaderIssue(t, ctx, fixture, issue)
}
// Two rows of the same infra type, one per plane. `message` is built in,
// so the type is valid on every backend without configuration.
for _, id := range []string{wispMessage, promotedMessage} {
message := readerIssue(id, types.TypeMessage, scope)
message.Title = needle + " message"
message.Ephemeral = true
seedReaderWisp(t, ctx, fixture, message)
}
if err := fixture.PromoteWisp(ctx, promotedMessage, "seed"); err != nil {
t.Fatalf("promote wisp %s: %v", promotedMessage, err)
}
searchType := func(issueType types.IssueType) publicops.ListRequest {
req := searchScoped(needle, scope)
req.IssueType = string(issueType)
return req
}
for _, tc := range []struct {
name string
req publicops.ListRequest
want []string
}{
{"a title match, case-insensitively, under the default exclusions", publicops.ListRequest{Labels: []string{scope}, Query: needle}, []string{titleHit}},
{"AllFlag takes the closed match back", publicops.ListRequest{Labels: []string{scope}, Query: needle, AllFlag: true}, []string{titleHit, closedHit}},
{"an id match whose title does not contain the text", publicops.ListRequest{Labels: []string{scope}, Query: idHit, AllFlag: true}, []string{idHit}},
{"text nothing contains", publicops.ListRequest{Labels: []string{scope}, Query: needle + "-absent", AllFlag: true}, nil},
{"no text narrows nothing", publicops.ListRequest{Labels: []string{scope}}, []string{titleHit, idHit, miss}},
{"SearchListRequest, `bd search`'s scope, takes every status and every kind of row back", searchScoped(needle, scope), []string{titleHit, closedHit, template, gate, wispMessage, promotedMessage}},
{"SearchListRequest under an infra type keeps both planes' rows of it", searchType(types.TypeMessage), []string{wispMessage, promotedMessage}},
{"SearchListRequest under the gate type", searchType(types.TypeGate), []string{gate}},
{"SearchListRequest under a plain type keeps its templates", searchType(types.TypeTask), []string{titleHit, closedHit, template}},
// Outside the search scope an infra type alone reads only its
// ephemeral rows, which is where creating one puts it; IncludeEphemeral
// is what lifts that narrowing to the durable rows as well.
{"an infra type alone reads only its ephemeral rows", publicops.ListRequest{Labels: []string{scope}, Query: needle, IssueType: string(types.TypeMessage)}, []string{wispMessage}},
{"IncludeEphemeral lifts that narrowing", publicops.ListRequest{Labels: []string{scope}, Query: needle, IssueType: string(types.TypeMessage), IncludeEphemeral: true}, []string{wispMessage, promotedMessage}},
} {
page, err := fixture.Reader.List(ctx, tc.req)
if err != nil {
t.Errorf("List %s: %v", tc.name, err)
continue
}
assertReaderPageIDSet(t, "List "+tc.name, page, tc.want)
}
}
// searchScoped is the library's search request narrowed to one case's label,
// the request every `bd search` route sends.
func searchScoped(query, label string) publicops.ListRequest {
req := publicops.SearchListRequest(query)
req.Labels = []string{label}
return req
}
// RunReaderListEmptyPageIsWellFormed pins the page shape when nothing matches
// (reader.go:376-381). Items is never nil for a successful call, so no caller
// has to tell null from empty to learn that nothing matched, and an empty page
@ -3065,6 +3175,335 @@ func assertReaderBriefRow(t *testing.T, what string, brief, full *types.Issue) {
}
}
// RunReaderListTimeBoundsAreStrictAndWholeSecond pins the eight time bounds
// ListRequest carries beside the created pair — UpdatedAfter/Before,
// ClosedAfter/Before, DeferAfter/Before and DueAfter/Before — at their exact
// boundaries (reader.go: each is a strict bound on its column).
//
// THE BOUNDARY IS THE ASSERTION. Three rows sit one second apart around an
// instant T, so a body that compared inclusively, swapped the two ends, or
// bound the wrong column fails on a row rather than on nothing:
//
// - after=T selects exactly the T+1s row and before=T exactly the T-1s row,
// so the row AT T is excluded by both;
// - a bound carrying a sub-second remainder (T+900ms) behaves as T on both
// ends, because the bound is compared at whole-second precision (the
// storage builder formats it as RFC 3339 without a fraction);
// - a row whose column is NULL — an open row's closed_at, an unset
// defer_until or due_at — never matches either bound;
// - a bound spelled in a non-UTC zone selects exactly what the same instant
// spelled in UTC does. An offset is part of the instant, not decoration,
// and a body that dropped it would move the bound by the offset.
//
// Every family scopes itself by id and seeds no labels, so no write after the
// insert can move updated_at off the instant it was seeded at; AllFlag keeps
// the closed rows in view.
func RunReaderListTimeBoundsAreStrictAndWholeSecond(t *testing.T, ctx context.Context, fixture ReaderFixture) {
t.Helper()
at := time.Now().UTC().Truncate(time.Second).Add(-3 * time.Hour)
created := at.Add(-time.Hour)
instants := []struct {
tag string
at time.Time
}{
{"early", at.Add(-time.Second)},
{"exact", at},
{"late", at.Add(time.Second)},
}
for _, family := range []struct {
name string
// set stamps the family's column onto a seed.
set func(issue *types.Issue, v time.Time)
// nullable seeds a fourth row with the column NULL.
nullable bool
after func(*publicops.ListRequest, *time.Time)
before func(*publicops.ListRequest, *time.Time)
}{
{
name: "updated",
set: func(issue *types.Issue, v time.Time) { issue.UpdatedAt = v },
after: func(r *publicops.ListRequest, v *time.Time) { r.UpdatedAfter = v },
before: func(r *publicops.ListRequest, v *time.Time) { r.UpdatedBefore = v },
},
{
name: "closed",
set: func(issue *types.Issue, v time.Time) {
issue.Status = types.StatusClosed
issue.UpdatedAt = v
issue.ClosedAt = &v
},
nullable: true,
after: func(r *publicops.ListRequest, v *time.Time) { r.ClosedAfter = v },
before: func(r *publicops.ListRequest, v *time.Time) { r.ClosedBefore = v },
},
{
name: "defer",
set: func(issue *types.Issue, v time.Time) { issue.DeferUntil = &v },
nullable: true,
after: func(r *publicops.ListRequest, v *time.Time) { r.DeferAfter = v },
before: func(r *publicops.ListRequest, v *time.Time) { r.DeferBefore = v },
},
{
name: "due",
set: func(issue *types.Issue, v time.Time) { issue.DueAt = &v },
nullable: true,
after: func(r *publicops.ListRequest, v *time.Time) { r.DueAfter = v },
before: func(r *publicops.ListRequest, v *time.Time) { r.DueBefore = v },
},
} {
caseTag := "ltb" + family.name
ids := map[string]string{}
var scope []string
for _, inst := range instants {
id := readerID(fixture, caseTag, inst.tag)
ids[inst.tag] = id
scope = append(scope, id)
issue := readerIssue(id, types.TypeTask, "")
issue.CreatedAt, issue.UpdatedAt = created, created
family.set(issue, inst.at)
seedReaderIssue(t, ctx, fixture, issue)
}
if family.nullable {
id := readerID(fixture, caseTag, "null")
scope = append(scope, id)
issue := readerIssue(id, types.TypeTask, "")
issue.CreatedAt, issue.UpdatedAt = created, created
seedReaderIssue(t, ctx, fixture, issue)
}
idScope := readerIDFilter(scope...)
list := func(what string, apply func(*publicops.ListRequest, *time.Time), bound time.Time) []string {
t.Helper()
req := publicops.ListRequest{IDFilter: idScope, AllFlag: true}
apply(&req, &bound)
page, err := fixture.Reader.List(ctx, req)
if err != nil {
t.Fatalf("List (%s %s): %v", family.name, what, err)
}
assertReaderPageNotNil(t, "List ("+family.name+" "+what+")", page)
got := readerPageIDs(page)
slices.Sort(got)
return got
}
expect := func(what string, apply func(*publicops.ListRequest, *time.Time), bound time.Time, want string) {
t.Helper()
if got := list(what, apply, bound); !slices.Equal(got, []string{want}) {
t.Errorf("List (%s %s %s) = %v, want exactly [%s]", family.name, what, bound.Format(time.RFC3339Nano), got, want)
}
}
plus2 := time.FixedZone("UTC+2", 2*60*60)
for _, bound := range []struct {
what string
v time.Time
}{
{"at T", at},
{"at T with a sub-second remainder", at.Add(900 * time.Millisecond)},
{"at T spelled in a +02:00 zone", at.In(plus2)},
} {
expect("after "+bound.what, family.after, bound.v, ids["late"])
expect("before "+bound.what, family.before, bound.v, ids["early"])
}
// The NULL row is outside even the widest bounds on both ends.
if family.nullable {
wide := at.Add(-24 * time.Hour)
if got, want := list("after a day earlier", family.after, wide), sortedCopy(ids["early"], ids["exact"], ids["late"]); !slices.Equal(got, want) {
t.Errorf("List (%s after a day earlier) = %v, want %v — a NULL column never matches", family.name, got, want)
}
if got, want := list("before a day later", family.before, at.Add(24*time.Hour)), sortedCopy(ids["early"], ids["exact"], ids["late"]); !slices.Equal(got, want) {
t.Errorf("List (%s before a day later) = %v, want %v — a NULL column never matches", family.name, got, want)
}
}
}
}
// RunReaderListFilterFamiliesNarrowToTheirRows pins one included and one
// excluded row for each remaining ListRequest filter family that `bd list`
// publishes beyond the scope filters: the priority trio, the three text
// substrings, the empty-description and no-labels predicates, the top-level
// predicate, the type exclusion, the spec prefix, the label pattern and
// regex, the external-ref pair, the pinned-flag pair, the deferred and
// overdue predicates, the status exclusion and the molecule type.
//
// Each row is scoped by id and every arm asks AllFlag (the pinned arms
// excepted, which are about that interplay), so an arm whose filter the body
// dropped answers its whole scope and fails, and one whose filter the body
// inverted answers the other row.
//
// PinnedFlag with NoPinnedFlag is a contradiction, and the role refuses it as
// a validation error rather than letting one of the two silently win.
// ParentID with NoParent is refused the same way, as CountRequest refuses it.
func RunReaderListFilterFamiliesNarrowToTheirRows(t *testing.T, ctx context.Context, fixture ReaderFixture) {
t.Helper()
id := func(name string) string { return readerID(fixture, "lff", name) }
seed := func(name string, mutate func(*types.Issue)) string {
t.Helper()
issue := readerIssue(id(name), types.TypeTask, "")
if mutate != nil {
mutate(issue)
}
seedReaderIssue(t, ctx, fixture, issue)
return issue.ID
}
intp := func(v int) *int { return &v }
past := time.Now().UTC().Truncate(time.Second).Add(-48 * time.Hour)
future := time.Now().UTC().Truncate(time.Second).Add(48 * time.Hour)
label := readerLabel(fixture, "lffpat")
external := fixture.IssuePrefix + "-LFF-ext-17"
spec := "docs/" + fixture.IssuePrefix + "-lff/"
p0 := seed("p0", func(i *types.Issue) { i.Priority = 0 })
p2 := seed("p2", func(i *types.Issue) { i.Priority = 2 })
p4 := seed("p4", func(i *types.Issue) { i.Priority = 4 })
textT := seed("text-t", func(i *types.Issue) { i.Title = "a title carrying ttok-lff" })
textD := seed("text-d", func(i *types.Issue) { i.Description = "a description carrying dtok-lff" })
textN := seed("text-n", func(i *types.Issue) { i.Notes = "notes carrying ntok-lff" })
labeled := seed("labeled", func(i *types.Issue) { i.Labels = []string{label} })
unlabeled := seed("unlabeled", nil)
parent := seed("parent", func(i *types.Issue) { i.IssueType = types.TypeEpic })
child := seed("child", nil)
if err := fixture.AddDependency(ctx, &types.Dependency{IssueID: child, DependsOnID: parent, Type: types.DepParentChild}, "seed"); err != nil {
t.Fatalf("seed edge %s -> %s: %v", child, parent, err)
}
loose := seed("loose", nil)
typeTask := seed("type-task", nil)
typeBug := seed("type-bug", func(i *types.Issue) { i.IssueType = types.TypeBug })
typeChore := seed("type-chore", func(i *types.Issue) { i.IssueType = types.TypeChore })
specced := seed("specced", func(i *types.Issue) { i.SpecID = spec + "design.md" })
unspecced := seed("unspecced", nil)
extRow := seed("ext", func(i *types.Issue) { i.ExternalRef = &external })
extOther := seed("ext-other", func(i *types.Issue) {
other := fixture.IssuePrefix + "-other-99"
i.ExternalRef = &other
})
pinned := seed("pinned", func(i *types.Issue) { i.Pinned = true })
unpinned := seed("unpinned", nil)
deferred := seed("deferred", func(i *types.Issue) { i.DeferUntil = &future })
undeferred := seed("undeferred", nil)
overdue := seed("overdue", func(i *types.Issue) { i.DueAt = &past })
dueLater := seed("due-later", func(i *types.Issue) { i.DueAt = &future })
closedOverdue := seed("closed-overdue", func(i *types.Issue) {
i.Status = types.StatusClosed
closedAt := time.Now().UTC().Truncate(time.Second).Add(-time.Hour)
i.ClosedAt = &closedAt
i.DueAt = &past
})
noDue := seed("no-due", nil)
swarm := seed("mol-swarm", func(i *types.Issue) { i.MolType = types.MolTypeSwarm })
patrol := seed("mol-patrol", func(i *types.Issue) { i.MolType = types.MolTypePatrol })
stOpen := seed("st-open", nil)
stProgress := seed("st-progress", func(i *types.Issue) { i.Status = types.StatusInProgress })
stBlocked := seed("st-blocked", func(i *types.Issue) { i.Status = types.StatusBlocked })
stClosed := seed("st-closed", func(i *types.Issue) {
i.Status = types.StatusClosed
closedAt := time.Now().UTC().Truncate(time.Second).Add(-time.Hour)
i.ClosedAt = &closedAt
})
statusScope := readerIDFilter(stOpen, stProgress, stBlocked, stClosed)
molType := func(m types.MolType) *publicops.MolType { return &m }
scoped := func(ids ...string) publicops.ListRequest {
return publicops.ListRequest{IDFilter: readerIDFilter(ids...), AllFlag: true}
}
with := func(req publicops.ListRequest, mutate func(*publicops.ListRequest)) publicops.ListRequest {
mutate(&req)
return req
}
for _, test := range []struct {
name string
req publicops.ListRequest
want []string
}{
{"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}},
} {
page, err := fixture.Reader.List(ctx, test.req)
if err != nil {
t.Errorf("List (%s): %v", test.name, err)
continue
}
assertReaderPageIDSet(t, "List ("+test.name+")", page, test.want)
}
// An exclusion naming no status in the workspace vocabulary is refused,
// never an exclusion that silently excludes nothing.
if _, err := fixture.Reader.List(ctx, publicops.ListRequest{IDFilter: statusScope, ExcludeStatus: []string{"clsoed"}}); !errors.Is(err, publicops.ErrValidation) {
t.Errorf("List with ExcludeStatus naming an unknown status = %v, want an error wrapping ErrValidation", err)
}
_, err := fixture.Reader.List(ctx, publicops.ListRequest{
IDFilter: readerIDFilter(pinned, unpinned), PinnedFlag: true, NoPinnedFlag: true,
})
if !errors.Is(err, publicops.ErrValidation) {
t.Errorf("List with PinnedFlag and NoPinnedFlag = %v, want an error wrapping ErrValidation", err)
}
_, err = fixture.Reader.List(ctx, publicops.ListRequest{
IDFilter: readerIDFilter(parent, child, loose), ParentID: parent, NoParent: true,
})
if !errors.Is(err, publicops.ErrValidation) {
t.Errorf("List with ParentID and NoParent = %v, want an error wrapping ErrValidation", err)
}
}
// sortedCopy returns its arguments as a sorted slice.
func sortedCopy(ids ...string) []string {
out := slices.Clone(ids)
slices.Sort(out)
return out
}
// readerIssue builds the seed every case starts from: an open, unassigned,
// unblocked task that qualifies for ready work. A case that needs it to fail one
// of those tests changes the field it means to test and nothing else.

View file

@ -769,7 +769,21 @@ type EpochFixture struct {
// Version now resolves to under the new epoch. A nil hook means this
// backend cannot report that, and the case that needs it skips with
// that reason.
//
// It only reads: it mints nothing and changes no state. It returns the
// address it was given when nothing carried the Version to a new one,
// and an error for an address the store does not serve.
CurrentAddressFor func(ctx context.Context, storeID string, oldAddress Address) (Address, error)
// LoseVersion records that storeID no longer serves the Version named by
// address. That address, and every address the same Version was carried
// to or from by a token-scheme change, resolves GoneReorganization from
// then on, in every later epoch: an epoch voids what the store lost,
// never what it still serves (R20-n). It is idempotent, never revives
// anything, and returns an error for an address storeID never minted. A
// nil LoseVersion means this backend cannot record a loss, and the cases
// that need one skip with that reason.
LoseVersion func(ctx context.Context, storeID string, address Address) error
}
// RunAnEpochBumpIsTriggeredOnlyByRestoreReinitOrSchemeChange pins R20-m: a
@ -819,94 +833,258 @@ func RunAnEpochBumpIsTriggeredOnlyByRestoreReinitOrSchemeChange(t *testing.T, ct
// RunEpochBumpVoidsOnlyAddressesOfVersionsNoLongerServed pins R20-n — "Rev7
// tightening... the clause most likely to be gotten wrong" in the
// architecture doc's own words. A prior-epoch Address goes
// GoneReorganization UNLESS the backend still serves that Version, in which
// case it must stay Live AND additionally report the Address it now
// resolves to under the new epoch.
// architecture doc's own words: an epoch voids what the store lost, never
// what it still serves.
//
// StillServes is an ORACLE here, not a control: this case cannot make a real
// backend keep serving one address and drop another, since Phase 0 wires no
// real backend. It asks StillServes what the fixture (once real) decided,
// and checks the rest of the contract's promise against that decision for
// both outcomes.
// Survival is RECORDED, never inferred (gastownhall/beads#6664, bee-ghosttrack
// review 5360880888, Major 1). An earlier form of this case made a Version
// survive by minting it again in every later epoch, and treated a Version
// nobody minted again as lost. That reads loss off the absence of a mint, so
// it could not express a Version the store lost after minting it, and it
// voided every survivor that nobody happened to mint again. Here a restore or
// a destructive reinit leaves every address row alone: an address the store
// still serves stays Live at its own address with no upkeep, and the only way
// an address goes Gone is LoseVersion saying so.
//
// Each phase is a named subtest, so a backend that cannot record a loss skips
// only the phases that need LoseVersion, and a failure names its phase.
func RunEpochBumpVoidsOnlyAddressesOfVersionsNoLongerServed(t *testing.T, ctx context.Context, fixture EpochFixture) {
t.Helper()
if fixture.MintUnderEpoch == nil {
t.Skip("this backend has no way to mint a Version under a known epoch (MintUnderEpoch is nil)")
}
if fixture.BumpEpoch == nil {
t.Skip("this backend has no epoch concept yet (BumpEpoch is nil)")
}
if fixture.StillServes == nil {
t.Skip("this backend cannot report whether it still serves a prior-epoch Version (StillServes is nil)")
}
if fixture.Resolve == nil {
t.Skip("this backend does not yet report retention state (Resolve is nil)")
}
if fixture.CurrentAddressFor == nil {
t.Skip("this backend cannot report a still-served Version's new Address (CurrentAddressFor is nil)")
}
store := epochStore(fixture, "voids")
epochSkipUnlessReady(t, fixture, false)
addrA, err := fixture.MintUnderEpoch(ctx, store, "record-a")
if err != nil {
t.Fatalf("MintUnderEpoch(record-a): %v", err)
// survivor-and-lost: of two Versions minted before a transition, the one
// the store loses goes Gone and the other stays Live at the address it
// already had, with no re-mint, for both triggers that leave addresses
// alone.
t.Run("survivor-and-lost", func(t *testing.T) {
if fixture.LoseVersion == nil {
t.Skip(epochLoseVersionSkip)
}
for _, trigger := range []EpochBumpTrigger{EpochBumpTriggerRestore, EpochBumpTriggerDestructiveReinit} {
t.Run(trigger.String(), func(t *testing.T) {
store := epochStore(fixture, "survivor-"+trigger.String())
addrA := epochMintAddress(t, ctx, fixture, store, "record-a")
addrB := epochMintAddress(t, ctx, fixture, store, "record-b")
newEpoch := epochBumpTo(t, ctx, fixture, store, trigger)
epochLoseAddress(t, ctx, fixture, store, addrB)
epochRequireLive(t, ctx, fixture, store, addrA, newEpoch,
"record-a was never lost, so the transition leaves it served at its own address with no re-mint (R20-n's exception)")
epochRequireGone(t, ctx, fixture, store, addrB, newEpoch,
"record-b was lost, so the transition voids it (R20-n)")
current := epochCurrentAddress(t, ctx, fixture, store, addrA)
epochRequireLive(t, ctx, fixture, store, current, newEpoch,
"the address CurrentAddressFor reports for a survivor must be served")
epochRequireLive(t, ctx, fixture, store, addrA, newEpoch,
"asking CurrentAddressFor must not retire or move the survivor's address")
if lostCurrent, err := fixture.CurrentAddressFor(ctx, store, addrB); err == nil {
t.Errorf("CurrentAddressFor(a lost address) = %s with no error, want an error: a lost Version has no current address", lostCurrent)
}
epochRequireGone(t, ctx, fixture, store, addrB, newEpoch,
"CurrentAddressFor on a lost address must not bring it back")
})
}
})
// gone-is-terminal: once an address is lost it stays lost. A later mint of
// the same id starts a new lineage under a new address, and neither that
// mint nor CurrentAddressFor revives the lost one (bee-ghosttrack's
// assertion for Major 1: a read-only lookup must not mint a replacement
// that makes a lost address look served).
t.Run("gone-is-terminal", func(t *testing.T) {
if fixture.LoseVersion == nil {
t.Skip(epochLoseVersionSkip)
}
store := epochStore(fixture, "terminal")
lost := epochMintAddress(t, ctx, fixture, store, "record-g")
epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
epochLoseAddress(t, ctx, fixture, store, lost)
laterEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
fresh := epochMintAddress(t, ctx, fixture, store, "record-g")
if fresh == lost {
t.Fatalf("MintUnderEpoch(record-g) returned %s, the address already lost: a lost address is never handed out again", lost)
}
epochRequireLive(t, ctx, fixture, store, fresh, laterEpoch,
"a fresh mint of the id is a new lineage and is served")
epochRequireGone(t, ctx, fixture, store, lost, laterEpoch,
"a later mint of the same id must not revive a lost address")
if replacement, err := fixture.CurrentAddressFor(ctx, store, lost); err == nil {
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)
}
epochRequireGone(t, ctx, fixture, store, lost, laterEpoch,
"CurrentAddressFor on a lost address must not revive it")
// Losing it a second time is a no-op that leaves the fresh lineage
// alone.
epochLoseAddress(t, ctx, fixture, store, lost)
epochRequireLive(t, ctx, fixture, store, fresh, laterEpoch,
"losing the old address again must leave the fresh lineage served")
})
// survival-needs-no-upkeep: with nothing lost, an address stays Live across
// any number of counter-only transitions without being minted again, and a
// later mint of the same id neither retires it nor revives anything. This
// is the phase the earlier, mint-driven form failed: it answered Gone for
// every survivor nobody minted again.
t.Run("survival-needs-no-upkeep", func(t *testing.T) {
store := epochStore(fixture, "upkeep")
kept := epochMintAddress(t, ctx, fixture, store, "record-c")
epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerDestructiveReinit)
finalEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
epochRequireLive(t, ctx, fixture, store, kept, finalEpoch,
"nothing was lost, so three counter-only transitions leave the address served without a re-mint")
fresh := epochMintAddress(t, ctx, fixture, store, "record-c")
if fresh == kept {
t.Fatalf("MintUnderEpoch(record-c) returned %s again after three bumps, want a new address for the new epoch", kept)
}
epochRequireLive(t, ctx, fixture, store, kept, finalEpoch,
"a later mint of the same id must not retire a served address")
epochRequireLive(t, ctx, fixture, store, fresh, finalEpoch,
"the fresh mint is served")
current := epochCurrentAddress(t, ctx, fixture, store, kept)
epochRequireLive(t, ctx, fixture, store, current, finalEpoch,
"the current address of a survivor must be served")
epochRequireLive(t, ctx, fixture, store, kept, finalEpoch,
"asking for the current address must not change the survivor")
})
}
// RunTokenSchemeChangeCarriesLiveAddressesAndOnlyThose pins R20-n's retained
// mapping for the one trigger that changes how addresses are encoded. A
// token-scheme-change bump gives every Version the store still serves a new
// address under the new epoch and keeps the old address resolving, so a holder
// of the old address is neither stranded nor pointed at something else. A
// Version the store already lost gets no new address and stays Gone.
func RunTokenSchemeChangeCarriesLiveAddressesAndOnlyThose(t *testing.T, ctx context.Context, fixture EpochFixture) {
t.Helper()
epochSkipUnlessReady(t, fixture, true)
store := epochStore(fixture, "scheme-change")
addrA := epochMintAddress(t, ctx, fixture, store, "record-a")
addrB := epochMintAddress(t, ctx, fixture, store, "record-b")
// record-b is lost in the epoch it was minted in, which a store may do.
epochLoseAddress(t, ctx, fixture, store, addrB)
newEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerTokenSchemeChange)
epochRequireLive(t, ctx, fixture, store, addrA, newEpoch,
"record-a is still served after the scheme change, through the retained mapping")
epochRequireGone(t, ctx, fixture, store, addrB, newEpoch,
"record-b was lost before the scheme change, which must not carry it")
carried := epochCurrentAddress(t, ctx, fixture, store, addrA)
if carried == addrA {
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)
}
addrB, err := fixture.MintUnderEpoch(ctx, store, "record-b")
if err != nil {
t.Fatalf("MintUnderEpoch(record-b): %v", err)
epochRequireLive(t, ctx, fixture, store, carried, newEpoch,
"the carried address must be served under the new epoch")
epochRequireLive(t, ctx, fixture, store, addrA, newEpoch,
"the old address must keep resolving after its carried address is looked up")
if again := epochCurrentAddress(t, ctx, fixture, store, carried); again != carried {
t.Errorf("CurrentAddressFor(%s) = %s, want the carried address itself: from the newest address the mapping is already current", carried, again)
}
if lostCurrent, err := fixture.CurrentAddressFor(ctx, store, addrB); err == nil {
t.Errorf("CurrentAddressFor(a lost address) = %s with no error, want an error: a lost Version is not carried", lostCurrent)
}
}
// RunACarriedAddressKeepsResolvingAcrossLaterBumps pins that a carried mapping
// is recorded once and then simply persists: later counter-only transitions do
// not change it, and a second token-scheme change extends it to the newest
// address without breaking any older one. Every address of the Version points
// directly at the newest address (one hop from any member), never along a
// chain.
func RunACarriedAddressKeepsResolvingAcrossLaterBumps(t *testing.T, ctx context.Context, fixture EpochFixture) {
t.Helper()
epochSkipUnlessReady(t, fixture, false)
store := epochStore(fixture, "carried-later")
addrA := epochMintAddress(t, ctx, fixture, store, "record-a")
epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerTokenSchemeChange)
addrA1 := epochCurrentAddress(t, ctx, fixture, store, addrA)
if addrA1 == addrA {
t.Fatalf("CurrentAddressFor(%s) = the same address after a token-scheme change, want a new one", addrA)
}
newEpoch, err := fixture.BumpEpoch(ctx, store, EpochBumpTriggerRestore)
if err != nil {
t.Fatalf("BumpEpoch: %v", err)
// Two counter-only transitions, with nothing minted in between.
epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
counterEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerDestructiveReinit)
epochRequireLive(t, ctx, fixture, store, addrA, counterEpoch,
"the original address must still resolve after counter-only transitions")
epochRequireLive(t, ctx, fixture, store, addrA1, counterEpoch,
"the carried address must still resolve after counter-only transitions")
if got := epochCurrentAddress(t, ctx, fixture, store, addrA); got != addrA1 {
t.Errorf("CurrentAddressFor(%s) = %s, want %s: a counter-only transition does not change the mapping", addrA, got, addrA1)
}
servesA, err := fixture.StillServes(ctx, store, addrA)
if err != nil {
t.Fatalf("StillServes(%s): %v", addrA, err)
// A second scheme change carries the Version again.
secondEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerTokenSchemeChange)
addrA2 := epochCurrentAddress(t, ctx, fixture, store, addrA)
if addrA2 == addrA || addrA2 == addrA1 {
t.Fatalf("CurrentAddressFor(%s) = %s after a second scheme change, want an address different from %s and %s", addrA, addrA2, addrA, addrA1)
}
servesB, err := fixture.StillServes(ctx, store, addrB)
if err != nil {
t.Fatalf("StillServes(%s): %v", addrB, err)
for _, member := range []Address{addrA, addrA1, addrA2} {
epochRequireLive(t, ctx, fixture, store, member, secondEpoch,
"every address of a carried Version must resolve after a second scheme change")
}
if servesA == 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")
if got := epochCurrentAddress(t, ctx, fixture, store, addrA1); got != addrA2 {
t.Errorf("CurrentAddressFor(%s) = %s, want %s: every address of the Version points straight at the newest one", addrA1, got, addrA2)
}
stillServed, noLongerServed := addrA, addrB
if servesB && !servesA {
stillServed, noLongerServed = addrB, addrA
finalEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
epochRequireLive(t, ctx, fixture, store, addrA2, finalEpoch,
"the newest carried address must still resolve after a later restore")
}
// RunALostAddressStaysGoneAcrossASchemeChange pins that loss is terminal even
// across a token-scheme change. Losing a Version loses every address of its
// lineage at once, and a later scheme change must not carry a lost lineage
// back into service.
func RunALostAddressStaysGoneAcrossASchemeChange(t *testing.T, ctx context.Context, fixture EpochFixture) {
t.Helper()
epochSkipUnlessReady(t, fixture, true)
store := epochStore(fixture, "lost-scheme-change")
addrA := epochMintAddress(t, ctx, fixture, store, "record-a")
epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerTokenSchemeChange)
addrA1 := epochCurrentAddress(t, ctx, fixture, store, addrA)
lostEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerRestore)
// One lineage, two addresses: losing either loses both.
epochLoseAddress(t, ctx, fixture, store, addrA)
epochRequireGone(t, ctx, fixture, store, addrA, lostEpoch,
"the original address of a lost Version must be Gone")
epochRequireGone(t, ctx, fixture, store, addrA1, lostEpoch,
"the carried address of a lost Version must be Gone too")
schemeEpoch := epochBumpTo(t, ctx, fixture, store, EpochBumpTriggerTokenSchemeChange)
epochRequireGone(t, ctx, fixture, store, addrA, schemeEpoch,
"a later scheme change must not carry a lost lineage back into service")
epochRequireGone(t, ctx, fixture, store, addrA1, schemeEpoch,
"a later scheme change must not carry a lost lineage back into service")
for _, lostAddress := range []Address{addrA, addrA1} {
if current, err := fixture.CurrentAddressFor(ctx, store, lostAddress); err == nil {
t.Errorf("CurrentAddressFor(%s) = %s with no error, want an error: a lost lineage has no current address", lostAddress, current)
}
}
voidedAnswer, err := fixture.Resolve(ctx, store, noLongerServed)
if err != nil {
t.Fatalf("Resolve(no-longer-served): %v", err)
}
if voidedAnswer.Restriction != RestrictionGoneReorganization {
t.Errorf("Resolve(a prior-epoch Address no longer served) = %s, want RestrictionGoneReorganization (R20-n)", voidedAnswer.Restriction)
}
if voidedAnswer.Epoch == nil {
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)")
} else if *voidedAnswer.Epoch != newEpoch {
t.Errorf("Resolve(a prior-epoch Address no longer served).Epoch = %d, want the current epoch %d", *voidedAnswer.Epoch, newEpoch)
}
keptAnswer, err := fixture.Resolve(ctx, store, stillServed)
if err != nil {
t.Fatalf("Resolve(still-served): %v", err)
}
if keptAnswer.Restriction != RestrictionLive {
t.Errorf("Resolve(a prior-epoch Address the backend still serves) = %s, want RestrictionLive (R20-n's exception)", keptAnswer.Restriction)
}
newAddr, err := fixture.CurrentAddressFor(ctx, store, stillServed)
if err != nil {
t.Fatalf("CurrentAddressFor(%s): %v", stillServed, err)
}
if newAddr == "" {
t.Error("CurrentAddressFor(a still-served prior-epoch Address) returned an empty Address, want a real one under the new epoch")
fresh := epochMintAddress(t, ctx, fixture, store, "record-a")
if fresh == addrA || fresh == addrA1 {
t.Fatalf("MintUnderEpoch(record-a) returned %s, an address of the lost lineage: a lost address is never handed out again", fresh)
}
epochRequireLive(t, ctx, fixture, store, fresh, schemeEpoch,
"a fresh mint of the id after the loss is a new lineage and is served")
}
// --- fixture helpers -------------------------------------------------------
@ -953,6 +1131,137 @@ func epochStore(fixture EpochFixture, tag string) string {
return fixture.IssuePrefix + "-epoch-store-" + tag
}
// epochLoseVersionSkip is the skip reason of every phase that needs
// EpochFixture.LoseVersion.
const epochLoseVersionSkip = "this backend cannot record that the store lost a Version (LoseVersion is nil)"
// epochSkipUnlessReady skips the case when the fixture lacks a capability the
// epoch cases need. The cases that record a loss also need LoseVersion. The
// all-nil wiring test runs every case against an empty fixture, so each case
// must call this before it touches any of them.
func epochSkipUnlessReady(t *testing.T, fixture EpochFixture, needsLoseVersion bool) {
t.Helper()
if fixture.MintUnderEpoch == nil {
t.Skip("this backend has no way to mint a Version under a known epoch (MintUnderEpoch is nil)")
}
if fixture.BumpEpoch == nil {
t.Skip("this backend has no epoch concept yet (BumpEpoch is nil)")
}
if fixture.StillServes == nil {
t.Skip("this backend cannot report whether it still serves a prior-epoch Version (StillServes is nil)")
}
if fixture.Resolve == nil {
t.Skip("this backend does not yet report retention state (Resolve is nil)")
}
if fixture.CurrentAddressFor == nil {
t.Skip("this backend cannot report a still-served Version's new Address (CurrentAddressFor is nil)")
}
if needsLoseVersion && fixture.LoseVersion == nil {
t.Skip(epochLoseVersionSkip)
}
}
// epochMintAddress mints id on store, failing the case if minting fails.
func epochMintAddress(t *testing.T, ctx context.Context, fixture EpochFixture, store, id string) Address {
t.Helper()
address, err := fixture.MintUnderEpoch(ctx, store, id)
if err != nil {
t.Fatalf("MintUnderEpoch(%s, %s): %v", store, id, err)
}
return address
}
// epochBumpTo bumps store's epoch for trigger and returns the epoch it
// reports. Epochs are captured from the return value, never assumed: the
// counter is one per database, shared by every store the suite uses.
func epochBumpTo(t *testing.T, ctx context.Context, fixture EpochFixture, store string, trigger EpochBumpTrigger) int {
t.Helper()
epoch, err := fixture.BumpEpoch(ctx, store, trigger)
if err != nil {
t.Fatalf("BumpEpoch(%s, %s): %v", store, trigger, err)
}
return epoch
}
// epochLoseAddress records that store lost the Version behind address.
func epochLoseAddress(t *testing.T, ctx context.Context, fixture EpochFixture, store string, address Address) {
t.Helper()
if err := fixture.LoseVersion(ctx, store, address); err != nil {
t.Fatalf("LoseVersion(%s, %s): %v", store, address, err)
}
}
// epochCurrentAddress asks where address now resolves, failing the case on an
// error or an empty answer.
func epochCurrentAddress(t *testing.T, ctx context.Context, fixture EpochFixture, store string, address Address) Address {
t.Helper()
current, err := fixture.CurrentAddressFor(ctx, store, address)
if err != nil {
t.Fatalf("CurrentAddressFor(%s, %s): %v", store, address, err)
}
if current == "" {
t.Fatalf("CurrentAddressFor(%s, %s) returned an empty Address, want a real one", store, address)
}
return current
}
// epochRequireLive asserts that address is served at epoch: StillServes is true
// and Resolve answers RestrictionLive naming that epoch. why says what the
// assertion is checking, for the failure message.
func epochRequireLive(t *testing.T, ctx context.Context, fixture EpochFixture, store string, address Address, epoch int, why string) {
t.Helper()
serves, err := fixture.StillServes(ctx, store, address)
if err != nil {
t.Fatalf("StillServes(%s): %v", address, err)
}
if !serves {
t.Errorf("StillServes(%s) = false, want true: %s", address, why)
}
answer, err := fixture.Resolve(ctx, store, address)
if err != nil {
t.Fatalf("Resolve(%s): %v", address, err)
}
if answer.Restriction != RestrictionLive {
t.Errorf("Resolve(%s) = %s, want RestrictionLive: %s", address, answer.Restriction, why)
}
epochRequireAnswerEpoch(t, answer, address, epoch, why)
}
// epochRequireGone asserts that address is no longer served at epoch:
// StillServes is false and Resolve answers RestrictionGoneReorganization
// naming that epoch.
func epochRequireGone(t *testing.T, ctx context.Context, fixture EpochFixture, store string, address Address, epoch int, why string) {
t.Helper()
serves, err := fixture.StillServes(ctx, store, address)
if err != nil {
t.Fatalf("StillServes(%s): %v", address, err)
}
if serves {
t.Errorf("StillServes(%s) = true, want false: %s", address, why)
}
answer, err := fixture.Resolve(ctx, store, address)
if err != nil {
t.Fatalf("Resolve(%s): %v", address, err)
}
if answer.Restriction != RestrictionGoneReorganization {
t.Errorf("Resolve(%s) = %s, want RestrictionGoneReorganization: %s", address, answer.Restriction, why)
}
epochRequireAnswerEpoch(t, answer, address, epoch, why)
}
// epochRequireAnswerEpoch asserts that a Live or Gone answer names the current
// epoch (R20-n: the answer carries the epoch, not just the Restriction).
func epochRequireAnswerEpoch(t *testing.T, answer RetentionAnswer, address Address, epoch int, why string) {
t.Helper()
if answer.Epoch == nil {
t.Errorf("Resolve(%s).Epoch = nil, want the current epoch %d: %s", address, epoch, why)
return
}
if *answer.Epoch != epoch {
t.Errorf("Resolve(%s).Epoch = %d, want the current epoch %d: %s", address, *answer.Epoch, epoch, why)
}
}
// sameRetentionAnswer compares two RetentionAnswer values by content rather
// than identity, so a case can assert "this did not change" without
// depending on the concrete Restriction the backend happened to pick.

View file

@ -44,6 +44,10 @@ var roleContractCases = []roleContract{
RunBatchApplyRefusesACrossPlaneEdgeBetweenRowsItCreated,
RunBatchApplyAcceptsAnExternalEdgeTarget,
RunBatchApplyNormalizesTheWaitsForGate,
RunBatchApplyStampsSpawnerIDOnlyWhenNamed,
RunBatchApplyCarriesThreadIDOntoTheStoredEdge,
RunBatchApplyCarriesThreadIDOntoAnExistingEdge,
RunBatchApplyRefusesAThreadIDLongerThanItsColumn,
RunBatchApplySplicesAForwardMetadataRef,
RunBatchApplySplicesASelfMetadataRef,
RunBatchApplyRefusesAMetadataRefNoItemDeclares,
@ -54,6 +58,12 @@ var roleContractCases = []roleContract{
RunBatchApplyReplayMintsANewSetOfRows,
RunBatchApplyDoesNotMutateTheCallerRequest,
RunBatchApplyRefusesAnUnusableRequest,
RunBatchApplyUpdateItemsRefuseATemplate,
RunBatchApplySplicesTheMetadataOfATemplateItCreates,
RunBatchApplyCloseItemsAnswerToTheCloseGuards,
RunBatchApplyRefusesADottedChildGatedOnItsOwnParent,
RunBatchApplyAppliesTheDefaultPriority,
RunBatchApplyCarriesTheGateMembers,
),
roleCases("BatchCloser", "BatchCloser()", oncePerRole,
@ -78,6 +88,7 @@ var roleContractCases = []roleContract{
RunBatchCloserAllRefusedBatchRecordsNoHistory,
RunBatchCloserDoesNotMutateTheCallerRequest,
RunBatchCloserSettlesTheDependersOfWhatItClosed,
RunBatchCloserItemsAnswerToTheCloseGuards,
),
roleCases("BatchCreator", "BatchCreator()", oncePerRole,
@ -95,6 +106,7 @@ var roleContractCases = []roleContract{
RunBatchCreatorRecordsNoHistoryForAnEphemeralBatch,
RunBatchCreatorDoesNotMutateTheCallerRequest,
RunBatchCreatorEchoesSubSecondTimestamps,
RunBatchCreatorAppliesTheDefaultPriority,
),
roleCases("BlockingAnnotator", "BlockingAnnotator()", oncePerRole,
@ -116,6 +128,7 @@ var roleContractCases = []roleContract{
RunBlockingAnnotatorRefusesAnEmptyID,
RunBlockingAnnotatorLeavesTheRequestAlone,
RunBlockingAnnotatorWritesNothing,
RunBlockingAnnotatorReportsTheTransitiveBlockedFlag,
),
// One contract file covers both halves of workspace identity: the eight
@ -259,6 +272,7 @@ var roleContractCases = []roleContract{
RunDependencyEditorSameTypeReAddIsIdempotent,
RunDependencyEditorSameTypeReAddWithChangedMetadataMintsOneVersion,
RunDependencyEditorSameTypeReAddWithIdenticalMetadataIsANoOp,
RunDependencyEditorSameTypeReAddWithChangedThreadMintsOneVersion,
RunDependencyEditorRepeatsWithinOneRequestCollapse,
RunDependencyEditorAttributesItsEventsToTheActor,
RunDependencyEditorRetypeRefusalLeavesTheOriginalEdge,
@ -292,6 +306,7 @@ var roleContractCases = []roleContract{
RunDependencyEditorAcceptsADiamond,
RunDependencyEditorGateScopeFollowsTheEdgeType,
RunDependencyEditorAcceptsBlockingAcrossIssueTypes,
RunDependencyEditorRefusesADottedChildGatedOnItsOwnParent,
),
// The accessor named here is not an accessor at all, alone among these
@ -428,12 +443,14 @@ var roleContractCases = []roleContract{
RunLifecycleExpectedVersionIsCheckedBeforeTheNoOps,
RunLifecycleReopenRecordsItsReason,
RunLifecycleResultsAreHydratedPostStateSnapshots,
RunLifecycleResultsCarryThePostWriteRowVersion,
RunLifecycleCloseAndReopenRequireActorAndIssueID,
RunLifecycleReopenProvenanceLabelsHistory,
RunLifecycleCloseSettlesItsTransitiveAndCrossPlaneDependers,
RunLifecycleCloseSettlesTheClosedRowItselfAndItsChild,
RunLifecycleCloseOnASpawnersLastChildSatisfiesAWaitsForGate,
RunLifecycleReopenReblocksItsDependers,
RunLifecycleCloseEnforcesTheCloseGuards,
),
// The accessor-reachable half of Lifecycle.Create, moved out of the staging
@ -446,6 +463,9 @@ var roleContractCases = []roleContract{
RunLifecycleCreateInheritsParentLabels,
RunLifecycleCreateWritesEveryScalarField,
RunLifecycleCreateEchoesSubSecondTimestamps,
RunLifecycleCreateAppliesTheDefaultPriority,
RunLifecycleCreateWritesTheGateMembers,
RunLifecycleCreateBoundsTheGateMembers,
),
roleCases("LifecycleUpdate", "IssueLifecycle()", oncePerRole,
@ -472,7 +492,13 @@ var roleContractCases = []roleContract{
RunLifecycleUpdateParentIDReplacesTheParentEdge,
RunLifecycleUpdateParentIDReplacesEveryParent,
RunLifecycleUpdatePersistentPreservesUnversionedClass,
RunLifecycleUpdateWispModesRefuseAnUnversionedRow,
RunLifecycleUpdatePersistentPromotesAWisp,
RunLifecycleUpdateProvenanceLabelsHistory,
RunLifecycleUpdateRefusesATemplate,
RunLifecycleUpdateAllowTemplateEditsATemplate,
RunLifecycleUpdatePatchesTheGateMembers,
RunLifecycleUpdateBoundsTheGateMembers,
),
roleCases("Memories", "Memories()", oncePerRole,
@ -487,7 +513,7 @@ var roleContractCases = []roleContract{
RunMemoriesRememberRefusesAnUnderivableKey,
RunMemoriesRecallAnswersTheStoredValue,
RunMemoriesRecallReportsAMissAsNotFoundNotAnError,
RunMemoriesRecallConflatesStoredEmptyWithAbsent,
RunMemoriesEmptyRowIsPresentUntilForgotten,
RunMemoriesForgetRemovesExactlyTheNamedRow,
RunMemoriesForgetNeverTouchesTheSettingsPlane,
RunMemoriesForgetReportsTheForgottenValue,
@ -550,6 +576,7 @@ var roleContractCases = []roleContract{
RunReaderListKeysetPositionResumesTheCreatedDescIDAscOrder,
RunReaderListReadyFlagAnswersTheBlockerAwareSet,
RunReaderListReadyFlagRefusesAFilterItCannotCarry,
RunReaderListQueryMatchesTheTitleOrTheID,
RunReaderListEmptyPageIsWellFormed,
RunReaderListMaxRowsIsHonored,
RunReaderListMaxRowsBoundaryIsLimitPlusOffset,
@ -577,6 +604,8 @@ var roleContractCases = []roleContract{
RunReaderListWispTypeNarrowsTheAdmittedPlaneRatherThanAdmittingIt,
RunReaderListBriefDropsTheFreeFormTextAndNothingElse,
RunReaderReadyBriefDropsTheFreeFormTextAndNothingElse,
RunReaderListTimeBoundsAreStrictAndWholeSecond,
RunReaderListFilterFamiliesNarrowToTheirRows,
),
roleCases("ReadyClaimer", "ReadyClaimer() and IssueReader()", oncePerRole,

View file

@ -129,5 +129,14 @@ func TestVersionedHistoryPhase0RunsInFullSkipMode(t *testing.T) {
t.Run("EpochBumpVoidsOnlyAddressesOfVersionsNoLongerServed", func(t *testing.T) {
RunEpochBumpVoidsOnlyAddressesOfVersionsNoLongerServed(t, ctx, fixture)
})
t.Run("TokenSchemeChangeCarriesLiveAddressesAndOnlyThose", func(t *testing.T) {
RunTokenSchemeChangeCarriesLiveAddressesAndOnlyThose(t, ctx, fixture)
})
t.Run("ACarriedAddressKeepsResolvingAcrossLaterBumps", func(t *testing.T) {
RunACarriedAddressKeepsResolvingAcrossLaterBumps(t, ctx, fixture)
})
t.Run("ALostAddressStaysGoneAcrossASchemeChange", func(t *testing.T) {
RunALostAddressStaysGoneAcrossASchemeChange(t, ctx, fixture)
})
})
}

View file

@ -0,0 +1,356 @@
package conformance
import (
"context"
"testing"
"time"
)
// This file holds the contract for R7.1 (gastownhall/beads#6136, design doc
// gastownhall/beads#5898 revision 9): the as-of read — the "versioned
// reads" half of Phase 3's title, authored here from scratch, since no
// fixture for it exists anywhere in this package to un-skip.
//
// R7.1, VERBATIM (design doc #5898 rev 9): "An as-of read is a named read
// whose selector is an instant. Given an instant T or a version address, a
// store returns one Bead's durable state as of that point — the latest
// version it holds that was accepted at or before T, with everything later
// excluded — under R7's record shape, marking the address it served, or
// refuses as gone or unknown with the reason (R8, R20). Like every history
// answer it is complete for the answering store's holdings and may change
// after a sync (TC3)."
//
// ADDRESS, RESTRICTION, AND CHANGEATTRIBUTION ARE DECLARED IN
// expected_revision_contract.go — see that file's package-level note on
// where this suite's shared vocabulary lives and why. This file reuses
// Restriction's five values as-is for the gone-or-unknown refusal outcome
// (R8): an as-of read never invents a sixth state, and never distinguishes
// "gone" from "unknown" any differently than R20 already does.
//
// EVERY HOOK ON THE FIXTURE BELOW IS INDEPENDENTLY NILABLE — see the
// package-level note in expected_revision_contract.go. Every case
// nil-checks every hook it uses and SKIPS BY NAME when one is missing. No
// backend implements as-of reads yet — the implementation is
// the child this suite is written ahead of.
//
// EXPLICIT NON-GOAL: MEMORY-PLANE CONSUMER POLICY IS NOT PART OF THIS
// PRIMITIVE. R7.1's own text is explicit that a closed-before-T boundary,
// sibling exclusion, and supersession exclusion "are Memory-plane policies
// a consumer layers on this primitive (#5877), not part of it." This suite
// does not implement or assert any of the three — a future reader who finds
// them absent should read that as this file honoring R7.1's own scope, not
// as an oversight. This is the read-side analog of the R16/R16.1 boundary
// risk already recorded in expected_revision_contract.go: do not conflate
// the primitive with policy layered on top of it.
//
// THIS SUITE ASSERTS LOCAL COMPLETENESS ONLY (TC3). Nothing below requires,
// or even checks, that two stores asked about the same lineage agree — R7.1
// itself says an as-of answer "may change after a sync," so two stores at
// different sync points are expected to answer differently, and neither is
// wrong. RunAsOfReadIsCompleteOnlyForTheAnsweringStoresHoldings is the one
// case that touches more than one store, and what it asserts is exactly
// this: each store answers strictly from its own holdings, never a
// sibling's — not that the two agree.
// AsOfSelector names the point R7.1 resolves against: either a wall-clock
// instant, or a specific version Address treated as the selector itself —
// "the read that names its own answer" (R7.1: "an instant T or a version
// address"). Exactly one of At/Version is populated in every case this file
// exercises; R7.1 does not speak to the shape where both or neither are
// set, so this suite does not either.
type AsOfSelector struct {
At *time.Time
Version *Address
}
// AsOfReadRefusal is R8's typed outcome for an as-of read that cannot be
// answered. Restriction is always one of the four Gone*/Unknown values,
// never RestrictionLive — a live answer is a served AsOfReadResult, not a
// refusal. Reason explains why (R8).
type AsOfReadRefusal struct {
Restriction Restriction
Reason string
}
// AsOfReadResult is the outcome of an as-of read (R7.1). Address/State and
// Refusal are mutually exclusive: read Address/State only when Refusal is
// nil.
type AsOfReadResult struct {
// Address is the version this read served, marking "the address it
// served" (R7.1). Populated only when Refusal is nil.
Address Address
// State is the served version's durable state under R7's record shape.
// Opaque to this suite: the fixture adapter translates a backend's real
// record shape into this map, and no case here asserts its field-level
// content — only that a served result carries an Address.
State map[string]any
// Refusal is populated instead of Address/State when the read cannot be
// answered (R8). Nil means the read was served.
Refusal *AsOfReadRefusal
}
// AsOfRead resolves storeID's answer to an as-of read against id's lineage,
// at selector (R7.1).
type AsOfRead func(ctx context.Context, storeID, id string, selector AsOfSelector) (AsOfReadResult, error)
// AsOfReadFixture supplies the capability under test for R7.1: a read whose
// selector is an instant or a version address, resolving to the latest
// version accepted at or before that point, or a typed refusal.
type AsOfReadFixture struct {
IssuePrefix string
// Resolve performs the as-of read under test (R7.1). A nil hook means
// this backend does not implement as-of reads yet, and every case in
// this file skips with that reason.
Resolve AsOfRead
// MintAt mints a fresh version for id under storeID, recorded as
// accepted at the given instant, and returns its Address. Cases use
// this to build a lineage with known accept-times to resolve an as-of
// read against. A nil hook means this backend has no way to mint a
// version at a controlled accept-time, and cases that need one skip
// with that reason.
MintAt func(ctx context.Context, storeID, id string, acceptedAt time.Time) (Address, error)
// MakeUnanswerable arranges for id to be unanswerable at storeID for
// the given Restriction (one of RestrictionGoneRetention/GoneErasure/
// GoneReorganization/Unknown) — 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. A
// nil hook means this backend has no way to arrange this, and the case
// that needs it skips with that reason.
MakeUnanswerable func(ctx context.Context, storeID, id string, restriction Restriction) error
}
// RunAsOfReadSelectorAcceptsEitherAnInstantOrAVersionAddress pins R7.1's
// selector shape: an instant T and the version address that instant
// resolves to are two names for the same answer, and a store must accept
// either.
func RunAsOfReadSelectorAcceptsEitherAnInstantOrAVersionAddress(t *testing.T, ctx context.Context, fixture AsOfReadFixture) {
t.Helper()
if fixture.Resolve == nil {
t.Skip("this backend does not implement as-of reads (Resolve is nil)")
}
if fixture.MintAt == nil {
t.Skip("this backend has no way to mint a version at a controlled accept-time (MintAt is nil)")
}
store := asOfReadStore(fixture, "selector-kinds")
id := fixture.IssuePrefix + "-asof-selector"
t0 := time.Now().UTC().Add(-time.Hour)
asOfReadMint(t, ctx, fixture, store, id, t0)
t1 := t0.Add(time.Minute)
second := asOfReadMint(t, ctx, fixture, store, id, t1)
byInstant, err := fixture.Resolve(ctx, store, id, AsOfSelector{At: &t1})
if err != nil {
t.Fatalf("Resolve(selector=instant): %v", err)
}
if byInstant.Refusal != nil {
t.Fatalf("Resolve(selector=instant) = %+v, want a served result", byInstant)
}
byVersion, err := fixture.Resolve(ctx, store, id, AsOfSelector{Version: &second})
if err != nil {
t.Fatalf("Resolve(selector=version address): %v", err)
}
if byVersion.Refusal != nil {
t.Fatalf("Resolve(selector=version address) = %+v, want a served result", byVersion)
}
if byInstant.Address != second {
t.Errorf("Resolve(selector=instant matching a version's own accept-time).Address = %s, want %s", byInstant.Address, second)
}
if byVersion.Address != second {
t.Errorf("Resolve(selector=version address).Address = %s, want the same address named %s", byVersion.Address, second)
}
if byInstant.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)
}
}
// RunAsOfReadReturnsTheLatestVersionAtOrBeforeTStrictlyExcludingLater pins
// R7.1's ordering promise: resolving at T returns the latest version
// accepted at or before T, and a version accepted after T is excluded even
// when its own instant is close by.
func RunAsOfReadReturnsTheLatestVersionAtOrBeforeTStrictlyExcludingLater(t *testing.T, ctx context.Context, fixture AsOfReadFixture) {
t.Helper()
if fixture.Resolve == nil {
t.Skip("this backend does not implement as-of reads (Resolve is nil)")
}
if fixture.MintAt == nil {
t.Skip("this backend has no way to mint a version at a controlled accept-time (MintAt is nil)")
}
store := asOfReadStore(fixture, "ordering")
id := fixture.IssuePrefix + "-asof-ordering"
t0 := time.Now().UTC().Add(-time.Hour)
asOfReadMint(t, ctx, fixture, store, id, t0)
t1 := t0.Add(time.Minute)
middle := asOfReadMint(t, ctx, fixture, store, id, t1)
t2 := t0.Add(2 * time.Minute)
asOfReadMint(t, ctx, fixture, store, id, t2)
atExactly, err := fixture.Resolve(ctx, store, id, AsOfSelector{At: &t1})
if err != nil {
t.Fatalf("Resolve(T=middle's own instant): %v", err)
}
if atExactly.Refusal != nil || atExactly.Address != middle {
t.Errorf("Resolve(T=middle's own instant) = %+v, want the version accepted exactly at T (%s), not a later one", atExactly, middle)
}
between := t1.Add(30 * time.Second)
betweenResult, err := fixture.Resolve(ctx, store, id, AsOfSelector{At: &between})
if err != nil {
t.Fatalf("Resolve(T strictly between two versions): %v", err)
}
if betweenResult.Refusal != nil || betweenResult.Address != middle {
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
// returned, not merely a truthy success.
func RunAsOfReadReportsTheAddressItServed(t *testing.T, ctx context.Context, fixture AsOfReadFixture) {
t.Helper()
if fixture.Resolve == nil {
t.Skip("this backend does not implement as-of reads (Resolve is nil)")
}
if fixture.MintAt == nil {
t.Skip("this backend has no way to mint a version at a controlled accept-time (MintAt is nil)")
}
store := asOfReadStore(fixture, "reports-address")
id := fixture.IssuePrefix + "-asof-reports-address"
at := time.Now().UTC()
address := asOfReadMint(t, ctx, fixture, store, id, at)
result, err := fixture.Resolve(ctx, store, id, AsOfSelector{At: &at})
if err != nil {
t.Fatalf("Resolve: %v", err)
}
if result.Refusal != nil {
t.Fatalf("Resolve = %+v, want a served result", result)
}
if result.Address == "" {
t.Fatal("Resolve returned an empty Address on a served result, want the address of the version it served (R7.1)")
}
if result.Address != address {
t.Errorf("Resolve(...).Address = %s, want the served version's own address %s", result.Address, address)
}
}
// RunAsOfReadRefusesAsGoneOrUnknownNeverSubstitutingAnotherVersion pins R8:
// a read that cannot be answered refuses as a typed Gone or Unknown outcome
// with a reason, and never silently returns a neighboring version, the
// nearest surviving version, or current state as a substitute — R8's own
// text names all three as non-answers.
func RunAsOfReadRefusesAsGoneOrUnknownNeverSubstitutingAnotherVersion(t *testing.T, ctx context.Context, fixture AsOfReadFixture) {
t.Helper()
if fixture.Resolve == nil {
t.Skip("this backend does not implement as-of reads (Resolve is nil)")
}
if fixture.MintAt == nil {
t.Skip("this backend has no way to mint a version at a controlled accept-time (MintAt is nil)")
}
if fixture.MakeUnanswerable == nil {
t.Skip("this backend has no way to make a lineage unanswerable (MakeUnanswerable is nil)")
}
for _, restriction := range []Restriction{
RestrictionGoneRetention,
RestrictionGoneErasure,
RestrictionGoneReorganization,
RestrictionUnknown,
} {
t.Run(restriction.String(), func(t *testing.T) {
store := asOfReadStore(fixture, "unanswerable-"+restriction.String())
id := fixture.IssuePrefix + "-asof-unanswerable-" + restriction.String()
at := time.Now().UTC()
address := asOfReadMint(t, ctx, fixture, store, id, at)
if err := fixture.MakeUnanswerable(ctx, store, id, restriction); err != nil {
t.Fatalf("MakeUnanswerable(%s, %s): %v", id, restriction, err)
}
result, err := fixture.Resolve(ctx, store, id, AsOfSelector{At: &at})
if err != nil {
t.Fatalf("Resolve after MakeUnanswerable(%s): %v", restriction, err)
}
if result.Refusal == nil {
t.Fatalf("Resolve after MakeUnanswerable(%s) = %+v, want a Refusal, not a served result (R8)", restriction, result)
}
if result.Refusal.Restriction != restriction {
t.Errorf("Refusal.Restriction = %s, want %s", result.Refusal.Restriction, restriction)
}
if result.Refusal.Reason == "" {
t.Error("Refusal.Reason is empty, want a reason (R8)")
}
if result.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)
}
})
}
}
// RunAsOfReadIsCompleteOnlyForTheAnsweringStoresHoldings pins R7.1's closing
// clause and TC3: an as-of answer "is complete for the answering store's
// holdings and may change after a sync." This case asserts NOTHING about
// agreement between two stores asked about the same lineage — proving that
// absence is the point, not a gap. It mints a lineage into exactly one of
// two stores and confirms each store answers strictly from its own
// holdings: the store that holds the lineage serves it, and the store that
// never received it answers Unknown (FR-06, reused from R20) rather than
// reaching across to a sibling store's knowledge, erroring, or answering
// Gone — which would claim knowledge of a lineage it never held.
func RunAsOfReadIsCompleteOnlyForTheAnsweringStoresHoldings(t *testing.T, ctx context.Context, fixture AsOfReadFixture) {
t.Helper()
if fixture.Resolve == nil {
t.Skip("this backend does not implement as-of reads (Resolve is nil)")
}
if fixture.MintAt == nil {
t.Skip("this backend has no way to mint a version at a controlled accept-time (MintAt is nil)")
}
holds := asOfReadStore(fixture, "tc3-holds-the-lineage")
neverSynced := asOfReadStore(fixture, "tc3-never-synced")
id := fixture.IssuePrefix + "-asof-tc3"
at := time.Now().UTC()
address := asOfReadMint(t, ctx, fixture, holds, id, at)
local, err := fixture.Resolve(ctx, holds, id, AsOfSelector{At: &at})
if err != nil {
t.Fatalf("Resolve on the store that holds the lineage: %v", err)
}
if local.Refusal != nil || local.Address != address {
t.Fatalf("Resolve on the store that holds the lineage = %+v, want it served from that store's own holdings (%s)", local, address)
}
remote, err := fixture.Resolve(ctx, neverSynced, id, AsOfSelector{At: &at})
if err != nil {
t.Fatalf("Resolve on a store that never received this lineage: %v", err)
}
if remote.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)
}
if remote.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)
}
}
// --- fixture helpers -------------------------------------------------------
// asOfReadStore names a storeID namespaced by the fixture's IssuePrefix and
// tag, so cases that need more than one store (e.g. the TC3 local-
// completeness case) get independent ones.
func asOfReadStore(fixture AsOfReadFixture, tag string) string {
return fixture.IssuePrefix + "-asof-store-" + tag
}
// asOfReadMint mints a version for id on store at the given instant via
// fixture.MintAt, fataling the case if minting fails.
func asOfReadMint(t *testing.T, ctx context.Context, fixture AsOfReadFixture, store, id string, at time.Time) Address {
t.Helper()
address, err := fixture.MintAt(ctx, store, id, at)
if err != nil {
t.Fatalf("MintAt(%s, %s, %s): %v", store, id, at, err)
}
return address
}

192
backend/http/BUILD.bazel Normal file
View file

@ -0,0 +1,192 @@
load("@rules_go//go:def.bzl", "go_library", "go_test")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
go_library(
name = "http",
srcs = [
"attach.go",
"credential.go",
"errors.go",
"http.go",
"target.go",
],
importpath = "github.com/steveyegge/beads/backend/http",
visibility = ["//visibility:public"],
deps = [
"//backend",
"//internal/configfile",
"//internal/gitignore",
"//internal/httpapi/apigen",
"//internal/httpclient",
"//internal/httpclient/wire",
"//internal/storage/backends",
],
)
go_test(
name = "http_test",
# The served e2e cases run ~4-5 min on the farm under
# BEADS_TEST_EMBEDDED_DOLT=1, past the medium 300s action limit.
size = "large",
timeout = "long",
srcs = [
"attach_test.go",
"e2e_blocked_flags_test.go",
"e2e_blocked_test.go",
"e2e_cli_test.go",
"e2e_export_test.go",
"e2e_gates_test.go",
"e2e_heartbeat_test.go",
"e2e_link_test.go",
"e2e_list_filters_test.go",
"e2e_list_page_edges_test.go",
"e2e_mol_test.go",
"e2e_promote_test.go",
"e2e_read_your_own_write_test.go",
"e2e_recompute_blocked_test.go",
"e2e_remote_roles_test.go",
"e2e_request_budget_test.go",
"e2e_search_test.go",
"e2e_show_current_test.go",
"e2e_show_single_fetch_test.go",
"open_test.go",
"per_open_credential_test.go",
"register_test.go",
],
# The e2e files exec the real bd (bazeltest.PrebuiltBD); they run under
# BEADS_TEST_EMBEDDED_DOLT=1 and skip otherwise.
data = ["//cmd/bd:bd_for_tests"],
env = {"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)"},
deps = [
":http",
"//backend",
"//internal/configfile",
"//internal/httpapi",
"//internal/httpclient",
"//internal/storage",
"//internal/storage/backends",
"//internal/storage/domain",
"//internal/storage/embeddeddolt",
"//internal/storage/issueops",
"//internal/testutil/bazeltest",
],
)
# http_test again, with the e2e tier on: BEADS_TEST_EMBEDDED_DOLT=1 starts the
# in-process server over embedded Dolt and BEADS_HTTP_TEST_REQUIRED=1 turns a
# skip of that tier into a failure. http_test alone skips the TestE2E_* cases
# in every lane, because no lane sets those variables for it. It repeats
# http_test's `env` (go_test_pinned_shard.sh, like go_test_variant.sh, does
# not inherit it).
#
# Shard count: the package's tests are serial, and as one shard the target
# ran 235-394s on the lane's executors (2026-10-10..13), the embedded lane's
# longest action in most runs where it executed; the lane's other shards end
# by ~90-125s. The 19 TestE2E_* cases that take >= 3s are pinned
# (tools/bazel/go_test_pinned_shard.sh, served_pinned_shards.txt from
# tools/bazel/pin_shards.py --shards 6 --min-seconds 3) onto 6 shards, and
# the binary's round-robin runs the other ~28 (well under a second
# together) in the 7th. The durations are the maximum over two sharded runs
# of the lane (bazel.yml's bazel-embedded-served-testxml artifact): 11-90s
# each, ~770s together. The same test's time varied 2-5x between those runs
# with the executors' load, and sharded runs took up to 2x what the
# single-shard runs did, so size the pins from sharded runs of the lane,
# never from a single-shard or local one.
# Regenerate the manifest from PR runs' bazel-embedded-served-testxml
# artifacts (each http_served_test directory holds shard_*_of_7/test.xml;
# pass several runs, pin_shards.py takes each test's maximum):
# python3 tools/bazel/pin_shards.py --shards 6 --min-seconds 3 \
# --write backend/http/served_pinned_shards.txt \
# <run1>/http_served_test <run2>/http_served_test
#
# Tags:
# embedded: the embedded-Dolt tier; excluded from --config=prcore/ci,
# selected by --config=embedded.
sh_test(
name = "http_served_test",
size = "large",
# -test.timeout=19m fires (with a goroutine dump) before Bazel's 1200s
# action limit (eternal under --config=embedded).
timeout = "eternal",
srcs = ["//tools/bazel:go_test_pinned_shard.sh"],
args = [
"$(rootpath :served_pinned_shards.txt)",
"$(rootpath :http_test)",
"-test.v",
"-test.count=1",
"-test.timeout=19m",
],
data = [
"served_pinned_shards.txt",
":http_test",
"//cmd/bd:bd_for_tests",
],
env = {
"BEADS_HTTP_TEST_REQUIRED": "1",
"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)",
"BEADS_TEST_EMBEDDED_DOLT": "1",
},
shard_count = 7,
tags = ["embedded"],
)
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
filegroup(
name = "repo_doc_files",
srcs = glob(
[
"**/*.md",
"**/*.mdx",
],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_srcs",
srcs = glob(
["**/*.go"],
allow_empty = True,
exclude = [
"**/*_test.go",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_test_srcs",
srcs = glob(
["**/*_test.go"],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_other_files",
srcs = glob(
["**"],
exclude = [
"**/*.db",
"**/*.exe",
"**/*.go",
"**/*.md",
"**/*.mdx",
"**/*.out",
"**/*.prof",
"**/*.pyc",
"**/*.test",
"**/__pycache__/**",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
# --- end repo_files ---

133
backend/http/attach.go Normal file
View file

@ -0,0 +1,133 @@
// Written fresh for OSS beads S6 (no bd-enterprise source copied): closes the
// S6 review's MED-8 finding, which asked for one public helper an embedder
// (or `bd connect`) can call to activate a workspace for this backend,
// instead of each caller hand-assembling the two-file write itself.
package bdhttp
import (
"context"
"fmt"
"github.com/steveyegge/beads/internal/configfile"
"github.com/steveyegge/beads/internal/gitignore"
"github.com/steveyegge/beads/internal/httpclient"
)
// Attach activates the http backend for the workspace at beadsDir: it writes
// the per-user activation sidecar (SaveTarget) pinning target's server and
// project, then sets the workspace's git-tracked backend selection in
// metadata.json to this backend, preserving every other configured field
// (database, project id, ...) and creating a fresh default metadata.json only
// when none exists yet. Both files are written atomically (temp file plus
// rename, 0600): see SaveTarget and configfile.Config.Save.
//
// Unless the caller already set target.PreviousBackend, Attach fills it in
// from the workspace's PRIOR backend selection, so `bd connect --clear` can
// restore it later; see that field's doc.
//
// Attach does NOT verify target itself — it has no network access and takes
// target on faith. A caller MUST call Handshake (or httpclient.Handshake)
// against target first and only call Attach once that succeeds; attaching an
// unverified target lets a workspace record a server that is wrong, hostile,
// or simply never answers. Connect, below, does both in the right order and
// is the easier door for a caller that does not need them split.
//
// Attach does not create beadsDir itself — MkdirAll is the caller's job, same
// as SaveTarget's own precondition. It DOES ensure both of this backend's
// per-user filenames are covered by beadsDir's .gitignore
// (gitignore.EnsurePatternIgnored): the sidecar, and
// httpclient.LocalMetadataFileName, which the store writes on first use. That
// is the same guarantee `bd connect` makes via doctor.EnsureGitignoreForBeadsDir
// — but through a small, independent implementation here rather than
// importing cmd/bd/doctor, whose package as a whole pulls in dolt and
// git-process dependencies that would break backend/http's promise of a
// minimal dependency footprint for an embedder. The two are complementary and
// idempotent together.
//
// It is the one place that writes BOTH of the files that activate beads/http
// (the sidecar and metadata.json's backend selection; the local metadata file
// is the store's own), so a caller that used to hand-assemble the pair
// (`bd connect`'s own connectCmd.RunE, test/embedder's linkage proof) can call
// this instead and stay correct across a future change to either file's shape.
func Attach(beadsDir string, target Target) error {
cfg, err := configfile.Load(beadsDir)
if err != nil {
return fmt.Errorf("reading %s: %w", configfile.ConfigFileName, err)
}
if cfg == nil {
cfg = configfile.DefaultConfig()
}
// target.PreviousBackend (bee-ghosttrack CHANGES_REQUESTED on #7288,
// should-fix 1) is what `bd connect --clear` restores metadata.json's
// backend selection to. A caller rarely sets it itself (connect.go
// doesn't), so fill it in here unless the workspace is ALREADY on this
// backend — a re-connect (a new URL, or re-pinning the same one) must
// not overwrite an earlier recorded previous backend with "http" itself,
// or a chain of reconnects would forget what to restore and --clear
// would land back on http with no sidecar. Carry the ALREADY-recorded
// value forward instead; a failed or missing read just leaves it "",
// the same as a workspace with nothing to restore. The check reads the
// raw field: in a process that never ran Register, GetBackend() reports an
// http workspace as the dolt default, and the reconnect would record that.
if target.PreviousBackend == "" {
if cfg.Backend == httpclient.Backend {
if prior, err := httpclient.LoadTarget(beadsDir); err == nil {
target.PreviousBackend = prior.PreviousBackend
}
} else {
target.PreviousBackend = cfg.GetBackend()
}
}
if err := SaveTarget(beadsDir, target); err != nil {
return fmt.Errorf("writing %s: %w", httpclient.TargetFileName, err)
}
// Both of this backend's per-user files: the sidecar just written, and
// the local metadata file the store itself writes on first use, which
// never passes through here and so must be covered in advance.
for _, name := range []string{httpclient.TargetFileName, httpclient.LocalMetadataFileName} {
if err := gitignore.EnsurePatternIgnored(beadsDir, name); err != nil {
return fmt.Errorf("ensuring %s is gitignored: %w", name, err)
}
}
// Only the backend SELECTION changes here. cfg.Database/cfg.ProjectID (if
// an existing metadata.json carried them for a different, prior backend)
// are left exactly as loaded — see connect.go's own comment on this same
// hazard: this backend's identity lives entirely in the sidecar just
// written above, and clobbering those fields would corrupt a future
// `bd connect --clear` back to a different backend.
cfg.Backend = httpclient.Backend
if err := cfg.Save(beadsDir); err != nil {
return fmt.Errorf("writing %s: %w", configfile.ConfigFileName, err)
}
return nil
}
// Connect is Handshake followed by Attach: it verifies target — the same
// server-identity check `bd connect` performs before it ever writes
// anything — and only then activates the workspace. It is the convenience
// door for a caller that wants Attach's ordering guarantee (never attach a
// workspace to a server this process has not handshaken) without composing
// Handshake and Attach itself.
//
// Mirroring `bd connect`'s own project-id pinning: if target.ExpectProjectID
// is empty, Connect pins it to whatever project the server answered with
// before calling Attach, so the workspace is tied to that project from this
// call on. If it is already set, Handshake itself refuses a mismatch and
// Connect returns that error without calling Attach at all. Connect does not
// replicate `bd connect`'s other CLI-level policy — --force re-pinning an
// already-attached workspace, or refusing to switch a workspace from a
// different backend — those stay the command's own job; Connect's contract
// is exactly "handshake, then attach".
func Connect(ctx context.Context, beadsDir string, target Target, opts Options) (*ServerSnapshot, error) {
snapshot, err := Handshake(ctx, target, opts)
if err != nil {
return nil, err
}
if target.ExpectProjectID == "" {
target.ExpectProjectID = snapshot.ProjectID
}
if err := Attach(beadsDir, target); err != nil {
return nil, err
}
return snapshot, nil
}

180
backend/http/attach_test.go Normal file
View file

@ -0,0 +1,180 @@
package bdhttp_test
// Written fresh for OSS beads S6: pins the bee-ghosttrack CHANGES_REQUESTED
// finding on #7288, should-fix 1 — `bd connect --clear` restoring a
// workspace's previous backend selection needs Attach to have recorded what
// that previous backend WAS, onto the sidecar, at connect time.
import (
"net/url"
"os"
"path/filepath"
"strings"
"testing"
bdhttp "github.com/steveyegge/beads/backend/http"
"github.com/steveyegge/beads/internal/configfile"
"github.com/steveyegge/beads/internal/httpclient"
)
func mustAttachTestURL(t *testing.T, raw string) *url.URL {
t.Helper()
u, err := url.Parse(raw)
if err != nil {
t.Fatalf("url.Parse(%q): %v", raw, err)
}
return u
}
// TestAttachRecordsThePriorBackendAsPreviousBackend is the first-connect
// case: a workspace that selected "dolt" before ever running `bd connect`
// must have Attach record "dolt" as PreviousBackend, so --clear can restore
// it later.
func TestAttachRecordsThePriorBackendAsPreviousBackend(t *testing.T) {
beadsDir := t.TempDir()
cfg := &configfile.Config{Backend: "dolt", Database: "beads.db"}
if err := cfg.Save(beadsDir); err != nil {
t.Fatalf("seed metadata.json: %v", err)
}
target := bdhttp.Target{BaseURL: mustAttachTestURL(t, "http://127.0.0.1:8080")}
if err := bdhttp.Attach(beadsDir, target); err != nil {
t.Fatalf("Attach: %v", err)
}
got, err := bdhttp.LoadTarget(beadsDir)
if err != nil {
t.Fatalf("LoadTarget: %v", err)
}
if got.PreviousBackend != "dolt" {
t.Errorf("PreviousBackend = %q, want %q", got.PreviousBackend, "dolt")
}
after, err := configfile.Load(beadsDir)
if err != nil {
t.Fatalf("reload metadata.json: %v", err)
}
// Asserts on the raw stored field, not GetBackend(): GetBackend() falls
// back to BackendDolt for any name backendnames.Has doesn't recognize
// (TestGetBackendAllowlist in internal/configfile), and "http" is only
// ever added there by bdhttp.Register/httpclient.Register — a
// once-per-process, panics-on-duplicate production wiring call this test
// package must not make. The raw field is exactly what Attach controls.
if after.Backend != httpclient.Backend {
t.Errorf("metadata.json backend = %q after Attach, want %q", after.Backend, httpclient.Backend)
}
}
// TestAttachOnAFreshWorkspaceRecordsTheImplicitDoltDefault covers a
// workspace with no metadata.json at all: GetBackend()'s own default
// ("dolt") is what a future --clear restores to, matching what every other
// backend-selection read in this codebase already treats as this
// workspace's backend.
func TestAttachOnAFreshWorkspaceRecordsTheImplicitDoltDefault(t *testing.T) {
beadsDir := t.TempDir()
target := bdhttp.Target{BaseURL: mustAttachTestURL(t, "http://127.0.0.1:8080")}
if err := bdhttp.Attach(beadsDir, target); err != nil {
t.Fatalf("Attach: %v", err)
}
got, err := bdhttp.LoadTarget(beadsDir)
if err != nil {
t.Fatalf("LoadTarget: %v", err)
}
if got.PreviousBackend != "dolt" {
t.Errorf("PreviousBackend = %q, want %q (configfile.BackendDolt)", got.PreviousBackend, "dolt")
}
}
// TestAttachOnAReconnectKeepsTheEarlierPreviousBackend covers a workspace
// ALREADY on http (a bare re-connect, or --force re-pinning the same
// backend): Attach must not overwrite an already-recorded PreviousBackend
// with "http" itself, or a chain of reconnects would forget what --clear is
// supposed to restore.
func TestAttachOnAReconnectKeepsTheEarlierPreviousBackend(t *testing.T) {
beadsDir := t.TempDir()
// Not dolt: an unregistered "http" reads back through GetBackend() as the
// dolt default, so a dolt prior could not tell carrying it forward from
// recording that default.
cfg := &configfile.Config{Backend: "postgres", Database: "beads.db"}
if err := cfg.Save(beadsDir); err != nil {
t.Fatalf("seed metadata.json: %v", err)
}
first := bdhttp.Target{BaseURL: mustAttachTestURL(t, "http://127.0.0.1:8080")}
if err := bdhttp.Attach(beadsDir, first); err != nil {
t.Fatalf("first Attach: %v", err)
}
// A second connect to a different url, same workspace, same backend
// ("http", already selected) — the shape `bd connect --force` to a new
// server produces for an already-http workspace.
second := bdhttp.Target{BaseURL: mustAttachTestURL(t, "http://127.0.0.1:9090")}
if err := bdhttp.Attach(beadsDir, second); err != nil {
t.Fatalf("second Attach: %v", err)
}
got, err := bdhttp.LoadTarget(beadsDir)
if err != nil {
t.Fatalf("LoadTarget: %v", err)
}
if got.PreviousBackend != "postgres" {
t.Errorf("PreviousBackend after a reconnect = %q, want the original %q carried forward, not the just-left \"http\"", got.PreviousBackend, "postgres")
}
if got.BaseURL.String() != "http://127.0.0.1:9090" {
t.Errorf("BaseURL = %q, want the second connect's url", got.BaseURL.String())
}
}
// TestAttachHonorsACallerSuppliedPreviousBackend covers Connect's doc
// contract: a caller that already set target.PreviousBackend itself (none
// of this package's own callers do today) must have that value win over
// Attach's own inference.
func TestAttachHonorsACallerSuppliedPreviousBackend(t *testing.T) {
beadsDir := t.TempDir()
cfg := &configfile.Config{Backend: "dolt", Database: "beads.db"}
if err := cfg.Save(beadsDir); err != nil {
t.Fatalf("seed metadata.json: %v", err)
}
target := bdhttp.Target{BaseURL: mustAttachTestURL(t, "http://127.0.0.1:8080"), PreviousBackend: "mysql"}
if err := bdhttp.Attach(beadsDir, target); err != nil {
t.Fatalf("Attach: %v", err)
}
got, err := bdhttp.LoadTarget(beadsDir)
if err != nil {
t.Fatalf("LoadTarget: %v", err)
}
if got.PreviousBackend != "mysql" {
t.Errorf("PreviousBackend = %q, want the caller-supplied %q to win over the inferred %q", got.PreviousBackend, "mysql", "dolt")
}
}
// TestAttachGitignoresBothPerUserFiles pins Attach's .gitignore guarantee for
// both files this backend keeps per user in beadsDir: the sidecar Attach
// writes, and the local metadata file the store writes later, on first use.
// `bd connect` also covers the second through doctor's required patterns,
// but an embedder activating through Attach alone has only this. A reconnect
// must not duplicate either line.
func TestAttachGitignoresBothPerUserFiles(t *testing.T) {
beadsDir := t.TempDir()
for _, raw := range []string{"http://127.0.0.1:8080", "http://127.0.0.1:9090"} {
if err := bdhttp.Attach(beadsDir, bdhttp.Target{BaseURL: mustAttachTestURL(t, raw)}); err != nil {
t.Fatalf("Attach(%s): %v", raw, err)
}
}
content, err := os.ReadFile(filepath.Join(beadsDir, ".gitignore"))
if err != nil {
t.Fatalf("read .gitignore after Attach: %v", err)
}
for _, name := range []string{httpclient.TargetFileName, httpclient.LocalMetadataFileName} {
count := 0
for _, line := range strings.Split(string(content), "\n") {
if strings.TrimSpace(line) == name {
count++
}
}
if count != 1 {
t.Errorf(".gitignore names %s %d time(s) after two Attaches, want exactly 1:\n%s", name, count, content)
}
}
}

View file

@ -0,0 +1,146 @@
load("@rules_go//go:def.bzl", "go_test")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
go_test(
name = "corpus_test",
# The corpus runs every shape through the real bd (bazeltest.PrebuiltBD),
# served and embedded, under BEADS_TEST_EMBEDDED_DOLT=1 (corpus_served_test
# below); it skips otherwise.
size = "large",
timeout = "long",
srcs = [
"corpus_parts_test.go",
"corpus_test.go",
"gate_check_served_test.go",
"harness_test.go",
"reference_proxy_test.go",
"required_corpus_tier_test.go",
],
data = glob(["testdata/**"]) + ["//cmd/bd:bd_for_tests"],
env = {"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)"},
deps = [
"//internal/httpapi",
"//internal/httpapi/apigen",
"//internal/storage",
"//internal/storage/domain",
"//internal/storage/embeddeddolt",
"//internal/testutil/bazeltest",
"//internal/types",
"@in_gopkg_yaml_v3//:yaml_v3",
],
)
# corpus_test again, with the corpus tier on: BEADS_TEST_EMBEDDED_DOLT=1 runs
# TestServedCorpusPart1..N and BEADS_HTTP_TEST_REQUIRED=1 turns a skip of
# them into a failure. corpus_test alone skips them in every lane, because no
# lane sets those variables for it. It repeats corpus_test's `env`
# (go_test_pinned_shard.sh, like go_test_variant.sh, does not inherit it).
#
# Shard count: as one shard (one TestServedCorpus over every shape) the
# target ran 292-597s on the lane's executors (2026-10-11..13), the embedded
# lane's longest action in most runs where it executed. About 100s of that
# is the per-process server and seed, the rest the ~130 shapes (~1.9s each,
# serial, ~242s together). The shapes are now dealt round robin across
# corpusParts = 4 parts (corpus_test.go), each a top-level test with its own
# server and seed, and served_pinned_shards.txt pins part k to shard k; the
# 5th shard runs the package's other tests through the binary's
# round-robin (the engine-free ones, plus
# TestServedGateCheckOverAwaitTypedGates, which seeds its own small served
# store). Each part pays the setup again, though it seeds the served
# and embedded sides concurrently (~62-76s on the lane's executors), so a
# part's shard is that plus ~60s of shapes: 114-146s measured. Three parts
# ran 170-180s each; they save one setup (~75 test-seconds a run) but
# lengthen the lane's served long pole, which is on the gate's critical
# path, by ~34s.
#
# Tags:
# embedded: the embedded-Dolt tier; excluded from --config=prcore/ci,
# selected by --config=embedded.
sh_test(
name = "corpus_served_test",
size = "large",
# -test.timeout=19m fires (with a goroutine dump) before Bazel's 1200s
# action limit (eternal under --config=embedded).
timeout = "eternal",
srcs = ["//tools/bazel:go_test_pinned_shard.sh"],
args = [
"$(rootpath :served_pinned_shards.txt)",
"$(rootpath :corpus_test)",
"-test.v",
"-test.count=1",
"-test.timeout=19m",
],
data = [
"served_pinned_shards.txt",
":corpus_test",
"//cmd/bd:bd_for_tests",
],
env = {
"BEADS_HTTP_TEST_REQUIRED": "1",
"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)",
"BEADS_TEST_EMBEDDED_DOLT": "1",
},
shard_count = 5,
tags = ["embedded"],
)
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
filegroup(
name = "repo_doc_files",
srcs = glob(
[
"**/*.md",
"**/*.mdx",
],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_srcs",
srcs = glob(
["**/*.go"],
allow_empty = True,
exclude = [
"**/*_test.go",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_test_srcs",
srcs = glob(
["**/*_test.go"],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_other_files",
srcs = glob(
["**"],
exclude = [
"**/*.db",
"**/*.exe",
"**/*.go",
"**/*.md",
"**/*.mdx",
"**/*.out",
"**/*.prof",
"**/*.pyc",
"**/*.test",
"**/__pycache__/**",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
# --- end repo_files ---

View file

@ -0,0 +1,154 @@
# Served command corpus
This suite is the working definition of "bd fully supports a remote HTTP
backend". It runs every distinct `bd` command shape that an orchestrator (gc)
and its packs and formulas issue against a work store. Each shape runs
against a served workspace and is compared with the same command on an
embedded workspace.
## What runs
The shapes are dealt round robin, in corpus order, across `corpusParts`
parts (`corpus_test.go`). Each part is a top-level test,
`TestServedCorpusPart1` .. `TestServedCorpusPartN`, and each does the
following for its share of the shapes:
1. Builds `bd` from this tree. `BEADS_TEST_BD_BINARY=<path>` reuses a prebuilt
binary instead.
2. Starts an in-process `bd serve` (`httpapi.Listen` over embedded Dolt) the
way a deployed server is bound: `AllowNonLoopback` plus a bearer token
file. The socket is still `127.0.0.1`, but the bind mode decides every
behaviour the server keys on, including its refusal of unlimited reads.
3. Puts a reference proxy in front of the server. The proxy makes it answer
like the deployed reference server described in
`testdata/reference_server.json`:
- the context handshake publishes exactly that server's capability set and
its `ContextResponse` members (so no `wire_revision`);
- an operation the reference server does not publish gets the server's own
404;
- a query parameter or top-level request member it does not declare gets
the server's own 400 `unknown_parameter`.
4. Runs `bd connect` on one workspace and `bd init` on another. Both get the
`seed` from `testdata/corpus.yaml`: one graph of named rows, plus bulk
graphs that put more than one server page of ready rows and wisps in the
store. Both sides use `BEADS_ACTOR=worker` and set `CLAUDE_SESSION_ID`.
The embedded side is initialized and seeded on its own goroutine while
steps 2 and 3 run and the served side is seeded (`prepareSide`): the two
sides share no directory, env or process, and each runs the seed in
order, so the seeded data does not depend on the overlap.
5. Runs each of its shapes as a subtest, on both sides. The embedded run must
exit with the shape's `expect_exit` and match its `expect_stderr`. If it does
not, the shape is wrong or bd changed, and the subtest fails as a corpus
bug that no pending mark or allowlist entry hides. The served run must:
- exit like the embedded run;
- carry no refusal (`ErrUnsupported`, a v0-wire refusal, the
loopback-only 400, or a reference-profile 404/400);
- match the embedded output under the shape's `compare` mode, after
timestamps and revision tokens are dropped (but not `defer_until` or
`due_at`: a shape sets those itself, as absolute dates, and they must
match exactly);
- for writes, give the same JSON from every `verify` read on both sides
afterwards.
A part takes its own server, workspaces and seed, so no shape can see
another part's writes. That is safe because no shape depends on another
shape's effects:
- every check compares the served run with the embedded run after the same
commands, so it holds whatever ran before it on both sides;
- each part keeps corpus order, so its reads still run on the bare seed,
before any of its writes;
- each write owns its target ids (`e2e-t-*`, or ids it creates).
`TestCorpusPartsDealEveryShapeOnce` checks that every shape is in exactly one
part, in corpus order. A new shape must keep that independence: it may rely on
the seed and its own `setup`, never on another shape having run.
Every part seeds again, so running all the parts in one process takes
longer than one run over every shape did; each part logs its setup time
(`part N setup ...`). Run one part with
`-run 'TestServedCorpusPart2$'`.
There are four parts. In the embedded lane each part's setup (server start
plus both seeds, run concurrently) takes ~62-76s and the shapes ~242s in
total. Four parts ran 114-146s each and three ran 170-180s. Three would save
one setup (~75 test-seconds a run), but the longest part is the lane's
served long pole and sits on the CI gate's critical path, so four parts win.
To change the count, update `corpusParts`, `servedCorpusParts`,
`served_pinned_shards.txt` and the target's `shard_count` together.
```
CGO_ENABLED=1 BEADS_TEST_EMBEDDED_DOLT=1 BEADS_HTTP_TEST_REQUIRED=1 \
go test -tags gms_pure_go -run 'TestServedCorpus|TestCorpus' ./backend/http/corpus/
```
In CI, `//backend/http/corpus:corpus_served_test` runs the suite with both
variables set, in the Embedded Dolt lane (`--config=embedded`; see
[engdocs/TESTING.md](../../../engdocs/TESTING.md)). Its
`served_pinned_shards.txt` pins part k to Bazel shard k, so the parts run
concurrently. `corpus_test` on its own sets neither variable, so it skips
the parts.
Two environment variables change the run:
- `BEADS_CORPUS_REPORT=<file>` writes a JSON summary with per-shape status
and request counts.
- `BEADS_CORPUS_SKIP_PENDING=1` skips pending shapes without running them.
## The data
| File | Holds |
|---|---|
| `testdata/corpus.yaml` | assets, the seed, and the shapes |
| `testdata/allowlist.yaml` | permanent refusals, each with its reason and the refusal text the served run must match |
| `testdata/reference_server.json` | the reference server's wire surface |
Each shape in `corpus.yaml` has these fields:
| Field | Meaning |
|---|---|
| `id` | `gc-*` for orchestrator subprocess shapes, `mc-*` for pack/formula/prompt shapes |
| `source` | where the shape comes from |
| `args` | the argv; `{file:NAME}` expands to an asset path and `{rev:ID}` to that side's current revision of `ID` |
| `stdin` | text piped to `bd` on both sides |
| `setup` | commands run on both sides before the shape; one that fails fails the shape |
| `compare` | `json` (default), `ids`, `count`, `text` or `exit` |
| `ordered` | under `json` and `ids`, array order is significant; by default arrays are sorted before comparing |
| `prefix_of` | for a limited `ids` listing: its unlimited form. Each side's limited rows must be a prefix, in order, of that side's own unlimited listing, both sides return as many rows, and the two unlimited listings hold the same ids. A limit that cuts through a tie set (same priority, `created_at` in the same second) lands on different rows on two workspaces seeded seconds apart, so the limited rows are not compared across sides directly |
| `verify` | reads run after the shape |
| `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**:
- while it fails, the subtest is skipped and the skip records what was
observed;
- once it passes, the subtest fails with "now passes; remove the pending
mark".
So removing a mark is how a slice proves itself, and any other failure is
unexpected and fails the suite.
## Updating the reference profile
`reference_server.json` was derived from two things:
- the deployed server's live `GET /v0/beads/context` capabilities;
- its published OpenAPI document (bd 1.3.0, no `wire_revision`). For each
operation the profile keeps the method, the path template, the query
parameter names, and the top-level request members.
When the deployed server is upgraded (SRV-1), regenerate the file the same
way. Then remove the `SRV-1` pending marks that now pass.
## Known fidelity limits
- Responses pass through unfiltered. A response member the reference server
would not send still reaches the client.
- Only top-level request members are checked; nested members (for example
`batchApply` items) are not.
- The served backend underneath is embedded Dolt, not the reference
deployment's storage backend.
- Out of scope, because they are local by design or never touch a remote
store: `init`, `bootstrap`, `migrate`, `doctor`, `flatten`, `gc`, and the
`dolt` subcommands. `context`, `version`, `backup status` and `prime`
are in the corpus, but only checked for exit codes.

View file

@ -0,0 +1,211 @@
//go:build cgo
package corpus_test
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"reflect"
"runtime"
"strings"
"sync"
"testing"
)
// TestCorpusPartsDealEveryShapeOnce runs without the embedded engine. It
// holds the deal TestServedCorpusPart1..N run to what makes splitting the
// corpus safe: every shape lands in exactly one part, each part keeps corpus
// order (so a part's reads still run before its writes, on its own fresh
// seed), no part is empty, and there is one TestServedCorpusPartN per part.
func TestCorpusPartsDealEveryShapeOnce(t *testing.T) {
if len(servedCorpusParts) != corpusParts {
t.Fatalf("servedCorpusParts has %d tests, want corpusParts = %d", len(servedCorpusParts), corpusParts)
}
c, _ := loadCorpus(t)
index := map[string]int{}
for i, s := range c.Shapes {
index[s.ID] = i
}
seen := map[string]int{}
for part := 1; part <= corpusParts; part++ {
shapes := corpusPart(c.Shapes, part)
if len(shapes) == 0 {
t.Errorf("part %d runs no shapes", part)
}
last := -1
for _, s := range shapes {
if prev, dup := seen[s.ID]; dup {
t.Errorf("shape %s is in part %d and part %d", s.ID, prev, part)
}
seen[s.ID] = part
i, ok := index[s.ID]
if !ok {
t.Errorf("part %d runs %s, which is not a corpus shape", part, s.ID)
continue
}
if i <= last {
t.Errorf("part %d runs %s out of corpus order", part, s.ID)
}
last = i
}
}
for _, s := range c.Shapes {
if _, ok := seen[s.ID]; !ok {
t.Errorf("shape %s is in no part", s.ID)
}
}
}
// The deal itself, on a corpus of 10 against 4 parts: round robin in corpus
// order.
func TestCorpusPartIsRoundRobinInOrder(t *testing.T) {
var shapes []shape
for i := 0; i < 10; i++ {
shapes = append(shapes, shape{ID: fmt.Sprint(i)})
}
want := map[int]string{1: "[0 4 8]", 2: "[1 5 9]", 3: "[2 6]", 4: "[3 7]"}
for part, w := range want {
var ids []string
for _, s := range corpusPartOf(shapes, part, 4) {
ids = append(ids, s.ID)
}
if got := fmt.Sprint(ids); got != w {
t.Errorf("part %d of 4 = %s, want %s", part, got, w)
}
}
}
// fakeBD writes a stand-in for bd that appends its arguments, one call per
// line, to calls.log in its working directory, and exits 3 when an argument
// is "boom".
func fakeBD(t *testing.T) string {
t.Helper()
bin := filepath.Join(t.TempDir(), "bd")
script := "#!/bin/sh\necho \"$*\" >> calls.log\nfor a in \"$@\"; do [ \"$a\" = boom ] && { echo boom >&2; exit 3; }; done\nexit 0\n"
if err := os.WriteFile(bin, []byte(script), 0o700); err != nil {
t.Fatal(err)
}
return bin
}
func calls(t *testing.T, sd *side) []string {
t.Helper()
raw, err := os.ReadFile(filepath.Join(sd.dir, "calls.log"))
if err != nil {
t.Fatal(err)
}
return strings.Split(strings.TrimSpace(string(raw)), "\n")
}
// prepareSide is what lets testServedCorpus seed the served and embedded
// sides at once: each side attaches, writes its assets and runs the seed in
// its own directories, in seed order, and a failure comes back as an error
// rather than a t.Fatal from a goroutine that is not the test's.
func TestPrepareSideSeedsBothSidesConcurrently(t *testing.T) {
bin := fakeBD(t)
c := &corpusFile{
Files: []corpusAsset{{Name: "plan.json", Content: "{}"}},
Seed: [][]string{{"create", "--graph", "{file:plan.json}"}, {"close", "e2e-x"}},
}
a := &side{name: "served", dir: t.TempDir(), files: t.TempDir()}
b := &side{name: "embedded", dir: t.TempDir(), files: t.TempDir()}
var wg sync.WaitGroup
errs := make([]error, 2)
for i, sd := range []*side{a, b} {
wg.Add(1)
go func() {
defer wg.Done()
errs[i] = prepareSide(context.Background(), t, bin, c, sd, []string{"init", sd.name})
}()
}
wg.Wait()
for i, sd := range []*side{a, b} {
if errs[i] != nil {
t.Fatalf("%s: %v", sd.name, errs[i])
}
want := []string{"init " + sd.name, "create --graph " + filepath.Join(sd.files, "plan.json"), "close e2e-x"}
if got := calls(t, sd); !reflect.DeepEqual(got, want) {
t.Errorf("%s ran %q, want %q", sd.name, got, want)
}
if _, err := os.Stat(filepath.Join(sd.files, "plan.json")); err != nil {
t.Errorf("%s: asset not written: %v", sd.name, err)
}
}
}
func TestPrepareSideReportsAFailedStepAsAnError(t *testing.T) {
bin := fakeBD(t)
c := &corpusFile{Seed: [][]string{{"create", "boom"}, {"close", "e2e-x"}}}
sd := &side{name: "embedded", dir: t.TempDir(), files: t.TempDir()}
err := prepareSide(context.Background(), t, bin, c, sd, []string{"init"})
if err == nil || !strings.Contains(err.Error(), "seed [create boom] on embedded failed") || !strings.Contains(err.Error(), "exit=3") {
t.Fatalf("err = %v, want the failed seed step with its exit", err)
}
if got := calls(t, sd); !reflect.DeepEqual(got, []string{"init", "create boom"}) {
t.Errorf("ran %q; the seed must stop at the failed step", got)
}
sd = &side{name: "served", dir: t.TempDir(), files: t.TempDir()}
if err := prepareSide(context.Background(), t, bin, c, sd, []string{"connect", "boom"}); err == nil || !strings.Contains(err.Error(), "bd connect boom on served") {
t.Fatalf("err = %v, want the failed attach", err)
}
}
// Once the other side has failed, the test cancels: a side stops before its
// next step instead of seeding on for nothing.
func TestPrepareSideStopsWhenCancelled(t *testing.T) {
bin := fakeBD(t)
c := &corpusFile{Seed: [][]string{{"create", "e2e-x"}}}
sd := &side{name: "embedded", dir: t.TempDir(), files: t.TempDir()}
ctx, cancel := context.WithCancel(context.Background())
cancel()
if err := prepareSide(ctx, t, bin, c, sd, []string{"init"}); !errors.Is(err, context.Canceled) {
t.Fatalf("err = %v, want context.Canceled", err)
}
if _, err := os.Stat(filepath.Join(sd.dir, "calls.log")); !os.IsNotExist(err) {
t.Errorf("bd ran after the cancel (calls.log: %v)", err)
}
}
// A part test wired to another part's number would run that part's shapes
// twice and drop its own without a word; testServedCorpus refuses to run
// unless the test's name is its part's (corpusPartNameErr).
func TestCorpusPartNameMustMatchItsPart(t *testing.T) {
if err := corpusPartNameErr("TestServedCorpusPart3", 3); err != nil {
t.Errorf("matching name: %v", err)
}
for _, c := range []struct {
name string
part int
}{
{"TestServedCorpusPart3", 2},
{"TestServedCorpusPart1", 10},
{"TestServedCorpusPart10", 1},
{"TestServedCorpusPart3/sub", 3},
{"TestServedCorpus", 1},
// A stray part past corpusParts would run no shapes at all.
{fmt.Sprintf("TestServedCorpusPart%d", corpusParts+1), corpusParts + 1},
{"TestServedCorpusPart0", 0},
} {
if err := corpusPartNameErr(c.name, c.part); err == nil {
t.Errorf("corpusPartNameErr(%q, %d) = nil, want a mismatch", c.name, c.part)
}
}
// Every wired part test passes the guard: run each with the engine
// off, so the guard (which comes first) is all that can fail it.
for k, fn := range servedCorpusParts {
want := fmt.Sprintf("TestServedCorpusPart%d", k+1)
if got := testFuncName(fn); got != want {
t.Errorf("servedCorpusParts[%d] is %s, want %s", k, got, want)
}
}
}
// testFuncName is fn's unqualified function name.
func testFuncName(fn func(*testing.T)) string {
full := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
return full[strings.LastIndex(full, ".")+1:]
}

View file

@ -0,0 +1,968 @@
//go:build cgo
// Package corpus_test is the served command-corpus suite: every distinct bd
// command shape an orchestrator (gc) and its packs/formulas issue, run by the
// real bd binary against an in-process bd serve masked to a reference
// deployment's wire surface, and compared with the same command on an embedded
// workspace. See README.md.
package corpus_test
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
"reflect"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"testing"
"time"
"gopkg.in/yaml.v3"
)
// corpusFile is testdata/corpus.yaml.
type corpusFile struct {
Files []corpusAsset `yaml:"files"`
Seed [][]string `yaml:"seed"`
Shapes []shape `yaml:"shapes"`
}
// corpusAsset is a file the shapes reference as {file:NAME}. Exactly one of
// Content and Bulk is set.
type corpusAsset struct {
Name string `yaml:"name"`
Content string `yaml:"content"`
Bulk *bulkGraph `yaml:"bulk"`
}
// bulkGraph generates a `bd create --graph` plan of Count independent tasks
// with ids IDPrefix-001.. so the suite can hold more rows than one server page
// without a 100-line literal in the corpus.
type bulkGraph struct {
IDPrefix string `yaml:"id_prefix"`
Count int `yaml:"count"`
Priority int `yaml:"priority"`
Ephemeral bool `yaml:"ephemeral"`
Metadata map[string]string `yaml:"metadata"`
}
type shape struct {
ID string `yaml:"id"`
Source string `yaml:"source"`
// Args is the bd argv. Tokens may carry {file:NAME} (the side's copy of a
// corpus asset) and {rev:ID} (that side's current revision of ID).
Args []string `yaml:"args"`
Stdin string `yaml:"stdin"`
Setup [][]string `yaml:"setup"`
// Compare is how the served stdout is held to the embedded stdout:
// json (default), ids, count, text, or exit (exit code only).
Compare string `yaml:"compare"`
// Ordered keeps array order significant under json/ids.
Ordered bool `yaml:"ordered"`
// PrefixOf is the unlimited form of a limited listing (compare: ids). A
// limit cut through a tie set (same priority, created_at within one
// second) lands at a different row on two workspaces seeded seconds
// apart, so the limited rows are not compared across sides. Instead each
// side's limited rows must be, in order, a prefix of that SAME side's
// PrefixOf listing, both sides must return as many rows, and the two
// PrefixOf listings must hold the same ids.
PrefixOf []string `yaml:"prefix_of"`
// IgnoreFields are extra JSON keys dropped before comparing.
IgnoreFields []string `yaml:"ignore_fields"`
// ExpectExit is the exit code both sides must produce (default 0). An
// allowlisted shape must state it: the embedded run is held to it even
// though the served run is only held to the allowlisted refusal.
ExpectExit *int `yaml:"expect_exit"`
// ExpectStderr, when set, must match both sides' stderr (only the
// embedded side's on an allowlisted shape).
ExpectStderr string `yaml:"expect_stderr"`
// Verify are reads run on both sides after the shape and compared as json:
// how a write is checked for having done the same thing on both backends.
Verify [][]string `yaml:"verify"`
// Requests, when set, is exactly how many requests the served run of Args
// makes through the reference proxy (not its setup or verify reads). Each
// is a sequential round trip, so the count is the shape's latency floor
// over a gateway: a change that adds one fails here, and one that saves
// one updates the pin.
Requests *int `yaml:"requests"`
// Pending marks a known failure and names the slice that fixes it.
Pending *pending `yaml:"pending"`
}
// wantExit is the exit code the embedded run must produce.
func (s shape) wantExit() int {
if s.ExpectExit == nil {
return 0
}
return *s.ExpectExit
}
type pending struct {
Slice string `yaml:"slice"`
Reason string `yaml:"reason"`
}
// allowEntry is testdata/allowlist.yaml: a shape that is EXPECTED to be
// refused over http, permanently, for a stated reason. The served run must
// fail and match Refusal; if it ever succeeds the entry is stale and fails.
// The embedded run is still held to the shape's expect_exit and
// expect_stderr, and nothing else of the shape is checked.
type allowEntry struct {
ID string `yaml:"id"`
Reason string `yaml:"reason"`
Refusal string `yaml:"refusal"`
}
// refusalMarkers are the texts a refusal of an operation over http carries:
// issueops.ErrUnsupported, encode.RefusedError, the client's capability
// preflight (wire.CapabilityError, which never reaches the proxy), the
// server's loopback-only unlimited-read 400, an unrouted 404, and a strict
// decoder's unknown member.
var refusalMarkers = regexp.MustCompile(`(?i)not supported by the|not expressible on the v0 wire|loopback-only|capability "[^"]+" not advertised|does not advertise capability|no such route on this server|unknown_parameter|unknown query parameter|json: unknown field`)
// volatileKey names JSON members that legitimately differ between two
// workspaces fed the same commands: timestamps and revision tokens.
var volatileKey = regexp.MustCompile(`(^|_)at$|^revision$|^row_version$|^expected_revision$|^current_revision$`)
// callerTimeKey names the timestamps a shape's own arguments set (bd create
// --defer, --due). They are compared as given, neither dropped as volatile
// nor scrubbed to <ts>, so a client that sends the wrong one fails; a shape
// must give them as absolute dates, since a relative one resolves against
// each side's own clock.
var callerTimeKey = map[string]bool{"defer_until": true, "due_at": true}
var timestampText = regexp.MustCompile(`\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?`)
func loadCorpus(t *testing.T) (*corpusFile, map[string]allowEntry) {
t.Helper()
raw, err := os.ReadFile("testdata/corpus.yaml")
if err != nil {
t.Fatalf("read corpus: %v", err)
}
var c corpusFile
dec := yaml.NewDecoder(strings.NewReader(string(raw)))
dec.KnownFields(true)
if err := dec.Decode(&c); err != nil {
t.Fatalf("parse testdata/corpus.yaml: %v", err)
}
rawAllow, err := os.ReadFile("testdata/allowlist.yaml")
if err != nil {
t.Fatalf("read allowlist: %v", err)
}
var entries []allowEntry
dec = yaml.NewDecoder(strings.NewReader(string(rawAllow)))
dec.KnownFields(true)
if err := dec.Decode(&entries); err != nil {
t.Fatalf("parse testdata/allowlist.yaml: %v", err)
}
allow := map[string]allowEntry{}
for _, e := range entries {
if e.ID == "" || strings.TrimSpace(e.Reason) == "" || e.Refusal == "" {
t.Fatalf("allowlist entry %+v needs id, reason and refusal", e)
}
allow[e.ID] = e
}
return &c, allow
}
// TestCorpusFileIsWellFormed runs without the embedded engine: it keeps the
// data honest (unique ids, a source and a slice for every pending mark, no
// allowlist entry for a shape that does not exist, no shape both pending and
// allowlisted, an allowlisted shape states its embedded exit code and
// carries no check that the allowlist would skip, every expect_stderr and
// refusal compiles, and the reference profile loads).
func TestCorpusFileIsWellFormed(t *testing.T) {
c, allow := loadCorpus(t)
seen := map[string]bool{}
for _, s := range c.Shapes {
if s.ID == "" || len(s.Args) == 0 {
t.Errorf("shape %+v needs an id and args", s)
continue
}
if seen[s.ID] {
t.Errorf("duplicate shape id %q", s.ID)
}
seen[s.ID] = true
if strings.TrimSpace(s.Source) == "" {
t.Errorf("shape %s names no source", s.ID)
}
if s.Pending != nil && (s.Pending.Slice == "" || strings.TrimSpace(s.Pending.Reason) == "") {
t.Errorf("shape %s is pending without a slice and a reason", s.ID)
}
if _, ok := allow[s.ID]; ok {
if s.Pending != nil {
t.Errorf("shape %s is both pending and allowlisted; pick one", s.ID)
}
if s.ExpectExit == nil {
t.Errorf("shape %s is allowlisted without expect_exit; state the exit code the embedded run must produce", s.ID)
}
if modeOf(s) != "exit" || len(s.Verify) > 0 {
t.Errorf("shape %s is allowlisted, so only its exit code and stderr are checked; give it compare: exit and no verify", s.ID)
}
if s.Requests != nil {
t.Errorf("shape %s is allowlisted, so its request count is not checked; drop requests", s.ID)
}
}
switch s.Compare {
case "", "json", "ids", "count", "text", "exit":
default:
t.Errorf("shape %s: unknown compare mode %q", s.ID, s.Compare)
}
if len(s.PrefixOf) > 0 && s.Compare != "ids" {
t.Errorf("shape %s: prefix_of needs compare: ids", s.ID)
}
if _, err := regexp.Compile(s.ExpectStderr); err != nil {
t.Errorf("shape %s: expect_stderr: %v", s.ID, err)
}
if s.Requests != nil && *s.Requests < 0 {
t.Errorf("shape %s: requests %d is negative", s.ID, *s.Requests)
}
}
for id, entry := range allow {
if !seen[id] {
t.Errorf("allowlist names %q, which is not a corpus shape", id)
}
if _, err := regexp.Compile(entry.Refusal); err != nil {
t.Errorf("allowlist entry %s: refusal: %v", id, err)
}
}
for _, a := range c.Files {
if (a.Content == "") == (a.Bulk == nil) {
t.Errorf("asset %s needs exactly one of content and bulk", a.Name)
}
}
loadReferenceProfile(t)
}
// side is one workspace the corpus runs in.
type side struct {
name string
dir string
files string
env []string
}
type outcome struct {
id, status, detail string
requests int64
}
// corpusParts is how many parts the shapes are dealt across. Each part is a
// top-level test of its own (TestServedCorpusPart1..N, servedCorpusParts)
// that starts its own server and seeds its own pair of workspaces, so the
// embedded lane runs each part in a Bazel shard of its own
// (served_pinned_shards.txt pins part k to shard k). The parts can be split
// because no shape depends on another's effects: every comparison is the
// served side against the embedded side after the same commands, and each
// part keeps corpus order, so its reads still run on the bare seed before
// any of its writes (see testdata/corpus.yaml's header).
//
// Four parts, from the embedded lane's measured part times (PR #7538): each
// part's server start and concurrent seed take ~62-76s and the 127 shapes
// ~242s together, so four parts ran 114-146s each and three ran 170-180s.
// Three would save one setup (~75 test-seconds a run), but the longest part
// is the embedded lane's served long pole, on the gate's critical path
// (forks' above all), so the ~34s it saves is worth more.
const corpusParts = 4
// servedCorpusParts are the parts' tests, one per part, in part order.
var servedCorpusParts = []func(*testing.T){
TestServedCorpusPart1, TestServedCorpusPart2, TestServedCorpusPart3, TestServedCorpusPart4,
}
func TestServedCorpusPart1(t *testing.T) { testServedCorpus(t, 1) }
func TestServedCorpusPart2(t *testing.T) { testServedCorpus(t, 2) }
func TestServedCorpusPart3(t *testing.T) { testServedCorpus(t, 3) }
func TestServedCorpusPart4(t *testing.T) { testServedCorpus(t, 4) }
// corpusPartNameErr fails a part test whose name is not its part's: a
// TestServedCorpusPart3 that ran part 2 would run part 2's shapes twice and
// silently drop its own. A part outside 1..corpusParts (a stray
// TestServedCorpusPart5 left after the parts shrink) would run no shapes.
func corpusPartNameErr(name string, part int) error {
if part < 1 || part > corpusParts {
return fmt.Errorf("%s runs corpus part %d; there are parts 1..%d (corpusParts)", name, part, corpusParts)
}
if want := fmt.Sprintf("TestServedCorpusPart%d", part); name != want {
return fmt.Errorf("%s runs corpus part %d; only %s may (fix its testServedCorpus call)", name, part, want)
}
return nil
}
// corpusPart returns the shapes part (1..corpusParts) runs.
func corpusPart(shapes []shape, part int) []shape {
return corpusPartOf(shapes, part, corpusParts)
}
// corpusPartOf deals shapes round robin, in corpus order, across parts parts
// and returns part's (1-based) share: shapes part-1, part-1+parts, and so on.
// Round robin keeps each part a mix of the corpus's reads and writes in
// their original order.
func corpusPartOf(shapes []shape, part, parts int) []shape {
var out []shape
for i := part - 1; i < len(shapes); i += parts {
out = append(out, shapes[i])
}
return out
}
// testServedCorpus is the suite, for one part of the corpus. Each shape is a
// subtest; a pending shape is still RUN and then skipped with what it did, so
// a slice that fixes it sees the subtest fail with "now passes; remove the
// pending mark". BEADS_CORPUS_SKIP_PENDING=1 skips pending shapes without
// running them. BEADS_CORPUS_REPORT=<path> writes a JSON summary of every
// part this process has run.
func testServedCorpus(t *testing.T, part int) {
// First, before the engine gate: a part test wired to the wrong part
// fails in every lane, not only where the corpus runs.
if err := corpusPartNameErr(t.Name(), part); err != nil {
t.Fatal(err)
}
skipUnlessEmbeddedDolt(t)
c, allow := loadCorpus(t)
shapes := corpusPart(c.Shapes, part)
profile := loadReferenceProfile(t)
bin := buildBD(t)
common := []string{
"BEADS_ACTOR=worker",
"CLAUDE_SESSION_ID=corpus-session-s23",
"BD_BACKUP_ENABLED=false",
"BD_EXPORT_AUTO=false",
}
// The embedded side needs no server: init and seed it on a goroutine
// while this one starts the server and seeds the served side. Each side
// has its own directories, env and bd processes (prepareSide), and each
// still runs the seed in order, so the seeded data is what it was when
// the two sides were seeded command by command in turn. The deferred
// cancel and Wait run on every exit, a t.Fatal included, so the goroutine
// never outlives the test or its TempDirs.
setupStart := time.Now()
ctx, cancel := context.WithCancel(context.Background())
var seeding sync.WaitGroup
defer seeding.Wait()
defer cancel()
local := &side{name: "embedded", dir: t.TempDir(), files: t.TempDir(), env: common}
var localErr error
seeding.Add(1)
go func() {
defer seeding.Done()
localErr = prepareSide(ctx, t, bin, c, local,
[]string{"init", "-p", corpusPrefix, "--non-interactive", "--skip-hooks", "--skip-agents", "-q"})
if localErr != nil {
cancel()
}
}()
serverAddr := startCorpusServer(t)
proxy := newReferenceProxy(t, profile, serverAddr)
proxyAddr := startProxy(t, proxy)
served := &side{name: "served", dir: t.TempDir(), files: t.TempDir(),
env: append([]string{"BEADS_HTTP_TOKEN=" + proxyAddr + "=" + corpusToken}, common...)}
servedErr := prepareSide(ctx, t, bin, c, served,
[]string{"connect", "http://" + proxyAddr, "--expect-project-id", corpusProjectID, "--json"})
if servedErr != nil {
cancel()
}
seeding.Wait()
// The side that failed first is the one to report; the other may only
// have seen the cancel.
for _, err := range []error{servedErr, localErr} {
if err != nil && !errors.Is(err, context.Canceled) {
t.Fatal(err)
}
}
t.Logf("part %d setup (server start and both sides seeded concurrently): %s", part, time.Since(setupStart).Round(100*time.Millisecond))
proxy.takeRefusals()
skipPending := os.Getenv("BEADS_CORPUS_SKIP_PENDING") == "1"
var outcomes []outcome
for _, s := range shapes {
s := s
t.Run(s.ID, func(t *testing.T) {
o := outcome{id: s.ID}
defer func() { outcomes = append(outcomes, o) }()
if s.Pending != nil && skipPending {
o.status = "pending:" + s.Pending.Slice
t.Skipf("pending %s: %s", s.Pending.Slice, s.Pending.Reason)
}
before := proxy.requests.Load()
failures := runShape(t, bin, s, served, local, allow, proxy)
o.requests = proxy.requests.Load() - before
entry, allowed := allow[s.ID]
switch {
case hasCorpusBug(failures):
// The embedded side itself disagrees with the corpus: no pending
// mark or allowlist entry may hide that, or a pending shape that
// can never pass would sit in the corpus forever.
o.status = "FAIL(corpus)"
o.detail = failures[0]
for _, f := range failures {
t.Error(f)
}
case s.Pending != nil && len(failures) == 0:
o.status = "FAIL(pending-now-passes)"
t.Errorf("shape is marked pending %s but now passes on the reference profile; remove the pending mark from testdata/corpus.yaml", s.Pending.Slice)
case s.Pending != nil:
o.status = "pending:" + s.Pending.Slice
o.detail = failures[0]
t.Skipf("pending %s: %s\nobserved:\n%s", s.Pending.Slice, s.Pending.Reason, strings.Join(failures, "\n"))
case len(failures) > 0:
o.status = "FAIL"
o.detail = failures[0]
for _, f := range failures {
t.Error(f)
}
case allowed:
o.status = "allowed"
o.detail = entry.Reason
default:
o.status = "pass"
}
})
}
summarize(t, part, len(c.Shapes), outcomes)
}
// runShape runs one shape on both sides and returns every way the served run
// fell short. It never calls t.Error itself, so the caller can turn a pending
// shape's failures into a skip.
func runShape(t *testing.T, bin string, s shape, served, local *side, allow map[string]allowEntry, proxy *referenceProxy) []string {
t.Helper()
var fails []string
failf := func(format string, a ...any) { fails = append(fails, fmt.Sprintf(format, a...)) }
wantStderr, err := regexp.Compile(s.ExpectStderr)
if err != nil {
failf("CORPUS BUG: expect_stderr %q: %v", s.ExpectStderr, err)
return fails
}
for _, args := range s.Setup {
for _, sd := range []*side{served, local} {
if r := runBD(t, bin, sd.dir, sd.env, "", expand(context.Background(), t, bin, sd, args)...); r.code != 0 {
failf("setup %v failed on %s: %s", args, sd.name, r)
return fails
}
}
}
proxy.takeRefusals()
args := expand(context.Background(), t, bin, served, s.Args)
before := proxy.requests.Load()
sr := runBD(t, bin, served.dir, served.env, s.Stdin, args...)
servedRequests := proxy.requests.Load() - before
wireRefusals := proxy.takeRefusals()
lr := runBD(t, bin, local.dir, local.env, s.Stdin, expand(context.Background(), t, bin, local, s.Args)...)
t.Logf("bd %s\nserved: %s\nembedded: exit=%d", strings.Join(s.Args, " "), sr, lr.code)
if len(wireRefusals) > 0 {
t.Logf("reference-profile refusals on the wire: %v", wireRefusals)
}
// The embedded run is the oracle for every shape, an allowlisted one
// included: when it no longer does what the shape says, the shape is
// wrong or bd changed, whatever the served run did.
if lr.code != s.wantExit() {
failf("CORPUS BUG: the embedded run exited %d, want %d; the shape itself is wrong or bd changed: %s", lr.code, s.wantExit(), lr)
return fails
}
if s.ExpectStderr != "" && !wantStderr.MatchString(lr.stderr) {
failf("CORPUS BUG: embedded stderr does not match %q: %s", s.ExpectStderr, lr.stderr)
return fails
}
if entry, ok := allow[s.ID]; ok {
re, err := regexp.Compile(entry.Refusal)
if err != nil {
failf("allowlist refusal regexp for %s: %v", s.ID, err)
return fails
}
if sr.code == 0 {
failf("allowlisted (%s) but the served run SUCCEEDED; drop it from testdata/allowlist.yaml and give it a comparison", entry.Reason)
} else if !re.MatchString(sr.stderr + sr.stdout) {
failf("allowlisted refusal did not match %q (a different failure than the one allowed): %s", entry.Refusal, sr)
}
return fails
}
if m := refusalMarkers.FindString(sr.stderr + sr.stdout); m != "" {
failf("served run carries a refusal (%q): %s", m, sr)
} else if len(wireRefusals) > 0 && sr.code != 0 {
failf("served run failed on a reference-profile refusal %v: %s", wireRefusals, sr)
}
if sr.code != lr.code {
failf("exit code: served %d, embedded %d: %s", sr.code, lr.code, sr)
}
if s.ExpectStderr != "" && !wantStderr.MatchString(sr.stderr) {
failf("served stderr does not match %q (embedded does): %s", s.ExpectStderr, sr)
}
if s.Requests != nil && servedRequests != int64(*s.Requests) {
failf("the served run made %d requests, want exactly %d (requests); a change that saves one updates the pin", servedRequests, *s.Requests)
}
if len(fails) > 0 {
return fails
}
if len(s.PrefixOf) > 0 {
vs := runBD(t, bin, served.dir, served.env, "", expand(context.Background(), t, bin, served, s.PrefixOf)...)
vl := runBD(t, bin, local.dir, local.env, "", expand(context.Background(), t, bin, local, s.PrefixOf)...)
if vs.code != 0 || vl.code != 0 {
failf("prefix_of %v: exit served %d, embedded %d: served %s", s.PrefixOf, vs.code, vl.code, vs)
} else if d := comparePrefix(sr.stdout, lr.stdout, vs.stdout, vl.stdout); d != "" {
failf("output parity (ids, prefix_of): %s", d)
}
} else if d := compareOutputs(s, sr.stdout, lr.stdout); d != "" {
failf("output parity (%s): %s", modeOf(s), d)
}
for _, args := range s.Verify {
vs := runBD(t, bin, served.dir, served.env, "", expand(context.Background(), t, bin, served, args)...)
vl := runBD(t, bin, local.dir, local.env, "", expand(context.Background(), t, bin, local, args)...)
if vs.code != vl.code {
failf("verify %v: exit served %d, embedded %d: served %s", args, vs.code, vl.code, vs)
continue
}
if vl.code != 0 {
continue // both refused the read (e.g. a deleted id): equal is the check
}
if d := compareJSON(vs.stdout, vl.stdout, s.IgnoreFields, false); d != "" {
failf("verify %v diverged after the write: %s", args, d)
}
}
return fails
}
func hasCorpusBug(failures []string) bool {
for _, f := range failures {
if strings.HasPrefix(f, "CORPUS BUG") {
return true
}
}
return false
}
func modeOf(s shape) string {
if s.Compare == "" {
return "json"
}
return s.Compare
}
func compareOutputs(s shape, served, local string) string {
switch modeOf(s) {
case "exit":
return ""
case "text":
a, b := scrubText(served), scrubText(local)
if a != b {
return fmt.Sprintf("text differs\nserved:\n%s\nembedded:\n%s", clip(a, 3000), clip(b, 3000))
}
return ""
case "count":
a, errA := topLevelLen(served)
b, errB := topLevelLen(local)
if errA != nil || errB != nil {
return fmt.Sprintf("count: served err=%v embedded err=%v\nserved:\n%s", errA, errB, clip(served, 2000))
}
if a != b {
return fmt.Sprintf("row count: served %d, embedded %d", a, b)
}
return ""
case "ids":
a, errA := idList(served, s.Ordered)
b, errB := idList(local, s.Ordered)
if errA != nil || errB != nil {
return fmt.Sprintf("ids: served err=%v embedded err=%v\nserved:\n%s", errA, errB, clip(served, 2000))
}
if !reflect.DeepEqual(a, b) {
return fmt.Sprintf("ids differ\nserved (%d): %v\nembedded (%d): %v", len(a), a, len(b), b)
}
return ""
default:
return compareJSON(served, local, s.IgnoreFields, s.Ordered)
}
}
// comparePrefix holds a limited listing to its unlimited form on each side:
// see shape.PrefixOf.
func comparePrefix(served, local, servedAll, localAll string) string {
lists := make([][]string, 4)
for i, out := range []string{served, local, servedAll, localAll} {
ids, err := idList(out, true)
if err != nil {
return fmt.Sprintf("listing %d: %v\n%s", i, err, clip(out, 2000))
}
lists[i] = ids
}
s, l, sAll, lAll := lists[0], lists[1], lists[2], lists[3]
if len(s) != len(l) {
return fmt.Sprintf("row count: served %d, embedded %d", len(s), len(l))
}
for _, c := range []struct {
name string
rows, all []string
}{{"served", s, sAll}, {"embedded", l, lAll}} {
if len(c.rows) > len(c.all) || !reflect.DeepEqual(c.rows, c.all[:len(c.rows)]) {
return fmt.Sprintf("%s limited rows are not a prefix of its own unlimited listing\nlimited: %v\nunlimited: %v", c.name, c.rows, c.all)
}
}
sSet := append([]string(nil), sAll...)
lSet := append([]string(nil), lAll...)
sort.Strings(sSet)
sort.Strings(lSet)
if !reflect.DeepEqual(sSet, lSet) {
return fmt.Sprintf("unlimited ids differ\nserved (%d): %v\nembedded (%d): %v", len(sSet), sSet, len(lSet), lSet)
}
return ""
}
func scrubText(s string) string {
return strings.TrimSpace(timestampText.ReplaceAllString(s, "<ts>"))
}
func decode(s string) (any, error) {
var v any
if err := json.Unmarshal([]byte(strings.TrimSpace(s)), &v); err != nil {
return nil, fmt.Errorf("not JSON: %w", err)
}
return v, nil
}
// rows finds the row array in a bd --json payload: the payload itself, or the
// first array member of an envelope object.
func rows(v any) ([]any, bool) {
switch x := v.(type) {
case []any:
return x, true
case map[string]any:
for _, k := range []string{"issues", "data", "items", "results"} {
if arr, ok := x[k].([]any); ok {
return arr, true
}
}
}
return nil, false
}
func topLevelLen(s string) (int, error) {
v, err := decode(s)
if err != nil {
return 0, err
}
arr, ok := rows(v)
if !ok {
return 0, fmt.Errorf("no row array in output")
}
return len(arr), nil
}
func idList(s string, ordered bool) ([]string, error) {
v, err := decode(s)
if err != nil {
return nil, err
}
arr, ok := rows(v)
if !ok {
return nil, fmt.Errorf("no row array in output")
}
out := []string{}
for _, r := range arr {
if m, ok := r.(map[string]any); ok {
if id, ok := m["id"].(string); ok {
out = append(out, id)
}
}
}
if !ordered {
sort.Strings(out)
}
return out, nil
}
func compareJSON(served, local string, ignore []string, ordered bool) string {
a, errA := decode(served)
b, errB := decode(local)
if errA != nil || errB != nil {
return fmt.Sprintf("served err=%v embedded err=%v\nserved:\n%s\nembedded:\n%s", errA, errB, clip(served, 2000), clip(local, 2000))
}
drop := map[string]bool{}
for _, k := range ignore {
drop[k] = true
}
a, b = normalize(a, drop, ordered), normalize(b, drop, ordered)
if path, x, y, same := firstDiff("$", a, b); !same {
return fmt.Sprintf("first difference at %s: served=%s embedded=%s", path, brief(x), brief(y))
}
return ""
}
func normalize(v any, drop map[string]bool, ordered bool) any {
switch x := v.(type) {
case map[string]any:
out := make(map[string]any, len(x))
for k, val := range x {
if drop[k] {
continue
}
if callerTimeKey[k] {
out[k] = val
continue
}
if volatileKey.MatchString(k) {
continue
}
out[k] = normalize(val, drop, ordered)
}
return out
case []any:
out := make([]any, len(x))
for i, e := range x {
out[i] = normalize(e, drop, ordered)
}
if !ordered {
sort.SliceStable(out, func(i, j int) bool { return sortKey(out[i]) < sortKey(out[j]) })
}
return out
case string:
return timestampText.ReplaceAllString(x, "<ts>")
default:
return v
}
}
func sortKey(v any) string {
if m, ok := v.(map[string]any); ok {
for _, k := range []string{"id", "issue_id", "key"} {
if s, ok := m[k].(string); ok {
return k + "=" + s
}
}
if inner, ok := m["issue"].(map[string]any); ok {
if s, ok := inner["id"].(string); ok {
return "issue.id=" + s
}
}
}
raw, _ := json.Marshal(v)
return string(raw)
}
func firstDiff(path string, a, b any) (string, any, any, bool) {
switch x := a.(type) {
case map[string]any:
y, ok := b.(map[string]any)
if !ok {
return path, a, b, false
}
keys := map[string]bool{}
for k := range x {
keys[k] = true
}
for k := range y {
keys[k] = true
}
sorted := make([]string, 0, len(keys))
for k := range keys {
sorted = append(sorted, k)
}
sort.Strings(sorted)
for _, k := range sorted {
xv, xok := x[k]
yv, yok := y[k]
if !xok || !yok {
return path + "." + k, xv, yv, false
}
if p, l, r, same := firstDiff(path+"."+k, xv, yv); !same {
return p, l, r, false
}
}
return "", nil, nil, true
case []any:
y, ok := b.([]any)
if !ok {
return path, a, b, false
}
if len(x) != len(y) {
return path + ".length", len(x), len(y), false
}
for i := range x {
if p, l, r, same := firstDiff(path+"["+strconv.Itoa(i)+"]", x[i], y[i]); !same {
return p, l, r, false
}
}
return "", nil, nil, true
default:
if reflect.DeepEqual(a, b) {
return "", nil, nil, true
}
return path, a, b, false
}
}
func brief(v any) string {
if v == nil {
return "<absent>"
}
raw, _ := json.Marshal(v)
return clip(string(raw), 400)
}
var placeholder = regexp.MustCompile(`\{(file|rev):([^}]+)\}`)
// expand substitutes {file:NAME} and {rev:ID} in args for side sd. It never
// fails t (a {rev:} it cannot read becomes "0"), so prepareSide may call it
// off the test's goroutine; its {rev:} lookup runs under ctx, so a cancelled
// prepareSide starts no further bd there either.
func expand(ctx context.Context, t *testing.T, bin string, sd *side, args []string) []string {
t.Helper()
out := make([]string, len(args))
for i, a := range args {
out[i] = placeholder.ReplaceAllStringFunc(a, func(m string) string {
parts := placeholder.FindStringSubmatch(m)
switch parts[1] {
case "file":
return filepath.Join(sd.files, parts[2])
default:
r, err := execBD(ctx, bin, sd.dir, sd.env, "", "show", parts[2], "--json")
if err != nil {
t.Logf("{rev:%s} on %s: %v", parts[2], sd.name, err)
return "0"
}
if r.code != 0 {
t.Logf("{rev:%s} on %s: show failed: %s", parts[2], sd.name, r)
return "0"
}
v, err := decode(r.stdout)
if err != nil {
return "0"
}
if arr, ok := rows(v); ok && len(arr) > 0 {
v = arr[0]
}
if m, ok := v.(map[string]any); ok {
if rev, ok := m["revision"].(string); ok {
return rev
}
}
return "0"
}
})
}
return out
}
// prepareSide attaches sd to its store with bd attach (connect or init),
// writes the corpus's asset files into sd.files and runs the seed on sd, in
// order. It touches only sd's own directories and bd processes and returns a
// failure as an error instead of failing t, so testServedCorpus runs it for
// the two sides at once; it stops before its next bd once ctx is done.
func prepareSide(ctx context.Context, t *testing.T, bin string, c *corpusFile, sd *side, attach []string) error {
t.Helper()
r, err := execBD(ctx, bin, sd.dir, sd.env, "", attach...)
if err != nil {
return err
}
if r.code != 0 {
return fmt.Errorf("bd %s on %s: %s", strings.Join(attach, " "), sd.name, r)
}
if err := writeAssets(c.Files, sd.files); err != nil {
return fmt.Errorf("%s: %w", sd.name, err)
}
for _, args := range c.Seed {
if err := ctx.Err(); err != nil {
return err
}
r, err := execBD(ctx, bin, sd.dir, sd.env, "", expand(ctx, t, bin, sd, args)...)
if err != nil {
return err
}
if r.code != 0 {
return fmt.Errorf("seed %v on %s failed; the seed must use shapes that work on the reference profile: %s", args, sd.name, r)
}
}
return nil
}
func writeAssets(assets []corpusAsset, dir string) error {
for _, a := range assets {
content := a.Content
if a.Bulk != nil {
content = bulkPlan(*a.Bulk)
}
if err := os.WriteFile(filepath.Join(dir, a.Name), []byte(content), 0o600); err != nil {
return fmt.Errorf("write asset %s: %w", a.Name, err)
}
}
return nil
}
func bulkPlan(b bulkGraph) string {
type node struct {
Key string `json:"key"`
ID string `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
Priority int `json:"priority"`
Ephemeral bool `json:"ephemeral,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
plan := struct {
CommitMessage string `json:"commit_message"`
Nodes []node `json:"nodes"`
}{CommitMessage: "corpus bulk " + b.IDPrefix}
for i := 1; i <= b.Count; i++ {
id := fmt.Sprintf("%s-%03d", b.IDPrefix, i)
plan.Nodes = append(plan.Nodes, node{Key: id, ID: id, Title: "bulk " + id, Type: "task",
Priority: b.Priority, Ephemeral: b.Ephemeral, Metadata: b.Metadata})
}
raw, _ := json.MarshalIndent(plan, "", " ")
return string(raw)
}
// reported is every outcome of every part this process has run, in the order
// the parts ran, for BEADS_CORPUS_REPORT.
var reported []outcome
func summarize(t *testing.T, part, total int, outcomes []outcome) {
t.Helper()
counts := map[string]int{}
var lines []string
for _, o := range outcomes {
key := o.status
if strings.HasPrefix(key, "pending:") {
key = "pending"
}
counts[key]++
lines = append(lines, fmt.Sprintf("%-26s %-48s req=%-3d %s", o.status, o.id, o.requests, firstLine(o.detail)))
}
t.Logf("corpus summary, part %d of %d (%d of %d shapes): %v\n%s", part, corpusParts, len(outcomes), total, counts, strings.Join(lines, "\n"))
reported = append(reported, outcomes...)
if path := os.Getenv("BEADS_CORPUS_REPORT"); path != "" {
type row struct {
ID string `json:"id"`
Status string `json:"status"`
Requests int64 `json:"requests"`
Detail string `json:"detail,omitempty"`
}
var out []row
for _, o := range reported {
out = append(out, row{o.id, o.status, o.requests, o.detail})
}
raw, _ := json.MarshalIndent(out, "", " ")
if err := os.WriteFile(path, raw, 0o600); err != nil {
t.Errorf("write BEADS_CORPUS_REPORT: %v", err)
}
}
}
func firstLine(s string) string {
s = strings.TrimSpace(s)
if i := strings.IndexByte(s, '\n'); i >= 0 {
s = s[:i]
}
return clip(s, 160)
}

View file

@ -0,0 +1,355 @@
//go:build cgo
package corpus_test
import (
"context"
"encoding/json"
"net/http"
"os"
"path/filepath"
"slices"
"strings"
"sync"
"testing"
"time"
"github.com/steveyegge/beads/internal/httpapi"
"github.com/steveyegge/beads/internal/storage/embeddeddolt"
"github.com/steveyegge/beads/internal/types"
)
// gateCheckRequestLog records every request the reference proxy forwards.
type gateCheckRequestLog struct {
mu sync.Mutex
seen []string
next http.Handler
}
func (l *gateCheckRequestLog) ServeHTTP(w http.ResponseWriter, r *http.Request) {
l.mu.Lock()
l.seen = append(l.seen, r.Method+" "+r.URL.Path)
l.mu.Unlock()
l.next.ServeHTTP(w, r)
}
func (l *gateCheckRequestLog) take() []string {
l.mu.Lock()
defer l.mu.Unlock()
out := l.seen
l.seen = nil
return out
}
func gateCheckWrites(reqs []string) []string {
var writes []string
for _, r := range reqs {
if !strings.HasPrefix(r, http.MethodGet+" ") {
writes = append(writes, r)
}
}
return writes
}
// TestServedGateCheckOverAwaitTypedGates runs `bd gate check` over HTTP, through
// the reference proxy, against REAL await-typed gates, on a server that
// advertises neither gate token (issues.create.gates, issues.update.gates; the
// profile is masked here, so this holds whatever reference_server.json
// advertises). No create through it carries await_*: the gates are seeded
// straight into the served store before it listens, and every outcome is read
// back from that store:
//
// - --dry-run writes nothing;
// - an expired timer closes, a pending one stays open;
// - a bead gate whose target is open records its sighting (issues.update),
// and one whose target is closed closes;
// - a merged gh:pr gate closes, a closed one escalates and stays open;
// - a gh:run gate with a workflow-name hint discovers its run but cannot
// persist await_id through a server without issues.update.gates: the
// client refuses the patch before the dial, that gate's error names the
// missing token and the server, not a Go method, and await_id is
// untouched;
// - a persisted proto's gates are templates: listed, but no sweep evaluates
// or writes them, and they take no row of --limit (they sort first here).
//
// The corpus.yaml shapes prove the listing only (their gates have no
// await_type); this is the test that proves what the sweep does to the gates.
func TestServedGateCheckOverAwaitTypedGates(t *testing.T) {
skipUnlessEmbeddedDolt(t)
bin := buildBD(t)
ctx := context.Background()
store, err := embeddeddolt.Open(ctx, t.TempDir(), corpusDatabase, "main")
if err != nil {
t.Fatalf("open the served store: %v", err)
}
t.Cleanup(func() { _ = store.Close() })
if err := store.SetConfig(ctx, "issue_prefix", corpusPrefix); err != nil {
t.Fatalf("set the issue prefix: %v", err)
}
// The templates keep P0 and every other row gets P2, so the store's default
// order puts the template gates ahead of every live one.
seed := func(i *types.Issue) {
t.Helper()
i.Status = types.StatusOpen
i.Title = i.ID
if !i.IsTemplate {
i.Priority = 2
}
if err := store.CreateIssue(ctx, i, "seed"); err != nil {
t.Fatalf("seed %s: %v", i.ID, err)
}
}
seed(&types.Issue{ID: "e2e-tgt-open", IssueType: "task"})
seed(&types.Issue{ID: "e2e-tgt-closed", IssueType: "task"})
if err := store.CloseIssue(ctx, "e2e-tgt-closed", "done", "seed", ""); err != nil {
t.Fatalf("close e2e-tgt-closed: %v", err)
}
seed(&types.Issue{ID: "e2e-g-timer", IssueType: "gate", AwaitType: "timer", Timeout: time.Millisecond})
seed(&types.Issue{ID: "e2e-g-timer-pending", IssueType: "gate", AwaitType: "timer", Timeout: 100 * time.Hour})
seed(&types.Issue{ID: "e2e-g-bead-open", IssueType: "gate", AwaitType: "bead", AwaitID: "e2e-tgt-open"})
seed(&types.Issue{ID: "e2e-g-bead-closed", IssueType: "gate", AwaitType: "bead", AwaitID: "e2e-tgt-closed"})
seed(&types.Issue{ID: "e2e-g-pr-merged", IssueType: "gate", AwaitType: "gh:pr", AwaitID: "11"})
seed(&types.Issue{ID: "e2e-g-pr-closed", IssueType: "gate", AwaitType: "gh:pr", AwaitID: "12"})
seed(&types.Issue{ID: "e2e-g-run-hint", IssueType: "gate", AwaitType: "gh:run", AwaitID: "ci-wf"})
seed(&types.Issue{ID: "e2e-tpl-timer", IssueType: "gate", AwaitType: "timer", Timeout: time.Millisecond, IsTemplate: true})
seed(&types.Issue{ID: "e2e-tpl-bead", IssueType: "gate", AwaitType: "bead", AwaitID: "e2e-tgt-open", IsTemplate: true})
seed(&types.Issue{ID: "e2e-tpl-run", IssueType: "gate", AwaitType: "gh:run", AwaitID: "ci-wf", IsTemplate: true})
tokenFile := filepath.Join(t.TempDir(), "tokens")
if err := os.WriteFile(tokenFile, []byte(corpusToken+"\n"), 0o600); err != nil {
t.Fatalf("write the token file: %v", err)
}
auth, err := httpapi.NewTokenFileAuth(tokenFile)
if err != nil {
t.Fatalf("load the token file: %v", err)
}
cfg := corpusServeConfig(t, store)
cfg.AllowNonLoopback = true
cfg.Auth = auth
srv, err := httpapi.Listen(cfg)
if err != nil {
t.Fatalf("bind the in-process server: %v", err)
}
serveCtx, cancel := context.WithCancel(context.Background())
done := make(chan struct{})
go func() { defer close(done); _ = srv.Serve(serveCtx) }()
t.Cleanup(func() {
cancel()
select {
case <-done:
case <-time.After(30 * time.Second):
t.Error("the in-process server did not shut down")
}
})
// The gh:run case pins a server that cannot take an await_id patch, so the
// profile is held without issues.update.gates whatever
// reference_server.json advertises: upgrading the reference profile must
// not turn this case into a different test.
profile := loadReferenceProfile(t)
profile.Capabilities = slices.DeleteFunc(profile.Capabilities, func(c string) bool { return c == "issues.update.gates" })
proxy := newReferenceProxy(t, profile, srv.Addr())
reqs := &gateCheckRequestLog{next: proxy}
proxyAddr := startProxy(t, reqs)
// gh and gt are fakes on PATH: gh answers the run discovery and the two PR
// states, gt records each escalation.
binDir := t.TempDir()
gh := `#!/bin/sh
case "$1 $2" in
"run list") echo '[{"databaseId":4242,"name":"ci-wf","status":"completed","conclusion":"success","createdAt":"2026-10-15T00:00:00Z","workflowName":"ci-wf"}]' ;;
"run view") echo '{"status":"completed","conclusion":"success","name":"ci-wf"}' ;;
"pr view") if [ "$3" = "11" ]; then echo '{"state":"MERGED","title":"m"}'; else echo '{"state":"CLOSED","title":"c"}'; fi ;;
*) echo "unexpected gh $*" >&2; exit 3 ;;
esac
`
if err := os.WriteFile(filepath.Join(binDir, "gh"), []byte(gh), 0o755); err != nil {
t.Fatalf("write fake gh: %v", err)
}
if err := os.WriteFile(filepath.Join(binDir, "gt"), []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
t.Fatalf("write fake gt: %v", err)
}
dir := t.TempDir()
env := []string{
"BEADS_HTTP_TOKEN=" + proxyAddr + "=" + corpusToken,
"BEADS_ACTOR=worker",
"BD_BACKUP_ENABLED=false",
"BD_EXPORT_AUTO=false",
"PATH=" + binDir + string(os.PathListSeparator) + os.Getenv("PATH"),
}
if r := runBD(t, bin, dir, env, "", "connect", "http://"+proxyAddr, "--expect-project-id", corpusProjectID, "--json"); r.code != 0 {
t.Fatalf("bd connect: %s", r)
}
reqs.take()
time.Sleep(50 * time.Millisecond) // the 1ms timer is expired by now
get := func(id string) *types.Issue {
t.Helper()
issue, err := store.GetIssue(ctx, id)
if err != nil {
t.Fatalf("read %s back: %v", id, err)
}
return issue
}
wantStatus := func(id string, want types.Status) {
t.Helper()
if got := get(id).Status; got != want {
t.Errorf("%s status = %s, want %s", id, got, want)
}
}
seenOf := func(id string) string {
t.Helper()
var meta map[string]json.RawMessage
raw := get(id).Metadata
if len(raw) == 0 {
return ""
}
if err := json.Unmarshal(raw, &meta); err != nil {
t.Fatalf("%s metadata %s: %v", id, raw, err)
}
var seen string
_ = json.Unmarshal(meta["await_seen"], &seen)
return seen
}
allGates := []string{"e2e-g-timer", "e2e-g-timer-pending", "e2e-g-bead-open", "e2e-g-bead-closed", "e2e-g-pr-merged", "e2e-g-pr-closed", "e2e-g-run-hint"}
t.Run("dry-run writes nothing", func(t *testing.T) {
r := runBD(t, bin, dir, env, "", "gate", "check", "--dry-run")
if r.code != 0 {
t.Fatalf("bd gate check --dry-run: %s", r)
}
if w := gateCheckWrites(reqs.take()); len(w) != 0 {
t.Fatalf("--dry-run sent writes %v\n%s", w, r)
}
for _, id := range allGates {
wantStatus(id, types.StatusOpen)
}
if seen := seenOf("e2e-g-bead-open"); seen != "" {
t.Errorf("--dry-run recorded a sighting %q", seen)
}
if got := get("e2e-g-run-hint").AwaitID; got != "ci-wf" {
t.Errorf("--dry-run persisted await_id %q", got)
}
})
t.Run("limit counts only live gates", func(t *testing.T) {
// bd gate list still lists templates, so its first three rows show the
// order the sweep's own listing would be cut from.
r := runBD(t, bin, dir, env, "", "gate", "list", "--limit", "3", "--json")
var listed []types.Issue
if start := strings.Index(r.stdout, "["); r.code != 0 || start < 0 || json.Unmarshal([]byte(r.stdout[start:]), &listed) != nil {
t.Fatalf("bd gate list --limit 3 --json: %s", r)
}
var ids []string
for _, g := range listed {
if strings.HasPrefix(g.ID, "e2e-tpl-") {
ids = append(ids, g.ID)
}
}
if len(listed) != 3 || len(ids) != 3 {
t.Fatalf("bd gate list --limit 3 listed %d gates, %d of them templates (%v), want the three template gates first", len(listed), len(ids), ids)
}
reqs.take()
r = runBD(t, bin, dir, env, "", "gate", "check", "--dry-run", "--limit", "3")
if r.code != 0 {
t.Fatalf("bd gate check --dry-run --limit 3: %s", r)
}
if w := gateCheckWrites(reqs.take()); len(w) != 0 {
t.Fatalf("--dry-run sent writes %v\n%s", w, r)
}
if !strings.Contains(r.stdout, "Checked 3 gates") {
t.Errorf("--limit 3 behind three template gates must still check three live gates:\n%s", r)
}
if strings.Contains(r.stdout+r.stderr, "e2e-tpl-") {
t.Errorf("a template gate was checked:\n%s", r)
}
})
t.Run("timer sweep closes the expired timer", func(t *testing.T) {
r := runBD(t, bin, dir, env, "", "gate", "check", "--type=timer", "--escalate")
if r.code != 0 {
t.Fatalf("bd gate check --type=timer --escalate: %s", r)
}
reqs.take()
wantStatus("e2e-g-timer", types.StatusClosed)
wantStatus("e2e-g-timer-pending", types.StatusOpen)
wantStatus("e2e-tpl-timer", types.StatusOpen)
})
t.Run("bead sweep records the sighting and closes the done gate", func(t *testing.T) {
r := runBD(t, bin, dir, env, "", "gate", "check", "--type=bead")
if r.code != 0 {
t.Fatalf("bd gate check --type=bead: %s", r)
}
writes := gateCheckWrites(reqs.take())
sighted := false
for _, w := range writes {
if strings.Contains(w, "e2e-g-bead-open") {
sighted = true
}
if strings.Contains(w, "e2e-tpl-bead") {
t.Errorf("the sweep wrote to the template gate: %s", w)
}
}
if !sighted {
t.Errorf("no write to e2e-g-bead-open reached the server; writes: %v\n%s", writes, r)
}
if seen := seenOf("e2e-g-bead-open"); seen != "e2e-tgt-open" {
t.Errorf("e2e-g-bead-open await_seen = %q, want e2e-tgt-open\n%s", seen, r)
}
if seen := seenOf("e2e-tpl-bead"); seen != "" {
t.Errorf("e2e-tpl-bead recorded a sighting %q; a template gate is never checked", seen)
}
wantStatus("e2e-g-bead-open", types.StatusOpen)
wantStatus("e2e-g-bead-closed", types.StatusClosed)
})
t.Run("gh:pr sweep closes the merged PR gate", func(t *testing.T) {
r := runBD(t, bin, dir, env, "", "gate", "check", "--type=gh:pr", "--escalate")
if r.code != 0 {
t.Fatalf("bd gate check --type=gh:pr --escalate: %s", r)
}
reqs.take()
wantStatus("e2e-g-pr-merged", types.StatusClosed)
wantStatus("e2e-g-pr-closed", types.StatusOpen)
if !strings.Contains(r.stdout, "e2e-g-pr-closed: ESCALATE") {
t.Errorf("closed PR gate was not escalated:\n%s", r)
}
})
t.Run("gh:run await_id persist refuses by the missing token", func(t *testing.T) {
r := runBD(t, bin, dir, env, "", "gate", "check", "--type=gh:run")
if r.code == 0 {
t.Fatalf("bd gate check --type=gh:run succeeded; the reference server does not advertise issues.update.gates: %s", r)
}
if w := gateCheckWrites(reqs.take()); len(w) != 0 {
t.Errorf("the refused await_id persist sent writes %v", w)
}
if !strings.Contains(r.stderr, "e2e-g-run-hint") || !strings.Contains(r.stderr, `does not advertise capability "issues.update.gates"`) {
t.Errorf("gh:run error does not name the gate and the missing issues.update.gates token:\n%s", r)
}
if !strings.Contains(r.stderr, "bd serve at http://"+proxyAddr) {
t.Errorf("gh:run error does not name the server it reached:\n%s", r)
}
if strings.Contains(r.stderr, "e2e-tpl-run") {
t.Errorf("the template gh:run gate was checked:\n%s", r)
}
// The capability refusal names the wire operation (updateIssue) that
// needs the token; the role and store methods stay out of it.
for _, leak := range []string{"UpdateIssue", "Lifecycle.Update"} {
if strings.Contains(r.stderr, leak) {
t.Errorf("gh:run error leaks %q:\n%s", leak, r)
}
}
if got := get("e2e-g-run-hint").AwaitID; got != "ci-wf" {
t.Errorf("e2e-g-run-hint await_id = %q, want ci-wf untouched", got)
}
wantStatus("e2e-g-run-hint", types.StatusOpen)
if got := get("e2e-tpl-run").AwaitID; got != "ci-wf" {
t.Errorf("e2e-tpl-run await_id = %q, want ci-wf untouched", got)
}
})
}

View file

@ -0,0 +1,333 @@
//go:build cgo
package corpus_test
import (
"context"
"errors"
"fmt"
"io"
"net"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"sync"
"testing"
"time"
"github.com/steveyegge/beads/internal/httpapi"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/domain"
"github.com/steveyegge/beads/internal/storage/embeddeddolt"
"github.com/steveyegge/beads/internal/testutil/bazeltest"
)
const (
corpusProjectID = "proj-corpus-s23"
corpusDatabase = "corpus"
corpusPrefix = "e2e"
// corpusToken is the bearer the in-process server accepts. The reference
// deployment authenticates every request, so the suite does too.
// #nosec G101 -- a throwaway test credential for an httptest-scoped server.
corpusToken = "corpus-s23-test-token"
// bdTimeout bounds one bd subprocess so a hung shape fails rather than
// stalling the whole suite.
bdTimeout = 90 * time.Second
)
// startCorpusServer binds the in-process server the way the reference
// deployment is bound: AllowNonLoopback with a bearer token file. The socket is
// still 127.0.0.1 (this suite never leaves the host), but every behavior the
// server keys off its bind mode — the loopback-only refusal of an unlimited
// read above all — is the non-loopback one, because that is decided by
// Config.AllowNonLoopback and not by the address.
func startCorpusServer(t *testing.T) string {
t.Helper()
beadsDir := t.TempDir()
ctx := context.Background()
store, err := embeddeddolt.Open(ctx, beadsDir, corpusDatabase, "main")
if err != nil {
t.Fatalf("open the served store: %v", err)
}
t.Cleanup(func() { _ = store.Close() })
if err := store.SetConfig(ctx, "issue_prefix", corpusPrefix); err != nil {
t.Fatalf("set the issue prefix: %v", err)
}
tokenFile := filepath.Join(t.TempDir(), "tokens")
if err := os.WriteFile(tokenFile, []byte(corpusToken+"\n"), 0o600); err != nil {
t.Fatalf("write the token file: %v", err)
}
auth, err := httpapi.NewTokenFileAuth(tokenFile)
if err != nil {
t.Fatalf("load the token file: %v", err)
}
cfg := corpusServeConfig(t, store)
cfg.AllowNonLoopback = true
cfg.Auth = auth
srv, err := httpapi.Listen(cfg)
if err != nil {
t.Fatalf("bind the in-process server: %v", err)
}
serveCtx, cancel := context.WithCancel(context.Background())
done := make(chan struct{})
go func() { defer close(done); _ = srv.Serve(serveCtx) }()
t.Cleanup(func() {
cancel()
select {
case <-done:
case <-time.After(30 * time.Second):
t.Error("the in-process server did not shut down")
}
})
return srv.Addr()
}
// startProxy serves h on an ephemeral loopback port.
func startProxy(t *testing.T, h http.Handler) string {
t.Helper()
srv := &http.Server{Handler: h, ReadHeaderTimeout: 10 * time.Second}
ln, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("listen for the reference proxy: %v", err)
}
go func() { _ = srv.Serve(ln) }()
t.Cleanup(func() { _ = srv.Close() })
return ln.Addr().String()
}
// corpusServeConfig takes every role off the store, as bd serve does. It
// mirrors backend/http's e2eServeConfig (a sibling test package, so it cannot
// be imported).
func corpusServeConfig(t *testing.T, s storage.DoltStorage) httpapi.Config {
t.Helper()
cfg := httpapi.Config{
Addr: "127.0.0.1:0",
Stdout: io.Discard,
Stderr: io.Discard,
Workspace: domain.ContextInfo{ProjectID: corpusProjectID, Database: corpusDatabase},
}
var err error
must := func(name string) {
t.Helper()
if err != nil {
t.Fatalf("%s(): %v", name, err)
}
}
cfg.Reader, err = s.IssueReader()
must("IssueReader")
cfg.Claimer, err = s.IssueClaimer()
must("IssueClaimer")
cfg.ReadyClaimer, err = s.ReadyClaimer()
must("ReadyClaimer")
cfg.Releaser, err = s.Releaser()
must("Releaser")
cfg.Lifecycle, err = s.IssueLifecycle()
must("IssueLifecycle")
cfg.Settings, err = s.WorkspaceConfig()
must("WorkspaceConfig")
cfg.Stats, err = s.StatsReporter()
must("StatsReporter")
cfg.CycleDetector, err = s.CycleDetector()
must("CycleDetector")
cfg.EdgeReader, err = s.EdgeReader()
must("EdgeReader")
cfg.GraphCounter, err = s.GraphCounter()
must("GraphCounter")
cfg.BatchGetter, err = s.BatchGetter()
must("BatchGetter")
cfg.LeaseReclaimer, err = s.LeaseReclaimer()
must("LeaseReclaimer")
cfg.Heartbeater, err = s.Heartbeater()
must("Heartbeater")
cfg.BlockedLister, err = s.BlockedLister()
must("BlockedLister")
cfg.Relations, err = s.IssueRelations()
must("IssueRelations")
cfg.Commenter, err = s.Commenter()
must("Commenter")
cfg.BlockingAnnotator, err = s.BlockingAnnotator()
must("BlockingAnnotator")
cfg.TreeWalker, err = s.TreeWalker()
must("TreeWalker")
cfg.ReadyCounter, err = s.ReadyCounter()
must("ReadyCounter")
cfg.Counter, err = s.Counter()
must("Counter")
cfg.Querier, err = s.Querier()
must("Querier")
cfg.Sweeper, err = s.Sweeper()
must("Sweeper")
cfg.Deleter, err = s.Deleter()
must("Deleter")
cfg.BatchCreator, err = s.BatchCreator()
must("BatchCreator")
cfg.BatchCloser, err = s.BatchCloser()
must("BatchCloser")
cfg.DependencyEditor, err = s.DependencyEditor()
must("DependencyEditor")
cfg.MetadataCAS, err = s.MetadataCAS()
must("MetadataCAS")
cfg.BatchApplier, err = s.BatchApplier()
must("BatchApplier")
cfg.Memories, err = s.Memories()
must("Memories")
return cfg
}
// This file is the corpus tier's cgo half; see TestCorpusTierIsLinkedWhenRequired.
func init() { corpusTierLinked = true }
// skipUnlessEmbeddedDolt is the served tier's gate, as in backend/http.
func skipUnlessEmbeddedDolt(t *testing.T) {
t.Helper()
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") == "1" {
return
}
if os.Getenv("BEADS_HTTP_TEST_REQUIRED") == "1" {
t.Fatal("BEADS_HTTP_TEST_REQUIRED=1 but BEADS_TEST_EMBEDDED_DOLT is not 1; the http corpus tier is not enforced")
}
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run the http command-corpus tier")
}
type bdResult struct {
stdout, stderr string
code int
}
func (r bdResult) String() string {
return fmt.Sprintf("exit=%d\nstdout:\n%s\nstderr:\n%s", r.code, clip(r.stdout, 4000), clip(r.stderr, 4000))
}
func clip(s string, n int) string {
if len(s) <= n {
return s
}
return s[:n] + fmt.Sprintf("\n... (%d more bytes)", len(s)-n)
}
// runBD runs the built bd binary in dir with a hermetic environment.
func runBD(t *testing.T, bin, dir string, env []string, stdin string, args ...string) bdResult {
t.Helper()
r, err := execBD(context.Background(), bin, dir, env, stdin, args...)
if err != nil {
t.Fatal(err)
}
return r
}
// execBD is runBD without the testing.T: it returns an error, rather than
// failing a test, when bd could not be run at all or ctx was cancelled, so it
// is safe on a goroutine that is not the test's. A bd that runs and fails is
// a bdResult with its exit code, as in runBD.
func execBD(ctx context.Context, bin, dir string, env []string, stdin string, args ...string) (bdResult, error) {
if err := ctx.Err(); err != nil {
return bdResult{}, err
}
ctx, cancel := context.WithTimeout(ctx, bdTimeout)
defer cancel()
cmd := exec.CommandContext(ctx, bin, args...)
cmd.Dir = dir
cmd.Env = minimalBDEnv(dir, env...)
if stdin != "" {
cmd.Stdin = strings.NewReader(stdin)
}
var o, e strings.Builder
cmd.Stdout, cmd.Stderr = &o, &e
err := cmd.Run()
code := 0
if err != nil {
var ee *exec.ExitError
switch {
case errors.Is(ctx.Err(), context.DeadlineExceeded):
code = -1
e.WriteString(fmt.Sprintf("\n[corpus harness] bd timed out after %s", bdTimeout))
case ctx.Err() != nil:
return bdResult{}, fmt.Errorf("bd %s: %w", strings.Join(args, " "), ctx.Err())
case errors.As(err, &ee):
code = ee.ExitCode()
default:
return bdResult{}, fmt.Errorf("running bd %s: %v", strings.Join(args, " "), err)
}
}
return bdResult{stdout: o.String(), stderr: e.String(), code: code}, nil
}
// minimalBDEnv is backend/http's hermetic bd environment: PATH and the few
// variables a Go binary needs, HOME repointed at dir, nothing BEADS_* carried
// over from the invoking shell. extra is applied last.
func minimalBDEnv(dir string, extra ...string) []string {
env := []string{
"HOME=" + dir,
"BD_DISABLE_METRICS=1",
"BD_DISABLE_EVENT_FLUSH=1",
}
for _, key := range []string{"PATH", "TMPDIR", "SYSTEMROOT", "WINDIR"} {
if v, ok := os.LookupEnv(key); ok {
env = append(env, key+"="+v)
}
}
return append(env, extra...)
}
var (
buildBDOnce sync.Once
bdBinPath string
bdBuildErr error
bdBinOwnBuild bool
)
// buildBD builds bd from this tree once per test process (or takes Bazel's
// prebuilt binary). TestMain deletes the build.
func buildBD(t *testing.T) string {
t.Helper()
buildBDOnce.Do(func() {
if bazeltest.IsBazel() {
bdBinPath, bdBuildErr = bazeltest.PrebuiltBD()
return
}
if prebuilt, err := bazeltest.PrebuiltBD(); err != nil || prebuilt != "" {
bdBinPath, bdBuildErr = prebuilt, err
return
}
dir, err := os.MkdirTemp(os.Getenv("TMPDIR"), "bd-corpus")
if err != nil {
bdBuildErr = fmt.Errorf("mkdir temp for bd binary: %w", err)
return
}
bin := filepath.Join(dir, "bd-corpus")
cmd := exec.Command("go", "build", "-tags", "gms_pure_go", "-o", bin, "./cmd/bd")
cmd.Dir = repoRoot()
if out, err := cmd.CombinedOutput(); err != nil {
bdBuildErr = fmt.Errorf("build bd: %w\n%s", err, out)
_ = os.RemoveAll(dir)
return
}
bdBinPath = bin
bdBinOwnBuild = true
})
if bdBuildErr != nil {
t.Fatal(bdBuildErr)
}
if bdBinPath == "" {
t.Fatal("no bd binary: Bazel did not provide one")
}
return bdBinPath
}
func TestMain(m *testing.M) {
code := m.Run()
if bdBinOwnBuild && bdBinPath != "" {
_ = os.RemoveAll(filepath.Dir(bdBinPath))
}
os.Exit(code)
}
func repoRoot() string {
_, file, _, _ := runtime.Caller(0) // <repo>/backend/http/corpus/harness_test.go
return filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(file))))
}

View file

@ -0,0 +1,279 @@
//go:build cgo
package corpus_test
import (
"bytes"
"encoding/json"
"fmt"
"io"
"maps"
"net/http"
"net/http/httputil"
"net/url"
"os"
"regexp"
"slices"
"sort"
"strings"
"sync"
"sync/atomic"
"testing"
"github.com/steveyegge/beads/internal/httpapi"
"github.com/steveyegge/beads/internal/httpapi/apigen"
)
// referenceProfile is testdata/reference_server.json: the wire surface of the
// deployed server the corpus must work against. See README.md.
type referenceProfile struct {
Capabilities []string `json:"capabilities"`
ContextMembers []string `json:"context_members"`
Operations []referenceOperation `json:"operations"`
}
type referenceOperation struct {
Method string `json:"method"`
Path string `json:"path"`
OperationID string `json:"operation_id"`
Query []string `json:"query"`
Body []string `json:"body"`
pattern *regexp.Regexp
query map[string]bool
body map[string]bool
}
func loadReferenceProfile(t *testing.T) *referenceProfile {
t.Helper()
raw, err := os.ReadFile("testdata/reference_server.json")
if err != nil {
t.Fatalf("read the reference server profile: %v", err)
}
var p referenceProfile
if err := json.Unmarshal(raw, &p); err != nil {
t.Fatalf("parse testdata/reference_server.json: %v", err)
}
if len(p.Capabilities) == 0 || len(p.Operations) == 0 || len(p.ContextMembers) == 0 {
t.Fatal("testdata/reference_server.json is missing capabilities, operations or context_members")
}
for i := range p.Operations {
op := &p.Operations[i]
pattern, err := templatePattern(op.Path)
if err != nil {
t.Fatalf("testdata/reference_server.json: operation %s path %q: %v", op.OperationID, op.Path, err)
}
op.pattern = pattern
op.query = setOf(op.Query)
op.body = setOf(op.Body)
}
return &p
}
// templatePattern turns an OpenAPI path template into an anchored regexp. A
// path parameter never spans a "/" or a ":" (AIP-136 custom methods hang off
// the last segment as {id}:verb, and no issue id, config key or memory key
// carries a raw colon), so /issues/{id} does not swallow /issues/{id}:claim.
// A "{" with no "}" is an error: the profile is edited by hand, and without the
// check the loop would never advance past it.
func templatePattern(tmpl string) (*regexp.Regexp, error) {
var b strings.Builder
b.WriteString("^")
for {
open := strings.IndexByte(tmpl, '{')
if open < 0 {
b.WriteString(regexp.QuoteMeta(tmpl))
break
}
closeAt := strings.IndexByte(tmpl[open:], '}')
if closeAt < 0 {
return nil, fmt.Errorf("unclosed { in %q", tmpl[open:])
}
b.WriteString(regexp.QuoteMeta(tmpl[:open]))
b.WriteString(`[^/:]+`)
tmpl = tmpl[open+closeAt+1:]
}
b.WriteString("$")
return regexp.Compile(b.String())
}
func setOf(xs []string) map[string]bool {
m := make(map[string]bool, len(xs))
for _, x := range xs {
m[x] = true
}
return m
}
// referenceProxy fronts the in-process server and makes it answer the way the
// reference server answers, at the wire level, for everything this suite can
// see from a client:
//
// - GET /v0/beads/context publishes only the reference ContextResponse
// members (so no wire_revision: the reference server predates it) and
// exactly the reference capability set, whatever this build advertises;
// - a request for an operation the reference document does not publish gets
// the server's own unrouted 404 problem;
// - a query parameter or top-level JSON request member the reference
// operation does not declare gets the server's own 400 unknown_parameter
// problem naming it — which is how the real reference server answers,
// since its decoder is strict.
//
// Responses are otherwise passed through untouched. That is deliberately
// generous in one direction (a response member the reference server would not
// send still reaches the client) and is the residual fidelity gap README.md
// records.
type referenceProxy struct {
profile *referenceProfile
upstream *url.URL
rp *httputil.ReverseProxy
requests atomic.Int64
mu sync.Mutex
refused []string // "METHOD path: why", for the per-shape log
}
func newReferenceProxy(t *testing.T, profile *referenceProfile, upstreamAddr string) *referenceProxy {
t.Helper()
u, err := url.Parse("http://" + upstreamAddr)
if err != nil {
t.Fatalf("parse upstream address: %v", err)
}
p := &referenceProxy{profile: profile, upstream: u}
p.rp = &httputil.ReverseProxy{
Rewrite: func(r *httputil.ProxyRequest) {
r.SetURL(u) // also rewrites Host, so the server's Host gate sees its own bind
},
FlushInterval: -1, // events:watch streams
}
return p
}
func (p *referenceProxy) takeRefusals() []string {
p.mu.Lock()
defer p.mu.Unlock()
out := p.refused
p.refused = nil
return out
}
func (p *referenceProxy) noteRefusal(r *http.Request, why string) {
p.mu.Lock()
defer p.mu.Unlock()
p.refused = append(p.refused, fmt.Sprintf("%s %s: %s", r.Method, r.URL.Path, why))
}
func (p *referenceProxy) match(r *http.Request) *referenceOperation {
path := r.URL.EscapedPath()
var best *referenceOperation
for i := range p.profile.Operations {
op := &p.profile.Operations[i]
if op.Method != r.Method || !op.pattern.MatchString(path) {
continue
}
// Prefer the most literal template when two match (none do today).
if best == nil || len(op.Path) > len(best.Path) {
best = op
}
}
return best
}
func (p *referenceProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
p.requests.Add(1)
if r.Method == http.MethodGet && r.URL.Path == "/v0/beads/context" {
p.serveContext(w, r)
return
}
op := p.match(r)
if op == nil {
p.noteRefusal(r, "operation not published by the reference server")
detail := "no such route on this server"
httpapi.Write(w, httpapi.Result{Problem: apigen.Problem{
Status: http.StatusNotFound,
Title: http.StatusText(http.StatusNotFound),
Code: string(httpapi.CodeNotFound),
Detail: &detail,
}})
return
}
if offender := firstUnknown(slices.Collect(maps.Keys(r.URL.Query())), op.query); offender != "" {
p.noteRefusal(r, "query parameter "+offender+" unknown to "+op.OperationID)
httpapi.Write(w, httpapi.InvalidArgument(offender, httpapi.ReasonUnknownParameter,
"unknown query parameter "+offender))
return
}
if r.Body != nil && r.Body != http.NoBody {
raw, err := io.ReadAll(r.Body)
_ = r.Body.Close()
if err != nil {
http.Error(w, "reference proxy: read body: "+err.Error(), http.StatusBadGateway)
return
}
r.Body = io.NopCloser(bytes.NewReader(raw))
r.ContentLength = int64(len(raw))
var members map[string]json.RawMessage
if len(bytes.TrimSpace(raw)) > 0 && json.Unmarshal(raw, &members) == nil {
if offender := firstUnknown(slices.Collect(maps.Keys(members)), op.body); offender != "" {
p.noteRefusal(r, "request member "+offender+" unknown to "+op.OperationID)
httpapi.Write(w, httpapi.InvalidArgument(offender, httpapi.ReasonUnknownParameter,
"json: unknown field \""+offender+"\""))
return
}
}
}
p.rp.ServeHTTP(w, r)
}
// firstUnknown names the smallest key not in known, the same deterministic
// choice the server makes, or "" when every key is known.
func firstUnknown(keys []string, known map[string]bool) string {
sort.Strings(keys)
for _, k := range keys {
if !known[k] {
return k
}
}
return ""
}
func (p *referenceProxy) serveContext(w http.ResponseWriter, r *http.Request) {
out := r.Clone(r.Context())
out.URL.Scheme, out.URL.Host, out.Host = p.upstream.Scheme, p.upstream.Host, p.upstream.Host
out.RequestURI = ""
resp, err := http.DefaultTransport.RoundTrip(out)
if err != nil {
http.Error(w, "reference proxy: "+err.Error(), http.StatusBadGateway)
return
}
defer resp.Body.Close()
raw, err := io.ReadAll(resp.Body)
if err != nil {
http.Error(w, "reference proxy: "+err.Error(), http.StatusBadGateway)
return
}
if resp.StatusCode != http.StatusOK {
maps.Copy(w.Header(), resp.Header)
w.WriteHeader(resp.StatusCode)
_, _ = w.Write(raw)
return
}
var body map[string]json.RawMessage
if err := json.Unmarshal(raw, &body); err != nil {
http.Error(w, "reference proxy: decode context: "+err.Error(), http.StatusBadGateway)
return
}
keep := setOf(p.profile.ContextMembers)
for k := range body {
if !keep[k] {
delete(body, k)
}
}
caps, _ := json.Marshal(p.profile.Capabilities)
body["capabilities"] = caps
masked, _ := json.Marshal(body)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
_, _ = w.Write(masked)
}

View file

@ -0,0 +1,23 @@
package corpus_test
import (
"os"
"testing"
)
// corpusTierLinked reports whether this test binary links the corpus tier.
// harness_test.go, which builds only under cgo like every other file in this
// package, sets it from its init.
var corpusTierLinked bool
// TestCorpusTierIsLinkedWhenRequired is the one corpus check that builds
// without cgo. skipUnlessEmbeddedDolt turns a missing BEADS_TEST_EMBEDDED_DOLT
// into a failure under BEADS_HTTP_TEST_REQUIRED=1, but it lives in a cgo file:
// with cgo off the go tool drops every other file in this package, so no
// corpus test exists to fail, and a required run would pass having run nothing.
func TestCorpusTierIsLinkedWhenRequired(t *testing.T) {
if os.Getenv("BEADS_HTTP_TEST_REQUIRED") == "1" && !corpusTierLinked {
t.Fatal("BEADS_HTTP_TEST_REQUIRED=1 but this test binary was built without cgo, which drops " +
"the http command corpus (every other file in this package); build it with CGO_ENABLED=1")
}
}

View file

@ -0,0 +1,12 @@
# Pinned shards for tools/bazel/go_test_pinned_shard.sh. Not pin_shards.py's:
# each corpus part (corpus_test.go's corpusParts; TestServedCorpusPart1..N)
# runs alone in the shard of its number, on its own server and seed, and the
# binary's round-robin runs the package's other (engine-free) tests in the
# one shard left over. Change corpusParts, this file and the target's
# shard_count together (scripts TestCorpusPartsArePinnedOnePerShard).
#
# <pinned shard> <TestName>
1 TestServedCorpusPart1
2 TestServedCorpusPart2
3 TestServedCorpusPart3
4 TestServedCorpusPart4

View file

@ -0,0 +1,29 @@
# Shapes that are EXPECTED to be refused on a served workspace, permanently.
# The served run must fail and its output must match `refusal`; if it ever
# succeeds, the entry is stale and the suite fails until it is removed. The
# embedded run is still held to the shape's expect_exit, which an allowlisted
# shape must state, and to its expect_stderr: a shape that stops doing what it
# says on the embedded backend fails as a corpus bug, not as allowed.
# A gap some slice will close is NOT listed here: it is a `pending` mark on the
# shape in corpus.yaml instead.
- id: gc-sql-ready-projection
reason: >-
bd sql needs a Dolt sql-server workspace: the embedded backend refuses it
too (the shape's expect_exit and expect_stderr pin that), and an http
workspace refuses it with the same "embedded mode" text. gc must not issue
it against a remote workspace (DESIGN B3 #10 and B6: gc reads the ready
projection through roles there).
refusal: "'bd sql' is not yet supported"
- id: gc-sql-release-fallback
reason: >-
bd sql needs a Dolt sql-server workspace and the embedded backend refuses
it too; gc's ReleaseIfCurrent fallback must take the conditional update
path on a remote workspace (DESIGN B3 #10).
refusal: "'bd sql' is not yet supported"
- id: mc-meta-set
reason: >-
`bd meta set` is not an OSS bd command (pack scripts written against an
older pinned CLI); it fails on the embedded backend too. The packs should
use `bd update --set-metadata`, which the corpus covers.
refusal: 'unknown command "meta"'

882
backend/http/corpus/testdata/corpus.yaml vendored Normal file
View file

@ -0,0 +1,882 @@
# Served command corpus (slice S23): every distinct bd command shape the
# orchestrator (gc) and its packs/formulas issue against a work store.
#
# Sources:
# gc: gascity origin/main internal/beads/bdstore*.go, internal/config/workquery.go,
# cmd/gc (BdStore subprocess shapes, work_query/scale_check/on_boot/on_death
# shell, hook claim, agent-script actions, doctor/preflight probes).
# mc: pack, formula, prompt and script invocations counted across the
# maintainer packs (flag sets, not values; values here are representative).
#
# Each shape runs on a served workspace (bd connect to an in-process bd serve,
# non-loopback bind mode, bearer auth, masked to testdata/reference_server.json)
# and on an embedded workspace, with BEADS_ACTOR=worker and CLAUDE_SESSION_ID set
# on both. See README.md for the fields. Reads come first; writes after them
# each own their target ids (e2e-t-*), so write order never changes a read.
# The shapes are dealt round robin, in this order, across the suite's parts,
# and each part seeds its own workspaces: a shape may rely on the seed and its
# own setup, never on another shape having run.
#
# pending: {slice, reason} marks a known failure. The shape still runs; when it
# passes the subtest FAILS until the mark is removed. That is how a slice proves
# itself. Permanent refusals live in allowlist.yaml instead.
files:
- name: seed-core.json
content: |
{"commit_message": "corpus seed", "nodes": [
{"key": "r1", "id": "e2e-r1", "title": "Routed open task", "type": "task", "priority": 1, "labels": ["lane:a"], "metadata": {"gc.routed_to": "pool-a"}},
{"key": "r2", "id": "e2e-r2", "title": "Held routed task", "type": "task", "labels": ["hold:mayor"], "metadata": {"gc.routed_to": "pool-a"}},
{"key": "r3", "id": "e2e-r3", "title": "Routed epic", "type": "epic", "metadata": {"gc.routed_to": "pool-a"}},
{"key": "wf1", "id": "e2e-wf1", "title": "Workflow root", "type": "task", "metadata": {"gc.run_target": "pool-a", "gc.kind": "workflow"}},
{"key": "a1", "id": "e2e-a1", "title": "Alice bug", "type": "bug", "assignee": "alice"},
{"key": "ip1", "id": "e2e-ip1", "title": "Worker in progress", "type": "task", "priority": 0, "assignee": "worker", "metadata": {"gc.routed_to": "pool-a"}},
{"key": "wr", "id": "e2e-wr", "title": "Worker ready task", "type": "task", "assignee": "worker"},
{"key": "ipna", "id": "e2e-ipna", "title": "Orphaned in progress", "type": "task", "metadata": {"gc.routed_to": "pool-a"}},
{"key": "ipnb", "id": "e2e-ipnb", "title": "Orphaned workflow", "type": "task", "metadata": {"gc.run_target": "pool-a", "gc.kind": "workflow"}},
{"key": "blk", "id": "e2e-blk", "title": "Blocked by r1", "type": "task", "deps": [{"target": "r1"}]},
{"key": "done", "id": "e2e-done", "title": "Closed task", "type": "task"},
{"key": "ext", "id": "e2e-ext", "title": "GitHub source", "type": "task", "external_ref": "gh-123", "metadata": {"gc.kind": "github_source", "gc.github.kind": "issue", "gc.github.repo": "o/r"}},
{"key": "ep", "id": "e2e-ep", "title": "Epic", "type": "epic"},
{"key": "ep.1", "id": "e2e-ep.1", "title": "Epic child one", "type": "task", "parent_key": "ep"},
{"key": "ep.2", "id": "e2e-ep.2", "title": "Epic child two", "type": "task", "parent_key": "ep"},
{"key": "mol", "id": "e2e-mol", "title": "Molecule root", "type": "epic"},
{"key": "mol.1", "id": "e2e-mol.1", "title": "step one", "type": "task", "assignee": "worker", "parent_key": "mol"},
{"key": "mol.2", "id": "e2e-mol.2", "title": "step two", "type": "task", "parent_key": "mol", "deps": [{"target": "mol.1"}], "metadata": {"gc.root_bead_id": "e2e-mol", "gc.routed_to": "pool-a"}},
{"key": "mol.3", "id": "e2e-mol.3", "title": "step three", "type": "task", "parent_key": "mol"},
{"key": "mac", "id": "e2e-mac", "title": "Auto-close molecule", "type": "epic"},
{"key": "mac.1", "id": "e2e-mac.1", "title": "done step", "type": "task", "parent_key": "mac"},
{"key": "mac.2", "id": "e2e-mac.2", "title": "last step", "type": "task", "assignee": "worker", "parent_key": "mac"},
{"key": "wisp-1", "id": "e2e-wisp-1", "title": "Wisp wisp-1", "type": "task", "ephemeral": true, "metadata": {"gc.routed_to": "pool-a"}, "labels": ["lane:w"]},
{"key": "wisp-2", "id": "e2e-wisp-2", "title": "Wisp wisp-2", "type": "task", "ephemeral": true, "assignee": "worker", "labels": ["lane:w"]},
{"key": "wisp-wr", "id": "e2e-wisp-wr", "title": "Wisp worker ready", "type": "task", "ephemeral": true, "priority": 1, "assignee": "worker"},
{"key": "wisp-c", "id": "e2e-wisp-c", "title": "Wisp wisp-c", "type": "task", "ephemeral": true},
{"key": "wisp-p", "id": "e2e-wisp-p", "title": "Wisp wisp-p", "type": "task", "ephemeral": true},
{"key": "wisp-m", "id": "e2e-wisp-m", "title": "Wisp molecule", "type": "epic", "ephemeral": true},
{"key": "wisp-m.1", "id": "e2e-wisp-m.1", "title": "wisp step", "type": "task", "ephemeral": true, "parent_key": "wisp-m"},
{"key": "gate-o", "id": "e2e-gate-o", "title": "Open gate", "type": "gate"},
{"key": "gate-c", "id": "e2e-gate-c", "title": "Closed gate", "type": "gate"},
{"key": "wisp-gate", "id": "e2e-wisp-gate", "title": "Wisp gate", "type": "gate", "ephemeral": true},
{"key": "t-upd", "id": "e2e-t-upd", "title": "target upd", "type": "task", "labels": ["lane:z"]},
{"key": "t-upd2", "id": "e2e-t-upd2", "title": "target upd2", "type": "task"},
{"key": "t-m1", "id": "e2e-t-m1", "title": "target m1", "type": "task"},
{"key": "t-m2", "id": "e2e-t-m2", "title": "target m2", "type": "task"},
{"key": "t-claim", "id": "e2e-t-claim", "title": "target claim", "type": "task"},
{"key": "t-claim2", "id": "e2e-t-claim2", "title": "target claim2", "type": "task"},
{"key": "t-rev", "id": "e2e-t-rev", "title": "target rev", "type": "task"},
{"key": "t-rev2", "id": "e2e-t-rev2", "title": "target rev2", "type": "task"},
{"key": "t-sling", "id": "e2e-t-sling", "title": "target sling", "type": "task"},
{"key": "t-as", "id": "e2e-t-as", "title": "target as", "type": "task"},
{"key": "t-ms", "id": "e2e-t-ms", "title": "target ms", "type": "task"},
{"key": "t-msc", "id": "e2e-t-msc", "title": "target msc", "type": "task"},
{"key": "t-um", "id": "e2e-t-um", "title": "target um", "type": "task", "metadata": {"k": "v"}},
{"key": "t-notes", "id": "e2e-t-notes", "title": "target notes", "type": "task"},
{"key": "t-er", "id": "e2e-t-er", "title": "target er", "type": "task"},
{"key": "t-md", "id": "e2e-t-md", "title": "target md", "type": "task"},
{"key": "t-asg", "id": "e2e-t-asg", "title": "target asg", "type": "task"},
{"key": "t-dac", "id": "e2e-t-dac", "title": "target dac", "type": "task"},
{"key": "t-c1", "id": "e2e-t-c1", "title": "target c1", "type": "task"},
{"key": "t-c2", "id": "e2e-t-c2", "title": "target c2", "type": "task"},
{"key": "t-c3", "id": "e2e-t-c3", "title": "target c3", "type": "task"},
{"key": "t-c4", "id": "e2e-t-c4", "title": "target c4", "type": "task"},
{"key": "t-c5", "id": "e2e-t-c5", "title": "target c5", "type": "task"},
{"key": "t-d1", "id": "e2e-t-d1", "title": "target d1", "type": "task"},
{"key": "t-d2", "id": "e2e-t-d2", "title": "target d2", "type": "task"},
{"key": "t-d3", "id": "e2e-t-d3", "title": "target d3", "type": "task"},
{"key": "t-d4", "id": "e2e-t-d4", "title": "target d4", "type": "task"},
{"key": "t-df1", "id": "e2e-t-df1", "title": "target df1", "type": "task"},
{"key": "t-df2", "id": "e2e-t-df2", "title": "target df2", "type": "task"},
{"key": "t-da", "id": "e2e-t-da", "title": "target da", "type": "task"},
{"key": "t-db", "id": "e2e-t-db", "title": "target db", "type": "task"},
{"key": "t-l", "id": "e2e-t-l", "title": "target l", "type": "task"},
{"key": "t-as2", "id": "e2e-t-as2", "title": "target as2", "type": "task"},
{"key": "t-cm", "id": "e2e-t-cm", "title": "target cm", "type": "task"},
{"key": "t-rel", "id": "e2e-t-rel", "title": "target rel", "type": "task", "assignee": "worker"},
{"key": "t-xfer", "id": "e2e-t-xfer", "title": "target xfer", "type": "task", "assignee": "worker"},
{"key": "t-ifa", "id": "e2e-t-ifa", "title": "target ifa", "type": "task", "assignee": "worker", "metadata": {"seeded": "keep"}},
{"key": "t-death", "id": "e2e-t-death", "title": "target death", "type": "task", "assignee": "worker"},
{"key": "t-rc", "id": "e2e-t-rc", "title": "target rc", "type": "task", "assignee": "worker"},
{"key": "t-hb", "id": "e2e-t-hb", "title": "target hb", "type": "task"},
{"key": "t-hb2", "id": "e2e-t-hb2", "title": "target hb2", "type": "task"},
{"key": "t-hb3", "id": "e2e-t-hb3", "title": "target hb3", "type": "task"},
{"key": "t-boot", "id": "e2e-t-boot", "title": "target boot", "type": "task"},
{"key": "t-ro", "id": "e2e-t-ro", "title": "target reopen", "type": "task"},
{"key": "t-dr", "id": "e2e-t-dr", "title": "target dep remove", "type": "task", "deps": [{"target": "t-db"}]},
{"key": "t-dc", "id": "e2e-t-dc", "title": "cascade root", "type": "epic"},
{"key": "t-dc.1", "id": "e2e-t-dc.1", "title": "cascade child", "type": "task", "parent_key": "t-dc"},
{"key": "t-gcr", "id": "e2e-t-gcr", "title": "target gate create", "type": "task"},
{"key": "t-gct", "id": "e2e-t-gct", "title": "target gate check", "type": "task"},
{"key": "t-gw", "id": "e2e-t-gw", "title": "target gate waiter", "type": "gate"},
{"key": "t-gaw", "id": "e2e-t-gaw", "title": "target gate await id", "type": "gate"}
]}
- name: bulk-ready-a.json
bulk: {id_prefix: e2e-bra, count: 60, priority: 3, metadata: {gc.routed_to: pool-a}}
- name: bulk-ready-b.json
bulk: {id_prefix: e2e-brb, count: 60, priority: 3, metadata: {gc.routed_to: pool-a}}
- name: bulk-wisp-a.json
bulk: {id_prefix: e2e-wisp-bwa, count: 55, priority: 3, ephemeral: true, metadata: {gc.routed_to: pool-a}}
- name: bulk-wisp-b.json
bulk: {id_prefix: e2e-wisp-bwb, count: 55, priority: 3, ephemeral: true, metadata: {gc.routed_to: pool-a}}
- name: graph-small.json
content: |
{"commit_message": "gc graph apply", "nodes": [
{"key": "root", "id": "e2e-g-root", "title": "graph root", "type": "epic", "metadata": {"gc.kind": "workflow"}},
{"key": "s1", "id": "e2e-g-s1", "title": "graph step 1", "type": "task", "parent_key": "root", "assignee": "worker", "labels": ["lane:g"], "metadata": {"gc.routed_to": "pool-a"}},
{"key": "s2", "id": "e2e-g-s2", "title": "graph step 2", "type": "task", "parent_key": "root"}
], "edges": [{"from_key": "s2", "to_key": "s1", "type": "blocks"}]}
- name: graph-eph.json
content: |
{"nodes": [
{"key": "root", "id": "e2e-wisp-g-root", "title": "wisp graph root", "type": "epic"},
{"key": "s1", "id": "e2e-wisp-g-s1", "title": "wisp graph step", "type": "task", "parent_key": "root"}
]}
- name: delete-list.txt
content: |
e2e-t-df1
e2e-t-df2
seed:
- [create, --graph, "{file:seed-core.json}", --json]
- [create, --graph, "{file:bulk-ready-a.json}", --json]
- [create, --graph, "{file:bulk-ready-b.json}", --json]
- [create, --graph, "{file:bulk-wisp-a.json}", --json]
- [create, --graph, "{file:bulk-wisp-b.json}", --json]
# Graph plans carry no status: a node created in_progress or closed stamps
# started_at/closed_at, which batchApply's create vocabulary cannot carry
# (gc's own plans never set a status). Lifecycle goes through update/close.
- [update, e2e-ip1, e2e-ipna, e2e-ipnb, e2e-mol.1, e2e-mac.2, e2e-t-rel, e2e-t-xfer, e2e-t-ifa, e2e-t-death, e2e-t-rc, e2e-t-boot, --status, in_progress]
- [update, e2e-wisp-2, --status, in_progress]
- [close, --force, e2e-done, e2e-ep.2, e2e-mol.3, e2e-mac.1, e2e-t-ro, e2e-gate-c]
- [comments, add, e2e-r1, "seed comment"]
shapes:
# ---------------------------------------------------------------- show
# requests pins each show's round trips (mc-5dkzp): resolving the id,
# fetching the row and reading it for output are one request per id, which
# the per-command read memo answers once.
- id: gc-show-json
source: gc bdstore.go BdStore.Get (show --json <id>); counts must not read 0
args: [show, --json, e2e-blk]
requests: 1
- id: gc-show-json-batch
source: gc bdstore_exact_batch.go GetExactBatch
args: [show, --json, e2e-r1, e2e-a1, e2e-blk, e2e-mol]
requests: 4
- id: gc-show-json-wisp
source: gc workquery.go blocked_by enrichment; wisps live in the ready tier
args: [show, e2e-wisp-1, --json]
requests: 1
- id: gc-show-id-flag
source: gc cmd_bd_show_watch.go bdWatchRunner (show --json --id=<id>)
args: [show, --json, --id=e2e-r1]
requests: 1
# The worker holds eight in-progress issues; e2e-ip1 is the only P0 among
# them, so "first in the store's default order" (priority first) names it on
# both sides. Among equal priorities the order rests on created_at, and a
# seed that straddles a second boundary on one side only picked another issue.
- id: gc-show-current
source: gc cmd_bd_show_watch.go bdWatchRunner (show --current --json)
args: [show, --current, --json]
requests: 3
- id: gc-show-missing
source: gc BdStore.Get not-found classification (routing fallbacks)
args: [show, --json, e2e-nonexistent]
expect_exit: 1
expect_stderr: "(?i)not found"
compare: exit
requests: 1
# Text show reads the row, then its dependents and its comments: three
# different URLs the memo cannot collapse.
- id: mc-show-text
source: mc prompts (bd show <id>, ~80)
args: [show, e2e-r1]
compare: text
requests: 3
# ---------------------------------------------------------------- ready
# e2e-wr and e2e-wisp-wr are the only open rows assigned to the worker when
# these shapes run, so the assignee shapes compare real rows: a client that
# sends the wrong assignee or drops --include-ephemeral returns a different
# list. The wisp is P1 and the task P2, so --limit=1 picks the wisp on both
# sides by priority alone.
- id: gc-ready-unlimited
source: gc bdstore.go bdReadyArgs (BdStore.Ready, ready --json --limit 0)
args: [ready, --json, --limit, "0"]
compare: ids
- id: gc-ready-ephemeral-assignee-unlimited
source: gc bdstore.go bdReadyArgs with --include-ephemeral --assignee
args: [ready, --json, --include-ephemeral, --assignee, worker, --limit, "0"]
compare: ids
- id: gc-ready-pool-demand
source: gc workquery.go bdReadyPoolDemandShell (scale_check, --limit=20)
args: [ready, --metadata-field, gc.routed_to=pool-a, --unassigned, --exclude-type=epic, --exclude-label, "hold:mayor", --exclude-label, "hold:external", --json, --limit=20]
compare: ids
- id: gc-ready-pool-demand-unlimited
source: gc workquery.go bdReadyPoolDemandShell (work_query, --include-ephemeral --limit 0)
args: [ready, --include-ephemeral, --metadata-field, gc.routed_to=pool-a, --unassigned, --exclude-type=epic, --exclude-label, "hold:mayor", --exclude-label, "hold:external", --json, --limit, "0"]
compare: ids
- id: gc-ready-workflow-migration
source: gc workquery.go bdReadyPoolDemandMigrationShell (--sort oldest --limit 0)
args: [ready, --include-ephemeral, --metadata-field, gc.run_target=pool-a, --metadata-field, gc.kind=workflow, --unassigned, --exclude-type=epic, --exclude-label, "hold:mayor", --exclude-label, "hold:external", --json, --sort, oldest, --limit, "0"]
compare: ids
- id: gc-ready-graph-anchor
source: gc workquery.go assignedGraphWorkflowAnchorReadyFunctionScript
args: [ready, --include-ephemeral, --metadata-field, gc.root_bead_id=e2e-mol, --metadata-field, gc.routed_to=pool-a, --exclude-type=epic, --exclude-label, "hold:mayor", --exclude-label, "hold:external", --json, --sort, oldest, --limit=20]
compare: ids
- id: gc-ready-assigned-tier
source: gc workquery.go assignedReadyTierCommand (--assignee=<id> --limit=1)
args: [ready, --include-ephemeral, --assignee=worker, --json, --limit=1]
compare: ids
- id: gc-ready-probe
source: gc examples/bd gc-beads-bd.sh (bare bd ready probe)
args: [ready]
compare: exit
- id: mc-ready-json
source: mc scripts/prompts (bd ready --json, ~36)
args: [ready, --json]
compare: ids
- id: mc-ready-mol
source: mc skills/pr-review (bd ready --mol <root>)
args: [ready, --mol, e2e-mol, --json]
- id: mc-ready-parent
source: mc skills/pr-review (bd ready --parent <root>)
args: [ready, --parent, e2e-ep, --json]
compare: ids
# ---------------------------------------------------------------- list
- id: gc-list-full-filters
source: gc bdstore.go listViaBDList (List/ListByLabel/ListByMetadata)
args: [list, --json, --label=lane:a, --status=open, --type=task, --include-infra, --include-gates, --limit, "0", --metadata-field, gc.routed_to=pool-a]
- id: gc-list-ping
source: gc bdstore.go BdStore.Ping (list --json --limit 0)
args: [list, --json, --limit, "0"]
compare: ids
- id: gc-list-limit1
source: gc doctor_gate_sandbox.go / doctor_store_preflight.go
args: [list, --json, --limit, "1"]
compare: count
- id: gc-list-readonly
source: gc doctor_v2_session_migration.go readOnlyBdRunner
args: [--readonly, list, --json, --limit, "1"]
compare: count
- id: gc-list-assignee-status
source: gc bdstore.go listViaBDList (ListByAssignee)
args: [list, --json, --assignee=worker, --status=in_progress, --include-infra, --include-gates, --limit, "0"]
- id: gc-list-all-created-before
source: gc bdstore.go listViaBDList (--all --created-before --include-templates --skip-labels)
args: [list, --json, --all, --created-before, "2100-01-01T00:00:00Z", --include-infra, --include-gates, --include-templates, --limit, "0", --skip-labels]
compare: ids
- id: gc-list-children
source: gc bdstore.go listViaBDList (Children, --parent)
args: [list, --json, --include-infra, --include-gates, --limit, "0", --parent, e2e-ep, --all]
- id: gc-list-in-progress-tier
source: gc workquery.go assignedInProgressTierCommandWithLimit
args: [list, --status, in_progress, --assignee=worker, --json, --limit=20]
- id: gc-list-on-death
source: gc workquery.go EffectiveOnDeath
args: [list, --assignee=worker, --status=in_progress, --json]
- id: gc-list-on-boot
source: gc workquery.go on_boot recovery (--no-assignee)
args: [list, --metadata-field, gc.routed_to=pool-a, --status=in_progress, --no-assignee, --json]
pending: {slice: "SRV-1", reason: "S15b sends --no-assignee as listIssues no_assignee behind issues.list.noAssignee, 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-list-on-boot-workflow
source: gc workquery.go on_boot recovery, workflow lane
args: [list, --metadata-field, gc.run_target=pool-a, --metadata-field, gc.kind=workflow, --status=in_progress, --no-assignee, --json]
pending: {slice: "SRV-1", reason: "S15b sends --no-assignee as listIssues no_assignee behind issues.list.noAssignee, 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: mc-list-meta-status
source: mc assets snapshot.md (list --json --limit --metadata-field --status)
args: [list, --json, --limit, "50", --metadata-field, gc.routed_to=pool-a, --status, open]
compare: ids
# More than 50 rows match, most at one priority: --limit 50 cuts a tie set
# whose created_at order differs between the two seeds, so each side's 50
# rows are held to its own unlimited listing instead.
prefix_of: [list, --json, --limit, "0", --metadata-field, gc.routed_to=pool-a, --status, open]
- id: mc-list-github-source
source: mc github-intake (list --all --json --limit --metadata-field x3)
args: [list, --metadata-field, gc.kind=github_source, --metadata-field, gc.github.kind=issue, --metadata-field, gc.github.repo=o/r, --all, --json, --limit, "0"]
- id: mc-list-all-type
source: mc normalized_candidate_graph.py (list --all --type)
args: [list, --all, --type, epic, --json, --limit, "50"]
- id: mc-list-include-gates-infra-label
source: mc mol-normalized-issue-pr-v1 (list --all --include-gates --include-infra --json --label --limit)
args: [list, --all, --include-gates, --include-infra, --json, --label, "lane:a", --limit, "0"]
- id: mc-list-title
source: mc mol-normalized-issue-pr-v1 (list --all --include-infra --json --limit --title)
args: [list, --all, --include-infra, --json, --limit, "10", --title, "Routed open task"]
pending: {slice: "SRV-1", reason: "S15b sends --title as 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: mc-list-id
source: mc skills/pr-review (list --all --id --json --limit)
args: [list, --all, --id, "e2e-r1,e2e-a1", --json, --limit, "0"]
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"}
- id: gc-polecat-title-contains
source: gascity core formulas/mol-polecat-base.toml (list --title-contains --status a,b,c --json)
args: [list, --title-contains, "Routed", --status, "open,in_progress,blocked", --json]
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)
args: [list, --title-contains, "closed task", --status, closed, --closed-after, "2000-01-01", --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"}
- id: gc-polecat-closed-after
source: gascity core formulas/mol-polecat-base.toml:267 (list --title-contains --status closed --closed-after --json)
args: [list, --title-contains, "task", --status, closed, --closed-after, "2000-01-01", --json]
compare: ids
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"}
- id: wf-session-cleanup
source: an order cleanup script's closed-session sweep (list --all --include-infra --include-gates --status closed --label --closed-before --updated-before)
args: [list, --json, --all, --include-infra, --include-gates, --status, closed, --label, "lane:a", --closed-before, "2100-01-01T00:00:00Z", --updated-before, "2100-01-01T00:00:00Z", --limit, "0"]
compare: ids
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)
args: [list, --json, --priority-min, "1", --priority-max, "3", --limit, "0"]
compare: ids
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)
args: [list, --json, --exclude-type, epic, --no-parent, --limit, "0"]
compare: ids
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)
args: [list, --json, --updated-after, "2000-01-01", --limit, "0"]
compare: ids
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: mc-list-assignee-status
source: mc review summaries (list --assignee --json --limit --status)
args: [list, --assignee, alice, --json, --limit, "10", --status, open]
- id: mc-list-label-text
source: mc normalized_child_launch.py (list --label)
args: [list, --label, "lane:a"]
compare: text
- id: mc-list-plain
source: mc scripts (bare bd list)
args: [list]
compare: exit
- id: mc-children
source: mc prompts (bd children <epic>)
args: [children, e2e-ep, --json]
# ---------------------------------------------------------------- query / count / search
- id: gc-query-wisps
source: gc bdstore.go listEphemeral (query --json "ephemeral=true AND ..." --limit N)
args: [query, --json, "ephemeral=true AND label=lane:w", --limit, "50"]
- id: gc-query-wisps-all
source: gc bdstore.go listEphemeral with IncludeClosed (--all)
args: [query, --json, "ephemeral=true AND status=in_progress", --all, --limit, "50"]
- id: gc-query-wisp-by-id
source: gc bdstore.go getEphemeralByID
args: [query, --json, "ephemeral=true AND id=e2e-wisp-1", --all, --limit, "1"]
- id: gc-query-wisps-unlimited
source: gc workquery.go bdQueryEphemeralStatusShell (--limit=0, wisp tier)
args: [query, --json, "ephemeral=true AND status=open", --limit=0]
compare: ids
- id: mc-query
source: mc pr_merge.py (bd query)
args: [query, --json, "status=open AND priority<=1", --limit, "50"]
- id: gc-count
source: gc native CountIssues fallback (count without scope)
args: [count, --json]
- id: gc-count-status
source: gc count with a status filter
args: [count, --json, --status, open]
- id: mc-search
source: mc mol-bug-report-flow-v2 (bd search)
args: [search, "Routed", --json]
compare: ids
pending: {slice: "S6c+SRV-1", reason: "S26 sends bd search as listIssues q behind issues.list.search, which the reference server does not advertise, so the client refuses before dialing; remove the mark when reference_server.json is upgraded"}
- id: mc-status
source: mc normalized_child_launch.py (bd status)
args: [status, --json]
# ---------------------------------------------------------------- deps / graph reads
- id: gc-dep-list
source: gc bdstore.go DepList
args: [dep, list, e2e-blk, --json]
- id: gc-dep-list-up
source: gc bdstore.go DepList (--direction=up)
args: [dep, list, e2e-r1, --json, --direction=up]
- id: gc-dep-list-batch
source: gc bdstore.go DepListBatch
args: [dep, list, e2e-blk, e2e-mol.2, --json]
- id: mc-dep-tree
source: mc pr_review.py city_dep_subtree (dep tree <root> --json)
args: [dep, tree, e2e-mol, --json]
- id: gc-blocked
source: gc bdstore_ready_projection.go fetchReadyProjectionViaBlocked
args: [blocked, --json]
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)
args: [blocked, --flags, --json]
stdin: "e2e-mol\ne2e-mol.1\ne2e-mol.2\ne2e-no-such-row\n"
compare: json
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)
args: [blocked, --flags, --raw, --json]
stdin: "e2e-mol\ne2e-mol.1\ne2e-mol.2\ne2e-no-such-row\n"
compare: json
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"}
# ---------------------------------------------------------------- molecules
- id: mc-mol-current
source: mc worker prompts (bd mol current, ~38; inferred from in_progress work)
args: [mol, current, --json]
- id: mc-mol-current-text
source: mc gc-role-worker template (bd mol current, text)
args: [mol, current]
compare: text
- id: mc-mol-current-id
source: mc prompts (bd mol current <id>)
args: [mol, current, e2e-mol, --json]
- id: mc-mol-progress
source: mc prompts (bd mol progress <id>)
args: [mol, progress, e2e-mol, --json]
# ---------------------------------------------------------------- config / probes / local
- id: gc-config-get-types
source: gc beads_provider_lifecycle.go / checks_custom_types.go (config get --json types.custom)
args: [config, get, --json, types.custom]
- id: gc-config-get-prefix
source: gc gc-beads-bd.sh (config get issue_prefix)
args: [config, get, issue_prefix]
compare: text
- id: gc-types
source: gc checks_custom_types.go (types --json)
args: [types, --json]
- id: gc-context
source: gc beads_preflight_checker.go (context --json); never touches the store
args: [context, --json]
compare: exit
- id: gc-version
source: gc bdstore_blocked_repair.go BDVersion
args: [version]
compare: exit
- id: gc-ping
source: gc cmd_beads_city_migrate_proxied.go / dashboard (ping --json)
args: [ping, --json]
compare: exit
- id: mc-prime
source: mc formulas (bd prime)
args: [prime]
compare: exit
- id: gc-sql-ready-projection
source: gc bdstore_ready_projection.go fetchReadyProjection
args: [sql, "select id,is_blocked from issues where status <> 'closed' union all select id,is_blocked from wisps where status <> 'closed'", --json]
expect_exit: 1
expect_stderr: "'bd sql' is not yet supported"
compare: exit
- id: gc-sql-release-fallback
source: gc bdstore.go ReleaseIfCurrent fallback (sql UPDATE)
args: [sql, --json, "UPDATE issues SET status='open', assignee='' WHERE id='e2e-t-rel' AND status='in_progress' AND assignee='worker'"]
expect_exit: 1
expect_stderr: "'bd sql' is not yet supported"
compare: exit
- id: gc-purge-dry-run
source: gc bdstore.go Purge (purge --json --dry-run)
args: [purge, --json, --dry-run]
compare: exit
pending: {slice: "SRV-1", reason: "purge needs the sweep tokens the reference server does not advertise (B3 #13); remove the mark when reference_server.json is upgraded"}
- id: gc-recompute-blocked
source: gc bdstore_blocked_repair.go RecomputeBlocked
args: [recompute-blocked, --json]
compare: exit
- id: gc-backup-status
source: gc checks_proxied_backup_coverage.go (backup status --json)
args: [backup, status, --json]
compare: exit
# The seed holds an open gate, a closed gate and an ephemeral gate, so the
# open listing and the --all listing answer different, non-empty sets.
- id: mc-gate-list
source: gc core pack order renudge-stale-human-gates.sh (gc bd gate list --limit 0 --json)
args: [gate, list, --limit, "0", --json]
- id: mc-gate-list-all
source: core pack orders (gate list --all)
args: [gate, list, --all, --json]
# gate check lists the open gates through the same ListGates entry. No
# seeded gate carries an await type (the seed graph carries no gate members;
# mc-gate-check-timer-resolves below creates a real timer gate), so the
# typed sweeps find nothing of their type and the untyped one lists the open
# gates and evaluates none: the listing is what these shapes prove served,
# and nothing resolves, escalates (no gt exec) or writes.
- id: mc-gate-check-timer
source: gc core pack gate-sweep.sh (bd gate check --type=timer --escalate)
args: [gate, check, --type=timer, --escalate]
compare: text
- id: mc-gate-check-gh
source: gc core pack gate-sweep.sh (bd gate check --type=gh --escalate)
args: [gate, check, --type=gh, --escalate]
compare: text
- id: gate-check-all
source: bd gate check (every open gate)
args: [gate, check]
compare: text
- id: gc-export-all
source: gc core pack reaper (gc bd export --all -o F)
args: [export, --all, -o, "{file:export.jsonl}"]
compare: exit
# ================================================================ writes
# ---------------------------------------------------------------- create
- id: gc-create-full
source: gc bdstore.go CreateWithStorage (every optional flag but --parent)
args: [create, --json, "gc created", -t, task, --id, e2e-n1, --priority, "1", --description, "made by gc", --assignee, worker, --deps, e2e-r1, --labels, "lane:n,x", --metadata, '{"gc.routed_to":"pool-a"}']
compare: exit
verify: [[show, --json, e2e-n1]]
- id: gc-create-parent
source: gc bdstore.go CreateWithStorage (--parent, server-minted child id)
args: [create, --json, "gc child", -t, task, --parent, e2e-ep]
compare: exit
verify: [[show, --json, e2e-ep.3]]
- id: gc-create-ephemeral
source: gc bdstore.go CreateWithStorage (--ephemeral)
args: [create, --json, "gc wisp", -t, task, --id, e2e-wisp-n2, --ephemeral, --metadata, '{"gc.routed_to":"pool-a"}']
compare: exit
verify: [[show, --json, e2e-wisp-n2]]
- id: gc-create-no-history
source: gc bdstore.go CreateWithStorage (--no-history, agent beads)
args: [create, --json, "gc agent bead", -t, task, --id, e2e-n3, --no-history]
compare: exit
verify: [[show, --json, e2e-n3]]
- id: gc-create-defer
source: gc bdstore.go CreateWithStorage (--defer RFC3339)
args: [create, --json, "gc deferred", -t, task, --id, e2e-n4, --defer, "2100-01-01T00:00:00Z"]
compare: exit
verify: [[show, --json, e2e-n4]]
- id: mc-create-external-ref
source: mc snapshot.md (create --external-ref --labels --metadata --type)
args: [create, "triaged issue", --external-ref, gh-999, --labels, "triage", --metadata, '{"gc.kind":"github_source"}', --type, task, --id, e2e-n5, --json]
compare: exit
verify: [[show, --json, e2e-n5]]
- id: mc-create-text
source: mc prompts (bd create, text output)
args: [create, "plain create", --type, task, --id, e2e-n6]
compare: exit
verify: [[show, --json, e2e-n6]]
- id: gc-create-graph
source: gc bdstore_graph_apply.go ApplyGraphPlanWithStorage
args: [create, --graph, "{file:graph-small.json}", --json]
verify: [[show, --json, e2e-g-root, e2e-g-s1, e2e-g-s2]]
- id: gc-create-graph-ephemeral
source: gc bdstore_graph_apply.go (--ephemeral by storage class)
args: [create, --graph, "{file:graph-eph.json}", --json, --ephemeral]
verify: [[show, --json, e2e-wisp-g-root, e2e-wisp-g-s1]]
# ---------------------------------------------------------------- update
- id: gc-update-fields
source: gc bdstore.go bdUpdateArgs (Update)
args: [update, --json, e2e-t-upd, --title, "updated", --status, in_progress, --type, bug, --priority, "1", --description, "new", --assignee, bob, --set-metadata, a=1, --set-metadata, b=2, --add-label, x, --remove-label, "lane:z"]
compare: exit
verify: [[show, --json, e2e-t-upd]]
- id: gc-update-parent
source: gc bdstore.go bdUpdateArgs (--parent)
args: [update, --json, e2e-t-upd2, --parent, e2e-ep]
compare: exit
verify: [[show, --json, e2e-t-upd2]]
- id: gc-update-many
source: gc bdstore.go UpdateAll / setMetadataBatchAll
args: [update, --json, e2e-t-m1, e2e-t-m2, --set-metadata, gc.batch=1, --priority, "3"]
compare: exit
verify: [[show, --json, e2e-t-m1, e2e-t-m2]]
- id: gc-update-claim
source: gc bdstore.go BdStore.Claim and gc hook --claim (update <id> --claim --json)
args: [update, e2e-t-claim, --claim, --json]
compare: exit
verify: [[show, --json, e2e-t-claim]]
- id: gc-update-claim-actor
source: gc cmd_agent_script.go bd_claim (update <id> --claim --actor X)
args: [update, e2e-t-claim2, --claim, --actor, alice]
compare: exit
verify: [[show, --json, e2e-t-claim2]]
- id: gc-update-claim-wisp
source: gc ready queues include ephemeral work; claiming a wisp
args: [update, e2e-wisp-c, --claim, --json]
compare: exit
verify: [[show, --json, e2e-wisp-c]]
pending: {slice: "SRV-1", reason: "the reference server lacks UpdateIssueRequest.claim, and the claimIssue fallback excludes wisps (B3 #6); remove the mark when reference_server.json is upgraded"}
- id: gc-update-if-revision
source: gc bdstore_conditional.go UpdateIfMatch / CompareAndSetMetadataKey
args: [update, e2e-t-rev, --set-metadata, k=v, --if-revision, "{rev:e2e-t-rev}"]
compare: exit
verify: [[show, --json, e2e-t-rev]]
- id: gc-update-if-revision-stale
source: gc bdstore_conditional.go UpdateIfMatch mismatch (exit 13)
args: [update, e2e-t-rev2, --set-metadata, k=v, --if-revision, "1"]
expect_exit: 13
compare: exit
verify: [[show, --json, e2e-t-rev2]]
- id: gc-update-release-if-current
source: gc bdstore_conditional_release.go releaseIfCurrentViaBdVerb
args: [update, e2e-t-rel, --if-assignee, worker, --if-status, in_progress, --status, open, --assignee, ""]
compare: exit
verify: [[show, --json, e2e-t-rel]]
- id: gc-update-transfer-if-current
source: gc bdstore_conditional_release.go TransferIfCurrent
args: [update, e2e-t-xfer, --if-assignee, worker, --if-status, in_progress, --assignee, alice]
compare: exit
verify: [[show, --json, e2e-t-xfer]]
- id: gc-update-if-assignment
source: gc bdstore_conditional.go UpdateIfAssignment
args: [update, --json, e2e-t-ifa, --set-metadata, k=v, --if-status, in_progress, --if-assignee, worker]
compare: exit
verify: [[show, --json, e2e-t-ifa]]
# e2e-t-ifa is seeded with metadata seeded=keep, so each refused (exit 13)
# update's verify still holds that the refusal left existing metadata
# alone, in whichever corpus part runs it (the parts seed separately, so
# the k=v written by gc-update-if-assignment may not be there).
- id: gc-update-if-assignment-assignee-stale
source: gc bdstore_conditional.go UpdateIfAssignment mismatch (exit 13)
args: [update, --json, e2e-t-ifa, --set-metadata, probe=a, --if-status, in_progress, --if-assignee, nobody]
expect_exit: 13
compare: exit
verify: [[show, --json, e2e-t-ifa]]
- id: gc-update-if-assignment-status-stale
source: gc bdstore_conditional.go UpdateIfAssignment mismatch (exit 13)
args: [update, --json, e2e-t-ifa, --set-metadata, probe=s, --if-status, open, --if-assignee, worker]
expect_exit: 13
compare: exit
verify: [[show, --json, e2e-t-ifa]]
- id: gc-update-on-death
source: gc workquery.go on_death (update --assignee "" --status open --set-metadata)
args: [update, e2e-t-death, --assignee, "", --status, open, --set-metadata, gc.run_target=pool-a]
compare: exit
verify: [[show, --json, e2e-t-death]]
- id: gc-update-on-boot
source: gc workquery.go on_boot (update <id> --status open)
args: [update, e2e-t-boot, --status, open]
compare: exit
verify: [[show, --json, e2e-t-boot]]
- id: gc-update-sling
source: gc workquery.go DefaultSlingQuery (update --set-metadata gc.routed_to=)
args: [update, e2e-t-sling, --set-metadata, gc.routed_to=pool-b]
compare: exit
verify: [[show, --json, e2e-t-sling]]
- id: gc-update-agent-script
source: gc cmd_agent_script.go bd_update (--assignee --status --append-notes --set-metadata)
args: [update, e2e-t-as, --assignee, worker, --status, in_progress, --append-notes, "agent note", --set-metadata, k=v]
compare: exit
verify: [[show, --json, e2e-t-as]]
- id: gc-update-dolt-auto-commit-off
source: gc bdstore.go bdTransientWriteArgs (--dolt-auto-commit off prefix)
args: [--dolt-auto-commit, "off", update, --json, e2e-t-dac, --set-metadata, k=v]
compare: exit
verify: [[show, --json, e2e-t-dac]]
- id: mc-update-meta-status
source: mc prompts (update --set-metadata --status, ~151)
args: [update, e2e-t-ms, --set-metadata, review.verdict=iterate, --status, in_progress]
compare: exit
verify: [[show, --json, e2e-t-ms]]
- id: mc-update-meta-status-closed
source: mc prompts (update --set-metadata --status closed, under Claude Code)
args: [update, e2e-t-msc, --set-metadata, review.verdict=done, --status, closed]
compare: exit
verify: [[show, --json, e2e-t-msc]]
pending: {slice: "S6d", reason: "a silent data difference, not a refusal: the update succeeds on both sides under CLAUDE_SESSION_ID, but the served update records no closed_by_session (an http update patch cannot carry one, so the CLI drops it without a word; bd close does carry it) where embedded records the session, so the verify show differs (B3 #7)"}
- id: mc-update-unset-metadata
source: mc adopt-pr-operator (update --unset-metadata)
args: [update, e2e-t-um, --unset-metadata, k]
compare: exit
verify: [[show, --json, e2e-t-um]]
- id: mc-update-notes
source: mc github fix-issue formula (update --notes)
args: [update, e2e-t-notes, --notes, "notes text"]
compare: exit
verify: [[show, --json, e2e-t-notes]]
- id: mc-update-external-ref-metadata
source: mc snapshot.md (update --external-ref --metadata)
args: [update, e2e-t-er, --external-ref, gh-1, --metadata, '{"gc.kind":"github_source"}']
compare: exit
verify: [[show, --json, e2e-t-er]]
- id: mc-update-metadata
source: mc build-base prepare.md (update --metadata)
args: [update, e2e-t-md, --metadata, '{"x":"1"}']
compare: exit
verify: [[show, --json, e2e-t-md]]
- id: mc-update-assignee
source: mc review reports (update --assignee)
args: [update, e2e-t-asg, --assignee, bob]
compare: exit
verify: [[show, --json, e2e-t-asg]]
# ---------------------------------------------------------------- close / reopen
- id: gc-close-force-reason-many
source: gc bdstore.go bdCloseArgs (CloseAll/CloseAllWithReason)
args: [close, --force, --json, --reason, done, e2e-t-c1, e2e-t-c2]
compare: exit
verify: [[show, --json, e2e-t-c1, e2e-t-c2]]
- id: gc-close-if-revision
source: gc bdstore_conditional.go CloseIfMatch
args: [close, --force, --json, e2e-t-c3, --if-revision, "{rev:e2e-t-c3}"]
compare: exit
verify: [[show, --json, e2e-t-c3]]
- id: mc-close-text
source: mc formulas (bd close <id>)
args: [close, e2e-t-c4]
compare: exit
verify: [[show, --json, e2e-t-c4]]
- id: mc-close-reason
source: mc build-basic-review (bd close --reason)
args: [close, e2e-t-c5, --reason, "review applied"]
compare: exit
verify: [[show, --json, e2e-t-c5]]
- id: gc-close-last-step-autocloses-molecule
source: gc/mc molecule lifecycle (closing the last open step closes the root)
args: [close, --force, --json, e2e-mac.2]
compare: exit
verify: [[show, --json, e2e-mac]]
- id: gc-reopen
source: gc bdstore.go Reopen
args: [reopen, --json, e2e-t-ro]
compare: exit
verify: [[show, --json, e2e-t-ro]]
# ---------------------------------------------------------------- delete / reclaim / promote / burn
- id: gc-delete
source: gc bdstore.go Delete
args: [delete, --force, --json, e2e-t-d1]
compare: exit
verify: [[show, --json, e2e-t-d1]]
- id: gc-delete-if-revision
source: gc bdstore_conditional.go DeleteIfMatch
args: [delete, --force, --json, e2e-t-d2, --if-revision, "{rev:e2e-t-d2}"]
compare: exit
verify: [[show, --json, e2e-t-d2]]
- id: gc-delete-batch
source: gc bdstore.go DeleteBatch (no --json)
args: [delete, e2e-t-d3, e2e-t-d4, --force]
compare: exit
verify: [[show, --json, e2e-t-d3]]
- id: gc-delete-cascade
source: gc cmd_convoy_dispatch.go deleteWorkflowMatches
args: [delete, e2e-t-dc, --cascade, --force]
compare: exit
verify: [[show, --json, e2e-t-dc.1]]
- id: mc-delete-from-file
source: mc session_cleanup.py / core reaper (delete --from-file)
args: [delete, --from-file, "{file:delete-list.txt}", --force]
compare: exit
verify: [[show, --json, e2e-t-df1]]
- id: gc-reclaim
source: gc bdstore.go ReclaimStale (reclaim --id <id> --json)
args: [reclaim, --id, e2e-t-rc, --json]
compare: exit
verify: [[show, --json, e2e-t-rc]]
pending: {slice: "SRV-1", reason: "the reference server does not advertise issues.reclaim (B3 #12), so the client refuses at its capability preflight"}
- id: gc-heartbeat
source: gc formulas/mol-do-work.toml:47 (gc bd heartbeat <id> -> bd heartbeat)
setup: [[update, e2e-t-hb, --claim]]
args: [heartbeat, e2e-t-hb, --json]
verify: [[show, --json, e2e-t-hb]]
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)
setup: [[update, e2e-t-hb2, --claim, --actor, alice]]
args: [heartbeat, e2e-t-hb2]
expect_exit: 1
expect_stderr: "(?i)claimed by|alice"
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"}
- id: gc-heartbeat-closed
source: gc formulas/mol-do-work.toml:47 (a worker heartbeating a bead that was closed under it)
setup: [[update, e2e-t-hb3, --claim], [close, e2e-t-hb3]]
args: [heartbeat, e2e-t-hb3]
expect_exit: 1
expect_stderr: "(?i)status closed|is closed"
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"}
- 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"}
- id: mc-promote
source: mc mol-normalized-issue-pr-v1 (promote --reason)
args: [promote, e2e-wisp-p, --reason, "keep it"]
compare: exit
pending: {slice: "SRV-1", reason: "the reference server does not advertise issues.update.persistence, so the client refuses at its capability preflight"}
- id: mc-mol-burn
source: mc review fixtures (mol burn --force)
args: [mol, burn, e2e-wisp-m, --force]
compare: exit
verify: [[show, --json, e2e-wisp-m.1]]
pending: {slice: "S17", reason: "mol burn needs RunInTransaction (B3 #14)"}
# ---------------------------------------------------------------- deps / comments / labels / config writes
- id: gc-dep-add
source: gc bdstore.go DepAdd
args: [dep, add, e2e-t-da, e2e-t-db, --type, blocks]
compare: exit
verify: [[dep, list, e2e-t-da, --json]]
- id: gc-dep-remove
source: gc bdstore.go DepRemove
args: [dep, remove, e2e-t-dr, e2e-t-db]
compare: exit
verify: [[dep, list, e2e-t-dr, --json]]
- id: mc-comment
source: mc bug_hunt.py (bd comment <id> <text>)
args: [comment, e2e-t-cm, "a comment"]
compare: exit
verify: [[comments, e2e-t-cm, --json]]
ignore_fields: [id] # comment ids are minted per workspace
- id: mc-comments-list
source: mc prompts (bd comments <id>)
args: [comments, e2e-r1, --json]
ignore_fields: [id] # comment ids are minted per workspace
- id: mc-label-add
source: mc prompts (bd label add)
args: [label, add, e2e-t-l, "lane:q"]
compare: exit
verify: [[show, --json, e2e-t-l]]
- id: mc-assign
source: mc prompts (bd assign)
args: [assign, e2e-t-as2, alice]
compare: exit
verify: [[show, --json, e2e-t-as2]]
- id: gc-config-set-types
source: gc beads_provider_lifecycle.go (config set types.custom a,b)
args: [config, set, types.custom, "corpus-a,corpus-b"]
compare: exit
verify: [[config, get, --json, types.custom]]
- id: mc-meta-set
source: mc adopt-pr-review checks (bd meta set <id> k=v)
args: [meta, set, e2e-r1, review.verdict=done]
expect_exit: 1
expect_stderr: 'unknown command "meta"'
compare: exit
# ---------------------------------------------------------------- gates
# The gate writes: create (one createIssue carrying the gate members and the
# blocks edge), a real timer gate resolving under gate check, add-waiter (a
# guarded waiters patch) and update --await-id. A --timeout=1ns timer is
# expired by the time gate check runs, so the resolution is deterministic.
- id: mc-gate-create-timer
source: core formulas / gate-sweep (bd gate create --type=timer --timeout --blocks)
args: [gate, create, --type=timer, --timeout=1ns, --blocks, e2e-t-gcr, --json]
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
setup: [[gate, create, --type=timer, --timeout=1ns, --blocks, e2e-t-gct]]
args: [gate, check, --type=timer, --escalate]
compare: exit
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"}
- id: mc-gate-add-waiter
source: bd done --phase-complete (gate add-waiter)
args: [gate, add-waiter, e2e-t-gw, "rig/workers/a"]
compare: text
verify: [[show, --json, e2e-t-gw]]
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"}
- id: mc-update-await-id
source: gate discover / gate check gh:run persist (update --await-id)
args: [update, e2e-t-gaw, --await-id, "12345", --json]
compare: exit
verify: [[show, --json, e2e-t-gaw]]
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"}

View file

@ -0,0 +1,595 @@
{
"comment": [
"The reference server profile the corpus suite masks the in-process server to.",
"It is the wire surface of a deployed bd 1.3.0 `bd serve` that predates wire_revision:",
"capabilities is that server's advertised ContextResponse.capabilities (read off a live GET /v0/beads/context),",
"context_members is its ContextResponse property set, and operations are the method, path template,",
"query parameter names and top-level JSON request members of its published OpenAPI document (MIT).",
"Regenerate by hand when the reference deployment is upgraded; see README.md."
],
"capabilities": [
"config.get",
"config.list",
"config.set",
"config.unset",
"dependencies.add",
"dependencies.blocking",
"dependencies.count",
"dependencies.cycles",
"dependencies.list",
"dependencies.remove",
"dependencies.tree",
"events.list",
"events.watch",
"issues.addComment",
"issues.batchApply",
"issues.batchClose",
"issues.batchCreate",
"issues.casMetadata",
"issues.claim",
"issues.claimNext",
"issues.close",
"issues.count",
"issues.create",
"issues.delete",
"issues.get",
"issues.list",
"issues.list.sort",
"issues.query",
"issues.related",
"issues.release",
"issues.reopen",
"issues.sweep",
"issues.update",
"memories.forget",
"memories.get",
"memories.list",
"memories.remember",
"policy.external_dependencies",
"project.enforce",
"ready.count",
"ready.list",
"stats.get"
],
"context_members": [
"api_version",
"backend",
"bd_version",
"beads_dir",
"capabilities",
"database",
"dolt_mode",
"project_id",
"repo_root",
"schema_version"
],
"operations": [
{
"method": "GET",
"path": "/healthz",
"operation_id": "health",
"query": [],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/config",
"operation_id": "listSettings",
"query": [],
"body": []
},
{
"method": "DELETE",
"path": "/v0/beads/config/{key}",
"operation_id": "unsetSetting",
"query": [],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/config/{key}",
"operation_id": "getSetting",
"query": [],
"body": []
},
{
"method": "PUT",
"path": "/v0/beads/config/{key}",
"operation_id": "setSetting",
"query": [],
"body": [
"value"
]
},
{
"method": "GET",
"path": "/v0/beads/context",
"operation_id": "getContext",
"query": [],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/dependencies",
"operation_id": "listDependencies",
"query": [
"issue_id",
"type"
],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/dependencies/blocking",
"operation_id": "listBlockingAnnotations",
"query": [
"issue_id"
],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/dependencies/cycles",
"operation_id": "listDependencyCycles",
"query": [],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/dependencies/tree",
"operation_id": "getDependencyTree",
"query": [
"direction",
"max_depth",
"root_id",
"status"
],
"body": []
},
{
"method": "POST",
"path": "/v0/beads/dependencies:add",
"operation_id": "addDependencies",
"query": [],
"body": [
"actor",
"edges"
]
},
{
"method": "GET",
"path": "/v0/beads/dependencies:count",
"operation_id": "countDependencyEdges",
"query": [
"direction",
"issue_id",
"status",
"type"
],
"body": []
},
{
"method": "POST",
"path": "/v0/beads/dependencies:remove",
"operation_id": "removeDependency",
"query": [],
"body": [
"actor",
"depends_on_id",
"issue_id"
]
},
{
"method": "GET",
"path": "/v0/beads/events",
"operation_id": "listEvents",
"query": [
"limit",
"since"
],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/events:watch",
"operation_id": "watchEvents",
"query": [
"since"
],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/issues",
"operation_id": "listIssues",
"query": [
"all",
"assignee",
"brief",
"created_after",
"created_before",
"cursor",
"exclude_label",
"has_metadata_key",
"include_ephemeral",
"include_gates",
"include_infra",
"include_templates",
"label",
"label_any",
"limit",
"metadata_field",
"parent",
"reverse",
"sort",
"status",
"type"
],
"body": []
},
{
"method": "POST",
"path": "/v0/beads/issues",
"operation_id": "createIssue",
"query": [],
"body": [
"acceptance_criteria",
"actor",
"assignee",
"defer_until",
"dependencies",
"description",
"design",
"due_at",
"ephemeral",
"estimated_minutes",
"external_ref",
"force_id_prefix",
"id",
"inherit_labels_from_parent",
"issue_type",
"labels",
"metadata",
"no_history",
"notes",
"owner",
"parent_id",
"priority",
"sender",
"status",
"title",
"waits_for"
]
},
{
"method": "GET",
"path": "/v0/beads/issues/{id}",
"operation_id": "getIssue",
"query": [
"brief_deps",
"include_comments",
"include_dependents"
],
"body": []
},
{
"method": "PATCH",
"path": "/v0/beads/issues/{id}",
"operation_id": "updateIssue",
"query": [],
"body": [
"actor",
"expected_assignee",
"expected_status",
"expected_version",
"force_assignee_transfer",
"force_close_policy",
"patch"
]
},
{
"method": "POST",
"path": "/v0/beads/issues/{id}/comments",
"operation_id": "addComment",
"query": [],
"body": [
"author",
"text"
]
},
{
"method": "GET",
"path": "/v0/beads/issues/{id}/related",
"operation_id": "listRelatedIssues",
"query": [
"direction",
"type"
],
"body": []
},
{
"method": "POST",
"path": "/v0/beads/issues/{id}:casMetadata",
"operation_id": "compareAndSetMetadata",
"query": [],
"body": [
"actor",
"expected",
"key",
"value"
]
},
{
"method": "POST",
"path": "/v0/beads/issues/{id}:claim",
"operation_id": "claimIssue",
"query": [],
"body": [
"actor"
]
},
{
"method": "POST",
"path": "/v0/beads/issues/{id}:close",
"operation_id": "closeIssue",
"query": [],
"body": [
"actor",
"expected_version",
"force",
"reason",
"session"
]
},
{
"method": "POST",
"path": "/v0/beads/issues/{id}:release",
"operation_id": "releaseIssue",
"query": [],
"body": [
"actor",
"expected_assignee",
"force"
]
},
{
"method": "POST",
"path": "/v0/beads/issues/{id}:reopen",
"operation_id": "reopenIssue",
"query": [],
"body": [
"actor",
"expected_version",
"reason"
]
},
{
"method": "POST",
"path": "/v0/beads/issues:batchApply",
"operation_id": "applyBatch",
"query": [],
"body": [
"actor",
"force_id_prefix",
"items",
"provenance",
"skip_per_edge_cycle_check"
]
},
{
"method": "POST",
"path": "/v0/beads/issues:batchClose",
"operation_id": "batchCloseIssues",
"query": [],
"body": [
"actor",
"claim_next",
"force",
"items",
"session"
]
},
{
"method": "POST",
"path": "/v0/beads/issues:batchCreate",
"operation_id": "batchCreateIssues",
"query": [],
"body": [
"actor",
"items"
]
},
{
"method": "POST",
"path": "/v0/beads/issues:claimNext",
"operation_id": "claimNextIssue",
"query": [
"assignee",
"exclude_label",
"exclude_type",
"has_metadata_key",
"include_deferred",
"include_ephemeral",
"label",
"label_any",
"label_pattern",
"label_regex",
"metadata_field",
"parent",
"priority",
"sort",
"type",
"unassigned"
],
"body": [
"actor"
]
},
{
"method": "GET",
"path": "/v0/beads/issues:count",
"operation_id": "countIssues",
"query": [
"assignee",
"closed_after",
"closed_before",
"created_after",
"created_before",
"desc_contains",
"empty_description",
"group_by",
"id",
"include_infra",
"label",
"label_any",
"metadata_field",
"no_assignee",
"no_labels",
"notes_contains",
"priority",
"priority_max",
"priority_min",
"status",
"title",
"title_contains",
"type",
"updated_after",
"updated_before"
],
"body": []
},
{
"method": "POST",
"path": "/v0/beads/issues:delete",
"operation_id": "deleteIssues",
"query": [],
"body": [
"actor",
"cascade",
"dry_run",
"expected_version",
"force",
"ids"
]
},
{
"method": "GET",
"path": "/v0/beads/issues:query",
"operation_id": "queryIssues",
"query": [
"all",
"limit",
"q",
"reverse",
"sort"
],
"body": []
},
{
"method": "POST",
"path": "/v0/beads/issues:sweep",
"operation_id": "sweepIssues",
"query": [],
"body": [
"actor",
"closed_before",
"dry_run",
"pattern",
"protect_referenced",
"tier"
]
},
{
"method": "GET",
"path": "/v0/beads/memories",
"operation_id": "listMemories",
"query": [
"search"
],
"body": []
},
{
"method": "POST",
"path": "/v0/beads/memories",
"operation_id": "rememberMemory",
"query": [],
"body": [
"content",
"key"
]
},
{
"method": "DELETE",
"path": "/v0/beads/memories/{key}",
"operation_id": "forgetMemory",
"query": [],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/memories/{key}",
"operation_id": "getMemory",
"query": [],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/ready",
"operation_id": "listReadyWork",
"query": [
"assignee",
"brief",
"exclude_label",
"exclude_type",
"has_metadata_key",
"include_deferred",
"include_ephemeral",
"label",
"label_any",
"label_pattern",
"label_regex",
"limit",
"metadata_field",
"parent",
"priority",
"sort",
"type",
"unassigned"
],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/ready:count",
"operation_id": "countReadyWork",
"query": [
"assignee",
"exclude_label",
"exclude_type",
"has_metadata_key",
"include_deferred",
"include_ephemeral",
"label",
"label_any",
"label_pattern",
"label_regex",
"metadata_field",
"parent",
"priority",
"type",
"unassigned"
],
"body": []
},
{
"method": "GET",
"path": "/v0/beads/stats",
"operation_id": "getStats",
"query": [
"assignee",
"skip_blocked"
],
"body": []
}
]
}

View file

@ -0,0 +1,66 @@
package bdhttp
import (
"net/url"
"github.com/steveyegge/beads/internal/httpclient"
)
// CredentialProvider authorizes outbound requests to a bd serve.
//
// An implementation must be safe for concurrent use, must never log or
// persist a secret, and must FAIL CLOSED: a configured source that errors
// aborts the request rather than silently downgrading to an unauthenticated
// one.
//
// Authorize is called once per request, not once per attempt: a read whose
// first attempt stalls or has its connection reset is resent once with the
// same headers, up to the client's overall timeout later. A provider whose
// credentials are single-use or short-lived should expect that resend to draw
// a 401, which reaches Refresh like any other.
type CredentialProvider = httpclient.CredentialProvider
const (
// TokenEnv carries the bearer token itself, the highest rung of the
// built-in ladder.
// #nosec G101 -- the NAME of an environment variable, not a credential.
TokenEnv = httpclient.TokenEnv
// TokenCommandEnv names a helper that prints a token, either bare or in
// the kubectl ExecCredential envelope {"token","expirationTimestamp"}.
// #nosec G101 -- the NAME of an environment variable, not a credential.
TokenCommandEnv = httpclient.TokenCommandEnv
)
// BearerProvider is the built-in credential ladder: TokenEnv, then
// TokenCommandEnv, then the credentials file's [host:port] section, then no
// credential at all (the tip OSS server's loopback-trust posture, a
// legitimate answer and not a failure).
type BearerProvider = httpclient.BearerProvider
// NewBearerProvider builds the built-in ladder for a server. Open and
// Handshake already dial with it; it is exported so an embedder that wants to
// WRAP the default (decorate it for one target, delegate to it for the rest)
// does not have to reimplement it.
func NewBearerProvider(base *url.URL) *BearerProvider {
return httpclient.NewBearerProvider(base)
}
// ProvidedCredential adapts a CredentialProvider into the opaque
// backends.Credential marker interface, so it can be carried through
// beads.OpenOptions / beads.OpenBestAvailableWith (and, directly, through
// backends.OpenOptions) to the registered "http" backend's OpenWith hook
// Register installs.
//
// A multi-tenant embedder (for example gc, Gas City: one process serving many
// workspaces, called "cities") that wants a distinct credential per workspace
// wraps that workspace's own provider in a ProvidedCredential when it opens
// through the registry (the direct door takes the provider itself, as
// Options.Credential): the registered dialer Register installs is
// process-wide and cannot hold one credential per tenant, but the per-open
// OpenWith seam can, and this is the opaque wrapper type that seam
// recognizes. Either way the supplied provider is the ONLY credential the
// open uses, and no ambient credential, CA or plaintext grant is read; see the
// package doc's "Credentials" section. See httpclient.ResolveCredential and
// backends.OpenOptions.Credential's own doc comment for the single-tenant
// ambient-ladder default this exists to opt out of.
type ProvidedCredential = httpclient.ProvidedCredential

View file

@ -0,0 +1,287 @@
//go:build cgo
package bdhttp_test
import (
"context"
"encoding/json"
"errors"
"os/exec"
"reflect"
"sort"
"strings"
"testing"
"github.com/steveyegge/beads/internal/storage/issueops"
)
// runBDStdin is runBD with stdin.
func runBDStdin(t *testing.T, f *remoteRolesFixture, stdin string, args ...string) bdResult {
t.Helper()
cmd := exec.Command(f.bin, args...)
cmd.Dir = f.dir
cmd.Env = minimalBDEnv(f.dir)
cmd.Stdin = strings.NewReader(stdin)
var o, e strings.Builder
cmd.Stdout, cmd.Stderr = &o, &e
err := cmd.Run()
code := 0
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
code = exitErr.ExitCode()
} else if err != nil {
t.Fatalf("run bd %v: %v", args, err)
}
return bdResult{stdout: o.String(), stderr: e.String(), code: code}
}
type blockedFlagRow struct {
ID string `json:"id"`
IsBlocked bool `json:"is_blocked"`
}
func parseBlockedFlags(t *testing.T, out string) []blockedFlagRow {
t.Helper()
var rows []blockedFlagRow
if err := json.Unmarshal([]byte(strings.TrimSpace(out)), &rows); err != nil {
t.Fatalf("parse bd blocked --flags --json: %v\n%s", err, out)
}
if rows == nil {
t.Fatalf("bd blocked --flags --json printed null, want an array: %s", out)
}
return rows
}
// flagStdin is every id the fixture created, in title order, plus an id that
// names no row, a blank line and a repeat: the omitted, ignored and collapsed
// cases.
func flagStdin(f *remoteRolesFixture) string {
titles := make([]string, 0, len(f.ids))
for title := range f.ids {
titles = append(titles, title)
}
sort.Strings(titles)
var b strings.Builder
for _, title := range titles {
b.WriteString(f.ids[title] + "\n")
}
b.WriteString("\n " + f.ids[titles[0]] + " \ne2e-no-such-row\n")
return b.String()
}
// TestE2E_BlockedFlagsOverHTTP runs `bd blocked --flags --json` (the blocked
// flag per id read from stdin, the readiness column gc projects) through the
// real `bd` binary against an in-process `bd serve` and against a local
// embedded workspace holding the same graph, and requires the same JSON once
// each generated id is mapped to its title. Over HTTP the read is
// listBlockingAnnotations with is_blocked; an older server's handshake is
// refused before the dial, naming dependencies.blocking.isBlocked.
//
// It also pins that this is the FLAG and not the listing: a row whose stored
// flag is set with no nameable blocker reads true here and is absent from
// `bd blocked --json`.
func TestE2E_BlockedFlagsOverHTTP(t *testing.T) {
skipUnlessEmbeddedDolt(t)
bin := buildBD(t)
seed := func(f *remoteRolesFixture) {
f.seed()
blocker := f.create("blocker", "-t", "task")
gp := f.create("gate-parent", "-t", "epic")
kid := f.create("gate-kid", "-t", "task")
f.mustRun(nil, "dep", "add", kid, gp, "--type", "parent-child")
f.mustRun(nil, "dep", "add", gp, blocker)
}
t.Run("served equals local", func(t *testing.T) {
addr := startE2EServer(t)
local := newEmbeddedFixture(t, bin)
seed(local)
served := newHTTPFixture(t, bin, addr)
seed(served)
lr := runBDStdin(t, local, flagStdin(local), "blocked", "--flags", "--json")
sr := runBDStdin(t, served, flagStdin(served), "blocked", "--flags", "--json")
if lr.code != 0 || sr.code != 0 {
t.Fatalf("exit local=%d served=%d\nlocal: %s %s\nserved: %s %s", lr.code, sr.code, lr.stdout, lr.stderr, sr.stdout, sr.stderr)
}
normalize := func(f *remoteRolesFixture, rows []blockedFlagRow) []blockedFlagRow {
titleOf := map[string]string{}
for title, id := range f.ids {
titleOf[id] = title
}
out := make([]blockedFlagRow, 0, len(rows))
for _, row := range rows {
if title, ok := titleOf[row.ID]; ok {
row.ID = title
}
out = append(out, row)
}
return out
}
want := normalize(local, parseBlockedFlags(t, lr.stdout))
got := normalize(served, parseBlockedFlags(t, sr.stdout))
if !reflect.DeepEqual(want, got) {
t.Errorf("served bd blocked --flags --json differs from the local command:\nlocal: %v\nserved: %v", want, got)
}
if len(want) != len(local.ids) {
t.Errorf("local answered %d rows for %d ids (the unknown id omitted, the repeat collapsed): %v", len(want), len(local.ids), want)
}
blocked := map[string]bool{}
for _, row := range got {
blocked[row.ID] = row.IsBlocked
}
for title, wantBlocked := range map[string]bool{
"loner": true, "child-x": true, "gate-parent": true, "gate-kid": true,
"blocker": false, "child-b": false, "parent": false,
} {
if blocked[title] != wantBlocked {
t.Errorf("%s is_blocked = %v, want %v (rows %v)", title, blocked[title], wantBlocked, got)
}
}
// Byte-for-byte the same members in the same order.
if strings.Count(lr.stdout, "\n") != strings.Count(sr.stdout, "\n") {
t.Errorf("line counts differ:\nlocal:\n%s\nserved:\n%s", lr.stdout, sr.stdout)
}
// Nothing piped is an empty array.
if r := runBDStdin(t, served, "", "blocked", "--flags", "--json"); r.code != 0 || strings.TrimSpace(r.stdout) != "[]" {
t.Errorf("empty stdin: exit %d stdout %q, want [] and exit 0", r.code, r.stdout)
}
// The listing's filters are refused, not silently ignored.
if r := runBDStdin(t, served, "x\n", "blocked", "--flags", "--json", "--label", "a"); r.code != 1 {
t.Errorf("--flags --label exited %d, want 1: %s", r.code, r.stdout)
}
})
t.Run("the flag, not the listing", func(t *testing.T) {
addr, reference := startE2EServerWithStore(t, e2eProjectID, e2eDatabase)
served := newHTTPFixture(t, bin, addr)
stale := served.create("stale")
if err := reference.RunEventsMaintenanceTx(context.Background(), func(ctx context.Context, tx issueops.DBTX) error {
_, err := tx.ExecContext(ctx, "UPDATE issues SET is_blocked = 1 WHERE id = ?", stale)
return err
}); err != nil {
t.Fatalf("set the stale flag: %v", err)
}
rows := parseBlockedFlags(t, runBDStdin(t, served, stale+"\n", "blocked", "--flags", "--json").stdout)
if len(rows) != 1 || rows[0].ID != stale || !rows[0].IsBlocked {
t.Errorf("--flags for a stale-flagged row = %v, want [{%s true}]", rows, stale)
}
listing := served.mustRun(nil, "blocked", "--json").stdout
if strings.Contains(listing, stale) {
t.Errorf("bd blocked --json lists %s, which has no nameable blocker: %s", stale, listing)
}
})
t.Run("raw is the stored column", func(t *testing.T) {
addr, reference := startE2EServerWithStore(t, e2eProjectID, e2eDatabase)
local := newEmbeddedFixture(t, bin)
seed(local)
served := newHTTPFixture(t, bin, addr)
seed(served)
flagsOf := func(f *remoteRolesFixture, stdin string, args ...string) map[string]bool {
t.Helper()
r := runBDStdin(t, f, stdin, append([]string{"blocked", "--flags", "--json"}, args...)...)
if r.code != 0 {
t.Fatalf("bd blocked --flags --json %v exited %d: %s %s", args, r.code, r.stdout, r.stderr)
}
titleOf := map[string]string{}
for title, id := range f.ids {
titleOf[id] = title
}
out := map[string]bool{}
for _, row := range parseBlockedFlags(t, r.stdout) {
key := row.ID
if title, ok := titleOf[row.ID]; ok {
key = title
}
out[key] = row.IsBlocked
}
return out
}
localRaw := flagsOf(local, flagStdin(local), "--raw")
servedRaw := flagsOf(served, flagStdin(served), "--raw")
if !reflect.DeepEqual(localRaw, servedRaw) {
t.Errorf("served --raw differs from local --raw:\nlocal: %v\nserved: %v", localRaw, servedRaw)
}
lr := runBDStdin(t, local, flagStdin(local), "blocked", "--flags", "--json", "--raw")
sr := runBDStdin(t, served, flagStdin(served), "blocked", "--flags", "--json", "--raw")
if strings.Count(lr.stdout, "\n") != strings.Count(sr.stdout, "\n") {
t.Errorf("--raw line counts differ:\nlocal:\n%s\nserved:\n%s", lr.stdout, sr.stdout)
}
// child-x is blocked ONLY by an unsatisfied external ref: the policy
// flag says blocked, the stored column does not.
decorated := flagsOf(served, flagStdin(served))
if !decorated["child-x"] || servedRaw["child-x"] || localRaw["child-x"] {
t.Errorf("child-x (externally blocked only): --flags %v, --raw served %v local %v; want true, false, false",
decorated["child-x"], servedRaw["child-x"], localRaw["child-x"])
}
// Locally blocked rows read the same either way.
for _, title := range []string{"loner", "gate-parent", "gate-kid", "blocker"} {
if decorated[title] != servedRaw[title] {
t.Errorf("%s: --flags %v, --raw %v; a local blocker is the column", title, decorated[title], servedRaw[title])
}
}
// A stale flag (set, no blocker) is the column, so both read true.
stale := served.create("stale")
if err := reference.RunEventsMaintenanceTx(context.Background(), func(ctx context.Context, tx issueops.DBTX) error {
_, err := tx.ExecContext(ctx, "UPDATE issues SET is_blocked = 1 WHERE id = ?", stale)
return err
}); err != nil {
t.Fatalf("set the stale flag: %v", err)
}
if got := flagsOf(served, stale+"\n", "--raw"); !got["stale"] {
t.Errorf("--raw for the stale-flagged row = %v, want true", got)
}
if got := flagsOf(served, stale+"\n"); !got["stale"] {
t.Errorf("--flags for the stale-flagged row = %v, want true", got)
}
// --raw qualifies --flags only.
if r := runBDStdin(t, served, "", "blocked", "--json", "--raw"); r.code != 1 || !strings.Contains(r.stdout+r.stderr, "--raw") {
t.Errorf("bd blocked --raw without --flags: exit %d %s %s, want exit 1 naming --raw", r.code, r.stdout, r.stderr)
}
// A server that applies the policy answers the decorated flag and the
// wire cannot ask it for the column: --raw is refused there, before
// the annotation read, rather than answered with the policy flag.
proxyAddr, counter := startMaskingProxy(t, addr, func(body map[string]any) {
caps, _ := body["capabilities"].([]any)
body["capabilities"] = append(caps, "policy.external_dependencies")
})
enforced := newHTTPFixture(t, bin, proxyAddr)
counter.reset()
r := runBDStdin(t, enforced, served.ids["child-x"]+"\n", "blocked", "--flags", "--json", "--raw")
if r.code != 1 || !strings.Contains(r.stdout+r.stderr, "policy.external_dependencies") {
t.Errorf("--raw against a policy server: exit %d %s %s, want exit 1 naming the policy token", r.code, r.stdout, r.stderr)
}
for _, p := range counter.snapshot() {
if strings.Contains(p, "/v0/beads/dependencies/blocking") {
t.Errorf("a refused --raw dialed %s", p)
}
}
})
t.Run("older server mask", func(t *testing.T) {
addr := startE2EServer(t)
proxyAddr, counter := startMaskingProxy(t, addr, mcContextMask)
f := newHTTPFixture(t, bin, proxyAddr)
counter.reset()
r := runBDStdin(t, f, "e2e-anything\n", "blocked", "--flags", "--json")
if r.code != 1 {
t.Fatalf("bd blocked --flags against a server without the token exited %d, want 1: %s", r.code, r.stdout)
}
if !strings.Contains(r.stdout+r.stderr, "dependencies.blocking.isBlocked") {
t.Errorf("refusal does not name the missing capability: stdout=%s stderr=%s", r.stdout, r.stderr)
}
for _, p := range counter.snapshot() {
if strings.Contains(p, "/v0/beads/dependencies/blocking") {
t.Errorf("a refused bd blocked --flags dialed %s", p)
}
}
})
}

View file

@ -0,0 +1,229 @@
//go:build cgo
package bdhttp_test
import (
"encoding/json"
"reflect"
"slices"
"strings"
"testing"
)
// TestE2E_BlockedOverHTTP runs `bd blocked --json` (the blocked door gc's
// readiness projection reads) through the real `bd` binary against an
// in-process `bd serve`, and against a local embedded workspace holding the
// same graph.
//
// Over HTTP the CLI takes the store's BlockedLister, which dials
// GET /v0/beads/blocked behind blocked.list. The two answers must be the same
// JSON once the values that cannot agree between two workspaces (each row's
// generated id, and its timestamps) are mapped out: the same rows, the same
// members, the same blockers (local, parent-attributed and external), in the
// same order. Against a server that does not advertise blocked.list (an older
// server's handshake) the client refuses before the dial, naming the token.
func TestE2E_BlockedOverHTTP(t *testing.T) {
skipUnlessEmbeddedDolt(t)
bin := buildBD(t)
addr := startE2EServer(t)
seedBlocked := func(f *remoteRolesFixture) {
f.seed()
// A plain blocks edge, a blocked parent's child attributed to the
// parent, and a labelled blocked row for the filter arms.
blocker := f.create("blocker", "-t", "task", "-p", "1")
gp := f.create("gate-parent", "-t", "epic", "-p", "2")
// Its own priority: rows tied on priority and created_at fall to the
// id order, and ids are generated per workspace, so a tie would order
// the two workspaces differently.
kid := f.create("gate-kid", "-t", "task", "-p", "3")
tagged := f.create("tagged", "-t", "task", "-p", "1", "-l", "lane:a")
// Blocked by nothing but an unsatisfied external ref, as child-x is,
// and labelled: the decorator lists such rows itself, after the label
// query ran, so the filter arms must judge them too.
extTagged := f.create("ext-tagged", "-t", "task", "-p", "4", "-l", "lane:a")
f.mustRun(nil, "dep", "add", kid, gp, "--type", "parent-child")
f.mustRun(nil, "dep", "add", gp, blocker)
f.mustRun(nil, "dep", "add", tagged, blocker)
f.mustRun(nil, "dep", "add", extTagged, "external:other:cap")
}
local := newEmbeddedFixture(t, bin)
seedBlocked(local)
served := newHTTPFixture(t, bin, addr)
seedBlocked(served)
for _, args := range [][]string{
{"blocked", "--json"},
{"blocked", "--json", "--label", "lane:a"},
{"blocked", "--json", "--label-any", "lane:a"},
{"blocked", "--json", "--exclude-label", "lane:a"},
{"blocked", "--json", "--parent", "{gate-parent}"},
{"blocked", "--json", "--label", "no-such-label"},
} {
t.Run(strings.Join(args[1:], " "), func(t *testing.T) {
want := local.mustRun(nil, local.expand(args)...).stdout
got := served.mustRun(nil, served.expand(args)...).stdout
if strings.TrimSpace(want) == "null" || strings.TrimSpace(got) == "null" {
t.Fatalf("bd blocked --json printed null: local=%s served=%s", want, got)
}
if w, g := normalizeBlocked(t, local, want), normalizeBlocked(t, served, got); !reflect.DeepEqual(w, g) {
t.Errorf("served bd blocked --json differs from the local command:\nlocal: %v\nserved: %v", w, g)
}
if w, g := blockedKeyOrder(t, want), blockedKeyOrder(t, got); !reflect.DeepEqual(w, g) {
t.Errorf("served member order %v differs from the local command's %v", g, w)
}
})
}
t.Run("names the external blocker", func(t *testing.T) {
got := normalizeBlocked(t, served, served.mustRun(nil, "blocked", "--json").stdout)
found := false
for _, row := range got {
if row["id"] == "child-x" {
found = reflect.DeepEqual(row["blocked_by"], []any{"external:other:cap"})
}
}
if !found {
t.Errorf("served bd blocked --json does not list child-x blocked by its external ref: %v", got)
}
})
// The arms above compare the two answers, which agree just as well when
// both list a row the filter rules out. These pin which rows each filter
// leaves, the external-only ones (child-x unlabelled, ext-tagged
// labelled) among them.
for _, tc := range []struct {
args []string
want []string // the whole listing, when set
listed, ruled []string
}{
{args: []string{"--label", "lane:a"}, want: []string{"ext-tagged", "tagged"}},
{args: []string{"--label-any", "lane:a"}, want: []string{"ext-tagged", "tagged"}},
{args: []string{"--label", "no-such-label"}, want: []string{}},
{args: []string{"--exclude-label", "lane:a"}, listed: []string{"child-x"}, ruled: []string{"ext-tagged", "tagged"}},
} {
t.Run("filters external-only rows "+strings.Join(tc.args, " "), func(t *testing.T) {
for _, f := range []struct {
name string
f *remoteRolesFixture
}{{"local", local}, {"served", served}} {
got := f.f.titlesOf(f.f.mustRun(nil, append([]string{"blocked", "--json"}, tc.args...)...).stdout)
if tc.want != nil && !slices.Equal(got, tc.want) {
t.Errorf("%s bd blocked %s listed %v, want %v", f.name, strings.Join(tc.args, " "), got, tc.want)
}
for _, title := range tc.listed {
if !slices.Contains(got, title) {
t.Errorf("%s bd blocked %s does not list %s: %v", f.name, strings.Join(tc.args, " "), title, got)
}
}
for _, title := range tc.ruled {
if slices.Contains(got, title) {
t.Errorf("%s bd blocked %s lists %s, which the filter rules out: %v", f.name, strings.Join(tc.args, " "), title, got)
}
}
}
})
}
t.Run("older server mask", func(t *testing.T) {
proxyAddr, counter := startMaskingProxy(t, addr, mcContextMask)
f := newHTTPFixture(t, bin, proxyAddr)
counter.reset()
r := f.run(nil, "blocked", "--json")
if r.code != 1 {
t.Fatalf("bd blocked against a server without blocked.list exited %d, want 1: %s", r.code, r.stdout)
}
if !strings.Contains(r.stdout+r.stderr, "blocked.list") {
t.Errorf("refusal does not name the missing capability: stdout=%s stderr=%s", r.stdout, r.stderr)
}
for _, p := range counter.snapshot() {
if strings.Contains(p, "/v0/beads/blocked") {
t.Errorf("a refused bd blocked dialed %s; the refusal must come before the dial", p)
}
}
})
}
// normalizeBlocked parses `bd blocked --json` and maps out what two
// workspaces cannot share: each id (and each blocker id) becomes the title the
// fixture created it under, and every timestamp member is blanked.
func normalizeBlocked(t *testing.T, f *remoteRolesFixture, out string) []map[string]any {
t.Helper()
var rows []map[string]any
if err := json.Unmarshal([]byte(strings.TrimSpace(out)), &rows); err != nil {
t.Fatalf("parse bd blocked --json: %v\n%s", err, out)
}
titleOf := map[string]string{}
for title, id := range f.ids {
titleOf[id] = title
}
var walk func(key string, v any) any
walk = func(key string, v any) any {
switch v := v.(type) {
case map[string]any:
for k, inner := range v {
v[k] = walk(k, inner)
}
return v
case []any:
for i := range v {
v[i] = walk("", v[i])
}
return v
case string:
if strings.HasSuffix(key, "_at") {
return "<time>"
}
if title, ok := titleOf[v]; ok {
return title
}
}
return v
}
for _, row := range rows {
walk("", row)
}
return rows
}
// blockedKeyOrder is the member order of each row as printed, so the two
// encodings are compared as text, not only as values.
func blockedKeyOrder(t *testing.T, out string) [][]string {
t.Helper()
var rows []json.RawMessage
if err := json.Unmarshal([]byte(strings.TrimSpace(out)), &rows); err != nil {
t.Fatalf("parse bd blocked --json: %v\n%s", err, out)
}
order := make([][]string, 0, len(rows))
for _, raw := range rows {
dec := json.NewDecoder(strings.NewReader(string(raw)))
var keys []string
depth := 0
for {
tok, err := dec.Token()
if err != nil {
break
}
switch v := tok.(type) {
case json.Delim:
if v == '{' || v == '[' {
depth++
} else {
depth--
}
case string:
if depth == 1 {
keys = append(keys, v)
// Skip the value.
var skip json.RawMessage
if err := dec.Decode(&skip); err != nil {
t.Fatalf("decode value of %s: %v", v, err)
}
}
}
}
order = append(order, keys)
}
return order
}

1072
backend/http/e2e_cli_test.go Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,203 @@
//go:build cgo
package bdhttp_test
import (
"encoding/json"
"maps"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
)
type exportLine struct {
Type string `json:"_type"`
ID string `json:"id"`
Ephemeral bool `json:"ephemeral"`
NoHistory bool `json:"no_history"`
WispPlane *bool `json:"wisp_plane"`
Labels []string `json:"labels"`
CommentCount int `json:"comment_count"`
DepCount int `json:"dependency_count"`
Dependencies []struct {
IssueID string `json:"issue_id"`
DependsOnID string `json:"depends_on_id"`
Type string `json:"type"`
} `json:"dependencies"`
Comments []struct {
Text string `json:"text"`
} `json:"comments"`
// Key and Value are a memory record's fields.
Key string `json:"key"`
Value string `json:"value"`
}
// plane renders the explicit wisps-plane marker: "absent", "true" or "false".
func (l exportLine) plane() string {
if l.WispPlane == nil {
return "absent"
}
return strconv.FormatBool(*l.WispPlane)
}
func readExportRecords(t *testing.T, path string) []exportLine {
t.Helper()
data, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read export: %v", err)
}
var out []exportLine
for _, line := range strings.Split(strings.TrimSpace(string(data)), "\n") {
if line == "" {
continue
}
var rec exportLine
if err := json.Unmarshal([]byte(line), &rec); err != nil {
t.Fatalf("parse export line %q: %v", line, err)
}
out = append(out, rec)
}
return out
}
func readExportLines(t *testing.T, path string) map[string]exportLine {
t.Helper()
out := map[string]exportLine{}
for _, rec := range readExportRecords(t, path) {
if rec.Type == "issue" {
out[rec.ID] = rec
}
}
return out
}
// readExportMemories returns an export's memory records, value by key.
func readExportMemories(t *testing.T, path string) map[string]string {
t.Helper()
out := map[string]string{}
for _, rec := range readExportRecords(t, path) {
if rec.Type == "memory" {
out[rec.Key] = rec.Value
}
}
return out
}
func wantExportMemories(t *testing.T, export string, got, want map[string]string) {
t.Helper()
if !maps.Equal(got, want) {
t.Errorf("%s memories = %v, want %v", export, got, want)
}
}
// TestE2E_ExportOverHTTP is S21. `bd export` read through the raw SearchIssues
// method and the bulk relation reads, which the http backend refuses, so gc's
// JSONL-export order failed on every remote scope. It now composes served role
// reads (issueops.ReadExport): the rows with their labels and counts, every
// row's dependency records and the comment bodies. Memories come from the
// served memory plane (listMemories): the settings enumeration withholds every
// kv.* row, so a remote export that read them there carried none.
//
// The no-history row pins the one place this route still differs from the
// local ones. No served read publishes plane membership, so the row is
// exported without the wisp_plane marker, and a current import pins it to the
// durable issues plane: the data-safe side, since a wrong marker would drop a
// durable row's relations (bd-r9uce). Serving the membership (bd-1lbvas)
// flips those assertions: the row is then marked and re-imports as a wisp.
func TestE2E_ExportOverHTTP(t *testing.T) {
bd := connectE2EWorkspace(t, "worker")
blocked := createE2EIssue(t, bd, "blocked work")
blocker := createE2EIssue(t, bd, "blocker")
mustRun(t, bd, "dep", "add", blocked, blocker, "--json")
mustRun(t, bd, "label", "add", blocked, "lane:x", "--json")
mustRun(t, bd, "comments", "add", blocked, "an export comment")
closed := createE2EIssue(t, bd, "closed work")
mustRun(t, bd, "close", closed, "--json")
wisp := firstJSONField(t, mustRun(t, bd, "create", "a wisp", "--ephemeral", "--json").stdout, "id")
noHistory := firstJSONField(t, mustRun(t, bd, "create", "a no-history wisp", "--no-history", "--json").stdout, "id")
memories := map[string]string{
"export-alpha": "remembered over http",
"export-beta": "a second memory",
}
for key, content := range memories {
mustRun(t, bd, "remember", content, "--key", key)
}
dir := t.TempDir()
all := filepath.Join(dir, "all.jsonl")
mustRun(t, bd, "export", "--all", "-o", all)
wantExportMemories(t, "bd export --all", readExportMemories(t, all), memories)
got := readExportLines(t, all)
for _, id := range []string{blocked, blocker, closed, wisp, noHistory} {
if _, ok := got[id]; !ok {
t.Errorf("bd export --all is missing %s; got %d issues", id, len(got))
}
}
rec := got[blocked]
if len(rec.Dependencies) != 1 || rec.Dependencies[0].DependsOnID != blocker || rec.DepCount != 1 {
t.Errorf("%s dependencies = %+v (count %d), want one edge onto %s", blocked, rec.Dependencies, rec.DepCount, blocker)
}
if len(rec.Labels) != 1 || rec.Labels[0] != "lane:x" {
t.Errorf("%s labels = %v, want [lane:x]", blocked, rec.Labels)
}
if rec.CommentCount != 1 || len(rec.Comments) != 1 || rec.Comments[0].Text != "an export comment" {
t.Errorf("%s comments = %+v (count %d), want the one comment", blocked, rec.Comments, rec.CommentCount)
}
if !got[wisp].Ephemeral {
t.Errorf("%s exported without ephemeral: %+v", wisp, got[wisp])
}
if rec := got[noHistory]; !rec.NoHistory || rec.plane() != "absent" {
t.Errorf("%s exported as no_history=%v wisp_plane=%s, want no_history with no marker", noHistory, rec.NoHistory, rec.plane())
}
// The default export keeps every status and the no-history row, and drops
// the true wisp.
def := filepath.Join(dir, "default.jsonl")
mustRun(t, bd, "export", "-o", def)
gotDef := readExportLines(t, def)
if _, ok := gotDef[wisp]; ok {
t.Errorf("bd export (default) exported the wisp %s", wisp)
}
for _, id := range []string{blocked, blocker, closed, noHistory} {
if _, ok := gotDef[id]; !ok {
t.Errorf("bd export (default) is missing %s", id)
}
}
if rec := gotDef[noHistory]; rec.plane() != "absent" {
t.Errorf("bd export (default) stamped %s wisp_plane=%s, want no marker", noHistory, rec.plane())
}
// Memories are opt-in: absent by default, present with --include-memories.
wantExportMemories(t, "bd export (default)", readExportMemories(t, def), map[string]string{})
withMemories := filepath.Join(dir, "memories.jsonl")
mustRun(t, bd, "export", "--include-memories", "-o", withMemories)
wantExportMemories(t, "bd export --include-memories", readExportMemories(t, withMemories), memories)
// Import the remote export into a fresh local workspace and export it
// again there. The local route stamps wisp_plane from table membership,
// which the locally created control row proves, so the imported row's
// missing marker means it sits in the durable issues table.
bin := buildBD(t)
localDir := t.TempDir()
local := func(args ...string) bdResult {
t.Helper()
return runBD(t, bin, localDir, []string{"BEADS_ACTOR=worker"}, args...)
}
mustRun(t, local, "init", "--prefix", "e2e", "--quiet")
mustRun(t, local, "import", "-i", all)
control := firstJSONField(t, mustRun(t, local, "create", "a local no-history wisp", "--no-history", "--json").stdout, "id")
back := filepath.Join(dir, "reexport.jsonl")
mustRun(t, local, "export", "--all", "-o", back)
gotBack := readExportLines(t, back)
if rec, ok := gotBack[control]; !ok || rec.plane() != "true" {
t.Fatalf("local control %s exported with wisp_plane=%s (present=%v), want true", control, rec.plane(), ok)
}
wantExportMemories(t, "the local re-export", readExportMemories(t, back), memories)
if rec, ok := gotBack[noHistory]; !ok {
t.Errorf("the local re-export is missing the imported %s", noHistory)
} else if !rec.NoHistory || rec.plane() != "absent" {
t.Errorf("imported %s re-exported as no_history=%v wisp_plane=%s, want no_history on the durable plane (no marker)", noHistory, rec.NoHistory, rec.plane())
}
}

View file

@ -0,0 +1,315 @@
//go:build cgo
package bdhttp_test
import (
"encoding/json"
"fmt"
"net/http"
"os"
"path/filepath"
"slices"
"strings"
"sync"
"testing"
"time"
)
// gateTokens are the two behavior tokens the gate commands depend on:
// issues.create.gates for a create carrying gate members (bd gate create),
// issues.update.gates for an await_id or waiters patch (bd gate add-waiter,
// bd gate discover, gate check's gh:run persist, bd update --await-id).
var gateTokens = []string{"issues.create.gates", "issues.update.gates"}
// withoutGateTokens rewrites the handshake into a server that predates the
// gate members: the live capability list minus the two gate tokens.
func withoutGateTokens(body map[string]any) {
caps, _ := body["capabilities"].([]any)
kept := make([]any, 0, len(caps))
for _, c := range caps {
if s, _ := c.(string); slices.Contains(gateTokens, s) {
continue
}
kept = append(kept, c)
}
body["capabilities"] = kept
}
// gateShow is the subset of `bd show --json` the gate cases read.
type gateShow struct {
ID string `json:"id"`
Status string `json:"status"`
IssueType string `json:"issue_type"`
AwaitType string `json:"await_type"`
AwaitID string `json:"await_id"`
Timeout int64 `json:"timeout"`
Waiters []string `json:"waiters"`
}
func showGate(t *testing.T, f *remoteRolesFixture, id string) gateShow {
t.Helper()
out := strings.TrimSpace(f.mustRun(nil, "show", id, "--json").stdout)
var rows []gateShow
if err := json.Unmarshal([]byte(out), &rows); err != nil {
var one gateShow
if err1 := json.Unmarshal([]byte(out), &one); err1 != nil {
t.Fatalf("parse bd show --json: %v\n%s", err, out)
}
return one
}
if len(rows) == 0 {
t.Fatalf("bd show %s --json returned no row", id)
}
return rows[0]
}
func readyIDs(t *testing.T, f *remoteRolesFixture) map[string]bool {
t.Helper()
ids := map[string]bool{}
for _, row := range jsonRows(t, f.mustRun(nil, "ready", "--json", "--limit", "0").stdout) {
if id, ok := row["id"].(string); ok {
ids[id] = true
}
}
return ids
}
func writesOf(paths []string) []string {
var writes []string
for _, p := range paths {
if !strings.HasPrefix(p, http.MethodGet+" ") {
writes = append(writes, p)
}
}
return writes
}
// TestE2E_GatesOverHTTP runs the gate commands through the real `bd` binary
// against an in-process `bd serve`.
//
// Against a server that advertises the gate tokens:
// - `bd gate create` is ONE createIssue carrying the gate members and the
// blocks edge (timer, gh:run and bead gates), and the blocked issue
// leaves the ready set;
// - `bd gate check --type=timer` closes an expired timer gate and the
// blocked issue becomes ready;
// - `bd gate add-waiter` registers a waiter once (the repeat writes nothing);
// - `bd update --await-id` sets await_id.
//
// Against a server that does not advertise them, each command is refused
// before any write, naming the token it needs, and nothing changes.
func TestE2E_GatesOverHTTP(t *testing.T) {
skipUnlessEmbeddedDolt(t)
bin := buildBD(t)
addr := startE2EServer(t)
proxyAddr, counter := startCountingProxy(t, addr)
f := newHTTPFixture(t, bin, proxyAddr)
var waiterGate string
t.Run("advertised", func(t *testing.T) {
timerTarget := f.create("timer target")
counter.reset()
created := f.mustRun(nil, "gate", "create", "--type=timer", "--timeout=1ns", "--blocks", timerTarget, "--json")
if w := writesOf(counter.snapshot()); !slices.Equal(w, []string{"POST /v0/beads/issues"}) {
t.Errorf("gate create wrote %v, want exactly one createIssue", w)
}
timerGate := firstJSONField(t, created.stdout, "id")
if g := showGate(t, f, timerGate); g.IssueType != "gate" || g.AwaitType != "timer" || g.Timeout != 1 || g.Status != "open" {
t.Errorf("timer gate reads back %+v, want an open timer gate with a 1ns timeout", g)
}
if readyIDs(t, f)[timerTarget] {
t.Errorf("%s is ready while its gate is open", timerTarget)
}
time.Sleep(10 * time.Millisecond)
r := f.mustRun(nil, "gate", "check", "--type=timer", "--escalate")
if !strings.Contains(r.stdout, "1 resolved") {
t.Errorf("gate check --type=timer = %q, want one resolved gate", r.stdout)
}
if g := showGate(t, f, timerGate); g.Status != "closed" {
t.Errorf("expired timer gate %s is %s after gate check, want closed", timerGate, g.Status)
}
if !readyIDs(t, f)[timerTarget] {
t.Errorf("%s is not ready after its timer gate resolved", timerTarget)
}
runTarget := f.create("run target")
runGate := firstJSONField(t, f.mustRun(nil, "gate", "create", "--type=gh:run", "--await-id=ci-wf", "--repo=owner/repo", "--blocks", runTarget, "--json").stdout, "id")
if g := showGate(t, f, runGate); g.AwaitType != "gh:run" || g.AwaitID != "ci-wf" {
t.Errorf("gh:run gate reads back %+v, want await gh:run ci-wf", g)
}
awaited := f.create("awaited bead")
beadTarget := f.create("bead target")
beadGate := firstJSONField(t, f.mustRun(nil, "gate", "create", "--type=bead", "--await-id", awaited, "--blocks", beadTarget, "--json").stdout, "id")
if g := showGate(t, f, beadGate); g.AwaitType != "bead" || g.AwaitID != awaited {
t.Errorf("bead gate reads back %+v, want await bead %s", g, awaited)
}
waiterGate = beadGate
counter.reset()
r = f.mustRun(nil, "gate", "add-waiter", beadGate, "rig/workers/a")
if !strings.Contains(r.stdout, "Added waiter to gate "+beadGate+": rig/workers/a") {
t.Errorf("add-waiter output = %q", r.stdout)
}
if w := writesOf(counter.snapshot()); len(w) != 1 || !strings.HasPrefix(w[0], "PATCH /v0/beads/issues/") {
t.Errorf("add-waiter wrote %v, want one updateIssue", w)
}
counter.reset()
r = f.mustRun(nil, "gate", "add-waiter", beadGate, "rig/workers/a")
if !strings.Contains(r.stdout, "Waiter already registered on gate "+beadGate) {
t.Errorf("repeat add-waiter output = %q", r.stdout)
}
if w := writesOf(counter.snapshot()); len(w) != 0 {
t.Errorf("a repeat add-waiter wrote %v", w)
}
f.mustRun(nil, "gate", "add-waiter", beadGate, "rig/workers/b")
if g := showGate(t, f, beadGate); !slices.Equal(g.Waiters, []string{"rig/workers/a", "rig/workers/b"}) {
t.Errorf("waiters = %v, want [rig/workers/a rig/workers/b]", g.Waiters)
}
f.mustRun(nil, "update", runGate, "--await-id", "12345", "--json")
if g := showGate(t, f, runGate); g.AwaitID != "12345" {
t.Errorf("await_id after update --await-id = %q, want 12345", g.AwaitID)
}
})
// A convoy registering on one gate at once: every adder must exit 0 and
// every waiter must be on the gate. Each round of simultaneous guarded
// writes has one winner, so this pins the retry backoff, not just the
// compare-and-set.
t.Run("concurrent add-waiter", func(t *testing.T) {
const adders = 10
target := f.create("convoy target")
gate := firstJSONField(t, f.mustRun(nil, "gate", "create", "--blocks", target, "--json").stdout, "id")
results := make([]bdResult, adders+1)
var wg sync.WaitGroup
start := make(chan struct{})
for i := 0; i <= adders; i++ {
waiter := fmt.Sprintf("rig/workers/c%d", i%adders) // the last one repeats c0
wg.Add(1)
go func(i int) {
defer wg.Done()
<-start
results[i] = f.run(nil, "gate", "add-waiter", gate, waiter)
}(i)
}
close(start)
wg.Wait()
for i, r := range results {
if r.code != 0 {
t.Errorf("adder %d exited %d: %s", i, r.code, r.stderr)
}
}
got := showGate(t, f, gate).Waiters
slices.Sort(got)
var want []string
for i := 0; i < adders; i++ {
want = append(want, fmt.Sprintf("rig/workers/c%d", i))
}
slices.Sort(want)
if !slices.Equal(got, want) {
t.Errorf("waiters after %d concurrent adders = %v, want each exactly once: %v", adders+1, got, want)
}
})
// gate discover over HTTP: a fake gh answers the run listing, and the
// discovered run ID is recorded through updateIssue (issues.update.gates).
binDir := t.TempDir()
gh := `#!/bin/sh
case "$1 $2" in
"run list") echo '[{"databaseId":4242,"name":"ci-wf","status":"in_progress","conclusion":"","createdAt":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'","workflowName":"ci-wf","headBranch":"main"}]' ;;
*) echo "unexpected gh $*" >&2; exit 3 ;;
esac
`
if err := os.WriteFile(filepath.Join(binDir, "gh"), []byte(gh), 0o755); err != nil {
t.Fatalf("write fake gh: %v", err)
}
ghEnv := []string{"PATH=" + binDir + string(os.PathListSeparator) + os.Getenv("PATH")}
t.Run("discover", func(t *testing.T) {
target := f.create("discover target")
gate := firstJSONField(t, f.mustRun(nil, "gate", "create", "--type=gh:run", "--await-id=ci-wf", "--blocks", target, "--json").stdout, "id")
counter.reset()
r := f.run(ghEnv, "gate", "discover")
if r.code != 0 {
t.Fatalf("gate discover exited %d: %s %s", r.code, r.stdout, r.stderr)
}
if !strings.Contains(r.stdout, "Updated 1 gate(s)") {
t.Errorf("gate discover output = %q, want one updated gate", r.stdout)
}
if w := writesOf(counter.snapshot()); len(w) != 1 || !strings.HasPrefix(w[0], "PATCH /v0/beads/issues/") {
t.Errorf("gate discover wrote %v, want one updateIssue", w)
}
if g := showGate(t, f, gate); g.AwaitID != "4242" {
t.Errorf("await_id after discover = %q, want 4242", g.AwaitID)
}
})
t.Run("refused without the tokens", func(t *testing.T) {
if waiterGate == "" {
t.Skip("the advertised case created no gate")
}
maskedAddr, maskedCounter := startMaskingProxy(t, addr, withoutGateTokens)
m := newHTTPFixture(t, bin, maskedAddr)
target := m.create("masked target")
before := showGate(t, f, waiterGate)
cases := []struct {
name string
args []string
token string
}{
{"gate create", []string{"gate", "create", "--type=timer", "--timeout=1h", "--blocks", target}, "issues.create.gates"},
{"gate create human", []string{"gate", "create", "--blocks", target}, "issues.create.gates"},
{"gate add-waiter", []string{"gate", "add-waiter", waiterGate, "rig/workers/c"}, "issues.update.gates"},
{"update --await-id", []string{"update", waiterGate, "--await-id", "999"}, "issues.update.gates"},
}
for _, tc := range cases {
maskedCounter.reset()
r := m.run(nil, tc.args...)
if r.code == 0 {
t.Errorf("%s against a server without %s exited 0: %s", tc.name, tc.token, r.stdout)
}
if !strings.Contains(r.stderr, tc.token) {
t.Errorf("%s refusal does not name %s: %s", tc.name, tc.token, r.stderr)
}
if w := writesOf(maskedCounter.snapshot()); len(w) != 0 {
t.Errorf("a refused %s wrote %v; the refusal must come before any write", tc.name, w)
}
}
// gate discover finds the run but cannot record it: the gate's error
// names the token, nothing is written, and the command fails rather
// than reporting the gate as updated.
runTarget := f.create("masked discover target")
runGate := firstJSONField(t, f.mustRun(nil, "gate", "create", "--type=gh:run", "--await-id=ci-wf", "--blocks", runTarget, "--json").stdout, "id")
maskedCounter.reset()
r := m.run(ghEnv, "gate", "discover")
if r.code == 0 {
t.Errorf("gate discover against a server without issues.update.gates exited 0: %s", r.stdout)
}
if !strings.Contains(r.stderr, "issues.update.gates") || !strings.Contains(r.stderr, runGate) {
t.Errorf("gate discover refusal does not name the gate and issues.update.gates: %s", r.stderr)
}
if strings.Contains(r.stdout, "Updated 1") {
t.Errorf("gate discover reported the refused gate as updated: %s", r.stdout)
}
if w := writesOf(maskedCounter.snapshot()); len(w) != 0 {
t.Errorf("a refused gate discover wrote %v", w)
}
if g := showGate(t, f, runGate); g.AwaitID != "ci-wf" {
t.Errorf("await_id after a refused discover = %q, want ci-wf untouched", g.AwaitID)
}
if !readyIDs(t, m)[target] {
t.Errorf("%s left the ready set though every gate create was refused", target)
}
after := showGate(t, f, waiterGate)
if after.AwaitID != before.AwaitID || !slices.Equal(after.Waiters, before.Waiters) {
t.Errorf("refused writes changed the gate: before %+v after %+v", before, after)
}
})
}

View file

@ -0,0 +1,185 @@
//go:build cgo
package bdhttp_test
import (
"context"
"encoding/json"
"strings"
"testing"
"time"
"github.com/steveyegge/beads/internal/storage/issueops"
)
// TestE2E_HeartbeatOverHTTP runs `bd heartbeat <id>` — the keepalive gc's
// mol-do-work formula issues every ~90s (`gc bd heartbeat`, corpus shapes
// gc-heartbeat*) — through the real `bd` binary against an in-process `bd
// serve`.
//
// The CLI takes the store's Heartbeater, which over HTTP dials POST
// /v0/beads/issues/{id}:heartbeat. What a worker relies on is pinned here end
// to end: exit 0 and the {"id","status":"heartbeat","owner"} shape for the
// holder, with the row's revision and updated_at UNCHANGED (the heartbeat
// writes only the lease, so the holder's guarded writes keep their token);
// exit 1 for a foreign holder (whose lease stays untouched), a closed issue, a
// wisp and an unclaimed issue, each saying which. Against a server that does
// not advertise issues.heartbeat (an older server's handshake shape) the
// client refuses BEFORE the dial, naming the token, and never falls back.
func TestE2E_HeartbeatOverHTTP(t *testing.T) {
skipUnlessEmbeddedDolt(t)
bin := buildBD(t)
addr, reference := startE2EServerWithStore(t, e2eProjectID, e2eDatabase)
leaseRow := func(id string) string {
t.Helper()
var row string
if err := reference.RunEventsMaintenanceTx(context.Background(), func(ctx context.Context, tx issueops.DBTX) error {
return tx.QueryRowContext(ctx,
"SELECT CONCAT(holder, '|', CAST(lease_expires_at AS CHAR), '|', CAST(heartbeat_at AS CHAR)) FROM leases WHERE issue_id = ?", id,
).Scan(&row)
}); err != nil {
t.Fatalf("read the lease row on %s: %v", id, err)
}
return row
}
ageLease := func(id string) {
t.Helper()
aged := time.Now().UTC().Add(-time.Minute).Truncate(time.Second)
if err := reference.RunEventsMaintenanceTx(context.Background(), func(ctx context.Context, tx issueops.DBTX) error {
_, err := tx.ExecContext(ctx, "UPDATE leases SET lease_expires_at = ?, heartbeat_at = ? WHERE issue_id = ?", aged, aged, id)
return err
}); err != nil {
t.Fatalf("age the lease on %s: %v", id, err)
}
}
heartbeatPosts := func(paths []string) int {
n := 0
for _, p := range paths {
if strings.HasPrefix(p, "POST ") && strings.HasSuffix(p, ":heartbeat") {
n++
}
}
return n
}
t.Run("advertised", func(t *testing.T) {
proxyAddr, counter := startCountingProxy(t, addr)
f := newHTTPFixture(t, bin, proxyAddr)
id := f.create("heartbeat target")
f.mustRun(nil, "update", id, "--claim", "--actor", "worker-7")
before := f.mustRun(nil, "show", id, "--json").stdout
revision := firstJSONField(t, before, "revision")
if revision == "" {
t.Fatalf("bd show --json reported no revision: %s", before)
}
updatedAt := firstJSONField(t, before, "updated_at")
counter.reset()
r := f.mustRun(nil, "heartbeat", id, "--actor", "worker-7", "--json")
var out map[string]any
if err := json.Unmarshal([]byte(strings.TrimSpace(r.stdout)), &out); err != nil {
t.Fatalf("parse bd heartbeat --json: %v\n%s", err, r.stdout)
}
if out["id"] != id || out["status"] != "heartbeat" || out["owner"] != "worker-7" {
t.Errorf("bd heartbeat --json = %v, want {id: %s, status: heartbeat, owner: worker-7}", out, id)
}
if n := heartbeatPosts(counter.snapshot()); n != 1 {
t.Errorf("bd heartbeat sent %d :heartbeat requests, want exactly one: %v", n, counter.snapshot())
}
for _, p := range counter.snapshot() {
if strings.HasPrefix(p, "PATCH ") || (strings.HasPrefix(p, "POST ") && !strings.HasSuffix(p, ":heartbeat")) {
t.Errorf("bd heartbeat sent %s; a heartbeat writes nothing but the lease", p)
}
}
after := f.mustRun(nil, "show", id, "--json").stdout
if got := firstJSONField(t, after, "revision"); got != revision {
t.Errorf("revision moved across a heartbeat: %s -> %s; a guarded write against the pre-heartbeat token would now fail", revision, got)
}
if got := firstJSONField(t, after, "updated_at"); got != updatedAt {
t.Errorf("updated_at moved across a heartbeat: %s -> %s", updatedAt, got)
}
// The holder's guarded write with the pre-heartbeat token still lands.
f.mustRun(nil, "update", id, "--notes", "still mine", "--if-revision", revision, "--actor", "worker-7")
// A second heartbeat is fine: it only moves the expiry later.
f.mustRun(nil, "heartbeat", id, "--actor", "worker-7")
})
t.Run("refusals", func(t *testing.T) {
f := newHTTPFixture(t, bin, addr)
foreign := f.create("held by alice")
f.mustRun(nil, "update", foreign, "--claim", "--actor", "alice")
// Aged first, so a heartbeat that ignored the holder fence would
// really change the row rather than rewrite the claim's own second.
ageLease(foreign)
held := leaseRow(foreign)
r := f.run(nil, "heartbeat", foreign, "--actor", "bob")
if r.code != 1 || !strings.Contains(r.stderr, "claimed by alice") {
t.Errorf("heartbeat by a non-holder: exit %d stderr=%s, want exit 1 naming the holder", r.code, r.stderr)
}
if got := leaseRow(foreign); got != held {
t.Errorf("a refused heartbeat by a non-holder moved alice's lease: %s -> %s", held, got)
}
// Each lease_not_held names the one state it found, and no other.
says := func(what, stderr, want string, not ...string) {
t.Helper()
if !strings.Contains(stderr, want) {
t.Errorf("heartbeat on %s: stderr=%s, want it to say %q", what, stderr, want)
}
for _, n := range not {
if strings.Contains(stderr, n) {
t.Errorf("heartbeat on %s: stderr=%s says %q, which is not the state it found", what, stderr, n)
}
}
}
closed := f.create("closed under its worker")
f.mustRun(nil, "update", closed, "--claim", "--actor", "worker-7")
f.mustRun(nil, "close", closed, "--actor", "worker-7")
r = f.run(nil, "heartbeat", closed, "--actor", "worker-7")
if r.code != 1 {
t.Errorf("heartbeat on a closed issue exited %d, want 1: %s", r.code, r.stderr)
}
says("a closed issue", r.stderr, "is closed", "ephemeral", "not claimed")
wisp := f.create("a wisp is never leased", "--ephemeral")
r = f.run(nil, "heartbeat", wisp, "--actor", "worker-7")
if r.code != 1 {
t.Errorf("heartbeat on a wisp exited %d, want 1: %s", r.code, r.stderr)
}
says("a wisp", r.stderr, "ephemeral wisp", "closed", "not claimed")
unclaimed := f.create("never claimed")
r = f.run(nil, "heartbeat", unclaimed, "--actor", "worker-7")
if r.code != 1 {
t.Errorf("heartbeat on an unclaimed issue exited %d, want 1: %s", r.code, r.stderr)
}
says("an unclaimed issue", r.stderr, "not claimed", "closed", "ephemeral")
})
t.Run("older server mask", func(t *testing.T) {
proxyAddr, counter := startMaskingProxy(t, addr, mcContextMask)
f := newHTTPFixture(t, bin, proxyAddr)
id := f.create("an old server cannot refresh this lease")
f.mustRun(nil, "update", id, "--claim", "--actor", "worker-7")
counter.reset()
r := f.run(nil, "heartbeat", id, "--actor", "worker-7")
if r.code != 1 {
t.Fatalf("bd heartbeat against a server without issues.heartbeat exited %d, want 1: %s", r.code, r.stdout)
}
if !strings.Contains(r.stderr, "issues.heartbeat") {
t.Errorf("refusal does not name the missing capability: %s", r.stderr)
}
for _, p := range counter.snapshot() {
if !strings.HasPrefix(p, "GET ") {
t.Errorf("a refused heartbeat sent %s; the refusal must come before any write", p)
}
}
})
}

Some files were not shown because too many files have changed in this diff Show more