Skip to content

Stream the changes of Missions as server-sent events.

API version mission-status unreleased

GET
/events

A change stream, served as text/event-stream. OpenAPI 3.1 has no native way to describe a stream of named events, so the stream is documented here as a convention; the schema of the 200 response is the schema of the data field of each event, not of the whole body.

Event names and data schemas. There are exactly three event names, each with one data schema, and no other event name is ever sent:

  • status-transition -> StatusTransitionEvent: a work package changed status lane.
  • mission-lifecycle -> MissionLifecycleEvent: the Mission was created, or a planning phase started or completed.
  • log-truncated -> LogTruncatedEvent: the Mission’s event log shrank or changed; resynchronise.

Framing. Each event is sent as an event: line with the event name, an id: line with the StreamCursorString of the event, a data: line with the JSON of the data schema, and a blank line. The id is the same string the streamCursor parameter and the Last-Event-ID header accept. Two kinds of event carry no id: line, so that a browser’s automatic Last-Event-ID never holds a position that cannot be resumed from. Every event of an unscoped stream (no missionId) is sent without an id: line, because a cursor is a position in one Mission’s log and the unscoped stream interleaves Missions. A log-truncated event is sent without an id: line on every stream, because its own cursor is the reset position, offset 0, and resuming from it would replay the whole log; the cursor stays inside its data. A heartbeat is a comment line, : heartbeat, sent every 30 seconds; it carries no data and is not an event.

Projection. Raw rows of the Mission’s event log never appear. Only a status transition and seven lifecycle types (MissionCreated, SpecifyStarted, SpecifyCompleted, PlanStarted, PlanCompleted, TasksStarted, TasksCompleted) are forwarded; annotation rows, decision-point rows, retrospective rows, reviewer self-approval rows, work package creation rows and every unknown row are dropped, never forwarded. The seven lifecycle types are owned by this contract and are a subset of the runtime’s twelve; a type added upstream later is dropped.

Scope and ordering. With missionId the stream carries that Mission only; a missionId that names no Mission is answered with 404 before any event is sent. Without it the stream carries every Mission, live only: it never replays and no cursor can be used. A new connection without a cursor is live only from the moment it connects. Order is guaranteed per Mission, in the order of that Mission’s log; there is no order across Missions, and a log-truncated event of one Mission may arrive between events of others.

Resume. A cursor is a StreamCursor position in one Mission’s own physical event log (the TailCursor of the tail reader, the same position spec-kitty events tail resumes from), so it is valid for that log only and always needs missionId. Send the id of the last event you consumed as streamCursor, or let the browser send it as Last-Event-ID. A cursor that cannot be trusted is refused before any event is sent, with a problem whose code is negative, out_of_range, misaligned or content_mismatch (the reasons of the tail reader’s ResumeRefused), or cursor_without_mission when a cursor comes without missionId. The status of each code is fixed: negative, misaligned and cursor_without_mission are 400; out_of_range and content_mismatch are 409 (StreamRefusal states this as a checkable rule). A browser EventSource cannot read the body of a refused connection, it only closes, so a consumer that must tell these refusals apart opens the stream with a fetch that streams the response body instead of EventSource. After a log-truncated event on a Mission-scoped stream the last id the browser holds is the one before the truncation, and a reconnect with it is refused; the consumer then resynchronises as below.

Consumer actions. On log-truncated, discard the stored cursor of that Mission, read the Mission detail again, and resume from the streamCursor of that detail; the cursor inside the event is only the reset one, offset 0 with the digest of the empty input. A value inside a known kind that a consumer does not know, such as an unlisted eventType, is treated as unknown and is not a failure; the schemas stay closed, so a producer must not send one.

Provisional. These parts are provisional: the framing of the stream and which events carry an id line, the text form of the cursor, the rule that streamCursor wins over Last-Event-ID, the HTTP status of each refusal and the heartbeat interval are conventions owned by this contract; the tail reader has no text form of a cursor and no transport. They are open on #5528 and may change before release. No emitter, server or transport exists yet: this describes a stream that a later change implements.

Parameters

Query Parameters

missionId
MissionId

The canonical machine identity of a Mission: a 26-character Crockford ULID minted when the Mission is created and never changed. Never confuse it with displayNumber, which is display-only and repeats.

string
/^[0-9A-HJKMNP-TV-Z]{26}$/

Restricts the stream to one Mission, by its 26-character ULID. Without it the stream carries the events of every Mission, live only, and no cursor can be used. The display number is never accepted.

streamCursor
StreamCursorString

