feat(guard): the guard.v1 SDK and a business-hours guard (archie #1986)
publish / publish (push) Successful in 1m12s

This commit is contained in:
sam committed 2026-11-16 05:11:58 +11:00
1 parent af379c0532
commit 40121f6d10
9 files changed
+1548

No files matched your search

+1
View File
@@ -15,6 +15,7 @@ workflows/<name>/ package.yaml + workflow YAML, projected into workflow-d
channels/<name>/ package.yaml + Go source, served over channel.v1 (email)
forge/<name>/ package.yaml + Go source, served over forge.v1 (github, gitea)
connectors/<name>/ package.yaml + Go source, served over connector.v1 (alertmanager)
guards/<name>/ package.yaml + Go source, served over guard.v1 (business-hours)
playbooks/<name>/ package.yaml + EDA playbook YAML, projected into eda-playbooks
profiles/<name>/ package.yaml + agent profile YAML, projected into agent-profiles
sdk/ generated surface stubs and the Serve helper
+86
View File
@@ -0,0 +1,86 @@
// business-hours holds actions that change something outside working hours at
// propose and wait. Settings: timezone (IANA name, default UTC), start and end
// (hour of day, default 9 and 17), and days (comma-separated weekday numbers
// with Sunday as 0, default 1,2,3,4,5).
package main
import (
"context"
"fmt"
"strconv"
"strings"
"time"
"github.com/samcharles93/archipelago/sdk/guard"
)
type hours struct {
loc *time.Location
start, end int
days map[time.Weekday]bool
}
func build(cfg guard.Config) (guard.Guard, error) {
h := hours{start: 9, end: 17, days: map[time.Weekday]bool{}}
var err error
if h.loc, err = time.LoadLocation(or(cfg.Settings["timezone"], "UTC")); err != nil {
return nil, fmt.Errorf("timezone: %w", err)
}
if h.start, err = hour(cfg.Settings["start"], 9); err != nil {
return nil, fmt.Errorf("start: %w", err)
}
if h.end, err = hour(cfg.Settings["end"], 17); err != nil {
return nil, fmt.Errorf("end: %w", err)
}
for _, d := range strings.Split(or(cfg.Settings["days"], "1,2,3,4,5"), ",") {
n, err := strconv.Atoi(strings.TrimSpace(d))
if err != nil || n < 0 || n > 6 {
return nil, fmt.Errorf("days: %q is not a weekday number", d)
}
h.days[time.Weekday(n)] = true
}
return h, nil
}
func or(s, fallback string) string {
if s == "" {
return fallback
}
return s
}
func hour(s string, fallback int) (int, error) {
if s == "" {
return fallback, nil
}
n, err := strconv.Atoi(s)
if err != nil || n < 0 || n > 24 {
return 0, fmt.Errorf("%q is not an hour of the day", s)
}
return n, nil
}
func (hours) Describe() guard.Description {
return guard.Description{Name: "business-hours", Version: "1.0.0"}
}
func (h hours) Judge(_ context.Context, a guard.Action) (guard.Verdict, error) {
if a.Effect.ReadOnly {
return guard.Verdict{Ceiling: guard.ActQuietly}, nil
}
at := a.At.In(h.loc)
if h.days[at.Weekday()] && at.Hour() >= h.start && at.Hour() < h.end {
return guard.Verdict{Ceiling: guard.ActQuietly}, nil
}
return guard.Verdict{
Ceiling: guard.ProposeAndWait,
Findings: []guard.Finding{{
Text: "the action changes something outside business hours",
Evidence: "the host's clock reads " + at.Format("Mon 15:04 MST"),
Strength: guard.Strong,
}},
BlindSpots: []string{"public holidays"},
}, nil
}
func main() { guard.Serve(build) }
+46
View File
@@ -0,0 +1,46 @@
package main
import (
"testing"
"time"
"github.com/samcharles93/archipelago/sdk/guard"
)
// TestJudgeHoldsChangesOutsideBusinessHours guards the guard's one job: a
// change outside the configured hours is held, a read never is.
func TestJudgeHoldsChangesOutsideBusinessHours(t *testing.T) {
tests := []struct {
name string
settings map[string]string
at time.Time
readOnly bool
want guard.Ceiling
}{
{name: "a weekday morning acts quietly", at: time.Date(2026, 11, 16, 10, 0, 0, 0, time.UTC), want: guard.ActQuietly},
{name: "a weekday night is held", at: time.Date(2026, 11, 16, 22, 0, 0, 0, time.UTC), want: guard.ProposeAndWait},
{name: "a weekend is held", at: time.Date(2026, 11, 15, 10, 0, 0, 0, time.UTC), want: guard.ProposeAndWait},
{name: "a read is never held", at: time.Date(2026, 11, 15, 3, 0, 0, 0, time.UTC), readOnly: true, want: guard.ActQuietly},
{
name: "the timezone decides the hour",
settings: map[string]string{"timezone": "Australia/Sydney"},
at: time.Date(2026, 11, 16, 10, 0, 0, 0, time.UTC),
want: guard.ProposeAndWait,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g, err := build(guard.Config{Settings: tt.settings})
if err != nil {
t.Fatal(err)
}
v, err := g.Judge(t.Context(), guard.Action{At: tt.at, Effect: guard.Effect{ReadOnly: tt.readOnly}})
if err != nil {
t.Fatal(err)
}
if v.Ceiling != tt.want {
t.Fatalf("ceiling = %d, want %d", v.Ceiling, tt.want)
}
})
}
}
+11
View File
@@ -0,0 +1,11 @@
apiVersion: dev.archie.package.v1
displayName: Business hours
description: Hold actions that change something outside working hours at propose and wait.
version: 1.0.0
contributes:
extensions:
- surface: guard
path: bin/business-hours
files:
- path: bin/business-hours
mode: 493
+109
View File
@@ -0,0 +1,109 @@
// Package guard is what a Go guard extension builds on: the generated
// guard.v1 contract, the interface a guard implements and the Serve helper
// archie-core launches it with.
package guard
import (
"context"
"encoding/json/jsontext"
"time"
)
// Contract is the guard contract version this SDK speaks.
const Contract = "v1"
// Ceiling is the five-level scale a guard answers with, from the most
// autonomy to the least. The action runs at the lowest ceiling any guard sets.
type Ceiling int
// The five levels. The zero Ceiling means the guard gave none, which holds the
// action at propose and wait.
const (
ActQuietly Ceiling = iota + 1
ActAndTell
ProposeAndWait
Escalate
Never
)
// Strength is how much a finding's evidence supports it.
type Strength int
// Evidence strengths.
const (
StrengthUnspecified Strength = iota
Weak
Moderate
Strong
)
// Config is the operator's settings and the host-resolved secrets.
type Config struct {
Settings map[string]string
Secrets map[string]string
}
// Description names the guard and says whether its verdicts count.
type Description struct {
Name string
Version string
// Advisory verdicts are recorded and set no ceiling.
Advisory bool
}
// Action is one concrete action put to the guard.
type Action struct {
Connector string
Name string
Input jsontext.Value
Digest string
Target Target
Effect Effect
RunID string
// DecisionKey identifies the attempt to run the action.
DecisionKey string
// Deadline is how long the host waits for the verdict.
Deadline time.Duration
// At is the host's clock when the action was put to the guard.
At time.Time
}
// Target is what the action acts on.
type Target struct {
Kind string
ID string
Environment string
Disposable bool
}
// Effect is what the connector says the action does.
type Effect struct {
ReadOnly bool
// Reversibility is 1 (undone automatically), 2 (recoverable), 3
// (irreversible), or 0 when the connector declared none.
Reversibility int
Summary string
}
// Finding is one thing the guard noticed, with what it rests on.
type Finding struct {
Text string
Evidence string
Strength Strength
}
// Verdict is a guard's judgement of one action. A guard with no concern
// returns Ceiling ActQuietly and no findings.
type Verdict struct {
Ceiling Ceiling
Findings []Finding
BlindSpots []string
}
// Guard judges one concrete action.
type Guard interface {
Describe() Description
// Judge returns the verdict. An error holds the action at propose and
// wait, unless the guard is advisory.
Judge(ctx context.Context, a Action) (Verdict, error)
}
+40
View File
@@ -0,0 +1,40 @@
package guard
import (
"context"
goplugin "github.com/hashicorp/go-plugin"
"google.golang.org/grpc"
guardv1 "github.com/samcharles93/archipelago/sdk/guard/v1"
)
const surface = "guard"
type plugin struct {
goplugin.NetRPCUnsupportedPlugin
impl guardv1.GuardServiceServer
}
func (p *plugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error {
guardv1.RegisterGuardServiceServer(s, p.impl)
return nil
}
func (*plugin) GRPCClient(context.Context, *goplugin.GRPCBroker, *grpc.ClientConn) (any, error) {
return nil, nil
}
// Serve runs the guard build returns as the extension process. build is called
// on every Configure. Serve returns when archie-core stops the extension.
func Serve(build func(Config) (Guard, error)) {
goplugin.Serve(&goplugin.ServeConfig{
HandshakeConfig: goplugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "ARCHIE_EXTENSION",
MagicCookieValue: "archie",
},
Plugins: goplugin.PluginSet{surface: &plugin{impl: &server{build: build}}},
GRPCServer: goplugin.DefaultGRPCServer,
})
}
+76
View File
@@ -0,0 +1,76 @@
package guard
import (
"context"
"sync/atomic"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
guardv1 "github.com/samcharles93/archipelago/sdk/guard/v1"
)
// server adapts a Guard to the gRPC surface.
type server struct {
guardv1.UnimplementedGuardServiceServer
build func(Config) (Guard, error)
g atomic.Pointer[Guard]
}
func (s *server) Configure(_ context.Context, req *guardv1.ConfigureRequest) (*guardv1.ConfigureResponse, error) {
g, err := s.build(Config{Settings: req.GetSettings(), Secrets: req.GetSecrets()})
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "configure: %v", err)
}
s.g.Store(&g)
return &guardv1.ConfigureResponse{}, nil
}
func (s *server) guard() (Guard, error) {
g := s.g.Load()
if g == nil {
return nil, status.Error(codes.FailedPrecondition, "guard not configured")
}
return *g, nil
}
func (s *server) Describe(context.Context, *guardv1.DescribeRequest) (*guardv1.DescribeResponse, error) {
g, err := s.guard()
if err != nil {
return nil, err
}
d := g.Describe()
return &guardv1.DescribeResponse{Contract: Contract, Name: d.Name, Version: d.Version, Advisory: d.Advisory}, nil
}
func (s *server) Judge(ctx context.Context, req *guardv1.JudgeRequest) (*guardv1.JudgeResponse, error) {
g, err := s.guard()
if err != nil {
return nil, err
}
if d := req.GetDeadline(); d != nil {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, d.AsDuration())
defer cancel()
}
v, err := g.Judge(ctx, action(req))
if err != nil {
return nil, status.Errorf(codes.Unavailable, "judge: %v", err)
}
out := &guardv1.JudgeResponse{Ceiling: guardv1.Ceiling(v.Ceiling), BlindSpots: v.BlindSpots}
for _, f := range v.Findings {
out.Findings = append(out.Findings, &guardv1.Finding{Text: f.Text, Evidence: f.Evidence, Strength: guardv1.Strength(f.Strength)})
}
return out, nil
}
func action(req *guardv1.JudgeRequest) Action {
t, e := req.GetTarget(), req.GetEffect()
return Action{
Connector: req.GetConnector(), Name: req.GetName(), Input: req.GetInput(), Digest: req.GetDigest(),
Target: Target{Kind: t.GetKind(), ID: t.GetId(), Environment: t.GetEnvironment(), Disposable: t.GetDisposable()},
Effect: Effect{ReadOnly: e.GetReadOnly(), Reversibility: int(e.GetReversibility()), Summary: e.GetSummary()},
RunID: req.GetRun().GetRunId(), DecisionKey: req.GetRun().GetDecisionKey(),
Deadline: req.GetDeadline().AsDuration(), At: req.GetAt().AsTime(),
}
}
+960
View File
@@ -0,0 +1,960 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc (unknown)
// source: guard/v1/guard.proto
package guardv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
durationpb "google.golang.org/protobuf/types/known/durationpb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Reversibility int32
const (
Reversibility_REVERSIBILITY_UNSPECIFIED Reversibility = 0
Reversibility_REVERSIBILITY_UNDONE_AUTOMATICALLY Reversibility = 1
Reversibility_REVERSIBILITY_RECOVERABLE Reversibility = 2
Reversibility_REVERSIBILITY_IRREVERSIBLE Reversibility = 3
)
// Enum value maps for Reversibility.
var (
Reversibility_name = map[int32]string{
0: "REVERSIBILITY_UNSPECIFIED",
1: "REVERSIBILITY_UNDONE_AUTOMATICALLY",
2: "REVERSIBILITY_RECOVERABLE",
3: "REVERSIBILITY_IRREVERSIBLE",
}
Reversibility_value = map[string]int32{
"REVERSIBILITY_UNSPECIFIED": 0,
"REVERSIBILITY_UNDONE_AUTOMATICALLY": 1,
"REVERSIBILITY_RECOVERABLE": 2,
"REVERSIBILITY_IRREVERSIBLE": 3,
}
)
func (x Reversibility) Enum() *Reversibility {
p := new(Reversibility)
*p = x
return p
}
func (x Reversibility) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Reversibility) Descriptor() protoreflect.EnumDescriptor {
return file_guard_v1_guard_proto_enumTypes[0].Descriptor()
}
func (Reversibility) Type() protoreflect.EnumType {
return &file_guard_v1_guard_proto_enumTypes[0]
}
func (x Reversibility) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Reversibility.Descriptor instead.
func (Reversibility) EnumDescriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{0}
}
// Ceiling is the five-level scale, from the most autonomy to the least.
type Ceiling int32
const (
Ceiling_CEILING_UNSPECIFIED Ceiling = 0
Ceiling_CEILING_ACT_QUIETLY Ceiling = 1
Ceiling_CEILING_ACT_AND_TELL Ceiling = 2
Ceiling_CEILING_PROPOSE_AND_WAIT Ceiling = 3
Ceiling_CEILING_ESCALATE Ceiling = 4
Ceiling_CEILING_NEVER Ceiling = 5
)
// Enum value maps for Ceiling.
var (
Ceiling_name = map[int32]string{
0: "CEILING_UNSPECIFIED",
1: "CEILING_ACT_QUIETLY",
2: "CEILING_ACT_AND_TELL",
3: "CEILING_PROPOSE_AND_WAIT",
4: "CEILING_ESCALATE",
5: "CEILING_NEVER",
}
Ceiling_value = map[string]int32{
"CEILING_UNSPECIFIED": 0,
"CEILING_ACT_QUIETLY": 1,
"CEILING_ACT_AND_TELL": 2,
"CEILING_PROPOSE_AND_WAIT": 3,
"CEILING_ESCALATE": 4,
"CEILING_NEVER": 5,
}
)
func (x Ceiling) Enum() *Ceiling {
p := new(Ceiling)
*p = x
return p
}
func (x Ceiling) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Ceiling) Descriptor() protoreflect.EnumDescriptor {
return file_guard_v1_guard_proto_enumTypes[1].Descriptor()
}
func (Ceiling) Type() protoreflect.EnumType {
return &file_guard_v1_guard_proto_enumTypes[1]
}
func (x Ceiling) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Ceiling.Descriptor instead.
func (Ceiling) EnumDescriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{1}
}
// Strength is how much a finding's evidence supports it.
type Strength int32
const (
Strength_STRENGTH_UNSPECIFIED Strength = 0
Strength_STRENGTH_WEAK Strength = 1
Strength_STRENGTH_MODERATE Strength = 2
Strength_STRENGTH_STRONG Strength = 3
)
// Enum value maps for Strength.
var (
Strength_name = map[int32]string{
0: "STRENGTH_UNSPECIFIED",
1: "STRENGTH_WEAK",
2: "STRENGTH_MODERATE",
3: "STRENGTH_STRONG",
}
Strength_value = map[string]int32{
"STRENGTH_UNSPECIFIED": 0,
"STRENGTH_WEAK": 1,
"STRENGTH_MODERATE": 2,
"STRENGTH_STRONG": 3,
}
)
func (x Strength) Enum() *Strength {
p := new(Strength)
*p = x
return p
}
func (x Strength) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Strength) Descriptor() protoreflect.EnumDescriptor {
return file_guard_v1_guard_proto_enumTypes[2].Descriptor()
}
func (Strength) Type() protoreflect.EnumType {
return &file_guard_v1_guard_proto_enumTypes[2]
}
func (x Strength) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Strength.Descriptor instead.
func (Strength) EnumDescriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{2}
}
type ConfigureRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Settings map[string]string `protobuf:"bytes,1,rep,name=settings,proto3" json:"settings,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
Secrets map[string]string `protobuf:"bytes,2,rep,name=secrets,proto3" json:"secrets,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ConfigureRequest) Reset() {
*x = ConfigureRequest{}
mi := &file_guard_v1_guard_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ConfigureRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfigureRequest) ProtoMessage() {}
func (x *ConfigureRequest) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfigureRequest.ProtoReflect.Descriptor instead.
func (*ConfigureRequest) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{0}
}
func (x *ConfigureRequest) GetSettings() map[string]string {
if x != nil {
return x.Settings
}
return nil
}
func (x *ConfigureRequest) GetSecrets() map[string]string {
if x != nil {
return x.Secrets
}
return nil
}
type ConfigureResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ConfigureResponse) Reset() {
*x = ConfigureResponse{}
mi := &file_guard_v1_guard_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ConfigureResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfigureResponse) ProtoMessage() {}
func (x *ConfigureResponse) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfigureResponse.ProtoReflect.Descriptor instead.
func (*ConfigureResponse) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{1}
}
type DescribeRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *DescribeRequest) Reset() {
*x = DescribeRequest{}
mi := &file_guard_v1_guard_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DescribeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DescribeRequest) ProtoMessage() {}
func (x *DescribeRequest) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DescribeRequest.ProtoReflect.Descriptor instead.
func (*DescribeRequest) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{2}
}
type DescribeResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
// contract is the contract version the guard speaks, "v1".
Contract string `protobuf:"bytes,1,opt,name=contract,proto3" json:"contract,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
// version is the guard's own release, recorded with each verdict.
Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
// advisory says the guard's verdicts are recorded and set no ceiling.
Advisory bool `protobuf:"varint,4,opt,name=advisory,proto3" json:"advisory,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *DescribeResponse) Reset() {
*x = DescribeResponse{}
mi := &file_guard_v1_guard_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DescribeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DescribeResponse) ProtoMessage() {}
func (x *DescribeResponse) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DescribeResponse.ProtoReflect.Descriptor instead.
func (*DescribeResponse) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{3}
}
func (x *DescribeResponse) GetContract() string {
if x != nil {
return x.Contract
}
return ""
}
func (x *DescribeResponse) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *DescribeResponse) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
func (x *DescribeResponse) GetAdvisory() bool {
if x != nil {
return x.Advisory
}
return false
}
type Effect struct {
state protoimpl.MessageState `protogen:"open.v1"`
ReadOnly bool `protobuf:"varint,1,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"`
Reversibility Reversibility `protobuf:"varint,2,opt,name=reversibility,proto3,enum=guard.v1.Reversibility" json:"reversibility,omitempty"`
Summary string `protobuf:"bytes,3,opt,name=summary,proto3" json:"summary,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Effect) Reset() {
*x = Effect{}
mi := &file_guard_v1_guard_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Effect) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Effect) ProtoMessage() {}
func (x *Effect) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Effect.ProtoReflect.Descriptor instead.
func (*Effect) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{4}
}
func (x *Effect) GetReadOnly() bool {
if x != nil {
return x.ReadOnly
}
return false
}
func (x *Effect) GetReversibility() Reversibility {
if x != nil {
return x.Reversibility
}
return Reversibility_REVERSIBILITY_UNSPECIFIED
}
func (x *Effect) GetSummary() string {
if x != nil {
return x.Summary
}
return ""
}
type Target struct {
state protoimpl.MessageState `protogen:"open.v1"`
Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
Environment string `protobuf:"bytes,3,opt,name=environment,proto3" json:"environment,omitempty"`
Disposable bool `protobuf:"varint,4,opt,name=disposable,proto3" json:"disposable,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Target) Reset() {
*x = Target{}
mi := &file_guard_v1_guard_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Target) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Target) ProtoMessage() {}
func (x *Target) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Target.ProtoReflect.Descriptor instead.
func (*Target) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{5}
}
func (x *Target) GetKind() string {
if x != nil {
return x.Kind
}
return ""
}
func (x *Target) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Target) GetEnvironment() string {
if x != nil {
return x.Environment
}
return ""
}
func (x *Target) GetDisposable() bool {
if x != nil {
return x.Disposable
}
return false
}
type RunContext struct {
state protoimpl.MessageState `protogen:"open.v1"`
RunId string `protobuf:"bytes,1,opt,name=run_id,json=runId,proto3" json:"run_id,omitempty"`
// decision_key identifies the attempt to run the action.
DecisionKey string `protobuf:"bytes,2,opt,name=decision_key,json=decisionKey,proto3" json:"decision_key,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RunContext) Reset() {
*x = RunContext{}
mi := &file_guard_v1_guard_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RunContext) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RunContext) ProtoMessage() {}
func (x *RunContext) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RunContext.ProtoReflect.Descriptor instead.
func (*RunContext) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{6}
}
func (x *RunContext) GetRunId() string {
if x != nil {
return x.RunId
}
return ""
}
func (x *RunContext) GetDecisionKey() string {
if x != nil {
return x.DecisionKey
}
return ""
}
type JudgeRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Connector string `protobuf:"bytes,1,opt,name=connector,proto3" json:"connector,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Input []byte `protobuf:"bytes,3,opt,name=input,proto3" json:"input,omitempty"`
// digest identifies the exact action: its name and input.
Digest string `protobuf:"bytes,4,opt,name=digest,proto3" json:"digest,omitempty"`
Target *Target `protobuf:"bytes,5,opt,name=target,proto3" json:"target,omitempty"`
Effect *Effect `protobuf:"bytes,6,opt,name=effect,proto3" json:"effect,omitempty"`
Run *RunContext `protobuf:"bytes,7,opt,name=run,proto3" json:"run,omitempty"`
// deadline is how long the host waits for the verdict.
Deadline *durationpb.Duration `protobuf:"bytes,8,opt,name=deadline,proto3" json:"deadline,omitempty"`
// at is the host's clock when the action was put to the guard.
At *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=at,proto3" json:"at,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *JudgeRequest) Reset() {
*x = JudgeRequest{}
mi := &file_guard_v1_guard_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *JudgeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*JudgeRequest) ProtoMessage() {}
func (x *JudgeRequest) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use JudgeRequest.ProtoReflect.Descriptor instead.
func (*JudgeRequest) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{7}
}
func (x *JudgeRequest) GetConnector() string {
if x != nil {
return x.Connector
}
return ""
}
func (x *JudgeRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *JudgeRequest) GetInput() []byte {
if x != nil {
return x.Input
}
return nil
}
func (x *JudgeRequest) GetDigest() string {
if x != nil {
return x.Digest
}
return ""
}
func (x *JudgeRequest) GetTarget() *Target {
if x != nil {
return x.Target
}
return nil
}
func (x *JudgeRequest) GetEffect() *Effect {
if x != nil {
return x.Effect
}
return nil
}
func (x *JudgeRequest) GetRun() *RunContext {
if x != nil {
return x.Run
}
return nil
}
func (x *JudgeRequest) GetDeadline() *durationpb.Duration {
if x != nil {
return x.Deadline
}
return nil
}
func (x *JudgeRequest) GetAt() *timestamppb.Timestamp {
if x != nil {
return x.At
}
return nil
}
type Finding struct {
state protoimpl.MessageState `protogen:"open.v1"`
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
// evidence is what the finding rests on, in plain words.
Evidence string `protobuf:"bytes,2,opt,name=evidence,proto3" json:"evidence,omitempty"`
Strength Strength `protobuf:"varint,3,opt,name=strength,proto3,enum=guard.v1.Strength" json:"strength,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Finding) Reset() {
*x = Finding{}
mi := &file_guard_v1_guard_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Finding) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Finding) ProtoMessage() {}
func (x *Finding) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Finding.ProtoReflect.Descriptor instead.
func (*Finding) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{8}
}
func (x *Finding) GetText() string {
if x != nil {
return x.Text
}
return ""
}
func (x *Finding) GetEvidence() string {
if x != nil {
return x.Evidence
}
return ""
}
func (x *Finding) GetStrength() Strength {
if x != nil {
return x.Strength
}
return Strength_STRENGTH_UNSPECIFIED
}
type JudgeResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
// ceiling must be set. A guard with no concern answers CEILING_ACT_QUIETLY.
Ceiling Ceiling `protobuf:"varint,1,opt,name=ceiling,proto3,enum=guard.v1.Ceiling" json:"ceiling,omitempty"`
Findings []*Finding `protobuf:"bytes,2,rep,name=findings,proto3" json:"findings,omitempty"`
// blind_spots are what the guard could not see.
BlindSpots []string `protobuf:"bytes,3,rep,name=blind_spots,json=blindSpots,proto3" json:"blind_spots,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *JudgeResponse) Reset() {
*x = JudgeResponse{}
mi := &file_guard_v1_guard_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *JudgeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*JudgeResponse) ProtoMessage() {}
func (x *JudgeResponse) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use JudgeResponse.ProtoReflect.Descriptor instead.
func (*JudgeResponse) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{9}
}
func (x *JudgeResponse) GetCeiling() Ceiling {
if x != nil {
return x.Ceiling
}
return Ceiling_CEILING_UNSPECIFIED
}
func (x *JudgeResponse) GetFindings() []*Finding {
if x != nil {
return x.Findings
}
return nil
}
func (x *JudgeResponse) GetBlindSpots() []string {
if x != nil {
return x.BlindSpots
}
return nil
}
var File_guard_v1_guard_proto protoreflect.FileDescriptor
const file_guard_v1_guard_proto_rawDesc = "" +
"\n" +
"\x14guard/v1/guard.proto\x12\bguard.v1\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x94\x02\n" +
"\x10ConfigureRequest\x12D\n" +
"\bsettings\x18\x01 \x03(\v2(.guard.v1.ConfigureRequest.SettingsEntryR\bsettings\x12A\n" +
"\asecrets\x18\x02 \x03(\v2'.guard.v1.ConfigureRequest.SecretsEntryR\asecrets\x1a;\n" +
"\rSettingsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1a:\n" +
"\fSecretsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x13\n" +
"\x11ConfigureResponse\"\x11\n" +
"\x0fDescribeRequest\"x\n" +
"\x10DescribeResponse\x12\x1a\n" +
"\bcontract\x18\x01 \x01(\tR\bcontract\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x18\n" +
"\aversion\x18\x03 \x01(\tR\aversion\x12\x1a\n" +
"\badvisory\x18\x04 \x01(\bR\badvisory\"~\n" +
"\x06Effect\x12\x1b\n" +
"\tread_only\x18\x01 \x01(\bR\breadOnly\x12=\n" +
"\rreversibility\x18\x02 \x01(\x0e2\x17.guard.v1.ReversibilityR\rreversibility\x12\x18\n" +
"\asummary\x18\x03 \x01(\tR\asummary\"n\n" +
"\x06Target\x12\x12\n" +
"\x04kind\x18\x01 \x01(\tR\x04kind\x12\x0e\n" +
"\x02id\x18\x02 \x01(\tR\x02id\x12 \n" +
"\venvironment\x18\x03 \x01(\tR\venvironment\x12\x1e\n" +
"\n" +
"disposable\x18\x04 \x01(\bR\n" +
"disposable\"F\n" +
"\n" +
"RunContext\x12\x15\n" +
"\x06run_id\x18\x01 \x01(\tR\x05runId\x12!\n" +
"\fdecision_key\x18\x02 \x01(\tR\vdecisionKey\"\xcd\x02\n" +
"\fJudgeRequest\x12\x1c\n" +
"\tconnector\x18\x01 \x01(\tR\tconnector\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" +
"\x05input\x18\x03 \x01(\fR\x05input\x12\x16\n" +
"\x06digest\x18\x04 \x01(\tR\x06digest\x12(\n" +
"\x06target\x18\x05 \x01(\v2\x10.guard.v1.TargetR\x06target\x12(\n" +
"\x06effect\x18\x06 \x01(\v2\x10.guard.v1.EffectR\x06effect\x12&\n" +
"\x03run\x18\a \x01(\v2\x14.guard.v1.RunContextR\x03run\x125\n" +
"\bdeadline\x18\b \x01(\v2\x19.google.protobuf.DurationR\bdeadline\x12*\n" +
"\x02at\x18\t \x01(\v2\x1a.google.protobuf.TimestampR\x02at\"i\n" +
"\aFinding\x12\x12\n" +
"\x04text\x18\x01 \x01(\tR\x04text\x12\x1a\n" +
"\bevidence\x18\x02 \x01(\tR\bevidence\x12.\n" +
"\bstrength\x18\x03 \x01(\x0e2\x12.guard.v1.StrengthR\bstrength\"\x8c\x01\n" +
"\rJudgeResponse\x12+\n" +
"\aceiling\x18\x01 \x01(\x0e2\x11.guard.v1.CeilingR\aceiling\x12-\n" +
"\bfindings\x18\x02 \x03(\v2\x11.guard.v1.FindingR\bfindings\x12\x1f\n" +
"\vblind_spots\x18\x03 \x03(\tR\n" +
"blindSpots*\x95\x01\n" +
"\rReversibility\x12\x1d\n" +
"\x19REVERSIBILITY_UNSPECIFIED\x10\x00\x12&\n" +
"\"REVERSIBILITY_UNDONE_AUTOMATICALLY\x10\x01\x12\x1d\n" +
"\x19REVERSIBILITY_RECOVERABLE\x10\x02\x12\x1e\n" +
"\x1aREVERSIBILITY_IRREVERSIBLE\x10\x03*\x9c\x01\n" +
"\aCeiling\x12\x17\n" +
"\x13CEILING_UNSPECIFIED\x10\x00\x12\x17\n" +
"\x13CEILING_ACT_QUIETLY\x10\x01\x12\x18\n" +
"\x14CEILING_ACT_AND_TELL\x10\x02\x12\x1c\n" +
"\x18CEILING_PROPOSE_AND_WAIT\x10\x03\x12\x14\n" +
"\x10CEILING_ESCALATE\x10\x04\x12\x11\n" +
"\rCEILING_NEVER\x10\x05*c\n" +
"\bStrength\x12\x18\n" +
"\x14STRENGTH_UNSPECIFIED\x10\x00\x12\x11\n" +
"\rSTRENGTH_WEAK\x10\x01\x12\x15\n" +
"\x11STRENGTH_MODERATE\x10\x02\x12\x13\n" +
"\x0fSTRENGTH_STRONG\x10\x032\xd1\x01\n" +
"\fGuardService\x12D\n" +
"\tConfigure\x12\x1a.guard.v1.ConfigureRequest\x1a\x1b.guard.v1.ConfigureResponse\x12A\n" +
"\bDescribe\x12\x19.guard.v1.DescribeRequest\x1a\x1a.guard.v1.DescribeResponse\x128\n" +
"\x05Judge\x12\x16.guard.v1.JudgeRequest\x1a\x17.guard.v1.JudgeResponseB\x95\x01\n" +
"\fcom.guard.v1B\n" +
"GuardProtoP\x01Z8github.com/samcharles93/archipelago/sdk/guard/v1;guardv1\xa2\x02\x03GXX\xaa\x02\bGuard.V1\xca\x02\bGuard\\V1\xe2\x02\x14Guard\\V1\\GPBMetadata\xea\x02\tGuard::V1b\x06proto3"
var (
file_guard_v1_guard_proto_rawDescOnce sync.Once
file_guard_v1_guard_proto_rawDescData []byte
)
func file_guard_v1_guard_proto_rawDescGZIP() []byte {
file_guard_v1_guard_proto_rawDescOnce.Do(func() {
file_guard_v1_guard_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_guard_v1_guard_proto_rawDesc), len(file_guard_v1_guard_proto_rawDesc)))
})
return file_guard_v1_guard_proto_rawDescData
}
var file_guard_v1_guard_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_guard_v1_guard_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_guard_v1_guard_proto_goTypes = []any{
(Reversibility)(0), // 0: guard.v1.Reversibility
(Ceiling)(0), // 1: guard.v1.Ceiling
(Strength)(0), // 2: guard.v1.Strength
(*ConfigureRequest)(nil), // 3: guard.v1.ConfigureRequest
(*ConfigureResponse)(nil), // 4: guard.v1.ConfigureResponse
(*DescribeRequest)(nil), // 5: guard.v1.DescribeRequest
(*DescribeResponse)(nil), // 6: guard.v1.DescribeResponse
(*Effect)(nil), // 7: guard.v1.Effect
(*Target)(nil), // 8: guard.v1.Target
(*RunContext)(nil), // 9: guard.v1.RunContext
(*JudgeRequest)(nil), // 10: guard.v1.JudgeRequest
(*Finding)(nil), // 11: guard.v1.Finding
(*JudgeResponse)(nil), // 12: guard.v1.JudgeResponse
nil, // 13: guard.v1.ConfigureRequest.SettingsEntry
nil, // 14: guard.v1.ConfigureRequest.SecretsEntry
(*durationpb.Duration)(nil), // 15: google.protobuf.Duration
(*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp
}
var file_guard_v1_guard_proto_depIdxs = []int32{
13, // 0: guard.v1.ConfigureRequest.settings:type_name -> guard.v1.ConfigureRequest.SettingsEntry
14, // 1: guard.v1.ConfigureRequest.secrets:type_name -> guard.v1.ConfigureRequest.SecretsEntry
0, // 2: guard.v1.Effect.reversibility:type_name -> guard.v1.Reversibility
8, // 3: guard.v1.JudgeRequest.target:type_name -> guard.v1.Target
7, // 4: guard.v1.JudgeRequest.effect:type_name -> guard.v1.Effect
9, // 5: guard.v1.JudgeRequest.run:type_name -> guard.v1.RunContext
15, // 6: guard.v1.JudgeRequest.deadline:type_name -> google.protobuf.Duration
16, // 7: guard.v1.JudgeRequest.at:type_name -> google.protobuf.Timestamp
2, // 8: guard.v1.Finding.strength:type_name -> guard.v1.Strength
1, // 9: guard.v1.JudgeResponse.ceiling:type_name -> guard.v1.Ceiling
11, // 10: guard.v1.JudgeResponse.findings:type_name -> guard.v1.Finding
3, // 11: guard.v1.GuardService.Configure:input_type -> guard.v1.ConfigureRequest
5, // 12: guard.v1.GuardService.Describe:input_type -> guard.v1.DescribeRequest
10, // 13: guard.v1.GuardService.Judge:input_type -> guard.v1.JudgeRequest
4, // 14: guard.v1.GuardService.Configure:output_type -> guard.v1.ConfigureResponse
6, // 15: guard.v1.GuardService.Describe:output_type -> guard.v1.DescribeResponse
12, // 16: guard.v1.GuardService.Judge:output_type -> guard.v1.JudgeResponse
14, // [14:17] is the sub-list for method output_type
11, // [11:14] is the sub-list for method input_type
11, // [11:11] is the sub-list for extension type_name
11, // [11:11] is the sub-list for extension extendee
0, // [0:11] is the sub-list for field type_name
}
func init() { file_guard_v1_guard_proto_init() }
func file_guard_v1_guard_proto_init() {
if File_guard_v1_guard_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_guard_v1_guard_proto_rawDesc), len(file_guard_v1_guard_proto_rawDesc)),
NumEnums: 3,
NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_guard_v1_guard_proto_goTypes,
DependencyIndexes: file_guard_v1_guard_proto_depIdxs,
EnumInfos: file_guard_v1_guard_proto_enumTypes,
MessageInfos: file_guard_v1_guard_proto_msgTypes,
}.Build()
File_guard_v1_guard_proto = out.File
file_guard_v1_guard_proto_goTypes = nil
file_guard_v1_guard_proto_depIdxs = nil
}
+219
View File
@@ -0,0 +1,219 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.2
// - protoc (unknown)
// source: guard/v1/guard.proto
package guardv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
GuardService_Configure_FullMethodName = "/guard.v1.GuardService/Configure"
GuardService_Describe_FullMethodName = "/guard.v1.GuardService/Describe"
GuardService_Judge_FullMethodName = "/guard.v1.GuardService/Judge"
)
// GuardServiceClient is the client API for GuardService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// GuardService is the surface a guard extension serves. A guard judges one
// concrete action and answers with a ceiling on the five-level scale. The host
// asks every running guard about every action and runs the action at the lowest
// ceiling.
type GuardServiceClient interface {
// Configure hands the guard its settings and resolved secrets, once, right
// after launch and before any Judge.
Configure(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureResponse, error)
// Describe names the guard and says whether its verdicts count.
Describe(ctx context.Context, in *DescribeRequest, opts ...grpc.CallOption) (*DescribeResponse, error)
// Judge returns the guard's verdict on one action. The host enforces the
// request's deadline: a guard that errors, answers late or answers without
// a ceiling holds the action at propose and wait, unless it is advisory.
Judge(ctx context.Context, in *JudgeRequest, opts ...grpc.CallOption) (*JudgeResponse, error)
}
type guardServiceClient struct {
cc grpc.ClientConnInterface
}
func NewGuardServiceClient(cc grpc.ClientConnInterface) GuardServiceClient {
return &guardServiceClient{cc}
}
func (c *guardServiceClient) Configure(ctx context.Context, in *ConfigureRequest, opts ...grpc.CallOption) (*ConfigureResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ConfigureResponse)
err := c.cc.Invoke(ctx, GuardService_Configure_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *guardServiceClient) Describe(ctx context.Context, in *DescribeRequest, opts ...grpc.CallOption) (*DescribeResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DescribeResponse)
err := c.cc.Invoke(ctx, GuardService_Describe_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *guardServiceClient) Judge(ctx context.Context, in *JudgeRequest, opts ...grpc.CallOption) (*JudgeResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(JudgeResponse)
err := c.cc.Invoke(ctx, GuardService_Judge_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// GuardServiceServer is the server API for GuardService service.
// All implementations must embed UnimplementedGuardServiceServer
// for forward compatibility.
//
// GuardService is the surface a guard extension serves. A guard judges one
// concrete action and answers with a ceiling on the five-level scale. The host
// asks every running guard about every action and runs the action at the lowest
// ceiling.
type GuardServiceServer interface {
// Configure hands the guard its settings and resolved secrets, once, right
// after launch and before any Judge.
Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error)
// Describe names the guard and says whether its verdicts count.
Describe(context.Context, *DescribeRequest) (*DescribeResponse, error)
// Judge returns the guard's verdict on one action. The host enforces the
// request's deadline: a guard that errors, answers late or answers without
// a ceiling holds the action at propose and wait, unless it is advisory.
Judge(context.Context, *JudgeRequest) (*JudgeResponse, error)
mustEmbedUnimplementedGuardServiceServer()
}
// UnimplementedGuardServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedGuardServiceServer struct{}
func (UnimplementedGuardServiceServer) Configure(context.Context, *ConfigureRequest) (*ConfigureResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Configure not implemented")
}
func (UnimplementedGuardServiceServer) Describe(context.Context, *DescribeRequest) (*DescribeResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Describe not implemented")
}
func (UnimplementedGuardServiceServer) Judge(context.Context, *JudgeRequest) (*JudgeResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Judge not implemented")
}
func (UnimplementedGuardServiceServer) mustEmbedUnimplementedGuardServiceServer() {}
func (UnimplementedGuardServiceServer) testEmbeddedByValue() {}
// UnsafeGuardServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to GuardServiceServer will
// result in compilation errors.
type UnsafeGuardServiceServer interface {
mustEmbedUnimplementedGuardServiceServer()
}
func RegisterGuardServiceServer(s grpc.ServiceRegistrar, srv GuardServiceServer) {
// If the following call panics, it indicates UnimplementedGuardServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&GuardService_ServiceDesc, srv)
}
func _GuardService_Configure_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ConfigureRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GuardServiceServer).Configure(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: GuardService_Configure_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GuardServiceServer).Configure(ctx, req.(*ConfigureRequest))
}
return interceptor(ctx, in, info, handler)
}
func _GuardService_Describe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DescribeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GuardServiceServer).Describe(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: GuardService_Describe_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GuardServiceServer).Describe(ctx, req.(*DescribeRequest))
}
return interceptor(ctx, in, info, handler)
}
func _GuardService_Judge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(JudgeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GuardServiceServer).Judge(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: GuardService_Judge_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GuardServiceServer).Judge(ctx, req.(*JudgeRequest))
}
return interceptor(ctx, in, info, handler)
}
// GuardService_ServiceDesc is the grpc.ServiceDesc for GuardService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var GuardService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "guard.v1.GuardService",
HandlerType: (*GuardServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Configure",
Handler: _GuardService_Configure_Handler,
},
{
MethodName: "Describe",
Handler: _GuardService_Describe_Handler,
},
{
MethodName: "Judge",
Handler: _GuardService_Judge_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "guard/v1/guard.proto",
}