Skip to content
Beskid The Beskid Book

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

15.3 Generator, Analyzer, Rewriter

What each mod contract may change—and what happens when they disagree.

Generator, Analyzer, Rewriter

Three roles, one merged program. Order matters; host merge is bounded and fail-closed.

  • Emits typed AST fragments only.
  • Host merges, re-parses, repeats up to maxGeneratorRounds.
  • Incremental by default—don’t regenerate the universe per keystroke.

Spec: Typed emitter and transforms.

  • Runs on host + generated code after semantic snapshot exists.
  • Emits diagnostics; may register rewrites as fixes.
  • Must not assume generated code is “second class”—it’s all one program now.

Spec: Analysis, query, and diagnostics facades.

// Conceptual shape — see SDK for exact signatures
Result<TTargetNode, FixError> Rewrite(TSourceNode sourceNode);

Replaces any valid node with any other valid typed node—power with responsibility. Conflicts → diagnostics, not silent corruption.

Scheduling and determinism: Incremental scheduling and determinism. When two mods fight over the same node, the host picks a documented winner or fails—read the ADRs before betting production on undocumented merge luck.

beskid mod CLI