Files
Maven/internal/router/semantic/contract.go
T
claude b6a21c17eb router/semantic: coarse-route contract, interface, and legacy mapping (slice 12)
Defines the six-class SemanticRoute type (conversation, knowledge,
action, memory_write, system, uncertain), the SemanticRouteDecision
output, the SemanticRouter interface, and the deterministic
Intent→SemanticRoute mapping from the current seven-intent cascade.
2026-09-07 01:42:17 +04:00

61 lines
2.0 KiB
Go

// Package semantic defines the coarse-route contract for the learned-router
// experiment. The existing seven-intent router remains authoritative; this
// package provides a six-class semantic layer that runs only in eval/shadow
// mode until it earns promotion.
//
// The six coarse routes are:
//
// - conversation — social turns, greetings, mood, jokes, open-ended chat
// - knowledge — questions seeking an answer (world, recall, calendar)
// - action — executable commands and reminders (act, reminder)
// - memory_write — structured or unstructured writes (fact, note)
// - system — time, date, quiet mode, self-management
// - uncertain — too little signal to decide; the authoritative router clarifies
//
// No capability, function, slot, or source information lives in this artifact.
// That is a later stage. The contract here is purely coarse-route + confidence.
package semantic
// SemanticRoute — one of six coarse semantic classes.
type SemanticRoute string
const (
RouteConversation SemanticRoute = "conversation"
RouteKnowledge SemanticRoute = "knowledge"
RouteAction SemanticRoute = "action"
RouteMemoryWrite SemanticRoute = "memory_write"
RouteSystem SemanticRoute = "system"
RouteUncertain SemanticRoute = "uncertain"
)
// AllRoutes is the ordered set of valid routes, for iteration and confusion
// matrix layout.
var AllRoutes = []SemanticRoute{
RouteConversation,
RouteKnowledge,
RouteAction,
RouteMemoryWrite,
RouteSystem,
RouteUncertain,
}
// SemanticRouteDecision — the output of a coarse router. No slots, no
// capability, no source — just the route, confidence, and whether the model
// chose to abstain.
type SemanticRouteDecision struct {
Route SemanticRoute
Confidence float64
Abstain bool
ModelID string
}
// ValidRoute reports whether r is one of the six defined routes.
func ValidRoute(r SemanticRoute) bool {
switch r {
case RouteConversation, RouteKnowledge, RouteAction,
RouteMemoryWrite, RouteSystem, RouteUncertain:
return true
}
return false
}