Documentation
¶
Index ¶
- func Enforce[Input, Output any](ctx context.Context, client *Client, operation Operation, input Input, ...) (Output, *Decision, *Decision, error)
- func Observe[Input, Output any](ctx context.Context, client *Client, operation Operation, input Input, ...) (Output, <-chan Observation, error)
- func OpenAIDecisionsConfigSHA256(question DecisionsQuestion) (string, error)
- func ParseExecutorPrivateKeyPEM(data []byte) (ed25519.PrivateKey, error)
- type ApprovalContinuation
- type ApprovalRequired
- type Call
- type Client
- type Config
- type CustomerAPIConfig
- type CustomerRead
- type CustomerReadResult
- type CustomerSource
- type Decision
- func RecoverApprovalFrom[Input, Output any](ctx context.Context, client *Client, continuation ApprovalContinuation, ...) (Output, *Decision, error)
- func ResumeApproval[Input, Output any](ctx context.Context, pending *ApprovalRequired, ...) (Output, *Decision, error)
- func ResumeApprovalFrom[Input, Output any](ctx context.Context, client *Client, continuation ApprovalContinuation, ...) (Output, *Decision, error)
- type DecisionsQuestion
- type Discovery
- type DiscoveryConfig
- type EnforceBlockedError
- type ExecutionContext
- type ExtractionProvenance
- type ExtractionResult
- type ExtractionSource
- type Extractor
- type FactResolution
- func ExtractContextFact(ctx context.Context, source ExtractionSource, lookupKey string, ...) (FactResolution, error)
- func LookupCustomerFact(ctx context.Context, source CustomerSource, lookupKey string, ...) (FactResolution, error)
- func LookupQuickBooksInvoiceBalance(ctx context.Context, source QuickBooksInvoiceSource, invoiceID string) (FactResolution, error)
- func LookupStripeInvoiceStatus(ctx context.Context, source StripeInvoiceSource, invoiceID string) (FactResolution, error)
- type FactSummary
- type GuardEvidence
- type GuardHandler
- type GuardObligationStatus
- type GuardRequirement
- type GuardTarget
- type Observation
- type ObservedExecutionOutcome
- type ObservedExecutionRecording
- type OpenAIDecisionsConfig
- type Operation
- type OutcomeUnknownError
- type QuickBooksInvoiceSource
- type Recovery
- type ReviewField
- type ReviewSummary
- type StripeInvoiceSource
- type TrajectorySnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enforce ¶
func Enforce[Input, Output any](ctx context.Context, client *Client, operation Operation, input Input, execute func(context.Context, Input, ExecutionContext) (Output, error)) (Output, *Decision, *Decision, error)
Enforce checks the call before invoking the protected function, retains a signed start receipt, and checks the result before returning it to the agent.
func Observe ¶
func Observe[Input, Output any](ctx context.Context, client *Client, operation Operation, input Input, execute func(context.Context) (Output, error)) (Output, <-chan Observation, error)
Observe wraps a function while preserving its Go result and error. The buffered channel reports advisory checks after the function returns.
func OpenAIDecisionsConfigSHA256 ¶
func OpenAIDecisionsConfigSHA256(question DecisionsQuestion) (string, error)
OpenAIDecisionsConfigSHA256 pins the reviewed question, model, and uncertainty threshold.
func ParseExecutorPrivateKeyPEM ¶
func ParseExecutorPrivateKeyPEM(data []byte) (ed25519.PrivateKey, error)
ParseExecutorPrivateKeyPEM reads a PKCS#8 Ed25519 key held by the protected application.
Types ¶
type ApprovalContinuation ¶
ApprovalContinuation retains an exact pending call and its retained decision. Encrypt and scope it to the authenticated customer and operation in application storage. It contains private arguments and must never be accepted from an agent.
type ApprovalRequired ¶
type ApprovalRequired struct {
Decision *Decision
// contains filtered or unexported fields
}
ApprovalRequired retains the original checked call in memory. Persist its Continuation in protected application storage before crossing a restart.
func (*ApprovalRequired) Continuation ¶
func (e *ApprovalRequired) Continuation() (ApprovalContinuation, error)
Continuation returns an independent snapshot for application-owned persistence. Store it before claiming a permit so a lost response can use RecoverApprovalFrom.
func (*ApprovalRequired) Error ¶
func (e *ApprovalRequired) Error() string
type Call ¶
type Call struct {
RequestID string
OperationVersionID string
ActionKey string
PrincipalID string
SessionID string
ResourceID string
PrincipalSource string
ResourceSource string
Arguments json.RawMessage
FactResolutions []FactResolution
Trajectory *TrajectorySnapshot
ReviewSummary *ReviewSummary
Traceparent string
GuardEvidence []GuardEvidence
// contains filtered or unexported fields
}
Call carries one authenticated application assertion for an exact action phase.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks only to a sidecar on the same host. It has no deployment credential.
func NewClient ¶
NewClient accepts only loopback HTTP and caps check latency so local decisions cannot redirect or indefinitely delay the protected application.
func (*Client) Reconcile ¶
func (c *Client) Reconcile(ctx context.Context, recovery Recovery, providerReference, outcome string) (string, error)
Reconcile reports only the outcome established by the protected executor's provider lookup using the original idempotency key.
func (*Client) ReportObservedExecution ¶
func (c *Client) ReportObservedExecution(ctx context.Context, call Call, outcome ObservedExecutionOutcome) (ObservedExecutionRecording, error)
ReportObservedExecution uses the original prepared call and exact signed input. Calling it is separate from running the tool; its failure must not retry the effect.
type Config ¶
type Config struct {
SidecarURL string
AdapterToken string
HTTPClient *http.Client
OrganisationID string
DeploymentID string
ExecutorPrivateKey ed25519.PrivateKey
// GuardHandlers run only during Enforce, at exact reviewed string targets.
GuardHandlers []GuardHandler
}
Config binds one protected application to its local sidecar and signing key. The sidecar, not this client, holds the AuthRail deployment credential.
type CustomerAPIConfig ¶
type CustomerRead ¶
type CustomerRead func(context.Context, string) (CustomerReadResult, error)
func NewCustomerAPIReader ¶
func NewCustomerAPIReader(config CustomerAPIConfig) (CustomerRead, error)
NewCustomerAPIReader creates a fixed HTTPS read-only lookup and rejects redirects so a provider credential cannot follow an unreviewed endpoint.
type CustomerReadResult ¶
type CustomerSource ¶
type Decision ¶
type Decision struct {
RequestID string `json:"requestId"`
Mode string `json:"mode"`
Enforced bool `json:"enforced"`
Coverage string `json:"coverage"`
Outcome string `json:"outcome"`
Sequence int64 `json:"sequence"`
BundleID *string `json:"bundleId"`
RailVersionIDs []string `json:"railVersionIds"`
MatchedRuleIDs []string `json:"matchedRuleIds"`
ReasonCodes []string `json:"reasonCodes"`
Facts []FactSummary `json:"facts,omitempty"`
Obligations []GuardObligationStatus `json:"obligations,omitempty"`
RecordingStatus string `json:"recordingStatus"`
ActionID string `json:"actionId"`
CertificateID string `json:"certificateId"`
ApprovalRequestID string `json:"approvalRequestId"`
ReportReplayed *bool `json:"reportReplayed"`
Unresolved []struct {
Root string `json:"root"`
Path []string `json:"path"`
Reason string `json:"reason"`
} `json:"unresolved"`
}
Decision is advisory in Observe mode; RecordingStatus does not prove execution.
func RecoverApprovalFrom ¶
func RecoverApprovalFrom[Input, Output any](ctx context.Context, client *Client, continuation ApprovalContinuation, execute func(context.Context, Input, ExecutionContext) (Output, error)) (Output, *Decision, error)
RecoverApprovalFrom reads only the exact existing unexpired, unstarted permit. It never issues a replacement permit or retries an uncertain business effect.
func ResumeApproval ¶
func ResumeApproval[Input, Output any](ctx context.Context, pending *ApprovalRequired, execute func(context.Context, Input, ExecutionContext) (Output, error)) (Output, *Decision, error)
ResumeApproval consumes one pending call and claims its one-use permit. The caller must supply the same protected operation; no callback runs if the permit claim is uncertain, expired, or rejected.
func ResumeApprovalFrom ¶
func ResumeApprovalFrom[Input, Output any](ctx context.Context, client *Client, continuation ApprovalContinuation, execute func(context.Context, Input, ExecutionContext) (Output, error)) (Output, *Decision, error)
ResumeApprovalFrom claims the original approved call after a request or process boundary. An uncertain claim requires RecoverApprovalFrom, never a blind retry.
type DecisionsQuestion ¶
type Discovery ¶
type Discovery struct {
InventoryItemID string `json:"inventoryItemId"`
InventoryRevisionID string `json:"inventoryRevisionId"`
DeploymentID string `json:"deploymentId"`
ConfirmationStatus string `json:"confirmationStatus"`
}
Discovery identifies the unconfirmed or confirmed Inventory item and its Observe deployment.
type DiscoveryConfig ¶
type DiscoveryConfig struct {
ControlPlaneURL string
SetupKey string
AgentKey string
HTTPClient *http.Client
}
DiscoveryConfig holds a short-lived setup key, separate from sidecar and deployment credentials.
type EnforceBlockedError ¶
type EnforceBlockedError struct {
Phase string
EffectMayHaveOccurred bool
Decision *Decision
Cause error
}
EnforceBlockedError means the protected function was not called for a call block. A result block may follow a completed external effect.
func (*EnforceBlockedError) Error ¶
func (e *EnforceBlockedError) Error() string
func (*EnforceBlockedError) Unwrap ¶
func (e *EnforceBlockedError) Unwrap() error
type ExecutionContext ¶
type ExecutionContext = Recovery
ExecutionContext must be persisted with the provider request for recovery.
type ExtractionProvenance ¶
type ExtractionProvenance struct {
SourceSHA256 string `json:"sourceSha256"`
SourceBytes int `json:"sourceBytes"`
SourceLocation string `json:"sourceLocation"`
ModelID string `json:"modelId"`
ModelConfigSHA256 string `json:"modelConfigSha256"`
PromptVersion string `json:"promptVersion"`
ExtractedAt string `json:"extractedAt"`
}
type ExtractionResult ¶
type ExtractionSource ¶
type Extractor ¶
type Extractor func(context.Context, []byte) (ExtractionResult, error)
func NewOpenAIDecisionsExtractor ¶
func NewOpenAIDecisionsExtractor(config OpenAIDecisionsConfig) (Extractor, error)
NewOpenAIDecisionsExtractor sends the selected document bytes to OpenAI. The caller must authorise and minimise that disclosure before invoking it; this client does not redact protected content. The model supplies a typed fact, never authorization, and ExtractContextFact validates its provenance.
type FactResolution ¶
type FactResolution struct {
SourceVersionID string `json:"sourceVersionId"`
ProviderAccountID string `json:"providerAccountId,omitempty"`
SourceIdentity string `json:"sourceIdentity,omitempty"`
AccountBoundary string `json:"accountBoundary,omitempty"`
Lookup string `json:"lookup"`
LookupKey string `json:"lookupKey"`
AuthenticatedExecutor bool `json:"authenticatedExecutor"`
Status string `json:"status"`
ObservedAt string `json:"observedAt,omitempty"`
Value map[string]any `json:"value,omitempty"`
Extraction *ExtractionProvenance `json:"extraction,omitempty"`
}
FactResolution is a signed source observation for Data Rails, never permission to execute the business action.
func ExtractContextFact ¶
func ExtractContextFact(ctx context.Context, source ExtractionSource, lookupKey string, sourceLocation string, observedAt time.Time, document []byte, extractor Extractor) (FactResolution, error)
ExtractContextFact validates one bounded AI-assisted value against the reviewed source and records uncertainty; the model never decides access.
func LookupCustomerFact ¶
func LookupCustomerFact(ctx context.Context, source CustomerSource, lookupKey string, read CustomerRead) (FactResolution, error)
LookupCustomerFact accepts only a matching protected source and account; callers must keep lookup credentials outside the agent.
func LookupQuickBooksInvoiceBalance ¶
func LookupQuickBooksInvoiceBalance(ctx context.Context, source QuickBooksInvoiceSource, invoiceID string) (FactResolution, error)
LookupQuickBooksInvoiceBalance reads one invoice in the reviewed realm. The protected application owns the OAuth token; a failed read never supplies a value.
func LookupStripeInvoiceStatus ¶
func LookupStripeInvoiceStatus(ctx context.Context, source StripeInvoiceSource, invoiceID string) (FactResolution, error)
LookupStripeInvoiceStatus checks the reviewed account before reading one invoice; provider failures return unavailable context, not a guessed value.
type FactSummary ¶
type FactSummary struct {
SourceVersionID string `json:"sourceVersionId"`
FactKey string `json:"factKey"`
ProviderAccountID string `json:"providerAccountId,omitempty"`
SourceIdentity string `json:"sourceIdentity,omitempty"`
AccountBoundary string `json:"accountBoundary,omitempty"`
Lookup string `json:"lookup"`
LookupKeySHA256 string `json:"lookupKeySha256,omitempty"`
Status string `json:"status"`
Uncertainty string `json:"uncertainty,omitempty"`
ObservedAt string `json:"observedAt,omitempty"`
AgeSeconds float64 `json:"ageSeconds,omitempty"`
}
type GuardEvidence ¶
type GuardEvidence struct {
Phase string `json:"phase"`
BundleID string `json:"bundleId"`
Kind string `json:"kind"`
HandlerID string `json:"handlerId"`
HandlerVersion string `json:"handlerVersion"`
Target GuardTarget `json:"target"`
InputSHA256 string `json:"inputSha256"`
OutputSHA256 string `json:"outputSha256"`
}
GuardEvidence binds the executor's processing assertion to the exact bundle and before/after values. It is not business permission or handler-code proof.
func (GuardEvidence) MarshalJSON ¶
func (e GuardEvidence) MarshalJSON() ([]byte, error)
MarshalJSON preserves canonical sorted keys inside signed evidence arrays.
type GuardHandler ¶
type GuardHandler struct {
ID string
Version string
Kind string
Process func(context.Context, string) (string, error)
}
GuardHandler is application-owned processing for one exact reviewed handler version. Process receives only its target string and must honour cancellation. Registering a handler does not establish independent code or isolation proof.
type GuardObligationStatus ¶
type GuardObligationStatus struct {
GuardRequirement
Status string `json:"status"`
InputSHA256 string `json:"inputSha256,omitempty"`
OutputSHA256 string `json:"outputSha256,omitempty"`
}
GuardObligationStatus reports whether a requirement was fulfilled by the executor evidence; this assertion does not independently verify handler code.
type GuardRequirement ¶
type GuardRequirement struct {
RailVersionID string `json:"railVersionId"`
RuleID string `json:"ruleId"`
Kind string `json:"kind"`
HandlerID string `json:"handlerId"`
HandlerVersion string `json:"handlerVersion"`
Target GuardTarget `json:"target"`
}
GuardRequirement names one exact published rule and its required processing.
type GuardTarget ¶
GuardTarget identifies one reviewed string field in the call or result.
type Observation ¶
type Observation struct {
// Call is the original frozen attempt used to bind optional execution outcome evidence.
Call *Call
CallDecision *Decision
ResultDecision *Decision
CallError error
ResultError error
}
Observation reports both decision checks. Errors are coverage gaps, not tool errors. Observation keeps call and result checks separate from the tool's own error.
type ObservedExecutionOutcome ¶
type ObservedExecutionOutcome struct {
Event string
ProviderIdempotencyKey string
ProviderReference *string
}
ObservedExecutionOutcome records executor knowledge without authorizing an advisory attempt. Use unknown when an error cannot establish whether the effect happened.
type ObservedExecutionRecording ¶
type ObservedExecutionRecording struct {
RecordingStatus string `json:"recordingStatus"`
ReceiptID string `json:"receiptId,omitempty"`
ActionID string `json:"actionId,omitempty"`
State string `json:"state,omitempty"`
Replayed bool `json:"replayed,omitempty"`
}
ObservedExecutionRecording distinguishes local durable delivery from central retention.
type OpenAIDecisionsConfig ¶
type OpenAIDecisionsConfig struct {
Source ExtractionSource
Question DecisionsQuestion
APIKey string
Client *http.Client
}
type Operation ¶
type Operation struct {
VersionID string
ActionKey string
PrincipalID string
SessionID string
ResourceID string
PrincipalSource string
ResourceSource string
FactResolutions []FactResolution
Trajectory *TrajectorySnapshot
ReviewSummary *ReviewSummary
Traceparent string
}
Operation identifies the reviewed action and a stable key from the workflow.
type OutcomeUnknownError ¶
OutcomeUnknownError never authorizes a retry of the business effect.
func (*OutcomeUnknownError) Error ¶
func (e *OutcomeUnknownError) Error() string
func (*OutcomeUnknownError) Unwrap ¶
func (e *OutcomeUnknownError) Unwrap() error
type QuickBooksInvoiceSource ¶
type Recovery ¶
type Recovery struct {
ActionID string
AttemptID string
PermitID *string
InputSHA256 string
ProviderIdempotencyKey string
Traceparent string
}
Recovery identifies an attempt whose provider outcome must be checked by the protected application before it can send a reconciliation receipt.
type ReviewField ¶
type ReviewSummary ¶
type ReviewSummary struct {
Title string `json:"title"`
Fields []ReviewField `json:"fields"`
}
ReviewSummary is bounded, safe context shown to named approval reviewers.
type StripeInvoiceSource ¶
type TrajectorySnapshot ¶
type TrajectorySnapshot struct {
SessionID string `json:"sessionId"`
Start bool `json:"start,omitempty"`
Complete bool `json:"complete"`
PriorReadOperationVersionIDs []string `json:"priorReadOperationVersionIds"`
Values map[string]any `json:"values,omitempty"`
}
TrajectorySnapshot asserts bounded prior reads from the authenticated task; the sidecar still checks them against its restart-safe ledger.