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

message-passing/queries

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

Use upsertSearchAttributes to maintain queryable pipeline state at every status transition

Call upsertSearchAttributes at every state change to maintain a denormalized index for cross-Workflow visibility queries. For example, after each failed Activity, upsert LoanStatus = 'PENDING_FIX' and FailedActivity = 'activityName' using typed Search Attribute keys. This enables operators and automated agents to query for specific blocked Workflows using the Temporal Visibility API. Queries like "LoanStatus = 'PENDING_FIX' AND FailedActivity = 'runCreditCheck'" return all applications blocked on credit checks, enabling targeted routing to the appropriate resolution resource (human or automated agent).

Query API provides strongly consistent internal Workflow state snapshot

Use Queries to read the full internal state of a single running Workflow. Unlike Search Attributes which expose denormalized metadata for cross-Workflow queries and are eventually consistent, Queries return strongly consistent data directly from the Workflow. Define a Query handler with setHandler(getStateQuery, () => ({...})) that returns the complete Workflow state including current status, list of completed Activities, fix history, compensation history, failure details, and current application data. This gives individual Workflow visibility that complements the aggregate cross-pipeline view provided by Search Attribute queries.

Example: Query handler returning complete Workflow state

```typescript setHandler(getStateQuery, () => ({ status, failedActivity, failureMessage, completedActivities: [...completedActivities], fixHistory: [...fixHistory], application: { ...app }, })); ``` The Query handler returns a snapshot of the full pipeline state without side effects. This includes current status (STARTED, PENDING_FIX, COMPENSATING, ROLLED_BACK, CLOSED), the name of the failed Activity if in PENDING_FIX, the failure error message, list of completed Activities, complete audit trail of all corrections applied (fixHistory), and the current application data including any patches sent via Signal.

LoanStatus and FailedActivity Search Attributes enable routing to resolution resources

Create two custom Search Attributes to track pipeline state: (1) LoanStatus (Keyword type) tracks the current stage: STARTED, INCOME_VERIFIED, CREDIT_CHECKED, APPRAISAL_ORDERED, TITLE_SEARCHED, UNDERWRITTEN, CLOSED, PENDING_FIX, or FAILED. (2) FailedActivity (Keyword type) records the name of the Activity that caused failure (verifyIncome, runCreditCheck, orderAppraisal, performTitleSearch, underwrite, closeLoan). Together these enable queries like "LoanStatus = 'PENDING_FIX' AND FailedActivity = 'runCreditCheck'" to find every application blocked on a credit check. An operations dashboard can filter by any combination to display statistics or route work to the appropriate human team or automated agent.

Queryable metadata routes blocked processes to right resolution resource via Search Attributes

Search Attributes provide a queryable index updated at every state transition. By upserting LoanStatus and FailedActivity at each step change, all active Workflows become searchable by any combination of these attributes. This enables: (1) Operations dashboards to display real-time pipeline statistics and filter blocked Workflows for human attention. (2) Automated agents to poll for specific failure categories (e.g., 'PENDING_FIX AND FailedActivity = creditCheck') and apply programmatic corrections. (3) Audit and compliance queries to track which failure types occur most frequently and how long applications sit in PENDING_FIX. The same Search Attribute interface that routes work to humans also routes work to automated agents.

Query mechanism for reading Workflow state

Queries are the mechanism for reading Workflow state without affecting execution. Queries are defined using the @workflow.query decorator. Query responses are not recorded in Event History (0 events generated). In the approval pattern, queries allow external clients to check the document status and retrieve the audit trail without blocking or modifying the Workflow's execution.

Give your agent this brain