Skip to content

feat(cli): add status-get read twin for NIP-34 patch/pr/issue roots (#4112) - #4116

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue4112-nip34-status-read-20260802
Open

feat(cli): add status-get read twin for NIP-34 patch/pr/issue roots (#4112)#4116
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue4112-nip34-status-read-20260802

Conversation

@iroiro147

Copy link
Copy Markdown

Summary

  • Adds the read twin for the NIP-34 status setters: buzz patches status-get, buzz pr status-get, buzz issues status-get. All three resolve the currently-effective kind:1630-1633 status for a root event exactly per the protocol rule (latest from root author or repo owner wins; tie → lexicographic id), without every consumer re-implementing the reduce.
  • Deliberately takes the issue's second shape — a status get twin to the existing setter — so the read is primitive-shaped and mirrors the setter's flag surface (--repo-owner carries the same eligibility hint it does for status).
  • Output is a single JSON envelope: {root, state, implicit, kind, author, created_at, event}. event is the full winning status JSON so merge-commit / applied-patch (q) / revision references travel without a second query; implicit: true marks "no status ever set" distinctly from "an explicit open exists".

Changes

  • crates/buzz-cli/src/commands/git_status.rs (new): resolve_git_status + pick_winning_status (pure reduce, unit-testable without a relay) + cmd_git_status_get shared envelope printer. Root-kind fetch guards typo'd ids (fails loudly) instead of silently resolving implicit-open. Fetches via query_paginated(..., 1000) — bounded, cursor-driven like the rest of the CLI.
  • patches.rs / pr.rs / issues.rs: one dispatch arm each to the shared resolver with the right root kind (1617 / 1618 / 1621).
  • lib.rs: three StatusGet subcommand variants (--root for patches/pr, --issue for issues, --repo-owner optional on all three); surface-stability tests updated for the deliberate surface change.
  • 8 resolver unit tests: latest-wins, created_at-tie → id tiebreak, root-author + repo-owner eligibility, outsider ignored, minimal rule without --repo-owner, malformed rows skipped, non-status kinds skipped, empty history → None (implicit open).

Verification

  • cargo check -p buzz-cli / cargo clippy -p buzz-cli --lib -- -D warnings — clean.
  • cargo test -p buzz-cli --lib — 280 passed, 0 failed.
  • cargo run -p buzz-cli -- patches status-get --help and issues status-get --help render as expected.

Fixes #4112

…lock#4112)

`buzz patches status`, `buzz pr status`, and `buzz issues status` can all SET
kind:1630-1633 status events, but nothing in the CLI could read them back —
every consumer that wants to render current state (review dashboards, ci
bots, channel bridges) had to speak raw relay filters and re-implement
NIP-34's winner rule. This adds the read twin:

    buzz patches status-get --root <hex> [--repo-owner <hex>]
    buzz pr       status-get --root <hex> [--repo-owner <hex>]
    buzz issues   status-get --issue <hex> [--repo-owner <hex>]

Resolution implements the NIP-34 rule client-side over a single paginated
bridge query: among kind:1630-1633 events e-tagged to the root, only events
from the root author or repo owner (when the caller supplies the hint,
mirroring the setter's --repo-owner contract) are eligible; latest
created_at wins, ties break on lexicographic id. When no authoritative
status exists the implicit default state (open) is returned with
`implicit: true` so renderers can distinguish "never set" from "an open
status event exists" — the same asymmetry the setter's kind:1630 carries.

The output envelope contains the machine-friendly fields (state word, kind,
author, created_at) plus the full winning event JSON, so consumers that
need merge-commit / applied-patch (`q`) / revision references read them
without a second query. Root-kind fetch precedes resolution so a typo'd
root id fails loudly instead of silently resolving to implicit-open.

crates/buzz-cli/src/commands/git_status.rs is the shared resolver and
envelope printer; the three command files only wire a per-kind dispatch
arm. Surface-stability tests updated to reflect the three new subcommands;
8 resolver unit tests cover winner rule, tie-break, eligibility with and
without --repo-owner, outsider events, malformed rows, non-status kinds,
and the empty-history (implicit open) case.

Verification: cargo check/clippy clean; 280 buzz-cli lib tests pass;
`patches status-get --help` / `issues status-get --help` render as
expected.
Signed-off-by: Sarthak Singh <sarthak.singh@juspay.in>
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.

NIP-34 statuses are settable but not readable from the CLI

1 participant