requests

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package requests owns durable human requests and assignments. These records are persistence models, not public wire DTOs; transports project them through current authorization before returning any response.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignmentRecord

type AssignmentRecord struct {
	ID                 contract.AssignmentID
	RequestID          contract.RequestID
	Principal          contract.PrincipalID
	OriginalTarget     contract.Assignee
	Stage              uint16
	Status             contract.AssignmentStatus
	AllowedResponses   []contract.ResponseKind
	MembershipRevision contract.Revision
}

type CancelCommit

type CancelCommit struct {
	Identity                   WriteIdentity
	RequestID                  contract.RequestID
	ExpectedRevision           contract.Revision
	ExpectedPolicyRevision     contract.Revision
	ExpectedMembershipRevision contract.Revision
	Reason                     string
	Events                     []contract.EventEnvelope
}

type Clock

type Clock interface{ Now() time.Time }

type CreateCommit

type CreateCommit struct {
	Identity                   WriteIdentity
	Request                    RequestRecord
	ExpectedPolicyRevision     contract.Revision
	ExpectedMembershipRevision contract.Revision
	ExpectedSubject            *contract.SubjectRef
	Assignments                []AssignmentRecord
	History                    contract.RequestHistoryEntry
	Events                     []contract.EventEnvelope
}

type DecisionCommit

type DecisionCommit struct {
	Request                    RequestRecord
	ExpectedRevision           contract.Revision
	Decision                   DecisionRecord
	Receipt                    contract.ResponseReceipt
	Identity                   WriteIdentity
	ExpectedSubject            *contract.SubjectRef
	ExpectedPolicyRevision     contract.Revision
	ExpectedMembershipRevision contract.Revision
	Events                     []contract.EventEnvelope
}

type DecisionReceiptLookup

type DecisionReceiptLookup interface {
	LookupResponseReceipt(context.Context, WriteIdentity) (contract.ResponseReceipt, bool, error)
}

DecisionReceiptLookup resolves a response retry before current assignment eligibility is evaluated. Implementations scope receipts by the complete authenticated write identity and reject reuse with a different digest.

type DecisionRecord

type DecisionRecord struct {
	Tenant       contract.TenantID
	ID           contract.DecisionID
	RequestID    contract.RequestID
	AssignmentID contract.AssignmentID
	Actor        contract.PrincipalID
	OnBehalfOf   contract.PrincipalID
	Response     contract.ResponseKind
	Comment      string
	Information  *contract.InformationResponse
	At           time.Time
}

type DecisionStore

type DecisionStore interface {
	Get(ctx context.Context, tenant contract.TenantID, id contract.RequestID) (RequestRecord, error)
	CommitDecision(ctx context.Context, change DecisionCommit) (contract.ResponseReceipt, error)
}

type DirectTaskProjector

type DirectTaskProjector struct{}

DirectTaskProjector exposes subject-free direct tasks only to the requester and the requester's own assignment. It is not suitable for governed or workflow-originated requests, which require a domain-owned projector.

func (DirectTaskProjector) History

func (DirectTaskProjector) Request

func (DirectTaskProjector) Response

type IDSource

type IDSource interface{ NewID() string }

type ManagementAuthorization

type ManagementAuthorization struct {
	PolicyRevision     contract.Revision
	MembershipRevision contract.Revision
	Replacement        *AssignmentRecord
}

type NoResponseSchemas

type NoResponseSchemas struct{}

NoResponseSchemas fails closed until a tenant/domain schema registry is assembled. DirectTaskAuthorizer rejects information requests before this adapter is reached.

func (NoResponseSchemas) Registered

type ParticipantProjector

type ParticipantProjector struct{}

ParticipantProjector combines the strict direct-task projection with the minimal subject-bound approval projection. Authorization is still performed by the service and domain policy before projection; this type only limits fields and participant history visible to the current requester/assignee.

func (ParticipantProjector) History

func (ParticipantProjector) Request

func (ParticipantProjector) Response

type PreparedResponse

type PreparedResponse struct {
	// contains filtered or unexported fields
}

PreparedResponse is an opaque result of response-time authorization. It binds the decision to the request revision, subject snapshot, actor and authorization epochs checked during preparation.

func (*PreparedResponse) CommitInTx

func (p *PreparedResponse) CommitInTx(ctx context.Context, tx *sql.Tx) (contract.ResponseReceipt, error)

CommitInTx records the response in the caller's transaction. The caller remains responsible for committing or rolling back that transaction.

func (*PreparedResponse) Context

func (p *PreparedResponse) Context() (ResponseContext, bool)

Context returns a copied immutable view of the request bound to this prepared response. Replays have no action context and must not execute work.

func (*PreparedResponse) ReplayReceipt

func (p *PreparedResponse) ReplayReceipt() (contract.ResponseReceipt, bool)

ReplayReceipt reports a previously committed result after the service has rechecked that the current execution can still see the request. Coordinators must return this receipt without executing any domain effect.

type PreparedSubmission

type PreparedSubmission struct {
	// contains filtered or unexported fields
}

PreparedSubmission is an opaque result of current request, subject, policy, membership and assignment authorization. CommitInTx atomically records the request and its assignment/history/outbox/idempotency rows.

func (*PreparedSubmission) CommitInTx

func (p *PreparedSubmission) CommitInTx(ctx context.Context, tx *sql.Tx) (RequestRecord, error)

CommitInTx appends the prepared request to a caller-owned transaction. The caller remains responsible for committing or rolling back the transaction.

type ReassignCommit

type ReassignCommit struct {
	Identity                   WriteIdentity
	RequestID                  contract.RequestID
	ExpectedRevision           contract.Revision
	ExpectedPolicyRevision     contract.Revision
	ExpectedMembershipRevision contract.Revision
	AssignmentID               contract.AssignmentID
	Replacement                AssignmentRecord
	Reason                     string
	Events                     []contract.EventEnvelope
}

