mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-11-28 23:59:25 +00:00
Every run executes on Petri, so the in-process legacy executor goes: `fabro-core` and, in `fabro-workflow`, the handlers, lifecycle, pipeline execution, routing, retry, conditions, node handlers, steering, agent memory, artifacts, checkpoints, command log, and the `start`, `resume`, `retry`, `fork`, `rewind` and `timeline` operations. The two are deleted together because the engine half of `fabro-workflow` was the only user of `fabro-core` and `fabro-core` the only runtime of that half; neither compiles without the other. Kept in `fabro-workflow`, narrowed: the parse/transform/validate/persist pipeline and `create`, `archive`, `validate` (workflow definitions still come from DOT and settings); the run tools (`run_tools`, moved from `handler/llm/fabro_tools.rs`) for Ask Fabro, `fabro exec` and Petri's host tools; the pull request pipeline (`pull_request`, moved from `pipeline/`, for the step 0 port); Run Files' diff helpers in `sandbox_git`; `git_identity`, `usage_rollup`, `run_status`, `run_materialization`, `web_search` and `workflow_bundle`. Server: `RegistryFactoryOverride` becomes `execute_in_process`; `RunAnswerTransport::InProcess` carries only the interviewer; the interrupt endpoint answers 501 `interrupt_unsupported` and every pair endpoint 501 `pair_unsupported` (status lists none); rewind, fork, retry and timeline handlers and routes are removed; the command log is served from the stage output blob; usage rollups accumulate from the settled projection after an in-process run as after a worker exit. Ported while here: - `materialize_admitted_run` materializes the goal and drops a disabled pull request block, as the legacy materializer did. - A run whose admitted graph has an agent or prompt node is refused at create when no LLM provider is ready (`fabro.model.no_ready_provider`); a workflow of commands and gates needs no model and is admitted. - The projection's question type falls back on the options, as the interview adapter does, so a gate with edge-label options answers as multiple choice. Tests: the server scenarios (lifecycle, run completion, SSE, helpers) run in process on Petri and assert Petri's stage labels and stream names; the reconcile tests assert Petri's relaunch semantics; legacy unit tests of the deleted executor are removed; three server unit tests the removal took with it are restored; the pair fixtures go with the pair feature. Petri test fixtures no longer name `[workflow] engine`. Still red after this commit, all legacy consumers the next steps delete or port: fabro-store's Slate/reducer fixtures and fabro-types legacy JSON tests (step 4); server unit tests over legacy run events (retry endpoints, list_run_events, artifacts, per-event pause/unpause, run history activation, legacy sandbox fixtures) (steps 3-4); CLI tests that parse legacy event envelopes, the legacy `events`/`attach`/`diff`/ `dump`/`inspect` snapshots, `run rewind`/`run fork`, the ACP and git-identity workflow tests, and the runner tests that drive the legacy worker by hand (steps 3-4); the web app's Petri fixtures still carry `engine` (regenerate with `FABRO_CAPTURE_PETRI_FIXTURES` in step 4). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
88 lines
2.9 KiB
Rust
88 lines
2.9 KiB
Rust
use std::time::Duration;
|
|
|
|
use axum::body::Body;
|
|
use axum::http::{Request, StatusCode};
|
|
use http_body_util::BodyExt;
|
|
use tokio::time::timeout;
|
|
use tower::ServiceExt;
|
|
|
|
use crate::helpers::{
|
|
api, checked_response, create_and_start_run_from_intent, minimal_intent_json_with_dry_run,
|
|
test_app_state_with_options, test_app_with_scheduler, test_settings,
|
|
wait_for_run_status_not_in,
|
|
};
|
|
|
|
const SIMPLE_DOT: &str = r#"digraph SSETest {
|
|
graph [goal="Test SSE"]
|
|
start [shape=Mdiamond]
|
|
work [shape=box, prompt="Do work"]
|
|
exit [shape=Msquare]
|
|
start -> work -> exit
|
|
}"#;
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
async fn sse_stream_contains_expected_event_types() {
|
|
let workspace = tempfile::tempdir().unwrap();
|
|
let state = test_app_state_with_options(test_settings(), 5);
|
|
let app = test_app_with_scheduler(state);
|
|
|
|
let run_id = create_and_start_run_from_intent(
|
|
&app,
|
|
minimal_intent_json_with_dry_run(&app, SIMPLE_DOT, workspace.path()).await,
|
|
)
|
|
.await;
|
|
|
|
wait_for_run_status_not_in(&app, &run_id, &["runnable", "starting"]).await;
|
|
|
|
// Replay from the beginning so the assertion does not depend on whether
|
|
// the run advances before the attach request is handled.
|
|
let req = Request::builder()
|
|
.method("GET")
|
|
.uri(api(&format!("/runs/{run_id}/attach?after=0")))
|
|
.body(Body::empty())
|
|
.unwrap();
|
|
let response = checked_response(
|
|
app.clone().oneshot(req).await.unwrap(),
|
|
StatusCode::OK,
|
|
format!("GET /api/v1/runs/{run_id}/attach?after=0"),
|
|
)
|
|
.await;
|
|
|
|
let content_type = response
|
|
.headers()
|
|
.get("content-type")
|
|
.unwrap()
|
|
.to_str()
|
|
.unwrap();
|
|
assert!(content_type.contains("text/event-stream"));
|
|
|
|
// Collect SSE frames with a timeout
|
|
let mut body = response.into_body();
|
|
let mut sse_data = String::new();
|
|
while let Ok(Some(Ok(frame))) = timeout(Duration::from_secs(2), body.frame()).await {
|
|
if let Some(data) = frame.data_ref() {
|
|
sse_data.push_str(&String::from_utf8_lossy(data));
|
|
}
|
|
}
|
|
|
|
// Every frame is one stream item: Petri's events name the stage they
|
|
// belong to, so the run's stages show up as `visit.started`.
|
|
let mut event_types: Vec<String> = Vec::new();
|
|
for line in sse_data.lines() {
|
|
if let Some(json_str) = line.strip_prefix("data:") {
|
|
if let Ok(item) = serde_json::from_str::<serde_json::Value>(json_str.trim()) {
|
|
let name = item["item"]["record"]["body"]["event"]
|
|
.as_str()
|
|
.or_else(|| item["item"]["derived"]["event"].as_str());
|
|
if let Some(name) = name {
|
|
event_types.push(name.to_string());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
assert!(
|
|
event_types.iter().any(|t| t == "visit.started"),
|
|
"should contain stage events, got: {event_types:?}"
|
|
);
|
|
}
|