modeldiff

package
v0.270.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 9 Imported by: 0 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 modeldiff compares two authorization models and classifies the differences between their shapes.

Index

Constants

View Source
const (
	CostIncreased = "increased"
	CostDecreased = "decreased"
)

Direction values are a stable part of the JSON contract.

View Source
const (
	// Breaking.
	TypeRemoved               = "type_removed"
	RelationRemoved           = "relation_removed"
	DirectTypeRemoved         = "direct_type_removed"
	ConditionRemoved          = "condition_removed"
	ConditionParamRemoved     = "condition_param_removed"
	ConditionParamTypeChanged = "condition_param_type_changed"
	// ConditionParamAdded is breaking: existing callers and stored tuple
	// contexts do not supply the new parameter, so checks can fail.
	ConditionParamAdded = "condition_param_added"

	// Changed.
	RewriteChanged             = "rewrite_changed"
	ConditionExpressionChanged = "condition_expression_changed"
	SchemaVersionChanged       = "schema_version_changed"

	// Added.
	TypeAdded       = "type_added"
	RelationAdded   = "relation_added"
	DirectTypeAdded = "direct_type_added"
	ConditionAdded  = "condition_added"
)

Kind values are stable and part of the JSON contract.

Variables

This section is empty.

Functions

This section is empty.

Types

type CostEntry

type CostEntry struct {
	Type      string         `json:"type"`
	Relation  string         `json:"relation"`
	Direction string         `json:"direction" jsonschema:"enum=increased,enum=decreased"`
	Old       map[string]int `json:"old" jsonschema_description:"Weight per user type; -1 means unbounded (infinite) weight."`
	New       map[string]int `json:"new" jsonschema_description:"Weight per user type; -1 means unbounded (infinite) weight."`
}

CostEntry is one relation whose per-user-type weights differ between models.

type Entry

type Entry struct {
	Kind      string `` /* 365-byte string literal not displayed */
	Type      string `json:"type,omitempty"`
	Relation  string `json:"relation,omitempty"`
	Condition string `json:"condition,omitempty"`
	Detail    string `json:"detail"`
}

Entry is one difference between the two models.

type Result

type Result struct {
	Breaking []Entry `json:"breaking"`
	Changed  []Entry `json:"changed"`
	Added    []Entry `json:"added"`
	// Cost lists relations whose per-user-type weights differ.
	Cost []CostEntry `json:"cost"`
	// CostSkipped explains why Cost could not be computed.
	CostSkipped string `json:"costSkipped,omitempty"`
}

Result groups the differences by severity.

func Diff

func Diff(oldM, newM *optimize.Model) Result

Diff compares the shapes of old and new.

func (Result) Empty

func (r Result) Empty() bool

Empty reports whether the models have no differences.

func (Result) HasCostIncrease

func (r Result) HasCostIncrease() bool

HasCostIncrease reports whether any relation got more expensive.

Jump to

Keyboard shortcuts

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