feat(cli): add status-get read twin for NIP-34 patch/pr/issue roots (#4112) - #4116
Open
iroiro147 wants to merge 1 commit into
Open
feat(cli): add status-get read twin for NIP-34 patch/pr/issue roots (#4112)#4116iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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.status gettwin to the existing setter — so the read is primitive-shaped and mirrors the setter's flag surface (--repo-ownercarries the same eligibility hint it does forstatus).{root, state, implicit, kind, author, created_at, event}.eventis the full winning status JSON so merge-commit / applied-patch (q) / revision references travel without a second query;implicit: truemarks "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_getshared envelope printer. Root-kind fetch guards typo'd ids (fails loudly) instead of silently resolving implicit-open. Fetches viaquery_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: threeStatusGetsubcommand variants (--rootfor patches/pr,--issuefor issues,--repo-owneroptional on all three); surface-stability tests updated for the deliberate surface change.--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 --helpandissues status-get --helprender as expected.Fixes #4112