Commit graph

2 commits

Author SHA1 Message Date
CI Bot
1ce5e13cb1 refactor(show): share issue-detail assembly and normalize not-found (bd-hc1)
Lift the detail view - labels, dependencies with metadata, the three
cardinality counts, the comments-omitted flag, the shallow dependent
rows, and epic progress - into internal/workapi/detail.go behind
BuildIssueDetails + DetailSource, with store and UOW adapters. Both
copies in cmd/bd are deleted: bd show's direct assembly block and
proxiedBuildDetails, along with proxiedGetIssueOrWisp, proxiedCountDeps,
and proxiedCountComments. Fuzzy id resolution, --current, watch mode,
and the array-of-one output envelope stay CLI-local; so do
proxiedListDeps and proxiedGetComments, which feed terminal rendering
rather than the shared shape.

The point of the slice is the correctness fix, not the code motion. The
two storage seams disagree about "no such issue": the store wraps
storage.ErrNotFound, while db.issueSQLRepositoryImpl.Get returns a bare
sql.ErrNoRows that issueUseCaseImpl.get wraps with the id - never
storage.ErrNotFound, and never a (nil, nil) pair. workapi.GetIssueOrWisp
normalizes both shapes, plus nil-issue-with-nil-error, to the
storage.ErrNotFound sentinel, and short-circuits hard errors instead of
retrying them against the wisp table. Putting that in the shared
function - not in a caller - is what stops the next frontend
reintroducing either failure mode: `if err != nil || issue == nil` -> 404
reports a dropped connection as a missing issue, and its mirror image
ships a 500 for one.

Six proxied callers inherit the fix. Most visibly, `bd show <missing-id>`
in proxied mode printed "Error fetching x: get x: sql: no rows in result
set" and gate list answered "issue not found" for any backend failure at
all; both now say what actually happened.

Two behaviour deltas, both in error paths the corpus does not cover:
the proxied JSON path no longer swallows a failed --include-dependents /
--include-comments read (it errors like the direct path always has), and
a proxied lookup that fails for a non-not-found reason reports that
reason. Row streams are collected through storage.Iter on both seams,
so the direct path keeps its be-4d36f2 streaming and the proxied path
gains it; the comment collector now copies each value, per Iter's
documented pointer-reuse contract.

Also deletes shallowDependentsForJSON, which had no production caller
left; its be-4d36f2 guard moves to workapi as
TestBuildIssueDetailsShallowDependents.

Verification: protocol corpus unchanged structurally (no diff under
cmd/bd/protocol vs the base) and behaviourally (TestCorpusGolden green
with BEADS_PROTOCOL_REQUIRE_DOLT=1, before and after);
TestProxiedServerShow{,2,3} 50/50 subtests green with
BEADS_TEST_PROXIED_SERVER=1; TestEmbeddedShow 21/21 green with
BEADS_TEST_EMBEDDED_DOLT=1; TestShow_* green individually;
TestCoverage_ShowUpdateClose green; TestProxiedServer{State,SetState,
Label,Comment,GateList,GateCheck} green. TestShow_IDFlag and
TestCoverage_TemplateAndPinnedProtections fail identically on the base
commit (in-process harness state leakage), and TestCoverage_ShowThread
skips on the base commit for want of a reachable Dolt server.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 07:58:46 +00:00
CI Bot
af56541bb3 refactor(workapi): add internal/workapi with the list-filter builder and a pre-extraction golden (bd-fv4)
First half of the bd-fv4 extraction, kept separate so the golden table is
provably generated from the OLD code: this commit adds
internal/workapi/list.go (BuildListFilter, ListParams, ListConfig,
ConfigSource, DefaultListLimit) without touching cmd/bd's copy, records
what cmd/bd's buildListFilter produces for 35 inputs into
internal/workapi/testdata/list_filter_golden.json, and asserts the moved
builder reproduces it byte for byte.

DefaultListLimit = 50 is today's CLI default, not a new choice: both
cmd/bd/list.go's --limit flag and internal/config's list.limit default are
50 at HEAD.

The generator (cmd/bd/zz_list_filter_golden_gen_test.go) is scaffolding and
is deleted in the follow-up commit that removes cmd/bd/list_filter.go. Its
params -> listInput conversion cannot launder a mistake into a false pass:
the golden records the ListParams, so a mis-mapped field there makes the
replay fail rather than succeed.

Agent-Signature: claude-code-opus-5-unknown-reasoning on behalf of CI Bot
2026-07-31 05:42:40 +00:00