Skip to content

TaskGraph

The task graph: every live task of the Session (pending, running, waiting, completing) with its owner edge, the conversations it owns and its durable status, without checkpoint or outcome payloads (pi spec §9.5). A terminal task leaves the graph.

import { TaskGraph } from "@effective-harness/core"
import * as Effect from "effect/Effect"
const program = Effect.gen(function* () {
const graph = yield* TaskGraph.get
for (const node of Object.values(graph.tasks)) console.log(node.kind, node.id, node.state.status)
})

Unlike Scheduler.inspect, the graph is derived from committed records only, so it reads the same with the scheduler paused or closed, and a watch advances it from commit publications.

Since v0.0.0


The graph after one commit that changed it.

Signature

export interface Frame {
readonly seq: Seq
readonly value: TaskGraph
/** Operations from the previously delivered value; one root `replace` after an overflow. */
readonly ops: JsonPatch.JsonPatch
}

Source

Since v0.0.0

Signature

export interface Node {
readonly id: TaskId
readonly kind: string
readonly conversationId: ConversationId
/** Owner task; absent for a conversation-owned task. */
readonly owner?: TaskId
readonly background: boolean
readonly abortRequested: boolean
readonly state: NodeState
/** Conversations this task owns, in ID order. */
readonly conversations: ReadonlyArray<ConversationId>
}

Source

Since v0.0.0

A live task’s durable status; phase is its checkpoint’s tag.

Signature

type NodeState =
| { readonly status: "pending" | "running"; readonly phase: string }
| {
readonly status: "waiting"
readonly phase: string
readonly on: ReadonlyArray<TaskId>
readonly policy: JoinPolicy
}
/** An outcome held until the task's ordinary owned work drains. */
| { readonly status: "completing"; readonly outcome: TaskOutcome["status"] }

Source

Since v0.0.0

Signature

export interface TaskGraph {
/** Every live task, keyed by its decimal ID. */
readonly tasks: { readonly [id: string]: Node }
}

Source

Since v0.0.0

Signature

export interface Watch {
/** The graph at acquisition. */
readonly value: TaskGraph
/**
* Every later commit that changed a node, in order. When more than `Session.MaxPendingWatchFrames` frames are
* waiting, they collapse into one root replacement. Ends when the Session closes.
*/
readonly changes: Stream.Stream<Frame>
}

Source

Since v0.0.0

The current graph, read on the commit line.

Signature

declare const get: Effect.Effect<TaskGraph, StorageFailure | SessionPoisoned, Session>

Source

Since v0.0.0

Watch the graph. The value and the registration for later commits are captured atomically on the commit line; the watch lives until its scope closes.

Signature

declare const watch: Effect.Effect<Watch, StorageFailure | SessionPoisoned, any>

Source

Since v0.0.0