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 ¶
- type AssignmentRecord
- type Authorizer
- type CancelCommit
- type Clock
- type CreateCommit
- type DecisionCommit
- type DecisionReceiptLookup
- type DecisionRecord
- type DecisionStore
- type DirectTaskProjector
- func (p DirectTaskProjector) History(ctx context.Context, exec policy.Execution, record RequestRecord, ...) (contract.RequestHistoryEntry, error)
- func (DirectTaskProjector) Request(_ context.Context, exec policy.Execution, record RequestRecord) (contract.RequestView, error)
- func (p DirectTaskProjector) Response(ctx context.Context, exec policy.Execution, record RequestRecord, ...) (contract.ResponseDetail, error)
- type IDSource
- type ManagementAuthorization
- type NoResponseSchemas
- type ParticipantProjector
- func (p ParticipantProjector) History(ctx context.Context, exec policy.Execution, record RequestRecord, ...) (contract.RequestHistoryEntry, error)
- func (p ParticipantProjector) Request(ctx context.Context, exec policy.Execution, record RequestRecord) (contract.RequestView, error)
- func (p ParticipantProjector) Response(ctx context.Context, exec policy.Execution, record RequestRecord, ...) (contract.ResponseDetail, error)
- type PreparedResponse
- type PreparedSubmission
- type Projector
- type ReassignCommit
- type RequestRecord
- type ResponseAuthorization
- type ResponseContext
- type ResponseSchemas
- type Service
- func (s *Service) Cancel(ctx context.Context, exec policy.Execution, id contract.RequestID, ...) (contract.RequestView, error)
- func (s *Service) ExpireDue(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
- func (s *Service) Get(ctx context.Context, exec policy.Execution, id contract.RequestID) (contract.RequestView, error)
- func (s *Service) History(ctx context.Context, exec policy.Execution, id contract.RequestID, ...) (contract.Page[contract.RequestHistoryEntry], error)
- func (s *Service) List(ctx context.Context, exec policy.Execution, filter contract.RequestFilter) (contract.Page[contract.RequestView], error)
- func (s *Service) MarkRead(ctx context.Context, exec policy.Execution, id contract.RequestID) error
- func (s *Service) PrepareResponse(ctx context.Context, exec policy.Execution, id contract.RequestID, ...) (*PreparedResponse, error)
- func (s *Service) PrepareSubmit(ctx context.Context, exec policy.Execution, cmd contract.SubmitRequest) (*PreparedSubmission, error)
- func (s *Service) PrepareWorkflowSubmit(ctx context.Context, exec policy.Execution, cmd contract.SubmitRequest, ...) (*PreparedSubmission, error)
- func (s *Service) Reassign(ctx context.Context, exec policy.Execution, id contract.RequestID, ...) (contract.RequestView, error)
- func (s *Service) Respond(ctx context.Context, exec policy.Execution, id contract.RequestID, ...) (contract.ResponseReceipt, error)
- func (s *Service) Response(ctx context.Context, exec policy.Execution, requestID contract.RequestID, ...) (contract.ResponseDetail, error)
- func (s *Service) Submit(ctx context.Context, exec policy.Execution, cmd contract.SubmitRequest) (contract.RequestView, error)
- type Store
- type SubmissionAuthorization
- type TransactionCreateStore
- type TransactionDecisionStore
- type VisibilityScope
- type WorkflowSubmissionAuthorizer
- type WriteIdentity
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 Authorizer ¶
type Authorizer interface {
Submission(context.Context, policy.Execution, contract.SubmitRequest) (SubmissionAuthorization, error)
Response(context.Context, policy.Execution, RequestRecord, contract.RespondRequest) (ResponseAuthorization, error)
Management(context.Context, policy.Execution, RequestRecord, string, *contract.ReassignRequest) (ManagementAuthorization, error)
Visibility(context.Context, policy.Execution) (VisibilityScope, error)
}
type CancelCommit ¶
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 (p DirectTaskProjector) History(ctx context.Context, exec policy.Execution, record RequestRecord, entry contract.RequestHistoryEntry) (contract.RequestHistoryEntry, error)
func (DirectTaskProjector) Request ¶
func (DirectTaskProjector) Request(_ context.Context, exec policy.Execution, record RequestRecord) (contract.RequestView, error)
func (DirectTaskProjector) Response ¶
func (p DirectTaskProjector) Response(ctx context.Context, exec policy.Execution, record RequestRecord, value DecisionRecord) (contract.ResponseDetail, error)
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 ¶
func (NoResponseSchemas) Validate ¶
func (NoResponseSchemas) Validate(context.Context, contract.SchemaRef, contract.InformationResponse) error
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 (p ParticipantProjector) History(ctx context.Context, exec policy.Execution, record RequestRecord, entry contract.RequestHistoryEntry) (contract.RequestHistoryEntry, error)
func (ParticipantProjector) Request ¶
func (p ParticipantProjector) Request(ctx context.Context, exec policy.Execution, record RequestRecord) (contract.RequestView, error)
func (ParticipantProjector) Response ¶
func (p ParticipantProjector) Response(ctx context.Context, exec policy.Execution, record RequestRecord, value DecisionRecord) (contract.ResponseDetail, error)
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 Projector ¶
type Projector interface {
Request(context.Context, policy.Execution, RequestRecord) (contract.RequestView, error)
History(context.Context, policy.Execution, RequestRecord, contract.RequestHistoryEntry) (contract.RequestHistoryEntry, error)
Response(context.Context, policy.Execution, RequestRecord, DecisionRecord) (contract.ResponseDetail, error)
}
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 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) PrepareResponse ¶
func (s *Service) PrepareResponse(ctx context.Context, exec policy.Execution, id contract.RequestID, cmd contract.RespondRequest) (*PreparedResponse, error)
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.
type Store ¶
type Store interface {
DecisionStore
Create(ctx context.Context, change CreateCommit) (RequestRecord, error)
ListVisible(ctx context.Context, scope VisibilityScope, filter contract.RequestFilter) (contract.Page[RequestRecord], error)
Reassign(ctx context.Context, change ReassignCommit) (RequestRecord, error)
Cancel(ctx context.Context, change CancelCommit) (RequestRecord, error)
History(ctx context.Context, scope VisibilityScope, id contract.RequestID, page contract.PageRequest) (contract.Page[contract.RequestHistoryEntry], error)
Response(ctx context.Context, scope VisibilityScope, request contract.RequestID, decision contract.DecisionID) (DecisionRecord, error)
MarkRead(ctx context.Context, scope VisibilityScope, id contract.RequestID) error
ExpireDue(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
MarkStale(ctx context.Context, tenant contract.TenantID, id contract.RequestID, expected contract.Revision, observed contract.SubjectRef) error
}
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
}