Documentation
¶
Overview ¶
Package accessintentworker runs River v0.51.0 workers in runtime-api that reconcile durable access-control intents (grants, adapter enrollments, and post-deactivation agent cleanup) against Kubernetes and Platform API.
Index ¶
- Constants
- Variables
- func SpecDigest(spec json.RawMessage) string
- type AgentCleanupExecutor
- type AgentCleanupPlatformClient
- type AgentCleanupWorker
- type CSRProvider
- type CertificateRequestManager
- type CertificateRequestSpec
- type CertificateRequestState
- type EnrollmentPlatformClient
- type EnrollmentWorker
- type GrantPlatformClient
- type GrantProjector
- type GrantWorker
- type K8sCertificateRequestManager
- type K8sGrantProjector
- type ProjectedGrant
- type ReconcileAgentCleanupJob
- type ReconcileEnrollmentJob
- type ReconcileGrantJob
- type Runner
- type RunnerConfig
Constants ¶
const ( // QueueSchema is the River PostgreSQL schema shared with platform-api. QueueSchema = "access_intent_queue" // QueueAccessControl is the River queue for access-control reconciliation jobs. QueueAccessControl = "access_control" // KindReconcileGrant reconciles one grant incarnation. KindReconcileGrant = "reconcile_grant" // KindReconcileEnrollment reconciles one adapter enrollment operation. KindReconcileEnrollment = "reconcile_enrollment" // KindReconcileAgentCleanup reconciles post-deactivation agent cleanup. KindReconcileAgentCleanup = "reconcile_agent_cleanup" // GrantIDAnnotation links a projected MCPAccessGrant CR to its immutable platform grant incarnation ID. GrantIDAnnotation = "mcpruntime.org/grant-id" // DesiredRevisionAnnotation records the durable intent revision projected into a CR. DesiredRevisionAnnotation = "mcpruntime.org/desired-revision-id" // SpecDigestAnnotation records the canonical spec digest projected into a CR. SpecDigestAnnotation = "mcpruntime.org/spec-digest" )
Variables ¶
var ErrGrantOwnershipConflict = errors.New("grant CR owned by different incarnation")
ErrGrantOwnershipConflict indicates a Kubernetes CR belongs to a different grant incarnation.
Functions ¶
func SpecDigest ¶
func SpecDigest(spec json.RawMessage) string
SpecDigest returns a stable sha256 digest of a grant's JSON spec payload.
Types ¶
type AgentCleanupExecutor ¶
type AgentCleanupExecutor func(ctx context.Context, intent apikit.AgentCleanupIntent) error
AgentCleanupExecutor runs idempotent post-deactivation audit/cleanup follow-up without mutating authoritative session state (already revoked synchronously in Postgres).
type AgentCleanupPlatformClient ¶
type AgentCleanupPlatformClient interface {
ClaimAgentCleanupIntentFence(ctx context.Context, agentID, workerID string) (apikit.AgentCleanupFenceResponse, error)
RecordAgentCleanupIntentReceipt(ctx context.Context, agentID string, req apikit.AgentCleanupReceiptRequest) (apikit.AgentCleanupReceipt, error)
}
AgentCleanupPlatformClient is the Platform API surface used by AgentCleanupWorker.
type AgentCleanupWorker ¶
type AgentCleanupWorker struct {
river.WorkerDefaults[ReconcileAgentCleanupJob]
Platform AgentCleanupPlatformClient
Executor AgentCleanupExecutor
WorkerID string
}
AgentCleanupWorker reconciles post-deactivation agent cleanup follow-up jobs.
func (*AgentCleanupWorker) Work ¶
func (w *AgentCleanupWorker) Work(ctx context.Context, job *river.Job[ReconcileAgentCleanupJob]) error
type CSRProvider ¶
type CSRProvider func(ctx context.Context, intent apikit.EnrollmentIntent) (csrPEM string, duration time.Duration, err error)
CSRProvider resolves an in-flight PEM CSR for submission (kept out of Postgres).
type CertificateRequestManager ¶
type CertificateRequestManager interface {
GetCertificateRequest(ctx context.Context, namespace, name string) (*CertificateRequestState, bool, error)
CreateCertificateRequest(ctx context.Context, spec CertificateRequestSpec) (*CertificateRequestState, error)
}
CertificateRequestManager inspects and creates deterministic CertificateRequest objects.
type CertificateRequestSpec ¶
type CertificateRequestSpec struct {
Namespace string
Name string
SessionName string
OperationID string
IssuerName string
CSRPEM string
Duration time.Duration
}
CertificateRequestSpec describes the deterministic cert-manager CertificateRequest to submit.
type CertificateRequestState ¶
type CertificateRequestState struct {
Name string
UID string
Issued bool
Pending bool
Failed bool
FailureReason string
Serial string
Fingerprint string
}
CertificateRequestState is the observed status of a Kubernetes CertificateRequest.
type EnrollmentPlatformClient ¶
type EnrollmentPlatformClient interface {
ClaimEnrollmentIntentFence(ctx context.Context, opID, workerID string) (apikit.EnrollmentIntentFenceResponse, error)
RecordEnrollmentIntentReceipt(ctx context.Context, opID string, req apikit.EnrollmentIntentReceiptRequest) (apikit.EnrollmentReceipt, error)
ActivateEnrollmentIntent(ctx context.Context, opID string, req apikit.EnrollmentIntentActivateRequest) (apikit.EnrollmentIntent, error)
}
EnrollmentPlatformClient is the Platform API surface used by EnrollmentWorker.
type EnrollmentWorker ¶
type EnrollmentWorker struct {
river.WorkerDefaults[ReconcileEnrollmentJob]
Platform EnrollmentPlatformClient
CRManager CertificateRequestManager
CSRProvider CSRProvider
ClusterIssuer string
WorkerID string
SnoozeDelay time.Duration
}
EnrollmentWorker reconciles durable adapter certificate enrollment operations.
func (*EnrollmentWorker) Work ¶
func (w *EnrollmentWorker) Work(ctx context.Context, job *river.Job[ReconcileEnrollmentJob]) error
type GrantPlatformClient ¶
type GrantPlatformClient interface {
ClaimGrantIntentFence(ctx context.Context, grantID, workerID string) (apikit.GrantIntentFenceResponse, error)
GetGrantIntent(ctx context.Context, grantID string) (apikit.GrantIntent, bool, error)
RecordGrantIntentReceipt(ctx context.Context, grantID string, req apikit.GrantIntentReceiptRequest) (apikit.GrantReceipt, error)
}
GrantPlatformClient is the Platform API surface used by GrantWorker.
type GrantProjector ¶
type GrantProjector interface {
ApplyGrant(ctx context.Context, intent apikit.GrantIntent) (ProjectedGrant, error)
DeleteGrantByUID(ctx context.Context, namespace, name, expectedUID, expectedGrantID string) (bool, error)
}
GrantProjector projects durable grant intents onto Kubernetes MCPAccessGrant CRs.
type GrantWorker ¶
type GrantWorker struct {
river.WorkerDefaults[ReconcileGrantJob]
Platform GrantPlatformClient
Projector GrantProjector
WorkerID string
}
GrantWorker reconciles durable grant intents onto Kubernetes MCPAccessGrant resources.
func (*GrantWorker) Work ¶
func (w *GrantWorker) Work(ctx context.Context, job *river.Job[ReconcileGrantJob]) error
type K8sCertificateRequestManager ¶
K8sCertificateRequestManager manages deterministic cert-manager CertificateRequests.
func (*K8sCertificateRequestManager) CreateCertificateRequest ¶
func (m *K8sCertificateRequestManager) CreateCertificateRequest(ctx context.Context, spec CertificateRequestSpec) (*CertificateRequestState, error)
func (*K8sCertificateRequestManager) GetCertificateRequest ¶
func (m *K8sCertificateRequestManager) GetCertificateRequest(ctx context.Context, namespace, name string) (*CertificateRequestState, bool, error)
type K8sGrantProjector ¶
K8sGrantProjector applies and UID-conditionally deletes MCPAccessGrant CRs via dynamic.Interface.
func (*K8sGrantProjector) ApplyGrant ¶
func (p *K8sGrantProjector) ApplyGrant(ctx context.Context, intent apikit.GrantIntent) (ProjectedGrant, error)
func (*K8sGrantProjector) DeleteGrantByUID ¶
type ProjectedGrant ¶
ProjectedGrant is the Kubernetes identity metadata observed after applying an MCPAccessGrant CR.
type ReconcileAgentCleanupJob ¶
type ReconcileAgentCleanupJob struct {
AgentID string `json:"agentId"`
RevisionID string `json:"revisionId"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
}
ReconcileAgentCleanupJob matches platform-api's reconcile_agent_cleanup River job payload.
func (ReconcileAgentCleanupJob) Kind ¶
func (ReconcileAgentCleanupJob) Kind() string
type ReconcileEnrollmentJob ¶
type ReconcileEnrollmentJob struct {
OperationID string `json:"operationId"`
RevisionID string `json:"revisionId"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
}
ReconcileEnrollmentJob matches platform-api's reconcile_enrollment River job payload.
func (ReconcileEnrollmentJob) Kind ¶
func (ReconcileEnrollmentJob) Kind() string
type ReconcileGrantJob ¶
type ReconcileGrantJob struct {
GrantID string `json:"grantId"`
RevisionID string `json:"revisionId"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
}
ReconcileGrantJob matches platform-api's reconcile_grant River job payload.
func (ReconcileGrantJob) Kind ¶
func (ReconcileGrantJob) Kind() string
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner owns the River pgxv5 client and worker lifecycle for access_control jobs.
type RunnerConfig ¶
type RunnerConfig struct {
PostgresDSN string
PlatformClient *platformapi.Client
DynamicClient dynamic.Interface
ClusterIssuer string
WorkerID string
MaxWorkers int
CSRProvider CSRProvider
CleanupExec AgentCleanupExecutor
}
RunnerConfig configures the opt-in runtime-api River worker pool for access intents.