Commit graph

17 commits

Author SHA1 Message Date
Julian Knutsen
0500fc6f40
ci(bazel): run the scripts and source-walking tests remotely; retire their go test legs (#7320)
//scripts:scripts_test and //scripts/check-versions:check-versions_test
drop their host-tools/no-remote-exec/no-remote-cache tags and run on the
rbe-west workers like every other target (the worker image ships bash, git,
python3, jq, yq, curl, openssl, unzip and coreutils; a missing tool fails the
test under Bazel rather than skipping it). Go comes in hermetically as the
registered SDK; check-versions.sh's `go build` is stood in for by the
Bazel-built checker.

The tests that walked the source checkout now get it as data:
tools/bazel/go_srcs.py keeps a managed `repo_files` filegroup in every
package and aggregates them into //:repo_files (exactly the tracked files
Bazel can see; make bazel-sync-check fails on a package without one).
scripts_test and docsync_test take it instead of hand-listed filegroups,
and every TEST_SRCDIR/IsBazel skip and go-test-only block in them is gone.
The release formula under .bazelignore'd .beads/ comes in through a
@beads_formulas local repository; npm-package/ and .claude/ are visible to
Bazel again (only their node_modules/worktrees stay ignored), so the npm
manifest release check and the AGENTS.md skill links run under Bazel too.
TestZZStdioNotLeaked falls back to TestMain's pre-run streams instead of
skipping in a shard without its baseline.

tools/bazel/equivalence_allowlist.txt shrinks from 20 skip entries to the
two cmd/bd tests of plain go test's own bd build fallback, which Bazel never
takes; pr-preflight-platforms now runs them on Linux, macOS and Windows. The
scripts-go-checks scripts-test and allowlisted legs, their scripts
(scripts-go-test.sh, allowlisted-go-tests.sh, run_allowlisted_go_tests.py)
and main.yml's --compile-only warm for them are removed. The vet leg stays
(ga-96smfk.18).

