Skip to content

Fragments

A fragment is a YAML file that defines the names one repo owns. Fragments compose: each imports the fragments it builds on and adds its own definitions. Nothing is registered centrally; the global catalog on the specs site is generated from every published fragment.

Where fragments live

Convention Rule
Location <repo>/naming/<fragment-id>.yaml
Id dotted, lowercase: virtufin.<area>[.<name>], e.g. virtufin.venue.binance, virtufin.service.workmanager
C# embed as a resource named naming/<file> and pack it under naming/ (see below); NameRegistry.Load(assembly) finds it in the assembly and every assembly it references
Python ship it as package data under <package>/naming/ and register the package in the entry-point group virtufin.naming; NameRegistry.load() finds it
TypeScript export the YAML text (e.g. NAMING_FRAGMENTS of @virtufin/domain-devkit and @virtufin/marketdata-devkit, embedded from naming/ at build); the caller composes it explicitly
Docs the docs workflow renders naming/*.yaml to docs/v1/naming.md, or to docs/v1/naming/tables.md when docs/v1/naming/ is a folder (see Docs tables)
<ItemGroup>
  <EmbeddedResource Include="..\..\naming\virtufin.market.yaml" LogicalName="naming/%(Filename)%(Extension)" />
  <None Include="..\..\naming\virtufin.market.yaml" Pack="true" PackagePath="naming/" Visible="false" />
  <PackageReference Include="Virtufin.Naming" />
</ItemGroup>

Load follows assembly references, not package references

NameRegistry.Load(assembly) walks the assembly's compiled references. The compiler emits a reference only for an assembly whose types the code actually uses, so a package you reference but never touch is not walked, and its fragments are missing:

Situation What goes wrong Use instead
A worker references a devkit only for its fragment (e.g. LiveExecutor and the Binance venue) the unused reference is pruned, GetVenue("binance") throws NameRegistry.LoadFrom(typeof(A).Assembly, typeof(B).Assembly, ...) naming each owning assembly
A C# script or notebook (Verso, Roslyn scripting) the script assembly references only what earlier cells used LoadFrom with the owning assemblies, e.g. examples' dotnet/names.cs
Trimming or NativeAOT reference walking is not trimming-safe (RequiresUnreferencedCode) LoadFrom

LoadFrom reads exactly the assemblies it is given (plus core), so the caller states which packages its names come from.

Schema

Key Type Meaning
fragment string, required the fragment id
description string shown in the docs
imports list of ids fragments this one references; virtufin.core is always imported
patterns map name → pattern named patterns, referenced as {ref: name} here or {ref: <fragment>/name} elsewhere
entities map name → entity new entities (see below)
bind map name → {entity, with} specializations: entity is a local name or <fragment>/<name>, with fixes parameters
venues map name → {symbol, case, intervals} venues this fragment owns
workers map type → {consumes, produces} worker types this fragment owns; each becomes the core worker entity bound to that type
tags map key → {meaning, scope, format} documented tag keys this fragment owns (see Tag keys)

Entity keys

Key Type Meaning
scope pattern leading segments dropped from the ce-type, e.g. {ref: virtufin.worlds/world}
path pattern the vocabulary path
identity pattern the segments identifying one instance
entity_type string the subject prefix
subject parameter or list identity parameters forming the subject; default all of them
index bool whether stem.index is a valid key
events map event → {partitioned} partitioned defaults to true
status live | reserved reserved: specified, nothing produces it yet

Pattern syntax

YAML Combinator
exchange Lit("exchange")
[a, b, c] Seq(a, b, c)
{vocab: venue}, {identifier: world}, {pair: pair}, {guid: id}, {interval: interval}, {token: run_id}, {any: x} Seg(class, name)
{ref: name} the named pattern
{optional: pattern} Optional(pattern)
{oneOf: {selector: s, alternatives: {a: pattern, b: pattern}}} OneOf(s, (a, …), (b, …))

Tag keys

Workers, triggers and groups carry a free-form tag map. A tag is read only by people, clients and scripts and never changes what the platform does. A fragment documents the standard keys of its layer, so every client writes the same key with the same meaning:

Key Type Meaning
meaning string, required what the key says about the item
scope non-empty list of workers, triggers, groups which kinds of item carry the key
format pattern, or {regex: <expression>}, required the value format: a pattern (any syntax above) when the value is a name the library knows, so {ref: virtufin.worlds/world} accepts act and hyp.REPLAY; otherwise a regular expression the whole value must match

Rules:

  • A tag key is vocabulary ([a-z][a-z0-9-]*) and is declared by exactly one fragment; composition fails on a second declaration.
  • A regex is anchored at both ends by the library. Write it in the subset C#, Python and JavaScript agree on: character classes like [0-9] rather than \d, no look-behind, no named groups.
  • Keys no fragment declares stay free-form: the registry accepts any value for them.
  • Which keys belong to which layer is a convention, not a check: infra keys (name, managed-by, endpoint) come from worker-devkit, domain keys (type, scenario, world, universe, venue) from domain-devkit.
fragment: virtufin.tags
imports: [virtufin.worlds]

tags:
  world:
    meaning: The market-data world the item belongs to.
    scope: [workers, triggers, groups]
    format: {ref: virtufin.worlds/world}
  endpoint:
    meaning: The external host or host:port a worker talks to; no credentials, no path.
    scope: [workers]
    format: {regex: "[A-Za-z0-9.-]+(:[0-9]{1,5})?"}

The composed registry exposes the keys and checks values; a refused value fails with an error naming the key and leaving the value out (it may hold a credential):

C# Python TypeScript
keys registry.Tags (IReadOnlyDictionary<string, TagKey>), GetTag(key) registry.tags (mapping), tag(key) registry.tags (ReadonlyMap), tag(key)
check one ValidateTag(key, value) validate_tag(key, value) validateTag(key, value)
check a map ValidateTags(pairs) validate_tags(mapping) validateTags(record or map)
one key TagKey.Key, Meaning, Scope, Format, Fragment, IsValid, Validate TagKey.key, meaning, scope, format, fragment, is_valid, validate TagKey.key, meaning, scope, format, fragment, isValid, validate
scopes TagScopes.Workers, Triggers, Groups, All TAG_SCOPE_WORKERS, TAG_SCOPE_TRIGGERS, TAG_SCOPE_GROUPS, TAG_SCOPES the same names as Python

The rendered naming page of a repo lists its tag keys under Tag keys.

Example

fragment: virtufin.market
imports: [virtufin.worlds]

patterns:
  venue_path: [exchange, {vocab: venue}]

entities:
  orderbook:
    scope: {ref: virtufin.worlds/world}
    path: [{ref: venue_path}, orderbook]
    identity: [{pair: pair}]
    entity_type: currency_pair
    events:
      update: {partitioned: false}   # raw venue feed, all pairs on one topic
      snapshot: {partitioned: false}
      changed: {}
      gap: {}

Ownership and conflicts

Rule Enforced by
A fragment defines names only under what it owns: its venue, its worker types, its service, or new entities of its domain. Everything else comes through imports. review; the conflict check below
A reference to another fragment's pattern or entity requires importing it. composition fails
A venue or worker type is declared by exactly one fragment. composition fails
No two families may produce the same topic or key, unless one is a bind of the other. composition fails, naming both families and their templates
The same fragment id may appear twice only with identical content (e.g. two packages carrying one copy). composition fails

Docs tables

The docs workflow (docs-common.yaml) runs the renderer whenever a repo has a naming/ folder:

virtufin-naming render naming/ -o docs/v1/naming.md

Imports are resolved from the NuGet packages the docs build restored (each Virtufin.* package carries its fragments under naming/) and from installed Python packages. To check a repo's fragments locally:

uvx --from virtufin-naming virtufin-naming check naming/

Python scripts and tools in a repo checkout compose the repo's fragments with everything they import the same way:

from virtufin_naming import NameRegistry
names = NameRegistry.discover("naming")   # + NuGet cache + installed packages

The specs site runs virtufin-naming collect to download every published fragment and virtufin-naming render --reference to build the global catalog. A conflict between two repos fails that build.