Add Epiphany investigation checkpoints
This commit is contained in:
parent
e1298e58a9
commit
71ea1ed2ea
17 changed files with 578 additions and 40 deletions
|
|
@ -1646,6 +1646,20 @@ mod tests {
|
|||
shard_count: 1,
|
||||
dirty_path_count: 0,
|
||||
}),
|
||||
investigation_checkpoint: Some(
|
||||
v2::ThreadEpiphanySceneInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-1".to_string(),
|
||||
kind: "slice_planning".to_string(),
|
||||
disposition: codex_protocol::protocol::EpiphanyInvestigationDisposition::ResumeReady,
|
||||
focus: "Keep the durable resume packet visible.".to_string(),
|
||||
summary: Some("Checkpointed the bounded planning slice.".to_string()),
|
||||
next_action: Some("Patch one typed field next.".to_string()),
|
||||
captured_at_turn_id: Some("turn-7".to_string()),
|
||||
open_question_count: 1,
|
||||
code_ref_count: 2,
|
||||
evidence_count: 1,
|
||||
},
|
||||
),
|
||||
observations: v2::ThreadEpiphanySceneRecords {
|
||||
total_count: 1,
|
||||
latest: vec![v2::ThreadEpiphanySceneRecord {
|
||||
|
|
@ -1724,6 +1738,18 @@ mod tests {
|
|||
"shardCount": 1,
|
||||
"dirtyPathCount": 0
|
||||
},
|
||||
"investigationCheckpoint": {
|
||||
"checkpointId": "ix-1",
|
||||
"kind": "slice_planning",
|
||||
"disposition": "resume_ready",
|
||||
"focus": "Keep the durable resume packet visible.",
|
||||
"summary": "Checkpointed the bounded planning slice.",
|
||||
"nextAction": "Patch one typed field next.",
|
||||
"capturedAtTurnId": "turn-7",
|
||||
"openQuestionCount": 1,
|
||||
"codeRefCount": 2,
|
||||
"evidenceCount": 1
|
||||
},
|
||||
"observations": {
|
||||
"totalCount": 1,
|
||||
"latest": [
|
||||
|
|
@ -1851,6 +1877,17 @@ mod tests {
|
|||
..Default::default()
|
||||
}),
|
||||
checkpoint: None,
|
||||
investigation_checkpoint: Some(
|
||||
codex_protocol::protocol::EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-1".to_string(),
|
||||
kind: "source_gathering".to_string(),
|
||||
focus: "Audit the compaction seam.".to_string(),
|
||||
next_action: Some(
|
||||
"Re-gather source if this packet is stale.".to_string(),
|
||||
),
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
observations: vec![codex_protocol::protocol::EpiphanyObservation {
|
||||
id: "obs-1".to_string(),
|
||||
summary: "Context shard is read-only.".to_string(),
|
||||
|
|
@ -1906,6 +1943,13 @@ mod tests {
|
|||
"frontier": {
|
||||
"active_node_ids": ["state-spine"]
|
||||
},
|
||||
"investigationCheckpoint": {
|
||||
"checkpoint_id": "ix-1",
|
||||
"kind": "source_gathering",
|
||||
"disposition": "resume_ready",
|
||||
"focus": "Audit the compaction seam.",
|
||||
"next_action": "Re-gather source if this packet is stale."
|
||||
},
|
||||
"observations": [
|
||||
{
|
||||
"id": "obs-1",
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ 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::EpiphanyInvestigationCheckpoint as CoreEpiphanyInvestigationCheckpoint;
|
||||
use codex_protocol::protocol::EpiphanyInvestigationDisposition as CoreEpiphanyInvestigationDisposition;
|
||||
use codex_protocol::protocol::EpiphanyModeState as CoreEpiphanyModeState;
|
||||
use codex_protocol::protocol::EpiphanyObservation as CoreEpiphanyObservation;
|
||||
use codex_protocol::protocol::EpiphanyRetrievalStatus as CoreEpiphanyRetrievalStatus;
|
||||
|
|
@ -3956,6 +3958,9 @@ pub struct ThreadEpiphanyScene {
|
|||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub retrieval: Option<ThreadEpiphanySceneRetrieval>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub investigation_checkpoint: Option<ThreadEpiphanySceneInvestigationCheckpoint>,
|
||||
pub observations: ThreadEpiphanySceneRecords,
|
||||
pub evidence: ThreadEpiphanySceneRecords,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
|
|
@ -4062,6 +4067,28 @@ pub struct ThreadEpiphanySceneRetrieval {
|
|||
pub dirty_path_count: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanySceneInvestigationCheckpoint {
|
||||
pub checkpoint_id: String,
|
||||
pub kind: String,
|
||||
pub disposition: CoreEpiphanyInvestigationDisposition,
|
||||
pub focus: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub summary: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub next_action: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub captured_at_turn_id: Option<String>,
|
||||
pub open_question_count: u32,
|
||||
pub code_ref_count: u32,
|
||||
pub evidence_count: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
@ -4242,6 +4269,9 @@ pub struct ThreadEpiphanyContext {
|
|||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub checkpoint: Option<CoreEpiphanyGraphCheckpoint>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub investigation_checkpoint: Option<CoreEpiphanyInvestigationCheckpoint>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub observations: Vec<CoreEpiphanyObservation>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
|
|
@ -4480,6 +4510,9 @@ pub struct ThreadEpiphanyUpdatePatch {
|
|||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub scratch: Option<CoreEpiphanyScratchPad>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub investigation_checkpoint: Option<CoreEpiphanyInvestigationCheckpoint>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub observations: Vec<CoreEpiphanyObservation>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
|
|
@ -4532,6 +4565,7 @@ pub enum ThreadEpiphanyStateUpdatedField {
|
|||
GraphFrontier,
|
||||
GraphCheckpoint,
|
||||
Scratch,
|
||||
InvestigationCheckpoint,
|
||||
Observations,
|
||||
Evidence,
|
||||
Churn,
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ use codex_app_server_protocol::ThreadEpiphanyScene;
|
|||
use codex_app_server_protocol::ThreadEpiphanySceneAction;
|
||||
use codex_app_server_protocol::ThreadEpiphanySceneChurn;
|
||||
use codex_app_server_protocol::ThreadEpiphanySceneGraph;
|
||||
use codex_app_server_protocol::ThreadEpiphanySceneInvestigationCheckpoint;
|
||||
use codex_app_server_protocol::ThreadEpiphanySceneParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanySceneRecord;
|
||||
use codex_app_server_protocol::ThreadEpiphanySceneRecords;
|
||||
|
|
@ -4602,6 +4603,7 @@ impl CodexMessageProcessor {
|
|||
graphs: patch.graphs.clone(),
|
||||
graph_frontier: patch.graph_frontier.clone(),
|
||||
graph_checkpoint: patch.graph_checkpoint.clone(),
|
||||
investigation_checkpoint: patch.investigation_checkpoint.clone(),
|
||||
churn: patch.churn.clone(),
|
||||
observations: patch.observations.clone(),
|
||||
evidence: patch.evidence.clone(),
|
||||
|
|
@ -4636,6 +4638,7 @@ impl CodexMessageProcessor {
|
|||
graph_frontier: patch.graph_frontier,
|
||||
graph_checkpoint: patch.graph_checkpoint,
|
||||
scratch: patch.scratch,
|
||||
investigation_checkpoint: patch.investigation_checkpoint,
|
||||
observations: patch.observations,
|
||||
evidence,
|
||||
churn: patch.churn,
|
||||
|
|
@ -4723,6 +4726,7 @@ impl CodexMessageProcessor {
|
|||
graph_frontier: patch.graph_frontier,
|
||||
graph_checkpoint: patch.graph_checkpoint,
|
||||
scratch: patch.scratch,
|
||||
investigation_checkpoint: patch.investigation_checkpoint,
|
||||
observations: patch.observations,
|
||||
evidence: patch.evidence,
|
||||
churn: patch.churn,
|
||||
|
|
@ -10707,6 +10711,7 @@ fn map_epiphany_scene(state: Option<&EpiphanyThreadState>, loaded: bool) -> Thre
|
|||
invariant_status_counts: Vec::new(),
|
||||
graph: ThreadEpiphanySceneGraph::default(),
|
||||
retrieval: None,
|
||||
investigation_checkpoint: None,
|
||||
observations: ThreadEpiphanySceneRecords::default(),
|
||||
evidence: ThreadEpiphanySceneRecords::default(),
|
||||
churn: None,
|
||||
|
|
@ -10741,6 +10746,20 @@ fn map_epiphany_scene(state: Option<&EpiphanyThreadState>, loaded: bool) -> Thre
|
|||
shard_count: retrieval.shards.len() as u32,
|
||||
dirty_path_count: retrieval.dirty_paths.len() as u32,
|
||||
}),
|
||||
investigation_checkpoint: state.investigation_checkpoint.as_ref().map(|checkpoint| {
|
||||
ThreadEpiphanySceneInvestigationCheckpoint {
|
||||
checkpoint_id: checkpoint.checkpoint_id.clone(),
|
||||
kind: checkpoint.kind.clone(),
|
||||
disposition: checkpoint.disposition,
|
||||
focus: checkpoint.focus.clone(),
|
||||
summary: checkpoint.summary.clone(),
|
||||
next_action: checkpoint.next_action.clone(),
|
||||
captured_at_turn_id: checkpoint.captured_at_turn_id.clone(),
|
||||
open_question_count: checkpoint.open_questions.len() as u32,
|
||||
code_ref_count: checkpoint.code_refs.len() as u32,
|
||||
evidence_count: checkpoint.evidence_ids.len() as u32,
|
||||
}
|
||||
}),
|
||||
observations: ThreadEpiphanySceneRecords {
|
||||
total_count: state.observations.len() as u32,
|
||||
latest: state
|
||||
|
|
@ -11073,6 +11092,7 @@ fn map_epiphany_context(
|
|||
.then(|| state.graph_frontier.clone())
|
||||
.flatten(),
|
||||
checkpoint: state.graph_checkpoint.clone(),
|
||||
investigation_checkpoint: state.investigation_checkpoint.clone(),
|
||||
observations,
|
||||
evidence,
|
||||
},
|
||||
|
|
@ -11398,6 +11418,7 @@ fn thread_epiphany_patch_has_state_replacements(patch: &ThreadEpiphanyUpdatePatc
|
|||
|| patch.graph_frontier.is_some()
|
||||
|| patch.graph_checkpoint.is_some()
|
||||
|| patch.scratch.is_some()
|
||||
|| patch.investigation_checkpoint.is_some()
|
||||
|| patch.churn.is_some()
|
||||
|| patch.mode.is_some()
|
||||
}
|
||||
|
|
@ -11496,6 +11517,9 @@ fn epiphany_update_patch_changed_fields(
|
|||
if patch.scratch.is_some() {
|
||||
fields.push(ThreadEpiphanyStateUpdatedField::Scratch);
|
||||
}
|
||||
if patch.investigation_checkpoint.is_some() {
|
||||
fields.push(ThreadEpiphanyStateUpdatedField::InvestigationCheckpoint);
|
||||
}
|
||||
if !patch.observations.is_empty() {
|
||||
fields.push(ThreadEpiphanyStateUpdatedField::Observations);
|
||||
}
|
||||
|
|
@ -12868,6 +12892,29 @@ mod tests {
|
|||
}],
|
||||
..Default::default()
|
||||
}),
|
||||
investigation_checkpoint: Some(
|
||||
codex_protocol::protocol::EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-5".to_string(),
|
||||
kind: "slice_planning".to_string(),
|
||||
disposition:
|
||||
codex_protocol::protocol::EpiphanyInvestigationDisposition::ResumeReady,
|
||||
focus: "Keep the durable planning packet visible.".to_string(),
|
||||
summary: Some("Checkpointed the next bounded slice.".to_string()),
|
||||
next_action: Some("Patch the typed state writer next.".to_string()),
|
||||
captured_at_turn_id: Some("turn-5".to_string()),
|
||||
open_questions: vec![
|
||||
"Should scene and context both surface this?".to_string(),
|
||||
],
|
||||
evidence_ids: vec!["ev-scene".to_string()],
|
||||
code_refs: vec![codex_protocol::protocol::EpiphanyCodeRef {
|
||||
path: test_path_buf("/repo/app-server/src/codex_message_processor.rs"),
|
||||
start_line: Some(10692),
|
||||
end_line: Some(10811),
|
||||
symbol: Some("map_epiphany_scene".to_string()),
|
||||
note: None,
|
||||
}],
|
||||
},
|
||||
),
|
||||
observations: vec![codex_protocol::protocol::EpiphanyObservation {
|
||||
id: "obs-scene".to_string(),
|
||||
summary: "Scene is derived".to_string(),
|
||||
|
|
@ -12920,6 +12967,13 @@ mod tests {
|
|||
scene.retrieval.as_ref().and_then(|r| r.indexed_chunk_count),
|
||||
Some(8)
|
||||
);
|
||||
assert_eq!(
|
||||
scene
|
||||
.investigation_checkpoint
|
||||
.as_ref()
|
||||
.map(|checkpoint| checkpoint.checkpoint_id.as_str()),
|
||||
Some("ix-5")
|
||||
);
|
||||
assert_eq!(scene.observations.total_count, 1);
|
||||
assert_eq!(scene.evidence.latest[0].id, "ev-scene");
|
||||
assert_eq!(
|
||||
|
|
@ -13121,6 +13175,18 @@ mod tests {
|
|||
summary: Some("Context shard checkpoint".to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
investigation_checkpoint: Some(
|
||||
codex_protocol::protocol::EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-context".to_string(),
|
||||
kind: "source_gathering".to_string(),
|
||||
focus: "Trace the exact reflection seam.".to_string(),
|
||||
next_action: Some(
|
||||
"Re-gather source before editing if this goes stale.".to_string(),
|
||||
),
|
||||
evidence_ids: vec!["ev-linked".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
observations: vec![codex_protocol::protocol::EpiphanyObservation {
|
||||
id: "obs-1".to_string(),
|
||||
summary: "Observation carries linked evidence.".to_string(),
|
||||
|
|
@ -13196,6 +13262,13 @@ mod tests {
|
|||
.map(|checkpoint| checkpoint.checkpoint_id.as_str()),
|
||||
Some("ck-context")
|
||||
);
|
||||
assert_eq!(
|
||||
context
|
||||
.investigation_checkpoint
|
||||
.as_ref()
|
||||
.map(|checkpoint| checkpoint.checkpoint_id.as_str()),
|
||||
Some("ix-context")
|
||||
);
|
||||
assert_eq!(
|
||||
context
|
||||
.observations
|
||||
|
|
@ -13331,6 +13404,7 @@ mod tests {
|
|||
objective: Some("Keep the event readable".to_string()),
|
||||
graphs: Some(Default::default()),
|
||||
graph_frontier: Some(Default::default()),
|
||||
investigation_checkpoint: Some(Default::default()),
|
||||
observations: vec![Default::default()],
|
||||
evidence: vec![Default::default()],
|
||||
churn: Some(Default::default()),
|
||||
|
|
@ -13343,6 +13417,7 @@ mod tests {
|
|||
ThreadEpiphanyStateUpdatedField::Objective,
|
||||
ThreadEpiphanyStateUpdatedField::Graphs,
|
||||
ThreadEpiphanyStateUpdatedField::GraphFrontier,
|
||||
ThreadEpiphanyStateUpdatedField::InvestigationCheckpoint,
|
||||
ThreadEpiphanyStateUpdatedField::Observations,
|
||||
ThreadEpiphanyStateUpdatedField::Evidence,
|
||||
ThreadEpiphanyStateUpdatedField::Churn,
|
||||
|
|
|
|||
69
vendor/codex/codex-rs/core/src/codex_thread.rs
vendored
69
vendor/codex/codex-rs/core/src/codex_thread.rs
vendored
|
|
@ -31,6 +31,7 @@ use codex_protocol::protocol::EpiphanyGraphCheckpoint;
|
|||
use codex_protocol::protocol::EpiphanyGraphFrontier;
|
||||
use codex_protocol::protocol::EpiphanyGraphs;
|
||||
use codex_protocol::protocol::EpiphanyInvariant;
|
||||
use codex_protocol::protocol::EpiphanyInvestigationCheckpoint;
|
||||
use codex_protocol::protocol::EpiphanyModeState;
|
||||
use codex_protocol::protocol::EpiphanyObservation;
|
||||
use codex_protocol::protocol::EpiphanyRetrievalState;
|
||||
|
|
@ -110,6 +111,7 @@ pub struct EpiphanyStateUpdate {
|
|||
pub graph_frontier: Option<EpiphanyGraphFrontier>,
|
||||
pub graph_checkpoint: Option<EpiphanyGraphCheckpoint>,
|
||||
pub scratch: Option<EpiphanyScratchPad>,
|
||||
pub investigation_checkpoint: Option<EpiphanyInvestigationCheckpoint>,
|
||||
pub observations: Vec<EpiphanyObservation>,
|
||||
pub evidence: Vec<EpiphanyEvidenceRecord>,
|
||||
pub churn: Option<EpiphanyChurnState>,
|
||||
|
|
@ -126,6 +128,7 @@ impl EpiphanyStateUpdate {
|
|||
&& self.graph_frontier.is_none()
|
||||
&& self.graph_checkpoint.is_none()
|
||||
&& self.scratch.is_none()
|
||||
&& self.investigation_checkpoint.is_none()
|
||||
&& self.observations.is_empty()
|
||||
&& self.evidence.is_empty()
|
||||
&& self.churn.is_none()
|
||||
|
|
@ -631,6 +634,17 @@ fn epiphany_state_update_validation_errors(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(checkpoint) = update.investigation_checkpoint.as_ref() {
|
||||
for evidence_id in &checkpoint.evidence_ids {
|
||||
if !known_evidence_ids.contains(evidence_id.as_str()) {
|
||||
errors.push(format!(
|
||||
"investigation checkpoint cites missing evidence id {:?}",
|
||||
evidence_id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
errors.extend(epiphany_state_replacement_validation_errors(state, update));
|
||||
errors
|
||||
}
|
||||
|
|
@ -643,6 +657,16 @@ fn epiphany_state_replacement_validation_errors(
|
|||
let validates_graph_target = update.graphs.is_some()
|
||||
|| update.graph_frontier.is_some()
|
||||
|| update.graph_checkpoint.is_some();
|
||||
let mut known_evidence_ids: HashSet<&str> = state
|
||||
.recent_evidence
|
||||
.iter()
|
||||
.filter_map(|evidence| nonempty_id(&evidence.id))
|
||||
.collect();
|
||||
for evidence in &update.evidence {
|
||||
if let Some(id) = nonempty_id(&evidence.id) {
|
||||
known_evidence_ids.insert(id);
|
||||
}
|
||||
}
|
||||
|
||||
validate_state_replacement_patch(EpiphanyStateReplacementValidationInput {
|
||||
active_subgoal_id: update.active_subgoal_id.as_deref(),
|
||||
|
|
@ -662,6 +686,8 @@ fn epiphany_state_replacement_validation_errors(
|
|||
},
|
||||
graph_frontier: update.graph_frontier.as_ref(),
|
||||
graph_checkpoint: update.graph_checkpoint.as_ref(),
|
||||
investigation_checkpoint: update.investigation_checkpoint.as_ref(),
|
||||
available_evidence_ids: Some(&known_evidence_ids),
|
||||
churn: update.churn.as_ref(),
|
||||
})
|
||||
}
|
||||
|
|
@ -705,6 +731,9 @@ fn apply_epiphany_state_update(
|
|||
if let Some(scratch) = update.scratch {
|
||||
state.scratch = Some(scratch);
|
||||
}
|
||||
if let Some(checkpoint) = update.investigation_checkpoint {
|
||||
state.investigation_checkpoint = Some(checkpoint);
|
||||
}
|
||||
if let Some(churn) = update.churn {
|
||||
state.churn = Some(churn);
|
||||
}
|
||||
|
|
@ -771,6 +800,15 @@ mod epiphany_update_tests {
|
|||
&mut state,
|
||||
EpiphanyStateUpdate {
|
||||
objective: Some("Keep the map honest".to_string()),
|
||||
investigation_checkpoint: Some(EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-1".to_string(),
|
||||
kind: "slice_planning".to_string(),
|
||||
focus: "Keep the durable packet small and explicit.".to_string(),
|
||||
next_action: Some(
|
||||
"Resume from the packet instead of the ghost transcript.".to_string(),
|
||||
),
|
||||
..Default::default()
|
||||
}),
|
||||
evidence: vec![EpiphanyEvidenceRecord {
|
||||
id: "new-evidence".to_string(),
|
||||
kind: "verification".to_string(),
|
||||
|
|
@ -791,6 +829,13 @@ mod epiphany_update_tests {
|
|||
assert_eq!(state.revision, 4);
|
||||
assert_eq!(state.objective.as_deref(), Some("Keep the map honest"));
|
||||
assert_eq!(state.last_updated_turn_id.as_deref(), Some("turn-1"));
|
||||
assert_eq!(
|
||||
state
|
||||
.investigation_checkpoint
|
||||
.as_ref()
|
||||
.map(|checkpoint| checkpoint.checkpoint_id.as_str()),
|
||||
Some("ix-1")
|
||||
);
|
||||
assert_eq!(state.recent_evidence[0].id, "new-evidence");
|
||||
assert_eq!(state.recent_evidence[1].id, "old-evidence");
|
||||
assert_eq!(
|
||||
|
|
@ -929,6 +974,30 @@ mod epiphany_update_tests {
|
|||
.any(|error| error.contains("graph frontier references missing node"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validate_epiphany_state_update_rejects_investigation_checkpoint_with_missing_evidence() {
|
||||
let update = EpiphanyStateUpdate {
|
||||
investigation_checkpoint: Some(EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-missing".to_string(),
|
||||
kind: "source_gathering".to_string(),
|
||||
focus: "Trace the compaction seam.".to_string(),
|
||||
next_action: Some("Re-gather source before implementation.".to_string()),
|
||||
evidence_ids: vec!["ev-missing".to_string()],
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let errors =
|
||||
epiphany_state_update_validation_errors(&EpiphanyThreadState::default(), &update);
|
||||
|
||||
assert!(
|
||||
errors
|
||||
.iter()
|
||||
.any(|error| error.contains("investigation checkpoint cites missing evidence id"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn pending_message_input_item(message: &ResponseItem) -> CodexResult<ResponseInputItem> {
|
||||
|
|
|
|||
|
|
@ -336,6 +336,7 @@ fn sample_epiphany_state_for_prompt() -> EpiphanyThreadState {
|
|||
open_question_ids: vec!["q-boundary".to_string()],
|
||||
open_gap_ids: vec!["gap-resume-proof".to_string()],
|
||||
}),
|
||||
investigation_checkpoint: None,
|
||||
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()),
|
||||
|
|
|
|||
38
vendor/codex/codex-rs/protocol/src/protocol.rs
vendored
38
vendor/codex/codex-rs/protocol/src/protocol.rs
vendored
|
|
@ -3017,6 +3017,9 @@ pub struct EpiphanyThreadState {
|
|||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "EpiphanyScratchPad | null")]
|
||||
pub scratch: Option<EpiphanyScratchPad>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "EpiphanyInvestigationCheckpoint | null")]
|
||||
pub investigation_checkpoint: Option<EpiphanyInvestigationCheckpoint>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[ts(type = "Array<EpiphanyObservation>")]
|
||||
pub observations: Vec<EpiphanyObservation>,
|
||||
|
|
@ -3258,6 +3261,41 @@ pub struct EpiphanyScratchPad {
|
|||
pub notes: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(rename_all = "snake_case")]
|
||||
pub enum EpiphanyInvestigationDisposition {
|
||||
#[default]
|
||||
ResumeReady,
|
||||
RegatherRequired,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
pub struct EpiphanyInvestigationCheckpoint {
|
||||
pub checkpoint_id: String,
|
||||
pub kind: String,
|
||||
pub disposition: EpiphanyInvestigationDisposition,
|
||||
pub focus: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "string | null")]
|
||||
pub summary: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "string | null")]
|
||||
pub next_action: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "string | null")]
|
||||
pub captured_at_turn_id: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[ts(type = "Array<string>")]
|
||||
pub open_questions: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[ts(type = "Array<EpiphanyCodeRef>")]
|
||||
pub code_refs: Vec<EpiphanyCodeRef>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
#[ts(type = "Array<string>")]
|
||||
pub evidence_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
pub struct EpiphanyObservation {
|
||||
pub id: String,
|
||||
|
|
|
|||
Reference in a new issue