Documentation
¶
Overview ¶
Package steering is the public SDK facade over Harbor's internal/runtime/steering package — the run loop that drives a planner, the per-run control inbox/registry, and the steering taxonomy (RFC §3.6, §6.3; D-204). Alias-based re-exports only: no behavior lives here. RunLoop construction stays internal (the assembled Stack carries the production RunLoop); control-history internals and event payload structs are deliberately private.
Example ¶
Example shows the steering facade's primary entry surface: a Registry hands out one Inbox per run (keyed by the run's identity Quadruple); a caller Enqueues a scoped, validated ControlEvent; the run loop Drains it. Here a CANCEL — which requires at least the owning-user scope (RFC §6.3) — is submitted and drained back. Enqueue fails closed on an identity mismatch, an insufficient scope, or an invalid payload, so a misrouted or under-privileged control never reaches a run.
package main
import (
"fmt"
"log"
"github.com/hurtener/Harbor/sdk/identity"
"github.com/hurtener/Harbor/sdk/steering"
)
func main() {
reg := steering.NewRegistry()
run := identity.Quadruple{
Identity: identity.Identity{TenantID: "acme", UserID: "u-1", SessionID: "s-1"},
RunID: "run-1",
}
inbox, err := reg.Open(run)
if err != nil {
log.Fatalf("open inbox: %v", err)
}
defer func() { _ = reg.Retire(run) }()
// A bare CANCEL carries no payload. CallerScope/CallerTenant are what
// the Protocol edge derived from the submitting caller's JWT.
err = inbox.Enqueue(steering.ControlEvent{
Type: steering.ControlCancel,
Identity: run,
CallerScope: steering.ScopeOwnerUser,
CallerTenant: "acme",
})
if err != nil {
fmt.Println("enqueue:", err)
return
}
events, err := inbox.Drain()
if err != nil {
fmt.Println("drain:", err)
return
}
fmt.Println(events[0].Type)
}
Output: CANCEL
Index ¶
Examples ¶
Constants ¶
const ( // ControlInjectContext — INJECT_CONTEXT. ControlInjectContext = internal.ControlInjectContext // ControlRedirect — REDIRECT. ControlRedirect = internal.ControlRedirect // ControlCancel — CANCEL. ControlCancel = internal.ControlCancel // ControlPrioritize — PRIORITIZE. ControlPrioritize = internal.ControlPrioritize // ControlPause — PAUSE. ControlPause = internal.ControlPause // ControlResume — RESUME. ControlResume = internal.ControlResume // ControlApprove — APPROVE. ControlApprove = internal.ControlApprove // ControlReject — REJECT. ControlReject = internal.ControlReject // ControlUserMessage — USER_MESSAGE. ControlUserMessage = internal.ControlUserMessage )
ControlType values — the nine-entry steering taxonomy (RFC §6.3).
const ( // ScopeSessionUser — the session's own user. ScopeSessionUser = internal.ScopeSessionUser // ScopeOwnerUser — the owning user across their sessions. ScopeOwnerUser = internal.ScopeOwnerUser // ScopeAdmin — the elevated admin scope. ScopeAdmin = internal.ScopeAdmin )
Scope values.
const DefaultMaxSteps = internal.DefaultMaxSteps
DefaultMaxSteps is the run loop's default planner-step cap.
Variables ¶
var ( // ErrIdentityRequired — the run's identity quadruple is incomplete. ErrIdentityRequired = internal.ErrIdentityRequired // ErrUnknownControlType — the control type is not in the taxonomy. ErrUnknownControlType = internal.ErrUnknownControlType // ErrPayloadInvalid — the control payload failed validation. ErrPayloadInvalid = internal.ErrPayloadInvalid // ErrScopeMismatch — the caller scope is insufficient. ErrScopeMismatch = internal.ErrScopeMismatch // ErrInvalidScope — the caller scope is not a valid Scope. ErrInvalidScope = internal.ErrInvalidScope // ErrInboxNotFound — no inbox is open for the run. ErrInboxNotFound = internal.ErrInboxNotFound // ErrNoPlanner — RunSpec.Planner is nil. ErrNoPlanner = internal.ErrNoPlanner // ErrRunLoopMisconfigured — the RunLoop misses a mandatory dependency. ErrRunLoopMisconfigured = internal.ErrRunLoopMisconfigured // ErrNoOutstandingPause — the control targets a run with no pause. ErrNoOutstandingPause = internal.ErrNoOutstandingPause // ErrMaxStepsExceeded — the run loop hit its step cap. ErrMaxStepsExceeded = internal.ErrMaxStepsExceeded // ErrDecisionShapeUnsupported — the executor cannot dispatch the shape. ErrDecisionShapeUnsupported = internal.ErrDecisionShapeUnsupported )
Re-exported sentinel errors callers compare via errors.Is.
var ControlTypes = internal.ControlTypes
ControlTypes lists the taxonomy.
var IsValidControlType = internal.IsValidControlType
IsValidControlType reports whether t is in the taxonomy.
var IsValidScope = internal.IsValidScope
IsValidScope reports whether s is a valid Scope.
var NewRegistry = internal.NewRegistry
NewRegistry constructs a steering registry.
var RequiredScope = internal.RequiredScope
RequiredScope returns the minimum scope a control type demands.
var ValidatePayload = internal.ValidatePayload
ValidatePayload validates a control payload's shape budget.
var WithClock = internal.WithClock
WithClock injects a controllable clock into NewRegistry.
Functions ¶
This section is empty.
Types ¶
type AppliedControl ¶
type AppliedControl = internal.AppliedControl
AppliedControl records one applied control on the history.
type ControlEvent ¶
type ControlEvent = internal.ControlEvent
ControlEvent is one validated, scoped control instruction.
type ControlType ¶
type ControlType = internal.ControlType
ControlType names one steering control (the nine-entry taxonomy).
type RunLoop ¶
RunLoop is the shared planner-driving loop (one instance backs every spawned task; obtain it from the assembled Stack).
type ToolExecutor ¶
type ToolExecutor = internal.ToolExecutor
ToolExecutor dispatches the planner's non-Finish decisions.