Documentation
¶
Overview ¶
Package core implements the shared Agent Health Specification model.
Index ¶
- Constants
- func NewHTTPClient() *http.Client
- func SupportedMCPVersion(v string) bool
- func SupportedModelAPI(api string) bool
- func ValidVectorStore(t Target) bool
- func ValidateResult(r Result) error
- func WriteGitHub(w io.Writer, results []Result) error
- func WriteHuman(w io.Writer, results []Result) error
- func WriteJSON(w io.Writer, results []Result) error
- func WriteJUnit(w io.Writer, results []Result) error
- func WriteYAML(w io.Writer, results []Result) error
- type A2AInteraction
- type A2AOptions
- type AHPOptions
- type AHPServer
- type Adapter
- type AgentOptions
- type AgentTask
- type AuthReference
- type CheckResult
- type Config
- type DatabaseOptions
- type Dependency
- type Engine
- type Failure
- type HTTPOptions
- type MCPInvocation
- type MCPOAuth
- type MCPOptions
- type MCPStdio
- type Metadata
- type ModelInference
- type ModelOptions
- type Observation
- type Redactor
- type Registry
- type Request
- type Result
- type Status
- type Target
- type TargetCloser
- type TargetIdentity
- type Thresholds
- type VectorQuery
- type VectorStoreOptions
Constants ¶
const DefaultRetryDelay = 100 * time.Millisecond
const DefaultTimeout = 5 * time.Second
Variables ¶
This section is empty.
Functions ¶
func NewHTTPClient ¶
NewHTTPClient creates an isolated TLS-verifying transport. Redirects are not followed, preventing probes or credentials from moving to another endpoint.
func SupportedMCPVersion ¶ added in v0.2.0
func SupportedModelAPI ¶ added in v0.15.0
SupportedModelAPI reports whether api names an implemented inference dialect.
func ValidVectorStore ¶ added in v0.17.0
ValidVectorStore validates endpoint and vector options for both config and adapter callers.
func ValidateResult ¶
ValidateResult verifies the wire shape before emitting it. Adapters remain responsible for redacting messages before handing them to the output layer.
func WriteGitHub ¶ added in v0.19.0
WriteGitHub emits safe GitHub workflow annotations. Names and diagnostic text are omitted because they can contain secrets or workflow command syntax.
func WriteHuman ¶
WriteHuman presents the same result tree without terminal control characters.
func WriteJUnit ¶ added in v0.19.0
WriteJUnit emits one case per target/dependency occurrence. Every non-HEALTHY status fails the case; no inconclusive health result is treated as skipped.
Types ¶
type A2AInteraction ¶ added in v0.3.0
type A2AOptions ¶ added in v0.3.0
type A2AOptions struct {
CardURL string `yaml:"card_url"`
ProtocolVersion string `yaml:"protocol_version"`
RequiredSkills []string `yaml:"required_skills"`
RequiredCapabilities []string `yaml:"required_capabilities"`
Functional *A2AInteraction `yaml:"functional"`
}
A2AOptions describes passive expectations and an explicitly safe interaction.
type AHPOptions ¶ added in v0.9.0
AHPOptions controls the experimental v1 HTTP binding. Token grants access to topology and evidence; it must be resolved by the caller from a secret reference.
type AHPServer ¶ added in v0.9.0
type AHPServer struct {
// contains filtered or unexported fields
}
AHPServer runs checks independently of requests and serves immutable snapshots. Construct one server per configuration; Run must remain active while serving.
func NewAHPServer ¶ added in v0.9.0
func NewAHPServer(engine *Engine, config Config, options AHPOptions) (*AHPServer, error)
type Adapter ¶
type Adapter interface {
Metadata() Metadata
Check(context.Context, Request, string) (Observation, error)
}
Adapter implementations must honor context cancellation and use the supplied HTTP client for HTTP requests. The engine trusts compiled-in adapter code; arbitrary code cannot be sandboxed or forcibly stopped in-process.
type AgentOptions ¶ added in v0.5.0
type AgentOptions struct {
RequiredCapabilities []string `yaml:"required_capabilities"`
Functional *AgentTask `yaml:"functional"`
}
AgentOptions configures the bounded agent health interface.
type AuthReference ¶
type AuthReference struct {
BearerEnv string `yaml:"bearer_env"`
}
AuthReference resolves a credential from the environment; never a literal secret.
type CheckResult ¶
type CheckResult struct {
Code string `json:"code,omitempty"`
Status Status `json:"status"`
Message string `json:"message,omitempty"`
Steps map[string]Status `json:"steps,omitempty"`
}
func NormalizeError ¶
func NormalizeError(err error, responseReceived bool) CheckResult
NormalizeError never incorporates raw errors (which may contain credentials).
type Config ¶
type Config struct {
Concurrency int `yaml:"concurrency"`
Version string `yaml:"version"`
Targets []Target `yaml:"targets"`
}
func LoadConfig ¶
LoadConfig accepts exactly one YAML document and rejects unknown fields. Parser details are deliberately suppressed because they may contain secrets.
func LoadConfigFile ¶
type DatabaseOptions ¶ added in v0.16.0
type DatabaseOptions struct {
Username string `yaml:"username"`
PasswordEnv string `yaml:"password_env"`
TLS string `yaml:"tls"`
}
DatabaseOptions permits fixed read-only probes, never caller-supplied queries.
type Dependency ¶
type Dependency struct {
Target `yaml:",inline"`
Ref string `yaml:"ref"`
Relationship string `yaml:"relationship"`
Critical *bool `yaml:"critical"`
}
func (Dependency) IsCritical ¶
func (d Dependency) IsCritical() bool
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine executes targets in declaration order with a bounded adapter-call pool. Construct it with NewEngine; share it across concurrent runs if needed.
type Failure ¶
type Failure struct{ Status Status }
Failure carries a normalized health classification, never a raw diagnostic.
type HTTPOptions ¶
type HTTPOptions struct {
Method string `yaml:"method"`
ExpectedStatus []int `yaml:"expected_status"`
Headers map[string]string `yaml:"headers"`
BodyContains string `yaml:"body_contains"`
MaxBodyBytes *int `yaml:"max_body_bytes"`
}
HTTPOptions specifies passive method and response expectations, never credentials.
type MCPInvocation ¶ added in v0.2.0
type MCPOAuth ¶ added in v0.2.0
type MCPOAuth struct {
Issuer string `yaml:"issuer"`
ClientID string `yaml:"client_id"`
Grant string `yaml:"grant"`
ClientSecretEnv string `yaml:"client_secret_env"`
RefreshTokenEnv string `yaml:"refresh_token_env"`
TokenFile string `yaml:"token_file"`
Scopes []string `yaml:"scopes"`
RedirectPort *int `yaml:"redirect_port"`
}
MCPOAuth uses a pinned issuer and environment/file references, never secrets.
type MCPOptions ¶ added in v0.2.0
type MCPOptions struct {
Transport string `yaml:"transport"`
Stdio *MCPStdio `yaml:"stdio"`
OAuth *MCPOAuth `yaml:"oauth"`
ProtocolVersion string `yaml:"protocol_version"`
RequiredTools []string `yaml:"required_tools"`
RequiredResources []string `yaml:"required_resources"`
RequiredPrompts []string `yaml:"required_prompts"`
Functional *MCPInvocation `yaml:"functional"`
}
MCPOptions configures Streamable HTTP discovery and an explicitly safe probe.
type Metadata ¶
type Metadata struct {
Name, Version, CompatibilityVersion string
TargetTypes, Dimensions, ActiveChecks []string
}
Metadata declares compatibility, implemented dimensions, and active checks. All active checks must remain non-destructive, even when opted in.
type ModelInference ¶ added in v0.15.0
type ModelOptions ¶ added in v0.15.0
type ModelOptions struct {
API string `yaml:"api"`
RequiredModels []string `yaml:"required_models"`
Functional *ModelInference `yaml:"functional"`
}
ModelOptions selects the inference API dialect, passive model expectations, and an explicitly safe, token-bounded minimal inference.
type Observation ¶
type Observation struct {
Check CheckResult
ResponseReceived bool
// Code selects an engine-owned diagnostic; arbitrary adapter text is suppressed.
Code string
}
Observation records whether a response was received, distinguishing partial responses before a timeout from failures to establish communication.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor masks resolved credentials, URL addresses (including userinfo and query strings), and recognizable authentication assignments.
func NewRedactor ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry supports concurrent lookup and registration; duplicate types fail atomically rather than silently replacing an adapter.
func NewRegistry ¶
func NewRegistry() *Registry
type Request ¶
type Request struct {
// TargetContext bounds resources shared across dimensions; Check must still honor its attempt context.
TargetContext context.Context
// MarkResponse must be called as soon as any response arrives, before reading its body.
MarkResponse func()
// RecordStep records only allowlisted transport stages and health states.
RecordStep func(string, Status)
// Environment is a per-target snapshot of configured environment references.
Environment map[string]string
// RunState belongs to one target execution; adapters may cache acquired credentials.
RunState *sync.Map
// RememberSecret registers dynamically acquired credentials for output redaction.
RememberSecret func(string)
Target Target
Credential string
Client *http.Client
}
Request contains per-target state. Credentials must never be logged. Client verifies TLS, restricts redirects, and follows the check context.
type Result ¶
type Result struct {
Relationship string `json:"relationship,omitempty"`
Critical *bool `json:"critical,omitempty"`
Target TargetIdentity `json:"target"`
Status Status `json:"status"`
LatencyMS *float64 `json:"latency_ms"`
Checks map[string]CheckResult `json:"checks"`
Dependencies []Result `json:"dependencies"`
}
type Status ¶
type Status string
Status is ordered by the specification's severity, not by reachability.
func Aggregate ¶
func Aggregate(checks map[string]CheckResult, dependencies []Result, critical []bool) Status
Aggregate excludes the dependency diagnostic from own health; dependencies contribute independently even when the diagnostic was not requested.
func DependencyContribution ¶
DependencyContribution maps dependency health onto the parent's ability to work.
type Target ¶
type Target struct {
VectorStore *VectorStoreOptions `yaml:"vector_store"`
Database *DatabaseOptions `yaml:"database"`
Agent *AgentOptions `yaml:"agent"`
ID string `yaml:"id"`
BudgetMS *int `yaml:"budget_ms"`
Name string `yaml:"name"`
Type string `yaml:"type"`
Endpoint string `yaml:"endpoint"`
Checks []string `yaml:"checks"`
Thresholds *Thresholds `yaml:"thresholds"`
Dependencies []Dependency `yaml:"dependencies"`
TimeoutMS *int `yaml:"timeout_ms"`
Retries *int `yaml:"retries"`
RetryDelayMS *int `yaml:"retry_delay_ms"`
CheckTimeouts map[string]int `yaml:"check_timeouts_ms"`
Auth *AuthReference `yaml:"auth"`
HTTP *HTTPOptions `yaml:"http"`
MCP *MCPOptions `yaml:"mcp"`
A2A *A2AOptions `yaml:"a2a"`
Model *ModelOptions `yaml:"model"`
}
func (Target) CredentialReferences ¶ added in v0.2.0
CredentialReferences lists only references used by this target.
type TargetCloser ¶ added in v0.4.0
TargetCloser optionally releases per-target resources after all dimensions. It must honor the bounded cleanup context and is not called concurrently with another CloseTarget.
type TargetIdentity ¶
type Thresholds ¶
type Thresholds struct {
LatencyMS *float64 `yaml:"latency_ms"`
}
type VectorQuery ¶ added in v0.17.0
type VectorStoreOptions ¶ added in v0.17.0
type VectorStoreOptions struct {
Provider string `yaml:"provider"`
Collection string `yaml:"collection"`
Namespace string `yaml:"namespace"`
Functional *VectorQuery `yaml:"functional"`
}
VectorStoreOptions selects read-only metadata and an optional bounded query.