Skip to content

Topics

Topics organize frames in the event stream. The . character creates hierarchy, enabling wildcard queries.

Naming Rules

RuleDetail
Allowed charactersa-z A-Z 0-9 _ - .
Must start witha-z A-Z 0-9 _
Cannot end with.
Cannot contain..
Max length255 bytes

Valid: chat, user.alice, orders.2024.pending, my_topic-v2

Invalid: .hidden, -dash, trailing., foo..bar, has space

Hierarchy

The . separator creates a topic hierarchy:

user.alice.messages
user.alice.status
user.bob.messages

This structure enables prefix queries.

Wildcard Queries

Use .* suffix to query all direct and nested children of a prefix:

Terminal window
# All frames under user.alice (messages, status, etc.)
xs cat ./store --topic "user.alice.*"
# All user frames
xs cat ./store --topic "user.*"

The wildcard user.* matches user.alice, user.alice.messages, and user.bob—but not user itself.

Use * alone to match all topics (equivalent to omitting --topic).

Topic queries return frames in chronological order (by frame ID), not grouped by topic. Both historical reads and live follows maintain this ordering.

Component Suffixes

cross.stream uses topic suffixes to coordinate component lifecycle.

Generators

SuffixDescriptionEmitted By
.spawnCreate or update a generatorUser
.terminateStop a generatorUser
.sendInput to duplex generatorsUser
.runningGenerator has startedSystem
.stoppedGenerator pipeline stoppedSystem
.shutdownGenerator loop fully exitedSystem
.parse.errorScript parsing failedSystem
.recvOutput from generatorSystem

Handlers

SuffixDescriptionEmitted By
.registerRegister a handlerUser
.unregisterUnregister a handlerUser
.activeHandler is now activeSystem
.unregisteredHandler has been removedSystem
.outOutput from handlerSystem

Commands

SuffixDescriptionEmitted By
.defineDefine a commandUser
.callInvoke a commandUser
.readyCommand ready for callsSystem
.errorCommand execution failedSystem
.responseCommand execution resultSystem

System Topics

TopicDescription
xs.startSystem initialization complete
xs.thresholdStream processing threshold marker
xs.pulseSynthetic pulse events (configurable interval)

Customizable Suffixes

Output suffixes can be changed via return_options.suffix:

  • .recv (Generators)
  • .out (Handlers)
  • .response (Commands)
Terminal window
{
run: {|| "Hello, World!" },
return_options: {
suffix: ".message" # Changes .recv to .message
}
}

Event Metadata

Lifecycle and output events include:

  • source_id / handler_id / command_id: Component instance ID
  • frame_id: Triggering frame ID (handlers/commands)
  • error: Error details (on error events)
  • reason: Stop reason (on stopped events)