diff --git a/.bazelrc b/.bazelrc index 0ac5774bf..63d000368 100644 --- a/.bazelrc +++ b/.bazelrc @@ -104,17 +104,6 @@ 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: what pr.yml's retired container-backed jobs ("Test # (storage domain + uow)" and "Contract corpus") ran, but every dolt @@ -138,9 +127,6 @@ test:doltserver --test_arg=-test.parallel=4 # 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 and //cmd/bd:bd_managed_local_test (the @@ -174,40 +160,6 @@ 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 @@ -235,21 +187,6 @@ 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"): @@ -280,68 +217,13 @@ 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. 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. +# goroutine to test.log, which Bazel's kill at 1200s does not. +test:doltserver-cmd --test_arg=-test.timeout=19m 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 - -# 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 @@ -386,13 +268,6 @@ 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 @@ -419,15 +294,11 @@ 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. +# .golangci.yml enables) runs beside every Go compile of every lane, so any +# `bazel build`/`bazel test` fails on a finding. --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 diff --git a/.bazelversion b/.bazelversion index b13d146a7..deeb3d66e 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -9.3.0 +9.2.0 diff --git a/.claude/skills/beads-docs/SKILL.md b/.claude/skills/beads-docs/SKILL.md index a5454d2ea..52bab8362 100644 --- a/.claude/skills/beads-docs/SKILL.md +++ b/.claude/skills/beads-docs/SKILL.md @@ -201,8 +201,7 @@ 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: `bazel test //test/docsync:docsync_test --config=ci` -(nav↔file sync + link conventions), +The short list: `go test ./test/docsync` (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`. diff --git a/.claude/skills/beads-docs/references/simplification.md b/.claude/skills/beads-docs/references/simplification.md index 916834ca5..5152fd2b5 100644 --- a/.claude/skills/beads-docs/references/simplification.md +++ b/.claude/skills/beads-docs/references/simplification.md @@ -39,9 +39,8 @@ 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:** `bazel test //test/docsync:docsync_test --config=ci`, every - fence parses, no body H1, no HTML comments (MDX), preview with - `make docs-dev`. +6. **Gates:** `go test ./test/docsync`, 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. diff --git a/.claude/skills/beads-docs/references/verification.md b/.claude/skills/beads-docs/references/verification.md index 44aabca76..559bfb6f3 100644 --- a/.claude/skills/beads-docs/references/verification.md +++ b/.claude/skills/beads-docs/references/verification.md @@ -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). -bazel test //test/docsync:docsync_test --config=ci +go test ./test/docsync # 2. Generated CLI docs freshness: regenerates from the live command tree # and diffs docs/CLI_REFERENCE.md, docs/cli-reference/, and the CLI diff --git a/.githooks/pre-push b/.githooks/pre-push index 4a20fb57d..fc57efb0b 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -61,15 +61,12 @@ fi # `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 ;; +while read -r local_ref local_sha _remote_ref remote_sha; do + case "$local_ref" in + refs/heads/*) ;; + *) continue ;; esac if [ "$local_sha" = "$zero_sha" ] || ! git cat-file -e "$local_sha^{commit}" 2>/dev/null; then continue diff --git a/.github/actions/setup-bazel/action.yml b/.github/actions/setup-bazel/action.yml index 497ad56ce..8bb03ddd1 100644 --- a/.github/actions/setup-bazel/action.yml +++ b/.github/actions/setup-bazel/action.yml @@ -8,9 +8,7 @@ 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), 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 + the read-only fork cache (--config=fork-cache); 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 @@ -78,8 +76,6 @@ 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 { diff --git a/.github/actions/setup-bazel/cache-rrc-probe.sh b/.github/actions/setup-bazel/cache-rrc-probe.sh deleted file mode 100644 index 1dc60a233..000000000 --- a/.github/actions/setup-bazel/cache-rrc-probe.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/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//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 diff --git a/.github/actions/setup-bazel/write-bazelrc.sh b/.github/actions/setup-bazel/write-bazelrc.sh index 15671cd37..5dca6562f 100644 --- a/.github/actions/setup-bazel/write-bazelrc.sh +++ b/.github/actions/setup-bazel/write-bazelrc.sh @@ -32,13 +32,7 @@ # 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. 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. +# and Bazel refuses a remote that does not. # # 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 @@ -100,7 +94,6 @@ 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:-}" @@ -123,13 +116,6 @@ 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 @@ -241,38 +227,14 @@ 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 probes never fail - # this script; they only decide the lines. + # transport only, so action keys are unchanged. The probe never fails + # this script; it only decides the line. { 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" diff --git a/.github/scripts/embedded-cmd-test-shards.txt b/.github/scripts/embedded-cmd-test-shards.txt index 21e6f181d..6b4d1dfd0 100644 --- a/.github/scripts/embedded-cmd-test-shards.txt +++ b/.github/scripts/embedded-cmd-test-shards.txt @@ -1,17 +1,199 @@ +# Embedded cmd test shard manifest. +# +# Format: +# +# 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: # -# 100-shard split for the Bazel-only embedded-Dolt cmd tier +# 50-shard split for the Bazel-only embedded-Dolt cmd tier # (bazel-embedded in .github/workflows/bazel.yml), bin-packed -# longest-first by measured wall-time from +# longest-processing-time-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) 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 +# and its "relative weight, not absolute SLA" caveat). +# Regenerate with scripts/ci/gen_embedded_cmd_shard_manifest.py 50 # --weights=duration --write after adding, splitting or removing -# TestEmbedded* functions in cmd/bd/*_test.go. --write is +# TestEmbedded* functions in cmd/bd/*_embedded_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 @@ -24,522 +206,298 @@ # This file is generated: notes added here are erased by the next # regeneration. Add them to the generator or the durations file instead. -100 1 TestEmbeddedUpdateConcurrent - -100 2 TestEmbeddedShowConcurrent - -100 3 TestEmbeddedCloseConcurrent - -100 4 TestEmbeddedEpicConcurrent - -100 5 TestEmbeddedConfigConcurrent - -100 6 TestEmbeddedListFilteringBasicAndLabels - -100 7 TestEmbeddedDepConcurrent - -100 8 TestEmbeddedMaxRowsListLimitInteraction - -100 9 TestEmbeddedChildrenConcurrent - -100 10 TestEmbeddedCreateScalarAndRelationships - -100 11 TestEmbeddedKVConcurrent - -100 12 TestEmbeddedGatedRendering - -100 13 TestEmbeddedListFilteringStatusAndHierarchy - -100 14 TestEmbeddedReopenConcurrent - -100 15 TestEmbeddedPurgeWispsPlaneRetention - -100 16 TestEmbeddedMemoryConcurrent - -100 17 TestEmbeddedReopen - -100 18 TestEmbeddedLabelPropagateRename -100 18 TestEmbeddedPrune_protectsBeadCitedByCustomStatusBead - -100 19 TestEmbeddedLabelConcurrent -100 19 TestEmbeddedNewDoltStore_StrictReadOnlyRefusesWritesOnFreshDatabase - -100 20 TestEmbeddedInitRoleRoutingRetainedFork -100 20 TestEmbeddedMigrateSchema_IdentityMismatchRefusesBeforeApplying - -100 21 TestEmbeddedMaxRowsReady -100 21 TestEmbeddedMigratePersonal_movesIssues - -100 22 TestEmbeddedCount -100 22 TestEmbeddedIfRevisionCloseReplaysMoleculeAutoClose - -100 23 TestEmbeddedCountConcurrent -100 23 TestEmbeddedExportExcludeOwner_flag - -100 24 TestEmbeddedEventsTailFollowReportsTruncationOnTheStream -100 24 TestEmbeddedUndeferConcurrent -100 24 TestEmbeddedWispGCProtectsActiveWisps - -100 25 TestEmbeddedDoltRemoteAdd_LocalOnly_FiresBeforeGuard -100 25 TestEmbeddedMaxRowsListBasic -100 25 TestEmbeddedRemovedBackendHealRejectionPerBackend - -100 26 TestEmbeddedDoltRemoteAdd_JSON_AllowGitOrigin_WarningOnStderr -100 26 TestEmbeddedExternalMutationPolicy -100 26 TestEmbeddedPersistentPreRunLogsAndSkipsIdentityCheckForFreshEmbeddedWorkspace - -100 27 TestEmbeddedDoltRemoteAdd_GitOriginCollision_RefusalMessageCopy -100 27 TestEmbeddedNewDoltStoreFromConfig_DottedDBName -100 27 TestEmbeddedShipConcurrent - -100 28 TestEmbeddedDoltLocalOnly_RemoteAdd_RefusesExitOne -100 28 TestEmbeddedHistoryConcurrent -100 28 TestEmbeddedImportChunkedRealStoreResumeConverges - -100 29 TestEmbeddedDoltLocalOnly_RemoteAdd_ErrorOnStderr -100 29 TestEmbeddedEpicCloseEligibleReasonFlag -100 29 TestEmbeddedImportChunkedNoReadyWindowWithReadinessEdgeIntoCycle - -100 30 TestEmbeddedCloseGuardsAndEpics -100 30 TestEmbeddedDoltLocalOnly_Push_ExitsZeroWithMessage -100 30 TestEmbeddedImportChunkedCrossBucketBlocksEdgesResumeBackfills - -100 31 TestEmbeddedDoltLocalOnly_ConfigRoundTrip -100 31 TestEmbeddedIfRevisionCloseWarnsOnForcedOpenChildren -100 31 TestEmbeddedInitSelectedExcludeRoutingForkInvalidQuiet - -100 32 TestEmbeddedDoctorUnsupportedJSON -100 32 TestEmbeddedIfRevisionAdvertisedOnFourVerbs -100 32 TestEmbeddedListSearchAndOutputFormats - -100 33 TestEmbeddedBootstrapJSONLAndGitOrigin -100 33 TestEmbeddedDeleteJournalsTheRequestingActor -100 33 TestEmbeddedExportExcludeOwner_verbose - -100 34 TestEmbeddedCopyIssueRelations_preservesCommentWithTimestamp -100 34 TestEmbeddedEventsTailReportsTruncationToTheCLI -100 34 TestEmbeddedUnclaimBatchAndRefusals -100 34 TestEmbeddedWispGCPurgeClosedDoesNotCascadeIntoLiveSteps - -100 35 TestEmbeddedAutoPruneRespectsBdConfigSet -100 35 TestEmbeddedEventsReadNoticesADisabledJournal -100 35 TestEmbeddedGateCreateBeadRename -100 35 TestEmbeddedVersionedHistoryEnvIsProcessWideAndOnlyTurnsRecordingOn - -100 36 TestEmbeddedAutoPruneLeavesAnUnboundedJournalAlone -100 36 TestEmbeddedDoltRemoteResetData_UnknownRemote -100 36 TestEmbeddedGateConcurrent -100 36 TestEmbeddedUnclaimIfAssigneeCLIDifferentSpelling - -100 37 TestEmbeddedAutoPruneBoundsTheJournalAfterAMutatingCommand -100 37 TestEmbeddedDoltRemoteResetData_CloudRemoteRefused -100 37 TestEmbeddedMaxRowsDepTreeAndDuplicates -100 37 TestEmbeddedSpawnMolecule_SubstitutesTemplatedStepFields - -100 38 TestEmbeddedGraphConcurrent -100 38 TestEmbeddedRoutedCreateJournalsIntoTheTargetWorkspace -100 38 TestEmbeddedUnclaimIfAssigneeFlagValidation - -100 39 TestEmbeddedIfRevisionRejectsLabelAndParentEdits -100 39 TestEmbeddedMaxRowsGraph -100 39 TestEmbeddedNewDoltStoreFromConfig_NoMetadata - -100 40 TestEmbeddedIfRevisionOutranksReassignFenceCLI -100 40 TestEmbeddedNewDoltStoreFromConfig_HyphenatedDBName -100 40 TestEmbeddedUpdateLifecycleClaimParentCommit - -100 41 TestEmbeddedDuplicateConcurrent -100 41 TestEmbeddedVersionedHistoryFollowsTheStoreItWritesInto - -100 42 TestEmbeddedInitAForkAutoContributor -100 42 TestEmbeddedUpdateIfGuardsFlagValidation - -100 43 TestEmbeddedIfRevisionMultiIDRejected -100 43 TestEmbeddedInitExplicitBeadsDirIsAuthoritative - -100 44 TestEmbeddedIfRevisionComposesWithIfAssigneeIfStatus -100 44 TestEmbeddedStaleConcurrent - -100 45 TestEmbeddedGraph -100 45 TestEmbeddedUpdateIfGuardsCLI - -100 46 TestEmbeddedCloseAlreadyClosedClaimNextAndMolecule -100 46 TestEmbeddedIfRevisionMatchAndMismatch - -100 47 TestEmbeddedListSearchAndOutputSearchAndSort -100 47 TestEmbeddedRevisionRemintMatrix - -100 48 TestEmbeddedDeferConcurrent -100 48 TestEmbeddedReassignFenceCLI - -100 49 TestEmbeddedBackupRestoreStrictReadonly -100 49 TestEmbeddedInitAPushConsentAndRemoteBootstrap -100 49 TestEmbeddedMigratePersonal_abortOnNoConfirm - -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 +50 1 TestEmbeddedCommentsCLI +50 1 TestEmbeddedDepAddWispSource +50 1 TestEmbeddedListFiltering +50 1 TestEmbeddedPrimeChangeDirDefaultTemplateMatchesTarget + +50 2 TestEmbeddedCreateRepoFromNonBeadsCwd +50 2 TestEmbeddedDeleteJSONDependencyErrorContract +50 2 TestEmbeddedDepBulkNoCycleCheckKeepsWholeGraphGate +50 2 TestEmbeddedHistoryConcurrent +50 2 TestEmbeddedInitA + +50 3 TestEmbeddedAdminCompactTier2Honesty +50 3 TestEmbeddedMaxRowsListLimitInteraction +50 3 TestEmbeddedOrphans +50 3 TestEmbeddedShowUnresolvableDeps +50 3 TestEmbeddedStale + +50 4 TestEmbeddedBootstrapConcurrent +50 4 TestEmbeddedDuplicatesConcurrent +50 4 TestEmbeddedInfo +50 4 TestEmbeddedMaxRowsDoctorAndConfig +50 4 TestEmbeddedRoutedSiblingWritesCommitTargetHead + +50 5 TestEmbeddedCreateScalarAndRelationships +50 5 TestEmbeddedDefer +50 5 TestEmbeddedDoltBlockedAndCommit +50 5 TestEmbeddedGCConcurrent +50 5 TestEmbeddedPromote + +50 6 TestEmbeddedCreateStorageClassConflicts +50 6 TestEmbeddedGC +50 6 TestEmbeddedGetDependencies +50 6 TestEmbeddedQuickConcurrent + +50 7 TestEmbeddedCreateCrossRepoDryRunWithParent +50 7 TestEmbeddedEpicStatus +50 7 TestEmbeddedGate +50 7 TestEmbeddedWhere + +50 8 TestEmbeddedChangeDirOverridesInheritedBeadsDir +50 8 TestEmbeddedMemoryConcurrent +50 8 TestEmbeddedUpdateConcurrent +50 8 TestEmbeddedVCConcurrent + +50 9 TestEmbeddedCloseAlreadyClosed +50 9 TestEmbeddedConfigConcurrent +50 9 TestEmbeddedExternalCapabilityReadyAfterShip +50 9 TestEmbeddedPrimeConcurrent + +50 10 TestEmbeddedDepB +50 10 TestEmbeddedHuman +50 10 TestEmbeddedInitExplicitBeadsDirIsAuthoritative +50 10 TestEmbeddedPromoteCLI + +50 11 TestEmbeddedBlockedConcurrent +50 11 TestEmbeddedDepA +50 11 TestEmbeddedMaxRowsDepTreeAndDuplicates +50 11 TestEmbeddedState + +50 12 TestEmbeddedDirectCommitPathsBatchAutoCommitDoesNotAdvanceHead +50 12 TestEmbeddedPrimeChangeDirPrimesTarget +50 12 TestEmbeddedPromoteCLIConcurrent +50 12 TestEmbeddedSearchConcurrent +50 12 TestEmbeddedTypes + +50 13 TestEmbeddedAutoImportJSONLNoExplicitCommit +50 13 TestEmbeddedDiff +50 13 TestEmbeddedDuplicates +50 13 TestEmbeddedShipConcurrent + +50 14 TestEmbeddedInitConcurrent +50 14 TestEmbeddedOrphansConcurrent +50 14 TestEmbeddedPrimeChangeDirRedirectNoticeFollowsTarget +50 14 TestEmbeddedRoutedMutatingSiblingDeleteClose +50 14 TestEmbeddedSwarm + +50 15 TestEmbeddedChildrenConcurrent +50 15 TestEmbeddedConfigValidateJSONNoWorkspaceWritesStdout +50 15 TestEmbeddedCreateDryRunCrossRepoDoesNotMigrateTarget +50 15 TestEmbeddedEpicCloseEligibleReasonFlag +50 15 TestEmbeddedExplicitHierarchicalParentEdges +50 15 TestEmbeddedIfRevisionReopenGuardDirect +50 15 TestEmbeddedVersionConcurrent + +50 16 TestEmbeddedBlockedLabelFilters +50 16 TestEmbeddedGCConditionalMatcherDecode +50 16 TestEmbeddedGateInheritsDownParentChain +50 16 TestEmbeddedKV +50 16 TestEmbeddedMaxRowsReady +50 16 TestEmbeddedMemoryCorpusBudget +50 16 TestEmbeddedOpen_EmptyDatabaseRejected +50 16 TestEmbeddedRestoreConcurrent +50 16 TestEmbeddedVCCommitVariantsAndMerge +50 16 TestEmbeddedVersion + +50 17 TestEmbeddedCloseGuardsAndEpics +50 17 TestEmbeddedCompact +50 17 TestEmbeddedGateConcurrent +50 17 TestEmbeddedListComments + +50 18 TestEmbeddedContext +50 18 TestEmbeddedContributorCreate +50 18 TestEmbeddedImportClosedChildWhoseParentWasDeleted +50 18 TestEmbeddedReopen +50 18 TestEmbeddedStateConcurrent + +50 19 TestEmbeddedAdminBlocked +50 19 TestEmbeddedCreateRepoRelativeExistingWorkspaceUnaffected +50 19 TestEmbeddedDoltConcurrent +50 19 TestEmbeddedMaxRowsListBasic +50 19 TestEmbeddedPruneSafetyAndScope + +50 20 TestEmbeddedCreateStorageClassBatchAndMisc +50 20 TestEmbeddedDepListSingleIDWarnsOnDroppedExternalEdge +50 20 TestEmbeddedKVConcurrent +50 20 TestEmbeddedSetup + +50 21 TestEmbeddedBackup +50 21 TestEmbeddedCreateCrossRepoUninit +50 21 TestEmbeddedDiffConcurrent +50 21 TestEmbeddedQuick +50 21 TestEmbeddedQuickstart + +50 22 TestEmbeddedAdminCompactReadOnlyAllowed +50 22 TestEmbeddedCreateRepoProxiedTargetError +50 22 TestEmbeddedDuplicateConcurrent +50 22 TestEmbeddedFlatten +50 22 TestEmbeddedTypesAgreeWithCreate + +50 23 TestEmbeddedExportConcurrent +50 23 TestEmbeddedHistory +50 23 TestEmbeddedMaxRowsGraph +50 23 TestEmbeddedSetupConcurrent +50 23 TestEmbeddedShip + +50 24 TestEmbeddedCloseBasic +50 24 TestEmbeddedImportUpsertAndPrefixSync +50 24 TestEmbeddedQuery +50 24 TestEmbeddedUpdateRoutedStoreCommitsTargetHead + +50 25 TestEmbeddedBackupConcurrent +50 25 TestEmbeddedCreateStorageClassBasic +50 25 TestEmbeddedFindDuplicatesConcurrent +50 25 TestEmbeddedInitGitBootstrapRouting +50 25 TestEmbeddedInitHooksRouting + +50 26 TestEmbeddedCreateCommitPending +50 26 TestEmbeddedInitC +50 26 TestEmbeddedRenamePrefixBasic +50 26 TestEmbeddedRoutedMutatingSiblingAssignTagDep +50 26 TestEmbeddedSupersedeConcurrent + +50 27 TestEmbeddedComments +50 27 TestEmbeddedMaxRowsReadyMerge +50 27 TestEmbeddedPrime +50 27 TestEmbeddedPruneDryRunAndFilters +50 27 TestEmbeddedReopenConcurrent + +50 28 TestEmbeddedConfigNoWorkspaceStoreFreeCommands +50 28 TestEmbeddedEpicCloseEligibleReasonOutput +50 28 TestEmbeddedMigrate +50 28 TestEmbeddedStatus +50 28 TestEmbeddedSwarmConcurrent + +50 29 TestEmbeddedClaimPools +50 29 TestEmbeddedCreateGraphAndBulk +50 29 TestEmbeddedCreateJSONEchoesSubSecondTimestamps +50 29 TestEmbeddedHumanConcurrent +50 29 TestEmbeddedInitSelectedExcludeRouting + +50 30 TestEmbeddedAutoImportFallback_ConflictSkip_EmptyDBImportsAll +50 30 TestEmbeddedDepConcurrent +50 30 TestEmbeddedExportFormats +50 30 TestEmbeddedReadyClaimConcurrent +50 30 TestEmbeddedStaleConcurrent + +50 31 TestEmbeddedAutoImportFallback_ConflictSkip_DoesNotClobber +50 31 TestEmbeddedAutoImportJSONLConcurrentWriter +50 31 TestEmbeddedDeferAutoWake +50 31 TestEmbeddedExternalMutationPolicy +50 31 TestEmbeddedShowConcurrent + +50 32 TestEmbeddedCreateCrossRepo +50 32 TestEmbeddedDuplicate +50 32 TestEmbeddedInitArtifactRouting +50 32 TestEmbeddedShowBasicsAndJSON +50 32 TestEmbeddedUpdateLifecycle + +50 33 TestEmbeddedCreateConcurrent +50 33 TestEmbeddedCreateRepoRelativeUninitRefused +50 33 TestEmbeddedEpicCloseEligible +50 33 TestEmbeddedSearch +50 33 TestEmbeddedTodo + +50 34 TestEmbeddedCreateDryRunRepoDoesNotInitializeTarget +50 34 TestEmbeddedGateListScoped +50 34 TestEmbeddedLintConcurrent +50 34 TestEmbeddedPurgeWispsPlaneRetention +50 34 TestEmbeddedReady + +50 35 TestEmbeddedCommentsCLIConcurrent +50 35 TestEmbeddedHooksConcurrent +50 35 TestEmbeddedLabelPropagateRename +50 35 TestEmbeddedListSearchAndOutput +50 35 TestEmbeddedSupersede + +50 36 TestEmbeddedDeferConcurrent +50 36 TestEmbeddedFederationPeers +50 36 TestEmbeddedFlattenConcurrent +50 36 TestEmbeddedStatusConcurrent +50 36 TestEmbeddedTodoConcurrent + +50 37 TestEmbeddedInfoSuppressGitHooks +50 37 TestEmbeddedInitB +50 37 TestEmbeddedQueryConcurrent +50 37 TestEmbeddedUndeferConcurrent +50 37 TestEmbeddedUpdateBatchAutoCommitDoesNotAdvanceHead + +50 38 TestEmbeddedBlocked +50 38 TestEmbeddedCreateCrossRepoWithParent +50 38 TestEmbeddedEpicConcurrent +50 38 TestEmbeddedHooks +50 38 TestEmbeddedUndefer + +50 39 TestEmbeddedBranchConcurrent +50 39 TestEmbeddedCountIncludeInfra +50 39 TestEmbeddedCreateWithGitRemote +50 39 TestEmbeddedDelete +50 39 TestEmbeddedUpdateFields + +50 40 TestEmbeddedCountConcurrent +50 40 TestEmbeddedCountIncludeEphemeral +50 40 TestEmbeddedCreateFormCommitsLabelOnlyCreate +50 40 TestEmbeddedLabelEditReports +50 40 TestEmbeddedPreviewDoesNotConsumeVersionMarker + +50 41 TestEmbeddedGateCreate +50 41 TestEmbeddedLabelAddRemove +50 41 TestEmbeddedLabelConcurrent +50 41 TestEmbeddedListConcurrent +50 41 TestEmbeddedTypesConcurrent + +50 42 TestEmbeddedImportFromSources +50 42 TestEmbeddedReadyConcurrent +50 42 TestEmbeddedRenamePrefixEdgeCases +50 42 TestEmbeddedRestore +50 42 TestEmbeddedSquashWispMoleculeClearsRootEphemeral + +50 43 TestEmbeddedFindDuplicates +50 43 TestEmbeddedGraph +50 43 TestEmbeddedImportPromotedWispRoundtrip +50 43 TestEmbeddedInfoConcurrent +50 43 TestEmbeddedQuickstartConcurrent + +50 44 TestEmbeddedDoltRemoteAndPush +50 44 TestEmbeddedGraphConcurrent +50 44 TestEmbeddedImportConcurrent +50 44 TestEmbeddedInitRoleRouting +50 44 TestEmbeddedWhereConcurrent + +50 45 TestEmbeddedChildren +50 45 TestEmbeddedCompactConcurrent +50 45 TestEmbeddedMigrateConcurrent +50 45 TestEmbeddedShowDetailAndCurrent +50 45 TestEmbeddedVCStatusAndCommit + +50 46 TestEmbeddedCompactMisdatedChild +50 46 TestEmbeddedCount +50 46 TestEmbeddedCreateDryRunDoesNotMigrate +50 46 TestEmbeddedFederationStatus +50 46 TestEmbeddedStaleLabelFilters + +50 47 TestEmbeddedBootstrap +50 47 TestEmbeddedBranch +50 47 TestEmbeddedContextConcurrent +50 47 TestEmbeddedLint +50 47 TestEmbeddedPurgeConcurrent + +50 48 TestEmbeddedCloseConcurrent +50 48 TestEmbeddedConfig +50 48 TestEmbeddedDepAndLinkBatchAutoCommitDoesNotAdvanceHead +50 48 TestEmbeddedOnboardConcurrent +50 48 TestEmbeddedQuietFlagSuppressesSuccessOutput + +50 49 TestEmbeddedDepNoCycleCheck +50 49 TestEmbeddedFederationConcurrent +50 49 TestEmbeddedMemory +50 49 TestEmbeddedOnboard +50 49 TestEmbeddedPurgeFiltered + +50 50 TestEmbeddedAutoImportJSONLSkipsNonEmpty +50 50 TestEmbeddedExportFlags +50 50 TestEmbeddedPurgeBasics +50 50 TestEmbeddedRenamePrefixConcurrent +50 50 TestEmbeddedUnclaim diff --git a/.github/scripts/embedded-storage-test-shards.txt b/.github/scripts/embedded-storage-test-shards.txt index c3f45aacb..9d033d94a 100644 --- a/.github/scripts/embedded-storage-test-shards.txt +++ b/.github/scripts/embedded-storage-test-shards.txt @@ -114,12 +114,12 @@ # # Format: # -# 40-shard split for the Bazel-only embedded-Dolt storage tier +# 15-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 40 +# Regenerate with scripts/ci/gen_embedded_storage_shard_manifest.py 15 # --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,475 +134,411 @@ # This file is generated: notes added here are erased by the next # regeneration. Add them to the generator or the durations file instead. -40 1 TestLifecycleCloseReopenContract +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 2 TestBatchApplyContract +15 2 TestActiveDatabaseSizeScopesToActiveEmbeddedDatabase +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 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 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 4 TestBlockedListerContract -40 4 TestCreateBatchFastPathsMatchPerRowSmallDepAdd_Embedded -40 4 TestEmbeddedIssueOperationsUpdateLabelPatchOrdering -40 4 TestEmbeddedReaderGetMissIsNotFoundAndBackendFailureDoesNotDecay -40 4 TestEmbeddedReaderListFilterFamiliesNarrowToTheirRows -40 4 TestMergeAndSettleWithStrategy_EmptyStrategyMatchesMergeAndSettle +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 TestPromoteClearsNoHistory +15 4 TestRemoteVerbPlainRemoteKeepsAmbientEnv +15 4 TestReopenIssue +15 4 TestWithPeerAuth +15 4 TestWithPeerAuth_EnvFallbackDoesNotObservePeerCredentials -40 5 TestEmbeddedClaimerRefusesIncompleteRequestsAndAnAbsentIDWithoutTouchingState -40 5 TestEmbeddedIssueOperationsCloseAndReopenAWisp -40 5 TestEmbeddedReaderListKeysetPositionResumesTheCreatedDescIDAscOrder -40 5 TestRecordVersionKeepsSubSecondChangeAt -40 5 TestWithPeerAuth +15 5 TestActiveDatabaseSizeFailsForMissingEmbeddedDatabase +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 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 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 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 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 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 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 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 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 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 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 TestReclaimRefusesForeignReplicaLease +15 10 TestRemoteEntryPointsUseVersionControlOps +15 10 TestTransactionCleanupBeforeSQLCommitRemainsDefinite +15 10 TestVersionReconcilerContract +15 10 TestWithPeerAuth_MissingRemoteFailsClosed -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 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 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 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 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 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 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 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 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 +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 diff --git a/.github/scripts/embedded-test-shard.sh b/.github/scripts/embedded-test-shard.sh index 3b7bdc7e2..a89757e69 100755 --- a/.github/scripts/embedded-test-shard.sh +++ b/.github/scripts/embedded-test-shard.sh @@ -3,7 +3,7 @@ # # Usage: embedded-test-shard.sh # -# Discovers all TestEmbedded* top-level functions in cmd/bd/*_test.go. +# Discovers all TestEmbedded* top-level functions from cmd/bd/*_embedded_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,12 +33,8 @@ fi SHARD_INDEX=$(( SHARD_NUMBER - 1 )) MANIFEST="${BEADS_TEST_SHARD_MANIFEST:-.github/scripts/embedded-cmd-test-shards.txt}" -# 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 \ +# Discover all top-level TestEmbedded* functions. +ALL_TESTS=$(grep -rh '^func TestEmbedded' cmd/bd/*_embedded_test.go \ | sed 's/func \(TestEmbedded[A-Za-z0-9_]*\).*/\1/' \ | sort -u) diff --git a/.github/scripts/proxied-cmd-test-shards.txt b/.github/scripts/proxied-cmd-test-shards.txt index fca167226..92b21b1d4 100644 --- a/.github/scripts/proxied-cmd-test-shards.txt +++ b/.github/scripts/proxied-cmd-test-shards.txt @@ -2,12 +2,233 @@ # # Format: # -# 34-shard split for the Bazel-only proxied-server tier +# 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: +# +# 30-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 34 +# Regenerate with scripts/ci/gen_proxied_shard_manifest.py 30 # --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 @@ -29,260 +250,215 @@ # regeneration. Add them to the generator or the durations file # instead. -34 1 TestProxiedServerDep2 -34 1 TestProxiedServerMolProgress -34 1 TestProxiedServerReadyClaimConcurrent -34 1 TestProxiedServerServeActivatesTheEventsJournal -34 1 TestProxiedServerServeRelease +30 1 TestProxiedServerGateList +30 1 TestProxiedServerHuman +30 1 TestProxiedServerReclaim +30 1 TestProxiedServerSQLStatementRouting +30 1 TestProxiedServerServeLifecycle -34 2 TestProxiedServerDepListSingleIDWarnsOnDroppedExternalEdge -34 2 TestProxiedServerGateList -34 2 TestProxiedServerList -34 2 TestProxiedServerServeRemoveDependency -34 2 TestProxiedServerUpdateC +30 2 TestProxiedServerDelete +30 2 TestProxiedServerDeleteForceOrphans +30 2 TestProxiedServerIfRevisionGuardAssign +30 2 TestProxiedServerListComments +30 2 TestProxiedServerPromote +30 2 TestProxiedServerTypesAgreeWithCreate -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 3 TestProxiedServerDuplicates +30 3 TestProxiedServerReadyWisp +30 3 TestProxiedServerServeDelete +30 3 TestProxiedServerServeModeGate +30 3 TestProxiedServerServeReadRevision -34 4 TestProxiedServerMolStale -34 4 TestProxiedServerReadyConcurrent -34 4 TestProxiedServerServeRelatedIssues -34 4 TestProxiedServerServeSettingsWrites -34 4 TestProxiedServerShow2 -34 4 TestServerModeServeSkipsPostRunMaintenance +30 4 TestProxiedServerGateCreateInheritsRepoMetadata +30 4 TestProxiedServerMolBurn +30 4 TestProxiedServerReadyConcurrent +30 4 TestProxiedServerServeAddDependencies +30 4 TestProxiedServerServeRelatedIssues -34 5 TestProxiedServerHistoryRemoteRefusalFrontDoorMatrix -34 5 TestProxiedServerInfo -34 5 TestProxiedServerNote -34 5 TestProxiedServerOutageReconnectAcceptanceMatrix -34 5 TestProxiedServerUpdate3 -34 5 TestServerModeDeferAutoWake +30 5 TestProxiedServerCleanDatabases +30 5 TestProxiedServerCreate +30 5 TestProxiedServerEventsJournal +30 5 TestProxiedServerPour +30 5 TestProxiedServerServeUpdateClaim +30 5 TestServerModeDeferAutoWake -34 6 TestProxiedServerPing -34 6 TestProxiedServerQuick -34 6 TestProxiedServerServeReadsTheJournalItJustWrote -34 6 TestProxiedServerSwarm -34 6 TestProxiedServerUpdate2B -34 6 TestProxiedServerVersionedHistorySwitchRefusesAnUnrecordableGateTimeout -34 6 TestProxiedServerWispList +30 6 TestProxiedServerBatchParity +30 6 TestProxiedServerHistoryRemoteSupportedFrontDoorParity +30 6 TestProxiedServerMolShow +30 6 TestProxiedServerMultiStatementSQL +30 6 TestProxiedServerReady +30 6 TestProxiedServerServeRemoveDependency -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 7 TestProxiedServerCleanDatabasesPurgeDropped +30 7 TestProxiedServerCount +30 7 TestProxiedServerCountIncludeInfra +30 7 TestProxiedServerDoltLifecycle +30 7 TestProxiedServerGC +30 7 TestProxiedServerUpdate -34 8 TestProxiedServerClose2 -34 8 TestProxiedServerDeleteWisp -34 8 TestProxiedServerExport -34 8 TestProxiedServerFindDuplicates -34 8 TestProxiedServerGateCheck -34 8 TestProxiedServerServeReadParity +30 8 TestProxiedServerInitIfMissing +30 8 TestProxiedServerPathHelpers +30 8 TestProxiedServerReopenConcurrent +30 8 TestProxiedServerShow2 +30 8 TestProxiedServerTypes +30 8 TestProxiedServerUpdateClosePolicy +30 8 TestServerModeSharedServeGlobalReportsTheServedDatabase -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 9 TestProxiedServerCloseConcurrent +30 9 TestProxiedServerDep2 +30 9 TestProxiedServerListWatchCountsTheOffsetIntoMaxRows +30 9 TestProxiedServerMolReadyGated +30 9 TestProxiedServerSQL -34 10 TestProxiedServerContext -34 10 TestProxiedServerCreate2B -34 10 TestProxiedServerGateCheckB -34 10 TestProxiedServerServeRefusesAStreamOnADisabledJournal -34 10 TestProxiedServerTypes -34 10 TestProxiedServerUpdate2C +30 10 TestProxiedServerAutoPrune +30 10 TestProxiedServerClose2 +30 10 TestProxiedServerPing +30 10 TestProxiedServerServeClose +30 10 TestProxiedServerServeEdgeCounts -34 11 TestProxiedServerBatchParity -34 11 TestProxiedServerCompactHistory -34 11 TestProxiedServerPour -34 11 TestProxiedServerQuery -34 11 TestProxiedServerReady -34 11 TestProxiedServerServeAddDependencies +30 11 TestProxiedServerBatchDefersThenDoltCommitAdvancesHeadOnce +30 11 TestProxiedServerOutageReconnectAcceptanceMatrix +30 11 TestProxiedServerReady2 +30 11 TestProxiedServerServeReadsTheJournalItJustWrote +30 11 TestProxiedServerServeRefusesTheJournalWhenItIsDisabled +30 11 TestProxiedServerShow -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 12 TestProxiedServerAssign +30 12 TestProxiedServerConfigSetMany +30 12 TestProxiedServerContext +30 12 TestProxiedServerInitExplicitBeadsDirIsAuthoritative +30 12 TestProxiedServerReadyClaimConcurrent +30 12 TestProxiedServerServeBatchClose -34 13 TestProxiedServerCompactDolt -34 13 TestProxiedServerCreate2 -34 13 TestProxiedServerGraph -34 13 TestProxiedServerHistoryRemoteSupportedDirectParity -34 13 TestProxiedServerMolSquash -34 13 TestProxiedServerPromote -34 13 TestProxiedServerServeRefusesAStaleCheckpointWithGone +30 13 TestProxiedServerChildren +30 13 TestProxiedServerConfig +30 13 TestProxiedServerDoltRemoteRemove +30 13 TestProxiedServerExternalMutationPolicy +30 13 TestProxiedServerPriority +30 13 TestProxiedServerServeUpdate -34 14 TestProxiedServerAssign -34 14 TestProxiedServerCloseB -34 14 TestProxiedServerDuplicates -34 14 TestProxiedServerHeartbeat -34 14 TestProxiedServerIfRevisionCloseReplaysMoleculeAutoClose -34 14 TestProxiedServerInitIfMissing -34 14 TestProxiedServerMolReadyGated +30 14 TestProxiedServerInfo +30 14 TestProxiedServerLint +30 14 TestProxiedServerNote +30 14 TestProxiedServerQuery +30 14 TestProxiedServerUpdate3 +30 14 TestProxiedServerWispCreate -34 15 TestProxiedServerDepConcurrent -34 15 TestProxiedServerImport -34 15 TestProxiedServerMoleculeFrontDoorWriteParity -34 15 TestProxiedServerReopenConcurrent -34 15 TestProxiedServerSQL +30 15 TestProxiedServerCompactDolt +30 15 TestProxiedServerMolDistill +30 15 TestProxiedServerMolProgress +30 15 TestProxiedServerServeClaimNext +30 15 TestProxiedServerServeRefusesAStreamOnADisabledJournal +30 15 TestProxiedServerUnclaimIfAssigneeParity -34 16 TestProxiedServerBackupRefusedOnExternalTopology -34 16 TestProxiedServerCascadeParity -34 16 TestProxiedServerConfigSetMany -34 16 TestProxiedServerKV -34 16 TestProxiedServerServeCount -34 16 TestProxiedServerServeCreate -34 16 TestProxiedServerUpdateHooks +30 16 TestProxiedServerCascadeParity +30 16 TestProxiedServerExternalCreate +30 16 TestProxiedServerGraph +30 16 TestProxiedServerLabel +30 16 TestProxiedServerSwarm +30 16 TestProxiedServerTodo +30 16 TestProxiedServerUpdateConcurrentMetadata -34 17 TestProxiedServerDep -34 17 TestProxiedServerMultiStatementSQL -34 17 TestProxiedServerOrphans -34 17 TestProxiedServerPrime -34 17 TestProxiedServerSQLDatabaseFlag -34 17 TestProxiedServerServeModeGate -34 17 TestServerModeServeIgnoresGraphModeDependency +30 17 TestProxiedServerClose +30 17 TestProxiedServerConfigConcurrent +30 17 TestProxiedServerDeleteConcurrent +30 17 TestProxiedServerIfRevisionGuardUpdate +30 17 TestProxiedServerSearch +30 17 TestProxiedServerServeReadParity +30 17 TestProxiedServerStatus -34 18 TestProxiedServerClose3 -34 18 TestProxiedServerCount -34 18 TestProxiedServerCountIncludeInfra -34 18 TestProxiedServerDoltRemoteRemove -34 18 TestProxiedServerMolShow -34 18 TestProxiedServerWispCreateRejectsEnumViolatingVar +30 18 TestProxiedServerHeartbeat +30 18 TestProxiedServerMolBond +30 18 TestProxiedServerSQLDatabaseFlag +30 18 TestProxiedServerServeCount +30 18 TestProxiedServerUpdate2 +30 18 TestServerModeTypesAgreeWithCreate -34 19 TestProxiedServerCreate -34 19 TestProxiedServerMolCurrent -34 19 TestProxiedServerServeBatchClose -34 19 TestProxiedServerShow3 -34 19 TestServerModeTypesAgreeWithCreate +30 19 TestProxiedServerCreate2 +30 19 TestProxiedServerEdit +30 19 TestProxiedServerIfRevisionGuardReopen +30 19 TestProxiedServerPourRejectsEnumViolatingVar +30 19 TestProxiedServerReassignFence +30 19 TestProxiedServerUpdateWisp +30 19 TestServerModeServe -34 20 TestProxiedServerDelete -34 20 TestProxiedServerLint -34 20 TestProxiedServerPriority -34 20 TestProxiedServerShow2B -34 20 TestProxiedServerWispGC -34 20 TestServerModeSharedServeGlobalReportsTheServedDatabase +30 20 TestProxiedServerExternalPolicyDirectParity +30 20 TestProxiedServerHistory +30 20 TestProxiedServerImport +30 20 TestProxiedServerMemory +30 20 TestProxiedServerMolCurrent +30 20 TestProxiedServerServeStreamsTheJournalItIsWriting -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 21 TestProxiedServerDeleteWisp +30 21 TestProxiedServerDepConcurrent +30 21 TestProxiedServerListSortRetiresTheWalk +30 21 TestProxiedServerPrime +30 21 TestProxiedServerRelate +30 21 TestProxiedServerSetState +30 21 TestProxiedServerUpdateConcurrentAppendNotes -34 22 TestProxiedServerGateCreateInheritsRepoMetadata -34 22 TestProxiedServerRecomputeBlocked -34 22 TestProxiedServerServeEdgeCounts -34 22 TestProxiedServerTag -34 22 TestProxiedServerUpdateB -34 22 TestProxiedServerUpdateConcurrentMetadata +30 22 TestProxiedServerCompactHistory +30 22 TestProxiedServerGateLifecycle +30 22 TestProxiedServerKV +30 22 TestProxiedServerShow3 +30 22 TestProxiedServerStale +30 22 TestProxiedServerStatuses -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 23 TestProxiedServerBackupRefusedOnExternalTopology +30 23 TestProxiedServerCloseSiblingBlockersFanIn +30 23 TestProxiedServerDeleteBlockedJSONSingleDoc +30 23 TestProxiedServerQuick +30 23 TestProxiedServerStorageClass +30 23 TestProxiedServerUpdateHooks +30 23 TestProxiedServerWispGC -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 24 TestProxiedServerCreateInfraTypeRoutesToWisps +30 24 TestProxiedServerEpic +30 24 TestProxiedServerLink +30 24 TestProxiedServerMoleculeFrontDoorDirectServerProxyParity +30 24 TestProxiedServerRecomputeBlocked +30 24 TestServerModeServeSkipsPostRunMaintenance -34 25 TestProxiedServerInitExplicitBeadsDirIsAuthoritative -34 25 TestProxiedServerSetState -34 25 TestProxiedServerShow -34 25 TestProxiedServerShowB -34 25 TestProxiedServerStale -34 25 TestProxiedServerWispCreate +30 25 TestProxiedServerDeferUndefer +30 25 TestProxiedServerOrphans +30 25 TestProxiedServerServeClaim +30 25 TestProxiedServerShowWatch +30 25 TestProxiedServerUpdateIfGuards +30 25 TestProxiedServerWispCreateRejectsEnumViolatingVar -34 26 TestProxiedServerDeferAutoWake -34 26 TestProxiedServerExternalMutationPolicy -34 26 TestProxiedServerReopenB -34 26 TestProxiedServerSearch -34 26 TestProxiedServerServeClaim -34 26 TestProxiedServerShow3B +30 26 TestProxiedServerFindDuplicates +30 26 TestProxiedServerGateCheck +30 26 TestProxiedServerGateFrontDoorDirectServerProxyParity +30 26 TestProxiedServerServeAddComment +30 26 TestProxiedServerServeSettingsWrites +30 26 TestProxiedServerState -34 27 TestProxiedServerDeferUndefer -34 27 TestProxiedServerGatedRendering -34 27 TestProxiedServerHistory -34 27 TestProxiedServerLabel -34 27 TestProxiedServerLabelB -34 27 TestProxiedServerUpdateClosePolicy +30 27 TestProxiedServerBlocked +30 27 TestProxiedServerIfRevisionGuardClose +30 27 TestProxiedServerMolLastActivity +30 27 TestProxiedServerMolStale +30 27 TestProxiedServerMoleculeFrontDoorWriteParity +30 27 TestProxiedServerServeActivatesTheEventsJournal +30 27 TestProxiedServerServeRefusesAStaleCheckpointWithGone -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 28 TestProxiedServerComment +30 28 TestProxiedServerExport +30 28 TestProxiedServerList +30 28 TestProxiedServerReopen +30 28 TestProxiedServerServeCreate +30 28 TestProxiedServerUnclaim -34 29 TestProxiedServerGateFrontDoorDirectServerProxyParity -34 29 TestProxiedServerMolDistill -34 29 TestProxiedServerReopen -34 29 TestProxiedServerServeDelete -34 29 TestProxiedServerState +30 29 TestProxiedServerDeferAutoWake +30 29 TestProxiedServerDep +30 29 TestProxiedServerDepListSingleIDWarnsOnDroppedExternalEdge +30 29 TestProxiedServerHistoryRemoteRefusalFrontDoorMatrix +30 29 TestProxiedServerIfRevisionGuardDelete +30 29 TestProxiedServerTag +30 29 TestProxiedServerWispList -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 +30 30 TestProxiedServerEventsJournalOffByDefault +30 30 TestProxiedServerMolSquash +30 30 TestProxiedServerPrune +30 30 TestProxiedServerPurgeWispsPlaneRetention +30 30 TestProxiedServerServeRelease +30 30 TestProxiedServerUpdateConcurrentClaim diff --git a/.github/scripts/rrc-lane-commands.txt b/.github/scripts/rrc-lane-commands.txt deleted file mode 100644 index 331e18657..000000000 --- a/.github/scripts/rrc-lane-commands.txt +++ /dev/null @@ -1,17 +0,0 @@ -# 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 diff --git a/.github/scripts/rrc-run-lanes.sh b/.github/scripts/rrc-run-lanes.sh deleted file mode 100755 index d5f329a84..000000000 --- a/.github/scripts/rrc-run-lanes.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/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... --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[@]}"} &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 diff --git a/.github/scripts/rrc-writer-credential.sh b/.github/scripts/rrc-writer-credential.sh deleted file mode 100755 index a650c7ddc..000000000 --- a/.github/scripts/rrc-writer-credential.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/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" diff --git a/.github/workflows/bazel-farm.yml b/.github/workflows/bazel-farm.yml index caeb0ad2f..7ab2c0a7b 100644 --- a/.github/workflows/bazel-farm.yml +++ b/.github/workflows/bazel-farm.yml @@ -120,18 +120,8 @@ 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 diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index b319ab300..66322c9d5 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -46,14 +46,7 @@ # only what the PR changed is built and tested on the runner, and it is # their only PR-time integration run (no legacy job runs it on PRs). Mode # local (rbe=off) still skips it. Direct runs (push to main, -# workflow_dispatch, nightly.yml's call) gate nothing. In mode remote the -# dolt-server and proxied-server tiers run as one union job, bazel-dolt-race -# (`bazel test --config=dolt-race`), whose job.status is both the -# bazel-doltserver and the bazel-proxied output; in every other mode -# bazel-doltserver and bazel-proxied run as before and report their own. -# Exactly one of the two arms runs in any mode, so the gate ids -# (BAZEL_DOLTSERVER, BAZEL_PROXIED) and bazel-gate.sh's skips are unchanged -# (engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md, "dolt-race Union Lane"). +# workflow_dispatch, nightly.yml's call) gate nothing. # # Execution mode, decided once by the rbe job (every other job needs it and # reads its outputs; none re-derives the condition) and passed to @@ -223,9 +216,8 @@ on: # test would silently stop the lane on main. integration: description: > - "off" skips bazel-integration, bazel-cmd-dolt and - bazel-server-storage; anything else (pr.yml and bazel-farm.yml - pass "on") runs them where remote execution is on. + "off" skips bazel-integration; anything else (pr.yml and + bazel-farm.yml pass "on") runs it where remote execution is on. type: string required: false default: "on" @@ -349,27 +341,18 @@ on: bazel-integration: description: "bazel-integration's job.status" value: ${{ jobs.bazel-integration.outputs.result }} - # Mode remote: bazel-dolt-race runs both tiers and the member jobs - # skip; every other mode: the reverse. One side is always empty. bazel-doltserver: - description: "the dolt-server tier's job.status: bazel-dolt-race's in mode remote, bazel-doltserver's otherwise" - value: ${{ jobs.bazel-dolt-race.outputs.result || jobs.bazel-doltserver.outputs.result }} + description: "bazel-doltserver's job.status" + value: ${{ jobs.bazel-doltserver.outputs.result }} bazel-proxied: - description: "the proxied-server tier's job.status: bazel-dolt-race's in mode remote, bazel-proxied's otherwise" - value: ${{ jobs.bazel-dolt-race.outputs.result || jobs.bazel-proxied.outputs.result }} - # Mode remote: bazel-dolt-int runs both tiers and the member jobs - # skip; every other mode: the reverse. One side is always empty - # (item 5 A2). bazel-dolt-int reports its own per-tier classification - # (classify_tier_results.py), not job.status: the job carries no - # continue-on-error, so job.status alone would read failure for both - # tiers on a cmd-dolt-only failure, unlike bazel-cmd-dolt's own - # advisory, continue-on-error nature outside mode remote. + description: "bazel-proxied's job.status" + value: ${{ jobs.bazel-proxied.outputs.result }} bazel-server-storage: - description: "the server-Dolt storage tier's result: bazel-dolt-int's server_storage_result in mode remote, bazel-server-storage's job.status otherwise" - value: ${{ jobs.bazel-dolt-int.outputs.server_storage_result || jobs.bazel-server-storage.outputs.result }} + description: "bazel-server-storage's job.status" + value: ${{ jobs.bazel-server-storage.outputs.result }} bazel-cmd-dolt: - description: "the cmd/bd Dolt-server tier's result (advisory unless pr.yml's BAZEL_CMD_DOLT_REQUIRED is \"true\"): bazel-dolt-int's cmd_dolt_result in mode remote, bazel-cmd-dolt's job.status otherwise" - value: ${{ jobs.bazel-dolt-int.outputs.cmd_dolt_result || jobs.bazel-cmd-dolt.outputs.result }} + description: "bazel-cmd-dolt's job.status (advisory unless pr.yml's BAZEL_CMD_DOLT_REQUIRED is \"true\")" + value: ${{ jobs.bazel-cmd-dolt.outputs.result }} package-mcp: description: "package-mcp's job.status (empty unless package-gates is 'on')" value: ${{ jobs.package-mcp.outputs.result }} @@ -441,7 +424,6 @@ jobs: enabled: ${{ steps.decide.outputs.enabled }} mode: ${{ steps.decide.outputs.mode }} tier: ${{ steps.decide.outputs.tier }} - rrc: ${{ steps.rrc.outputs.rrc }} steps: # The expressions' == is case-insensitive (RBE_WEST_WORKERS=True counts). # A push, merge_group or dispatch has no pull_request, so FORK is false. @@ -514,38 +496,6 @@ jobs: } >> "$GITHUB_OUTPUT" echo "Bazel execution mode: **$mode** (RBE_WEST_WORKERS on: $RBE_VAR_ON, rbe=off: $RBE_INPUT_OFF, rbe=cache: $RBE_INPUT_CACHE, fork: $FORK, dependabot: $DEPENDABOT, fork farm: $FORK_FARM, executor secret: $HAS_EXECUTOR)" | tee -a "$GITHUB_STEP_SUMMARY" - # Bazel's remote repo contents cache on rbe-west (ga-vnycm2.29, ported - # from gascity's bazel.yml; gascity - # engdocs/design/bazel-remote-repo-contents-cache.md): extracted - # external repositories (go_deps, the Go SDK, the LLVM slice) come from - # rbe-west's action cache instead of being re-fetched by every cold lane - # client. vars.RBE_REPO_CONTENTS_CACHE rolls it out: - # unset/off nothing (the default); - # seed main pushes seed the cache (rrc-seed); no lane reads it; - # canary seed, and bazel-test reads; - # on seed, and every lane in .github/scripts/rrc-lane-commands.txt - # reads. - # Mode remote only: fork pull_request runs see no vars (mode cache - # reads through setup-bazel's rc instead, in the jobs that pass - # BAZEL_RRC_READ, behind its probe of rbe-cache: write-bazelrc.sh). Any other value is off, with a warning, so a typo - # never fails the required gate. Like decide, this step runs no - # repository code (it comes before the checkout). - - name: Remote repo contents cache - id: rrc - env: - RRC: ${{ vars.RBE_REPO_CONTENTS_CACHE }} - MODE: ${{ steps.decide.outputs.mode }} - run: | - rrc=off - case "$RRC" in - "" | off) ;; - seed | canary | on) - if [ "$MODE" = remote ]; then rrc=$RRC; fi ;; - *) echo "::warning title=RBE_REPO_CONTENTS_CACHE::unknown value '$RRC' (want off, seed, canary or on); treated as off" ;; - esac - echo "rrc=$rrc" >> "$GITHUB_OUTPUT" - echo "Remote repo contents cache: **$rrc**" >> "$GITHUB_STEP_SUMMARY" - # The worker-env preflight (see the job's comment): the PR's own copy, # so a PR that syncs it passes. Only the two paths it compares. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -777,19 +727,16 @@ jobs: # and cache runs (forks, rbe=off/cache, no secrets) build everything # they miss on the runner, so they get the larger GitHub-hosted one. # Fork modes (fork-ro/fork-rw) execute remotely but stay GitHub-hosted, - # like every fork job: the runner is only a client. ubuntu-24.04, not - # ubuntu-latest, in every lane that reads the remote repo contents cache - # in mode cache: the cached trees are Linux x86_64 ones from a 24.04 host - # (design R2), so the image must not move under them. + # like every fork job: the runner is only a client. # - # 8 vCPU, not the other lanes' 4: with every action a remote cache hit, + # 4 vCPU, not the other lanes' 2: with every action a remote cache hit, # this lane's `bazel test //... --config=ci` spent ~63 of 81s in # client-side loading and analysis (1798 packages, 66k configured # targets; critical path 7.65s, merge group 37721729916), which Bazel - # parallelizes across the client's cores. Analysis-only, seeded runner - # cache (ga-vnycm2.8): 38.3s on 2 vCPU, 25.6s on 4, 16.3s on 8. + # parallelizes across the client's cores. Revert to 2 vCPU if the A/B + # does not save at least 15s on that step. needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} # Remote execution goes to rbe-west (instance "oss", the Blacksmith-backed # worker pool shared with gascity). Skipped only in mode skip (same-repo # runs while RBE_WEST_WORKERS is unset). @@ -838,22 +785,6 @@ jobs: - name: Verify restored Go modules run: go mod verify - # The remote repo contents cache, read-only (the rbe job's rrc output: - # canary, bazel-test; on, every lane). Each cached repository costs - # several sequential round trips, resolved on Skyframe's loading - # threads (default: the CPU count), so without 64 of them a cached read - # is slower than fetching. Both lines are key neutral (startup and - # loading only). Reading only: setup-bazel's rc keeps - # --noremote_upload_local_results, so nothing here writes; rrc-seed - # writes, on push to main. Before Set up Bazel: no server starts first. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && (needs.rbe.outputs.rrc == 'on' || needs.rbe.outputs.rrc == 'canary') }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -864,7 +795,6 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} @@ -1079,13 +1009,13 @@ jobs: name: pure-Go and js/wasm # Same runner and skip rule as bazel-test. needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} if: ${{ needs.rbe.outputs.mode != 'skip' }} timeout-minutes: 90 outputs: result: ${{ steps.result.outputs.result }} env: - PURE_CMD_BD_TESTS: '^Test(Help|CheckRemoteSafety|FormatDestroyToken|ShouldWireInitRemote|ExtractPrefix|IsNumericID|GetWorktreeGitDir|DriftItemStatuses|RunDriftChecks|IsServerProbablyRunning|CheckHooksDriftNotGitRepo|CheckServerDriftNoBeadsDir|CheckRemoteDriftNoBeadsDir|NocgoFactoriesHonorSharedServer|NocgoNewDoltStoreFromConfig_ErrorSuggestsCorrectFlag|NocgoNewReadOnlyStoreFromConfig_ErrorSuggestsCorrectFlag|NocgoStoreFactoriesRefuseGraphWorkspace)' + PURE_CMD_BD_TESTS: '^Test(Help|CheckRemoteSafety|FormatDestroyToken|ShouldWireInitRemote|ExtractPrefix|IsNumericID|GetWorktreeGitDir|DriftItemStatuses|RunDriftChecks|IsServerProbablyRunning|CheckHooksDriftNotGitRepo|CheckServerDriftNoBeadsDir|CheckRemoteDriftNoBeadsDir|NocgoFactoriesHonorSharedServer|NocgoNewDoltStoreFromConfig_ErrorSuggestsCorrectFlag|NocgoNewReadOnlyStoreFromConfig_ErrorSuggestsCorrectFlag)' # The only pre-merge run of these boundaries: where it executes # remotely --config=sole-run fails on a remote cache eviction instead # of re-running the whole invocation (whose retry could turn a failed @@ -1115,15 +1045,6 @@ jobs: with: node-version: '24' - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -1134,7 +1055,6 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} @@ -1306,7 +1226,7 @@ jobs: bazel-release-cross: name: release cross-compile needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} if: ${{ needs.rbe.outputs.mode != 'skip' }} timeout-minutes: 90 outputs: @@ -1350,11 +1270,9 @@ jobs: JOB_STATUS: ${{ job.status }} run: echo "result=$JOB_STATUS" >> "$GITHUB_OUTPUT" - # pr-risk.yml's retired embedded-Dolt tier ("Test (Embedded Dolt Cmd N/20)", + # pr-risk.yml's embedded-Dolt tier ("Test (Embedded Dolt Cmd N/20)", # "Test (Embedded Dolt Storage N/5)", "Test (Embedded Dolt Conformance - - # core/audit)") as --config=embedded: those jobs, and the frozen 20-shard - # cmd block they read, no longer exist (see engdocs/TESTING.md) — this runs - # the embedded-tagged variants of + # core/audit)") as --config=embedded: the embedded-tagged variants of # //cmd/bd:bd_test and //internal/storage/embeddeddolt:embeddeddolt_test. # The shard variants run the jobs' own shard scripts and manifests, so Bazel # shard k runs exactly the tests of job k. A job of its own rather than a @@ -1365,33 +1283,36 @@ jobs: name: embedded Dolt tier # Remote execution only: skipped unless the rbe job chose remote, # fork-ro or fork-rw (enabled; not in modes cache, local or skip). - # Locally the tier is 72 race test - # processes (50 cmd/bd shards + 20 embeddeddolt storage shards + 2 + # Locally the tier is 67 race test + # processes (50 cmd/bd shards + 15 embeddeddolt storage shards + 2 # conformance partitions; ~24k test-seconds measured locally -- see # scripts/ci/embedded_cmd_test_durations.json and # scripts/ci/embedded_storage_test_durations.json -- up from an earlier, # smaller test surface's ~7-10k estimate) on one runner, several hours # per run on the pool whose job cap this track exists to relieve, and it - # proved nothing pr-risk.yml's embedded jobs (which ran for forks before - # #7353 retired them) did not. + # proves nothing pr-risk.yml's embedded jobs (which do run for forks) do + # not. # - # Shard counts: storage (40): its tests are serial, so a shard's wall - # time is the sum of its tests, and CI shards run ~1.3-1.6x the rbe-west - # measurements; 40 is where the LPT-packed heaviest shard + # Shard counts: storage (15) is sized the way both tiers were originally + # meant to be -- the smallest count whose LPT-packed heaviest shard # (scripts/ci/gen_embedded_storage_shard_manifest.py --weights=duration - # --repack) is its heaviest single top-level test, ~71s - # (TestLifecycleCloseReopenContract). cmd is a 100-shard block split - # over two targets, //cmd/bd:bd_embedded_test (shards 1-50) and - # //cmd/bd:bd_embedded_part2_test (51-100), because Bazel caps a rule at - # 50 shards ("Having more than 50 shards is indicative of poor test - # organization. Please reduce the number of shards." -- a native - # analysis-time error, not a style lint); the step below checks that - # the two ranges tile the block exactly once. After its slowest - # functions were split into smaller top-level tests, a cmd shard's wall - # time is its slowest test: ~45s median, and at most the *Concurrent - # stress tests' 65-145s (their bd subprocesses queue on one workspace's - # writer lock, so they cannot be split without changing what they test). On RBE the tier's wall time ~= that floor - # + fixed cost (checkout, build, shard dispatch), not ~= + # --repack) lands at or below the tier's own heaviest single top-level + # test (211-225s). cmd cannot reach that floor: Bazel hard-caps + # shard_count at 50 per sh_test-like rule ("Having more than 50 shards is + # indicative of poor test organization. Please reduce the number of + # shards." -- a native analysis-time error, not a style lint), and at 50 + # shards the cmd suite's LPT-packed heaviest shard is ~409.6s -- above + # its own single heaviest test's 239.7s, because the suite's total + # duration (~20145 test-seconds across 242 tests) is too large to flatten + # to the single-test floor within 50 bins. Clearing more shards would + # need either further per-test speedups spread across the suite or + # splitting bd_embedded_test into multiple <=50-shard sh_test rules with + # shard-index-offset plumbing through tools/bazel/go_test_manifest_shard.sh + # and check_shard_coverage.py; neither is done here, so this lane's floor + # is cmd's ~409.6s, not the ~240s a 5-minute lane (including this job's + # ~60s fixed cost) would need -- tracked as a follow-up, not silently + # hidden in the shard count. On RBE this makes the tier's wall time ~= + # that floor + fixed cost (checkout, build, shard dispatch), not ~= # sum(durations)/shard_count the way a CPU-core-bound local sweep is -- # each shard is its own remote action and runs concurrently with every # other shard, farm capacity permitting. @@ -1400,7 +1321,7 @@ jobs: # The runs-on expression is the shared one: Blacksmith in mode remote, # GitHub-hosted in the fork modes (a client only). needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} if: ${{ needs.rbe.outputs.enabled == 'true' }} timeout-minutes: 60 outputs: @@ -1415,15 +1336,6 @@ jobs: persist-credentials: false allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -1434,7 +1346,6 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} @@ -1487,11 +1398,9 @@ jobs: run: >- python3 tools/bazel/check_shard_coverage.py --bep "$RUNNER_TEMP/bazel-bep.json" - --suite //cmd/bd:bd_embedded_test .github/scripts/embedded-test-shard.sh 50@0/100 - --suite //cmd/bd:bd_embedded_part2_test .github/scripts/embedded-test-shard.sh 50@50/100 - --suite //internal/storage/embeddeddolt:embeddeddolt_embedded_test .github/scripts/embedded-storage-test-shard.sh 40 + --suite //cmd/bd:bd_embedded_test .github/scripts/embedded-test-shard.sh 50 + --suite //internal/storage/embeddeddolt:embeddeddolt_embedded_test .github/scripts/embedded-storage-test-shard.sh 15 --whole //internal/storage/embeddeddolt:embeddeddolt_conformance_core_test - --whole //internal/storage/embeddeddolt:embeddeddolt_conformance_core_slow_test --whole //internal/storage/embeddeddolt:embeddeddolt_conformance_audit_test - name: Upload test logs @@ -1506,25 +1415,6 @@ jobs: if-no-files-found: ignore retention-days: 7 - # The served targets' per-test durations, on every run: their pinned - # shard manifests (backend/http/served_pinned_shards.txt from - # tools/bazel/pin_shards.py, the corpus parts' split) are sized from a - # sharded run of this lane, and the logs above are kept only on failure. - # test.xml only, a few KB each. Telemetry like the CI analytics upload: - # nothing in CI reads it, so an artifact 5xx or stall must not fail or - # hold the lane (scripts TestBazelEmbeddedServedTimingsUploadIsTelemetry). - - name: Upload served test timings - if: ${{ !cancelled() && steps.test.outcome != 'skipped' }} - continue-on-error: true - timeout-minutes: 2 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - overwrite: true # a job re-run is the same run: replace, not 409 - name: bazel-embedded-served-testxml - path: bazel-testlogs/backend/http/**/test.xml - if-no-files-found: ignore - retention-days: 7 - # Same redacted summary as bazel-test's; see its comment. - name: CI analytics summary id: ci-analytics @@ -1601,12 +1491,9 @@ jobs: # A caller may turn it off with integration: "off"; pr.yml and # bazel-farm.yml pass "on". needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} if: ${{ (needs.rbe.outputs.enabled == 'true' || needs.rbe.outputs.mode == 'cache') && inputs.integration != 'off' }} - # F5 S2 Variant A added the "Nogo: integration library files" step after - # `test`; +5 over the previous 85 keeps it headroom without exceeding - # TestBazelIntegrationJob's test-step-timeout+15 ceiling (75+15=90). - timeout-minutes: 90 + timeout-minutes: 85 outputs: result: ${{ steps.result.outputs.result }} steps: @@ -1619,15 +1506,6 @@ jobs: persist-credentials: false allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -1638,7 +1516,6 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} @@ -1687,34 +1564,6 @@ jobs: if: ${{ always() && steps.test.outcome != 'skipped' }} run: python3 tools/bazel/check_testcases.py --bep "$RUNNER_TEMP/bazel-bep.json" --not-go //tools/bazel:dolt_version_test --not-go //scripts/repochecks:all - # F5 S2 Variant A: the integration/doltserver-integration/doltserver-cmd - # configuration (--config=integration plus race) has no full-lane nogo - # owner (every lane above passes --norun_validations, .bazelrc). This - # narrow build keeps full nogo (vet + golangci-lint) on the - # configuration's non-test library package, - # //internal/testutil/integration, which every one of those lanes - # compiles; the 56 integration-tagged _test.go files this does not - # cover are the accepted loss (tools/nogo/unvalidated_integration_tests.txt, - # f5-spec.md §3). --keep_going so one finding does not hide another. - # scripts/nogo_lint_policy_test.go's - # TestNogoConfigurationsHaveOneValidatingLane pins this step as the - # configuration's sole validating lane. - - name: "Nogo: integration library files" - id: nogo-integration - if: ${{ always() && steps.test.outcome != 'skipped' }} - timeout-minutes: 10 - run: | - set -o pipefail - start=$(date +%s) - rc=0 - bazel build --config=integration --@rules_go//go/config:race --keep_going \ - --output_groups=nogo_fix \ - -- //internal/testutil/integration:integration \ - 2>&1 | tee "$RUNNER_TEMP/bazel-nogo-integration.log" || rc=$? - procs=$(grep -oE 'INFO: [0-9]+ process' "$RUNNER_TEMP/bazel-nogo-integration.log" | tail -1 || true) - echo "nogo-integration: exit $rc, $(( $(date +%s) - start ))s wall${procs:+, $procs}" | tee -a "$GITHUB_STEP_SUMMARY" - exit "$rc" - - name: Upload test logs if: ${{ failure() && steps.test.outcome != 'skipped' }} uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 @@ -1774,18 +1623,12 @@ jobs: # doctor/fix, protocol in 8 shards, testutil), each of which starts its # own dolt sql-server from the pinned dolt, so they execute on the remote # workers like any other test (locally with rbe=off). - # Not in mode remote: there bazel-dolt-race runs this tier together with - # the proxied-server tier and reports for both (item 5). In the fork - # modes, cache and local there is no in-flight deduplication of one - # client's actions and the client does the work, so a union would cost the - # sum of the two tiers instead of the max: this job runs there as before. bazel-doltserver: name: dolt-server lane - # Same runner as bazel-test; bazel-test's skip rule, plus mode remote - # (bazel-dolt-race's). + # Same runner and skip rule as bazel-test. needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }} - if: ${{ needs.rbe.outputs.mode != 'skip' && needs.rbe.outputs.mode != 'remote' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} + if: ${{ needs.rbe.outputs.mode != 'skip' }} timeout-minutes: 90 outputs: result: ${{ steps.result.outputs.result }} @@ -1808,15 +1651,6 @@ jobs: persist-credentials: false allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -1827,7 +1661,6 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} @@ -1901,23 +1734,20 @@ jobs: JOB_STATUS: ${{ job.status }} run: echo "result=$JOB_STATUS" >> "$GITHUB_OUTPUT" - # Like pr-risk.yml's retired proxied-server tier, "Test (Proxied Dolt Cmd - # N/15)" (that job, and the frozen 15-shard block it read, no longer exist; - # see engdocs/TESTING.md), as --config=doltserver-proxied: - # //cmd/bd:bd_proxied_test runs the shard script, so shard k runs exactly - # that manifest entry's tests. This lane runs 34 shards of its own - # (.github/scripts/proxied-cmd-test-shards.txt's duration-balanced 34-block; - # see scripts/ci/proxied_test_durations.json) — shard k here was never the - # same split as the retired job's shard k. Same build as --config=doltserver - # (race bd_test, non-race + # Like pr-risk.yml's proxied-server tier, "Test (Proxied Dolt Cmd N/15)", + # as --config=doltserver-proxied: //cmd/bd:bd_proxied_test runs the shard + # script, so shard k runs exactly that manifest entry's tests. This lane + # runs 30 shards of its own (.github/scripts/proxied-cmd-test-shards.txt's + # duration-balanced 30-block; see scripts/ci/proxied_test_durations.json), + # not the legacy jobs' 15 — shard k here is not the same split as their + # shard k. Same build as --config=doltserver (race bd_test, non-race # bd_for_tests), shared with bazel-doltserver through the remote cache. # The test binary is race, as PR Risk's retired jobs built it. It also runs # //cmd/bd:bd_managed_local_test, the managed-local proxied lifecycle # (formerly proxied-local-smoke.yml) in a loopback-only network # namespace, which needs the workers' unprivileged user namespaces. A job # of its own, not gated by any integration switch: it runs in pr.yml's - # call and its gate requires it (BAZEL_PROXIED). Fork modes only: in mode - # remote bazel-dolt-race runs this tier (see bazel-doltserver's comment). + # call and its gate requires it (BAZEL_PROXIED). bazel-proxied: name: proxied-server tier # Remote execution only, like bazel-embedded: 30 concurrent shards, each @@ -1926,8 +1756,8 @@ jobs: # This lane is the tier's only PR run (pr-risk.yml's legacy jobs are # retired) and pr.yml's gate requires it to have run here and passed. needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} - if: ${{ needs.rbe.outputs.enabled == 'true' && needs.rbe.outputs.mode != 'remote' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} + if: ${{ needs.rbe.outputs.enabled == 'true' }} timeout-minutes: 30 outputs: result: ${{ steps.result.outputs.result }} @@ -1941,15 +1771,6 @@ jobs: persist-credentials: false allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -1960,7 +1781,6 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} @@ -1978,16 +1798,35 @@ jobs: fi # Remote: each shard's Go timeout is its job's 15m, 1200s Bazel cap, - # plus a compile. The 34-shard block is LPT-packed by - # scripts/ci/proxied_test_durations.json, a rbe-west capture of each - # top-level test's summed leaf-test time (see its header), to ~187 - # cost-seconds per shard; shards are expected around 55-95s (the same - # packed cost has run up to 1.45x the median wall time). Nearly - # all of that is `bd init --proxied-server` against the shard's dolt - # sql-server, ~one per subtest, each as a user scoped to its own - # database (cmd/bd/proxied_shared_harness_test.go); a shard running far - # longer is worth comparing against this job's recent history before - # assuming a hang. + # plus a compile. scripts/ci/proxied_test_durations.json's 176 entries + # are each a clean, single-job (no concurrent heavy bazel/dolt job + # intentionally started on the box; see that file's header for its + # ambient-contention caveat), -test.parallel=4 top-level-test + # duration — the exact config this job uses — from a single fresh, + # manifest-aligned 30-shard sweep's own (errors="0", + # so a failing-but-complete suite's time is still trustworthy); every + # one of the 176 discovered tests completed inside its shard run, so + # no `bazel run` leaf-summation workaround was needed this time. See + # that file's header for the full methodology, including why an + # earlier -test.parallel=1 (serial) capture was replaced: serial + # timings don't model this lane (which always runs parallel=4), and + # an independent re-review measured near-zero correlation (r=0.08) + # between the serial-derived predicted shard load and actual + # parallel=4 wall time. + # + # Measured per-shard wall time for the full 30-shard local sweep that + # produced this data: shards ranged from roughly 32s to 341s, with + # most clustering well under this job's 25m step timeout / 30m job + # timeout. After repacking with these corrected weights, the LPT + # estimate clusters every shard within a few seconds of ~355-360s + # (sum of all 176 measured durations / 30 shards) — no single test or + # small group of tests dominates a shard the way the discarded serial + # data wrongly implied. This is a local, single-job measurement, not + # a verified RBE forecast (this job has only ever run remote); if a + # shard's RBE wall time diverges sharply from this local estimate, + # that is RBE throughput differing from local execution, not + # necessarily a regression — compare against this job's own recent + # run history before assuming a hang. - name: bazel test //... --config=doltserver-proxied id: test timeout-minutes: 25 @@ -2016,7 +1855,7 @@ jobs: run: >- python3 tools/bazel/check_shard_coverage.py --bep "$RUNNER_TEMP/bazel-bep.json" - --suite //cmd/bd:bd_proxied_test .github/scripts/proxied-test-shard.sh 34 + --suite //cmd/bd:bd_proxied_test .github/scripts/proxied-test-shard.sh 30 - name: Upload test logs if: ${{ failure() && steps.test.outcome != 'skipped' }} @@ -2071,208 +1910,25 @@ jobs: JOB_STATUS: ${{ job.status }} run: echo "result=$JOB_STATUS" >> "$GITHUB_OUTPUT" - # Item 5 (scripts/bazel_dolt_race_test.go): the dolt-server and - # proxied-server tiers in one `bazel test --config=dolt-race` (.bazelrc: - # exactly the union of --config=doltserver's and - # --config=doltserver-proxied's lines, one tag filter for both), mode - # remote only, in place of bazel-doltserver and bazel-proxied, which run - # in every other mode. One client waits on rbe-west for both tiers' - # shards at once (27 + 35 test actions, under the remote-exec config's 64 - # jobs), so the job ends with the slower tier and saves the other's - # runner. Each member target's test action key is unchanged (aquery- - # verified), so cached results carry over both ways, and a revert of the - # cutover re-executes nothing. Gated: its job.status is both the - # bazel-doltserver and the bazel-proxied workflow_call output (a failure - # in either tier fails both ids, which are both required). Every step has - # a timeout and the job's exceeds their sum by 5 minutes while staying - # under the merge queue's 60-minute check timeout - # (TestBazelDoltRaceJobTimeouts), so a hang fails a named step instead of - # dropping the merge group. The member jobs' configs and the union's must - # stay key-identical: the mode decides which runs (TestBazelDoltRaceConfigIsMemberUnion). - # Its ci-analytics LANE is dolt-race. - bazel-dolt-race: - name: dolt-race - needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} - if: ${{ needs.rbe.outputs.mode == 'remote' }} - # At least every step's timeout-minutes plus 5, and below the merge - # queue's 60-minute check timeout so this job alone cannot exhaust it - # (TestBazelDoltRaceJobTimeouts). Not a whole-run bound: the rbe job runs - # first and sibling lanes have longer timeouts. - timeout-minutes: 56 - outputs: - result: ${{ steps.result.outputs.result }} - steps: - # inputs.checkout-sha: see the header (empty: the event's default ref). - # checkout v7 refuses a fork head on pull_request_target unless opted - # in; only bazel-farm.yml's authorized call opts in (false elsewhere). - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - timeout-minutes: 5 - with: - ref: ${{ inputs.checkout-sha }} - persist-credentials: false - allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - timeout-minutes: 1 - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - - name: Set up Bazel - id: bazel - timeout-minutes: 5 - uses: ./.github/actions/setup-bazel - env: - BAZEL_REMOTE_EXECUTOR: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_WEST_EXECUTOR || '' }} - RBE_TLS_CERT: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CERT || '' }} - RBE_TLS_KEY: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_KEY || '' }} - RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} - RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} - BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache - BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} - RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} - RBE_FORK_PR: ${{ github.event.pull_request.number }} - - # As in bazel-proxied. - - name: No test target is marked flaky - timeout-minutes: 3 - run: | - flaky="$(bazel query 'attr(flaky, 1, tests(//...))')" - if [ -n "$flaky" ]; then - echo "::error::flaky = True on ${flaky//$'\n'/ }: the gated lanes run each test once" - exit 1 - fi - - # Both tiers' shards at once: 27 dolt-server + 35 proxied test actions, - # under the remote-exec config's 64 jobs. No --config=sole-run: its one - # line (no retry on a remote cache eviction) is already in the union. - # Shards are expected around 55-95s on rbe-west (see bazel-proxied's - # test step), the proxied tier's 1200s cap included. The step timeout is - # >= proxied test_timeout 1200 s + about 3 min so Bazel writes TIMEOUT - # logs before GitHub kills the step. - - name: bazel test //... --config=dolt-race - id: test - timeout-minutes: 23 - run: | - set -o pipefail - start=$(date +%s) - rc=0 - bazel test //... --config=dolt-race ${BAZEL_FRESH:+"$BAZEL_FRESH"} \ - --build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \ - --execution_log_compact_file="$RUNNER_TEMP/bazel-exec.log.zst" \ - --profile="$RUNNER_TEMP/bazel-profile.json" \ - --experimental_build_event_upload_strategy=local \ - 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$? - echo "bazel test --config=dolt-race: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY" - exit "$rc" - - # The member lanes' checks, once over the union's BEP: bazel-proxied's - # (the dolt-server lane has none). check_shard_coverage ignores targets - # it does not list; check_testcases checks every target, so it covers - # the dolt-server tier too, which bazel-doltserver does not check: a - # dolt-server shard that runs no test turns this job red. - - name: Every target and shard ran tests - if: ${{ always() && steps.test.outcome != 'skipped' }} - timeout-minutes: 2 - run: python3 tools/bazel/check_testcases.py --bep "$RUNNER_TEMP/bazel-bep.json" - - - name: Every listed test ran in its shard - if: ${{ always() && steps.test.outcome != 'skipped' }} - timeout-minutes: 2 - run: >- - python3 tools/bazel/check_shard_coverage.py - --bep "$RUNNER_TEMP/bazel-bep.json" - --suite //cmd/bd:bd_proxied_test .github/scripts/proxied-test-shard.sh 34 - - - name: Upload test logs - if: ${{ failure() && steps.test.outcome != 'skipped' }} - timeout-minutes: 3 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - overwrite: true # a job re-run is the same run: replace, not 409 - name: bazel-dolt-race-testlogs - path: | - bazel-testlogs/**/test.log - bazel-testlogs/**/test.xml - if-no-files-found: ignore - retention-days: 7 - - # Same redacted summary as bazel-test's; see its comment. - - name: CI analytics summary - id: ci-analytics - if: "!cancelled() && steps.test.outcome != 'skipped'" - continue-on-error: true - timeout-minutes: 2 - env: - LANE: dolt-race - MODE: ${{ needs.rbe.outputs.mode }} - CHECK_RUN_ID: ${{ job.check_run_id }} - PR_HINT: ${{ github.event.pull_request.number || 0 }} - run: | - [ -f "$RUNNER_TEMP/bazel-bep.json" ] || exit 0 - zstd --version || echo "::warning::zstd missing: no per-mnemonic data in this lane's summary" - python3 tools/bazel/ci_analytics_extract.py \ - --lane "$LANE" --mode "$MODE" --check-run-id "$CHECK_RUN_ID" --pr-hint "$PR_HINT" \ - --invocation test "$RUNNER_TEMP/bazel-bep.json" "$RUNNER_TEMP/bazel-exec.log.zst" "$RUNNER_TEMP/bazel-profile.json" \ - --out "$RUNNER_TEMP/ci-analytics/ci-analytics.json" - - - name: Upload CI analytics summary - if: "!cancelled() && steps.ci-analytics.outcome == 'success'" - continue-on-error: true - timeout-minutes: 2 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - overwrite: true # a job re-run is the same run: replace, not 409 - name: ci-analytics-dolt-race-${{ github.run_attempt }} - path: ${{ runner.temp }}/ci-analytics/ci-analytics.json - retention-days: 7 - if-no-files-found: ignore - - # Last step: the job's result as the bazel-doltserver and - # bazel-proxied workflow_call outputs for pr.yml's ci-gate. always() - # runs it after a failure, a timeout or a cancellation too. - - name: Record job result - id: result - if: ${{ always() }} - timeout-minutes: 1 - env: - JOB_STATUS: ${{ job.status }} - run: echo "result=$JOB_STATUS" >> "$GITHUB_OUTPUT" - # pr-risk.yml's server-Dolt storage tier, "Test (Server Dolt Conformance)" # and "Test (Server Dolt Full Suite N/16)", as --config=doltserver-integration: # the conformance and 16-shard full-suite variants of # //internal/storage/dolt over a non-race dolt_test build, each shard # running the job's own shard script. --config=doltserver-integration has # exactly --config=integration's build flags, so it compiles nothing - # bazel-integration does not (shared through the remote cache). This is a - # PR-time tier, unlike main.yml's integration jobs, and pr.yml's gate - # requires it (BAZEL_SERVER_STORAGE); it also honors the same - # `integration` input as bazel-integration/bazel-cmd-dolt so an explicit - # "off" skips it too, even though no caller passes that today (pr.yml and - # bazel-farm.yml both pass "on") -- see the `integration` input's own - # description. - # Not in mode remote: there bazel-dolt-int runs this tier together with - # the cmd/bd Dolt-server tier and reports for both (item 5 A2). In the - # fork modes and cache there is no in-flight deduplication of one client's - # actions, so a union would cost the sum of the two tiers instead of the - # max: this job runs there as before. + # bazel-integration does not (shared through the remote cache). A job of + # its own, not gated by any integration switch: this is a PR-time tier, + # unlike main.yml's integration jobs, and pr.yml's gate requires it + # (BAZEL_SERVER_STORAGE). bazel-server-storage: name: server-Dolt storage tier # Remote execution only, like bazel-integration: locally the tagged race - # build of //... alone is most of the timeout. Plus mode remote - # (bazel-dolt-int's). + # build of //... alone is most of the timeout. # This lane is the tier's only PR run (pr-risk.yml's legacy jobs are # retired) and pr.yml's gate requires it to have run here and passed. needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} - if: ${{ needs.rbe.outputs.enabled == 'true' && needs.rbe.outputs.mode != 'remote' && inputs.integration != 'off' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} + if: ${{ needs.rbe.outputs.enabled == 'true' }} timeout-minutes: 30 outputs: result: ${{ steps.result.outputs.result }} @@ -2286,15 +1942,6 @@ jobs: persist-credentials: false allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -2305,7 +1952,6 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} @@ -2419,12 +2065,12 @@ jobs: run: echo "result=$JOB_STATUS" >> "$GITHUB_OUTPUT" # The cmd/bd Dolt-server tier, as --config=doltserver-cmd: the whole - # integration-tagged cmd/bd suite (//cmd/bd:bd_dolt_server_test, 32 - # shards, the slowest tests pinned to 16 of them) against a hermetic dolt sql-server, i.e. the Dolt-gated cmd/bd + # integration-tagged cmd/bd suite (//cmd/bd:bd_dolt_server_test, 16 + # shards) against a hermetic dolt sql-server, i.e. the Dolt-gated cmd/bd # tests (TestCLI_*, TestInit*, the store-backed suites) that every other - # lane skips with BEADS_TEST_SKIP=dolt or leaves out of its + # lane and legacy job skips with BEADS_TEST_SKIP=dolt or leaves out of its # manifest; plus the differential regression suite - # (//tests/regression:regression_test, 14 shards: the candidate + # (//tests/regression:regression_test, 8 shards: the candidate # bd_for_tests against the catalog-pinned v0.49.6 release, formerly # regression.yml). --config=doltserver-cmd has exactly # --config=integration's build flags, so it shares bazel-integration's @@ -2442,12 +2088,9 @@ jobs: # (TestBazelIntegrationExcludesBdTestOnlyWhereCmdDoltCovers). bazel-cmd-dolt: name: cmd/bd Dolt-server tier - # Not in mode remote: there bazel-dolt-int runs this tier together with - # the server-Dolt storage tier (item 5 A2). See bazel-server-storage's - # comment above. needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }} - if: ${{ (needs.rbe.outputs.enabled == 'true' || needs.rbe.outputs.mode == 'cache') && inputs.integration != 'off' && needs.rbe.outputs.mode != 'remote' }} + runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} + if: ${{ (needs.rbe.outputs.enabled == 'true' || needs.rbe.outputs.mode == 'cache') && inputs.integration != 'off' }} timeout-minutes: 85 continue-on-error: true outputs: @@ -2462,15 +2105,6 @@ jobs: persist-credentials: false allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - name: Set up Bazel id: bazel uses: ./.github/actions/setup-bazel @@ -2481,16 +2115,14 @@ jobs: RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} RBE_FORK_PR: ${{ github.event.pull_request.number }} # Remote: a compile shared with bazel-integration plus the longest - # of 32 shards (~1 minute: tools/bazel/go_test_pinned_shard.sh pins - # the slowest tests to shards of their own; each shard pays a few - # seconds of TestMain and its own dolt sql-server; Go's - # -test.timeout=19m, Bazel's 1200s cap). Mode cache on a 4-CPU runner: the compile hits + # of 16 shards (~3 minutes measured; each shard pays ~30-40 s of + # TestMain and its own dolt sql-server; Go's -test.timeout=19m, + # Bazel's 1200s cap). Mode cache on a 4-CPU runner: the compile hits # the read-only cache, and a PR that changes cmd/bd or what it imports # runs every shard locally, four at a time (~2,200 test-seconds # measured unloaded, slower four-up: ~20-30 minutes); with the cache @@ -2572,292 +2204,6 @@ jobs: JOB_STATUS: ${{ job.status }} run: echo "result=$JOB_STATUS" >> "$GITHUB_OUTPUT" - # Item 5 A2 (scripts/bazel_dolt_int_test.go): the server-Dolt storage and - # cmd/bd Dolt-server tiers in one `bazel test --config=dolt-int` (.bazelrc: - # exactly the union of --config=doltserver-integration's and - # --config=doltserver-cmd's lines, one tag filter for both), mode remote - # only, in place of bazel-server-storage and bazel-cmd-dolt, which run in - # every other mode (there a single client does both tiers' work without - # in-flight deduplication, so a union would cost the sum of the two tiers - # rather than the max). One client waits on rbe-west for both tiers' shards - # at once (17 + 46 = 63 test actions, under the remote-exec config's 64 - # jobs), so the job ends with the slower tier and the other tier's runner - # is saved. cmd-dolt's Go-level -test.timeout=19m arg and its - # BEADS_TEST_REQUIRE_EXCLUDE_PERMISSION env moved from --config=doltserver-cmd - # onto //cmd/bd:bd_dolt_server_test's and //tests/regression:regression_test's - # own args/env (their comments), so the union's tag filter alone decides - # which targets see them: without the move, server-storage's per-shard 15m - # Go timeout would become 19m under the union. The final argv and - # environment either way are identical (aquery-verified for all 4 affected - # targets, item 5 A2 PR), so remote action digests -- what RBE's cache keys - # on -- are unchanged and cached results should carry over; this is a local - # actionKey change for cmd-dolt's 46 actions, not a remote one (--test_env - # is part of the build configuration's own fingerprint, which every target - # under that configuration picks up, unlike a target's own env attribute), - # confirmed in practice by the first merge group's tests_cached == - # tests_total in ci-analytics, not claimed here as already observed. - # - # Unlike dolt-race, the members have different gating categories: - # bazel-server-storage is plain-gated (BAZEL_SERVER_STORAGE), bazel-cmd-dolt - # is flag-gated and advisory (BAZEL_CMD_DOLT, continue-on-error) until - # pr.yml's BAZEL_CMD_DOLT_REQUIRED is "true". This job therefore carries no - # job-level continue-on-error: on push, nightly and dispatch nothing reads - # BAZEL_SERVER_STORAGE off a workflow_call output, so job-level - # continue-on-error (job.status reads success regardless of the test step's - # own result) would let a server-storage failure end such a run green, - # where it must stay red exactly as it does on main today. Instead only the - # `bazel test` step carries continue-on-error, and an always() step - # (tools/bazel/classify_tier_results.py) reads the BEP by target label, - # computes each tier's own result, and fails the job itself iff - # server-storage's tier failed (a cmd-dolt-only test failure leaves the job - # green, as bazel-cmd-dolt's own continue-on-error already does outside - # mode remote) or bazel's exit code was neither 0 nor 3 (a build or infra - # failure is not attributable to one tier, so both are marked failed and - # the job fails regardless). Both members' workflow_call outputs read this - # job's matching per-tier output first, then their own member's; a job that - # dies before the classify step leaves both outputs empty, which mode - # remote's gate (bazel-gate.sh, ci-gate.sh) already treats as skipped and - # fails, same as an empty bazel-server-storage/bazel-cmd-dolt result would. - # Every step has a timeout and the job's exceeds their sum by 5 minutes - # while staying under the merge queue's 60-minute check timeout - # (TestBazelDoltIntJobTimeouts): 58 leaves only about 2 minutes for runner - # pickup and the rbe job inside that 60-minute budget, so a hang that runs - # to this job's own timeout can drop the merge group; accepted, because - # such a run is red anyway and the 58-minute job timeout bounds only this - # job, not the whole run (as #7514's dolt-race job comment). The member - # jobs' configs and the union's must stay key-identical: the mode decides - # which runs (TestBazelDoltIntConfigIsMemberUnion). Its ci-analytics LANE - # is dolt-int. - bazel-dolt-int: - name: dolt-int - needs: rbe - runs-on: ${{ needs.rbe.outputs.mode == 'remote' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} - if: ${{ needs.rbe.outputs.mode == 'remote' && inputs.integration != 'off' }} - # At least every step's timeout-minutes plus 5, and below the merge - # queue's 60-minute check timeout so this job alone cannot exhaust it - # (TestBazelDoltIntJobTimeouts). 58 leaves only about 2 minutes for - # runner pickup and the rbe job inside the merge queue's 60-minute check; - # a hang that runs to this timeout can therefore drop the group, which is - # accepted because such a run is red anyway and the 58-minute job timeout - # bounds this job, not the whole run (as #7514's dolt-race job comment). - timeout-minutes: 58 - outputs: - server_storage_result: ${{ steps.classify.outputs.server_storage_result }} - cmd_dolt_result: ${{ steps.classify.outputs.cmd_dolt_result }} - steps: - # inputs.checkout-sha: see the header (empty: the event's default ref). - # checkout v7 refuses a fork head on pull_request_target unless opted - # in; only bazel-farm.yml's authorized call opts in (false elsewhere). - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - timeout-minutes: 5 - with: - ref: ${{ inputs.checkout-sha }} - persist-credentials: false - allow-unsafe-pr-checkout: ${{ inputs.fork-farm == 'authorized' && github.event_name == 'pull_request_target' }} - - # The remote repo contents cache, read-only, as in bazel-test. - - name: Remote repo contents cache (read) - if: ${{ needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc == 'on' }} - timeout-minutes: 1 - run: | - { - echo 'startup --experimental_remote_repo_contents_cache' - echo 'common --loading_phase_threads=64' - } >> .bazelrc.local - - - name: Set up Bazel - id: bazel - timeout-minutes: 5 - uses: ./.github/actions/setup-bazel - env: - BAZEL_REMOTE_EXECUTOR: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_WEST_EXECUTOR || '' }} - RBE_TLS_CERT: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CERT || '' }} - RBE_TLS_KEY: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_KEY || '' }} - RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} - RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} - BAZEL_FORK_CACHE: ${{ needs.rbe.outputs.mode == 'cache' && 'true' || '' }} - BAZEL_RRC_READ: 'true' # mode cache reads the repo contents cache through rbe-cache - BAZEL_FORK_REMOTE: ${{ startsWith(needs.rbe.outputs.mode, 'fork-') && 'true' || '' }} - RBE_FORK_TIER: ${{ needs.rbe.outputs.tier }} - RBE_FORK_PR: ${{ github.event.pull_request.number }} - - # As in bazel-server-storage and bazel-proxied. - - name: No test target is marked flaky - timeout-minutes: 3 - run: | - flaky="$(bazel query 'attr(flaky, 1, tests(//...))')" - if [ -n "$flaky" ]; then - echo "::error::flaky = True on ${flaky//$'\n'/ }: the gated lanes run each test once" - exit 1 - fi - - # Both tiers' shards at once: 17 server-storage + 46 cmd-dolt test - # actions, under the remote-exec config's 64 jobs. No --config=sole-run: - # its one line (no retry on a remote cache eviction) is already in the - # union. The step timeout is >= the union's eternal-size test_timeout - # cap (1200s, shared by bd_dolt_server_test and regression_test) + about - # 3 min so Bazel writes TIMEOUT logs before GitHub kills the step, plus - # the margin server-storage's own step budgets for a cold compile (its - # own step was 25). continue-on-error: a cmd-dolt-only test failure - # must not fail this step (and so the job) outright; the classify step - # below decides that per-tier, from this step's own exit code (written - # to its "rc" output) and the BEP. - - name: bazel test //... --config=dolt-int - id: test - timeout-minutes: 25 - continue-on-error: true - run: | - set -o pipefail - start=$(date +%s) - rc=0 - bazel test //... --config=dolt-int ${BAZEL_FRESH:+"$BAZEL_FRESH"} \ - --build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \ - --execution_log_compact_file="$RUNNER_TEMP/bazel-exec.log.zst" \ - --profile="$RUNNER_TEMP/bazel-profile.json" \ - --experimental_build_event_upload_strategy=local \ - 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$? - echo "bazel test --config=dolt-int: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY" - echo "rc=$rc" >> "$GITHUB_OUTPUT" - exit "$rc" - - # check_testcases split per tier (should-fix 2, PR #7535 review): a - # single shared step with no continue-on-error would fail this job - # outright on a cmd-dolt-only zero-testcase shard (e.g. TestMain dying - # on dolt server start under BEADS_TEST_REQUIRE_DOLT_CONTAINER=1), - # where main (bazel-cmd-dolt alone) stays green, and the divergence - # would only show up under the documented rollback to - # BAZEL_CMD_DOLT_REQUIRED=false. Each step is --label-scoped to its own - # tier (so a --label typo or a label the run did not test fails - # closed, not open: check_testcases.py's own --label section) and - # carries continue-on-error so neither can fail the job by itself; the - # classify step below folds each step's own outcome into that tier's - # result with --check, so a cmd-dolt failure here reaches - # cmd_dolt_result only, same as a cmd-dolt BEP test failure does. - - name: Every target and shard ran tests (server-storage) - id: check-ss - if: ${{ always() && steps.test.outcome != 'skipped' }} - continue-on-error: true - timeout-minutes: 1 - run: >- - python3 tools/bazel/check_testcases.py - --bep "$RUNNER_TEMP/bazel-bep.json" - --label //internal/storage/dolt:dolt_server_full_test - --label //internal/storage/dolt:dolt_server_conformance_test - - - name: Every target and shard ran tests (cmd-dolt) - id: check-cd - if: ${{ always() && steps.test.outcome != 'skipped' }} - continue-on-error: true - timeout-minutes: 1 - run: >- - python3 tools/bazel/check_testcases.py - --bep "$RUNNER_TEMP/bazel-bep.json" - --label //cmd/bd:bd_dolt_server_test - --label //tests/regression:regression_test - - # bazel-server-storage's own check (cmd-dolt has none): every - # full-suite shard ran exactly the tests its shard script lists, and - # neither it nor the conformance target only skips. - - name: Every listed test ran in its shard - if: ${{ always() && steps.test.outcome != 'skipped' }} - timeout-minutes: 2 - run: >- - python3 tools/bazel/check_shard_coverage.py - --bep "$RUNNER_TEMP/bazel-bep.json" - --suite //internal/storage/dolt:dolt_server_full_test .github/scripts/server-storage-test-shard.sh 16 - --whole //internal/storage/dolt:dolt_server_conformance_test - - # bazel-server-storage's own check, scoped with --label to the one - # target it has always budgeted: cmd-dolt's bd_dolt_server_test and - # regression_test shards are sharded too but no job budgeted them - # before the union, and this script has never judged them (see its - # docstring). - - name: Shard balance - if: ${{ always() && steps.test.outcome != 'skipped' }} - timeout-minutes: 2 - run: >- - python3 tools/bazel/shard_budget.py - --bep "$RUNNER_TEMP/bazel-bep.json" - --label //internal/storage/dolt:dolt_server_full_test - - # failure() alone misses an ordinary test failure here: the `bazel - # test` step carries its own continue-on-error (must-fix 2), so a - # failing test does not make failure() true until the classify step - # (which runs after this one) exits non-zero. steps.test.outcome == - # 'failure' catches that case directly (nit, PR #7535 review). - - name: Upload test logs - if: ${{ (failure() || steps.test.outcome == 'failure') && steps.test.outcome != 'skipped' }} - timeout-minutes: 3 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - overwrite: true # a job re-run is the same run: replace, not 409 - name: bazel-dolt-int-testlogs - path: | - bazel-testlogs/**/test.log - bazel-testlogs/**/test.xml - if-no-files-found: ignore - retention-days: 7 - - # Same redacted summary as bazel-test's; see its comment. - - name: CI analytics summary - id: ci-analytics - if: "!cancelled() && steps.test.outcome != 'skipped'" - continue-on-error: true - timeout-minutes: 2 - env: - LANE: dolt-int - MODE: ${{ needs.rbe.outputs.mode }} - CHECK_RUN_ID: ${{ job.check_run_id }} - PR_HINT: ${{ github.event.pull_request.number || 0 }} - run: | - [ -f "$RUNNER_TEMP/bazel-bep.json" ] || exit 0 - zstd --version || echo "::warning::zstd missing: no per-mnemonic data in this lane's summary" - python3 tools/bazel/ci_analytics_extract.py \ - --lane "$LANE" --mode "$MODE" --check-run-id "$CHECK_RUN_ID" --pr-hint "$PR_HINT" \ - --invocation test "$RUNNER_TEMP/bazel-bep.json" "$RUNNER_TEMP/bazel-exec.log.zst" "$RUNNER_TEMP/bazel-profile.json" \ - --out "$RUNNER_TEMP/ci-analytics/ci-analytics.json" - - - name: Upload CI analytics summary - if: "!cancelled() && steps.ci-analytics.outcome == 'success'" - continue-on-error: true - timeout-minutes: 2 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - overwrite: true # a job re-run is the same run: replace, not 409 - name: ci-analytics-dolt-int-${{ github.run_attempt }} - path: ${{ runner.temp }}/ci-analytics/ci-analytics.json - retention-days: 7 - if-no-files-found: ignore - - # Last step: each tier's own result (not job.status: this job carries - # no continue-on-error, see the job's own comment) as the - # bazel-server-storage and bazel-cmd-dolt workflow_call outputs for - # pr.yml's ci-gate. always() runs it after a failure, a timeout or a - # cancellation too (steps.test.outcome stays "skipped" then, so the - # script's --bep file does not exist; it is only read when the test - # step actually ran). This step's own exit code decides job.status: it - # fails the job iff server-storage's tier failed, or `bazel test`'s - # exit code was neither 0 nor 3 (a build or infra failure, not - # attributable to one tier, fails both and the job). - - name: Classify tier results - id: classify - if: ${{ always() && steps.test.outcome != 'skipped' }} - timeout-minutes: 1 - env: - TEST_RC: ${{ steps.test.outputs.rc }} - CHECK_SS_OUTCOME: ${{ steps.check-ss.outcome }} - CHECK_CD_OUTCOME: ${{ steps.check-cd.outcome }} - run: >- - python3 tools/bazel/classify_tier_results.py - --bep "$RUNNER_TEMP/bazel-bep.json" - --rc "$TEST_RC" - --tier server-storage=//internal/storage/dolt:dolt_server_full_test,//internal/storage/dolt:dolt_server_conformance_test - --tier cmd-dolt=//cmd/bd:bd_dolt_server_test,//tests/regression:regression_test - --gate-tier server-storage - --check "server-storage=$CHECK_SS_OUTCOME" - --check "cmd-dolt=$CHECK_CD_OUTCOME" - --github-output "$GITHUB_OUTPUT" - # F3: moved here from pr.yml so the gate depends on nothing but the rbe # job's decision (not the whole bazel call). Only pr.yml opts in (package-gates: "on"); # bazel-farm.yml and nightly.yml keep the default "off" and this job does @@ -2921,7 +2267,7 @@ jobs: # bazel-out/k8-fastbuild-ST-.../bin/cmd/bd/bd_for_tests/bd path). - name: bazel build //cmd/bd:bd_for_tests if: ${{ steps.detect.outputs.mcp_package == 'true' && needs.rbe.outputs.mode == 'remote' }} - run: bazel build --@rules_go//go/config:race //cmd/bd:bd_for_tests --remote_download_regex='.*/bin/cmd/bd/bd_for_tests/bd$' --norun_validations + run: bazel build --@rules_go//go/config:race //cmd/bd:bd_for_tests --remote_download_regex='.*/bin/cmd/bd/bd_for_tests/bd$' - name: Package the Bazel-built bd if: ${{ steps.detect.outputs.mcp_package == 'true' && needs.rbe.outputs.mode == 'remote' }} @@ -3043,7 +2389,7 @@ jobs: # bazel-out/k8-fastbuild-ST-.../bin/cmd/bd/bd_for_tests/bd path). - name: bazel build //cmd/bd:bd_for_tests if: ${{ steps.detect.outputs.npm_package == 'true' && needs.rbe.outputs.mode == 'remote' }} - run: bazel build --@rules_go//go/config:race //cmd/bd:bd_for_tests --remote_download_regex='.*/bin/cmd/bd/bd_for_tests/bd$' --norun_validations + run: bazel build --@rules_go//go/config:race //cmd/bd:bd_for_tests --remote_download_regex='.*/bin/cmd/bd/bd_for_tests/bd$' - name: Package the Bazel-built bd if: ${{ steps.detect.outputs.npm_package == 'true' && needs.rbe.outputs.mode == 'remote' }} @@ -3105,138 +2451,3 @@ jobs: env: JOB_STATUS: ${{ job.status }} run: echo "result=$JOB_STATUS" >> "$GITHUB_OUTPUT" - - # The remote repo contents cache's only writer (ga-vnycm2.29, ported from - # gascity's bazel.yml). On a push to main, with the rbe job's rrc not off, - # run every lane's loading and analysis (.github/scripts/rrc-lane-commands.txt, - # --nobuild): only main's repository rules and Starlark run (gazelle's - # fetch_repo, the Go SDK and LLVM downloads, extraction: what every lane - # already runs on its runner), never a build or test action. Bazel uploads - # each reproducible repository's tree (--remote_upload_local_results) with - # a 30-minute rbe-rrc-writer-beads certificate that rbe-west's mint signs - # only for this workflow on a push to main - # (.github/scripts/rrc-writer-credential.sh); rbe-west's rrc-gate admits - # repo-contents entries from it and refuses every other action cache - # write, and the certificate cannot Execute. Cache only (--remote_cache, - # no executor). Not a lane: no result output, never in pr.yml's gate - # (which never sees it anyway: push only), so a failed seed only leaves the - # lanes fetching. setup-bazel runs in local mode (no secrets): its rc, the - # runner cache and the pinned Bazel, nothing else. The only bazel.yml job - # with id-token: write; every caller must grant it (GitHub checks a called - # workflow's job permissions at startup, even for a job that skips), and - # the mint refuses any token but a main-push bazel.yml one. - rrc-seed: - name: repo contents cache seed - needs: rbe - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc != 'off' }} - runs-on: blacksmith-8vcpu-ubuntu-2404 - timeout-minutes: 30 - permissions: - contents: read - id-token: write # the rbe-rrc-writer-beads certificate (GitHub OIDC) - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - name: Set up Bazel - uses: ./.github/actions/setup-bazel - - name: rbe-rrc-writer certificate - id: writer - env: - BAZEL_CI_SECRET_DIR: ${{ runner.temp }}/bazel-ci-secret - run: bash .github/scripts/rrc-writer-credential.sh - - name: Seed the remote repo contents cache - if: ${{ steps.writer.outputs.cert != '' }} - env: - CERT: ${{ steps.writer.outputs.cert }} - KEY: ${{ steps.writer.outputs.key }} - ENDPOINT: ${{ steps.writer.outputs.endpoint }} - INSTANCE: ${{ steps.writer.outputs.instance }} - run: >- - bash .github/scripts/rrc-run-lanes.sh --experimental_remote_repo_contents_cache -- - --loading_phase_threads=64 - "--remote_cache=$ENDPOINT" "--remote_instance_name=$INSTANCE" - "--tls_client_certificate=$CERT" "--tls_client_key=$KEY" - --remote_upload_local_results - - name: Remove the writer key - if: ${{ always() }} - run: rm -f -- "$RUNNER_TEMP/bazel-ci-secret/rrc-writer.key" "$RUNNER_TEMP/bazel-ci-secret/rrc-writer.crt" - - # Nightly check of the remote repo contents cache (gascity design R1/R2). A - # cached repository tree is trusted by every reader, and nothing on the - # reader checks it against what its rule produces. So, from nightly.yml (or - # a dispatch), fetch every lane's repositories cold (rrc-lane-commands.txt - # with --nobuild and no repo contents cache, Bazel set up exactly as a - # lane) and compare each repository's tree and marker with the cached - # entry a lane would read for the same key (tools/bazel/rrc_verify.py, - # reads only, with the lanes' certificate and the endpoint from - # setup-bazel's rc: no secret is referenced outside setup-bazel). A - # mismatch is a poisoned entry or a rule falsely marked reproducible: the - # job fails and opens (or comments on) an rrc-verify issue. Not a lane: - # never gated. The only bazel.yml job with issues: write; every caller - # must grant it, as for rrc-seed's id-token. - rrc-verify: - name: repo contents cache verify - needs: rbe - if: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && needs.rbe.outputs.mode == 'remote' && needs.rbe.outputs.rrc != 'off' }} - runs-on: blacksmith-8vcpu-ubuntu-2404 - timeout-minutes: 45 - permissions: - contents: read - issues: write # the rrc-verify alert issue - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - name: Set up Bazel - uses: ./.github/actions/setup-bazel - env: - BAZEL_REMOTE_EXECUTOR: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_WEST_EXECUTOR || '' }} - RBE_TLS_CERT: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CERT || '' }} - RBE_TLS_KEY: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_KEY || '' }} - RBE_TLS_CA: ${{ needs.rbe.outputs.mode == 'remote' && secrets.RBE_TLS_CA || '' }} - RBE_INSTANCE: ${{ needs.rbe.outputs.mode == 'remote' && 'oss' || '' }} - - name: Cold fetch (every lane, no repo contents cache) - run: bash .github/scripts/rrc-run-lanes.sh -- --loading_phase_threads=64 - - name: Compare with the cache - id: verify - run: | - set -euo pipefail - secret_dir="$RUNNER_TEMP/bazel-ci-secret" - prefix='build:remote-exec --remote_executor=' - endpoint=$(grep -F -m1 "$prefix" "$secret_dir/ci.bazelrc" || true) - endpoint=${endpoint#"$prefix"} - [ -n "$endpoint" ] || { echo "::error::setup-bazel's rc names no executor"; exit 1; } - python3 tools/bazel/rrc_verify.py \ - --output-base "$(bazel info output_base)" \ - --endpoint "$endpoint" --instance oss \ - --cert "$secret_dir/client.crt" --key "$secret_dir/client.key" \ - --bazel-version "$(tr -d '[:space:]' < .bazelversion)" \ - --json "$RUNNER_TEMP/rrc-verify.json" --summary "$GITHUB_STEP_SUMMARY" - - name: Upload the report - if: ${{ always() && hashFiles(format('{0}/rrc-verify.json', runner.temp)) != '' }} - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 - with: - overwrite: true # a job re-run is the same run: replace, not 409 - name: rrc-verify-${{ github.run_attempt }} - path: ${{ runner.temp }}/rrc-verify.json - retention-days: 30 - - name: Alert (rrc-verify issue) - if: ${{ failure() && steps.verify.outcome == 'failure' }} - env: - GH_TOKEN: ${{ github.token }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - run: | - set -euo pipefail - title="rrc-verify: remote repo contents cache differs from a cold fetch" - body="The nightly rrc-verify run found cached repository trees that differ from a cold fetch, or could not check them: $RUN_URL (summary and the rrc-verify report artifact). - - A mismatch is a poisoned entry or a repository rule falsely marked reproducible (gascity engdocs/design/bazel-remote-repo-contents-cache.md, R1/R2). Contain the fork-cache readers first: they see no repository variables, so (1) commit fork_rrc_read=off in both probe scripts, beads .github/actions/setup-bazel/cache-rrc-probe.sh and gascity tools/rbe/cache-rrc-probe.sh (beads has no fresh-merge: an open fork PR keeps the old switch until it is pushed again); (2) for immediate server-side containment, an operator runs rbe-cache-gate close on core, which stops all fork-cache, and fails fork-cache lanes already reading; (3) on a mismatch, set RBE_REPO_CONTENTS_CACHE to seed: the trusted readers read the same entries (rbe-cache serves the oss action cache), and seed stops every one of them while rrc-seed and this check keep running; set it to off only to stop seeding too, which also stops rrc-verify; if this run only says it could not check, leave the variable as it is. Then follow gascity/infra nativelink-cas/west/README.md (remote repo contents cache writer, poisoned entries)." - gh label create rrc-verify -R "$GITHUB_REPOSITORY" --color B60205 \ - --description "Remote repo contents cache verification failures" 2>/dev/null || true - n=$(gh issue list -R "$GITHUB_REPOSITORY" --label rrc-verify --state open --json number --jq '.[0].number // empty') - if [ -n "$n" ]; then - gh issue comment "$n" -R "$GITHUB_REPOSITORY" --body "Again: $RUN_URL" - else - gh issue create -R "$GITHUB_REPOSITORY" --label rrc-verify --title "$title" --body "$body" - fi diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7bd190a2d..56f6a23e7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -25,18 +25,6 @@ jobs: # engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md). 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 }} diff --git a/.github/workflows/pr-risk.yml b/.github/workflows/pr-risk.yml index 155b3b944..bf7960b75 100644 --- a/.github/workflows/pr-risk.yml +++ b/.github/workflows/pr-risk.yml @@ -24,8 +24,8 @@ env: # 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 +# tier`, `proxied-server tier` 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. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 22dc8c23e..9483e2b36 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1347,18 +1347,8 @@ jobs: # build their own bd via this call's rbe job. bazel: name: Bazel - # 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 secrets: RBE_WEST_EXECUTOR: ${{ secrets.RBE_WEST_EXECUTOR }} diff --git a/.github/workflows/update-vendor-hash.yml b/.github/workflows/update-vendor-hash.yml index 8ad1b449f..16b841a59 100644 --- a/.github/workflows/update-vendor-hash.yml +++ b/.github/workflows/update-vendor-hash.yml @@ -82,14 +82,6 @@ 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: | diff --git a/.github/workflows/worker-env-autosync.yml b/.github/workflows/worker-env-autosync.yml deleted file mode 100644 index 2978a5617..000000000 --- a/.github/workflows/worker-env-autosync.yml +++ /dev/null @@ -1,196 +0,0 @@ -# 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 <> "$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" diff --git a/.golangci.yml b/.golangci.yml index 1ed2975a4..5af1120fe 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -467,28 +467,12 @@ 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. - # - # `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$' + - path: '^cmd/bd/(close|duplicates|find_duplicates|gate|gc|graph|info|label|orphans|purge|search|todo|wisp|human)(_proxied_server)?\.go$' text: 'do not write a filter here' linters: - forbidigo # Molecule reporting: each selects the members of one molecule. - # - # `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$' + - path: '^cmd/bd/mol_(current|port|progress|ready_gated|stale)\.go$' text: 'do not write a filter here' linters: - forbidigo diff --git a/AGENTS.md b/AGENTS.md index e908a5070..1a450309e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -126,29 +126,9 @@ make install # build and install bd to ~/.local/bin (canonical) 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). +- `go test` (`./scripts/test.sh`, `make test-go`) is an inner-loop + convenience only. CI does not enforce it, and it skips nogo, gofmt and the + guards; finish with `make test`. - **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`, diff --git a/BUILD.bazel b/BUILD.bazel index 0a1d10355..97db2f488 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -22,7 +22,6 @@ gazelle(name = "gazelle") exports_files( [".buildflags"], visibility = [ - "//scripts:__pkg__", "//scripts/prlintmake:__pkg__", "//tests/upgrade_smoke:__pkg__", ], @@ -34,11 +33,9 @@ exports_files([ ]) # The golangci-lint configuration nogo applies (//tools/nogo), and its test. -# //test/docsync checks the agent instructions' links to it. exports_files( [".golangci.yml"], visibility = [ - "//test/docsync:__pkg__", "//tools/nogo:__pkg__", "//tools/nogo/internal/golangci:__pkg__", ], @@ -52,8 +49,7 @@ exports_files( ) # //tests/hook_timeout_backends: the tracked git hooks whose managed section -# it runs against real timeout implementations. //scripts:shell_scripts_test -# runs pre-push's suite dispatch. +# it runs against real timeout implementations. exports_files( [ ".githooks/post-checkout", @@ -62,56 +58,7 @@ exports_files( ".githooks/pre-push", ".githooks/prepare-commit-msg", ], - visibility = [ - "//scripts:__pkg__", - "//tests/hook_timeout_backends:__pkg__", - ], -) - -# //scripts:shell_scripts_test: scripts/test.sh's skip list. -exports_files( - [".test-skip"], - visibility = ["//scripts:__pkg__"], -) - -# //scripts:shell_scripts_test: Oracle A's runner, whose EXIT-trap removal of -# its reference worktree oracle_a_script_test.go checks in a fixture repository. -exports_files( - ["tests/oracle-a/run-oracle-a.sh"], - visibility = ["//scripts:__pkg__"], -) - -# The nested Go modules' go.mod files, which mark where the root module ends: -# //scripts:go_test_sources_test's scan of every _test.go file skips their -# trees, as `go test ./...` does. (go.mod is in no Go partition below: it is -# in //:repo_other_files.) -filegroup( - name = "nested_go_modules", - srcs = [ - "examples/bd-example-extension-go/go.mod", - "examples/library-usage/go.mod", - "//tools/nogo:go.mod", - ], - visibility = ["//scripts:__pkg__"], -) - -# //scripts/repochecks:winget_portable_alias_test: the winget manifests. -filegroup( - name = "winget_manifests", - srcs = glob(["winget/**"]), - visibility = ["//scripts/repochecks:__pkg__"], -) - -# //test/docsync: the repository files outside its Markdown and Go-test -# partitions that the docs and agent instructions link to by path. A new link -# to a file not listed here fails docsync_test under Bazel; add the file. -exports_files( - [ - ".github/workflows/bazel.yml", - "beads.go", - "docs/docs.json", - ], - visibility = ["//test/docsync:__pkg__"], + visibility = ["//tests/hook_timeout_backends:__pkg__"], ) # //cmd/bd:bd_test: tracked git hooks (generator parity) and the formula @@ -132,13 +79,11 @@ exports_files( # PR Risk's manifest-sharded tiers' shard scripts and their committed # manifests (embedded-Dolt cmd and storage, proxied-server cmd, server-Dolt -# storage). The variants (//cmd/bd:bd_embedded_test and -# //cmd/bd:bd_embedded_part2_test, //cmd/bd:bd_proxied_test, +# storage). The variants (//cmd/bd:bd_embedded_test, //cmd/bd:bd_proxied_test, # //internal/storage/embeddeddolt:embeddeddolt_embedded_test, # //internal/storage/dolt:dolt_server_full_test) run them through # tools/bazel/go_test_manifest_shard.sh, so each Bazel shard runs exactly the -# tests of the CI job with the same shard number. //scripts:go_test_sources_test -# checks the manifests and scripts against the tests they shard. +# tests of the CI job with the same shard number. exports_files( [ ".github/scripts/embedded-cmd-test-shards.txt", @@ -154,7 +99,6 @@ exports_files( "//cmd/bd:__pkg__", "//internal/storage/dolt:__pkg__", "//internal/storage/embeddeddolt:__pkg__", - "//scripts:__pkg__", ], ) @@ -253,716 +197,15 @@ exports_files( visibility = ["//internal/httpclient/encode:__pkg__"], ) -# --- begin go_srcs (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) --- - -filegroup( - name = "go_srcs", - srcs = glob( - ["**/*.go"], - allow_empty = True, - exclude = ["bazel-*/**"], - ), - visibility = ["//:__subpackages__"], -) - -# --- 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/**", - ".agents/**", - ".amp/**", - ".augment/**", - ".bazelrc.local", - ".claude/*.lock", - ".claude/*.log", - ".claude/settings.local.json", - ".codex/**", - ".cursor/**", - ".direnv/**", - ".envrc", - ".git/**", - ".idea/**", - ".logs/**", - ".vscode/**", - "bazel-*/**", - "bd", - "bd-fixed", - "bd-original", - "bd-test", - "bd_test", - "beads", - "go.work", - "go.work.sum", - "history/**", - "mcp_agent_mail/**", - "npm-package/bin/*.tar.gz", - "npm-package/bin/*.zip", - "npm-package/bin/CHANGELOG.md", - "npm-package/bin/LICENSE", - "npm-package/bin/README.md", - "npm-package/bin/bd", - "npm-package/package-lock.json", - "output", - "result", - "state.json", - "user.bazelrc", - ], - ) + [ - "//backend:repo_doc_files", - "//backend/conformance:repo_doc_files", - "//backend/http:repo_doc_files", - "//backend/http/corpus:repo_doc_files", - "//beadserrors:repo_doc_files", - "//cmd/bd:repo_doc_files", - "//cmd/bd/doctor:repo_doc_files", - "//cmd/bd/doctor/fix:repo_doc_files", - "//cmd/bd/protocol:repo_doc_files", - "//cmd/bd/setup:repo_doc_files", - "//format:repo_doc_files", - "//internal/ado:repo_doc_files", - "//internal/atomicfile:repo_doc_files", - "//internal/audit:repo_doc_files", - "//internal/beads:repo_doc_files", - "//internal/ceiling:repo_doc_files", - "//internal/compact:repo_doc_files", - "//internal/config:repo_doc_files", - "//internal/configfile:repo_doc_files", - "//internal/creds:repo_doc_files", - "//internal/debug:repo_doc_files", - "//internal/doltremote:repo_doc_files", - "//internal/doltserver:repo_doc_files", - "//internal/doltversion:repo_doc_files", - "//internal/eventsjournal:repo_doc_files", - "//internal/execenv:repo_doc_files", - "//internal/fdhygiene:repo_doc_files", - "//internal/formula:repo_doc_files", - "//internal/formula/cmd/schemagen:repo_doc_files", - "//internal/formula/schemagen:repo_doc_files", - "//internal/git:repo_doc_files", - "//internal/gitenv:repo_doc_files", - "//internal/githooksenv:repo_doc_files", - "//internal/github:repo_doc_files", - "//internal/gitignore:repo_doc_files", - "//internal/gitlab:repo_doc_files", - "//internal/gittraceenv:repo_doc_files", - "//internal/hooks:repo_doc_files", - "//internal/httpapi:repo_doc_files", - "//internal/httpapi/apigen:repo_doc_files", - "//internal/httpapi/spec:repo_doc_files", - "//internal/httpapi/wireshape:repo_doc_files", - "//internal/httpapi/wireshape/cmd/gendigest:repo_doc_files", - "//internal/httpclient:repo_doc_files", - "//internal/httpclient/encode:repo_doc_files", - "//internal/httpclient/wire:repo_doc_files", - "//internal/idgen:repo_doc_files", - "//internal/initprocs:repo_doc_files", - "//internal/jira:repo_doc_files", - "//internal/linear:repo_doc_files", - "//internal/lockfile:repo_doc_files", - "//internal/memoryapi:repo_doc_files", - "//internal/metrics:repo_doc_files", - "//internal/migration:repo_doc_files", - "//internal/migration/legacysqlite:repo_doc_files", - "//internal/molecules:repo_doc_files", - "//internal/notion:repo_doc_files", - "//internal/procid:repo_doc_files", - "//internal/query:repo_doc_files", - "//internal/recipes:repo_doc_files", - "//internal/remotecache:repo_doc_files", - "//internal/routing:repo_doc_files", - "//internal/storage:repo_doc_files", - "//internal/storage/backendnames:repo_doc_files", - "//internal/storage/backends:repo_doc_files", - "//internal/storage/batchbench:repo_doc_files", - "//internal/storage/batchfixtures:repo_doc_files", - "//internal/storage/contextinfo:repo_doc_files", - "//internal/storage/createbatchequiv:repo_doc_files", - "//internal/storage/dberrors:repo_doc_files", - "//internal/storage/dbproxy/identity:repo_doc_files", - "//internal/storage/dbproxy/pidfile:repo_doc_files", - "//internal/storage/dbproxy/proxy:repo_doc_files", - "//internal/storage/dbproxy/server:repo_doc_files", - "//internal/storage/dbproxy/util:repo_doc_files", - "//internal/storage/depid:repo_doc_files", - "//internal/storage/dolt:repo_doc_files", - "//internal/storage/doltutil:repo_doc_files", - "//internal/storage/domain:repo_doc_files", - "//internal/storage/domain/db:repo_doc_files", - "//internal/storage/domain/fs:repo_doc_files", - "//internal/storage/domain/git:repo_doc_files", - "//internal/storage/embeddeddolt:repo_doc_files", - "//internal/storage/embeddeddolt/cmd:repo_doc_files", - "//internal/storage/externaldeps:repo_doc_files", - "//internal/storage/fs:repo_doc_files", - "//internal/storage/git:repo_doc_files", - "//internal/storage/historyoffequiv:repo_doc_files", - "//internal/storage/issueops:repo_doc_files", - "//internal/storage/journalscan:repo_doc_files", - "//internal/storage/kvkeys:repo_doc_files", - "//internal/storage/memoryops:repo_doc_files", - "//internal/storage/rowid:repo_doc_files", - "//internal/storage/schema:repo_doc_files", - "//internal/storage/sqlbuild:repo_doc_files", - "//internal/storage/sqlclass:repo_doc_files", - "//internal/storage/sqlcount:repo_doc_files", - "//internal/storage/storagecontract:repo_doc_files", - "//internal/storage/unsupportedgen:repo_doc_files", - "//internal/storage/uow:repo_doc_files", - "//internal/storage/versioncontrolops:repo_doc_files", - "//internal/telemetry:repo_doc_files", - "//internal/templates:repo_doc_files", - "//internal/templates/agents:repo_doc_files", - "//internal/testutil:repo_doc_files", - "//internal/testutil/bazeltest:repo_doc_files", - "//internal/testutil/credentialcmd:repo_doc_files", - "//internal/testutil/fixtures:repo_doc_files", - "//internal/testutil/integration:repo_doc_files", - "//internal/timeparsing:repo_doc_files", - "//internal/tracker:repo_doc_files", - "//internal/tracker/conformance:repo_doc_files", - "//internal/types:repo_doc_files", - "//internal/ui:repo_doc_files", - "//internal/uimd:repo_doc_files", - "//internal/utils:repo_doc_files", - "//internal/validation:repo_doc_files", - "//internal/versioncheck:repo_doc_files", - "//internal/versionedhistory:repo_doc_files", - "//internal/workapi:repo_doc_files", - "//internal/workapi/storecounter:repo_doc_files", - "//internal/workapi/storequerier:repo_doc_files", - "//internal/workapi/storereader:repo_doc_files", - "//internal/workapi/storereadycounter:repo_doc_files", - "//internal/workapi/storestats:repo_doc_files", - "//internal/workapi/storeversionreconciler:repo_doc_files", - "//internal/workapi/storeworkspaceconfig:repo_doc_files", - "//internal/workspacegate:repo_doc_files", - "//internal/worktreeremove:repo_doc_files", - "//issueops:repo_doc_files", - "//journalops:repo_doc_files", - "//memoryops:repo_doc_files", - "//platforms:repo_doc_files", - "//plugins/beads:repo_doc_files", - "//schema:repo_doc_files", - "//scripts:repo_doc_files", - "//scripts/bench-ready-indexes:repo_doc_files", - "//scripts/check-versions:repo_doc_files", - "//scripts/checkworkflowtags:repo_doc_files", - "//scripts/gitattributespolicy:repo_doc_files", - "//scripts/internal/testbash:repo_doc_files", - "//scripts/migration-test/catalog:repo_doc_files", - "//scripts/pr-lint:repo_doc_files", - "//scripts/prlintmake:repo_doc_files", - "//scripts/repochecks:repo_doc_files", - "//scripts/repro-dolt-hang:repo_doc_files", - "//scripts/repro-dolt-prod-timeouts:repo_doc_files", - "//scripts/workflowtags:repo_doc_files", - "//test/conformance:repo_doc_files", - "//test/docsync:repo_doc_files", - "//test/embedder:repo_doc_files", - "//test/testmainconvention:repo_doc_files", - "//tests/hook_timeout_backends:repo_doc_files", - "//tests/migration:repo_doc_files", - "//tests/regression:repo_doc_files", - "//tests/upgrade_smoke:repo_doc_files", - "//third_party/cc_toolchain:repo_doc_files", - "//third_party/patches:repo_doc_files", - "//tools/bazel:repo_doc_files", - "//tools/docsmint:repo_doc_files", - "//tools/nogo:repo_doc_files", - "//tools/nogo/analyzers/depguard:repo_doc_files", - "//tools/nogo/analyzers/errcheck:repo_doc_files", - "//tools/nogo/analyzers/forbidigo:repo_doc_files", - "//tools/nogo/analyzers/gosec:repo_doc_files", - "//tools/nogo/analyzers/misspell:repo_doc_files", - "//tools/nogo/analyzers/sloglint:repo_doc_files", - "//tools/nogo/analyzers/unconvert:repo_doc_files", - "//tools/nogo/analyzers/unparam:repo_doc_files", - "//tools/nogo/internal/analyzertest:repo_doc_files", - "//tools/nogo/internal/golangci:repo_doc_files", - "//tools/nogo/internal/position:repo_doc_files", - ], - visibility = ["//:__subpackages__"], -) - filegroup( name = "repo_files", - srcs = [ - ":repo_doc_files", - ":repo_go_srcs", - ":repo_go_test_srcs", - ":repo_other_files", - ], - visibility = [ - "//scripts:__pkg__", - "//scripts/repochecks:__pkg__", - ], -) - -filegroup( - name = "repo_go_srcs", - srcs = glob( - ["**/*.go"], - allow_empty = True, - exclude = [ - "**/*_test.go", - "**/node_modules/**", - ".agents/**", - ".amp/**", - ".augment/**", - ".bazelrc.local", - ".claude/*.lock", - ".claude/*.log", - ".claude/settings.local.json", - ".codex/**", - ".cursor/**", - ".direnv/**", - ".envrc", - ".git/**", - ".idea/**", - ".logs/**", - ".vscode/**", - "bazel-*/**", - "bd", - "bd-fixed", - "bd-original", - "bd-test", - "bd_test", - "beads", - "go.work", - "go.work.sum", - "history/**", - "mcp_agent_mail/**", - "npm-package/bin/*.tar.gz", - "npm-package/bin/*.zip", - "npm-package/bin/CHANGELOG.md", - "npm-package/bin/LICENSE", - "npm-package/bin/README.md", - "npm-package/bin/bd", - "npm-package/package-lock.json", - "output", - "result", - "state.json", - "user.bazelrc", - ], - ) + [ - "//backend:repo_go_srcs", - "//backend/conformance:repo_go_srcs", - "//backend/http:repo_go_srcs", - "//backend/http/corpus:repo_go_srcs", - "//beadserrors:repo_go_srcs", - "//cmd/bd:repo_go_srcs", - "//cmd/bd/doctor:repo_go_srcs", - "//cmd/bd/doctor/fix:repo_go_srcs", - "//cmd/bd/protocol:repo_go_srcs", - "//cmd/bd/setup:repo_go_srcs", - "//format:repo_go_srcs", - "//internal/ado:repo_go_srcs", - "//internal/atomicfile:repo_go_srcs", - "//internal/audit:repo_go_srcs", - "//internal/beads:repo_go_srcs", - "//internal/ceiling:repo_go_srcs", - "//internal/compact:repo_go_srcs", - "//internal/config:repo_go_srcs", - "//internal/configfile:repo_go_srcs", - "//internal/creds:repo_go_srcs", - "//internal/debug:repo_go_srcs", - "//internal/doltremote:repo_go_srcs", - "//internal/doltserver:repo_go_srcs", - "//internal/doltversion:repo_go_srcs", - "//internal/eventsjournal:repo_go_srcs", - "//internal/execenv:repo_go_srcs", - "//internal/fdhygiene:repo_go_srcs", - "//internal/formula:repo_go_srcs", - "//internal/formula/cmd/schemagen:repo_go_srcs", - "//internal/formula/schemagen:repo_go_srcs", - "//internal/git:repo_go_srcs", - "//internal/gitenv:repo_go_srcs", - "//internal/githooksenv:repo_go_srcs", - "//internal/github:repo_go_srcs", - "//internal/gitignore:repo_go_srcs", - "//internal/gitlab:repo_go_srcs", - "//internal/gittraceenv:repo_go_srcs", - "//internal/hooks:repo_go_srcs", - "//internal/httpapi:repo_go_srcs", - "//internal/httpapi/apigen:repo_go_srcs", - "//internal/httpapi/spec:repo_go_srcs", - "//internal/httpapi/wireshape:repo_go_srcs", - "//internal/httpapi/wireshape/cmd/gendigest:repo_go_srcs", - "//internal/httpclient:repo_go_srcs", - "//internal/httpclient/encode:repo_go_srcs", - "//internal/httpclient/wire:repo_go_srcs", - "//internal/idgen:repo_go_srcs", - "//internal/initprocs:repo_go_srcs", - "//internal/jira:repo_go_srcs", - "//internal/linear:repo_go_srcs", - "//internal/lockfile:repo_go_srcs", - "//internal/memoryapi:repo_go_srcs", - "//internal/metrics:repo_go_srcs", - "//internal/migration:repo_go_srcs", - "//internal/migration/legacysqlite:repo_go_srcs", - "//internal/molecules:repo_go_srcs", - "//internal/notion:repo_go_srcs", - "//internal/procid:repo_go_srcs", - "//internal/query:repo_go_srcs", - "//internal/recipes:repo_go_srcs", - "//internal/remotecache:repo_go_srcs", - "//internal/routing:repo_go_srcs", - "//internal/storage:repo_go_srcs", - "//internal/storage/backendnames:repo_go_srcs", - "//internal/storage/backends:repo_go_srcs", - "//internal/storage/batchbench:repo_go_srcs", - "//internal/storage/batchfixtures:repo_go_srcs", - "//internal/storage/contextinfo:repo_go_srcs", - "//internal/storage/createbatchequiv:repo_go_srcs", - "//internal/storage/dberrors:repo_go_srcs", - "//internal/storage/dbproxy/identity:repo_go_srcs", - "//internal/storage/dbproxy/pidfile:repo_go_srcs", - "//internal/storage/dbproxy/proxy:repo_go_srcs", - "//internal/storage/dbproxy/server:repo_go_srcs", - "//internal/storage/dbproxy/util:repo_go_srcs", - "//internal/storage/depid:repo_go_srcs", - "//internal/storage/dolt:repo_go_srcs", - "//internal/storage/doltutil:repo_go_srcs", - "//internal/storage/domain:repo_go_srcs", - "//internal/storage/domain/db:repo_go_srcs", - "//internal/storage/domain/fs:repo_go_srcs", - "//internal/storage/domain/git:repo_go_srcs", - "//internal/storage/embeddeddolt:repo_go_srcs", - "//internal/storage/embeddeddolt/cmd:repo_go_srcs", - "//internal/storage/externaldeps:repo_go_srcs", - "//internal/storage/fs:repo_go_srcs", - "//internal/storage/git:repo_go_srcs", - "//internal/storage/historyoffequiv:repo_go_srcs", - "//internal/storage/issueops:repo_go_srcs", - "//internal/storage/journalscan:repo_go_srcs", - "//internal/storage/kvkeys:repo_go_srcs", - "//internal/storage/memoryops:repo_go_srcs", - "//internal/storage/rowid:repo_go_srcs", - "//internal/storage/schema:repo_go_srcs", - "//internal/storage/sqlbuild:repo_go_srcs", - "//internal/storage/sqlclass:repo_go_srcs", - "//internal/storage/sqlcount:repo_go_srcs", - "//internal/storage/storagecontract:repo_go_srcs", - "//internal/storage/unsupportedgen:repo_go_srcs", - "//internal/storage/uow:repo_go_srcs", - "//internal/storage/versioncontrolops:repo_go_srcs", - "//internal/telemetry:repo_go_srcs", - "//internal/templates:repo_go_srcs", - "//internal/templates/agents:repo_go_srcs", - "//internal/testutil:repo_go_srcs", - "//internal/testutil/bazeltest:repo_go_srcs", - "//internal/testutil/credentialcmd:repo_go_srcs", - "//internal/testutil/fixtures:repo_go_srcs", - "//internal/testutil/integration:repo_go_srcs", - "//internal/timeparsing:repo_go_srcs", - "//internal/tracker:repo_go_srcs", - "//internal/tracker/conformance:repo_go_srcs", - "//internal/types:repo_go_srcs", - "//internal/ui:repo_go_srcs", - "//internal/uimd:repo_go_srcs", - "//internal/utils:repo_go_srcs", - "//internal/validation:repo_go_srcs", - "//internal/versioncheck:repo_go_srcs", - "//internal/versionedhistory:repo_go_srcs", - "//internal/workapi:repo_go_srcs", - "//internal/workapi/storecounter:repo_go_srcs", - "//internal/workapi/storequerier:repo_go_srcs", - "//internal/workapi/storereader:repo_go_srcs", - "//internal/workapi/storereadycounter:repo_go_srcs", - "//internal/workapi/storestats:repo_go_srcs", - "//internal/workapi/storeversionreconciler:repo_go_srcs", - "//internal/workapi/storeworkspaceconfig:repo_go_srcs", - "//internal/workspacegate:repo_go_srcs", - "//internal/worktreeremove:repo_go_srcs", - "//issueops:repo_go_srcs", - "//journalops:repo_go_srcs", - "//memoryops:repo_go_srcs", - "//platforms:repo_go_srcs", - "//plugins/beads:repo_go_srcs", - "//schema:repo_go_srcs", - "//scripts:repo_go_srcs", - "//scripts/bench-ready-indexes:repo_go_srcs", - "//scripts/check-versions:repo_go_srcs", - "//scripts/checkworkflowtags:repo_go_srcs", - "//scripts/gitattributespolicy:repo_go_srcs", - "//scripts/internal/testbash:repo_go_srcs", - "//scripts/migration-test/catalog:repo_go_srcs", - "//scripts/pr-lint:repo_go_srcs", - "//scripts/prlintmake:repo_go_srcs", - "//scripts/repochecks:repo_go_srcs", - "//scripts/repro-dolt-hang:repo_go_srcs", - "//scripts/repro-dolt-prod-timeouts:repo_go_srcs", - "//scripts/workflowtags:repo_go_srcs", - "//test/conformance:repo_go_srcs", - "//test/docsync:repo_go_srcs", - "//test/embedder:repo_go_srcs", - "//test/testmainconvention:repo_go_srcs", - "//tests/hook_timeout_backends:repo_go_srcs", - "//tests/migration:repo_go_srcs", - "//tests/regression:repo_go_srcs", - "//tests/upgrade_smoke:repo_go_srcs", - "//third_party/cc_toolchain:repo_go_srcs", - "//third_party/patches:repo_go_srcs", - "//tools/bazel:repo_go_srcs", - "//tools/docsmint:repo_go_srcs", - "//tools/nogo:repo_go_srcs", - "//tools/nogo/analyzers/depguard:repo_go_srcs", - "//tools/nogo/analyzers/errcheck:repo_go_srcs", - "//tools/nogo/analyzers/forbidigo:repo_go_srcs", - "//tools/nogo/analyzers/gosec:repo_go_srcs", - "//tools/nogo/analyzers/misspell:repo_go_srcs", - "//tools/nogo/analyzers/sloglint:repo_go_srcs", - "//tools/nogo/analyzers/unconvert:repo_go_srcs", - "//tools/nogo/analyzers/unparam:repo_go_srcs", - "//tools/nogo/internal/analyzertest:repo_go_srcs", - "//tools/nogo/internal/golangci:repo_go_srcs", - "//tools/nogo/internal/position:repo_go_srcs", - ], - visibility = ["//:__subpackages__"], -) - -filegroup( - name = "repo_go_test_srcs", - srcs = glob( - ["**/*_test.go"], - allow_empty = True, - exclude = [ - "**/node_modules/**", - ".agents/**", - ".amp/**", - ".augment/**", - ".bazelrc.local", - ".claude/*.lock", - ".claude/*.log", - ".claude/settings.local.json", - ".codex/**", - ".cursor/**", - ".direnv/**", - ".envrc", - ".git/**", - ".idea/**", - ".logs/**", - ".vscode/**", - "bazel-*/**", - "bd", - "bd-fixed", - "bd-original", - "bd-test", - "bd_test", - "beads", - "go.work", - "go.work.sum", - "history/**", - "mcp_agent_mail/**", - "npm-package/bin/*.tar.gz", - "npm-package/bin/*.zip", - "npm-package/bin/CHANGELOG.md", - "npm-package/bin/LICENSE", - "npm-package/bin/README.md", - "npm-package/bin/bd", - "npm-package/package-lock.json", - "output", - "result", - "state.json", - "user.bazelrc", - ], - ) + [ - "//backend:repo_go_test_srcs", - "//backend/conformance:repo_go_test_srcs", - "//backend/http:repo_go_test_srcs", - "//backend/http/corpus:repo_go_test_srcs", - "//beadserrors:repo_go_test_srcs", - "//cmd/bd:repo_go_test_srcs", - "//cmd/bd/doctor:repo_go_test_srcs", - "//cmd/bd/doctor/fix:repo_go_test_srcs", - "//cmd/bd/protocol:repo_go_test_srcs", - "//cmd/bd/setup:repo_go_test_srcs", - "//format:repo_go_test_srcs", - "//internal/ado:repo_go_test_srcs", - "//internal/atomicfile:repo_go_test_srcs", - "//internal/audit:repo_go_test_srcs", - "//internal/beads:repo_go_test_srcs", - "//internal/ceiling:repo_go_test_srcs", - "//internal/compact:repo_go_test_srcs", - "//internal/config:repo_go_test_srcs", - "//internal/configfile:repo_go_test_srcs", - "//internal/creds:repo_go_test_srcs", - "//internal/debug:repo_go_test_srcs", - "//internal/doltremote:repo_go_test_srcs", - "//internal/doltserver:repo_go_test_srcs", - "//internal/doltversion:repo_go_test_srcs", - "//internal/eventsjournal:repo_go_test_srcs", - "//internal/execenv:repo_go_test_srcs", - "//internal/fdhygiene:repo_go_test_srcs", - "//internal/formula:repo_go_test_srcs", - "//internal/formula/cmd/schemagen:repo_go_test_srcs", - "//internal/formula/schemagen:repo_go_test_srcs", - "//internal/git:repo_go_test_srcs", - "//internal/gitenv:repo_go_test_srcs", - "//internal/githooksenv:repo_go_test_srcs", - "//internal/github:repo_go_test_srcs", - "//internal/gitignore:repo_go_test_srcs", - "//internal/gitlab:repo_go_test_srcs", - "//internal/gittraceenv:repo_go_test_srcs", - "//internal/hooks:repo_go_test_srcs", - "//internal/httpapi:repo_go_test_srcs", - "//internal/httpapi/apigen:repo_go_test_srcs", - "//internal/httpapi/spec:repo_go_test_srcs", - "//internal/httpapi/wireshape:repo_go_test_srcs", - "//internal/httpapi/wireshape/cmd/gendigest:repo_go_test_srcs", - "//internal/httpclient:repo_go_test_srcs", - "//internal/httpclient/encode:repo_go_test_srcs", - "//internal/httpclient/wire:repo_go_test_srcs", - "//internal/idgen:repo_go_test_srcs", - "//internal/initprocs:repo_go_test_srcs", - "//internal/jira:repo_go_test_srcs", - "//internal/linear:repo_go_test_srcs", - "//internal/lockfile:repo_go_test_srcs", - "//internal/memoryapi:repo_go_test_srcs", - "//internal/metrics:repo_go_test_srcs", - "//internal/migration:repo_go_test_srcs", - "//internal/migration/legacysqlite:repo_go_test_srcs", - "//internal/molecules:repo_go_test_srcs", - "//internal/notion:repo_go_test_srcs", - "//internal/procid:repo_go_test_srcs", - "//internal/query:repo_go_test_srcs", - "//internal/recipes:repo_go_test_srcs", - "//internal/remotecache:repo_go_test_srcs", - "//internal/routing:repo_go_test_srcs", - "//internal/storage:repo_go_test_srcs", - "//internal/storage/backendnames:repo_go_test_srcs", - "//internal/storage/backends:repo_go_test_srcs", - "//internal/storage/batchbench:repo_go_test_srcs", - "//internal/storage/batchfixtures:repo_go_test_srcs", - "//internal/storage/contextinfo:repo_go_test_srcs", - "//internal/storage/createbatchequiv:repo_go_test_srcs", - "//internal/storage/dberrors:repo_go_test_srcs", - "//internal/storage/dbproxy/identity:repo_go_test_srcs", - "//internal/storage/dbproxy/pidfile:repo_go_test_srcs", - "//internal/storage/dbproxy/proxy:repo_go_test_srcs", - "//internal/storage/dbproxy/server:repo_go_test_srcs", - "//internal/storage/dbproxy/util:repo_go_test_srcs", - "//internal/storage/depid:repo_go_test_srcs", - "//internal/storage/dolt:repo_go_test_srcs", - "//internal/storage/doltutil:repo_go_test_srcs", - "//internal/storage/domain:repo_go_test_srcs", - "//internal/storage/domain/db:repo_go_test_srcs", - "//internal/storage/domain/fs:repo_go_test_srcs", - "//internal/storage/domain/git:repo_go_test_srcs", - "//internal/storage/embeddeddolt:repo_go_test_srcs", - "//internal/storage/embeddeddolt/cmd:repo_go_test_srcs", - "//internal/storage/externaldeps:repo_go_test_srcs", - "//internal/storage/fs:repo_go_test_srcs", - "//internal/storage/git:repo_go_test_srcs", - "//internal/storage/historyoffequiv:repo_go_test_srcs", - "//internal/storage/issueops:repo_go_test_srcs", - "//internal/storage/journalscan:repo_go_test_srcs", - "//internal/storage/kvkeys:repo_go_test_srcs", - "//internal/storage/memoryops:repo_go_test_srcs", - "//internal/storage/rowid:repo_go_test_srcs", - "//internal/storage/schema:repo_go_test_srcs", - "//internal/storage/sqlbuild:repo_go_test_srcs", - "//internal/storage/sqlclass:repo_go_test_srcs", - "//internal/storage/sqlcount:repo_go_test_srcs", - "//internal/storage/storagecontract:repo_go_test_srcs", - "//internal/storage/unsupportedgen:repo_go_test_srcs", - "//internal/storage/uow:repo_go_test_srcs", - "//internal/storage/versioncontrolops:repo_go_test_srcs", - "//internal/telemetry:repo_go_test_srcs", - "//internal/templates:repo_go_test_srcs", - "//internal/templates/agents:repo_go_test_srcs", - "//internal/testutil:repo_go_test_srcs", - "//internal/testutil/bazeltest:repo_go_test_srcs", - "//internal/testutil/credentialcmd:repo_go_test_srcs", - "//internal/testutil/fixtures:repo_go_test_srcs", - "//internal/testutil/integration:repo_go_test_srcs", - "//internal/timeparsing:repo_go_test_srcs", - "//internal/tracker:repo_go_test_srcs", - "//internal/tracker/conformance:repo_go_test_srcs", - "//internal/types:repo_go_test_srcs", - "//internal/ui:repo_go_test_srcs", - "//internal/uimd:repo_go_test_srcs", - "//internal/utils:repo_go_test_srcs", - "//internal/validation:repo_go_test_srcs", - "//internal/versioncheck:repo_go_test_srcs", - "//internal/versionedhistory:repo_go_test_srcs", - "//internal/workapi:repo_go_test_srcs", - "//internal/workapi/storecounter:repo_go_test_srcs", - "//internal/workapi/storequerier:repo_go_test_srcs", - "//internal/workapi/storereader:repo_go_test_srcs", - "//internal/workapi/storereadycounter:repo_go_test_srcs", - "//internal/workapi/storestats:repo_go_test_srcs", - "//internal/workapi/storeversionreconciler:repo_go_test_srcs", - "//internal/workapi/storeworkspaceconfig:repo_go_test_srcs", - "//internal/workspacegate:repo_go_test_srcs", - "//internal/worktreeremove:repo_go_test_srcs", - "//issueops:repo_go_test_srcs", - "//journalops:repo_go_test_srcs", - "//memoryops:repo_go_test_srcs", - "//platforms:repo_go_test_srcs", - "//plugins/beads:repo_go_test_srcs", - "//schema:repo_go_test_srcs", - "//scripts:repo_go_test_srcs", - "//scripts/bench-ready-indexes:repo_go_test_srcs", - "//scripts/check-versions:repo_go_test_srcs", - "//scripts/checkworkflowtags:repo_go_test_srcs", - "//scripts/gitattributespolicy:repo_go_test_srcs", - "//scripts/internal/testbash:repo_go_test_srcs", - "//scripts/migration-test/catalog:repo_go_test_srcs", - "//scripts/pr-lint:repo_go_test_srcs", - "//scripts/prlintmake:repo_go_test_srcs", - "//scripts/repochecks:repo_go_test_srcs", - "//scripts/repro-dolt-hang:repo_go_test_srcs", - "//scripts/repro-dolt-prod-timeouts:repo_go_test_srcs", - "//scripts/workflowtags:repo_go_test_srcs", - "//test/conformance:repo_go_test_srcs", - "//test/docsync:repo_go_test_srcs", - "//test/embedder:repo_go_test_srcs", - "//test/testmainconvention:repo_go_test_srcs", - "//tests/hook_timeout_backends:repo_go_test_srcs", - "//tests/migration:repo_go_test_srcs", - "//tests/regression:repo_go_test_srcs", - "//tests/upgrade_smoke:repo_go_test_srcs", - "//third_party/cc_toolchain:repo_go_test_srcs", - "//third_party/patches:repo_go_test_srcs", - "//tools/bazel:repo_go_test_srcs", - "//tools/docsmint:repo_go_test_srcs", - "//tools/nogo:repo_go_test_srcs", - "//tools/nogo/analyzers/depguard:repo_go_test_srcs", - "//tools/nogo/analyzers/errcheck:repo_go_test_srcs", - "//tools/nogo/analyzers/forbidigo:repo_go_test_srcs", - "//tools/nogo/analyzers/gosec:repo_go_test_srcs", - "//tools/nogo/analyzers/misspell:repo_go_test_srcs", - "//tools/nogo/analyzers/sloglint:repo_go_test_srcs", - "//tools/nogo/analyzers/unconvert:repo_go_test_srcs", - "//tools/nogo/analyzers/unparam:repo_go_test_srcs", - "//tools/nogo/internal/analyzertest:repo_go_test_srcs", - "//tools/nogo/internal/golangci:repo_go_test_srcs", - "//tools/nogo/internal/position:repo_go_test_srcs", - ], - visibility = ["//:__subpackages__"], -) - -filegroup( - name = "repo_other_files", srcs = glob( ["**"], exclude = [ "**/*.db", "**/*.exe", - "**/*.go", - "**/*.md", - "**/*.mdx", "**/*.out", "**/*.prof", "**/*.pyc", @@ -1008,180 +251,177 @@ filegroup( "user.bazelrc", ], ) + [ - "//backend:repo_other_files", - "//backend/conformance:repo_other_files", - "//backend/http:repo_other_files", - "//backend/http/corpus:repo_other_files", - "//beadserrors:repo_other_files", - "//cmd/bd:repo_other_files", - "//cmd/bd/doctor:repo_other_files", - "//cmd/bd/doctor/fix:repo_other_files", - "//cmd/bd/protocol:repo_other_files", - "//cmd/bd/setup:repo_other_files", - "//format:repo_other_files", - "//internal/ado:repo_other_files", - "//internal/atomicfile:repo_other_files", - "//internal/audit:repo_other_files", - "//internal/beads:repo_other_files", - "//internal/ceiling:repo_other_files", - "//internal/compact:repo_other_files", - "//internal/config:repo_other_files", - "//internal/configfile:repo_other_files", - "//internal/creds:repo_other_files", - "//internal/debug:repo_other_files", - "//internal/doltremote:repo_other_files", - "//internal/doltserver:repo_other_files", - "//internal/doltversion:repo_other_files", - "//internal/eventsjournal:repo_other_files", - "//internal/execenv:repo_other_files", - "//internal/fdhygiene:repo_other_files", - "//internal/formula:repo_other_files", - "//internal/formula/cmd/schemagen:repo_other_files", - "//internal/formula/schemagen:repo_other_files", - "//internal/git:repo_other_files", - "//internal/gitenv:repo_other_files", - "//internal/githooksenv:repo_other_files", - "//internal/github:repo_other_files", - "//internal/gitignore:repo_other_files", - "//internal/gitlab:repo_other_files", - "//internal/gittraceenv:repo_other_files", - "//internal/hooks:repo_other_files", - "//internal/httpapi:repo_other_files", - "//internal/httpapi/apigen:repo_other_files", - "//internal/httpapi/spec:repo_other_files", - "//internal/httpapi/wireshape:repo_other_files", - "//internal/httpapi/wireshape/cmd/gendigest:repo_other_files", - "//internal/httpclient:repo_other_files", - "//internal/httpclient/encode:repo_other_files", - "//internal/httpclient/wire:repo_other_files", - "//internal/idgen:repo_other_files", - "//internal/initprocs:repo_other_files", - "//internal/jira:repo_other_files", - "//internal/linear:repo_other_files", - "//internal/lockfile:repo_other_files", - "//internal/memoryapi:repo_other_files", - "//internal/metrics:repo_other_files", - "//internal/migration:repo_other_files", - "//internal/migration/legacysqlite:repo_other_files", - "//internal/molecules:repo_other_files", - "//internal/notion:repo_other_files", - "//internal/procid:repo_other_files", - "//internal/query:repo_other_files", - "//internal/recipes:repo_other_files", - "//internal/remotecache:repo_other_files", - "//internal/routing:repo_other_files", - "//internal/storage:repo_other_files", - "//internal/storage/backendnames:repo_other_files", - "//internal/storage/backends:repo_other_files", - "//internal/storage/batchbench:repo_other_files", - "//internal/storage/batchfixtures:repo_other_files", - "//internal/storage/contextinfo:repo_other_files", - "//internal/storage/createbatchequiv:repo_other_files", - "//internal/storage/dberrors:repo_other_files", - "//internal/storage/dbproxy/identity:repo_other_files", - "//internal/storage/dbproxy/pidfile:repo_other_files", - "//internal/storage/dbproxy/proxy:repo_other_files", - "//internal/storage/dbproxy/server:repo_other_files", - "//internal/storage/dbproxy/util:repo_other_files", - "//internal/storage/depid:repo_other_files", - "//internal/storage/dolt:repo_other_files", - "//internal/storage/doltutil:repo_other_files", - "//internal/storage/domain:repo_other_files", - "//internal/storage/domain/db:repo_other_files", - "//internal/storage/domain/fs:repo_other_files", - "//internal/storage/domain/git:repo_other_files", - "//internal/storage/embeddeddolt:repo_other_files", - "//internal/storage/embeddeddolt/cmd:repo_other_files", - "//internal/storage/externaldeps:repo_other_files", - "//internal/storage/fs:repo_other_files", - "//internal/storage/git:repo_other_files", - "//internal/storage/historyoffequiv:repo_other_files", - "//internal/storage/issueops:repo_other_files", - "//internal/storage/journalscan:repo_other_files", - "//internal/storage/kvkeys:repo_other_files", - "//internal/storage/memoryops:repo_other_files", - "//internal/storage/rowid:repo_other_files", - "//internal/storage/schema:repo_other_files", - "//internal/storage/sqlbuild:repo_other_files", - "//internal/storage/sqlclass:repo_other_files", - "//internal/storage/sqlcount:repo_other_files", - "//internal/storage/storagecontract:repo_other_files", - "//internal/storage/unsupportedgen:repo_other_files", - "//internal/storage/uow:repo_other_files", - "//internal/storage/versioncontrolops:repo_other_files", - "//internal/telemetry:repo_other_files", - "//internal/templates:repo_other_files", - "//internal/templates/agents:repo_other_files", - "//internal/testutil:repo_other_files", - "//internal/testutil/bazeltest:repo_other_files", - "//internal/testutil/credentialcmd:repo_other_files", - "//internal/testutil/fixtures:repo_other_files", - "//internal/testutil/integration:repo_other_files", - "//internal/timeparsing:repo_other_files", - "//internal/tracker:repo_other_files", - "//internal/tracker/conformance:repo_other_files", - "//internal/types:repo_other_files", - "//internal/ui:repo_other_files", - "//internal/uimd:repo_other_files", - "//internal/utils:repo_other_files", - "//internal/validation:repo_other_files", - "//internal/versioncheck:repo_other_files", - "//internal/versionedhistory:repo_other_files", - "//internal/workapi:repo_other_files", - "//internal/workapi/storecounter:repo_other_files", - "//internal/workapi/storequerier:repo_other_files", - "//internal/workapi/storereader:repo_other_files", - "//internal/workapi/storereadycounter:repo_other_files", - "//internal/workapi/storestats:repo_other_files", - "//internal/workapi/storeversionreconciler:repo_other_files", - "//internal/workapi/storeworkspaceconfig:repo_other_files", - "//internal/workspacegate:repo_other_files", - "//internal/worktreeremove:repo_other_files", - "//issueops:repo_other_files", - "//journalops:repo_other_files", - "//memoryops:repo_other_files", - "//platforms:repo_other_files", - "//plugins/beads:repo_other_files", - "//schema:repo_other_files", - "//scripts:repo_other_files", - "//scripts/bench-ready-indexes:repo_other_files", - "//scripts/check-versions:repo_other_files", - "//scripts/checkworkflowtags:repo_other_files", - "//scripts/gitattributespolicy:repo_other_files", - "//scripts/internal/testbash:repo_other_files", - "//scripts/migration-test/catalog:repo_other_files", - "//scripts/pr-lint:repo_other_files", - "//scripts/prlintmake:repo_other_files", - "//scripts/repochecks:repo_other_files", - "//scripts/repro-dolt-hang:repo_other_files", - "//scripts/repro-dolt-prod-timeouts:repo_other_files", - "//scripts/workflowtags:repo_other_files", - "//test/conformance:repo_other_files", - "//test/docsync:repo_other_files", - "//test/embedder:repo_other_files", - "//test/testmainconvention:repo_other_files", - "//tests/hook_timeout_backends:repo_other_files", - "//tests/migration:repo_other_files", - "//tests/regression:repo_other_files", - "//tests/upgrade_smoke:repo_other_files", - "//third_party/cc_toolchain:repo_other_files", - "//third_party/patches:repo_other_files", - "//tools/bazel:repo_other_files", - "//tools/docsmint:repo_other_files", - "//tools/nogo:repo_other_files", - "//tools/nogo/analyzers/depguard:repo_other_files", - "//tools/nogo/analyzers/errcheck:repo_other_files", - "//tools/nogo/analyzers/forbidigo:repo_other_files", - "//tools/nogo/analyzers/gosec:repo_other_files", - "//tools/nogo/analyzers/misspell:repo_other_files", - "//tools/nogo/analyzers/sloglint:repo_other_files", - "//tools/nogo/analyzers/unconvert:repo_other_files", - "//tools/nogo/analyzers/unparam:repo_other_files", - "//tools/nogo/internal/analyzertest:repo_other_files", - "//tools/nogo/internal/golangci:repo_other_files", - "//tools/nogo/internal/position:repo_other_files", + "//backend:repo_files", + "//backend/conformance:repo_files", + "//beadserrors:repo_files", + "//cmd/bd:repo_files", + "//cmd/bd/doctor:repo_files", + "//cmd/bd/doctor/fix:repo_files", + "//cmd/bd/protocol:repo_files", + "//cmd/bd/setup:repo_files", + "//format:repo_files", + "//internal/ado:repo_files", + "//internal/atomicfile:repo_files", + "//internal/audit:repo_files", + "//internal/beads:repo_files", + "//internal/ceiling:repo_files", + "//internal/compact:repo_files", + "//internal/config:repo_files", + "//internal/configfile:repo_files", + "//internal/creds:repo_files", + "//internal/debug:repo_files", + "//internal/doltremote:repo_files", + "//internal/doltserver:repo_files", + "//internal/doltversion:repo_files", + "//internal/eventsjournal:repo_files", + "//internal/execenv:repo_files", + "//internal/fdhygiene:repo_files", + "//internal/formula:repo_files", + "//internal/formula/cmd/schemagen:repo_files", + "//internal/formula/schemagen:repo_files", + "//internal/git:repo_files", + "//internal/gitenv:repo_files", + "//internal/githooksenv:repo_files", + "//internal/github:repo_files", + "//internal/gitignore:repo_files", + "//internal/gitlab:repo_files", + "//internal/gittraceenv:repo_files", + "//internal/hooks:repo_files", + "//internal/httpapi:repo_files", + "//internal/httpapi/apigen:repo_files", + "//internal/httpapi/spec:repo_files", + "//internal/httpapi/wireshape:repo_files", + "//internal/httpapi/wireshape/cmd/gendigest:repo_files", + "//internal/httpclient:repo_files", + "//internal/httpclient/encode:repo_files", + "//internal/httpclient/wire:repo_files", + "//internal/idgen:repo_files", + "//internal/jira:repo_files", + "//internal/linear:repo_files", + "//internal/lockfile:repo_files", + "//internal/memoryapi:repo_files", + "//internal/metrics:repo_files", + "//internal/migration:repo_files", + "//internal/migration/legacysqlite:repo_files", + "//internal/molecules:repo_files", + "//internal/notion:repo_files", + "//internal/procid:repo_files", + "//internal/query:repo_files", + "//internal/recipes:repo_files", + "//internal/remotecache:repo_files", + "//internal/routing:repo_files", + "//internal/storage:repo_files", + "//internal/storage/backendnames:repo_files", + "//internal/storage/backends:repo_files", + "//internal/storage/batchbench:repo_files", + "//internal/storage/batchfixtures:repo_files", + "//internal/storage/contextinfo:repo_files", + "//internal/storage/createbatchequiv:repo_files", + "//internal/storage/dberrors:repo_files", + "//internal/storage/dbproxy/identity:repo_files", + "//internal/storage/dbproxy/pidfile:repo_files", + "//internal/storage/dbproxy/proxy:repo_files", + "//internal/storage/dbproxy/server:repo_files", + "//internal/storage/dbproxy/util:repo_files", + "//internal/storage/depid:repo_files", + "//internal/storage/dolt:repo_files", + "//internal/storage/doltutil:repo_files", + "//internal/storage/domain:repo_files", + "//internal/storage/domain/db:repo_files", + "//internal/storage/domain/fs:repo_files", + "//internal/storage/domain/git:repo_files", + "//internal/storage/embeddeddolt:repo_files", + "//internal/storage/embeddeddolt/cmd:repo_files", + "//internal/storage/externaldeps:repo_files", + "//internal/storage/fs:repo_files", + "//internal/storage/git:repo_files", + "//internal/storage/issueops:repo_files", + "//internal/storage/journalscan:repo_files", + "//internal/storage/kvkeys:repo_files", + "//internal/storage/memoryops:repo_files", + "//internal/storage/rowid:repo_files", + "//internal/storage/schema:repo_files", + "//internal/storage/sqlbuild:repo_files", + "//internal/storage/sqlclass:repo_files", + "//internal/storage/sqlcount:repo_files", + "//internal/storage/storagecontract:repo_files", + "//internal/storage/uow:repo_files", + "//internal/storage/versioncontrolops:repo_files", + "//internal/telemetry:repo_files", + "//internal/templates:repo_files", + "//internal/templates/agents:repo_files", + "//internal/testutil:repo_files", + "//internal/testutil/bazeltest:repo_files", + "//internal/testutil/credentialcmd:repo_files", + "//internal/testutil/fixtures:repo_files", + "//internal/testutil/integration:repo_files", + "//internal/timeparsing:repo_files", + "//internal/tracker:repo_files", + "//internal/tracker/conformance:repo_files", + "//internal/types:repo_files", + "//internal/ui:repo_files", + "//internal/uimd:repo_files", + "//internal/utils:repo_files", + "//internal/validation:repo_files", + "//internal/versioncheck:repo_files", + "//internal/workapi:repo_files", + "//internal/workapi/storecounter:repo_files", + "//internal/workapi/storequerier:repo_files", + "//internal/workapi/storereader:repo_files", + "//internal/workapi/storereadycounter:repo_files", + "//internal/workapi/storestats:repo_files", + "//internal/workapi/storeversionreconciler:repo_files", + "//internal/workapi/storeworkspaceconfig:repo_files", + "//internal/workspacegate:repo_files", + "//internal/worktreeremove:repo_files", + "//issueops:repo_files", + "//journalops:repo_files", + "//memoryops:repo_files", + "//platforms:repo_files", + "//plugins/beads:repo_files", + "//schema:repo_files", + "//scripts:repo_files", + "//scripts/bench-ready-indexes:repo_files", + "//scripts/check-versions:repo_files", + "//scripts/checkworkflowtags:repo_files", + "//scripts/gitattributespolicy:repo_files", + "//scripts/internal/testbash:repo_files", + "//scripts/migration-test/catalog:repo_files", + "//scripts/pr-lint:repo_files", + "//scripts/prlintmake:repo_files", + "//scripts/repochecks:repo_files", + "//scripts/repro-dolt-hang:repo_files", + "//scripts/repro-dolt-prod-timeouts:repo_files", + "//scripts/workflowtags:repo_files", + "//test/conformance:repo_files", + "//test/docsync:repo_files", + "//test/testmainconvention:repo_files", + "//tests/hook_timeout_backends:repo_files", + "//tests/migration:repo_files", + "//tests/regression:repo_files", + "//tests/upgrade_smoke:repo_files", + "//third_party/cc_toolchain:repo_files", + "//third_party/patches:repo_files", + "//tools/bazel:repo_files", + "//tools/docsmint:repo_files", + "//tools/nogo:repo_files", + "//tools/nogo/analyzers/depguard:repo_files", + "//tools/nogo/analyzers/errcheck:repo_files", + "//tools/nogo/analyzers/forbidigo:repo_files", + "//tools/nogo/analyzers/gosec:repo_files", + "//tools/nogo/analyzers/misspell:repo_files", + "//tools/nogo/analyzers/sloglint:repo_files", + "//tools/nogo/analyzers/unconvert:repo_files", + "//tools/nogo/analyzers/unparam:repo_files", + "//tools/nogo/internal/analyzertest:repo_files", + "//tools/nogo/internal/golangci:repo_files", + "//tools/nogo/internal/position:repo_files", + ], + visibility = [ + "//scripts:__pkg__", + "//scripts/repochecks:__pkg__", + "//test/docsync:__pkg__", ], - visibility = ["//:__subpackages__"], ) # --- end repo_files --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 884a0d7f0..51577f7ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,295 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- `bd versions ` lists the versions recorded for a bead, and - `versioned-history.enabled` turns recording on. While it is on, every - accepted change to a bead created while it is on, or that enters the issues - plane while it is on (a wisp promoted or made persistent), stores a - snapshot of it as a row of `issue_versions` in the same transaction. It is - off by default and nothing is backfilled: a bead already on the issues - plane when it is turned on is legacy, and editing it records nothing. A - recorded write leaves `updated_at` where an unrecorded one would, so - `bd import`'s stale check sees the same timestamps either way. - `bd versions --json` answers `{"versions": [...], "recording": bool}`; the - command still lists what was recorded after recording is turned off, and - proxied-server and HTTP workspaces refuse it. The setting is a row of each - store's `config` table (`bd config set versioned-history.enabled true`), - and every store reads its own when it is opened: a write routed into - another workspace (a prefix-routed `bd update` or `bd close`, - `bd create --repo`) follows the target store's row, a proxied-server - provider reads it when it is constructed, and a long-lived `bd serve` - keeps the value it read until it restarts. - `BD_VERSIONED_HISTORY_ENABLED=1` (or a `config.yaml` value) turns - recording on for every store the process opens, and never turns it off. - The row replicates on `bd dolt push`/`pull`, and recording is single-writer - only: two clones recording at once can mint the same revision and fail the - pull, and a write from a writer that is not recording is folded into the - next recorded version under that version's actor, so keep recording on for - every writer of a store or off for all of them. Turning it on with - `bd config set` first checks every issue the store would version and - refuses, writing nothing, while any holds a number outside the I-JSON - exact-integer range (magnitude above 2^53-1, however it is spelled) in its - metadata or in a gate's timeout (held as nanoseconds, so about 104.25 - days), and prints the count, the ids, the field and the fix. There is no - override, and the check runs once; after that, a recorded write that would - hold such a number fails atomically. Migration 0071 adds a nullable - `removed_restriction` column to `issue_versions`. `bd version` now refuses - an argument and suggests `bd versions `, instead of printing bd's - build for a mistyped `bd version bd-123`. -- `bd blocked --flags` prints the blocked flag for each id read from stdin - (one per line; blank lines and repeats ignored), with `--json` as - `[{"id","is_blocked"}]` in the order the ids were given, omitting an id that - names no row on either plane. A closed id is answered too, with its stored - flag (a `status <> 'closed'` SQL read of the column leaves it out). It is the flag `bd ready` filters on, not the - listing: a row whose stored flag is set with no nameable blocker reads true - here and is absent from `bd blocked`. It runs `issueops.BlockedFlags` on - every route; over HTTP that is `listBlockingAnnotations` with `is_blocked`, - behind `dependencies.blocking.isBlocked`, refused before the dial against a - server that does not advertise it. The listing's filter flags are refused - with `--flags`. -- `bd blocked --flags --raw` answers the stored `is_blocked` column itself, - without the external-dependency policy: a row blocked only by an - unsatisfied `external:` ref reads `false` (the policy-aware `--flags` - reads `true`); a stale flag reads `true` either way. `--raw` is for the - local and proxied routes, where it reads the column directly and the two - answer the same. Over HTTP it is answered only by a server that does not - advertise `policy.external_dependencies` (whose flag is the column); a - server advertising it answers only the policy-aware flag, so `--raw` - against it is refused before the dial rather than answered with the - decorated flag. `--raw` without `--flags` is refused. -- `bd blocked` works over a connected HTTP workspace. The blocked listing is - a role, `issueops.BlockedLister` (`ListBlocked(BlockedRequest{ParentID, - Labels, LabelsAny, ExcludeLabels}) -> BlockedResult{Items}`), on every - backend leg over the same body `GetBlockedIssues` runs, and `bd serve` - publishes it as `GET /v0/beads/blocked` (`parent`, and the repeatable - `label`, `label_any` and `exclude_label`), answering `{items, has_more}` - with `BlockedIssue` rows (the element `bd blocked --json` prints), behind - the new `blocked.list` capability token (additive; no wire_revision bump). - The listing names unsatisfied `external:` blockers wherever the - external-dependency policy applies: on the server when it advertises - `policy.external_dependencies`, else on the client, as every other policy - read does. The HTTP backend's `BlockedLister()` and legacy - `GetBlockedIssues` dial it; against a server that does not advertise the - token they refuse before dialing with a typed capability error naming - `blocked.list`, and never compose the listing from other reads. The - listing is unpaged: a server answer that reports `has_more` is refused - with the new `httpclient.TruncatedListingError` rather than returned - short, and an answer over the client's 32 MiB response limit is refused - as any oversized response is. The external-dependency decorator's legacy - `GetBlockedIssues` over an HTTP store now reads the extra sources through - the served roles (it failed on a raw multi-id read before), so callers of - that door no longer fail on it; commands that also make other raw reads - the HTTP backend does not serve (`bd ready --explain`) still refuse on - those. `bd - blocked` runs the role on every route (the proxied-server route through - the provider's accessor) with unchanged output: `--json` prints the same - rows in the same order (priority, then newest first, then id, which now - also breaks a tie the order used to leave to chance), and `[]`, never - `null`, when nothing is blocked. -- `bd list`'s remaining filters work over a connected HTTP workspace. - `GET /v0/beads/issues` accepts `updated_after`/`updated_before`, - `closed_after`/`closed_before`, `defer_after`/`defer_before`, - `due_after`/`due_before`, `priority`, `priority_min`, `priority_max`, - `title_contains`, `desc_contains`, `notes_contains`, `external_contains`, - `external_ref`, `spec`, `label_pattern`, `label_regex`, - `empty_description`, `no_labels`, `no_parent`, a repeatable - `exclude_type`, `pinned`, `no_pinned`, `deferred`, `overdue`, `mol_type` - and `wisp_type`, behind one new capability token, `issues.list.filters` - (additive; no wire_revision bump; the names are `issues:count`'s where it - already spells the filter), and applies them through the same Reader role a - local `bd list` reads through. Bounds are strict and compared at - whole-second precision on both routes; relative and date-only values are - resolved on the client's clock and timezone as locally, while `--overdue` - compares against the server's clock. Against a server that does not - advertise the token the client refuses before dialing, naming - `issues.list.filters`, rather than sending a filter an older server rejects - or dropping one and answering a wider listing. The 29 corresponding - divergence-ledger refusal rows are removed. The default `bd list --parent` - tree view does not carry these filters yet: its descendant walk still - refuses one over HTTP rather than drop it, and `--flat` or `--json` skips - the walk and applies them to the parent's direct children (not its whole - subtree). -- `issueops.ListRequest.ExcludeStatus`: statuses to leave out of a listing, - appended to the default exclusions (never re-admitting what they hide), - comma-separated or repeated, each validated against the workspace's - statuses like `CountRequest.ExcludeStatus` (an unknown name is - `ErrValidation`). `GET /v0/beads/issues` accepts it as a repeatable - `exclude_status` under the same `issues.list.filters` token (an unknown - name is a `400` on `exclude_status`), so an HTTP-backed caller can leave - closed history out of an `all` listing (`all` plus - `exclude_status=closed` keeps every status not named, the `pinned` and - `hooked` statuses and custom done/frozen statuses included) instead of - reading the whole history. It is refused together with `ReadyFlag`, like the other - members the ready query cannot carry. There is no `bd list` flag for it - yet. - -- `bd serve` publishes the gate members: `await_type`, - `await_id`, `timeout` (nanoseconds) and `waiters` on `POST - /v0/beads/issues` and on `issues:batchApply` create items, behind the new - `issues.create.gates` capability token, and `await_id` and `waiters` (a - whole-value replacement; `[]` clears) on the `patch` of `PATCH - /v0/beads/issues/{id}` and of `issues:batchApply` update items, behind - `issues.update.gates`. Additive; no wire_revision bump. The bounds are the - library role's, the same ones a local create or update now enforces (see - Changed), answered as `400 invalid_argument` with `param` naming the - member. -- `issueops.IssuePatch.Waiters`: a whole-value replacement of a gate's waiter - list (nil or empty clears it, stored as `[]`), on `Lifecycle.Update` and on - `BatchApplier` update items, on every backend. `issueops.GateFieldError` - (`Field`, `Detail`; wraps `ErrValidation`) names the gate member a create or - update refused, as one of the new `issueops.GateFieldAwaitType`, - `GateFieldAwaitID`, `GateFieldTimeout` and `GateFieldWaiters` constants. -- The HTTP client sends the gate members on create, update and - `issues:batchApply` (create and update items) to a server that advertises - `issues.create.gates` / `issues.update.gates`. Against an older server a - request naming any gate member is refused before the dial with a typed - capability error naming the missing token (never sent without the - member); a batchApply plan is checked whole, so no partial plan is sent. - A request naming no gate member is unaffected by either token. -- `bd heartbeat` works over a connected HTTP workspace. - The lease refresh is a role, `issueops.Heartbeater` - (`Heartbeat(HeartbeatRequest{Actor, IssueID}) -> HeartbeatResult{IssueID, - Holder, HeartbeatAt, LeaseExpiresAt, Rearmed}`), on every backend leg, and - `bd serve` publishes it as `POST /v0/beads/issues/{id}:heartbeat` behind the - new `issues.heartbeat` capability token (additive; no wire_revision bump), - with the new `lease_not_held` (409) problem code (`reason: ephemeral` for a - wisp). A refresh writes ONLY the lease row: the issue's `revision` is not - reminted (a guarded write against the pre-heartbeat token still lands), no - version, event, journal entry or Dolt commit is recorded, and no hook - fires. `Rearmed` is true only when the heartbeat created the caller's lease - row (a hand-doled claim's first heartbeat). A re-arm is recorded as a - mutation; a refresh is not: the re-arm remints `revision`, stamps - `updated_at`, records a `lease_rearmed` event, a journal entry and a - version, makes a Dolt commit and fires `on_update` (see Fixed); the - reported times are whole seconds, exactly what the lease row stores. The - HTTP backend's `Heartbeater()` and legacy `HeartbeatIssue` dial it; - against a server that does not advertise the token they refuse before - dialing with a typed capability error naming `issues.heartbeat`, and never - fall back to a re-claim or a metadata stamp. A - busy (503) answer is replayed, because a repeat only moves the expiry later. - `bd heartbeat` now runs the role on every route (the proxied-server route - through the provider's accessor), with the same - `{"id","status":"heartbeat","owner"}` success output and the same exit - codes. Refusal TEXT on stderr changes per route: the direct routes (Dolt - server, embedded) gain a `lease not held: ` prefix - (`heartbeat X: lease not held: issue not claimable: X status closed`); the - proxied-server route loses its - `Heartbeat: db: IssueSQLRepository.HeartbeatIssue: ` prefix and reads as the - direct routes do; over HTTP the refusal is the problem's detail, which names - the state found (`it is closed`, `an ephemeral wisp`, `open and not - claimed`) or, for a foreign holder, the native `issue already claimed by - `. An id that names no row answers not-found from the role rather - than "not claimable" (the CLI resolves the id first, so its output is - unchanged), and every refusal for a caller that holds no live claim - (closed, released, reclaimed, moved off in_progress, or a wisp) is - `issueops.ErrLeaseNotHeld`, which still matches `ErrNotClaimable`. - -- `GET /v0/beads/dependencies/blocking` accepts `is_blocked`, behind the new - `dependencies.blocking.isBlocked` capability token (additive; no - wire_revision bump), and answers each item's stored, transitive - `is_blocked` flag, the column `bd ready` filters on; an item whose id names - no row carries none. `issueops.BlockingRequest` gains `IncludeIsBlocked` on - every BlockingAnnotator implementation, and `issueops.BlockedFlags` is the - batched read over it. The HTTP backend's `IsBlockedBatch` now serves - through it; against a server that does not advertise the token it still - refuses before dialing, now with a typed capability error naming the - token. An unsatisfied `external:` blocker sets the flag on every route, - just as it keeps the issue out of `bd ready`. -- `bd promote` works over a connected HTTP workspace (S21b). Its one library - entry, `issueops.Promote(ctx, PromoteRoles{Reader, Lifecycle, Commenter}, - PromoteRequest)`, reads the row, refuses one that is not a wisp - (`*issueops.NotAWispError`, the sentence `bd promote` always printed), moves - it with ONE `Lifecycle.Update` whose patch is `Persistence = persistent` - (labels, dependencies, events, comments and the child counter move with it - in the role's transaction), then records the promotion comment. The direct - and proxied-server routes run it over their own roles, so a local promote - now makes the same plane move `bd update --persistent` makes, honoring - `dolt.auto-commit`. That changes five things a script can see on those - routes: the workspace's `on_update` hook fires twice, once for the move and - once for the comment (the direct route never fired it, the proxied-server - route fired it once); the promotion comment is a row `bd comments` lists - (the direct route recorded only a `commented` event); a promoted parent - keeps its child counter, so its next `bd create --parent` mints the number - after its wisp children's instead of failing with - `issue already exists: .1`; a promotion records two Dolt - commits, `bd: promote ` for the move and `bd: comment ` for the - comment (an embedded workspace recorded one, `bd: promote (auto-commit)`, - and the proxied-server route one, `bd: promote `); and a promote that - loses a race to a concurrent one fails with the not-a-wisp sentence instead - of `promoting : wisp not found`. A comment that cannot - be written leaves the promotion standing behind a warning on every route; - the proxied-server route used to roll the promotion back. `bd serve` - publishes the move as `patch.persistence` on `PATCH /v0/beads/issues/{id}` - behind the new `issues.update.persistence` capability (additive; - `wire_revision` is unchanged), which also carries `bd update --persistent`, - `--ephemeral` and `--no-history` over HTTP. Against a server without the - token the client refuses before the dial, naming it; nothing is written. A - move the workspace refuses (an `unversioned`-class row asked for - `--ephemeral` or `--no-history`, or a demotion of a row with retained - snapshots) matches `ErrValidation` on every route: `bd serve` answers it - `400 invalid_argument`, and the local refusal gains a `validation failed: ` - prefix. -- `bd serve` advertises the new `issues.update.claim` behavior token for what - `PATCH /v0/beads/issues/{id}` already served untokened: `claim` (upstream - #6890), resolved on both planes, so a wisp is claimable there (additive; no - wire_revision bump). The HTTP client now picks the claim route from the - handshake before dialing: with the token every claim is one updateIssue call; - without it a claim alone goes to `{id}:claim` (no doomed 400 first; a wisp - still refuses by name, W-ClaimRequest.Wisp, now naming the token), and a - claim beside a patch, a guard, a force override or `allow_template` is - refused before the dial with an unsupported error naming - `issues.update.claim`. Skew note: a server that serves `claim` untokened - (wire_revision 2 builds before this release) now gets those two refusals - from a new client where it used to serve them; upgrade bd serve. A template - claimed alone without the token is still refused, on the client's own - pre-read: `{id}:claim` has no template guard (bd-jkp9v3). -- `issueops.LeaseReclaimer`, the stale-lease sweep behind `bd reclaim`, is a - role on every leg (dolt, embedded dolt, the unit-of-work provider and the - HTTP client), and `bd serve` publishes it as `POST /v0/beads/issues:reclaim` - behind the new `issues.reclaim` capability (additive; `wire_revision` is - unchanged). Every reverted row mints a new revision, reported per entry as - `revision`, so a holder that writes with its pre-reclaim token gets a version - mismatch. An id that is not a stale lease is left out of the answer, not - refused. `bd reclaim` now runs the role on both routes, which changes four - things a script can see: its `--json` entries gain `revision`; the - workspace's `on_update` hook fires once per reverted row (the raw path fired - none); `--id` now accepts at most 1000 ids per run (more is refused, never - truncated); and the role records its own version commit, honoring - `dolt.auto-commit` the way `bd prune` does, as - `bd: reclaim N expired lease(s)` on both routes. Over a connected HTTP - workspace `bd reclaim` now works instead of refusing. -- **`bd show --comments-tail N`** renders only the last N comments in text - output (including under `--watch`) - ([#6618](https://github.com/gastownhall/beads/pull/6618)), preceded by one - elision line naming how many older ones were hidden. A render-only cap for - fat, append-only beads whose full comment history is hundreds of KB — - description and metadata are unchanged, and omitting the flag (or passing - `0`) is byte-identical to today's output. JSON output is untouched; - `--include-comments` still streams every comment there. -- `GET /v0/beads/issues` accepts `no_assignee`, `title` and a repeatable `id` - (one id per value, at most 200), each behind its own new capability token - (`issues.list.noAssignee`, `issues.list.title`, `issues.list.ids`; additive, - no wire_revision bump; `id` and its token are bd-enterprise's contract, - adopted unchanged), and applies them through - the same Reader role a local `bd list` reads through. Over a connected HTTP - workspace `bd list --no-assignee`, `--title` and `--id` now work instead of - refusing. Against a server that does not advertise a flag's token the - client refuses before dialing, and the refusal names the token (every - capability refusal over HTTP now names its token). -- `GET /v0/beads/issues` accepts `q`, `bd search`'s free text, behind the - new `issues.list.search` capability token (additive; no wire_revision - bump). `issueops.ListRequest` gains `Query`, with `SearchIssues`' meaning - (title or id contains the text, case-insensitively), on every Reader - implementation, and `issueops.SearchListRequest` is search's scope as a - request. Every `bd search` route (direct, `--proxied-server` and the HTTP - backend) now asks `Reader.List` with it through one flag mapping; against - a server that does not advertise the token the HTTP client refuses before - dialing with a typed capability error. Two things a script can see follow - from that mapping: `bd search --type` expands aliases (`feat`, `mol`, - `dec`, ...) and validates the type as `bd list` does, so an unknown type - now exits 1 where it used to answer an empty result, and `bd search - --json` rows carry `comments_omitted` (additive) as `bd list --json` rows - do. - `bd create --graph` now plans its batch through `issueops.BatchApplier` instead of the old `buildDomainGraphPlan` path, so a graph create gets the same atomic multi-row semantics as `bd batch apply`. A `waits-for` edge's @@ -400,281 +111,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 will not send, and value constraints (`maxLength`, `pattern` and the like) are outside the digest: such changes need their own review against `wire_revision`. -- `cmd/bd` registers the http client backend built on top of the v0 `bd - serve` wire (`internal/httpclient`), so a workspace whose - `.beads/metadata.json` selects `"backend": "http"` opens over HTTP through - the ordinary `OpenBestAvailable` path, exactly like a registered extension - backend does. A new `bd connect ` command performs the handshake - (`api_version`, wire revision, and — with `--expect-project-id` — workspace - identity) and writes nothing until it succeeds; it then records the - per-user activation sidecar (`.beads/http_target.json`, never - git-tracked — `cmd/bd/doctor/gitignore.go` now requires it and its local - metadata sidecar `http_local_metadata.json` be ignored) and sets - `metadata.json`'s backend to `"http"`. `bd connect` refuses a plain `http://` - URL to a non-loopback host (a bearer credential would cross the network in - the clear) unless `--allow-plaintext` is given, and refuses to switch a - workspace that already selects a different backend unless `--force`. A - credential is never accepted on the command line or written to disk; it - comes from the same ladder every http request already uses - (`BEADS_HTTP_TOKEN=host[:port]=`, then - `BEADS_HTTP_TOKEN_COMMAND=host[:port]=`, then the credentials - file, then none); both variables take only that host-scoped form, and a - bare value is refused, since it would be sent to whatever server the - workspace's `http_target.json` names. - `bd create` sends no `created_by` on any backend: the - create role defaults it to the request's actor (see *Changed*). The - external-dependency policy decorator (`internal/storage/externaldeps`) - still wraps an http store, and passes every ready, claim, claim-next, - close, blocking and tree request through untouched when the server's - handshake advertises `policy.external_dependencies`, which every `bd - serve` composed through the policy now does (see below). Only against a - server that does not advertise it (an older `bd serve`, or one handed raw - roles) does the client apply the policy itself, in role terms: ready reads - and the ready claim exclude the workspace-wide externally blocked set over - a widened window, and per-issue checks (claim, close, batch close, list - annotations, tree leaves) read only the named issues' edges. - `bd close --claim-next` refuses over http before anything closes, since - the wire's batch close cannot carry the claim; its error says to close - without it and then run `bd ready --claim`. -- `bd serve` advertises the conditional behavior token - `policy.external_dependencies` exactly when the roles or provider it - serves were composed through the external-dependency policy - (`httpapi.Config.ExternalDependencyPolicy`, which `bd serve` derives with - `externaldeps.Applied` / `externaldeps.AppliedToProvider`); a server handed - raw roles withholds it. A client that sees it hands claim-next to the - server as one atomic call and takes the ready count from the server, - instead of judging external dependencies a second time against the CLIENT - machine's project config. -- `bd ping` works on an http workspace (a new `storage.Pinger`, which the - http store answers with its authenticated context read). -- The public `backend/http` package (`bdhttp`) is the out-of-tree door onto - this backend for an embedder that links beads as a library rather than - running `cmd/bd`: `Register(Options)` adds `"http"` to the registry and - installs its transport, `Open`/`Handshake` dial a server directly with no - workspace on disk, and the existing public `beads.OpenBestAvailableWith` - takes a per-call `OpenOptions.Credential` through it — the case a - multi-tenant embedder serving many workspaces needs, where a - process-global credential cannot stand in for one tenant's own. - EXPERIMENTAL, pin an exact beads version. -- Unlimited ready and query reads over the HTTP backend (`bd ready --limit - 0`, `bd query --limit 0`, and every library read asking for no limit) - return every row against any server, bounded on the client by the new - `BEADS_HTTP_UNLIMITED_READ_CAP` (a positive integer up to 1000000; default - 10000). The client never puts `limit=0` on the wire, which a `bd serve - --allow-non-loopback` refuses and which an older server answered with its - default page, silently capping the result: an unlimited ready or query - read is one request bounded at the cap plus one (one consistent snapshot). - Past the cap, or when a server reports more rows below the requested - bound, the read is refused with a typed error - (`httpclient.ErrUnlimitedReadCap`) naming the cap, never truncated. An - unlimited `bd list` is unchanged: it walks its keyset cursor a page at a - time and is bounded only by `--max-rows` / `BEADS_MAX_ROWS`. Unlike a - malformed `BEADS_MAX_ROWS`, which is ignored with a warning, a malformed - cap value fails every unlimited ready or query read rather than falling - back to the default. -- Two molecule capability tokens on `bd serve`. `issues.close.autoCloseMolecule` - announces that `POST /v0/beads/issues/{id}:close` and `POST - /v0/beads/issues:batchClose` accept `auto_close_molecule` and answer - `auto_closed_molecule` and `molecule_auto_close_refusal`; - `issues.advanceMolecule` is the new `POST - /v0/beads/issues/{id}:advanceMolecule`, `bd close --continue`'s advance. - Both run the one library entry (`issueops.CloseRequest.AutoCloseMolecule`, - `issueops.MoleculeStepper`) on the server. The public `issueops` package - gains the molecule rules as one implementation over the BatchGetter, - Relations and EdgeReader roles (`MoleculeRoots`, `LoadMolecule`, - `AnalyzeMolecule`, `ViewMolecule`, `ReadMoleculeProgress`, - `ActiveMoleculeIDs`, `CompletedMolecule`, `MoleculeRootClose`); a - molecule's membership is the parent-child edge. Against a server that - does not advertise a token the HTTP client refuses a library close that - sets `AutoCloseMolecule`, or an advance, before dialing, with a typed - capability error; it never runs a client-side copy of either rule. -- `bd close --json` reports the molecule auto-close. The entry of a close - that completed a molecule carries the root it closed as - `auto_closed_molecule`, or why the root stayed open as - `molecule_auto_close_refusal`, on every route; before, that refusal - reached only stderr. Both members are absent from every other entry, so - each entry still decodes as the closed issue, and the output stays an - array (under `closed` with `--suggest-next`, `--continue` or - `--claim-next`). ### Changed -- Over an HTTP workspace, `bd ready --json` without `BD_JSON_ENVELOPE` no - longer sends `GET /v0/beads/ready:count` after a page the limit cut short: - the total only went into the stderr hint. It lists one row past the limit - instead, and the hint says more issues matched without saying how many - (the wording the proxied-server route already uses). A local store, and the - envelope's `pagination.total`, keep the total. -- `bd` initializes its packages with `GOMAXPROCS` capped at 4 and hands it - back before `main` runs anything, so the garbage collections package - initialization triggers do not stop the world across every CPU of a large - host. On a 192-CPU machine this takes about 17 ms off every bd process. An - explicit `GOMAXPROCS` is restored as set. -- Over an HTTP workspace, `bd ready` no longer fetches `GET /v0/beads/context` - before its listing in every process only to learn whether the server - enforces the external-dependency policy. The answer is kept for 5 minutes - per server URL and pinned project under the user cache directory - (`BEADS_HTTP_POLICY_CACHE_TTL`, a duration, a number of seconds, or `off`), - and a handshake the process already holds still wins. Claims and closes - always ask the server. -- `bd serve` normalizes every RFC 3339 time bound on the issue listing and - count (`created_*`, `updated_*`, `closed_*`, and the new `defer_*` and - `due_*`) to UTC before it reaches storage. A bound carrying an offset - (`...+02:00`) now selects exactly what its `Z` twin does; previously a - backend whose timestamp column has no zone could read the offset bound's - wall clock and compare it hours off. `bd`'s own client always sent `Z`, so - its answers are unchanged. -- `bd serve` answers a `label_regex` the database cannot compile with - `400 invalid_argument` (`invalid_value` on `label_regex`) on - `GET /v0/beads/issues`, `GET /v0/beads/ready`, `GET /v0/beads/ready:count` - and `POST /v0/beads/issues:claimNext`, instead of `500 internal`. The pattern is - still compiled by the database in its own dialect; only the attribution - of its refusal changed. -- `issueops.Reader.List` refuses `PinnedFlag` together with `NoPinnedFlag` - with `ErrValidation` (`--pinned and --no-pinned are mutually exclusive`) on - every backend; it used to let `PinnedFlag` win silently. `bd list` already - refused the pair at flag parse, so its behavior is unchanged; over HTTP the - pair is a `400 invalid_argument` on `no_pinned`. -- `issueops.Reader.List` refuses `ParentID` together with `NoParent` with - `ErrValidation` (`--parent and --no-parent are mutually exclusive`) on - every backend, as `CountRequest` already did; it used to answer with only - the edge-less rows under the parent's dotted id, which both clauses match. - `bd list` already refused the pair at flag parse, so its behavior is - unchanged; over HTTP the pair is a `400 invalid_argument` on `no_parent`. - -- **`bd gate discover` skips template gates, as `bd gate check` does.** A - template gh:run gate is a proto that work is poured from; on the direct, - proxied and embedded routes `bd gate discover` used to record a discovered - run ID on it, which every later pour copied. It is now left alone on every - route. `bd gate add-waiter` on a template gate is refused by the update - role's template guard, where the direct, proxied and embedded routes all - used to write the waiter. -- **`bd gate create` refuses a negative `--timeout` on every route** - (`timeout cannot be negative`); the direct, proxied and embedded routes - used to store it. A `--type` longer than 32 characters fails with the same - typed validation error instead of a raw Dolt column error. -- **`bd gate create` and `bd gate add-waiter` follow `dolt.auto-commit` - like every other role write.** Under `dolt.auto-commit=off` `bd gate - create` no longer makes its own Dolt commit on the direct and embedded - routes (the proxied route already did not). The Dolt commit messages are - the role's: `bd: create gate X blocking Y` becomes the create's default - message, and `bd gate add-waiter`'s becomes the update's (`bd: update X` - on the direct and embedded routes, `update issue` on the proxied route). - On the proxied route `bd gate create` no longer journals a - `dependency_added` event on the blocked issue, matching the direct route - and `bd create --deps`. -- **Gate members are bounds-checked in the library, on every local backend.** - `issueops.Lifecycle.Create`, `Lifecycle.Update` and `BatchApplier` (create - and update items) now refuse, with a typed `*issueops.GateFieldError` - wrapping `ErrValidation`: a negative `Timeout` (previously accepted and - stored), an `await_type` over 32 characters, an `await_id` over 255 - characters, and a waiter list whose JSON encoding exceeds its TEXT column - (65535 bytes). Creates check all four; an update can change only - `await_id` and `waiters`, so it checks those two. The over-width values - previously failed with a raw Dolt driver error. There is no `await_type` vocabulary, no gate-type-only rule - and no waiter deduplication. -- **Over an http workspace, a bd command answers its repeated reads of a row - or setting from one response.** `bd show --json` makes one request - instead of three, text `bd show` three instead of six, and `bd update`, - `bd close`, `bd label add`, `bd comments` and `bd dep add` one to seven - fewer (port of bd-enterprise e626072b8). A one-shot command's transport - answers an identical `getIssue`, `getSetting` or `listSettings` GET from the - answer it already received, for at most 5 s from that answer. Any write the - command makes clears it, and only a 2xx that decoded is kept. `bd serve`, - `--watch` and `--follow` never memoize, and neither do library embedders. - Within one command a re-read no longer sees another writer's change made in - the meantime (ledger row `L-read-memo`); `BD_HTTP_READ_MEMO=0` turns the - memo off. The identity-gate preview and the real open now share one - transport, so a write makes one handshake. `bd list` reads its vocabulary - with one `listSettings`, and the hook decorator skips its post-write re-reads - when no hook for the event is installed. -- **`created_by` defaults to the actor in the library, for every create - shape and every backend.** `PreparePublicCreateRequest`, which - `Lifecycle.Create`, `BatchCreator` items and batch-apply create items all - prepare through, now sets an empty `Issue.CreatedBy` to the request's - `Actor`; an explicit value is kept. The CLI (`bd create`, the state event - create) and the three `bd serve` create handlers no longer stamp it - themselves. A library caller that left `CreatedBy` empty used to store - `""` locally and the actor over http; both now store the actor. The raw - `CreateIssue` seam is unchanged: import keeps the creator its rows carry, - and `bd swarm`, `bd todo`, `bd gate` and the create form still stamp - `currentActor()` there. -- **On an http workspace, `bd update -s closed` does not record - `closed_by_session`.** The update wire cannot carry it, so the CLI drops - it rather than refusing the close; the status change, its close-policy - guards and every other field in the same update still apply. A one-line - notice on stderr names the drop, both for an explicit `--session` and for - the ambient `CLAUDE_SESSION_ID` every agent under Claude Code exports, so - it is never silent. `bd close` (and `bd close --session`) still records - the session over http: its wire operation carries it. Local backends are - unchanged. -- **On an http workspace, `bd reopen` sends no Provenance label.** The - CLI's label is the fixed `bd: reopen `, which the wire cannot carry; - the server records its own reopen entry for the same issue and actor, so - the reopen no longer refuses. Local backends still record the label. -- **Routing settings are local-only on a remote backend.** For an http - workspace, `routing.mode`, `routing.contributor`, `routing.default`, - `routing.maintainer`, `contributor.auto_route` and - `contributor.planning_repo` come from local config (`config.yaml` or the - environment) only; the server's shared settings document is not read for - them, because routing targets are local filesystem paths that one shared - document cannot name for every client. `bd create`'s routing decision, `bd - migrate-personal` and the missing-id lookup fallback all read the same - local-only answer, and none pays a settings round trip for it. Local - backends still fall back to the database values. -- **The molecule auto-close runs inside the step's close, and an error in - it fails the close.** `bd close` of a molecule's last step closes the - root in the same transaction (opt-in `AutoCloseMolecule`, so an - orchestrator that runs its own molecule lifecycle is not doubled), and it - replays on an idempotent re-close. The root close is unforced, so a root - a direct close would refuse stays open and is reported while the step's - close stands: one its close policy refuses (such as a live blocker), and - now also one a close guard refuses (a template, a pinned root, a root - another actor holds). Any other failure of the root close (such as a - storage error) now fails the step's close with it, where the CLI used to - close the root afterwards and only warn. - Two closes that finish a molecule's last steps at the same time no - longer leave its root open: one of them retries and closes it. The cost - is that concurrent closes of steps under one open auto-closing root now - serialize, whether or not either finishes the molecule: each conflict is - retried, and a close still conflicting when its retry budget runs out - fails with the serialization error. A batch close reports each root once, - on the first item under it that closed. -- **`bd close --continue` claims the next step for real.** The advance is - the `MoleculeStepper` role on every route: the assignee is set and a step - another agent holds is skipped, never taken (the direct and http routes - used to flip the status only). -- **`bd mol current`, `bd mol progress`, `bd ready --mol` and `bd mol show` - read through the library's molecule entries on every route**, so - membership is the parent-child edge everywhere (`bd mol show` no longer - adds children found only by an id pattern). -- **Against a server without the molecule tokens, `bd close` says what it - did not do.** If the server does not advertise - `issues.close.autoCloseMolecule` (an older `bd serve`, or one whose - orchestrator owns the molecule lifecycle), the close goes out without the - auto-close request. When that leaves a molecule with every step closed and - its root open, a notice on stderr names the root, once per root in a batch - and again on a re-close; a step under an ordinary epic or an unfinished - molecule prints nothing. If it does not advertise - `issues.advanceMolecule`, or the handshake that would say so fails, `bd - close --continue` refuses before closing anything, so the step is never - left closed with the next step unclaimed. -- Every `bd` invocation used to start two git subprocesses before doing any - work: `git rev-parse` to locate the repository and `git config user.name` - to resolve the actor. On Linux the repository is now located in-process - (ordinary repositories, linked worktrees, submodules, no repository), - producing exactly what `git rev-parse` printed and still running git for - anything it does not model (`GIT_DIR` and related overrides, - `core.worktree`/`core.bare`, repository extensions, includes, foreign - ownership subject to `safe.directory`). The `git config user.name` actor - fallback is resolved only when a command actually needs an actor, so - read-only commands such as `bd list` and `bd show` start no git process - for it. The actor's value and priority order are unchanged. In an embedded - workspace with `backup.enabled` unset, the per-command auto-backup check - ("is there a git remote?") is likewise answered from the git config files - when they are plain (no includes, no command-line config), instead of - running `git -C .beads rev-parse --git-common-dir` and `git remote`. - - `bd create --graph` now stores a plan whose path from a node's parent to the node runs through a `waits-for` edge; the graph-only preflight that walked every ready-work edge used to refuse it. The plan now goes through @@ -692,702 +131,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `scripts/check-versions.sh` and `bd preflight` list the three that work: with `cmd/bd/version.go` already at the release version, that re-run rewrites only the `.githooks` markers and `uv.lock` and leaves any other drifted file as it was. -- **BREAKING (fail-closed): bd no longer migrates an existing database without - explicit consent** (Beads 1.2 release remediation). The 1.2.0/1.2.1 releases - applied migrations 54–65 at store open on ANY command — including pure reads - like `bd list` — with no prompt, and older binaries then refuse the migrated - database (schema-skew guard). A command that would apply pending - main-sequence migrations to an existing database at store open (in embedded - mode that includes reads) now refuses with guidance instead, and the refused - open performs ZERO writes (dolt_ignore seeding and clone-local migrations - included). Server-mode read commands open without running migrations, so - they keep reading at the current schema. `bd dolt commit` and `bd vc commit` - warn and commit at the current schema without migrating, so the dirty-table - recovery (commit, then `bd migrate schema`) still works on a database that - is both behind and dirty. Consent is any of: `bd migrate schema`, the verb - that names the migration (a preview flag withholds it); `--force` on - `bd migrate` or `bd migrate schema`; or `BD_ALLOW_MIGRATE=1` for scripts/CI - (`BD_ALLOW_REMOTE_MIGRATE=1` is honored as an alias). Bare `bd migrate`, - including `--update-repo-id`, `--inspect` and `--dry-run`, does not consent. - Fresh databases (`bd init`) still migrate to latest — creating a database is - consent for its schema, kept across the retry of an interrupted server - bootstrap — and the same creation principle covers a workspace the - invocation just cloned into existence (`bd init --remote`, `bd bootstrap` - sync), so the #4259 behind-remote flows keep their exact behavior. A - database already at this binary's latest version never consults the gate; - one left at v65 by 1.2.x or at v66 by 1.3.x still has migrations pending - under this release, so it asks once. The remote-backed case keeps all of the - #4259 remote-migrate gate's additional protections (smart gate, adopt - fast-forward, fork-skew analysis) unchanged. JSON consumers: the refusal - renders as a structured error whose `error` states the refusal and whose - `hint` is a non-runnable operator directive (neither names a migration - command or a consent variable), plus a `migrate_consent` object - (`current_version`, `required_version`, `pending`, `severity: "blocking"`, - `human_decision_required: true`, and `options`: `migrate` runs - `bd migrate schema`, or `bd migrate schema --global` under `--global`; - `keep` has no command). -- **Shipped migrations are frozen by CI** (same remediation): the content hash - of every released up-migration (main 0001–0066, ignored 0001–0026, through - the 1.3.x releases) is pinned by `TestShippedMigrationsAreFrozen`. Any - amendment to a released migration must land as a new migration (0070+, or - ignored 0028+, as of this change) so installed schemas and freshly-migrated - ones cannot fork. -- **BREAKING: the close guards now hold for every close operation, not only - `bd close`.** The template read-only guard, the pin guard and the assignee - authority fence (be-035) used to be a pre-read in `cmd/bd`, so a close - through `bd serve` (`POST /v0/beads/issues/{id}:close`), `issues:batchClose`, - a `close` item of `issues:batchApply`, or a library caller of - `issueops.Lifecycle.Close`, `BatchCloser` or `BatchApplier` closed a - template, a pinned issue, or a bead another actor holds that `bd close` - refused. They now live in the role, inside the close's own transaction, on - every backend: a template refuses with `*issueops.TemplateReadOnlyError` (no - bypass), and unless `Force` is set a pinned issue refuses with - `*issueops.PinnedError` and another actor's bead with - `*issueops.CloseNotAssigneeError` (matching `ErrNotOwner`). Over HTTP they - are `409` `template_read_only`, `issue_pinned` and `not_assignee` (the - holder in `assignee`, also on a batch-close outcome), and the client - rebuilds the same typed errors. `bd close` prints the same lines and exits - as before, and `bd close --if-revision`, which skipped the guards, now - applies them too. Two paths stay outside the guards. The raw storage - `CloseIssue`, which a `close` line of `bd batch` and the other closes - `cmd/bd` makes outside `bd close` use, runs neither the guards nor close - policy on dolt, embedded or proxied; over HTTP it now sends - `force`, so there it also stops applying close policy, and only a template - refuses. A status update into the done category (`bd update -s closed`, a - `PATCH` whose `status` is done, an `update` item of `issues:batchApply`) - answers to close policy only, as before, so it still closes a pinned issue - or another actor's bead. Migration: HTTP and library callers that close - pinned issues or beads another actor holds must send `force` (`Force` on the - request), or reclaim the bead first; the close operations never close a - template, forced or not (pour it instead). -- **BREAKING (out-of-tree storage backends): a create without a priority now - arrives as priority 0 with `DefaultPriority` set.** `bd create` without - `--priority`, a `bd create --graph` node without `priority` and a - `bd create --file` template without a valid `### Priority` used to reach a - backend's `IssueLifecycle().Create`, `BatchCreator().CreateBatch` and - `BatchApplier().ApplyBatch` as priority 2. They now arrive as priority 0 - with `issueops.CreateRequest.DefaultPriority` (or `BatchCreateItem` / - `CreateItem.DefaultPriority`) set, as does an HTTP create without - `priority` when `bd serve` fronts the backend. The fields are additive, so - such a backend compiles unchanged, but the shared preparation that applies - the default lives under `internal/`, so a backend that ignores the flag now - stores P0 (critical) for those `bd create` paths, and still stores P0 for - that HTTP create. Migration: store `issueops.DefaultCreatePriority` when - `DefaultPriority` is set, and refuse `DefaultPriority` with a non-zero - priority as `ErrValidation`; `conformance.RunRoleContracts` checks both - through `RunLifecycleCreateAppliesTheDefaultPriority`, - `RunBatchCreatorAppliesTheDefaultPriority` and - `RunBatchApplyAppliesTheDefaultPriority`. ### Fixed - -- An HTTP workspace whose server cannot be reached now says which step - failed. A connect that is refused names the address and says nothing is - listening; one that times out (a filtered port, a down host) names the - address that never answered and how long it waited; a host name that does - not resolve is named as such. The error was the transport's - `Get "https://…/v0/beads/context": dial tcp …: i/o timeout`, which named the - request rather than the address. -- **`bd link` works over a connected HTTP workspace.** It wrote through the - store's raw `AddDependencyWithOptions`, which the HTTP client refuses, so - every `bd link` failed there with `operation "AddDependencyWithOptions" not - supported by the http backend`, whatever the type. It now writes through - the `DependencyEditor` role, the route `bd dep add` takes, on the direct - and HTTP routes alike (the proxied-server route is unchanged). Over HTTP - that is one `dependencies:add` request, so `bd link` keeps accepting any - non-empty type of at most 32 characters (`owned-by`, `ships-in`, ...). - An empty or over-long type is still refused before anything is written, - and an edge that already exists with another type still reports the typed - conflict. On a Dolt store the history commit is now the role's, like - `bd dep add`'s: `bd: dep add ` in place of - `dependency: add -> `. - -- **`bd query` reports an uppercase duration unit as an unparseable time, not - a negated internal error.** `created>30M` failed with - `not a compact duration: "-30M"`, naming a value nobody typed; it now fails - with `cannot parse time expression: "30M"`. A signed spelling - (`created>+30M`) stops at the parser, as `created>+30x` already did, so - quote one to match it as a literal (`label="+30M"`). Units remain lowercase - (`30min`, `6h`, `7d`, `2w`, `3m`, `1y`); help and docs already say so. -- **Strict `--readonly` no longer creates workspace gate files.** A - `bd --readonly` command took its shared workspace gates with - create-if-missing, so on a workspace no bd command had gated yet it left - `/.beads.gate.lock` and the physical-root gate file - (`.beads/embeddeddolt.gate.lock` or `.beads/dolt.gate.lock`) behind, although - strict readonly promises not to mutate the workspace. It now opens an - existing gate file read-only and holds it shared as before, so a maintenance - operation still sees it and a running one still makes it wait; when no gate - file exists it holds nothing. Every other command still creates the files. -- **Strict `--readonly` refuses `bd backup init`, `backup sync`, - `backup remove`, `backup restore` and `bd import`.** None of them checked - readonly mode. On a server-mode store they ran to completion under - `--readonly`: `backup init` and `backup remove` rewrote or emptied the - server's backup registry, `backup sync` wrote the backup destination, - `backup restore --force` replaced the store, and `import` wrote issues. On - an embedded store they failed with the storage layer's `store is read-only` - error instead, after `backup sync` had left `.beads/backup.lock` behind and - `backup restore` had left workspace-gate holder files. They now exit 1 with - the standard `Error: operation '' is not allowed in read-only mode`, - and a restore is refused before it takes the exclusive workspace gate. - `bd import --dry-run` is refused too, as `bd create --dry-run` already is - and as a migration freeze already refuses it. `bd backup status` still runs - under `--readonly`. -- **`bd init --server --external` no longer starts a Dolt server of its own.** - Init builds its store config by hand and turned auto-start on for every - server init, so an `--external` init that named no port launched a - repo-local `dolt sql-server`, although `--external` says the server is - managed outside bd. `--external` now turns auto-start off. When the - external server cannot be reached, init gives one message on every route - (host and port, socket, shared server, auto-start pinned off): it names the - endpoint it dialed, says that bd did not start a server, and no longer - advises `bd dolt start`. With no port named at all, it asks for one - (`--server-port` or `BEADS_DOLT_SERVER_PORT`) instead of offering a default. -- **A failed `bd init --server` can be retried.** A first attempt that could - not reach its server left an empty `.beads/dolt` and nothing on disk that - records the server choice, so the legacy-upgrade guard refused every retry - as a "legacy Dolt workspace" and no bd command could repair it. When init - itself selects server mode, the guard now admits exactly that root: empty, - with no `.local_version` witness. A pre-1.0 witness, or a `.beads/dolt` that - holds anything, is still refused, and commands other than `bd init` are - decided as before. -- **A graph-mode workspace is refused instead of opened as an Issue store.** - Graph-preview builds mark their workspaces with `"graph_mode": "link"` and - `graph_*` binding fields in `metadata.json`, beside an ordinary Dolt - backend. bd opened such a workspace as an Issue store and ran Issue schema - initialization against the graph database, and every `metadata.json` rewrite - (including the `config.json` to `metadata.json` migration) dropped the - marker and the binding. Now any `graph_mode` other than `dependency`, - including a value bd does not recognize, makes every command that runs in - the workspace or names it with `--db` or `BEADS_DB` (`bd init`, `bd doctor` - and `bd bootstrap` included), and `bd create --repo` aimed at it, refuse it - before touching anything. The refusal names the format and exits with code - 16, so installed beads git hooks refuse commits and pushes there too. - Commands that reach such a workspace only through a route from another - one, such as a routed `bd show`, fail without touching it, but not with - code 16. Store-less commands such as `bd version` and `bd help` still run. - A `metadata.json` rewrite keeps `graph_mode` and the `graph_*` fields - graph-preview builds write, and like those builds it omits a zero - `graph_schema_version` and a false `graph_ready`. -- **A graph workspace without `graph_mode` in its metadata is refused too.** - Graph-preview builds write a `.beads/graph-preview-format` marker before - `metadata.json`. bd ignored it. When an older bd had rewritten - `metadata.json` without `graph_mode`, bd opened the graph database by its - recorded name and 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. A `.beads` holding that - marker, whatever it contains and whatever its metadata says (absent, - stripped, unparseable or an explicit `dependency`), is now refused wherever - a `graph_mode` workspace is: commands run in it or naming it with `--db` or - `BEADS_DB`, `bd create --repo` aimed at it, and `bd bootstrap` in a - workspace below it that would take its metadata exit with code 16 and a - hint to restore `metadata.json`, and routed and cross-repository opens fail - without opening its database. -- **The Go library's opens refuse a graph workspace too.** - `beads.OpenBestAvailable`, `OpenBestAvailableWith`, `OpenFromConfig` and - `OpenGated` opened a workspace whose `metadata.json` declares a - `graph_mode` other than `dependency`, or whose `.beads` holds the - `graph-preview-format` marker, as an Issue store and ran Issue schema - migrations into the graph database. They now - return `*beads.UnsupportedWorkspaceFormatError` (match it with `errors.As`) - before opening, creating or changing anything, the same refusal the CLI - exits 16 with. -- **`bd setup claude --remove` no longer leaves a blank-line hole.** Removing - the beads section from `CLAUDE.md` (or, with the other setup recipes, from - `AGENTS.md` or `GEMINI.md`) left the blank lines around it behind, three in - the `CLAUDE.md` `bd init` writes, and setup then re-added the section after - two more, so every remove and re-add grew the file. `--remove` now takes - those blank lines with the section, and setup appends a section after one - blank line, so removing and re-adding it toggles between the same two files. - A re-added section goes at the end of the file. -- **`bd config set` no longer truncates a `config.yaml` that has a line of - 64 KiB or more.** Setting an undotted key (such as `actor` or `no-db`) - rewrites the file line by line, and a line of 65,536 bytes or more ended - that read early without an error, so the command reported success and wrote - back only the lines before the long one, plus the key it set. Dotted keys - and `bd config unset` were not affected. Setting an undotted key in such a - file now fails with `bufio.Scanner: token too long`. `bd config set` leaves - the file as it was. `set-many` stops at that key, but it has already written - any `config.yaml` keys listed before it, such as a dotted `sync.remote`. -- **`bd show --as-of` exits 1 when it reads no issue.** A ref the Dolt AS OF - read does not take (an instant, a versioned-history address), a ref that - does not exist, or an issue that did not exist at the ref was reported on - stderr while the command exited 0 with nothing on stdout, even under - `--json`. It now ends the way plain `bd show` does: exit 1, with the JSON - error envelope on stdout under `--json`. A batch that reads at least one of - its ids still exits 0. Both the direct and the proxied-server routes - changed. -- **`bd list --format dot` prints the same graph the same way every time.** - Nodes are declared in id order and edges in source, target and type order. - They used to follow the listing order, which breaks a priority tie by - creation time to the second, so two equal-priority issues swapped places - depending on whether they were created in the same second, and the - proxied-server route did not pin the order of one issue's edges. `--sort` - and `--limit` still choose which issues are listed. -- **`bd init --quiet` no longer prints "Removed SessionStart hook" or "Removed - PreCompact hook"** when the project's `.claude/settings.json` (or the legacy - `.claude/settings.local.json`) still carries the bare `bd prime` hooks an - older bd registered. The hooks are still migrated to the SessionStart - `bd prime --hook-json` hook; the removal lines now go to the installer's own - output, which `--quiet` discards, instead of straight to stdout. -- **A new `AGENTS.md` from `bd init` lists `bd dolt push` in its Quick - Reference only when the workspace has a Dolt remote.** The managed Beads - section already left out its push lines when no Dolt remote is configured or - the workspace is `no-push`, but the Quick Reference above it still showed - `bd dolt push # Push beads data to remote`. It now follows the same rule. - `bd init` still leaves an existing `AGENTS.md` alone outside the managed - section, and writes an `--agents-template` as given. -- **`bd setup claude` no longer rewrites a CLAUDE.md whose beads section is - already current.** A rerun (and `bd init`, which runs it) wrote the same - bytes back as a new file, resetting its mode to 0644 and its mtime, and - reported "Updated existing beads section"; it now leaves the file alone and - reports the section current (the report `bd init` already gives a current - AGENTS.md). `bd setup factory`, `opencode`, `mux` and `gemini` share the - fix. A section whose END marker is missing or comes before BEGIN, which was - also reported as updated while nothing changed, is now reported as an error: - `bd setup factory`, `opencode` and `mux` exit 1 (`mux` before installing its - `.mux` hooks), while `claude` and `gemini` warn and carry on. When CLAUDE.md - is an `@AGENTS.md` stub and it is AGENTS.md that cannot be updated, `claude` - now names AGENTS.md in the warning and keeps the beads block left in the - stub, which it used to delete although AGENTS.md was never updated. -- **Time-bound filters and the keyset cursor compare the same instant on every - engine, whatever zone they are given in.** The storage filter builder binds - every time bound (`created_*`, `updated_*`, `closed_*`, `started_*`, - `defer_*`, `due_*`) as the UTC spelling of its instant. An engine whose - timestamp column carries no zone drops a literal's offset, so a `+02:00` - bound would have compared as that wall clock; Dolt already honored the - offset and `bd` resolves bounds to UTC, so no answer changes here. The - keyset cursor (`AfterCreatedAt`) is now bound in UTC too: embedded Dolt's - driver sends a `time.Time` as its wall clock with no zone, so a library - caller paging with a cursor in another zone was answered from the wrong - position there (server Dolt was unaffected). -- **`bd setup claude --global` keeps its beads section in `~/.claude/CLAUDE.md`.** - It wrote the section into the current directory's `CLAUDE.md`: run from your - home directory it created `~/CLAUDE.md`, which by default stops Claude Code - reading `AGENTS.md` in the projects below it, and `--remove --global` - stripped the section a project's own install had put in its `CLAUDE.md` - while leaving that project's hooks in place. A global install and removal now - use only the user-level files beside `~/.claude/settings.json`. A new - `~/.claude/CLAUDE.md` holds just the section, rendered the same whichever - project you run from. Claude Code loads that file in every project, so its - section, task-tracking rules included, applies only in repositories that use - beads. With global or plugin hooks `--check` accepts it when the project's - instructions have none, or names `--global` when it is missing and the - project has no `CLAUDE.md` of its own. Run from `~/.claude`, - or from your home directory unless `~/CLAUDE.md` still holds a section an - earlier run left there, `--check` judges the user-level files, and from your - home directory it names `--global` when no hooks are installed. From your - home directory, whose `.claude/settings.json` is the global one, `--remove` - removes the user-level section with the hooks. If you ran `--global` before, - re-run `bd setup claude --global` to add the section to `~/.claude/CLAUDE.md`. - A section an earlier `--global` run left in a directory's `CLAUDE.md` stays - there; delete it by hand if you don't want it. -- **`bd blocked --label`, `--label-any` and `--exclude-label` apply to a row - blocked only by an unsatisfied `external:` dependency.** The - external-dependency policy lists such a row itself, after the label query - has run, and it was listed whatever its labels; it is now narrowed by the - label filters like every other row, on every route. On the proxied-server - route such a row also printed with no labels; it now prints them. -- **`bd gate add-waiter` survives contention the store gave up replaying.** - It retried only a version miss, so a convoy adder failed when its guarded - write ended in a serialization failure or deadlock the backend stopped - replaying (Dolt/MySQL 1213/1205, Postgres 40001/40P01), or, over HTTP, in a - 503 busy. Those are now retried, but at most twice: each arrives only after - the store or `bd serve` has spent a whole replay budget on the write (up to - 15s), so the 20-write bound a version miss gets could hold an adder for - minutes. Each retry waits the jittered backoff plus a busy answer's - Retry-After, as `bd serve` sent it. The retry is safe because every round - re-reads the gate, deduplicates and writes the whole list guarded by the - version it read: a 503 is not proof that nothing was written (a gateway can - answer one after the commit), and a write that did land is found on the - re-read, so the waiter is never added twice; when the last write allowed is - answered busy, one more read checks for it before the command fails. A - server fault (500) and an unreachable database are still returned at once, - and once the retries run out the error says no write was confirmed and - names the write contention, instead of saying the gate kept changing. -- `bd list --title-contains X` works against an HTTP workspace. The client - folds it onto the listing's existing `title` parameter (the store compiles - both flags to the same case-insensitive substring predicate), so it needs - the `issues.list.title` capability, like `--title`. A `--title` and a - `--title-contains` that differ other than in letter case are two - predicates, so they ride `title` and `title_contains` together and also - need `issues.list.filters` (see Added), as does the `--closed-after` in - gascity's polecat pre-flight lookup of recently closed beads. Either flag - with `--parent` in the default tree view still refuses over HTTP. -- **`bd gate create`, `bd gate add-waiter` and `bd gate discover` work over a - connected HTTP workspace.** They wrote through the legacy `CreateIssue`, - `AddDependency` and map-based `UpdateIssue`, which the HTTP store does not - implement, so each failed before any gate member reached the wire. They now - run through the library roles on every route: - - `bd gate create` is ONE `Lifecycle.Create` carrying the gate members and - a reverse `blocks` edge from the blocked issue to the new gate, so the - gate and its edge land atomically (one `createIssue` over HTTP, behind - `issues.create.gates`). The direct route used to make two writes and an - explicit commit; the proxied-server route now uses the same role. - - `bd gate add-waiter` reads the gate through `Reader.Get`, deduplicates, - and writes the whole waiter list through `Lifecycle.Update` guarded by - the row version it read. On a version mismatch it re-reads and retries - after a jittered, doubling backoff (10 ms up to 400 ms per wait, at most - 20 writes), so a convoy of workers registering on one gate at once all - succeed. On the direct route concurrent adders used to lose - each other's waiters while every one exited 0; no waiter is lost now. - Over HTTP it needs `issues.update.gates`. - - `bd gate discover` lists through `issueops.ListGates` (as `bd gate check` - does) and records each discovered run ID through `Lifecycle.Update`, the - same `await_id` write `bd gate check` and `bd close` make. Over HTTP it - needs `issues.update.gates`. Its summary now counts only the gates whose - run ID was recorded, and it exits non-zero when any matched gate's write - failed (it used to report such a gate as updated and exit 0). - - Against a server that does not advertise the token it needs, `bd gate - create` and `bd gate add-waiter` are refused before any write, naming the - token; `bd gate discover` writes nothing and reports the token as that - gate's error. The served corpus gains `mc-gate-create-timer`, - `mc-gate-check-timer-resolves`, `mc-gate-add-waiter` and - `mc-update-await-id` (pending until the reference server advertises the - gate tokens), pinned passing by `TestE2E_GatesOverHTTP`. -- **`bd import` no longer reports a failed dependency check as a skipped - dependency.** Import skips an edge the dependency checks refuse (a - self-dependency, a cycle, or a blocker that is the issue's own ancestor or - descendant) and reports it on a `Skipped dependency:` line, or in - `skipped_dependencies` with `--json`. It did the same when the check's own - query failed, for example on a timeout, a dropped connection or a statement - the backend could not run: the SQL error became the skip reason, and on - Dolt, where the transaction survives a failed statement, the import - committed without the edge and exited 0. Such an error now fails the - import. Refused edges are still skipped as before. - -- **`bd mol bond ` ignored prefix routing** — operand resolution now uses - the same routing fallback as `bd show`/`bd update`/`bd close`, so a bead that - lives in a routed store (a prefix-routed rig via `routes.jsonl`, or the - contributor planning store) resolves instead of failing with `'' not found - as issue or formula`. Previously `bd mol bond` resolved operands - against the local store only, so `gt sling ` — which cooks the - default formula and bonds it to a rig-routed bead — died at `bd mol bond` even - though `bd show ` resolved the same ID. Resolution is write-intent: the - routed target opens writable and the bond commits where the bead lives. Two - operands that live in the same routed rig share one store handle and bond - normally; only a bond whose operands resolve to genuinely different databases - is rejected rather than written to the wrong one. As part of this change, an - auto-route — contributor, maintainer or default — now opens writable for the - commands that change an existing issue (`bd update`, `bd close`, - `bd comment`, `bd unclaim`, `bd dep` and the other routed mutation commands, - as well as `bd mol bond`), so the write commits where the issue lives: for a - contributor, in the planning repository, as the contributor workflow - documents. Every auto-route used to open read-only, so on an embedded - workspace these writes were refused. `bd unclaim` now opens a routed issue - writable, as `bd update --claim` does, and commits the release there; on an - embedded workspace `bd human respond` and `bd human dismiss` now record a - routed change as a Dolt commit in the routed repository instead of leaving it - uncommitted in that repository's working set. A routed - write, prefix or auto, never creates the target's database: an embedded - repository that has not been bootstrapped yet fails the write instead of - gaining an empty database that `bd bootstrap` would then take for the real - one. An auto-routed store, read or write, now opens the target's own - configured `dolt_database`, as a prefix route already did, even when - `BEADS_DOLT_SERVER_DATABASE` names the current workspace's database. An - auto-routed write refuses a target whose `metadata.json` is unreadable or - names no `dolt_database`, while a target with no `metadata.json` at all (a - planning repository nothing has been created in yet) opens the one embedded - database it holds, or its default database when it holds none or several; a - prefix route still requires the target's `dolt_database`. A - routing failure, such as an unreadable `routes.jsonl` or a - routed store that fails to open, is now reported as itself instead of as - `no issue found matching`. Same routing-parity fix as - [#3608](https://github.com/gastownhall/beads/issues/3608) for `bd close`. - Fixes [#4714](https://github.com/gastownhall/beads/issues/4714). - -- **`bd gate check` works over a connected HTTP workspace.** Its open-gate - listing built the same raw `SearchIssues` filter `bd gate list` did before - S20, so the HTTP backend refused the command before reading a gate and gc's - core `gate-sweep` order (`bd gate check --type=timer --escalate`) failed on - every remote scope. It now lists through `issueops.ListGates` over the - route's Querier (direct, proxied and remote alike). Closing a resolved gate - was already served. A bead gate's first sighting of its awaited bead - (`await_seen`, recorded when the check finds that bead, not yet closed, in - the gate's own store) was written through the legacy map-based - `UpdateIssue`, which the HTTP store does not implement, so every open bead - gate with an open target was an error on every sweep; it now goes through - the Lifecycle role's `Update` (a single-key metadata set, `issues.update` on - the wire), as does the gh:run discovery's `await_id` persist, which the - HTTP client sends to a server that advertises `issues.update.gates` (see - Added). Against an older server it refuses that patch before the dial, so a - gh:run gate with a workflow-name hint stays that gate's error, naming the - missing token and the server rather than a Go method. - The sweep also skips the gates of a persisted proto - (`bd cook --persist`): they are templates that every pour copies, so a - write to one was refused on every sweep and, in a local workspace, a - resolved one (an expired timer, say) was closed in the proto itself. The - listing's query leaves them out (`template=false`), so they take no row of - `--limit` and cannot crowd a live gate out of the sweep; `bd gate list` - still lists them. A negative `--limit` is now an error; the direct and - proxied routes used to read it as no limit. The served corpus gains - `mc-gate-check-timer`, `mc-gate-check-gh`, `gate-check-all` and a served - test over await-typed and template gates. - -- **`bd list`'s text renderings read only the listed issues' dependency - edges.** The tree (the default), `--deps`, `--parent`, `--format` and - `--watch` loaded every dependency record in the workspace - (`GetAllDependencyRecords`) to draw one page. Over a connected HTTP - workspace that is a walk of the whole workspace: every issue id, 200 per - request, then every id's edges, 100 per request. `bd list --limit 20` - against a ~3,800-issue workspace made 62 sequential requests (~5.7 s at - ~50 ms a round trip). Every rendering reads only edges a listed issue owns, - so the listing now reads exactly those through the `EdgeReader` role: one - request per 100 listed ids over HTTP. The same listing makes 6 requests - (~0.5 s), one more than `bd list --json`, and prints the same bytes. On a - local store a default page is as fast or faster. A listing that covers most - of a large store now pays batched reads (four queries per 200 listed ids) - instead of one scan of both edge tables, which costs more past roughly - 1,000 listed rows: +0.07 s at 1,000 rows and +0.46 s at 4,000 on embedded - Dolt. A store with many wisps, whose edges the old read also scanned, is - faster at every page size. -- A heartbeat can no longer resurrect a lease after a release or close. A - heartbeat re-arming a hand-doled claim (in_progress with no lease row) could - race a release or close on Dolt and leave an orphaned lease row on an open - or closed issue; every later heartbeat by the former holder then refreshed - it and answered success for a claim it no longer held. This affected every - Dolt route, including releases before this one. The re-arm is now recorded - as a mutation and remints the issue's row_lock, which every claim-ending - path rewrites, so it collides with a racing release or close and one side - is replayed against the other's result (the cost: a hand-doled claim's - first heartbeat changes its `revision` once). The refresh also requires, in - the same transaction, that the issue is still in_progress under the holder, - and a refusal deletes the caller's orphaned lease row, so a lease row - orphaned any other way never answers a heartbeat. A refresh and a refusal - still make no Dolt commit on any route; a re-arm commits only its own - tables (never `DOLT_COMMIT('-Am')`), so another writer's uncommitted - batch-mode edits to other tables stay uncommitted (a re-arm stages its - tables whole, as every other direct-route write does). On embedded Dolt, a heartbeat landing in - the same second as the previous one no longer re-grants the lease - (rewriting its `granted_at` / `granted_node`), and on every route a - heartbeat whose actor is a different spelling of the lease's holder - (`gastown.mayor` for `gastown__mayor`) refreshes the lease in place, - keeping its `granted_at` and granting replica, instead of re-granting it - under this node. For a Postgres port: the - refresh now reads the issue row, so under SERIALIZABLE expect more retried - serialization failures between a holder's own edits and its heartbeat. -- **`bd gate list` works over a connected HTTP workspace** (S20). The - workspace-wide listing built a raw `SearchIssues` filter, which the HTTP - backend refuses, so gc's `renudge-stale-human-gates` order failed on every - remote scope. Every route now calls one library entry, - `issueops.ListGates`, which asks the Querier role (`queryIssues`, served by - every deployed server) for `type=gate` with closed rows hidden unless - `--all`: the same rows the raw filter selected, on both planes. `--limit 0` - is unlimited, as before. The bead-scoped form (`bd gate list `) is - unchanged. -- **`bd export` works over a connected HTTP workspace** (S21). It read - through the raw `SearchIssues` method and the bulk label, dependency and - comment reads, which the HTTP backend refuses, so gc's 15-minute JSONL - export order (`gc bd export --all`) failed on every remote scope. On a remote - backend the read set now comes from one library entry, `issueops.ReadExport`, - composed over role reads every deployed server publishes: an unlimited - `Reader.List` for the rows, their labels and counts, `EdgeReader.ReadEdges` - for the dependency records, and `Reader.Get` with comments for each row - that has any. The JSONL is written by the same code as on every other - route. Memories (`--all`, `--include-memories`) come from the served memory - plane (`listMemories`), not the settings listing, which withholds every - `kv.*` row and so exported none. A failed read fails the export, never - shortens it. A remote export does not yet stamp the `wisp_plane` marker, - because the server publishes no plane membership. So a current `bd import` - of a remote export puts genuine no-history wisps on the durable issues - plane instead of the wisps plane, and gc's JSONL archive keeps them. - Nothing is dropped. -- **A silent HTTP connection no longer costs a read the full 60s.** The HTTP - backend client gives a read's first attempt 15s from when it is sent to get - its response headers (`BEADS_HTTP_RESPONSE_HEADER_TIMEOUT`: a duration, a - number of seconds, or `off`), then retries it once on another connection - with no header timer, on what is left of the same 60s request timeout. A - slow but healthy read still finishes if its retry's headers and body - together fit in that remainder (about 45s); one that needs longer now fails - at 60s. A read whose connection is reset is retried the same way (on Windows - only when the reset surfaces as an early EOF), and each retry is logged to - stderr with its count. The events:watch stream's connect gets neither the - timer nor the retry. A write is never retried; one that was sent and timed - out before its headers fails with a typed `wire.ResponseHeaderTimeoutError` - naming the server's host, because it may or may not have been applied, - while a dial or TLS timeout stays a plain connection error. The batch get, - a read on POST, is now also retried on a 503 the way a GET is. -- **A large batch apply over HTTP no longer fails at 60s while the server - commits it.** `bd serve` runs an `issues:batchApply` of more than 100 items - (a large `bd create --graph` plan, say) under its `--large-apply-ceiling` - (5 minutes by default), on a context detached from the client, but the HTTP - backend client gave every request 60s. A large apply that took longer - failed client-side with a timeout while the server went on to commit it. - Such a request is now dialed with 6 minutes, which covers the server's - default ceiling plus what it may spend before (reading the request, waiting - for the one-wide large-apply slot) and after (writing the answer back). - Every other request keeps 60s. An `*http.Client` passed in through - `backend/http`'s `Options.HTTPClient` is raised the same way for that one - request when its `Timeout` is shorter than 6 minutes; one with no `Timeout` - stays unbounded. A server whose `--large-apply-ceiling` is raised past about - 5m15s can still outlast the client: it does not advertise its ceiling, so - the client cannot learn it. -- **An update of a template is now refused for every caller, not only - `bd update`.** The template guard used to be a pre-read in `cmd/bd`, so an - update through `bd serve` (`PATCH /v0/beads/issues/{id}`), an `update` item - of `issues:batchApply`, or a library caller of `issueops.Lifecycle.Update` or - `BatchApplier` edited a template that `bd update` refused. It now lives in - the role, in the update's own transaction, on every backend: any update - naming a template refuses with `*issueops.TemplateReadOnlyError` (matching - `ErrTemplateReadOnly`), whatever its patch and force flags, after the - compare-and-set guards. Over HTTP it is `409` `template_read_only`, and the - client rebuilds the same typed error. HTTP and library callers that edited - templates are now refused (pour the template instead) unless they set the - new `UpdateRequest.AllowTemplate` (`allow_template` on the PATCH body), which - stands the guard down for that one request. `bd update`, `bd assign` and the - proxied `bd tag` print the same line as before; `bd label` and - `bd set-state` set `AllowTemplate` and keep editing templates as they always - have. A batch create that makes a template and splices its metadata still - lands: the splice finishes the create. Version skew: a new `bd` against an - older `bd serve` (no `issues.update.allowTemplate` token in the handshake) - refuses a single template update itself before dialing, and never sends - `allow_template` to it. A batch `update` item gets no such check (its target - resolves on the server), so through an older `bd serve` it still edits a - template. An older `bd label` or `bd set-state` against a new `bd serve` - cannot send `allow_template`, so it now gets `409` `template_read_only` on a - template; upgrade the client. Not yet moved: `bd comment`, `bd note`, - `bd priority` and `bd tag` still refuse templates with their own pre-read in - `cmd/bd` (their direct-route writes do not go through `Lifecycle.Update`), so - for those four the guard lives only in the CLI. Claim, reopen, `:casMetadata` - and the served `addComment` have no template check at all yet (bd-jkp9v3): - `POST /v0/beads/issues/{id}:claim` (`issueops.Claimer`) still claims a - template that a `PATCH` with `claim: true` refuses. Close's guards move to - the role in their own change (#7425). -- The dotted-id hierarchy refusal (a child such as `bd-abc.1` may not carry an - explicit edge to its own ancestor, other than the parent-child edge to its - immediate parent) moved from `cmd/bd` into the library as - `issueops.CheckDottedChildDependency` / `*issueops.DottedChildDependencyError` - (unwraps to `ErrValidation`). Every `DependencyEditor` (dolt, embedded, - unit of work, HTTP) and every `BatchApplier` dep_add item now enforces it, so - an HTTP `dependencies:add`, a `batch:apply` edge and `bd create --graph`'s own - edges are refused like `bd dep add` (HTTP: 400 `invalid_argument`). `bd dep - add`, `bd dep --blocks`, `bd link` and `bd dep add --file` print the same - messages as before, and a `bd batch` script's `dep add` line, which neither - backend checked, is now refused with that message and rolls the whole batch - back. The refusal is decided from the two ids, ahead of every check that - reads the stored graph, so for a child whose parent-child edge is already - stored (a `bd create --parent` child) an HTTP caller now gets that 400 where - it used to get 409 `dependency_cycle` (a blocking type) or - `dependency_exists` (any other type). -- An HTTP create (`issues:create`, `issues:batchCreate`, a `batch:apply` - create item) that omits `priority` now stores the create default, P2, as the - spec documents, instead of P0 (critical). The default lives in one place: - `issueops.CreateRequest.DefaultPriority` (and `BatchCreateItem` / - `CreateItem.DefaultPriority`) asks the shared create preparation to store - `issueops.DefaultCreatePriority`; the handlers set it for an absent member, - the HTTP client omits `priority` for it only when the server advertises the - new additive `issues.create.defaultPriority` handshake token (an older - `bd serve` reads an absent `priority` as P0, so a new client sends `2` - explicitly to it), and `bd create` (no `--priority`), - `bd create --graph` (a node without `priority`) and `bd create --file` (a - template without `### Priority`) rely on it rather than spelling 2. An - explicit `0` is still P0, and `DefaultPriority` with a non-zero priority is - `ErrValidation`. CLI output is unchanged on the in-tree backends, except - that `bd create --file` now warns on stderr about a `### Priority` it cannot - parse, as it already did for `### Type`, rather than dropping it silently. - The client decides from the handshake its store cached (once per command - in `bd`), so a create that lands on an older build behind the same URL (a - `bd serve` rolled back under a live store, or mixed builds during a - rollout) still stores P0, with no error on either side. - Out-of-tree storage backends must now honor `DefaultPriority`; see the - BREAKING (out-of-tree storage backends) entry under `### Changed`. -- Blocked-state repair no longer lets a stale `is_blocked` bit on a parent - with no reason row of its own hold itself up through a parent that blocks - on its own child, in a malformed parent-child cycle (gastownhall/beads#7386). - The explained-parent walk, on both the full repair and the per-write - recompute, now climbs through such a parent, whose bit is inherited, - instead of treating it as a final unexplained ancestor; `bd doctor`'s - Blocked State check counts the stale bit and `--fix` clears it. - -- `bd show --current` over the HTTP backend no longer prints the wrong issue. - Its in-progress/hooked lookup used the raw `SearchIssues` method, which - the HTTP backend refuses; the refusal was swallowed and the command fell - back to the last-touched issue, exit 0. The lookup now reads through the - `issueops.Querier` role, and a failed read is an error on every route - (including `--proxied-server`), never a fallback. A miss (nothing in - progress or hooked, or no actor) is another matter: `--proxied-server` now - falls back to the last-touched issue as the direct route always has, where - it used to fail with `no current issue found`. -- `bd list --type --include-ephemeral` (and `GET - /v0/beads/issues` with the same parameters) now include that type's durable - rows — a promoted wisp, an issue retyped after it was created — beside its - wisps, as `--include-ephemeral` promises; the type used to narrow the read - to its wisps alone. `bd count --include-infra --include-ephemeral` and the - count endpoint count the same rows. An infra `--type` without - `--include-ephemeral` still reads only the wisps, and `bd search --type - `, now served by the same listing, still finds that type's - wisps and durable rows alike. -- `bd recompute-blocked` on a workspace connected to `bd serve` is a no-op - that exits 0 instead of refusing: the server maintains `is_blocked` on - every write and the column lives in its database. `--json` reports - `{"rows_corrected": 0, "maintained_by": "server"}`. -- **The http store's `GetIssue` answers a miss with `storage.ErrNotFound`, - like the local stores.** It used to answer a missing (or empty) id with - `(nil, nil)`, which every caller written against the backend contract - read as a hit: `bd create --graph` refused every plan naming an explicit - id over http. The miss is now `not found: issue `, wrapping - `storage.ErrNotFound` exactly as `issueops.GetIssueInTx` does; the empty - id never dials. -- **`bd list`, `bd children`, `bd show --json` counts, the default `bd dep - tree`, `bd ready --claim` and `bd close` work on an http workspace.** The - external-dependency decorator rebuilt its views from storage seams the - http store only partly serves, so `bd list`/`bd children` refused, `bd - show --json` printed zero dependency and comment counts without an error, - and the default dep tree refused; each view now passes the server's own - role through (see *Added*). A missing id is a plain not-found after one - `getIssue`, instead of a partial-id search refusal, and `bd update - --claim` answers a not-found gc classifies. -- **`bd mol wisp gc --age 0s` can miss a just-created wisp.** Dolt's - `DATETIME(0)` column rounds fractional seconds half-up on write rather - than truncating, so 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. The GC's - age check (`now.Sub(updatedAt) > ageThreshold`) then compares against a - negative duration and fails, even though `--age 0s`'s own contract is - that every wisp qualifies. `ageThreshold <= 0` now bypasses the clock - comparison entirely (#7236). -- **`bd mol wisp gc` no longer deletes a fresh step because a wisp it - depends on is abandoned.** The GC applied `--age` only to the wisps it - selected directly, then deleted their dependents at any age as long as - they were not live work, so a step created seconds earlier went with an - old wisp it depended on, and raising `--age` did not help. A dependent - now has to meet `--age` itself, by the same rule as the wisp it depends - on (including the #7236 rounding fix). One that is too young is spared - and loses its edge to the deleted wisp: an open one is collected once it - ages out, a closed one is left for `--all`, `--closed` or `bd purge`, - since without `--all` the GC reaches a closed wisp only as the dependent - of an abandoned one (#5219). -- `bd create --parent` works on the HTTP backend: the create role mints the - `.` child id (and inherits the parent's labels) inside the - create on every route, instead of the CLI reserving it through a raw - `GetNextChildID` the HTTP backend does not serve. `bd mol current` (with - or without an id) and `bd mol progress` no longer answer empty or refuse - over http, and `bd ready --mol` step rows carry their assignee and - timestamps. -- **Server-mode config writes are committed again.** On the direct SQL-server - route, `bd remember`, `bd forget` and `bd config set|unset|set-many` wrote - the `config` table but never created a Dolt commit: `maybeAutoCommit` - returns early off the embedded route, and plain `Commit()` excludes config - (GH#2455). The rows sat in the working set, where `bd dolt push` does not - carry them, and a dirty internal key such as `status.custom` made the next - `bd dolt pull` refuse until an explicit `bd dolt commit`. With - `dolt.auto-commit` on (the default) these writes now commit right away - through the scoped `CommitConfigOnly`, which stages only `config` and the - lookup tables projected from it, so a concurrent operation's other dirty - tables are never swept; `batch` and `off` defer them to `bd dolt commit` - like every other write. `bd remember` and `bd forget` commit only user - `kv.*` rows. When an internal config key is dirty (such as the - `issue_prefix` that `bd rename-prefix` writes), the memory is still - stored but not committed: the command warns on stderr with the keys named - and exits 0, `--json` adds `committed: false`, `commit_error` and - `dirty_config_keys`, and `bd dolt commit` publishes the memory with those - keys. v1.0.1 ([#3052](https://github.com/gastownhall/beads/pull/3052)), - whose commits this restores, also warned on a failed memory commit - instead of failing the write. `bd config unset` of a yaml-only secret key - also commits its delete of a credential row an older bd stored in the - database, so HEAD, which `bd dolt push` publishes, no longer keeps it - ([#4078](https://github.com/gastownhall/beads/issues/4078)). - - **PRs based on `hotfix/**` branches now run full CI, not just cross-version historical smokes and triage labeling.** `pr.yml`, `pr-risk.yml`, `conformance.yml`, `cross-version-smoke.yml` and @@ -1671,20 +416,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `bd context` also prints `cwd repo: git: unavailable` rather than silently omitting the one degraded state it exists to report. -- **Server-mode `bd federation sync` and `bd federation status` work with Dolt - remotes that have no stored peer credentials** - ([#5128](https://github.com/gastownhall/beads/pull/5128), fixes - [#4837](https://github.com/gastownhall/beads/issues/4837)). A remote added - by `bd federation add-peer` without `--user` or by `bd dolt remote add` has - no `federation_peers` row, and every server-mode `bd federation` push, pull - and fetch to it failed at the credential lookup with `failed to get peer - credentials: not found: federation peer `. A missing row now means no - stored credentials, as it already did in embedded mode, so the operation - runs with Dolt's own credential discovery: `bd federation sync` without - `--peer` syncs those remotes too, and `status` fetches them. Errors reading - or decrypting a stored row still fail. A mistyped `--peer` now fails with - Dolt's own unknown-remote error instead. - - **`bd comment`/`bd comments add` refuse an abbreviated id and a reserved word instead of silently resolving one to the wrong issue** ([#5393](https://github.com/gastownhall/beads/pull/5393)). `bd comment list @@ -1711,28 +442,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 resolution never performed abbreviation matching in the first place) — a regression test now locks that in rather than leaving it undocumented. -- **`bd delete` no longer resolves an id it cannot find to a different issue - whose id begins with it.** - ([#7375](https://github.com/gastownhall/beads/pull/7375)). The direct - (embedded and server) route resolved - each id with the abbreviation-tolerant resolver, so an id that was already - gone (a retried delete, a re-run `--from-file` list, a parent whose child - survives) resolved by leading-prefix match to whichever surviving issue's id - it begins: after `fx-t00003` was deleted, `bd delete fx-t00003` previewed - `fx-t000031` and printed `bd delete fx-t000031 --force` as the next step, - and with `--force` deleted it. `--quiet` silenced the partial-id notice, so - a `--force --quiet` re-run deleted issues it never named without a word. - `bd delete` now requires an exact id on the preview and with `--force`, as - `bd comment` does and as the team-server route already did; full ids, bare - full hashes, child ids and routed ids resolve as before. An abbreviation is - refused with `issue "t000" not found: bd delete needs the full issue id, and - "t000" is only the start of fx-t000031`, naming every id it matches; under - `--if-revision` it is the guard's lost race instead (`precondition_failed`, - exit 13), as for any other gone id. This is a user-visible change: a script - or habit that deletes by abbreviation now gets that error and must pass the - full id. Reads and other writes keep accepting abbreviations; see [Working - with IDs](docs/core-concepts/hash-ids.md#working-with-ids). - - **A git hook beads never wrote is no longer reported as installed** ([#6084](https://github.com/gastownhall/beads/issues/6084)). `getHookVersion` returns no error for a readable hook file that carries no beads markers, so a @@ -1753,30 +462,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 installed/missing check still only tests for file existence and is tracked separately. -- **`bd close` verifies a bead gate in proxied-server mode.** The close - pre-check built its bead-gate lookup on the local store, which the - proxied-server route never opens, so closing a bead gate there refused with - `no local store available` even after the awaited bead had closed, while - `bd gate check` resolved the same gate. The close pre-check now reads the - awaited bead through the same fresh-read path `bd gate check` uses on that - route; the direct and embedded routes are unchanged - ([#5861](https://github.com/gastownhall/beads/issues/5861) item 1). - -- **`bd recall`, `bd forget`, `bd remember `, - `GET /v0/beads/memories/{key}` and `DELETE /v0/beads/memories/{key}` now - treat an empty-valued memory as present** - ([#5964](https://github.com/gastownhall/beads/pull/5964), fixes - [#5963](https://github.com/gastownhall/beads/issues/5963)). Presence used to - be derived from the stored value's truthiness, so a memory written out of - band with an empty string was invisible even though its row existed. `bd - recall` printed "No memory with key" and exited 1, `bd forget` refused to - delete it, `bd remember ` refused to recall it, and both HTTP - doors answered 404 (the DELETE leaving the row in place), while - `GET /v0/beads/memories` already enumerated the same row. Presence now comes from row existence on direct Dolt, embedded Dolt and - the proxied backend. An empty-valued memory is found, recalls as an empty - string, and is deleted on the first forget. Only a key with no row is a - miss. - - **`bd doctor` no longer flags a `.local_version` that starts with `v`.** The canonical spelling of a Go module version — and the string a build stamped from a Go pseudo-version reports and writes into `.local_version` itself — @@ -2133,30 +818,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 section — plus the upgrade and init-safety ordering rules — now records the `bd dolt pull` exception instead of stating the pull is always refused. - **Proxied-server mode reaches the stop too, and is told where to run the - remedy.** The store-open gate on that path supplied no branch-position - callback, so a proxied clone that was level on schema and behind in data - could never be classified data-behind: it got the blunt shared-store refusal, - whose body is the designated-migrator recipe — `bd migrate --force` then - `bd dolt push` — which in this state is the wedge the stop exists to prevent. - It now routes to the same data-behind stop as every other topology. Because - `bd dolt pull` is refused at the proxied front door - (`proxy.dolt_pull.unsupported`), along with `bd dolt push`, the bare - `bd migrate` and `bd conflicts`, the guidance there names the machine the pull - has to run on rather than printing a command this binary rejects; the `--json` - option is `pull-first-on-server-host`, and `expected` carries the same - qualifier so a single-field reader is not handed a locally-refused command. - The shared-store consent step is the other way round: `bd migrate schema - --force` is *not* refused here — the capability registry permits the - two-word `migrate schema` path — so the guidance says it can be run from this - workspace but only after the pull lands on the server host, and the warning - against forcing past the stop names it alongside `BD_ALLOW_REMOTE_MIGRATE=1` - as the two consent surfaces this topology can still reach. Read-only proxied - opens print the same pull-first block instead of the shared-consent template. - The *Clone behind the remote* docs section the payload links to, and the - upgrade and init-safety ordering rules that point at it, now give the same - proxied-server answer. - Both existing escape hatches are unchanged: `bd migrate --force` / `BD_ALLOW_REMOTE_MIGRATE=1` are still consulted before the smart gate, and `BD_SMART_GATE=0` still yields the blunt gate unconditionally (including for @@ -2497,37 +1158,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- **`bd init` refuses to initialize directly in your home directory** - ([#4635](https://github.com/gastownhall/beads/issues/4635)). `bd init` sets - up the directory it runs in as a project: it runs `git init` there unless it - finds a repository, and installs agent files — `CLAUDE.md`, `AGENTS.md`, - `.gitignore`, `.claude/`, `.codex/`, `.cursor/`, `.agents/`. In your home - directory most of those are your agents' user-wide settings, so bd's hooks - ended up running in every project, and init did this silently under - `--non-interactive`, which engages automatically whenever stdin is not a TTY - (so: whenever an agent runs it). A project is virtually never the home - directory itself, so this now refuses with exit code `15` - (`ExitHomeDirRefused`; `13` and `14` already mean a lost conditional-write - race and a migration freeze), documented at - `docs/recovery/init-safety.md#init-home-refused`. - - Deliberately narrow: it fires only when the working directory is *exactly* - your home directory, your home is not itself a git repository (tracked - dotfiles are unaffected, but a home that only sits inside an enclosing - repository, or a `GIT_DIR` inherited from the environment, does not count), - and you did not name a `BEADS_DIR` yourself. A subdirectory of home is an - ordinary project and is never refused. If you do name a `BEADS_DIR` from - an untracked home, init sets up only that workspace: no `git init`, no - agent files or `.gitignore` in your home directory, and nothing in a - repository your home sits inside (no hooks, `beads.role`, Dolt remote taken - from its origin, or bootstrap commit) unless a flag such as `--stealth` or - `--setup-exclude` asks for it. `--force` and - `--reinit-local` do not override the refusal — they bypass the local - data-safety guard, which is a different question from "is this the right - directory". The guard runs first in init's `RunE`, ahead of every path with - an effect, including the proxied dispatch and the store-opening - `--reinit-local` pre-checks. - - **The managed shared Dolt server now opens its configured remotesapi listener** ([#6020](https://github.com/gastownhall/beads/pull/6020)). `dolt.remotesapi-port` (machine-global user config) and @@ -2803,59 +1433,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 override) rather than letting a dead store read as satisfied. On the classic and proxied routes alike, `bd gate check` now exits non-zero whenever any gate it checks (gh, timer, or bead) could not be checked or - closed. A bead in a prefix-routed rig whose store cannot be read stays - pending, with the routing failure in its reason (`cannot confirm the - awaited bead is gone`); for a missing bead, see - [#6395](https://github.com/gastownhall/beads/pull/6395). - -- **`bd gate check` resolves a bead gate whose awaited bead was deleted** - ([#6395](https://github.com/gastownhall/beads/pull/6395)). A bead gate - waited for its target to close, so deleting the target left the gate - pending forever and its step blocked. The first `bd gate check` that finds - the target in this rig's own store now records the sighting in the gate's - metadata (`await_seen`), and a later check that no longer finds it there - resolves the gate (`awaited bead no longer exists`). An await ID that - no check has seen, such as a typo or a bead deleted before the first check, - stays pending with a diagnostic instead of unblocking the step: correct the - await ID or close the gate with `bd gate resolve`. A miss outside this - rig's store (a target whose prefix routes to another rig, or a contributor - auto-routed store) does not prove the bead gone, so the gate stays pending - and the reason names the cause. `bd close` on a bead gate follows the same - rule: it no longer needs `--force` once an earlier check saw the awaited - bead and the bead is gone from the gate's rig, with no route pointing - elsewhere. `bd rename` and `bd rename-prefix` point a bead gate at its - bead's new ID, sighting included, so a renamed bead does not read as - deleted, even to a check or `bd close` that read the gate before the - rename; a rename that fails partway leaves the gate pending without a - sighting, never resolved. A rename by an older bd does not move the - gate: if a check had already seen the bead, a later check or `bd close` - treats that rename as a deletion and closes the gate while the bead is - still open, so upgrade every client that renames beads together with the - ones that check gates. - -- **An epic that blocks on its own children no longer hides them from `bd - ready`** ([#6506](https://github.com/gastownhall/beads/issues/6506)). A - parent-child edge now propagates only a parent's *exogenous* blockedness — - blockedness whose cause lies outside the parent's own subtree — so the - close-gate idiom, a parent carrying `blocks` edges onto its own children (or - grandchildren) so it cannot close before them, stops darkening the very work - it is waiting for. The parent itself stays blocked, and a close gate does not - unlock the work under an epic that is itself blocked from outside: a sub-epic - blocked BOTH by its own children AND by an exogenously blocked ancestor still - darkens its children - ([#6601](https://github.com/gastownhall/beads/issues/6601)). - "Inside my own subtree" is decided to a fixed depth of **four** - parent-child levels — epic → sub-epic → leg → task — so a parent that - blocks on something deeper than that still darkens its whole subtree, exactly - as it did before this fix; that depth is a measured trade (the - bounded walk is a fixed chain of index probes, where a recursive one cost - 7.5x per evaluation) and raising it is a one-constant change. Existing stores - repair on the next write that touches the hierarchy, or with - `bd doctor --fix`. -- `bd dep add` no longer explains its refusal of a blocking edge onto your own - descendant by claiming the block would cascade down and never clear — it - does not, as of the fix above. The refusal stands, and now names the - sanctioned way to say it: a waits-for gate over the children. + closed. A missing bead still stays pending, and for now so does a bead in + a prefix-routed rig whose store cannot be read: routing still reports that + failure as not-found. - **`routes.jsonl` prefixes containing a hyphen now route** ([#5048](https://github.com/gastownhall/beads/issues/5048)). Prefix routing diff --git a/MODULE.bazel b/MODULE.bazel index e157d6d59..4daf1ae58 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -39,26 +39,12 @@ bazel_dep(name = "rules_cc", version = "0.2.17") # 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 .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", + mirrors = [ + "https://snapshot.ubuntu.com/ubuntu/20261001T000000Z/", + "https://archive.ubuntu.com/ubuntu/", + ], 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", @@ -84,7 +70,6 @@ deb_sysroot( "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" @@ -165,13 +150,6 @@ llvm_host_dist( 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++"}, @@ -210,22 +188,6 @@ go_sdk.nogo( 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). @@ -327,7 +289,7 @@ dolt_release( version = "2.1.8", ) -# The tracked release formula, for //scripts:shell_scripts_test and the +# The tracked release formula, for //scripts: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. diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 82bd1b0bc..275b6bfd9 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -18,8 +18,8 @@ "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/2.5.2/MODULE.bazel": "bb1b7081e390a8d3885f642cb0073dfcf8e7a36525e079fa8f5835af7079c0fe", - "https://bcr.bazel.build/modules/apple_support/2.5.2/source.json": "dd51ee925a550e92b55eb41c4c809a967da311a2d2520241252a238a48b39c4c", + "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/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", @@ -138,9 +138,9 @@ "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.63.0/MODULE.bazel": "a2079e783a5d2715a90e6e2970ec8ffd717a487ff2aecb5f553e3975c5294a21", @@ -229,7 +229,7 @@ "moduleExtensions": { "@@pybind11_bazel+//:internal_configure.bzl%internal_configure_extension": { "general": { - "bzlTransitiveDigest": "BsgERqYptkJeeC8wFaLj251IoTZTSy/58WA6kVp0q8I=", + "bzlTransitiveDigest": "NRXra7941UfmNUyIxnLt82V5hULluVGL2nBsijTl4j4=", "usagesDigest": "D1r3lfzMuUBFxgG8V6o0bQTLMk3GkaGOaPzw53wrwyw=", "recordedInputs": [ "REPO_MAPPING:pybind11_bazel+,bazel_tools bazel_tools", @@ -251,7 +251,7 @@ }, "@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { "general": { - "bzlTransitiveDigest": "WDuVCwqV73DvcHB5Of+02lhUZgPxr9MqtpvMRyUi0eQ=", + "bzlTransitiveDigest": "+Kp6j204mBZ3mxlIDDR0gBoP45BZ4jYRhRAcB8sU0qc=", "usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=", "recordedInputs": [ "REPO_MAPPING:rules_kotlin+,bazel_tools bazel_tools" @@ -308,7 +308,7 @@ }, "@@rules_python+//python/extensions:config.bzl%config": { "general": { - "bzlTransitiveDigest": "L+2ZCpb7GIJqvWaXpzkfk/80d916sIFVmSPzrSm6of8=", + "bzlTransitiveDigest": "dzD8Q2YmrP3fz8saWLHPmlwPLO91ImtTmP/c9JKTStM=", "usagesDigest": "ZVSXMAGpD+xzVNPuvF1IoLBkty7TROO0+akMapt1pAg=", "recordedInputs": [ "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", @@ -476,7 +476,7 @@ }, "@@rules_python+//python/uv:uv.bzl%uv": { "general": { - "bzlTransitiveDigest": "IgkgxNrtlAec7OnaFrWoCC5NQhHcY/aIz4jsqcNMm8Y=", + "bzlTransitiveDigest": "ijW9KS7qsIY+yBVvJ+Nr1mzwQox09j13DnE3iIwaeTM=", "usagesDigest": "H8dQoNZcoqP+Mu0tHZTi4KHATzvNkM5ePuEqoQdklIU=", "recordedInputs": [ "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", diff --git a/Makefile b/Makefile index d0bfbbdc6..fe5ada1c1 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ 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: 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: ci-pr-core ci-pr-lint ci-complexity ci-complexity-diff ci-complexity-check ci-package-mcp ci-package-npm .PHONY: api-gen api-check .PHONY: bazel-sync bazel-sync-check @@ -237,16 +237,6 @@ ci-pr-core: 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 diff --git a/README.md b/README.md index f7909900f..0984804ed 100644 --- a/README.md +++ b/README.md @@ -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 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). +`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). 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 schema` and `bd dolt push`; other clones install the new -binary and run `bd bootstrap`. See the full +`bd migrate` 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,153 +175,6 @@ 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]=`, then -`BEADS_HTTP_TOKEN_COMMAND=host[:port]=` (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. diff --git a/RELEASING.md b/RELEASING.md index 50acb6497..e05b73072 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -145,8 +145,7 @@ Before starting a release: - [ ] 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** - (`bazel test //tests/regression:regression_test --config=doltserver-cmd`) +- [ ] **Regression tests pass** (`make test-regression`) - [ ] **Every release target cross-compiles** — see [Cross-compile before tagging](#cross-compile-before-tagging). PR CI builds them only with cgo off, and a target that fails at tag time diff --git a/VERSIONED-BEADS-WRITE-PATHS.md b/VERSIONED-BEADS-WRITE-PATHS.md index bed384ade..887816aad 100644 --- a/VERSIONED-BEADS-WRITE-PATHS.md +++ b/VERSIONED-BEADS-WRITE-PATHS.md @@ -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 (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. | +| 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. | | 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 | diff --git a/backend/BUILD.bazel b/backend/BUILD.bazel index 912285a3e..efaf0d7b9 100644 --- a/backend/BUILD.bazel +++ b/backend/BUILD.bazel @@ -47,51 +47,12 @@ filegroup( # --- 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", + name = "repo_files", srcs = glob( ["**"], exclude = [ "**/*.db", "**/*.exe", - "**/*.go", - "**/*.md", - "**/*.mdx", "**/*.out", "**/*.prof", "**/*.pyc", @@ -100,7 +61,7 @@ filegroup( "**/node_modules/**", ], ), - visibility = ["//:__subpackages__"], + visibility = ["//:__pkg__"], ) # --- end repo_files --- diff --git a/backend/conformance/BUILD.bazel b/backend/conformance/BUILD.bazel index 2ba90b30b..3ff778c49 100644 --- a/backend/conformance/BUILD.bazel +++ b/backend/conformance/BUILD.bazel @@ -11,11 +11,9 @@ 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", @@ -29,25 +27,19 @@ 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", @@ -65,13 +57,11 @@ 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", @@ -125,51 +115,12 @@ filegroup( # --- 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", + name = "repo_files", srcs = glob( ["**"], exclude = [ "**/*.db", "**/*.exe", - "**/*.go", - "**/*.md", - "**/*.mdx", "**/*.out", "**/*.prof", "**/*.pyc", @@ -178,7 +129,7 @@ filegroup( "**/node_modules/**", ], ), - visibility = ["//:__subpackages__"], + visibility = ["//:__pkg__"], ) # --- end repo_files --- diff --git a/backend/conformance/batch_apply_contract.go b/backend/conformance/batch_apply_contract.go index 333745ada..5bb9e7056 100644 --- a/backend/conformance/batch_apply_contract.go +++ b/backend/conformance/batch_apply_contract.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "reflect" - "strings" "testing" "github.com/steveyegge/beads/internal/types" @@ -171,12 +170,6 @@ 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 @@ -888,12 +881,9 @@ 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, 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. +// 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. func RunBatchApplyClosePolicyEvaluatesAtTheCloseItem(t *testing.T, ctx context.Context, fixture BatchApplyFixture) { t.Helper() parent := fixture.IssuePrefix + "-closepolicy-parent" @@ -933,7 +923,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 waives the parent's close policy, it does not close the child", child, got, types.StatusOpen) + t.Errorf("%s status = %q, want %q: Force bypasses the close policy and nothing else", child, got, types.StatusOpen) } assertBatchApplyTypedEdgeCount(t, ctx, fixture, child, parent, string(publicops.DepParentChild), 1) } @@ -1535,11 +1525,10 @@ func RunBatchApplyNormalizesTheWaitsForGate(t *testing.T, ctx context.Context, f // 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). +// edges[].spawner_key/spawner_id). 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" @@ -1589,157 +1578,6 @@ func RunBatchApplyStampsSpawnerIDOnlyWhenNamed(t *testing.T, ctx context.Context } } -// 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 @@ -2403,20 +2241,6 @@ 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 @@ -2501,287 +2325,3 @@ 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) -} diff --git a/backend/conformance/batch_apply_gate_contract.go b/backend/conformance/batch_apply_gate_contract.go deleted file mode 100644 index c38689461..000000000 --- a/backend/conformance/batch_apply_gate_contract.go +++ /dev/null @@ -1,145 +0,0 @@ -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, '') 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{""} - } - return out -} diff --git a/backend/conformance/batch_closer_contract.go b/backend/conformance/batch_closer_contract.go index a62b7a667..fde364126 100644 --- a/backend/conformance/batch_closer_contract.go +++ b/backend/conformance/batch_closer_contract.go @@ -39,10 +39,9 @@ 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 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). +// - 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). // - 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 @@ -1398,96 +1397,3 @@ 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) -} diff --git a/backend/conformance/batch_creator_contract.go b/backend/conformance/batch_creator_contract.go index 1ff4852f4..0b48334f0 100644 --- a/backend/conformance/batch_creator_contract.go +++ b/backend/conformance/batch_creator_contract.go @@ -97,14 +97,6 @@ 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) @@ -697,63 +689,3 @@ 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) - } -} diff --git a/backend/conformance/batch_getter_contract.go b/backend/conformance/batch_getter_contract.go index f64dabde6..6cfdd6590 100644 --- a/backend/conformance/batch_getter_contract.go +++ b/backend/conformance/batch_getter_contract.go @@ -36,13 +36,6 @@ 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. @@ -212,7 +205,7 @@ func RunBatchGetterAcceptsExactlyTheCap(t *testing.T, ctx context.Context, fixtu for i := range ids { ids[i] = fmt.Sprintf("%s-atcap-%d", fixture.IssuePrefix, i) } - seedBatchGetterIssuesInBulk(t, ctx, fixture, ids...) + seedBatchGetterIssues(t, ctx, fixture, ids...) result := getMany(t, ctx, fixture, publicops.GetManyRequest{IDs: ids}) if len(result.Issues) != publicops.MaxGetManyIDs { @@ -370,23 +363,6 @@ 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 { diff --git a/backend/conformance/blocked_lister_contract.go b/backend/conformance/blocked_lister_contract.go deleted file mode 100644 index 9313e3e76..000000000 --- a/backend/conformance/blocked_lister_contract.go +++ /dev/null @@ -1,426 +0,0 @@ -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) - } -} diff --git a/backend/conformance/blocking_annotator_contract.go b/backend/conformance/blocking_annotator_contract.go index e17b49fb9..523b05037 100644 --- a/backend/conformance/blocking_annotator_contract.go +++ b/backend/conformance/blocking_annotator_contract.go @@ -546,65 +546,3 @@ 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) - } - } -} diff --git a/backend/conformance/dependency_editor_contract.go b/backend/conformance/dependency_editor_contract.go index 4f5b33268..df2aacb75 100644 --- a/backend/conformance/dependency_editor_contract.go +++ b/backend/conformance/dependency_editor_contract.go @@ -531,96 +531,6 @@ 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 @@ -2631,82 +2541,3 @@ 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) -} diff --git a/backend/conformance/dualwrite_history_contract.go b/backend/conformance/dualwrite_history_contract.go index e94a15d01..8bfb55c56 100644 --- a/backend/conformance/dualwrite_history_contract.go +++ b/backend/conformance/dualwrite_history_contract.go @@ -71,13 +71,11 @@ 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 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. +// 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. // - 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 diff --git a/backend/conformance/dualwrite_participation_generation_contract.go b/backend/conformance/dualwrite_participation_generation_contract.go deleted file mode 100644 index 7943e7e4a..000000000 --- a/backend/conformance/dualwrite_participation_generation_contract.go +++ /dev/null @@ -1,644 +0,0 @@ -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) - } -} diff --git a/backend/conformance/heartbeater_contract.go b/backend/conformance/heartbeater_contract.go deleted file mode 100644 index bde6409f0..000000000 --- a/backend/conformance/heartbeater_contract.go +++ /dev/null @@ -1,837 +0,0 @@ -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 -} diff --git a/backend/conformance/lease_reclaimer_contract.go b/backend/conformance/lease_reclaimer_contract.go deleted file mode 100644 index eadc6c176..000000000 --- a/backend/conformance/lease_reclaimer_contract.go +++ /dev/null @@ -1,625 +0,0 @@ -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 -} diff --git a/backend/conformance/lifecycle_close_reopen_contract.go b/backend/conformance/lifecycle_close_reopen_contract.go index c11556181..ca40fe53a 100644 --- a/backend/conformance/lifecycle_close_reopen_contract.go +++ b/backend/conformance/lifecycle_close_reopen_contract.go @@ -846,12 +846,11 @@ 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 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 +// 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 // is checked first, including for an idempotent close", with Force bypassing -// "the pin, the assignee fence, and blocker and open-child policy" and nothing -// else (:485-498). +// "blocker and open-child policy" and nothing else (:364-365). // // 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 @@ -1093,87 +1092,6 @@ 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 @@ -1384,14 +1302,13 @@ 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, 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. +// 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. // // 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 @@ -1824,175 +1741,3 @@ 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) - } -} diff --git a/backend/conformance/lifecycle_create_contract.go b/backend/conformance/lifecycle_create_contract.go index 5d728a6c8..ca906424a 100644 --- a/backend/conformance/lifecycle_create_contract.go +++ b/backend/conformance/lifecycle_create_contract.go @@ -490,12 +490,6 @@ 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"}, @@ -810,54 +804,3 @@ 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") -} diff --git a/backend/conformance/lifecycle_create_gate_contract.go b/backend/conformance/lifecycle_create_gate_contract.go deleted file mode 100644 index 4f5c22d30..000000000 --- a/backend/conformance/lifecycle_create_gate_contract.go +++ /dev/null @@ -1,170 +0,0 @@ -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) - } -} diff --git a/backend/conformance/lifecycle_update_contract.go b/backend/conformance/lifecycle_update_contract.go index ae5e0a420..5219b494d 100644 --- a/backend/conformance/lifecycle_update_contract.go +++ b/backend/conformance/lifecycle_update_contract.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "reflect" - "slices" "sort" "sync" "testing" @@ -1920,10 +1919,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: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. +// 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. // // 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 @@ -1964,90 +1963,6 @@ 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, @@ -2604,134 +2519,3 @@ 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) - } -} diff --git a/backend/conformance/lifecycle_update_gate_contract.go b/backend/conformance/lifecycle_update_gate_contract.go deleted file mode 100644 index 06c730625..000000000 --- a/backend/conformance/lifecycle_update_gate_contract.go +++ /dev/null @@ -1,133 +0,0 @@ -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()) - } -} diff --git a/backend/conformance/memories_contract.go b/backend/conformance/memories_contract.go index dc45191f4..c7b33221c 100644 --- a/backend/conformance/memories_contract.go +++ b/backend/conformance/memories_contract.go @@ -233,11 +233,14 @@ func RunMemoriesRememberWithExplicitKeyStoresVerbatim(t *testing.T, ctx context. } // RunMemoriesRememberReplacesAndReportsIt pins -// memoryops.RememberResult.Replaced against row presence. +// memoryops.RememberResult.Replaced, including the leg that makes it different +// from RecallResult.Found. // // 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. -// The third is the one a body computing `previous != ""` gets wrong. +// 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. func RunMemoriesRememberReplacesAndReportsIt(t *testing.T, ctx context.Context, fixture MemoriesFixture) { t.Helper() neighbors := seedMemoriesAllFourClasses(t, ctx, fixture) @@ -259,7 +262,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, "", true) + assertMemoriesRecall(t, ctx, fixture, emptied, "", false) 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, " + @@ -371,8 +374,8 @@ func RunMemoriesRecallAnswersTheStoredValue(t *testing.T, ctx context.Context, f } // RunMemoriesRecallReportsAMissAsNotFoundNotAnError pins the decision recorded -// in memoryops/errors.go: absence is a result callers inspect, not an -// operational error they must classify. +// in memoryops/errors.go: there is no ErrNotFound on this role, because the +// seam beneath it cannot see the difference the error would claim. func RunMemoriesRecallReportsAMissAsNotFoundNotAnError(t *testing.T, ctx context.Context, fixture MemoriesFixture) { t.Helper() seedMemoriesAllFourClasses(t, ctx, fixture) @@ -398,70 +401,33 @@ func RunMemoriesRecallReportsAMissAsNotFoundNotAnError(t *testing.T, ctx context } } -// 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. +// 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. // -// 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) { +// 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) { t.Helper() - neighbors := seedMemoriesAllFourClasses(t, ctx, fixture) + 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, "", true) + assertMemoriesRecall(t, ctx, fixture, emptied, "", false) 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 enumerated empty value", emptied, value, ok) + 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) } 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 @@ -562,7 +528,13 @@ 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. +// 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. // // 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. @@ -570,6 +542,10 @@ 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 { @@ -577,12 +553,14 @@ func RunMemoriesForgetOfAnAbsentKeyIsNotFoundAndDeletesNothing(t *testing.T, ctx } for attempt := 1; attempt <= 2; attempt++ { - 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) + 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) + } } } @@ -591,8 +569,11 @@ 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 two forgets that found nothing, want no change", before, after) + t.Fatalf("config rows went %d -> %d across four 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. diff --git a/backend/conformance/molecule_contract.go b/backend/conformance/molecule_contract.go deleted file mode 100644 index 36021d53a..000000000 --- a/backend/conformance/molecule_contract.go +++ /dev/null @@ -1,480 +0,0 @@ -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) - } -} diff --git a/backend/conformance/portable.go b/backend/conformance/portable.go index 488c02593..050b7f008 100644 --- a/backend/conformance/portable.go +++ b/backend/conformance/portable.go @@ -42,7 +42,6 @@ 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) }) @@ -578,36 +577,6 @@ 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) { diff --git a/backend/conformance/reader_contract.go b/backend/conformance/reader_contract.go index 245a9efaa..6910a5bbb 100644 --- a/backend/conformance/reader_contract.go +++ b/backend/conformance/reader_contract.go @@ -113,10 +113,6 @@ 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 @@ -790,112 +786,6 @@ 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 @@ -3175,335 +3065,6 @@ 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. diff --git a/backend/conformance/retention_epoch_contract.go b/backend/conformance/retention_epoch_contract.go index b2c0d100e..472b7a896 100644 --- a/backend/conformance/retention_epoch_contract.go +++ b/backend/conformance/retention_epoch_contract.go @@ -769,21 +769,7 @@ 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 @@ -833,258 +819,94 @@ 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: an epoch voids what the store lost, never -// what it still serves. +// 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. // -// 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. +// 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. func RunEpochBumpVoidsOnlyAddressesOfVersionsNoLongerServed(t *testing.T, ctx context.Context, fixture EpochFixture) { t.Helper() - epochSkipUnlessReady(t, fixture, false) - - // 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) + if fixture.MintUnderEpoch == nil { + t.Skip("this backend has no way to mint a Version under a known epoch (MintUnderEpoch is nil)") } - 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 fixture.BumpEpoch == nil { + t.Skip("this backend has no epoch concept yet (BumpEpoch is nil)") } - 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) + 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") -// 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) + addrA, err := fixture.MintUnderEpoch(ctx, store, "record-a") + if err != nil { + t.Fatalf("MintUnderEpoch(record-a): %v", err) + } + addrB, err := fixture.MintUnderEpoch(ctx, store, "record-b") + if err != nil { + t.Fatalf("MintUnderEpoch(record-b): %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) + newEpoch, err := fixture.BumpEpoch(ctx, store, EpochBumpTriggerRestore) + if err != nil { + t.Fatalf("BumpEpoch: %v", 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) + servesA, err := fixture.StillServes(ctx, store, addrA) + if err != nil { + t.Fatalf("StillServes(%s): %v", addrA, 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") + servesB, err := fixture.StillServes(ctx, store, addrB) + if err != nil { + t.Fatalf("StillServes(%s): %v", addrB, err) } - 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) + 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") } - 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) - } + stillServed, noLongerServed := addrA, addrB + if servesB && !servesA { + stillServed, noLongerServed = addrB, addrA } - 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) + 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") } - 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 ------------------------------------------------------- @@ -1131,137 +953,6 @@ 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. diff --git a/backend/conformance/role_bundle_cases.go b/backend/conformance/role_bundle_cases.go index 1c5e2cf00..bf65f8e7b 100644 --- a/backend/conformance/role_bundle_cases.go +++ b/backend/conformance/role_bundle_cases.go @@ -45,9 +45,6 @@ var roleContractCases = []roleContract{ RunBatchApplyAcceptsAnExternalEdgeTarget, RunBatchApplyNormalizesTheWaitsForGate, RunBatchApplyStampsSpawnerIDOnlyWhenNamed, - RunBatchApplyCarriesThreadIDOntoTheStoredEdge, - RunBatchApplyCarriesThreadIDOntoAnExistingEdge, - RunBatchApplyRefusesAThreadIDLongerThanItsColumn, RunBatchApplySplicesAForwardMetadataRef, RunBatchApplySplicesASelfMetadataRef, RunBatchApplyRefusesAMetadataRefNoItemDeclares, @@ -58,12 +55,6 @@ var roleContractCases = []roleContract{ RunBatchApplyReplayMintsANewSetOfRows, RunBatchApplyDoesNotMutateTheCallerRequest, RunBatchApplyRefusesAnUnusableRequest, - RunBatchApplyUpdateItemsRefuseATemplate, - RunBatchApplySplicesTheMetadataOfATemplateItCreates, - RunBatchApplyCloseItemsAnswerToTheCloseGuards, - RunBatchApplyRefusesADottedChildGatedOnItsOwnParent, - RunBatchApplyAppliesTheDefaultPriority, - RunBatchApplyCarriesTheGateMembers, ), roleCases("BatchCloser", "BatchCloser()", oncePerRole, @@ -88,7 +79,6 @@ var roleContractCases = []roleContract{ RunBatchCloserAllRefusedBatchRecordsNoHistory, RunBatchCloserDoesNotMutateTheCallerRequest, RunBatchCloserSettlesTheDependersOfWhatItClosed, - RunBatchCloserItemsAnswerToTheCloseGuards, ), roleCases("BatchCreator", "BatchCreator()", oncePerRole, @@ -106,7 +96,6 @@ var roleContractCases = []roleContract{ RunBatchCreatorRecordsNoHistoryForAnEphemeralBatch, RunBatchCreatorDoesNotMutateTheCallerRequest, RunBatchCreatorEchoesSubSecondTimestamps, - RunBatchCreatorAppliesTheDefaultPriority, ), roleCases("BlockingAnnotator", "BlockingAnnotator()", oncePerRole, @@ -128,7 +117,6 @@ var roleContractCases = []roleContract{ RunBlockingAnnotatorRefusesAnEmptyID, RunBlockingAnnotatorLeavesTheRequestAlone, RunBlockingAnnotatorWritesNothing, - RunBlockingAnnotatorReportsTheTransitiveBlockedFlag, ), // One contract file covers both halves of workspace identity: the eight @@ -272,7 +260,6 @@ var roleContractCases = []roleContract{ RunDependencyEditorSameTypeReAddIsIdempotent, RunDependencyEditorSameTypeReAddWithChangedMetadataMintsOneVersion, RunDependencyEditorSameTypeReAddWithIdenticalMetadataIsANoOp, - RunDependencyEditorSameTypeReAddWithChangedThreadMintsOneVersion, RunDependencyEditorRepeatsWithinOneRequestCollapse, RunDependencyEditorAttributesItsEventsToTheActor, RunDependencyEditorRetypeRefusalLeavesTheOriginalEdge, @@ -306,7 +293,6 @@ var roleContractCases = []roleContract{ RunDependencyEditorAcceptsADiamond, RunDependencyEditorGateScopeFollowsTheEdgeType, RunDependencyEditorAcceptsBlockingAcrossIssueTypes, - RunDependencyEditorRefusesADottedChildGatedOnItsOwnParent, ), // The accessor named here is not an accessor at all, alone among these @@ -443,14 +429,12 @@ 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 @@ -463,9 +447,6 @@ var roleContractCases = []roleContract{ RunLifecycleCreateInheritsParentLabels, RunLifecycleCreateWritesEveryScalarField, RunLifecycleCreateEchoesSubSecondTimestamps, - RunLifecycleCreateAppliesTheDefaultPriority, - RunLifecycleCreateWritesTheGateMembers, - RunLifecycleCreateBoundsTheGateMembers, ), roleCases("LifecycleUpdate", "IssueLifecycle()", oncePerRole, @@ -492,13 +473,7 @@ var roleContractCases = []roleContract{ RunLifecycleUpdateParentIDReplacesTheParentEdge, RunLifecycleUpdateParentIDReplacesEveryParent, RunLifecycleUpdatePersistentPreservesUnversionedClass, - RunLifecycleUpdateWispModesRefuseAnUnversionedRow, - RunLifecycleUpdatePersistentPromotesAWisp, RunLifecycleUpdateProvenanceLabelsHistory, - RunLifecycleUpdateRefusesATemplate, - RunLifecycleUpdateAllowTemplateEditsATemplate, - RunLifecycleUpdatePatchesTheGateMembers, - RunLifecycleUpdateBoundsTheGateMembers, ), roleCases("Memories", "Memories()", oncePerRole, @@ -513,7 +488,7 @@ var roleContractCases = []roleContract{ RunMemoriesRememberRefusesAnUnderivableKey, RunMemoriesRecallAnswersTheStoredValue, RunMemoriesRecallReportsAMissAsNotFoundNotAnError, - RunMemoriesEmptyRowIsPresentUntilForgotten, + RunMemoriesRecallConflatesStoredEmptyWithAbsent, RunMemoriesForgetRemovesExactlyTheNamedRow, RunMemoriesForgetNeverTouchesTheSettingsPlane, RunMemoriesForgetReportsTheForgottenValue, @@ -576,7 +551,6 @@ var roleContractCases = []roleContract{ RunReaderListKeysetPositionResumesTheCreatedDescIDAscOrder, RunReaderListReadyFlagAnswersTheBlockerAwareSet, RunReaderListReadyFlagRefusesAFilterItCannotCarry, - RunReaderListQueryMatchesTheTitleOrTheID, RunReaderListEmptyPageIsWellFormed, RunReaderListMaxRowsIsHonored, RunReaderListMaxRowsBoundaryIsLimitPlusOffset, @@ -604,8 +578,6 @@ var roleContractCases = []roleContract{ RunReaderListWispTypeNarrowsTheAdmittedPlaneRatherThanAdmittingIt, RunReaderListBriefDropsTheFreeFormTextAndNothingElse, RunReaderReadyBriefDropsTheFreeFormTextAndNothingElse, - RunReaderListTimeBoundsAreStrictAndWholeSecond, - RunReaderListFilterFamiliesNarrowToTheirRows, ), roleCases("ReadyClaimer", "ReadyClaimer() and IssueReader()", oncePerRole, diff --git a/backend/conformance/versioned_history_wiring_test.go b/backend/conformance/versioned_history_wiring_test.go index b022b716e..08eed2b53 100644 --- a/backend/conformance/versioned_history_wiring_test.go +++ b/backend/conformance/versioned_history_wiring_test.go @@ -129,14 +129,5 @@ 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) - }) }) } diff --git a/backend/conformance/versioned_read_contract.go b/backend/conformance/versioned_read_contract.go deleted file mode 100644 index 0e187117c..000000000 --- a/backend/conformance/versioned_read_contract.go +++ /dev/null @@ -1,356 +0,0 @@ -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 -} diff --git a/backend/http/BUILD.bazel b/backend/http/BUILD.bazel deleted file mode 100644 index f6359f820..000000000 --- a/backend/http/BUILD.bazel +++ /dev/null @@ -1,192 +0,0 @@ -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 \ -# /http_served_test /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 --- diff --git a/backend/http/attach.go b/backend/http/attach.go deleted file mode 100644 index f2175ff5f..000000000 --- a/backend/http/attach.go +++ /dev/null @@ -1,133 +0,0 @@ -// 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 -} diff --git a/backend/http/attach_test.go b/backend/http/attach_test.go deleted file mode 100644 index 7594b3240..000000000 --- a/backend/http/attach_test.go +++ /dev/null @@ -1,180 +0,0 @@ -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) - } - } -} diff --git a/backend/http/corpus/BUILD.bazel b/backend/http/corpus/BUILD.bazel deleted file mode 100644 index ee8631077..000000000 --- a/backend/http/corpus/BUILD.bazel +++ /dev/null @@ -1,146 +0,0 @@ -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 --- diff --git a/backend/http/corpus/README.md b/backend/http/corpus/README.md deleted file mode 100644 index 28451a0cf..000000000 --- a/backend/http/corpus/README.md +++ /dev/null @@ -1,154 +0,0 @@ -# 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=` 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=` 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. diff --git a/backend/http/corpus/corpus_parts_test.go b/backend/http/corpus/corpus_parts_test.go deleted file mode 100644 index e8c3ec84f..000000000 --- a/backend/http/corpus/corpus_parts_test.go +++ /dev/null @@ -1,211 +0,0 @@ -//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:] -} diff --git a/backend/http/corpus/corpus_test.go b/backend/http/corpus/corpus_test.go deleted file mode 100644 index ee4c30331..000000000 --- a/backend/http/corpus/corpus_test.go +++ /dev/null @@ -1,968 +0,0 @@ -//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 , 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= 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, "")) -} - -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, "") - 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 "" - } - 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) -} diff --git a/backend/http/corpus/gate_check_served_test.go b/backend/http/corpus/gate_check_served_test.go deleted file mode 100644 index 60d9f82c0..000000000 --- a/backend/http/corpus/gate_check_served_test.go +++ /dev/null @@ -1,355 +0,0 @@ -//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) - } - }) -} diff --git a/backend/http/corpus/harness_test.go b/backend/http/corpus/harness_test.go deleted file mode 100644 index d2a2c4d02..000000000 --- a/backend/http/corpus/harness_test.go +++ /dev/null @@ -1,333 +0,0 @@ -//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) // /backend/http/corpus/harness_test.go - return filepath.Dir(filepath.Dir(filepath.Dir(filepath.Dir(file)))) -} diff --git a/backend/http/corpus/reference_proxy_test.go b/backend/http/corpus/reference_proxy_test.go deleted file mode 100644 index 0142b1ad4..000000000 --- a/backend/http/corpus/reference_proxy_test.go +++ /dev/null @@ -1,279 +0,0 @@ -//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) -} diff --git a/backend/http/corpus/required_corpus_tier_test.go b/backend/http/corpus/required_corpus_tier_test.go deleted file mode 100644 index 055afeb79..000000000 --- a/backend/http/corpus/required_corpus_tier_test.go +++ /dev/null @@ -1,23 +0,0 @@ -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") - } -} diff --git a/backend/http/corpus/served_pinned_shards.txt b/backend/http/corpus/served_pinned_shards.txt deleted file mode 100644 index 6fc0f44d9..000000000 --- a/backend/http/corpus/served_pinned_shards.txt +++ /dev/null @@ -1,12 +0,0 @@ -# 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). -# -# -1 TestServedCorpusPart1 -2 TestServedCorpusPart2 -3 TestServedCorpusPart3 -4 TestServedCorpusPart4 diff --git a/backend/http/corpus/testdata/allowlist.yaml b/backend/http/corpus/testdata/allowlist.yaml deleted file mode 100644 index 090577cc9..000000000 --- a/backend/http/corpus/testdata/allowlist.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# 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"' diff --git a/backend/http/corpus/testdata/corpus.yaml b/backend/http/corpus/testdata/corpus.yaml deleted file mode 100644 index 925d1db64..000000000 --- a/backend/http/corpus/testdata/corpus.yaml +++ /dev/null @@ -1,882 +0,0 @@ -# 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 ); 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=) - 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 , ~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= --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 ) - args: [ready, --mol, e2e-mol, --json] - - id: mc-ready-parent - source: mc skills/pr-review (bd ready --parent ) - 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 ) - 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 --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 ) - args: [mol, current, e2e-mol, --json] - - id: mc-mol-progress - source: mc prompts (bd mol progress ) - 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 --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 --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 --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 ) - 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 --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 -> 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 ) - 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 ) - 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 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"} diff --git a/backend/http/corpus/testdata/reference_server.json b/backend/http/corpus/testdata/reference_server.json deleted file mode 100644 index 7bdf6d0d0..000000000 --- a/backend/http/corpus/testdata/reference_server.json +++ /dev/null @@ -1,595 +0,0 @@ -{ - "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": [] - } - ] -} \ No newline at end of file diff --git a/backend/http/credential.go b/backend/http/credential.go deleted file mode 100644 index 3290fd3b7..000000000 --- a/backend/http/credential.go +++ /dev/null @@ -1,66 +0,0 @@ -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 diff --git a/backend/http/e2e_blocked_flags_test.go b/backend/http/e2e_blocked_flags_test.go deleted file mode 100644 index 1943bd676..000000000 --- a/backend/http/e2e_blocked_flags_test.go +++ /dev/null @@ -1,287 +0,0 @@ -//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) - } - } - }) -} diff --git a/backend/http/e2e_blocked_test.go b/backend/http/e2e_blocked_test.go deleted file mode 100644 index 786379fba..000000000 --- a/backend/http/e2e_blocked_test.go +++ /dev/null @@ -1,229 +0,0 @@ -//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 " " - aliases: ["fart"] - short: "Bond two protos or molecules together" - hidden: false - runnable: true - long: - | Bond two protos or molecules to create a compound. - | - | The bond command is polymorphic - it handles different operand types: - | - | formula + formula → cook both, compound proto - | formula + proto → cook formula, compound proto - | formula + mol → cook formula, spawn and attach - | proto + proto → compound proto (reusable template) - | proto + mol → spawn proto, attach to molecule - | mol + proto → spawn proto, attach to molecule - | mol + mol → join into compound molecule - | - | Formula names (e.g., mol-polecat-arm) are cooked inline as ephemeral protos. - | This avoids needing pre-cooked proto beads in the database. - | - | Bond types: - | sequential (default) - B runs after A completes - | parallel - B runs alongside A - | conditional - B runs only if A fails - | - | With --ref, the spawned proto arm is nested inside the molecule operand - | rather than ordered against it - whichever side of the bond that is - so a - | sequential --ref arm carries no ordering: it is ready as soon as it is - | spawned. Ordering a nested arm against its own container is unsatisfiable - | in both directions (the arm waits for the molecule to close; the molecule - | cannot close while it holds an open arm). --ref is refused with --type - | conditional, which has no safe degradation - omit --ref to bond a - | conditional arm as a sibling. - | - | Phase control: - | By default, spawned protos follow the target's phase: - | - Attaching to mol (Ephemeral=false) → spawns as persistent (Ephemeral=false) - | - Attaching to ephemeral issue (Ephemeral=true) → spawns as ephemeral (Ephemeral=true) - | - | Override with: - | --pour Force spawn as liquid (persistent, Ephemeral=false) - | --ephemeral Force spawn as vapor (ephemeral, Ephemeral=true, excluded from Dolt sync via dolt_ignore) - | - | Dynamic bonding (Christmas Ornament pattern): - | Use --ref to specify a custom child reference with variable substitution. - | This creates IDs like "parent.child-ref" instead of random hashes. - | - | Example: - | bd mol bond mol-worker-arm bd-patrol --ref arm-{{worker_name}} --var worker_name=ace - | # Creates: bd-patrol.arm-ace (and children like bd-patrol.arm-ace.capture) - | - | Use cases: - | - Found important bug during patrol? Use --pour to persist it - | - Need ephemeral diagnostic on persistent feature? Use --ephemeral - | - Spawning per-worker arms on a patrol? Use --ref for readable IDs - | - | Examples: - | bd mol bond mol-feature mol-deploy # Compound proto - | bd mol bond mol-feature mol-deploy --type parallel # Run in parallel - | bd mol bond mol-feature bd-abc123 # Attach proto to molecule - | bd mol bond bd-abc123 bd-def456 # Join two molecules - | bd mol bond mol-critical-bug wisp-patrol --pour # Persist found bug - | bd mol bond mol-temp-check bd-feature --ephemeral # Ephemeral diagnostic - | bd mol bond mol-arm bd-patrol --ref arm-{{name}} --var name=ace # Dynamic child ID - flag --as type=string default="" usage="Custom title for compound proto (proto+proto only)" - flag --dry-run type=bool default="false" usage="Preview what would be created" - flag --ephemeral type=bool default="false" usage="Force spawn as vapor (ephemeral, Ephemeral=true)" - flag --pour type=bool default="false" usage="Force spawn as liquid (persistent, Ephemeral=false)" - flag --ref type=string default="" usage="Custom child reference with {{var}} substitution (e.g., arm-{{polecat_name}})" - flag --type type=string default="sequential" usage="Bond type: sequential, parallel, or conditional" - flag --var type=stringArray default="[]" usage="Variable substitution for spawned protos (key=value)" - -bd mol burn - use: "burn [molecule-id...]" - short: "Delete a molecule without creating a digest" - hidden: false - runnable: true - long: - | Burn a molecule, deleting it without creating a digest. - | - | Unlike squash (which creates a permanent digest before deletion), burn - | completely removes the molecule with no trace. Use this for: - | - Abandoned patrol cycles - | - Crashed or failed workflows - | - Test/debug molecules you don't want to preserve - | - | The burn operation differs based on molecule phase: - | - Wisp (ephemeral): Direct delete - | - Mol (persistent): Cascade delete (syncs to remotes) - | - | CAUTION: This is a destructive operation. The molecule's data will be - | permanently lost. If you want to preserve a summary, use 'bd mol squash'. - | - | Example: - | bd mol burn bd-abc123 # Delete molecule with no trace - | bd mol burn bd-abc123 --dry-run # Preview what would be deleted - | bd mol burn bd-abc123 --force # Skip confirmation - | bd mol burn bd-a1 bd-b2 bd-c3 # Batch delete multiple wisps - flag --dry-run type=bool default="false" usage="Preview what would be deleted" - flag --force type=bool default="false" usage="Skip confirmation prompt" - flag --yes -y type=bool default="false" hidden usage="Alias for --force (skip confirmation)" - -bd mol current - use: "current [molecule-id]" - short: "Show current position in molecule workflow" - hidden: false - runnable: true - long: - | Show where you are in a molecule workflow. - | - | If molecule-id is given, show status for that molecule. - | If not given, infer from in_progress issues assigned to current agent. - | - | The output shows all steps with status indicators: - | [done] - Step is complete (closed) - | [current] - Step is in_progress (you are here) - | [ready] - Step is ready to start (unblocked) - | [blocked] - Step is blocked by dependencies - | [pending] - Step is waiting - | - | For large molecules (>100 steps), a summary is shown instead. - | Use --limit or --range to view specific steps: - | bd mol current --limit 50 # Show first 50 steps - | bd mol current --range 100-150 # Show steps 100-150 - flag --for type=string default="" usage="Show molecules for a specific agent/assignee" - flag --limit type=int default="0" usage="Maximum number of steps to display (0 = auto, use 'all' threshold)" - flag --range type=string default="" usage="Display specific step range (e.g., '1-50', '100-150')" - -bd mol distill - use: "distill [formula-name]" - short: "Extract a formula from an existing epic" - hidden: false - runnable: true - long: - | Distill a molecule by extracting a reusable formula from an existing epic. - | - | This is the reverse of pour: instead of formula → molecule, it's molecule → formula. - | - | The distill command: - | 1. Loads the existing epic and all its children - | 2. Converts the structure to a .formula.json file - | 3. Replaces concrete values with {{variable}} placeholders (via --var flags) - | - | Use cases: - | - Team develops good workflow organically, wants to reuse it - | - Capture tribal knowledge as executable templates - | - Create starting point for similar future work - | - | Variable syntax (both work - we detect which side is the concrete value): - | --var branch=feature-auth Spawn-style: variable=value (recommended) - | --var feature-auth=branch Substitution-style: value=variable - | - | Output locations (first writable wins): - | 1. /formulas/ (project-level, default) - | 2. /.beads/formulas/ (repo-local formulas) - | 3. ~/.beads/formulas/ (user-level, if project not writable) - | - | Examples: - | bd mol distill bd-o5xe my-workflow - | bd mol distill bd-abc release-workflow --var feature_name=auth-refactor - flag --dry-run type=bool default="false" usage="Preview what would be created" - flag --output type=string default="" usage="Output directory for formula file" - flag --var type=stringArray default="[]" usage="Replace value with {{variable}} placeholder (variable=value)" - -bd mol last-activity - use: "last-activity " - short: "Show last activity timestamp for a molecule" - hidden: false - runnable: true - long: - | Show the most recent activity timestamp for a molecule. - | - | Returns the timestamp of the most recent change to any step in the molecule, - | making it easy to detect stale or stuck molecules. - | - | Activity sources: - | step_closed - A step was closed - | step_updated - A step was updated (claimed, edited, etc.) - | molecule_updated - The molecule root itself was updated - | - | Examples: - | bd mol last-activity hq-wisp-0laki - | bd mol last-activity hq-wisp-0laki --json - -bd mol pour - use: "pour " - short: "Instantiate a proto as a persistent mol (solid -> liquid)" - hidden: false - runnable: true - long: - | Pour a proto into a persistent mol - like pouring molten metal into a mold. - | - | This is the chemistry-inspired command for creating PERSISTENT work from templates. - | The resulting mol is stored as persistent beads in the issue database and - | syncs like any other bead (bd dolt push / pull). - | - | Phase transition: Proto (solid) -> pour -> Mol (liquid) - | - | WHEN TO USE POUR vs WISP: - | pour (liquid): Persistent work that needs audit trail - | - Feature implementations spanning multiple sessions - | - Work you may need to reference later - | - Anything worth preserving in git history - | - | wisp (vapor): Ephemeral work that auto-cleans up - | - Release workflows (one-time execution) - | - Operational loops and recurring cycles - | - Health checks and diagnostics - | - Any operational workflow without audit value - | - | TIP: Formulas can specify phase:"vapor" to recommend wisp usage. - | If you pour a vapor-phase formula, you'll get a warning. - | - | Examples: - | bd mol pour mol-feature --var name=auth # Persistent feature work - | bd mol pour mol-review --var pr=123 # Persistent code review - flag --assignee type=string default="" usage="Assign the root issue to this agent/user" - flag --attach type=stringSlice default="[]" usage="Proto to attach after spawning (repeatable)" - flag --attach-type type=string default="sequential" usage="Bond type for attachments: sequential, parallel, or conditional" - flag --dry-run type=bool default="false" usage="Preview what would be created" - flag --var type=stringArray default="[]" usage="Variable substitution (key=value); a name the proto cannot consume is an error" - -bd mol progress - use: "progress [molecule-id]" - short: "Show molecule progress summary" - hidden: false - runnable: true - long: - | Show efficient progress summary for a molecule. - | - | This command uses indexed queries to count progress without loading all steps, - | making it suitable for very large molecules (millions of steps). - | - | If no molecule-id is given, shows progress for any molecule you're working on. - | - | Output includes: - | - Progress: completed / total (percentage) - | - Current step: the in-progress step (if any) - | - Rate: steps/hour based on closure times - | - ETA: estimated time to completion - | - | Example: - | bd mol progress bd-hanoi-xyz - -bd mol ready - use: "ready --gated" - short: "Find molecules ready for gate-resume dispatch" - hidden: false - runnable: true - long: - | Find molecules where a gate has closed and the workflow is ready to resume. - | - | This command discovers molecules waiting at a gate step where: - | 1. The molecule has a gate bead that blocks a step - | 2. The gate bead is now closed (condition satisfied) - | 3. The blocked step is now ready to proceed - | 4. No agent currently has this molecule hooked - | - | This enables discovery-based resume without explicit waiter tracking. - | The patrol system uses this to find and dispatch gate-ready molecules. - | - | Examples: - | bd mol ready --gated # Find all gate-ready molecules - | bd mol ready --gated --json # JSON output for automation - flag --gated type=bool default="false" usage="Find molecules ready for gate-resume dispatch (always on for this subcommand)" - -bd mol seed - use: "seed " - short: "Verify formula accessibility" - hidden: false - runnable: true - long: - | Verify that a formula is accessible and can be cooked. - | - | The seed command checks formula search paths to ensure a formula exists - | and can be loaded. This is useful for verifying system health before - | attempting to spawn work from a formula. - | - | Formula search paths (checked in order): - | 1. /formulas/ (active project) - | 2. /.beads/formulas/ (repo-local formulas) - | 3. ~/.beads/formulas/ (user level) - | 4. $GT_ROOT/.beads/formulas/ (shared workspace root, if GT_ROOT set) - | - | Examples: - | bd mol seed mol-feature # Verify specific formula - | bd mol seed mol-review --var name=test # Verify with variable substitution - flag --var type=stringArray default="[]" usage="Variable substitution for condition filtering (key=value)" - -bd mol show - use: "show " - short: "Show molecule details" - hidden: false - runnable: true - long: - | Show molecule structure and details. - | - | A molecule's steps are the issues linked to its root by parent-child - | dependencies (bd create --parent, bd mol pour); an id that merely looks - | hierarchical, like bd-xyz.4, does not make an issue a step. - | - | The --parallel flag highlights parallelizable steps: - | - Steps with no blocking dependencies can run in parallel - | - Shows which steps are ready to start now - | - Identifies parallel groups (steps that can run concurrently) - | - | Example: - | bd mol show bd-patrol --parallel - flag --parallel -p type=bool default="false" usage="Show parallel step analysis" - -bd mol squash - use: "squash " - short: "Compress molecule execution into a digest" - hidden: false - runnable: true - long: - | Squash a molecule's ephemeral children into a single digest issue. - | - | This command collects all ephemeral child issues of a molecule (Ephemeral=true), - | generates a summary digest, and promotes the wisps to persistent by - | clearing their Wisp flag (or optionally deletes them). - | - | The squash operation: - | 1. Loads the molecule and all its children - | 2. Filters to only wisps (ephemeral issues with Ephemeral=true) - | 3. Generates a digest (summary of work done) - | 4. Creates a permanent digest issue (Ephemeral=false) - | 5. Clears Wisp flag on children (promotes to persistent) - | OR keeps them with --keep-children (default: delete) - | - | AGENT INTEGRATION: - | Use --summary to provide an AI-generated summary. This keeps bd as a pure - | tool - the calling agent (orchestrator worker, Claude Code, etc.) is responsible - | for generating intelligent summaries. Without --summary, a basic concatenation - | of child issue content is used. - | - | This is part of the wisp workflow: spawn creates wisps, - | execution happens, squash compresses the trace into an outcome (digest). - | - | Example: - | bd mol squash bd-abc123 # Squash and promote children - | bd mol squash bd-abc123 --dry-run # Preview what would be squashed - | bd mol squash bd-abc123 --keep-children # Keep wisps after digest - | bd mol squash bd-abc123 --summary "Agent-generated summary of work done" - flag --dry-run type=bool default="false" usage="Preview what would be squashed" - flag --keep-children type=bool default="false" usage="Don't delete ephemeral children after squash" - flag --summary type=string default="" usage="Agent-provided summary (bypasses auto-generation)" - -bd mol stale - use: "stale" - short: "Detect molecules with all children closed but root still open" - hidden: false - runnable: true - long: - | Detect molecules (epics with children) whose children are all closed - | with completing reasons, but the root is still open. - | - | A molecule is considered stale if: - | 1. Every child is closed with a completing reason (not duplicate/wontfix/superseded) - | 2. Root issue is still open - | 3. Not assigned to anyone (optional, use --unassigned) - | 4. Is blocking other work (optional, use --blocking) - | - | Review whether epic scope is actually finished before closing — child - | closure alone does not prove the epic's stated work is done (GH#5026). - | - | Examples: - | bd mol stale # List all stale molecules - | bd mol stale --json # Machine-readable output - | bd mol stale --blocking # Only show those blocking other work - | bd mol stale --unassigned # Only show unassigned molecules - | bd mol stale --all # Include molecules with 0 children - flag --all type=bool default="false" usage="Include molecules with 0 children" - flag --blocking type=bool default="false" usage="Only show molecules blocking other work" - flag --unassigned type=bool default="false" usage="Only show unassigned molecules" - -bd mol wisp - use: "wisp [proto-id]" - short: "Create or manage wisps (ephemeral molecules)" - hidden: false - runnable: true - long: - | Create or manage wisps - EPHEMERAL molecules for operational workflows. - | - | When called with a proto-id argument, creates a wisp from that proto. - | When called with a subcommand (list, gc), manages existing wisps. - | - | Wisps are issues with Ephemeral=true in the main database. They're stored - | locally but NOT synced via git. - | - | WHEN TO USE WISP vs POUR: - | wisp (vapor): Ephemeral work that auto-cleans up - | - Release workflows (one-time execution) - | - Operational loops and recurring cycles - | - Health checks and diagnostics - | - Any operational workflow without audit value - | - | pour (liquid): Persistent work that needs audit trail - | - Feature implementations spanning multiple sessions - | - Work you may need to reference later - | - Anything worth preserving in git history - | - | TIP: Formulas can specify phase:"vapor" to recommend wisp usage. - | If you use pour on a vapor-phase formula, you'll get a warning. - | - | The wisp lifecycle: - | 1. Create: bd mol wisp or bd create --ephemeral - | 2. Execute: Normal bd operations work on wisp issues - | 3. Squash: bd mol squash (clears Ephemeral flag, promotes to persistent) - | 4. Or burn: bd mol burn (deletes without creating digest) - | - | Examples: - | bd mol wisp beads-release --var version=1.0 # Release workflow - | bd mol wisp mol-my-workflow # Ephemeral operational cycle - | bd mol wisp list # List all wisps - | bd mol wisp gc # Garbage collect old wisps - | - | Subcommands: - | list List all wisps in current context - | gc Garbage collect orphaned wisps - flag --dry-run type=bool default="false" usage="Preview what would be created" - flag --root-only type=bool default="false" usage="Create only the root issue (no child step issues)" - flag --var type=stringArray default="[]" usage="Variable substitution (key=value); a name the proto cannot consume is an error" - -bd mol wisp create - use: "create " - short: "Instantiate a proto as a wisp (solid -> vapor)" - hidden: false - runnable: true - long: - | Create a wisp from a proto - sublimation from solid to vapor. - | - | This is the chemistry-inspired command for creating ephemeral work from templates. - | The resulting wisp is stored in the main database with Ephemeral=true and NOT synced via git. - | - | Phase transition: Proto (solid) -> Wisp (vapor) - | - | Use wisp for: - | - Operational loops and recurring cycles - | - Health checks and monitoring - | - One-shot orchestration runs - | - Routine operations with no audit value - | - | The wisp will: - | - Be stored in main database with Ephemeral=true flag - | - NOT be synced via git - | - Either evaporate (burn) or condense to digest (squash) - | - | Examples: - | bd mol wisp create mol-patrol # Ephemeral patrol cycle - | bd mol wisp create mol-health-check # One-time health check - | bd mol wisp create mol-diagnostics --var target=db # Diagnostic run - flag --dry-run type=bool default="false" usage="Preview what would be created" - flag --root-only type=bool default="false" usage="Create only the root issue (no child step issues)" - flag --var type=stringArray default="[]" usage="Variable substitution (key=value); a name the proto cannot consume is an error" - -bd mol wisp gc - use: "gc" - short: "Garbage collect old/abandoned wisps" - hidden: false - runnable: true - long: - | Garbage collect old or abandoned wisps from the database. - | - | A wisp is considered abandoned if: - | - It hasn't been updated in --age duration and is not closed - | - AND it is not live work: blocked steps (waiting on a dependency), pinned - | beads, and any step whose status category is wip (in_progress, blocked, - | hooked) or frozen (deferred, pinned) are never reclaimed by age, no matter - | how long they have been waiting (GH#4394). Custom statuses count by their - | configured category, so only plain open (active) and closed (done) steps - | are age-reclaimable. If the blocked set or the custom-status list cannot be - | read, the GC aborts rather than risk reclaiming live steps. - | - | Wisps that depend on an abandoned wisp are deleted with it, closed ones - | included even without --all, but only if they too haven't been updated in - | --age duration and are not live work. A dependent that is too young is - | spared and loses its edge to the deleted wisp: an open one is collected once - | it ages out, a closed one only by --all, --closed or 'bd purge'. - | - | Abandoned wisps are deleted without creating a digest. Use 'bd mol squash' - | if you want to preserve a summary before garbage collection. - | - | Use --closed to purge ALL closed wisps (regardless of age). This is the - | fastest way to reclaim space from accumulated wisp bloat. Safe by default: - | requires --force to actually delete. - | - | Note: This uses time-based cleanup, appropriate for ephemeral wisps. - | For graph-pressure staleness detection (blocking other work), see 'bd mol stale'. - | - | Examples: - | bd mol wisp gc # Clean abandoned wisps (default: 1h threshold) - | bd mol wisp gc --dry-run # Preview what would be cleaned - | bd mol wisp gc --age 24h # Custom age threshold - | bd mol wisp gc --all # Also clean closed wisps older than threshold - | bd mol wisp gc --closed # Preview closed wisp deletion - | bd mol wisp gc --closed --force # Delete all closed wisps - | bd mol wisp gc --closed --dry-run # Explicit dry-run (same as no --force) - | bd mol wisp gc --exclude-type agent,rig # Protect agent and rig wisps from GC - | bd mol wisp gc --closed --force --exclude-type mol # Delete closed wisps except mol type - flag --age type=string default="1h" usage="Age threshold for abandoned wisp detection" - flag --all type=bool default="false" usage="Also clean closed wisps older than threshold" - flag --closed type=bool default="false" usage="Delete all closed wisps (ignores --age threshold)" - flag --dry-run type=bool default="false" usage="Preview what would be cleaned" - flag --exclude-type type=stringSlice default="[]" usage="Exclude wisps of these types from GC (comma-separated, e.g., agent,rig)" - flag --force -f type=bool default="false" usage="Actually delete (default: preview only)" - -bd mol wisp list - use: "list" - short: "List all wisps in current context" - hidden: false - runnable: true - long: - | List all wisps (ephemeral molecules) in the current context. - | - | Wisps are issues with Ephemeral=true in the main database. They are stored - | locally but not synced via git. - | - | The list shows: - | - ID: Issue ID of the wisp - | - Title: Wisp title - | - Status: Current status (open, in_progress, closed) - | - Started: When the wisp was created - | - Updated: Last modification time - | - | Old wisp detection: - | - Old wisps haven't been updated in 24+ hours - | - Use 'bd mol wisp gc' to clean up old/abandoned wisps - | - | Examples: - | bd mol wisp list # List all wisps - | bd mol wisp list --json # JSON output for programmatic use - | bd mol wisp list --all # Include closed wisps - flag --all type=bool default="false" usage="Include closed wisps" - flag --type type=string default="" usage="Filter by issue type (e.g., agent, task, patrol)" - -bd note - use: "note [text...]" - short: "Append a note to an issue" - group: "issues" - hidden: false - runnable: true - long: - | Append a note to an issue's notes field. - | - | Shorthand for 'bd update --append-notes "text"'. - | - | Examples: - | bd note gt-abc "Fixed the flaky test" - | bd note gt-abc Fixed the flaky test - | echo "note from pipe" | bd note gt-abc --stdin - | bd note gt-abc --file notes.txt - | - | Note: "note" has NO subcommands — it only appends. - | To read notes on an issue, use: bd show - flag --file type=string default="" annotations={cobra_annotation_mutually_exclusive=["stdin file"]} usage="Read note text from file" - flag --stdin type=bool default="false" annotations={cobra_annotation_mutually_exclusive=["stdin file"]} usage="Read note text from stdin" - -bd notion - use: "notion" - short: "Notion integration commands" - hidden: false - runnable: false - long: - | Commands for syncing issues between beads and Notion. - -bd notion connect - use: "connect" - short: "Connect bd to an existing Notion database or data source" - hidden: false - runnable: true - flag --url type=string default="" annotations={cobra_annotation_bash_completion_one_required_flag=["true"]} usage="Existing Notion database or data source URL" - -bd notion init - use: "init" - short: "Create a dedicated Beads database in Notion" - hidden: false - runnable: true - flag --parent type=string default="" annotations={cobra_annotation_bash_completion_one_required_flag=["true"]} usage="Parent page ID" - flag --title type=string default="Beads Issues" usage="Database title" - -bd notion pull - use: "pull [refs...]" - short: "Pull specific items from Notion" - hidden: false - runnable: true - long: - | Pull one or more items from Notion. - | - | Accepts bead IDs or external references as positional arguments. - | Equivalent to: bd notion sync --pull --issues - flag --dry-run type=bool default="false" usage="Preview pull without making changes" - -bd notion push - use: "push [bead-ids...]" - short: "Push specific beads to Notion" - hidden: false - runnable: true - long: - | Push one or more beads issues to Notion. - | - | Accepts bead IDs as positional arguments. - | Equivalent to: bd notion sync --push --issues - flag --dry-run type=bool default="false" usage="Preview push without making changes" - -bd notion status - use: "status" - short: "Show Notion sync status" - hidden: false - runnable: true - -bd notion sync - use: "sync" - short: "Sync issues with Notion" - hidden: false - runnable: true - long: - | Synchronize issues between beads and Notion. - | - | By default this performs bidirectional sync. Use --pull or --push to limit direction. - flag --create-only type=bool default="false" usage="Only create missing remote pages, do not update existing ones" - flag --dry-run type=bool default="false" usage="Preview changes without making mutations" - flag --issues type=string default="" usage="Comma-separated bead IDs to sync selectively (e.g., bd-abc,bd-def). Mutually exclusive with --parent." - flag --parent type=string default="" usage="Limit push to this bead and its descendants (push only). Mutually exclusive with --issues." - flag --prefer-local type=bool default="false" usage="On conflict, keep the local beads version" - flag --prefer-notion type=bool default="false" usage="On conflict, use the Notion version" - flag --pull type=bool default="false" usage="Only pull issues from Notion" - flag --push type=bool default="false" usage="Only push issues to Notion" - flag --state type=string default="all" usage="Issue state to sync: open, closed, or all" - -bd onboard - use: "onboard" - short: "Display minimal snippet for agent instructions file" - group: "setup" - hidden: false - runnable: true - long: - | Display a minimal snippet to add to your agent instructions file for bd integration. - | - | By default, the agent instructions file is AGENTS.md. Use 'bd init --agents-file' - | to configure a different filename (e.g. BEADS.md). - | - | This outputs a small (~10 line) snippet that points to 'bd prime' for full - | workflow context. This is the same minimal profile that 'bd init' generates - | by default. This approach: - | - | • Keeps your agent file lean (doesn't bloat with instructions) - | • bd prime provides dynamic, always-current workflow details - | • Hooks auto-inject bd prime at session start - | - | For agents or environments that do not auto-inject hook output, use - | 'bd init --agents-profile=full' to embed the complete command reference. - -bd orphans - use: "orphans" - short: "Identify orphaned issues (referenced in commits but still open)" - hidden: false - runnable: true - long: - | Identify orphaned issues - issues that are referenced in commit messages but remain open or in_progress in the database. - | - | This helps identify work that has been implemented but not formally closed. - | - | Examples: - | bd orphans # Show orphaned issues - | bd orphans --json # Machine-readable output - | bd orphans --details # Show full commit information - | bd orphans --fix # Close orphaned issues with confirmation - | bd orphans --label theme:personal # Only orphans with this label - | bd orphans --label-any theme:personal,theme:ventures # Orphans with either label - flag --details type=bool default="false" usage="Show full commit information" - flag --fix -f type=bool default="false" usage="Close orphaned issues with confirmation" - flag --label -l type=stringSlice default="[]" usage="Filter by labels (AND: must have ALL). Can combine with --label-any" - flag --label-any type=stringSlice default="[]" usage="Filter by labels (OR: must have AT LEAST ONE). Can combine with --label" - -bd ping - use: "ping" - short: "Check database connectivity" - group: "maint" - hidden: false - runnable: true - long: - | Lightweight health check that confirms bd can reach its database. - | - | Steps: - | 1. Resolve the .beads workspace - | 2. Open the store (embedded or server) - | 3. Run a trivial query (one issue row; a remote backend reads its - | authenticated server context instead) - | 4. Report timing - | - | Exit 0 on success, exit 1 on failure. - | - | Examples: - | bd ping # Quick connectivity check - | bd ping --json # Structured output for automation - -bd preflight - use: "preflight" - short: "Show PR readiness checklist" - group: "maint" - hidden: false - runnable: true - long: - | Display a checklist of common pre-PR checks for contributors. - | - | This command helps catch common issues before pushing to CI: - | - Tests not run locally - | - Lint errors - | - Unformatted Go files - | - .beads/issues.jsonl pollution - | - Stale nix vendorHash - | - Version mismatches - | - | Examples: - | bd preflight # Show checklist - | bd preflight --check # Run checks automatically - | bd preflight --check --json # JSON output for programmatic use - | bd preflight --check --skip-lint # Explicitly skip lint check - | - flag --check type=bool default="false" usage="Run checks automatically" - flag --fix type=bool default="false" usage="Auto-fix issues where possible (vendorHash)" - flag --skip-lint type=bool default="false" usage="Skip lint check explicitly" - -bd prime - use: "prime" - short: "Output AI-optimized workflow context" - group: "setup" - hidden: false - runnable: true - long: - | Output essential Beads workflow context in AI-optimized markdown format. - | - | Automatically detects if MCP server is active and adapts output: - | - MCP mode: Brief workflow reminders (~50 tokens) - | - CLI mode: Full command reference (~1-2k tokens) - | - | Designed for Claude Code, Gemini CLI, and Codex SessionStart hooks to prevent - | agents from forgetting bd workflow after context compaction. - | - | Config options: - | - no-git-ops: When true, outputs stealth mode (no git commands in session close protocol). - | Set via: bd config set no-git-ops true - | Useful when you want to control when commits happen manually. - | - agent.profile: Explicit policy profile for git/commit authority wording - | (conservative | minimal | team-maintainer; default conservative). - | Set via: bd config set agent.profile team-maintainer - | Or per-session: BD_AGENT_PROFILE=team-maintainer (env var takes precedence). - | See docs/getting-started/ide-setup.md#policy-profiles for what each profile means. - | - prime.disabled: When true, bd prime prints nothing, as it does outside a - | workspace (an empty envelope under --hook-json), whatever its other flags. - | For sessions whose host briefs the agent itself but that inherit a - | project's bd prime hook, such as an orchestrator's agent sessions. - | Set per-session: BD_PRIME_DISABLED=true. Or: bd config set prime.disabled true - | - | Workflow customization: - | - Place a PRIME.md file to override the default workflow text. Checked in this - | order, once bd resolves a workspace (outside one, prime emits no content): - | (1) .beads/PRIME.md relative to the current directory (the -C target - | when -C is set); - | (2) PRIME.md in the .beads directory bd resolves for this workspace - | (honors $BEADS_DIR, which -C overrides; a redirected .beads is - | followed); - | (3) the global PRIME.md in bd's user config dir: - | ~/.config/beads/ on Linux ($XDG_CONFIG_HOME/beads/ if set), - | ~/Library/Application Support/beads/ on macOS, - | %AppData%\beads\ on Windows. - | - Persistent memories (from bd remember) are still appended so memory - | injection keeps working under a custom template. - | - Use --export to dump the default content for customization. - | - Use --memories-only for hook contexts that should inject only persistent memories; this returns only the memories section even when a custom PRIME.md is present. - | - Use --no-memories to omit the persistent memories section (useful when the memories section is large and would dominate a context budget). --memories-only takes precedence if both are set. - | - | Memory injection caps: - | Large memory sets can exceed what a session-start hook host will ingest, - | and hosts truncate silently. Cap what prime injects with --max-memories N - | and/or --max-memory-chars N (or the prime.max-memories / - | prime.max-memory-chars config keys; an explicit flag wins, and an explicit - | 0 forces unlimited). Caps apply at whole-memory boundaries, at least one - | memory is always emitted, and a banner ahead of the entries reports how - | many were elided and how to browse the rest with bd memories. - | --max-memory-chars caps the total bytes of the injected memory entries; - | the section header and elision banner are excluded from the budget. - flag --export type=bool default="false" usage="Output default content (ignores PRIME.md override)" - flag --full type=bool default="false" usage="Force full CLI output (ignore MCP detection)" - flag --hook-json type=bool default="false" usage="Wrap output in the SessionStart hook JSON envelope (Claude Code, Gemini CLI, Codex)" - flag --max-memories type=int default="0" usage="Cap injected persistent memories to N entries (0 = unlimited; falls back to the prime.max-memories config key)" - flag --max-memory-chars type=int default="0" usage="Cap the total bytes of injected memory entries, at whole-memory boundaries; section header and banner are not counted (0 = unlimited; falls back to the prime.max-memory-chars config key)" - flag --mcp type=bool default="false" usage="Force MCP mode (minimal output)" - flag --memories-only type=bool default="false" usage="Output only persistent memories for compact hook contexts" - flag --no-memories type=bool default="false" usage="Omit the persistent memories section (ignored when --memories-only is set, which wins)" - flag --stealth type=bool default="false" usage="Stealth mode (no git operations, flush only)" - -bd priority - use: "priority " - short: "Set the priority of an issue" - group: "issues" - hidden: false - runnable: true - long: - | Set the priority of an issue. - | - | Shorthand for 'bd update --priority '. - | - | Priority levels: - | 0 - Critical (security, data loss, broken builds) - | 1 - High (major features, important bugs) - | 2 - Medium (default) - | 3 - Low (polish, optimization) - | 4 - Backlog (future ideas) - | - | Examples: - | bd priority bd-123 0 # Critical - | bd priority bd-123 2 # Medium - -bd promote - use: "promote " - short: "Promote a wisp to a permanent bead" - group: "issues" - hidden: false - runnable: true - long: - | Promote a wisp (ephemeral issue) to a permanent bead. - | - | This copies the issue from the wisps table (dolt_ignored) to the permanent - | issues table (Dolt-versioned), preserving labels, dependencies, events, and - | comments. The original ID is preserved so all links keep working. - | - | A comment is added recording the promotion and optional reason. - | - | Examples: - | bd promote bd-wisp-abc123 - | bd promote bd-wisp-abc123 --reason "Worth tracking long-term" - flag --reason -r type=string default="" usage="Reason for promotion" - -bd provenance - use: "provenance" - short: "Append-only provenance event log" - group: "issues" - hidden: false - runnable: false - long: - | Record and read provenance events: typed bindings from an issue to an - | opaque external artifact (a git SHA, PR, work-id, transcript, or branch). - | - | The log is append-only — there is no update or delete. bd never interprets the - | actor or ref; only kind and ref-kind are structurally validated. Recording is - | idempotent on a deterministic id, so a producer firing twice is harmless. - -bd provenance by-ref - use: "by-ref " - short: "List provenance events bound to a ref" - hidden: false - runnable: true - -bd provenance log - use: "log " - short: "List provenance events for an issue" - hidden: false - runnable: true - flag --kind type=string default="" usage="filter by kind (optional)" - -bd provenance record - use: "record --issue --kind --source " - short: "Record a provenance event (idempotent)" - hidden: false - runnable: true - long: - | Record a provenance event. The event is appended idempotently: a - | deterministic id is computed from source:issue:kind:(ref or --at), so re-running - | the same record is a no-op. - | - | An event recorded without --ref requires --at so the id is caller-owned. - flag --actor type=string default="" usage="opaque actor identifier (optional)" - flag --at type=string default="" usage="event-time as RFC3339 (required for ref-less kinds)" - flag --issue type=string default="" annotations={cobra_annotation_bash_completion_one_required_flag=["true"]} usage="issue id (required)" - flag --kind type=string default="" annotations={cobra_annotation_bash_completion_one_required_flag=["true"]} usage="event kind: cut|claim|suspend|resume|handoff|commit|land|used (required)" - flag --payload type=string default="" usage="opaque payload, e.g. JSON (optional)" - flag --ref type=string default="" usage="opaque external reference, e.g. a SHA or PR url (optional)" - flag --ref-kind type=string default="" usage="ref kind: git-sha|pr|work-id|transcript|branch (optional)" - flag --source type=string default="" annotations={cobra_annotation_bash_completion_one_required_flag=["true"]} usage="producer of the event, e.g. git-hook, orchestrator (required)" - -bd prune - use: "prune" - short: "Delete old closed beads to reclaim space and shrink exports" - group: "maint" - hidden: false - runnable: true - long: - | Permanently delete closed non-ephemeral beads and their associated data. - | - | Use this to trim closed regular beads (tasks, features, bugs, chores, etc.) - | that are no longer useful. The common case is a long-lived repo where - | closed work has piled up and is bloating auto-export or slowing queries. - | - | Requires --older-than or --pattern. The flag is a safety gate — without - | it, a muscle-memory `--force` could wipe every closed bead in the repo. - | Use `--pattern '*'` if you really do want to sweep everything closed. - | - | Deletes: issues, dependencies, labels, events, and comments for matching beads. - | Skips: pinned beads (protected), open/in-progress beads, and ephemeral beads. - | - | Also skips closed beads whose ID appears in the description, notes, or - | comments of any open / in-progress bead. This protects ADR / decision / - | verification trails that downstream beads still cite. Use - | --ignore-references to override (e.g., when bulk-decommissioning a - | retired label across the rig). - | - | To delete closed ephemeral beads (wisps, transient molecules) use - | `bd purge` instead. - | - | For full Dolt storage reclaim after deleting many rows, follow with `bd flatten` - | so history can be collapsed and old chunks can be garbage-collected. - | - | EXAMPLES: - | bd prune --older-than 30d # Preview closed beads >30d old - | bd prune --older-than 30d --force # Delete them - | bd prune --older-than 90d --dry-run # Detailed preview with stats - | bd prune --pattern "*" --force # Delete all closed regular beads - | bd prune --pattern "gm-temp-*" --force # Scope to a pattern - flag --dry-run type=bool default="false" usage="Preview what would be pruned with stats" - flag --force -f type=bool default="false" usage="Actually prune (without this, shows preview)" - flag --ignore-references type=bool default="false" usage="Delete closed beads even when referenced by open beads (use with care; see --help for details)" - flag --older-than type=string default="" usage="Only prune beads closed more than N ago (e.g., 30d, 2w, 60, 36h)" - flag --pattern type=string default="" usage="Only prune beads matching ID glob pattern (e.g., 'gm-old-*')" - -bd purge - use: "purge" - short: "Delete closed ephemeral beads to reclaim space" - group: "maint" - hidden: false - runnable: true - long: - | Permanently delete closed ephemeral beads and their associated data. - | - | Closed ephemeral beads (wisps, transient molecules) accumulate rapidly and - | have no value once closed. This command removes them to reclaim storage. - | - | Deletes: issues, dependencies, labels, events, and comments for matching beads. - | Skips: pinned beads, and closed beads a live bead still depends on through a - | parent-child, tracks or blocks edge (a closed molecule root whose step is open, - | a closed bead a live convoy tracks). Live means any status that is not done. - | - | --wisps-plane selects by storage plane instead: every closed row stored in the - | wisps table, including --no-history beads, which the default ephemeral - | selection leaves to `bd prune`. It reaches durable-tier rows, so it requires - | --older-than or --pattern, like `bd prune`. - | - | --limit N caps one run at N beads, oldest-closed first, so a large backlog can - | be drained in bounded transactions; --json then reports "remaining" and - | "has_more". Loop while has_more is true. - | - | --older-than takes days (7, 7d), weeks (2w) or a duration with hour precision - | (36h, 168h, 90m). - | - | To delete closed non-ephemeral beads (regular tasks, features, bugs, etc.) - | use `bd prune` instead. - | - | For full Dolt storage reclaim after deleting many rows, follow with `bd flatten` - | so history can be collapsed and old chunks can be garbage-collected. - | - | EXAMPLES: - | bd purge # Preview what would be purged - | bd purge --force # Delete all closed ephemeral beads - | bd purge --older-than 7d --force # Only purge items closed 7+ days ago - | bd purge --pattern "*-wisp-*" # Only purge matching ID pattern - | bd purge --older-than 36h --force # Hour precision: closed 36+ hours ago - | bd purge --wisps-plane --older-than 168h --force - | # Every closed wisps-table row, incl. no-history - | bd purge --dry-run # Detailed preview with stats - flag --dry-run type=bool default="false" usage="Preview what would be purged with stats" - flag --force -f type=bool default="false" usage="Actually purge (without this, shows preview)" - flag --limit type=int default="0" usage="Purge at most N beads this run, oldest-closed first (0 = no limit); --json reports remaining/has_more" - flag --older-than type=string default="" usage="Only purge beads closed more than N ago (e.g., 7d, 2w, 30, 36h)" - flag --pattern type=string default="" usage="Only purge beads matching ID glob pattern (e.g., *-wisp-*)" - flag --wisps-plane type=bool default="false" usage="Select every closed row in the wisps table, including --no-history beads (requires --older-than or --pattern)" - -bd q - use: "q [title]" - short: "Quick capture: create issue and output only ID" - group: "issues" - hidden: false - runnable: true - long: - | Quick capture creates an issue and outputs only the issue ID. - | Designed for scripting and AI agent integration. - | - | Example: - | bd q "Fix login bug" # Outputs: bd-a1b2 - | ISSUE=$(bd q "New feature") # Capture ID in variable - | bd q "Task" | xargs bd show # Pipe to other commands - | bd q "Subtask" --parent=bd-a1b2 # Hierarchical child (outputs: bd-a1b2.1) - flag --labels -l type=stringSlice default="[]" usage="Labels" - flag --parent type=string default="" usage="Parent issue ID for hierarchical child (e.g., 'bd-a3f8e9')" - flag --priority -p type=string default="2" usage="Priority (0-4 or P0-P4)" - flag --type -t type=string default="task" usage="Issue type" - -bd query - use: "query [expression]" - short: "Query issues using a simple query language" - group: "issues" - hidden: false - runnable: true - long: - | Query issues using a simple query language that supports compound filters, - | boolean operators, and date-relative expressions. - | - | The query language enables complex filtering that would otherwise require - | multiple flags or piping through jq. - | - | Syntax: - | field=value Equality comparison - | field!=value Inequality comparison - | field>value Greater than - | field>=value Greater than or equal - | field1" - | bd query "status=open AND priority<=2 AND updated>7d" - | bd query "(status=open OR status=blocked) AND priority<2" - | bd query "type=bug AND label=urgent" - | bd query "NOT status=closed" - | bd query "assignee=none AND type=task" - | bd query "created>30d AND status!=closed" - | bd query "label=frontend OR label=backend" - | bd query "title=authentication AND priority=0" - flag --all -a type=bool default="false" usage="Include closed issues (default: exclude closed)" - flag --limit -n type=int default="50" usage="Limit results (default: 50, 0 = unlimited)" - flag --long type=bool default="false" usage="Show detailed multi-line output for each issue" - flag --offset type=int default="0" usage="Skip the first N matching results (0-based). Only supported under --proxied-server." - flag --parse-only type=bool default="false" usage="Only parse the query and show the AST (for debugging)" - flag --reverse -r type=bool default="false" usage="Invert the sort field's default direction (created/updated/closed default to newest-first, so --sort updated --reverse is oldest-first)" - flag --sort type=string default="" usage="Sort by field: priority, created, updated, closed, status, id, title, type, assignee" - -bd quickstart - use: "quickstart" - short: "Quick start guide for bd" - group: "setup" - hidden: false - runnable: true - long: - | Display a quick start guide showing common bd workflows and patterns. - -bd ready - use: "ready" - short: "Show ready work (open, no active blockers)" - hidden: false - runnable: true - long: - | Show ready work (open issues with no active blockers). - | - | Excludes in_progress, blocked, deferred, and hooked issues. This uses the - | GetReadyWork API which applies blocker-aware semantics to find truly claimable work. - | - | Note: 'bd list --ready' uses the same blocker-aware ready-work semantics. - | - | Use --mol to filter to a specific molecule's steps: - | bd ready --mol bd-patrol # Show ready steps within molecule - | - | Use --gated to find molecules ready for gate-resume dispatch: - | bd ready --gated # Find molecules where a gate closed - | - | Use --claim to atomically claim the first ready issue matching the filters: - | bd ready --claim --json - | - | This is useful for agents executing molecules to see which steps can run next. - flag --assignee -a type=string default="" usage="Filter by assignee" - flag --brief type=bool default="false" usage="Omit the free-form text (description, design, acceptance criteria, notes, payload, waiters) from each row. Filters that read those fields still select on them. An omitted field is indistinguishable from an empty one; fetch a whole issue with bd show. Requires --json, and cannot be combined with --claim, --gated, --mol or --explain." - flag --claim type=bool default="false" usage="Atomically claim the first ready issue matching the filters" - flag --exclude-label type=stringSlice default="[]" usage="Exclude issues that have ANY of these labels" - flag --exclude-type type=stringSlice default="[]" usage="Exclude issue types from results (comma-separated or repeatable, e.g., --exclude-type=convoy,epic)" - flag --explain type=bool default="false" usage="Show dependency-aware reasoning for why issues are ready or blocked" - flag --flat type=bool default="false" usage="Alias for --plain, spelled the way bd list spells it" - flag --gated type=bool default="false" usage="Find molecules ready for gate-resume dispatch" - flag --has-metadata-key type=string default="" usage="Filter issues that have this metadata key set" - flag --include-deferred type=bool default="false" usage="Include issues with future defer_until timestamps" - flag --include-ephemeral type=bool default="false" usage="Include ephemeral issues (wisps) in results" - flag --label -l type=stringSlice default="[]" usage="Filter by labels (AND: must have ALL). Can combine with --label-any" - flag --label-any type=stringSlice default="[]" usage="Filter by labels (OR: must have AT LEAST ONE). Can combine with --label" - flag --label-pattern type=string default="" usage="Filter by label glob pattern (e.g., 'tech-*' matches tech-debt, tech-legacy)" - flag --label-regex type=string default="" usage="Filter by label regex pattern (e.g., 'tech-(debt|legacy)')" - flag --limit -n type=int default="100" usage="Maximum issues to show (use 0 for unlimited)" - flag --max-rows type=int default="0" usage="Hard upper bound on rows fetched from storage. Returns a non-zero exit (code 2) and an error to stderr if exceeded. 0 disables (the default). Overrides BEADS_MAX_ROWS for this invocation. Useful in CI/agent rigs that want a circuit breaker against pathological queries. Not supported under --proxied-server: an explicit --max-rows or BEADS_MAX_ROWS cap errors out rather than silently going unenforced." - flag --metadata-field type=stringArray default="[]" usage="Filter by metadata field (key=value, repeatable)" - flag --mol type=string default="" usage="Filter to steps within a specific molecule" - flag --mol-type type=string default="" usage="Filter by molecule type: swarm, patrol, or work" - flag --offset type=int default="0" usage="Skip the first N matching results (0-based). Only supported under --proxied-server." - flag --parent type=string default="" usage="Filter to descendants of this bead/epic" - flag --plain type=bool default="false" usage="Display issues as a plain numbered list" - flag --pretty type=bool default="true" usage="Display issues in a tree format with status/priority symbols" - flag --priority -p type=int default="0" usage="Filter by priority" - flag --sort -s type=string default="priority" usage="Sort policy: priority (default), hybrid, oldest" - flag --type -t type=string default="" usage="Filter by issue type (task, bug, feature, epic, decision, merge-request). Aliases: mr→merge-request, feat→feature, mol→molecule, dec/adr→decision" - flag --unassigned -u type=bool default="false" usage="Show only unassigned issues" - -bd recall - use: "recall " - short: "Retrieve a specific memory" - group: "setup" - hidden: false - runnable: true - long: - | Retrieve the full content of a memory by its key. - | - | Examples: - | bd recall dolt-phantoms - | bd recall auth-jwt - -bd reclaim - use: "reclaim" - short: "Revert stale-lease in_progress issues back to ready (dead-worker recovery)" - group: "issues" - hidden: false - runnable: true - long: - | Revert in_progress issues whose lease has gone stale back to ready. - | - | When a worker claims an issue it takes a lease that expires after a TTL, kept - | alive by 'bd heartbeat'. A worker that dies stops heartbeating, so its lease - | expires and its issue would otherwise stay in_progress forever. reclaim is the - | reaper: it finds in_progress issues whose lease expired more than --older-than - | ago, clears the assignee, and sets them back to open so another worker can - | claim them. The previous owner's stale lease is recorded as a recovery event. - | - | --older-than is a grace window past lease expiry: only leases that expired at - | least this long ago are reclaimed, so a worker briefly paused (GC, clock skew) - | is not robbed of live work. Run it from a supervisor on a timer with a window - | of roughly 2× the claim TTL. - | - | By default reclaim covers every stale lease THIS replica granted. The scope - | filters below narrow it further, using the same label surface claiming is - | scoped by (--label / --label-any / --exclude-label), plus --assignee and --id. - | Filters AND-combine and never widen the set: a reclaimed lease must still be - | stale. - | - | Replicas and leases (federated deployments) - | ------------------------------------------- - | A lease is only meaningful on the replica that granted it. Every other - | replica's view of the holder's liveness is stale by up to one sync interval, - | so a reaper elsewhere can revert a unit that is very much alive over there. - | reclaim therefore records the granting replica on each lease and SKIPS a lease - | another replica granted, summarizing what it declined on stderr (one line per - | run; 'bd -v' expands it to the first 20 leases individually). Reap it where it - | was granted; use --any-replica only when that replica is permanently gone (or - | when this node was renamed and its own old leases now look foreign — an - | ordinary heartbeat keeps a lease alive but does not re-home it to the node - | heartbeating it). Prefer the narrow form '--any-replica --id ': bare - | --any-replica reverts EVERY foreign stale lease, live peers included. - | - | Two invariants the guard cannot enforce for you: - | - | grace window > sync interval, and lease TTL > sync interval. - | - | A TTL or grace shorter than the cadence at which replicas exchange state is - | meaningless across the bridge — the remote view is a full interval old by - | construction. Raise the TTL/grace above the sync interval, never the reverse. - | The guard is opt-in: set BEADS_NODE_ID, or run 'bd config set node_id ' - | (which writes the per-machine ~/.config/bd/config.yaml — never commit a node_id - | to the git-tracked .beads/config.yaml, or every clone reads the same name and - | the guard goes armed-but-inert). One id per STORE, not per host: machines that - | are clients of the same dolt sql-server are ONE replica and must share one value - | or leave it unset. There is no hostname fallback — the hostname names the client - | process's machine, not the store — so an unnamed deployment keeps the old, - | unguarded behavior instead of stranding its own work. - | - | Examples: - | bd reclaim # default grace window (2× the lease TTL) - | bd reclaim --older-than 10m # reclaim leases expired >10m ago - | bd reclaim --older-than 0s # reclaim every currently-expired lease - | bd reclaim --label lane-a # only this machine's claim partition - | bd reclaim --label-any lane-a,lane-b --exclude-label pinned - | bd reclaim --assignee zelda --assignee epona # only these workers' leases - | bd reclaim --id wy-abc --id wy-def # exactly these issues - | bd reclaim --any-replica # also reap leases granted by a departed replica - flag --any-replica type=bool default="false" usage="Also reclaim leases granted by ANOTHER replica (unsafe unless that replica is gone; see 'Replicas and leases')" - flag --assignee -a type=stringSlice default="[]" usage="Only reclaim leases held by these assignees (repeatable)" - flag --exclude-label type=stringSlice default="[]" usage="Never reclaim issues carrying ANY of these labels" - flag --id type=stringSlice default="[]" usage="Only reclaim these issue IDs (repeatable)" - flag --label -l type=stringSlice default="[]" usage="Only reclaim issues with ALL these labels (AND). Can combine with --label-any" - flag --label-any type=stringSlice default="[]" usage="Only reclaim issues with AT LEAST ONE of these labels (OR). Can combine with --label" - flag --older-than type=duration default="10m0s" usage="Only reclaim leases that expired at least this long ago (grace window)" - -bd recompute-blocked - use: "recompute-blocked" - short: "Recompute is_blocked for all issues (repairs stale flags after a pull)" - group: "maint" - hidden: false - runnable: true - long: - | Recompute the denormalized is_blocked flag for every issue and wisp. - | - | is_blocked is derived from the dependency graph and maintained automatically by - | local writes and by a post-pull recompute scoped to what the merge changed. If - | that scoped recompute is skipped — a recompute that failed after its merge - | committed, or a conflicted pull resolved by hand — the flag can go stale, and a - | later pull that merges nothing will not refresh it (bd-6dnrw.37). 'bd ready' - | trusts the flag, so stale values silently hide ready work or surface blocked - | work. - | - | This command runs the full recompute unconditionally and commits the result. - | It is idempotent: on a consistent database it changes nothing. Works in every - | storage mode — embedded, server, and proxied-server (unlike 'bd doctor', which - | is server-mode only). - | - | On a workspace connected to a bd serve backend ('bd connect') it is a no-op - | that exits 0: the server maintains is_blocked on every write, and the column - | lives in the server's database, so the repair is run there, by the server's - | operator. --json then reports {"rows_corrected": 0, "maintained_by": "server"}. - | - | Examples: - | bd recompute-blocked # Repair stale is_blocked flags - | bd recompute-blocked --json # Machine-parseable {"rows_corrected": N} - -bd remember - use: "remember \"\"" - short: "Store a persistent memory" - group: "setup" - hidden: false - runnable: true - long: - | Store a memory that persists across sessions and account rotations. - | - | Memories are injected at prime time (bd prime) so you have them - | in every session without manual loading. - | - | The positional arg is the memory CONTENT (the key is auto-generated from it - | unless --key is given). As a convenience, if the arg is a bare key naming an - | existing memory, it is RECALLED instead of stored (same as 'bd recall'); - | a bare key naming nothing is refused. Use --key to store slug-like content. - | - | Corpus budget (opt-in, off by default): set the memories.budget-chars config - | key to a byte ceiling for the whole memory corpus (sum of len(key)+len(content)). - | A write that would cross it is refused, and --force overrides; a write that - | lands at or above 80% of the budget warns. With the key unset nothing changes. - | bd prime's --max-memory-chars also counts bytes, but of each memory as - | injected, formatting included, so a budget equal to that cap does not - | guarantee prime injects every memory; set the budget below it for that. - | - | Examples: - | bd remember "always run tests with -race flag" - | bd remember "Dolt phantom DBs hide in three places" --key dolt-phantoms - | bd remember "auth module uses JWT not sessions" --key auth-jwt - | bd remember dolt-phantoms # bare existing key: reads it (= bd recall) - flag --force type=bool default="false" usage="Store even when the write would cross the memories.budget-chars corpus budget (no effect when the budget is unset)" - flag --key type=string default="" usage="Explicit key for the memory (auto-generated from content if not set). If a memory with this key already exists, it will be updated in place" - -bd rename - use: "rename " - short: "Rename an issue ID" - hidden: false - runnable: true - long: - | Rename an issue from one ID to another. - | - | This updates: - | - The issue's primary ID - | - All references in other issues (descriptions, titles, notes, etc.) - | - Dependencies pointing to/from this issue - | - Labels, comments, and events - | - | Examples: - | bd rename bd-w382l bd-dolt # Rename to memorable ID - | bd rename gt-abc123 gt-auth # Use descriptive ID - | - | Note: The new ID must use a valid prefix for this database. - -bd rename-prefix - use: "rename-prefix " - short: "Rename the issue prefix for all issues in the database" - group: "maint" - hidden: false - runnable: true - long: - | Rename the issue prefix for all issues in the database. - | This will update all issue IDs and all text references across all fields. - | - | USE CASES: - | - Shortening long prefixes (e.g., 'knowledge-work-' → 'kw-') - | - Rebranding project naming conventions - | - Consolidating multiple prefixes after database corruption - | - Migrating to team naming standards - | - | Prefix validation rules: - | - Allowed characters: lowercase letters, numbers, hyphens - | - Must start with a letter - | - Must end with a hyphen (e.g., 'kw-', 'work-') - | - Cannot be empty or just a hyphen - | - | Multiple prefix detection and repair: - | If issues have multiple prefixes (corrupted database), use --repair to consolidate them. - | The --repair flag will rename all issues with incorrect prefixes to the new prefix, - | preserving issues that already have the correct prefix. - | - | EXAMPLES: - | bd rename-prefix kw- # Rename from 'knowledge-work-' to 'kw-' - | bd rename-prefix mtg- --repair # Consolidate multiple prefixes into 'mtg-' - | bd rename-prefix team- --dry-run # Preview changes without applying - | - | NOTE: This is a rare operation. Most users never need this command. - flag --dry-run type=bool default="false" usage="Preview changes without applying them" - flag --repair type=bool default="false" usage="Repair database with multiple prefixes by consolidating them" - -bd reopen - use: "reopen [id...]" - short: "Reopen one or more closed issues" - group: "issues" - hidden: false - runnable: true - long: - | Reopen closed issues by setting status to 'open' and clearing the closed_at timestamp. - | This is more explicit than 'bd update --status open' and emits a Reopened event. - | - | Exit codes: 1 for general failures; 13 when the failure is a stale - | --if-revision guard (the precondition no longer held, nothing was written — - | another actor won the race, so retrying the same guard is pointless). - flag --if-revision type=string default="" usage="Apply the write only if the issue's current revision equals this value (the decimal int64 from `bd show --json`'s \"revision\" field). One id only: refused before any write when combined with more than one issue id. A mismatch writes nothing and exits 13 (vs 1 for other failures)." - flag --reason -r type=string default="" usage="Reason for reopening" - -bd repo - use: "repo" - short: "Manage multiple repository configuration" - group: "advanced" - hidden: false - runnable: false - long: - | Configure and manage multiple repository support for multi-repo hydration. - | - | Multi-repo support allows hydrating issues from multiple beads repositories - | into a single database for unified cross-repo issue tracking. - | - | Configuration is stored in .beads/config.yaml under the 'repos' section: - | - | repos: - | primary: "." - | additional: - | - ~/beads-planning - | - ~/work-repo - | - | Examples: - | bd repo add ~/beads-planning # Add planning repo - | bd repo add ../other-repo # Add relative path repo - | bd repo list # Show all configured repos - | bd repo remove ~/beads-planning # Remove by path - | bd repo sync # Sync from all configured repos - -bd repo add - use: "add " - short: "Add an additional repository to sync" - hidden: false - runnable: true - long: - | Add a repository path to the repos.additional list in config.yaml. - | - | The path should point to a directory containing a .beads folder. - | Paths can be absolute or relative (they are stored as-is). - | - | This modifies .beads/config.yaml, which is version-controlled and - | shared across all clones of this repository. - -bd repo list - use: "list" - short: "List all configured repositories" - hidden: false - runnable: true - long: - | List all repositories configured in .beads/config.yaml. - | - | Shows the primary repository (always ".") and any additional - | repositories configured for hydration. - -bd repo remove - use: "remove " - short: "Remove a repository from sync configuration" - hidden: false - runnable: true - long: - | Remove a repository path from the repos.additional list in config.yaml. - | - | The path must exactly match what was added (e.g., if you added "~/foo", - | you must remove "~/foo", not "/home/user/foo"). - | - | This command also removes any previously-hydrated issues from the database - | that came from the removed repository. - -bd repo sync - use: "sync" - short: "Manually trigger multi-repo sync" - hidden: false - runnable: true - long: - | Synchronize issues from all configured additional repositories. - | - | Reads issues.jsonl from each additional repository and imports them into - | the primary database with their original prefixes and source_repo set. - | Uses mtime caching to skip repos whose JSONL hasn't changed. - | - | Also triggers Dolt push/pull if a remote is configured. - flag --verbose type=bool default="false" usage="Show detailed sync progress" - -bd restore - use: "restore " - short: "Restore the pre-compaction content of a compacted issue" - group: "sync" - hidden: false - runnable: true - long: - | Restore the pre-compaction content of a compacted issue. - | - | When an issue is compacted, its description/design/notes/acceptance criteria - | are summarized and the originals are archived to a compaction snapshot. This - | command recovers that original content. - | - | By default it is read-only: it displays the archived content without modifying - | the database. Pass --apply to write the original content back into the issue - | and step its compaction level back down. - | - | If no archived snapshot exists (e.g. the issue was compacted by an older bd - | before snapshot archiving), restore falls back to a best-effort reconstruction - | from Dolt version history, which can only be displayed, not applied. - flag --apply type=bool default="false" usage="Write the restored content back into the issue (default: display only)" - -bd rules - use: "rules" - short: "Audit and compact Claude rules" - group: "maint" - hidden: false - runnable: false - -bd rules audit - use: "audit" - short: "Scan rules for contradictions and merge opportunities" - hidden: false - runnable: true - flag --path type=string default=".claude/rules/" usage="Path to rules directory" - flag --threshold type=float64 default="0.6" usage="Jaccard similarity threshold" - -bd rules compact - use: "compact" - short: "Merge related rules into composites" - hidden: false - runnable: true - flag --auto type=bool default="false" usage="Apply audit suggestions" - flag --dry-run type=bool default="false" usage="Preview without applying" - flag --group type=stringSlice default="[]" usage="Rule names to merge" - flag --path type=string default=".claude/rules/" usage="Path to rules directory" - -bd schema - use: "schema" - short: "Print the JSON Schema for bd's --json / export output" - hidden: false - runnable: true - annotations: {bd:skip_store="1"} - long: - | Print the JSON Schema for bd's canonical output record types. - | - | The schema is reflected from the same Go structs bd serializes, so it stays in - | lockstep with the actual --json / export output. Use it to generate typed - | consumer models (datamodel-code-generator, quicktype, ...) rather than - | hand-maintaining them. - | - | bd schema | jq '.types.issue' # the issue record schema - | bd schema | jq '.types.dependency' # the dependency record schema - -bd search - use: "search [query]" - short: "Search issues by text query" - group: "issues" - hidden: false - runnable: true - long: - | Search issues across title and ID (all statuses, including closed). - | - | ID-like queries (e.g., "bd-123", "hq-319") use fast exact/prefix matching. - | Text queries search titles. Use --desc-contains for description search. - | Use --status open (etc.) to narrow; closed issues are included by default - | so "was this already filed/fixed?" cannot silently answer no. Matches - | beyond --limit are dropped status-blind, so when hunting live work in a - | large DB, narrow with --status open or raise --limit. - | - | Examples: - | bd search "authentication bug" - | bd search "login" --status open - | bd search "database" --label backend --limit 10 - | bd search --query "performance" --assignee alice - | bd search "bd-5q" # Search by partial ID (fast prefix match) - | bd search "security" --priority-min 0 --priority-max 2 - | bd search "bug" --created-after 2025-01-01 - | bd search "refactor" --status open # Only open issues - | bd search "bug" --sort priority - | bd search "task" --sort created --reverse - | bd search "api" --desc-contains "endpoint" - | bd search "cleanup" --no-assignee --no-labels - flag --assignee -a type=string default="" usage="Filter by assignee" - flag --closed-after type=string default="" usage="Filter issues closed after date (YYYY-MM-DD or RFC3339)" - flag --closed-before type=string default="" usage="Filter issues closed before date (YYYY-MM-DD or RFC3339)" - flag --created-after type=string default="" usage="Filter issues created after date (YYYY-MM-DD or RFC3339)" - flag --created-before type=string default="" usage="Filter issues created before date (YYYY-MM-DD or RFC3339)" - flag --desc-contains type=string default="" usage="Filter by description substring (case-insensitive)" - flag --empty-description type=bool default="false" usage="Filter issues with empty or missing description" - flag --external-contains type=string default="" usage="Filter by external ref substring (case-insensitive)" - flag --has-metadata-key type=string default="" usage="Filter issues that have this metadata key set" - flag --label -l type=stringSlice default="[]" usage="Filter by labels (AND: must have ALL)" - flag --label-any type=stringSlice default="[]" usage="Filter by labels (OR: must have AT LEAST ONE)" - flag --limit -n type=int default="50" usage="Limit results (default: 50)" - flag --long type=bool default="false" usage="Show detailed multi-line output for each issue" - flag --metadata-field type=stringArray default="[]" usage="Filter by metadata field (key=value, repeatable)" - flag --no-assignee type=bool default="false" usage="Filter issues with no assignee" - flag --no-labels type=bool default="false" usage="Filter issues with no labels" - flag --notes-contains type=string default="" usage="Filter by notes substring (case-insensitive)" - flag --priority-max type=string default="" usage="Filter by maximum priority (inclusive, 0-4 or P0-P4)" - flag --priority-min type=string default="" usage="Filter by minimum priority (inclusive, 0-4 or P0-P4)" - flag --query type=string default="" usage="Search query (alternative to positional argument)" - flag --reverse -r type=bool default="false" usage="Invert the sort field's default direction (created/updated/closed default to newest-first, so --sort updated --reverse is oldest-first)" - flag --sort type=string default="" usage="Sort by field: priority, created, updated, closed, status, id, title, type, assignee" - flag --status -s type=string default="" usage="Filter by stored status (comma-separated for OR; open, in_progress, blocked, deferred, closed, all). Default searches all statuses including closed. Note: dependency-blocked issues use 'bd blocked'" - flag --type -t type=string default="" usage="Filter by type (bug, feature, task, epic, chore, decision, message, molecule, gate, spike, story, milestone); custom types require types.custom config, and an unknown type is an error. Aliases: feat/enhancement→feature, mol→molecule, dec/adr→decision, mr→merge-request" - flag --updated-after type=string default="" usage="Filter issues updated after date (YYYY-MM-DD or RFC3339)" - flag --updated-before type=string default="" usage="Filter issues updated before date (YYYY-MM-DD or RFC3339)" - -bd send-metrics - use: "send-metrics" - short: "Internal: flush queued telemetry events (spawned by bd)" - hidden: true - runnable: true - -bd serve - use: "serve" - short: "Serve the beads HTTP API over loopback" - hidden: false - runnable: true - long: - | Serve the beads HTTP API — the same work surface the CLI answers, for - | automation clients that would otherwise fork a bd subprocess per call. - | - | The wire contract is described by an OpenAPI document (/v0); GET - | /v0/beads/context reports which operations this build actually implements. - | - | DEPLOYMENT - | - | Pass an explicit port. The default 127.0.0.1:0 takes an ephemeral one, which - | is right for ad-hoc and test use — where the bound address printed on stdout - | is read immediately — but carries no mutual exclusion: two serves against one - | workspace then run side by side on different ports with no way to enumerate - | them. On a fixed port the second one fails to bind, which is the intended - | behavior. Concurrent serves are data-safe either way; claims are arbitrated - | in the SQL server. - | - | Run it under a supervisor. bd shuts down gracefully on SIGHUP as well as - | SIGINT and SIGTERM, so closing the terminal of a foreground bd serve stops it. - | - | PROBES - | - | GET /healthz is LIVENESS only: it answers from the process and never touches - | the database, so it stays green while the database is unreachable. For - | readiness use GET /v0/beads/ready?limit=1 — a real query, where 200 means - | ready and 503 means live but not ready. - | - | AUTHENTICATION - | - | Optional, and off by default on loopback — where the trust model is the - | loopback boundary itself, the same one the database behind it already relies - | on. --auth-token-file turns it on: every operation except GET /healthz then - | requires an "Authorization: Bearer " header, GET /v0/beads/context - | included, because it reports the repo root, beads directory and database name. - | - | The file holds ONE TOKEN PER LINE and every line is accepted. That is the - | rotation mechanism: write the new token alongside the old, roll the clients - | over, then delete the old line. The file is re-read while the server runs, so - | both the addition and the removal take effect within about a second and - | neither needs a restart. Write it atomically (a temp file plus rename; a - | Kubernetes secret mount already does this). - | - | There is deliberately no --auth-token flag. A credential passed as an - | argument is readable by every local user in the process listing. - | - | --allow-non-loopback REQUIRES a token file. Beyond loopback, reaching the - | address would otherwise be the whole authorization: any peer could read every - | issue and claim work as any actor. --insecure-no-auth is the explicit, - | auditable way to say you meant that anyway. - | - | The Host allowlist is what a service deployment usually trips over first. The - | DNS-rebinding check answers only to loopback spellings and the bind address, - | so a client dialing a service name gets 400 on every request; enumerate the - | names it dials with --allowed-host (repeatable). Matching is exact — no - | wildcards — and the startup log line prints the effective allowlist. - | - | WHAT THIS DOES NOT DO - | - | No TLS. Even with a token, the credential and every issue body travel in - | plaintext, so a deployment beyond loopback has to supply confidentiality - | itself — a service mesh, or a network boundary you already trust. - | - | Hooks do not fire. A hook is a user-controlled subprocess per mutation: in a - | concurrent server that is an unbounded latency multiplier and an orphaned - | child at shutdown, and its working-directory-derived hook lookup is - | meaningless in a server process. A CLI claim runs on_update; an HTTP claim - | does not. - | - | The per-command auto-commit machinery does not run. Durability is per request: - | a successful claim commits inside its own transaction, exactly as a proxied - | CLI claim does today. - | - | An actor on an HTTP request is caller-asserted provenance for the audit trail, - | not authenticated identity — the same thing it has always been on the CLI, - | where any local process can pass any --actor. - | - | It does not run under --readonly, and refuses to start rather than binding. - | Every server it binds publishes the issue-claim operation, and the capability - | set it advertises is a property of the build rather than of the flags on the - | process that started it — so a read-only server would advertise a write it - | could never land. - | - | DESTRUCTIVE OPERATIONS - | - | POST /v0/beads/issues:sweep deletes closed beads in bulk — the operation - | behind bd purge and bd prune — and nothing it deletes comes back. It shares - | the library surface those commands call, so it inherits their guards: pinned - | beads are never swept, and a durable sweep with neither a cutoff nor an id - | pattern is refused rather than clearing every closed bead in the workspace. - | Combined with the trust model above, that means anyone who can reach this - | address can erase closed work; bind it accordingly. - flag --addr type=string default="127.0.0.1:0" usage="Address to bind as IP:PORT; the host must be a numeric IP literal, and port 0 takes an ephemeral port" - flag --allow-non-loopback type=bool default="false" usage="Permit a bind beyond loopback. Requires --auth-token-file, since reaching the address would otherwise be the whole authorization" - flag --allowed-host type=stringArray default="[]" usage="Additional Host header value to answer to, e.g. a service DNS name. Repeatable; matched exactly, with no wildcards" - flag --auth-token-file type=string default="" usage="Require an Authorization: Bearer token from this file, one token per line, all accepted. Re-read while running, so rewriting it rotates tokens without a restart (env BEADS_SERVE_TOKEN_FILE)" - flag --insecure-no-auth type=bool default="false" usage="Serve a non-loopback bind with NO authentication. Every peer that can reach the address gets full read and claim access" - flag --large-apply-ceiling type=duration default="5m0s" usage="Whole-run budget for a POST issues:batchApply request over 100 items (a ceiling, not a target; requests at or under 100 items are unaffected). Must be positive. The orchestrator's stop grace must be at least this long plus 5s, or an external SIGKILL can cut off an in-flight large apply a graceful drain would otherwise have waited out; see engdocs/SERVE_RUNBOOK.md" - -bd set-state - use: "set-state =" - short: "Set operational state (creates event + updates label)" - group: "issues" - hidden: false - runnable: true - long: - | Atomically set operational state on an issue. - | - | This command: - | 1. Creates an event bead recording the state change (source of truth) - | 2. Removes any existing label for the dimension - | 3. Adds the new dimension:value label (fast lookup cache) - | - | State labels follow the convention :, for example: - | patrol:active, patrol:muted - | mode:normal, mode:degraded - | health:healthy, health:failing - | - | Examples: - | bd set-state agent-abc patrol=muted --reason "Investigating stuck worker" - | bd set-state agent-abc mode=degraded --reason "High error rate detected" - | bd set-state agent-abc health=healthy - | - | The --reason flag provides context for the event bead (recommended). - flag --reason type=string default="" usage="Reason for the state change (recorded in event)" - -bd setup - use: "setup [recipe]" - short: "Setup integration with AI editors" - group: "setup" - hidden: false - runnable: true - long: - | Setup integration files for AI editors and coding assistants. - | - | Recipes define where beads workflow instructions are written. Built-in recipes - | include cursor, claude, copilot, gemini, aider, factory, codex, mux, opencode, junie, kiro, windsurf, cody, and kilocode. - | - | Examples: - | bd setup cursor # Install Cursor IDE integration (rules + agent hooks) - | bd setup cursor --global # Install global Cursor hooks (~/.cursor/hooks.json) - | bd setup kiro # Install Kiro steering guidance - | bd setup codex # Install Codex skill + AGENTS.md guidance + native hooks - | bd setup codex --global # Install global Codex skill + guidance + native hooks - | bd setup copilot # Install Copilot CLI plugin + repository instructions - | bd setup mux --project # Install Mux workspace layer (.mux/AGENTS.md) - | bd setup mux --global # Install Mux global layer (~/.mux/AGENTS.md) - | bd setup mux --project --global # Install both Mux layers - | bd setup --list # Show all available recipes - | bd setup --print # Print the template to stdout - | bd setup -o rules.md # Write template to custom path - | bd setup --add myeditor .myeditor/rules.md # Add custom recipe - | - | Use 'bd setup --check' to verify installation status. - | Use 'bd setup --remove' to uninstall. - flag --add type=string default="" usage="Add a custom recipe with given name" - flag --check type=bool default="false" usage="Check if integration is installed" - flag --global type=bool default="false" usage="Install globally (claude/codex/cursor/mux; writes to ~/.claude/settings.json, $CODEX_HOME/AGENTS.md or ~/.codex/AGENTS.md, ~/.cursor/hooks.json, or ~/.mux/AGENTS.md)" - flag --list type=bool default="false" usage="List all available recipes" - flag --output -o type=string default="" usage="Write template to custom path" - flag --print type=bool default="false" usage="Print the template to stdout" - flag --project type=bool default="false" usage="Install for this project only (gemini/mux)" - flag --remove type=bool default="false" usage="Remove the integration" - flag --stealth type=bool default="false" usage="Use stealth mode (claude/gemini)" - -bd ship - use: "ship " - short: "Publish a capability for cross-project dependencies" - hidden: false - runnable: true - long: - | Ship a capability to satisfy cross-project dependencies. - | - | This command: - | 1. Finds issue with export: label - | 2. Validates issue is closed (or --force to override) - | 3. Adds provides: label - | - | External projects can depend on this capability using: - | bd dep add external:: - | - | The capability is resolved when the external project has a closed issue - | with the provides: label. - | - | Examples: - | bd ship mol-run-assignee # Ship the mol-run-assignee capability - | bd ship mol-run-assignee --force # Ship even if issue is not closed - | bd ship mol-run-assignee --dry-run # Preview without making changes - flag --dry-run type=bool default="false" usage="Preview without making changes" - flag --force type=bool default="false" usage="Ship even if issue is not closed" - -bd show - use: "show [id...] [--id=...] [--current]" - aliases: ["view"] - short: "Show issue details" - group: "issues" - hidden: false - runnable: true - flag --as-of type=string default="" usage="Show issue as it existed at a specific commit hash or branch (requires Dolt; commit hashes must be the full 32-character hash from 'bd history', not a prefix)" - flag --brief-deps type=bool default="false" usage="Reduce each dependency to its identity fields in JSON output (--json only; drops description, design, notes and acceptance criteria)" - flag --children type=bool default="false" usage="Show only the children of this issue" - flag --comments-tail type=int default="0" usage="Render only the last N comments in text output, preceded by one elision line naming how many older ones were hidden (text output only; 0, the default, renders every comment unchanged; N must be >= 0)" - flag --current type=bool default="false" usage="Show the currently active issue (in-progress, hooked, or last touched)" - flag --id type=stringArray default="[]" usage="Issue ID (use for IDs that look like flags, e.g., --id=gt--xyz)" - flag --include-comments type=bool default="false" usage="Stream full comment bodies in JSON output (--json only; may be slow on issues with many comments). Without it the comments field is absent entirely, not truncated: an issue with comments carries comment_count and comments_omitted=true, so check those before reading an absent comments field as none." - flag --include-dependents type=bool default="false" usage="Stream full dependent issues in JSON output (--json only; may be slow on hub beads)" - flag --local-time type=bool default="false" usage="Show timestamps in local time instead of UTC (date-only fields are always local)" - flag --long type=bool default="false" usage="Show all available fields (extended metadata, agent identity, gate fields, etc.)" - flag --refs type=bool default="false" usage="Show issues that reference this issue (reverse lookup)" - flag --short type=bool default="false" usage="Show compact one-line output per issue" - flag --thread type=bool default="false" usage="Show full conversation thread (for messages)" - flag --watch -w type=bool default="false" usage="Watch for changes and auto-refresh display" - -bd sql - use: "sql " - short: "Execute raw SQL against the beads database" - group: "maint" - hidden: false - runnable: true - long: - | Execute a raw SQL query against the underlying database (Dolt). - | - | Useful for debugging, maintenance, and working around bugs in higher-level commands. - | - | Examples: - | bd sql 'SELECT COUNT(*) FROM issues' - | bd sql 'SELECT id, title FROM issues WHERE status = "open" LIMIT 5' - | bd sql 'DELETE FROM dirty_issues WHERE issue_id = "bd-abc123"' - | bd sql --csv 'SELECT id, title, status FROM issues' - | - | The query is passed directly to the database. Reads (SELECT, WITH ... SELECT, - | SHOW, EXPLAIN) return results as a table (or JSON/CSV with --json/--csv). Writes - | (INSERT, UPDATE, DELETE, DDL) report the number of rows affected. Statements - | that may both write and return rows, such as CALL, are committed and print any - | rows they return (or "OK"). - | - | In proxied-server mode, multiple statements separated by ';' run as a single - | committed batch and report "OK", and --database runs the query against a - | different server database (equivalent to a session USE) without changing the - | project's configured database. - | - | WARNING: Direct database access bypasses the storage layer. Use with caution. - flag --csv type=bool default="false" usage="Output results in CSV format" - -bd stale - use: "stale" - short: "Show stale issues (not updated recently)" - group: "views" - hidden: false - runnable: true - long: - | Show issues that haven't been updated recently and may need attention. - | This helps identify: - | - In-progress issues with no recent activity (may be abandoned) - | - Open issues that have been forgotten - | - Issues that might be outdated or no longer relevant - flag --days -d type=int default="30" usage="Issues not updated in this many days" - flag --exclude-label type=stringSlice default="[]" usage="Exclude issues that have ANY of these labels" - flag --label -l type=stringSlice default="[]" usage="Filter by labels (AND: must have ALL). Can combine with --label-any" - flag --label-any type=stringSlice default="[]" usage="Filter by labels (OR: must have AT LEAST ONE). Can combine with --label" - flag --limit -n type=int default="50" usage="Maximum issues to show" - flag --status -s type=string default="" usage="Filter by status (open|in_progress|blocked|deferred)" - -bd state - use: "state " - short: "Query the current value of a state dimension" - group: "issues" - hidden: false - runnable: true - long: - | Query the current value of a state dimension from an issue's labels. - | - | State labels follow the convention :, for example: - | patrol:active - | mode:degraded - | health:healthy - | - | This command extracts the value for a given dimension. - | - | Examples: - | bd state witness-abc patrol # Output: active - | bd state witness-abc mode # Output: normal - | bd state witness-abc health # Output: healthy - -bd state list - use: "list " - short: "List all state dimensions on an issue" - hidden: false - runnable: true - long: - | List all state labels (dimension:value format) on an issue. - | - | This filters labels to only show those following the state convention. - | - | Example: - | bd state list witness-abc - | # Output: - | # patrol: active - | # mode: normal - | # health: healthy - -bd status - use: "status" - aliases: ["stats"] - short: "Show issue database overview and statistics" - group: "views" - hidden: false - runnable: true - long: - | Show a quick snapshot of the issue database state and statistics. - | - | This command provides a summary of issue counts by state (open, in_progress, - | blocked, closed), ready work, extended statistics (pinned issues, - | average lead time), and recent activity over the last 24 hours from git history. - | - | Similar to how 'git status' shows working tree state, 'bd status' gives you - | a quick overview of your issue database without needing multiple queries. - | - | Use cases: - | - Quick project health check - | - Onboarding for new contributors - | - Integration with shell prompts or CI/CD - | - Daily standup reference - | - Fast CI status checks that don't need blocked-count accuracy - | - | Examples: - | bd status # Show summary with activity - | bd status --no-activity # Skip git activity (faster) - | bd status --no-blocked # Skip slow blocked-count scan (faster) - | bd stats --no-blocked --json # JSON output without blocked count - | bd status --json # JSON format output - | bd status --assigned # Show issues assigned to current user - | bd stats # Alias for bd status - flag --all type=bool default="false" usage="Show all issues (default behavior)" - flag --assigned type=bool default="false" usage="Show issues assigned to current user" - flag --no-activity type=bool default="false" usage="Skip git activity summary (faster)" - flag --no-blocked type=bool default="false" usage="Skip blocked-count computation (faster on large rigs; not supported in proxied-server mode)" - -bd statuses - use: "statuses" - short: "List valid issue statuses" - group: "views" - hidden: false - runnable: true - long: - | List all valid issue statuses and their categories. - | - | Built-in statuses (open, in_progress, blocked, etc.) are always valid. - | Additional statuses can be configured via status.custom: - | - | bd config set status.custom "in_review:active,qa_testing:wip,on_hold:frozen" - | - | Categories control behavior: - | active — appears in 'bd ready' and default 'bd list' - | wip — excluded from 'bd ready', visible in default 'bd list' - | done — excluded from 'bd ready' and default 'bd list' - | frozen — excluded from 'bd ready' and default 'bd list' - | - | Statuses without a category (legacy format) are valid but excluded from 'bd ready'. - | - | Examples: - | bd statuses # List all statuses with icons and categories - | bd statuses --json # Output as JSON - | - -bd supersede - use: "supersede --with " - short: "Mark an issue as superseded by a replacement issue" - group: "deps" - hidden: false - runnable: true - long: - | Mark an issue as superseded by a different (replacement) issue. - | - | The superseded issue is automatically closed with a reference to the replacement. - | Useful for design docs, specs, and evolving artifacts. - | - | Examples: - | bd supersede bd-old --with bd-new # Mark bd-old as superseded by bd-new - flag --with type=string default="" annotations={cobra_annotation_bash_completion_one_required_flag=["true"]} usage="Replacement issue ID (required)" - -bd swarm - use: "swarm" - short: "Swarm management for structured epics" - group: "deps" - hidden: false - runnable: false - long: - | Swarm management commands for coordinating parallel work on epics. - | - | A swarm is a structured body of work defined by an epic and its children, - | with dependencies forming a DAG (directed acyclic graph) of work. - -bd swarm create - use: "create [epic-id]" - short: "Create a swarm molecule from an epic" - hidden: false - runnable: true - long: - | Create a swarm molecule to orchestrate parallel work on an epic. - | - | The swarm molecule: - | - Links to the epic it orchestrates - | - Has mol_type=swarm for discovery - | - Specifies a coordinator (optional) - | - Can be picked up by any coordinator agent - | - | If given a single issue (not an epic), it will be auto-wrapped: - | - Creates an epic with that issue as its only child - | - Then creates the swarm molecule for that epic - | - | Examples: - | bd swarm create bd-epic-123 # Create swarm for epic - | bd swarm create bd-epic-123 --coordinator=observer/ # With specific coordinator - | bd swarm create bd-task-456 # Auto-wrap single issue - flag --coordinator type=string default="" usage="Coordinator address (e.g., my-project/witness)" - flag --force type=bool default="false" usage="Create new swarm even if one already exists" - -bd swarm list - use: "list" - short: "List all swarm molecules" - hidden: false - runnable: true - long: - | List all swarm molecules with their status. - | - | Shows each swarm molecule with: - | - Progress (completed/total issues) - | - Active workers - | - Epic ID and title - | - | Examples: - | bd swarm list # List all swarms - | bd swarm list --json # Machine-readable output - -bd swarm status - use: "status [epic-or-swarm-id]" - short: "Show current swarm status" - hidden: false - runnable: true - long: - | Show the current status of a swarm, computed from beads. - | - | Accepts either: - | - An epic ID (shows status for that epic's children) - | - A swarm molecule ID (follows the link to find the epic) - | - | Displays issues grouped by state: - | - Completed: Closed issues - | - Active: Issues currently in_progress (with assignee) - | - Ready: Open issues with all dependencies satisfied - | - Blocked: Open issues waiting on dependencies - | - | The status is COMPUTED from beads, not stored separately. - | If beads changes, status changes. - | - | Examples: - | bd swarm status gt-epic-123 # Show swarm status by epic - | bd swarm status gt-swarm-456 # Show status via swarm molecule - | bd swarm status gt-epic-123 --json # Machine-readable output - -bd swarm validate - use: "validate [epic-id]" - short: "Validate epic structure for swarming" - hidden: false - runnable: true - long: - | Validate an epic's structure to ensure it's ready for swarm execution. - | - | Checks for: - | - Correct dependency direction (requirement-based, not temporal) - | - Orphaned issues (roots with no dependents) - | - Missing dependencies (leaves that should depend on something) - | - Cycles (impossible to resolve) - | - Disconnected subgraphs - | - | Reports: - | - Ready fronts (waves of parallel work) - | - Estimated worker-sessions - | - Maximum parallelism - | - Warnings for potential issues - | - | Examples: - | bd swarm validate gt-epic-123 # Validate epic structure - | bd swarm validate gt-epic-123 --verbose # Include detailed issue graph - flag --verbose type=bool default="false" usage="Include detailed issue graph in output" - -bd sync - use: "sync" - short: "Pull, check for conflicts, repair is_blocked, and push (the federation loop)" - group: "sync" - hidden: false - runnable: true - long: - | Run one full synchronization cycle against the Dolt remote. - | - | This is the loop every multi-machine beads deployment otherwise hand-rolls in - | shell: - | - | 1. pull from the remote - | 2. check for merge conflicts POSITIVELY, from the merge's own conflict rows - | and from Dolt's conflict tables — never inferred from the pull's exit - | status, which is not a trustworthy conflict signal in either direction - | 3. recompute the denormalized is_blocked flag, so dependency edges merged in - | from another replica do not leave 'bd ready' stale - | 4. push, retrying a bounded number of times when another replica wins the - | push race - | - | The repair in step 3 refuses to run while another writer has uncommitted changes - | to issues/dependencies. That is transient and not this sync's doing, so it is - | retried on the same budget as a push race rather than failing the run. A working - | set that is NOT transient exits 4 instead, because no amount of retrying will - | ever publish and only an operator can clear it. Two kinds of evidence say so: - | constraint violations on the dirty tables are detected positively and escalate - | on the very attempt that finds them; an abandoned uncommitted edit has no such - | positive signal, so it is only inferred once the same pending graph edits have - | blocked every attempt of several consecutive runs. - | - | Conflicts sync cannot resolve safely are NEVER auto-resolved: it halts before - | recomputing or pushing and exits 2, and repeated runs keep halting the same way - | until an operator resolves the divergence. (The pull underneath does auto-settle - | the conflict classes it can settle convergently — machine-local metadata, - | audit-only dependency rows, and last-write-wins on issue cells. Anything beyond - | those halts here.) Whether the halted merge was aborted or left live in the - | working set depends on the pull route, so the halt message reports which. - | - | Exit codes (a sync timer can branch on these without parsing output): - | - | 0 synced, or nothing to do - | 1 error (transport, auth, storage) - | 2 merge conflict — halted, nothing pushed, resolve it by hand - | 3 retries exhausted (push race, or a concurrent writer's dirty working set) - | — transient, nothing pushed, retry on the next tick - | 4 the dirty working set is stuck, not busy: identical pending graph edits - | blocked every attempt of several consecutive runs — nothing pushed, and no - | later tick will publish until an operator clears it - | - | On the default-remote path, a rig with no Dolt remote yet but a git origin - | configured adopts that origin as its Dolt remote first, exactly as 'bd dolt push' - | does — so 'bd sync' works as a first-time federation bring-up step instead of - | reporting 'no remote' and doing nothing. Passing --remote never adopts anything. - | - | This is not 'bd federation sync', which syncs with named peer towns and takes a - | --strategy ours|theirs to resolve whatever conflicts it meets. 'bd sync' targets - | the configured remote and has no such switch: what it cannot settle, it halts on. - | - | Examples: - | bd sync # sync with the default remote - | bd sync --remote mini # sync with a specific remote - | bd sync --attempts 5 # allow more push-race retries - | bd sync --json # machine-parseable outcome - flag --attempts type=int default="3" usage="Maximum pull/push attempts before reporting a transient retry exhaustion (exit 3)" - flag --no-adopt type=bool default="false" usage="Never derive a Dolt remote from git origin (also BD_NO_REMOTE_ADOPT=1)" - flag --remote type=string default="" usage="Sync with a specific named remote instead of the default" - flag --yes -y type=bool default="false" usage="Consent to adopting a Dolt remote derived from git origin when none is configured" - -bd tag - use: "tag