Skip to main content

Event-Serving Reference

Metadata​

  • Owner: Origo Engineering
  • Last updated: 2026-04-17
  • Slice/version reference: S14, S15, S16, S17, S18, S19, S20, S21, S39, S42, S43, S46, S47, S48, S50, S52, S56, S61

Purpose and scope​

  • User-facing reference for the event-driven serving semantics introduced in Slice 14 and expanded in S15/S16/S17/S18/S19.
  • Scope includes view_id/view_version, rights metadata fields, and canonical guarantee semantics used by Raw Query/Export.
  • Unified cross-surface success and failure semantics are anchored by docs/failure-semantics-reference.md.

Inputs and outputs with contract shape​

  • Query request extensions:
    • view_id: optional string
    • view_version: optional integer (>0)
    • rule: both must be set together or both omitted
  • Query response extensions:
    • sources: requested source list
    • view_id
    • view_version
    • rights_state
    • rights_provisional
  • Export submit/status response extensions:
    • rights_state
    • rights_provisional
    • source
    • view_id
    • view_version

Data definitions (fields, types, units, timezone, nullability)​

  • rights_state:
    • Hosted Allowed
    • BYOK Required
    • Ingest Only
  • rights_provisional: boolean (true when temporarily hosted under legal transition).
  • view_id: logical projection/view identifier string.
  • view_version: positive integer identifying immutable view contract version.
  • Canonical aligned serving sink:
    • table: canonical_aligned_1s_aggregates
    • required for Binance, OKX, Bybit, ETF, FRED, and Bitcoin-derived aligned serving paths in current scope.

