-
Notifications
You must be signed in to change notification settings - Fork 1
feat(hooks): deterministic pipeline enforcement via CSA:NEXT_STEP directives #538
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
Changes from all commits
a0232e3
5d0f1e4
1c3c9ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ use tracing::{error, info, warn}; | |||||||||||||||
| use csa_config::ProjectConfig; | ||||||||||||||||
| use csa_core::types::ToolName; | ||||||||||||||||
| use csa_executor::ModelSpec; | ||||||||||||||||
| use csa_hooks::format_next_step_directive; | ||||||||||||||||
| use weave::compiler::{ExecutionPlan, FailAction, PlanStep}; | ||||||||||||||||
|
|
||||||||||||||||
| use super::plan_cmd_exec::{ | ||||||||||||||||
|
|
@@ -267,6 +268,21 @@ pub(super) async fn execute_plan_with_journal( | |||||||||||||||
| persist_plan_journal(path, run_ctx.journal)?; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // Emit CSA:NEXT_STEP directive for pipeline chaining. | ||||||||||||||||
| // On success: point to the next step in the plan. | ||||||||||||||||
| // On failure: no directive (pipeline stops on abort). | ||||||||||||||||
| if !is_failure | ||||||||||||||||
| && !result.skipped | ||||||||||||||||
| && let Some(next_step) = find_next_step(step, &plan.steps) | ||||||||||||||||
| { | ||||||||||||||||
| let cmd = format!( | ||||||||||||||||
| "csa plan run --step {} \"{}\"", | ||||||||||||||||
| next_step.id, next_step.title | ||||||||||||||||
| ); | ||||||||||||||||
| let required = matches!(next_step.on_fail, FailAction::Abort); | ||||||||||||||||
| eprintln!("{}", format_next_step_directive(&cmd, required)); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // Abort on failure when: on_fail=abort, or retry exhausted (retries | ||||||||||||||||
| // already happened inside execute_step; reaching here means all failed), | ||||||||||||||||
| // or delegate (unsupported in v1 — treated as abort). | ||||||||||||||||
|
|
@@ -615,3 +631,11 @@ pub(crate) fn should_inject_assignment_markers(step: &PlanStep) -> bool { | |||||||||||||||
| pub(crate) fn is_assignment_marker_key(key: &str) -> bool { | ||||||||||||||||
| validate_variable_name(key).is_ok() | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /// Find the next step in the plan after the current step. | ||||||||||||||||
| /// | ||||||||||||||||
| /// Returns the first step with an ID greater than the current step's ID, | ||||||||||||||||
| /// which is the sequential successor in a linear workflow. | ||||||||||||||||
| fn find_next_step<'a>(current: &PlanStep, steps: &'a [PlanStep]) -> Option<&'a PlanStep> { | ||||||||||||||||
| steps.iter().find(|s| s.id > current.id) | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+639
to
+641
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. The current implementation of
Suggested change
|
||||||||||||||||
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.
The plan path builds
cmdwith an embedded quoted title ("{}"), thenformat_next_step_directivewraps that whole command incmd="..."again. Because the parser stops quoted values at the first"inparse_next_step_directive, emitted directives get truncated/malformed whenever a title is present, so downstream consumers cannot reliably parse the intended next command (and may missrequired=true).Useful? React with 👍 / 👎.