Skip to main content

Guardrail API

Table of Contents

Top

upsquad/guardrail/v1/guardrail.proto

CreateGuardrailRequest

CreateGuardrailRequest seeds a new Guardrail. Sentence may be empty during draft; server rejects on save when the rule is unparseable.

FieldTypeLabelDescription
namestringname is the founder-supplied label.
sentenceSentenceItemrepeatedsentence is the rule body.
scopestringscope is a free-text scope label.
severitySeverityseverity drives the severity pill.
enabledboolenabled controls whether the guardrail is live on save.

CreateGuardrailResponse

CreateGuardrailResponse echoes the persisted Guardrail with id assigned.

FieldTypeLabelDescription
guardrailGuardrailguardrail is the stored row including the assigned GR-NN id.

DeleteGuardrailRequest

DeleteGuardrailRequest marks a row deleted (soft).

FieldTypeLabelDescription
idstringid is the GR-NN target.

DeleteGuardrailResponse

DeleteGuardrailResponse is empty on success.

GetGuardrailRequest

GetGuardrailRequest targets a single guardrail by id.

FieldTypeLabelDescription
idstringid is the GR-NN form.

GetGuardrailResponse

GetGuardrailResponse returns the guardrail or a NotFound error.

FieldTypeLabelDescription
guardrailGuardrailguardrail is the stored row.

GetUsageStatsRequest

GetUsageStatsRequest queries usage of one guardrail.

FieldTypeLabelDescription
idstringid selects the persisted guardrail.
window_daysint32window_days caps at 30. Defaults to 7.

GetUsageStatsResponse

GetUsageStatsResponse is the aggregate stats card.

FieldTypeLabelDescription
triggeredint32triggered is the total event count that this guardrail evaluated.
blockedint32blocked is the count of events the guardrail blocked.
allowedint32allowed is the count of events the guardrail allowed.
last_fired_atgoogle.protobuf.Timestamplast_fired_at is unset when the guardrail has never fired.

Guardrail

Guardrail is the overlay resource. Joins to existing policy rows are resolved server-side; the wire shape is sentence-first, not policy-first.

FieldTypeLabelDescription
idstringid is the human-readable GR-NN form (e.g. "GR-04"). Sequential per tenant. Re-used across drafts of the same rule (Update keeps the id).
namestringname is the founder-supplied label (e.g. "Refund ceiling").
sentenceSentenceItemrepeatedsentence is the ordered list of items (text + tokens) that renders the rule. The prototype consumes this as an alternating array.
scopestringscope is a free-text scope label (e.g. "All teams", "Finance"). The prototype renders it verbatim; v1 stores it as text and a future LLD will resolve it to org_unit ids when compiling to policies.
severitySeverityseverity drives the severity pill rendered on the row + detail view.
enabledboolenabled gates whether the guardrail is live. Disabled rows are returned by List so the UI can show them with reduced opacity.
last_editstringlast_edit is a human label (e.g. "Marcus R · Apr 23"). Composed server-side from updated_by + updated_at.
created_atgoogle.protobuf.Timestampcreated_at is the wall-clock insert time.
updated_atgoogle.protobuf.Timestampupdated_at is the wall-clock time of the last mutation.

GuardrailTemplate

GuardrailTemplate seeds step-1 of the New Guardrail modal.

FieldTypeLabelDescription
idstringid is the template id (e.g. "ceiling", "data-export").
labelstringlabel is the displayed template name.
descriptionstringdescription is the one-line subtitle on the template card.
iconstringicon is a short glyph string ("$", "⊟", "↗", "⌥", "◴", "+"). The UI looks it up against an icon set; passing it on the wire keeps the frontend free of duplicate hard-coded mappings.
prefill_sentenceSentenceItemrepeatedprefill_sentence seeds the editable sentence on step 2.
prefill_scopestringprefill_scope seeds the scope dropdown.
prefill_severitySeverityprefill_severity seeds the severity selector.

ListGuardrailsRequest

ListGuardrailsRequest is paginated. The Guardrails redesign loads up to a few-dozen rows in practice; pagination is defence in depth.

FieldTypeLabelDescription
page_sizeint32page_size caps returned rows. Default 50, max 200.
page_tokenstringpage_token is an opaque cursor returned by a prior call.

