Files
mesh-delivery/contracts/go/seats/meshdelivery/contract.go
T
jschoubben e1df6af536 CT7: the seat mesh-delivery keeps the state turns, and asks until their last users go; regenerated
Left in the definition: no line of the contracts part removes the state turns, and the
state asks is read by the teller, the forge bridge, the view and the indexer, whose rows
remove their reads; it is removed in the head where its last reader goes (design 47 G §431).

Builds: design 47 G §305, §431.

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-11 11:05:56 +01:00

727 lines
24 KiB
Go

// Code generated by seatgen from the seat definitions; DO NOT EDIT.
// Package meshdelivery is the contract of the seat "mesh-delivery", defined whole (seats/mesh-delivery/seat.json): The delivery gate: reads and steers deliveries, merges and the checks that decide them; the merge is made on the operator's Approve once both checks passed.
package meshdelivery
import (
"bytes"
"encoding/json"
"errors"
"strings"
"time"
)
// Seat is the seat's name.
const Seat = "mesh-delivery"
const (
VerbDeliveries = "deliveries"
VerbShow = "show"
VerbGroups = "groups"
VerbSource = "source"
VerbStalled = "stalled"
VerbRecovery = "recovery"
)
const (
EventOwed = "owed"
EventPinned = "pinned"
EventFreed = "freed"
EventHeadsReplaced = "heads-replaced"
EventRecordOpened = "record-opened"
EventRecordEnded = "record-ended"
EventFilling = "filling"
EventFull = "full"
EventRoom = "room"
EventSourceMoved = "source-moved"
EventRecoveryMerged = "recovery-merged"
)
// Verbs is every verb the seat serves, in its definition's order: a new copy each call.
func Verbs() []string {
return []string{VerbDeliveries, VerbShow, VerbGroups, VerbSource, VerbStalled, VerbRecovery}
}
// Events is every event published on the seat's subject: a new copy each call.
func Events() []string {
return []string{EventOwed, EventPinned, EventFreed, EventHeadsReplaced, EventRecordOpened, EventRecordEnded, EventFilling, EventFull, EventRoom, EventSourceMoved, EventRecoveryMerged}
}
// Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects.
const (
Family = "mesh-delivery.events"
FamilyMaxAgeDays = 7
)
// StreamOwed is the stream owed is kept in.
const StreamOwed = "SEAT_mesh-delivery_owed"
// SubjectOwed is where owed is published, on mesh.seat.mesh-delivery.event.owed.<repository>.<number>.
func SubjectOwed(repository, number string) string {
return "mesh.seat.mesh-delivery.event.owed." + repository + "." + number
}
// SubjectOwedAll hears every owed.
const SubjectOwedAll = "mesh.seat.mesh-delivery.event.owed.*.*"
// SubjectPinned is where pinned is published.
const SubjectPinned = "mesh.seat.mesh-delivery.event.pinned"
// SubjectFreed is where freed is published.
const SubjectFreed = "mesh.seat.mesh-delivery.event.freed"
// SubjectHeadsReplaced is where heads-replaced is published.
const SubjectHeadsReplaced = "mesh.seat.mesh-delivery.event.heads-replaced"
// SubjectRecordOpened is where record-opened is published.
const SubjectRecordOpened = "mesh.seat.mesh-delivery.event.record-opened"
// SubjectRecordEnded is where record-ended is published.
const SubjectRecordEnded = "mesh.seat.mesh-delivery.event.record-ended"
// SubjectFilling is where filling is published.
const SubjectFilling = "mesh.seat.mesh-delivery.event.filling"
// SubjectFull is where full is published.
const SubjectFull = "mesh.seat.mesh-delivery.event.full"
// SubjectRoom is where room is published.
const SubjectRoom = "mesh.seat.mesh-delivery.event.room"
// SubjectSourceMoved is where source-moved is published, on mesh.seat.mesh-delivery.event.source-moved.<branch>.
func SubjectSourceMoved(branch string) string {
return "mesh.seat.mesh-delivery.event.source-moved." + branch
}
// SubjectSourceMovedAll hears every source-moved.
const SubjectSourceMovedAll = "mesh.seat.mesh-delivery.event.source-moved.*"
// SubjectRecoveryMerged is where recovery-merged is published.
const SubjectRecoveryMerged = "mesh.seat.mesh-delivery.event.recovery-merged"
const (
StateSource = "source"
StateMerges = "merges"
StateAsks = "asks"
StateOwed = "owed"
StateTurns = "turns"
)
// SourceByBranchKey is the key of one value of the state source under the form "<branch>".
func SourceByBranchKey(branch string) string { return branch }
// ParseSourceByBranchKey reads the parts of a key of the form "<branch>", in the order of the form; the last result is false for a key of another form.
func ParseSourceByBranchKey(key string) (string, bool) {
rest := key
if rest == "" {
return "", false
}
v0 := rest
rest = ""
if rest != "" {
return "", false
}
return v0, true
}
// DecodeSourceByBranchValue reads one value of the state source under the form "<branch>", refusing a field SourceByBranchValue does not know and any text after the value.
func DecodeSourceByBranchValue(raw []byte) (SourceByBranchValue, error) {
var v SourceByBranchValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
}
// MergesByGroupKey is the key of one value of the state merges under the form "<group>".
func MergesByGroupKey(group string) string { return group }
// ParseMergesByGroupKey reads the parts of a key of the form "<group>", in the order of the form; the last result is false for a key of another form.
func ParseMergesByGroupKey(key string) (string, bool) {
rest := key
if rest == "" {
return "", false
}
v0 := rest
rest = ""
if rest != "" {
return "", false
}
return v0, true
}
// DecodeMergesByGroupValue reads one value of the state merges under the form "<group>", refusing a field MergesByGroupValue does not know and any text after the value.
func DecodeMergesByGroupValue(raw []byte) (MergesByGroupValue, error) {
var v MergesByGroupValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
}
// AsksByMergeGroupHeadsKey is the key of one value of the state asks under the form "merge.<group>.<heads>".
func AsksByMergeGroupHeadsKey(group, heads string) string { return "merge." + group + "." + heads }
// ParseAsksByMergeGroupHeadsKey reads the parts of a key of the form "merge.<group>.<heads>", in the order of the form; the last result is false for a key of another form.
func ParseAsksByMergeGroupHeadsKey(key string) (string, string, bool) {
rest := key
if !strings.HasPrefix(rest, "merge.") {
return "", "", false
}
rest = rest[6:]
v1, after1, found1 := strings.Cut(rest, ".")
if !found1 || v1 == "" {
return "", "", false
}
rest = after1
if rest == "" {
return "", "", false
}
v3 := rest
rest = ""
if rest != "" {
return "", "", false
}
return v1, v3, true
}
// DecodeAsksByMergeGroupHeadsValue reads one value of the state asks under the form "merge.<group>.<heads>", refusing a field AsksByMergeGroupHeadsValue does not know and any text after the value.
func DecodeAsksByMergeGroupHeadsValue(raw []byte) (AsksByMergeGroupHeadsValue, error) {
var v AsksByMergeGroupHeadsValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
}
// OwedByRepositoryNumberHeadActKey is the key of one value of the state owed under the form "<repository>.<number>.<head>.<act>".
func OwedByRepositoryNumberHeadActKey(repository, number, head, act string) string {
return repository + "." + number + "." + head + "." + act
}
// ParseOwedByRepositoryNumberHeadActKey reads the parts of a key of the form "<repository>.<number>.<head>.<act>", in the order of the form; the last result is false for a key of another form.
func ParseOwedByRepositoryNumberHeadActKey(key string) (string, string, string, string, bool) {
rest := key
v0, after0, found0 := strings.Cut(rest, ".")
if !found0 || v0 == "" {
return "", "", "", "", false
}
rest = after0
v2, after2, found2 := strings.Cut(rest, ".")
if !found2 || v2 == "" {
return "", "", "", "", false
}
rest = after2
v4, after4, found4 := strings.Cut(rest, ".")
if !found4 || v4 == "" {
return "", "", "", "", false
}
rest = after4
if rest == "" {
return "", "", "", "", false
}
v6 := rest
rest = ""
if rest != "" {
return "", "", "", "", false
}
return v0, v2, v4, v6, true
}
// DecodeOwedByRepositoryNumberHeadActValue reads one value of the state owed under the form "<repository>.<number>.<head>.<act>", refusing a field OwedByRepositoryNumberHeadActValue does not know and any text after the value.
func DecodeOwedByRepositoryNumberHeadActValue(raw []byte) (OwedByRepositoryNumberHeadActValue, error) {
var v OwedByRepositoryNumberHeadActValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
}
// TurnsByRepositoryKey is the key of one value of the state turns under the form "<repository>".
func TurnsByRepositoryKey(repository string) string { return repository }
// ParseTurnsByRepositoryKey reads the parts of a key of the form "<repository>", in the order of the form; the last result is false for a key of another form.
func ParseTurnsByRepositoryKey(key string) (string, bool) {
rest := key
if rest == "" {
return "", false
}
v0 := rest
rest = ""
if rest != "" {
return "", false
}
return v0, true
}
// DecodeTurnsByRepositoryValue reads one value of the state turns under the form "<repository>", refusing a field TurnsByRepositoryValue does not know and any text after the value.
func DecodeTurnsByRepositoryValue(raw []byte) (TurnsByRepositoryValue, error) {
var v TurnsByRepositoryValue
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return v, err
}
if dec.More() {
return v, errors.New("text after the value")
}
return v, nil
}
// Act is an act the gate said for a group, with its recorded outcome once the forge bridge said one.
type Act struct {
// when the outcome was recorded
At *time.Time `json:"at,omitempty"`
// the outcome the forge bridge said as owed.ended and the gate recorded; absent while unanswered
Outcome string `json:"outcome,omitempty"`
Owed Owed `json:"owed"`
// the forge's own words for a refusal, the error for an act that could not be performed, why one is undecodable or dropped
Words string `json:"words,omitempty"`
}
// The values of Act's outcome.
const (
ActOutcomePerformed = "performed"
ActOutcomeRefused = "refused"
ActOutcomeCouldNotBePerformed = "could not be performed"
ActOutcomeUndecodable = "undecodable"
ActOutcomeDropped = "dropped"
)
// Ask is the one Approve ask of a milestone (ADR 0493 §9), said apart from each delivery's transition.
type Ask struct {
// on answered: approve or decline
Answer string `json:"answer,omitempty"`
// the ask's id
Ask string `json:"ask"`
// when
At *time.Time `json:"at,omitempty"`
// on answered: who answered
By string `json:"by,omitempty"`
// its delivery group
Group string `json:"group"`
// repository to the head asked
Heads map[string]string `json:"heads,omitempty"`
// the milestone
Milestone string `json:"milestone"`
// on withdrawn: why, such as a new head of a member
Why string `json:"why,omitempty"`
}
// Fill is the delivery records' ledger's fill against its cap.
type Fill struct {
// when
At *time.Time `json:"at,omitempty"`
Bytes int64 `json:"bytes"`
// bytes
Cap int64 `json:"cap"`
// what full refuses, such as the next record
Refused string `json:"refused,omitempty"`
// the kept data, by its name in the holder's manifest
Store string `json:"store"`
}
// Group is one delivery group: its members, its derived state and the acts the gate said for it.
type Group struct {
// the acts the gate said for it, each with its id and its recorded outcome; an id said and not answered is the forge bridge's to perform
Acts []Act `json:"acts"`
// the group's check: its verdict, or asked as <id>
Check string `json:"check,omitempty"`
// the group's id, its branch
ID string `json:"id"`
// its members in merge order
Members []Member `json:"members"`
// its state, derived from its members
State string `json:"state"`
// why it is in that state
Why string `json:"why,omitempty"`
}
// Member is one member of a group: a pull request.
type Member struct {
// the branch it merges into
Base string `json:"base,omitempty"`
// its head
Head string `json:"head"`
// the member's delivery id
ID string `json:"id"`
// the pull request's number
Number int64 `json:"number"`
// the pull request is open: not merged, closed or final
Open bool `json:"open,omitempty"`
// the repository, <owner>/<name>
Repository string `json:"repository"`
// the member's delivery state
State string `json:"state"`
}
// Owed is one act the gate owes the forge, said once under its id and safe to repeat at the forge (design 47 *What the gate owes the forge*); the forge bridge performs it through the seat git's verb of the same act.
type Owed struct {
// the act: merge (the seat git's merge-pull), status, view, comment or note
Act string `json:"act"`
// the operator's ask that approved the heads, for a merge
Ask string `json:"ask,omitempty"`
// the commit a status or a note line is on; the head when absent
Commit string `json:"commit,omitempty"`
// a status: its context, such as mesh/merge-gate
Context string `json:"context,omitempty"`
// a status: what it says
Description string `json:"description,omitempty"`
// the delivery group the pull request is a member of, for a merge
Group string `json:"group,omitempty"`
// the pull request's head the act is for
Head string `json:"head"`
// the act's id, the same each time it is said again; a comment and a note line carry it, so the forge holds it once
ID string `json:"id"`
// a note line: the one line
Line string `json:"line,omitempty"`
// the pull request's number
Number int64 `json:"number"`
// the repository, <owner>/<name>
Repository string `json:"repository"`
// when the gate first said it
Said *time.Time `json:"said,omitempty"`
// a status: its state, pending, success, failure or error
State string `json:"state,omitempty"`
// a status: the page it links to
Target string `json:"target,omitempty"`
// a comment or the view: the text, markdown
Text string `json:"text,omitempty"`
}
// The values of Owed's act.
const (
OwedActMerge = "merge"
OwedActStatus = "status"
OwedActView = "view"
OwedActComment = "comment"
OwedActNote = "note"
)
// Pins is the graph revisions a delivery record starts or stops pointing at.
type Pins struct {
// assignment graph revisions, by their number on the seat mesh-wants
Assignment []int64 `json:"assignment,omitempty"`
// catalog graph revisions, by their number on the seat mesh-catalog
Catalog []int64 `json:"catalog,omitempty"`
// the record's milestone
Milestone string `json:"milestone"`
// the record's id
Record string `json:"record"`
// on freed: the record ended past its retention, or was removed by hand
Why string `json:"why,omitempty"`
}
// SourceHead is one repository of the source revision: its trunk branch and that trunk's head.
type SourceHead struct {
// the trunk's head the source revision names
Head string `json:"head"`
// the repository, <owner>/<name>
Repository string `json:"repository"`
// its trunk branch, such as main
Trunk string `json:"trunk"`
}
// DeliveriesInput is what deliveries takes.
type DeliveriesInput struct {
// "true": the final ones of the last thirty days too
All string `json:"all,omitempty"`
// a group's id (its branch name)
Group string `json:"group,omitempty"`
// owner/repository
Repository string `json:"repository,omitempty"`
// one state, e.g. delivering or held
State string `json:"state,omitempty"`
}
// The values of DeliveriesInput's all.
const (
DeliveriesInputAllTrue = "true"
DeliveriesInputAllFalse = "false"
)
// DeliveriesAnswer is what deliveries answers.
type DeliveriesAnswer = map[string]any
// ShowInput is what show takes.
type ShowInput struct {
// a delivery's id, or a group's
ID string `json:"id"`
}
// ShowAnswer is what show answers.
type ShowAnswer = map[string]any
// GroupsInput is what groups takes.
type GroupsInput struct {
// "true": the groups that ended too
All string `json:"all,omitempty"`
// one group's id: that group alone, ended or not
Group string `json:"group,omitempty"`
}
// The values of GroupsInput's all.
const (
GroupsInputAllTrue = "true"
GroupsInputAllFalse = "false"
)
// GroupsAnswer is what groups answers.
type GroupsAnswer struct {
// why it could not answer at all; a group it does not know is answered with no groups, never an error
Error string `json:"error,omitempty"`
Groups []Group `json:"groups,omitempty"`
}
// SourceInput is what source takes.
type SourceInput struct {
// the watched branch, escaped as a key name is
Branch string `json:"branch"`
}
// SourceAnswer is what source answers.
type SourceAnswer struct {
// the watched branch the source revision is of
Branch string `json:"branch,omitempty"`
// why it could not be read
Error string `json:"error,omitempty"`
// the group that moved the source revision last; absent before the first
Group string `json:"group,omitempty"`
// every repository the source revision names, by name
Repositories []SourceHead `json:"repositories,omitempty"`
// the source revision's number on the bus; 0 before the first
Revision int64 `json:"revision,omitempty"`
}
// StalledInput is what stalled takes.
type StalledInput struct {
}
// StalledAnswer is what stalled answers.
type StalledAnswer = map[string]any
// RecoveryInput is what recovery takes.
type RecoveryInput struct {
// the merge commit
Commit string `json:"commit"`
// the repository, <owner>/<name>
Repository string `json:"repository"`
// why the merge is a recovery
Why string `json:"why"`
}
// RecoveryAnswer is what recovery answers.
type RecoveryAnswer struct {
// the caller the runtime proved
By string `json:"by,omitempty"`
// the merge commit
Commit string `json:"commit"`
Recovery bool `json:"recovery"`
// the repository
Repository string `json:"repository,omitempty"`
}
// OwedEvent is the body of the event owed.
type OwedEvent = Owed
// PinnedEvent is the body of the event pinned.
type PinnedEvent = Pins
// FreedEvent is the body of the event freed.
type FreedEvent = Pins
// HeadsReplacedEvent is the body of the event heads-replaced.
type HeadsReplacedEvent struct {
// when
At *time.Time `json:"at,omitempty"`
// the pull request closed
Closed bool `json:"closed,omitempty"`
// the group
Group string `json:"group"`
// its new head; absent when it closed
Head string `json:"head,omitempty"`
// the candidate's heads, 12 hex digits, as its revisions are keyed
Heads string `json:"heads"`
// its pull request's number
Number int64 `json:"number"`
// the member whose head moved or which closed
Repository string `json:"repository"`
}
// RecordOpenedEvent is the body of the event record-opened.
type RecordOpenedEvent struct {
// when
At *time.Time `json:"at,omitempty"`
// a merge made at the forge, with no Approve
ForgeMade bool `json:"forge-made,omitempty"`
// its milestone
Milestone string `json:"milestone"`
// the record's id
Record string `json:"record"`
}
// RecordEndedEventAwayItem is a type of the contract.
type RecordEndedEventAwayItem struct {
// a node away
Node string `json:"node"`
// since when
Since *time.Time `json:"since,omitempty"`
}
// RecordEndedEvent is the body of the event record-ended.
type RecordEndedEvent struct {
// when
At *time.Time `json:"at,omitempty"`
// the nodes away, each with since when; it ends without them
Away []RecordEndedEventAwayItem `json:"away,omitempty"`
// a merge made at the forge, with no Approve
ForgeMade bool `json:"forge-made,omitempty"`
// its milestone
Milestone string `json:"milestone"`
// the record's id
Record string `json:"record"`
}
// FillingEvent is the body of the event filling.
type FillingEvent = Fill
// FullEvent is the body of the event full.
type FullEvent = Fill
// RoomEvent is the body of the event room.
type RoomEvent = Fill
// SourceMovedEvent is the body of the event source-moved.
type SourceMovedEvent struct {
At *time.Time `json:"at,omitempty"`
Branch string `json:"branch"`
// the group that moved it, when one did
Group string `json:"group,omitempty"`
Revision int64 `json:"revision"`
V int64 `json:"v,omitempty"`
}
// RecoveryMergedEvent is the body of the event recovery-merged.
type RecoveryMergedEvent struct {
At *time.Time `json:"at,omitempty"`
// the caller the runtime proved
By string `json:"by,omitempty"`
// the merge commit
Commit string `json:"commit"`
// the repository
Repository string `json:"repository"`
V int64 `json:"v"`
// why
Why string `json:"why"`
}
// SourceByBranchValue is one value of the state source under the key <branch>.
type SourceByBranchValue struct {
// the group that moved it
Group string `json:"group"`
// repository to the merged head, a full commit
Heads map[string]string `json:"heads"`
// the layout version
V int64 `json:"v,omitempty"`
}
// MergesByGroupValuePullsItem is a type of the contract.
type MergesByGroupValuePullsItem struct {
Commit string `json:"commit,omitempty"`
Head string `json:"head"`
Number int64 `json:"number"`
Repository string `json:"repository"`
// merging, merged or refused
State string `json:"state"`
Words string `json:"words,omitempty"`
}
// MergesByGroupValue is one value of the state merges under the key <group>.
type MergesByGroupValue struct {
// <repository>@<number> to the approved head
Approved map[string]string `json:"approved,omitempty"`
// the ask key
Ask string `json:"ask"`
Group string `json:"group"`
Pulls []MergesByGroupValuePullsItem `json:"pulls"`
// the layout version
V int64 `json:"v,omitempty"`
}
// AsksByMergeGroupHeadsValueHeadsItem is a type of the contract.
type AsksByMergeGroupHeadsValueHeadsItem struct {
// the full commit
Head string `json:"head"`
Number int64 `json:"number"`
// <owner>/<name>
Repository string `json:"repository"`
}
// AsksByMergeGroupHeadsValue is one value of the state asks under the key merge.<group>.<heads>.
type AsksByMergeGroupHeadsValue struct {
// the operator-channel ask as raised
Ask any `json:"ask"`
// the number of times it was asked
Asking int64 `json:"asking,omitempty"`
Group string `json:"group"`
Heads []AsksByMergeGroupHeadsValueHeadsItem `json:"heads"`
// the layout version
V int64 `json:"v,omitempty"`
}
// OwedByRepositoryNumberHeadActValue is one value of the state owed under the key <repository>.<number>.<head>.<act>.
type OwedByRepositoryNumberHeadActValue struct {
// status=<context>, view, note or comment.<seq>
Act string `json:"act"`
Context string `json:"context,omitempty"`
Ref string `json:"ref,omitempty"`
State string `json:"state,omitempty"`
Target string `json:"target,omitempty"`
Text string `json:"text,omitempty"`
// the layout version
V int64 `json:"v,omitempty"`
}
// TurnsByRepositoryValueWaitingItem is a type of the contract.
type TurnsByRepositoryValueWaitingItem struct {
// when (RFC 3339 time)
Approved time.Time `json:"approved"`
Ask string `json:"ask,omitempty"`
Group string `json:"group"`
Heads string `json:"heads"`
// when (RFC 3339 time)
Since time.Time `json:"since"`
Step string `json:"step,omitempty"`
WaitsFor string `json:"waits-for,omitempty"`
// when (RFC 3339 time)
WaitsSince *time.Time `json:"waits-since,omitempty"`
}
// TurnsByRepositoryValue is one value of the state turns under the key <repository>.
type TurnsByRepositoryValue struct {
Repository string `json:"repository"`
// the layout version
V int64 `json:"v,omitempty"`
Waiting []TurnsByRepositoryValueWaitingItem `json:"waiting"`
}