Skip to content

fathom

import "github.com/KrakenNet/fathom-go"

Package fathom provides a Go client for the Fathom policy engine REST API.

Index

type AssertFactRequest

AssertFactRequest is the payload for POST /v1/facts.

type AssertFactRequest struct {
    SessionID string         `json:"session_id"`
    Template  string         `json:"template"`
    Data      map[string]any `json:"data"`
}

type AssertFactResponse

AssertFactResponse is the response from POST /v1/facts.

type AssertFactResponse struct {
    Success bool `json:"success"`
}

type Client

Client communicates with the Fathom REST API.

type Client struct {
    // contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string, opts ...ClientOption) *Client

NewClient creates a new Fathom client pointing at the given base URL. Example:

client := NewClient("http://localhost:8000", WithBearerToken("secret"))

func (*Client) AssertFact

func (c *Client) AssertFact(ctx context.Context, req *AssertFactRequest) (*AssertFactResponse, error)

AssertFact asserts a single fact into the session's working memory.

func (*Client) Evaluate

func (c *Client) Evaluate(ctx context.Context, req *EvaluateRequest) (*EvaluateResponse, error)

Evaluate sends facts to the engine and returns the policy decision.

func (*Client) Query

func (c *Client) Query(ctx context.Context, req *QueryRequest) (*QueryResponse, error)

Query retrieves facts from the session's working memory.

func (*Client) Retract

func (c *Client) Retract(ctx context.Context, req *RetractRequest) (*RetractResponse, error)

Retract removes facts matching the request's template + optional filter from the session's working memory and returns the number of retractions.

type ClientOption

ClientOption mutates a Client during construction.

type ClientOption func(*Client)

func WithBearerToken

func WithBearerToken(tok string) ClientOption

WithBearerToken configures the client to send "Authorization: Bearer \<tok>" on every request.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) ClientOption

WithHTTPClient overrides the underlying *http.Client (useful for tests or custom transports).

type EvaluateRequest

EvaluateRequest is the payload for POST /v1/evaluate.

type EvaluateRequest struct {
    Facts     []FactInput `json:"facts"`
    Ruleset   string      `json:"ruleset"`
    SessionID string      `json:"session_id,omitempty"`
}

type EvaluateResponse

EvaluateResponse is the response from POST /v1/evaluate.

type EvaluateResponse struct {
    Decision         string   `json:"decision"`
    Reason           string   `json:"reason"`
    RuleTrace        []string `json:"rule_trace"`
    ModuleTrace      []string `json:"module_trace"`
    DurationUS       int64    `json:"duration_us"`
    AttestationToken string   `json:"attestation_token,omitempty"`
}

type FactInput

FactInput is a single fact assertion used inside EvaluateRequest.

type FactInput struct {
    Template string         `json:"template"`
    Data     map[string]any `json:"data"`
}

type QueryRequest

QueryRequest is the payload for POST /v1/query.

type QueryRequest struct {
    SessionID string         `json:"session_id"`
    Template  string         `json:"template"`
    Filter    map[string]any `json:"filter,omitempty"`
}

type QueryResponse

QueryResponse is the response from POST /v1/query.

type QueryResponse struct {
    Facts []map[string]any `json:"facts"`
}

type RetractRequest

RetractRequest is the payload for DELETE /v1/facts.

type RetractRequest struct {
    SessionID string         `json:"session_id"`
    Template  string         `json:"template"`
    Filter    map[string]any `json:"filter,omitempty"`
}

type RetractResponse

RetractResponse is the response from DELETE /v1/facts.

type RetractResponse struct {
    RetractedCount int `json:"retracted_count"`
}

Generated by gomarkdoc