143 lines
4.8 KiB
Go
143 lines
4.8 KiB
Go
package capability
|
|
|
|
import (
|
|
"git.cin.su/m/Assistant/contracts/identity"
|
|
"git.cin.su/m/Assistant/platform/ids"
|
|
)
|
|
|
|
type CapabilityID ids.ID
|
|
type CapabilityBindingID ids.ID
|
|
type CapabilityKind string
|
|
|
|
type BindingState string
|
|
type BindingProtocol string
|
|
|
|
// CandidateBindingMode controls how a release-scoped binding may be used.
|
|
// It is deliberately separate from a production BindingState.
|
|
type CandidateBindingMode string
|
|
type CandidateBindingStatus string
|
|
|
|
const (
|
|
BindingActive BindingState = "ACTIVE"
|
|
BindingRetired BindingState = "RETIRED"
|
|
|
|
CandidateBindingModeCandidate CandidateBindingMode = "CANDIDATE"
|
|
CandidateBindingModeShadow CandidateBindingMode = "SHADOW"
|
|
|
|
CandidateBindingActive CandidateBindingStatus = "ACTIVE"
|
|
CandidateBindingRevoked CandidateBindingStatus = "REVOKED"
|
|
|
|
ProtocolIdempotentReceiptV1 BindingProtocol = "IDEMPOTENT_RECEIPT_V1"
|
|
|
|
CapabilityKindReadEmail CapabilityKind = "READ_EMAIL"
|
|
CapabilityKindSendEmail CapabilityKind = "SEND_EMAIL"
|
|
CapabilityKindReadDatabase CapabilityKind = "READ_DATABASE"
|
|
CapabilityKindQueryLogs CapabilityKind = "QUERY_LOGS"
|
|
CapabilityKindInspectProject CapabilityKind = "INSPECT_PROJECT"
|
|
CapabilityKindModifyCode CapabilityKind = "MODIFY_CODE"
|
|
CapabilityKindRunTests CapabilityKind = "RUN_TESTS"
|
|
CapabilityKindWebResearch CapabilityKind = "WEB_RESEARCH"
|
|
CapabilityKindCognitiveReasoning CapabilityKind = "COGNITIVE_REASONING"
|
|
CapabilityKindScheduleReminder CapabilityKind = "SCHEDULE_REMINDER"
|
|
CapabilityKindVerifyFact CapabilityKind = "VERIFY_FACT"
|
|
CapabilityKindSpeechToText CapabilityKind = "SPEECH_TO_TEXT"
|
|
CapabilityKindImageUnderstanding CapabilityKind = "IMAGE_UNDERSTANDING"
|
|
CapabilityKindOCR CapabilityKind = "OCR"
|
|
CapabilityKindVideoUnderstanding CapabilityKind = "VIDEO_UNDERSTANDING"
|
|
CapabilityKindImageGeneration CapabilityKind = "IMAGE_GENERATION"
|
|
CapabilityKindVideoGeneration CapabilityKind = "VIDEO_GENERATION"
|
|
)
|
|
|
|
// Binding is Capability-owned correctness state. SecretRef is an opaque
|
|
// lookup name; it must never contain credential bytes.
|
|
type Binding struct {
|
|
ID CapabilityBindingID
|
|
CapabilityID CapabilityID
|
|
OwnerPrincipalID identity.PrincipalID
|
|
Revision int64
|
|
State BindingState
|
|
HTTPSOrigin string
|
|
DeliveryPath string
|
|
ReceiptPath string
|
|
Protocol BindingProtocol
|
|
SecretRef string
|
|
VerifiedAtUnixMillis int64
|
|
Health HealthState
|
|
}
|
|
|
|
// CandidateReleaseContext is supplied by a candidate runtime, not inferred
|
|
// from a host name or process-local state. It scopes dynamic capability
|
|
// resolution to one release slot and task.
|
|
type CandidateReleaseContext struct {
|
|
ReleaseSetID string
|
|
Slot string
|
|
TaskID string
|
|
TaskRevision int64
|
|
PrincipalID identity.PrincipalID
|
|
CapabilityID CapabilityID
|
|
ResourceScope string
|
|
Mode CandidateBindingMode
|
|
TargetKind string
|
|
TargetRef string
|
|
TargetDigest string
|
|
AuthorityGrantID string
|
|
}
|
|
|
|
// CandidateBinding is Capability-owned release-scoped state. TargetOrigin is
|
|
// intentionally distinct from Binding.HTTPSOrigin: a SHADOW target can be an
|
|
// internal candidate receiver and must never be promoted into the ACTIVE head.
|
|
type CandidateBinding struct {
|
|
ID CapabilityBindingID
|
|
Revision int64
|
|
BaseActiveBindingID CapabilityBindingID
|
|
BaseActiveBindingRevision int64
|
|
Context CandidateReleaseContext
|
|
TargetOrigin string
|
|
DeliveryPath string
|
|
ReceiptPath string
|
|
Protocol BindingProtocol
|
|
CreatedAtUnixMillis int64
|
|
ExpiresAtUnixMillis int64
|
|
Status CandidateBindingStatus
|
|
}
|
|
|
|
type CandidateBindingResolution struct {
|
|
Binding CandidateBinding
|
|
Mode CandidateBindingMode
|
|
Reason string
|
|
}
|
|
|
|
type HealthState string
|
|
|
|
const (
|
|
HealthUnknown HealthState = "UNKNOWN"
|
|
HealthAvailable HealthState = "AVAILABLE"
|
|
HealthDegraded HealthState = "DEGRADED"
|
|
HealthUnavailable HealthState = "UNAVAILABLE"
|
|
)
|
|
|
|
type HealthReason string
|
|
|
|
const (
|
|
ReasonCognitiveProvidersUnavailable HealthReason = "COGNITIVE_PROVIDERS_UNAVAILABLE"
|
|
ReasonNone HealthReason = "NONE"
|
|
)
|
|
|
|
type HealthSemanticVersion int
|
|
|
|
const (
|
|
HealthV1 HealthSemanticVersion = 1
|
|
HealthV2 HealthSemanticVersion = 2
|
|
)
|
|
|
|
// Health is the Capability owner's current, explicit statement about whether
|
|
// a capability can be used. It is not an authority grant.
|
|
type Health struct {
|
|
CapabilityID CapabilityID
|
|
State HealthState
|
|
Reason HealthReason
|
|
Revision int64
|
|
SemanticVersion HealthSemanticVersion
|
|
ObservedAtUnixMillis *int64
|
|
}
|