Source/provenance and freshness semantics​

  • Served rows are projection outputs derived from immutable canonical events.
  • Canonical event rows carry full-envelope provenance:
    • permanent source identity: source_id, stream_id, partition_id, source_offset_or_equivalent
    • envelope metadata: domain_event_type, schema_version, correlation_id, nullable causation_id, producer_id, producer_version
  • Canonical source authority is enforced separately from exactly-once identity:
    • central registry: contracts/canonical-source-authority-v1.json
    • selector-aware families: ETF and FRED via record_source_id
    • rejected authority claims fail before append and are recorded in canonical_authority_conflicts
  • Canonical timestamp semantics are enforced separately from numeric field precision:
    • central registry: contracts/canonical-source-timestamp-semantics-v1.json
    • source_event_time_utc is the canonical family time reference, not always the highest-precision source-native event clock
    • ETF/FRED batch-day families, Bitcoin consensus-time families, and mempool snapshot-time families must be interpreted through that registry
  • Canonical dedup semantics are enforced separately from source authority and timestamp meaning:
    • central registry: contracts/canonical-dedup-strategy-v1.json
    • canonical dedup is authoritative only at the canonical write boundary
    • canonical dedup lookup is current-truth lineage, not raw append history alone
    • ETF and FRED canonical identity exclude value fields
    • proof-layer duplicate allowances and local cleanup remain visible but non-authoritative
  • Adapter boundary law is enforced separately from authority, time meaning, and dedup:
    • central registry: contracts/adapter-expected-contract-v1.json
    • authoritative model: deterministic invariants, consumed adjacent policy gates, and statistical drift monitoring
    • deterministic invariant failure is hard-stop and fail-loud before canonical write
    • drift is alert-only by default and must surface through runtime-audit and Slice 40 operator-visible truth
    • rejection evidence is stage-aware: pre_artifact_failure or artifact_backed_rejection
  • Canonical payload-schema law is enforced separately from envelope metadata and precision:
    • central registry: contracts/canonical-payload-schema-v1.json
    • schema key: (source_id, stream_id, schema_version)
    • domain_event_type remains taxonomy only and is not the schema key
    • validation target is canonical post-precision payload_json
    • invalid payloads fail before canonical append on writer-mediated and direct insert paths
    • runtime-audit emits canonical_payload_schema_rejection
  • Canonical source-pressure law is enforced separately from downstream store/client limits:
    • central registry: contracts/source-pressure-v1.json
    • registry scope is declared source-pressure subjects only
    • current live subjects are all pull
    • fixed controls cover source timeouts, source-safe concurrency, retry policy, worker-pool size, request window size, and source-safe pacing where declared
    • operator-visible distress surfaces are Dagster run failure, Dagster sensor/alert, runtime-audit evidence, and proof/quarantine state
    • push-source admission stays blocked until a durable platform-owned accept-then-drain buffer contract exists
    • retained raw artifacts are not sufficient to qualify as a push buffer
  • Pre-S39 historical rows can surface null metadata values until replay/rewrite completes; this is intentional so old thin-envelope rows do not pretend to carry valid provenance.
  • Canonical domain_event_type is a source/domain taxonomy. Runtime-audit event_type remains a separate system-operation taxonomy.
  • payload_raw and payload_sha256_raw remain the byte-level source provenance anchor.
  • Canonical storage ordering is per stream key (source_id, stream_id, partition_id) via stream_sequence, assigned at the store boundary.
  • Authoritative append concurrency is ClickHouse-only and optimistic. Origo does not use a second stream-head store or an external lease service.
  • The authoritative head components are:
    • canonical_stream_sequence_heads
    • canonical_event_log_active_v1
    • canonical_partition_reset_boundaries
  • Every authoritative append must target exactly one canonical stream key.
  • Same-stream multi-row append batches are allowed.
  • Mixed-stream authoritative append batches are rejected.
  • Cross-stream coordination is choreography only.
  • Cross-stream choreography uses separate stream-local canonical appends linked by explicit correlation_id; it does not use a shared commit boundary.
  • run_id remains execution identity and must not be treated as choreography identity.
  • The writer/input seam supports explicit correlation_id so choreography identity does not need to piggyback on run_id.
  • Compensation is represented as an ordinary stream-local canonical event that points to exactly one prior parent event via causation_id, with wider grouping on correlation_id.
  • Expected-head semantics are lineage-aware and include the current stream key, latest reset-boundary lineage, and current-truth last_stream_sequence.
  • Unreplayed pre-S42 rows may still keep null stream_sequence until rewrite cutover completes.
  • Any incremental write or idempotent dedup path that would match against those pre-S42 null-sequence rows must fail closed and requires replay/rewrite first; the system must not pretend those rows are safe incremental dedup targets.
  • Gap detection and continuity truth come from the raw append-only log, not from the current-truth active view.
  • Logical reset boundaries explicitly rebase current-truth head lineage for append concurrency.
  • Projector fetch/resume order and checkpoint/watermark progression must therefore follow stream_sequence.
  • Default current-truth reads that need canonical event-log truth must route through canonical_event_log_active_v1.
  • Raw append-only event-log history is forensic/proof-only and must route explicitly through canonical_event_log_history_v1.
  • Freshness semantics remain source-driven and warning-aware per endpoint docs, with ETF/FRED auxiliary freshness rules explicitly separate from canonical event time.
  • Projection rebuild and serving promotion are gated on terminal proof coverage during Slice 34 backfill.
  • Historical availability claims therefore mean terminally proved history, not merely source history that exists upstream.
  • Canonical append is the only business-truth write boundary after acquisition/normalization.
  • Native and aligned tables are read models only.
  • Canonical truth and first-class serving truth stay forever hot in ClickHouse:
    • canonical_event_log
    • canonical_event_log_active_v1
    • native historical serving tables
    • aligned_1s serving tables
  • Hot/warm/cold tiering is not part of the current Origo design.
  • Retained source files are rebuild substrate only where a governed substrate exists; they are not a consumer query tier.
  • Supported projection modes are:
    • projector: dedicated post-append projection path
    • deferred: append and proof now, projection or rebuild later
  • inline is not a supported runtime mode.
  • Authoritative partition completion is separate from proof and separate from raw/native/aligned row existence:
    • authority table: canonical_partition_completion_outcomes
    • only completion_state=complete may mean partition green/completed
    • terminal proof remains supporting evidence, not final success by itself
    • ordinary rerun refusal is allowed only from authoritative completion complete
  • User-visible native and aligned historical serving must remain dark until the same completion authority says complete.
  • Native/aligned rows written before completion promotion are provisional residue, not served truth.
  • Operational/proof control stores such as partition proofs, quarantines, checkpoints, and reset boundaries are not CQRS debt.
  • Any temporary non-serving legacy residue must be statically excluded from supported runtime surfaces and emit runtime-audit visibility on invocation.
  • The only sanctioned operator rebuild path for canonical projections is Dagster job origo_projection_rebuild_job.
  • The sanctioned rebuild path:
    • resets native rows, aligned aggregate rows, projector checkpoints, and projector watermarks together under one authority
    • replays current-truth canonical events from canonical_event_log_active_v1
    • treats append-only raw history as forensic/event-sourcing truth rather than the operator rebuild input for this slice
  • rebuild complete requires the full end-to-end hot truth chain:
    • canonical_event_log_active_v1
    • native historical serving tables
    • aligned_1s serving tables
    • required proof and promotion surfaces
  • canonical-only replay is not enough to claim rebuild completion.
  • Rebuild proof must include:
    • normalized content hashes
    • typed row-level diff explainers
  • Typed rebuild diff vocabulary:
    • bucket_mismatch
    • event_within_bucket_mismatch
    • metric_observation_mismatch
    • validity_interval_mismatch
    • coverage_mismatch
  • Volatile rebuild bookkeeping such as projected_at_utc, checkpointed_at_utc, and checkpoint run metadata is excluded from deterministic equality.
  • Served timestamps that already participate in serving semantics remain inside rebuild equality.
  • Historically valid pre-S39 null envelope metadata rows and bypass-writer canonical rows must remain rebuild-compatible; sanctioned rebuild must not pretend they disappeared.