The text form of a StreamCursor: the decimal byte offset, a colon, and the 64 lowercase hexadecimal characters of the invariant, for example an offset of 0 followed by a colon and the digest of the empty input. It is the value of the streamCursor query parameter, of the Last-Event-ID request header and of the SSE id field of the events of a Mission-scoped stream (log-truncated carries no id), all the same string. The offset has no leading zeros, so one cursor has exactly one text. The JSON object form, StreamCursor, is what travels inside the data of an event. It has no relationship to the opaque page cursor used for paging lists.

string
/^(0|[1-9][0-9]*):[0-9a-f]{64}$/

Resumes the stream of one Mission after the event that carried this cursor, in the text form offset, colon, invariant. It requires missionId: a cursor sent without one is refused with the code cursor_without_mission. The cursor is bound to one physical event log, so a cursor taken from another log is refused with content_mismatch.

Header Parameters

Last-Event-ID
StreamCursorString

The text form of a StreamCursor: the decimal byte offset, a colon, and the 64 lowercase hexadecimal characters of the invariant, for example an offset of 0 followed by a colon and the digest of the empty input. It is the value of the streamCursor query parameter, of the Last-Event-ID request header and of the SSE id field of the events of a Mission-scoped stream (log-truncated carries no id), all the same string. The offset has no leading zeros, so one cursor has exactly one text. The JSON object form, StreamCursor, is what travels inside the data of an event. It has no relationship to the opaque page cursor used for paging lists.

string
/^(0|[1-9][0-9]*):[0-9a-f]{64}$/

The same text as streamCursor. A browser sends it by itself when it reconnects, with the id of the last event it received, so the stream resumes where it stopped. It requires missionId in the same way, and only a Mission-scoped stream sends event ids, so a browser never sends it to an unscoped stream. When both this header and streamCursor are sent, streamCursor is used.

Responses

200

The event stream. The connection stays open and carries named events and heartbeat comment lines until either side closes it.

Media type text/event-stream
One of:
StatusTransitionEvent

The data of a status-transition event: one work package changed status lane. It is projected from a status-transition row of the Mission’s event log by an allow-list, so no other field of the row is ever shown. missionId is the identity stored in the Mission’s metadata (meta.json), never the aggregate_id of the row: aggregate_id is the Mission ULID only on MissionCreated, the slug on several other rows and the work package id on WPCreated. A row whose wp_id does not match WpId is not a valid event: it is dropped, never forwarded or repaired, and the drop is counted and reported. The allow-list deliberately leaves out these StatusEvent fields: reason, reason_source, review_ref, evidence, review_result, policy_metadata, execution_mode and mission_slug, so adding one later is a contract decision. The schema is closed.

object
actor
required
Actor

Who made the transition, as three handles.

object
profile
required
ActorHandle

The handle of the agent profile the actor used, or null when unknown or not a valid handle.

string | null
>= 1 characters <= 128 characters /^[A-Za-z0-9._:-]+$/
role
required
ActorHandle

The handle of the role the actor held, or null when unknown or not a valid handle.

string | null
>= 1 characters <= 128 characters /^[A-Za-z0-9._:-]+$/
tool
required
ActorHandle

The handle of the agent or tool that acted, or null when unknown or not a valid handle.

string | null
>= 1 characters <= 128 characters /^[A-Za-z0-9._:-]+$/
at
required

When the transition happened, an RFC 3339 date-time with an offset.

string format: date-time
eventId
required

The identifier of the event, unique within the Mission’s event log.

string
>= 1 characters <= 64 characters
force
required

True when the transition bypassed the usual guards.

boolean
fromStatusLane
required
One of:
StatusLane

The display state of a work package in the status model. Exactly nine values. The runtime enum also carries genesis and uninitialized, which are not display values: a work package with no events reads as a null status lane, never as one of those two. This is the status lane, not a code lane or the repo-root lane; the contract never groups these values into board columns.

string
Allowed values: planned claimed in_progress for_review in_review approved done blocked canceled
missionId
required
MissionId

The identity of the Mission whose log carried the transition, from the Mission’s metadata and never from aggregate_id.

string
/^[0-9A-HJKMNP-TV-Z]{26}$/
streamCursor
required
StreamCursor

The position just after this event in the Mission’s own event log; resume from it.

object
invariant
required

The 64-character lowercase hexadecimal SHA-256 digest of the last consumed line, or the digest of the empty input when the offset is 0. The stored attribute is named content_invariant.

string
/^[0-9a-f]{64}$/
offset
required

The byte offset in the event log just after the last consumed line; 0 means nothing consumed yet.

integer format: int64
toStatusLane
required
StatusLane

The status lane the work package entered.

string
Allowed values: planned claimed in_progress for_review in_review approved done blocked canceled
wpId
required
WpId

The work package that changed status lane.

