* fix(cli): emit claim failures as structured JSON under --json (wy-kxgf4)
Protocol v0 §E5 requires that with --json, errors are emitted as a JSON
object carrying at least "error" and schema_version: 1. bd honored that on
the not-found path but not on the claim paths: `bd update <id> --claim
--json` printed
Error claiming t04...-qqr: issue already claimed by alice
as plain text on stderr, so an agent driving bd with --json got an
unparseable line for the single most common contended-write failure it has
to branch on. The §E4 message contract held (the class and the holder/state
are named); the §E5 structured contract did not.
Route both claim paths (the direct-store loop in update.go and the
SQL-server proxied path) through a new reportClaimFailure helper: under
--json it emits {error, schema_version:1} via jsonStderrError, otherwise the
plain-text wording is unchanged, byte for byte, since §E4 tests pin it. The
JSON object goes to stderr so a mixed batch's stdout stays the clean array
of the issues that did update; the stream split itself is proposal OQ-5 and
is not pinned.
Un-skips TestProtocol_ErrorClass_ClaimFailures_StructuredJSON, which was
written against the clause and skipped pending this fix; it now passes and
becomes the guardrail. Full cmd/bd/protocol package green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(protocol): pin claim refusals on the single --json batch report (wy-kxgf4)
Adopt-PR review fixup for #4756, iteration 1. It takes option (a) from
the review synthesis, which is also maphew's CHANGES_REQUESTED fix: drop
the eager per-claim JSON object and pin §E4/§E5 on main's centralized
batch report instead.
Major 1 (claude+codex, maphew's blocker). Under --json, a refused claim
printed two JSON documents on stderr: the indented reportClaimFailure
object, then reportUpdateFailures' compact {error, failed,
schema_version} summary. A consumer reading the whole stream, or main's
documented "last stderr line", did not get one document. Main has
already moved on (wy-ghg0d). That summary reports every per-id refusal,
and the refused id's failed[] entry already names the class and the
holder or state:
{"error":"1 of 1 issues failed to update","failed":[{"id":"…",
"error":"updating issue: issue already claimed by alice"}],
"schema_version":1}
So cmd/bd/errors.go, update.go and update_proxied_server.go go back to
base byte for byte. reportClaimFailure and its two call sites are gone,
and text output, stdout and exit codes are main's. That supersedes the
helper the contributor commit describes. The PR now changes only tests,
so its title and squash message should say so at finalize. This also
covers the commit-message nit.
Major 2 (the proxied claim arm was not gated on `claim`, so a proxied
--assignee fence refusal read "failed to claim") is moot: the object it
mislabelled no longer exists. Both routes report through the same
summary. The message-drift minor is moot too. So is the synthesis's
follow-up about the direct route's non-claim fence refusals under
--json: they already land in the same failed[] list. The remaining
"updating issue:" vs "claiming issue:" entry prefixes are pre-existing on
main.
TestProtocol_ErrorClass_ClaimFailures_StructuredJSON stays un-skipped
and is re-pinned. It now requires:
- exactly one top-level JSON error document (the new jsonErrorDocs steps
over each decoded object, so failed[] entries are not counted);
- §E5's error and schema_version on that document;
- a failed[] entry for the refused id that names "already claimed" and
"alice", or "not claimable" and "closed".
TestProxiedServerUpdate gains
claim_conflict_json_reports_holder_in_failed_entry, the proxied
guardrail the review found missing. Two test-gap asks are dropped
because they targeted the claim-only branch, which is gone: the
--assignee --json negative case, and --format json (which reaches the
same jsonOutput-keyed reporter).
Validation (local Dolt 2.2.0 server, scrubbed env):
- cmd/bd/protocol, whole package, with BEADS_PROTOCOL_REQUIRE_DOLT=1:
109 pass, 1 pre-existing PTY skip.
- Mutant (this PR's original errors.go, update.go and
update_proxied_server.go restored): the protocol test and the new
proxied subtest both fail on "2 JSON error documents"; both pass at
this head.
- TestProxiedServerUpdate (proxied-lane env): all subtests pass.
- TestParityUpdate* (including TestParityUpdateJSONFailureReport) and
TestMultiIDUpdate*: pass.
- make ci-pr-lint: 0 issues (native, windows, darwin).
Follow-up, not in this PR: typed claim-conflict fields in failed[]
(issueops.ClaimConflictError's holder and status), so consumers need
not match on message text.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Conformance corpus WP4 from PROPOSAL-beads-protocol-v0.md §11: the errors,
memories, and versioning clauses that the manifest listed as TODO. All of them
are CLI-surface clauses, so they land in cmd/bd/protocol — the corpus an
alternate implementation replays against its own binary.
Pinned:
E3 exit codes 10 (remote-divergence refused), 12 (destroy-token missing),
130 (prompt canceled), asserted as LITERALS, not as bd's Go constants —
the clause freezes the numbers a script branches on.
E4 error classes distinguishable from the message alone: not-found,
already-claimed (naming the holder), not-claimable (naming the state),
validation.
E5 --json errors are {error, hint?, schema_version:1}.
M1 memory CRUD surface (remember / recall / memories / forget).
M4 reserved namespace: `bd kv set memory.*` refuses and names the owner.
V2 designated-migrator gate; BD_ALLOW_REMOTE_MIGRATE=1 is the way through.
V3 schema-skew refusal, and the BD_IGNORE_SCHEMA_SKEW downgrade to a warning.
Rebased onto origin/main and the exit-130 prompt deadline widened to 120s: that
case is the one init test on the SUCCESS path (initEnv pins the suite's Dolt
server), so it pays a full store creation before the wizard prompts — the old
15s deadline fired mid-init and misreported a missing prompt (wy-wst4r).
Landed via wy-wst4r after the original close of wy-ge2h8 cited a wyvern-side
doc-only commit and left this 1005-line corpus stranded on a local branch.
Agent-Signature: claude-code-opus-4.8-high on behalf of Steve Yegge