Expand ↗
Page list (46)
anuna

Extension points

The dialect mechanism — CBCL’s homoiconic self-extension surface. A dialect is itself a CBCL message in S-expression syntax. Installation runs through three gating safety checks (R1, R2, R3), one closure check (DCFL tag preservation via msg_tag.rs), and finally lands in the per-agent DialectRegistry. Once installed, the agent runtime dispatches incoming messages by pattern-matching against installed performatives and expanding their templates under R2 fuel. Dialects propagate between agents via the gossip protocol, with safety re-checked at the receiving end.

This is the architectural distinguisher of CBCL: agents define and exchange new vocabularies at runtime without escaping the DCFL complexity class. Lean theorem dcfl_preserved (lean-cbcl/LeanCbcl/DeterministicUnion.lean) proves that installing a fresh-named dialect into an agent with unique dialect names preserves DCFL membership of the agent’s message language. R3CorePreservation.lean’s install_preserves_core + install_no_core_redefinition compose to the runtime guarantee that the eight core performatives can never be shadowed.

graph LR
    dialect-source["Dialect Source\n(S-expression text)"]
    dialect-parser["Dialect Parser\ncrates/cbcl-parser/src/dialect_parser.rs"]
    registry["Dialect Registry\ncrates/cbcl-core/src/dialect.rs"]
    template-expand["Template Expansion\ncrates/cbcl-core/src/template.rs"]
    r1-check["R1 No Recursion\ncrates/cbcl-core/src/r1.rs"]
    r2-check["R2 Resource Bounds\ncrates/cbcl-core/src/r2.rs"]
    r3-check["R3 Core Preservation\ncrates/cbcl-core/src/r3.rs"]
    msg-tag-check["DCFL Tag Preservation\ncrates/cbcl-core/src/msg_tag.rs"]
    gossip-propagation["Gossip Propagation\ncrates/cbcl-core/src/gossip.rs"]
    agent-runtime["Agent Runtime\ncrates/cbcl-core/src/agent.rs"]

    dialect-source --> dialect-parser
    dialect-parser -->|"parse_dialect"| r1-check
    r1-check -->|"DFS sound + complete"| r2-check
    r2-check -->|"static bounds OK"| r3-check
    r3-check -->|"no core override"| msg-tag-check
    msg-tag-check -->|"dcfl_preserved"| registry
    registry -->|"installed"| agent-runtime
    agent-runtime -->|"message dispatch"| template-expand
    template-expand -->|"R2 fuel"| agent-runtime
    registry -.->|"install + propagate"| gossip-propagation
    gossip-propagation -.->|"merges into peer"| registry

Components

Dialect parser (crates/cbcl-parser/src/dialect_parser.rs). Parses an S-expression dialect source into a structured dialect term ready for safety checks.

R1 — no recursion (crates/cbcl-core/src/r1.rs). DFS over performative templates. Sound and complete (Lean: r1_mutual_sound + dfsNoCycle_complete).

R2 — resource bounds (crates/cbcl-core/src/r2.rs). Validates that ResourceBounds (depth, expansion, time) are within the agent’s configured ceilings; the runtime version of the check enforces them per-message via fuel consumption.

R3 — core preservation (crates/cbcl-core/src/r3.rs). The eight core performatives (tell, ask, reply, hello, bye, ok, error, cancel) cannot be redefined. Lean: R3CorePreservation.install_preserves_core + install_no_core_redefinition.

DCFL tag preservation (crates/cbcl-core/src/msg_tag.rs). Deterministic tagging shows the new dialect’s grammar union remains decidable. Lean: dcfl_preserved.

Dialect registry (crates/cbcl-core/src/dialect.rs). Per-agent store of installed dialects.

Template expansion (crates/cbcl-core/src/template.rs). Pure declarative pattern→template substitution. Iteration, recursion, and reflection are all forbidden by R1; expansion size and depth are capped by R2 fuel. Used by the evaluator at message-dispatch time.

Gossip propagation (crates/cbcl-core/src/gossip.rs). Newly installed dialects spread between agents via an epidemic gossip protocol with configurable topology (fully-connected, ring, random). Each receiving agent re-runs R1/R2/R3 + DCFL tag check before installing — propagation does not bypass safety.

Agent runtime (crates/cbcl-core/src/agent.rs). Dispatches incoming messages by pattern-matching against installed performatives.

Constraint

R1, R2, R3 must hold at install time and stay enforced during message dispatch. Plus the DCFL closure condition: msg_tag.rs’s deterministic tagging must show the new dialect’s grammar union remains decidable. Failing any check returns a DialectInstallError; partial installs are not possible.

See also