Skip to content

Export Screenplay metadata

A Screenplay document lets the model of your application live as text next to its code, so a pull request that adds a command also shows the model change. arc-gen can export the part of that model it knows from your Go declarations: command inputs, read models and their snapshot and observable queries.

The export is partial metadata, not an event model. Go analysis has no event, projection, reactor or slice descriptors yet, so the document says what it can and lists what it cannot as comments at the top of the file.

The export needs a formatVersion 2 profile, which carries the exact Go scalar types that distinguish Screenplay Int from Decimal and DateTime from a string. The profile name becomes the Screenplay domain, so it must be an ASCII identifier:

{
"formatVersion": 2,
"name": "Tasks",
"defaultNamespace": "Tasks",
"screenplay": { "out": "docs/model.play" }
}

From the application module:

Terminal window
GOWORK=off GOTOOLCHAIN=local arc-gen -config arc-gen.json ./features/...
GOWORK=off GOTOOLCHAIN=local arc-gen -config arc-gen.json -check ./features/...

screenplay.out is a .play file relative to the module root; the -screenplay-out flag sets or overrides it. The same input always produces the same bytes, regardless of package order, so -check can fail CI when the committed document drifts from source.

Enabling Screenplay, including through -screenplay-out alone, also enables wire analysis and endpoint verification in generated Go adapters. Like OpenAPI and TypeScript output, it requires a static namespace from source or the profile. Adding or dropping Screenplay as the only wire consumer changes endpoint-bearing adapters, not just the .play file. Pass the same profile, package scope, build tags and output flags to generation and -check; a check without the -screenplay-out flag used to generate the adapters reports them as stale. Changing only the output file location does not change endpoint verification.

Ownership works as for the OpenAPI document: a manifest in the module root (or the TypeScript output root when you also publish TypeScript proxies) records the file. arc-gen refuses to overwrite an unowned or hand-edited document, and deletes the owned document when the same profile and package/build scope stops requesting it. Unrelated adapter-only invocations leave that artifact manifest and its files alone. The file starts with the standard // Code generated by arc-gen … DO NOT EDIT. line.

For a Register command and a Listing read model with an All query that takes a Prefix argument and returns queries.Page[Listing], the body after the header comments is:

domain Tasks
type Listing
@id Int
@label String
type Register
@count Int
@name String
module Application
feature Metadata
slice StateChange CommandRegister
command Register
@count Int
@name String
slice StateView ReadModelListing
readmodel Listing
@id Int
@label String
query All => Listing[]
filter prefix String
  • Each command becomes a StateChange slice with its input properties.
  • Each read model becomes a StateView slice with its queries. Observable queries return observable types; query arguments become filter lines.
  • The Application module and Metadata feature are presentation grouping only. Go packages and HTTP routes are not treated as domain modules.

The grammar targets Cratis.Screenplay 4.48.1, the version pinned by C# Arc.

Comments at the top of the file name every omission (SPG001 to SPG104), for example:

  • Events, command event production, projections, reducers, reactions, constraints, specifications and screens are not in the analysis graph. Their absence from the document does not mean your application lacks them.
  • Authorization, validation rules, defaults, paging, sorting and command response values are omitted, and the affected artifact is named.
  • HTTP routes, binding and codecs are not a Screenplay contract.

Shapes Screenplay cannot express refuse the whole export with an error naming the artifact: maps, enums, concepts, opaque codecs, nested collections, nullable collection elements, empty models, commands without input, colliding type names and graph diagnostics. Nothing is renamed or flattened to make it fit.

C# Arc can embed generated documents and serve a read-only event-model explorer at /.cratis/event-model. Arc.Go does not: there is no embedded viewer and no HTTP route for the document. Open the committed .play file with the Cratis CLI or Screenplay tooling instead. The export also never starts your application, connects to Chronicle or reads stored events.