string
>= 1 characters <= 64 characters /^WP[0-9]{2,}$/

400

The event stream request was refused before any event was sent. The body is a problem details object whose code names the refusal.

Media type application/problem+json
StreamRefusal

The problem details body of a refused event stream request. It is a Problem whose code is one of five values: negative, out_of_range, misaligned and content_mismatch, which are the reasons of the tail reader’s ResumeRefused, and cursor_without_mission, the refusal of a streamCursor or Last-Event-ID sent without a missionId. A refused request is answered before any event is sent; the stream never resynchronises silently. The status follows from the code: 400 for negative, misaligned and cursor_without_mission, 409 for out_of_range and content_mismatch. Consumers branch on code, never on title.

object
code
required

A stable machine-readable code for the problem, such as the name of a refusal reason. Consumers branch on it, never on the title.

string
detail
required

A human-readable explanation specific to this occurrence of the problem.

string
instance

A URI reference that identifies this occurrence of the problem.

string
status
required

The HTTP status code of this occurrence.

integer
>= 400 <= 599
title
required

A short, human-readable summary of the kind of problem. It does not change between occurrences.

string
type

A URI reference that identifies the kind of problem. Absent means about:blank.

string
code
required

Negative: the offset is below 0. out_of_range: the offset is beyond the end of the log. misaligned: the offset is not at the start of a line. content_mismatch: the digest does not match the log at that offset. cursor_without_mission: a cursor was sent with no missionId.

string
Allowed values: negative out_of_range misaligned content_mismatch cursor_without_mission
status
required

The HTTP status of the refusal, fixed by its code: 400 for negative, misaligned and cursor_without_mission, 409 for out_of_range and content_mismatch.

integer
Allowed values: 400 409

404

The request failed. The body is a problem details object.

Media type application/problem+json
Problem

The only non-2xx body of any module. A problem details object in the sense of RFC 9457, served as application/problem+json.

object
code

A stable machine-readable code for the problem, such as the name of a refusal reason. Consumers branch on it, never on the title.

string
detail

A human-readable explanation specific to this occurrence of the problem.

string
instance

A URI reference that identifies this occurrence of the problem.

string
status
required

The HTTP status code of this occurrence.

integer
>= 400 <= 599
title
required

A short, human-readable summary of the kind of problem. It does not change between occurrences.

string
type

A URI reference that identifies the kind of problem. Absent means about:blank.

string

409

The event stream request was refused before any event was sent. The body is a problem details object whose code names the refusal.

Media type application/problem+json
StreamRefusal

The problem details body of a refused event stream request. It is a Problem whose code is one of five values: negative, out_of_range, misaligned and content_mismatch, which are the reasons of the tail reader’s ResumeRefused, and cursor_without_mission, the refusal of a streamCursor or Last-Event-ID sent without a missionId. A refused request is answered before any event is sent; the stream never resynchronises silently. The status follows from the code: 400 for negative, misaligned and cursor_without_mission, 409 for out_of_range and content_mismatch. Consumers branch on code, never on title.

object
code
required

A stable machine-readable code for the problem, such as the name of a refusal reason. Consumers branch on it, never on the title.

string
detail
required

A human-readable explanation specific to this occurrence of the problem.

string
instance

A URI reference that identifies this occurrence of the problem.

string
status
required

The HTTP status code of this occurrence.

integer
>= 400 <= 599
title
required

A short, human-readable summary of the kind of problem. It does not change between occurrences.

string
type

A URI reference that identifies the kind of problem. Absent means about:blank.

string
code
required

Negative: the offset is below 0. out_of_range: the offset is beyond the end of the log. misaligned: the offset is not at the start of a line. content_mismatch: the digest does not match the log at that offset. cursor_without_mission: a cursor was sent with no missionId.

string
Allowed values: negative out_of_range misaligned content_mismatch cursor_without_mission
status
required

The HTTP status of the refusal, fixed by its code: 400 for negative, misaligned and cursor_without_mission, 409 for out_of_range and content_mismatch.

integer
Allowed values: 400 409

default

The request failed. The body is a problem details object.

Media type application/problem+json
Problem

The only non-2xx body of any module. A problem details object in the sense of RFC 9457, served as application/problem+json.

object
code

A stable machine-readable code for the problem, such as the name of a refusal reason. Consumers branch on it, never on the title.

string
detail

A human-readable explanation specific to this occurrence of the problem.

string
instance

A URI reference that identifies this occurrence of the problem.

string
status
required

The HTTP status code of this occurrence.

integer
>= 400 <= 599
title
required

A short, human-readable summary of the kind of problem. It does not change between occurrences.

string
type

A URI reference that identifies the kind of problem. Absent means about:blank.

string