Failure modes, warnings, and error codes​

  • Authoritative-surface disagreement is itself a hard failure:
    • Dagster green with missing or non-complete authoritative completion
    • Dagster red with authoritative complete
    • proof terminal while authoritative completion is not complete
  • Completion transitions and authoritative-surface disagreement must surface through runtime-audit; they may not remain manual forensic interpretation only.
  • Missing rights metadata in export tags is fail-loud (EXPORT_STATUS_METADATA_ERROR path).
  • Missing rights metadata in query response contract is fail-loud (response validation error).
  • Unsupported/missing view metadata combinations are rejected by request contract validation.
  • Binance aligned serving storage contract violations are fail-loud (missing table / schema drift).
  • OKX aligned serving storage contract violations are fail-loud (missing table / schema drift).
  • ETF aligned serving storage contract violations are fail-loud (missing table / schema drift).
  • FRED aligned serving storage contract violations are fail-loud (missing table / schema drift).
  • Bybit aligned serving storage contract violations are fail-loud (missing table / schema drift).
  • Bitcoin aligned serving storage contract violations are fail-loud (missing table / schema drift).
  • Exact duplicate source-event identity short-circuits to duplicate before stale-head conflict evaluation.
  • Stale-head conflict is not duplicate delivery; it is a fail-fast write conflict for append intent not already present in current truth.
  • Caller-visible automatic retry count on write conflict is 0.
  • Write conflict must surface in writer/runtime status and runtime audit rather than being silently repaired.
  • Adapter boundary rejection must surface through runtime-audit as adapter_boundary_rejection.
  • Adapter drift observation must surface through runtime-audit as adapter_boundary_drift.
  • strict=true warning escalation remains a 409 failure path on query/export surfaces that emit warnings.

Determinism/replay notes​

  • Determinism and parity proof execution references for event serving live under:
    • spec/slices/slice-14-event-sourcing-core.md
    • spec/slices/slice-15-binance-event-sourcing-port.md
    • spec/slices/slice-16-etf-event-sourcing-port.md
    • spec/slices/slice-17-fred-event-sourcing-port.md
    • spec/slices/slice-18-okx-event-sourcing-port.md
    • spec/slices/slice-19-bybit-event-sourcing-port.md
    • spec/slices/slice-20-bitcoin-event-sourcing-port.md
  • Generated proof evidence for the migrated completed slices is written under spec/slices-generated/<slice-slug>/ and is intentionally not committed.
  • Slice 34 closeout-prep reporting for proof coverage and manifest evidence is generated by:
    • spec/slices/slice-34-full-canonical-backfill/proof-s34-g1-g2-closeout-prep.json

Environment variables and required config​

  • ORIGO_SOURCE_RIGHTS_MATRIX_PATH
  • ORIGO_INTERNAL_API_KEY

Minimal examples​

  • Query with view metadata:
    • { "mode":"native", "sources":["binance_spot_trades"], "view_id":"aligned_1s_raw", "view_version":1, "n_rows":100, "strict":false }
  • Export status rights metadata shape:
    • { "rights_state":"Hosted Allowed", "rights_provisional":false, "source":"binance" }