runtime

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: GPL-3.0 Imports: 74 Imported by: 0

Documentation

Overview

Package runtime is the public application-runtime boundary used by generated Golem application packages. It owns immutable schema/provider state and creates a fresh actor policy set for every caller execution.

Index

Constants

View Source
const (
	MaxMutationNestedDepth         = 5
	MaxMutationTouchedRows         = 1_000
	MaxMutationFacts               = eventprovider.MaximumCausationFacts
	MaxMutationOutboxBytes         = 1 << 20
	MaxMutationStatementParameters = 999
	MaxMutationUpsertAttempts      = 3
)
View Source
const MaxBatchLoaderKeys = 90_000

MaxBatchLoaderKeys is an execution-owned memory/statement-complexity guard. SQL parameter bounds are separately enforced per chunk by read/sql.

Variables

This section is empty.

Functions

func CallerAggregate

func CallerAggregate[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], request golem.AggregateRequest[M]) (golem.AggregateResult[M], error)

func CallerCount

func CallerCount[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (result int64, resultErr error)

func CallerCreate

func CallerCreate[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], input golem.CreateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

CallerCreate is the generated-client execution ABI for one authorized root scalar create. Hooks, facts, and nested operations are later P4 layers and cannot enter this scalar path; root upsert has its own guarded kernel.

func CallerDelete

func CallerDelete[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerDeleteMany

func CallerDeleteMany[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M]) (count int64, resultErr error)

func CallerDeleteVersioned added in v0.1.0

func CallerDeleteVersioned[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, projections ...golem.Projection[M]) (golem.Row[M], error)

CallerDeleteVersioned is the typed generated-client ABI for one caller CAS.

func CallerEvents

func CallerEvents[P, A, M, E any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], options ...golem.EventOption[M]) (golem.EventStream[E], error)

CallerEvents is the generated caller-only typed stream entry point. It performs all fallible request binding and the model-read gate before hub registration. The retained state contains only an owned principal snapshot and immutable, schema-bound request data; no caller execution survives.

func CallerExecuteFrozenAnalytics

func CallerExecuteFrozenAnalytics[P, A any](ctx context.Context, caller *Caller[P, A], request golem.FrozenAnalyticsRequest) ([][]golem.RuntimeAnalyticsCell, error)

CallerExecuteFrozenAnalytics is the generated GraphQL bridge into the same caller analytics execution path used by generated Go clients. It performs no GraphQL-specific authorization, planning, SQL rendering, or evaluation.

func CallerExecuteFrozenRead

func CallerExecuteFrozenRead[P, A any](ctx context.Context, caller *Caller[P, A], request golem.FrozenReadRequest) ([]golem.RuntimeModelRow, error)

CallerExecuteFrozenRead is the model-erased P3 execution seam used by the generated GraphQL adapter. It preserves the ordinary caller lifecycle: generated typed before hooks may transform the frozen request, every transformation is rebound before later hooks observe it, P3 owns all policy and SQL work, and generated typed after hooks receive only masked rows.

func CallerExplainAggregate added in v0.1.0

func CallerExplainAggregate[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], request golem.AggregateRequest[M]) (queryplan.Report, error)

func CallerExplainCount added in v0.1.0

func CallerExplainCount[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (queryplan.Report, error)

func CallerExplainFindFirst added in v0.1.0

func CallerExplainFindFirst[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (queryplan.Report, error)

func CallerExplainFindMany added in v0.1.0

func CallerExplainFindMany[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (queryplan.Report, error)

CallerExplainFindMany prepares the exact authorized Caller read and asks the provider to plan it without executing the data statement or decoding rows.

func CallerExplainFindUnique added in v0.1.0

func CallerExplainFindUnique[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], selector golem.UniqueSelectorValue[M], options ...golem.ReadOption[M]) (queryplan.Report, error)

func CallerExplainGroupBy added in v0.1.0

func CallerExplainGroupBy[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], request golem.GroupRequest[M]) (queryplan.Report, error)

func CallerExplainRelationGroupBy added in v0.1.0

func CallerExplainRelationGroupBy[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], request golem.RelationGroupRequest[M]) (queryplan.Report, error)

