Roux.Runtime.Context (roux v0.2.2)

Copy Markdown View Source

Threaded context passed through query execution.

A plain struct recording the execution state for a single query call chain: the active query, the query stack (for cycle detection), accumulated dependencies, created entities, and the minimum durability across transitive inputs.

This module is intentionally independent of Roux.Runtime — it is a data structure, not behavior. Cycle detection reads query_stack without any Runtime dependency.

Fields

  • db — the database handle.
  • active_query — the currently executing query, or nil if at top level.
  • query_stack — stack of active queries from outermost to innermost. Used for cycle detection.
  • recorded_deps — dependencies accumulated during the current query's execution. Flushed to the memo entry on completion.
  • created_entities — entities created during the current query's execution. Flushed to the memo entry on completion.
  • min_durability — the minimum durability level seen across all inputs read transitively. Propagated to the memo entry for the durability optimization. Starts at :high (identity for min).
  • code_version — the code version of the active query (Roux.Query), stored with its entry.
  • blobs — the Roux.Blob digests the active query's value names (Roux.Runtime.hold/1).

Summary

Functions

Creates a new context for the given database handle.

Types

t()

@type t() :: %Roux.Runtime.Context{
  active_query: Roux.Memo.query_key() | nil,
  blobs: [String.t()],
  code_version: binary() | nil,
  created_entities: [{module(), Roux.Entity.entity_id()}],
  db: Roux.Database.t(),
  min_durability: Roux.Revision.durability(),
  query_stack: [Roux.Memo.query_key()],
  recorded_deps: [Roux.Memo.dependency()]
}

Functions

new(db)

@spec new(Roux.Database.t()) :: t()

Creates a new context for the given database handle.