Skip to main content

Module trigger_contract

Module trigger_contract 

Source
Expand description

The deterministic contract behind state-trigger matching.

This module is the first explicit boundary in FeltDB between a deterministic semantic contract and the runtime that executes it. It exists so the question “did this committed change match this trigger?” can be answered identically by more than one implementation.

              canonical input bytes
                       │
        ┌──────────────┴──────────────┐
        │                             │
  native evaluation             WASM evaluation
        │                             │
        └──────────────┬──────────────┘
                       │
              canonical output bytes

The contract is not a plugin system. It defines one decision with one shape, and FeltDB remains authoritative for everything around it: state, committed changes, workload creation, idempotency, authorization, durability, provenance and execution lifecycle. A contract implementation returns a decision; it never mutates FeltDB.

§Determinism budget

Evaluation reads nothing but its input. It does not consult a clock, the filesystem, the network, a random source, or any process-global mutable state, and its output contains no values derived from any of those.

§Relationship to production

crate::state_trigger::StateTrigger::matches delegates to evaluate_trigger on the typed native path. Canonical bytes are the wire form used to carry the same input into another runtime; production evaluation does not pay for encoding on every candidate pair.

Structs§

ContractChange
The part of a committed change the decision actually depends on.
ContractErrorBody
The error body of a contract output.
ContractPredicate
The deterministic equality predicate the state-trigger evaluator already had.
ContractTrigger
The part of a trigger definition the decision actually depends on.
MatchOutcome
The decision.
TriggerMatchInput
The complete deterministic input to one trigger-match decision.
TriggerMatchOutput
The complete deterministic output of one trigger-match decision.

Enums§

ContractChangeKind
The kind of committed change, as the contract names it.
ContractErrorCode
Why an input could not be evaluated.
ContractRuntime
The runtime that executed a contract, recorded in evidence.
MatchReason
Why the decision came out the way it did.

Constants§

TRIGGER_MATCH_CONTRACT_ID
Stable identity of this contract. It is part of the input and the output so that a decision can never be silently attributed to a different contract.
TRIGGER_MATCH_CONTRACT_VERSION
Version of this contract’s input shape, output shape and semantics.

Functions§

canonical_input_bytes
The canonical byte encoding of a contract input.
canonical_output_bytes
The canonical byte encoding of a contract output.
evaluate_canonical
The runtime-independent entry point: canonical bytes in, canonical bytes out.
evaluate_canonical_output
evaluate_canonical before encoding, for callers that want the value.
evaluate_trigger
The deterministic contract, natively implemented.
input_digest
Content identity of a contract input, for provenance.