Documentation
¶
Overview ¶
Package batch owns the execution-neutral, bounded exact-set contract for update-many and delete-many. It deliberately separates the sentinel capture query from every write: an executor cannot obtain write statements until it has proved that the complete authorized set fits the configured limit.
Index ¶
- type AuthorizationColumn
- type AuthorizedRow
- type Binding
- type Cardinality
- type Error
- type ErrorCode
- type FactSpec
- type FieldGrant
- type Prepared
- func (prepared Prepared) Count() int64
- func (prepared Prepared) FactRequirement() mutationir.FactRequirement
- func (prepared Prepared) Operation() mutationir.Operation
- func (prepared Prepared) Statements() []Statement
- func (prepared Prepared) Verify(applied, after []mutationdecode.Row, factOrdinalBase uint32) (Verification, error)
- func (prepared Prepared) VerifyAuthorized(authorized []AuthorizedRow, applied, after []mutationdecode.Row, ...) (Verification, error)
- type Program
- func (program Program) CaptureStatement() Statement
- func (program Program) MaxRows() uint32
- func (program Program) ModelID() policyir.ModelID
- func (program Program) Operation() mutationir.Operation
- func (program Program) PrepareCaptured(rows []mutationdecode.Row) (Prepared, error)
- func (program Program) PrimaryKey() []policyir.FieldID
- func (program Program) Provider() policyir.Provider
- func (program Program) SemanticIndexed() bool
- func (program Program) SentinelRows() uint32
- func (program Program) TransactionRequirement() TransactionRequirement
- type ResultColumn
- type Role
- type RowVerification
- func (row RowVerification) After() (mutationdecode.Row, bool)
- func (row RowVerification) AuthoredChangedFields() []policyir.FieldID
- func (row RowVerification) Before() mutationdecode.Row
- func (row RowVerification) Ordinal() uint32
- func (row RowVerification) RequiredFieldAuthorizations() []mutationir.FieldAuthorization
- type Statement
- func (statement Statement) AuthorizationColumns() []AuthorizationColumn
- func (statement Statement) Bindings() []Binding
- func (statement Statement) Cardinality() Cardinality
- func (statement Statement) Columns() []ResultColumn
- func (statement Statement) ExpectedRows() uint32
- func (statement Statement) Role() Role
- func (statement Statement) SQL() string
- type TransactionRequirement
- type Verification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizationColumn ¶
type AuthorizationColumn struct {
// contains filtered or unexported fields
}
func (AuthorizationColumn) Alias ¶
func (column AuthorizationColumn) Alias() string
func (AuthorizationColumn) FieldID ¶
func (column AuthorizationColumn) FieldID() policyir.FieldID
type AuthorizedRow ¶
type AuthorizedRow struct {
// contains filtered or unexported fields
}
func NewAuthorizedRow ¶
func NewAuthorizedRow(before mutationdecode.Row, grants ...FieldGrant) (AuthorizedRow, error)
func (AuthorizedRow) Before ¶
func (row AuthorizedRow) Before() mutationdecode.Row
func (AuthorizedRow) Grants ¶
func (row AuthorizedRow) Grants() []FieldGrant
type Binding ¶
type Binding struct {
// contains filtered or unexported fields
}
Binding is one immutable positional argument. Batch programs intentionally contain static values only; captured identity values are encoded into the prepared program and never accepted from a second caller-controlled source.
type Cardinality ¶
type Cardinality uint8
const ( AtMostSentinelRows Cardinality = iota + 1 ExactlyCapturedRows )
type Error ¶
type ErrorCode ¶
type ErrorCode string
const ( CodeInput ErrorCode = "P4_BATCH_INPUT" CodeSchema ErrorCode = "P4_BATCH_SCHEMA" CodeProvider ErrorCode = "P4_BATCH_PROVIDER" CodeLimit ErrorCode = "P4_BATCH_LIMIT_EXCEEDED" CodeSet ErrorCode = "P4_BATCH_SET_MISMATCH" CodeIdentity ErrorCode = "P4_BATCH_IDENTITY_CHANGE" CodeForbidden ErrorCode = "P4_BATCH_FORBIDDEN" )
type FactSpec ¶
type FactSpec struct {
// contains filtered or unexported fields
}
FactSpec is the exact runtime seam for one ordered fact. Event and causation IDs remain runtime-owned; the batch kernel fixes action, images, and ordinal.
func (FactSpec) Action ¶
func (fact FactSpec) Action() mutationir.FactAction
func (FactSpec) Before ¶
func (fact FactSpec) Before() mutationdecode.Row
type FieldGrant ¶
type FieldGrant struct {
// contains filtered or unexported fields
}
FieldGrant is one SQL-evaluated authorization decision from the locked pre-image. Callers cannot substitute a condition or a post-write value here; an executor must decode the AuthorizationColumns emitted by the prepared AuthorizePreImage statement.
func NewFieldGrant ¶
func NewFieldGrant(field policyir.FieldID, granted bool) (FieldGrant, error)
func (FieldGrant) FieldID ¶
func (grant FieldGrant) FieldID() policyir.FieldID
func (FieldGrant) Granted ¶
func (grant FieldGrant) Granted() bool
type Prepared ¶
type Prepared struct {
// contains filtered or unexported fields
}
func (Prepared) FactRequirement ¶
func (prepared Prepared) FactRequirement() mutationir.FactRequirement
func (Prepared) Operation ¶
func (prepared Prepared) Operation() mutationir.Operation
func (Prepared) Statements ¶
func (Prepared) Verify ¶
func (prepared Prepared) Verify(applied, after []mutationdecode.Row, factOrdinalBase uint32) (Verification, error)
Verify consumes provider-decoded complete images only after every prepared statement met its exact cardinality. It verifies set equality again by primary identity, reorders results to capture order, computes truthful diffs, and allocates one fact specification per captured row.
func (Prepared) VerifyAuthorized ¶
func (prepared Prepared) VerifyAuthorized(authorized []AuthorizedRow, applied, after []mutationdecode.Row, factOrdinalBase uint32) (Verification, error)
VerifyAuthorized consumes the SQL-evaluated grants captured from every AuthorizePreImage statement. The locked rows are the before side of the exact logical diff. A false or missing grant matters only when that exact diff says the corresponding caller-authored field actually changed.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program contains only the capture phase. PrepareCaptured is the sole bridge to write SQL and enforces the +1 sentinel before producing any statement.
func Render ¶
func Render(plan mutationir.Plan, registry *schema.Registry, provider policyir.Provider, capabilities policysql.CapabilityProof) (Program, error)
Render creates the only statement that may run before the batch bound is known. The capture uses the planner's complete action constraint, declared primary-key order, and a MaxRows+1 sentinel. It is SQL-only and performs no evaluation in Go.
func (Program) CaptureStatement ¶
func (Program) Operation ¶
func (program Program) Operation() mutationir.Operation
func (Program) PrepareCaptured ¶
func (program Program) PrepareCaptured(rows []mutationdecode.Row) (Prepared, error)
PrepareCaptured is intentionally a value-receiving phase boundary. If the capture contains the +1 sentinel it returns LIMIT_EXCEEDED and no Prepared value, so no caller can obtain a truncated write program.
func (Program) PrimaryKey ¶
func (Program) SemanticIndexed ¶ added in v0.3.0
SemanticIndexed carries the plan's registry-derived decision that a write to this model must be recorded for semantic re-embedding.
func (Program) SentinelRows ¶
func (Program) TransactionRequirement ¶
func (program Program) TransactionRequirement() TransactionRequirement
type ResultColumn ¶
type ResultColumn struct {
// contains filtered or unexported fields
}
func (ResultColumn) Alias ¶
func (column ResultColumn) Alias() string
func (ResultColumn) FieldID ¶
func (column ResultColumn) FieldID() policyir.FieldID
type RowVerification ¶
type RowVerification struct {
// contains filtered or unexported fields
}
func (RowVerification) After ¶
func (row RowVerification) After() (mutationdecode.Row, bool)
func (RowVerification) AuthoredChangedFields ¶
func (row RowVerification) AuthoredChangedFields() []policyir.FieldID
func (RowVerification) Before ¶
func (row RowVerification) Before() mutationdecode.Row
func (RowVerification) Ordinal ¶
func (row RowVerification) Ordinal() uint32
func (RowVerification) RequiredFieldAuthorizations ¶
func (row RowVerification) RequiredFieldAuthorizations() []mutationir.FieldAuthorization
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
func (Statement) AuthorizationColumns ¶
func (statement Statement) AuthorizationColumns() []AuthorizationColumn
func (Statement) Cardinality ¶
func (statement Statement) Cardinality() Cardinality
func (Statement) Columns ¶
func (statement Statement) Columns() []ResultColumn
func (Statement) ExpectedRows ¶
type TransactionRequirement ¶
type TransactionRequirement uint8
const ( PostgreSQLTransaction TransactionRequirement = iota + 1 // SQLiteImmediateTransaction requires write intent before Capture executes. // That is what stabilizes the captured set on SQLite; a deferred transaction // is not an implementation of this contract. SQLiteImmediateTransaction )
type Verification ¶
type Verification struct {
// contains filtered or unexported fields
}
func (Verification) Count ¶
func (verification Verification) Count() int64
func (Verification) Facts ¶
func (verification Verification) Facts() []FactSpec
func (Verification) Rows ¶
func (verification Verification) Rows() []RowVerification