outcomecal

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Overview

Package outcomecal joins recorded local task outcomes with the packet stance (answered or abstained) that preceded them and reports calibration only. It never writes, and it never changes a threshold: a proposed threshold is reported with applied=false and must pass the learned-trace admission evaluation gate before any mechanism change (AGENTS.md invariant 5).

Index

Constants

View Source
const (
	ProposalProposed        = "proposed"
	ProposalInsufficient    = "insufficient-sample"
	ProposalNoScoredRecords = "no-scored-records"
)

Proposal states.

View Source
const MinimumSample = 20

MinimumSample is the smallest joined sample that may carry a proposal. Below it the report abstains instead of inventing a calibrated threshold (AGENTS.md invariant 2).

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Lower   float64
	Upper   float64
	Records int
	Success int
}

Bucket is one fixed decile of the relevance-floor score.

type Matrix

type Matrix struct {
	AnsweredSuccess  int
	AnsweredFailure  int
	AbstainedSuccess int
	AbstainedFailure int
	UnknownSuccess   int
	UnknownFailure   int
}

Matrix is the answered/abstained by success/failure contingency table. Failure covers every non-passed recorded outcome (failed and blocked today).

func (Matrix) Classified

func (matrix Matrix) Classified() int

Classified is the number of rows whose stance is known.

type Observation

type Observation struct {
	Stance   Stance
	Success  bool
	Score    float64
	HasScore bool
}

Observation is one joined row: the packet stance for a task, whether the task outcome succeeded, and the relevance-floor score when the record carries one.

func Observe

func Observe(record trace.Record) Observation

Observe projects one recorded trace onto the calibration join.

Stance and Score are absent from the schema-version-1 record: `corvint record` stores the task outcome, not the packet decision that preceded it or the score that decision used. Every record therefore classifies as Unknown with no score until the producer records those fields; the report counts those rows explicitly rather than guessing a stance.

type Proposal

type Proposal struct {
	ThresholdTenths int
	Calibrated      int
	SampleSize      int
}

Proposal is the threshold that would have maximised abstention accuracy on this sample. It is never applied. The threshold is reported in tenths because the candidate grid is the eleven decile edges of [0, 1] and the canonical wire encoding carries integers only.

func (Proposal) Accuracy

func (proposal Proposal) Accuracy() float64

Accuracy is the proposal's abstention accuracy on the scored sample.

type Report

type Report struct {
	TraceState    string
	Since         string
	Window        int
	SampleSize    int
	Matrix        Matrix
	UnknownReason string
	Accuracy      float64
	HasAccuracy   bool
	ScoreCoverage int
	ScoreReason   string
	Buckets       []Bucket
	Insufficient  bool
	ProposalState string
	Proposal      Proposal
}

Report is the whole read-only calibration result.

func Build

func Build(observations []Observation, traceState string) Report

Build joins the observations into the calibration report. It reads only the supplied rows and writes nothing.

func (Report) Payload

func (report Report) Payload() map[string]any

Payload renders the report as the canonical wire object. It is pure data: no member of it is ever written back to the repository.

func (Report) Table

func (report Report) Table() string

Table renders the same report as a deterministic fixed-order text table.

type Stance

type Stance string

Stance is the packet decision recorded for a task.

const (
	// Answered means the packet returned evidence for the task.
	Answered Stance = "answered"
	// Abstained means the packet declined to answer the task.
	Abstained Stance = "abstained"
	// Unknown means no readable field carries the packet decision.
	Unknown Stance = "unknown"
)

Jump to

Keyboard shortcuts

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