Skip to content

Syntax tree compatibility

The syntax tree is a public API. Every consumer that compiles Screenplay to something - a code generator, a designer, a documentation tool - is written against these types, so what the tree promises across versions decides how much work a Screenplay upgrade costs them.

This page states those promises. It is deliberately narrow: a guarantee you cannot rely on is worse than one that was never made.

ApplicationSyntax.Agents is nullable and init-only. Both syntax writers omit it when absent, preserving legacy syntax bytes. An explicit block contains ordered AgentOperationSyntax entries and an AgentTokensSyntax declaration under AgentsSyntax; operation kind is carried as syntaxKind, separately from the node’s kind. Scope and description remain authored fields, not inferred permissions. These three node kinds are registered in the native schema and generated TypeScript contracts. An explicit block, including an empty one, selects ESM v42; absence retains the model’s earlier executable version. See Agents.

SampleDataValueKind.Rows = 4 is additive; the existing enum values, positional constructor and deconstruction of SampleDataFieldSyntax are unchanged. Its init-only Rows sequence defaults to empty and is omitted from syntax JSON when empty, including on legacy scalar fields. syntaxKind: "Rows" distinguishes an explicit empty collection from an omitted field. Nonempty child rows keep authored order and recurse through the same row/field syntax. Only collections of declared top-level types admit nested rows; read-model shapes remain invalid member types (PLAY0273). See sample data.

No AST shape changes. Direct and wrapped file/tagged-fence handler forms now accept produces; PLAY0035 is retired and permanently reserved. The binder admits only resolved nonempty bodies with unconditional productions, using the existing ESM v23 handler reference and context/result v1. Pending hints, legacy bodyless models and canonical model bytes are unchanged. Resolution, language, body location and hash remain sidecar metadata; reference execution still reports ImplementationBody. See commands.

Decision 0110 adds nullable init-only Subject properties to ScreenActionSyntax, ScreenGuardedActionSyntax and ToolbarItemSyntax, plus ordered init-only Inputs on plain actions. Positional constructors and deconstruction arities are unchanged. TypeScript adds optional equivalents. JSON omits absent subjects and empty inputs; unknown subject enum values and subjects on non-action toolbar items are rejected. Raw compile/parse and printing preserve authored syntax. Effective semantics require native ScreenActionSubjects.Resolve(application) or TypeScript resolveActionSubjects(application); neither mutates its input. See action subjects for the paired fixture/context boundary.

Decisions 0106/0107 add optional ApplicationSyntax.TimeZone, CommandSyntax.Calendar, SpecificationSyntax.GivenTimeZone and ComparisonConditionSyntax.LeftExpression members. They are omitted from JSON when absent, so legacy syntax vectors retain their bytes. The comparison’s existing string Left remains unchanged for paths; for a clock operand it contains canonical text and LeftExpression holds the structured expression. ClockOffsetExpressionSyntax and DateOfExpressionSyntax may appear on either side. A bare today or now is still a path, not a globally reserved keyword.

A model that uses these additions binds to ESM v37 (decisions 0106 and 0107). See commands.

Every node is a positional record deriving from SyntaxNode, which carries a SourceLocation. Nodes are immutable, compare by value, and support with expressions. A construct with several forms - an expression, a policy condition, a projection block, a screen directive, a projection mapping, a projection key, a validation block, a constraint - is an abstract base record with a concrete record per form.

That shape is stable. Nodes will stay records, stay immutable, and keep deriving from SyntaxNode.

A node kind can be added. New constructs arrive as new record types. If the new type derives from an existing abstract base, it starts appearing in collections you already read - see the caveat below. If you consume the tree through ScreenplaySyntaxWalker, a new kind arrives as a new Visit method with a default implementation that walks its children, so your subclass compiles unchanged and keeps walking. That is the property the walker exists to give you.

An unknown form never throws. The walker dispatches abstract bases with a fallback: a concrete form it does not recognize is passed to VisitNode and then left alone. A tool compiled against an older Screenplay does not fault on a document using a newer construct - it silently does not act on it, which is the recoverable failure.

