Documentation
¶
Overview ¶
Package sqlstore owns SQL schema details for durable human requests.
Index ¶
- func SchemaStatements(dialect db.Dialect) ([]string, error)
- type DirectTaskAuthorizer
- func (a *DirectTaskAuthorizer) Management(ctx context.Context, exec policy.Execution, record requests.RequestRecord, ...) (requests.ManagementAuthorization, error)
- func (a *DirectTaskAuthorizer) Response(ctx context.Context, exec policy.Execution, record requests.RequestRecord, ...) (requests.ResponseAuthorization, error)
- func (a *DirectTaskAuthorizer) Submission(ctx context.Context, exec policy.Execution, cmd contract.SubmitRequest) (requests.SubmissionAuthorization, error)
- func (a *DirectTaskAuthorizer) Visibility(ctx context.Context, exec policy.Execution) (requests.VisibilityScope, error)
- type Store
- func (s *Store) Cancel(ctx context.Context, change requests.CancelCommit) (requests.RequestRecord, error)
- func (s *Store) CommitDecision(ctx context.Context, change requests.DecisionCommit) (contract.ResponseReceipt, error)
- func (s *Store) CommitDecisionInTx(ctx context.Context, tx *sql.Tx, change requests.DecisionCommit) (contract.ResponseReceipt, error)
- func (s *Store) Create(ctx context.Context, change requests.CreateCommit) (requests.RequestRecord, error)
- func (s *Store) CreateInTx(ctx context.Context, tx *sql.Tx, change requests.CreateCommit) (requests.RequestRecord, error)
- func (s *Store) DirectTaskNotificationRecipients(ctx context.Context, tenant contract.TenantID, site string, ...) ([]contract.PrincipalID, error)
- func (s *Store) ExpireDue(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
- func (s *Store) Get(ctx context.Context, tenant contract.TenantID, id contract.RequestID) (requests.RequestRecord, error)
- func (s *Store) History(ctx context.Context, scope requests.VisibilityScope, id contract.RequestID, ...) (contract.Page[contract.RequestHistoryEntry], error)
- func (s *Store) ListVisible(ctx context.Context, scope requests.VisibilityScope, ...) (contract.Page[requests.RequestRecord], error)
- func (s *Store) LookupResponseReceipt(ctx context.Context, identity requests.WriteIdentity) (contract.ResponseReceipt, bool, error)
- func (s *Store) MarkRead(ctx context.Context, scope requests.VisibilityScope, id contract.RequestID) error
- func (s *Store) MarkStale(ctx context.Context, tenant contract.TenantID, id contract.RequestID, ...) error
- func (s *Store) Reassign(ctx context.Context, change requests.ReassignCommit) (requests.RequestRecord, error)
- func (s *Store) Response(ctx context.Context, scope requests.VisibilityScope, ...) (requests.DecisionRecord, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SchemaStatements ¶
SchemaStatements returns additive request tables and indexes for a tenant database. Tenant identity is retained in each row even though each tenant has a separate database, so moving/querying records cannot silently erase the security boundary.
Types ¶
type DirectTaskAuthorizer ¶
type DirectTaskAuthorizer struct {
// contains filtered or unexported fields
}
DirectTaskAuthorizer implements the policy for direct, subject-free user tasks. It deliberately does not authorize governed approvals, role/group expansion, or subject-bound requests; those decisions belong to a domain policy provider.
func NewDirectTaskAuthorizer ¶
func NewDirectTaskAuthorizer(database *sql.DB, dialect db.QueryDialect) (*DirectTaskAuthorizer, error)
func (*DirectTaskAuthorizer) Management ¶
func (a *DirectTaskAuthorizer) Management(ctx context.Context, exec policy.Execution, record requests.RequestRecord, operation string, command *contract.ReassignRequest) (requests.ManagementAuthorization, error)
func (*DirectTaskAuthorizer) Response ¶
func (a *DirectTaskAuthorizer) Response(ctx context.Context, exec policy.Execution, record requests.RequestRecord, cmd contract.RespondRequest) (requests.ResponseAuthorization, error)
func (*DirectTaskAuthorizer) Submission ¶
func (a *DirectTaskAuthorizer) Submission(ctx context.Context, exec policy.Execution, cmd contract.SubmitRequest) (requests.SubmissionAuthorization, error)
func (*DirectTaskAuthorizer) Visibility ¶
func (a *DirectTaskAuthorizer) Visibility(ctx context.Context, exec policy.Execution) (requests.VisibilityScope, error)
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists request data in the tenant database. It is deliberately not an HTTP service: callers must authorize and project records before exposing them. Create commits the request, assignment snapshot, history, outbox events and retry receipt in one SQL transaction.
func (*Store) Cancel ¶
func (s *Store) Cancel(ctx context.Context, change requests.CancelCommit) (requests.RequestRecord, error)
Cancel atomically closes a pending request, stops outstanding assignments, appends history/events and stores the retry receipt. Policy authorization is evaluated by the service and fenced by the authorization epochs here.
func (*Store) CommitDecision ¶
func (s *Store) CommitDecision(ctx context.Context, change requests.DecisionCommit) (contract.ResponseReceipt, error)
CommitDecision durably records one authorized assignment response. It locks the tenant authorization epochs and request row, then updates the decision, quorum state, history, outbox and idempotency receipt in one transaction. The caller must re-evaluate actor eligibility and subject visibility before constructing this commit; the epochs make that check stable through commit.
func (*Store) CommitDecisionInTx ¶
func (s *Store) CommitDecisionInTx(ctx context.Context, tx *sql.Tx, change requests.DecisionCommit) (contract.ResponseReceipt, error)
CommitDecisionInTx performs the response using the transaction owned by a composition-layer unit of work. The caller is responsible for commit or rollback; no second connection is acquired by this method.
func (*Store) Create ¶
func (s *Store) Create(ctx context.Context, change requests.CreateCommit) (requests.RequestRecord, error)
Create atomically records a newly authorized submission. Authorization snapshots are supplied by the request service; this method validates their binding and makes every local durable effect commit or roll back together.
func (*Store) CreateInTx ¶
func (s *Store) CreateInTx(ctx context.Context, tx *sql.Tx, change requests.CreateCommit) (requests.RequestRecord, error)
CreateInTx appends the request, assignment snapshot, history, event outbox, and idempotency receipt to the caller's transaction. It deliberately leaves transaction ownership with the caller.
func (*Store) DirectTaskNotificationRecipients ¶
func (s *Store) DirectTaskNotificationRecipients(ctx context.Context, tenant contract.TenantID, site string, requestID contract.RequestID, eventType string) ([]contract.PrincipalID, error)
DirectTaskNotificationRecipients resolves only the small, current set of active direct-task participants. It returns identifiers, never request content; later notification delivery remains a recipient-scoped invalidation and the request API rechecks visibility when the client refetches.
func (*Store) ExpireDue ¶
func (s *Store) ExpireDue(ctx context.Context, tenant contract.TenantID, limit uint16) (uint16, error)
ExpireDue closes a bounded batch of requests whose deadline has passed. The database clock is sampled in the selection query and reused for every write so workers on differently skewed hosts agree with response/cancellation checks. Each terminal state, assignment cancellation, history record and outbox event is committed in one transaction.
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, tenant contract.TenantID, id contract.RequestID) (requests.RequestRecord, error)
Get loads the current durable record. Visibility and field authorization are intentionally enforced by the request service before projection.
func (*Store) History ¶
func (s *Store) History(ctx context.Context, scope requests.VisibilityScope, id contract.RequestID, page contract.PageRequest) (contract.Page[contract.RequestHistoryEntry], error)
History returns a stable sequence page only when the verified visibility scope contains the requester, a current assigned participant, or a manager. A missing and an unauthorized request both return NotFound.
func (*Store) ListVisible ¶
func (s *Store) ListVisible(ctx context.Context, scope requests.VisibilityScope, filter contract.RequestFilter) (contract.Page[requests.RequestRecord], error)
ListVisible returns a bounded keyset page. The cursor is bound to the tenant, actor, manager scope and every filter; SQL independently enforces row visibility on every page.
func (*Store) LookupResponseReceipt ¶
func (s *Store) LookupResponseReceipt(ctx context.Context, identity requests.WriteIdentity) (contract.ResponseReceipt, bool, error)
LookupResponseReceipt is the public request-service seam for resolving a same-command retry before checking the now-completed assignment again.
func (*Store) MarkRead ¶
func (s *Store) MarkRead(ctx context.Context, scope requests.VisibilityScope, id contract.RequestID) error
MarkRead stores a per-principal watermark. It deliberately does not change request state or emit a completion event. Visibility authorization is done by the service before this storage operation.
func (*Store) MarkStale ¶
func (s *Store) MarkStale(ctx context.Context, tenant contract.TenantID, id contract.RequestID, expected contract.Revision, observed contract.SubjectRef) error
MarkStale persists the terminal transition after the caller has observed a different live subject revision. It refuses to stale an unrelated or already terminal request and records no subject content in the event payload.
func (*Store) Reassign ¶
func (s *Store) Reassign(ctx context.Context, change requests.ReassignCommit) (requests.RequestRecord, error)
Reassign atomically transfers a pending assignment, records the immutable history entry, publishes invalidations and stores the retry receipt.
func (*Store) Response ¶
func (s *Store) Response(ctx context.Context, scope requests.VisibilityScope, requestID contract.RequestID, decisionID contract.DecisionID) (requests.DecisionRecord, error)
Response returns a stored decision only for a requester, current assigned participant or explicit manager. It deliberately leaves information schema validation and field-level projection to the authorized request service.