proto/term.proto#
Normative. proto/** is part of specs/ ([STYL.2.14.1]); message names, field numbers, types and reserved ranges carry the same force as a clause of English ([STYL.2.14.2]). Cite this file as proto/term.proto and a message within it as proto/term.proto#<Message> ([STYL.2.14.3]). This page is the protobuf source, rendered.
/* SPDX-FileCopyrightText: 2026 Dan Finster and the Desert Sage Contributors */
/* SPDX-License-Identifier: BSD-4-Clause OR AGPL-3.0-or-later */
syntax = "proto3";
package ds.v1;
import "rete_expr.proto";
// TerminalNode atom — one terminal node (rule firing point) in the RETE network.
//
// node_id is globally unique across AlphaNode / BetaNode / TerminalNode atoms. 0 = null.
//
// parent_beta_id → BetaNode.node_id of the beta node whose token activates
// this terminal.
//
// rule_name references the rule the RuleCooldown / RuleSource / RuleDebugName
// atoms name. The loader reads the cooldown from RuleCooldown, and so on.
//
// bind_count: number of let-binding slots needed for RHS evaluation.
//
// actions: evaluated in order when the rule fires. Truth maintenance is an
// action's, not the terminal's: an ACTION_LOGICAL_ASSERT's fact takes the
// firing activation as its justifier ([IRET.12.1]).
TerminalNode#
message TerminalNode {
uint32 node_id = 1;
uint32 parent_beta_id = 2;
string rule_name = 3;
uint32 bind_count = 4;
// The action kind says which facts are truth-maintained ([RLOW.7.1.3]).
// RESERVED, never reissued.
reserved 5;
reserved "has_logical_lhs";
repeated Action actions = 6;
// Optional guard: a time-dependent condition, the cooldown's
// FN_RATE_ALLOW rate gate, or the condition AND the gate, in that
// order. The condition is read before the firing, the gate once
// inside it. The shapes and what a runtime does with each part are
// [RDSC.4a.8.2].
Expr fire_guard = 7;
// A DS binding names a fact. RESERVED, never reissued.
reserved 8;
reserved "pattern_vars";
// DS has no rule priority ([LSCO.3.10.1]): the agenda's outer key
// is the terminal ordinal assigned at load from TerminalNode order
// ([LDET.5.4]), which is not a wire field. RESERVED, never reissued.
reserved 9;
reserved "salience";
}
Action#
message Action {
ActionKind kind = 1;
Expr expr = 2; // for CALL
string schema_name = 3; // for ASSERT / LOGICAL_ASSERT
repeated SlotAssign assigns = 4; // for ASSERT / LOGICAL_ASSERT
// `ttl_override` ([LDTL.4.1]): per-emit TTL override for
// `emit … retain: <dur>` on a ttl-lifecycle schema, gated on dynamic_ttl: true.
// Evaluated at fire time to a duration; the asserted fact's deadline is
// `assert_ns + ttl_override_ns` instead of the schema default. Absent ⇒ use
// the schema TTL. A runtime that does not know this field rejects the
// artefact (reject-don't-skip) rather than silently applying the schema TTL.
Expr ttl_override = 5;
// for WITHDRAW ([LGRA.10.1], [LCYC.3.1.1]):
// the LHS pattern position of the positively-bound fact to withdraw, on
// the same addressing `VarExpr.pattern_index` uses. The
// compiler resolves `withdraw <binding>`'s NAME to this position; nothing
// at this level carries the source-level name.
uint32 withdraw_pattern_index = 6;
// for WITHDRAW_BY_ID (IRET.10.7): evaluates to a reference to the fact
// to withdraw, read from the capture fact of a nested body. A reference
// that names no live fact: the action does nothing.
Expr withdraw_fact_id = 7;
}
ActionKind#
enum ActionKind {
ACTION_CALL = 0;
ACTION_ASSERT = 1;
ACTION_LOGICAL_ASSERT = 2;
ACTION_WITHDRAW = 3;
ACTION_WITHDRAW_BY_ID = 4; // IRET.10.7
}
SlotAssign#
message SlotAssign {
uint32 slot_index = 1;
Expr expr = 2;
}