diff

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package diff compares two contract versions and classifies each field change.

Index

Constants

View Source
const (
	FieldAudiences      = "expects.audiences"
	FieldIssuers        = "expects.issuers"
	FieldAlgorithms     = "expects.algorithms"
	FieldRequiredClaims = "expects.required_claims"
	FieldClockSkew      = "expects.clock_skew_sec"
	FieldRefreshUnknown = "jwks_behavior.refreshes_on_unknown_kid"
	FieldCacheTTL       = "jwks_behavior.cache_ttl_sec"
	FieldConsumer       = "consumer"
)

Field path constants matching PRD §9.2.

Variables

This section is empty.

Functions

func Compute

func Compute(from, to model.ContractVersion) []model.ChangeEvent

Compute diffs two contract versions and returns the classified change events (PRD §9). Consumers are matched across versions by StableID; a consumer present in only one version yields a consumer_added / consumer_removed event.

Field-level changes are decomposed into atomic operations and run through Classify (classify.go). Each added/removed element of a set-valued field (audiences, issuers, algorithms, required_claims) produces exactly one event — so adding a single audience yields exactly one `widened` event (AC-7).

Types

type Classification

type Classification struct {
	Class    model.ChangeClass
	Severity model.Severity
}

Classification is the result of classifying one field change.

func Classify

func Classify(field string, op FieldOp, value any, confidence float64) Classification

Classify applies the exact classification and severity tables from PRD §9.2/§9.3 to a single atomic field change. `value` carries the added/removed element where it matters (notably `algorithms: none`).

type FieldOp

type FieldOp string

FieldOp is the atomic operation the diff walker detected on a field.

const (
	OpAdd         FieldOp = "add"          // value added to a set-valued field
	OpRemove      FieldOp = "remove"       // value removed from a set-valued field
	OpIncrease    FieldOp = "increase"     // numeric field went up
	OpDecrease    FieldOp = "decrease"     // numeric field went down
	OpTrueToFalse FieldOp = "true_false"   // boolean flipped to false
	OpFalseToTrue FieldOp = "false_true"   // boolean flipped to true
	OpConsumerAdd FieldOp = "consumer_add" // whole consumer appeared
	OpConsumerDel FieldOp = "consumer_del" // whole consumer disappeared
)

Jump to

Keyboard shortcuts

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