Enum members keep their numeric values. SliceType, ValidationRuleKind, ComparisonOperator, LogicalOperator, AutoMapMode and CaptureWhenKind gain members at the end and never renumber existing ones. This one matters more than it looks: the C# compiler inlines an enum constant into the consuming assembly, so renumbering a member changes behavior in an already-compiled consumer with no error anywhere - the value it was built with silently means something else. New members are therefore always appended.

public const values never change. The diagnostic codes are public const string, and a const inlines into consumers exactly the way an enum member does. A code’s value is fixed once published; a diagnostic that changes meaning gets a new code rather than a new value on the old one. The same rule applies to every other published constant, such as QuerySyntax.ObservableModifier and PropertySyntax.IdentifierModifier.

A node grows by init-only property, not by a new parameter. A node gaining an optional value gains it as an init property on the record body, so the primary constructor and Deconstruct keep the exact signature they were published with. Positional construction you already wrote keeps compiling, with expressions reach the new value like any other, and it participates in equality and ToString the same way a parameter would.

Appending a trailing optional parameter instead looks equivalent and is not. It is source compatible and binary breaking: the compiler emits a different primary constructor and a different Deconstruct, so an assembly built against the previous version calls a member that no longer exists and fails at run time with a missing method - with no error at compile time anywhere. It has shipped once, Cratis.Arc.Screenplay built against 1.5.2 breaking against 1.7.0 exactly this way. Package validation now fails the build that would repeat it, so the guarantee is enforced rather than intended.

Authoring metadata follows this rule: SpecificationSyntax.Description and the Documentation members on modules, features, slices, commands, read models and reactions are nullable init-only properties. They appear in the syntax transport schema, not in the executable semantic model. Preserve them when rewriting a declaration.

SpecificationSyntax.GivenCallerPersona is an additive init-only reference with a name and location, distinct from GivenCaller. It is omitted from syntax JSON when absent, preserving untouched documents’ bytes. A reader that predates the persona member must reject the new member rather than silently interpret an unauthenticated caller. Effective syntax expands the reference and carries SpecificationValueOrigin.Persona with persona and policy provenance; it adds no ESM member or version.

ScreenActionSyntax.Presentation is an init-only IEnumerable<PresentationValueSyntax>, defaulting to empty; the positional constructor and deconstruction are unchanged. TypeScript exposes optional presentation with PresentationValueSyntax entries. Each entry has name, value and its source location. Preserve authored order and unknown keys/values during AST rewrites.

AST JSON omits an empty collection and accepts older actions without the member as empty. Readers reject explicit null, wrong shapes, duplicate keys, empty keys and empty/whitespace placement values. Writers preserve erroneous presentation on partially typed documents so authoring tools can describe them alongside diagnostics; this does not make those documents valid reader input. Nonempty presentation requires an explicit item subject. The UI contract exposes a key-sorted string dictionary in scene.actions; UiAction and the ESM are unchanged, and no executable schema version is selected by the hint.

ApplicationSyntax.ReactionProductionMode is a nullable init-only ReactionProductionMode enum. The only admitted value is Atomic, authored as application-root reaction batches atomic; absence preserves legacy behavior and is omitted from syntax JSON. The scalar is visible to VisitApplication, not a new child node. Folder layout keeps it only in the root document, and imported reactions inherit it. Strict transport readers reject unknown values. ESM v22 writes the distinct optional final application member reactionProductionMode: "atomic"; consumers must preserve the choice during source recovery or refuse it.

ApplicationSyntax.CommandReadMode is a nullable init-only CommandReadMode enum, with the sole value Protected. Application-root command reads protected selects it; syntax JSON writes commandReadMode: "Protected" only when present. The scalar is visible to VisitApplication, not a child node, and duplicates or conflicting/non-root declarations report PLAY0780. Folder layout keeps it in the application root; imported commands inherit it. Preserve it during rewrites and source recovery.

ESM v28 admits Uuid == and != command conditions without changing AST kinds or adding ESM members or value variants. A literal stays a text constant, typed from the other condition operand only at v28 or later and checked as a canonical Uuid. Older readers and validators reject the shape. This does not change equality in specification expectations, keys or constraints. See Uuid equality.

