* feat(list): bd list's remaining filters over http behind issues.list.filters Over http every `bd list` filter beyond the created bounds and the title, id and no-assignee scope refused (time bounds, priority range, text and external-ref matches, spec, label pattern/regex, exclude-type, no-parent, no-labels, empty-description, pinned/no-pinned, deferred, overdue, mol/wisp type). The library entry already applied all of them: issueops.Reader.List via workapi.BuildListFilter, shared by the CLI and the handler. This adds only the wire. - Server: GET /v0/beads/issues decodes 29 new optional parameters (listFilterParams, decode only; countIssues' names where it already spells the filter) into the existing ListRequest, behind one new behavior token, issues.list.filters. mol_type/wisp_type are closed enums refused by name (an empty value too). wire_revision stays 2; apigen and the wireshape golden are regenerated (additive only). - Every RFC 3339 bound the listing and count decode is normalized to UTC, so an offset-bearing bound selects what its Z twin does on a zone-less timestamp column. - workapi.BuildListFilter refuses PinnedFlag with NoPinnedFlag (ErrValidation, the CLI's own sentence) instead of letting PinnedFlag win; over http that is a 400 on no_pinned. - Client: the encoder sends the members (encode.ListFiltersMembers, one list read by the encoder, the pre-dial gate and a spec-parity test). Against a server not advertising the token, httpReader.List refuses before dialing with ErrUnsupported naming issues.list.filters. The 29 E-ListRequest ledger refusal rows retire; the ledger doc is updated; skew flag mappings added. - Tests: handler decode/parity/enum/UTC/malformed/pinned-pair tests; encode member/gate/spec parity and bound encoding; per-member ride-behind-token and pre-dial skew refusal; two new Reader contract cases on every leg (dolt, embedded, uow, served): the eight time bounds at exact boundaries (strict, whole-second truncation, NULL never matches, +02:00 equals UTC) and one in/out row per remaining family; three served Reader cases unparked; TestE2E_ListFilterParityOverHTTP (served == embedded, masked server refuses naming the token, no dial); five corpus shapes marked pending until the reference server profile advertises the token. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(list): exclude_status on listIssues, the 30th issues.list.filters member issueops.ListRequest gains ExcludeStatus: statuses to leave out of a listing, appended to the default exclusions (never re-admitting what they hide), comma-separated or repeated, and validated against the workspace's statuses by the same rule CountRequest.ExcludeStatus uses (an unknown name is ErrValidation). The rule moves into one shared function, workapi.ParseExcludeStatus, called by both builders. With AllFlag it reads the active set without enumerating every status, so an http-backed caller can list O(active) rows instead of the whole history. - Server: listIssues decodes a repeatable `exclude_status` under the same issues.list.filters token (no new token); an unknown name is a 400 on exclude_status. apigen and the wireshape golden are regenerated (additive). - Client: the encoder sends it and it joins encode.ListFiltersMembers, so the pre-dial gate asks for the token. - It is refused together with ReadyFlag, like the other members the ready query cannot carry. - No `bd list --exclude-status` flag yet (it would need the CLI docs regenerated); the member is reachable through the library and the wire. Tests: builder unit test (append, AllFlag, comma split, unknown name); handler decode and 400; encoder, round-trip and gate; Reader contract cases on every leg (active set under AllFlag, repeated and comma values, adds to the defaults, narrows an explicit Status, unknown name refused). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(list): label_regex compile errors are 400s; review polish for list filters - An invalid `label_regex` on GET /v0/beads/issues, /v0/beads/ready and /v0/beads/ready:count is now `400 invalid_argument` (`invalid_value` on `label_regex`) instead of `500 internal`. The database still compiles the pattern in its own dialect; a request that sent a regex and earned the engine's "regular expression is invalid" refusal is attributed to the parameter (failRegexReadErr). The same text on a request with no regex stays a server fault. - mol_type and wisp_type refuse each other's vocabulary (tests pin `mol_type=heartbeat` and `wisp_type=swarm`), so the call-site allowlist, not just the spec enum, is covered. - exclude_status with a workspace custom status: leg tests on the embedded store and over the served wire (accepted and applied; a name in no vocabulary refused). ReaderFixture cannot configure custom statuses, so these sit beside the count's twin rather than in the contract. - The search e2e gains a positive arm: --desc-contains returns exactly the row whose description carries the token. - Docs: `all` plus `exclude_status` keeps every status not named (pinned, hooked and custom done/frozen included unless named), not "the active set"; label_regex documents its 400. A corpus source line is made neutral; a test message says 30. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(list): compose issues.list.filters with the --title-contains fold #7631, now on main, folds `bd list --title-contains` onto listIssues `title` and refuses the TitleContains left over from a --title and --title-contains pair that differs, because the listing then had one title parameter. This branch publishes `title_contains` behind issues.list.filters, so that leftover now rides it beside `title` and the server applies both. Neither half is dropped, and against a server without the token the pre-dial gate refuses, naming issues.list.filters. - encode.FoldTitleContains still runs first; its doc now says where a differing pair goes. - Tests: the fold table expects `title` plus `title_contains` for a differing pair, including the ſ/s pair strings.EqualFold would match; the differing-pair refusal names issues.list.filters; the list_filters_test sweep pairs its TitleContains probe with a differing TitleSearch, since a lone one asks only for issues.list.title; the e2e differing-pair refusal becomes a listFilterShapes row that answers exactly child-a over http and embedded, and refuses before dialing without the token. - The gc-polecat-closed-after corpus shape's pending reason also names issues.list.title. The CHANGELOG --title-contains entry no longer lists the differing pair and --closed-after as refused. Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(bazel): auto-sync BUILD files Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/39013611268 (`make bazel-sync`: gazelle, tools/bazel/go_srcs.py, bazel mod tidy). Only BUILD.bazel, MODULE.bazel and MODULE.bazel.lock are ever pushed; see scripts/bazel-autofix-push.sh. * fix(list): serve --priority-max in search parity, refuse the parent pair The proxied tier's search parity table still expected a remote `bd search --priority-max 1` to refuse, because listIssues could not carry it. This branch serves priority_max behind issues.list.filters, so the remote route answered and the dolt-race shard went red in TestProxiedServerSearchRoutesAgree. The row now expects the answer on every route. It was the last wireCan=false row; the branch stays, with a comment, for the next flag listIssues cannot carry. - ParentID with NoParent: a served listing now carries no_parent beside parent, and ANDing the two answered only the edge-less rows under the parent's dotted id. BuildListFilter refuses the pair with ErrValidation, in the sentence bd list and BuildCountFilter already use, so issueops.Reader.List refuses it on every backend and the listing answers 400 on no_parent. Pinned by a builder test, a reader conformance case (dolt, embedded, uow, served http) and two httpapi tests. - POST /v0/beads/issues:claimNext shares the ready listing's label_regex but answered a pattern the database cannot compile with 500. It now gives the listing's 400 invalid_value on label_regex, through the helper the listing's mapping is split into. - The descendant walk's ledger rows said listIssues publishes no parameter for members it now serves behind issues.list.filters. They now say the walk does not send them yet, and that --flat or --json asks listIssues directly. The ExcludeStatus, Pinned and ExcludeTypes rows, the parentwalk.go header, the walk table's doc and two walk test comments are corrected the same way, and the ledger doc is regenerated. parentWalkRefusals notes that a member moved off the list must check issues.list.filters itself, because the walk dials past the listing's pre-dial gate. - Spec: the listing's no_parent documents the pair's 400, the count's exclude_status no longer says it has no listing counterpart, and claimNext's label_regex documents its 400. types.gen.go is regenerated. Comment-only: countFilters, and readyScopeFields' ExcludeStatus entry. - CHANGELOG and README say the default `bd list --parent` tree view does not carry the new filters yet; the label_regex entry names claimNext, and a Changed entry records the parent-pair refusal. Second review pass: docs and comments only, no behavior change. - The prose copies of the issues.list.filters member set now match ListFiltersMembers: CapIssuesListFilters and wire.CapListFilters name the status exclusion, and the spec's capabilities text names label-regex. - Every time bound on the listing and the count goes through q.timestamp, which normalizes it to UTC, and sqlbuild compares it strictly at whole-second precision. listIssues' created_before and created_after, and countIssues' created, updated and closed bounds, now say so in the words the new listing bounds use. The count's updated bounds also say what they filter, and its closed bounds say that a NULL closed_at never matches. types.gen.go is regenerated. - README and CHANGELOG: `--flat` or `--json` applies the filters to the parent's direct children, not its whole subtree. - The 29 listRefusal rows this branch serves stay deleted rather than kept as retired rows, as #7550 deleted its TitleSearch, IDFilter and NoAssignee rows when it served them. The CHANGELOG now says the rows are removed, not retired. Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
210 lines
9 KiB
Go
210 lines
9 KiB
Go
// Contributed by gascity from bd-enterprise (internal/enterprise/httpstore/role_reader.go@49d1df2f6)
|
|
// to OSS beads under the MIT license.
|
|
package httpclient
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"slices"
|
|
"strings"
|
|
|
|
"github.com/steveyegge/beads/internal/httpapi/apigen"
|
|
"github.com/steveyegge/beads/internal/httpclient/encode"
|
|
"github.com/steveyegge/beads/internal/httpclient/wire"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
"github.com/steveyegge/beads/issueops"
|
|
)
|
|
|
|
// httpReader is issueops.Reader over the v0 wire (design D8 row 1): Ready is
|
|
// listReadyWork, List is listIssues, Get is getIssue.
|
|
//
|
|
// It builds no filter and applies no default. Both request types are handed to
|
|
// the encoder whole, and the SERVER runs the same two workapi builders a local
|
|
// command would — against its own authoritative vocabulary, which is what heals
|
|
// L7's degraded client-side status/type set for every query that goes through
|
|
// here. What stays on this side is the part the wire genuinely cannot carry:
|
|
// the display order, the caller-supplied keyset position and the MaxRows cap,
|
|
// all three of them ledgered client-side in the encoder table and all three
|
|
// implemented in list_walk.go.
|
|
type httpReader struct{ store *Store }
|
|
|
|
// Ready serves listReadyWork.
|
|
//
|
|
// One request, no paging: the operation publishes no cursor, so `limit` and the
|
|
// server's own has_more ARE the page contract. An Offset is refused by the
|
|
// encoder rather than dropped — ready work carries no keyset position, so there
|
|
// is no honest way to page it (E-ReadyRequest.Offset).
|
|
//
|
|
// An explicit Limit of 0 (unlimited) is NOT sent as `limit=0`: it becomes one
|
|
// request bounded at the client cap plus one, refused past the cap rather than
|
|
// truncated (unlimited_read.go).
|
|
func (r httpReader) Ready(ctx context.Context, req issueops.ReadyRequest) (issueops.IssuePage, error) {
|
|
params, err := encode.ReadyParams(req)
|
|
if err != nil {
|
|
return issueops.IssuePage{}, r.store.inexpressible("Reader.Ready", err)
|
|
}
|
|
readCap, err := boundUnlimitedPage(params, req.Limit != nil && *req.Limit == 0)
|
|
if err != nil {
|
|
return issueops.IssuePage{}, err
|
|
}
|
|
var body apigen.ReadyPage
|
|
if err := r.store.dispatch(ctx, wire.Request{
|
|
Op: wire.OpListReadyWork,
|
|
Method: http.MethodGet,
|
|
Path: wire.PathReady,
|
|
Query: params,
|
|
}, &body); err != nil {
|
|
return issueops.IssuePage{}, err
|
|
}
|
|
if err := checkUnlimitedPage(wire.OpListReadyWork, readCap, len(body.Items), body.HasMore); err != nil {
|
|
return issueops.IssuePage{}, err
|
|
}
|
|
return issueops.IssuePage{Items: wireRows(body.Items, req.Brief), HasMore: body.HasMore}, nil
|
|
}
|
|
|
|
// List serves listIssues, through the pager in list_walk.go.
|
|
//
|
|
// `--title-contains` is folded onto `title` first (encode.FoldTitleContains:
|
|
// the two compile to one predicate), so it is gated by issues.list.title like
|
|
// `--title` is, and refused before the dial against a server without it.
|
|
func (r httpReader) List(ctx context.Context, req issueops.ListRequest) (issueops.IssuePage, error) {
|
|
req = encode.FoldTitleContains(req)
|
|
if err := r.refuseUnservedListFilters(ctx, req); err != nil {
|
|
return issueops.IssuePage{}, err
|
|
}
|
|
params, err := encode.ListParams(req)
|
|
if err != nil {
|
|
return issueops.IssuePage{}, r.store.inexpressible("Reader.List", err)
|
|
}
|
|
return r.store.walkIssues(ctx, params, req)
|
|
}
|
|
|
|
// tokenedListFilters are the ListRequest members listIssues carries only on a
|
|
// server advertising a behavior token of their own, each with that token:
|
|
// `bd search`'s text (S26), `bd list --title`, `--id` and `--no-assignee`
|
|
// (S15b), and the rest of `bd list`'s filters behind issues.list.filters.
|
|
// `--title-contains` is folded onto TitleSearch first
|
|
// (encode.FoldTitleContains), so alone it is gated by issues.list.title;
|
|
// only one that differs from `--title` keeps TitleContains, which rides
|
|
// `title_contains` with the filters.
|
|
// Order decides which token a request carrying several names; each refusal is
|
|
// complete on its own, so any order is honest.
|
|
var tokenedListFilters = []struct {
|
|
token string
|
|
set func(issueops.ListRequest) bool
|
|
}{
|
|
{wire.CapListSearch, func(r issueops.ListRequest) bool { return r.Query != "" }},
|
|
{wire.CapListNoAssignee, func(r issueops.ListRequest) bool { return r.NoAssignee }},
|
|
{wire.CapListTitle, func(r issueops.ListRequest) bool { return r.TitleSearch != "" }},
|
|
// An id set naming no id (only commas and blanks) sends no `id`, so it
|
|
// needs no token.
|
|
{wire.CapListIDs, func(r issueops.ListRequest) bool {
|
|
return strings.TrimSpace(strings.ReplaceAll(r.IDFilter, ",", "")) != ""
|
|
}},
|
|
// The rest of `bd list`'s filter vocabulary, one token for the set: the
|
|
// members are encode.ListFiltersMembers, the same list the encoder emits
|
|
// from, so a member cannot ride the wire without asking for the token.
|
|
{wire.CapListFilters, encode.ListFiltersSet},
|
|
}
|
|
|
|
// refuseUnservedListFilters is the pre-dial gate for the tokened members. An
|
|
// older server answers each one's parameter with 400 unknown_parameter, so a
|
|
// request carrying one against a server that does not advertise its token is
|
|
// refused HERE, with the typed capability error naming that token: never a
|
|
// round trip that is refused anyway, and never a wider listing (the
|
|
// unsearched one, every in-progress bead instead of the unassigned ones, the
|
|
// whole workspace instead of an id set) passed off as the answer.
|
|
//
|
|
// listIssues is a baseline operation, so dispatch preflights nothing for it;
|
|
// this is the one handshake a tokened request costs, and a request without
|
|
// any of these members never asks for it.
|
|
func (r httpReader) refuseUnservedListFilters(ctx context.Context, req issueops.ListRequest) error {
|
|
var snap *apigen.ContextResponse
|
|
for _, f := range tokenedListFilters {
|
|
if !f.set(req) {
|
|
continue
|
|
}
|
|
if snap == nil {
|
|
var err error
|
|
if snap, err = r.store.snapshot(ctx); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if snap == nil || !slices.Contains(snap.Capabilities, f.token) {
|
|
return r.store.unsupportedCapability("Reader.List", f.token)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Get serves getIssue, including the two landed include parameters that retired
|
|
// ledger row L4.
|
|
//
|
|
// A 404 arrives as the `not_found` problem code, which the wire's problem
|
|
// mapper has already turned into issueops.ErrNotFound — the same sentinel a
|
|
// local miss answers with — so the role's "a miss is ErrNotFound, a backend
|
|
// failure passes through unchanged" promise holds without a single decision
|
|
// here. The nil detail view on any error is the other half of it.
|
|
func (r httpReader) Get(ctx context.Context, req issueops.GetRequest) (*issueops.IssueDetails, error) {
|
|
id, params := encode.GetTarget(req)
|
|
path, err := wire.IssuePath(id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var details types.IssueDetails
|
|
if err := r.store.dispatch(ctx, wire.Request{
|
|
Op: wire.OpGetIssue,
|
|
Method: http.MethodGet,
|
|
Path: path,
|
|
Query: params,
|
|
IssueID: id,
|
|
}, &details); err != nil {
|
|
return nil, err
|
|
}
|
|
// Issue.RowVersion is json:"-"; the wire's only spelling of the token is
|
|
// Revision (the decimal string getIssue publishes), so a bare decode
|
|
// leaves RowVersion at its zero value on every read — a guarded write
|
|
// built off this result would carry a token the row never held, same as
|
|
// bd-enterprise's (*Store).GetIssue bridge below and the write
|
|
// responses parseRevision already stitches this way.
|
|
version, err := parseRevision("getIssue", details.Revision)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
details.Issue.RowVersion = version
|
|
return &details, nil
|
|
}
|
|
|
|
// wireRows lifts a wire page onto the pointer slice the role's page carries,
|
|
// and stamps the projection marker the wire cannot carry.
|
|
//
|
|
// The element type is an ALIAS of types.IssueWithCounts — the same struct the
|
|
// server projects onto and the same one `bd list --json` marshals — so this
|
|
// takes an address and copies nothing under the header. The result is never
|
|
// nil: an empty page is an empty slice on every surface, and a caller must not
|
|
// have to tell null from empty to learn that nothing matched.
|
|
//
|
|
// brief IS A PARAMETER RATHER THAN A FIELD ON ANYTHING, so every page decode on
|
|
// this client has to answer the question. types.Issue.IsLitePartial is
|
|
// `json:"-"` — it never crosses — and a `brief` page therefore arrives
|
|
// byte-identical to a page of genuinely textless rows. The only thing that can
|
|
// tell them apart is having ASKED, which is what issueops.ListRequest.Brief's
|
|
// own leaf says a wire consumer distinguishes them by, and this client is the
|
|
// consumer that asked. A call site that could forget it would be a page whose
|
|
// rows lie about being whole; making it an argument means the compiler asks.
|
|
//
|
|
// IT IS NEVER STAMPED ON A HYDRATED READ. The marker means "the heavy columns
|
|
// were not selected", so setting it on a full page would send a caller to
|
|
// refetch a body it already has — the same defect as the missing stamp, pointed
|
|
// the other way.
|
|
func wireRows(items []apigen.IssueWithCounts, brief bool) []*types.IssueWithCounts {
|
|
out := make([]*types.IssueWithCounts, 0, len(items))
|
|
for i := range items {
|
|
row := &items[i]
|
|
if brief && row.Issue != nil {
|
|
row.IsLitePartial = true
|
|
}
|
|
out = append(out, row)
|
|
}
|
|
return out
|
|
}
|