bobbai00 commented on code in PR #6009:
URL: https://github.com/apache/texera/pull/6009#discussion_r4342458925


##########
agent-service/src/agent/tools/result-formatting.ts:
##########
@@ -17,119 +17,42 @@
  * under the License.
  */
 
-import type { OperatorInfo } from "../../types/execution";
-import type { WorkflowState } from "../workflow-state";
-import { formatExecuteOperatorResult, getVisibleResultHeaders } from 
"./tools-utility";
-
-export function formatOperatorResult(operatorId: string, opInfo: OperatorInfo, 
workflowState: WorkflowState): string {
-  if (opInfo.error) {
-    return `[ERROR] ${opInfo.error}`;
+import type { OperatorExecutionSummary } from "../../types/execution";
+import {
+  formatExecuteOperatorResult,
+  formatSampleTuplesAsTsv,
+  getOperatorErrorText,
+  getOperatorWarnings,
+  redactVisualizationPayloads,
+  tupleColumns,
+} from "./tools-utility";
+
+export function formatOperatorResult(operatorId: string, opInfo: 
OperatorExecutionSummary): string {
+  const errorText = getOperatorErrorText(opInfo);
+  if (errorText) {
+    return `[ERROR] ${errorText}`;
   }
 
-  if (!opInfo.result || !Array.isArray(opInfo.result)) {
+  const resultSummary = opInfo.resultSummary;
+  const sampleTuples = resultSummary?.sampleTuples;
+  if (!sampleTuples || !Array.isArray(sampleTuples)) {

Review Comment:
   Done in 5450e20.



##########
agent-service/src/agent/tools/workflow-execution-tools.ts:
##########
@@ -438,7 +382,7 @@ export async function executeOperatorAndFormat(
   operatorId: string,
   options: {
     abortSignal?: AbortSignal;
-    onResult?: (operatorId: string, operatorInfo: OperatorInfo) => void;
+    onResult?: (operatorId: string, operatorInfo: OperatorExecutionSummary) => 
void;
     onResultLegacy?: (operatorId: string, backendStats?: Record<string, 
string>) => void;

Review Comment:
   Removed in dc2a6e0.



##########
agent-service/src/types/execution.ts:
##########
@@ -17,56 +17,118 @@
  * under the License.
  */
 
-interface ConsoleMessage {
-  msgType: string;
-  message: string;
+export enum WorkflowFatalErrorType {
+  COMPILATION_ERROR = "COMPILATION_ERROR",
+  EXECUTION_FAILURE = "EXECUTION_FAILURE",
 }
 
-interface PortShape {
-  portIndex: number;
-  rows: number;
-  columns: number;
+// Canonical agent-service error projection. It follows the engine's
+// workflowruntimestate.proto shape so compile and execution errors share one 
model.
+// Re-exported by api/compile-api.ts.
+export interface WorkflowFatalError {
+  readonly type: Readonly<{ name: WorkflowFatalErrorType }>;
+  readonly timestamp: Readonly<{ seconds: number; nanos: number }>;
+  readonly message: string;
+  readonly details: string;
+  readonly operatorId: string;
+  readonly workerId: string;
 }
 
-export interface OperatorInfo {
-  state: string;
-  inputTuples: number;
-  outputTuples: number;
-  inputPortShapes?: PortShape[];
-  resultMode: string;
-  result?: Record<string, any>[];
-  totalRowCount?: number;
-  displayedRows?: number;
-  truncated?: boolean;
-  consoleLogs?: ConsoleMessage[];
-  error?: string;
-  warnings?: string[];
-  resultStatistics?: Record<string, string>;
+// Lifecycle state of a single operator, as reported by the engine
+// (mirrors the backend's WorkflowAggregatedState string mapping).
+export enum OperatorState {
+  UNINITIALIZED = "Uninitialized",
+  READY = "Ready",
+  RUNNING = "Running",
+  PAUSING = "Pausing",
+  PAUSED = "Paused",
+  RESUMING = "Resuming",
+  COMPLETED = "Completed",
+  FAILED = "Failed",
+  KILLED = "Killed",
+  TERMINATED = "Terminated",
+  UNKNOWN = "Unknown",
 }
 
-export interface SyncExecutionResult {
-  success: boolean;
-  state: string;
-  operators: Record<string, OperatorInfo>;
-  compilationErrors?: Record<string, string>;
-  errors?: string[];
+// Aggregated state of a whole workflow execution: the OperatorState values the
+// engine reports, plus agent-service execution outcomes.
+export enum WorkflowExecutionState {
+  UNINITIALIZED = "Uninitialized",
+  READY = "Ready",
+  RUNNING = "Running",
+  PAUSING = "Pausing",
+  PAUSED = "Paused",
+  RESUMING = "Resuming",
+  COMPLETED = "Completed",
+  FAILED = "Failed",
+  KILLED = "Killed",
+  TERMINATED = "Terminated",
+  UNKNOWN = "Unknown",
+  ERROR = "Error",
+  COMPILATION_FAILED = "CompilationFailed",
 }
 
-/**
- * Wire projection of one operator's execution result, summarized for the
- * client: counts and a small record sample instead of full payloads. Returned
- * by the REST route `GET /agents/:id/operator-results`.
- */
+export enum ConsoleMessageType {
+  PRINT = "PRINT",
+  ERROR = "ERROR",
+  COMMAND = "COMMAND",
+  DEBUGGER = "DEBUGGER",
+}
+
+// A reduced console-message projection. The engine proto also has
+// workerId/timestamp/source; this summary keeps only the fields consumed by 
agent-service.
+export interface ConsoleMessageSummary {
+  readonly msgType: ConsoleMessageType;
+  readonly title: string;
+  readonly message: string;
+}
+
+// A normalized result tuple using the engine Tuple shape: a schema plus 
positional fields.

Review Comment:
   Done in 94579a2.



##########
frontend/src/app/workspace/service/agent/agent.service.ts:
##########
@@ -97,21 +99,45 @@ export interface ModelType {
 /**
  * API response types
  */
-/**
- * Summary of operator execution results for annotation display.
- */
+export interface Schema {
+  readonly attributes: ReadonlyArray<SchemaAttribute>;
+}
+
+// A normalized result tuple from agent-service (schema + positional fields).
+// Sampled tuples are truncated, so each Tuple carries a synthetic all-STRING 
schema.
+export interface Tuple {
+  readonly schema: Schema;
+  readonly fields: ReadonlyArray<unknown>;
+}
+
+export type IndexedTuple = readonly [rowIndex: number, tuple: Tuple];
+
+// The column names of a tuple, in schema order.
+export function tupleColumns(tuple: Tuple): string[] {

Review Comment:
   Done in 3b80b55.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to