ESM v26 admits chronological Date/DateTime command comparisons without changing AST kinds or adding ESM members or value variants. A literal stays a text constant, typed from the other condition operand or validation subject only at v26 or later. Canonical date text is yyyy-MM-dd; canonical DateTime text is UTC with seven fractional digits and Z. Older readers and validators reject the shape rather than interpreting it as text comparison. This does not change ordinal equality in specification expectations, keys or constraints. See command date comparisons.

ESM v25 writes the distinct optional final application member commandReadMode: "protected", plus each command’s admitted reads entries (name, readModel, key, presence: "required"). Read-path expressions record kind: "readPath", read and the view property id; condition property operands carry the read name. Earlier ESM readers and programmatic validators reject these members instead of silently losing protection. Omission preserves earlier bytes, version and legacy refusals. Consumers must explicitly admit the version or refuse it; reference execution and target realization are separate verdicts.

Generation rule bodies and checksum validation

Section titled “Generation rule bodies and checksum validation”

GenerationSyntax.File and .Code are nullable init-only members; old omissions remain absent in transport. They belong to generate rule Name, independently of a concept’s provenance file. Preserve and walk them when rewriting concepts. Exactly one direct source is required for executable admission. ValidationRuleKind.Checksum and the semantic counterpart are appended enum members; earlier numeric values are unchanged. Checksum uses the existing rule operand and severity/message envelope.

ESM v21 generation has only authored pattern/checksum, exact Int64 min/max, or implementation requirement id members, according to strategy. No current year, support counts, proof status or body bytes serialize. A ValueGeneration requirement and its Now/Tenant typed-context descriptor belong to the same compilation and attachment manifest; an ESM-only reader cannot invent them. Consumers explicitly admit v21 or reject it. Earlier ESM and corpus bytes are frozen.

NavigationTargetSyntax adds optional init-only Screen (JSON/TypeScript screen), a selected page-capable executable screen in the exact Module.Feature path. The existing C# three-argument constructor and three-output Deconstruct remain unchanged. Old JSON without screen still reads and serializes without the member; the schema does not require it. Omitting it preserves the consumer’s landing fallback. Missing or invalid explicit destinations do not fall back during compiler validation.

The member survives syntax printing, JSON and walking; hierarchy refactorings keep it, while renaming a selected screen or moving its owning slice requires coordinated typed edits. Scene conversion and Stage need consumer updates to preserve and honor the destination. No executable UI-contract version or global startup policy changes here.

Screenplay 6 replaced LayoutSyntax.Navigation, ModuleSyntax.Navigation, ModuleSyntax.Toolbars, FeatureSyntax.Toolbars and SlotSyntax.Contributes with outlets: a layout, screen template, dialog template, module, feature and screen carry an init-only Outlets collection of OutletSyntax (Name, a nullable Kind, Mode, Items, and optional Subject, Slot, Hides and Logo). The JSON omits outlets when empty. OutletKind (Actions, Filters, Tabs, Stats, Navigation), OutletMode (Unspecified, Inherit, Extend, Override) and OutletPlacement (Before, After) are append-only enums: a declaration carries a kind and no mode, a lower level a mode and no kind. Items derive from OutletItemSyntax (Id, Title, IsDefault, Position): ToolbarButtonSyntax, OutletGroupSyntax, OutletFilterSyntax, OutletTabSyntax, OutletStatSyntax and NavigationItemSyntax, which nests sub-items in Children and holds its target in NavigationTargetSyntax. ContributionSyntax.Items holds the items a contribution adds. See Outlets.

ScreenToolbarSyntax.Buttons is an additive init-only collection of ToolbarButtonSyntax (Id, Title, optional Slice, Emphasis, Icon, Runs). The JSON omits buttons when empty and the optional members when null. ToolbarEmphasis (Primary, Secondary, Quiet) is append-only. See Toolbar buttons.

