Commit graph

9 commits

Author SHA1 Message Date
matt wilkie
a97eec9739 Add atomic ready claim (GH-3570) 2026-04-28 07:11:13 -07:00
Robin Carswell
7358de6934
feat: add -C <path> flag to change directory before running (#3442)
* feat: add -C <path> flag to change directory before running commands

Adds a persistent -C/--directory flag (matching git -C) that calls
os.Chdir before .beads/ discovery or database initialisation. Allows
running bd commands against a different project without changing
directory first.

Example: bd -C ~/projects/myapp ready

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

* Avoid cwd mutation for directory flag

Resolve -C by binding command selection to the target project's .beads directory instead of calling os.Chdir. Add focused coverage for invalid targets and no process cwd mutation.\n\nCo-authored-by: Robin Carswell <2803445+rjc123@users.noreply.github.com>

* test: resolve symlinks in tempdir for macOS compatibility

t.TempDir() returns paths under /var/folders on macOS, but
resolveChangeDirBeadsDir canonicalizes via EvalSymlinks to
/private/var/folders. Resolve projectDir up front so the
expected and actual paths match on every OS.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-04-27 13:54:28 -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
Robin Carswell
34a580c1e9
feat: add --exclude-label flag to bd ready and bd list
Co-authored-by: Robin Carswell <2803445+rjc123@users.noreply.github.com>
2026-04-24 08:17:14 -07:00
matt wilkie
f443df1f2a
fix: resolve CI failures from flock, version bump, and lint (#2981)
* fix: resolve CI failures from flock, version bump, and lint

Three categories of CI failure on main after the v1.0.0 release:

1. rules.go lint/format: Fix gofmt alignment, errcheck on tw.Flush(),
   gosec G304 (add nosec comment), gosec G306 (use 0o600 perms).

2. doctor_test.go version tracking: The 'slightly outdated version'
   test used 0.55.0 which now has a major version diff from 1.0.0,
   correctly triggering a warning. Update expected status to match.

3. Embedded Dolt concurrent tests: The exclusive flock from #2571
   causes concurrent bd processes to fail with 'one writer at a time'.
   Update 58 concurrent test files to tolerate this expected error
   while still failing on unexpected errors and panics.

Amp-Thread-ID: https://ampcode.com/threads/T-019d5386-b41e-7138-bc81-6ea331b80760
Co-authored-by: Amp <amp@ampcode.com>

* fix: concurrent test post-conditions tolerate flock contention

With exclusive flock (commit 543e1943), only some workers can acquire
the lock in concurrent tests. Update post-conditions in 5 tests to:
- Only verify side effects from workers that succeeded (r.err == nil)
- Require at least 1 worker succeeds (fail if all hit flock)
- Log success/failure counts for visibility
- Still verify correct behavior for successful operations

Tests fixed:
- TestEmbeddedCloseConcurrent: remove Fatalf on failures, skip total count check
- TestEmbeddedDeferConcurrent: only check deferred status for successful workers
- TestEmbeddedUndeferConcurrent: only check open status for successful workers
- TestEmbeddedReopenConcurrent: only check open status for successful workers
- TestEmbeddedPromoteCLIConcurrent: only check permanent for successful workers

Amp-Thread-ID: https://ampcode.com/threads/T-019d5386-b41e-7138-bc81-6ea331b80760
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d5386-b41e-7138-bc81-6ea331b80760
Co-authored-by: Amp <amp@ampcode.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
2026-04-03 07:27:00 -07:00
matt wilkie
59b49c45f0 fix: add missing //go:build cgo tags to embedded test files and cmd
Several test files and one main.go that depend on CGO-only types
(EmbeddedDoltStore methods like Close, CreateIssue, GetIssue) were
missing //go:build cgo build tags, causing compilation failures when
building with CGO_ENABLED=0.

Files fixed:
- 67 cmd/bd/*_embedded_test.go files
- cmd/bd/metadata_filter_test.go (uses newTestStore from cgo-tagged helper)
- cmd/bd/doctor/federation_test.go (uses doctorTestServerPort/testSharedDB)
- cmd/bd/doctor/fix/migrate_import_test.go (uses fixTestServerPort)
- 6 internal/storage/embeddeddolt/*_test.go files
- internal/storage/embeddeddolt/cmd/main.go

Amp-Thread-ID: https://ampcode.com/threads/T-019d4938-40d4-73ae-89d1-1891a19a9a15
Co-authored-by: Amp <amp@ampcode.com>
2026-04-01 07:08:41 -07:00
coffeegoddd☕️✨
a35edfd28e /{internal,cmd,.goreleaser,.github}: embedded mode by default 2026-03-28 13:47:20 -07:00
coffeegoddd☕️✨
74e6ac7ecf /{cmd,.github}: fix tests and share go mod cache 2026-03-25 16:17:25 -07:00
coffeegoddd☕️✨
bc143e756d /cmd/bd: tests for additional commands 2026-03-25 15:57:20 -07:00