ListGuardrailsResponse

ListGuardrailsResponse returns one page of guardrails.

FieldTypeLabelDescription
guardrailsGuardrailrepeatedguardrails is the returned page.
next_page_tokenstringnext_page_token is empty when no more rows exist.

ListTemplatesRequest

ListTemplatesRequest takes no parameters. Templates are static.

ListTemplatesResponse

ListTemplatesResponse returns the 6 hardcoded templates.

FieldTypeLabelDescription
templatesGuardrailTemplaterepeatedtemplates is the ordered list.

ListTokenValuesRequest

ListTokenValuesRequest is keyed on TokenKind. v1 ignores tenant context and returns static values; future LLDs may resolve dynamic values (e.g. role names from RBAC, dataclasses from compliance registry).

FieldTypeLabelDescription
kindTokenKindkind selects the dropdown to populate.

ListTokenValuesResponse

ListTokenValuesResponse returns the populated dropdown.

FieldTypeLabelDescription
valuesTokenValueOptionrepeatedvalues is empty when the kind is free-input (number / text) — the UI then renders a numeric or text input instead of a dropdown.

SampleDiff

SampleDiff is one audit row whose verdict would have flipped.

FieldTypeLabelDescription
event_idstringevent_id is the audit log primary key.
event_atgoogle.protobuf.Timestampevent_at is the audit row's created_at.
current_verdictstringcurrent_verdict is one of "allow", "deny", "requires_approval", or "n/a" when the engine could not produce a verdict.
would_be_verdictstringwould_be_verdict is the verdict the simulated guardrail would yield.
summarystringsummary is a human-readable one-line description of the event for the UI's "Show diff" panel.

SentenceItem

SentenceItem is one element of a Guardrail.sentence. Exactly one of text or token is set. Mirrors the JSX tokens.map(t => typeof t === "string" ? <span/> : <Token/>).

FieldTypeLabelDescription
textstringtext is a literal string fragment ("Block any refund over").
tokenTokenValuetoken is a typed value slot (e.g. money / clearance).

SimulateAgainstHistoryRequest

SimulateAgainstHistoryRequest replays audit events. Either pass an existing guardrail id and let the server use its persisted sentence, or override with edited_sentence to preview an unsaved edit.

FieldTypeLabelDescription
idstringid selects the persisted guardrail. Required.
edited_sentenceSentenceItemrepeatededited_sentence overrides the persisted sentence for preview. May be empty (= use persisted).
window_daysint32window_days is capped at 30. Defaults to 7 when 0.

SimulateAgainstHistoryResponse

SimulateAgainstHistoryResponse is the simulation outcome.

FieldTypeLabelDescription
would_changeint32would_change is the count of events whose verdict differs.
keptint32kept is the count of events whose verdict is unchanged.
sample_diffsSampleDiffrepeatedsample_diffs holds up to 20 example rows for the UI drawer.
total_events_evaluatedint32total_events_evaluated equals would_change + kept (audit window size). Returned for the prototype's "X of Y events" copy.

TokenValue

TokenValue is one colored slot inside a guardrail sentence. The prototype stores tokens as { kind, value } objects intermixed with raw strings; SentenceItem mirrors that shape.

FieldTypeLabelDescription
kindTokenKindkind is the discriminator (TOKEN_KIND_*).
valuestringvalue is the rendered form (e.g. "2500" for a money token, "Standard" for a clearance token, "8pm" for a time token). The UI formats based on kind ($ prefix, locale grouping for numbers).

TokenValueOption

TokenValueOption is one selectable option for a select-typed token.

FieldTypeLabelDescription
valuestringvalue is the wire form stored on the sentence token.
labelstringlabel is the display form rendered in the dropdown. Often equal to value but kept distinct for future i18n.

UpdateGuardrailRequest

UpdateGuardrailRequest replaces all editable fields on the row.

FieldTypeLabelDescription
idstringid is the GR-NN target.
namestringname is the new label.
sentenceSentenceItemrepeatedsentence is the new rule body.
scopestringscope is the new scope label.
severitySeverityseverity is the new severity band.
enabledboolenabled is the new enable bit.

UpdateGuardrailResponse