Screenplay 6 lets a screen stand outside a slice (decision 0166). The additions are all init-only members with empty defaults and new node kinds, so no positional record of the public tree changes: ApplicationSyntax.Shapes (ShapeSyntax: Name, Properties, optional Description) and ApplicationSyntax.Screens, ModuleSyntax.Screens and FeatureSyntax.Screens (the free ScreenSyntax), SliceSyntax.UsedScreens (UsesScreenSyntax: Screen, Provisions; a ScreenProvisionSyntax is Need, Query, optional By and Mappings of ScreenProvisionMappingSyntax, Field, Path), and ScreenNeedSyntax (Type, optional Alias), a new ScreenDirectiveSyntax. The JSON omits shapes, screens and usedScreens when empty, so a model without free screens serializes exactly as before. A ScreenSyntax a slice declares in its own body stays in SliceSyntax.Screens. See Free screens.

ScreenActionSyntax.Available and ScreenDataSyntax.Available are init-only members that default to empty, so no positional record of the public tree changes (decision 0169). They hold the available gates written under the element; the JSON omits the member when it is empty, so a screen without element gates serializes exactly as before. A consumer that renders elements should hide an element whose bound command or query is not available as well as one these gates close. The executable model carries the gates as "available" on a screen data entry and a screen action, and such a model is ESM v59.

AudienceAvailabilityRequirementSyntax.Negated is an init-only Boolean, not a positional constructor parameter, so the constructor of the public tree does not change (decision 0169). It is true for available for not <Audience> and false otherwise; a consumer that ignores it reads not Incident as Incident, so match on it wherever the audience is read. The executable model writes "negated":true only for a negated audience, and such a model is ESM v58.

ConceptSyntax.ValueNumbers is a nullable init-only collection of int32, not a positional constructor parameter. Absent numbers stay null and the syntax JSON omits valueNumbers, keeping existing documents’ bytes. Populated numbers parallel values in authored order; cardinality must match, numbers must be unique, and the concept must be an enum. Preserve the distinction between absent and populated numbers when rewriting. Positional pins retain the original executable bytes; other numbers select ESM v12 and become the optional canonical numbers member, parallel to ESM values. Consumers must explicitly admit that contract.

ReadModelSyntax.IsPassive is an additive default-false init property, preserving constructor and Deconstruct signatures. Syntax JSON omits false and restores a missing member as false. Preserve it when replacing read-model nodes. It is realization metadata: the binder reports PLAY0270 and carries canonical identities in SemanticCompilation.PassiveReadModels, outside portable ESM. Toggling it changes neither executable bytes nor revision; renderers must hash the sidecar separately. See Passive decision state.

ReadModelSyntax.Sink, GraphSyntax.Sink and ApplicationSyntax.Sinks are additive init properties, preserving constructor and Deconstruct signatures. Syntax JSON omits them when absent or empty and restores a missing member as absent. SinkSyntax is a new node kind whose kind of storage is the stores member. They are realization metadata: the binder reports PLAY0270 and carries the choices in SemanticCompilation.Sinks, ReadModelSinks and GraphSinks, outside portable ESM. Changing a sink changes neither executable bytes nor revision; renderers must hash these members separately. See Sinks.

PropertySyntax.IsKey, QuerySyntax.ByParts, ReadsSyntax.ByParts, ProducesSyntax.Stream, ReactionSyntax.From and ReducerSyntax.From are additive init-only properties. Constructors and Deconstruct signatures stay unchanged. Missing members default to false, empty collections or null. Writers omit those defaults. Preserve authored key-part and mapping order when rewriting nodes.

A pending HandlerSyntax.Implementation may coexist with unconditional CommandSyntax.Produces. This selects ESM v23 without a new syntax node: the command’s final optional handler member carries requirementId and resultVersion: 1, while ordered hints and Pending attachment state stay in the sidecar. Required event payload properties may be unmapped because produces is the result contract, not its implementation. Older ESM readers must refuse v23 rather than discard the described body. File/inline handlers bind only as a constrained attachment: the command needs an unconditional produces result contract and the body must be resolved, nonempty and language-tagged with a valid content hash and reference, no hints and no ambiguity; otherwise binding refuses with PLAY0800. This does not mean arbitrary handler bodies execute. commands without a described handler retain their prior bytes. See Handler intent edits.