type RequestRecord

type RequestRecord struct {
	Tenant              contract.TenantID
	ID                  contract.RequestID
	Revision            contract.Revision
	Kind                contract.RequestKind
	AssignmentMode      contract.AssignmentMode
	Status              contract.RequestStatus
	Requester           contract.PrincipalID
	Subject             *contract.SubjectRef
	SubjectDigest       string
	Title               string
	Message             string
	Source              *contract.RequestSource
	DueAt               *time.Time
	Outcome             *contract.RequestOutcome
	ResolvedAt          *time.Time
	Continuation        *contract.ContinuationView
	CreatedAt           time.Time
	UpdatedAt           time.Time
	PolicyID            string
	PolicyRevision      contract.Revision
	InformationSchema   *contract.SchemaRef
	SupersedesRequestID *contract.RequestID
	Assignments         []AssignmentRecord
}

type ResponseAuthorization

type ResponseAuthorization struct {
	PolicyRevision     contract.Revision
	MembershipRevision contract.Revision
	ExpectedSubject    *contract.SubjectRef
	// SubjectDigest is read from the live domain subject. A match is required
	// before recording the decision; local effects still revalidate it inside
	// their domain transaction, while external continuations must reconcile it.
	SubjectDigest string
}

type ResponseContext

type ResponseContext struct {
	Tenant        contract.TenantID
	RequestID     contract.RequestID
	Kind          contract.RequestKind
	PolicyID      string
	Subject       *contract.SubjectRef
	SubjectDigest string
}

ResponseContext is the server-authorized snapshot a composition layer may use to select a registered local domain action. It contains no caller-chosen command or transport identity.

type ResponseSchemas

type ResponseSchemas interface {
	Registered(context.Context, contract.SchemaRef) error
	Validate(context.Context, contract.SchemaRef, contract.InformationResponse) error
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(store Store, authorizer Authorizer, projector Projector, responseSchemas ResponseSchemas, clock Clock, ids IDSource) (*Service, error)

func (*Service) Cancel

func (*Service) ExpireDue

func (s *Service) ExpireDue(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)

func (*Service) Get

func (*Service) List

func (*Service) MarkRead

func (s *Service) MarkRead(ctx context.Context, exec policy.Execution, id contract.RequestID) error

func (*Service) PrepareResponse

PrepareResponse performs response-time authorization and creates an opaque, revision-bound decision. Composers call CommitInTx after starting their unit of work so a local domain mutation and this decision share one transaction.

func (*Service) PrepareSubmit

func (s *Service) PrepareSubmit(ctx context.Context, exec policy.Execution, cmd contract.SubmitRequest) (*PreparedSubmission, error)

PrepareSubmit performs the same policy and subject checks as Submit and returns an opaque commit that can be composed with a workflow wait in a caller-owned transaction. The authorization snapshot is rechecked by the SQL store inside that transaction.

func (*Service) PrepareWorkflowSubmit

func (s *Service) PrepareWorkflowSubmit(ctx context.Context, exec policy.Execution, cmd contract.SubmitRequest, source contract.RequestSource) (*PreparedSubmission, error)

PrepareWorkflowSubmit binds a request to a workflow instance and step. Source identity is supplied by the workflow runtime, never by the public request DTO, and participates in the idempotency digest.

func (*Service) Response

func (s *Service) Response(ctx context.Context, exec policy.Execution, requestID contract.RequestID, decisionID contract.DecisionID) (contract.ResponseDetail, error)

func (*Service) Submit

type SubmissionAuthorization

type SubmissionAuthorization struct {
	PolicyID           string
	PolicyRevision     contract.Revision
	MembershipRevision contract.Revision
	AssignmentMode     contract.AssignmentMode
	Assignments        []AssignmentRecord
	ExpectedSubject    *contract.SubjectRef
	SubjectDigest      string
}

type TransactionCreateStore

type TransactionCreateStore interface {
	CreateInTx(context.Context, *sql.Tx, CreateCommit) (RequestRecord, error)
}

TransactionCreateStore records an authorized request in a transaction owned by the caller. Implementations must not commit or roll back the transaction. Workflow human steps use this boundary to register their durable wait and request as one local unit of work.

type TransactionDecisionStore

type TransactionDecisionStore interface {
	CommitDecisionInTx(context.Context, *sql.Tx, DecisionCommit) (contract.ResponseReceipt, error)
}

TransactionDecisionStore persists a prepared response using a transaction owned by the caller. Implementations must neither commit nor roll it back.

type VisibilityScope

type VisibilityScope struct {
	Tenant       contract.TenantID
	Actor        contract.PrincipalID
	CanManageAll bool // derived by policy; never decoded from HTTP
}

type WorkflowSubmissionAuthorizer

type WorkflowSubmissionAuthorizer interface {
	WorkflowSubmission(context.Context, policy.Execution, contract.SubmitRequest, contract.RequestSource) (SubmissionAuthorization, error)
}

WorkflowSubmissionAuthorizer is an optional domain-owned policy boundary used only by PrepareWorkflowSubmit. A workflow request cannot fall back to the public user-submission policy because its verified actor is a service principal and its source is bound by the durable workflow executor.

type WriteIdentity

type WriteIdentity struct {
	Tenant         contract.TenantID
	Actor          contract.PrincipalID
	Operation      string
	IdempotencyKey contract.IdempotencyKey
	CommandDigest  string
}

Directories

Path Synopsis
Package sqlstore owns SQL schema details for durable human requests.
Package sqlstore owns SQL schema details for durable human requests.

Jump to

Keyboard shortcuts

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