Refs: ga-96smfk.16

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 22:20:16 +00:00
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
Julian Knutsen
f66375459f
test(bazel): runfiles helpers + declared inputs for scan-guard tests (#6828)
* test(bazel): add internal/testutil/bazeltest runfiles helpers

Repository-path resolution for tests that works identically under plain
go test (package cwd, full checkout), bazel test locally, and remote
execution (declared runfiles only):

- IsBazel, RepoRoot (BEADS_TEST_REPO_ROOT, then the runfiles workspace
  root, then a go.mod walk), OverrideRoot (drop-in condition for existing
  helpers; empty under plain go test), CallerDir
- Runfile for $(rlocationpath) values, GOROOT for type-checking tests
- ShardFreeEnv for helpers that re-exec a test binary

Every helper reduces to the pre-Bazel behavior under go test.

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

* test(bazel): declare source/data reads for 14 scan-guard targets

Source-scanning and repo-file tests read files their Bazel targets never
declared, so they failed under `bazel test` (and could not run on remote
workers at all). Declare narrow inputs as `data` and resolve paths through
bazeltest where the test located the tree via runtime.Caller:

- tools/bazel/go_srcs.py (run by `make bazel-sync` after gazelle) keeps a
  managed `go_srcs` filegroup in the packages whose Go source tests scan,
  plus `//internal/storage:tree_go_srcs` for the storage-tree walk. Bazel
  globs stop at package boundaries, so the aggregate needs one filegroup
  per package; the script keeps it in sync and gazelle-stable.
- Hand-written narrow inputs: //internal/storage/schema:migrations,
  //:docsync_files, //plugins/beads:plugin_files, and exports of
  .gitattributes, .claude-plugin/marketplace.json, cmd/bd list.go and
  ready.go, testutil/testdoltcommon.go, scripts README.md and the release
  catalog, each visible only to its consumer.
- runtime.Caller-based roots in backend, backend/conformance,
  internal/storage, internal/formula and test/docsync now go through
  bazeltest.CallerDir / OverrideRoot; relative-path tests need data only.
- integrations/ leaves .bazelignore (it is still gazelle-excluded) so the
  docsync link check can declare integrations/beads-mcp/PYPI.md.

Under --config=prcore every target reports the same PASS/SKIP/FAIL test
set as `go test -race -short` for its package, locally and remotely.
Plain `go test` behavior is unchanged.

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

* test(bazel): guard generated go_srcs and harden bazeltest root override

- tools/bazel/go_srcs.py: add --check (print diff, exit 1 on stale blocks);
  new `make bazel-sync-check` target runs it.
- scripts/bazel_policy_test.go: under go test, assert every tree_go_srcs
  (//internal/storage) lists exactly the BUILD.bazel packages below its
  root, run go_srcs.py --check, and forbid BUILD files under docs/ and
  engdocs/ (they would cut subtrees out of //:docsync_files).
- bazeltest: honor BEADS_TEST_REPO_ROOT only when it holds go.mod
  (RepoRoot fails loudly otherwise); drop the unused GOROOT() helper,
  whose compiled-in branch could never fire under rules_go.
- scripts/ci/lib/test-env.sh: unset BEADS_TEST_REPO_ROOT.
- Document the hand-listed out-of-tree link targets in //:docsync_files.

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

* build(bazel): re-sync BUILD files with main

Regenerated with make bazel-sync after commits that landed while the
scaffold PR was in CI (new internal/execenv, gitenv, gitignore packages
and new sources/deps).

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

* test(bazel): declare init_safety_help.go for docsync

TestInitSafetyCLIHelpCoversReCloneGotchas (#6431) reads
cmd/bd/init_safety_help.go; export it to //test/docsync only.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 08:24:08 -07:00
Julian Knutsen
57ef364501
build(bazel): side-by-side Bazel scaffold + policy tests (#6798)
* build(bazel): add side-by-side Bazel scaffold (module + gazelle)

Add a Bzlmod Bazel build alongside the Go toolchain. `go build` and
`go test` are unchanged; nothing in CI invokes Bazel yet.

- MODULE.bazel: rules_go 0.63.0, gazelle 0.53.0, Go SDK 1.26.7 (matches
  the go.mod toolchain directive), go_deps from go.mod.
- ICU policy (engdocs/ICU-POLICY.md): a go-mysql-server gazelle_override
  selects the pure-Go regex backend and excludes regex_cgo.go, and
  .bazelrc builds with --@rules_go//go/config:tags=gms_pure_go, so no
  target depends on go-icu-regex or links libicu.
- third_party/patches: three module_override patches for dolt deps that
  ship WORKSPACE-era BUILD files, adapted from the gascity project.
- .bazelrc: prcore/ci test configs (inert for now; they match pr-core's
  test selection, not yet its environment isolation) and a generic
  remote-exec config with a bounded remote timeout. Executor endpoints and
  TLS credentials come only from a gitignored .bazelrc.local/user.bazelrc
  or a CI rc outside the workspace.
- .bazelversion pins Bazel 9.2.0; .bazelignore skips separate modules,
  non-Go trees, nested agent worktrees (.claude, .worktrees) and local
  data/output dirs (.beads, .dolt, dist, .runtime, tmp), so a primary
  checkout neither builds nor gazelle-rewrites nested worktree copies.
- Gazelle-generated BUILD.bazel files for every Go package.
- Makefile: `make bazel-sync` (gazelle + bazel mod tidy).
- .gitignore: bazel-* output symlinks and machine-local rc files.

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

* test(bazel): policy tests for the Bazel configuration

Add scripts/bazel_policy_test.go, plain Go tests that run under both
`go test ./scripts` and `bazel test //scripts:scripts_test`:

- MODULE.bazel go_sdk.download version equals the go.mod toolchain.
- ICU policy: .bazelrc sets gms_pure_go for build, the go-mysql-server
  gazelle_override excludes regex_cgo.go, and the root BUILD.bazel
  carries `# gazelle:build_tags gms_pure_go`.
- .bazelversion pins an exact Bazel release.
- .bazelrc.local and user.bazelrc are gitignored (parsed from .gitignore
  and cross-checked with git check-ignore when in a checkout).
- No remote-execution endpoints or credentials in committed bazelrc-like
  files, Markdown docs or .github/**: remote/BES/TLS flags
  (--remote_executor, --remote_cache, --bes_backend, --remote_header,
  --tls_client_certificate, ...) with a literal value, with or without a
  URL scheme, and non-loopback gRPC URLs in rc/.github files. Placeholders,
  $VARIABLES, and loopback are allowed; Markdown gRPC URLs (OTel exporter
  docs) are not flagged. Skipped outside a git checkout, e.g. in the Bazel
  sandbox.

Each check is a pure function also exercised against fixtures that break
the invariant. The files the tests read are declared as data via
//:bazel_policy_files so they resolve from runfiles under Bazel.

scripts/check-build-tags.sh now treats Bazel invocations as governed by
.bazelrc: the shell command segment that invokes Bazel (split on &&, ||,
;, |, $( and backticks) is exempt from the per-line `go` tag check, while
a bare `go` in another segment of the same line is still flagged. When
any scanned file invokes Bazel (or .bazelrc exists) .bazelrc must set
--@rules_go//go/config:tags=gms_pure_go for build.
scripts/check_build_tags_test.go covers both in a temp repository.

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

* fix(scripts): split bazel lines in pure bash so check-build-tags works with BSD sed

BSD sed (macOS) does not expand \n in s/// replacements, so the segment
split never happened and the Bazel-exemption tests failed on macos-latest.

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

* test(scripts): skip check-build-tags tests when bash lacks mapfile

macOS runners use /bin/bash 3.2, which has no mapfile; check-build-tags.sh
has always required bash >= 4, so the new tests are skipped there.

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-27 03:41:02 -07:00
Julian Knutsen
b3d17caa6d Merge release/1.3.0 into main (post-tag forward-port)
Forward-ports the 38 commits that shipped on release/1.3.0 (tagged v1.3.0 at
f45b249ce) into main, as RELEASING.md mandates after a tag. None of them had
ever been forward-ported. Recorded as a merge so main becomes a superset of
the release branch and the lineage is in the history.

Migration ordinal collision (the reason this needed a human-shaped merge):
both branches independently claimed clone-local ignored slot 0026 under
different filenames, so git merged both in with no conflict and left the
series with two migrations at ordinal 26 — a single-integer cursor cannot
address that, and migrationSource.list() panics on it.

Main's ignored/0026_add_wisps_current_revision is renumbered to 0027.
Release's 0026_dep_rekey_dedup_marker is in the shipped v1.3.0 tag, so field
stores have already recorded it at 26 and it can never move; main's twin has
never shipped in any release, so it is the one that is free to move. 0027 was
unused in the ignored series (both sides topped out at 26).

This trips check-migration-hygiene.sh Check C (frozen migrations), which has
no exemption mechanism. That is expected and accepted: breaking the collision
requires a rename, and the ignored series' cursor table is itself dolt-ignored,
so its content hashes are clone-local and never participate in the cross-clone
ContentHashSkew comparison that Check C exists to protect. Main's 0067 body is
deliberately NOT edited for the same reason in reverse — it is main-plane and
its hash IS compared across clones.

Conflicts resolved:

  CHANGELOG.md                       release's finalized [1.3.0] section kept
                                     byte-identical; main's two unreleased
                                     entries (#6023, #5859) moved up under
                                     [Unreleased] where they belong
  cmd/bd/init_safety.go              union — release's added paragraph is
  cmd/bd/init_safety_help.go         accurate against the merged code (three
                                     exit-12 sources, incl. init.go:3147)
  internal/storage/uow/dolt_sql_provider.go
                                     kept main's newProvider refactor AND
                                     release's readOnly field/assertion;
                                     newProvider gained readOnly: opts.readOnly
                                     so release's read-through-refused-migration
                                     behavior survives main's refactor
  .github/workflows/main.yml         single -timeout=30m per release's #6091
  scripts/ci_workflow_test.go        design (flag on the invocation, not in
                                     matrix.test-flags); the shadowed 25m in
                                     matrix.test-flags removed
  scripts/migration-test/lib/versions.sh
                                     union — main's darwin/arm64 corpus plus
                                     release's v1.2.2 linux/amd64 entry
  integrations/beads-mcp/uv.lock     ruff 0.16.5 (release, newer); block is
                                     internally consistent, uv lock --check ok
  default.nix                        vendorHash left at main's value and is
                                     KNOWN STALE — see below

Version stamp lands at 1.3.0 (main had been sitting at the previously-released
1.2.2, this project's between-releases pattern). check-versions.sh: 24/24.

Known follow-up: default.nix vendorHash. The merged go.mod/go.sum is a genuine
union (release's kin-openapi/oapi-codegen bumps + main's newer Dolt stack) and
matches neither side, so neither recorded hash is correct. It must be
regenerated with scripts/update-nix-vendorhash.sh. The repo's automatic fixer
(update-vendor-hash.yml) is dependabot-only and will not run on this PR.
2026-09-15 22:09:13 +00:00
Athos Bernardes
a07794015f
migration-test: port the historical-Dolt upgrade corpus to darwin/arm64 (#6072)
* migration-test: port the historical-Dolt upgrade corpus to darwin/arm64

The harness was Linux/amd64-only, gated by an unconditional uname check.
Porting it turned out to need more than the linux-only STRICT_RELEASE_ASSETS
table: sourcing lib/versions.sh's associative arrays fails outright under
macOS's bundled bash 3.2 (no `declare -A` support), `realpath -e` and
`find -printf` are GNU-only, the release-binary version probe's sandboxed
PATH=/usr/bin:/bin has no `timeout` on macOS, and the v0.9.1 source build's
own scratch dir was never canonicalized against macOS's symlinked TMPDIR.

- lib/versions.sh: guard on bash >= 4 with an actionable message instead of
  a cryptic mid-file parse error; add reviewed darwin|arm64 asset+checksum
  entries for all 12 corpus versions (existence confirmed via `gh release
  view`, checksums taken from each release's own checksums.txt — the same
  provenance as the existing linux|amd64 rows, cross-checked byte-for-byte
  against them).
- historical-dolt-upgrade-test.sh: accept linux/x86_64 or darwin/arm64
  (still an explicit allowlist, not a generic passthrough); replace the two
  `find -printf` uses with a portable per-entry describer (Linux keeps the
  original find command unchanged) and a plain `-exec basename`.
- lib/binary.sh: add resolve_existing_path (realpath -e on Linux, plain
  realpath elsewhere — verified to already require existence on macOS);
  resolve `timeout` to an absolute path before entering the sandboxed probe
  rather than widening its PATH; canonicalize the v0.9.1 build's scratch dir
  immediately after mktemp; parameterize its GOOS/GOARCH/cache-path instead
  of hardcoding linux/amd64.

Validated natively on darwin/arm64: syntax-checked under bash 5; the
existing legacy-bridge-test.sh smoke suite passes unchanged (including its
assertion that the sandboxed probe PATH stays exactly /usr/bin:/bin); real
end-to-end runs of run.sh (the actual CI entrypoint) pass for the embedded
Dolt lane (v1.1.2), the external server-Dolt lane against the pinned Dolt
runtime (v0.62.0 — production's current schema), and a classic-SQLite bridge
lane (v0.49.6). linux|amd64 behavior is unchanged (existing entries and
branches are untouched byte-for-byte; only new darwin-only branches added).

v0.9.1's own lane gets past every platform fix here and then hits an
unrelated, pre-existing bug: migrate-legacy-to-current.sh's bridge
comparison stringifies timestamps as local-time-with-offset on the old side
and UTC-Z on the candidate side, so it only happens to line up when the
runner's local timezone is UTC (true for CI, false here). Left unfixed as
out of scope for a platform-corpus change — noted for the reviewer.

Ref: ga-9sghx (Gas Town HQ)

* fix(ga-9sghx): address PR #6072 review feedback

bee-ghosttrack's review (CHANGES_REQUESTED) found resolve_existing_path's
non-Linux branch assumed BSD realpath, but Homebrew coreutils puts GNU
realpath on macOS PATH too — and GNU's flagless default silently accepts
a missing final path component, dropping the existence guarantee this
function promises callers. Add an explicit [ -e "$1" ] guard so it holds
regardless of which realpath resolves.

Also skip the v0.63.3 embedded-Dolt lane specifically on darwin/arm64:
that release's published darwin/arm64 binary was built without CGO and
can't open an embedded-Dolt store at all — an upstream release artifact
limitation, not fixable here. Skipping just that one version (with an
explicit, non-silent message) keeps ./run.sh from being permanently red
on a Mac; every other embedded-Dolt version is unaffected.

Verified: legacy-bridge-test.sh passes; --version v0.63.3 now exits via
the explicit skip instead of the CGO error; resolve_existing_path
unit-checked directly for both the existing-path and missing-path cases.

---------

Co-authored-by: Test <test@example.com>
2026-09-02 18:38:57 -07:00
Julian Knutsen
362eecc6bf
test(migration): wisp-plane upgrade corpus — seed and assert the ignored-plane classes the 1.3.0 chain depends on (#6049)
* test(migration): seed and assert the wisp plane on the v1.1.2 upgrade lane

The migration-test harness has never seeded a wisp. Its shared fixture is three
issues, a dependency, a label and a comment, and thirteen version lanes assert
its exact `length == 3` shape — so the plane that 1.3.0's chain actually
rewrites (wisps, wisp_dependencies, wisp_comments, leases, events and the
ignored-migration cursor) reaches the candidate empty, and every migration in
main 0054-0066 plus ignored 0012-0025 runs as DDL over zero rows.

Add a separate `run_wisp_plane_upgrade` lane in its own workspace, dispatched
after the shared embedded lane the way the v0.55.4 second lane already is, so
no existing assertion changes. It seeds two issues and five wisps covering the
open, closed, blocked-by-issue, blocked-by-wisp and conditional-blocks classes,
plus a wisp comment, a wisp label, an issue-blocked-by-wisp edge through
dependencies.depends_on_wisp_id, and a file:// Dolt remote published with the
old binary.

There is no `bd dolt sql`, so plane state is read with the already-pinned
external Dolt v2.1.8 CLI as a read-only oracle. `dolt sql -q` can exit 0 on
failure, so every read is decided by its CSV payload rather than its status.

Assertions and the trap each one guards:

  - wisp survival and row counts        gc must not collect a fresh closed wisp
  - updated_at stability                0059/ignored-0015 derived-state restamp
  - is_blocked truth table + bd blocked the wisp-aware blocker predicate
  - dolt_ignore superset                the #5947 read-before-write clobber
  - dolt_status clean                   migrations must not leave dirty tables
  - events row count across 0062        the drop/commit/recreate flip
  - leases + granted_node present       the #5366 contradicted-cursor replay
  - unblock on close                    blocks vs conditional-blocks release
  - journal shape + wisp writability    0064/0066 and 0060 storage_class
  - full-fingerprint second open        the ignored track, which `Schema
                                        already at vN` cannot see at all

That last one matters most: MigrateUp reports `applied` from the main track
only and never adds appliedIgnored, so the harness's existing no-op check is
structurally blind to an ignored-track replay. The fingerprint is the only
guard there is.

Extend the pinned-runtime gate and the workflow's Dolt install step to the
wisp-capable versions, which now need that binary as an oracle. Cache keys are
untouched: corpora are seeded fresh per run and the cache holds only release
binaries keyed by asset checksum.

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

* test(migration): extend the wisp lane to v1.1.0 and the pre-split v1.0.1 regime

v1.1.2 alone only proves the post-split regime. v1.0.1 is the one source in the
corpus that still stores wisp dependencies in the legacy single-target shape
(issue_id, depends_on_id) and has no ignored-migration cursor at all, so it is
the only lane where the candidate has to perform the ignored/0003-0005 split,
the 0047 delegate repair and the 0058 heal on populated rows, and bootstrap the
ignored cursor from nothing rather than find both already done.

Add verify_wisp_dependency_split: the three split target columns exist, the
legacy column is gone, and each seeded edge lands on the right target —
wisp-on-issue and conditional-blocks in depends_on_issue_id, wisp-on-wisp in
depends_on_wisp_id, and the issue-on-wisp edge in the main dependencies table's
depends_on_wisp_id. Mis-homing those rows is the "duplicate primary key given"
hazard class in migrations/README.md, and it is invisible to every count-based
check.

Make verify_no_restamp regime-aware, because which migrations replay is a
property of the source cursor. 0059 and ignored/0015 self-assign
`updated_at = updated_at`; their predecessors 0046, 0047 and ignored/0007 do
not. A v1.0.1 store replays all of them, so every non-closed row legitimately
moves. A v1.1.x store has 0046/0047 behind its main cursor, so issues must not
move at all — but its ignored cursor says 0011 while leases.granted_node does
not exist, the sentinel disbelieves the cursor, and the ignored series replays
anyway (#5366), dragging in unguarded ignored/0007.

What is gated in both regimes is the part that is unconditionally true: closed
rows never move, because every recompute is scoped
`WHERE status NOT IN ('closed', 'pinned')`. That bites the moment one forgets
its scope. The tighter guard on everything else is the idempotence fingerprint,
which requires a second open to move nothing at all.

Record the per-version capability probe results as a table rather than leaving
them as assumptions, and run bd doctor quick on every wisp lane instead of only
the ones with a remote.

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

* test(smoke): add a tolerant wisp-plane scenario to the release gate

cross-version-smoke.yml runs upgrade-smoke-test.sh as the release gate, and all
six of its scenarios work entirely in the versioned plane. The wisp tables
therefore reach the candidate empty, and 0054-0066 plus ignored 0012-0025 only
ever run as DDL over zero rows — the same blind spot Scenario 6 was written to
close for the dependencies split.

Scenario 7 seeds a wisp with the old binary, gives it a blocker edge so the
is_blocked recompute has real work to do, upgrades, and then checks the
surfaces that break when the replay is wrong: the wisp is still listed, the
blocker queries stay wisp-aware without erroring, the wisp is still writable
through the migrated storage_class default, and doctor quick is happy.

The matrix reaches back thirty releases on a tag push, so a binary that cannot
create a wisp or cannot produce a parseable id passes with a SKIP instead of
failing. Same tolerant, grep-based, dependency-free style as the rest of the
file: no jq, no Dolt CLI.

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

* test(migration): cover the #5816 dirty tracked wisp-table state

#5816 is still open: an ignored-named table that is tracked at HEAD *and* dirty,
with ignored migrations pending, hard-locks the open. Nothing in either upgrade
harness has ever constructed that state, so the containment surface is
untested.

It is not reachable from clean OSS lineage — every release since v0.63.3
registers the dolt_ignore patterns before creating the tables — so the scenario
builds it deliberately: force-add and commit the wisp tables through the pinned
Dolt CLI, then dirty one again with an ordinary old-binary wisp write. That is
the shape real clones from forks and older-behavior lineages arrive in, and it
is the only place this file issues DML through the oracle.

Because the bug is open, the scenario deliberately does not gate on whether the
candidate accepts or refuses. It gates on what must hold either way: the
command terminates rather than hard-locking, and no wisp rows are lost. A
refusal additionally has to name the dirty tables instead of failing opaquely.
Carries a TODO(#5816) to tighten to must-succeed once the fix lands.

Observed on the current candidate: a clean refusal in about a second naming
`wisps`, with all rows intact.

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

* test(migration): add v1.2.2 to the corpus and make the lane dispatch array-driven

v1.2.2 is the tag field upgrades actually start from — the recovery release that
superseded the accidental v1.2.1 — and it has never been in this corpus. It is
the v1.1.2 tree re-tagged, so it adds no new storage regime; it closes the
"the exact tag in the field was never tested" gap for the price of one matrix
job.

Adding it exposed a latent trap: the dispatch loop carried its own hardcoded
copy of the embedded-Dolt version list, so a version added to
EMBEDDED_DOLT_VERSIONS in lib/versions.sh was silently routed into the
server-Dolt bridge lane instead, and failed there with a confusing "candidate
list did not refuse with explicit migration is required". Dispatch on
membership of the array that already declares the corpus, so the list exists
once.

Asset checksum verified against the published beads_1.2.2_linux_amd64.tar.gz.
No existing cache-identity string changes.

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-28 23:24:39 -07:00
Julian Knutsen
ed382cbdb8
Pin authenticated historical release catalog (#5100)
* Pin authenticated historical release catalog (bd-9q3.1)

Establish the exact 122-version SumDB-backed source universe and record proxy prereleases, archived repository-only tags, current repository-tag drift, and optional release asset provenance. Offline validation pins the complete reviewed catalog identity.

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

* Simplify validateCatalog into phase helpers

Extract validateCatalog's validation phases into validateVersionEntries,
validateEntryProvenance, validateTagDrift, validateSourceRelations, and
validateExclusions, dropping its cyclomatic/cognitive complexity from
43/43 to 11/8. Behavior and error paths are unchanged: the pinned catalog
digest and offline hermetic validation still pass.

Also derive the proxy @v/list URL from modulePath so version listing and
module downloads cannot drift to different module identities.

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

* fix(review): dedupe bd init legacy-upgrade guard; document release catalog anchor

Maintainer review fixups for PR #5100 (adopt-pr review loop, attempt 1).

cmd/bd/init.go: remove the duplicate guardLegacyUpgradeWorkspace block in bd init. After the rebase onto feature/v12-u0-history-20260719 the base already carried the guard, so the PR's added block was a byte-identical second call that re-ran the read-only workspace classification twice and misrepresented the diff intent. A single guard call before the existing-workspace safety checks is retained; behavior is unchanged (reviewer-confirmed idempotent).

scripts/migration-test/catalog/README.md: document that the pinned release catalog is currently a self-validated reference anchor (pinned SHA-256 identity + strict offline validator + go test ./... digest gate) whose intended consumer is the stacked v1.2 upgrade-census / runtime-schema coverage work, since no migration-test harness consumes it yet.

Addresses the two minor findings from the Claude + Codex review synthesis (decision: approve; scorecard 971/1000). Contributor commits preserved.

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

* fix(migration-test/catalog): correct semver prerelease ordering

versionCompare tie-broke same-core versions with strings.Compare, so
v1.2.3-rc.10 sorted before v1.2.3-rc.2 and a stable release sorted before
its own prereleases. generate and validate share this comparator, so a
wrong canonical order self-validates against the pinned digest and the
anti-tamper check cannot catch it. Replace the lexicographic tiebreak with
a SemVer 2.0.0 section 11 prerelease comparator (numeric-aware identifier
comparison, numeric < alphanumeric, longer set wins, stable > prerelease)
and add regression coverage including rc.2 vs rc.10. The checked catalog's
canonical order and pinned digest are unchanged: its only same-core group,
v1.1.0-rc.1/-rc.2, sorts identically.

Maintainer adoption fixups for PR #5100 review:
- tighten origin-ref provenance from any refs/ prefix to the exact
  refs/tags/<version> or refs/heads/main shapes actually used
- key the digest-pinned Catalog/Entry/SourceZip/AssetRecord composite
  literals to avoid silent field-shift on a future struct reorder
- drop the inert GONOSUMDB= env entry and print the recomputed SHA-256
  from generate to make deliberate digest updates less error-prone

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-18 12:25:44 -07:00
Julian Knutsen
92ad0295f1
Guard and qualify historical upgrades to v1.2 (#4907)
* Add sealed-copy SQLite migration bridge (bd-mvh)

Create a fresh current workspace from a fingerprinted copy of an authenticated historical SQLite workspace. Keep every historical executable inside an isolated destination and reject malformed or semantically lossy cutovers without touching the source.

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Test User <test@test.com>
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot

* Refuse implicit historical workspace upgrades (bd-mvh)

Detect historical SQLite and legacy Dolt layouts before config migration, version tracking, init, bootstrap, doctor, or store construction. Require the sealed-copy bridge while preserving current shared-server admission against the explicitly selected workspace.

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Test User <test@test.com>
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot

* Qualify authenticated historical upgrades (bd-mvh)

Replace generic recipe discovery with a fixed, checksum-pinned corpus spanning the reviewed SQLite, server-Dolt, and embedded-Dolt eras. Assert source isolation, representative data fidelity, schema idempotence, and rollback retention while keeping historical executables inside bounded temporary environments.

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Test User <test@test.com>
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot

* Add authenticated legacy SQLite reader (bd-tku)

Let the current binary read the exact v0.49.6/v0.50.3 SQLite contract from a sealed private DB/WAL copy and emit canonical JSONL for the normal fresh-Dolt import path. Reject schema drift and values that current import would lose, default, truncate, or deduplicate.

Qualify both authentic releases end to end, including current DATETIME(0) canonicalization and reader-to-fresh-import timestamp equality.

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

* Fix empty embedded-root upgrade bypass (bd-e6m)

Require an actual embedded Dolt repository marker before current layout precedence can suppress historical SQLite or legacy Dolt refusal.

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

* fix(migrate): maintainer review fixups for legacy SQLite upgrade PR

- decompose the legacy-workspace guard and extract the dependency-row loader
  (behavior-preserving), and align the legacy SQLite reader projection with
  issueops.ScanIssueFrom arity after the 0060/0061 rebase, guarded by a
  projection arity test.

- assert the historical-upgrade harness schema no-op by shape
  ("Schema already at v<N>") instead of a hardcoded v59, so the migration-test
  matrix stops reddening on every schema bump (candidate now prints v61).

* Fix historical upgrade review blockers (bd-mvh)

Route direct SQLite lanes through the current authenticated reader, guard no-store commands before legacy workspace mutation, and move coarse embedded repository detection behind the storage adapter. Restore the legacy reader projection contract and verify source-preserving behavior across the repaired paths.

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

* Fix historical upgrade edge cases (bd-mvh)

Refuse ambiguous local server-Dolt roots before storage opens and normalize nullable legacy SQLite sentinel fields during authenticated export.

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

* Fix final historical upgrade review blockers (bd-mvh)

Make explicit server selection outrank stale embedded repository markers, so ambiguous local server roots still fail closed.

Permit zero-record cutovers only through the authenticated direct SQLite reader, verify the empty round trip against a fresh current export, and align the upgrade guidance with the enforced admission matrix.

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

---------

Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: Test User <test@test.com>
2026-08-06 18:45:04 -07:00
matt wilkie
4c3df8dd6b
test(migration): assert bd ready/blocked/close on migrated DB (mybd-ihg5) (#4584)
The migration-test harness (scripts/migration-test/) already builds a
BUG->TASK dependency fixture (create_dataset in lib/features.sh: `dep add
"$bug_id" "$task_id"`, i.e. bug depends on task, task is the blocker) and
migrates it in place with the candidate binary, but only verified fidelity
via bd list/show JSON. It never exercised bd's blocker-aware query paths on
the migrated DB, which is exactly the surface of the historical `bd close`
Dolt errno 1105 failure on a stale post-migration dependency schema
(verified manually for the 1.0.5 release in mybd-kdxj).

Add check_blocker_paths() in lib/snapshot.sh, run against the migrated DB
after check_fidelity in all three harness outcomes (direct upgrade, recipe
fallback, stepping-stone) plus the --self-test path:
  - bd blocked lists the dependent (bug) while the blocker (task) is open
  - bd ready excludes the dependent but includes the open blocker
  - bd close on the blocker succeeds post-migration (the errno 1105 path)
  - bd ready then lists the dependent (unblock/is_blocked recompute)

Violations fold into the existing violation count and flip AUTO/MANUAL
results to BLOCKED so a regression fails the harness loudly, matching the
existing report.sh exit-code convention. Skips gracefully when the source
version's dataset has no dependency.

cross-version-smoke.yml's parallel gate (scripts/upgrade-smoke-test.sh)
already added equivalent Scenario 6 blocker-path assertions in #4238; no
change needed there.

Verified: `--self-test` (candidate -> candidate, no downloads) and a real
`v0.63.3 -> candidate` direct upgrade both pass with the new BLOCKER-CHECK
line green.


Agent-Signature: claude-opus-4-8-high on behalf of matt wilkie

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 13:32:37 -07:00
Ben Madore
3b39ce577a
docs: update user-facing URLs from steveyegge/beads to gastownhall/beads
Co-authored-by: Ben Madore <823868+madorb@users.noreply.github.com>
2026-04-24 08:17:42 -07:00
matt wilkie
164e25195e
fix: remove unsupported stepping-stone migration paths (#3073) (#3110)
Multi-hop upgrade paths through old releases are inherently broken
because intermediate binaries have bugs that cannot be patched
retroactively. Users should upgrade directly to the latest release.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 12:56:56 -07:00
matt wilkie
8d94fafd0c
fix: preserve dependencies and labels in SQLite-era JSONL migration (#3079) (#3082)
All three test plan items verified:
- Migration harness: 0 fidelity violations, deps and labels replayed correctly
- Graceful skip for absent tables confirmed
- Unit tests pass (unrelated /tmp disk quota failures only)
2026-04-06 20:08:55 -07:00
matt wilkie
4fc0459740
fix: unblock v0.62.0 migration test by allowing Dolt auto-start (#3072) (#3076)
BEADS_TEST_MODE=1 disables Dolt server auto-start and forces port 1,
which makes every bd command fail for server-era versions (v0.50-v0.62).
Change default to 0 since the harness runs in isolated temp-dir
workspaces.  Also make epic creation non-fatal with task fallback.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 16:02:13 -07:00
matt wilkie
af12d6f720
fix: export data before clearing metadata in server→embedded migration (#3075)
The server_to_embedded recipe deleted metadata.json before attempting to
export data via the old binary. Without metadata.json, the old binary
couldn't locate its Dolt server configuration and returned empty results.
The candidate's init then created a fresh empty database, silently losing
all data.

Reorder the recipe to: (1) export via old binary while metadata.json is
still present, (2) clear metadata, (3) init with candidate, (4) verify
data exists, and (5) reimport from JSONL if the candidate DB is empty.

Fixes #3071

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 16:02:09 -07:00
matt wilkie
0537368b01
fix: unblock SQLite-era migration by clearing old DB before init (#3070) (#3077)
The sqlite_to_current recipe was blocked because the candidate binary's
init --from-jsonl refused to run when .beads/beads.db already existed
(checkExistingBeadsData guard). Fix by renaming old SQLite artifacts
(.beads/beads.db, metadata.json, config.json) to .pre-migration before
calling init.

Also switch sqlite3 extraction from -json flag to .mode json for
broader compatibility with older sqlite3 builds.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 16:02:06 -07:00
matt wilkie
e4fca03f6b
feat: add migration test harness for cross-era upgrade fidelity (#3067)
* wip: add migration test harness for cross-era upgrade fidelity

Rich dataset generator, field-level fidelity checker, and migration
recipes for SQLite/Dolt-server/embedded-Dolt eras. Addresses GH#2938
upgrade pain by testing and documenting working upgrade paths.

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

* fix: snapshot JSON format handling and self-test mode

- show --json returns array, not object — use jq array concatenation
- Field is issue_type not type in bd JSON output
- Normalize empty comment_count to 0 (show vs list field differences)
- Add --self-test flag for harness validation without old binaries
- Fix local variable outside function in self-test block

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

* ci: re-trigger Kilo Code Review

* address review: timeouts, env var docs, quoting

- Add BD_OP_TIMEOUT (30s) for bd operations via timeout(1)
- Add DOWNLOAD_TIMEOUT (60s) for curl binary downloads
- Document all environment variables in run.sh header
- Convert init_flags from word-split string to proper bash array

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

* fix: fall back to source build when release binary has missing shared libs

Downloaded release binaries dynamically link ICU (libicui18n.so.74),
which isn't available on all systems. Now download_binary verifies the
binary actually runs, and falls back to building from source with
gms_pure_go tag when it doesn't. Also applies gms_pure_go to
build_candidate for consistency.

Ref: gastownhall/beads#3065

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

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 14:30:35 -07:00