@smthrs/gateway 1.0.0-rc.3 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/EngineTrace.d.ts.map +1 -1
- package/dist/cjs/EngineTrace.js +10 -2
- package/dist/cjs/EngineTrace.js.map +2 -2
- package/dist/cjs/GatewayProjection.d.ts.map +1 -1
- package/dist/cjs/GatewayProjection.js +10 -1
- package/dist/cjs/GatewayProjection.js.map +2 -2
- package/dist/cjs/HostBranchPresence.d.ts +7 -0
- package/dist/cjs/HostBranchPresence.d.ts.map +1 -1
- package/dist/cjs/HostBranchPresence.js.map +2 -2
- package/dist/cjs/RunTrace.d.ts.map +1 -1
- package/dist/cjs/RunTrace.js +3 -1
- package/dist/cjs/RunTrace.js.map +2 -2
- package/dist/cjs/internal/actionRenderings.d.ts +10 -0
- package/dist/cjs/internal/actionRenderings.d.ts.map +1 -1
- package/dist/cjs/internal/actionRenderings.js.map +2 -2
- package/dist/cjs/internal/inspectLabels.d.ts +5 -0
- package/dist/cjs/internal/inspectLabels.d.ts.map +1 -1
- package/dist/cjs/internal/inspectLabels.js.map +2 -2
- package/dist/esm/EngineTrace.d.ts.map +1 -1
- package/dist/esm/EngineTrace.js +19 -10
- package/dist/esm/EngineTrace.js.map +1 -1
- package/dist/esm/GatewayProjection.d.ts.map +1 -1
- package/dist/esm/GatewayProjection.js +7 -0
- package/dist/esm/GatewayProjection.js.map +1 -1
- package/dist/esm/HostBranchPresence.d.ts +7 -0
- package/dist/esm/HostBranchPresence.d.ts.map +1 -1
- package/dist/esm/HostBranchPresence.js +4 -1
- package/dist/esm/HostBranchPresence.js.map +1 -1
- package/dist/esm/RunTrace.d.ts.map +1 -1
- package/dist/esm/RunTrace.js +4 -3
- package/dist/esm/RunTrace.js.map +1 -1
- package/dist/esm/internal/actionRenderings.d.ts +10 -0
- package/dist/esm/internal/actionRenderings.d.ts.map +1 -1
- package/dist/esm/internal/actionRenderings.js +10 -0
- package/dist/esm/internal/actionRenderings.js.map +1 -1
- package/dist/esm/internal/inspectLabels.d.ts +5 -0
- package/dist/esm/internal/inspectLabels.d.ts.map +1 -1
- package/dist/esm/internal/inspectLabels.js +5 -0
- package/dist/esm/internal/inspectLabels.js.map +1 -1
- package/package.json +13 -13
- package/src/EngineTrace.ts +34 -12
- package/src/GatewayProjection.ts +17 -6
- package/src/HostBranchPresence.ts +5 -1
- package/src/RunTrace.ts +9 -6
- package/src/internal/actionRenderings.ts +11 -0
- package/src/internal/inspectLabels.ts +6 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ The root entry point exports these namespaces; local modules are also importable
|
|
|
36
36
|
| `GatewayServer` | `Health`, `layerHealth`, `layerHandlers`, `watchHeartbeatKind`, `layerKeepAlive`, `layerProjectionsKeepAlive`, `layerControlHttp`, `layerProjectionsHttp`, `layerSyncHttp`, `rpcPaths`, `boundedPostPaths`, `protectedPaths`, `routedPath`, `defaultMaxRequestBodyBytes`, `loopbackHostNames`, `loopbackHostHeaderNames`, `IngressOptions`, `exceededBodyLimit`, `bodyRefusal`, `carriesRpcRequest`, `ticketPath`, `ticketPaths`, `defaultTicketMillis`, `Ticket`, `layerIngress`, `LayerOptions`, `layer` | Assembles the whole HTTP surface as one application layer a host serves. |
|
|
37
37
|
| `Projections` | `heartbeatIntervalMillis`, `maxWorkspaceRuns`, `maxEventsPerRun`, `maxEventsScanned`, `maxEventsPerPage`, `maxDurationRuns`, `maxProjectionBytes`, `maxEventBytes`, `Service`, `Projections`, `make`, `layer`, `layerWith` | Serves the bounded read path as snapshots and followed deltas. |
|
|
38
38
|
| `RunHistory` | `Step`, `VerifyInput`, `VerifyReport`, `StepEdit`, `ForkInput`, `ForkOutput`, `HistoryRefused`, `Service`, `RunHistory` | Declares the run fork and verify wire shapes and the host service that serves them. |
|
|
39
|
-
| `RuntimeBridge` | `protocol`, `Identity`, `LaunchCommand`, `DecisionCommand`, `SignalCommand`, `SteerCommand`, `LifecycleCommand`, `Command`, `ObserveRequest`, `CommandReceipt`, `Config`, `BridgeError`, `execute`, `observe`, `monitor`, `CommandResponse`, `ObserveResponse`, `ErrorResponse`, `layer`
|
|
39
|
+
| `RuntimeBridge` | `protocol`, `Identity`, `LaunchCommand`, `DecisionCommand`, `SignalCommand`, `SteerCommand`, `LifecycleCommand`, `Command`, `ObserveRequest`, `CommandReceipt`, `Config`, `BridgeError`, `execute`, `observe`, `monitor`, `CommandResponse`, `ObserveResponse`, `ErrorResponse`, `layer` | Adapts authenticated versioned JSON commands to the canonical Control service. |
|
|
40
40
|
| `Sync` | `RunCatalog`, `SyncClient`, `SyncError`, `SyncProtocol`, `SyncRpcs`, `SyncServer` | Re-exports `@smthrs/sync`, the read-only journal replication protocol. |
|
|
41
41
|
| `node/NodeGateway` | `ServerOptions`, `defaultServerOptions`, `isLoopbackHost`, `bindRefusal`, `listenOptions`, `ingressOptions`, `layerAuth`, `bearerPrincipal`, `scopedPrincipal`, `scopedTokenPaths`, `layer` | Binds the assembled gateway to a Node HTTP server under the bind and credential policy. |
|
|
42
42
|
| `bun/BunGateway` | `ServerOptions`, `layer`, `bearerPrincipal`, `scopedPrincipal` | Bun HTTP/WebSocket adapter using the same bind, bearer, ingress and RPC policies. |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineTrace.d.ts","sourceRoot":"","sources":["../../src/EngineTrace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAA;AAI1D,OAAO,KAAK,EAAE,aAAa,EAAc,YAAY,EAAE,MAAM,eAAe,CAAA;AAgF5E;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,iBAAiB,CAA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 @@ const foldEngineJournal = (records) => {
|
|
|
256
256
|
if (node === void 0 || import_effect.Option.isSome(scheduled)) {
|
|
257
257
|
const instance = (instances.get(nodeKey) ?? 0) + 1;
|
|
258
258
|
instances.set(nodeKey, instance);
|
|
259
|
-
node = span(
|
|
259
|
+
node = span(
|
|
260
|
+
`engine-node:${nodeKey}#${instance}`,
|
|
261
|
+
"call",
|
|
262
|
+
(0, import_inspectLabels.inspectLabel)(action ?? recorded.nodeId),
|
|
263
|
+
envelope.emittedAtMs,
|
|
264
|
+
detail(row, envelope)
|
|
265
|
+
);
|
|
260
266
|
nodes.set(nodeKey, node);
|
|
261
267
|
execution.span.children.push(node);
|
|
262
268
|
}
|
|
@@ -325,7 +331,9 @@ const foldEngineJournal = (records) => {
|
|
|
325
331
|
else if (kind === "sleep") existing.kind = kind;
|
|
326
332
|
};
|
|
327
333
|
if (recorded.value.event._tag === "Execution" && recorded.value.event.lifecycle.state !== "completed") {
|
|
328
|
-
for (const wait of recorded.value.event.lifecycle.waits)
|
|
334
|
+
for (const wait of recorded.value.event.lifecycle.waits) {
|
|
335
|
+
registerWait(wait.waitId, wait._tag === "Clock" ? "sleep" : "signal");
|
|
336
|
+
}
|
|
329
337
|
}
|
|
330
338
|
if (recorded.value.event._tag === "ClockScheduled") {
|
|
331
339
|
registerWait(recorded.value.event.waitId, "sleep");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/EngineTrace.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Recorded native evidence, decoded through the contracts that wrote it.\n *\n * @since 1.0.0\n */\n\nimport { RunState } from \"@smthrs/engine-store/RunState\"\nimport { ResultEncoded } from \"@smthrs/flow/Flow\"\nimport * as EngineEvent from \"@smthrs/journal/EngineEvent\"\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport { Option, Schema } from \"effect\"\nimport { inspectLabel } from \"./internal/inspectLabels.ts\"\nimport type { JournalRecord, SpanDetail, TraceBuilder } from \"./RunTrace.ts\"\n\n// This is the private control bridge's envelope, not another engine contract.\nconst Envelope = Schema.Struct({\n version: Schema.Literal(1),\n executionId: JournalEvent.RunId,\n generation: JournalEvent.NonNegativeQuantity,\n sequence: JournalEvent.Seq,\n eventId: Schema.String,\n sourceId: JournalEvent.SourceId,\n sourceSequence: JournalEvent.SourceSeq,\n emittedAtMs: JournalEvent.TimestampMs,\n eventType: Schema.NonEmptyString,\n payload: Schema.Json,\n meta: Schema.Json\n})\ntype Envelope = typeof Envelope.Type\n\nconst decodeEnvelope = Schema.decodeUnknownOption(Envelope)\nconst decodeGraph = Schema.decodeUnknownOption(EngineEvent.NodeGraph)\nconst decodeScheduled = Schema.decodeUnknownOption(EngineEvent.NodeScheduledPayload)\nconst decodeSettled = Schema.decodeUnknownOption(EngineEvent.NodeSettledPayload)\nconst decodeAttempt = Schema.decodeUnknownOption(EngineEvent.AttemptPayload, { onExcessProperty: \"error\" })\nconst decodeState = Schema.decodeUnknownOption(EngineEvent.StatePayload, { onExcessProperty: \"error\" })\nconst decodeMarker = Schema.decodeUnknownOption(EngineEvent.CurrentAttempt)\nconst stateDecisions = [\n \"created\",\n \"resumed\",\n \"transitioned\",\n \"handed-off\",\n \"lineage-exhausted\",\n \"round-invalid\",\n \"quarantined\",\n \"interrupt-released\"\n] as const\nconst decodeDecision = Schema.decodeUnknownOption(Schema.Struct({\n decision: Schema.Literals(stateDecisions),\n status: Schema.optionalKey(Schema.Literals([\"pending\", \"running\", \"suspended\", \"completed\", \"failed\", \"cancelled\"])),\n state: RunState\n}))\n// RunDriver's durable cancellation record has no run-decision counterpart.\nconst decodeCancellation = Schema.decodeUnknownOption(Schema.Struct({\n outcome: Schema.Literal(\"cancelled\"),\n interruptedAtMs: JournalEvent.TimestampMs,\n owner: Schema.String,\n cascadedTo: Schema.optionalKey(Schema.Array(JournalEvent.RunId))\n}))\nconst decodeResult = Schema.decodeUnknownOption(ResultEncoded, { onExcessProperty: \"error\" })\n\nconst json = (value: unknown): string => typeof value === \"string\" ? value : JSON.stringify(value)\nconst identity = (...parts: ReadonlyArray<string | number>) =>\n parts.map((part) => encodeURIComponent(String(part))).join(\":\")\nconst span = (id: string, kind: TraceBuilder[\"kind\"], label: string, at: number, detail: SpanDetail): TraceBuilder => ({\n id,\n kind,\n label,\n status: \"recorded\",\n startedAt: at,\n children: [],\n detail\n})\nconst detail = (row: JournalRecord, envelope: Envelope): SpanDetail => ({\n sequence: row.sequence,\n event: envelope.eventType,\n fields: { ...envelope }\n})\ninterface Execution {\n readonly envelope: Envelope\n readonly span: TraceBuilder\n parentId?: string | undefined\n parentExecutionId?: string | undefined\n parentKnown?: boolean | undefined\n flowName?: string | undefined\n coherent: boolean\n waits?: Map<string, { id: string; kind: \"sleep\" | \"signal\"; since: number; settledAt?: number }>\n graph?: EngineEvent.NodeGraph | undefined\n result?: { readonly value: unknown; readonly sequence: number } | undefined\n failure?: EngineExecutionEvidence[\"failure\"] | undefined\n}\n\n/**\n * A render-only view of the same decoded execution facts; never persisted.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface EngineExecutionEvidence {\n readonly executionId: string\n readonly generation: number\n readonly spanId: string\n readonly parentExecutionId?: string | undefined\n readonly parentKnown: boolean\n readonly flowName?: string | undefined\n readonly input?: unknown | undefined\n readonly coherent: boolean\n /** Declared nodes, including work not reached at this journal cursor. */\n readonly graph?: EngineEvent.NodeGraph | undefined\n readonly status: string\n /** Recorded clock and deferred registrations and their explicit settlements. */\n readonly waits: ReadonlyArray<{ readonly id: string; readonly kind: \"sleep\" | \"signal\"; readonly since: number; readonly settledAt?: number }>\n readonly result?: { readonly value: unknown; readonly sequence: number } | undefined\n /** Original classified failure bytes, never parsed from rendered detail. */\n readonly failure?: {\n readonly kind: \"cause\" | \"error\" | \"defect\" | \"interrupted\" | \"encoding\"\n readonly value: unknown\n readonly sequence: number\n } | undefined\n}\nconst decodeProjection = Schema.decodeUnknownOption(Schema.Struct({\n version: Schema.Literal(1),\n executionId: JournalEvent.RunId,\n generation: JournalEvent.NonNegativeQuantity\n}))\n\n/**\n * Observation completion is separate from the control run's terminal verdict.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineProjectionPending = (records: ReadonlyArray<JournalRecord> = []): boolean => {\n const states = new Map<string, { generation: number; pending: boolean }>()\n for (const row of [...records].sort((left, right) => (left.sequence ?? 0) - (right.sequence ?? 0))) {\n if (row.kind === \"control.engine.projection-gap\") {\n // The gap is rendered as missing evidence. Stop polling rather than\n // disguising an observation failure as an indefinitely running task.\n for (const state of states.values()) state.pending = false\n continue\n }\n if (row.kind !== \"control.engine.projection-started\" && row.kind !== \"control.engine.projection-settled\") continue\n const decoded = decodeProjection(row.payload)\n if (Option.isNone(decoded)) continue\n const { executionId, generation } = decoded.value\n const current = states.get(executionId)\n if (row.kind === \"control.engine.projection-started\") {\n if (current === undefined || generation > current.generation) {\n states.set(executionId, { generation, pending: true })\n }\n } else if (current?.generation === generation) current.pending = false\n }\n return [...states.values()].some((state) => state.pending)\n}\n\n/**\n * Generations never share attempt identity. Native timestamps describe native\n * work; the outer control sequence still determines the historical UI cursor.\n * Only recorded parent IDs can nest executions. Ambiguous parent generations\n * remain beside the root instead of guessing which historical parent owned them.\n */\nconst foldEngineJournal = (records: ReadonlyArray<JournalRecord>) => {\n const executions = new Map<string, Execution>()\n const attempts = new Map<string, TraceBuilder>()\n const notices: Array<TraceBuilder> = []\n const nodes = new Map<string, TraceBuilder>()\n const instances = new Map<string, number>()\n const seen = new Map<string, string>()\n for (const row of records) {\n if (row.kind === \"control.engine.projection-gap\") {\n const notice = span(\n `engine-gap:${row.sequence ?? notices.length}`,\n \"event\",\n \"Engine evidence gap\",\n row.occurredAt ?? 0,\n {\n sequence: row.sequence,\n event: row.kind,\n fields: { evidence: row.payload }\n }\n )\n notice.status = \"unknown\"\n notice.endedAt = notice.startedAt\n notices.push(notice)\n continue\n }\n if (row.kind !== \"control.engine.event\") continue\n const decoded = decodeEnvelope(row.payload)\n if (Option.isNone(decoded)) {\n const notice = span(\n `engine-invalid:${row.sequence ?? notices.length}`,\n \"event\",\n \"Unreadable engine evidence\",\n row.occurredAt ?? 0,\n {\n sequence: row.sequence,\n event: row.kind,\n fields: { evidence: row.payload }\n }\n )\n notice.status = \"unknown\"\n notice.endedAt = notice.startedAt\n notices.push(notice)\n continue\n }\n const envelope = decoded.value\n const key = identity(envelope.executionId, envelope.generation)\n const eventKey = identity(key, envelope.sequence)\n const previous = seen.get(eventKey)\n if (previous !== undefined) {\n if (previous !== JSON.stringify(envelope)) {\n const conflict = executions.get(key)\n conflict!.coherent = false\n }\n continue\n }\n seen.set(eventKey, JSON.stringify(envelope))\n let execution = executions.get(key)\n if (execution === undefined) {\n execution = {\n envelope,\n coherent: true,\n span: span(`engine:${key}`, \"execution\", envelope.executionId, envelope.emittedAtMs, detail(row, envelope))\n }\n executions.set(key, execution)\n }\n const parent = (parentId: string | undefined) => {\n if (execution.parentKnown && execution.parentExecutionId !== parentId) execution.coherent = false\n execution.parentKnown = true\n execution.parentExecutionId = parentId\n execution.parentId = parentId\n }\n const result = (value: unknown) => {\n if (Number.isSafeInteger(row.sequence) && row.sequence! >= 0) {\n execution.result = { value, sequence: row.sequence! }\n }\n }\n const failure = (kind: NonNullable<EngineExecutionEvidence[\"failure\"]>[\"kind\"], value: unknown) => {\n if (Number.isSafeInteger(row.sequence) && row.sequence! >= 0) {\n execution.failure = { kind, value, sequence: row.sequence! }\n }\n }\n const generic = () => {\n const event = span(\n `engine-event:${eventKey}`,\n \"event\",\n envelope.eventType,\n envelope.emittedAtMs,\n detail(row, envelope)\n )\n event.endedAt = event.startedAt\n execution.span.children.push(event)\n }\n const attempt = (step: string, number: number) => {\n const attemptKey = identity(key, step, number)\n let current = attempts.get(attemptKey)\n if (current === undefined) {\n current = span(\n `engine-attempt:${attemptKey}`,\n \"attempt\",\n `attempt ${number} \u00B7 ${step.slice(0, 12)}`,\n envelope.emittedAtMs,\n detail(row, envelope)\n )\n attempts.set(attemptKey, current)\n execution.span.children.push(current)\n }\n return current\n }\n if (envelope.eventType === EngineEvent.nodeEventTypes.planRecorded || envelope.eventType === EngineEvent.nodeEventTypes.subgraphAppended) {\n const payload = envelope.payload as { graph?: unknown }\n const graph = decodeGraph(payload?.graph)\n if (Option.isSome(graph)) {\n const nodes = new Map(execution.graph?.nodes.map(node => [node.id, node]))\n for (const node of graph.value.nodes) nodes.set(node.id, node)\n execution.graph = { ...graph.value, nodes: [...nodes.values()] }\n }\n generic()\n continue\n }\n if (envelope.eventType === EngineEvent.nodeEventTypes.nodeScheduled || envelope.eventType === EngineEvent.nodeEventTypes.nodeSettled) {\n const scheduled = envelope.eventType === EngineEvent.nodeEventTypes.nodeScheduled\n ? decodeScheduled(envelope.payload) : Option.none()\n const settled = envelope.eventType === EngineEvent.nodeEventTypes.nodeSettled\n ? decodeSettled(envelope.payload) : Option.none()\n const recorded = Option.isSome(scheduled) ? scheduled.value : Option.isSome(settled) ? settled.value : undefined\n if (recorded === undefined) {\n generic()\n continue\n }\n const nodeKey = identity(key, recorded.nodeId)\n const action = recorded.action ?? execution.graph?.nodes.find(node => node.id === recorded.nodeId)?.action\n let node = nodes.get(nodeKey)\n if (node === undefined || Option.isSome(scheduled)) {\n const instance = (instances.get(nodeKey) ?? 0) + 1\n instances.set(nodeKey, instance)\n node = span(`engine-node:${nodeKey}#${instance}`, \"call\", inspectLabel(action ?? recorded.nodeId), envelope.emittedAtMs, detail(row, envelope))\n nodes.set(nodeKey, node)\n execution.span.children.push(node)\n }\n if (action !== undefined) node.label = inspectLabel(action)\n node.detail = { ...detail(row, envelope), sequence: node.detail.sequence }\n if (Option.isSome(scheduled)) {\n node.status = \"running\"\n } else {\n const value = Option.getOrThrow(settled)\n node.status = value.outcome === \"failed\" ? \"failed\"\n : value.outcome === \"deferred\" ? \"waiting\"\n : value.outcome === \"skipped\" ? \"skipped\" : \"completed\"\n if (value.outcome !== \"deferred\") node.endedAt = envelope.emittedAtMs\n // The redacted preview is evidence, including when truncated. Never\n // evaluate it, or mistake a JSON prefix for a complete return value.\n if (value.result !== undefined) node.detail = { ...node.detail, output: value.result.preview }\n }\n continue\n }\n if (\n envelope.eventType === \"flows.engine.attempt-started\" || envelope.eventType === \"flows.engine.attempt-finished\"\n ) {\n const marker = decodeMarker({ eventType: envelope.eventType, payload: envelope.payload })\n if (Option.isNone(marker) || marker.value.payload.runId !== envelope.executionId) {\n generic()\n continue\n }\n const current = attempt(marker.value.payload.stepKeyDigest, marker.value.payload.attempt)\n if (marker.value.eventType === \"flows.engine.attempt-started\") current.status = \"running\"\n else {\n current.status = marker.value.payload.state === \"succeeded\" ? \"completed\" : \"failed\"\n current.endedAt = envelope.emittedAtMs\n }\n current.detail = { ...current.detail, fields: { ...envelope } }\n continue\n }\n if (envelope.eventType === EngineEvent.attemptEventType) {\n const recorded = decodeAttempt(envelope.payload)\n if (Option.isNone(recorded) || recorded.value.executionId !== envelope.executionId) {\n execution.coherent = false\n generic()\n continue\n }\n const { lifecycle, lineage, stepKeyDigest, attempt: number } = recorded.value\n // Lineage may describe a trampoline predecessor, not a spawned parent.\n // Product ancestry comes only from RunState.parentExecutionId below.\n execution.parentId = lineage.parentRunId ?? undefined\n const current = attempt(stepKeyDigest, number)\n current.startedAt = lifecycle.startedAtMs\n current.status = lifecycle.state === \"succeeded\"\n ? \"completed\"\n : lifecycle.state === \"suspended\"\n ? \"waiting\"\n : lifecycle.state\n current.detail = { ...detail(row, envelope), sequence: current.detail.sequence }\n if (lifecycle.state === \"succeeded\" || lifecycle.state === \"failed\") {\n current.endedAt = lifecycle.finishedAtMs\n current.detail = {\n ...current.detail,\n ...(lifecycle.result._tag === \"Success\"\n ? { output: json(lifecycle.result.value) }\n : { message: json(lifecycle.result.detail) })\n }\n }\n continue\n }\n if (envelope.eventType === EngineEvent.stateEventType) {\n const recorded = decodeState(envelope.payload)\n if (Option.isNone(recorded) || recorded.value.executionId !== envelope.executionId) {\n execution.coherent = false\n generic()\n continue\n }\n execution.parentId = recorded.value.lineage.parentRunId ?? undefined\n const registerWait = (waitId: string, kind: \"sleep\" | \"signal\") => {\n const waits = execution.waits ??= new Map()\n const id = identity(key, waitId)\n const existing = waits.get(id)\n if (existing === undefined) waits.set(id, { id: `engine-wait:${id}`, kind, since: envelope.emittedAtMs })\n // A later clock record refines a generic deferred identity without\n // restarting the wait or dropping its recorded settlement.\n else if (kind === \"sleep\") existing.kind = kind\n }\n if (recorded.value.event._tag === \"Execution\" && recorded.value.event.lifecycle.state !== \"completed\") {\n for (const wait of recorded.value.event.lifecycle.waits) registerWait(wait.waitId, wait._tag === \"Clock\" ? \"sleep\" : \"signal\")\n }\n if (recorded.value.event._tag === \"ClockScheduled\") {\n registerWait(recorded.value.event.waitId, \"sleep\")\n } else if (recorded.value.event._tag === \"DeferredCompleted\") {\n const wait = execution.waits?.get(identity(key, recorded.value.event.waitId))\n if (wait !== undefined && wait.settledAt === undefined) wait.settledAt = envelope.emittedAtMs\n }\n if (recorded.value.event._tag !== \"Execution\") {\n generic()\n continue\n }\n const { lifecycle } = recorded.value.event\n execution.result = undefined\n execution.failure = undefined\n execution.span.detail = {\n ...detail(row, envelope),\n sequence: execution.span.detail.sequence,\n input: execution.span.detail.input\n }\n if (lifecycle.state === \"completed\") {\n execution.span.status = lifecycle.result._tag === \"Success\" ? \"completed\" : \"failed\"\n execution.span.endedAt = envelope.emittedAtMs\n execution.span.detail = {\n ...execution.span.detail,\n ...(lifecycle.result._tag === \"Success\"\n ? { output: json(lifecycle.result.value) }\n : { message: json(lifecycle.result.detail) })\n }\n if (lifecycle.result._tag === \"Success\") result(lifecycle.result.value)\n else failure(lifecycle.result.reason, lifecycle.result.detail)\n } else execution.span.status = lifecycle.state === \"suspended\" ? \"waiting\" : \"running\"\n continue\n }\n if (envelope.eventType === \"flows.engine.interrupted\") {\n const cancelled = decodeCancellation(envelope.payload)\n if (Option.isNone(cancelled)) {\n generic()\n continue\n }\n execution.result = undefined\n execution.failure = undefined\n execution.span.status = \"cancelled\"\n execution.span.endedAt = cancelled.value.interruptedAtMs\n execution.span.detail = {\n ...detail(row, envelope),\n sequence: execution.span.detail.sequence,\n input: execution.span.detail.input\n }\n continue\n }\n if (envelope.eventType === \"flows.engine.run-decision\") {\n const decision = decodeDecision(envelope.payload)\n if (Option.isNone(decision)) {\n const payload = envelope.payload\n // Claim, owner-fence, wake and child-policy decisions deliberately do\n // not carry RunState. Keep them visible without losing valid state\n // evidence; malformed state-bearing decisions still refuse claims.\n if (\n typeof payload === \"object\" && payload !== null &&\n (\"state\" in payload || (\"decision\" in payload && stateDecisions.some((name) => name === payload.decision)))\n ) {\n execution.coherent = false\n }\n generic()\n continue\n }\n const { state, status } = decision.value\n if (execution.flowName !== undefined && execution.flowName !== state.flowName) execution.coherent = false\n execution.flowName = state.flowName\n execution.span.label = inspectLabel(state.flowName)\n parent(state.parentExecutionId)\n execution.result = undefined\n execution.failure = undefined\n execution.span.detail = {\n ...detail(row, envelope),\n sequence: execution.span.detail.sequence,\n input: state.payload\n }\n if (decision.value.decision === \"created\") execution.span.status = \"pending\"\n // RunDriver commits this decision with suspended even when its payload\n // omits status/result (a released host scope can retain no suspension).\n else if (decision.value.decision === \"interrupt-released\") execution.span.status = \"waiting\"\n else if (status === \"running\" || status === \"pending\" || status === \"suspended\") {\n execution.span.status = status === \"suspended\" ? \"waiting\" : status\n } else if (status !== undefined) {\n const decodedResult = decodeResult(state.result)\n if (\n Option.isSome(decodedResult) && decodedResult.value._tag === \"Handoff\" && status === \"completed\" &&\n decision.value.decision === \"handed-off\"\n ) {\n // A round handed off; its raw result describes the successor, not an output.\n execution.span.status = \"completed\"\n execution.span.endedAt = envelope.emittedAtMs\n continue\n }\n if (\n Option.isNone(decodedResult) || decodedResult.value._tag !== \"Complete\" ||\n (status === \"completed\") !== (decodedResult.value.exit._tag === \"Success\")\n ) {\n execution.coherent = false\n execution.span.status = \"unknown\"\n generic()\n continue\n }\n execution.span.status = status\n execution.span.endedAt = envelope.emittedAtMs\n execution.span.detail = {\n ...execution.span.detail,\n ...(decodedResult.value.exit._tag === \"Success\"\n ? { output: json(decodedResult.value.exit.value) }\n : { message: json(decodedResult.value.exit.cause) })\n }\n if (decodedResult.value.exit._tag === \"Success\") result(decodedResult.value.exit.value)\n else failure(\"cause\", decodedResult.value.exit.cause)\n }\n continue\n }\n generic()\n }\n const byExecution = new Map<string, Array<Execution>>()\n for (const current of executions.values()) {\n const generations = byExecution.get(current.envelope.executionId) ?? []\n generations.push(current)\n byExecution.set(current.envelope.executionId, generations)\n }\n const roots: Array<TraceBuilder> = []\n for (const current of executions.values()) {\n const parents = current.parentId === undefined ? [] : byExecution.get(current.parentId) ?? []\n // Build only a forest. Malformed cycles remain separate evidence rows.\n const ancestors = new Set<string>([current.envelope.executionId])\n let parent = parents.length === 1 ? parents[0] : undefined\n let cursor = parent\n while (cursor !== undefined) {\n if (ancestors.has(cursor.envelope.executionId)) {\n parent = undefined\n break\n }\n ancestors.add(cursor.envelope.executionId)\n const next = cursor.parentId === undefined ? [] : byExecution.get(cursor.parentId) ?? []\n cursor = next.length === 1 ? next[0] : undefined\n }\n if (parent === undefined) roots.push(current.span)\n else parent.span.children.push(current.span)\n }\n const evidence: Array<EngineExecutionEvidence> = [...executions.values()].map((current) => ({\n executionId: current.envelope.executionId,\n generation: current.envelope.generation,\n spanId: current.span.id,\n parentExecutionId: current.parentExecutionId,\n parentKnown: current.parentKnown === true,\n flowName: current.flowName,\n input: current.span.detail.input,\n coherent: current.coherent,\n graph: current.graph,\n status: current.span.status,\n waits: [...current.waits?.values() ?? []],\n result: current.result,\n failure: current.failure\n }))\n return { trace: [...roots, ...notices], evidence }\n}\n\n/**\n * Folds native executions and attempts into trace spans with recorded ancestry.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineTraceFromJournal = (records: ReadonlyArray<JournalRecord>): Array<TraceBuilder> =>\n foldEngineJournal(records).trace\n\n/**\n * Product claims use these typed facts, never text rendered into trace details.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineExecutionEvidence = (\n records: ReadonlyArray<JournalRecord>\n): ReadonlyArray<EngineExecutionEvidence> => foldEngineJournal(records).evidence\n\n/**\n * Same recorded native ancestry and historical cursor for every product result projection.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineRunEvidence = (records: ReadonlyArray<JournalRecord>, rootId: string, cursorSeq?: number) => {\n const visible: ReadonlyArray<JournalRecord> = records\n .filter((row) =>\n Number.isSafeInteger(row.sequence) && Number(row.sequence) >= 0 &&\n (cursorSeq === undefined || Number(row.sequence) <= cursorSeq)\n )\n .sort((left, right) => Number(left.sequence) - Number(right.sequence))\n const executions = engineExecutionEvidence(visible)\n const generations = new Map<string, Array<EngineExecutionEvidence>>()\n for (const execution of executions) {\n const found = generations.get(execution.executionId) ?? []\n found.push(execution)\n generations.set(execution.executionId, found)\n }\n const current = (execution: EngineExecutionEvidence) =>\n execution.coherent &&\n execution.generation === Math.max(...generations.get(execution.executionId)!.map((row) => row.generation))\n const belongs = (execution: EngineExecutionEvidence, ownerId = rootId): boolean => {\n const visited = new Set<string>()\n let candidate: EngineExecutionEvidence = execution\n while (true) {\n if (!candidate.coherent || !candidate.parentKnown || visited.has(candidate.executionId)) return false\n visited.add(candidate.executionId)\n if (candidate.executionId === ownerId) return ownerId !== rootId || candidate.parentExecutionId === undefined\n if (candidate.parentExecutionId === undefined) return false\n const parents: ReadonlyArray<EngineExecutionEvidence> = generations.get(candidate.parentExecutionId) ?? []\n // A child names a native parent ID, not its generation. Never infer a\n // parent generation from arrival time after a rewind.\n if (parents.length !== 1) return false\n candidate = parents[0]!\n }\n }\n const owned = executions.filter((row) => current(row) && belongs(row))\n const completed = owned.filter((row) => row.status === \"completed\" && row.result !== undefined)\n return { executions: owned, completed, belongs }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAyB;AACzB,kBAA8B;AAC9B,kBAA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;AAClD,QAAM,cAAc,oBAAI,IAA4C;AACpE,aAAW,aAAa,YAAY;AAClC,UAAM,QAAQ,YAAY,IAAI,UAAU,WAAW,KAAK,CAAC;AACzD,UAAM,KAAK,SAAS;AACpB,gBAAY,IAAI,UAAU,aAAa,KAAK;AAAA,EAC9C;AACA,QAAM,UAAU,CAAC,cACf,UAAU,YACV,UAAU,eAAe,KAAK,IAAI,GAAG,YAAY,IAAI,UAAU,WAAW,EAAG,IAAI,CAAC,QAAQ,IAAI,UAAU,CAAC;AAC3G,QAAM,UAAU,CAAC,WAAoC,UAAU,WAAoB;AACjF,UAAM,UAAU,oBAAI,IAAY;AAChC,QAAI,YAAqC;AACzC,WAAO,MAAM;AACX,UAAI,CAAC,UAAU,YAAY,CAAC,UAAU,eAAe,QAAQ,IAAI,UAAU,WAAW,EAAG,QAAO;AAChG,cAAQ,IAAI,UAAU,WAAW;AACjC,UAAI,UAAU,gBAAgB,QAAS,QAAO,YAAY,UAAU,UAAU,sBAAsB;AACpG,UAAI,UAAU,sBAAsB,OAAW,QAAO;AACtD,YAAM,UAAkD,YAAY,IAAI,UAAU,iBAAiB,KAAK,CAAC;AAGzG,UAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,kBAAY,QAAQ,CAAC;AAAA,IACvB;AAAA,EACF;AACA,QAAM,QAAQ,WAAW,OAAO,CAAC,QAAQ,QAAQ,GAAG,KAAK,QAAQ,GAAG,CAAC;AACrE,QAAM,YAAY,MAAM,OAAO,CAAC,QAAQ,IAAI,WAAW,eAAe,IAAI,WAAW,MAAS;AAC9F,SAAO,EAAE,YAAY,OAAO,WAAW,QAAQ;AACjD;",
|
|
4
|
+
"sourcesContent": ["/**\n * Recorded native evidence, decoded through the contracts that wrote it.\n *\n * @since 1.0.0\n */\n\nimport { RunState } from \"@smthrs/engine-store/RunState\"\nimport { ResultEncoded } from \"@smthrs/flow/Flow\"\nimport * as EngineEvent from \"@smthrs/journal/EngineEvent\"\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport { Option, Schema } from \"effect\"\nimport { inspectLabel } from \"./internal/inspectLabels.ts\"\nimport type { JournalRecord, SpanDetail, TraceBuilder } from \"./RunTrace.ts\"\n\n// This is the private control bridge's envelope, not another engine contract.\nconst Envelope = Schema.Struct({\n version: Schema.Literal(1),\n executionId: JournalEvent.RunId,\n generation: JournalEvent.NonNegativeQuantity,\n sequence: JournalEvent.Seq,\n eventId: Schema.String,\n sourceId: JournalEvent.SourceId,\n sourceSequence: JournalEvent.SourceSeq,\n emittedAtMs: JournalEvent.TimestampMs,\n eventType: Schema.NonEmptyString,\n payload: Schema.Json,\n meta: Schema.Json\n})\ntype Envelope = typeof Envelope.Type\n\nconst decodeEnvelope = Schema.decodeUnknownOption(Envelope)\nconst decodeGraph = Schema.decodeUnknownOption(EngineEvent.NodeGraph)\nconst decodeScheduled = Schema.decodeUnknownOption(EngineEvent.NodeScheduledPayload)\nconst decodeSettled = Schema.decodeUnknownOption(EngineEvent.NodeSettledPayload)\nconst decodeAttempt = Schema.decodeUnknownOption(EngineEvent.AttemptPayload, { onExcessProperty: \"error\" })\nconst decodeState = Schema.decodeUnknownOption(EngineEvent.StatePayload, { onExcessProperty: \"error\" })\nconst decodeMarker = Schema.decodeUnknownOption(EngineEvent.CurrentAttempt)\nconst stateDecisions = [\n \"created\",\n \"resumed\",\n \"transitioned\",\n \"handed-off\",\n \"lineage-exhausted\",\n \"round-invalid\",\n \"quarantined\",\n \"interrupt-released\"\n] as const\nconst decodeDecision = Schema.decodeUnknownOption(Schema.Struct({\n decision: Schema.Literals(stateDecisions),\n status: Schema.optionalKey(Schema.Literals([\"pending\", \"running\", \"suspended\", \"completed\", \"failed\", \"cancelled\"])),\n state: RunState\n}))\n// RunDriver's durable cancellation record has no run-decision counterpart.\nconst decodeCancellation = Schema.decodeUnknownOption(Schema.Struct({\n outcome: Schema.Literal(\"cancelled\"),\n interruptedAtMs: JournalEvent.TimestampMs,\n owner: Schema.String,\n cascadedTo: Schema.optionalKey(Schema.Array(JournalEvent.RunId))\n}))\nconst decodeResult = Schema.decodeUnknownOption(ResultEncoded, { onExcessProperty: \"error\" })\n\nconst json = (value: unknown): string => typeof value === \"string\" ? value : JSON.stringify(value)\nconst identity = (...parts: ReadonlyArray<string | number>) =>\n parts.map((part) => encodeURIComponent(String(part))).join(\":\")\nconst span = (id: string, kind: TraceBuilder[\"kind\"], label: string, at: number, detail: SpanDetail): TraceBuilder => ({\n id,\n kind,\n label,\n status: \"recorded\",\n startedAt: at,\n children: [],\n detail\n})\nconst detail = (row: JournalRecord, envelope: Envelope): SpanDetail => ({\n sequence: row.sequence,\n event: envelope.eventType,\n fields: { ...envelope }\n})\ninterface Execution {\n readonly envelope: Envelope\n readonly span: TraceBuilder\n parentId?: string | undefined\n parentExecutionId?: string | undefined\n parentKnown?: boolean | undefined\n flowName?: string | undefined\n coherent: boolean\n waits?: Map<string, { id: string; kind: \"sleep\" | \"signal\"; since: number; settledAt?: number }>\n graph?: EngineEvent.NodeGraph | undefined\n result?: { readonly value: unknown; readonly sequence: number } | undefined\n failure?: EngineExecutionEvidence[\"failure\"] | undefined\n}\n\n/**\n * A render-only view of the same decoded execution facts; never persisted.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface EngineExecutionEvidence {\n readonly executionId: string\n readonly generation: number\n readonly spanId: string\n readonly parentExecutionId?: string | undefined\n readonly parentKnown: boolean\n readonly flowName?: string | undefined\n readonly input?: unknown | undefined\n readonly coherent: boolean\n /** Declared nodes, including work not reached at this journal cursor. */\n readonly graph?: EngineEvent.NodeGraph | undefined\n readonly status: string\n /** Recorded clock and deferred registrations and their explicit settlements. */\n readonly waits: ReadonlyArray<\n { readonly id: string; readonly kind: \"sleep\" | \"signal\"; readonly since: number; readonly settledAt?: number }\n >\n readonly result?: { readonly value: unknown; readonly sequence: number } | undefined\n /** Original classified failure bytes, never parsed from rendered detail. */\n readonly failure?: {\n readonly kind: \"cause\" | \"error\" | \"defect\" | \"interrupted\" | \"encoding\"\n readonly value: unknown\n readonly sequence: number\n } | undefined\n}\nconst decodeProjection = Schema.decodeUnknownOption(Schema.Struct({\n version: Schema.Literal(1),\n executionId: JournalEvent.RunId,\n generation: JournalEvent.NonNegativeQuantity\n}))\n\n/**\n * Observation completion is separate from the control run's terminal verdict.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineProjectionPending = (records: ReadonlyArray<JournalRecord> = []): boolean => {\n const states = new Map<string, { generation: number; pending: boolean }>()\n for (const row of [...records].sort((left, right) => (left.sequence ?? 0) - (right.sequence ?? 0))) {\n if (row.kind === \"control.engine.projection-gap\") {\n // The gap is rendered as missing evidence. Stop polling rather than\n // disguising an observation failure as an indefinitely running task.\n for (const state of states.values()) state.pending = false\n continue\n }\n if (row.kind !== \"control.engine.projection-started\" && row.kind !== \"control.engine.projection-settled\") continue\n const decoded = decodeProjection(row.payload)\n if (Option.isNone(decoded)) continue\n const { executionId, generation } = decoded.value\n const current = states.get(executionId)\n if (row.kind === \"control.engine.projection-started\") {\n if (current === undefined || generation > current.generation) {\n states.set(executionId, { generation, pending: true })\n }\n } else if (current?.generation === generation) current.pending = false\n }\n return [...states.values()].some((state) => state.pending)\n}\n\n/**\n * Generations never share attempt identity. Native timestamps describe native\n * work; the outer control sequence still determines the historical UI cursor.\n * Only recorded parent IDs can nest executions. Ambiguous parent generations\n * remain beside the root instead of guessing which historical parent owned them.\n */\nconst foldEngineJournal = (records: ReadonlyArray<JournalRecord>) => {\n const executions = new Map<string, Execution>()\n const attempts = new Map<string, TraceBuilder>()\n const notices: Array<TraceBuilder> = []\n const nodes = new Map<string, TraceBuilder>()\n const instances = new Map<string, number>()\n const seen = new Map<string, string>()\n for (const row of records) {\n if (row.kind === \"control.engine.projection-gap\") {\n const notice = span(\n `engine-gap:${row.sequence ?? notices.length}`,\n \"event\",\n \"Engine evidence gap\",\n row.occurredAt ?? 0,\n {\n sequence: row.sequence,\n event: row.kind,\n fields: { evidence: row.payload }\n }\n )\n notice.status = \"unknown\"\n notice.endedAt = notice.startedAt\n notices.push(notice)\n continue\n }\n if (row.kind !== \"control.engine.event\") continue\n const decoded = decodeEnvelope(row.payload)\n if (Option.isNone(decoded)) {\n const notice = span(\n `engine-invalid:${row.sequence ?? notices.length}`,\n \"event\",\n \"Unreadable engine evidence\",\n row.occurredAt ?? 0,\n {\n sequence: row.sequence,\n event: row.kind,\n fields: { evidence: row.payload }\n }\n )\n notice.status = \"unknown\"\n notice.endedAt = notice.startedAt\n notices.push(notice)\n continue\n }\n const envelope = decoded.value\n const key = identity(envelope.executionId, envelope.generation)\n const eventKey = identity(key, envelope.sequence)\n const previous = seen.get(eventKey)\n if (previous !== undefined) {\n if (previous !== JSON.stringify(envelope)) {\n const conflict = executions.get(key)\n conflict!.coherent = false\n }\n continue\n }\n seen.set(eventKey, JSON.stringify(envelope))\n let execution = executions.get(key)\n if (execution === undefined) {\n execution = {\n envelope,\n coherent: true,\n span: span(`engine:${key}`, \"execution\", envelope.executionId, envelope.emittedAtMs, detail(row, envelope))\n }\n executions.set(key, execution)\n }\n const parent = (parentId: string | undefined) => {\n if (execution.parentKnown && execution.parentExecutionId !== parentId) execution.coherent = false\n execution.parentKnown = true\n execution.parentExecutionId = parentId\n execution.parentId = parentId\n }\n const result = (value: unknown) => {\n if (Number.isSafeInteger(row.sequence) && row.sequence! >= 0) {\n execution.result = { value, sequence: row.sequence! }\n }\n }\n const failure = (kind: NonNullable<EngineExecutionEvidence[\"failure\"]>[\"kind\"], value: unknown) => {\n if (Number.isSafeInteger(row.sequence) && row.sequence! >= 0) {\n execution.failure = { kind, value, sequence: row.sequence! }\n }\n }\n const generic = () => {\n const event = span(\n `engine-event:${eventKey}`,\n \"event\",\n envelope.eventType,\n envelope.emittedAtMs,\n detail(row, envelope)\n )\n event.endedAt = event.startedAt\n execution.span.children.push(event)\n }\n const attempt = (step: string, number: number) => {\n const attemptKey = identity(key, step, number)\n let current = attempts.get(attemptKey)\n if (current === undefined) {\n current = span(\n `engine-attempt:${attemptKey}`,\n \"attempt\",\n `attempt ${number} \u00B7 ${step.slice(0, 12)}`,\n envelope.emittedAtMs,\n detail(row, envelope)\n )\n attempts.set(attemptKey, current)\n execution.span.children.push(current)\n }\n return current\n }\n if (\n envelope.eventType === EngineEvent.nodeEventTypes.planRecorded ||\n envelope.eventType === EngineEvent.nodeEventTypes.subgraphAppended\n ) {\n const payload = envelope.payload as { graph?: unknown }\n const graph = decodeGraph(payload?.graph)\n if (Option.isSome(graph)) {\n const nodes = new Map(execution.graph?.nodes.map((node) => [node.id, node]))\n for (const node of graph.value.nodes) nodes.set(node.id, node)\n execution.graph = { ...graph.value, nodes: [...nodes.values()] }\n }\n generic()\n continue\n }\n if (\n envelope.eventType === EngineEvent.nodeEventTypes.nodeScheduled ||\n envelope.eventType === EngineEvent.nodeEventTypes.nodeSettled\n ) {\n const scheduled = envelope.eventType === EngineEvent.nodeEventTypes.nodeScheduled\n ? decodeScheduled(envelope.payload) :\n Option.none()\n const settled = envelope.eventType === EngineEvent.nodeEventTypes.nodeSettled\n ? decodeSettled(envelope.payload) :\n Option.none()\n const recorded = Option.isSome(scheduled) ? scheduled.value : Option.isSome(settled) ? settled.value : undefined\n if (recorded === undefined) {\n generic()\n continue\n }\n const nodeKey = identity(key, recorded.nodeId)\n const action = recorded.action ?? execution.graph?.nodes.find((node) => node.id === recorded.nodeId)?.action\n let node = nodes.get(nodeKey)\n if (node === undefined || Option.isSome(scheduled)) {\n const instance = (instances.get(nodeKey) ?? 0) + 1\n instances.set(nodeKey, instance)\n node = span(\n `engine-node:${nodeKey}#${instance}`,\n \"call\",\n inspectLabel(action ?? recorded.nodeId),\n envelope.emittedAtMs,\n detail(row, envelope)\n )\n nodes.set(nodeKey, node)\n execution.span.children.push(node)\n }\n if (action !== undefined) node.label = inspectLabel(action)\n node.detail = { ...detail(row, envelope), sequence: node.detail.sequence }\n if (Option.isSome(scheduled)) {\n node.status = \"running\"\n } else {\n const value = Option.getOrThrow(settled)\n node.status = value.outcome === \"failed\" ?\n \"failed\"\n : value.outcome === \"deferred\" ?\n \"waiting\"\n : value.outcome === \"skipped\"\n ? \"skipped\"\n : \"completed\"\n if (value.outcome !== \"deferred\") node.endedAt = envelope.emittedAtMs\n // The redacted preview is evidence, including when truncated. Never\n // evaluate it, or mistake a JSON prefix for a complete return value.\n if (value.result !== undefined) node.detail = { ...node.detail, output: value.result.preview }\n }\n continue\n }\n if (\n envelope.eventType === \"flows.engine.attempt-started\" || envelope.eventType === \"flows.engine.attempt-finished\"\n ) {\n const marker = decodeMarker({ eventType: envelope.eventType, payload: envelope.payload })\n if (Option.isNone(marker) || marker.value.payload.runId !== envelope.executionId) {\n generic()\n continue\n }\n const current = attempt(marker.value.payload.stepKeyDigest, marker.value.payload.attempt)\n if (marker.value.eventType === \"flows.engine.attempt-started\") current.status = \"running\"\n else {\n current.status = marker.value.payload.state === \"succeeded\" ? \"completed\" : \"failed\"\n current.endedAt = envelope.emittedAtMs\n }\n current.detail = { ...current.detail, fields: { ...envelope } }\n continue\n }\n if (envelope.eventType === EngineEvent.attemptEventType) {\n const recorded = decodeAttempt(envelope.payload)\n if (Option.isNone(recorded) || recorded.value.executionId !== envelope.executionId) {\n execution.coherent = false\n generic()\n continue\n }\n const { lifecycle, lineage, stepKeyDigest, attempt: number } = recorded.value\n // Lineage may describe a trampoline predecessor, not a spawned parent.\n // Product ancestry comes only from RunState.parentExecutionId below.\n execution.parentId = lineage.parentRunId ?? undefined\n const current = attempt(stepKeyDigest, number)\n current.startedAt = lifecycle.startedAtMs\n current.status = lifecycle.state === \"succeeded\"\n ? \"completed\"\n : lifecycle.state === \"suspended\"\n ? \"waiting\"\n : lifecycle.state\n current.detail = { ...detail(row, envelope), sequence: current.detail.sequence }\n if (lifecycle.state === \"succeeded\" || lifecycle.state === \"failed\") {\n current.endedAt = lifecycle.finishedAtMs\n current.detail = {\n ...current.detail,\n ...(lifecycle.result._tag === \"Success\"\n ? { output: json(lifecycle.result.value) }\n : { message: json(lifecycle.result.detail) })\n }\n }\n continue\n }\n if (envelope.eventType === EngineEvent.stateEventType) {\n const recorded = decodeState(envelope.payload)\n if (Option.isNone(recorded) || recorded.value.executionId !== envelope.executionId) {\n execution.coherent = false\n generic()\n continue\n }\n execution.parentId = recorded.value.lineage.parentRunId ?? undefined\n const registerWait = (waitId: string, kind: \"sleep\" | \"signal\") => {\n const waits = execution.waits ??= new Map()\n const id = identity(key, waitId)\n const existing = waits.get(id)\n if (existing === undefined) waits.set(id, { id: `engine-wait:${id}`, kind, since: envelope.emittedAtMs })\n // A later clock record refines a generic deferred identity without\n // restarting the wait or dropping its recorded settlement.\n else if (kind === \"sleep\") existing.kind = kind\n }\n if (recorded.value.event._tag === \"Execution\" && recorded.value.event.lifecycle.state !== \"completed\") {\n for (const wait of recorded.value.event.lifecycle.waits) {\n registerWait(wait.waitId, wait._tag === \"Clock\" ? \"sleep\" : \"signal\")\n }\n }\n if (recorded.value.event._tag === \"ClockScheduled\") {\n registerWait(recorded.value.event.waitId, \"sleep\")\n } else if (recorded.value.event._tag === \"DeferredCompleted\") {\n const wait = execution.waits?.get(identity(key, recorded.value.event.waitId))\n if (wait !== undefined && wait.settledAt === undefined) wait.settledAt = envelope.emittedAtMs\n }\n if (recorded.value.event._tag !== \"Execution\") {\n generic()\n continue\n }\n const { lifecycle } = recorded.value.event\n execution.result = undefined\n execution.failure = undefined\n execution.span.detail = {\n ...detail(row, envelope),\n sequence: execution.span.detail.sequence,\n input: execution.span.detail.input\n }\n if (lifecycle.state === \"completed\") {\n execution.span.status = lifecycle.result._tag === \"Success\" ? \"completed\" : \"failed\"\n execution.span.endedAt = envelope.emittedAtMs\n execution.span.detail = {\n ...execution.span.detail,\n ...(lifecycle.result._tag === \"Success\"\n ? { output: json(lifecycle.result.value) }\n : { message: json(lifecycle.result.detail) })\n }\n if (lifecycle.result._tag === \"Success\") result(lifecycle.result.value)\n else failure(lifecycle.result.reason, lifecycle.result.detail)\n } else execution.span.status = lifecycle.state === \"suspended\" ? \"waiting\" : \"running\"\n continue\n }\n if (envelope.eventType === \"flows.engine.interrupted\") {\n const cancelled = decodeCancellation(envelope.payload)\n if (Option.isNone(cancelled)) {\n generic()\n continue\n }\n execution.result = undefined\n execution.failure = undefined\n execution.span.status = \"cancelled\"\n execution.span.endedAt = cancelled.value.interruptedAtMs\n execution.span.detail = {\n ...detail(row, envelope),\n sequence: execution.span.detail.sequence,\n input: execution.span.detail.input\n }\n continue\n }\n if (envelope.eventType === \"flows.engine.run-decision\") {\n const decision = decodeDecision(envelope.payload)\n if (Option.isNone(decision)) {\n const payload = envelope.payload\n // Claim, owner-fence, wake and child-policy decisions deliberately do\n // not carry RunState. Keep them visible without losing valid state\n // evidence; malformed state-bearing decisions still refuse claims.\n if (\n typeof payload === \"object\" && payload !== null &&\n (\"state\" in payload || (\"decision\" in payload && stateDecisions.some((name) => name === payload.decision)))\n ) {\n execution.coherent = false\n }\n generic()\n continue\n }\n const { state, status } = decision.value\n if (execution.flowName !== undefined && execution.flowName !== state.flowName) execution.coherent = false\n execution.flowName = state.flowName\n execution.span.label = inspectLabel(state.flowName)\n parent(state.parentExecutionId)\n execution.result = undefined\n execution.failure = undefined\n execution.span.detail = {\n ...detail(row, envelope),\n sequence: execution.span.detail.sequence,\n input: state.payload\n }\n if (decision.value.decision === \"created\") execution.span.status = \"pending\"\n // RunDriver commits this decision with suspended even when its payload\n // omits status/result (a released host scope can retain no suspension).\n else if (decision.value.decision === \"interrupt-released\") execution.span.status = \"waiting\"\n else if (status === \"running\" || status === \"pending\" || status === \"suspended\") {\n execution.span.status = status === \"suspended\" ? \"waiting\" : status\n } else if (status !== undefined) {\n const decodedResult = decodeResult(state.result)\n if (\n Option.isSome(decodedResult) && decodedResult.value._tag === \"Handoff\" && status === \"completed\" &&\n decision.value.decision === \"handed-off\"\n ) {\n // A round handed off; its raw result describes the successor, not an output.\n execution.span.status = \"completed\"\n execution.span.endedAt = envelope.emittedAtMs\n continue\n }\n if (\n Option.isNone(decodedResult) || decodedResult.value._tag !== \"Complete\" ||\n (status === \"completed\") !== (decodedResult.value.exit._tag === \"Success\")\n ) {\n execution.coherent = false\n execution.span.status = \"unknown\"\n generic()\n continue\n }\n execution.span.status = status\n execution.span.endedAt = envelope.emittedAtMs\n execution.span.detail = {\n ...execution.span.detail,\n ...(decodedResult.value.exit._tag === \"Success\"\n ? { output: json(decodedResult.value.exit.value) }\n : { message: json(decodedResult.value.exit.cause) })\n }\n if (decodedResult.value.exit._tag === \"Success\") result(decodedResult.value.exit.value)\n else failure(\"cause\", decodedResult.value.exit.cause)\n }\n continue\n }\n generic()\n }\n const byExecution = new Map<string, Array<Execution>>()\n for (const current of executions.values()) {\n const generations = byExecution.get(current.envelope.executionId) ?? []\n generations.push(current)\n byExecution.set(current.envelope.executionId, generations)\n }\n const roots: Array<TraceBuilder> = []\n for (const current of executions.values()) {\n const parents = current.parentId === undefined ? [] : byExecution.get(current.parentId) ?? []\n // Build only a forest. Malformed cycles remain separate evidence rows.\n const ancestors = new Set<string>([current.envelope.executionId])\n let parent = parents.length === 1 ? parents[0] : undefined\n let cursor = parent\n while (cursor !== undefined) {\n if (ancestors.has(cursor.envelope.executionId)) {\n parent = undefined\n break\n }\n ancestors.add(cursor.envelope.executionId)\n const next = cursor.parentId === undefined ? [] : byExecution.get(cursor.parentId) ?? []\n cursor = next.length === 1 ? next[0] : undefined\n }\n if (parent === undefined) roots.push(current.span)\n else parent.span.children.push(current.span)\n }\n const evidence: Array<EngineExecutionEvidence> = [...executions.values()].map((current) => ({\n executionId: current.envelope.executionId,\n generation: current.envelope.generation,\n spanId: current.span.id,\n parentExecutionId: current.parentExecutionId,\n parentKnown: current.parentKnown === true,\n flowName: current.flowName,\n input: current.span.detail.input,\n coherent: current.coherent,\n graph: current.graph,\n status: current.span.status,\n waits: [...current.waits?.values() ?? []],\n result: current.result,\n failure: current.failure\n }))\n return { trace: [...roots, ...notices], evidence }\n}\n\n/**\n * Folds native executions and attempts into trace spans with recorded ancestry.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineTraceFromJournal = (records: ReadonlyArray<JournalRecord>): Array<TraceBuilder> =>\n foldEngineJournal(records).trace\n\n/**\n * Product claims use these typed facts, never text rendered into trace details.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineExecutionEvidence = (\n records: ReadonlyArray<JournalRecord>\n): ReadonlyArray<EngineExecutionEvidence> => foldEngineJournal(records).evidence\n\n/**\n * Same recorded native ancestry and historical cursor for every product result projection.\n *\n * @category utilities\n * @since 1.0.0\n */\nexport const engineRunEvidence = (records: ReadonlyArray<JournalRecord>, rootId: string, cursorSeq?: number) => {\n const visible: ReadonlyArray<JournalRecord> = records\n .filter((row) =>\n Number.isSafeInteger(row.sequence) && Number(row.sequence) >= 0 &&\n (cursorSeq === undefined || Number(row.sequence) <= cursorSeq)\n )\n .sort((left, right) => Number(left.sequence) - Number(right.sequence))\n const executions = engineExecutionEvidence(visible)\n const generations = new Map<string, Array<EngineExecutionEvidence>>()\n for (const execution of executions) {\n const found = generations.get(execution.executionId) ?? []\n found.push(execution)\n generations.set(execution.executionId, found)\n }\n const current = (execution: EngineExecutionEvidence) =>\n execution.coherent &&\n execution.generation === Math.max(...generations.get(execution.executionId)!.map((row) => row.generation))\n const belongs = (execution: EngineExecutionEvidence, ownerId = rootId): boolean => {\n const visited = new Set<string>()\n let candidate: EngineExecutionEvidence = execution\n while (true) {\n if (!candidate.coherent || !candidate.parentKnown || visited.has(candidate.executionId)) return false\n visited.add(candidate.executionId)\n if (candidate.executionId === ownerId) return ownerId !== rootId || candidate.parentExecutionId === undefined\n if (candidate.parentExecutionId === undefined) return false\n const parents: ReadonlyArray<EngineExecutionEvidence> = generations.get(candidate.parentExecutionId) ?? []\n // A child names a native parent ID, not its generation. Never infer a\n // parent generation from arrival time after a rewind.\n if (parents.length !== 1) return false\n candidate = parents[0]!\n }\n }\n const owned = executions.filter((row) => current(row) && belongs(row))\n const completed = owned.filter((row) => row.status === \"completed\" && row.result !== undefined)\n return { executions: owned, completed, belongs }\n}\n"],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MAAM,SAAS,GACpB,QAAQ,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,EACjD,MAAM,aAAa,CAAC,UAAU,GAAG,SAAS,KACzC,aAAa,CAAC,WAAW,CA8B3B,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GACrB,QAAQ,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,KAChD,aAAa,CAAC,aAAa,CAsB7B,CAAA;AAyCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,EACjD,QAAQ,SAAS,CAAC,MAAM,GAAG,SAAS,KACnC,aAAa,CAAC,YAAY,CA4B5B,CAAA;AAMD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,SAAS,aAAa,CAAC,YAAY,CAAC,KACnC,aAAa,CAAC,eAAe,CAmB/B,CAAA;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU,GACrB,QAAQ,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,KAChD,aAAa,CAAC,aAAa,CAuB7B,CAAA;AA4BD;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,aAAa,CAAC,UAAU,EAC7B,QAAQ,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,EACjD,KAAK,MAAM,KACV,MAAM,CAAC,YAwBT,CAAA"}
|
|
@@ -196,7 +196,10 @@ const runSummary = (run, events, now = Math.max(run.updatedAt, events.at(-1)?.oc
|
|
|
196
196
|
outputTokens: facts.outputTokens,
|
|
197
197
|
verdict: Diagnosis.verdict(facts),
|
|
198
198
|
diagnosis: Diagnosis.render({ runId: run.runId, ...optional("flowId", run.flowId) }, facts),
|
|
199
|
-
...optional(
|
|
199
|
+
...optional(
|
|
200
|
+
"finalOutput",
|
|
201
|
+
Diagnosis.resolvedOutput(facts) ?? (run.status === "failed" && facts.fault?.tag.endsWith("/source_refused") && facts.cause?.match(/source_refused: ([a-z_]+)/) ? JSON.stringify({ message: facts.cause.match(/source_refused: ([a-z_]+)/)[0] }) : void 0)
|
|
202
|
+
),
|
|
200
203
|
...run.status === "failed" ? optional("failureFault", facts.fault?.class) : {},
|
|
201
204
|
...run.status === "failed" ? optional("failureTag", facts.fault?.tag) : {}
|
|
202
205
|
};
|
|
@@ -307,7 +310,13 @@ const humanWaitRow = (run, wait, projected, questionProvenance = "legacy-observa
|
|
|
307
310
|
};
|
|
308
311
|
const approvals = (events, run) => {
|
|
309
312
|
const native = run === void 0 ? void 0 : import_journal.ExecutionFact.foldControl(events, run.runId, run.executionView);
|
|
313
|
+
const grantFacts = events.filter(
|
|
314
|
+
(event) => event.kind === "control.approval.requested" && import_effect.Schema.is(import_control.ControlFacts.ApprovalRequestFact)(event.payload)
|
|
315
|
+
);
|
|
316
|
+
const grants = import_control.ControlFacts.fold(grantFacts).approvals;
|
|
310
317
|
const observed = run?.pendingWaits?.map((wait) => {
|
|
318
|
+
const grant = grants.find((row) => row.runId === run.runId && row.requestId === wait.token);
|
|
319
|
+
if (grant !== void 0) return grant;
|
|
311
320
|
const projected = native?.provenance.humanWaits === "events" ? native.view?.humanWaits?.find(
|
|
312
321
|
(candidate) => candidate.executionId === wait.runId && candidate.waiting?.tokenDigest === wait.tokenDigest
|
|
313
322
|
) : void 0;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/GatewayProjection.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The stable wire rows the gateway serves for each projection, and the pure\n * folds that compute them from control-plane facts.\n *\n * These rows are the whole read contract. Nothing here exposes a store row, a\n * database column, or an engine type: every field is either a\n * `@smthrs/control` projection value or something folded out of the ordered\n * `ControlEvent` deltas `Control.watch` publishes. Wire names are the flows\n * names (`flowId`, `createdAt`, and the `ApprovalTarget.Node` envelope), so a\n * client written against the control plane reads these rows without a\n * translation table.\n *\n * @since 1.0.0\n */\n\nimport { ControlFacts, ControlSchema, Health, Monitor } from \"@smthrs/control\"\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport { ExecutionFact } from \"@smthrs/journal\"\nimport { Schema } from \"effect\"\nimport * as Diagnosis from \"./Diagnosis.ts\"\nimport { callScope, openCallIndex, uniqueCallEvents } from \"./internal/callEvents.ts\"\nimport * as NativeResolution from \"./internal/nativeResolution.ts\"\nimport * as NodeEvents from \"./internal/nodeEvents.ts\"\n\n/**\n * One run, everything a run card displays, and the diagnosis of what happened\n * to it.\n *\n * `flowId` carries what the old wire split across `run.workflowKey` and\n * `run.workflow`, and `createdAt` carries `run.createdAtMs`: one flows name\n * each, rather than two spellings of one fact.\n *\n * @since 1.0.0\n * @category models\n */\nexport const RunSummaryRow = Schema.Struct({\n runId: Schema.String,\n flowId: Schema.String,\n statusRollup: Schema.optional(Health.StatusRollup),\n status: ControlSchema.RunStatus,\n lifecycleProvenance: Schema.optional(ControlFacts.LifecycleProvenance),\n executionProvenance: Schema.optional(ExecutionFact.Provenance),\n createdAt: Schema.Number,\n updatedAt: Schema.Number,\n planId: Schema.optional(Schema.String),\n planDigest: Schema.optional(Schema.String),\n parentRunId: Schema.optional(Schema.String),\n lineageId: Schema.optional(Schema.String),\n roundOrdinal: Schema.optional(Schema.Number),\n waitingReason: Schema.optional(Schema.String),\n steeringPending: Schema.optional(Schema.Number),\n cancellation: Schema.optional(ControlSchema.Cancellation),\n /** When the run's approved deadline passes; absent for a run with none. */\n deadlineAt: Schema.optional(Schema.Number),\n /** The model seat the run's last opened turn ran on. */\n seat: Schema.optional(Schema.String),\n turns: Schema.Number,\n calls: Schema.Number,\n callsFailed: Schema.Number,\n editsAttempted: Schema.Number,\n editsSucceeded: Schema.Number,\n inputTokens: Schema.Number,\n outputTokens: Schema.Number,\n /**\n * One line: the run row's status plus the reason that most explains it.\n *\n * Lifecycle provenance distinguishes a covered control fact from a legacy\n * snapshot or a separate engine observation. Missing facts never silently\n * replace a newer observed state with the last recorded status.\n */\n verdict: Schema.String,\n /** The whole diagnosis card, which the old wire called `whatHappened`. */\n diagnosis: Schema.String,\n finalOutput: Schema.optional(Schema.String),\n /** The failed run's fault class and `<_tag>/<code>`, stamped when it failed. */\n failureFault: Schema.optional(Fault.Class),\n failureTag: Schema.optional(Schema.String)\n})\n\n/**\n * One run, everything a run card displays, and its diagnosis.\n *\n * @since 1.0.0\n * @category models\n */\nexport type RunSummaryRow = typeof RunSummaryRow.Type\n\n/**\n * One node of a run, as a tree view renders it.\n *\n * `label` carries what the old wire called `node.cardLabel`, and `seat`\n * carries `node.agent`: the model seat is the flows name for who ran a node.\n *\n * `nodeId` is the ordinal the call opened on, because the emitter names no\n * node. {@link runTree} says why.\n *\n * @since 1.0.0\n * @category models\n */\nexport const RunTreeRow = Schema.Struct({\n runId: Schema.String,\n nodeId: Schema.String,\n label: Schema.String,\n status: Schema.Literals([\"running\", \"completed\", \"failed\"]),\n seat: Schema.optional(Schema.String),\n startedAt: Schema.Number,\n endedAt: Schema.optional(Schema.Number),\n parentRunId: Schema.optional(Schema.String)\n})\n\n/**\n * One node of a run, as a tree view renders it.\n *\n * @since 1.0.0\n * @category models\n */\nexport type RunTreeRow = typeof RunTreeRow.Type\n\n/**\n * One approval a run is parked on, carrying the exact payload that decides it.\n *\n * `title` carries the old `approval.requestTitle` and `request` the old\n * `approval.request`; `payload` is the `ApprovalTarget.Node` envelope a client\n * submits back unchanged, so no client reconstructs authority.\n *\n * @since 1.0.0\n * @category models\n */\nexport const ApprovalRow = Schema.Struct({\n runId: Schema.String,\n /**\n * The execution holding the wait, when this gate is a question a person owes\n * an answer to and it is held below `runId`.\n *\n * `runId` is the run a person opened and the run a decision is addressed to;\n * a `HumanTask` in a nested flow parks its own execution, and the two are\n * different runs. Present only on such a gate, so a reader can tell a\n * question rolled up from a tree from one the named run raised itself, and\n * an inbox can list one question once however many ancestors carry it.\n */\n waitRunId: Schema.optional(Schema.String),\n questionProvenance: Schema.optional(Schema.Literals([\"events\", \"legacy-observation\", \"unverified-observation\"])),\n requestId: Schema.String,\n title: Schema.String,\n request: Schema.Json,\n payload: ControlSchema.ApprovalPayload,\n requestedAt: Schema.Number,\n status: Schema.Literals([\"pending\", \"approved\", \"denied\"])\n})\n\n/**\n * One approval a run is parked on.\n *\n * @since 1.0.0\n * @category models\n */\nexport type ApprovalRow = typeof ApprovalRow.Type\n\n/**\n * The output one node produced.\n *\n * @since 1.0.0\n * @category models\n */\nexport const NodeOutputRow = Schema.Struct({\n runId: Schema.String,\n nodeId: Schema.String,\n outcome: Schema.Literals([\"success\", \"failure\"]),\n output: Schema.String,\n settledAt: Schema.Number\n})\n\n/**\n * The output one node produced.\n *\n * @since 1.0.0\n * @category models\n */\nexport type NodeOutputRow = typeof NodeOutputRow.Type\n\n/**\n * How long one flow's nodes take, per action tag.\n *\n * `samples` is the number of measured executions behind the two percentiles,\n * and it is on the wire because a percentile over one sample and a percentile\n * over twenty are different claims. A tag with no measured execution has no\n * row at all: there is no shape here for an unmeasured prediction.\n *\n * @since 1.0.0\n * @category models\n */\nexport const FlowDurationRow = Schema.Struct({\n flowId: Schema.String,\n actionTag: Schema.String,\n samples: Schema.Number,\n p50Ms: Schema.Number,\n p90Ms: Schema.Number\n})\n\n/**\n * How long one flow's nodes take, per action tag.\n *\n * @since 1.0.0\n * @category models\n */\nexport type FlowDurationRow = typeof FlowDurationRow.Type\n\n/**\n * One measured execution of one node, as a duration fold's sample.\n *\n * The action tag is the only part of a node's key material that survives a\n * re-key, which is why history is grouped by it rather than by node id or by\n * dispatch key.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface NodeDuration {\n readonly actionTag: string\n readonly durationMs: number\n}\n\n/**\n * One line of a run's turn-by-turn transcript.\n *\n * @since 1.0.0\n * @category models\n */\nexport const TranscriptRow = Schema.Struct({\n runId: Schema.String,\n sequence: Schema.Number,\n turn: Schema.Number,\n at: Schema.Number,\n kind: Schema.String,\n /** Dispatch identity on current call records; absent on legacy history. */\n callId: Schema.optional(Schema.String),\n text: Schema.String\n})\n\n/**\n * One line of a run's turn-by-turn transcript.\n *\n * @since 1.0.0\n * @category models\n */\nexport type TranscriptRow = typeof TranscriptRow.Type\n\n/** Copies only the optional fields a run summary actually carries. */\nconst optional = <A>(key: string, value: A | undefined): Record<string, A> =>\n value === undefined ? {} : { [key]: value }\n\n/**\n * Folds one run's summary and events into the served `run-summary` row.\n *\n * @param run the control-plane run summary\n * @param events that run's ordered control events\n * @param now the instant the row is rendered at\n * @param carry the digest of the events a bounded reader dropped before them\n * @since 1.0.0\n * @category projections\n */\nexport const runSummary = (\n run: ControlSchema.RunSummary,\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n now: number = Math.max(run.updatedAt, events.at(-1)?.occurredAt ?? 0),\n carry?: Diagnosis.Digest | undefined\n): RunSummaryRow => {\n const projected = ControlFacts.fold(events, run)\n // Supplying a snapshot guarantees a run: uncovered facts retain that\n // observation; only the event-only fold can return an absent run.\n run = projected.run!\n const native = ExecutionFact.foldControl(events, run.runId, run.executionView)\n // The control fold remains control authority. Native lifecycle is independently\n // replayed/verified against the coherent executor observation when available.\n if (run.executionObservation === \"observed\" && native?.view !== undefined) {\n const { root, current } = native.view\n run = {\n ...run,\n status: current.status === \"pending\" ? \"accepted\" : current.status === \"suspended\"\n ? current.waiting?.reason === \"approval\" ||\n (native.view.humanWaits?.length ?? run.pendingWaits?.length ?? 0) > 0\n ? \"waiting-approval\" :\n \"parked\"\n : current.status === \"running\" && (native.view.humanWaits?.length ?? run.pendingWaits?.length ?? 0) > 0\n ? \"waiting-approval\" :\n current.status,\n waitingReason: current.status === \"suspended\" ? current.waiting?.reason : undefined,\n parentRunId: root.parentRunId ?? undefined,\n lineageId: root.lineageId,\n roundOrdinal: root.roundOrdinal\n }\n }\n // `carry` is the digest of the events a bounded reader dropped ahead of\n // `events`. Combining it keeps turns, calls, edits and tokens exact for a run\n // whose journal no longer fits one window, so the counters a run card shows\n // describe the whole run and not just its tail.\n const window = Diagnosis.digest(events, run.runId)\n const facts = { ...(carry === undefined ? window : Diagnosis.combine(carry, window)), status: run.status }\n return {\n runId: run.runId,\n flowId: run.flowId,\n status: run.status,\n lifecycleProvenance: projected.provenance,\n ...optional(\"executionProvenance\", native?.provenance),\n statusRollup: statusRollup(run, events, now),\n createdAt: run.createdAt,\n updatedAt: run.updatedAt,\n ...optional(\"planId\", run.planId),\n ...optional(\"planDigest\", run.planDigest),\n ...optional(\"parentRunId\", run.parentRunId),\n ...optional(\"lineageId\", run.lineageId),\n ...optional(\"roundOrdinal\", run.roundOrdinal),\n ...optional(\"waitingReason\", run.waitingReason),\n ...optional(\"steeringPending\", run.steering?.pending),\n ...optional(\"cancellation\", run.cancellation),\n ...optional(\"deadlineAt\", run.deadlineAt),\n ...optional(\"seat\", facts.seat),\n turns: facts.turns,\n calls: facts.calls,\n callsFailed: facts.callsFailed,\n editsAttempted: facts.editsAttempted,\n editsSucceeded: facts.editsSucceeded,\n inputTokens: facts.inputTokens,\n outputTokens: facts.outputTokens,\n verdict: Diagnosis.verdict(facts),\n diagnosis: Diagnosis.render({ runId: run.runId, ...optional(\"flowId\", run.flowId) }, facts),\n ...optional(\"finalOutput\", Diagnosis.resolvedOutput(facts) ?? (\n run.status === \"failed\" && facts.fault?.tag.endsWith(\"/source_refused\") &&\n facts.cause?.match(/source_refused: ([a-z_]+)/)\n ? JSON.stringify({ message: facts.cause.match(/source_refused: ([a-z_]+)/)![0] })\n : undefined\n )) ,\n ...(run.status === \"failed\" ? optional(\"failureFault\", facts.fault?.class) : {}),\n ...(run.status === \"failed\" ? optional(\"failureTag\", facts.fault?.tag) : {})\n }\n}\n\n/**\n * Claims a call by its durable dispatch identity. Legacy history has no id:\n * match only legacy starts by flow name (or FIFO when unnamed). A new\n * settlement can close a legacy start after an old parked run resumes, but\n * neither fallback may steal an identified call.\n */\nconst takeOpenCall = <\n A extends { readonly flowName: string; readonly callId: string | undefined; readonly scope: string | undefined }\n>(\n open: Array<A>,\n callId: string | undefined,\n flowName: string | undefined,\n scope: string | undefined\n): A | undefined => {\n const found = openCallIndex(open, callId, flowName, scope)\n return found < 0 ? undefined : open.splice(found, 1)[0]\n}\n\n/**\n * One agent call, as every node projection sees it: the ordinal it opened on,\n * the seat that ran it, and the settlement that closed it, if one did.\n */\ninterface CallRecord {\n readonly nodeId: string\n readonly flowName: string\n readonly seat: string | undefined\n readonly startedAt: number\n readonly settlement: CallSettlement | undefined\n}\n\n/** What closed a call, and where among the run's settlements it closed. */\ninterface CallSettlement {\n /** The rank of this settlement among the run's, counting from one. */\n readonly order: number\n /** The run the settlement named, which a malformed journal can omit. */\n readonly runId: string | undefined\n readonly at: number\n readonly outcome: \"success\" | \"failure\"\n readonly output: string\n}\n\n/**\n * Folds one run's events into the agent calls it made, in the order they\n * opened.\n *\n * This is the only fold that assigns a call its `call-N` identity, records the\n * seat and time it opened on, and pairs a settlement with the call it closed.\n * A client asks for a node's output by the id a tree row carries, so the two\n * projections have to agree on that id; when they counted separately they\n * could disagree, and once did, because skipping an event before the ordinal\n * advanced shifted one fold's keys against the other's. The ordinal therefore\n * advances on every distinct start, whatever else that event is missing.\n * Identified duplicate starts and settlements are ignored. Old idless rows\n * retain their original ordinal/FIFO interpretation; their missing dispatch\n * identity cannot be reconstructed when same-name calls overlapped.\n *\n * `uniqueCallEvents` also normalizes native step facts, so this fold reads the\n * run's own records and one stream per step a module run dispatched. The three\n * classes `Diagnosis` names apply here too, field by field:\n *\n * | Field | Class | Why |\n * | ----------------------- | --------------- | ------------------------------------------------------ |\n * | `nodeId` (`call-N`) | aggregate | one tree lists every call the run made, steps included |\n * | `flowName`, `startedAt` | aggregate | read off the call's own record |\n * | `settlement` | aggregate | claimed by call identity within the recorded scope |\n * | `seat` | scope dependent | who ran THIS call, so the turn must be this call's own |\n *\n * There is no root-only field here: a tree row describes a call, never the\n * run's answer or state. A new field has to name its class.\n */\nconst callHistory = (\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<CallRecord> => {\n const calls = new Map<string, CallRecord>()\n const open: Array<\n {\n readonly callId: string | undefined\n readonly flowName: string\n readonly call: CallRecord\n readonly scope: string | undefined\n }\n > = []\n // The seat of the last turn opened in each scope. A module run interleaves\n // steps in one journal, so the run-wide reading attributed one step's seat\n // to another step's calls. A prompt run records one unscoped stream and\n // reads exactly as it did.\n const seats = new Map<string | undefined, string | undefined>()\n let ordinal = 0\n let settlements = 0\n\n for (const event of uniqueCallEvents(events)) {\n const payload = Diagnosis.asRecord(event.payload)\n if (event.kind === \"control.agent.turn-opened\") {\n const scope = callScope(event)\n seats.set(scope, Diagnosis.asString(payload.seat) ?? seats.get(scope))\n continue\n }\n if (event.kind === \"control.agent.cell-call-started\") {\n const callId = Diagnosis.asString(payload.callId)\n ordinal += 1\n const nodeId = `call-${ordinal}`\n const flowName = Diagnosis.asString(payload.flowName) ?? nodeId\n const scope = callScope(event)\n // This scope's own turn, else the run's. A step that opened no turn of\n // its own borrows nothing from a sibling step.\n const seat = seats.get(scope) ?? seats.get(undefined)\n const call: CallRecord = { nodeId, flowName, seat, startedAt: Diagnosis.timeOf(event), settlement: undefined }\n open.push({ callId, flowName, call, scope })\n calls.set(nodeId, call)\n continue\n }\n if (event.kind !== \"control.agent.cell-call-settled\") continue\n const callId = Diagnosis.asString(payload.callId)\n const claimed = takeOpenCall(open, callId, Diagnosis.asString(payload.flowName), callScope(event))\n if (claimed === undefined) continue\n const failed = Diagnosis.asString(payload.outcome) === \"failure\"\n settlements += 1\n // Rewriting the entry keeps the call in the position it opened on, which\n // is the order a tree renders.\n calls.set(claimed.call.nodeId, {\n ...claimed.call,\n settlement: {\n order: settlements,\n runId: Diagnosis.asString(payload.runId) ?? event.runId,\n at: Diagnosis.timeOf(event),\n outcome: failed ? \"failure\" : \"success\",\n output: failed\n ? Diagnosis.asString(payload.message) ?? \"\"\n : Diagnosis.asString(payload.value) ?? JSON.stringify(payload.value ?? null)\n }\n })\n }\n return [...calls.values()]\n}\n\n/** How a tree row reports a call: settled the way it settled, or still running. */\nconst treeStatus = (settlement: CallSettlement | undefined): RunTreeRow[\"status\"] => {\n if (settlement === undefined) return \"running\"\n return settlement.outcome === \"failure\" ? \"failed\" : \"completed\"\n}\n\n/**\n * Folds one run's events into its node rows.\n *\n * A node opens on `control.agent.cell-call-started` and settles on the\n * matching `control.agent.cell-call-settled`.\n *\n * AgentSession journals the same `callId` from the harness's dispatch identity\n * on both records. Settlements join on it even when same-name calls overlap\n * and finish out of order. The distinct-start ordinal remains the published\n * `call-N` node key, preserving existing node links. Legacy records without\n * callId retain same-name FIFO pairing, restricted to other legacy records\n * (including a newly identified settlement of an old parked call).\n *\n * The durable engine's own `flows.engine.*` records are not folded here, but\n * that is a choice rather than a limit. A host keeps the control plane and the\n * engine in two databases with two journals (`@smthrs/cli`\n * `NodeControl.databasePath` and `executionDatabasePath`), and\n * `EngineJournalProjection` copies every engine entry of the run into the\n * control journal as a `control.engine.event` envelope, which is how\n * {@link nodeDurations} reads the node records. A tree row is an agent cell\n * call, so what an engine step did reaches this projection as the call that\n * made it.\n *\n * A node that never settled stays `running`, which is how a live tree renders\n * work in flight.\n *\n * @param run the control-plane run summary\n * @param events that run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const runTree = (\n run: ControlSchema.RunSummary,\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<RunTreeRow> =>\n callHistory(events).map((call): RunTreeRow => ({\n runId: run.runId,\n nodeId: call.nodeId,\n label: call.flowName,\n status: treeStatus(call.settlement),\n ...optional(\"seat\", call.seat),\n startedAt: call.startedAt,\n ...optional(\"endedAt\", call.settlement?.at),\n ...optional(\"parentRunId\", run.parentRunId)\n }))\n\n/**\n * The declared question of a human wait, as far as it can be read.\n *\n * `request` is whatever the wait wrote about itself, which for `HumanTask` is\n * `{task, name, kind, prompt, attempt, maxAttempts}`. A wait that declared\n * nothing \u2014 an older park, or a plugin's own \u2014 still produces a row, because a\n * gate a person cannot see is a run that waits forever; it just has less to\n * render.\n */\nconst questionOf = (wait: ControlSchema.PendingWait): Record<string, unknown> => Diagnosis.asRecord(wait.request)\n\n/**\n * One pending row for a human wait held anywhere in a run's tree.\n *\n * `runId` is the ROOT: this is the run a person opened, and the run a decision\n * is addressed to. `waitRunId` is the execution actually holding it, because a\n * client routes by run and the control plane routes within the tree.\n *\n * `requestId` is the wait point's own name (`coding-clarification#1`), which is\n * unique within a tree, stable across a re-read, and the name a `Signal`\n * addresses. The token travels in the request too, for a client that would\n * rather submit the exact durable address back.\n */\nconst humanWaitRow = (\n run: ControlSchema.RunSummary,\n wait: ControlSchema.PendingWait,\n projected?: ExecutionFact.Observation,\n questionProvenance: \"events\" | \"legacy-observation\" | \"unverified-observation\" = \"legacy-observation\"\n): ApprovalRow => {\n const question = projected === undefined ? questionOf(wait) : Diagnosis.asRecord(projected.waiting?.request)\n const name = wait.name ?? Diagnosis.asString(question[\"name\"]) ?? wait.token\n const requestId = wait.attempt === undefined ? name : `${name}#${wait.attempt}`\n const prompt = Diagnosis.asString(question[\"prompt\"])\n const waitFlowId = projected?.flowName ?? wait.flowId\n return {\n runId: run.runId,\n waitRunId: wait.runId,\n questionProvenance,\n requestId,\n title: prompt ?? `Answer needed \u2014 ${name}`,\n request: {\n ...question,\n kind: Diagnosis.asString(question[\"kind\"]) ?? \"ask\",\n name,\n ...(wait.attempt === undefined ? {} : { attempt: wait.attempt }),\n ...(waitFlowId === undefined ? {} : { waitFlowId }),\n token: wait.token\n },\n payload: {\n target: {\n _tag: \"Node\",\n runId: run.runId,\n requestId,\n digest: wait.token,\n // A human answer grants no capabilities: the envelope a decision binds\n // to is the empty one, the same shape a flow with none carries.\n envelope: { capabilities: [], flows: [], budget: {} }\n },\n scope: \"once\",\n // The identity is the PARK, not its name: a loop that re-asks one\n // question parks again under the same run, name and attempt, and a\n // name-keyed answer would deduplicate the second decision into the\n // first \u2014 accepted, never delivered, and parked forever.\n idempotencyKey: `answer:${run.runId}:${requestId}:${wait.tokenDigest ?? wait.token}`\n },\n requestedAt: projected?.createdAtMs ?? wait.createdAt,\n status: \"pending\"\n }\n}\n\n/**\n * Folds one run's events into its approval rows.\n *\n * A request opens a pending row carrying the submit-ready payload; the\n * matching `control.approval.approved` or `control.approval.denied` closes it\n * without discarding the request, so a decided gate stays readable.\n *\n * A `HumanTask` declares its question on the parked row. Native execution\n * facts carry the redacted question and token digest; verified facts supply\n * its display metadata here. `@smthrs/control` rolls current open waits onto\n * the root as `pendingWaits`, which supply each row's protected wake address.\n * History alone cannot create an answerable human wait. Older observations\n * remain visible with explicit question provenance when native fact coverage\n * is unavailable. These rows come first because they still need an answer.\n *\n * A decision names the gate it closed by `tokenId`. `@smthrs/control`\n * `SqlControlRuntime.lookupApproval` mints that token id from the target, and\n * for the `Node` target a run parks on it is the request id itself, so the two\n * records join on one field. A decision whose `tokenId` or `requestId` names\n * no row is retained for an exact later request. Only a legacy decision that\n * names neither field closes the oldest pending legacy row in that run.\n * Current facts bind the target digest; duplicates cannot reopen a decision.\n *\n * @param events the run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const approvals = (\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n run?: ControlSchema.RunSummary | undefined\n): ReadonlyArray<ApprovalRow> => {\n const native = run === undefined ? undefined : ExecutionFact.foldControl(events, run.runId, run.executionView)\n const observed = run?.pendingWaits?.map((wait) => {\n const projected = native?.provenance.humanWaits === \"events\" ?\n native.view?.humanWaits?.find((candidate) =>\n candidate.executionId === wait.runId && candidate.waiting?.tokenDigest === wait.tokenDigest\n ) :\n undefined\n return humanWaitRow(\n run,\n wait,\n projected,\n projected === undefined\n ? native?.provenance.humanWaits === \"events\" ?\n \"unverified-observation\" :\n native?.provenance.humanWaits ?? \"legacy-observation\"\n : \"events\"\n )\n })\n // The current observation supplies wake authority. History supplies only the\n // display metadata that verifies against that exact observed token digest.\n return ControlFacts.fold(events, undefined, observed).approvals\n}\n\n/**\n * Folds one run's events into its node outputs, keyed the way {@link runTree}\n * keys its rows: by the ordinal the call opened on.\n *\n * A settled call carries the value it produced, so the row carries that value.\n * A run's own result reaches a client as `RunSummaryRow.finalOutput` instead.\n *\n * @param events the run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const nodeOutput = (\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<NodeOutputRow> => {\n const settled: Array<{ readonly order: number; readonly row: NodeOutputRow }> = []\n for (const call of callHistory(events)) {\n const settlement = call.settlement\n if (settlement === undefined) continue\n // A row names the run it belongs to. A settlement that names none closes\n // its call without producing one.\n if (settlement.runId === undefined) continue\n settled.push({\n order: settlement.order,\n row: {\n runId: settlement.runId,\n nodeId: call.nodeId,\n outcome: settlement.outcome,\n output: settlement.output,\n settledAt: settlement.at\n }\n })\n }\n // A tree reads in the order calls opened; outputs read in the order they\n // settled, which is the order a client watched them arrive.\n return settled.sort((left, right) => left.order - right.order).map((entry) => entry.row)\n}\n\n/** The node id every execution gives the flow it was started to run. */\nconst rootNodeId = \"root\"\n\n/**\n * The native execution the host bound this control run to, when one is known.\n *\n * Only the host's own binding record names the root, and two records that\n * disagree name nothing: an ambiguous binding cannot tell a callee's\n * execution apart from the root's, so it authorizes no skip.\n *\n * The binding is written once, when the host takes the root up, so a window\n * bounded to a run's newest events is the one window it falls out of. The\n * carried digest keeps it across that eviction, and reading from the carry is\n * what keeps a long run's calls counted the same as a short run's.\n */\nconst boundExecution = (\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n carry: Diagnosis.Digest | undefined\n): string | undefined => {\n let resolution = carry?.nativeResolution\n for (const event of events) resolution = NativeResolution.combine(resolution, NativeResolution.fromEvent(event))\n return resolution === undefined || resolution.conflict === true ? undefined : resolution.binding?.executionId\n}\n\n/**\n * A callee's own view of a call its caller already measured.\n *\n * Every execution below the bound root was started by a `FlowCall` node in\n * the execution above it, and that node carries the same action tag over the\n * same span. The caller's node is the one kept, because it is the node a plan\n * carries and the one a graph can join a prediction onto.\n *\n * With no binding nothing is echoed: a fold that cannot name the root cannot\n * tell which `root` record belongs to it, and dropping samples on a guess\n * would answer a smaller history than the flow ran.\n */\nconst echoedRoot = (bound: string | undefined, executionId: string, nodeId: string): boolean =>\n bound !== undefined && nodeId === rootNodeId && executionId !== bound\n\n/**\n * Folds one run's events into the executions it measured.\n *\n * A node's work starts when the engine recorded it scheduled and ends when it\n * recorded it settled, so a duration is the distance between those two native\n * stamps. Four of the five outcomes contribute nothing: `clean` was served\n * from records rather than run, `failed` measures a collapse, `skipped` was\n * never reached, and `deferred` is scheduling debt. Only `built` ran.\n *\n * A settlement pairs with the LAST schedule of the same execution and node,\n * which is what makes a retried node measure its final attempt rather than\n * the span across every attempt. Two executions of one node id stay apart\n * because the pairing key carries the execution, and a settlement no schedule\n * opened measures nothing rather than measuring from zero.\n *\n * A record that names no action tag contributes nothing either: history is\n * grouped by tag, and a sample with no tag has nowhere honest to go.\n *\n * A called flow is measured once. The engine records one call twice: the\n * caller admits and settles the node that made it, and the callee's own\n * execution admits and settles its `root` over the same span with the same\n * action tag. {@link echoedRoot} drops the callee's copy, so one invocation\n * is one sample rather than two, and `samples` stays the count of executions\n * the flow performed.\n *\n * @param events the run's ordered control events\n * @param carry the digest of the events a bounded window dropped, when it dropped any\n * @since 1.0.0\n * @category projections\n */\nexport const nodeDurations = (\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n carry?: Diagnosis.Digest | undefined\n): ReadonlyArray<NodeDuration> => {\n const bound = boundExecution(events, carry)\n const started = new Map<string, number>()\n const measured: Array<NodeDuration> = []\n for (const event of events) {\n const schedule = NodeEvents.nodeScheduled(event)\n if (schedule !== undefined) {\n if (echoedRoot(bound, schedule.executionId, schedule.payload.nodeId)) continue\n started.set(`${schedule.executionId}\\u0000${schedule.payload.nodeId}`, schedule.emittedAtMs)\n continue\n }\n const settlement = NodeEvents.nodeSettled(event)\n if (settlement === undefined) continue\n if (echoedRoot(bound, settlement.executionId, settlement.payload.nodeId)) continue\n if (settlement.payload.outcome !== \"built\") continue\n const actionTag = settlement.payload.action\n if (actionTag === undefined) continue\n const key = `${settlement.executionId}\\u0000${settlement.payload.nodeId}`\n const startedAt = started.get(key)\n if (startedAt === undefined) continue\n started.delete(key)\n const durationMs = settlement.emittedAtMs - startedAt\n // Wall clocks can move backwards, and a completion that predates its own\n // start is a clock fact rather than a duration.\n if (durationMs < 0) continue\n measured.push({ actionTag, durationMs })\n }\n return measured\n}\n\n/** The nearest-rank percentile of an ascending sample, which is one observed value. */\nconst nearestRank = (ascending: ReadonlyArray<number>, percentile: number): number =>\n ascending[Math.ceil((percentile / 100) * ascending.length) - 1]!\n\n/**\n * Folds every measured execution of one flow into one row per action tag.\n *\n * Both percentiles are nearest-rank, so each answer is a duration the flow\n * really took rather than an interpolation between two it did not. Rows are\n * ordered by tag, so two reads of the same history answer in the same order.\n *\n * A tag reaches this function only by having been measured, so every row\n * carries at least one sample, and a flow nothing has measured answers with\n * no rows at all.\n *\n * @param flowId the flow whose history was read\n * @param samples every measured execution of that flow's runs\n * @since 1.0.0\n * @category projections\n */\nexport const flowDurations = (\n flowId: string,\n samples: ReadonlyArray<NodeDuration>\n): ReadonlyArray<FlowDurationRow> => {\n const byTag = new Map<string, Array<number>>()\n for (const sample of samples) {\n const held = byTag.get(sample.actionTag)\n if (held === undefined) byTag.set(sample.actionTag, [sample.durationMs])\n else held.push(sample.durationMs)\n }\n return [...byTag.entries()]\n .sort(([left], [right]) => left < right ? -1 : 1)\n .map(([actionTag, observed]) => {\n const ascending = [...observed].sort((left, right) => left - right)\n return {\n flowId,\n actionTag,\n samples: ascending.length,\n p50Ms: nearestRank(ascending, 50),\n p90Ms: nearestRank(ascending, 90)\n }\n })\n}\n\n/** Events the transcript reports verbatim rather than as agent activity. */\nconst transcriptKinds: ReadonlySet<string> = new Set([\"control.approval.requested\"])\n\n/**\n * Folds one run's events into a turn-numbered transcript.\n *\n * A row is reported for every `control.run.*` and `control.agent.*` event and\n * for an approval request, and for nothing else: the transcript is what a\n * reader follows, not the whole journal, which `run-events` already serves.\n * The turn counter advances on `control.agent.turn-opened`, so every row\n * carries the turn it belongs to, and each row's text is one display line, so\n * a multi-line seat, message, or question cannot split one row into several.\n *\n * `uniqueCallEvents` normalizes native step facts, so a module run's steps\n * report here too. The classes `Diagnosis` names apply, field by field:\n *\n * | Field | Class | Why |\n * | ------ | --------- | --------------------------------------------------------- |\n * | rows | aggregate | every row is one event this run recorded, wherever it ran |\n * | `turn` | aggregate | a turn a step opened is a turn this run opened |\n *\n * No row is root only, because no row claims to be the run's answer or state:\n * a `control.agent.resolved` row says one agent resolved, and the run's own\n * answer is served by `runSummary` from `Diagnosis`. A new field has to name\n * its class.\n *\n * @param events the run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const transcript = (\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<TranscriptRow> => {\n const rows: Array<TranscriptRow> = []\n let turn = 0\n for (const event of uniqueCallEvents(events)) {\n const payload = Diagnosis.asRecord(event.payload)\n const runId = Diagnosis.asString(payload.runId) ?? event.runId\n if (runId === undefined) continue\n const reported = event.kind.startsWith(\"control.run.\") ||\n event.kind.startsWith(\"control.agent.\") ||\n transcriptKinds.has(event.kind)\n if (!reported) continue\n if (event.kind === \"control.agent.turn-opened\") turn += 1\n rows.push({\n runId,\n sequence: event.sequence,\n turn,\n at: Diagnosis.timeOf(event),\n kind: event.kind,\n ...optional(\"callId\", Diagnosis.asString(payload.callId)),\n text: line(event.kind, payload)\n })\n }\n return rows\n}\n\n/** One event as a single transcript line. */\nconst line = (kind: string, payload: Record<string, unknown>): string => {\n switch (kind) {\n case \"control.agent.turn-opened\":\n return `turn opened \u00B7 ${Diagnosis.firstLine(Diagnosis.asString(payload.seat) ?? \"\")}`\n case \"control.agent.model-settled\": {\n const usage = Diagnosis.asRecord(payload.usage)\n return `model ${Diagnosis.asNumber(usage.inputTokens) ?? 0} in / ${\n Diagnosis.asNumber(usage.outputTokens) ?? 0\n } out`\n }\n case \"control.agent.cell-call-started\":\n return `call ${Diagnosis.firstLine(Diagnosis.asString(payload.flowName) ?? \"?\")}`\n case \"control.agent.cell-call-settled\":\n return Diagnosis.asString(payload.outcome) === \"failure\"\n ? ` -> FAIL ${Diagnosis.clip(Diagnosis.firstLine(Diagnosis.asString(payload.message) ?? \"\"), 100)}`\n : \" -> ok\"\n case \"control.agent.resolved\":\n return `resolved ${Diagnosis.clip(Diagnosis.firstLine(Diagnosis.asString(payload.text) ?? \"\"), 100)}`\n case \"control.approval.requested\":\n return `approval requested: ${Diagnosis.firstLine(Diagnosis.asString(payload.question) ?? \"\")}`\n default:\n return kind.slice(\"control.\".length)\n }\n}\n\n/** Fold health from the same authoritative summary and committed event buffer as the run card.\n * Invalid observations and foreign incarnations cannot color the current owner.\n * @category projections\n * @since 1.0.0\n */\nexport const statusRollup = (\n run: ControlSchema.RunSummary,\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n now: number\n): Health.StatusRollup => {\n const incarnation = Health.runIncarnation(run)\n const candidates: Array<Health.RecordedObservation> = []\n const decode = Schema.decodeUnknownOption(Health.HealthObservation)\n let evidenceSeq = 0\n for (const event of events) {\n if (event.kind === Health.statusObservedEventType) {\n const reading = decode(event.payload)\n if (reading._tag === \"Some\") candidates.push({ observation: reading.value, sequence: event.sequence })\n } else if (!Monitor.isBookkeepingEvent(event.kind)) evidenceSeq = Math.max(evidenceSeq, event.sequence)\n }\n const latest = Health.latestObservation(candidates, `run:${run.runId}`, incarnation)\n return Health.rollup({\n subjectId: `run:${run.runId}`,\n state: run.status,\n incarnation,\n waitingReason: run.waitingReason,\n baseHealth: latest?.observation.baseHealth ??\n Monitor.classify({ summary: run, events, beatsWithoutProgress: 0, stallBeats: 3 }),\n latest,\n now,\n evidenceSeq,\n updatedAt: run.updatedAt\n })\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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;AAAA,IACvG,WAAW,CAAC,uBAAQ,mBAAmB,MAAM,IAAI,EAAG,eAAc,KAAK,IAAI,aAAa,MAAM,QAAQ;AAAA,EACxG;AACA,QAAM,SAAS,sBAAO,kBAAkB,YAAY,OAAO,IAAI,KAAK,IAAI,WAAW;AACnF,SAAO,sBAAO,OAAO;AAAA,IACnB,WAAW,OAAO,IAAI,KAAK;AAAA,IAC3B,OAAO,IAAI;AAAA,IACX;AAAA,IACA,eAAe,IAAI;AAAA,IACnB,YAAY,QAAQ,YAAY,cAC9B,uBAAQ,SAAS,EAAE,SAAS,KAAK,QAAQ,sBAAsB,GAAG,YAAY,EAAE,CAAC;AAAA,IACnF;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,IAAI;AAAA,EACjB,CAAC;AACH;",
|
|
4
|
+
"sourcesContent": ["/**\n * The stable wire rows the gateway serves for each projection, and the pure\n * folds that compute them from control-plane facts.\n *\n * These rows are the whole read contract. Nothing here exposes a store row, a\n * database column, or an engine type: every field is either a\n * `@smthrs/control` projection value or something folded out of the ordered\n * `ControlEvent` deltas `Control.watch` publishes. Wire names are the flows\n * names (`flowId`, `createdAt`, and the `ApprovalTarget.Node` envelope), so a\n * client written against the control plane reads these rows without a\n * translation table.\n *\n * @since 1.0.0\n */\n\nimport { ControlFacts, ControlSchema, Health, Monitor } from \"@smthrs/control\"\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport { ExecutionFact } from \"@smthrs/journal\"\nimport { Schema } from \"effect\"\nimport * as Diagnosis from \"./Diagnosis.ts\"\nimport { callScope, openCallIndex, uniqueCallEvents } from \"./internal/callEvents.ts\"\nimport * as NativeResolution from \"./internal/nativeResolution.ts\"\nimport * as NodeEvents from \"./internal/nodeEvents.ts\"\n\n/**\n * One run, everything a run card displays, and the diagnosis of what happened\n * to it.\n *\n * `flowId` carries what the old wire split across `run.workflowKey` and\n * `run.workflow`, and `createdAt` carries `run.createdAtMs`: one flows name\n * each, rather than two spellings of one fact.\n *\n * @since 1.0.0\n * @category models\n */\nexport const RunSummaryRow = Schema.Struct({\n runId: Schema.String,\n flowId: Schema.String,\n statusRollup: Schema.optional(Health.StatusRollup),\n status: ControlSchema.RunStatus,\n lifecycleProvenance: Schema.optional(ControlFacts.LifecycleProvenance),\n executionProvenance: Schema.optional(ExecutionFact.Provenance),\n createdAt: Schema.Number,\n updatedAt: Schema.Number,\n planId: Schema.optional(Schema.String),\n planDigest: Schema.optional(Schema.String),\n parentRunId: Schema.optional(Schema.String),\n lineageId: Schema.optional(Schema.String),\n roundOrdinal: Schema.optional(Schema.Number),\n waitingReason: Schema.optional(Schema.String),\n steeringPending: Schema.optional(Schema.Number),\n cancellation: Schema.optional(ControlSchema.Cancellation),\n /** When the run's approved deadline passes; absent for a run with none. */\n deadlineAt: Schema.optional(Schema.Number),\n /** The model seat the run's last opened turn ran on. */\n seat: Schema.optional(Schema.String),\n turns: Schema.Number,\n calls: Schema.Number,\n callsFailed: Schema.Number,\n editsAttempted: Schema.Number,\n editsSucceeded: Schema.Number,\n inputTokens: Schema.Number,\n outputTokens: Schema.Number,\n /**\n * One line: the run row's status plus the reason that most explains it.\n *\n * Lifecycle provenance distinguishes a covered control fact from a legacy\n * snapshot or a separate engine observation. Missing facts never silently\n * replace a newer observed state with the last recorded status.\n */\n verdict: Schema.String,\n /** The whole diagnosis card, which the old wire called `whatHappened`. */\n diagnosis: Schema.String,\n finalOutput: Schema.optional(Schema.String),\n /** The failed run's fault class and `<_tag>/<code>`, stamped when it failed. */\n failureFault: Schema.optional(Fault.Class),\n failureTag: Schema.optional(Schema.String)\n})\n\n/**\n * One run, everything a run card displays, and its diagnosis.\n *\n * @since 1.0.0\n * @category models\n */\nexport type RunSummaryRow = typeof RunSummaryRow.Type\n\n/**\n * One node of a run, as a tree view renders it.\n *\n * `label` carries what the old wire called `node.cardLabel`, and `seat`\n * carries `node.agent`: the model seat is the flows name for who ran a node.\n *\n * `nodeId` is the ordinal the call opened on, because the emitter names no\n * node. {@link runTree} says why.\n *\n * @since 1.0.0\n * @category models\n */\nexport const RunTreeRow = Schema.Struct({\n runId: Schema.String,\n nodeId: Schema.String,\n label: Schema.String,\n status: Schema.Literals([\"running\", \"completed\", \"failed\"]),\n seat: Schema.optional(Schema.String),\n startedAt: Schema.Number,\n endedAt: Schema.optional(Schema.Number),\n parentRunId: Schema.optional(Schema.String)\n})\n\n/**\n * One node of a run, as a tree view renders it.\n *\n * @since 1.0.0\n * @category models\n */\nexport type RunTreeRow = typeof RunTreeRow.Type\n\n/**\n * One approval a run is parked on, carrying the exact payload that decides it.\n *\n * `title` carries the old `approval.requestTitle` and `request` the old\n * `approval.request`; `payload` is the `ApprovalTarget.Node` envelope a client\n * submits back unchanged, so no client reconstructs authority.\n *\n * @since 1.0.0\n * @category models\n */\nexport const ApprovalRow = Schema.Struct({\n runId: Schema.String,\n /**\n * The execution holding the wait, when this gate is a question a person owes\n * an answer to and it is held below `runId`.\n *\n * `runId` is the run a person opened and the run a decision is addressed to;\n * a `HumanTask` in a nested flow parks its own execution, and the two are\n * different runs. Present only on such a gate, so a reader can tell a\n * question rolled up from a tree from one the named run raised itself, and\n * an inbox can list one question once however many ancestors carry it.\n */\n waitRunId: Schema.optional(Schema.String),\n questionProvenance: Schema.optional(Schema.Literals([\"events\", \"legacy-observation\", \"unverified-observation\"])),\n requestId: Schema.String,\n title: Schema.String,\n request: Schema.Json,\n payload: ControlSchema.ApprovalPayload,\n requestedAt: Schema.Number,\n status: Schema.Literals([\"pending\", \"approved\", \"denied\"])\n})\n\n/**\n * One approval a run is parked on.\n *\n * @since 1.0.0\n * @category models\n */\nexport type ApprovalRow = typeof ApprovalRow.Type\n\n/**\n * The output one node produced.\n *\n * @since 1.0.0\n * @category models\n */\nexport const NodeOutputRow = Schema.Struct({\n runId: Schema.String,\n nodeId: Schema.String,\n outcome: Schema.Literals([\"success\", \"failure\"]),\n output: Schema.String,\n settledAt: Schema.Number\n})\n\n/**\n * The output one node produced.\n *\n * @since 1.0.0\n * @category models\n */\nexport type NodeOutputRow = typeof NodeOutputRow.Type\n\n/**\n * How long one flow's nodes take, per action tag.\n *\n * `samples` is the number of measured executions behind the two percentiles,\n * and it is on the wire because a percentile over one sample and a percentile\n * over twenty are different claims. A tag with no measured execution has no\n * row at all: there is no shape here for an unmeasured prediction.\n *\n * @since 1.0.0\n * @category models\n */\nexport const FlowDurationRow = Schema.Struct({\n flowId: Schema.String,\n actionTag: Schema.String,\n samples: Schema.Number,\n p50Ms: Schema.Number,\n p90Ms: Schema.Number\n})\n\n/**\n * How long one flow's nodes take, per action tag.\n *\n * @since 1.0.0\n * @category models\n */\nexport type FlowDurationRow = typeof FlowDurationRow.Type\n\n/**\n * One measured execution of one node, as a duration fold's sample.\n *\n * The action tag is the only part of a node's key material that survives a\n * re-key, which is why history is grouped by it rather than by node id or by\n * dispatch key.\n *\n * @since 1.0.0\n * @category models\n */\nexport interface NodeDuration {\n readonly actionTag: string\n readonly durationMs: number\n}\n\n/**\n * One line of a run's turn-by-turn transcript.\n *\n * @since 1.0.0\n * @category models\n */\nexport const TranscriptRow = Schema.Struct({\n runId: Schema.String,\n sequence: Schema.Number,\n turn: Schema.Number,\n at: Schema.Number,\n kind: Schema.String,\n /** Dispatch identity on current call records; absent on legacy history. */\n callId: Schema.optional(Schema.String),\n text: Schema.String\n})\n\n/**\n * One line of a run's turn-by-turn transcript.\n *\n * @since 1.0.0\n * @category models\n */\nexport type TranscriptRow = typeof TranscriptRow.Type\n\n/** Copies only the optional fields a run summary actually carries. */\nconst optional = <A>(key: string, value: A | undefined): Record<string, A> =>\n value === undefined ? {} : { [key]: value }\n\n/**\n * Folds one run's summary and events into the served `run-summary` row.\n *\n * @param run the control-plane run summary\n * @param events that run's ordered control events\n * @param now the instant the row is rendered at\n * @param carry the digest of the events a bounded reader dropped before them\n * @since 1.0.0\n * @category projections\n */\nexport const runSummary = (\n run: ControlSchema.RunSummary,\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n now: number = Math.max(run.updatedAt, events.at(-1)?.occurredAt ?? 0),\n carry?: Diagnosis.Digest | undefined\n): RunSummaryRow => {\n const projected = ControlFacts.fold(events, run)\n // Supplying a snapshot guarantees a run: uncovered facts retain that\n // observation; only the event-only fold can return an absent run.\n run = projected.run!\n const native = ExecutionFact.foldControl(events, run.runId, run.executionView)\n // The control fold remains control authority. Native lifecycle is independently\n // replayed/verified against the coherent executor observation when available.\n if (run.executionObservation === \"observed\" && native?.view !== undefined) {\n const { root, current } = native.view\n run = {\n ...run,\n status: current.status === \"pending\" ? \"accepted\" : current.status === \"suspended\"\n ? current.waiting?.reason === \"approval\" ||\n (native.view.humanWaits?.length ?? run.pendingWaits?.length ?? 0) > 0\n ? \"waiting-approval\" :\n \"parked\"\n : current.status === \"running\" && (native.view.humanWaits?.length ?? run.pendingWaits?.length ?? 0) > 0\n ? \"waiting-approval\" :\n current.status,\n waitingReason: current.status === \"suspended\" ? current.waiting?.reason : undefined,\n parentRunId: root.parentRunId ?? undefined,\n lineageId: root.lineageId,\n roundOrdinal: root.roundOrdinal\n }\n }\n // `carry` is the digest of the events a bounded reader dropped ahead of\n // `events`. Combining it keeps turns, calls, edits and tokens exact for a run\n // whose journal no longer fits one window, so the counters a run card shows\n // describe the whole run and not just its tail.\n const window = Diagnosis.digest(events, run.runId)\n const facts = { ...(carry === undefined ? window : Diagnosis.combine(carry, window)), status: run.status }\n return {\n runId: run.runId,\n flowId: run.flowId,\n status: run.status,\n lifecycleProvenance: projected.provenance,\n ...optional(\"executionProvenance\", native?.provenance),\n statusRollup: statusRollup(run, events, now),\n createdAt: run.createdAt,\n updatedAt: run.updatedAt,\n ...optional(\"planId\", run.planId),\n ...optional(\"planDigest\", run.planDigest),\n ...optional(\"parentRunId\", run.parentRunId),\n ...optional(\"lineageId\", run.lineageId),\n ...optional(\"roundOrdinal\", run.roundOrdinal),\n ...optional(\"waitingReason\", run.waitingReason),\n ...optional(\"steeringPending\", run.steering?.pending),\n ...optional(\"cancellation\", run.cancellation),\n ...optional(\"deadlineAt\", run.deadlineAt),\n ...optional(\"seat\", facts.seat),\n turns: facts.turns,\n calls: facts.calls,\n callsFailed: facts.callsFailed,\n editsAttempted: facts.editsAttempted,\n editsSucceeded: facts.editsSucceeded,\n inputTokens: facts.inputTokens,\n outputTokens: facts.outputTokens,\n verdict: Diagnosis.verdict(facts),\n diagnosis: Diagnosis.render({ runId: run.runId, ...optional(\"flowId\", run.flowId) }, facts),\n ...optional(\n \"finalOutput\",\n Diagnosis.resolvedOutput(facts) ?? (\n run.status === \"failed\" && facts.fault?.tag.endsWith(\"/source_refused\") &&\n facts.cause?.match(/source_refused: ([a-z_]+)/)\n ? JSON.stringify({ message: facts.cause.match(/source_refused: ([a-z_]+)/)![0] })\n : undefined\n )\n ),\n ...(run.status === \"failed\" ? optional(\"failureFault\", facts.fault?.class) : {}),\n ...(run.status === \"failed\" ? optional(\"failureTag\", facts.fault?.tag) : {})\n }\n}\n\n/**\n * Claims a call by its durable dispatch identity. Legacy history has no id:\n * match only legacy starts by flow name (or FIFO when unnamed). A new\n * settlement can close a legacy start after an old parked run resumes, but\n * neither fallback may steal an identified call.\n */\nconst takeOpenCall = <\n A extends { readonly flowName: string; readonly callId: string | undefined; readonly scope: string | undefined }\n>(\n open: Array<A>,\n callId: string | undefined,\n flowName: string | undefined,\n scope: string | undefined\n): A | undefined => {\n const found = openCallIndex(open, callId, flowName, scope)\n return found < 0 ? undefined : open.splice(found, 1)[0]\n}\n\n/**\n * One agent call, as every node projection sees it: the ordinal it opened on,\n * the seat that ran it, and the settlement that closed it, if one did.\n */\ninterface CallRecord {\n readonly nodeId: string\n readonly flowName: string\n readonly seat: string | undefined\n readonly startedAt: number\n readonly settlement: CallSettlement | undefined\n}\n\n/** What closed a call, and where among the run's settlements it closed. */\ninterface CallSettlement {\n /** The rank of this settlement among the run's, counting from one. */\n readonly order: number\n /** The run the settlement named, which a malformed journal can omit. */\n readonly runId: string | undefined\n readonly at: number\n readonly outcome: \"success\" | \"failure\"\n readonly output: string\n}\n\n/**\n * Folds one run's events into the agent calls it made, in the order they\n * opened.\n *\n * This is the only fold that assigns a call its `call-N` identity, records the\n * seat and time it opened on, and pairs a settlement with the call it closed.\n * A client asks for a node's output by the id a tree row carries, so the two\n * projections have to agree on that id; when they counted separately they\n * could disagree, and once did, because skipping an event before the ordinal\n * advanced shifted one fold's keys against the other's. The ordinal therefore\n * advances on every distinct start, whatever else that event is missing.\n * Identified duplicate starts and settlements are ignored. Old idless rows\n * retain their original ordinal/FIFO interpretation; their missing dispatch\n * identity cannot be reconstructed when same-name calls overlapped.\n *\n * `uniqueCallEvents` also normalizes native step facts, so this fold reads the\n * run's own records and one stream per step a module run dispatched. The three\n * classes `Diagnosis` names apply here too, field by field:\n *\n * | Field | Class | Why |\n * | ----------------------- | --------------- | ------------------------------------------------------ |\n * | `nodeId` (`call-N`) | aggregate | one tree lists every call the run made, steps included |\n * | `flowName`, `startedAt` | aggregate | read off the call's own record |\n * | `settlement` | aggregate | claimed by call identity within the recorded scope |\n * | `seat` | scope dependent | who ran THIS call, so the turn must be this call's own |\n *\n * There is no root-only field here: a tree row describes a call, never the\n * run's answer or state. A new field has to name its class.\n */\nconst callHistory = (\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<CallRecord> => {\n const calls = new Map<string, CallRecord>()\n const open: Array<\n {\n readonly callId: string | undefined\n readonly flowName: string\n readonly call: CallRecord\n readonly scope: string | undefined\n }\n > = []\n // The seat of the last turn opened in each scope. A module run interleaves\n // steps in one journal, so the run-wide reading attributed one step's seat\n // to another step's calls. A prompt run records one unscoped stream and\n // reads exactly as it did.\n const seats = new Map<string | undefined, string | undefined>()\n let ordinal = 0\n let settlements = 0\n\n for (const event of uniqueCallEvents(events)) {\n const payload = Diagnosis.asRecord(event.payload)\n if (event.kind === \"control.agent.turn-opened\") {\n const scope = callScope(event)\n seats.set(scope, Diagnosis.asString(payload.seat) ?? seats.get(scope))\n continue\n }\n if (event.kind === \"control.agent.cell-call-started\") {\n const callId = Diagnosis.asString(payload.callId)\n ordinal += 1\n const nodeId = `call-${ordinal}`\n const flowName = Diagnosis.asString(payload.flowName) ?? nodeId\n const scope = callScope(event)\n // This scope's own turn, else the run's. A step that opened no turn of\n // its own borrows nothing from a sibling step.\n const seat = seats.get(scope) ?? seats.get(undefined)\n const call: CallRecord = { nodeId, flowName, seat, startedAt: Diagnosis.timeOf(event), settlement: undefined }\n open.push({ callId, flowName, call, scope })\n calls.set(nodeId, call)\n continue\n }\n if (event.kind !== \"control.agent.cell-call-settled\") continue\n const callId = Diagnosis.asString(payload.callId)\n const claimed = takeOpenCall(open, callId, Diagnosis.asString(payload.flowName), callScope(event))\n if (claimed === undefined) continue\n const failed = Diagnosis.asString(payload.outcome) === \"failure\"\n settlements += 1\n // Rewriting the entry keeps the call in the position it opened on, which\n // is the order a tree renders.\n calls.set(claimed.call.nodeId, {\n ...claimed.call,\n settlement: {\n order: settlements,\n runId: Diagnosis.asString(payload.runId) ?? event.runId,\n at: Diagnosis.timeOf(event),\n outcome: failed ? \"failure\" : \"success\",\n output: failed\n ? Diagnosis.asString(payload.message) ?? \"\"\n : Diagnosis.asString(payload.value) ?? JSON.stringify(payload.value ?? null)\n }\n })\n }\n return [...calls.values()]\n}\n\n/** How a tree row reports a call: settled the way it settled, or still running. */\nconst treeStatus = (settlement: CallSettlement | undefined): RunTreeRow[\"status\"] => {\n if (settlement === undefined) return \"running\"\n return settlement.outcome === \"failure\" ? \"failed\" : \"completed\"\n}\n\n/**\n * Folds one run's events into its node rows.\n *\n * A node opens on `control.agent.cell-call-started` and settles on the\n * matching `control.agent.cell-call-settled`.\n *\n * AgentSession journals the same `callId` from the harness's dispatch identity\n * on both records. Settlements join on it even when same-name calls overlap\n * and finish out of order. The distinct-start ordinal remains the published\n * `call-N` node key, preserving existing node links. Legacy records without\n * callId retain same-name FIFO pairing, restricted to other legacy records\n * (including a newly identified settlement of an old parked call).\n *\n * The durable engine's own `flows.engine.*` records are not folded here, but\n * that is a choice rather than a limit. A host keeps the control plane and the\n * engine in two databases with two journals (`@smthrs/cli`\n * `NodeControl.databasePath` and `executionDatabasePath`), and\n * `EngineJournalProjection` copies every engine entry of the run into the\n * control journal as a `control.engine.event` envelope, which is how\n * {@link nodeDurations} reads the node records. A tree row is an agent cell\n * call, so what an engine step did reaches this projection as the call that\n * made it.\n *\n * A node that never settled stays `running`, which is how a live tree renders\n * work in flight.\n *\n * @param run the control-plane run summary\n * @param events that run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const runTree = (\n run: ControlSchema.RunSummary,\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<RunTreeRow> =>\n callHistory(events).map((call): RunTreeRow => ({\n runId: run.runId,\n nodeId: call.nodeId,\n label: call.flowName,\n status: treeStatus(call.settlement),\n ...optional(\"seat\", call.seat),\n startedAt: call.startedAt,\n ...optional(\"endedAt\", call.settlement?.at),\n ...optional(\"parentRunId\", run.parentRunId)\n }))\n\n/**\n * The declared question of a human wait, as far as it can be read.\n *\n * `request` is whatever the wait wrote about itself, which for `HumanTask` is\n * `{task, name, kind, prompt, attempt, maxAttempts}`. A wait that declared\n * nothing \u2014 an older park, or a plugin's own \u2014 still produces a row, because a\n * gate a person cannot see is a run that waits forever; it just has less to\n * render.\n */\nconst questionOf = (wait: ControlSchema.PendingWait): Record<string, unknown> => Diagnosis.asRecord(wait.request)\n\n/**\n * One pending row for a human wait held anywhere in a run's tree.\n *\n * `runId` is the ROOT: this is the run a person opened, and the run a decision\n * is addressed to. `waitRunId` is the execution actually holding it, because a\n * client routes by run and the control plane routes within the tree.\n *\n * `requestId` is the wait point's own name (`coding-clarification#1`), which is\n * unique within a tree, stable across a re-read, and the name a `Signal`\n * addresses. The token travels in the request too, for a client that would\n * rather submit the exact durable address back.\n */\nconst humanWaitRow = (\n run: ControlSchema.RunSummary,\n wait: ControlSchema.PendingWait,\n projected?: ExecutionFact.Observation,\n questionProvenance: \"events\" | \"legacy-observation\" | \"unverified-observation\" = \"legacy-observation\"\n): ApprovalRow => {\n const question = projected === undefined ? questionOf(wait) : Diagnosis.asRecord(projected.waiting?.request)\n const name = wait.name ?? Diagnosis.asString(question[\"name\"]) ?? wait.token\n const requestId = wait.attempt === undefined ? name : `${name}#${wait.attempt}`\n const prompt = Diagnosis.asString(question[\"prompt\"])\n const waitFlowId = projected?.flowName ?? wait.flowId\n return {\n runId: run.runId,\n waitRunId: wait.runId,\n questionProvenance,\n requestId,\n title: prompt ?? `Answer needed \u2014 ${name}`,\n request: {\n ...question,\n kind: Diagnosis.asString(question[\"kind\"]) ?? \"ask\",\n name,\n ...(wait.attempt === undefined ? {} : { attempt: wait.attempt }),\n ...(waitFlowId === undefined ? {} : { waitFlowId }),\n token: wait.token\n },\n payload: {\n target: {\n _tag: \"Node\",\n runId: run.runId,\n requestId,\n digest: wait.token,\n // A human answer grants no capabilities: the envelope a decision binds\n // to is the empty one, the same shape a flow with none carries.\n envelope: { capabilities: [], flows: [], budget: {} }\n },\n scope: \"once\",\n // The identity is the PARK, not its name: a loop that re-asks one\n // question parks again under the same run, name and attempt, and a\n // name-keyed answer would deduplicate the second decision into the\n // first \u2014 accepted, never delivered, and parked forever.\n idempotencyKey: `answer:${run.runId}:${requestId}:${wait.tokenDigest ?? wait.token}`\n },\n requestedAt: projected?.createdAtMs ?? wait.createdAt,\n status: \"pending\"\n }\n}\n\n/**\n * Folds one run's events into its approval rows.\n *\n * A request opens a pending row carrying the submit-ready payload; the\n * matching `control.approval.approved` or `control.approval.denied` closes it\n * without discarding the request, so a decided gate stays readable.\n *\n * A `HumanTask` declares its question on the parked row. Native execution\n * facts carry the redacted question and token digest; verified facts supply\n * its display metadata here. `@smthrs/control` rolls current open waits onto\n * the root as `pendingWaits`, which supply each row's protected wake address.\n * History alone cannot create an answerable human wait. Older observations\n * remain visible with explicit question provenance when native fact coverage\n * is unavailable. These rows come first because they still need an answer.\n *\n * A decision names the gate it closed by `tokenId`. `@smthrs/control`\n * `SqlControlRuntime.lookupApproval` mints that token id from the target, and\n * for the `Node` target a run parks on it is the request id itself, so the two\n * records join on one field. A decision whose `tokenId` or `requestId` names\n * no row is retained for an exact later request. Only a legacy decision that\n * names neither field closes the oldest pending legacy row in that run.\n * Current facts bind the target digest; duplicates cannot reopen a decision.\n *\n * @param events the run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const approvals = (\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n run?: ControlSchema.RunSummary | undefined\n): ReadonlyArray<ApprovalRow> => {\n const native = run === undefined ? undefined : ExecutionFact.foldControl(events, run.runId, run.executionView)\n const grantFacts = events.filter((event) =>\n event.kind === \"control.approval.requested\" && Schema.is(ControlFacts.ApprovalRequestFact)(event.payload)\n )\n const grants = ControlFacts.fold(grantFacts).approvals\n const observed = run?.pendingWaits?.map((wait) => {\n // An agent ask parks on its registered grant token, not a HumanTask answer.\n // Preserve the committed target instead of inventing an answer-only target.\n const grant = grants.find((row) => row.runId === run.runId && row.requestId === wait.token)\n if (grant !== undefined) return grant\n const projected = native?.provenance.humanWaits === \"events\" ?\n native.view?.humanWaits?.find((candidate) =>\n candidate.executionId === wait.runId && candidate.waiting?.tokenDigest === wait.tokenDigest\n ) :\n undefined\n return humanWaitRow(\n run,\n wait,\n projected,\n projected === undefined\n ? native?.provenance.humanWaits === \"events\" ?\n \"unverified-observation\" :\n native?.provenance.humanWaits ?? \"legacy-observation\"\n : \"events\"\n )\n })\n // The current observation supplies wake authority. History supplies only the\n // display metadata that verifies against that exact observed token digest.\n return ControlFacts.fold(events, undefined, observed).approvals\n}\n\n/**\n * Folds one run's events into its node outputs, keyed the way {@link runTree}\n * keys its rows: by the ordinal the call opened on.\n *\n * A settled call carries the value it produced, so the row carries that value.\n * A run's own result reaches a client as `RunSummaryRow.finalOutput` instead.\n *\n * @param events the run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const nodeOutput = (\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<NodeOutputRow> => {\n const settled: Array<{ readonly order: number; readonly row: NodeOutputRow }> = []\n for (const call of callHistory(events)) {\n const settlement = call.settlement\n if (settlement === undefined) continue\n // A row names the run it belongs to. A settlement that names none closes\n // its call without producing one.\n if (settlement.runId === undefined) continue\n settled.push({\n order: settlement.order,\n row: {\n runId: settlement.runId,\n nodeId: call.nodeId,\n outcome: settlement.outcome,\n output: settlement.output,\n settledAt: settlement.at\n }\n })\n }\n // A tree reads in the order calls opened; outputs read in the order they\n // settled, which is the order a client watched them arrive.\n return settled.sort((left, right) => left.order - right.order).map((entry) => entry.row)\n}\n\n/** The node id every execution gives the flow it was started to run. */\nconst rootNodeId = \"root\"\n\n/**\n * The native execution the host bound this control run to, when one is known.\n *\n * Only the host's own binding record names the root, and two records that\n * disagree name nothing: an ambiguous binding cannot tell a callee's\n * execution apart from the root's, so it authorizes no skip.\n *\n * The binding is written once, when the host takes the root up, so a window\n * bounded to a run's newest events is the one window it falls out of. The\n * carried digest keeps it across that eviction, and reading from the carry is\n * what keeps a long run's calls counted the same as a short run's.\n */\nconst boundExecution = (\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n carry: Diagnosis.Digest | undefined\n): string | undefined => {\n let resolution = carry?.nativeResolution\n for (const event of events) resolution = NativeResolution.combine(resolution, NativeResolution.fromEvent(event))\n return resolution === undefined || resolution.conflict === true ? undefined : resolution.binding?.executionId\n}\n\n/**\n * A callee's own view of a call its caller already measured.\n *\n * Every execution below the bound root was started by a `FlowCall` node in\n * the execution above it, and that node carries the same action tag over the\n * same span. The caller's node is the one kept, because it is the node a plan\n * carries and the one a graph can join a prediction onto.\n *\n * With no binding nothing is echoed: a fold that cannot name the root cannot\n * tell which `root` record belongs to it, and dropping samples on a guess\n * would answer a smaller history than the flow ran.\n */\nconst echoedRoot = (bound: string | undefined, executionId: string, nodeId: string): boolean =>\n bound !== undefined && nodeId === rootNodeId && executionId !== bound\n\n/**\n * Folds one run's events into the executions it measured.\n *\n * A node's work starts when the engine recorded it scheduled and ends when it\n * recorded it settled, so a duration is the distance between those two native\n * stamps. Four of the five outcomes contribute nothing: `clean` was served\n * from records rather than run, `failed` measures a collapse, `skipped` was\n * never reached, and `deferred` is scheduling debt. Only `built` ran.\n *\n * A settlement pairs with the LAST schedule of the same execution and node,\n * which is what makes a retried node measure its final attempt rather than\n * the span across every attempt. Two executions of one node id stay apart\n * because the pairing key carries the execution, and a settlement no schedule\n * opened measures nothing rather than measuring from zero.\n *\n * A record that names no action tag contributes nothing either: history is\n * grouped by tag, and a sample with no tag has nowhere honest to go.\n *\n * A called flow is measured once. The engine records one call twice: the\n * caller admits and settles the node that made it, and the callee's own\n * execution admits and settles its `root` over the same span with the same\n * action tag. {@link echoedRoot} drops the callee's copy, so one invocation\n * is one sample rather than two, and `samples` stays the count of executions\n * the flow performed.\n *\n * @param events the run's ordered control events\n * @param carry the digest of the events a bounded window dropped, when it dropped any\n * @since 1.0.0\n * @category projections\n */\nexport const nodeDurations = (\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n carry?: Diagnosis.Digest | undefined\n): ReadonlyArray<NodeDuration> => {\n const bound = boundExecution(events, carry)\n const started = new Map<string, number>()\n const measured: Array<NodeDuration> = []\n for (const event of events) {\n const schedule = NodeEvents.nodeScheduled(event)\n if (schedule !== undefined) {\n if (echoedRoot(bound, schedule.executionId, schedule.payload.nodeId)) continue\n started.set(`${schedule.executionId}\\u0000${schedule.payload.nodeId}`, schedule.emittedAtMs)\n continue\n }\n const settlement = NodeEvents.nodeSettled(event)\n if (settlement === undefined) continue\n if (echoedRoot(bound, settlement.executionId, settlement.payload.nodeId)) continue\n if (settlement.payload.outcome !== \"built\") continue\n const actionTag = settlement.payload.action\n if (actionTag === undefined) continue\n const key = `${settlement.executionId}\\u0000${settlement.payload.nodeId}`\n const startedAt = started.get(key)\n if (startedAt === undefined) continue\n started.delete(key)\n const durationMs = settlement.emittedAtMs - startedAt\n // Wall clocks can move backwards, and a completion that predates its own\n // start is a clock fact rather than a duration.\n if (durationMs < 0) continue\n measured.push({ actionTag, durationMs })\n }\n return measured\n}\n\n/** The nearest-rank percentile of an ascending sample, which is one observed value. */\nconst nearestRank = (ascending: ReadonlyArray<number>, percentile: number): number =>\n ascending[Math.ceil((percentile / 100) * ascending.length) - 1]!\n\n/**\n * Folds every measured execution of one flow into one row per action tag.\n *\n * Both percentiles are nearest-rank, so each answer is a duration the flow\n * really took rather than an interpolation between two it did not. Rows are\n * ordered by tag, so two reads of the same history answer in the same order.\n *\n * A tag reaches this function only by having been measured, so every row\n * carries at least one sample, and a flow nothing has measured answers with\n * no rows at all.\n *\n * @param flowId the flow whose history was read\n * @param samples every measured execution of that flow's runs\n * @since 1.0.0\n * @category projections\n */\nexport const flowDurations = (\n flowId: string,\n samples: ReadonlyArray<NodeDuration>\n): ReadonlyArray<FlowDurationRow> => {\n const byTag = new Map<string, Array<number>>()\n for (const sample of samples) {\n const held = byTag.get(sample.actionTag)\n if (held === undefined) byTag.set(sample.actionTag, [sample.durationMs])\n else held.push(sample.durationMs)\n }\n return [...byTag.entries()]\n .sort(([left], [right]) => left < right ? -1 : 1)\n .map(([actionTag, observed]) => {\n const ascending = [...observed].sort((left, right) => left - right)\n return {\n flowId,\n actionTag,\n samples: ascending.length,\n p50Ms: nearestRank(ascending, 50),\n p90Ms: nearestRank(ascending, 90)\n }\n })\n}\n\n/** Events the transcript reports verbatim rather than as agent activity. */\nconst transcriptKinds: ReadonlySet<string> = new Set([\"control.approval.requested\"])\n\n/**\n * Folds one run's events into a turn-numbered transcript.\n *\n * A row is reported for every `control.run.*` and `control.agent.*` event and\n * for an approval request, and for nothing else: the transcript is what a\n * reader follows, not the whole journal, which `run-events` already serves.\n * The turn counter advances on `control.agent.turn-opened`, so every row\n * carries the turn it belongs to, and each row's text is one display line, so\n * a multi-line seat, message, or question cannot split one row into several.\n *\n * `uniqueCallEvents` normalizes native step facts, so a module run's steps\n * report here too. The classes `Diagnosis` names apply, field by field:\n *\n * | Field | Class | Why |\n * | ------ | --------- | --------------------------------------------------------- |\n * | rows | aggregate | every row is one event this run recorded, wherever it ran |\n * | `turn` | aggregate | a turn a step opened is a turn this run opened |\n *\n * No row is root only, because no row claims to be the run's answer or state:\n * a `control.agent.resolved` row says one agent resolved, and the run's own\n * answer is served by `runSummary` from `Diagnosis`. A new field has to name\n * its class.\n *\n * @param events the run's ordered control events\n * @since 1.0.0\n * @category projections\n */\nexport const transcript = (\n events: ReadonlyArray<ControlSchema.ControlEvent>\n): ReadonlyArray<TranscriptRow> => {\n const rows: Array<TranscriptRow> = []\n let turn = 0\n for (const event of uniqueCallEvents(events)) {\n const payload = Diagnosis.asRecord(event.payload)\n const runId = Diagnosis.asString(payload.runId) ?? event.runId\n if (runId === undefined) continue\n const reported = event.kind.startsWith(\"control.run.\") ||\n event.kind.startsWith(\"control.agent.\") ||\n transcriptKinds.has(event.kind)\n if (!reported) continue\n if (event.kind === \"control.agent.turn-opened\") turn += 1\n rows.push({\n runId,\n sequence: event.sequence,\n turn,\n at: Diagnosis.timeOf(event),\n kind: event.kind,\n ...optional(\"callId\", Diagnosis.asString(payload.callId)),\n text: line(event.kind, payload)\n })\n }\n return rows\n}\n\n/** One event as a single transcript line. */\nconst line = (kind: string, payload: Record<string, unknown>): string => {\n switch (kind) {\n case \"control.agent.turn-opened\":\n return `turn opened \u00B7 ${Diagnosis.firstLine(Diagnosis.asString(payload.seat) ?? \"\")}`\n case \"control.agent.model-settled\": {\n const usage = Diagnosis.asRecord(payload.usage)\n return `model ${Diagnosis.asNumber(usage.inputTokens) ?? 0} in / ${\n Diagnosis.asNumber(usage.outputTokens) ?? 0\n } out`\n }\n case \"control.agent.cell-call-started\":\n return `call ${Diagnosis.firstLine(Diagnosis.asString(payload.flowName) ?? \"?\")}`\n case \"control.agent.cell-call-settled\":\n return Diagnosis.asString(payload.outcome) === \"failure\"\n ? ` -> FAIL ${Diagnosis.clip(Diagnosis.firstLine(Diagnosis.asString(payload.message) ?? \"\"), 100)}`\n : \" -> ok\"\n case \"control.agent.resolved\":\n return `resolved ${Diagnosis.clip(Diagnosis.firstLine(Diagnosis.asString(payload.text) ?? \"\"), 100)}`\n case \"control.approval.requested\":\n return `approval requested: ${Diagnosis.firstLine(Diagnosis.asString(payload.question) ?? \"\")}`\n default:\n return kind.slice(\"control.\".length)\n }\n}\n\n/** Fold health from the same authoritative summary and committed event buffer as the run card.\n * Invalid observations and foreign incarnations cannot color the current owner.\n * @category projections\n * @since 1.0.0\n */\nexport const statusRollup = (\n run: ControlSchema.RunSummary,\n events: ReadonlyArray<ControlSchema.ControlEvent>,\n now: number\n): Health.StatusRollup => {\n const incarnation = Health.runIncarnation(run)\n const candidates: Array<Health.RecordedObservation> = []\n const decode = Schema.decodeUnknownOption(Health.HealthObservation)\n let evidenceSeq = 0\n for (const event of events) {\n if (event.kind === Health.statusObservedEventType) {\n const reading = decode(event.payload)\n if (reading._tag === \"Some\") candidates.push({ observation: reading.value, sequence: event.sequence })\n } else if (!Monitor.isBookkeepingEvent(event.kind)) evidenceSeq = Math.max(evidenceSeq, event.sequence)\n }\n const latest = Health.latestObservation(candidates, `run:${run.runId}`, incarnation)\n return Health.rollup({\n subjectId: `run:${run.runId}`,\n state: run.status,\n incarnation,\n waitingReason: run.waitingReason,\n baseHealth: latest?.observation.baseHealth ??\n Monitor.classify({ summary: run, events, beatsWithoutProgress: 0, stallBeats: 3 }),\n latest,\n now,\n evidenceSeq,\n updatedAt: run.updatedAt\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,qBAA6D;AAC7D,YAAuB;AACvB,qBAA8B;AAC9B,oBAAuB;AACvB,gBAA2B;AAC3B,wBAA2D;AAC3D,uBAAkC;AAClC,iBAA4B;AAarB,MAAM,gBAAgB,qBAAO,OAAO;AAAA,EACzC,OAAO,qBAAO;AAAA,EACd,QAAQ,qBAAO;AAAA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W,KAAK,EAAE,aAAa,QAAQ,OAAO,UAAU,MAAM,SAAS,CAAC;AAAA,IACvG,WAAW,CAAC,uBAAQ,mBAAmB,MAAM,IAAI,EAAG,eAAc,KAAK,IAAI,aAAa,MAAM,QAAQ;AAAA,EACxG;AACA,QAAM,SAAS,sBAAO,kBAAkB,YAAY,OAAO,IAAI,KAAK,IAAI,WAAW;AACnF,SAAO,sBAAO,OAAO;AAAA,IACnB,WAAW,OAAO,IAAI,KAAK;AAAA,IAC3B,OAAO,IAAI;AAAA,IACX;AAAA,IACA,eAAe,IAAI;AAAA,IACnB,YAAY,QAAQ,YAAY,cAC9B,uBAAQ,SAAS,EAAE,SAAS,KAAK,QAAQ,sBAAsB,GAAG,YAAY,EAAE,CAAC;AAAA,IACnF;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,IAAI;AAAA,EACjB,CAAC;AACH;",
|
|
6
6
|
"names": ["callId"]
|
|
7
7
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-only adapter of the existing branch protocol and lease roster.
|
|
3
|
+
* The Go authorizer resolves branch, actor and socket session before forwarding.
|
|
4
|
+
* The runtime bearer is required on every RPC; participant IDs confer no rights.
|
|
5
|
+
*
|
|
6
|
+
* @since 1.0.0
|
|
7
|
+
*/
|
|
1
8
|
import { SyncError } from "@smthrs/sync/SyncError";
|
|
2
9
|
import { Layer } from "effect";
|
|
3
10
|
import { RpcServer } from "effect/unstable/rpc";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HostBranchPresence.d.ts","sourceRoot":"","sources":["../../src/HostBranchPresence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HostBranchPresence.d.ts","sourceRoot":"","sources":["../../src/HostBranchPresence.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,OAAO,EAAU,KAAK,EAAoB,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,uKAmD/B,CAAA"}
|