Documentation
¶
Overview ¶
Package kernel implements the single operation kernel (architecture specification invariants 2–3, KERNEL-001..007): every mutation from every source — HTTP, SDK, MCP, AI, CLI, UI, integrations, workers — enters one pipeline that resolves tenant and actor, authorizes, validates, checks idempotency and concurrency, executes one SQL transaction containing the business mutation plus the idempotency receipt, the audit row, and the outbox events, and returns a typed OperationResult.
The kernel never talks to a provider directly; durable delivery happens exclusively through the transactional outbox and its publishers.
Index ¶
- Constants
- Variables
- func BulkRowKey(importID string, index int) string
- func CanonicalDocHash(fields map[string]any) string
- func CanonicalVersion(v any) string
- func EncodeCommandResources(defs []*CommandResource) ([]json.RawMessage, error)
- func SequenceBulk(importID string, rows []BulkRow, fn func(row BulkRow, key string))
- type AuditRow
- type BulkOptions
- type BulkRow
- type BulkRowResult
- type CommandDefinition
- type CommandExtraInput
- type CommandGuard
- type CommandInput
- type CommandPresentation
- type CommandRegistry
- func (r *CommandRegistry) Extend(defs []*CommandResource) (*CommandRegistry, error)
- func (r *CommandRegistry) List() []*CommandResource
- func (r *CommandRegistry) Lookup(name string) (*CommandResource, bool)
- func (r *CommandRegistry) LookupCapability(capability contract.CapabilityName, operation string) (*CommandResource, bool)
- func (r *CommandRegistry) OwnerCommands() []*CommandResource
- func (r *CommandRegistry) Register(def *CommandResource) error
- type CommandResource
- func DecodeCommandResources(raw []json.RawMessage) ([]*CommandResource, error)
- func ParseCommandDir(dir string) ([]*CommandResource, error)
- func ParseCommandResource(raw []byte) (*CommandResource, error)
- func ParseCommandResourceDraftJSON(raw []byte) (*CommandResource, error)
- func ParseCommandResourceJSON(raw []byte) (*CommandResource, error)
- type CommandSchemaRegistry
- type CommandStep
- type ComputeBlock
- type ComputeEntry
- type CrossEntityCommand
- type FieldAdjust
- type GuardLock
- type GuardMatch
- type GuardPayment
- type Kernel
- func (k *Kernel) Execute(ctx context.Context, siteDB *sql.DB, reg *doctype.Registry, op Operation) (contract.CommandResult, *contract.Error)
- func (k *Kernel) ExecuteBulk(ctx context.Context, siteDB *sql.DB, reg *doctype.Registry, base Operation, ...) []BulkRowResult
- func (k *Kernel) ExecuteInTx(ctx context.Context, siteDB *sql.DB, dbTx *sql.Tx, reg *doctype.Registry, ...) (contract.CommandResult, func(), *contract.Error)
- func (k *Kernel) ExecuteScriptMutationInTx(ctx context.Context, dbTx *sql.Tx, txMgr *orm.TxManager, ...) (json.RawMessage, error)
- func (k *Kernel) LookupReceiptByIntent(ctx context.Context, siteDB *sql.DB, intent ReceiptIntent) (contract.CommandResult, bool, *contract.Error)
- type Operation
- type OperationContext
- type ReceiptIntent
- type RecordCreatePayload
- type RecordFieldChange
- type RecordMutationBundleItem
- type RecordMutationBundlePayload
- type RecordUpdatePayload
- type RelatedRecordResult
- type ResultData
- type Source
- type StepCreate
- type StepEnsure
- type StepUpdate
- type WorkflowStatusTransitionPayload
Constants ¶
const ( CommandRecordCreate = "record.create" CommandRecordMutateBundle = "record.mutate_bundle" CommandRecordUpdate = "record.update" CommandRecordDelete = "record.delete" CommandWorkflowStatusTransition = "workflow.status_transition" CommandPublicFormSubmit = "public_form.submit" )
Command names are canonical across all sources. Adapters resolve these definitions from the registry; they never implement their own semantics.
const ErrKeyAmbiguous = "import.key_ambiguous"
ErrKeyAmbiguous is the per-row message when a key matches two or more records.
const MaxCommandStepInstances = 500
MaxCommandStepInstances bounds how many writes one command may expand to after for_each, so a single request cannot fan out without limit.
const MaxComputeEntries = 32
MaxComputeEntries bounds the compute block of one command.
const MaxMutationBundleRecords = 50
MaxMutationBundleRecords bounds the number of related writes in one transactional command while leaving room for ordinary multi-line checkouts.
Variables ¶
var ( ErrUnauthenticated = contract.NewError(contract.CodeUnauthenticated, "operation context has no authenticated actor") ErrNoSite = contract.NewError(contract.CodeValidationFailed, "operation context missing tenant site") ErrPermission = contract.NewError(contract.CodePermissionDenied, "not permitted") ErrStaleVersion = contract.NewError(contract.CodeConflict, "document was modified by another operation") ErrKeyReused = contract.NewError(contract.CodeIdempotencyKeyReused, "idempotency key already used with a different payload") )
Typed sentinel errors. Adapters map these to wire errors via contract.Code; they must never be detected by string matching.
Functions ¶
func BulkRowKey ¶
BulkRowKey returns the idempotency key for a row of a bulk run.
func CanonicalDocHash ¶
CanonicalDocHash renders a document's field map as sorted-key JSON and returns the sha256 hex digest — the audit before/after state token (KERNEL-009). Hash input is deterministic: sorted keys, JSON-encoded values.
func CanonicalVersion ¶
CanonicalVersion renders a document version token (the `modified` timestamp) in a stable string form so callers can echo it back as expected_version regardless of driver time parsing.
func EncodeCommandResources ¶
func EncodeCommandResources(defs []*CommandResource) ([]json.RawMessage, error)
EncodeCommandResources converts parsed definitions into the JSON form kept in configuration snapshots, so commands version and activate with the rest of a tenant's configuration.
Types ¶
type AuditRow ¶
type AuditRow struct {
ID string
Site string
OperationID string
CorrelationID string
CausationID string
Source string
PrincipalType string
PrincipalID string
ActorUser string
ActorRoles string // JSON array of role names; empty when none
Command string
Doctype string
DocName string
Status string
ErrorCode string
PayloadHash string
BeforeHash string
AfterHash string
}
AuditRow is one immutable operation-audit ledger entry (_kora_operation_audit). The ledger records who did what, from which source, with which outcome — never payloads or secrets. Before/after hashes (KERNEL-009) carry sha256 digests of canonicalized document state so tampering is detectable without storing sensitive values.
type BulkOptions ¶
type BulkOptions struct {
// Rows are the inputs, run in order.
Rows []BulkRow
// ImportID scopes per-row idempotency keys: sha256(ImportID:index).
ImportID string
// DryRun executes each row and rolls it back; nothing is persisted.
DryRun bool
// KeyFields switches to upsert: a row updates the single record matching
// its key values, or creates one when none matches.
KeyFields []string
}
BulkOptions controls a bulk run.
type BulkRow ¶
type BulkRow struct {
Index int
Payload json.RawMessage
}
BulkRow is one input of a bulk run; Index is the caller's row number.
type BulkRowResult ¶
type BulkRowResult struct {
Index int
Result contract.CommandResult
Error *contract.Error // nil when the row succeeded
}
BulkRowResult reports the outcome of one row.
type CommandDefinition ¶
type CommandDefinition struct {
Name string
Version int
AuthorizesWith string // permission-matrix operation ("create", "write")
IdempotentByKey bool // replay-safe when an idempotency key is present
}
CommandDefinition is the single registered description of a command: its payload shape, authorization operation, idempotency class, and timeout.
func LookupCommand ¶
func LookupCommand(name string) (CommandDefinition, bool)
LookupCommand returns the canonical definition for a command name.
type CommandExtraInput ¶
type CommandExtraInput struct {
Type string `yaml:"type" json:"type"`
Required bool `yaml:"required,omitempty" json:"required,omitempty"`
}
CommandExtraInput types one input that is not a record field. Type is a JSON Schema primitive.
type CommandGuard ¶
type CommandGuard struct {
Lock *GuardLock `yaml:"lock,omitempty" json:"lock,omitempty"`
Exists *GuardMatch `yaml:"exists,omitempty" json:"exists,omitempty"`
NotExists *GuardMatch `yaml:"not_exists,omitempty" json:"not_exists,omitempty"`
Payment *GuardPayment `yaml:"payment,omitempty" json:"payment,omitempty"`
Equal []string `yaml:"equal,omitempty" json:"equal,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
As string `yaml:"as,omitempty" json:"as,omitempty"`
UnlessRole []string `yaml:"unless_role,omitempty" json:"unless_role,omitempty"`
}
CommandGuard is a precondition checked inside the command transaction before any step writes. Exactly one of Lock, Exists, NotExists, Payment or Equal is set.
- lock serializes concurrent commands on one record (SELECT ... FOR UPDATE), so a following not_exists check and create cannot race.
- exists requires at least one matching record; As binds the first match for later steps as $steps.<as>.name; $steps.<as>.<field> reads one of its scalar fields, which needs read access to the record.
- not_exists requires that no record matches.
- equal requires two numeric operands (a $computed or $input reference, or a decimal literal) to be exactly equal, compared as big.Rat.
UnlessRole, valid on exists, not_exists and equal, skips the guard when the verified actor holds any listed role (exact, case-sensitive match). It cannot be combined with As, since a skipped guard would leave the alias unbound.
type CommandInput ¶
type CommandInput struct {
Record string `yaml:"record" json:"record"`
// Extra declares operation inputs that are not fields of Record, so the
// published input schema can type them.
Extra map[string]CommandExtraInput `yaml:"extra,omitempty" json:"extra,omitempty"`
}
CommandInput types the payload. The slice form binds one record kind; collection-based inputs arrive with SPEC-003.
type CommandPresentation ¶
type CommandPresentation contract.SurfacePresentation
CommandPresentation is a SurfacePresentation read from YAML through its JSON keys, so the wire type needs no yaml tags.
func (*CommandPresentation) UnmarshalYAML ¶
func (p *CommandPresentation) UnmarshalYAML(node *yaml.Node) error
type CommandRegistry ¶
type CommandRegistry struct {
// contains filtered or unexported fields
}
CommandRegistry holds generation-scoped command definitions. It is safe for concurrent reads after loading; Register is intended during activation only.
func LoadCommandDir ¶
func LoadCommandDir(dir string) (*CommandRegistry, error)
LoadCommandDir parses every *.yaml file in dir (sorted by filename for deterministic registration order) into a fresh CommandRegistry. Parsing is strict: any invalid definition aborts the whole load and returns the accumulated errors — configuration is never silently discarded. A missing directory returns an empty registry and no error, so deployments without command definitions need no special-casing.
func NewCommandRegistry ¶
func NewCommandRegistry() *CommandRegistry
NewCommandRegistry returns an empty registry.
func (*CommandRegistry) Extend ¶
func (r *CommandRegistry) Extend(defs []*CommandResource) (*CommandRegistry, error)
Extend returns a new registry containing the receiver's definitions plus defs. The receiver is not modified, so a process-wide registry can be shared while each tenant generation layers its own configured commands on top. Name or capability collisions with existing definitions are rejected.
func (*CommandRegistry) List ¶
func (r *CommandRegistry) List() []*CommandResource
List returns all registered definitions sorted by name for stable introspection output.
func (*CommandRegistry) Lookup ¶
func (r *CommandRegistry) Lookup(name string) (*CommandResource, bool)
Lookup resolves a command by full name.
func (*CommandRegistry) LookupCapability ¶
func (r *CommandRegistry) LookupCapability(capability contract.CapabilityName, operation string) (*CommandResource, bool)
LookupCapability resolves the unique owner command attached to a declared capability operation. Definitions remain owned by CommandRegistry.
func (*CommandRegistry) OwnerCommands ¶
func (r *CommandRegistry) OwnerCommands() []*CommandResource
OwnerCommands returns registered owner-authored domain commands. Public transport adapters use it to ensure those commands only enter Kernel via their published capability binding, never by a guessed command name.
func (*CommandRegistry) Register ¶
func (r *CommandRegistry) Register(def *CommandResource) error
Register adds a definition; duplicate full names are rejected with a typed error so two packs cannot silently shadow each other.
type CommandResource ¶
type CommandResource struct {
Name string `yaml:"name" json:"name"`
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
Version int `yaml:"version" json:"version"`
Permission string `yaml:"permission" json:"permission"` // permission-matrix operation, default "create"
Input CommandInput `yaml:"input" json:"input"`
ModuleOwnerID contract.ModuleID `yaml:"module_owner_id,omitempty" json:"module_owner_id,omitempty"`
Capability contract.CapabilityName `yaml:"capability,omitempty" json:"capability,omitempty"`
Operation string `yaml:"operation,omitempty" json:"operation,omitempty"`
InputSchema contract.SchemaRef `yaml:"input_schema,omitempty" json:"input_schema,omitempty"`
OutputSchema contract.SchemaRef `yaml:"output_schema,omitempty" json:"output_schema,omitempty"`
CrossEntity *CrossEntityCommand `yaml:"cross_entity,omitempty" json:"cross_entity,omitempty"`
Preconditions []string `yaml:"preconditions" json:"preconditions,omitempty"`
Require []CommandGuard `yaml:"require,omitempty" json:"require,omitempty"`
Compute ComputeBlock `yaml:"compute,omitempty" json:"compute,omitempty"`
Output map[string]string `yaml:"output,omitempty" json:"output,omitempty"`
Steps []CommandStep `yaml:"transaction" json:"transaction"`
Emits []string `yaml:"emit" json:"emit,omitempty"`
BusinessEvents []contract.BusinessEventDefinition `yaml:"business_events" json:"business_events,omitempty"`
Labels map[string]string `yaml:"labels" json:"labels,omitempty"`
// Presentation and OfflineEligible are published with the operation.
Presentation *CommandPresentation `yaml:"presentation,omitempty" json:"presentation,omitempty"`
OfflineEligible bool `yaml:"offline_eligible,omitempty" json:"offline_eligible,omitempty"`
}
CommandResource is a config-defined business command (KERNEL-008, spec §19): a named, versioned mutation with typed input, optional preconditions, transaction steps over records, and emitted events. Definitions load from application configuration exactly like doctypes — no code generation.
Slice limitations (documented, not silent):
- update steps resolve their target by name equality only;
- preconditions are rejected because this runtime has no evaluator.
func DecodeCommandResources ¶
func DecodeCommandResources(raw []json.RawMessage) ([]*CommandResource, error)
DecodeCommandResources parses every stored definition and rejects duplicate names or capability operations within the set.
func ParseCommandDir ¶
func ParseCommandDir(dir string) ([]*CommandResource, error)
ParseCommandDir parses every *.yaml file in dir, sorted by filename. A missing directory yields no definitions and no error.
func ParseCommandResource ¶
func ParseCommandResource(raw []byte) (*CommandResource, error)
ParseCommandResource parses one command definition from YAML bytes with strict unknown-key rejection (KnownFields) so unsupported configuration is never silently discarded.
func ParseCommandResourceDraftJSON ¶
func ParseCommandResourceDraftJSON(raw []byte) (*CommandResource, error)
ParseCommandResourceDraftJSON is ParseCommandResourceJSON for a command whose schema refs the pack generator has not filled yet.
func ParseCommandResourceJSON ¶
func ParseCommandResourceJSON(raw []byte) (*CommandResource, error)
ParseCommandResourceJSON parses one stored command definition with the same strictness as the YAML loader: unknown keys are rejected and the definition is validated before it can be registered.
func (*CommandResource) FullName ¶
func (c *CommandResource) FullName() string
FullName is the canonical registry key: the namespace prefixes the name unless the name already carries it ("livestock.animal.register").
func (*CommandResource) PermOperation ¶
func (c *CommandResource) PermOperation() string
PermOperation is the permission-matrix operation this command requires.
func (*CommandResource) RequiredInputs ¶
func (c *CommandResource) RequiredInputs() []string
RequiredInputs lists the top-level input keys the command cannot run without: a reference in a require guard, a step selector (for_each, where, update name or where, adjust, ensure where) or a compute entry fails the command when its key is absent. Values written by create, update and ensure steps are skipped when absent, so they are not listed (the target record's own required fields govern those). Guards waived for some roles (unless_role) are not listed, since those roles may omit what they guard. The published input schema and the executor's field-level error both use it.
func (*CommandResource) TouchedRecords ¶
func (c *CommandResource) TouchedRecords() []string
TouchedRecords returns the distinct record kinds the command mutates, in first-touch order. Authorization evaluates every one of them.
type CommandSchemaRegistry ¶
type CommandSchemaRegistry interface {
Registered(contract.SchemaRef) bool
Validate(contract.SchemaRef, json.RawMessage) error
}
CommandSchemaRegistry is the existing versioned payload-schema contract injected into the kernel for module-owned commands.
type CommandStep ¶
type CommandStep struct {
// ForEach repeats the step once per object in an input list; values may
// then reference the element as $item.field.
ForEach string `yaml:"for_each,omitempty" json:"for_each,omitempty"`
// Where keeps only the for_each elements whose fields all equal these
// values; a value is a literal or an $input/$steps/$computed reference.
Where map[string]string `yaml:"where,omitempty" json:"where,omitempty"`
// As names the record this step writes so later steps can reference it
// as $steps.<as>.name, or read one of its scalar fields as $steps.<as>.<field>.
As string `yaml:"as,omitempty" json:"as,omitempty"`
Create *StepCreate `yaml:"create,omitempty" json:"create,omitempty"`
Update *StepUpdate `yaml:"update,omitempty" json:"update,omitempty"`
// Ensure makes sure one record exists: it is looked up by Where and
// created with Where plus Values when absent. With As, later steps
// address the existing or new record as $steps.<as>.name.
Ensure *StepEnsure `yaml:"ensure,omitempty" json:"ensure,omitempty"`
}
CommandStep is one transactional write. Values map target record fields to literal values or "$input.field" references into the operation payload.
type ComputeBlock ¶
type ComputeBlock []ComputeEntry
ComputeBlock keeps compute entries in declaration order, which is the evaluation order.
func (*ComputeBlock) UnmarshalYAML ¶
func (b *ComputeBlock) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML reads a mapping of key to entry and preserves its order.
type ComputeEntry ¶
type ComputeEntry struct {
Key string `yaml:"-" json:"key"`
Sum string `yaml:"sum,omitempty" json:"sum,omitempty"`
Count string `yaml:"count,omitempty" json:"count,omitempty"`
Expr string `yaml:"expr,omitempty" json:"expr,omitempty"`
// contains filtered or unexported fields
}
ComputeEntry derives one value from the command input before any step runs. Exactly one of Sum (with Expr) or Count must be set. Sum and Count name an "$input.<list>" and Expr is evaluated per element, with bare names reading the element's fields.
type CrossEntityCommand ¶
type CrossEntityCommand struct {
Resource string `yaml:"resource" json:"resource"`
Operation string `yaml:"operation" json:"operation"`
TargetEntityField string `yaml:"target_entity_field" json:"target_entity_field"`
}
CrossEntityCommand registers a command that requires exact grants in both the invoking entity and a target entity named in its typed input. The invoking entity always comes from verified server context.
type FieldAdjust ¶
type FieldAdjust struct {
Increase string `yaml:"increase,omitempty" json:"increase,omitempty"`
Decrease string `yaml:"decrease,omitempty" json:"decrease,omitempty"`
Min string `yaml:"min,omitempty" json:"min,omitempty"`
}
FieldAdjust changes one numeric field relative to its stored value. Exactly one of Increase or Decrease is set; Min, when set, is a floor the result may not fall below. Arithmetic is exact decimal, never float.
type GuardLock ¶
type GuardLock struct {
Record string `yaml:"record" json:"record"`
Name string `yaml:"name" json:"name"`
}
GuardLock names one record to lock, usually "$input.field".
type GuardMatch ¶
type GuardMatch struct {
Record string `yaml:"record" json:"record"`
Where map[string]string `yaml:"where" json:"where"`
}
GuardMatch is an equality match over declared fields. Values may be literals or $input / $steps references.
type GuardPayment ¶
type Kernel ¶
type Kernel struct {
Dialect db.Dialect
Outbox outbox.Writer
WorkflowStatusPolicies workflow.StatusPolicyRepository
// TxManager supplies request-scoped ORM lifecycle hooks and script runtime.
// Database, registry, dialect, site, user, and outbox are rebound per Execute.
TxManager *orm.TxManager
// Commands holds config-defined command resources (KERNEL-008). Nil means
// only built-in commands are available. Definitions are generation-scoped:
// swap the registry atomically on activation.
Commands *CommandRegistry
// CommandSchemas is the existing versioned schema registry used by
// module-owned commands. The same validator is applied for provider and
// direct command entry paths before transactional effects can commit.
CommandSchemas CommandSchemaRegistry
}
Kernel is the process-wide operation entry point. It is safe for concurrent use; per-site state (DB handle, registry) is supplied per call via SiteDB.
func New ¶
New returns a Kernel. Outbox may be nil only in tests that do not assert event delivery; production wiring always supplies outbox.NewSQLWriter().
func (*Kernel) Execute ¶
func (k *Kernel) Execute(ctx context.Context, siteDB *sql.DB, reg *doctype.Registry, op Operation) (contract.CommandResult, *contract.Error)
Execute runs the full pipeline for op against the given site database and registry. Exactly one of the following occurs:
- completed: business row + receipt + audit + outbox rows committed atomically;
- replayed: a prior committed result for the same stable tenant+idempotency key is returned;
- rejected: a typed error; nothing is persisted (transaction rolled back).
func (*Kernel) ExecuteBulk ¶
func (k *Kernel) ExecuteBulk(ctx context.Context, siteDB *sql.DB, reg *doctype.Registry, base Operation, opts BulkOptions) []BulkRowResult
ExecuteBulk runs base.Command once per row, sequentially, one transaction per row. It never stops on failure: every row is reported. Each row carries its own idempotency key so re-running a bulk skips completed rows (replayed receipts).
func (*Kernel) ExecuteInTx ¶
func (k *Kernel) ExecuteInTx(ctx context.Context, siteDB *sql.DB, dbTx *sql.Tx, reg *doctype.Registry, op Operation) (contract.CommandResult, func(), *contract.Error)
ExecuteInTx prepares and executes an authorized command inside a transaction owned by a higher-level unit of work. It does not commit or roll back dbTx. The caller must roll back on error, commit on success, and invoke afterCommit only after that commit succeeds. The verified execution is mandatory so a caller-supplied actor cannot acquire authority through this internal seam.
func (*Kernel) ExecuteScriptMutationInTx ¶
func (k *Kernel) ExecuteScriptMutationInTx(ctx context.Context, dbTx *sql.Tx, txMgr *orm.TxManager, request script.MutationRequest) (json.RawMessage, error)
ExecuteScriptMutationInTx is the narrow worker seam for script-provider writes inside an already-owned operation transaction. It cannot open a new transaction or bypass the kernel's authorization and domain validation.
func (*Kernel) LookupReceiptByIntent ¶
func (k *Kernel) LookupReceiptByIntent(ctx context.Context, siteDB *sql.DB, intent ReceiptIntent) (contract.CommandResult, bool, *contract.Error)
LookupReceiptByIntent recovers a completed receipt without dispatching the command. The caller must derive idempotencyKey from its full public intent (including scope and operation reference) before calling this method.
type Operation ¶
type Operation struct {
Context OperationContext
Command string // canonical command name
Payload json.RawMessage // JSON-encoded typed payload
Deadline time.Time // zero means no deadline; enforced before execution
}
Operation is a fully specified invocation handed to Kernel.Execute.
type OperationContext ¶
type OperationContext struct {
ModuleExecution *contract.ModuleExecution
BusinessScope contract.BusinessScope
BusinessReferenceValidator contract.BusinessReferenceValidator
HistoricalSnapshotValidator contract.HistoricalSnapshotValidator
Site string // authenticated tenant route, retained for audit and compatibility
TenantID contract.TenantID // stable tenant identity from routed runtime
Execution policy.Execution // verified identity; legacy internal callers are being migrated
Actor contract.ActorContext // authenticated principal
User string // owner-attribution user ("" → "system")
Owner string // internal owner override; adapters must not populate this from user data
UserRole string // primary role used by workflow policy
Roles []string // roles used for permission-matrix lookup
SkipHookScripts []string // trusted internal stack prevents recursive execution of active lifecycle scripts
AllowReadOnlyFields bool // trusted internal writers may update UI-read-only fields
Source Source // adapter surface
CorrelationID string
CausationID string
CausationDepth uint16
ExpectedVersion string
// ExpectedConfigRevision fences internal operations that selected behavior
// from tenant configuration before entering the source transaction.
ExpectedConfigRevision uint64
// ConfigRevision pins immutable behavior for durable asynchronous effects;
// it is distinct from the caller's expected-revision precondition.
ConfigRevision uint64
IdempotencyKey string
// contains filtered or unexported fields
}
OperationContext carries everything an adapter must resolve before invoking the kernel. It is an explicit value, never smuggled through context.Context.
type ReceiptIntent ¶
type ReceiptIntent struct {
Execution policy.Execution
ActorUser string
Command string
IdempotencyKey string
}
ReceiptIntent identifies the receipt LookupReceiptByIntent recovers. Every field is required.
type RecordCreatePayload ¶
type RecordCreatePayload struct {
Doctype string `json:"doctype"`
Data json.RawMessage `json:"data"`
PublicRoute string `json:"public_route,omitempty"`
}
RecordCreatePayload is the typed payload for record.create. Field values are schema-generic by design (the engine is config-driven) but are always validated against the doctype definition before execution; invalid shapes produce typed ValidationError lists, never silent acceptance.
type RecordFieldChange ¶
type RecordFieldChange struct {
Field string `json:"field"`
Before any `json:"before"`
After any `json:"after"`
}
RecordFieldChange is the before/after projection stored for a record write. Password and hidden fields are excluded before persistence, not only at read.
type RecordMutationBundleItem ¶
type RecordMutationBundleItem struct {
Key string `json:"key"`
Operation string `json:"operation,omitempty"` // create (default), update, decrement, or adjust
Doctype string `json:"doctype"`
Name string `json:"name,omitempty"`
ExpectedRevision uint64 `json:"expected_revision,omitempty"`
TransitionAction string `json:"transition_action,omitempty"` // configured transition, only valid on updates
Data json.RawMessage `json:"data"`
}
type RecordMutationBundlePayload ¶
type RecordMutationBundlePayload struct {
Doctype string `json:"doctype"`
Records []RecordMutationBundleItem `json:"records"`
}
type RecordUpdatePayload ¶
type RecordUpdatePayload struct {
Doctype string `json:"doctype"`
Name string `json:"name"`
Data json.RawMessage `json:"data"`
}
RecordUpdatePayload is the typed payload for record.update.
type RelatedRecordResult ¶
type ResultData ¶
type ResultData struct {
Doctype string `json:"doctype"`
Name string `json:"name"`
Created bool `json:"created"`
Deleted bool `json:"deleted,omitempty"`
Document map[string]any `json:"document,omitempty"`
AuditID string `json:"audit_id"`
Operation string `json:"operation_id"`
Related []RelatedRecordResult `json:"related,omitempty"`
}
ResultData is the typed success payload returned by record commands.
type Source ¶
type Source string
Source identifies the adapter surface that produced an operation. It is recorded on the audit ledger and drives authorization-parity tests: two sources executing the same command must produce identical outcomes.
type StepCreate ¶
type StepEnsure ¶
type StepEnsure struct {
Record string `yaml:"record" json:"record"`
Scope string `yaml:"business_scope" json:"business_scope,omitempty"`
Where map[string]string `yaml:"where" json:"where"`
Values map[string]string `yaml:"values,omitempty" json:"values,omitempty"`
}
StepEnsure is a create-if-absent. Where fields identify the record and seed its creation; Values are extra defaults applied only on creation. Pair it with a require lock on a record all writers of the same target share, since two concurrent first writers would otherwise both find nothing.
type StepUpdate ¶
type StepUpdate struct {
Record string `yaml:"record" json:"record"`
Name string `yaml:"name" json:"name"` // "$input.field" reference
// Where finds the single target by declared fields when Name is not set.
Where map[string]string `yaml:"where,omitempty" json:"where,omitempty"`
Scope string `yaml:"business_scope" json:"business_scope,omitempty"`
Values map[string]string `yaml:"values" json:"values"`
// Adjust changes numeric fields relative to their stored value.
Adjust map[string]FieldAdjust `yaml:"adjust,omitempty" json:"adjust,omitempty"`
}
type WorkflowStatusTransitionPayload ¶
type WorkflowStatusTransitionPayload struct {
Doctype string `json:"doctype"`
Name string `json:"name"`
Action string `json:"action"`
ExpectedRevision uint64 `json:"expected_revision,omitempty"`
}
WorkflowStatusTransitionPayload applies a configured transition to one record without exposing its workflow state as an ordinary field update.
Source Files
¶
- audit.go
- authorize.go
- bulk.go
- bulk_upsert.go
- bundle.go
- command_adjust.go
- command_compute.go
- command_exec.go
- command_guard_equal.go
- command_guard_payment.go
- command_guards.go
- command_load.go
- command_refs.go
- command_required_inputs.go
- command_resource.go
- command_rows.go
- command_snapshot.go
- command_step_fields.go
- cross_entity_command.go
- document.go
- errors.go
- hash.go
- historical_snapshot.go
- idempotency.go
- kernel.go
- mutation.go
- mutation_bundle.go
- mutation_record.go
- mutation_status.go
- pipeline.go
- quantity_adjust.go
- quantity_effect.go
- record_history.go
- script_mutation.go
- tx_run.go
- workflow_state.go