Documentation
¶
Overview ¶
Package capability owns Fort's closed capability catalog, strict plan contract, safe inventory projection, and deterministic placement solver.
It is deliberately pure core code: discovery and execution adapters live under exec, while this package makes no runtime or model calls.
Index ¶
- Constants
- func DirectionDigest(direction string) (string, error)
- func InputContractRevision(contract InputContract) (string, error)
- func OpaqueRevision(key []byte, domain string, value any) (string, error)
- func PlanRevision(identity PlanIdentity) (string, error)
- func SnapshotRevision(snapshot Snapshot) (string, error)
- func TextOnlySeatID(profileID, machineID, requestedModel string) string
- type Alternative
- type AttemptPolicy
- type BindingDefinition
- type BindingScope
- type CandidateReady
- type CandidateSet
- type CandidateSetup
- type CapabilityDefinition
- type Catalog
- func (c Catalog) BindingPredicateTemplates(profileID, bindingID string, capabilities []string) ([]PredicateTemplate, bool)
- func (c Catalog) LogicalPredicateTemplates(capabilityID string) ([]PredicateTemplate, bool)
- func (c Catalog) MapLegacyProfile(agent, label string) (string, bool)
- func (c Catalog) ProfilePredicateTemplates(profileID string) ([]PredicateTemplate, bool)
- func (c Catalog) RuntimeSelection(id string) (agent, model string, ok bool)
- type Deficit
- type ExecutionBindingOffer
- type Handoff
- type HypotheticalMappingEntry
- type IngressConstraints
- type InputContract
- type Instruction
- type InstructionBundle
- type InstructionBundleRef
- type InstructionStep
- type LogicalOffer
- type MachineInventory
- type MachineState
- type MappingEntry
- type NodeInventory
- type OfferState
- type Option
- type Placement
- type PlacementProof
- type Plan
- type PlanIdentity
- type PlanSource
- type Predicate
- type PredicateResolution
- type PredicateState
- type PredicateTemplate
- type ProfileDefinition
- type ProfileOffer
- type ProfileSelection
- type Reason
- type RecheckRequest
- type RefreshMode
- type RelevantMachine
- type RelevantProjection
- type RelevantScope
- type SelectionKind
- type SetupAlternative
- type Snapshot
- type SolveResult
- type SolveState
- type Stage
- type TextOnlyOptionOffer
Constants ¶
const ( ProtocolVersion = 3 CatalogVersion = 3 ProfileMappingVersion = 4 )
const ( MaxDirectionBytes = 65_536 MaxGeneratedPlanBytes = 131_072 MaxStageOutputBytes = 262_144 MaxHandoffReservedBytes = 1 << 20 )
Variables ¶
This section is empty.
Functions ¶
func DirectionDigest ¶
DirectionDigest validates and hashes the exact original UTF-8 bytes without Unicode normalization.
func InputContractRevision ¶
func InputContractRevision(contract InputContract) (string, error)
func OpaqueRevision ¶
OpaqueRevision derives one node-local proof from stable, non-secret invocation semantics. Callers must exclude paths, token bytes/expiry, raw probe output, and timestamps before calling.
func PlanRevision ¶
func PlanRevision(identity PlanIdentity) (string, error)
PlanRevision binds immutable plan semantics using length-delimited canonical fields. Inventory and placement facts are intentionally not inputs.
func SnapshotRevision ¶
SnapshotRevision hashes the timestamp-free, secret-free normalized solver projection.
func TextOnlySeatID ¶ added in v1.0.4
TextOnlySeatID binds a selectable seat to one exact profile, machine, and requested model. Callers cannot provide an alternate identity.
Types ¶
type Alternative ¶
type Alternative struct {
Placement Placement `json:"placement"`
Mapping []MappingEntry `json:"mapping"`
Handoffs []Handoff `json:"handoffs"`
}
type AttemptPolicy ¶
type BindingDefinition ¶
type BindingDefinition struct {
ID string `json:"id"`
Agent string `json:"agent"`
RuntimeContract string `json:"runtime_contract"`
CapabilityIDs []string `json:"capabilities"`
CapabilityAdapters []string `json:"logical_adapters"`
}
BindingDefinition is one closed, tested stage runtime composition.
type BindingScope ¶
type CandidateReady ¶
type CandidateReady struct {
Machine string `json:"machine"`
Profile string `json:"profile"`
Binding string `json:"binding"`
ProfileBindingRevision string `json:"profile_binding_revision"`
CapabilityBindingRevisions map[string]string `json:"capability_binding_revisions"`
ExecutionBindingRevision string `json:"execution_binding_revision"`
}
type CandidateSet ¶
type CandidateSet struct {
StageID string `json:"stage_id"`
Ready []CandidateReady `json:"ready"`
Setup []CandidateSetup `json:"setup"`
}
type CandidateSetup ¶
type CapabilityDefinition ¶
CapabilityDefinition is one logical capability and its only v1 adapter.
type Catalog ¶
type Catalog struct {
Version int `json:"version"`
ProfileMappingVersion int `json:"profile_mapping_version"`
Profiles []ProfileDefinition `json:"profiles"`
Capabilities []CapabilityDefinition `json:"capabilities"`
Bindings []BindingDefinition `json:"bindings"`
}
Catalog is the immutable input to validation and placement.
func CatalogV2 ¶
func CatalogV2() Catalog
CatalogV2 is the retained source-compatible constructor for the current closed catalog. Its Version field is authoritative on the wire.
func (Catalog) BindingPredicateTemplates ¶
func (c Catalog) BindingPredicateTemplates(profileID, bindingID string, capabilities []string) ([]PredicateTemplate, bool)
BindingPredicateTemplates returns the intrinsic graph for one exact profile/binding composition.
func (Catalog) LogicalPredicateTemplates ¶
func (c Catalog) LogicalPredicateTemplates(capabilityID string) ([]PredicateTemplate, bool)
LogicalPredicateTemplates returns the exact graph for a closed capability.
func (Catalog) MapLegacyProfile ¶
MapLegacyProfile maps only a cataloged agent/label pair. Display names are intentionally not accepted as provider identities.
func (Catalog) ProfilePredicateTemplates ¶
func (c Catalog) ProfilePredicateTemplates(profileID string) ([]PredicateTemplate, bool)
ProfilePredicateTemplates returns a defensive copy of the exact predicate graph for a closed profile ID.
func (Catalog) RuntimeSelection ¶
RuntimeSelection resolves one closed execution profile into the exact provider key and provider-native model selector carried to the runtime. The profile ID remains the authoritative identity; these fields are derived execution data, not another lookup surface.
type Deficit ¶
type Deficit struct {
DeficitID string `json:"deficit_id"`
Kind string `json:"kind"`
ID string `json:"id"`
PredicateID string `json:"predicate_id"`
Machine string `json:"machine"`
PredicateState PredicateState `json:"predicate_state"`
Reason Reason `json:"reason"`
RemedyEffectID string `json:"remedy_effect_id"`
PostconditionID string `json:"postcondition_id"`
}
type ExecutionBindingOffer ¶
type IngressConstraints ¶
type IngressConstraints struct {
PermittedProfiles []string `json:"permitted_profiles"`
PlannerProfileOverride string `json:"planner_profile_override"`
PlannerMachinePin string `json:"planner_machine_pin"`
SubstantiveMachinePin string `json:"substantive_machine_pin"`
DeliveryMode string `json:"delivery_mode"`
SignoffRequired bool `json:"signoff_required"`
}
type InputContract ¶
type InputContract struct {
RunID string `json:"run_id"`
PlanID string `json:"plan_id"`
PlanRevision string `json:"plan_revision"`
ChoiceRevision string `json:"choice_revision"`
SourceStageID string `json:"source_stage_id"`
ConsumerStageID string `json:"consumer_stage_id"`
SourceMachine string `json:"source_machine"`
TargetMachine string `json:"target_machine"`
Output string `json:"output"`
Format string `json:"format"`
MaxBytes int `json:"max_bytes"`
}
type Instruction ¶
type Instruction struct {
ID string `json:"id"`
Version int `json:"version"`
OperationID string `json:"operation_id"`
TemplateID string `json:"template_id"`
TemplateVersion int `json:"template_version"`
Target string `json:"target"`
Covers []string `json:"covers"`
RemedyEffectID string `json:"remedy_effect_id"`
PostconditionID string `json:"postcondition_id"`
EffectSummary string `json:"effect_summary"`
Steps []InstructionStep `json:"steps"`
}
type InstructionBundle ¶
type InstructionBundle struct {
ID string `json:"id"`
Version int `json:"version"`
EffectSummary string `json:"effect_summary"`
Instructions []Instruction `json:"instructions"`
}
type InstructionBundleRef ¶
type InstructionStep ¶
type LogicalOffer ¶
type MachineInventory ¶
type MachineInventory struct {
Name string `json:"name"`
Local bool `json:"local"`
RegistryRank int `json:"registry_rank"`
Reachable bool `json:"reachable"`
ProtocolVersion int `json:"protocol_version"`
CatalogVersion int `json:"catalog_version"`
ProfileMappingVersion int `json:"profile_mapping_version"`
State MachineState `json:"state"`
Reason Reason `json:"reason"`
ObservedAt time.Time `json:"observed_at"`
Profiles []ProfileOffer `json:"profiles"`
Offers []LogicalOffer `json:"offers"`
Bindings []ExecutionBindingOffer `json:"bindings"`
TextOnlyOptions []TextOnlyOptionOffer `json:"text_only_options"`
}
type MachineState ¶
type MachineState string
const ( MachineReady MachineState = "ready" MachinePartial MachineState = "partial" MachineUnknown MachineState = "unknown" )
type MappingEntry ¶
type MappingEntry struct {
StageID string `json:"stage_id"`
Machine string `json:"machine"`
Profile string `json:"profile"`
Binding string `json:"binding"`
ProfileBindingRevision string `json:"profile_binding_revision"`
CapabilityBindingRevisions map[string]string `json:"capability_binding_revisions"`
ExecutionBindingRevision string `json:"execution_binding_revision"`
}
type NodeInventory ¶
type NodeInventory struct {
ProtocolVersion int `json:"protocol_version"`
CatalogVersion int `json:"catalog_version"`
ProfileMappingVersion int `json:"profile_mapping_version"`
NodeID string `json:"node_id"`
ObservedAt time.Time `json:"observed_at"`
State MachineState `json:"state"`
Reason Reason `json:"reason"`
Profiles []ProfileOffer `json:"profiles"`
Offers []LogicalOffer `json:"offers"`
Bindings []ExecutionBindingOffer `json:"bindings"`
TextOnlyOptions []TextOnlyOptionOffer `json:"text_only_options"`
}
NodeInventory is the node-owned mesh payload. Public machine naming, local ownership, registry rank, reachability, and receipt freshness are assigned only by the coordinator.
type OfferState ¶
type OfferState string
OfferState is the closed public state of a profile, logical capability, or execution binding.
const ( OfferReady OfferState = "ready" OfferSetupRequired OfferState = "setup_required" OfferUnknown OfferState = "unknown" )
type Option ¶
type Option struct {
ID string `json:"id"`
Role string `json:"role"`
Label string `json:"label"`
Profile string `json:"profile,omitempty"`
Machine string `json:"machine,omitempty"`
ProfileBindingRevision string `json:"profile_binding_revision,omitempty"`
ExecutionBindingRevision string `json:"execution_binding_revision,omitempty"`
Placement Placement `json:"placement,omitempty"`
Mapping []MappingEntry `json:"mapping,omitempty"`
Handoffs []Handoff `json:"handoffs,omitempty"`
Mode string `json:"mode,omitempty"`
Deficits []Deficit `json:"deficits,omitempty"`
InstructionBundleRef *InstructionBundleRef `json:"instruction_bundle_ref,omitempty"`
HypotheticalMapping []HypotheticalMappingEntry `json:"hypothetical_mapping,omitempty"`
EffectSummary string `json:"effect_summary,omitempty"`
}
type PlacementProof ¶
type PlacementProof struct {
RelevantProjection RelevantProjection `json:"relevant_projection"`
RelevantRevision string `json:"relevant_revision"`
CandidateSets []CandidateSet `json:"candidate_sets"`
ReadyAlternatives []Alternative `json:"ready_alternatives"`
SetupAlternatives []SetupAlternative `json:"setup_alternatives"`
InstructionBundles []InstructionBundle `json:"instruction_bundles"`
Options []Option `json:"options"`
ChoiceRevision string `json:"choice_revision"`
}
func BuildPlacementProof ¶
func BuildPlacementProof(planRevision string, plan Plan, snapshot Snapshot, result SolveResult, pin, decisionID string, decisionVersion int) (PlacementProof, error)
BuildPlacementProof freezes the timestamp-free candidate, alternative, instruction, and semantic option projection used by a placement decision.
type Plan ¶
type Plan struct {
Stages []Stage `json:"stages"`
}
func DecodeGeneratedPlan ¶
DecodeGeneratedPlan strictly decodes, validates, and normalizes the one model-produced plan object. It supplies the immutable one-attempt stage policy; the model cannot choose execution retry or deadline behavior.
type PlanIdentity ¶
type PlanIdentity struct {
PlanID string
RunID string
Source PlanSource
DirectionDigest string
Constraints IngressConstraints
Plan Plan
CatalogVersion int
ProfileMappingVersion int
}
type PlanSource ¶
type Predicate ¶
type Predicate struct {
ID string `json:"id"`
Resolution PredicateResolution `json:"resolution"`
State PredicateState `json:"state"`
Reason Reason `json:"reason"`
DependsOn []string `json:"depends_on"`
RemedyEffectIDs []string `json:"remedy_effect_ids"`
}
Predicate is one complete, public, non-secret readiness predicate.
type PredicateResolution ¶
type PredicateResolution string
const ( ResolutionProbe PredicateResolution = "probe" ResolutionDerived PredicateResolution = "derived" )
type PredicateState ¶
type PredicateState string
const ( PredicateSatisfied PredicateState = "satisfied" PredicateUnsatisfied PredicateState = "unsatisfied" PredicateBlocked PredicateState = "blocked" )
type PredicateTemplate ¶
type PredicateTemplate struct {
ID string `json:"id"`
Resolution PredicateResolution `json:"resolution"`
DependsOn []string `json:"depends_on"`
RemedyEffectIDs []string `json:"remedy_effect_ids"`
}
PredicateTemplate is the immutable catalog portion of a predicate row. A node probe supplies only state/reason; it cannot alter dependencies or remedy semantics.
type ProfileDefinition ¶
type ProfileDefinition struct {
ID string `json:"id"`
Agent string `json:"agent"`
Adapter string `json:"adapter"`
Selection ProfileSelection `json:"selection"`
DisplayName string `json:"display_name"`
// contains filtered or unexported fields
}
ProfileDefinition is one immutable execution-profile catalog row.
func (ProfileDefinition) RequiresResolvedModel ¶ added in v1.0.4
func (p ProfileDefinition) RequiresResolvedModel() bool
RequiresResolvedModel reports whether the provider's ambient configuration must be resolved to an exact selector before this profile can be Ready.
type ProfileOffer ¶
type ProfileOffer struct {
ID string `json:"id"`
Agent string `json:"agent"`
Adapter string `json:"adapter"`
ResolvedModel string `json:"resolved_model,omitempty"`
State OfferState `json:"state"`
BindingRevision string `json:"binding_revision"`
Reason Reason `json:"reason"`
Predicates []Predicate `json:"predicates"`
}
type ProfileSelection ¶
type ProfileSelection struct {
Kind SelectionKind `json:"kind"`
ModelID string `json:"model_id,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
}
ProfileSelection contains only provider-native selection data.
type Reason ¶
type Reason string
Reason is a safe public reason code. It never includes probe output.
const ( ReasonAbsent Reason = "absent" ReasonAuthRequired Reason = "auth_required" ReasonCancellationUnconfirmed Reason = "cancellation_unconfirmed" ReasonCapabilityDrift Reason = "capability_drift" ReasonCommandContractChanged Reason = "command_contract_changed" ReasonDispatchStateUnknown Reason = "dispatch_state_unknown" ReasonHandoffLimitExceeded Reason = "handoff_limit_exceeded" ReasonHandoffStateUnknown Reason = "handoff_state_unknown" ReasonIncompatibleVersion Reason = "incompatible_version" ReasonNoExecutionPlane Reason = "no_execution_plane" ReasonOldNode Reason = "old_node" ReasonOutputLimitExceeded Reason = "output_limit_exceeded" ReasonPlannerFailed Reason = "planner_failed" ReasonPlannerInvalidOutput Reason = "planner_invalid_output" ReasonPlannerTimedOut Reason = "planner_timed_out" ReasonPluginUnready Reason = "plugin_unready" ReasonProbeFailed Reason = "probe_failed" ReasonProbeTimedOut Reason = "probe_timed_out" ReasonProfileUnmapped Reason = "profile_unmapped" ReasonRuntimeFailed Reason = "runtime_failed" ReasonSetupNotAutomated Reason = "setup_not_automated" ReasonSolverLimitExceeded Reason = "solver_limit_exceeded" ReasonStale Reason = "stale" ReasonStaticDAGUnsupported Reason = "static_dag_unsupported" ReasonUnsupportedPlatform Reason = "unsupported_platform" )
func FirstReason ¶
FirstReason chooses the first closed reason in the normative total order.
type RecheckRequest ¶
type RecheckRequest struct {
ProtocolVersion int `json:"protocol_version"`
RequestID string `json:"request_id"`
Mode RefreshMode `json:"mode"`
MaxAgeSeconds int `json:"max_age_seconds"`
Adapters []string `json:"adapters"`
}
type RefreshMode ¶
type RefreshMode string
const ( RefreshPlanning RefreshMode = "planning" RefreshUserRecheck RefreshMode = "user_recheck" )
type RelevantMachine ¶
type RelevantMachine struct {
Name string `json:"name"`
Local bool `json:"local"`
RegistryRank int `json:"registry_rank"`
Reachable bool `json:"reachable"`
ProtocolVersion int `json:"protocol_version"`
CatalogVersion int `json:"catalog_version"`
ProfileMappingVersion int `json:"profile_mapping_version"`
State MachineState `json:"state"`
Reason Reason `json:"reason"`
Profiles []ProfileOffer `json:"profiles"`
Offers []LogicalOffer `json:"offers"`
Bindings []ExecutionBindingOffer `json:"bindings"`
}
type RelevantProjection ¶
type RelevantProjection struct {
CatalogVersion int `json:"catalog_version"`
ProfileMappingVersion int `json:"profile_mapping_version"`
LocalMachine string `json:"local_machine"`
Scope RelevantScope `json:"scope"`
Machines []RelevantMachine `json:"machines"`
}
func RelevantInventory ¶
func RelevantInventory(plan Plan, snapshot Snapshot) (RelevantProjection, string, error)
RelevantInventory projects only plan-affecting offers and excludes observations, URLs, and unrelated capabilities.
type RelevantScope ¶
type RelevantScope struct {
Profiles []string `json:"profiles"`
Capabilities []string `json:"capabilities"`
Bindings []BindingScope `json:"bindings"`
}
type SelectionKind ¶
type SelectionKind string
SelectionKind is the closed provider-selection strategy for a profile.
const ( SelectionConfiguredDefault SelectionKind = "configured_default" SelectionModel SelectionKind = "model" SelectionProviderModel SelectionKind = "provider_model" SelectionConfiguredAgent SelectionKind = "configured_agent" )
type SetupAlternative ¶
type SetupAlternative struct {
Mode string `json:"mode"`
Deficits []Deficit `json:"deficits"`
InstructionBundleRef InstructionBundleRef `json:"instruction_bundle_ref"`
HypotheticalMapping []HypotheticalMappingEntry `json:"hypothetical_mapping"`
EffectSummary string `json:"effect_summary"`
InstructionBundle InstructionBundle `json:"instruction_bundle"`
}
type Snapshot ¶
type Snapshot struct {
CatalogVersion int `json:"catalog_version"`
ProfileMappingVersion int `json:"profile_mapping_version"`
Revision string `json:"revision"`
ObservedAt time.Time `json:"observed_at"`
LocalMachine string `json:"local_machine"`
Machines []MachineInventory `json:"machines"`
}
func NormalizeSnapshot ¶
NormalizeSnapshot validates and orders a complete public snapshot. It never fills missing proof data or converts static machine claims into readiness.
type SolveResult ¶
type SolveResult struct {
State SolveState `json:"state"`
Reason Reason `json:"reason,omitempty"`
Placement Placement `json:"placement,omitempty"`
Mapping []MappingEntry `json:"mapping,omitempty"`
Handoffs []Handoff `json:"handoffs,omitempty"`
ReadyAlternatives []Alternative `json:"ready_alternatives"`
SetupAlternatives []SetupAlternative `json:"setup_alternatives"`
}
type SolveState ¶
type SolveState string
const ( SolveReady SolveState = "ready" SolveChoiceRequired SolveState = "choice_required" SolveBlocked SolveState = "blocked" )
type Stage ¶
type Stage struct {
ID string `json:"id"`
Order int `json:"order"`
Title string `json:"title"`
Prompt string `json:"prompt"`
Profile string `json:"profile"`
Requires []string `json:"requires"`
InputFrom []string `json:"input_from"`
Output string `json:"output"`
OutputFormat string `json:"output_format"`
MaxOutputBytes int `json:"max_output_bytes"`
AttemptPolicy AttemptPolicy `json:"attempt_policy"`
}
type TextOnlyOptionOffer ¶ added in v1.0.4
type TextOnlyOptionOffer struct {
OfferVersion int `json:"offer_version"`
MachineID string `json:"machine_id"`
SeatID string `json:"seat_id"`
AgentKey string `json:"agent_key"`
ProfileID string `json:"profile_id"`
RequestedModel string `json:"requested_model"`
ResolvedModel string `json:"resolved_model"`
AccountType string `json:"account_type"`
AccountPlan string `json:"account_plan"`
PolicyID string `json:"policy_id"`
PolicyRevision string `json:"policy_revision"`
RuntimeContract string `json:"runtime_contract"`
ReasoningEffort string `json:"reasoning_effort"`
ReasoningContext string `json:"reasoning_context"`
RequestTimeoutMillis int `json:"request_timeout_millis"`
DeveloperInstructionRevision string `json:"developer_instruction_revision"`
AdapterID string `json:"adapter_id"`
AdapterRevision string `json:"adapter_revision"`
CodexVersion string `json:"codex_version"`
CodexExecutableRevision string `json:"codex_executable_revision"`
CodexSchemaRevision string `json:"codex_schema_revision"`
ThreadMode string `json:"thread_mode"`
SandboxMode string `json:"sandbox_mode"`
ApprovalPolicy string `json:"approval_policy"`
WorkdirMode string `json:"workdir_mode"`
DynamicToolsMode string `json:"dynamic_tools_mode"`
MCPMode string `json:"mcp_mode"`
CommandPolicy string `json:"command_policy"`
FileReadPolicy string `json:"file_read_policy"`
IsolationRevision string `json:"isolation_revision"`
}
TextOnlyOptionOffer is the complete, immutable authority envelope for the Phase 1 primary-channel agent. It is deliberately separate from ordinary profile readiness: a profile cannot become selectable unless every pinned subscription and isolation property is present and valid.
func NormalizeTextOnlyOptionOffer ¶ added in v1.0.4
func NormalizeTextOnlyOptionOffer(offer TextOnlyOptionOffer, expectedMachine string) (TextOnlyOptionOffer, string, error)
NormalizeTextOnlyOptionOffer validates the closed Phase 1 authority contract and returns its canonical server-computed option ID.