rule

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 0 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 rule is the enable/disable signal the scheduler folds to decide whether a package runs. A Rule gives one opinion; Resolve combines an ordered chain. Requirement gates (version, dependency, bootstrap) and intent rules (bundle, enable intent, enabled script) are all Rules, so the scheduler branches 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 rule's verdict, with the reason and message a disabled package reports.

func Resolve

func Resolve(rules ...Rule) Decision

Resolve folds an ordered chain into one decision: the first Forbid wins at once (later rules are not evaluated); otherwise the last soft vote (Enable or Disable) wins; Undefined is skipped, and a chain of Undefined only resolves to Undefined (not enabled).

type Kind

type Kind string

Kind is a rule's opinion. There is deliberately no hard enable: requirements must always be able 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() Decision
}

Rule gives one opinion. State outside the node is read through getters bound at construction, so Decide takes no arguments.

func Static

func Static(kind Kind) Rule

Static returns a Rule that always emits kind; used for floors.

Directories

Path Synopsis
Package bundle is a module intent rule: Enable when the active bundle of the active edition enables the module, a soft Disable otherwise.
Package bundle is a module intent rule: Enable when the active bundle of the active edition enables the module, a soft Disable otherwise.
Package dynamic is a module's enable intent rule.
Package dynamic is a module's enable intent rule.
Package script is a module's enabled script as a scheduler rule.
Package script is 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