* feat(issueops): gate members on create and update, one bounds validator
The library half of serving gate await fields. Every local leg already
stores await_type, await_id, timeout and waiters on create, and await_id
on update; this adds the two missing pieces.
- IssuePatch.Waiters: a whole-value replacement of the waiter list (nil
or empty clears, stored as []), mapped by UpdateFields and by the
unit-of-work updateSpec, deep-copied by CloneUpdateRequest, and
classified as a non-coordination signal on the dolt leg. Duplicates are
stored as given; dedup stays the CLI's.
- ValidateGateFields / ValidateGatePatch with *issueops.GateFieldError
{Field, Detail} wrapping ErrValidation, mirroring ReclaimFieldError so a
front door can name the member. The rules are the columns' only:
await_type <= 32 characters, await_id <= 255 characters, the JSON
waiter list <= one TEXT column (65535 bytes), and timeout >= 0. No
await_type allowlist, no gate-type-only rule, no timer-needs-timeout
rule. Run from ValidatePublicCreateRequest (every create shape on every
backend) and ValidateUpdateRequest (await_id, waiters).
- Conformance: LifecycleCreate WritesTheGateMembers / BoundsTheGateMembers,
LifecycleUpdate PatchesTheGateMembers / BoundsTheGateMembers and
BatchApply CarriesTheGateMembers, each bound asserted from both sides,
wired on the dolt, embedded and uow legs and parked on the http leg on
the live refusal rows until the wire slices land.
- httpclient: IssuePatch.Waiters is refused before the dial on both patch
documents under a new W-IssuePatch.Waiters row (refuse-not-drop), until
the wire publishes it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(httpapi): publish the gate members on create and update
The wire half of serving gate await fields, over the library slice.
- createIssue and the issues:batchApply create item publish await_type,
await_id, timeout (nanoseconds, the encoding Issue.timeout reads back)
and waiters, behind the new behavior token issues.create.gates (one token
for both create shapes, the issues.create.defaultPriority precedent).
- updateIssue's patch and the batchApply update item's patch publish
await_id and waiters (whole-value replacement; [] clears), behind
issues.update.gates. await_type and timeout are not patch members: no
local update route changes them. Neither is nullable; null is refused
naming the member, as on title.
- The handlers only decode and project (createGateMembers,
patchGateMembers). The wire is no stricter than the library: every bound
is the role's *issueops.GateFieldError (await_type <= 32, await_id <=
255, the JSON waiter list <= one TEXT column, timeout >= 0), mapped to the
existing 400 invalid_argument with param naming the member at its level
(await_type, patch.waiters, items[i].create.timeout,
items[i].update.patch.await_id). The spec mirrors exactly that:
maxLength 32/255 and minimum 0, and no minLength/maxLength/maxItems on
waiters. Blank and duplicate waiters and any await_type reach the role
untouched.
- Spec: the four schemas, the capability prose, and the stale sentences
(createIssue's "await_* publishes on no operation, read or write" and the
patch's "spec_id and await_id publish nowhere yet"). apigen regenerated
(from the remote drift test's diff), wireshape golden regenerated:
additive entries and sides only, wire_revision stays 2.
- Client: the two tokens are mirrored in wire.behaviorCapabilities so the
vocabulary stays set-equal with the server's. The client still refuses
every gate member before the dial (the client slice flips that); the write-ledger
pending sets name the newly published members under their live refusal
rows, and the W-CreateRequest.Issue / W-IssuePatch.AwaitID /
W-IssuePatch.Waiters reasons, the served-leg park reasons and the S4b
waiver now say the server publishes them and this client does not send
them yet.
Tests: internal/httpapi/gate_fields_test.go pins member mapping on all four
bodies, clear-by-empty on both patches, null and unpublished-member refusal,
GateFieldError -> param at every nesting level, and both tokens advertised.
Mutating the handlers (dropping the mapping, the GateFieldError arms or the
tokens) turns them red.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(httpclient): send the gate members behind their tokens
The client half of serving gate await fields, over the wire slice.
- Create: await_type, await_id, timeout (nanoseconds) and waiters join the
create vocabulary on createIssue and batchApply create items (now
twenty-four members), sent verbatim when populated. Patch: await_id (by
presence; "" clears) and waiters (whole-value; nil/empty travels as [])
are encoded on both updateIssue's and the batchApply update item's patch.
- Token gate before the dial: a create naming any gate member needs
issues.create.gates, a patch naming one needs issues.update.gates. Without
the token the request refuses with wire.NewCapabilityError naming it
(typed ErrUnsupported{Capability}), never a dropped member. batchApply
checks the whole plan once, so no partial plan is sent. A request naming
no gate member never reads either token. Store.requireCapabilityBeforeDial
is the shared helper; requirePersistenceMove now uses it.
- Bounds read back typed: the server's 400 invalid_argument/invalid_value
whose param names a gate member at any level (await_type, patch.waiters,
items[i].create.timeout, items[i].update.patch.await_id) is rebuilt as the
role's *issueops.GateFieldError, the problem kept in the chain (and a batch
refusal still becomes its *ItemError). Without this the served bounds
contracts could not pass.
- Ledger: W-IssuePatch.AwaitID RETIRED; the library slice's W-IssuePatch.Waiters row
deleted (it never shipped outside this branch); W-CreateRequest.Issue and
W-CreateItem.Issue no longer cover the gate members; new
W-CreateRequest.Gates (refuse, Capability issues.create.gates) records the
token-gated late refusal for both create shapes. engdocs ledger
regenerated from Ledger() (262 rows: 201 refuse, 34 degrade, 27 retired).
- Write-ledger table: the wire slice's pending sets are flipped into carried.
- Served leg: the five gate cases (LifecycleCreate Writes/Bounds,
LifecycleUpdate Patches/Bounds, BatchApply Carries) are un-parked and run;
the S4b waiver and served comments now say await_id is sent.
Tests: internal/httpclient/gate_fields_test.go (encode on all four bodies,
clears, old-server refusal per member naming the token with no dial, no
partial batchApply plan, plain requests unaffected on old and new servers,
GateFieldError rebuilt from the problem). Disabling the three pre-dial
checks turns the refusal tests red.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* build(bazel): auto-sync BUILD files
Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/38841144413
(`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.
* docs(issueops): say the gate timeout rule is no column's
The gate validator's doc said its rules were the stored columns' and that
no command line can produce a negative timeout. The widths are the
columns' (VARCHAR(32), VARCHAR(255), TEXT), but timeout_ns is a BIGINT,
so a non-negative timeout is a rule no column enforces; the wire
publishes it as minimum 0. The raw store creates (CreateIssue,
CreateIssues) and import do not run the validator, so bd gate create
--timeout=-5m, a formula step's gate.timeout and a template clone still
store a negative timeout until they move onto the role.
Also say that GateFieldError.Detail is prose whose HTTP copy ends with
the server's own clause, so a caller dispatches on Field, and why a
create omits an empty waiter list while a patch sends [] to clear it.
Comments only; no behaviour change.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(corpus): gh:run await_id persist refuses by the missing gate token
#7604 (now on main) made bd gate check persist a gh:run gate's discovered
run ID through Lifecycle.Update. Its served test expected the HTTP
client's W-IssuePatch.AwaitID refusal, which persistGateCheckAwaitID
rewords to name await_id. This PR retires that row: the patch carries
await_id behind issues.update.gates. Through the reference proxy, whose
server advertises no gate token, the persist is now refused before the
dial by the capability error ("bd serve at ... does not advertise
capability "issues.update.gates", which updateIssue requires"), so the
merged tree failed the subtest's await_id and updateIssue assertions.
The subtest now expects that refusal: no writes, the error names the
gate, the missing token and the server, no role or store method leaks,
and await_id is untouched. persistGateCheckAwaitID already returns a
capability error as the role raised it (#7604 pins that), so no code
changes. Against a server that advertises the token the persist goes
through: a scratch probe against the in-process server recorded
await_id=4242 and closed the gate.
Also correct the gate.go comment and the CHANGELOG entry that still said
the HTTP client refuses every await_id patch.
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: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
107 lines
4.2 KiB
Go
107 lines
4.2 KiB
Go
package issueops
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// GateListExpression is the query `bd gate list` asks: every row of the gate
|
|
// type, on both planes, whatever its other fields. It names no status, so the
|
|
// Querier's default closed exclusion applies unless GateListRequest.All lifts
|
|
// it (QueryRequest.IncludeClosed).
|
|
const GateListExpression = "type=gate"
|
|
|
|
// GateListRequest describes `bd gate list` over the whole workspace, and the
|
|
// listing `bd gate check` evaluates.
|
|
type GateListRequest struct {
|
|
// All admits closed gates, which the listing otherwise hides.
|
|
All bool
|
|
// ExcludeTemplates leaves template gates (a persisted proto's, which every
|
|
// pour copies) out of the query itself, so none of them takes a row of
|
|
// Limit. `bd gate list` leaves it unset and lists them; `bd gate check`,
|
|
// which never evaluates a template, sets it.
|
|
ExcludeTemplates bool
|
|
// Limit bounds the rows returned; 0 means unlimited. A negative limit is
|
|
// the Querier's ErrValidation.
|
|
Limit int
|
|
}
|
|
|
|
// ListGates answers `bd gate list` (no issue argument) through the Querier
|
|
// role, which every backend serves (a remote one as queryIssues, which every
|
|
// deployed server publishes). It is the one library entry for the listing:
|
|
// the CLI's direct, proxied and remote routes each call it with their route's
|
|
// Querier, so no route builds a storage filter of its own.
|
|
//
|
|
// The question is exactly the one the raw filter used to ask: the gate type,
|
|
// both planes, closed rows excluded unless All is set, no other default
|
|
// suppression (templates, pinned rows and ephemeral gates are all listed),
|
|
// in the store's default order, cut at Limit. ExcludeTemplates adds
|
|
// `template=false` to the expression rather than dropping templates from the
|
|
// page, so the cut at Limit counts only the gates that remain.
|
|
//
|
|
// A failed read is an error, never an empty list. Rows come back in the
|
|
// Querier's order; a row carrying no issue is dropped.
|
|
func ListGates(ctx context.Context, querier Querier, req GateListRequest) ([]*types.Issue, error) {
|
|
if querier == nil {
|
|
return nil, &ErrUnsupported{Op: "ListGates", Backend: "nil"}
|
|
}
|
|
expression := GateListExpression
|
|
if req.ExcludeTemplates {
|
|
expression += " AND template=false"
|
|
}
|
|
limit := req.Limit
|
|
page, err := querier.Query(ctx, QueryRequest{
|
|
Expression: expression,
|
|
IncludeClosed: req.All,
|
|
Limit: &limit,
|
|
})
|
|
if err != nil {
|
|
return nil, fmt.Errorf("listing gates: %w", err)
|
|
}
|
|
gates := make([]*types.Issue, 0, len(page.Items))
|
|
for _, row := range page.Items {
|
|
if row != nil && row.Issue != nil {
|
|
gates = append(gates, row.Issue)
|
|
}
|
|
}
|
|
return gates, nil
|
|
}
|
|
|
|
// The gate members a GateFieldError can name, spelled as the wire and the
|
|
// stored columns spell them.
|
|
const (
|
|
GateFieldAwaitType = "await_type"
|
|
GateFieldAwaitID = "await_id"
|
|
GateFieldTimeout = "timeout"
|
|
GateFieldWaiters = "waiters"
|
|
)
|
|
|
|
// GateFieldError reports a gate member a create or an update refused, and the
|
|
// one member it is about, so a front door can name that member without parsing
|
|
// the message. It wraps ErrValidation.
|
|
//
|
|
// The widths are the stored columns' and nothing more, so every backend
|
|
// refuses the same values a Dolt column always did: await_type at most 32
|
|
// characters, await_id at most 255, and the JSON-encoded waiter list at most
|
|
// one TEXT column. The one rule no column enforces is a timeout that is not
|
|
// negative (timeout_ns is a BIGINT), which the wire publishes as minimum 0;
|
|
// the raw store creates do not run it yet (see ValidateGateFields). There is
|
|
// deliberately no await_type vocabulary (formula gate types are free-form), no
|
|
// gate-type-only rule (any issue may carry the members, as local updates
|
|
// always allowed), and no waiter deduplication.
|
|
type GateFieldError struct {
|
|
// Field is one of the GateField* constants.
|
|
Field string
|
|
// Detail is the sentence the error reads as. It is prose, and the HTTP
|
|
// client's copy ends with the server's own clause ("; nothing was
|
|
// created", "; nothing was written"), so a caller dispatches on Field,
|
|
// never on Detail.
|
|
Detail string
|
|
}
|
|
|
|
func (e *GateFieldError) Error() string { return e.Detail }
|
|
|
|
// Unwrap makes GateFieldError match ErrValidation.
|
|
func (e *GateFieldError) Unwrap() error { return ErrValidation }
|