Skip to content

Improve bd where performance in worktree fallback#3195

Open
osamu2001 wants to merge 11 commits intogastownhall:mainfrom
osamu2001:bd-where-is-slow
Open

Improve bd where performance in worktree fallback#3195
osamu2001 wants to merge 11 commits intogastownhall:mainfrom
osamu2001:bd-where-is-slow

Conversation

@osamu2001
Copy link
Copy Markdown
Contributor

Summary

  • keep bd where on the lightweight diagnostic path in worktree fallback cases
  • preserve existing bd where output without triggering full direct-mode initialization on lookup
  • normalize dotted init prefixes so issue_prefix stays aligned with the Dolt database name, and add regression coverage

Validation

  • ./scripts/test.sh ./cmd/bd -run '^(TestResolveWhere|TestIsSelectedNoDBCommand_Where)$'
  • BEADS_TEST_EMBEDDED_DOLT=1 ./scripts/test-cgo.sh -run '^TestEmbeddedWhere$' ./cmd/bd
  • BEADS_TEST_EMBEDDED_DOLT=1 ./scripts/test-cgo.sh -run '^TestEmbeddedInit/(prefix_dot_sanitized|auto_detect_dotted_dirname)$' ./cmd/bd
  • BEADS_TEST_EMBEDDED_DOLT=1 ./scripts/test-cgo.sh -run '^TestEmbeddedInit$' ./cmd/bd
  • manual timing in /Users/osamu/.local/share/tb/timber-7z
    • bd where --json: about 0.10s

intent(where): timber-7z reproduces bd where at roughly three seconds while list and show stay under a tenth of a second
decision(where): treat where like context so it resolves beads_dir and database_path without opening the store
rejected(where-prefix): live issue_prefix lookup from the server-backed config because it reintroduced the same multi-second roundtrip; follow-up is tracked in beads-ayf
constraint(where): the fast path can only show prefix when issue-prefix is configured in config.yaml
intent(where): losing prefix in bd where was a functional regression even though the command became fast
decision(where-prefix): reopen a scoped read-only store from the resolved dbPath so issue_prefix comes back without re-running the old worktree discovery path
constraint(where): prefix recovery still has to stay cheap enough for timber-7z bare-parent worktrees; cold runs stay around one second and warm runs around five hundredths
learned(where): the slow part was the old command path resolution, not the narrow read-only config lookup once dbPath was already known
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

intent(where): keep selected-db routing inspectable through `bd where` even when only metadata is available for the target workspace

decision(where-prefix): trust config.yaml for selected server-mode workspaces and skip read-only store reopen unless the metadata indicates embedded storage
constraint(where-tests): explicit-db routing coverage executes real bd subprocesses, so the fixture runner now uses a timeout to fail fast on regressions instead of hanging indefinitely
intent(where-routing): preserve the same explicit-selector precedence guarantees that `context` already documents for selected no-db commands

decision(where-tests): add the missing `BEADS_DB > BD_DB` CLI case instead of broadening helper assertions so the precedence contract stays visible at the command boundary
constraint(where-routing): these regressions only show up when `bd` is executed as a subprocess with real env vars, so the test stays end-to-end rather than unit-only
…ekl.2)

intent(init): lock down the dotted-prefix sanitization path that now relies on config-derived prefix normalization before DoltDatabase is chosen

decision(init-tests): seed `.beads/config.yaml` before `bd init` instead of reusing `--prefix` coverage so the regression test exercises the config lookup branch directly
constraint(init-embedded): the normalization contract only matters once embedded init actually creates the store, so validation runs under the CGO embedded test path
…eads-yi0o)

intent(where-tests): make the explicit-db routing suite easier to extend without changing the command scenarios it exercises

decision(where-tests): extract a small package-local assertion helper instead of abstracting repo fixture setup so each case still shows its env and flag inputs inline
constraint(behavior): preserve the existing `where --json` contract checks for path, database_path, and prefix omission/presence exactly as before
intent(where-tests): increase confidence that selected workspace routing keeps the server-mode no-reopen guard while still allowing embedded and metadata-missing fallbacks

decision(where-tests): add focused unit cases around `shouldReadWherePrefixFromStore` instead of expanding slower subprocess coverage because the branching logic is package-local and deterministic
constraint(where-tests): clear server-mode env overrides inside the test so the expected metadata-driven decisions stay stable across developer environments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants