route

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package route wraps registry.Decider with everything internal/sdlc/engine needs to turn an AskJev effect into a JevDecided event: call-time criteria assembly for a select node's candidates and for top-level workflow selection (one assembler serving both, so their criteria have identical shape), bounded and redacted state, and Jev-unavailable/shadow-mode handling that always yields a usable decision — "a run never stalls on the classifier". route never decides thresholds itself; every decision is registry.Decider's, exactly as internal/mcp already reuses it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bound

func Bound(text string, maxBytes int) string

Bound head/tail-excerpts text to at most maxBytes, keeping both ends intact rather than truncating mid-structure — ralph's LOG_READ_MAX_BYTES discipline, ported to a single reusable place instead of every caller re-deriving its own truncation. maxBytes <= 0 means unbounded. The split is adjusted to the nearest rune boundary on each side so neither excerpt ends mid-character.

func CriteriaFromRubrics

func CriteriaFromRubrics(rubrics map[string]string) map[string]string

CriteriaFromRubrics is the one call-time criteria assembler both sdlc.agent-selection (id to each candidate's catalog rubric) and sdlc.workflow-selection (name to workflow description) use, so their criteria have identical shape by construction rather than by two call sites happening to agree: an empty id or rubric is dropped (Jev cannot use it either way), and each rubric is bounded the same way state is.

Types

type Asker

type Asker interface {
	Ask(ctx context.Context, req jev.Request) (*jev.Response, error)
}

Asker is the slice of the jev client route needs.

type Config

type Config struct {
	// Decider supplies the registry and applies its thresholds; its own
	// Getenv controls JEVKIT_SHADOW, exactly as internal/mcp uses it.
	Decider *registry.Decider
	// Client asks Jev.
	Client Asker
	// Redact scrubs state and call-time rubrics before transport; an error
	// rejects the call rather than sending unredacted text.
	Redact func(string) (string, []redact.Hit, error)
	// Unavailable returns "" when Jev can be used, else a short reason (no
	// key, breaker open). It must not return or log the key.
	Unavailable func(ctx context.Context) string
	// Now stamps a synthesized (Jev-unavailable) decision; nil means
	// time.Now.
	Now func() time.Time
}

Config wires a Router. Everything except Now is required.

type Result

type Result struct {
	Decision  registry.Decision
	Available bool
}

Result is what a caller turns into an engine.JevDecided event.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router asks Jev's registered question sets and applies their policy.

func New

func New(cfg Config) (*Router, error)

New validates cfg and returns a Router.

func (*Router) Decide

func (r *Router) Decide(ctx context.Context, setID, state string, criteria map[string]string) (Result, error)

Decide asks question set setID against state (already bounded by the caller via Bound; Decide redacts it before it reaches the wire) and returns the registry policy's decision.

criteria supplies call-time options for a choice question the registry declares with none (sdlc.agent-selection's candidates, or sdlc.workflow-selection's available workflows) — id to rubric, the same shape for both, which is what makes them "one implementation of call-time criteria assembly" per the plan. Pass nil for any other question set, whose criteria (if any) are already fixed in the registry.

Decide never returns an error for a reason internal to Jev itself (unavailable, transport failure, an unusable response, or a decide failure): each of those instead yields Available=false and a synthesized fallback Decision, so a caller can always proceed. An error return means the call was malformed (an unknown question set, criteria supplied where none was needed or omitted where it was, or state that failed redaction).

Jump to

Keyboard shortcuts

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