UpdateGuardrailResponse echoes the updated Guardrail.

FieldTypeLabelDescription
guardrailGuardrailguardrail is the stored row after update.

Severity

Severity mirrors the prototype's three-band severity selector.

NameNumberDescription
SEVERITY_UNSPECIFIED0SEVERITY_UNSPECIFIED is the proto3 zero value; rejected at the edge.
SEVERITY_LOW1SEVERITY_LOW maps to the "low" pill colour.
SEVERITY_MED2SEVERITY_MED maps to the "med" pill colour (warn band).
SEVERITY_HIGH3SEVERITY_HIGH maps to the "high" pill colour (danger band).

TokenKind

TokenKind enumerates the 11 supported token kinds. Mirrors the React prototype's kind discriminator on sentence tokens.

NameNumberDescription
TOKEN_KIND_UNSPECIFIED0TOKEN_KIND_UNSPECIFIED is the proto3 zero value; rejected at the edge.
TOKEN_KIND_MONEY1TOKEN_KIND_MONEY renders as a currency-formatted dollar amount.
TOKEN_KIND_COUNT2TOKEN_KIND_COUNT renders as a locale-grouped integer count.
TOKEN_KIND_CLEARANCE3TOKEN_KIND_CLEARANCE selects from the 5-tier clearance ladder.
TOKEN_KIND_ROLE4TOKEN_KIND_ROLE selects from RBAC role names.
TOKEN_KIND_CHANNEL5TOKEN_KIND_CHANNEL selects from outbound communication channels.
TOKEN_KIND_DATACLASS6TOKEN_KIND_DATACLASS selects from the data classification registry.
TOKEN_KIND_SCOPE7TOKEN_KIND_SCOPE selects from agent / team scope phrases.
TOKEN_KIND_AUTONOMY8TOKEN_KIND_AUTONOMY selects from autonomy levels (Supervised etc.).
TOKEN_KIND_TIME9TOKEN_KIND_TIME stores a free-text time-of-day phrase ("8pm").
TOKEN_KIND_TOOL10TOKEN_KIND_TOOL stores a free-text tool identifier ("GitHub · merge").
TOKEN_KIND_BRANCH11TOKEN_KIND_BRANCH selects a source-control branch name.

GuardrailService

GuardrailService exposes the founder-facing guardrail authoring surface.

Method NameRequest TypeResponse TypeDescription
CreateGuardrailCreateGuardrailRequestCreateGuardrailResponseCreateGuardrail persists a new Guardrail and returns it with the assigned GR-NN id. Sentence tokens are validated against TokenKind.
GetGuardrailGetGuardrailRequestGetGuardrailResponseGetGuardrail returns a single Guardrail by id (e.g. "GR-12").
UpdateGuardrailUpdateGuardrailRequestUpdateGuardrailResponseUpdateGuardrail mutates a stored Guardrail. The sentence may be edited in-place; simulation cache invalidates when the sentence_hash changes.
DeleteGuardrailDeleteGuardrailRequestDeleteGuardrailResponseDeleteGuardrail soft-deletes a Guardrail. Listing skips deleted rows.
ListGuardrailsListGuardrailsRequestListGuardrailsResponseListGuardrails returns all Guardrails in the caller's tenant. Paginated.
ListTokenValuesListTokenValuesRequestListTokenValuesResponseListTokenValues returns the candidate values for a token kind. The result powers the dropdowns on the inline-edit UI (guardrails-new.jsx TOKEN_OPTS). v1 returns static values for select-typed kinds and an empty list (= caller free-text input) for number / text kinds.
SimulateAgainstHistorySimulateAgainstHistoryRequestSimulateAgainstHistoryResponseSimulateAgainstHistory replays recent audit events through the policy engine using the (optionally edited) guardrail sentence and reports how many events would have changed outcome.
GetUsageStatsGetUsageStatsRequestGetUsageStatsResponseGetUsageStats aggregates triggered / blocked / allowed counts from the audit log for a guardrail over a window (capped at 30 days).
ListTemplatesListTemplatesRequestListTemplatesResponseListTemplates returns the 6 hardcoded New-Guardrail templates that seed step 1 of the New Guardrail modal (guardrails-new.jsx TEMPLATES).

Scalar Value Types

.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)