Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(auto-harness): refine pipeline final stage status

ray_le4f6a4a475bda
diff --git a/jiuwenswarm/agents/harness/common/auto_harness/scheduler.py b/jiuwenswarm/agents/harness/common/auto_harness/scheduler.py
index af42049d71..0f72e3203b 100644
--- a/jiuwenswarm/agents/harness/common/auto_harness/scheduler.py
+++ b/jiuwenswarm/agents/harness/common/auto_harness/scheduler.py
@@ -23,9 +23,6 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
-_TOLERANT_STAGES = {"build_verify"}
-
-
def _sync_append_log(log_path: Path, line: str) -> None:
"""Synchronous append+flush for log file — called via asyncio.to_thread."""
with log_path.open("a", encoding="utf-8") as f:
@@ -37,13 +34,13 @@ def _determine_pipeline_status_from_log(log_path) -> dict[str, Any]:
"""Parse a JSON Lines log file and determine whether the pipeline succeeded.
Rules:
- - Each stage has a harness.stage_result event with scope="" (stage-level).
- - All stages except those in _TOLERANT_STAGES must have status="success".
- - Tolerant stages (build_verify) accept either "success" or "failed".
+ - meta_evolve_pipeline: every stage must have harness.stage_result with status="success".
+ - extended_evolve_pipeline: build_verify must appear (any status), activate must be "success".
Returns:
{"failed": bool, "error": str}
"""
+ pipeline_type: str = ""
pipeline_stages: list[str] = []
stage_results: dict[str, str] = {}
@@ -56,6 +53,7 @@ def _determine_pipeline_status_from_log(log_path) -> dict[str, Any]:
continue
if entry.get("event_type") == "harness.message" and entry.get("stages") and entry.get("pipeline"):
pipeline_stages = [s.get("slot") for s in entry["stages"]]
+ pipeline_type = entry.get("pipeline", "")
if entry.get("event_type") == "harness.stage_result" and not entry.get("scope"):
slot = entry.get("stage")
status = entry.get("status")
@@ -65,10 +63,15 @@ def _determine_pipeline_status_from_log(log_path) -> dict[str, Any]:
logger.warning("[Scheduler] Failed to read log %s: %s", log_path, exc)
return {"failed": False, "error": ""}
+ if pipeline_type == "extended_evolve_pipeline":
+ if "build_verify" not in stage_results:
+ return {"failed": True, "error": "Stage 'build_verify' not appeared"}
+ if stage_results.get("activate") != "success":
+ return {"failed": True, "error": f"Stage 'activate' {stage_results.get('activate', 'not completed')}"}
+ return {"failed": False, "error": ""}
+
for slot in pipeline_stages:
result = stage_results.get(slot)
- if slot in _TOLERANT_STAGES:
- continue
if result != "success":
return {
"failed": True,
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/auto-harness.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/auto-harness.ts
index 6e4c0e2056..143f651c71 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/auto-harness.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/auto-harness.ts
@@ -1445,6 +1445,10 @@ interface ParseState {
gapCount: number;
ciFixCount: number;
hasFailure: boolean; // Track if any stage or extension failed during execution
+ // Track stages that have reported success via harness.stage_result
+ stagesWithSuccessResult: Set<string>;
+ // Track stages that have appeared (reported any result, including running/success/failed)
+ stagesAppeared: Set<string>;
}
function parseAndAggregateLogs(
@@ -1462,6 +1466,10 @@ function parseAndAggregateLogs(
let gapCount = initialState?.gapCount ?? 0;
let ciFixCount = initialState?.ciFixCount ?? 0;
let hasFailure = initialState?.hasFailure ?? false; // Track if any stage/extension failed
+ // Track stages that have explicitly reported success via harness.stage_result (scope="")
+ const stagesWithSuccessResult: Set<string> = initialState?.stagesWithSuccessResult ?? new Set<string>();
+ // Track stages that have appeared (reported any result, including running/success/failed)
+ const stagesAppeared: Set<string> = initialState?.stagesAppeared ?? new Set<string>();
// Note: pipeline type is determined dynamically in the loop when pipelineInfo is set
@@ -1625,6 +1633,14 @@ function parseAndAggregateLogs(
if (log.stage && !scope && (log.status === 'success' || log.status === 'failed') && !completedStages.includes(log.stage)) {
completedStages.push(log.stage);
if (log.status === 'failed') hasFailure = true;
+ // Track stages that have explicitly reported success (scope="", status="success")
+ if (log.status === 'success') {
+ stagesWithSuccessResult.add(log.stage);
+ }
+ }
+ // Track all stages that have appeared (any status including running)
+ if (log.stage && !scope) {
+ stagesAppeared.add(log.stage);
}
// Track current running stage (from any scope="" event)
if (log.stage && !scope && log.stage !== currentStage) {
@@ -1706,9 +1722,21 @@ function parseAndAggregateLogs(
const pipelineType = pipelineInfo?.pipeline || log.pipeline || "";
if (pipelineType === "extended_evolve_pipeline") {
- finalStatus = completedStages.includes("activate") ? "success" : "failed";
+ // Rule: build_verify just needs to appear (presence check), check if activate has success result
+ // activate stage must have success status for the pipeline to be successful
+ const hasBuildVerifyAppeared = stagesAppeared.has('build_verify');
+ const hasActivateSuccess = stagesWithSuccessResult.has('activate');
+ finalStatus = hasBuildVerifyAppeared && hasActivateSuccess ? "success" : "failed";
+ } else if (pipelineType === "meta_evolve_pipeline") {
+ // Rule: every stage must have harness.stage_result with success status
+ // Get all expected stages from pipelineInfo
+ const expectedStages = pipelineInfo?.stages?.map(s => s.slot) || [];
+ // Check if all expected stages have reported success
+ const allStagesSuccessful = expectedStages.length > 0 &&
+ expectedStages.every(stage => stagesWithSuccessResult.has(stage));
+ finalStatus = allStagesSuccessful && !hasFailure ? "success" : "failed";
} else {
- // For other pipelines (meta_evolve_pipeline etc): any failure means task failed
+ // For other pipelines: any failure means task failed
finalStatus = hasFailure ? "failed" : (log.status || "success");
}
@@ -1768,7 +1796,7 @@ function parseAndAggregateLogs(
}
}
- return { sections, state: { pipelineInfo, completedStages, currentStage, extensionOrder, extensionsByName, gapCount, ciFixCount, hasFailure } };
+ return { sections, state: { pipelineInfo, completedStages, currentStage, extensionOrder, extensionsByName, gapCount, ciFixCount, hasFailure, stagesWithSuccessResult, stagesAppeared } };
}
// Format log section for history display (detailed with colors)