rule

package
v1.77.0 Latest Latest
Warning

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

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

Documentation

Overview

Package rule models the single enable/disable signal type the scheduler folds to decide whether a package may run. A Rule contributes one opinion over the Kind lattice; Resolve combines an ordered list of them. Both the old "gate" checks (version, dependency, bootstrap) and future intent signals (bundle, user config, enabled script) are expressed uniformly as Rules — the scheduler never branches on rule type, only on the resolved Kind.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	Kind    Kind   `json:"kind"`
	Reason  string `json:"reason,omitempty"`
	Message string `json:"message,omitempty"`
}

Decision is a single rule's verdict: its opinion plus a reason and message suitable for surfacing as a Kubernetes status condition when the package ends up disabled.

func Resolve

func Resolve(rules ...Rule) Decision

Resolve folds an ordered list of rules into a single decision:

  • the first Forbid wins immediately — a hard veto cannot be overridden, so its position in the list does not affect the outcome;
  • among soft votes (Enable/Disable) the last one wins, so later rules take precedence over earlier ones;
  • Undefined rules are skipped; if every rule is Undefined the result is Undefined and the caller's floor decides the default.

type Kind

type Kind string

Kind classifies a single rule's opinion about whether a package should run. The four values form a lattice with two soft states (overridable votes) and one hard state (a non-overridable veto); there is deliberately no hard "force-enable" — requirements must always retain the power to block.

const (
	// Undefined means the rule has no opinion; resolution defers to other rules.
	Undefined Kind = "Undefined"
	// Enable is a soft vote to turn the package on; a later soft vote overrides it.
	Enable Kind = "Enable"
	// Disable is a soft vote to turn the package off; a later soft vote overrides it.
	Disable Kind = "Disable"
	// Forbid is a hard veto: the package is off and no other rule can re-enable it.
	Forbid Kind = "Forbid"
)

type Rule

type Rule interface {
	// Decide evaluates the rule and returns its verdict.
	Decide() Decision
}

Rule contributes one opinion about whether a package should run. Cross-module state (current versions, dependency presence, and the like) is captured by getters at construction time, so Decide takes no arguments.

func Static

func Static(kind Kind) Rule

Static returns a Rule that always emits the given kind with no reason or message. Use it for constant floors — e.g. an always-Enable floor for packages that should run whenever they are loaded.

Directories

Path Synopsis
Package bundle provides a module floor rule: it enables a module when the cluster's active bundle is one that enables it in the active edition, and soft-disables it otherwise.
Package bundle provides a module floor rule: it enables a module when the cluster's active bundle is one that enables it in the active edition, and soft-disables it otherwise.
Package dynamic provides the module enablement intent rule: the highest- precedence enablement signal a module carries, folding the external enable/disable signals (explicit ModuleConfig intent and the deprecated global-hook dynamic enable).
Package dynamic provides the module enablement intent rule: the highest- precedence enablement signal a module carries, folding the external enable/disable signals (explicit ModuleConfig intent and the deprecated global-hook dynamic enable).
Package script models a module's enabled script as a scheduler rule.
Package script models a module's enabled script as a scheduler rule.

Jump to

Keyboard shortcuts

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