func CallerExplainScoped added in v0.1.0

func CallerExplainScoped[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], request golem.ScopedQuery[M]) (queryplan.Report, error)

func CallerFindFirst

func CallerFindFirst[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (resultRow golem.Row[M], resultFound bool, resultErr error)

func CallerFindMany

func CallerFindMany[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (resultRows []golem.Row[M], resultErr error)

CallerFindMany is the generic execution primitive used by generated model clients. Application code normally calls caller.Posts.FindMany instead.

func CallerFindUnique

func CallerFindUnique[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], selector golem.UniqueSelectorValue[M], options ...golem.ReadOption[M]) (resultRow golem.Row[M], resultErr error)

func CallerFrozenEvents

func CallerFrozenEvents[P, A, E any](ctx context.Context, caller *Caller[P, A], request golem.FrozenEventRequest) (golem.EventStream[E], error)

CallerFrozenEvents is the model-erased generated GraphQL handoff. The request must already have crossed Golem's sealed event-option/operation binder; this function shares every admission, authorization, hub, and typed factory step with the ordinary generated Go client entry point.

func CallerFrozenReadEvents

func CallerFrozenReadEvents[P, A, E any](ctx context.Context, caller *Caller[P, A], readRequest golem.FrozenReadRequest, entitySelected bool) (golem.EventStream[E], error)

CallerFrozenReadEvents is the full-selection P5/P7 handoff used by the generated GraphQL subscription adapter. The request is the ordinary sealed, compiler-produced P3 read request and may contain relations and counts. Its bound where predicate is retained separately and re-conjoined after every read hook, so hooks cannot remove the subscription filter. This seam fresh-reads the complete P3 dependency/hydration row. For each received event, P7-F creates one fresh P5 computedExecution, encodes through the existing operation encoder, and closes it before the next frame; computed loaders never live in this hub or across events.

func CallerGroupBy

func CallerGroupBy[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], request golem.GroupRequest[M]) ([]golem.GroupRow[M], error)

func CallerRelationGroupBy

func CallerRelationGroupBy[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], request golem.RelationGroupRequest[M]) ([]golem.RelationGroupRow[M], error)

func CallerScoped

func CallerScoped[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], query golem.ScopedQuery[M]) ([]golem.ScopedRow, error)

func CallerSearch added in v0.1.1

func CallerSearch[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], indexName, query string, take int, predicates ...golem.Predicate[M]) ([]golem.SemanticResult[M], error)

CallerSearch executes ordinary caller authorization before distance evaluation. The authorized predicate is pushed into the ranking statement, so only rows the caller may read can occupy a result slot or affect ordering.

func CallerSimilar added in v0.1.0

func CallerSimilar[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], indexName string, source golem.UniqueSelectorValue[M], take int, predicates ...golem.Predicate[M]) ([]golem.SemanticResult[M], error)

CallerSimilar ranks authorized rows against the stored vector of a source row the caller is authorized to read. Resolving the source through an ordinary authorized unique read is what keeps the neighbourhood of a hidden row from becoming a readable projection of it.

func CallerTransaction

func CallerTransaction[P, A any](ctx context.Context, caller *Caller[P, A], callback func(*CallerTx[P, A]) error) (err error)

CallerTransaction owns the outer transaction around one generated caller callback. The callback is invoked exactly once; this function never retries application code.

func CallerTxAggregate

func CallerTxAggregate[P, A, M any](ctx context.Context, tx *CallerTx[P, A], descriptor golem.ModelDescriptor[M], request golem.AggregateRequest[M]) (golem.AggregateResult[M], error)

func CallerTxCount

