ApplyReceipt typedef

ApplyReceipt = ({ApplyArguments arguments, Cell cell, String? contextVersion, Function function, String id, int? ledgerSeq, String? pulseDigest, String? receptorVersion, String? ruleVersion, DateTime timestamp, int? txSequence, bool vetted})

The permanent, official record of a specific action taken by a cell.

ApplyReceipt is a detailed "proof of execution" created every time a command is submitted. It acts as a Forensic Marker, capturing exactly what happened, when it happened, and who was involved.

In the framework's biological metaphor, this is the "memory" of a nervous signal, stored in the ledger so the system can trace the cause and effect of every state change.

Why it is used

  • Causal Traceability: It allows developers and AI agents to look at any state change and see the exact command and arguments that caused it.
  • Transaction Auditing: It tracks whether an action was part of a larger transaction and where it sits in that sequence.
  • Security Verification: It records whether an action was "vetted" (checked against safety gates) or executed as a trusted internal operation.

How it works

A receipt is synthesized by the ApplyLedger and contains several identifying pieces of data:

  1. id: A unique string used to correlate requests with outcomes.
  2. timestamp: The exact moment the command was processed.
  3. vetted: A safety flag. If false, it means the action bypassed the standard integrity gates (usually because it was a trusted operation).

Technical Details

  • Immutable Record: Like other types in the apply system, this is a Dart record. It is read-only and designed to be stored in history logs without high memory overhead.
  • Correlation: The id is essential for asynchronous or transactional workflows where you need to match a result back to its original request.

See also:

  • ApplyOutcome — The result that carries this receipt.
  • ApplyLedger — The utility that generates these receipts.
  • ApplyCommand — The original request captured by this receipt.

Implementation

typedef ApplyReceipt = ({
  String id,
  Cell cell,
  Function function,
  ApplyArguments arguments,
  DateTime timestamp,
  int? txSequence,
  bool vetted,
  // Populated by Ledger.appendInternal; null on the receipt
  // returned by Cell.apply, non-null on the receipt stored in the ledger.
  int? ledgerSeq,
  String? pulseDigest,
  // Governance replay. Populated by Ledger.appendInternal from
  // the cell's live receptor/test-rule/context versions.
  String? receptorVersion,
  String? ruleVersion,
  String? contextVersion
});