rules

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 2 Imported by: ? 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 rules defines Fort's deterministic routing-rule schema and a strict parser for it (backlog AO-012). A ruleset is ordered; the matcher engine (package router) applies first-match-wins with a default fallback.

No model/LLM calls ever happen here — routing reads only deterministic signals on a task.

Index

Constants

View Source
const SupportedVersion = 1

SupportedVersion is the only ruleset schema version this build understands.

Variables

This section is empty.

Functions

This section is empty.

Types

type Defaults

type Defaults struct {
	Route string `yaml:"route"`
}

Defaults holds the fallback route used when no rule matches.

type Matcher

type Matcher struct {
	// Leaf signals.
	Label []string    `yaml:"label,omitempty"`
	Path  []string    `yaml:"path,omitempty"`
	Repo  string      `yaml:"repo,omitempty"`
	Agent string      `yaml:"agent,omitempty"`
	Size  []string    `yaml:"size,omitempty"`
	Time  *TimeWindow `yaml:"time,omitempty"`

	// Composition.
	Any []Matcher `yaml:"any,omitempty"`
	All []Matcher `yaml:"all,omitempty"`
}

Matcher is either a leaf (one or more of the signal fields, ANDed together) or a composition (Any / All of sub-matchers). A leaf with multiple fields requires all of them to hold.

type Rule

type Rule struct {
	ID    string  `yaml:"id"`
	When  Matcher `yaml:"when"`
	Route string  `yaml:"route"`
}

Rule is one ordered routing rule: when When matches a task, route to Route.

type Ruleset

type Ruleset struct {
	Version  int      `yaml:"version"`
	Defaults Defaults `yaml:"defaults"`
	Rules    []Rule   `yaml:"rules"`
}

Ruleset is a parsed, validated routing ruleset.

func Parse

func Parse(data []byte) (*Ruleset, error)

Parse decodes and validates a ruleset. YAML syntax errors are returned with line information from the underlying decoder; semantic errors name the offending rule.

type TimeWindow

type TimeWindow struct {
	After  string `yaml:"after"`
	Before string `yaml:"before"`
}

TimeWindow is a time-of-day window [After, Before) in 24h "HH:MM". When After > Before the window wraps midnight (e.g. 18:00–06:00).

Jump to

Keyboard shortcuts

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