pub struct ChangeLogWrite<'a> {
pub object_type: &'a str,
pub modification_type: &'a str,
pub tenant_id: Option<Uuid>,
pub trace_id: Option<&'a str>,
pub schema_version: Option<&'a str>,
pub trace_context: Option<&'a str>,
pub actor_type: Option<&'a str>,
pub acting_for: Option<Uuid>,
pub pre_image: bool,
}Expand description
The framework-owned change-log row the mutation executor writes in-txn.
Carries only the fields the adapter cannot derive from the
app.mutation_response row it already holds: the DML verb and a NOT-NULL
object_type fallback. The changed-entity identity + payload (object_id,
object_data, updated_fields, cascade) are read from the function’s own
returned row inside the same transaction (see
DatabaseAdapter::execute_function_call_with_changelog).
This is the Change Spine transactional-outbox contract. Beyond the
object_type/modification_type + changed-entity columns, it stamps the
envelope: tenant_id (carried here, from SecurityContext),
trace_id (the W3C trace id of the originating request), schema_version
(the compiled schema’s content hash — a per-deployment constant),
trace_context (the full W3C trace context as JSON), actor_type /
acting_for (the request’s actor classification and, for a delegated agent,
the underlying human — #390), commit_time (clock_timestamp() at INSERT),
and seq (the table’s SEQUENCE default).
Fields§
§object_type: &'a strNOT-NULL fallback for object_type when the row’s entity_type is NULL.
Sourced from MutationDefinition.return_type (always present).
modification_type: &'a strThe DML verb written to modification_type (e.g. "INSERT",
"UPDATE", "DELETE", "CUSTOM"), from MutationOperation.
tenant_id: Option<Uuid>The tenant partition stamp written to the tenant_id UUID column — the
Trinity public-facing identifier, read from SecurityContext.tenant_id
at write time and never reconstructed from connection / RLS state
(RLS is PG-only; out-of-session spine consumers bypass it, so the row
must carry tenant identity explicitly). None (→ SQL NULL) for an
unauthenticated request, a request with no tenant, or a tenant
identifier that is not a UUID.
trace_id: Option<&'a str>The W3C trace id of the originating request, written to the trace_id
column so an outbox row links back to its distributed trace (the #392
perf tooling surfaces it as the investigation handle). Read from the
request’s traceparent header at write time; None (→ SQL NULL) for a
request without a trace context — e.g. an unauthenticated mutation, which
carries no SecurityContext to stamp.
schema_version: Option<&'a str>The compiled schema’s version written to the schema_version column so an
outbox row records which deployment produced it — the replay /
zero-downtime correctness handle for #378 (reject a row replayed under a
different schema). A per-deployment constant derived from the compiled
schema (CompiledSchema::content_hash()), not from the request, so it
changes on any schema change. None (→ SQL NULL) for producers with no
compiled schema in scope — cooperative external producers (ETL) and the
non-PostgreSQL no-op path.
trace_context: Option<&'a str>The originating request’s full W3C trace context as a JSON object
({version, trace_id, parent_id, trace_flags, tracestate?}), written to the
trace_context JSONB column so a row carries enough to re-propagate /
reconstruct the distributed trace — not just the scalar trace_id. Carried
here as pre-serialized JSON text (the adapter binds it to the JSONB
column). Built from the request’s traceparent / tracestate headers at
write time; None (→ SQL NULL) for a request without a valid trace context,
consistent with trace_id.
actor_type: Option<&'a str>The request’s actor classification written to the actor_type column (the
snake_case ActorType token: "human_user", "service_account",
"ai_agent", "system_job"), from SecurityContext.actor_type() at write
time (#390). None (→ SQL NULL) for a request with no SecurityContext to
stamp (an unauthenticated mutation), or a cooperative external producer.
acting_for: Option<Uuid>For a delegated agent request, the underlying human the agent acts for
— the public-facing UUID, written to the acting_for UUID column from
SecurityContext.acting_for() (#390). Mirrors tenant_id’s UUID shape so
it is stamped without a DB lookup. None (→ SQL NULL) for a non-delegated
request, an unauthenticated mutation, or a subject that is not UUID-shaped.
pre_image: boolWhether this outbox write also records the changed entity’s pre-image
(before-state) into the object_data_before JSONB column, sourced from the
function’s own entity_before (the after-image comes from entity). Set
from MutationDefinition.changelog_pre_image; false (the default) leaves
object_data_before out of the INSERT entirely (NULL), byte-for-byte
today’s behavior. The changed-entity payload itself is read from the
returned row inside the outbox CTE, so this flag only selects which SQL
form the adapter emits.
Implementations§
Source§impl<'a> ChangeLogWrite<'a>
impl<'a> ChangeLogWrite<'a>
Sourcepub const fn new(object_type: &'a str, modification_type: &'a str) -> Self
pub const fn new(object_type: &'a str, modification_type: &'a str) -> Self
Build a change-log write descriptor with no envelope stamps (tenant_id,
trace_id, schema_version, trace_context, actor_type and
acting_for NULL). Chain with_tenant_id /
with_trace_id /
with_schema_version /
with_trace_context /
with_actor_type /
with_acting_for to stamp them.
Sourcepub const fn with_tenant_id(self, tenant_id: Option<Uuid>) -> Self
pub const fn with_tenant_id(self, tenant_id: Option<Uuid>) -> Self
Stamp the tenant partition id (the Trinity public-facing UUID) onto the
outbox row. None leaves tenant_id NULL — for system / unauthenticated
rows, or a tenant identifier that is not UUID-shaped.
Sourcepub const fn with_trace_id(self, trace_id: Option<&'a str>) -> Self
pub const fn with_trace_id(self, trace_id: Option<&'a str>) -> Self
Stamp the originating request’s W3C trace id onto the outbox row. None
leaves trace_id NULL — for a request with no trace context.
Sourcepub const fn with_schema_version(self, schema_version: Option<&'a str>) -> Self
pub const fn with_schema_version(self, schema_version: Option<&'a str>) -> Self
Stamp the compiled schema’s version (its content hash) onto the outbox
row. None leaves schema_version NULL — for producers with no compiled
schema in scope (cooperative external producers, the non-PostgreSQL no-op
path).
Sourcepub const fn with_trace_context(self, trace_context: Option<&'a str>) -> Self
pub const fn with_trace_context(self, trace_context: Option<&'a str>) -> Self
Stamp the originating request’s full W3C trace context (pre-serialized JSON
text) onto the outbox row’s trace_context JSONB column. None leaves it
NULL — for a request with no valid trace context, or a non-PostgreSQL
no-op / cooperative producer.
Sourcepub const fn with_actor_type(self, actor_type: Option<&'a str>) -> Self
pub const fn with_actor_type(self, actor_type: Option<&'a str>) -> Self
Stamp the request’s actor classification (the snake_case ActorType
token) onto the outbox row’s actor_type column (#390). None leaves it
NULL — for an unauthenticated mutation or a cooperative producer.
Sourcepub const fn with_acting_for(self, acting_for: Option<Uuid>) -> Self
pub const fn with_acting_for(self, acting_for: Option<Uuid>) -> Self
Stamp the delegated user’s UUID (the human a delegated agent acts for) onto
the outbox row’s acting_for column (#390). None leaves it NULL — for a
non-delegated request, an unauthenticated mutation, or a non-UUID subject.
Sourcepub const fn with_pre_image(self, pre_image: bool) -> Self
pub const fn with_pre_image(self, pre_image: bool) -> Self
Opt this outbox write into recording the changed entity’s pre-image into
the object_data_before column (from the function’s entity_before). When
false (the default), object_data_before is omitted from the INSERT
entirely, byte-for-byte today’s behavior. Set from
MutationDefinition.changelog_pre_image.
Trait Implementations§
Source§impl<'a> Clone for ChangeLogWrite<'a>
impl<'a> Clone for ChangeLogWrite<'a>
Source§fn clone(&self) -> ChangeLogWrite<'a>
fn clone(&self) -> ChangeLogWrite<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more