Documentation
¶
Overview ¶
Package setupcheck evaluates local runtime readiness (defaults, backends) for the CLI.
Index ¶
- Constants
- func ProbeLocalOllamaAPI(ctx context.Context) (baseURL string, ok bool)
- func ResolveMaxOutputTokens(states []runtimestate.BackendRuntimeState, provider, model string) int
- func StatesFromMap(m map[string]runtimestate.BackendRuntimeState) []runtimestate.BackendRuntimeState
- type BackendCheck
- type Input
- type Issue
- type Result
- func AddStalePolicyPresetIssue(r Result, stale []StalePolicyPreset, refreshCommand string) Result
- func AddTrustedBinaryIssue(r Result, drift []TrustedBinaryDrift, refreshCommand string) Result
- func EnrichResultWithOllamaProbe(ctx context.Context, r Result) Result
- func Evaluate(in Input) Result
- func OverlayEffectiveDefaults(res Result, model, provider string) Result
- type StalePolicyPreset
- type TrustedBinaryDrift
Constants ¶
const ( CategoryDefaults = "defaults" CategoryRegistration = "registration" CategoryHealth = "health" )
const CategoryPolicy = "policy"
CategoryPolicy groups issues about the HITL policy envelope on disk (the files behind hitl-policy-name), as distinct from model/backend readiness.
const DefaultOllamaSuggestModel = "qwen3:8b"
DefaultOllamaSuggestModel is the model name we suggest for local Ollama when no chat models are present yet.
const StalePolicyPresetsCode = "hitl_policy_presets_stale"
StalePolicyPresetsCode is the issue code for a policy file that predates the toolsets this build ships. Deliberately absent from blockingIssue's list.
const TrustedBinaryIssueCode = "hitl_trusted_binaries_drift"
TrustedBinaryIssueCode is the issue code for a policy whose trusted_binaries declarations no longer describe this host. Deliberately absent from blockingIssue's list: an entry that stopped matching costs an approval card, never a refusal to run.
Variables ¶
This section is empty.
Functions ¶
func ProbeLocalOllamaAPI ¶
ProbeLocalOllamaAPI returns (baseURL, true) if GET {base}/api/tags responds with HTTP 200.
func ResolveMaxOutputTokens ¶
func ResolveMaxOutputTokens(states []runtimestate.BackendRuntimeState, provider, model string) int
ResolveMaxOutputTokens returns the known output-token ceiling for the active provider/model from already-synced runtime state. It returns 0 when unknown.
func StatesFromMap ¶
func StatesFromMap(m map[string]runtimestate.BackendRuntimeState) []runtimestate.BackendRuntimeState
StatesFromMap flattens runtime state snapshots for Evaluate / GatherInput.
Types ¶
type BackendCheck ¶
type BackendCheck struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
BaseURL string `json:"baseUrl"`
Status string `json:"status"`
Reachable bool `json:"reachable"`
DefaultProvider bool `json:"defaultProvider"`
ModelCount int `json:"modelCount"`
ChatModelCount int `json:"chatModelCount"`
ChatModels []string `json:"chatModels,omitempty"`
// EmbedModels lists the backend's embedding-capable models, reported
// separately since chat and embedding models are usually disjoint sets.
EmbedModelCount int `json:"embedModelCount,omitempty"`
EmbedModels []string `json:"embedModels,omitempty"`
Error string `json:"error,omitempty"`
Hint string `json:"hint,omitempty"`
}
BackendCheck reports the runtime status of one registered backend.
type Input ¶
type Input struct {
DefaultModel string
DefaultProvider string
DefaultAltModel string
DefaultAltProvider string
// DefaultEmbedModel/DefaultEmbedProvider gate the optional workspace
// index; every issue they produce is a warning (see addEmbeddingIssues).
DefaultEmbedModel string
DefaultEmbedProvider string
DefaultChain string
HITLPolicyName string
States []runtimestate.BackendRuntimeState
// RegisteredBackendCount, if non-nil, overrides len(RegisteredBackends) / len(States)
// for BackendCount. CLI doctor sets this from ListBackends when runtime state sync is unavailable.
RegisteredBackendCount *int
RegisteredBackends []runtimetypes.Backend
// ResolvedFrom records where workspace-scoped keys came from: "workspace" or "global".
// Keys are camelCase JSON names: "defaultChain", "hitlPolicyName".
ResolvedFrom map[string]string
}
Input is everything needed to compute readiness; callers gather from DB + runtime state.
func GatherInput ¶
func GatherInput(ctx context.Context, db libdbexec.DBManager, states []runtimestate.BackendRuntimeState, workspaceID string) (Input, error)
GatherInput builds Input from SQLite KV defaults, registered backend count, and a runtime state snapshot. workspaceID scopes workspace-scoped keys (default-chain, hitl-policy-name) with global fallback.
type Issue ¶
type Issue struct {
Code string `json:"code"`
Severity string `json:"severity"`
Category string `json:"category,omitempty"`
Message string `json:"message"`
FixPath string `json:"fixPath,omitempty"`
CLICommand string `json:"cliCommand,omitempty"`
}
Issue describes one setup problem and how to fix it.
type Result ¶
type Result struct {
DefaultModel string `json:"defaultModel"`
DefaultProvider string `json:"defaultProvider"`
DefaultMaxOutputTokens int `json:"defaultMaxOutputTokens,omitempty"`
DefaultEmbedModel string `json:"defaultEmbedModel,omitempty"`
DefaultEmbedProvider string `json:"defaultEmbedProvider,omitempty"`
DefaultChain string `json:"defaultChain"`
HITLPolicyName string `json:"hitlPolicyName"`
BackendCount int `json:"backendCount"`
ReachableBackendCount int `json:"reachableBackendCount"`
Issues []Issue `json:"issues"`
BackendChecks []BackendCheck `json:"backendChecks,omitempty"`
ResolvedFrom map[string]string `json:"resolvedFrom,omitempty"`
}
Result is returned by GET /setup-status and contenox doctor.
func AddStalePolicyPresetIssue ¶
func AddStalePolicyPresetIssue(r Result, stale []StalePolicyPreset, refreshCommand string) Result
AddStalePolicyPresetIssue appends a warning for policy files that predate this build's toolsets, returning the Result unchanged when nothing is stale. Never a blocking code: a stale envelope just asks for approval more often, never a reason to refuse to run. Each stale file is named by full path with its default_action fall-through; a policy never gates tool visibility (the chain's tools allowlist does).
func AddTrustedBinaryIssue ¶ added in v0.38.0
func AddTrustedBinaryIssue(r Result, drift []TrustedBinaryDrift, refreshCommand string) Result
AddTrustedBinaryIssue appends a warning for declarations that no longer match this host, returning the Result unchanged when nothing drifted. The runtime's own answer for a drifted entry is a refusal (the allow is withdrawn and the call asks a human), so this only ever explains an otherwise puzzling approval card and names the verb that fixes it.
func EnrichResultWithOllamaProbe ¶
EnrichResultWithOllamaProbe probes the local Ollama HTTP API (OLLAMA_HOST or default) and augments registration-related issues when /api/tags is reachable but no Ollama backend is ready yet.
func Evaluate ¶
Evaluate returns readiness from gathered input (no I/O). Embedding-model issues are appended last and unconditionally, regardless of which early return fired in evaluateCore.
func OverlayEffectiveDefaults ¶
OverlayEffectiveDefaults credits an effective default model/provider supplied out-of-band (e.g. CLI flags) but never persisted to KV config: for each empty persisted default, a non-empty override fills it and clears the corresponding "missing default" issue. Empty overrides are ignored; a persisted default is never overwritten.
func (Result) BlockingIssues ¶
BlockingIssues returns the issues that make the runtime not ready, in the order Evaluate produced them. It performs no I/O.
type StalePolicyPreset ¶
type StalePolicyPreset struct {
Name string `json:"name"`
Path string `json:"path,omitempty"`
// Toolsets are the toolset names the file never mentions.
Toolsets []string `json:"toolsets"`
// Effect describes, in the operator's terms, what those toolsets get
// instead of a rule (e.g. "every call stops for approval").
Effect string `json:"effect,omitempty"`
}
StalePolicyPreset names one policy file on disk together with the shipped toolsets it has no rule for. The caller (the CLI, which owns the embedded presets) does the detection; this package only knows how to report it.
type TrustedBinaryDrift ¶ added in v0.38.0
type TrustedBinaryDrift struct {
Path string `json:"path"`
// Findings are one rendered line per entry that is missing, mismatched,
// unreadable, or unreachable.
Findings []string `json:"findings"`
}
TrustedBinaryDrift names one policy file together with the declaration findings for it. The caller (the CLI, which knows the policy search path) does the detection; this package only knows how to report it.