Add Epiphany runtime job bindings

This commit is contained in:
Meta Vens 2026-04-26 12:31:28 +01:00
commit 2c067eca30
35 changed files with 1822 additions and 56 deletions

View file

@ -1159,6 +1159,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -3849,6 +3911,15 @@
}
]
},
"jobBindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": [
"array",
"null"
]
},
"mode": {
"anyOf": [
{

View file

@ -1419,6 +1419,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1703,6 +1765,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",
@ -3799,6 +3867,7 @@
"graphCheckpoint",
"scratch",
"investigationCheckpoint",
"jobBindings",
"observations",
"evidence",
"churn",

View file

@ -8268,6 +8268,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/v2/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -8552,6 +8614,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/v2/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",
@ -15146,6 +15214,12 @@
},
"ThreadEpiphanyJob": {
"properties": {
"activeThreadIds": {
"items": {
"type": "string"
},
"type": "array"
},
"blockingReason": {
"type": [
"string",
@ -15202,6 +15276,12 @@
"null"
]
},
"runtimeAgentJobId": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
},
@ -15231,7 +15311,11 @@
"enum": [
"idle",
"needed",
"pending",
"running",
"completed",
"failed",
"cancelled",
"blocked",
"unavailable"
],
@ -16125,6 +16209,7 @@
"graphCheckpoint",
"scratch",
"investigationCheckpoint",
"jobBindings",
"observations",
"evidence",
"churn",
@ -16246,6 +16331,15 @@
}
]
},
"jobBindings": {
"items": {
"$ref": "#/definitions/v2/EpiphanyJobBinding"
},
"type": [
"array",
"null"
]
},
"mode": {
"anyOf": [
{

View file

@ -4828,6 +4828,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -5112,6 +5174,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",
@ -13033,6 +13101,12 @@
},
"ThreadEpiphanyJob": {
"properties": {
"activeThreadIds": {
"items": {
"type": "string"
},
"type": "array"
},
"blockingReason": {
"type": [
"string",
@ -13089,6 +13163,12 @@
"null"
]
},
"runtimeAgentJobId": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
},
@ -13118,7 +13198,11 @@
"enum": [
"idle",
"needed",
"pending",
"running",
"completed",
"failed",
"cancelled",
"blocked",
"unavailable"
],
@ -14012,6 +14096,7 @@
"graphCheckpoint",
"scratch",
"investigationCheckpoint",
"jobBindings",
"observations",
"evidence",
"churn",
@ -14133,6 +14218,15 @@
}
]
},
"jobBindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": [
"array",
"null"
]
},
"mode": {
"anyOf": [
{

View file

@ -418,6 +418,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -702,6 +764,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",
@ -792,6 +860,7 @@
"graphCheckpoint",
"scratch",
"investigationCheckpoint",
"jobBindings",
"observations",
"evidence",
"churn",

View file

@ -866,6 +866,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1150,6 +1212,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -807,6 +807,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1091,6 +1153,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -807,6 +807,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1091,6 +1153,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -807,6 +807,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1091,6 +1153,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -866,6 +866,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1150,6 +1212,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -807,6 +807,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1091,6 +1153,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -866,6 +866,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1150,6 +1212,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -807,6 +807,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1091,6 +1153,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -807,6 +807,68 @@
],
"type": "string"
},
"EpiphanyJobBinding": {
"properties": {
"blocking_reason": {
"type": [
"string",
"null"
]
},
"id": {
"type": "string"
},
"kind": {
"$ref": "#/definitions/EpiphanyJobKind"
},
"linked_graph_node_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"linked_subgoal_ids": {
"items": {
"type": "string"
},
"type": "array"
},
"owner_role": {
"type": "string"
},
"progress_note": {
"type": [
"string",
"null"
]
},
"runtime_agent_job_id": {
"type": [
"string",
"null"
]
},
"scope": {
"type": "string"
}
},
"required": [
"id",
"kind",
"owner_role",
"scope"
],
"type": "object"
},
"EpiphanyJobKind": {
"enum": [
"indexing",
"remap",
"verification",
"specialist"
],
"type": "string"
},
"EpiphanyModeState": {
"properties": {
"kind": {
@ -1091,6 +1153,12 @@
}
]
},
"job_bindings": {
"items": {
"$ref": "#/definitions/EpiphanyJobBinding"
},
"type": "array"
},
"last_updated_turn_id": {
"type": [
"string",

View file

@ -0,0 +1,6 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EpiphanyJobKind } from "./EpiphanyJobKind";
export type EpiphanyJobBinding = { id: string, kind: EpiphanyJobKind, scope: string, owner_role: string, runtime_agent_job_id?: string | null, linked_subgoal_ids?: Array<string>, linked_graph_node_ids?: Array<string>, progress_note?: string | null, blocking_reason?: string | null, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type EpiphanyJobKind = "indexing" | "remap" | "verification" | "specialist";

View file

@ -2,4 +2,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type EpiphanyThreadState = { revision: bigint, objective?: string | null, active_subgoal_id?: string | null, subgoals?: Array<EpiphanySubgoal>, invariants?: Array<EpiphanyInvariant>, graphs?: EpiphanyGraphs, graph_frontier?: EpiphanyGraphFrontier | null, graph_checkpoint?: EpiphanyGraphCheckpoint | null, retrieval?: EpiphanyRetrievalState | null, scratch?: EpiphanyScratchPad | null, investigation_checkpoint?: EpiphanyInvestigationCheckpoint | null, observations?: Array<EpiphanyObservation>, recent_evidence?: Array<EpiphanyEvidenceRecord>, churn?: EpiphanyChurnState | null, mode?: EpiphanyModeState | null, last_updated_turn_id?: string | null, };
export type EpiphanyThreadState = { revision: bigint, objective?: string | null, active_subgoal_id?: string | null, subgoals?: Array<EpiphanySubgoal>, invariants?: Array<EpiphanyInvariant>, graphs?: EpiphanyGraphs, graph_frontier?: EpiphanyGraphFrontier | null, graph_checkpoint?: EpiphanyGraphCheckpoint | null, retrieval?: EpiphanyRetrievalState | null, scratch?: EpiphanyScratchPad | null, investigation_checkpoint?: EpiphanyInvestigationCheckpoint | null, job_bindings?: Array<EpiphanyJobBinding>, observations?: Array<EpiphanyObservation>, recent_evidence?: Array<EpiphanyEvidenceRecord>, churn?: EpiphanyChurnState | null, mode?: EpiphanyModeState | null, last_updated_turn_id?: string | null, };

View file

@ -25,6 +25,8 @@ export type { EpiphanyGraphs } from "./EpiphanyGraphs";
export type { EpiphanyInvariant } from "./EpiphanyInvariant";
export type { EpiphanyInvestigationCheckpoint } from "./EpiphanyInvestigationCheckpoint";
export type { EpiphanyInvestigationDisposition } from "./EpiphanyInvestigationDisposition";
export type { EpiphanyJobBinding } from "./EpiphanyJobBinding";
export type { EpiphanyJobKind } from "./EpiphanyJobKind";
export type { EpiphanyModeState } from "./EpiphanyModeState";
export type { EpiphanyObservation } from "./EpiphanyObservation";
export type { EpiphanyRetrievalStatus } from "./EpiphanyRetrievalStatus";

View file

@ -4,4 +4,4 @@
import type { ThreadEpiphanyJobKind } from "./ThreadEpiphanyJobKind";
import type { ThreadEpiphanyJobStatus } from "./ThreadEpiphanyJobStatus";
export type ThreadEpiphanyJob = { id: string, kind: ThreadEpiphanyJobKind, scope: string, ownerRole: string, status: ThreadEpiphanyJobStatus, itemsProcessed?: number | null, itemsTotal?: number | null, progressNote?: string | null, lastCheckpointAtUnixSeconds?: bigint | null, blockingReason?: string | null, linkedSubgoalIds?: Array<string>, linkedGraphNodeIds?: Array<string>, };
export type ThreadEpiphanyJob = { id: string, kind: ThreadEpiphanyJobKind, scope: string, ownerRole: string, status: ThreadEpiphanyJobStatus, runtimeAgentJobId?: string | null, itemsProcessed?: number | null, itemsTotal?: number | null, progressNote?: string | null, lastCheckpointAtUnixSeconds?: bigint | null, blockingReason?: string | null, activeThreadIds?: Array<string>, linkedSubgoalIds?: Array<string>, linkedGraphNodeIds?: Array<string>, };

View file

@ -2,4 +2,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanyJobStatus = "idle" | "needed" | "running" | "blocked" | "unavailable";
export type ThreadEpiphanyJobStatus = "idle" | "needed" | "pending" | "running" | "completed" | "failed" | "cancelled" | "blocked" | "unavailable";

View file

@ -2,4 +2,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanyStateUpdatedField = "objective" | "activeSubgoalId" | "subgoals" | "invariants" | "graphs" | "graphFrontier" | "graphCheckpoint" | "scratch" | "investigationCheckpoint" | "observations" | "evidence" | "churn" | "mode";
export type ThreadEpiphanyStateUpdatedField = "objective" | "activeSubgoalId" | "subgoals" | "invariants" | "graphs" | "graphFrontier" | "graphCheckpoint" | "scratch" | "investigationCheckpoint" | "jobBindings" | "observations" | "evidence" | "churn" | "mode";

View file

@ -8,9 +8,10 @@ import type { EpiphanyGraphFrontier } from "../EpiphanyGraphFrontier";
import type { EpiphanyGraphs } from "../EpiphanyGraphs";
import type { EpiphanyInvariant } from "../EpiphanyInvariant";
import type { EpiphanyInvestigationCheckpoint } from "../EpiphanyInvestigationCheckpoint";
import type { EpiphanyJobBinding } from "../EpiphanyJobBinding";
import type { EpiphanyModeState } from "../EpiphanyModeState";
import type { EpiphanyObservation } from "../EpiphanyObservation";
import type { EpiphanyScratchPad } from "../EpiphanyScratchPad";
import type { EpiphanySubgoal } from "../EpiphanySubgoal";
export type ThreadEpiphanyUpdatePatch = { objective?: string | null, activeSubgoalId?: string | null, subgoals?: Array<EpiphanySubgoal> | null, invariants?: Array<EpiphanyInvariant> | null, graphs?: EpiphanyGraphs | null, graphFrontier?: EpiphanyGraphFrontier | null, graphCheckpoint?: EpiphanyGraphCheckpoint | null, scratch?: EpiphanyScratchPad | null, investigationCheckpoint?: EpiphanyInvestigationCheckpoint | null, observations?: Array<EpiphanyObservation>, evidence?: Array<EpiphanyEvidenceRecord>, churn?: EpiphanyChurnState | null, mode?: EpiphanyModeState | null, };
export type ThreadEpiphanyUpdatePatch = { objective?: string | null, activeSubgoalId?: string | null, subgoals?: Array<EpiphanySubgoal> | null, invariants?: Array<EpiphanyInvariant> | null, graphs?: EpiphanyGraphs | null, graphFrontier?: EpiphanyGraphFrontier | null, graphCheckpoint?: EpiphanyGraphCheckpoint | null, scratch?: EpiphanyScratchPad | null, investigationCheckpoint?: EpiphanyInvestigationCheckpoint | null, jobBindings?: Array<EpiphanyJobBinding> | null, observations?: Array<EpiphanyObservation>, evidence?: Array<EpiphanyEvidenceRecord>, churn?: EpiphanyChurnState | null, mode?: EpiphanyModeState | null, };

View file

@ -1820,6 +1820,7 @@ mod tests {
scope: "/workspace".to_string(),
owner_role: "epiphany-core".to_string(),
status: v2::ThreadEpiphanyJobStatus::Needed,
runtime_agent_job_id: None,
items_processed: Some(12),
items_total: None,
progress_note: Some(
@ -1827,6 +1828,7 @@ mod tests {
),
last_checkpoint_at_unix_seconds: Some(1_744_500_000),
blocking_reason: None,
active_thread_ids: Vec::new(),
linked_subgoal_ids: vec!["phase-6".to_string()],
linked_graph_node_ids: vec!["retrieval".to_string()],
}],

View file

@ -69,6 +69,7 @@ use codex_protocol::protocol::EpiphanyGraphs as CoreEpiphanyGraphs;
use codex_protocol::protocol::EpiphanyInvariant as CoreEpiphanyInvariant;
use codex_protocol::protocol::EpiphanyInvestigationCheckpoint as CoreEpiphanyInvestigationCheckpoint;
use codex_protocol::protocol::EpiphanyInvestigationDisposition as CoreEpiphanyInvestigationDisposition;
use codex_protocol::protocol::EpiphanyJobBinding as CoreEpiphanyJobBinding;
use codex_protocol::protocol::EpiphanyModeState as CoreEpiphanyModeState;
use codex_protocol::protocol::EpiphanyObservation as CoreEpiphanyObservation;
use codex_protocol::protocol::EpiphanyRetrievalStatus as CoreEpiphanyRetrievalStatus;
@ -4291,7 +4292,11 @@ pub enum ThreadEpiphanyJobKind {
pub enum ThreadEpiphanyJobStatus {
Idle,
Needed,
Pending,
Running,
Completed,
Failed,
Cancelled,
Blocked,
Unavailable,
}
@ -4307,6 +4312,9 @@ pub struct ThreadEpiphanyJob {
pub status: ThreadEpiphanyJobStatus,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub runtime_agent_job_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub items_processed: Option<u32>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
@ -4321,6 +4329,8 @@ pub struct ThreadEpiphanyJob {
#[ts(optional = nullable)]
pub blocking_reason: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub active_thread_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub linked_subgoal_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub linked_graph_node_ids: Vec<String>,
@ -4727,6 +4737,9 @@ pub struct ThreadEpiphanyUpdatePatch {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub investigation_checkpoint: Option<CoreEpiphanyInvestigationCheckpoint>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub job_bindings: Option<Vec<CoreEpiphanyJobBinding>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub observations: Vec<CoreEpiphanyObservation>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@ -4780,6 +4793,7 @@ pub enum ThreadEpiphanyStateUpdatedField {
GraphCheckpoint,
Scratch,
InvestigationCheckpoint,
JobBindings,
Observations,
Evidence,
Churn,

View file

@ -402,6 +402,8 @@ use codex_protocol::protocol::ConversationStartParams;
use codex_protocol::protocol::ConversationStartTransport;
use codex_protocol::protocol::ConversationTextParams;
use codex_protocol::protocol::EpiphanyInvestigationDisposition;
use codex_protocol::protocol::EpiphanyJobBinding;
use codex_protocol::protocol::EpiphanyJobKind as CoreEpiphanyJobKind;
use codex_protocol::protocol::EpiphanyRetrievalState;
use codex_protocol::protocol::EpiphanyRetrievalStatus;
use codex_protocol::protocol::EpiphanyThreadState;
@ -429,6 +431,9 @@ use codex_rmcp_client::perform_oauth_login_return_url;
use codex_rollout::state_db::StateDbHandle;
use codex_rollout::state_db::get_state_db;
use codex_rollout::state_db::reconcile_rollout;
use codex_state::AgentJobItemStatus;
use codex_state::AgentJobProgress;
use codex_state::AgentJobStatus;
use codex_state::StateRuntime;
use codex_state::ThreadMetadata;
use codex_state::ThreadMetadataBuilder;
@ -3398,7 +3403,7 @@ impl CodexMessageProcessor {
let loaded_thread = self.thread_manager.get_thread(thread_uuid).await.ok();
let mut state_db_ctx = loaded_thread.as_ref().and_then(|thread| thread.state_db());
if state_db_ctx.is_none() {
state_db_ctx = get_state_db(&self.config).await;
state_db_ctx = open_state_db_for_direct_thread_lookup(&self.config).await;
}
let Some(state_db_ctx) = state_db_ctx else {
self.send_internal_error(
@ -4212,6 +4217,15 @@ impl CodexMessageProcessor {
} else {
None
};
let mut state_db_ctx = loaded_thread.as_ref().and_then(|thread| thread.state_db());
if state_db_ctx.is_none() {
state_db_ctx = open_state_db_for_direct_thread_lookup(&self.config).await;
}
let job_resolution = load_epiphany_agent_job_snapshots(
state_db_ctx.as_ref(),
thread.epiphany_state.as_ref(),
)
.await;
let response = ThreadEpiphanyJobsResponse {
thread_id,
@ -4224,7 +4238,11 @@ impl CodexMessageProcessor {
.epiphany_state
.as_ref()
.map(|epiphany_state| epiphany_state.revision),
jobs: map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref()),
jobs: map_epiphany_jobs(
thread.epiphany_state.as_ref(),
retrieval_override.as_ref(),
&job_resolution,
),
};
self.outgoing.send_response(request_id, response).await;
}
@ -4821,6 +4839,7 @@ impl CodexMessageProcessor {
graph_checkpoint: patch.graph_checkpoint,
scratch: patch.scratch,
investigation_checkpoint: patch.investigation_checkpoint,
job_bindings: patch.job_bindings,
observations: patch.observations,
evidence,
churn: patch.churn,
@ -4909,6 +4928,7 @@ impl CodexMessageProcessor {
graph_checkpoint: patch.graph_checkpoint,
scratch: patch.scratch,
investigation_checkpoint: patch.investigation_checkpoint,
job_bindings: patch.job_bindings,
observations: patch.observations,
evidence: patch.evidence,
churn: patch.churn,
@ -11899,16 +11919,271 @@ fn extend_unique_strings(target: &mut Vec<String>, values: impl IntoIterator<Ite
}
}
#[derive(Debug, Default, Clone)]
struct EpiphanyAgentJobResolution {
available: bool,
snapshots_by_binding_id: HashMap<String, EpiphanyAgentJobSnapshot>,
}
#[derive(Debug, Clone)]
struct EpiphanyAgentJobSnapshot {
status: AgentJobStatus,
progress: AgentJobProgress,
updated_at_unix_seconds: i64,
last_error: Option<String>,
active_thread_ids: Vec<String>,
}
async fn load_epiphany_agent_job_snapshots(
state_db_ctx: Option<&StateDbHandle>,
state: Option<&EpiphanyThreadState>,
) -> EpiphanyAgentJobResolution {
let Some(state) = state else {
return EpiphanyAgentJobResolution::default();
};
let Some(state_db_ctx) = state_db_ctx else {
return EpiphanyAgentJobResolution {
available: false,
snapshots_by_binding_id: HashMap::new(),
};
};
let mut resolution = EpiphanyAgentJobResolution {
available: true,
snapshots_by_binding_id: HashMap::new(),
};
for binding in &state.job_bindings {
let Some(runtime_agent_job_id) = binding.runtime_agent_job_id.as_deref() else {
continue;
};
let Ok(Some(job)) = state_db_ctx.get_agent_job(runtime_agent_job_id).await else {
continue;
};
let Ok(progress) = state_db_ctx
.get_agent_job_progress(runtime_agent_job_id)
.await
else {
continue;
};
let active_thread_ids = state_db_ctx
.list_agent_job_items(
runtime_agent_job_id,
Some(AgentJobItemStatus::Running),
/*limit*/ Some(64),
)
.await
.map(|items| {
unique_strings(items.into_iter().filter_map(|item| item.assigned_thread_id))
})
.unwrap_or_default();
resolution.snapshots_by_binding_id.insert(
binding.id.clone(),
EpiphanyAgentJobSnapshot {
status: job.status,
progress,
updated_at_unix_seconds: job.updated_at.timestamp(),
last_error: job.last_error,
active_thread_ids,
},
);
}
resolution
}
fn map_epiphany_jobs(
state: Option<&EpiphanyThreadState>,
retrieval_override: Option<&EpiphanyRetrievalState>,
job_resolution: &EpiphanyAgentJobResolution,
) -> Vec<ThreadEpiphanyJob> {
vec![
let mut jobs = vec![
map_epiphany_index_job(state, retrieval_override),
map_epiphany_remap_job(state),
map_epiphany_verification_job(state),
map_epiphany_specialist_job(),
]
];
let Some(state) = state else {
return jobs;
};
for binding in &state.job_bindings {
let snapshot = job_resolution
.snapshots_by_binding_id
.get(binding.id.as_str());
let replacement = if let Some(existing) = jobs.iter().find(|job| job.id == binding.id) {
overlay_epiphany_job_binding(existing.clone(), binding, snapshot, job_resolution)
} else {
map_epiphany_bound_job(binding, snapshot, job_resolution)
};
if let Some(existing) = jobs.iter_mut().find(|job| job.id == binding.id) {
*existing = replacement;
} else {
jobs.push(replacement);
}
}
jobs
}
fn map_epiphany_bound_job(
binding: &EpiphanyJobBinding,
snapshot: Option<&EpiphanyAgentJobSnapshot>,
job_resolution: &EpiphanyAgentJobResolution,
) -> ThreadEpiphanyJob {
overlay_epiphany_job_binding(
ThreadEpiphanyJob {
id: binding.id.clone(),
kind: map_core_epiphany_job_kind(binding.kind),
scope: binding.scope.clone(),
owner_role: binding.owner_role.clone(),
status: if binding.blocking_reason.is_some() {
ThreadEpiphanyJobStatus::Blocked
} else {
ThreadEpiphanyJobStatus::Idle
},
runtime_agent_job_id: binding.runtime_agent_job_id.clone(),
items_processed: None,
items_total: None,
progress_note: None,
last_checkpoint_at_unix_seconds: None,
blocking_reason: None,
active_thread_ids: Vec::new(),
linked_subgoal_ids: binding.linked_subgoal_ids.clone(),
linked_graph_node_ids: binding.linked_graph_node_ids.clone(),
},
binding,
snapshot,
job_resolution,
)
}
fn overlay_epiphany_job_binding(
mut job: ThreadEpiphanyJob,
binding: &EpiphanyJobBinding,
snapshot: Option<&EpiphanyAgentJobSnapshot>,
job_resolution: &EpiphanyAgentJobResolution,
) -> ThreadEpiphanyJob {
job.kind = map_core_epiphany_job_kind(binding.kind);
job.scope = binding.scope.clone();
job.owner_role = binding.owner_role.clone();
job.runtime_agent_job_id = binding.runtime_agent_job_id.clone();
if !binding.linked_subgoal_ids.is_empty() {
job.linked_subgoal_ids = binding.linked_subgoal_ids.clone();
}
if !binding.linked_graph_node_ids.is_empty() {
job.linked_graph_node_ids = binding.linked_graph_node_ids.clone();
}
if let Some(progress_note) = binding.progress_note.clone() {
job.progress_note = Some(progress_note);
}
if let Some(blocking_reason) = binding.blocking_reason.clone() {
job.blocking_reason = Some(blocking_reason);
}
if let Some(snapshot) = snapshot {
job.status = map_thread_epiphany_job_status(snapshot.status);
job.items_processed = Some(progress_processed_items(&snapshot.progress));
job.items_total = Some(progress_total_items(&snapshot.progress));
job.progress_note = Some(render_agent_job_progress_note(snapshot));
job.last_checkpoint_at_unix_seconds = Some(snapshot.updated_at_unix_seconds);
job.active_thread_ids = snapshot.active_thread_ids.clone();
job.blocking_reason = match snapshot.status {
AgentJobStatus::Failed => snapshot.last_error.clone().or(job.blocking_reason),
AgentJobStatus::Cancelled => Some(
snapshot
.last_error
.clone()
.unwrap_or_else(|| "Bound runtime agent job was cancelled.".to_string()),
),
_ => None,
};
return job;
}
if let Some(runtime_agent_job_id) = binding.runtime_agent_job_id.as_deref() {
job.status = ThreadEpiphanyJobStatus::Blocked;
job.blocking_reason = Some(if job_resolution.available {
format!(
"Bound runtime agent job {:?} was not found in state runtime.",
runtime_agent_job_id
)
} else {
"State runtime is unavailable, so bound runtime agent jobs cannot be resolved."
.to_string()
});
}
job
}
fn map_core_epiphany_job_kind(kind: CoreEpiphanyJobKind) -> ThreadEpiphanyJobKind {
match kind {
CoreEpiphanyJobKind::Indexing => ThreadEpiphanyJobKind::Indexing,
CoreEpiphanyJobKind::Remap => ThreadEpiphanyJobKind::Remap,
CoreEpiphanyJobKind::Verification => ThreadEpiphanyJobKind::Verification,
CoreEpiphanyJobKind::Specialist => ThreadEpiphanyJobKind::Specialist,
}
}
fn map_thread_epiphany_job_status(status: AgentJobStatus) -> ThreadEpiphanyJobStatus {
match status {
AgentJobStatus::Pending => ThreadEpiphanyJobStatus::Pending,
AgentJobStatus::Running => ThreadEpiphanyJobStatus::Running,
AgentJobStatus::Completed => ThreadEpiphanyJobStatus::Completed,
AgentJobStatus::Failed => ThreadEpiphanyJobStatus::Failed,
AgentJobStatus::Cancelled => ThreadEpiphanyJobStatus::Cancelled,
}
}
fn progress_total_items(progress: &AgentJobProgress) -> u32 {
u32::try_from(progress.total_items).unwrap_or(u32::MAX)
}
fn progress_processed_items(progress: &AgentJobProgress) -> u32 {
u32::try_from(
progress
.completed_items
.saturating_add(progress.failed_items),
)
.unwrap_or(u32::MAX)
}
fn render_agent_job_progress_note(snapshot: &EpiphanyAgentJobSnapshot) -> String {
let progress = &snapshot.progress;
match snapshot.status {
AgentJobStatus::Pending => format!(
"Runtime agent job is pending with {} pending, {} running, {} completed, and {} failed item(s).",
progress.pending_items,
progress.running_items,
progress.completed_items,
progress.failed_items
),
AgentJobStatus::Running => format!(
"Runtime agent job is running with {} pending, {} running, {} completed, and {} failed item(s).",
progress.pending_items,
progress.running_items,
progress.completed_items,
progress.failed_items
),
AgentJobStatus::Completed => format!(
"Runtime agent job completed all {} item(s).",
progress.total_items
),
AgentJobStatus::Failed => format!(
"Runtime agent job failed with {} completed and {} failed item(s).",
progress.completed_items, progress.failed_items
),
AgentJobStatus::Cancelled => format!(
"Runtime agent job was cancelled with {} pending, {} completed, and {} failed item(s).",
progress.pending_items, progress.completed_items, progress.failed_items
),
}
}
fn map_epiphany_index_job(
@ -11928,11 +12203,13 @@ fn map_epiphany_index_job(
scope: "workspace".to_string(),
owner_role: "epiphany-core".to_string(),
status: ThreadEpiphanyJobStatus::Unavailable,
runtime_agent_job_id: None,
items_processed: None,
items_total: None,
progress_note: None,
last_checkpoint_at_unix_seconds: None,
blocking_reason: Some("Retrieval state is unavailable for this thread.".to_string()),
active_thread_ids: Vec::new(),
linked_subgoal_ids,
linked_graph_node_ids,
};
@ -11959,6 +12236,7 @@ fn map_epiphany_index_job(
scope: retrieval.workspace_root.display().to_string(),
owner_role: "epiphany-core".to_string(),
status: epiphany_job_status_from_retrieval_status(retrieval.status),
runtime_agent_job_id: None,
items_processed: retrieval.indexed_file_count,
items_total: None,
progress_note: Some(progress_note),
@ -11966,6 +12244,7 @@ fn map_epiphany_index_job(
blocking_reason: (retrieval.status == EpiphanyRetrievalStatus::Unavailable).then(|| {
"Indexing requires a readable workspace and configured retrieval backend.".to_string()
}),
active_thread_ids: Vec::new(),
linked_subgoal_ids,
linked_graph_node_ids,
}
@ -12024,11 +12303,13 @@ fn map_epiphany_remap_job(state: Option<&EpiphanyThreadState>) -> ThreadEpiphany
} else {
ThreadEpiphanyJobStatus::Idle
},
runtime_agent_job_id: None,
items_processed: None,
items_total: None,
progress_note: Some(progress_note),
last_checkpoint_at_unix_seconds: None,
blocking_reason: None,
active_thread_ids: Vec::new(),
linked_subgoal_ids: epiphany_active_subgoal_ids(Some(state)),
linked_graph_node_ids: epiphany_active_graph_node_ids(Some(state)),
}
@ -12069,11 +12350,13 @@ fn map_epiphany_verification_job(state: Option<&EpiphanyThreadState>) -> ThreadE
scope: "invariants/evidence".to_string(),
owner_role: "epiphany-harness".to_string(),
status,
runtime_agent_job_id: None,
items_processed: Some(verified),
items_total: Some(total),
progress_note: Some(progress_note),
last_checkpoint_at_unix_seconds: None,
blocking_reason: None,
active_thread_ids: Vec::new(),
linked_subgoal_ids: epiphany_active_subgoal_ids(Some(state)),
linked_graph_node_ids: epiphany_active_graph_node_ids(Some(state)),
}
@ -12086,6 +12369,7 @@ fn map_epiphany_specialist_job() -> ThreadEpiphanyJob {
scope: "role-scoped specialist work".to_string(),
owner_role: "epiphany-harness".to_string(),
status: ThreadEpiphanyJobStatus::Unavailable,
runtime_agent_job_id: None,
items_processed: None,
items_total: None,
progress_note: None,
@ -12094,6 +12378,7 @@ fn map_epiphany_specialist_job() -> ThreadEpiphanyJob {
"Specialist scheduling is not landed; this slot prevents clients from inventing private scheduler state."
.to_string(),
),
active_thread_ids: Vec::new(),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
}
@ -12111,11 +12396,13 @@ fn epiphany_blocked_state_job(
scope: scope.to_string(),
owner_role: "epiphany-harness".to_string(),
status: ThreadEpiphanyJobStatus::Blocked,
runtime_agent_job_id: None,
items_processed: None,
items_total: None,
progress_note: None,
last_checkpoint_at_unix_seconds: None,
blocking_reason: Some(blocking_reason.to_string()),
active_thread_ids: Vec::new(),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
}
@ -12165,6 +12452,7 @@ fn thread_epiphany_patch_has_state_replacements(patch: &ThreadEpiphanyUpdatePatc
|| patch.graph_checkpoint.is_some()
|| patch.scratch.is_some()
|| patch.investigation_checkpoint.is_some()
|| patch.job_bindings.is_some()
|| patch.churn.is_some()
|| patch.mode.is_some()
}
@ -12266,6 +12554,9 @@ fn epiphany_update_patch_changed_fields(
if patch.investigation_checkpoint.is_some() {
fields.push(ThreadEpiphanyStateUpdatedField::InvestigationCheckpoint);
}
if patch.job_bindings.is_some() {
fields.push(ThreadEpiphanyStateUpdatedField::JobBindings);
}
if !patch.observations.is_empty() {
fields.push(ThreadEpiphanyStateUpdatedField::Observations);
}
@ -14490,7 +14781,7 @@ mod tests {
..Default::default()
};
let jobs = map_epiphany_jobs(Some(&state), None);
let jobs = map_epiphany_jobs(Some(&state), None, &EpiphanyAgentJobResolution::default());
assert_eq!(jobs.len(), 4);
assert_eq!(jobs[0].id, "retrieval-index");
@ -14527,7 +14818,11 @@ mod tests {
..Default::default()
};
let jobs = map_epiphany_jobs(None, Some(&retrieval));
let jobs = map_epiphany_jobs(
None,
Some(&retrieval),
&EpiphanyAgentJobResolution::default(),
);
assert_eq!(jobs[0].status, ThreadEpiphanyJobStatus::Idle);
assert_eq!(jobs[0].items_processed, Some(7));
@ -14535,6 +14830,102 @@ mod tests {
assert_eq!(jobs[2].status, ThreadEpiphanyJobStatus::Blocked);
}
#[test]
fn map_epiphany_jobs_overlays_bound_runtime_agent_job_progress() {
let state = codex_protocol::protocol::EpiphanyThreadState {
job_bindings: vec![codex_protocol::protocol::EpiphanyJobBinding {
id: "specialist-work".to_string(),
kind: codex_protocol::protocol::EpiphanyJobKind::Specialist,
scope: "role-scoped specialist work".to_string(),
owner_role: "epiphany-harness".to_string(),
runtime_agent_job_id: Some("job-specialist-1".to_string()),
linked_subgoal_ids: vec!["phase-6".to_string()],
linked_graph_node_ids: vec!["job-surface".to_string()],
progress_note: Some("Bound to a real runtime job.".to_string()),
blocking_reason: None,
}],
..Default::default()
};
let resolution = EpiphanyAgentJobResolution {
available: true,
snapshots_by_binding_id: HashMap::from([(
"specialist-work".to_string(),
EpiphanyAgentJobSnapshot {
status: AgentJobStatus::Running,
progress: AgentJobProgress {
total_items: 3,
pending_items: 1,
running_items: 1,
completed_items: 1,
failed_items: 0,
},
updated_at_unix_seconds: 1_744_600_000,
last_error: None,
active_thread_ids: vec!["worker-thread-1".to_string()],
},
)]),
};
let jobs = map_epiphany_jobs(Some(&state), None, &resolution);
let specialist = jobs
.iter()
.find(|job| job.id == "specialist-work")
.expect("specialist slot should exist");
assert_eq!(specialist.status, ThreadEpiphanyJobStatus::Running);
assert_eq!(
specialist.runtime_agent_job_id.as_deref(),
Some("job-specialist-1")
);
assert_eq!(specialist.items_processed, Some(1));
assert_eq!(specialist.items_total, Some(3));
assert_eq!(
specialist.active_thread_ids,
vec!["worker-thread-1".to_string()]
);
assert_eq!(specialist.linked_subgoal_ids, vec!["phase-6".to_string()]);
assert_eq!(
specialist.linked_graph_node_ids,
vec!["job-surface".to_string()]
);
}
#[test]
fn map_epiphany_jobs_blocks_missing_bound_runtime_agent_job() {
let state = codex_protocol::protocol::EpiphanyThreadState {
job_bindings: vec![codex_protocol::protocol::EpiphanyJobBinding {
id: "specialist-work".to_string(),
kind: codex_protocol::protocol::EpiphanyJobKind::Specialist,
scope: "role-scoped specialist work".to_string(),
owner_role: "epiphany-harness".to_string(),
runtime_agent_job_id: Some("job-missing".to_string()),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
progress_note: None,
blocking_reason: None,
}],
..Default::default()
};
let resolution = EpiphanyAgentJobResolution {
available: true,
snapshots_by_binding_id: HashMap::new(),
};
let jobs = map_epiphany_jobs(Some(&state), None, &resolution);
let specialist = jobs
.iter()
.find(|job| job.id == "specialist-work")
.expect("specialist slot should exist");
assert_eq!(specialist.status, ThreadEpiphanyJobStatus::Blocked);
assert!(
specialist
.blocking_reason
.as_deref()
.is_some_and(|reason| reason.contains("not found in state runtime"))
);
}
#[test]
fn epiphany_update_patch_changed_fields_reports_patch_surface() {
let fields = epiphany_update_patch_changed_fields(&ThreadEpiphanyUpdatePatch {
@ -14542,6 +14933,7 @@ mod tests {
graphs: Some(Default::default()),
graph_frontier: Some(Default::default()),
investigation_checkpoint: Some(Default::default()),
job_bindings: Some(Vec::new()),
observations: vec![Default::default()],
evidence: vec![Default::default()],
churn: Some(Default::default()),
@ -14555,6 +14947,7 @@ mod tests {
ThreadEpiphanyStateUpdatedField::Graphs,
ThreadEpiphanyStateUpdatedField::GraphFrontier,
ThreadEpiphanyStateUpdatedField::InvestigationCheckpoint,
ThreadEpiphanyStateUpdatedField::JobBindings,
ThreadEpiphanyStateUpdatedField::Observations,
ThreadEpiphanyStateUpdatedField::Evidence,
ThreadEpiphanyStateUpdatedField::Churn,

View file

@ -32,6 +32,7 @@ use codex_protocol::protocol::EpiphanyGraphFrontier;
use codex_protocol::protocol::EpiphanyGraphs;
use codex_protocol::protocol::EpiphanyInvariant;
use codex_protocol::protocol::EpiphanyInvestigationCheckpoint;
use codex_protocol::protocol::EpiphanyJobBinding;
use codex_protocol::protocol::EpiphanyModeState;
use codex_protocol::protocol::EpiphanyObservation;
use codex_protocol::protocol::EpiphanyRetrievalState;
@ -112,6 +113,7 @@ pub struct EpiphanyStateUpdate {
pub graph_checkpoint: Option<EpiphanyGraphCheckpoint>,
pub scratch: Option<EpiphanyScratchPad>,
pub investigation_checkpoint: Option<EpiphanyInvestigationCheckpoint>,
pub job_bindings: Option<Vec<EpiphanyJobBinding>>,
pub observations: Vec<EpiphanyObservation>,
pub evidence: Vec<EpiphanyEvidenceRecord>,
pub churn: Option<EpiphanyChurnState>,
@ -129,6 +131,7 @@ impl EpiphanyStateUpdate {
&& self.graph_checkpoint.is_none()
&& self.scratch.is_none()
&& self.investigation_checkpoint.is_none()
&& self.job_bindings.is_none()
&& self.observations.is_empty()
&& self.evidence.is_empty()
&& self.churn.is_none()
@ -645,10 +648,44 @@ fn epiphany_state_update_validation_errors(
}
}
if let Some(job_bindings) = update.job_bindings.as_ref() {
errors.extend(validate_epiphany_job_bindings(job_bindings));
}
errors.extend(epiphany_state_replacement_validation_errors(state, update));
errors
}
fn validate_epiphany_job_bindings(job_bindings: &[EpiphanyJobBinding]) -> Vec<String> {
let mut errors = Vec::new();
let mut seen_ids = HashSet::<&str>::new();
for binding in job_bindings {
require_nonempty_update(&binding.id, "job_binding.id", &mut errors);
require_nonempty_update(&binding.scope, "job_binding.scope", &mut errors);
require_nonempty_update(&binding.owner_role, "job_binding.owner_role", &mut errors);
if let Some(runtime_agent_job_id) = binding.runtime_agent_job_id.as_deref() {
require_nonempty_update(
runtime_agent_job_id,
"job_binding.runtime_agent_job_id",
&mut errors,
);
}
if let Some(progress_note) = binding.progress_note.as_deref() {
require_nonempty_update(progress_note, "job_binding.progress_note", &mut errors);
}
if let Some(blocking_reason) = binding.blocking_reason.as_deref() {
require_nonempty_update(blocking_reason, "job_binding.blocking_reason", &mut errors);
}
if !binding.id.is_empty() && !seen_ids.insert(binding.id.as_str()) {
errors.push(format!("duplicate job binding id {:?}", binding.id));
}
}
errors
}
fn epiphany_state_replacement_validation_errors(
state: &EpiphanyThreadState,
update: &EpiphanyStateUpdate,
@ -734,6 +771,9 @@ fn apply_epiphany_state_update(
if let Some(checkpoint) = update.investigation_checkpoint {
state.investigation_checkpoint = Some(checkpoint);
}
if let Some(job_bindings) = update.job_bindings {
state.job_bindings = job_bindings;
}
if let Some(churn) = update.churn {
state.churn = Some(churn);
}
@ -760,6 +800,7 @@ mod epiphany_update_tests {
use super::*;
use codex_protocol::protocol::EpiphanyGraph;
use codex_protocol::protocol::EpiphanyGraphNode;
use codex_protocol::protocol::EpiphanyJobKind;
fn evidence(id: &str) -> EpiphanyEvidenceRecord {
EpiphanyEvidenceRecord {
@ -782,6 +823,20 @@ mod epiphany_update_tests {
}
}
fn job_binding(id: &str) -> EpiphanyJobBinding {
EpiphanyJobBinding {
id: id.to_string(),
kind: EpiphanyJobKind::Specialist,
scope: "role-scoped specialist work".to_string(),
owner_role: "epiphany-harness".to_string(),
runtime_agent_job_id: Some(format!("agent-job-{id}")),
linked_subgoal_ids: vec!["phase-6".to_string()],
linked_graph_node_ids: vec!["job-surface".to_string()],
progress_note: Some("Bound to a real runtime agent job.".to_string()),
blocking_reason: None,
}
}
#[test]
fn apply_epiphany_state_update_replaces_typed_fields_and_prepends_evidence() {
let mut state = EpiphanyThreadState {
@ -847,6 +902,33 @@ mod epiphany_update_tests {
);
}
#[test]
fn apply_epiphany_state_update_replaces_job_bindings() {
let mut state = EpiphanyThreadState {
revision: 2,
job_bindings: vec![job_binding("old")],
..Default::default()
};
apply_epiphany_state_update(
&mut state,
EpiphanyStateUpdate {
job_bindings: Some(vec![job_binding("new")]),
..Default::default()
},
Some("turn-jobs".to_string()),
);
assert_eq!(state.revision, 3);
assert_eq!(state.job_bindings.len(), 1);
assert_eq!(state.job_bindings[0].id, "new");
assert_eq!(
state.job_bindings[0].runtime_agent_job_id.as_deref(),
Some("agent-job-new")
);
assert_eq!(state.last_updated_turn_id.as_deref(), Some("turn-jobs"));
}
#[test]
fn validate_epiphany_state_update_accepts_observation_linked_to_existing_evidence() {
let state = EpiphanyThreadState {
@ -998,6 +1080,67 @@ mod epiphany_update_tests {
.any(|error| error.contains("investigation checkpoint cites missing evidence id"))
);
}
#[test]
fn validate_epiphany_state_update_rejects_invalid_job_bindings() {
let update = EpiphanyStateUpdate {
job_bindings: Some(vec![
job_binding("dup"),
job_binding("dup"),
EpiphanyJobBinding {
id: String::new(),
kind: EpiphanyJobKind::Verification,
scope: String::new(),
owner_role: String::new(),
runtime_agent_job_id: Some(String::new()),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
progress_note: Some(String::new()),
blocking_reason: Some(String::new()),
},
]),
..Default::default()
};
let errors =
epiphany_state_update_validation_errors(&EpiphanyThreadState::default(), &update);
assert!(
errors
.iter()
.any(|error| error.contains("duplicate job binding id"))
);
assert!(
errors
.iter()
.any(|error| error.contains("job_binding.id must not be empty"))
);
assert!(
errors
.iter()
.any(|error| error.contains("job_binding.scope must not be empty"))
);
assert!(
errors
.iter()
.any(|error| error.contains("job_binding.owner_role must not be empty"))
);
assert!(
errors
.iter()
.any(|error| error.contains("job_binding.runtime_agent_job_id must not be empty"))
);
assert!(
errors
.iter()
.any(|error| error.contains("job_binding.progress_note must not be empty"))
);
assert!(
errors
.iter()
.any(|error| error.contains("job_binding.blocking_reason must not be empty"))
);
}
}
fn pending_message_input_item(message: &ResponseItem) -> CodexResult<ResponseInputItem> {

View file

@ -337,6 +337,7 @@ fn sample_epiphany_state_for_prompt() -> EpiphanyThreadState {
open_gap_ids: vec!["gap-resume-proof".to_string()],
}),
investigation_checkpoint: None,
job_bindings: Vec::new(),
scratch: Some(EpiphanyScratchPad {
summary: Some("Inject the state as a developer fragment, not as a user message.".to_string()),
hypothesis: Some("Keeping the block bounded will help resume without making prompt sludge.".to_string()),

View file

@ -3021,6 +3021,9 @@ pub struct EpiphanyThreadState {
#[ts(type = "EpiphanyInvestigationCheckpoint | null")]
pub investigation_checkpoint: Option<EpiphanyInvestigationCheckpoint>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[ts(type = "Array<EpiphanyJobBinding>")]
pub job_bindings: Vec<EpiphanyJobBinding>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[ts(type = "Array<EpiphanyObservation>")]
pub observations: Vec<EpiphanyObservation>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@ -3296,6 +3299,39 @@ pub struct EpiphanyInvestigationCheckpoint {
pub evidence_ids: Vec<String>,
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
#[ts(rename_all = "snake_case")]
pub enum EpiphanyJobKind {
Indexing,
Remap,
Verification,
Specialist,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS)]
pub struct EpiphanyJobBinding {
pub id: String,
pub kind: EpiphanyJobKind,
pub scope: String,
pub owner_role: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(type = "string | null")]
pub runtime_agent_job_id: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[ts(type = "Array<string>")]
pub linked_subgoal_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[ts(type = "Array<string>")]
pub linked_graph_node_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(type = "string | null")]
pub progress_note: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(type = "string | null")]
pub blocking_reason: Option<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
pub struct EpiphanyObservation {
pub id: String,
@ -5722,6 +5758,7 @@ mod tests {
next_probe: Some("Replay after rollback and compaction".to_string()),
notes: vec!["Do not touch prompts yet".to_string()],
}),
job_bindings: Vec::new(),
observations: vec![EpiphanyObservation {
id: "obs-1".to_string(),
summary: "TurnContext already gives us the persistence seam".to_string(),