Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Syntax domain model generation - Design model

Platform spec article

Syntax domain model generation - Design model

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

This article documents the design model for SyntaxMirror domain model generation.

Collector predicates compile to keys over syntax identities from this model. The host regenerates or diffs snapshots so Generator and Rewriter never observe torn trees.

  • Compilation instance — active host compilation under transformation.
  • Syntax snapshot — immutable tree with stable node identities for incremental keys.
  • SyntaxMirror projection — Beskid-facing typed mirror of syntax nodes with query/AST operation contracts.
  • Rust AST in beskid_analysis is authoritative; SyntaxMirror is generated/mirrored for mod packages.
  • Legacy MetaDefinition nodes are removed from the mirror inventory.
  • The Rust inner item enum (syntax::Node) is host-only and is not emitted into the Mod SDK. Mod packages see Node contract + NodeRef instead.

beskid_ast_reflect_gen emits, under Beskid.Syntax.Nodes:

ArtifactRole
Per-type shape .bdStruct/enum mirrors for typed emit and rewrite (FunctionDefinition, …)
Node.bdpub contract Node — kind, ref, child push
NodeRef.bdOpaque stable handle
NodeSpan.bdSpan DTO for one node in one generation
NodeKind.bdClassification tokens (mirrors query::NodeKind)
NodeList.bdVec<Node> as cons-list of NodeRef
TraversalManifest.bdChild-slot table derived from Rust #[ast(child|children|skip)]

Traversal metadata must stay aligned with beskid_ast_derive::AstNode wiring in beskid_analysis.

Each node must have a stable identity within a syntax_generation_id window. Identities must survive trivia-only edits where language law marks them stable and must change on structural edits that affect collection predicates.

Torn tree prohibition — Hosts must not expose partial syntax trees to mod contracts. Parse failures abort the current generation round with diagnostics, leaving the previous committed generation untouched.

Multi-root workspaces — Identities must be qualified by normalized root path + in-root span so different projects cannot collide in caches.

  • Query-pipeline transforms run against one immutable SyntaxSnapshot generation and produce one new committed generation on success.
  • Pipeline application must be transactional: validation completes before any mutation becomes visible to mod code.
  • Span propagation is explicit:
    • untouched nodes preserve original spans;
    • replaced nodes receive source spans from replacement payloads when available;
    • synthetic nodes may use host-synthetic spans but must remain diagnosable.