accessintentworker

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

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

View Source
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

View Source
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

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

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

type K8sCertificateRequestManager

type K8sCertificateRequestManager struct {
	Dynamic dynamic.Interface
}

K8sCertificateRequestManager manages deterministic cert-manager CertificateRequests.

func (*K8sCertificateRequestManager) CreateCertificateRequest

func (*K8sCertificateRequestManager) GetCertificateRequest

func (m *K8sCertificateRequestManager) GetCertificateRequest(ctx context.Context, namespace, name string) (*CertificateRequestState, bool, error)

type K8sGrantProjector

type K8sGrantProjector struct {
	Dynamic dynamic.Interface
}

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

func (p *K8sGrantProjector) DeleteGrantByUID(ctx context.Context, namespace, name, expectedUID, expectedGrantID string) (bool, error)

type ProjectedGrant

type ProjectedGrant struct {
	UID        string
	Generation int64
	SpecDigest string
}

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

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

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.

func Start

func Start(ctx context.Context, cfg RunnerConfig) (*Runner, error)

Start opens the pgxpool connection, registers all access intent workers on the access_control queue in schema access_intent_queue, and starts River.

func (*Runner) Stop

func (r *Runner) Stop(ctx context.Context) error

Stop gracefully drains in-flight access intent jobs and closes the pool.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL