PtcRunner.Lisp.Eval.Effects (PtcRunner v0.14.0)

Copy Markdown View Source

Canonical evaluator audit effects and their ordering algebra.

Effect lists are stored newest-first while evaluation is in progress. Merging therefore places the newer delta before the older value. Prelude call counts add, and newer cache writes win key conflicts.

Summary

Functions

Adds prelude-call counts without changing other effect fields.

Returns effects in their public chronological representation.

Computes the effects added to a cumulative value after a baseline.

Returns an empty effect value.

Merges a newer effect value onto an older one.

Merges effect deltas already ordered by ascending semantic execution order.

Records one cache write.

Records one parallel-call ledger entry in newest-first order.

Increments one public prelude-call count.

Records one already-bounded print in newest-first order.

Records one already-compacted tool ledger entry in newest-first order.

Types

t()

@type t() :: %PtcRunner.Lisp.Eval.Effects{
  pmap_calls: [map()],
  prelude_call_counts: %{required(String.t()) => non_neg_integer()},
  prints: [String.t()],
  tool_cache: map(),
  tool_calls: [map()]
}

Functions

add_prelude_counts(effects, counts)

@spec add_prelude_counts(t(), %{required(String.t()) => non_neg_integer()}) :: t()

Adds prelude-call counts without changing other effect fields.

chronological(effects)

@spec chronological(t()) :: t()

Returns effects in their public chronological representation.

delta(cumulative, baseline)

@spec delta(t(), t()) :: t()

Computes the effects added to a cumulative value after a baseline.

List suffixes and count baselines are removed. Cache entries are retained when their value differs from the baseline, including overwrites of an existing key.

empty()

@spec empty() :: t()

Returns an empty effect value.

merge(newer, older)

@spec merge(t(), t()) :: t()

Merges a newer effect value onto an older one.

Lists remain newest-first, counts add, and newer cache entries win.

merge_ordered(ordered_effects)

@spec merge_ordered([t()]) :: t()

Merges effect deltas already ordered by ascending semantic execution order.

record_cache(effects, key, value)

@spec record_cache(t(), term(), term()) :: t()

Records one cache write.

record_pmap_call(effects, pmap_call)

@spec record_pmap_call(t(), map()) :: t()

Records one parallel-call ledger entry in newest-first order.

record_prelude_call(effects, ref)

@spec record_prelude_call(t(), String.t()) :: t()

Increments one public prelude-call count.

record_print(effects, message)

@spec record_print(t(), String.t()) :: t()

Records one already-bounded print in newest-first order.

record_tool_call(effects, tool_call)

@spec record_tool_call(t(), map()) :: t()

Records one already-compacted tool ledger entry in newest-first order.