-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(whaleflow): add serializable run result records #2815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Hmbown
merged 2 commits into
codex/v0.9.0-stewardship
from
codex/v090-whaleflow-results-ir
Jun 6, 2026
+136
−4
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,6 +246,63 @@ pub enum IsolationMode { | |
| Worktree, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct BranchResult { | ||
| pub branch_id: String, | ||
| pub task_id: String, | ||
| pub status: WorkflowRunStatus, | ||
| #[serde(default)] | ||
| pub artifacts: Vec<String>, | ||
| #[serde(default)] | ||
| pub notes: Option<String>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct LeafResult { | ||
| pub leaf_id: String, | ||
| pub task_id: String, | ||
| pub status: WorkflowRunStatus, | ||
| #[serde(default)] | ||
| pub output: Option<String>, | ||
|
Comment on lines
+265
to
+266
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| #[serde(default)] | ||
| pub artifacts: Vec<String>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct ControlNodeResult { | ||
| pub node_id: String, | ||
| pub kind: ControlNodeKind, | ||
| pub status: WorkflowRunStatus, | ||
| #[serde(default)] | ||
| pub selected_children: Vec<String>, | ||
| #[serde(default)] | ||
| pub summary: Option<String>, | ||
|
Comment on lines
+278
to
+279
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum WorkflowRunStatus { | ||
| #[default] | ||
| Pending, | ||
| Running, | ||
| Succeeded, | ||
| Failed, | ||
| Cancelled, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum ControlNodeKind { | ||
| BranchSet, | ||
| Leaf, | ||
| Sequence, | ||
| Reduce, | ||
| TeacherReview, | ||
| LoopUntil, | ||
| Cond, | ||
| Expand, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Error)] | ||
| pub enum WorkflowValidationError { | ||
| #[error("{field} must not be empty")] | ||
|
|
@@ -711,4 +768,77 @@ mod tests { | |
| let parsed: WorkflowConfig = serde_json::from_str(&json).expect("parse workflow"); | ||
| assert_eq!(parsed, workflow); | ||
| } | ||
|
|
||
| #[test] | ||
| fn branch_result_serialization() { | ||
| let result = BranchResult { | ||
| branch_id: "discover".to_string(), | ||
| task_id: "scan".to_string(), | ||
| status: WorkflowRunStatus::Succeeded, | ||
| artifacts: vec!["trace://branches/discover".to_string()], | ||
| notes: Some("validated prompt surfaces".to_string()), | ||
| }; | ||
|
|
||
| let json = serde_json::to_string(&result).expect("serialize branch result"); | ||
|
|
||
| assert!(json.contains("\"status\":\"succeeded\"")); | ||
| let parsed: BranchResult = serde_json::from_str(&json).expect("parse branch result"); | ||
| assert_eq!(parsed, result); | ||
|
|
||
| let minimal: BranchResult = | ||
| serde_json::from_str(r#"{"branch_id":"discover","task_id":"scan","status":"pending"}"#) | ||
| .expect("parse minimal branch result"); | ||
| assert!(minimal.artifacts.is_empty()); | ||
| assert_eq!(minimal.notes, None); | ||
| } | ||
|
|
||
| #[test] | ||
| fn leaf_result_serialization() { | ||
| let result = LeafResult { | ||
| leaf_id: "scan-readme".to_string(), | ||
| task_id: "scan".to_string(), | ||
| status: WorkflowRunStatus::Failed, | ||
| output: Some("README needs clearer setup steps".to_string()), | ||
| artifacts: vec!["trace://leaves/scan-readme".to_string()], | ||
| }; | ||
|
|
||
| let json = serde_json::to_string(&result).expect("serialize leaf result"); | ||
|
|
||
| assert!(json.contains("\"status\":\"failed\"")); | ||
| let parsed: LeafResult = serde_json::from_str(&json).expect("parse leaf result"); | ||
| assert_eq!(parsed, result); | ||
|
|
||
| let minimal: LeafResult = serde_json::from_str( | ||
| r#"{"leaf_id":"scan-readme","task_id":"scan","status":"pending"}"#, | ||
| ) | ||
| .expect("parse minimal leaf result"); | ||
| assert_eq!(minimal.output, None); | ||
| assert!(minimal.artifacts.is_empty()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn control_node_result_serialization() { | ||
| let result = ControlNodeResult { | ||
| node_id: "select-fix".to_string(), | ||
| kind: ControlNodeKind::TeacherReview, | ||
| status: WorkflowRunStatus::Running, | ||
| selected_children: vec!["branch-a".to_string(), "branch-c".to_string()], | ||
| summary: Some("teacher review is waiting on verifier evidence".to_string()), | ||
| }; | ||
|
|
||
| let json = serde_json::to_string(&result).expect("serialize control node result"); | ||
|
|
||
| assert!(json.contains("\"kind\":\"teacher_review\"")); | ||
| assert!(json.contains("\"status\":\"running\"")); | ||
| let parsed: ControlNodeResult = | ||
| serde_json::from_str(&json).expect("parse control node result"); | ||
| assert_eq!(parsed, result); | ||
|
|
||
| let minimal: ControlNodeResult = serde_json::from_str( | ||
| r#"{"node_id":"select-fix","kind":"branch_set","status":"pending"}"#, | ||
| ) | ||
| .expect("parse minimal control node result"); | ||
| assert!(minimal.selected_children.is_empty()); | ||
| assert_eq!(minimal.summary, None); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the serialized JSON representation clean and compact (especially for TraceStore storage), consider omitting
Nonefields from serialization using#[serde(skip_serializing_if = "Option::is_none")].