func CallerTxCount[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (int64, error)

func CallerTxCreate

func CallerTxCreate[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], input golem.CreateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerTxDelete

func CallerTxDelete[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerTxDeleteMany

func CallerTxDeleteMany[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M]) (int64, error)

func CallerTxDeleteVersioned added in v0.1.0

func CallerTxDeleteVersioned[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerTxEnqueue added in v0.3.0

func CallerTxEnqueue[P, A any](ctx context.Context, transaction *CallerTx[P, A], pending queue.Pending) (queue.JobID, error)

CallerTxEnqueue records one job on the caller transaction's executor, so the job row commits and rolls back with the domain write. The in-process worker is nudged when the transaction commits, never when the row is written.

func CallerTxFindFirst

func CallerTxFindFirst[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (golem.Row[M], bool, error)

func CallerTxFindMany

func CallerTxFindMany[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) ([]golem.Row[M], error)

CallerTxFindMany is the transaction-bound equivalent of CallerFindMany. Generated Tx model clients call this seam; it preserves caller hooks and policy isolation while forcing every statement through the bound sqlx.Tx.

func CallerTxFindUnique

func CallerTxFindUnique[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], selector golem.UniqueSelectorValue[M], options ...golem.ReadOption[M]) (golem.Row[M], error)

func CallerTxGroupBy

func CallerTxGroupBy[P, A, M any](ctx context.Context, tx *CallerTx[P, A], descriptor golem.ModelDescriptor[M], request golem.GroupRequest[M]) ([]golem.GroupRow[M], error)

func CallerTxRelationGroupBy

func CallerTxRelationGroupBy[P, A, M any](ctx context.Context, tx *CallerTx[P, A], descriptor golem.ModelDescriptor[M], request golem.RelationGroupRequest[M]) ([]golem.RelationGroupRow[M], error)

func CallerTxScoped

func CallerTxScoped[P, A, M any](ctx context.Context, tx *CallerTx[P, A], descriptor golem.ModelDescriptor[M], query golem.ScopedQuery[M]) ([]golem.ScopedRow, error)

func CallerTxUpdate

func CallerTxUpdate[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerTxUpdateMany

func CallerTxUpdateMany[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M], input golem.UpdateManyInput[M]) (int64, error)

func CallerTxUpdateVersioned added in v0.1.0

func CallerTxUpdateVersioned[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerTxUpsert

func CallerTxUpsert[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerTxUpsertVersioned added in v0.1.0

func CallerTxUpsertVersioned[P, A, M any](ctx context.Context, transaction *CallerTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ConcurrencyExpectation, create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerUpdate

func CallerUpdate[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func CallerUpdateMany

func CallerUpdateMany[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M], input golem.UpdateManyInput[M]) (count int64, resultErr error)

CallerUpdateMany executes one bounded, exact-set authorized update. Planning, policy classification, provider capability checks, and SQL rendering all complete before transaction acquisition.

func CallerUpdateVersioned added in v0.1.0

func CallerUpdateVersioned[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

CallerUpdateVersioned is the typed generated-client ABI for one caller CAS.

func CallerUpsert

func CallerUpsert[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

CallerUpsert executes exactly one truthful create or update branch. Public values and authorization are frozen/planned before the first transaction.

func CallerUpsertVersioned added in v0.1.0

func CallerUpsertVersioned[P, A, M any](ctx context.Context, caller *Caller[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ConcurrencyExpectation, create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func RuntimeBuildValidatedEvent

func RuntimeBuildValidatedEvent(registry EventFactoryRegistry, input ValidatedEvent) (any, error)

RuntimeBuildValidatedEvent is the model-erased handoff used by P7's evaluator and generated adapters. The input is sealed by an internal constructor; callers cannot supply raw model IDs, identity components, rows, or bytes through this function.

func SystemAggregate

func SystemAggregate[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], request golem.AggregateRequest[M]) (golem.AggregateResult[M], error)

func SystemCount

func SystemCount[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (result int64, resultErr error)

func SystemCreate

func SystemCreate[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], input golem.CreateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemDelete

func SystemDelete[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemDeleteMany

func SystemDeleteMany[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M]) (count int64, resultErr error)

func SystemDeleteVersioned added in v0.1.0

func SystemDeleteVersioned[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemFindFirst

func SystemFindFirst[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (resultRow golem.Row[M], resultFound bool, resultErr error)

func SystemFindMany

func SystemFindMany[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (resultRows []golem.Row[M], resultErr error)

func SystemFindUnique

func SystemFindUnique[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], selector golem.UniqueSelectorValue[M], options ...golem.ReadOption[M]) (resultRow golem.Row[M], resultErr error)

func SystemGroupBy

func SystemGroupBy[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], request golem.GroupRequest[M]) ([]golem.GroupRow[M], error)

func SystemRelationGroupBy

func SystemRelationGroupBy[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], request golem.RelationGroupRequest[M]) ([]golem.RelationGroupRow[M], error)

func SystemScoped

func SystemScoped[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], query golem.ScopedQuery[M]) ([]golem.ScopedRow, error)

func SystemSearch added in v0.1.1

func SystemSearch[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], indexName, query string, take int, predicates ...golem.Predicate[M]) ([]golem.SemanticResult[M], error)

func SystemSimilar added in v0.1.0

func SystemSimilar[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], indexName string, source golem.UniqueSelectorValue[M], take int, predicates ...golem.Predicate[M]) ([]golem.SemanticResult[M], error)

func SystemTransaction

func SystemTransaction[P, A any](ctx context.Context, system System[P, A], callback func(*SystemTx[P, A]) error) (err error)

SystemTransaction owns the outer transaction around one generated system callback. It does not construct caller policy or make caller hooks available.

func SystemTxAggregate

func SystemTxAggregate[P, A, M any](ctx context.Context, tx *SystemTx[P, A], descriptor golem.ModelDescriptor[M], request golem.AggregateRequest[M]) (golem.AggregateResult[M], error)

func SystemTxCount

func SystemTxCount[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (int64, error)

func SystemTxCreate

func SystemTxCreate[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], input golem.CreateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemTxDelete

func SystemTxDelete[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemTxDeleteMany

func SystemTxDeleteMany[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M]) (int64, error)

func SystemTxDeleteVersioned added in v0.1.0

func SystemTxDeleteVersioned[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemTxEnqueue added in v0.3.0

func SystemTxEnqueue[P, A any](ctx context.Context, transaction *SystemTx[P, A], pending queue.Pending) (queue.JobID, error)

SystemTxEnqueue is the unrestricted equivalent of CallerTxEnqueue.

func SystemTxFindFirst

func SystemTxFindFirst[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) (golem.Row[M], bool, error)

func SystemTxFindMany

func SystemTxFindMany[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], options ...golem.ReadOption[M]) ([]golem.Row[M], error)

func SystemTxFindUnique

func SystemTxFindUnique[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], selector golem.UniqueSelectorValue[M], options ...golem.ReadOption[M]) (golem.Row[M], error)

func SystemTxGroupBy

func SystemTxGroupBy[P, A, M any](ctx context.Context, tx *SystemTx[P, A], descriptor golem.ModelDescriptor[M], request golem.GroupRequest[M]) ([]golem.GroupRow[M], error)

func SystemTxRelationGroupBy

func SystemTxRelationGroupBy[P, A, M any](ctx context.Context, tx *SystemTx[P, A], descriptor golem.ModelDescriptor[M], request golem.RelationGroupRequest[M]) ([]golem.RelationGroupRow[M], error)

func SystemTxScoped

func SystemTxScoped[P, A, M any](ctx context.Context, tx *SystemTx[P, A], descriptor golem.ModelDescriptor[M], query golem.ScopedQuery[M]) ([]golem.ScopedRow, error)

func SystemTxUpdate

func SystemTxUpdate[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemTxUpdateMany

func SystemTxUpdateMany[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M], input golem.UpdateManyInput[M]) (int64, error)

func SystemTxUpdateVersioned added in v0.1.0

func SystemTxUpdateVersioned[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemTxUpsert

func SystemTxUpsert[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemTxUpsertVersioned added in v0.1.0

func SystemTxUpsertVersioned[P, A, M any](ctx context.Context, transaction *SystemTx[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ConcurrencyExpectation, create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemUpdate

func SystemUpdate[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemUpdateMany

func SystemUpdateMany[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], where golem.Predicate[M], input golem.UpdateManyInput[M]) (count int64, resultErr error)

func SystemUpdateVersioned added in v0.1.0

func SystemUpdateVersioned[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ExistingVersion, input golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemUpsert

func SystemUpsert[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

func SystemUpsertVersioned added in v0.1.0

func SystemUpsertVersioned[P, A, M any](ctx context.Context, system System[P, A], descriptor golem.ModelDescriptor[M], target golem.MutationTarget[M], expected golem.ConcurrencyExpectation, create golem.CreateInput[M], update golem.UpdateInput[M], projections ...golem.Projection[M]) (golem.Row[M], error)

Types

type AnalyticsLimits

type AnalyticsLimits struct {
	MaxMeasures             int
	MaxDimensions           int
	MaxRelationDepth        int
	MaxContributionRows     int
	MaxIntermediateGroups   int
	MaxProgrammaticGroups   int
	MaxScopedJoins          int
	MaxScopedSelections     int
	MaxScopedPredicateNodes int
}

type App

type App[P, A any] struct {
	// contains filtered or unexported fields
}

App contains immutable process-wide metadata only. No actor, policy set, loader, request context, or decoded row is retained here.

func Open

func Open[P, A any](ctx context.Context, config Config[P, A]) (result *App[P, A], resultErr error)

Open validates the complete generated artifact graph, fingerprints, provider selection, and live provider capabilities before publishing an App.

func (*App[P, A]) Enqueue added in v0.3.0

func (app *App[P, A]) Enqueue(ctx context.Context, pending queue.Pending) (queue.JobID, error)

Enqueue durably records one job on the application's connection pool and nudges an idle in-process worker.

func (*App[P, A]) EventCapabilities

func (app *App[P, A]) EventCapabilities() events.Capabilities

EventCapabilities returns a representation-closed operational snapshot.

func (*App[P, A]) EventLimits

func (app *App[P, A]) EventLimits() events.Limits

EventLimits returns the normalized, app-owned event limits used by the publisher, subscriptions, and generated GraphQL transport.

func (*App[P, A]) EventOperator

func (app *App[P, A]) EventOperator() events.Operator

func (*App[P, A]) ForPrincipal

func (app *App[P, A]) ForPrincipal(ctx context.Context, principal P) (*Caller[P, A], error)

ForPrincipal resolves the principal and builds every model policy exactly once for this fresh execution. Resolution or policy failure is never treated as system access.

func (*App[P, A]) QueueOperator added in v0.3.0

func (app *App[P, A]) QueueOperator() queue.Operator

QueueOperator returns the durable job control surface, or nil when the queue is not configured.

func (*App[P, A]) RefreshSemanticIndex added in v0.3.0

func (app *App[P, A]) RefreshSemanticIndex(ctx context.Context, model golem.ModelID, name string) error

RefreshSemanticIndex reconciles one declared semantic index. Writes made through Golem need no call here; they mark their own records and a drain job carries them.

func (*App[P, A]) RefreshSemanticIndexes added in v0.1.0

func (app *App[P, A]) RefreshSemanticIndexes(ctx context.Context) error

RefreshSemanticIndexes reconciles every declared semantic index with its current source rows. Unchanged rows do not call the embedding provider. Reconciliation reads the whole owner table, which is what lets it observe writes Golem never saw: the raw handle, an attached backfill, another service.

func (*App[P, A]) RunEventPublisher

func (app *App[P, A]) RunEventPublisher(ctx context.Context) (resultErr error)

RunEventPublisher owns the durable outbox publisher and every configured CDC adapter for the lifetime of ctx. Open performs no background work.

func (*App[P, A]) RunQueueWorker added in v0.3.0

func (app *App[P, A]) RunQueueWorker(ctx context.Context) error

RunQueueWorker owns the durable job worker for the lifetime of ctx. Open performs no background work, and a second concurrent call is refused with CodeWorkerRunning. On cancellation, claimed-but-unstarted jobs are released immediately and running handlers are given the configured shutdown grace; because Go cannot kill a goroutine, a handler that ignores its context may still be running when this returns.

func (*App[P, A]) System

func (app *App[P, A]) System() System[P, A]

type Caller

type Caller[P, A any] struct {
	// contains filtered or unexported fields
}

Caller is one principal-bound execution. Its policy set and identity are not shared with another Caller, even when the principals compare equal.

func (*Caller[P, A]) ExecuteFrozenRead

func (caller *Caller[P, A]) ExecuteFrozenRead(ctx context.Context, request golem.FrozenReadRequest) ([]golem.RuntimeModelRow, error)

func (*Caller[P, A]) GolemGraphQLCallerCapability

func (*Caller[P, A]) GolemGraphQLCallerCapability()

GolemGraphQLCallerCapability marks only principal-bound Caller values as eligible for generated custom GraphQL resolver dispatch. System, CallerTx, SystemTx, DB, and raw execution bindings intentionally lack this method.

func (*Caller[P, A]) Prepare

func (caller *Caller[P, A]) Prepare(request golem.FrozenReadRequest) (PreparedRead, error)

Prepare binds a caller request to the exact schema fingerprint and execution policy set. It performs no SQL and exposes no internal request representation.

type CallerMutationExecution

type CallerMutationExecution[P, A any] struct {
	// contains filtered or unexported fields
}

CallerMutationExecution combines one execution-scoped caller with the generated model descriptor inventory. It deliberately delegates reads to the same caller and dispatches each mutation call independently to P4, preserving GraphQL's serial field order without creating a cross-field transaction.

func NewCallerMutationExecution

func NewCallerMutationExecution[P, A any](caller *Caller[P, A], models ...CallerMutationModelAdapter[P, A]) (*CallerMutationExecution[P, A], error)

func (*CallerMutationExecution[P, A]) ExecuteFrozenMutation

func (execution *CallerMutationExecution[P, A]) ExecuteFrozenMutation(ctx context.Context, request golem.RuntimeMutationRequest) (golem.RuntimeMutationResult, error)

func (*CallerMutationExecution[P, A]) ExecuteFrozenRead

func (execution *CallerMutationExecution[P, A]) ExecuteFrozenRead(ctx context.Context, request golem.FrozenReadRequest) ([]golem.RuntimeModelRow, error)

type CallerMutationModelAdapter

type CallerMutationModelAdapter[P, A any] struct {
	// contains filtered or unexported fields
}

CallerMutationModelAdapter is the generated, model-specific bridge required to invoke generic P4 clients after GraphQL has erased the application's Go model type. Only Caller-backed constructors exist; System has no GraphQL mutation adapter.

func CallerMutationModel

func CallerMutationModel[P, A, M any](descriptor golem.ModelDescriptor[M]) CallerMutationModelAdapter[P, A]

CallerMutationModel binds one generated descriptor to the existing P4 caller mutation engine. It adds no policy, SQL, hook, transaction, invalidation, or fact behavior of its own.

type CallerTx

type CallerTx[P, A any] struct {
	// contains filtered or unexported fields
}

CallerTx is the opaque caller authorization and transaction capability used by generated transaction clients. Its fields deliberately expose neither the App database nor the underlying sqlx transaction.

type Config

type Config[P, A any] struct {
	Database               *providerapi.Database
	Embeddings             embedding.Registry
	Bundle                 golem.SchemaBundle
	Bindings               golem.ApplicationBindings[A]
	Descriptors            golem.ApplicationDescriptors
	ReadLimits             ReadLimits
	MutationLimits         MutationLimits
	AnalyticsLimits        AnalyticsLimits
	EventRegistry          golem.EventRegistry
	EventFactories         EventFactoryRegistry
	EventLimits            events.Limits
	EventTransport         events.EventTransport
	Observer               observe.Observer
	CDCAdapters            []events.CDCAdapter
	ReportEventOperator    events.OperatorAudit
	HistoricalEventBundles []golem.SchemaBundle
	AfterCommitError       func(context.Context, golem.AfterCommitFailure)
	AuditPrincipal         func(P) string
	ReportScopedQuery      func(context.Context, golem.ScopedAuditRecord)
	ResolvePrincipal       func(context.Context, P) (A, error)
	SnapshotPrincipal      func(P) (P, error)
	// SnapshotActor transfers ownership of mutable actor shapes into one stable
	// caller snapshot shared by policy construction and hooks. When omitted,
	// ForPrincipal accepts only deeply immutable value actors.
	SnapshotActor func(A) (A, error)
	// Queue enables the durable job queue. When omitted, no job storage is
	// created and every queue entry point refuses with CodeConfigInvalid.
	Queue *QueueConfig
}

Config contains application infrastructure and generated artifacts. P is the application's authenticated principal type; A is the actor type consumed by model policy methods.

type EventFactory

type EventFactory interface {
	ModelID() golem.ModelID
	EventSchemaDigest() golem.EventSchemaDigest
	Build(ValidatedEvent) (any, error)
}

type EventFactoryRegistry

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

func GeneratedEventFactoryRegistry

func GeneratedEventFactoryRegistry(expected golem.SchemaDigest, packages ...PackageEventFactories) (EventFactoryRegistry, error)

func (EventFactoryRegistry) GenerationDigest

func (registry EventFactoryRegistry) GenerationDigest() golem.SchemaDigest

type MutationLimits

type MutationLimits struct {
	MaxNestedDepth         int
	MaxTouchedRows         int
	MaxFacts               int
	MaxOutboxBytes         int
	MaxStatementParameters int
	MaxUpsertAttempts      int
}

MutationLimits bounds the complete touched graph and commit-derived fact buffer of one outer mutation transaction. Zero selects the portable default, which is also the hard ceiling. Applications may lower but never raise it.

type PackageEventFactories

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

func GeneratedPackageEventFactories

func GeneratedPackageEventFactories(generation golem.SchemaDigest, factories ...EventFactory) PackageEventFactories

type PreparedRead

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

PreparedRead is an opaque, schema-bound request. Later P3 planning and execution stages consume the private IR without reopening public identities.

func (PreparedRead) IsSystem

func (prepared PreparedRead) IsSystem() bool

func (PreparedRead) ModelID

func (prepared PreparedRead) ModelID() golem.ModelID

func (PreparedRead) Operation

func (prepared PreparedRead) Operation() golem.ReadOperation

type QueueConfig added in v0.3.0

type QueueConfig struct {
	Registry                  *queue.Registry
	Limits                    queue.Limits
	Resources                 []queue.Resource
	SemanticReconcileInterval time.Duration
}

QueueConfig enables the durable job queue for one application. The registry is the complete set of job types this process is willing to execute.

type ReadLimits

type ReadLimits struct {
	MaxTake                int
	MaxRelationFanout      int
	MaxRelationDepth       int
	MaxSelectedFields      int
	MaxStatementParameters int
	MaxStatementBytes      int
	MaxStatementAliases    int
	MaxLoaderKeys          int
}

ReadLimits bounds the work performed by one read without imposing a default row cap. MaxTake and MaxRelationFanout deliberately treat zero as unlimited; every other zero value selects the documented safe default.

Configured hard-complexity limits may lower, but never raise, Golem's provider-neutral ceilings. This keeps acceptance portable between SQLite and PostgreSQL.

type System

type System[P, A any] struct {
	// contains filtered or unexported fields
}

System is an explicit unrestricted capability. It never resolves a principal, builds caller policy, or invokes caller hooks.

func (System[P, A]) Prepare

func (system System[P, A]) Prepare(request golem.FrozenReadRequest) (PreparedRead, error)

type SystemTx

type SystemTx[P, A any] struct {
	// contains filtered or unexported fields
}

SystemTx is the opaque unrestricted transaction capability used by generated system transaction clients.

func CallerTxSystem added in v0.3.2

func CallerTxSystem[P, A any](transaction *CallerTx[P, A]) *SystemTx[P, A]

CallerTxSystem is the policy escape: it returns the unrestricted system stance for the caller transaction's own transaction, execution binding and execution identity, so a write it performs commits or rolls back with every caller write in the same transaction. Nothing it does is policy-checked. Every call emits a transaction.system_escape observation so a deployment can count how often application code leaves the authorized path. It returns nil for a transaction that never owned a caller execution.

type ValidatedEvent

type ValidatedEvent = typedvalue.ValidatedEvent

Jump to

Keyboard shortcuts

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