Commit graph

82 commits

Author SHA1 Message Date
Julian Knutsen
c86a87bb20
test(oracle-a): pin BEADS_TIP_SEED so human-output scenarios stop flaking (#7707)
After a successful human-output create/show/list/ready, bd may append a
"💡 Tip:" line chosen by a probability roll whose RNG is clock-seeded
unless BEADS_TIP_SEED is set. run_scenario env_clear()s and passes only
PATH/HOME/TMPDIR + BEADS_TEST_MODE=1, so on a host with ~/.claude (claude_setup
tip eligible, p=0.6) every bd process rolled independently and out-of-scope
human-output scenarios (create_human_readable_output, show_short_mode_text,
show_multiple_short, ready_empty_no_issues_plain, ...) diverged main-vs-main.

Pass BEADS_TIP_SEED=1214 to every step for both reference and candidate.
Go math/rand's first Float64() for that seed is 0.0000159, so the
highest-priority eligible tip always wins its roll. Where the host makes a
tip eligible, it stays visible and lands on a deterministic step, so a change
to which tip prints, on which step, or to its text (including a tip leaking
into --json) still diverges instead of being normalized away. Where no tip is
eligible (no ~/.claude, beads plugin enabled, or a `bd prime` hook) none
prints and tip changes go unobserved; the README now says so.

The new unit test spawns printenv through run_scenario. That races the
existing stub-bd test, which writes its stub with std::fs::write and then
execs it: a fork while the write fd is open makes the exec fail with ETXTBSY
(rust-lang/rust#114554). Serialize both spawning tests on a SPAWN mutex.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 22:02:44 +00:00
Julian Knutsen
2829d22192
test(oracle-a): let scenarios that start with init own initialization (#7704)
run_scenario always ran `bd init -p <prefix> --quiet` before a scenario's
steps. 43 deterministic catalog scenarios start with their own
`init --prefix X --non-interactive ...`; in 40 of them that step always hit
"This workspace is already initialized" (exit 1), pinning the double-init
refusal instead of a real init. The other 3 fail flag validation first,
which is what they test, and are unchanged. Their later steps (the commands
they are named for) ran against the harness's own pre-init and are
unaffected.

A scenario whose first step's command token is `init` now owns
initialization (Scenario::owns_init) and starts in an empty workspace; every
other scenario keeps the pre-init, and a later `init` step stays a re-init.
The pre-init decision is the pure harness_init() helper, and the step loop
is run_steps(), which takes the command runner as a closure.
normalize() now collapses the `Repository ID`/`Clone ID` values a real init
prints (hashed from the random workspace path) to <REPO_ID>/<CLONE_ID>.
init_proxied_server_not_implemented is marked deterministic:false: its
premise is stale and, un-masked, it starts a managed dolt sql-server.

New tests cover the owns_init rule, the harness_init decision, the
run_steps argv sequence (via a recording closure) and the fingerprint
normalization. None spawns a process, so none can hit the write-then-exec
ETXTBSY race against the suite's process-spawning tests.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 10:57:02 +00:00
Julian Knutsen
fb912f2438
fix(oracle-a): write scoreboard failure detail per run, not to shared /tmp (#7690)
The scoreboard dumped every in-scope failure to the host-global
/tmp/oracle-a-failures.txt, and run-oracle-a.sh copied it into its scratch
dir only after scoring finished. A concurrent scoreboard (another worktree,
a shard, another user) finishing in between overwrote or swapped the
detail, so a failing run could print nothing or another run's divergence.

The scoreboard now honors ORACLE_FAILURES_FILE (unset or empty keeps the
historical /tmp default for standalone use), and run-oracle-a.sh points it
at $SCRATCH/oracle-a-failures.txt and prints that file directly. The cp
and the /tmp fallback are gone.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 07:34:17 +00:00
Julian Knutsen
e3efb3107a
test(oracle-a): always remove the reference worktree on exit (#7689)
run-oracle-a.sh's EXIT trap removed its reference worktree only when
`git worktree list --porcelain | grep -qF "$REF_SRC"` matched. Under
pipefail that check reported a registered worktree as absent in two ways:
grep -q exits on its first match while git is still writing a large
listing, so git dies of SIGPIPE (141) and the pipeline fails; and git
lists the resolved path, which $REF_SRC never matches when $TMPDIR has a
trailing slash or runs through a symlink (both macOS defaults). Either
way the ref-src registration leaked as a prunable worktree.

Run `git worktree remove --force` unconditionally. It resolves the path
itself and fails harmlessly (silenced, `|| true`) when nothing is
registered, so cleanup is idempotent and exit codes are unchanged.

TestOracleAScriptRemovesItsReferenceWorktree runs the real script in a
fixture repo with a stand-in go that fails the reference build, covering
a >3 MB listing, a trailing-slash TMPDIR, a symlinked TMPDIR, and a run
that dies before the worktree is added.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 07:29:55 +00:00
Julian Knutsen
8fac20a7f1
test(oracle-a): normalize per-run revision token and workspace path so main-vs-main is clean (#7680)
* test(oracle-a): normalize the per-write revision token so main-vs-main is clean

Since #5535, `bd show --json` publishes `"revision"`, the decimal spelling
of the row's row_lock. Every create and status/ownership write remints that
token from crypto/rand (issueops.freshRowLock), so it differs between any
two runs of the same scenario. The harness did not normalize it, so Oracle A
failed against itself: on the curated tier, origin/main vs origin/main scored
31 pass / 13 fail in scope, and each failure was a `show --json` step that
differed only in `"revision"`.

normalize() now collapses a non-zero decimal `"revision"` string to `<REV>`.
It keeps everything else literal: the member name, its presence and its
string type, "0" (a row that was never stamped), number-typed values, other
`*_revision` members, and escaped text inside a JSON string. A new unit test
covers each of these cases.

Curated tier, REF_REF=origin/main, run against itself: before 31 pass /
13 fail in scope (0/1 out of scope); after 44 pass / 0 fail (1/0).

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(oracle-a): normalize the per-run workspace path

Each scenario runs in a fresh tempfile::tempdir(), so any bd output that
echoes the workspace path differs on every run. When origin/main's bd was
captured twice with the deep tier (ORACLE_CATALOG=1, 546 scenarios), 40
catalog scenarios differed only in that path. All 40 start with their own
`init --prefix X --non-interactive` step, which runs in a workspace the
harness already initialized and fails with "Found existing Dolt database:
/tmp/.tmpXXXXXX/.beads/embeddeddolt/X".

run_scenario now hands normalize_in_workspace() the exact workspace path
and its symlink-resolved spelling, and that function replaces only those
strings with <WORKSPACE>, longest first. Other paths stay literal, so no
stable value is collapsed. All 40 scenarios are out of scope, so in-scope
counts do not change.

Deep tier, origin/main's bd against itself, scored by the scoreboard:
- base harness: 256 pass / 67 fail in scope, 154 / 69 out of scope.
- with both normalizers: 323 / 0 in scope, 219 / 4 out of scope.

The out-of-scope remainder changes from run to run and none of it is a
field value. It comes from randomized "Tip:" lines in human output and one
unordered `list --format dot`.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(oracle-a): document and pin the <REV> match scope and the workspace wiring (mc-ro9kg)

Review fixes for #7680, iteration 1.

revision_regex runs over the raw stdout/stderr text before any JSON
parse, so it collapses every "revision" member holding a non-zero
decimal string, at any depth and in plain text, not only the
bd show --json issue token. That includes a user metadata key named
revision, which the in-scope --set-metadata/--metadata flags can set,
so a change to its value passes the gate. The regex comment and a new
README "What green does NOT prove" bullet now say so, and
normalize_collapses_revision_by_member_name_at_any_depth pins the
scope: a nested metadata member and plain text are collapsed, while a
metadata key with any other name still gates. The old test name said
nothing else was collapsed; it is now
normalize_collapses_non_zero_revision_strings.

run_scenario_collapses_the_workspace_in_both_step_streams runs
run_scenario against a stub bd that prints its cwd on stdout and its
resolved path on stderr, and expects <WORKSPACE> in both. Before, the
two normalize_in_workspace calls in run_scenario could be reverted with
every unit test and the curated tier still green.

The remint wording in the comment and the README now names every
writer (create, update, close, reopen, claim and unclaim) instead of
only status/ownership writes.

Tests: cargo test --locked --offline (7 passed), clippy clean, no new
rustfmt hunks. Mutants, each in its own copy and target dir: reverting
either or both normalize_in_workspace calls fails the run_scenario
test; skipping a nested metadata member, or matching only after { or
",", fails the scope test.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
2026-10-19 04:27:28 +00:00
Julian Knutsen
873162dafa
ci(bazel): dolt-int gates server-storage + cmd-dolt in mode remote (item 5 A2) (#7535)
* ci(bazel): dolt-int gates the server-storage and cmd-dolt tiers in mode remote (item 5 A2)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-13 09:17:54 +00:00
Julian Knutsen
6d27a4f96e
fix(issueops): enforce the close guards on every close leg (#7425)
* fix(issueops): enforce the close guards on every close leg

The template read-only guard, the pin guard and the assignee authority
fence (be-035) lived only in cmd/bd (validateIssueClosable), so a close
through bd serve, issues:batchClose, a batch:apply close item or a library
caller of Lifecycle.Close / BatchCloser / BatchApplier closed what bd close
refused.

They now run inside the close's own transaction in CloseIssueCheckedInTx
(enforceCloseGuardsInTx), the body every checked close shares (dolt,
embedded, uow, and the server behind httpapi), for a target that is not
already closed:
- a template refuses with *issueops.TemplateReadOnlyError (no bypass);
- unless Force (CloseRequest, CloseBatchRequest, CloseItem) is set, a pinned
  issue refuses with *issueops.PinnedError and another actor's bead with
  *issueops.CloseNotAssigneeError (matches ErrNotOwner).

Wire: 409 template_read_only, issue_pinned and not_assignee (holder in
`assignee`, also on a batch-close outcome); the client rebuilds the typed
errors. The decision is one exported pure rule over the pre-image,
issueops.CheckClosable (internal/storage/issueops), which the in-tx guard
calls; bd close's direct and proxied preflights call it too, ahead of gate
satisfaction under the same already-closed skip, so bd close output, refusal
order and exit codes are unchanged (validateIssueClosable is gone). bd close
--if-revision now applies the guards too.

Conformance: RunLifecycleCloseEnforcesTheCloseGuards,
RunBatchCloserItemsAnswerToTheCloseGuards and
RunBatchApplyCloseItemsAnswerToTheCloseGuards on dolt, embedded, uow and
http, plus handler mapping tests, a CheckClosable table test, and a cmd/bd
test pinning that the guards outrank gate satisfaction.

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

* fix(httpclient): send force on the raw close; scope the close guards

Review fixes for #7425 (adopt-pr bd-0h0ao4, iterations 1 and 2).

The raw close keeps parity over http. httpclient.Store.CloseIssue maps the
off-role raw close onto the role's closeIssue op and sent force=false.
With the guards in the role, a pinned or claimed target then refused (409
issue_pinned / not_assignee) on http only: dolt, embedded and proxied run
the raw close as issueops.CloseIssueInTx, which applies neither the guards
nor close policy. The molecule auto-close, `bd gate resolve`,
`bd todo done` and `bd human dismiss` all make that call, and its
signature carries no force a caller could pass. It now sends force. Over
http that also stops applying close policy to the raw close, which it did
at base and no other backend does; parity is the point, so that goes too.
The template guard has no bypass on the wire, so a template still refuses
the raw close over http where the other backends close it; no raw caller
is known to close one. TestServedRawCloseKeepsParityWithTheOtherBackends
closes both pin spellings, a held bead and a parent with an open child
through Store.CloseIssue and requires the template refusal; with force
back to false it fails on 409 issue_pinned.

The close guards stay on the close verbs. A status update that crosses
into the done category (`bd update -s closed`, PATCH, a batchApply update
item) still answers to close policy only, so it closes a pinned issue or
another actor's bead on every backend, as it did before this PR. Guarding
it changes what the update legs admit and needs its own refusal mapping on
PATCH and batchApply, so it is left for a follow-up; the update.go and
domain/db comments now say the exclusion is deliberate.

CHANGELOG: the entry moves from Fixed to Changed as BREAKING, is scoped to
the close operations, names the two paths the guards do not cover, and
adds a Migration line (send force or reclaim; templates are never
closable). Docs: the OpBatchCloseIssues item codes, the CloseIssueChecked
and CloseIssueOptions.Force docs (storage, dolt, embeddeddolt), the
oracle-a scenario strings that named the retired validateIssueClosable,
and the TestCloseCheckOne_CloseGuardsOutrankGateSatisfaction doc, which
claimed a proxied route it does not drive.

Iteration 2: the wire contract says what force waives. The OpenAPI
`force` members of CloseIssueRequest, BatchCloseRequest and ApplyCloseItem
said force bypasses close policy "and nothing else"; it also waives the
pin and the assignee guard, and never the template guard. The batchClose
"only two answers" paragraph now says the same, and types.gen.go is
regenerated (`make api-gen`). "Close guards" names the close operations
instead of "every route to a close" and adds that a status update into
the done category is not one, and the PATCH done-crossing paragraph says
a patch is never refused `issue_pinned` or `not_assignee`. The conformance
comments that quoted the old Force sentence (batch_apply_contract.go,
batch_closer_contract.go, lifecycle_close_reopen_contract.go) quote the
current docs, and the batch_apply failure message no longer says Force
does nothing else. CHANGELOG: a `close` line of `bd batch` is named among
the raw closes, and "a template is never closable" becomes "the close
operations never close a template, forced or not". The storage interface
CloseIssue gains a doc that states its HTTP exception.

TestCloseGuardRefusalsPrintTheGuardSentenceOnEveryRoute pins the sentence
`bd close` prints for each guard (template, pin, assignee) through each
printer (closeDirectRefusal, closeDirectTypedRefusal, closeProxiedRefusal,
closeProxiedTypedRefusal), with the refusal bare, wrapped by the use case
and the SQL repository, or inside a served problem envelope. One pinned
refusal also goes through closeProxiedOutcomes and closeProxiedFailures,
where the stderr line and the `--json` error field must both be the
sentence. Six overlay mutants fail it: closeGuardRefusal recognizing no
guard, or not the pin, and each of the four printers skipping its call to
closeGuardRefusal.

Not done here: a CLI test that `--if-revision` exits 1 on a guard refusal,
not ExitGuardMismatch. External PR #7372 carries per-id fence tests for
that route (6 of 7 pass at this head); they are better absorbed with
credit than rewritten.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 18:30:42 +00:00
Julian Knutsen
5a5b7cfd66
ci(bazel): pin the slowest cmd/bd Dolt-server tests to their own shards (#7413)
* ci(bazel): pin the slowest cmd/bd Dolt-server tests to their own shards

The cmd-dolt lane's wall time when its tests re-run is the bd_test race
compile plus its slowest shard. rules_go shards round-robin by test index,
so whichever shard drew TestSharedServerConcurrent and the TestInit*
family ran 117-170s while the median shard ran ~55s.

tools/bazel/go_test_pinned_shard.sh runs a go_test binary with the tests a
committed manifest pins (measured >= 5s, bin-packed longest-first by
tools/bazel/pin_shards.py) in shards of their own, and every other test in
the binary's own round-robin shards with the pinned set skipped, so each
test still runs exactly once and new tests need no manifest edit.
bd_dolt_server_test goes from 16 to 32 shards (16 pinned + 16 round-robin),
regression_test from 8 to 16 (10 + 6; its go_test becomes the manual
regression_suite binary behind an sh_test of the old name).

Pinning exposed a pre-existing order dependence: TestCLI_Import failed
whenever it was the binary's first test, because runBDInProcess reused the
workspace discovery an earlier in-process execution cached and `bd init` in
a fresh directory resolved the previous one's .beads. The in-process
runners now reset beads/git discovery caches per execution.

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

* ci(bazel): pin cmd/bd Dolt-server shards from two measured runs; regression in 14 shards

The bd manifest now takes each test's slowest of the 16- and 32-shard runs
(pin_shards.py over both), and regression_test drops to 10 pinned + 4
round-robin shards: its unpinned tests total ~128s, so 6 round-robin
shards were mostly fixed cost.

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

* test(scripts): place the pinned-shard tests by what they read (#7414 split)

The manifest-name scan reads every cmd/bd and tests/regression _test.go
file, so it moves to go_test_sources_test (with tests/regression's
manifest); the wrapper, generator and wiring checks stay in scripts_test.
Shared helpers live in a helpers-only file both targets compile, and
repoFiles takes #7414's minimum-file count.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 05:50:09 +00:00
Julian Knutsen
d90823480a
ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414)
* ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files

//scripts:scripts_test declared //:repo_files (the whole checkout), so every
PR re-ran it, and it took ~181s on rbe-west. Most of that (60-79s) was
TestBazelGatedLanesNeverRetryFlakyTests line-regexping the --run_under
wrapper's pinned dolt binary (tools/bazel/hermetic_bin/dolt, in every
test's runfiles); it now skips binary files, as git grep -I does.

tools/bazel/go_srcs.py's per-package repo_files block now partitions each
package's files into repo_go_srcs, repo_go_test_srcs, repo_doc_files and
repo_other_files, aggregated at the root; //:repo_files is their union
(same 4679 files). The //scripts tests are split into go_test targets by
what they read (traced per test with strace over a runfiles-shaped tree):

  scripts_test          CI/Bazel policy: //:repo_other_files (+1 Go file)
  shell_scripts_test    script fixtures: //scripts files, a few root files
  go_test_sources_test  _test.go scans: //:repo_go_test_srcs + shard files
  go_sources_test       check-testing-short.sh: every .go file
  tracked_files_test    every tracked file: //:repo_files

Shared helpers move to helpers-only files; TestScriptsTestTargetsPartition-
TheTests fails on a test file in no target or in two. //test/docsync and
the //scripts/repochecks slices declare partitions or single files instead
of //:repo_files where they can.

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

* ci(bazel): skip only the non-checkout hermetic_bin dir in the flaky-retry walk

Skipping every binary file also stopped scanning tracked binaries (images,
.binpb fixtures). Skip just tools/bazel/hermetic_bin, the --run_under
wrapper's runfiles directory, which is not in the checkout, so the walk's
coverage of tracked files is unchanged.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 05:13:07 +00:00
Julian Knutsen
77ab980790
ci(bazel): run the hook-timeout-backends check under Bazel; test-nix stops running tests (#7357)
checks.nix's hook-timeout-backends (the tracked git hook shims against
real GNU/uutils/busybox/toybox timeout implementations, with and without
perl, under dash, bash and busybox ash: 240 cases) was the one test PR
Risk's test-nix ran on a GitHub runner, through `nix flake check`. It is
now //tests/hook_timeout_backends:hook_timeout_backends_test, an sh_test
(pr-core-only) that the bazel-test lane runs remotely on every PR: the
static uutils 0.12.0, busybox 1.35.0 and toybox 0.8.15 binaries come in
sha256-pinned through MODULE.bazel; dash, bash, perl and GNU coreutils
from the executor, failing (not skipping) when one is missing.

checks.nix goes and flake.nix declares no checks, so test-nix's
`nix run .#default` + `nix flake check` is a packaging check (build the
package Nix users install, evaluate every flake output), not a test.
TestHookTimeoutBackendsRunUnderBazel pins the target and that no flake
check comes back.

ga-96smfk.22

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 11:05:39 +00:00
Julian Knutsen
bb9b9e5020
ci(bazel): run the upgrade smoke tests under Bazel; retire cross-version-smoke.yml (#7331)
cross-version-smoke.yml resolved the newest 5 GitHub releases (30 on a tag
push) with `gh release list`, then built the candidate and downloaded each
release on a GitHub runner for scripts/upgrade-smoke-test.sh.

//tests/upgrade_smoke has one target per release in the newest 30 the
release catalog pins a linux/amd64 asset for (@bd_releases//:versions.bzl):
upgrade_smoke_<release>_test runs the script against the non-race
bd_for_tests with that release pinned as PREV_BIN (sha256-verified when
Bazel fetches it; the script checks it reports the release and downloads
nothing). A release added to the catalog joins the window. Tagged
pr-core-only, so bazel-test (not the integration lane) runs them remotely
on every PR, merge group and
push, cached until the candidate, the script or the release changes.

The tested set is now reviewed rather than resolved at run time: stable
releases from the catalog, where the workflow took GitHub releases
including prereleases. cross-version-smoke.yml and the F7c checks of its
chunk fold, path filter, runners and binary cache are removed (the
path-filter and binary-cache checks had no other workflow left).

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 02:49:39 +00:00
Julian Knutsen
7e0adfd353
ci(bazel): run the historical-upgrade corpus under Bazel; retire migration-test.yml (#7330)
* chore(migration-test): extend the release catalog through v1.3.1

The catalog stopped at v1.1.2 (the v1.2 upgrade census). The migration
corpus already upgrades from v1.2.2, and the Bazel targets that replace
migration-test.yml and cross-version-smoke.yml take their pinned release
binaries from the catalog (@bd_releases), so it has to cover the releases
since. Regenerated with `catalog generate` after raising maximumVersion to
v1.3.1: five new stable versions (v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.3.1;
three with a linux/amd64 asset) and five new proxy prereleases; no existing
entry, drift record or repository-only exclusion changed. The count
constants and the identity digest are updated to match, and the README now
says how to add a release.

Refs: ga-96smfk.19

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

* ci(bazel): run the historical-upgrade corpus under Bazel; retire migration-test.yml

migration-test.yml ran scripts/migration-test/run.sh --version <release> for
14 reviewed releases in 3 shards on GitHub runners: it downloaded each
release archive, built v0.9.1 from source with Go 1.25 through the module
proxy, installed libicu74 and the dolt 2.1.8 runtime, all over the network.

//tests/migration now has one target per corpus release
(historical_upgrade_<release>_test) plus legacy_bridge_test, all hermetic:
- Published releases come from @bd_releases (the release catalog's
  sha256-verified assets) through a per-target directory
  (HISTORICAL_RELEASE_DIR); lib/binary.sh uses it instead of downloading and
  still checks each binary's self-reported version.
- v0.9.1 is //tests/migration:bd_source_tag, the same `go mod download` +
  `go build -trimpath` with CGO and Go 1.25.0, run offline as a build
  action: the module files come from tests/migration/source_tag_modules.json
  through a file:// GOPROXY tree (tools/bazel/go_module_proxy.bzl), the
  release's own zip is the catalog's source_zip, and go checks every
  dependency against the release's go.sum (SOURCE_TAG_SQLITE_BIN).
- The external Dolt runtime is @dolt_test_runtime_linux_amd64 (dolt.bzl's
  dolt_release gains a version attribute; 2.1.8 is pinned to versions.sh's
  digest), passed as DOLT_BIN to the server-Dolt and wisp-plane releases.
- The workers already provide jq, python3, sqlite3 and libicu74.

The targets are untagged, so bazel-test runs them remotely on every PR,
merge group and push; result caching replaces the path filter. Every
release also passed inside a loopback-only network namespace.
scripts/migration_corpus_bazel_test.go keeps the BUILD lists equal to
versions.sh's corpus, the catalog digests equal to STRICT_RELEASE_SHA256,
the source-tag lock equal to the catalog's source_zip, and the Dolt runtime
pin equal to versions.sh's. migration-test.yml and the policy tests that
pinned its shards, caches, apt step and runner are removed.

Refs: ga-96smfk.19

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

* ci(bazel): run the historical-upgrade targets in the PR-core lane only

The integration lane runs every untagged target too, and its
check_testcases.py requires Go testcases, which a shell test's test.xml does
not list. A new pr-core-only tag keeps //tests/migration out of
--config=integration (bazelIntegrationExcludedTags adds it), so the corpus
runs once, in bazel-test, against the release-shaped bd_for_tests (no
integration tag). build_source_tag.sh carries the build-tags opt-out: it
builds a historical release with that release's own go.mod, which predates
gms_pure_go.

Refs: ga-96smfk.19

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 02:16:11 +00:00
Julian Knutsen
9a91f0629e
ci(bazel): run the differential regression suite under Bazel; retire regression.yml (#7324)
regression.yml ran `go test -tags=regression ./tests/regression/...` on a
GitHub runner: it built the candidate with `go build`, downloaded the v0.49.6
baseline release over the network, and pulled the dolt-sql-server image.
None of that works on rbe-west workers (no network for fork lanes, no docker).

- tools/bazel/bd_releases.bzl: a module extension that reads
  scripts/migration-test/release-catalog.json and declares one repository per
  catalog release with a linux_amd64 asset digest (bd_release_<version>,
  verified against the catalog's sha256), behind the @bd_releases hub
  (@bd_releases//:<version>, plus versions.bzl). Adding a release is a
  catalog change only; nothing downloads until a test declares one.
- //tests/regression:regression_test: the suite's files build under
  `regression || integration`, so gazelle generates the target. It runs the
  injected non-race bd_for_tests (BEADS_TEST_BD_BINARY) against
  @bd_releases//:v0.49.6 (BD_REGRESSION_BASELINE_BIN), both over a hermetic
  dolt sql-server (BEADS_TEST_DOLT_SERVER=local, required), in 8 shards.
  TestMain checks the baseline reports BASELINE_VERSION, so the label and the
  file cannot drift. Tagged dolt-server-cmd: bazel.yml's bazel-cmd-dolt lane,
  which pr.yml's gate requires, runs it remotely; test result caching stands
  in for the old path detector.
- A plain `go test -tags=integration ./...` (nightly) compiles the files but
  skips the suite; only -tags=regression (make test-regression) or Bazel
  runs it.
- regression.yml, main.yml's warm-up compile for it and the policy tests that
  pinned its jobs are removed.

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 01:41:12 +00:00
Julian Knutsen
1137aeb70d
ci(bazel): embedded-Dolt tier 20/5 → 50/15 duration-balanced Bazel shards (F1) (#7156)
* ci(bazel): embedded-Dolt tier 20/5 -> 40/14 duration-balanced shards (F1)

Give the Bazel-only bazel-embedded job its own duration-balanced manifest
blocks for //cmd/bd:bd_embedded_test (20 -> 40 shards) and
//internal/storage/embeddeddolt:embeddeddolt_embedded_test (5 -> 14
shards), decoupled from PR Risk's/main.yml's legacy frozen 20/5-shard
fork/push jobs, mirroring F2's bd_proxied_test precedent.

- Measured every TestEmbedded* / embeddeddolt test's wall time in
  isolation; split 21 cmd-tier and 1 storage-tier single top-level test
  over 180s into disjoint sub-tests (3 irreducible exceptions left:
  TestEmbeddedUpdateConcurrent 475s, TestEmbeddedCloseConcurrent 308s,
  TestLargeBatchApplyStatementCounts712_Embedded 261s).
- New scripts/ci/gen_embedded_{cmd,storage}_shard_manifest.py +
  _embedded_shard_manifest_lib.py generate/check duration-balanced
  manifest blocks (LPT packing, incremental --write/--repack, exact-once
  --check), chosen at N=40/M=14 where the heaviest shard reaches the
  irreducible-test floor.
- Fixed 18 stale legacy 20-shard cmd manifest entries (and 1 storage
  entry) left over from earlier test splits, which would have hard-failed
  every shard of PR Risk's real test-embedded-cmd jobs on their next run.
- New scripts/embedded_shard_count_test.go policy tests tie the
  Bazel-only block's shard count to bazel.yml's check_shard_coverage.py
  argument and catch generator staleness; generalized
  TestBazelRetiredLanesCheckListedTestsRan's live-shard-count dispatch
  from bd_proxied_test-only to a map covering both embedded targets;
  removed TestBazelEmbeddedJobMirrorsEmbeddedTier's now-invalid
  BUILD.bazel-shard-count-equals-PR-Risk-matrix assertion.
- Verified: go test ./scripts/..., bazel test //scripts:scripts_test,
  actionlint, make ci-pr-policy, make bazel-sync-check all pass; full
  local bazel test of both targets at 40/14 shards passes 2/2; mutation
  testing confirms each new/changed policy test fails exactly when it
  should.

See ~/beads-bazel-plan/f1/impl-report.md for full detail.

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

* fix(embedded-dolt): skip 712-item statement-count assertion under -race (F1)

TestLargeBatchApplyStatementCounts712_Embedded genuinely costs ~260-300s
under -race (confirmed by solo re-measurement: 298.60s) -- 14014 real SQL
statement round-trips through the race-instrumented in-process Dolt engine,
not an artifact and not splittable (one indivisible ApplyBatchInTx
transaction). It was the storage tier's single-test floor for CI shard
packing.

Apply the exact precedent TestLargeBatchApplyWallClock_Embedded already set
for its 1000-item shape: skip this assertion under raceEnabled (the cost is
race-instrumentation overhead on the Dolt engine's own internal
goroutine/lock machinery, not this test's own logic) and extend nightly.yml's
"Embedded Dolt batch-apply suite (non-race)" step's -run regex so the full
pinned 14014-statement baseline still runs, non-race, every night. Verified
directly: under -race the assertion now skips in 0.00s; without -race it
still runs and asserts Total=14015 (within the existing +/-2 tolerance) in
36.76s.

Updates scripts/ci_workflow_test.go's
TestNightlyFullTestRunsEmbeddedDoltBatchApplySuite to match the extended
regex.

Storage tier's new single-test ceiling under the per-PR -race lane drops
from ~260.7s to 152.38s (TestBatchApplyContract).

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

* ci(bazel): correct cmd-tier long-pole durations, re-pack embedded manifolds (F1)

Investigated coordinator item 2 (single-test long poles): TestEmbeddedUpdateConcurrent
(recorded 475.39s) and TestEmbeddedCloseConcurrent (recorded 308.06s), plus
the two other >180s cmd-tier entries from the same capture
(TestEmbeddedInitA 196.94s, TestEmbeddedEpicCloseEligibleReason 192.47s).

Root cause: NOT host contention, NOT backoff/retry sleeps (bdRunWithFlockRetry
contributes negligibly), NOT race-instrumented-subprocess overhead alone.
These numbers were captured via `bazel --nohome_rc test --config=embedded`
with the then-current 20-shard legacy manifest (~10-11 tests/shard) and
`-test.parallel=4`. Go's t.Parallel() starts each parallel test's elapsed
clock when its function is invoked, before the Parallel() call blocks it
waiting for a free one-of-4 slot -- so a test queued behind several other
heavy shard-mates has that queueing wait baked into its own recorded
`--- PASS: TestX (Ys)` time. This is shard-composition-dependent scheduling
delay, not a cost intrinsic to the test.

Confirmed two ways in an isolated clone (not this worktree, per the
no-plain-go-test-from-a-beads-checkout rule):
- Solo (no rivals at all): 151.83s / 106.48s / 63.58s / 66.08s.
- All four together with the real -race -test.parallel=4 flags and exactly
  4 tests requested (so nobody queues -- parallel slots == test count):
  141.34s / 113.80s / 69.79s / 74.63s.
Both agree closely and both are far below the capture-time numbers.

F1's LPT packer already isolates the heaviest tests into shards with few or
no other heavy rivals (TestEmbeddedUpdateConcurrent lands alone in its own
40-shard-block shard), so under the new manifest these tests see little to
no queueing delay in real CI. None of the four needed splitting, parallel
subtests, or raceEnabled-scaled N: once correctly measured, none exceeds the
180s single-test guideline (new corrected weights: 155.0 / 115.0 / 72.0 /
77.0s). Corrected scripts/ci/embedded_cmd_test_durations.json accordingly
(with a doc-comment explaining the methodology and both confirmations) and
re-packed the 40-shard Bazel-only block (--repack --write); --check passes
(exact-once coverage of all 241 discovered tests). The frozen legacy 20-shard
block is untouched and independently re-verified exact-once by simulating
embedded-test-shard.sh across all 20 shards (241/241 tests, no
duplicates/misses/errors).

New cmd-tier single-test ceiling: 179.47s (TestEmbeddedCloseAlreadyClosed,
likely itself somewhat inflated by the same mechanism but already under the
180s line as recorded, so no action needed).

Also updates scripts/ci/embedded_storage_test_durations.json: the prior
commit's raceEnabled-skip for TestLargeBatchApplyStatementCounts712_Embedded
means it now costs ~0s in the per-PR -race lane bazel-embedded actually
packs for (not its real ~260-300s non-race cost, which nightly.yml still
exercises) -- weight set to 1.0 with a doc comment tying it to the skip in
large_batch_apply_measure_test.go. Re-packed the 14-shard Bazel-only block
accordingly; --check passes (exact-once coverage of all 387 discovered
tests, excluding TestMain/TestConformance per that file's existing
convention). The frozen legacy 5-shard block is untouched and independently
re-verified exact-once via embedded-storage-test-shard.sh simulation
(388/388 tests, no duplicates/misses/errors).

Verification: go test ./scripts/... (includes the nightly.yml policy test),
make ci-pr-policy, make bazel-sync-check, actionlint all pass. Real local
`bazel --nohome_rc test --config=embedded //cmd/bd:bd_embedded_test
//internal/storage/embeddeddolt:embeddeddolt_embedded_test`
(--local_test_jobs=8, both targets together, on a shared/noisy sandbox host)
passes both targets; per-shard wall time from each shard's test.xml: cmd/bd
max 218.9s (shard 23/40, min 20.6s), storage max 251.1s (shard 5/14, min
0.98s) -- down from the prior oversubscribed sweep's 783.41s / 351.94s and
well under the single-test-floor-based ~475s projection this slice started
from. Projected tier lane time (max of the two targets, real dedicated CI
runners should do at least this well): ~251s, under the 5-minute target.

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

* test(embedded): un-vacuous TestEmbeddedDepB edges, split epic-close test, trim concurrency stress N (F1 review)

Coordinator review follow-ups on the F1 embedded-Dolt resharding slice:

- TestEmbeddedDepB (one of TestEmbeddedDep's two CI-speed split halves) was
  asserting its tree_* subtests against an edgeless graph, passing
  vacuously; restores the same parent-child/blocks edges TestEmbeddedDepA
  builds so those subtests exercise real multi-node traversal (review S2).
- TestEmbeddedEpicCloseEligibleReason split into
  TestEmbeddedEpicCloseEligibleReasonFlag/...Output for CI shard balance,
  matching the project's established single-concern split pattern.
- TestEmbeddedUpdateConcurrent/TestEmbeddedCloseConcurrent's
  issuesPerWorker reduced 5->2: under real concurrent-shard-load
  measurement these were genuine (not queueing-artifact) serialized-write
  costs; 2 preserves every invariant the test checks (duplicate-ID
  detection across all workers, one non-decreasing-list-count check per
  worker) at a fraction of the serialized work.
- large712ShapeName: the 712-shape's race skip and its zero-match guard now
  share one named constant instead of two independent literal shape-name
  strings, so a future rename of the shape can't silently skip the pinned
  statement-count assertion under race (review N2).
- Comment-only fixes (review N5) in files referencing test names since
  renamed/split by this slice's earlier work: close_proxied_integration_test.go,
  graph_apply_test.go, storage_class_proxied_integration_test.go,
  tests/regression/discovery_test.go, plus doc-comment path cleanups (N1:
  drop unverified ~/beads-bazel-plan paths/bead ids in favor of the
  committed duration JSON files and engdocs/TESTING.md).

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

* ci(bazel): re-derive embedded-Dolt durations under concurrent load; cap cmd shards at Bazel's 50-shard limit (F1 round 2)

Coordinator review required re-deriving every per-test duration weight from
a single, consistent, CI-realistic measurement (all shards running
concurrently, -test.parallel=4, race-enabled) instead of the prior pass's
mix of crowded-shard captures and solo/4-together spot-corrections, and
required measuring per-shard wall time via BEP testAttemptDuration rather
than a shard's outer test.xml <testsuites time> (which can include a
different, already-finished shard-mate's setup/teardown).

- scripts/ci/embedded_cmd_test_durations.json (242 tests) and
  scripts/ci/embedded_storage_test_durations.json (387 tests) rewritten in
  full from one consistent sweep. Every entry is now a fresh measurement;
  none is a carried-over capture-time value or an unverified estimate. Both
  files' _comment blocks retract the earlier "queueing delay baked into a
  test's own reported elapsed time" theory (testing.go's (*T).Parallel does
  not add wait time to a blocked test's own clock) and document the real
  methodology.
- Only one cmd-tier test remains over 200s (TestEmbeddedListFiltering,
  239.70s), already under the ~240s ceiling; no further top-level splits
  were needed this round.
- New finding: Bazel hard-caps shard_count at 50 per sh_test-like rule
  ("Having more than 50 shards is indicative of poor test organization";
  a native analysis-time limit, not configurable). The previous 88-shard
  plan for //cmd/bd:bd_embedded_test (chosen as the LPT-packed floor before
  this limit was discovered) is reverted to 50, Bazel's real ceiling.
  Repacking the fresh weights at 50 shards gives a heaviest shard of
  409.6s -- above the single-test floor of 239.7s, because 50 bins is not
  enough headroom over the suite's ~20145 measured test-seconds to flatten
  every bin to that floor. This makes the <=5 min lane target unreachable
  for the cmd tier via resharding alone within Bazel's native per-rule
  limit; see ~/beads-bazel-plan/f1/impl-report.md section 3c for the full
  writeup and the two remaining levers (suite-wide speedups or a
  multi-Bazel-rule split), neither attempted in this slice.
- internal/storage/embeddeddolt gets 15 Bazel-only shards (unaffected by
  the 50-shard cap): LPT-packed heaviest shard 225.3s, within target.
- cmd/bd/BUILD.bazel, internal/storage/embeddeddolt/BUILD.bazel,
  .github/workflows/bazel.yml, engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md,
  scripts/embedded_shard_count_test.go, scripts/pr_risk_bazel_coverage_test.go,
  scripts/ci/gen_embedded_cmd_shard_manifest.py updated to the corrected
  50/15 shard counts (and, for the generator, N3: --write without an
  explicit total_shards now errors instead of silently regenerating the
  frozen legacy 20-shard block).
- .github/scripts/embedded-{cmd,storage}-test-shards.txt: re-packed
  Bazel-only blocks at 50/15; frozen legacy 20/5 blocks untouched except for
  N5 fixes to stale entries left by this slice's earlier test splits
  (TestShardScriptsListOnlyRealTests catches this class of bug; both
  legacy blocks reconfirmed exact-once).
- .github/workflows/nightly.yml / scripts/ci_workflow_test.go (N4): the
  embedded-dolt batch-apply nightly step now runs with `if: ${{
  !cancelled() }}` and its own explicit `-timeout 20m`, independent of the
  job-level timeout, with both halves now asserted by
  TestNightlyFullTestRunsEmbeddedDoltBatchApplySuite.

Verified: gofmt -l clean, go vet ./scripts/... clean, go test ./scripts/...
green, both generators' --check pass at 50/15 (and legacy 20/5 remain
exact-once via the frozen-block invariant).

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

* test(ci): rename embedded manifest staleness tests out of the ^TestEmbedded skip

The allowlisted go-test leg runs with -skip ^TestEmbedded, so tests named
TestEmbedded*ShardManifestGeneratorNotStale never ran there and the leg
failed with "matched no test that ran".

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

---------

Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-03 21:30:03 -07:00
Isis Anisoptera
45a116d1a7
fix(update): fence unforced --notes overwrites behind --force across all surfaces (#5946)
* fix(update): fence unforced --notes overwrites behind --force across all surfaces

bd update --notes silently replaced existing notes, destroying handoff
history. The contract now refuses an unforced overwrite of non-empty
notes with ErrNotesOverwrite (409 notes_overwrite_refused over HTTP,
force_notes_overwrite to override), enforced inside the mutation
transaction on both the dolt and uow backends, for single updates and
batch apply alike. CAS guards keep precedence: a stale
--if-assignee/--if-status still surfaces as the exit-13 mismatch, on
both backends, before the fence speaks.

CLI: --force and --if-assignee are no longer mutually exclusive (that
exclusion made overwriting under a guard impossible); both update
routes translate the fence's sentinel into the same actionable advice
(--force to overwrite, --append-notes to preserve history), and the
post---force warning is worded as an audit statement. The shipped
plugin skill docs and bd note help now prescribe --append-notes for
handoffs instead of the newly fenced bare --notes.

The fence is the single enforcement point: no client-side pre-read
copies of the rule. Conformance contracts, unit tests for
AuthorizeNotesOverwrite, and embedded/proxied/httpapi regression
coverage included.

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

* fix(update): exempt explicit clears from the notes fence; share its predicate

CI surfaced three gaps in the fence's reach:

- Clearing notes (--notes "" / patch.notes: "") was refused, diverging
  from every sibling text field's clear and from the backend behavior
  contracts. The fence now targets only its actual footgun — replacing
  non-empty notes with different non-empty content — via a single shared
  predicate, issueops.NotesReplacement, used by both the contract's
  AuthorizeNotesOverwrite and the CLI's warning path, so the two can no
  longer drift. Prose updated to match everywhere the rule is stated
  (ErrNotesOverwrite, ForceNotesOverwrite, OpenAPI spec + regenerated
  types).
- The revision-CAS integration tests' incidental concurrent writes now
  patch design instead of notes, so they no longer depend on notes-fence
  semantics at all.
- The historical-upgrade harness deliberately replaces fixture notes and
  asserts the new value; its two bd update --notes calls now pass
  --force.

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

* fix(update): address review — changelog BREAKING entry, problem.go doc block, close-policy-under-guard test

Review follow-ups on #5946 (bee-ghosttrack, MERGE-AFTER-FIXES):

- CHANGELOG: BREAKING entry under [Unreleased] ### Changed for the notes
  fence on both wires (CLI exit 1, HTTP 409 notes_overwrite_refused), with
  the --force / --append-notes migration line. It also names the two
  deliberate edges: the explicit-clear exemption, and --force widening to
  the close-policy half under --if-assignee now that the flag pair is legal.
- problem.go: CodeNotesOverwrite's comment had landed inside
  CodeDependencyCycle's doc block; each const now sits under its own docs.
- assign_fence_embedded_test.go: pin the previously untested close-policy
  half of --force under --if-assignee (refused unforced, authorized forced).

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

* test(update): align TestWarnNotesReplacement with the post-fence warning copy

The test landed on main after this branch was cut and pins the pre-fence
wording, where the warning fired on any unforced overwrite. Since the fence,
an unforced overwrite is refused outright and warnNotesReplacement fires only
after a forced one — the audit trail for a habitual --force — so the copy it
pins is now '--force replaced existing notes'.

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

* docs(import): record bd import's notes-fence exemption as by-design (GH#6190)

Import consults none of the per-field live-state fences — notes overwrite,
live-claim reassign, close policy — and that is the intended shape, not an
omission: its contract is wholesale row replacement, guarded by its own
staleness check (only strictly-newer rows rewrite local state, --allow-stale
is the single deliberate-overwrite opt-in) and reported field-by-field in
updated_issues. Named in AuthorizeNotesOverwrite's enforcement-boundary
comment and in bd import's help; the published CLI docs pick the help text
up at the next release pin bump.

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

* fix(update): refuse --notes "" and add --clear-notes; stop --notes help reading as additive

GH#6021: an empty --notes wiped the whole notes field at exit 0 behind the
same ✓ Updated receipt as a successful write — and the empty string is
exactly what a dead command substitution collapses to. The empty value is
now refused on both CLI routes (the accident and the deliberate clear are
the same bytes at the flag layer), and the deliberate clear gets its own
verb, --clear-notes, mutually exclusive with --notes/--append-notes. A verb
rather than the proposed --allow-empty-notes opt-in: what needs authorizing
is an intent, not an input path — --allow-empty-description unblocks
stdin/file plumbing, which notes does not have — and an opt-in passed
habitually would silently disarm the guard while a habitual --clear-notes
fails loudly. --force does not bypass the refusal; the fence's clear
exemption stands, so the verb alone authorizes the erase. The HTTP API is
unchanged: patch.notes "" still clears.

GH#6272: bd update --help called --notes "Additional notes" and the prime
text said "Add supplementary notes" — both read as appending, so agents
following the injected guidance faithfully clobbered prior context. The
update help now names the operation with the --append-notes contrast at the
point of use, the shared/create help is field-named like --description and
--design, and the prime line points at bd update --append-notes.

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

* fix(bazel): enumerate the PR-new files in cmd/bd and issueops srcs

The base added cmd/bd/BUILD.bazel and internal/storage/issueops/BUILD.bazel
with EXPLICIT srcs lists after this branch was cut, so the three files this
PR adds were never enumerated:

  cmd/bd/update_notes_guard.go        (go_library bd_lib)
  cmd/bd/update_notes_guard_test.go   (go_test bd_test)
  internal/storage/issueops/aggregate_authorize_notes_test.go (go_test)

The go_library omission is a hard build break, not a silent skip:
update.go:215,220 and update_input.go:106,111 are enumerated and call
validateNotesUpdate / clearNotesRequested, so //cmd/bd:bd_lib compiles the
callers without the callee. bazel.yml arms unconditionally for fork PRs
(head.repo.fork == true) and builds //cmd/bd:bd + //cmd/bd:bd_test, so this
reds the lane. make bazel-sync-check cannot see it -- go_srcs.py only
validates the glob-based go_srcs filegroup, never the rule srcs lists.

Generated by make bazel-sync (gazelle), not hand-edited, so the workflow's
own BUILD-files-in-sync drift step agrees byte-for-byte.

* fix(notes): name --clear-notes in bd note's rm guidance, correct the fence boundary comment, pin both request-shape rules

Takes all three non-gating minors from the review. No behavior change: two
prose fixes and two test cases.

1. cmd/bd/note.go's rm|remove|delete branch advised
   `bd update <id> --notes "text" --force` under "To change or clear notes",
   but clearing through --notes is exactly what this PR made impossible --
   validateNotesUpdate refuses an empty value unconditionally and --force does
   not reach it. The branch now names both verbs separately: --notes --force to
   replace, --clear-notes to clear. The edit and update branches speak only of
   replacing and were already correct, so they are untouched.

2. aggregate.go's enforcement-boundary comment claimed the UpdateIssueInTx
   funnel's "one notes-replacing caller is bd edit". Under this PR's own
   NotesReplacement predicate there are at least four more (bd note's
   read-combine-write, bd defer --reason, bd rename and delete-tombstoning's
   mechanical ID rewrites, bd compact's clears). The exemption is still sound --
   every funnel writer derives its new value from the current notes -- so the
   comment now names those CLASSES instead of a single caller, which is the
   claim that is actually true and that a future fence auditor can check.

3. Both branches this PR adds to ValidateUpdateRequest were uncovered: the
   batch apply leg reaches them here and nowhere else, while the single-issue
   HTTP handler's own pre-check returns before storage. Added a sibling table
   (the existing one varies only the patch; these two rules are properties of
   the REQUEST) with a case each. Mutation-checked, disjoint: neutralizing the
   force-without-notes branch reds only the first case, neutralizing the
   notes+append branch reds only the second, and the pre-existing
   canonical-fields table stays green under both.

Not an amend of 5ffcc9c16c: that commit's message states it was generated by
make bazel-sync and not hand-edited, so folding hand-written Go into it would
falsify the claim its own BUILD-files-in-sync argument rests on. No new files,
so the srcs lists it repaired stay correct.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
2026-10-01 05:02:40 -07:00
postoso
de8567eaae
fix(cli): --until, --defer and --due rejections name the supported unit set (#5718)
* fix(cli): --until rejection names the supported unit set

bd defer --until "+3mo" failed with: invalid --until format "+3mo".
Examples: +1h, tomorrow, next monday, 2025-01-15

The compact-duration parser accepts h, d, w, m and y, so "+3w" and "+3m"
both work. The message jumped from a single hours example straight to
absolute dates and never stated the unit set, so a caller who wanted three
months had to find "+3m" by trying units one at a time.

Months were already supported, spelled "+3m" (internal/timeparsing
applyDuration case "m" is AddDate(0, amount, 0)). This is a message change
only, parsing behavior is untouched.

The regression test pins the message to the parser it describes: every unit
the hint names must parse, and the real failure path must put the unit set
on stderr rather than only the constant being well formed.

* fix(cli): share the --until unit hint with --defer and --due

bd defer --until was not the only door onto ParseRelativeTime. bd create
--defer, bd update --defer and both --due flags still printed "Examples:
+1h, tomorrow, next monday, 2025-01-15", which names one example per
category and leaves a caller who typed +3mo guessing which units exist.

Reuse deferUntilFormatHint at the eight remaining sites, covering the
direct create and update paths and their proxied-input twins. Message
only, the parser is untouched.

A source guard pins the uniformity, because a site that re-inlines its own
example list still passes every call-level test. The proxied-input paths
also get a behavioural test that the unit set reaches the caller.

* fix(cli): name min=minutes in the shared relative-time hint

Adoption review iteration 1 found the shared hint under-reports the parser
by exactly one unit. internal/timeparsing accepts `min|[hdwmy]`
(parser.go:22) and its doc comment spells out `m = months (NOT minutes;
use "min" for minutes)`, but deferUntilFormatHint named only h/d/w/m/y --
so all nine rejection messages told a caller that minutes are unsupported,
defeating the premise the PR is built on. Measured at this head: +30min,
-15min and 90min parse; +3mo and +30mins do not.

The gap is rebase-introduced, not contributor error: min arrived on main in
eb1689cb9d (GH#6609/#6629) after the contributor's merge base. Nothing
could red on it, because the PR's own guard test hardcoded the same
five-unit list in three places, so the constant and its enforcement drifted
together.

Add min=minutes to the constant and to all three lists, and show +30min
beside +3m so the m-vs-min boundary the message exists to explain is
visible in the message itself. Reverting min out of the constant alone reds
TestDeferUntilFormatHintCoversCompactUnits,
TestDeferUntilRejectionNamesUnitSet and all five
TestGatherInputRejectionsNameUnitSet subtests, while
TestRelativeTimeRejectionsShareTheHint stays green -- it pins that sites
reference the constant, not what the constant says.

Two non-gating items from the same review, taken because they are adjacent:

- The four update sites use HandleErrorRespectJSON, whose --json branch
  writes to stdout inside a JSON error payload instead of to stderr. The
  existing subtests pin jsonOutput = false, so that branch carried the
  ~190-char hint untested. A new subtest flips jsonOutput and asserts the
  unit set in the decoded payload; decoding is required because
  json.Encoder HTML-escapes the angle brackets in "[+-]?<n><unit>". Making
  HandleErrorRespectJSON ignore jsonOutput reds only the new subtest and
  leaves the four stderr subtests green, which is what proves it is not a
  duplicate of them.
- Four pins strings in tests/oracle-a/harness/scenarios/enumerated.json
  quoted the message text this PR replaces. pins is documentation the
  runner ignores (harness/PROVENANCE.md:13), so nothing was broken, only
  stale; refreshed in place. Their stale update.go line references are left
  byte-intact deliberately -- those line numbers are identical at the merge
  base and at HEAD, so that staleness is base-owned, not this PR's.

Also records two edges the review raised on the PR's own mechanism: the
sign is optional, so the notation is now [+-]?<n><unit> (measured), and the
uniformity guard matches per line, which is now stated in its comment
rather than left for the next reader to rediscover.

Deliberately left out: the flag --help usage strings (create.go:955,
defer.go:156, update.go:1002) still carry the old bare example lists. They
feed the generated-and-pinned CLI reference, so aligning them owes the
docs-regen check and belongs in a follow-up. deferUntilFormatHint has no
help-string consumer today (censused: nine rejection sites and nothing
else), so this commit owes no CLI-docs regen.

Also carries the rebase gate's bazel repair, unchanged from this commit's
previous revision:

    chore(bazel): enumerate defer_until_hint_test.go in cmd/bd go_test

    gazelle output for the PR's new untagged test file. cmd/bd/BUILD.bazel
    enumerates go_test srcs explicitly (667 files at the merge base) and the
    enumeration is exhaustive for untagged tests -- the only 4 unenumerated
    _test.go files on disk all carry build tags. Without this row the target
    builds green while running none of the PR's 4 new tests (-test.list: 0 of
    4 unrepaired, 4 of 4 repaired), and bazel.yml's BUILD-sync step reds on
    the post-'make bazel-sync' git diff.

    The //internal/timeparsing deps row is gazelle canonicalization, not a
    compile fix: bd_test embeds bd_lib, whose deps already carry it.

The new subtest adds no BUILD row: encoding/json is stdlib, and a
re-run of make bazel-sync after these edits leaves the tree clean.

---------

Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
2026-10-01 01:29:58 -07:00
Julian Knutsen
671715bb8b
test(testutil): opt-in local dolt sql-server backend for Dolt-backed tests (#6891)
* test(testutil): local dolt sql-server backend behind the Dolt test server API

Add a second backend to internal/testutil behind the unchanged container
API (EnsureDoltContainerForTestMain, RequireDoltContainer,
StartIsolatedDoltContainer[Handle], NewContainerProvider,
RestartSharedDoltContainer, DoltContainerCrashed, IsolatedDoltContainer
Stop/Start/CurrentPort/Exec): the test process spawns `dolt sql-server`
from the pinned dolt CLI instead of a dolthub/dolt-sql-server container.

- BEADS_TEST_DOLT_SERVER=local|container selects it; unset keeps plain
  `go test` on the container (no behavior change) and makes `bazel test`
  use the local backend. Other values fail instead of guessing.
- The CLI (BEADS_TEST_DOLT_BINARY, else PATH) must be the image's version.
- Provisioned like testcontainers' dolt module: root@% (DOLT_ROOT_HOST=%),
  database beads_test, user test/test. Clean env, TZ=UTC, GOMAXPROCS=4,
  own dolt global config with metrics and the version check disabled.
- Loopback port picked here (dolt rejects -P 0), never 3307, retried when
  another process wins the port; readiness requires the server's own
  "Server ready" line plus a bounded ping, so a foreign listener on a
  contested port cannot pass for it.
- State lives under the TMPDIR captured at package init, outside every
  PinSuiteTempRoot root, so suite leak sweeps never see it. The server
  stays in the test's process group (bazel's group kill reaps it) with
  Pdeathsig on Linux.
- BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 now also makes every TestMain that
  only warned about an unavailable server exit 1
  (DoltUnavailableForTestMain), plus the shared proxied harness.
- dolt_benchmark_purge_test finds .dolt_dropped_databases relative to
  Exec's working directory (the data dir in both backends).
- TestDoltServerFingerprint checks each available backend against one
  checked-in fingerprint (users, grants, databases, server variables);
  local-backend tests cover the bind-race retry, 3307, crash detection,
  Stop/Start, Exec cwd, state outside the suite root, and teardown.
- Bazel: the requires-docker variants pin BEADS_TEST_DOLT_SERVER=container
  so the docker lane stays the container A/B control; the test wrapper's
  dolt global config disables metrics and the version check.

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

* fix(testutil): select the local Dolt test server only when asked for

Under Bazel an unset BEADS_TEST_DOLT_SERVER used to mean the local
backend, so every non-ci `bazel test` started servers for Dolt suites no
lane runs with one (//internal/storage/dolt:dolt_test went from a 16 s
skip to a timeout). Unset now means container everywhere: in a Bazel
action without docker that is the pre-existing warn+skip, and only a
target's env or --test_env=BEADS_TEST_DOLT_SERVER=local starts local
servers. Plain `go test` is unchanged.

The docker variants keep their container pin: a rule env beats
--test_env, so a local-backend invocation cannot flip the docker lane.

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

* fix(testutil): harden the local Dolt test server's host footprint

- DOLT_DISABLE_EVENT_FLUSH=1 for every dolt the backend runs (and in the
  Bazel test wrapper): the metrics/versioncheck keys stop network calls
  but not the detached `dolt send-metrics` child each command forks on
  exit, which re-created the version probe's removed HOME (one leaked
  bdt-doltver-* per test process) and raced terminate's RemoveAll.
- Every bdt-dolt-*/bdt-doltver-* root records its owner PID, and the
  first use of the backend in a process removes this user's roots whose
  owner is dead (the SweepDeadSuiteRoots rule; a copy, since doltserver's
  tests import testutil). A panicking, timed-out or killed test binary,
  or a package whose TestMain never terminates the singleton, no longer
  leaks a 40-100 MB state dir per run.
- secure_file_priv is the state root's sfp/ directory, set through a
  per-launch --config file (dolt ignores other flags with --config): a
  local server runs as the test user on the host with a passwordless
  root@%, so LOAD_FILE / INTO OUTFILE must not reach the user's files.
  The fingerprint treats that path as the container's "".
- Fingerprint: character_set_server, collation_server,
  max_allowed_packet, transaction_isolation, lower_case_table_names,
  lower_case_file_system (compared on Linux only: APFS reports ON),
  wait_timeout, innodb_lock_wait_timeout.
- The local backend's own tests skip off Linux (no Pdeathsig, so a
  killed test binary would orphan servers on the macOS runners) unless
  BEADS_TEST_DOLT_SERVER=local asks for them.

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

* ci: compare the container and local Dolt test servers in the domain+uow job

TestDoltServerFingerprint's container half never ran in CI: only the
test-domain-uow job has both the pulled image and the pinned dolt CLI,
and it never ran ./internal/testutil. Run the fingerprint there (with
BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 so the container half cannot skip)
so an image bump that drifts the container side fails in the PR.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 04:06:49 -07:00
postoso
1c14b4c566
docs(dep): say what --no-cycle-check skips on a single-edge add (#6688)
On a single-edge dep add (positional or --blocks), --no-cycle-check has
never skipped the per-edge cycle probe; it only suppresses the post-add
whole-graph warning. Only bulk --file adds trade the per-edge probe away.
The flag descriptions and the single-edge example said otherwise, as did
the purpose/pins notes on the Oracle A catalog scenario
dep_cycles_detected_via_no_cycle_check. Update all four to match what
the binary does. No behavior change.

Co-authored-by: postoso <postoso@users.noreply.github.com>
2026-09-26 06:43:14 -07:00
Harry Miller
0b9e644ba9
fix(label): report a no-op label edit instead of claiming it (#5988) (#6742)
* fix(label): report a no-op label edit instead of claiming it (#5988)

`bd label remove <id> x` printed "✓ Removed label 'x' from <id>" (JSON
status "removed") for a label the issue never had, and `bd label add`
printed "✓ Added label" for one it already had, so a real edit could not
be told from a no-op.

Root cause: applyLabelEdit discarded the issueops.UpdateResult of each
lifecycle.Update, and reportLabelEdit printed the operation for every
(issue, label) pair unconditionally. The storage side was already right:
ApplyLabelPatch compares the target set with the existing one and writes
nothing (no label row, no event, no Dolt commit) when they are equal.

Fix: keep the result and derive a per-label outcome. For a single label,
UpdateResult.Changed answers it exactly. A multi-label edit that changed
something reads the issue's labels before the update (Reader.Get, only in
that case) to split the labels that moved from those that did not. A label
left as it was is now reported as "• Label 'x' was not on <id>" /
"• <id> already has label 'x'" (the "•" accent no-op glyph `bd provenance`
already uses), with JSON status "unchanged"; the other JSON fields and the
added/removed values for real edits are unchanged. Both the direct and the
proxied-server routes go through applyLabelEdit, so they report alike.

The exit code is deliberately still 0: a no-op edit is not an error, and
making it one would break idempotent callers (the reporter advises against
it too).

Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(regression): mark BUG-70/71 fixed and assert the no-op output (#6742 review)

TestDiscovery_LabelRemoveNonexistentSilentSuccess and
TestDiscovery_LabelAddDuplicateReportsAdded only checked the exit code and
label count, so they kept flagging after the fix (a no-op still exits 0 by
design). They now assert the fixed output: no "Removed" / "Added" claim,
and the "was not on" / "already has label" line. They follow the
FIXED-and-kept-as-a-lock convention of TestDiscovery_LabelPatternFilterDeadCode.
Both fail against the unfixed label.go and pass with it. DISCOVERY.md
marks BUG-70 and BUG-71 as FIX PR / PR OPEN (#6742).

Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(label): pin the divergent multi-issue label report (#6742 review)

Maintainer review fixups for PR #6742. No production behavior change.

Every subtest the PR added edits exactly one issue, so nothing pinned the
shape the diff actually rewrote: the old code hoisted labelDesc out of the id
loop and printed one identical line per issue, while the new code appends a
labelEditOutcome per issue derived from that issue's own UpdateResult.Changed.
label_edit_divergent_multi_issue covers it — two issues, the label on only one,
one `bd label add A B shared` — asserting the two JSON rows (added for one
issue_id, unchanged for the other) and the two text lines, each naming its own
id. Verified non-vacuous rather than just green: with the outcome hoisted back
out of the id loop (the first result reused for every id) this is the ONLY one
of the 28 subtests that fails — the four new no-op subtests and
label_edit_mixed_reports_each_label all still pass, which is exactly the
refactor hazard the review named.

applyLabelEdit now records what the multi-label pre-edit read cannot promise:
it is taken outside the write transaction, so per-label attribution is
best-effort under a concurrent edit. The stored labels, the JSON shape and the
exit code stay correct regardless, because ApplyLabelPatch recomputes the
target set from current.Labels inside the write; a single-label edit is immune
by construction. The BatchApplier shape already named above it closes the
window structurally.

The two reworked discovery tests no longer call themselves a "regression lock".
The file is `//go:build regression && discovery` and no CI lane passes the
discovery tag (regression.yml runs -tags=regression,gms_pure_go), so the CI
lock for this fix is TestEmbeddedLabel/TestProxiedServerLabel in cmd/bd, and
the comments now say so.

Validation: TestEmbeddedLabel 28/28 green under BEADS_TEST_EMBEDDED_DOLT=1
(57s), go vet -tags "regression discovery" ./tests/regression/... clean,
go vet ./cmd/bd/ clean, gofmt clean, git diff --check clean.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
2026-09-26 04:29:06 -07:00
Jim Wordelman
42483de468
fix: TestMain teardown was dead code after os.Exit — 101 dolt containers leaked over 6 days (#5876)
* test(feat): red — Three TestMains defer TerminateDoltContainer then os.Exit in the same function — teardown is dead code, 101 dolt containers leaked over 6 days and exhausted swap (refs be-5kkk6)

* fix(feat): green — Three TestMains defer TerminateDoltContainer then os.Exit in the same function — teardown is dead code, 101 dolt containers leaked over 6 days and exhausted swap (refs be-5kkk6)

* chore(release-gates): add be-r3ysh gate evaluation (PASS 7/7)

refs be-r3ysh, be-43oyc, be-5kkk6
2026-08-20 06:06:32 -07:00
Vishnu J
cff6bac4ed
fix(ui): stop using blocked ● for priority in CLI output (#5511)
Priority used the filled circle also mapped to status-blocked, so agents
misread ready work as blocked (GH#4996). Render P-labels only; document
the convention for agents; keep ● for blocked status alone.

Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
2026-08-10 06:19:51 -07:00
Julian Knutsen
8c7db45c8b
fix(show): expose guarded-write revision in JSON (#5353)
* fix(show): expose guarded-write revision in JSON (bd-bwa7n)

Project RowVersion only at the bd show CLI edge so guarded subprocess clients receive the current opaque token without changing generic Issue, JSONL, or HTTP serialization. This preserves main's object-model boundary while restoring the show contract established by PR #4682.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot

* fix(show): resolve revision CLI/HTTP parity + emit legacy-zero token (bd-bwa7n)

Maintainer adoption fixup for PR #5353 (adopt-pr): pre-review CI normalization
plus the review-loop resolution of the CLI/HTTP parity decision that pre-review
deliberately deferred.

PR #5353 exposes the guarded-write revision (the row_lock optimistic-concurrency
token) in `bd show --json` via the CLI-edge DTO. That token is a per-write random
int64, so several oracles that pin bd's JSON shape needed to learn about it.

Pre-review CI normalization (mechanical volatile-token gaps):

- Contract corpus golden (cmd/bd/protocol): CanonicalizeJSON did not scrub the
  new field, so the show blob diffed on the random value and the double-run
  determinism check failed. Add a volatileValueKeys scrub for `revision` (pin the
  field's presence, replace its value with <REVISION>, same treatment as
  timestamps) and regenerate the two show goldens + manifest SHAs.
- Differential regression (tests/regression): the v0.49.6 baseline never emitted
  `revision`, and its value is random per write, so it is pure cross-version
  noise. Add it to volatileFields so normalizeIssue strips it before the
  baseline/candidate diff.

Review-loop resolution (was DEFERRED at pre-review; now decided):

- CLI/HTTP read-parity (major): `bd show --json` emits `revision` but the
  apigen-frozen GET /v0/beads/issues/{id} keeps RowVersion json:"-", so the
  field-level parity oracle (TestProxiedServerServeReadParity/show) would flag it
  as unreviewed drift. Resolve as an accepted CLI-only surface: add a documented
  readsParityAllowlist["revision"] entry and rewrite the allowlist narrative.
  Exposing the token over the frozen v0 HTTP object is out of scope; the token is
  only meaningful to the CLI guarded-write path.
- Legacy-zero token (minor): drop `omitempty` from the show DTO so a legitimate
  RowVersion==0 CAS token is emitted instead of being conflated with an absent
  field; a guarded client must read the 0 it needs to send on un-mutated legacy
  migration-0054 rows.
- Test evidence (minor): add TestProjectShowJSONDetailsEmitsZeroRevision pinning
  the legacy-zero wire behavior.

Validated locally: git diff --check; go test ./internal/types (RowVersion),
./cmd/bd (focused show unit tests incl. the new zero-revision case),
./cmd/bd/protocol (corpus goldens unchanged), and the proxied Dolt parity oracle
TestProxiedServerServeReadParity (the show subtest now excuses `revision`).

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

---------

Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-05 19:51:49 -07:00
Julian Knutsen
d801ec43dc
feat(issueops): put every issue capability behind one library surface
Beads had two implementations of most issue verbs: one for the direct route
(the CLI talking to a store it opened itself) and one for the proxied-server
route (the CLI talking through a unit of work over a running Dolt server).
They drifted — different commit messages, different transaction boundaries,
different refusals, occasionally different answers.

Seven role interfaces now live in the leaf package issueops: Lifecycle,
Reader, ReadyClaimer, BatchCloser, DependencyEditor, Commenter and Relations.
Each is reached only through a store accessor, never a constructor, because
the accessor is where the hook and telemetry decorators add their layers.
Three implementations back every role — dolt, embeddeddolt, and the
unit-of-work provider the proxied route uses. Both routes call the same role
for close, dep add/remove/list, comment, ready --claim and update.

A depguard rule (httpapi-domain-boundary) denies internal/storage/domain from
internal/httpapi, so a handler cannot reach uw.IssueUseCase() past the roles
and open a second front door one lint-clean commit at a time.

Behaviour users will notice, all in the CHANGELOG:
  - bd close a b c is one Dolt commit, not three, and --claim-next moved
    inside that transaction so it fires only when something landed
  - the open-children guard moved into the transaction and its hand-rolled
    cmd/bd copy is gone, removing a read-then-write window that made
    bd close <child> <parent> depend on argument order
  - bd dep add --file honours deferred version commit
  - embedded bd comment writes the role's message and author
  - dep verb commit messages are the role's on the direct route

Wisp-sourced dependency edges are restored. Moving bd dep add onto the role
had pinned an edge's SOURCE to the issues plane, and the two routes did not
even fail alike: direct refused with "issue <id> not found", proxied threw an
fk_dep_issue violation. The comment justifying the pin claimed the issues
plane was "the only one its unit-of-work sibling can reach" — that was false;
domain.DependencyUseCase declared a full set of wisp twins with no production
caller. All three implementations now route per edge by the edge's own
source. A mixed request stays one transaction: parent-child-first ordering
and the whole-graph cycle gate span both planes, and a refusal rolls back
both. Behind the role, three bulk add verbs collapsed into one source-routed
AddDependencies, so no plane-pinned variant is left to reach for by mistake.

Six Provenance fields with no production caller were deleted rather than
wired — CloseRequest, CloseBatchRequest, ClaimNextRequest, AddCommentRequest,
AddDependenciesRequest, RemoveDependencyRequest. Each role already composes an
id-bearing message, so a caller could only restate the default and make it
unreachable from production. Two are not caller-settable even in principle:
CloseBatchCommitMessage names what LANDED and ClaimNextCommitMessage names the
id the claim WON. UpdateRequest and ReopenRequest keep theirs; commit messages
users see are unchanged.

Verified: build, vet and gofmt clean; golangci-lint 0 issues; protocol corpus
byte-identical under BEADS_PROTOCOL_REQUIRE_DOLT=1; all twelve
DependencyEditor conformance wirings green (four contract functions against
each implementation); TestEmbeddedDepAddWispSource runs bd dep add <wisp-id>
at the front door and was demonstrated RED against the pinned routing first.
Three internal/storage/dolt failures reproduce on pristine origin/main.

Known gaps are enumerated in the PR description rather than left to be found:
comment listing is on no role, bd dep tree and bd dep cycles have no role,
bd create and bd reopen are on Lifecycle only on the direct route, per-edge
line attribution is lost in bd dep add --file, multi-store bd close
--claim-next rides only the first store's batch, and the is_blocked staging gap
(bd-2y9ke, predates this change). Seven of the eight role interfaces now have a
shared conformance contract in backend/conformance, run at all three
implementations; main's Claimer, added in parallel by #5334, is the eighth and
has none yet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 12:27:56 -07:00
Jim Wordelman
50003b803b
feat(storage): refuse test DBs on production dolt servers (AD-01) (#3632)
* feat(storage): be-c5p AD-01 isProductionPort + DB-name firewall

Generalize the BEADS_TEST_MODE production-port guard so deployments
on non-3307 ports (BEADS_PRODUCTION_PORT env, BeadsDir/dolt-server.port
file) are also caught, and add a defense-in-depth database-name
firewall that refuses test-named DBs on any server unless the operator
opts into the dedicated test-server lane via BEADS_TEST_SERVER=1.

Both defenses honor BEADS_TEST_SERVER=1 as the single opt-in for
test-server connections, so each test harness flips one env var rather
than each layer reasoning about test/prod independently. Adds benchdb_
to testDatabasePrefixes (per-bench scratch DBs from cmd/bd/dolt.go)
and updates the doc-block to call out the two sibling prefix lists
that need to converge under be-avn.

Test harnesses across cmd/bd, internal/storage/dolt, internal/molecules,
internal/tracker, internal/utils, doctor, doctor/fix, protocol,
regression, and the root suite now set BEADS_TEST_SERVER=1 alongside
BEADS_TEST_MODE=1 in TestMain. The cross-rig integration test that
filters BEADS_* env on subprocess Cmd.Env adds it back explicitly.

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

* chore: release gate PASS for be-c5p-firewall (be-m1u/47dcc380)

* fix(test): adapt store_unit_test.go for BEADS_DOLT_SERVER_PORT (rebase compat)

Tests that exercise applyConfigDefaults now clear BEADS_DOLT_SERVER_PORT (added
to main after this branch was cut) so the legacy BEADS_DOLT_PORT path runs as
intended. Without this, a GC-city environment with BEADS_DOLT_SERVER_PORT set
causes the tests to resolve an unexpected port.

* fix(dolt): stop BEADS_TEST_SERVER=1 from suppressing DefaultSQLPort detection

Restructure productionPortReasons so Rule 1 (cfg.ServerPort ==
DefaultSQLPort) is evaluated unconditionally; BEADS_TEST_SERVER=1 now only
suppresses the BEADS_PRODUCTION_PORT and dolt-server.port heuristics (Rules
2 and 3). isProductionPort loses its independent whole-function bypass and
becomes a thin wrapper. Update doc comments on both functions and the
buildTestModeProductionPortPanic fix list (which no longer lists
BEADS_TEST_SERVER=1 as a fix when port 3307 is the matched reason) to match.
Add TestApplyConfigDefaults_TestModeBlocksProdPort_EvenWithTestServerOptIn
asserting port 3307 is still refused with the opt-in set.

Also: drop a redundant explicit db.Close() in openServerConnection's
firewall-refusal path (already covered by the connReady defer), and fix two
comments that referenced a non-existent uniqueBenchDBName, pointing them at
the real generator (cmd/bd/template_test.go newTemplateBenchmarkStore) with
the correct benchdb_ name format.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 01:28:51 -07:00
Jim Wordelman
be402a022a
fix(filters): Dolt label-filter regression fix — LabelPattern + LabelRegex + JSON truncation hint suppression (#3971)
* fix(list): suppress truncation hint in --json mode + lock-in label filter tests (be-acnquj)

Filter logic for --label/--label-any/--label-pattern/--title-contains was
already correct in tree (BuildIssueFilterClauses handles each case), so the
bug PM observed was a stale-binary artifact. To prevent regression, add a
unit test in TestListLabelFiltersAcnquj that exercises every acceptance
criterion:

  AC#1 -l X returns ONLY beads with label X
  AC#2 --label-any A,B (OR semantics)
  AC#3 --label-pattern glob
  AC#4 --title-contains case-insensitive
  AC#5 -l NONEXISTENT returns empty
  AC#6 AND/OR composition with multiple flags

For AC#7, gate printTruncationHint on jsonOutput so the trailing
"Showing N issues; more results matched..." line is suppressed in
--json mode. TestPrintTruncationHintJSONSuppression exercises both paths.

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

* fix(filters): wire LabelPattern/LabelRegex through SQL builder (be-ucslk4)

Both fields had been on IssueFilter and set by the cobra layer for
`bd list`, but BuildIssueFilterClauses never consumed them — so
--label-pattern and --label-regex silently returned the full result
set instead of filtering. This was the live regression in be-ucslk4
(every agent's intake hook saw the entire open queue).

Fix:

- LabelPattern: convert glob (* / ?) to a SQL LIKE pattern, escape
  literal %/_/| with ESCAPE '|', and AND-join an `id IN (SELECT
  issue_id FROM <labels-table> WHERE label LIKE ? ESCAPE '|')`
  subquery — same shape as the existing single-label clause.
- LabelRegex: pass through verbatim to a `label REGEXP ?` subquery.
- Helper globToLikePattern is unit-tested for stars, question marks,
  literal wildcards, and the escape char itself.

Tests:

- filters_test.go: TestBuildIssueFilterClauses_LabelPattern (issues +
  wisps tables), TestBuildIssueFilterClauses_LabelRegex,
  TestGlobToLikePattern table test. These run without Dolt — they
  pin the SQL emission and arg shape so the regression cannot recur.
- list_embedded_test.go: strengthened the existing label_pattern
  subtest with negative-case assertions (feature/chore must NOT
  match `back*`). The prior assertion only checked positive
  inclusion, so it would pass even when the filter was a no-op.

Verified end-to-end on live city: --label-pattern, --label-regex,
--label, --label-any, --title-contains all return the correct counts
after the fix; trailing 'Showing N issues; more results matched...'
hint stays off stdout under --json.

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

* chore: release gate PASS for be-ucslk4-dolt-ship (be-qd2vmt)

* docs(regression): mark BUG-28 label-pattern filter as fixed (PR #3971)

TestDiscovery_LabelPatternFilterDeadCode's assertions already described the
correct (filtered) behavior, so no assertion changes were needed — it now
passes against the candidate binary where it previously failed and
documented the dead-code bug. Update the test docstring and the DISCOVERY.md
BUG-28 entry/status table/index list to reflect the fix landing in this PR
rather than describing an open bug.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

* fix(filters): dedupe globToLikePattern, pin test against live impl

TestGlobToLikePattern was pinning a byte-identical but unreachable copy of
globToLikePattern in internal/storage/issueops/filters.go — the production
caller is internal/storage/sqlbuild/filter.go:325 via BuildIssueFilterClauses.
An escaping regression in the sqlbuild copy (%, _, | handling) could have
shipped unseen since only the dead copy was tested.

Delete the issueops copy (and its now-unused "strings" import) and move
TestGlobToLikePattern into internal/storage/sqlbuild, in-package, so it
exercises the function BuildIssueFilterClauses actually calls.

Flagged by cross-vendor paired review (claude-opus + codex-gpt-5.6-sol) on
PR #3971.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

* test(list): add store-level --label-regex coverage

The label REGEXP ? path was previously pinned only at the clause-string
level (TestBuildIssueFilterClauses_LabelRegex); no committed test exercised
it end-to-end against the embedded store, though a reviewer's ad-hoc probe
had confirmed it works. Add a label_regex subtest beside the existing
label_pattern case in TestEmbeddedList, following the same build-tag/env
gating (BEADS_TEST_EMBEDDED_DOLT=1), covering both a single-label regex and
an alternation across unrelated labels to confirm REGEXP semantics (not just
substring/glob matching).

Flagged by cross-vendor paired review (claude-opus + codex-gpt-5.6-sol) on
PR #3971.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

* chore: drop contributor release-gate artifact from PR

release-gates/be-ucslk4-dolt-ship-gate.md is a contributor-process artifact
that doesn't belong in the upstream tree.

Flagged by cross-vendor paired review (claude-opus + codex-gpt-5.6-sol) on
PR #3971.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 00:17:02 -07:00
Julian Knutsen
607df586d1
feat(engine): guarded write ops — atomic metadata merge, row-version CAS, typed dep errors + events, bd close delegation (#4911)
* feat(metadata): MergeMetadata — atomic single-key metadata merge

SlotSet did a read-modify-write across TWO transactions: GetIssue (tx 1),
metadata[key]=value in memory, then UpdateIssue (tx 2). Two concurrent SlotSet
calls — even on DIFFERENT keys — both read the same base metadata and each
wrote back its whole blob, so the second clobbered the first's key. SlotClear
had the same bug. Add MergeMetadata, which does the read-modify-write inside
ONE transaction (so a concurrent conflict is retried and re-reads), stores a
JSON value (nested objects/arrays, not just strings), and reimplement SlotSet
and SlotClear on top of it so they inherit the atomicity.

- issueops.MergeMetadataInTx / DeleteMetadataInTx: read the metadata (routed
  issues/wisps; missing issue -> ErrNotFound), merge/delete the one key, and
  write the whole object back THROUGH UpdateIssueInTx — so the operation keeps
  everything the old SlotSet got from UpdateIssue (the EventUpdated history
  event with actor attribution, the configured metadata-schema validation, and
  updated_at), now atomic. The read and write share the caller's transaction,
  so a concurrent merge of a different key is retried and re-read, never
  clobbered.
- Storage.MergeMetadata implemented on DoltStore (perm withRetryTx +
  DOLT_ADD(issues,events) + DOLT_COMMIT; wisp path no commit) and
  EmbeddedDoltStore (withConn); forwarded on InstrumentedStorage; auto-promoted
  on HookFiringStore; no-op on the configStore mock. SlotSet/SlotClear rebuilt
  on it (a string value marshals to a JSON string, byte-compatible with the
  historical rewrite).
- Cross-backend conformance covers MergeMetadata + atomic SlotClear; the
  8-goroutine concurrent-no-clobber test proves the B1 fix on real Dolt, and
  a test asserts the EventUpdated event and schema validation are preserved.

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

* feat(concurrency): expose a per-row version on Issue reads (RowVersion)

The engine's internal row_lock column — a random non-zero int64 the engine
rewrites on every status/ownership-mutating write and on the generic update
path — was not surfaced on the public types.Issue. Consumers that wanted a
fine-grained optimistic-concurrency token had only updated_at, which is stored
at second granularity, so two same-second writes were indistinguishable. Expose
row_lock read-only as types.Issue.RowVersion so a caller can tell same-second
writes apart.

- types.Issue gains RowVersion int64 (json:"-": a Go-only concurrency token,
  never on the CLI/export JSON wire — it is opaque and equality-only). Added
  row_lock to the canonical sqlbuild.IssueBaseColumns and a matching scan target
  in issueops.ScanIssueFrom; both engine write stacks, wisps, and the counts /
  dependents parallel scans share those, so the field hydrates everywhere from a
  single-point change. Read-only — no CAS/write behavior (that is a follow-up).
- Doc is precise about coverage: RowVersion changes on claim/close/unclaim and
  the generic update path; it does NOT change on some direct-UPDATE paths
  (restore, compaction text), which bump updated_at — so a complete change key
  combines RowVersion with updated_at, status, and labels. A created row is
  already non-zero (create stamps row_lock); 0 only appears on legacy rows
  backfilled by migration 0054's DEFAULT 0.
- Tests: RowVersion hydrates on read and on the list path, changes on a mutating
  write, distinguishes two same-second writes (identical updated_at, distinct
  RowVersion), and never appears on any JSON surface.

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

* feat(deps): return a typed error on dependency type-conflict

Adding a dependency between a pair that already has an edge of a different type
is a deterministic rejection, but the two engine write paths disagreed on how
they surfaced it: one returned a typed *DependencyTypeConflictError, the other a
plain fmt.Errorf string. So a caller could errors.As the conflict on one path
but had to string-match the message on the other. Make both paths return the
same typed error, and re-export the two dependency-conflict types on the public
beads package so `bd` (and the library's own call sites) classify by errors.As
instead of parsing message text.

- issueops.AddDependencyInTx now returns *domain.DependencyTypeConflictError for
  the type-conflict case (byte-identical message — the struct's Error() is the
  exact former string, so no string-matcher changes). The hierarchy/cross-type
  case already returned *domain.DependencyHierarchyConflictError on both paths;
  self-dependency and cycle are already typed sentinels.
- beads.go re-exports DependencyTypeConflictError and
  DependencyHierarchyConflictError as type aliases, so errors.As against the
  public type matches the value the engine returns.
- Tests assert errors.As + the four fields + the byte-identical message on both
  write paths (permanent issues->issues and the wisp-source BeginTx/Commit seam),
  and lock the re-exports; the deterministic conflict is returned immediately
  (never retried as a transient serialization error).

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

* feat(deps): emit dependency_added / dependency_removed events

`bd dep add` and `bd dep remove` recorded no event, so the events feed never
surfaced dependency changes even though the event types (types.EventDependencyAdded
/ EventDependencyRemoved) have existed since the original SQLite backend, which
emitted them on every add/remove. The emission was dropped when that backend was
removed for the Dolt-only migration and never ported to the current write paths.
Restore it on both Dolt write plumbings, matching the original shape (an events
row on the source issue: "Added dependency: <src> <type> <target>" /
"Removed dependency on <target>").

- issueops.AddDependencyInTx / RemoveDependencyInTx record the event via
  RecordEventInTable on the source's event table (wisp-routed), on the genuine
  add/remove only — the idempotent same-type re-add and the no-op remove of a
  missing edge record nothing.
- The event is committed with the edge: DoltStore.AddDependency/RemoveDependency
  DOLT_ADD `events`, and the transaction-path (RunInTransaction / batch /
  graph-apply) methods mark the source's event table dirty (events or wisp_events)
  so StageAndCommit commits it — without this the event row would dangle in the
  working set.
- Emission is gated to the explicit dep-add/remove verb on both plumbings: the
  proxied-server repo only records when the use-case sets DepInsertOpts.EmitEvent,
  which create-with-deps (implicit parent-child / --deps / waits-for, via a direct
  repo Insert) does not — so `bd create --parent` produces the same history on
  either backend (the embedded create path via PersistDependencies likewise emits
  nothing).
- Tests on both plumbings: add/remove emit exactly once and commit (verified via
  `events AS OF 'HEAD'`), idempotent re-add and no-op remove emit nothing, wisp
  sources route to wisp_events, and create-with-deps emits no dependency_added.

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

* feat(close): optional ExpectedVersion CAS on CloseIssueChecked

CloseIssueChecked guards a close on is_blocked in-transaction, but a caller that
read an issue and then closes it has no way to say "only if it hasn't changed
since I read it" — a lost-update window. Add an optional compare-and-swap on the
row's version (the RowVersion / row_lock token): when the caller supplies an
ExpectedVersion, the close proceeds only if the row still has that version, else
it refuses with a typed ErrVersionMismatch. The version read and the close share
one transaction, so it is a true CAS with no read-then-write gap.

- storage.ErrVersionMismatch (re-exported as beads.ErrVersionMismatch) and
  CloseIssueOptions.ExpectedVersion *int64 (nil disables the check; a pointer so
  nil "no check" is distinct from "require version 0").
- issueops.CheckVersionInTx reads row_lock (wisp-routed; ErrNotFound on a missing
  row) and returns ErrVersionMismatch on divergence. CloseIssueCheckedInTx runs
  it FIRST — before the is_blocked guard and before the Force short-circuit, so
  Force bypasses only the guard, never the CAS (the version check is an
  orthogonal precondition). A mismatch returns before any write, so the tx rolls
  back leaving the issue open with no `closed` event (atomic refuse).
- The CAS has two limbs: the read-side check catches a writer that committed
  before the close began, and on the retry-wrapped permanent path a commit-time
  row_lock conflict is replayed by withRetryTx so the re-read refuses.
- Tests on both stores: match closes, stale refuses atomically (still open, zero
  closed events), a committed concurrent write invalidates a captured version,
  nil is unchanged behavior, Force does not bypass, missing id → ErrNotFound,
  wisp sources route to the wisps table, and an already-closed re-close with the
  post-close version stays idempotent (Unchanged).

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

* docs(close): document RowVersion CAS coverage boundary on ExpectedVersion

Both adoption reviewers flagged that the public ExpectedVersion godoc and the
shared CloseIssueCheckedInTx doc could be misread as a full-row "unchanged"
check. RowVersion (row_lock) only tracks lifecycle/ownership writes
(status/assignee/started_at), so concurrent label, dependency, rename, or
is_blocked writes leave it untouched and are intentionally outside this CAS
boundary. Document that on both sites, grounded in the freshRowLock invariant.
Doc-only; no behavior change.

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

* refactor(cli): bd close delegates to the engine's guarded close

The embedded `bd close` path ran its own is_blocked pre-check and then closed in
a separate call — a read-then-write TOCTOU that duplicated a guard the engine
provides atomically. The verb now builds CloseIssueOptions and delegates to
CloseIssueChecked, which runs the guard and the close in ONE transaction; the
CLI's duplicated guard is deleted. --force maps to Options.Force; a blocked
close refuses with the blockers named and the --force hint.

Behavior-preserving on purpose (verified against the previous binary):

- The engine guard now uses the exact historical CLI predicate — refuse only on
  a LIVE direct blocker (blocked && len(blockers) > 0), not on the bare
  denormalized is_blocked column. A transitively-blocked child (is_blocked
  inherited from a blocked parent, zero direct blockers) still closes without
  --force, and a stale is_blocked with since-closed blockers self-heals, exactly
  as before.
- An already-closed issue stays an idempotent success: it still appears in the
  --json array and the text report (same output shape), still exits 0, but no
  longer produces a spurious closed->closed audit entry, a no-op commit, or the
  real-close side effects (molecule auto-close, newly-unblocked, claim-next).

Tests cover: direct blocker refuses atomically (still open) and closes with
--force; transitively-blocked and stale-is_blocked beads close without --force;
already-closed emits in --json alone and in a mixed batch; idempotent exit 0 —
on the engine (both stores) and through the bd binary.

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

* feat(update): UpdateIssueChecked — optional ExpectedVersion CAS on the update

UpdateIssue applies a field-map update with no optimistic-concurrency option, so
a caller that wants "update only if unchanged since I read it" had to
read-then-write — a lost-update window. Add UpdateIssueChecked: when the caller
supplies an ExpectedVersion (the RowVersion / row_lock token), the version read
and the update share ONE transaction, refusing with the typed ErrVersionMismatch
if the row has moved — a true compare-and-swap. Nil disables the check and is
byte-identical to UpdateIssue, which is left untouched on the hot path.

- storage.UpdateIssueOptions{ExpectedVersion *int64} (aliased as
  beads.UpdateIssueOptions) + Storage.UpdateIssueChecked, mirroring the
  CloseIssueChecked pattern: CheckVersionInTx runs first inside the same
  transaction on every route — the permanent withRetryTx path, the wisp path,
  AND the demote route (an update carrying no_history/wisp routes through the
  demote flow; a pure demoteToWispInTx extraction lets the check compose
  atomically with the row move — verified byte-identical to the old
  DemoteToWisp).
- Implemented on DoltStore and EmbeddedDoltStore; InstrumentedStorage wraps it;
  HookFiringStore fires on_update only on success (never on a refused update).
- Tests on both stores: match updates and bumps RowVersion; stale refuses
  atomically (field unchanged, zero updated events); a committed concurrent
  write invalidates a captured version; nil behaves exactly like UpdateIssue;
  wisp match/stale; demote-route match (migrates + applies) and stale (still in
  issues, unchanged); missing id → ErrNotFound; the hook decorator fires once on
  success and never on refusal.

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

* refactor(cli): proxied bd close delegates to a library checked close

The proxied-server `bd close` path duplicated the close guard in the CLI:
it queried blockers via the dependency use-case, refused with its own message,
and then closed in a separate use-case call. Move the guard into the library —
IssueUseCase gains CloseIssueChecked / CloseWispChecked, which run the same
live-direct-blocker predicate (refuse only on blocked && len(blockers) > 0)
and then the untouched unchecked close — and thin the CLI verb to a single
delegated call. Both `bd close` paths now enforce the guard in the library and
emit the byte-identical refusal: the same storage.ErrCloseBlocked sentinel
("cannot close blocked issue: <id> is blocked by [...]") plus the
"(use --force to override)" hint.

- Guard and close run on the one pinned unit-of-work connection (the whole
  close batch is a single transaction), and the guard is read-only and refuses
  before any write — a refused id leaves the shared batch transaction clean,
  and an all-refused batch skips the commit entirely, exactly as before.
- The unchecked CloseIssue / CloseWisp are untouched: internal closes (molecule
  auto-close, gate closes, bd todo done) intentionally stay unguarded.
- Behavior-parity preserved: guard ordering (validate → epic-child → gate →
  blocked), exit codes, JSON/batch shape, already-closed handling, audit fields,
  and commit-message contents are unchanged; a transitively-blocked bead
  (is_blocked with no direct open blocker) still closes without --force, and
  --force still bypasses. The guard-failure diagnostic now uses the embedded
  path's generic wording (further convergence; nothing matched the old text).
- Tests: use-case level on real Dolt (direct blocker refuses with blockers
  named + still open, transitive-only closes, force closes, already-closed
  parity, wisp refuse/force) plus the proxied CLI integration suite.

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

* fix(review): cross-backend dependency-event + RowVersion parity

Maintainer review fixups for PR #4911 (adopt-pr review loop):

- RowVersion: the proxied/domain create (insertIssueRow) and generic Update
  paths never stamped or rewrote row_lock, so an issue written through the
  proxied-server backend read back RowVersion 0 on create and unchanged on
  update -- a stale CAS token that violated the types.Issue.RowVersion
  contract on that backend. Stamp a fresh non-zero row_lock on insert (and the
  duplicate-key rewrite) and append RowLockClause() to the generic update,
  mirroring the classic issueops insert/update invariant. Adds domain/db
  regression tests proving CreateIssue/CreateWisp are non-zero and
  UpdateIssue/UpdateWisp change it.

- Dependency events: embedded issueops AddDependencyInTx/RemoveDependencyInTx
  recorded history unconditionally, so structural create-with-deps
  (bd create --parent/--deps/--waits-for) and reparent (bd update --parent)
  emitted dependency_added/removed on embedded but were silent on the proxied
  backend, diverging issue history for identical commands. Gate the embedded
  emit on EmitEvent and thread it through AddDependencyWithOptions /
  RemoveDependencyWithOptions on both the store and transaction interfaces:
  the plain AddDependency/RemoveDependency are the no-event structural default
  (create-with-deps, reparent), while the explicit dep verbs (bd dep add/remove,
  bd link, bd relate/unrelate) pass EmitEvent -- matching the proxied
  DepInsertOpts.EmitEvent gate. DoltStore stages the events table only when an
  event was actually written (GH#2455). Corrects the false
  "parity with PersistDependencies" comments and adds symmetric embedded/proxied
  dep-event coverage for create-with-parent/deps and structural removal.

- Retain iteration-1 fixups: heal molecules on already-closed re-close,
  idempotent proxied checked-close, and documented public Storage growth.

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

* fix(storage): drop always-constant event param from fireDependencyHookByID (unparam)

golangci-lint (latest, v2.12.2 in CI) unparam flags fireDependencyHookByID:
its `event` parameter always receives hooks.EventUpdate. The parameter was
already effectively constant before this PR (both base call sites passed
EventUpdate); this PR adds two more call sites, all EventUpdate. Remove the
dead parameter and hardcode hooks.EventUpdate at the single runner.Run call.
All four call sites pass hooks.EventUpdate, so behavior is unchanged; go
build, go vet, and a scoped golangci-lint run pass clean.

Maintainer fixup during adoption finalize (PR #4911).

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

---------

Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <ci@beads.test>
2026-07-21 18:13:03 -07:00
matt wilkie
134b83c379 fix(metadata): update non-PR-CI test surfaces for always-string --set-metadata
PR #4232 changes toJSONValue() to always store --set-metadata values as
JSON strings (no more type inference), fixing GH#4146. Two test surfaces
outside PR CI still asserted the old inferred-number/bool behavior:

- cmd/bd/update_proxied_integration_test.go: update_set_metadata subtest
  expected got["score"] == float64(99); now expects the string "99".
- tests/oracle-a: the update_set_metadata_raw_scalars DIVERGENCE PIN
  comment and the deep-tier catalog entry update_set_metadata_incremental
  (scenarios/enumerated.json) documented the old coercion rules. Both are
  documentation only (PROVENANCE.md: "notes/pins are documentation the
  runner ignores" for the differential harness), so updating the text is
  the complete fix - there is no separate pin-regeneration step for these
  fields.

Agent-Signature: claude-fable-5-high on behalf of maphew
2026-07-13 20:51:52 -07:00
Chris Sells
789044b83e chore: purge deleted docs-pipeline references from release tooling, CI, and repo plumbing
- beads-release formula: drop the snapshot-docs step (ran the deleted
  scripts/snapshot-release-docs.sh on the critical needs-chain); stamp-
  changelog now needs update-vendorhash
- update-versions.sh: remove the mangled --skip-docs/docs-snapshot logic
  and garbled usage text left by mid-line deletions
- pre-push hook: drop the snapshot-script remediation hint
- release.yml: collapse the prerelease branch; BEADS_REQUIRE_RELEASE_DOCS
  has no consumer since check-docs-version.sh was deleted
- RELEASING.md / scripts/docs.md: describe the current pipeline (no
  --versioned, no website/ outputs, no check-docs-version.sh)
- docs-mintlify.yml: paths filter now includes engdocs/** and the curated
  root markdown files the docsync guard validates
- docs-render-check.sh: pin mint@4.2.687, fail closed when mint dies
  without producing a broken-links report, parse report lines only, drop
  dead extract_page_links(), fix the stale jq requirement; mint.sh pins
  the same version
- nightly.yml: remove the deleted website measurement suite option
- CODEOWNERS: init-safety ADR gate follows the file to engdocs/adr/
- beads-docs skill: align with settled decision 6 — no pointer stubs,
  moved pages get docs.json redirects; bd's printed paths are fixed at
  the source
- CHANGELOG (edited line), FEDERATION-SETUP, README, examples, oracle-a,
  .buildflags, gh-issue-to-pr formula: retarget moved-file references;
  anchor the build/ gitignore pattern
2026-07-12 11:07:26 -07:00
Test User
e7484b32f7 feat(oracle): add the opt-in enumerated deep tier (~500 scenarios)
Adds a second, opt-in tier to Oracle A: the enumerated catalog
(`tests/oracle-a/harness/scenarios/enumerated.json` — 523 entries, 501
deterministic) that sweeps the wider bd CLI surface as data. The curated set
stays the fast default (~2-7 min); `ORACLE_CATALOG=1` pulls in the catalog for a
deep run (~10-15 min).

- `catalog()` now loads `scenarios/enumerated.json` (harness-relative), and
  `scoreboard` gates it on `ORACLE_CATALOG` — symmetric with `capture_golden` —
  so a default run scores exactly the curated set with no no-golden noise.
- `run-oracle-a.sh` exports `ORACLE_CATALOG` through to both the capture and score
  steps (only when non-empty; the tools treat any set value as "on").
- Floor assertion reworked. The old per-scenario "every create must exit 0 with an
  id" check false-positived on the catalog's intentional error-path scenarios
  (invalid priority/type, missing title, unknown flag, ...), whose creates SHOULD
  exit non-zero, and aborted before scoring. It now aggregates: the reference must
  produce >= 1 successful create (proving bd can init + create a workspace);
  per-scenario error behavior is validated by the ref-vs-candidate diff, not the
  floor.

Verified (bd-vs-bd on origin/main d23ba38f8): deep-tier IN-SCOPE 323/323 PASS, 0
divergences; fast tier remains 44/44. The 45 out-of-scope failures are
informational only (build-stamp / human-output deltas that always vary between two
builds — the in-scope predicate excludes them, e.g. the non-deterministic
`version --json` scenarios).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 23:44:45 +00:00
Test User
eca5316863 test(oracle): add Oracle A — refactor-safety differential conformance for bd
Oracle A is a black-box differential conformance rig for `bd`. It builds `bd`
from the merge-base with origin/main (REFERENCE, "before") and from the working
tree (CANDIDATE, "after"), runs a curated set of CLI contract scenarios against
both as real processes, and diffs every step — exit code, stderr, and JSON-aware
stdout — with volatile values (timestamps / UUIDs / actor / email) normalized.
Zero in-scope divergences is the gate: green means the change altered no
user-visible bd behavior on the covered surface.

The rig is purely additive and treats bd as a black box — it needs only cargo,
go, and a CGO toolchain, and works against any bd tree. It is useful for
reviewing any refactor (storage seam, serialization, output plumbing), not just
one feature.

Layout (all under tests/oracle-a/):
- run-oracle-a.sh   — orchestrator: builds reference + candidate bd in isolated
                      worktrees, builds the harness, captures goldens from the
                      reference, scores the candidate, sets exit status.
- harness/          — a self-contained Rust conformance harness (MIT OR
                      Apache-2.0): capture_golden + scoreboard binaries over a
                      curated scenario set with JSON-aware, order-aware diffing.
- README.md         — how to run, and the explicit what-green-does /
                      does-not-prove boundary.

Extracted from #4601, where it was used to prove the SQL backends byte-identical
to the Dolt reference; it stands on its own as a general regression gate.

Verified: the main-vs-main leak test is green — 44/44 in-scope scenarios, 0
divergences — on origin/main d23ba38f8.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 23:44:45 +00:00
coffeegoddd☕️✨
d7d7a34607 : refactor to use RunE, emit usage metrics, skip metrics in CI
(cherry picked from commit 9596c7233d)
2026-06-22 20:44:43 +00:00
Julian Knutsen
8ae4c3c67b
fix: repair PR4107 blocked-state corruption (#4139)
* test: reproduce pr4107 corruption regressions (bd-rzn)

* test: expand pr4107 corruption coverage (bd-rzn)

* fix: repair pr4107 blocked-state corruption

* fix: restore green Dolt storage suite

* test: repair regression workflow after show json streaming

* fix: make mixed blocked migration upgrade-safe

* test(ready): benchmark limited wisp-heavy ready queries

* perf(ready): page limited ephemeral scans

* Fix review blockers for PR4107 corruption repair (bd-yueuq)
2026-05-24 05:37:52 -07:00
matt wilkie
a499c2bfe4
test(regression): make workspace cleanup robust (#3854) 2026-05-10 06:33:26 -07:00
matt wilkie
439afcf9e5
test(regression): prevent baseline daemon timeout (#3809)
Co-authored-by: upgrade-test <test@beads.test>
2026-05-08 08:23:58 -07:00
matt wilkie
bb6b8f226b
Fix ready/list UX regressions (#3481)
* fix(ready): honor filter.ExcludeTypes in GetReadyWorkInTx (GH#3397)

The --exclude-type CLI flag was silently ignored by bd ready. The CLI
correctly populated filter.ExcludeTypes, and the type's godoc promised
that values are "Appended to the default exclusion list", but the
no-Type branch of GetReadyWorkInTx built the NOT IN clause from the
hardcoded defaults only.

Merge user-supplied ExcludeTypes into the default exclusion list (with
dedup against defaults and empties) before building the placeholders.
This matches the pattern already used by issueops/filters.go and
dolt/queries.go for bd list.

Fixes GH#3397.

* fix(ready): --parent returns transitive descendants, not direct children only (GH#3396)

The SQL clause in GetReadyWorkInTx's ParentID branch was a one-hop join
against the parent-child dependency table, so only direct children
surfaced. The --parent help text in cmd/bd/ready.go:672 and the
WorkFilter.ParentID godoc (internal/types/types.go:1295) both promise
"descendants (recursive)".

Add a BFS helper GetDescendantIDsInTx alongside GetChildrenOfIssuesInTx
in blocked.go — BFS rather than a recursive CTE because the existing
children helper already iterates across both dependencies and
wisp_dependencies tables, and composing that inside a single CTE gets
ugly. The visited set breaks cycles and a depth cap (default 100,
matching the cycle-detection CTE elsewhere in issueops) guards against
malformed data.

Rewrite the ParentID branch in GetReadyWorkInTx to resolve descendants
via the new helper and OR that with the prior dotted-ID prefix match
(for implicit-parent IDs with no explicit parent-child dep), preserving
the original semantics for dotted IDs.

MoleculeID is deliberately left as one-hop — its inline comment
explicitly scopes it to "direct children" unlike ParentID.

Fixes GH#3396.

* Improve ready and list UX regressions (bd-main-typ)

* fix(list): make --ready flag use blocker-aware GetReadyWork semantics (GH#3478)

bd list --ready previously only filtered by status=open, showing issues
that bd ready correctly excluded as blocked. Now both commands use the
same GetReadyWork path, ensuring consistent results.

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

* Add list ready blocker regression coverage (bd-qo1)

* Fix ready list review regressions

---------

Co-authored-by: Daniel Jasiński <daniel.jasinski@gmail.com>
Co-authored-by: kev <kglynn@pryoninc.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-26 20:29:30 -07:00
matt wilkie
e2e4975044
Document supported go install modes (bd-o5a) (#3480)
- Removed bare first-party go install .../cmd/bd@latest guidance from docs,
    website docs, plugin/npm docs, examples, and doctor hints.
  - Standardized on:
      - CGO_ENABLED=0 go install ... for server-mode only
      - CGO_ENABLED=1 GOFLAGS=-tags=gms_pure_go go install ... for embedded-
        capable
  - Added scripts/check-go-install-guidance.sh and wired it into CI.
  - Updated default.nix to use gms_pure_go instead of ICU flags.

  Validation passed locally:

  - make test
  - golangci-lint run --build-tags=gms_pure_go ./...
  - ./scripts/check-go-install-guidance.sh
  - ./scripts/check-build-tags.sh
  - go test -tags gms_pure_go ./cmd/bd/doctor
  - doc flag check
2026-04-25 11:30:19 -07:00
matt wilkie
cf88aa760d test: fix regression workflow gate 2026-04-24 10:55:11 -07:00
Steven Syrek
f0057c7828
ci: install dolt binary on Linux and macOS test runners (#3440)
* ci: install dolt binary on Linux and macOS test runners

Install dolt via the official install.sh on Linux and via Homebrew on
macOS so the main test job can exercise the ~24 test gates that
previously silently skipped on every PR when dolt was absent from PATH.

Matches the installation pattern already used by nightly.yml.
Docker-testcontainer gates (testDoltServerPort == 0 skips) remain
skipped — a known GitHub Actions hang documented in
scripts/repro-dolt-hang/INCIDENT-REPORT.md and nightly.yml:37-41
prevents enabling testcontainers here.

* test: require dolt binary under GITHUB_ACTIONS

Add testutil.RequireDoltBinary: skips when the dolt CLI is absent
locally but fails the test under GITHUB_ACTIONS. Replace bare
exec.LookPath("dolt") skip-gates with the helper so ~24 tests that
previously fell through silently in CI now run — and hard-fail if
the CI workflow ever drops the dolt install step.

tests/regression/regression_test.go uses an inline variant because
its gate lives in TestMain, and internal/remotecache/cache_test.go
duplicates the helper inline to avoid an import cycle
(testutil -> doltutil -> remotecache).
2026-04-24 06:58:40 -07:00
matt wilkie
66af62221e
fix(ci): drop ICU linkage from test jobs, use -tags gms_pure_go everywhere (#3240)
* fix(ci): drop ICU linkage from Linux/macOS test jobs (bd-sz5, GH#3506)

Align the CI test matrix with how we ship: all Go build/test invocations
now use -tags gms_pure_go, matching the Windows job, goreleaser, and the
install scripts. Remove libicu-dev / icu4c installs and CGO_* env setup
from ubuntu-latest and macos-latest jobs in ci.yml, plus nightly,
migration-test, and cross-version-smoke workflows.

Upstream dolthub/go-mysql-server#3506 confirmed -tags=gms_pure_go is the
sanctioned escape hatch; testing an ICU-linked config nobody installs was
wasting CI minutes and producing spurious duplicate-rpath / malformed
LC_DYSYMTAB linker warnings on macOS.

Update docs/ICU-POLICY.md to reflect that the CI matrix no longer
intentionally omits the tag; scripts/test-cgo.sh remains as the local
developer tool for exercising the ICU code path on demand.

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

* fix(ci): add -tags gms_pure_go to test-helper go build shell-outs (bd-sz5)

Addresses review feedback on 7b36ab653. Several integration tests shell
out to `go build ./cmd/bd` (or `go build .`) from TestMain / t.Helper
setup functions. The outer `go test -tags 'integration gms_pure_go'`
tag does not propagate into these subprocesses, so the inner builds were
still trying to link ICU and failing with
`unicode/uregex.h: No such file or directory` in the nightly workflow.

Repo-wide audit of `exec.Command("go", "build", ...)` test helpers:
- internal/beads/beads_hash_multiclone_test.go (reviewer's cite)
- tests/regression/regression_test.go
- cmd/bd/protocol/helpers_test.go
- cmd/bd/doctor/dolt_e2e_test.go
- cmd/bd/{scripttest,import_prefix,explicit_db_nodb,init_embedded,
  main,init,cli_fast,shared_server_integration,doctor_repair,
  dolt_autostart_lifecycle_integration}_test.go

All 15 call sites now pass `-tags gms_pure_go`. `cmd/bd/preflight.go`
is production code (`bd preflight` user command), not a test helper,
and is intentionally left as-is.

Also narrow docs/ICU-POLICY.md "Common Mistakes" #3 -- libicu-dev is
needed only for local on-demand testing via scripts/test-cgo.sh, not
for CI test workflows (which no longer exercise the ICU path).

Verified: `go test -tags 'integration gms_pure_go' -run '^$' ./...`
passes cleanly from the worktree root (previously failed in
internal/beads).

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

* fix(preflight): add -tags gms_pure_go to test/lint shell-outs (bd-sz5)

preflight is a beads-maintainer pre-PR tool. On dev machines without
ICU dev libraries installed, `bd preflight --check` was failing at the
`go test -short ./...` step with the same `unicode/uregex.h` error we
fixed in nightly CI (bd13871bd).

Apply the gms_pure_go tag consistently:
- runTestCheck: `go test -tags gms_pure_go -short ./...`
- runLintCheck: `golangci-lint run --build-tags=gms_pure_go ./...`
- Update the user-visible Command labels to match
- Update the static checklist printed by `bd preflight` (no --check)
  so copy-pasted commands work on no-ICU machines

Matches the tag golangci-lint is now passed in CI, keeping local and
CI runs consistent.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 10:01:46 -07:00
Harry Miller
5d4aafd27e
Merge pull request #2821 from harry-miller-trimble/fix/idempotent-claim
fix: make bd update --claim idempotent for same user
2026-03-26 08:40:51 -07:00
beads/crew/emma
84494b7e1a cleanup: remove daemon infrastructure remnants (GH#2431)
Remove all BEADS_NO_DAEMON env var handling from test files (dead code
since daemon removal in v0.50.0), delete stopRepoDaemon() and daemon
file guards from test setup, remove no-daemon config key from tests,
and update daemon→server wording in docs and comments.

37 files changed, -193 lines net.

Co-Authored-By: davetashner <davetashner@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 15:24:27 -07:00
obsidian
3872308568 refactor(tests): migrate all test files from StartTestDoltServer to container-native API
Migrate 12 TestMain files to use EnsureDoltContainerForTestMain/TerminateDoltContainer
instead of the removed StartTestDoltServer/TestDoltServer API.

Replace testServer.IsCrashed()/CrashError() crash detection with standalone
testutil.DoltContainerCrashed()/DoltContainerCrashError() in 6 test files.

(bd-m7sy)
2026-03-03 10:07:32 -08:00
beads/crew/collins
41cd0953fe style: fix gofmt formatting in discovery_test.go
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 16:06:31 -08:00
beads/crew/collins
e10dbb957e fix(readiness): evaluate conditional-blocks deps in computeBlockedIDs()
conditional-blocks was declared as AffectsReadyWork() but never included
in the computeBlockedIDs() SQL query, so conditionally-blocked issues
silently appeared in bd ready. Add conditional-blocks to both the
readiness and blocked-list SQL queries, matching blocks semantics:
while the precondition is open, the fallback is blocked.

Resolves the gap identified in PR #2026 (Option A).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 13:30:07 -08:00
Xexr
376122ba46
fix: prevent test suite from leaking databases onto production Dolt server (#2089)
Set BEADS_TEST_MODE=1 unconditionally in all 9 TestMain functions that
interact with Dolt, before the test server nil check. Previously, test
mode was only set when the test Dolt server started successfully — if it
failed, tests silently connected to production on port 3307 and created
testdb_/beads_* databases that were never cleaned up.

Also:
- Fix doctorTestServerPort() fallback from 3307 (production) to 0
- Add dolt_purge_dropped_databases() to both cleanup functions
- Add isolated test Dolt server to integration test TestMain which had
  no server at all, causing bd init subprocess to hit production

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: beads/crew/lydia <steve.yegge@gmail.com>
2026-02-24 22:26:30 -08:00
onyx
6a21757419 fix(init): use prefix directly as database name instead of beads_ prefix
bd init --prefix was creating databases named beads_<prefix> (e.g.,
beads_sky, beads_gt). Convention should use the rig name directly as
the database name. This aligns with gastown doltserver.go which
already uses just the rig name.

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

Executed-By: beads/polecats/onyx
Rig: beads
Role: polecats
2026-02-24 14:57:01 -08:00
beads/crew/emma
a08f8bae87 fix(regression): improve test isolation and snapshot reliability
- Use full FNV hex hash instead of % 100000 for database prefixes,
  eliminating collision risk in parallel test runs
- Unify prefix strategy: discovery_test.go now uses FNV hash of
  workspace dir (matching regression_test.go) instead of rand.Intn
- Add --all to snapshot() bd list call so closed issues are captured,
  matching old bd export behavior
- Log warning when bd show returns unparseable JSON instead of silently
  skipping issues

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-24 13:13:58 -08:00
Joseph Turian
4e15ee4489 docs(regression): session 8c — blocked parent, label idempotency, dep tree
3 new failing discovery tests (BUG-69 through 71):
- blocked --parent nonexistent returns empty (no validation)
- label remove nonexistent says "Removed" (false positive)
- label add duplicate says "Added" when already exists

1 new protocol test:
- dep tree --max-depth -1 properly rejected

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-24 12:27:05 -08:00
Joseph Turian
8e0a57ca9f docs(regression): session 8b — stale edge, search comma-status, type filter
3 new failing discovery tests (BUG-61 through 63):
- stale --days 0 returns brand-new issues as "stale"
- search --status "open,closed" silently returns empty (same as BUG-44)
- list --type nonexistent silently returns empty (no validation)

5 new protocol tests confirming correct behavior:
- query priority range validation, unknown field rejection
- delete nonexistent --force errors, pin closed issue handled

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-24 12:27:05 -08:00
Joseph Turian
1b2b43048f docs(regression): session 8 — lifecycle validation, ready filters, duplicate cycles
5 new failing discovery tests (BUG-56 through BUG-60):
- reopen already-open issue succeeds silently
- undefer non-deferred issue succeeds silently
- ready --priority 5 (out of range) accepted silently
- children of nonexistent parent returns empty
- duplicate cycle (A dup B, B dup A) undetected

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

Executed-By: beads/crew/emma
Rig: beads
Role: crew
2026-02-24 12:27:05 -08:00