Add Phase 6 context shard reflection

This commit is contained in:
Meta Vens 2026-04-26 03:00:06 +01:00
commit aab3ae3334
21 changed files with 1459 additions and 47 deletions

View file

@ -14811,6 +14811,127 @@
"title": "ThreadCompactStartResponse",
"type": "object"
},
"ThreadEpiphanyContext": {
"properties": {
"checkpoint": {
"anyOf": [
{
"$ref": "#/definitions/v2/EpiphanyGraphCheckpoint"
},
{
"type": "null"
}
]
},
"evidence": {
"items": {
"$ref": "#/definitions/v2/EpiphanyEvidenceRecord"
},
"type": "array"
},
"frontier": {
"anyOf": [
{
"$ref": "#/definitions/v2/EpiphanyGraphFrontier"
},
{
"type": "null"
}
]
},
"graph": {
"$ref": "#/definitions/v2/ThreadEpiphanyGraphContext"
},
"observations": {
"items": {
"$ref": "#/definitions/v2/EpiphanyObservation"
},
"type": "array"
}
},
"required": [
"graph"
],
"type": "object"
},
"ThreadEpiphanyContextMissing": {
"properties": {
"evidenceIds": {
"items": {
"type": "string"
},
"type": "array"
},
"graphEdgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"graphNodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"observationIds": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyContextSource": {
"enum": [
"stored",
"live"
],
"type": "string"
},
"ThreadEpiphanyContextStateStatus": {
"enum": [
"missing",
"ready"
],
"type": "string"
},
"ThreadEpiphanyGraphContext": {
"properties": {
"architectureEdges": {
"items": {
"$ref": "#/definitions/v2/EpiphanyGraphEdge"
},
"type": "array"
},
"architectureNodes": {
"items": {
"$ref": "#/definitions/v2/EpiphanyGraphNode"
},
"type": "array"
},
"dataflowEdges": {
"items": {
"$ref": "#/definitions/v2/EpiphanyGraphEdge"
},
"type": "array"
},
"dataflowNodes": {
"items": {
"$ref": "#/definitions/v2/EpiphanyGraphNode"
},
"type": "array"
},
"links": {
"items": {
"$ref": "#/definitions/v2/EpiphanyGraphLink"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyJob": {
"properties": {
"blockingReason": {
@ -15160,6 +15281,7 @@
"index",
"retrieve",
"distill",
"context",
"jobs",
"propose",
"promote",

View file

@ -12698,6 +12698,127 @@
"title": "ThreadCompactStartResponse",
"type": "object"
},
"ThreadEpiphanyContext": {
"properties": {
"checkpoint": {
"anyOf": [
{
"$ref": "#/definitions/EpiphanyGraphCheckpoint"
},
{
"type": "null"
}
]
},
"evidence": {
"items": {
"$ref": "#/definitions/EpiphanyEvidenceRecord"
},
"type": "array"
},
"frontier": {
"anyOf": [
{
"$ref": "#/definitions/EpiphanyGraphFrontier"
},
{
"type": "null"
}
]
},
"graph": {
"$ref": "#/definitions/ThreadEpiphanyGraphContext"
},
"observations": {
"items": {
"$ref": "#/definitions/EpiphanyObservation"
},
"type": "array"
}
},
"required": [
"graph"
],
"type": "object"
},
"ThreadEpiphanyContextMissing": {
"properties": {
"evidenceIds": {
"items": {
"type": "string"
},
"type": "array"
},
"graphEdgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"graphNodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"observationIds": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyContextSource": {
"enum": [
"stored",
"live"
],
"type": "string"
},
"ThreadEpiphanyContextStateStatus": {
"enum": [
"missing",
"ready"
],
"type": "string"
},
"ThreadEpiphanyGraphContext": {
"properties": {
"architectureEdges": {
"items": {
"$ref": "#/definitions/EpiphanyGraphEdge"
},
"type": "array"
},
"architectureNodes": {
"items": {
"$ref": "#/definitions/EpiphanyGraphNode"
},
"type": "array"
},
"dataflowEdges": {
"items": {
"$ref": "#/definitions/EpiphanyGraphEdge"
},
"type": "array"
},
"dataflowNodes": {
"items": {
"$ref": "#/definitions/EpiphanyGraphNode"
},
"type": "array"
},
"links": {
"items": {
"$ref": "#/definitions/EpiphanyGraphLink"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyJob": {
"properties": {
"blockingReason": {
@ -13047,6 +13168,7 @@
"index",
"retrieve",
"distill",
"context",
"jobs",
"propose",
"promote",

View file

@ -0,0 +1,10 @@
// 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 { EpiphanyEvidenceRecord } from "../EpiphanyEvidenceRecord";
import type { EpiphanyGraphCheckpoint } from "../EpiphanyGraphCheckpoint";
import type { EpiphanyGraphFrontier } from "../EpiphanyGraphFrontier";
import type { EpiphanyObservation } from "../EpiphanyObservation";
import type { ThreadEpiphanyGraphContext } from "./ThreadEpiphanyGraphContext";
export type ThreadEpiphanyContext = { graph: ThreadEpiphanyGraphContext, frontier?: EpiphanyGraphFrontier | null, checkpoint?: EpiphanyGraphCheckpoint | null, observations?: Array<EpiphanyObservation>, evidence?: Array<EpiphanyEvidenceRecord>, };

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 ThreadEpiphanyContextMissing = { graphNodeIds?: Array<string>, graphEdgeIds?: Array<string>, observationIds?: Array<string>, evidenceIds?: Array<string>, };

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 ThreadEpiphanyContextSource = "stored" | "live";

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 ThreadEpiphanyContextStateStatus = "missing" | "ready";

View file

@ -0,0 +1,8 @@
// 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 { EpiphanyGraphEdge } from "../EpiphanyGraphEdge";
import type { EpiphanyGraphLink } from "../EpiphanyGraphLink";
import type { EpiphanyGraphNode } from "../EpiphanyGraphNode";
export type ThreadEpiphanyGraphContext = { architectureNodes?: Array<EpiphanyGraphNode>, architectureEdges?: Array<EpiphanyGraphEdge>, dataflowNodes?: Array<EpiphanyGraphNode>, dataflowEdges?: Array<EpiphanyGraphEdge>, links?: Array<EpiphanyGraphLink>, };

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 ThreadEpiphanySceneAction = "index" | "retrieve" | "distill" | "jobs" | "propose" | "promote" | "update";
export type ThreadEpiphanySceneAction = "index" | "retrieve" | "distill" | "context" | "jobs" | "propose" | "promote" | "update";

View file

@ -317,6 +317,11 @@ export type { ThreadArchivedNotification } from "./ThreadArchivedNotification";
export type { ThreadClosedNotification } from "./ThreadClosedNotification";
export type { ThreadCompactStartParams } from "./ThreadCompactStartParams";
export type { ThreadCompactStartResponse } from "./ThreadCompactStartResponse";
export type { ThreadEpiphanyContext } from "./ThreadEpiphanyContext";
export type { ThreadEpiphanyContextMissing } from "./ThreadEpiphanyContextMissing";
export type { ThreadEpiphanyContextSource } from "./ThreadEpiphanyContextSource";
export type { ThreadEpiphanyContextStateStatus } from "./ThreadEpiphanyContextStateStatus";
export type { ThreadEpiphanyGraphContext } from "./ThreadEpiphanyGraphContext";
export type { ThreadEpiphanyJob } from "./ThreadEpiphanyJob";
export type { ThreadEpiphanyJobKind } from "./ThreadEpiphanyJobKind";
export type { ThreadEpiphanyJobStatus } from "./ThreadEpiphanyJobStatus";

View file

@ -346,6 +346,11 @@ client_request_definitions! {
params: v2::ThreadEpiphanyJobsParams,
response: v2::ThreadEpiphanyJobsResponse,
},
#[experimental("thread/epiphany/context")]
ThreadEpiphanyContext => "thread/epiphany/context" {
params: v2::ThreadEpiphanyContextParams,
response: v2::ThreadEpiphanyContextResponse,
},
#[experimental("thread/epiphany/index")]
ThreadEpiphanyIndex => "thread/epiphany/index" {
params: v2::ThreadEpiphanyIndexParams,
@ -1808,6 +1813,120 @@ mod tests {
Ok(())
}
#[test]
fn serialize_thread_epiphany_context_response() -> Result<()> {
let response = ClientResponse::ThreadEpiphanyContext {
request_id: RequestId::Integer(8),
response: v2::ThreadEpiphanyContextResponse {
thread_id: "thr_123".to_string(),
source: v2::ThreadEpiphanyContextSource::Live,
state_status: v2::ThreadEpiphanyContextStateStatus::Ready,
state_revision: Some(3),
context: v2::ThreadEpiphanyContext {
graph: v2::ThreadEpiphanyGraphContext {
architecture_nodes: vec![codex_protocol::protocol::EpiphanyGraphNode {
id: "state-spine".to_string(),
title: "State spine".to_string(),
purpose: "Keep understanding typed".to_string(),
..Default::default()
}],
architecture_edges: vec![codex_protocol::protocol::EpiphanyGraphEdge {
id: Some("edge-state-read".to_string()),
source_id: "state-spine".to_string(),
target_id: "client-read".to_string(),
kind: "projects".to_string(),
..Default::default()
}],
..Default::default()
},
frontier: Some(codex_protocol::protocol::EpiphanyGraphFrontier {
active_node_ids: vec!["state-spine".to_string()],
..Default::default()
}),
checkpoint: None,
observations: vec![codex_protocol::protocol::EpiphanyObservation {
id: "obs-1".to_string(),
summary: "Context shard is read-only.".to_string(),
source_kind: "smoke".to_string(),
status: "ok".to_string(),
evidence_ids: vec!["ev-1".to_string()],
..Default::default()
}],
evidence: vec![codex_protocol::protocol::EpiphanyEvidenceRecord {
id: "ev-1".to_string(),
kind: "test".to_string(),
status: "ok".to_string(),
summary: "Context shard serialized.".to_string(),
..Default::default()
}],
},
missing: v2::ThreadEpiphanyContextMissing {
graph_node_ids: vec!["missing-node".to_string()],
..Default::default()
},
},
};
assert_eq!(response.id(), &RequestId::Integer(8));
assert_eq!(response.method(), "thread/epiphany/context");
assert_eq!(
json!({
"method": "thread/epiphany/context",
"id": 8,
"response": {
"threadId": "thr_123",
"source": "live",
"stateStatus": "ready",
"stateRevision": 3,
"context": {
"graph": {
"architectureNodes": [
{
"id": "state-spine",
"title": "State spine",
"purpose": "Keep understanding typed"
}
],
"architectureEdges": [
{
"source_id": "state-spine",
"target_id": "client-read",
"kind": "projects",
"id": "edge-state-read"
}
]
},
"frontier": {
"active_node_ids": ["state-spine"]
},
"observations": [
{
"id": "obs-1",
"summary": "Context shard is read-only.",
"source_kind": "smoke",
"status": "ok",
"evidence_ids": ["ev-1"]
}
],
"evidence": [
{
"id": "ev-1",
"kind": "test",
"status": "ok",
"summary": "Context shard serialized."
}
]
},
"missing": {
"graphNodeIds": ["missing-node"]
}
}
}),
serde_json::to_value(&response)?,
);
Ok(())
}
#[test]
fn serialize_thread_epiphany_retrieve_response() -> Result<()> {
let response = ClientResponse::ThreadEpiphanyRetrieve {
@ -2690,6 +2809,24 @@ mod tests {
assert_eq!(reason, Some("thread/epiphany/jobs"));
}
#[test]
fn thread_epiphany_context_is_marked_experimental() {
let request = ClientRequest::ThreadEpiphanyContext {
request_id: RequestId::Integer(1),
params: v2::ThreadEpiphanyContextParams {
thread_id: "thr_123".to_string(),
graph_node_ids: vec!["state-spine".to_string()],
graph_edge_ids: Vec::new(),
observation_ids: Vec::new(),
evidence_ids: Vec::new(),
include_active_frontier: Some(true),
include_linked_evidence: Some(true),
},
};
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
assert_eq!(reason, Some("thread/epiphany/context"));
}
#[test]
fn thread_epiphany_index_is_marked_experimental() {
let request = ClientRequest::ThreadEpiphanyIndex {

View file

@ -61,7 +61,10 @@ use codex_protocol::protocol::EpiphanyChurnState as CoreEpiphanyChurnState;
use codex_protocol::protocol::EpiphanyCodeRef as CoreEpiphanyCodeRef;
use codex_protocol::protocol::EpiphanyEvidenceRecord as CoreEpiphanyEvidenceRecord;
use codex_protocol::protocol::EpiphanyGraphCheckpoint as CoreEpiphanyGraphCheckpoint;
use codex_protocol::protocol::EpiphanyGraphEdge as CoreEpiphanyGraphEdge;
use codex_protocol::protocol::EpiphanyGraphFrontier as CoreEpiphanyGraphFrontier;
use codex_protocol::protocol::EpiphanyGraphLink as CoreEpiphanyGraphLink;
use codex_protocol::protocol::EpiphanyGraphNode as CoreEpiphanyGraphNode;
use codex_protocol::protocol::EpiphanyGraphs as CoreEpiphanyGraphs;
use codex_protocol::protocol::EpiphanyInvariant as CoreEpiphanyInvariant;
use codex_protocol::protocol::EpiphanyModeState as CoreEpiphanyModeState;
@ -3985,6 +3988,7 @@ pub enum ThreadEpiphanySceneAction {
Index,
Retrieve,
Distill,
Context,
Jobs,
Propose,
Promote,
@ -4172,6 +4176,107 @@ pub struct ThreadEpiphanyJob {
pub linked_graph_node_ids: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyContextParams {
pub thread_id: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub graph_node_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub graph_edge_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub observation_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub evidence_ids: Vec<String>,
/// Defaults to true so clients can request the current working slice with
/// only a thread id.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub include_active_frontier: Option<bool>,
/// Defaults to true so selected observations bring their evidence anchors.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub include_linked_evidence: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyContextResponse {
pub thread_id: String,
pub source: ThreadEpiphanyContextSource,
pub state_status: ThreadEpiphanyContextStateStatus,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub state_revision: Option<u64>,
pub context: ThreadEpiphanyContext,
pub missing: ThreadEpiphanyContextMissing,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanyContextSource {
Stored,
Live,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanyContextStateStatus {
Missing,
Ready,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyContext {
pub graph: ThreadEpiphanyGraphContext,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub frontier: Option<CoreEpiphanyGraphFrontier>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub checkpoint: Option<CoreEpiphanyGraphCheckpoint>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub observations: Vec<CoreEpiphanyObservation>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub evidence: Vec<CoreEpiphanyEvidenceRecord>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyGraphContext {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub architecture_nodes: Vec<CoreEpiphanyGraphNode>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub architecture_edges: Vec<CoreEpiphanyGraphEdge>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub dataflow_nodes: Vec<CoreEpiphanyGraphNode>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub dataflow_edges: Vec<CoreEpiphanyGraphEdge>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub links: Vec<CoreEpiphanyGraphLink>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyContextMissing {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub graph_node_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub graph_edge_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub observation_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub evidence_ids: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]