new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Temporal · all subjects

workflow control flow

4 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

WorkflowStream construction timing and handler registration

A WorkflowStream must be constructed once at the top of a Workflow function, before any blocking call. This is required because the stream's handlers (publish Signal, subscribe Update, and offset Query handlers) must be registered before the first publish Signal arrives. Constructing after a blocking call would miss any publishes that arrived before the run body resumed. Construct exactly one WorkflowStream per Workflow, as the constructor re-registers handlers unconditionally on every call, so multiple constructions register duplicate handlers.

WorkflowStreamState usage across Continue-As-New

The WorkflowStreamState argument to NewWorkflowStream is nil on a fresh Workflow start and a populated *WorkflowStreamState after a Continue-As-New rollover. The state must be carried in the Workflow input struct and passed to NewWorkflowStream to maintain stream continuity across rollovers. The NewContinueAsNewError helper method drains waiting subscribers, waits for in-flight handlers to finish, then returns a Continue-As-New error with the post-drain state.

Client publish path is not goroutine-safe

The client buffer is mutated on the publish path and read from the background flusher. Do not call Publish() on the same Client from multiple goroutines without coordinating; route events to a single owner.

Resumable Activity best practice: history growth management

Each correction cycle adds events to the Workflow history (signal received, state transitions, Activity scheduled/completed). For workflows that may receive many corrections over time, use Continue-As-New to carry the current state into a fresh execution before the history grows too large, rather than relying solely on an arbitrary correction counter.

Give your agent this brain