ObserverFilterSyntax carries an event source name, optional stream name and location. Routes and filters select ESM v10. Explicit single read-model keys preserve ESM bytes. Flat composite read-model identities mark several properties as identifiers, use keyParts for single-instance query arguments and kind: "parts" for projection keys, and select their own executable contract. Earlier readers reject these shapes. See AST authoring.

RemoveWithSyntax.PartsKey is a nullable init-only CompositeKeySyntax, beside the existing scalar Key. It holds the untyped key child block, defaults to null and is omitted from syntax JSON when absent. The walker visits its parts and expressions. Preserve it during source recovery; an earlier transport reader rejects the new member. A removal with both scalar and parts keys is invalid.

Set once, dictionary entries and children ordering

Section titled “Set once, dictionary entries and children ordering”

SetOnceMappingSyntax(Property, Source, Location) and RemoveKeyMappingSyntax(Property, Location) are additive MappingSyntax kinds for set once <target> = <value> and remove <target>. A dictionary-entry target, such as slots.$eventContent.slot, adds no node: the dynamic key stays in the existing Property text of any mapping kind, and the part before .$ is the property it writes into. The walker gains VisitSetOnceMapping and VisitRemoveKeyMapping.

ChildrenSyntax.Ordering is a nullable init-only ChildrenOrderingSyntax, not a new constructor or Deconstruct parameter. ChildrenOrderingSyntax(Placement, SortBy, Direction, Location) is an additive node; the additive enums are ChildrenPlacement (Append = 0, Prepend = 1, Sorted = 2) and ChildrenSortDirection (Ascending = 0, Descending = 1). SortBy is set only for Sorted. A block without an ordering line keeps Ordering null, and syntax JSON omits the member, preserving existing documents’ bytes; insert last is kept as an explicit Append. The walker gains VisitChildrenOrdering. Preserve the member when rewriting a children block.

On the executable side, SemanticProjectionOperation gains SetOnce = 6 ("operation":"setOnce"), and a children scope gains an optional ordering. Either selects ESM v43; a model that uses neither keeps its version and bytes, and insert last binds to no ordering. Dynamic keys and RemoveKeyMappingSyntax add no ESM member: the binder refuses them with PLAY0268. Older readers must reject v43 rather than drop set-once or ordering. See decision 0150.

ReactionSyntax.RunsAs is a nullable init-only ReactionIdentitySyntax, not a new constructor or Deconstruct parameter. ReactionIdentitySyntax(Kind, Roles, Location) is an additive node; its CLR Kind uses syntaxKind in typed syntax JSON to avoid the node discriminator. The walker gains VisitReactionIdentity, and generated transport and collection schemas describe the roles. Preserve RunsAs when rewriting a reaction. Old syntax JSON may omit the member; its default is null. A declared identity binds to the reaction’s runsAs member and selects ESM v10; omission preserves existing ESM bytes and revisions.

EventSyntax and ImportSyntax gain init-only Visibility (EventVisibility.Private by default) and nullable Origin. An origin-bearing declaration/import must have Public visibility. SliceSyntax gains nullable init-only Direction; its computed EffectiveDirection interprets an omitted Translate direction as inbound and is not serialized. Constructors and Deconstruct signatures are unchanged. Missing old JSON members default to Private/null/null, and writers omit these defaults, preserving legacy syntax bytes. Explicit Public, origin and direction values participate in structural equality and survive typed JSON and canonical printing.

C# SyntaxSchema owns the new optional fields; the generated transport/TypeScript mirrors are regenerated through the owning schema specification, not edited by hand, and the TypeScript parser reads and writes the same members. Any nondefault public-event metadata or explicit direction refuses semantic compilation with PLAY0268 (#481/#480); source authoring acceptance must not be confused with executable readiness. Preserve these fields when rewriting nodes.

