OptionalresumeState: ResumedRunStateInternal — supplied only by Resume. Its presence switches the emitter into resume mode: the manifest is left exactly as it is on disk and retention pruning is skipped (see bootstrap).
Whether this emitter re-attached to an existing run rather than opening a new one.
The highest sequence number emitted so far. A client tailing with sinceSeq only sees events
ABOVE its cursor, so a resumed emitter must continue from here — this getter is what lets a
caller (and a test) assert it did.
The run this emitter writes to.
Terminate the run as CANCELLED (a user/system abort stopped it mid-flight, not a failure and not a clean completion). Emits exitReason='aborted' so a cancelled run is distinguishable from one that finished — the persisted CompanyIntegrationRun has no 'Cancelled' status, so the artifact's ExitReason is the GQL-visible signal that the run was stopped early (partial state is still durable).
Optionalmessage: stringWrite a resumable checkpoint. resumableState should carry enough subsystem- specific data for the originating service to resume from this point.
Terminate the run as success.
Optionalmessage: stringUse Emit.
Emit a generic event.
Use ExternalCallComplete.
Optionaldata: Record<string, unknown>Use ExternalCallStart.
Optionaldata: Record<string, unknown>Terminate the run as failure.
Optionalcode: stringUse FieldAdded.
Use Flush.
Await all pending writes.
Optionalcounts: {Use Heartbeat.
Optionalcounts: {Use ObjectAdded.
Use PkClassifierResult.
Announce that this process picked a killed run back up. Emits the already-declared
'run.resumed' event carrying the already-declared 'Restart' trigger type — deliberately
NOT a new event type, and deliberately in the event's data rather than on the manifest,
because the manifest must not be rewritten (see Resume).
resumedFromSeq is the sequence the pre-restart process reached; a client can use it to tell
"these events are the continuation" from "these are a fresh run".
Optionalmessage: stringOptionaldata: Record<string, unknown>Convenience helpers — sugared emit() for the common cases.
Optionalmessage: stringOptionalcounts: {Optionaldata: Record<string, unknown>Use StageComplete.
counts is the canonical quartet the reader aggregates. data carries anything a specific
stage needs to survive that is not part of it — notably the CREATED vs UPDATED split, which
the quartet folds into succeeded and which history has to show separately
(plan.md: "Synced is different between created and updated").
Optionalcounts: {Optionaldata: Record<string, unknown>Optionaldata: Record<string, unknown>Use StageError.
Optionaldata: Record<string, unknown>Optionalmessage: stringOptionaldata: Record<string, unknown>Use Warning.
Emit a non-fatal warning. Carries a structured {stage, code, message, data}
payload that the reader aggregates into the run result's warnings[] rollup.
Unlike stageError, a warning never fails the run.
Optionaldata: Record<string, unknown>StaticnewStaticNewOptionalprefix: stringStaticResumeRe-attach to an existing, still-in-flight run and continue writing to its artifacts.
Why this exists: the RSU pipeline restarts the API process as one of its own steps. The
emitter dies mid-run, its run.end handler never fires, and the run stays flagged in-flight
forever. The work that finishes the pipeline then happens in a NEW process, which — without
this — could only open a brand-new run, invisible to every client already tailing the old one
(the reader returns strictly seq > cursor, and a fresh emitter restarts at 1, so those
events sort BELOW the client's cursor and are unrecoverable through that interface; worse,
the resolver echoes the unchanged cursor back and the client polls forever receiving nothing).
Three invariants make it safe:
result.json is refused, so a terminal record can never be
written twice or overwritten by a late re-attachment.The append-only journal is what makes all of this possible: it is never truncated, so its last line is an authoritative high-water mark for the sequence.
StaticSetRegister (or clear, with no arg) the global publish hook. The server registers this at startup so every emitted event also fans out to the live GraphQL subscription, in addition to the durable JSONL artifact + the pollable tail query.
Optionalhook: IntegrationProgressPublishHook
Writes structured progress artifacts to
<rootDir>/<runID>/:Sequence numbers monotonic per emitter instance. Disk I/O is async and serialized via an internal promise chain — callers don't await; the emitter guarantees ordered writes. A flush() method awaits the queue when needed (test teardown, run completion).