decide

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: AGPL-3.0 Imports: 4 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 decide implements the Decision Engine (ADR-0012): a deterministic capability gate on the pessimistic posterior quantile, then Thompson Sampling on the preference side. It reads the finest-matching Connection only (ADR-0013 Decision 2) and holds no state of its own — same ledger + same seed → same decision (ADR-0012 Decision 5).

Index

Constants

View Source
const (
	// QuantileQ is the quantile level, and — through gateBar — the bar for a
	// connection whose prior is uniform. The gate is self-referential: a
	// provider nobody knows anything about sits precisely on the bar and
	// passes, while one failure drops it well below (Beta(1,2) q20 ≈ 0.106).
	// For the uniform prior that state's q-quantile is exactly q, which is why
	// this one constant used to serve as both; gateBar (ADR-0038) states the
	// rule for every prior. No second semantic knob.
	QuantileQ = 0.20
)

Knobs (ADR-0012 Consequences: 分位点q と n(stakes)の固定表).

Variables

This section is empty.

Functions

func Draws

func Draws(size string) int

Draws is n(stakes): how many times to imagine before deciding (ADR-0012 Decision 4). A pure function of the size context attribute — v1 is the fixed table the ADR calls for. n=1 is pure Thompson Sampling; larger n cools exploration toward the posterior-mean greedy.

func GatePass

func GatePass(c *core.Connection, nowMs int64) bool

GatePass reports whether ONE connection clears its own bar — the per- connection question rehabilitation asks (ADR-0015: 名誉回復 = 悲観ゲートへの 再入場). This is a finer grain than Choose's gate, which under ADR-0042 対案2 clears a provider only if EVERY same-granularity sibling passes: a connection can GatePass on its own yet still see its provider gated out by a failing sibling. nil is the blank slate: pass.

func KnowsCapability

func KnowsCapability(conns []*core.Connection, target string, tokens []string) bool

KnowsCapability reports whether the ledger holds any capability connection for target readable under tokens — i.e. whether Choose's gate would read a real row rather than the Beta(1,1) blank slate. It answers by the same finest-match subset rule the decision itself reads with (ADR-0013 Decision 2), so "knowing a target in this context" and "deciding in this context" can never diverge on what the context is. ADR-0043 Decision 4 gates human's candidacy on this: ignorance is full exploration for a provider, but for human it would be handing the task back to the user.

func PairWobble

func PairWobble(c *core.Connection, m int, seed, nowMs int64) float64

PairWobble is Wobble for one preference posterior directly: the rate at which n=1 draws land on opposite sides of even. Absent connection = Beta(1,1), the maximum-flicker blank slate. Used by the Preference Gap's VoI, whose judgment is exactly this pair (ADR-0016 Decision 2).

func Wobble

func Wobble(conns []*core.Connection, providers, tokens []string, size string, m int, seed, nowMs int64) float64

Wobble is the judgment's flicker (ADR-0016: 判断の揺らぎ): run the same seeded decision m times and return the rate at which the winner disagrees with the modal winner. 0 = the lottery always names the same provider. Reused by VoI (ADR-0016) and the S4 sharpness gate (ADR-0017).

Types

type Candidate

type Candidate struct {
	Provider string
	// ScopeKey/Quantile name the connection this row reports on. For a passer
	// it is the finest match selection actually read ("" = blank slate); for a
	// provider gated out under ADR-0042 対案2 it is the refusing sibling — the
	// most pessimistic same-granularity connection that missed its bar.
	ScopeKey string
	Quantile float64 // pessimistic quantile of that connection at decision time
	Passed   bool
	Wins     int // pairwise preference wins among gate passers (-1 = gated)
	// contains filtered or unexported fields
}

Candidate is one provider's audit row in a Decision.

type Decision

type Decision struct {
	Provider   string
	Seed       int64
	N          int
	Q          float64
	Fallback   bool // no candidate passed the gate; least-bad was chosen
	Candidates []Candidate
}

Decision is the full audit record of one choice.

func Choose

func Choose(conns []*core.Connection, providers, tokens []string, size string, seed, nowMs int64) Decision

Choose picks a provider for the given context tokens. conns is the full projection (the function selects finest matches itself), providers the registered candidates, size the stakes attribute, seed the recorded lot.

func ChoosePlan

func ChoosePlan(conns []*core.Connection, menu, tokens []string, size string, seed, nowMs int64) Decision

ChoosePlan picks a plan variant from the menu — the same gate and lottery over the ledger's second bet target (ADR-0014 Decision 1: 二段とも同じ 機構が全適用される).

Jump to

Keyboard shortcuts

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