classify

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package classify infers a tool's reversibility class from its name, description, and schema - the single biggest onboarding barrier this system had. Hand-classifying an entire tool catalog into A/B/C before you can run anything is real work nobody wants to do on day one, and it was the difference between "docker run and see something" and "read the docs for an hour first."

Two honest limits, stated up front because they shape the whole design:

  1. This is a HEURISTIC, not an authority. It reads names, descriptions, and schemas - it cannot know that `archive_record` in your system actually hard-deletes. Every result carries the signals that fired and a confidence, and anything it calls Class C (or can't read confidently) is flagged for human review rather than silently trusted.

  2. It fails CLOSED. An unrecognized verb doesn't become "probably safe Class B" - it becomes "unknown, review this," because the expensive mistake here is under-classifying something irreversible, not over-classifying something harmless. A false Class C costs someone an approval click; a false Class B costs them a sent email they can't recall.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	Name        string
	Description string
	Method      string   // optional: GET/POST/PATCH/DELETE, when known
	ArgNames    []string // optional: property names from the tool's schema
}

Input is what the classifier can actually see about a tool. MCP gives name/description/schema and no HTTP verb; a REST-style catalog gives a method too. Both paths feed the same engine, the method is just an extra signal when it happens to be there.

type Report

type Report struct {
	Source         string         `json:"source"`
	TotalTools     int            `json:"total_tools"`
	ByClass        map[string]int `json:"by_class"`
	Irreversible   []string       `json:"irreversible_tools,omitempty"`
	NeedsReview    []string       `json:"needs_review_tools,omitempty"`
	Unclassified   []string       `json:"unclassified_tools,omitempty"`
	UndoableInName []string       `json:"compensable_but_no_pre_image,omitempty"`
	Results        []Result       `json:"results"`
}

Report is the aggregate view over a whole catalog - the thing that actually answers "how much damage can this agent do." The individual classifications matter less than these three numbers: how much of this catalog is irreversible, how much of it nobody has reviewed, and how much of it claims to be undoable without any way to actually undo it.

func Summarize

func Summarize(source string, results []Result, compensableGaps []string) Report

Summarize turns per-tool results into the aggregate. compensableGaps names tools classified compensable (Class A) that have no way to capture a pre-image - they read as "undoable" in a catalog while being undoable by nobody, which is the most dangerous kind of wrong.

type Result

type Result struct {
	Tool       string                      `json:"tool"`
	Class      registry.ReversibilityClass `json:"class,omitempty"`
	Confidence float64                     `json:"confidence"`
	Rationale  string                      `json:"rationale"`
	Signals    []Signal                    `json:"signals,omitempty"`

	// NeedsReview is set whenever a human must look before this
	// classification is trusted in production: anything irreversible,
	// anything ambiguous, and anything unrecognized.
	NeedsReview bool `json:"needs_review"`

	// Unclassified means no rule matched with enough confidence to name a
	// class at all. Deliberately distinct from "Class C" - "I don't know"
	// and "I know this is dangerous" are different messages to a human.
	Unclassified bool `json:"unclassified,omitempty"`
}

func Classify

func Classify(in Input) Result

Classify runs the heuristics over one tool.

type Signal

type Signal struct {
	Rule   string `json:"rule"`
	Detail string `json:"detail"`
}

Signal is one heuristic that fired, kept in the result so a human reviewing a classification can see WHY rather than having to trust it.

Jump to

Keyboard shortcuts

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