releasepolicy

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package releasepolicy evaluates the same bounded, declarative rules for playback, release search and unsaved previews. No client or UI dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Better

func Better(a, b Result) bool

Better gives explicit fallback tiers precedence, then ordered preferences. Equal policy results leave TRaSH, health and source routing order untouched.

func ChannelSourceAllowed

func ChannelSourceAllowed(r core.Release, duration time.Duration, renditionKbps int) bool

ChannelSourceAllowed is the owner's hard source envelope for virtual TV. Network headroom never admits 4K, remuxes or disc images. Ordinary encodes reserve 25% of the rendition budget for variable bitrate and cheap playout. Unknown individual file size is checked again after opening a pack/link.

func Conflict

func Conflict(rules []core.ReleaseRule) string

Conflict describes required rules that cannot be true of one release. Empty means no such conflict. Disabled rules, exceptions and fallbacks are left alone: those can still be satisfied.

func ConflictWith added in v0.3.3

func ConflictWith(rules []core.ReleaseRule, lookup FieldLookup) string

ConflictWith is Conflict with a caller-supplied field table; it is what the console-served descriptors declare as single-value that decides a conflict, so plugin single-value fields conflict the same way.

func Equivalent

func Equivalent(a, b Result) bool

Equivalent reports the same fallback tier and the same ordered preference vector. Health racing may overtake only an equivalent candidate; a fallback must not pass a still-valid primary.

func IsExternalFieldID added in v0.3.3

func IsExternalFieldID(id string) bool

IsExternalFieldID reports whether id is plugin-namespaced ("plugin:<id>/<key>"), the shape every plugin rule field takes.

func UsesOriginalAudio

func UsesOriginalAudio(rules []core.ReleaseRule) bool

UsesOriginalAudio reports whether evaluation of these rules needs the catalogue original language. Disabled rules do not.

Types

type Context

type Context struct {
	OriginalLanguage string
	ExternalMatch    func(core.Release, core.ReleaseCondition) (bool, bool)
}

Context is evidence that belongs to the title, not the release. OriginalLanguage is the catalogue title's original language (Title.Language) when the caller has that title. An empty value means the comparison is unavailable. It is never a guessed language, and it is not part of the profile selection hash or the search cache key.

type Explanation

type Explanation struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Action  string `json:"action"`
	State   State  `json:"state"`
	Outcome string `json:"outcome"` // pass, exclude, prefer, fallback, skip, unknown
}

type FieldLookup added in v0.3.3

type FieldLookup func(id string) (FieldSpec, bool)

FieldLookup resolves a condition field id to its spec. The resolver builds one from the descriptor registry; nil means the built-in table.

type FieldSpec added in v0.3.3

type FieldSpec struct {
	ID string
	// ValueClass: text, choice, language, number or none
	// (extend.RuleValue* values, kept as strings to avoid a cycle).
	ValueClass      string
	Operators       []string
	DefaultOperator string
	SingleValue     bool
	// External marks a plugin-contributed field: it compiles when its
	// descriptor is registered and evaluates Unknown until the plugin
	// hot path (WS9h) supplies matches.
	External bool
}

FieldSpec describes one rule field for validation and for the extend descriptor registry (WS1a). The console renders its condition picker from descriptors built on these specs, so this table is the one Go source for which fields exist and how their values validate.

func BuiltinFields added in v0.3.3

func BuiltinFields() []FieldSpec

BuiltinFields returns the built-in rule fields in console picker order.

func LookupBuiltinField added in v0.3.3

func LookupBuiltinField(id string) (FieldSpec, bool)

LookupBuiltinField is the default FieldLookup.

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

func Compile

func Compile(rules []core.ReleaseRule) (*Policy, error)

Compile validates rules against the built-in field table. Plugin-namespaced fields compile structurally (operator and value shape) and evaluate Unknown; see CompileWith for registry-checked compilation.

func CompileWith added in v0.3.3

func CompileWith(rules []core.ReleaseRule, lookup FieldLookup) (*Policy, error)

CompileWith is Compile with a caller-supplied field table, built by the resolver from the descriptor registry so registered plugin fields compile under their declared operators and value class. A nil lookup uses the built-in table. Behaviour for built-in fields is identical either way.

func (*Policy) Evaluate

func (p *Policy) Evaluate(rel core.Release, ctx Context) Result

type Result

type Result struct {
	Rejected     bool          `json:"rejected"`
	Unknown      bool          `json:"unknown"`
	Fallback     int           `json:"fallback"`
	Preferences  []int         `json:"preferences"`
	Explanations []Explanation `json:"explanations"`
}

func (Result) PreferRule added in v0.3.0

func (r Result) PreferRule(id string) int

PreferRule returns 1 when the prefer rule with id matched, 0 otherwise.

type State

type State string
const (
	Match   State = "match"
	Miss    State = "miss"
	Unknown State = "unknown"
)

Jump to

Keyboard shortcuts

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