Skip to main content

ML Detector API

Table of Contents

Top

upsquad/ml/v1/detector.proto

ClassifyRequest

ClassifyRequest carries the text to score plus attribution metadata used only for metric labels and structured logs.

FieldTypeLabelDescription
textstringtext is the user message to classify. Caller MUST enforce a 32KB soft ceiling; the service rejects >64KB with INVALID_ARGUMENT and logs 32–64KB as oversized-but-truncated.
tenant_idstringtenant_id is the calling organization UUID. Used for metric labels only; the sidecar does not authorise per-tenant access.
session_idstringsession_id is the agent session UUID. Used for log correlation.
agent_idstringagent_id is the invoking agent UUID. Used for metric labels.
model_hintstringmodel_hint selects the classifier model. Wave 5 accepts exactly "prompt-guard-86m"; any other value returns INVALID_ARGUMENT.

ClassifyResponse

ClassifyResponse carries the classifier verdict plus raw scores so the orchestrator can emit shadow-phase metrics without re-thresholding.

FieldTypeLabelDescription
jailbreak_scorefloatjailbreak_score is the Prompt-Guard JAILBREAK class probability, range [0.0, 1.0].
indirect_injection_scorefloatindirect_injection_score is the Prompt-Guard INJECTION class probability, range [0.0, 1.0]. Reserved for Wave 5.1 tuning.
verdictstringverdict is one of "allow", "warn", "block" — computed server-side from the tenant-provided thresholds passed in ClassifyRequest.
latency_msint32latency_ms is the sidecar-side wall-clock inference time in ms.
model_versionstringmodel_version identifies the classifier build for audit rows, e.g. "prompt-guard-86m@v1".
classified_atgoogle.protobuf.Timestampclassified_at is when the sidecar finished inference.

ModerateRequest

ModerateRequest is the LLD 23 placeholder. Wave 5 LLD 22 returns UNIMPLEMENTED from the server; shape may evolve in LLD 23 without a breaking change by extending reserved field numbers.

FieldTypeLabelDescription
textstringtext is the content to moderate.
tenant_idstringtenant_id is the calling organization UUID.
session_idstringsession_id is the agent session UUID.
agent_idstringagent_id is the invoking agent UUID.

ModerateResponse

ModerateResponse is the LLD 23 placeholder. Wave 5 LLD 22 returns UNIMPLEMENTED; LLD 23 defines the fields.

MLDetectorService

MLDetectorService hosts the Wave 5 ML inference RPCs. Runs in the ml-detector sidecar Deployment (namespace: platform). All RPCs are UNARY. The Go bridge in internal/runtime/security/mlclassifier calls Classify; LLD 23 fills the Moderate stub.

Method NameRequest TypeResponse TypeDescription
ClassifyClassifyRequestClassifyResponseClassify scores a single user message for prompt-injection / jailbreak risk using Prompt-Guard-86M. Latency budget: P95 <75ms including one RTT from the orchestrator. The service must fail fast on any input larger than 64KB with INVALID_ARGUMENT.
ModerateModerateRequestModerateResponseModerate scores a text buffer for policy-category violations. LLD 22 returns UNIMPLEMENTED; LLD 23 fills the body. Request and response shapes are minimal here to let LLD 23 land without a second proto.

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)