Event-target projections and reducers (projection X => PublicEvent, #482) and source events captures (#483) add no AST member. A projection’s or reducer’s ReadModel text and a capture source’s Kind (events) and from settings carry them: whether => names an event or a read model is decided by resolution against the assembled model, never by the parser. CaptureEventsSource (C#) and consumedEvents (TypeScript) read the consumed events. Both refuse semantic compilation with PLAY0268.

ConceptAttributeSyntax.Name keeps the wire values pii and sensitive, even though source uses canonical pii/secret and accepts the personal alias. Scope, SpecialCategory and Criminal are additive init-only properties. Old JSON omissions default to null/null/false; writers omit those defaults to preserve existing syntax bytes. Preserve explicitly declared values when rewriting a concept. Compliance markers select ESM v13 and bind to optional SemanticConcept.Compliance; reasons remain report-only. Personal takes precedence over secret, and no secret scope is stored next to personal. Identity and enum compliance, and protected events with an explicit subject mark, are refused; see concepts.

EventStreamIdPartSyntax(Name, Type, Location) is additive. EventStreamSyntax.StreamIdParts contains declarations in identity-bearing declaration order. CommandStreamSyntax.StreamIdParts and SpecificationStreamSyntax.StreamIdParts contain PropertyMappingSyntax in authored mapping order. These init-only collections default to empty, including old JSON omissions; existing positional constructors and scalar members are unchanged. A nonempty parts list is mutually exclusive with StreamId. Part names are not workspace references; part types are ordinary type references. The walker visits parts, their types and route mappings. Composite stream ids are admitted by ESM v8. Models using them select that version; models without sources or routes retain their existing ESM version and bytes.

IdentityExpressionSyntax(Path, Location) is an additive expression kind for $identity.<path>. Path contains only the text after $identity.. VisitIdentityExpression is an additive virtual walker method. $context.identity.<path> keeps its existing ContextExpressionSyntax kind and path; the printer preserves both spellings. The two forms bind to the same executable expressions and add no ESM member or version. Syntax transport consumers must support the new kind or reject it explicitly.

ApplicationSyntax.Identity is a nullable init-only property, never a new positional parameter. IdentitySyntax carries typed IdentityDetailSyntax entries with claim, query, inline code or file source nodes. Absent identity metadata is omitted from syntax JSON, preserving existing documents’ bytes. The walker visits all source children; syntax schema and TypeScript transport mirrors include the new kinds. Preserve the property during rewrites. The block adds no ESM member or version; executable reads of declared details refuse with PLAY0268 until admitted (#600).

The positional parameter list. Inserting a parameter, removing one, promoting an optional one to required, or appending a new one is a breaking change. The first three break source and binary; appending breaks binary only, which is the worse of the two to discover. Any of them is allowed in a major release and is enumerated in the release notes when it happens. If you construct nodes yourself, prefer named arguments and object initializers; if you consume them, prefer property access over deconstruction.

Exhaustive switch over an abstract base. A switch on ExpressionSyntax or ProjectionBlockSyntax with an arm per known form compiles today and still compiles tomorrow, but a form added later falls through. C# cannot check exhaustiveness over a type hierarchy, so this is a silent behavior change, not a compile error. Always write a default arm, or override the walker’s base-kind method (VisitExpression, VisitProjectionBlock, …) so the fallback is handled for you.

A collection’s element types. IEnumerable<ProjectionBlockSyntax> can start yielding a form your code has never seen. Code that casts elements to a concrete type rather than pattern-matching them will fault.

Hand-written traversal. Nothing protects a consumer that walks the tree with its own loops. A node gaining a child collection is invisible to it - the tree grew and the consumer silently stopped covering the document. This is the concrete reason to prefer the walker: a hand-written walk has no place for the language to tell you it changed.

  1. Derive from ScreenplaySyntaxWalker rather than writing the loops.
  2. Override the narrowest methods that answer your question, and call base unless you mean to prune.
  3. Pattern-match node forms; never cast, and always have a fallback.
  4. Treat an unrecognized form as “not my concern”, not as an error.
  5. Read diagnostics by Code, never by message text.

A consumer that does these five things is affected by a Screenplay release only when a construct it actively handles changes shape.