solver

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package solver implements constraint solving for Minecraft plugin version compatibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleSolver

type SimpleSolver struct{}

SimpleSolver implements a linear search constraint solver for MVP. Per ADR-010, this is sufficient for small numbers of plugins/servers.

func NewSimpleSolver

func NewSimpleSolver() *SimpleSolver

NewSimpleSolver creates a new simple linear search solver.

func (*SimpleSolver) FindBestPaperVersion

func (s *SimpleSolver) FindBestPaperVersion(
	ctx context.Context,
	server *mcv1beta1.PaperMCServer,
	matchedPlugins []mcv1beta1.Plugin,
	paperVersions []string,
) (string, error)

FindBestPaperVersion finds the maximum Paper version compatible with ALL plugins. Algorithm:

  1. Handle strategy-specific logic (pin/build-pin return exact version)
  2. Filter Paper versions by updateDelay
  3. Sort versions in descending order
  4. For each Paper version (highest first), check if ALL plugins have a compatible version
  5. Return first Paper version that satisfies all constraints

func (*SimpleSolver) FindBestPluginVersion

func (s *SimpleSolver) FindBestPluginVersion(
	ctx context.Context,
	plugin *mcv1beta1.Plugin,
	servers []mcv1beta1.PaperMCServer,
	allVersions []plugins.PluginVersion,
) (string, error)

FindBestPluginVersion finds the maximum plugin version compatible with ALL servers. Algorithm:

  1. Handle strategy-specific logic (pin/build-pin return exact version)
  2. Filter versions by updateDelay (skip too new versions)
  3. Sort versions in descending order
  4. For each version (highest first), check if compatible with ALL servers
  5. Return first version that satisfies all constraints

type Solver

type Solver interface {
	// FindBestPluginVersion finds the maximum plugin version compatible with ALL matched servers.
	// This implements the constraint: ∀ server ∈ servers: compatible(plugin_version, server.paperVersion).
	FindBestPluginVersion(
		ctx context.Context,
		plugin *mcv1beta1.Plugin,
		servers []mcv1beta1.PaperMCServer,
		allVersions []plugins.PluginVersion,
	) (string, error)

	// FindBestPaperVersion finds the maximum Paper version compatible with ALL matched plugins.
	// This implements the constraint: ∀ plugin ∈ plugins: ∃ plugin_version compatible with paper_version.
	FindBestPaperVersion(
		ctx context.Context,
		server *mcv1beta1.PaperMCServer,
		matchedPlugins []mcv1beta1.Plugin,
		paperVersions []string,
	) (string, error)
}

Solver defines the interface for finding compatible versions. Implementations include simple linear search (MVP) and future SAT-based solvers.

Jump to

Keyboard shortcuts

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