beads/tests/regression
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
..
BASELINE_VERSION test(regression): Dolt migration regression discovery (long-lived branch) (#1906) 2026-02-22 15:18:56 -08:00
DISCOVERY.md fix(label): report a no-op label edit instead of claiming it (#5988) (#6742) 2026-09-26 04:29:06 -07:00
discovery_test.go fix(label): report a no-op label edit instead of claiming it (#5988) (#6742) 2026-09-26 04:29:06 -07:00
regression_test.go fix: TestMain teardown was dead code after os.Exit — 101 dolt containers leaked over 6 days (#5876) 2026-08-20 06:06:32 -07:00
scenarios_test.go fix: repair PR4107 blocked-state corruption (#4139) 2026-05-24 05:37:52 -07:00