explain

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package explain renders a decision in human-readable form: what it depends on, how it decides, and what its rules say.

It exists as a library rather than as CLI formatting because the same rendering is what the MCP `verdict_explain` tool returns. An agent asking "what does this decision do?" and an engineer running `verdict explain` should get the same answer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Prompt      string            `json:"prompt_template"`
	Bindings    map[string]string `json:"input_bindings,omitempty"`
	OutputType  string            `json:"output_type,omitempty"`
	Validator   string            `json:"validator,omitempty"`
	MaxLatency  string            `json:"max_latency,omitempty"`
	MaxRetries  int               `json:"max_retries,omitempty"`
	OnFailure   string            `json:"on_failure,omitempty"`
	FallbackTo  string            `json:"fallback_decision,omitempty"`
	SessionHint string            `json:"session_hint,omitempty"`
}

Agent renders an agentDecision.

type Clause

type Clause struct {
	Label      string `json:"label,omitempty"`
	Expression string `json:"expression,omitempty"`
	Name       string `json:"name,omitempty"`
	TypeRef    string `json:"type_ref,omitempty"`
	Values     string `json:"values,omitempty"`
	Default    string `json:"default,omitempty"`
}

Clause is one input or output clause.

type Item

type Item struct {
	ID       string `json:"id"`
	Name     string `json:"name,omitempty"`
	TypeRef  string `json:"type_ref,omitempty"`
	Kind     string `json:"kind"`
	Question string `json:"question,omitempty"`
}

Item is a named DRG element reference.

type Logic

type Logic struct {
	Kind string `json:"kind"`
	// Summary is a one-line description.
	Summary string `json:"summary"`
	// Expression is the FEEL source, for a literal expression.
	Expression string `json:"expression,omitempty"`
	// Table is present for a decision table.
	Table *Table `json:"table,omitempty"`
	// Agent is present for an agentDecision.
	Agent *Agent `json:"agent,omitempty"`
}

Logic describes a decision's boxed expression.

type Rule

type Rule struct {
	ID          string   `json:"id"`
	When        []string `json:"when"`
	Then        []string `json:"then"`
	Annotations []string `json:"annotations,omitempty"`
}

Rule is one row of a decision table.

type Slice

type Slice struct {
	ModelID   string `json:"model_id"`
	ModelName string `json:"model_name,omitempty"`

	DecisionID   string `json:"decision_id"`
	DecisionName string `json:"decision_name,omitempty"`
	Question     string `json:"question,omitempty"`
	Answers      string `json:"allowed_answers,omitempty"`
	Description  string `json:"description,omitempty"`
	OutputName   string `json:"output_name"`
	OutputType   string `json:"output_type,omitempty"`

	// RequiredInputs are the input-data elements this decision reads, directly
	// or through the decisions it depends on.
	RequiredInputs []Item `json:"required_inputs,omitempty"`
	// RequiredDecisions are the decisions this one depends on directly.
	RequiredDecisions []Item `json:"required_decisions,omitempty"`
	// RequiredKnowledge are the business knowledge models it may invoke.
	RequiredKnowledge []Item `json:"required_knowledge,omitempty"`
	// Authorities are the knowledge sources cited as the decision's authority.
	Authorities []Item `json:"authorities,omitempty"`

	// Logic describes the boxed expression.
	Logic Logic `json:"logic"`

	// Analysis is the decision table's gap/overlap summary, when it has one.
	Analysis *TableSummary `json:"analysis,omitempty"`
}

Slice is the DRG neighbourhood of one decision, with its logic described.

func Decision

func Decision(defs *model.Definitions, graph *model.Graph, report *analyze.Report, ref string) (*Slice, error)

Decision builds the slice for one decision.

func (*Slice) Text

func (s *Slice) Text() string

Text renders a slice as the prose an engineer or an agent reads.

type Table

type Table struct {
	HitPolicy string   `json:"hit_policy"`
	Inputs    []Clause `json:"inputs"`
	Outputs   []Clause `json:"outputs"`
	Rules     []Rule   `json:"rules"`
}

Table renders a decision table.

type TableSummary

type TableSummary struct {
	Analysable       bool     `json:"analysable"`
	Reason           string   `json:"reason,omitempty"`
	Gaps             []string `json:"gaps,omitempty"`
	Overlaps         []string `json:"overlaps,omitempty"`
	UnreachableRules []string `json:"unreachable_rules,omitempty"`
}

TableSummary is the decision's static-analysis result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL