Skip to content

[replay #7505] test(agent-service): pin the context serializer and the execution tools - #16

Open
sshiv012 wants to merge 2 commits into
replay/7505-basefrom
replay/7505-head
Open

[replay #7505] test(agent-service): pin the context serializer and the execution tools#16
sshiv012 wants to merge 2 commits into
replay/7505-basefrom
replay/7505-head

Conversation

@sshiv012

@sshiv012 sshiv012 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Replay of apache#7505 for CodeRabbit evaluation.

merge-base 42d08a3701cd head d0d9cb1447e8 stratum frontend

Synthetic evaluation PR. Do not merge.

  • Added 15 agent service tests.
  • Increased context-utils.ts coverage to 100%.
  • Increased workflow-execution-tools.ts coverage to 95.16%.
  • Covered ordering, port mapping, cell rendering, schema errors, request construction, results, warnings, and tool configuration.
  • Modified test files only.
Author Lines added Lines removed
Xinyuan Lin 380 5

aglinxinyuan and others added 2 commits August 9, 2026 21:59
context-utils.ts builds the prompt the agent reasons over, and
workflow-execution-tools.ts turns an execution result into the table it
reads back. Both were partly covered by line count and thinly covered in
substance: bun credits a whole function body once entered, so blocks
inside jsonToTableFormat and executeOperatorAndFormat counted as covered
while nothing asserted them.

Adds 15 tests across the two existing specs. context-utils.ts reaches
100% lines and functions; workflow-execution-tools.ts goes from 91.24%
to 95.16%, with the remainder left alone because it is dead.

Ten of the mutations these kill target lines bun already reported as
covered - the DAG topological ordering and its tie-break, port ordinal
mapping, the NULL/null/undefined/object cell rendering, the row-gap
ellipsis, and the schema-violation messages.

No production file is touched.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request expands tests for workflow execution tools and context utilities. Coverage includes request construction, validation, result rendering, workflow serialization, property handling, status reporting, and compilation errors.

Changes

Workflow test coverage

Layer / File(s) Summary
Shared workflow fixtures and tool wiring
agent-service/src/agent/tools/workflow-execution-tools.spec.ts, agent-service/src/agent/util/context-utils.spec.ts
Adds reusable operator and link fixtures, request-body parsing, operator overrides, and per-invocation tool configuration checks.
Execution requests and result rendering
agent-service/src/agent/tools/workflow-execution-tools.spec.ts
Tests validation errors, request fields, port ordinals, flattened properties, warnings, row rendering, skipped rows, and empty outputs.
Context serialization and status reporting
agent-service/src/agent/util/context-utils.spec.ts
Tests tool-call statuses, topological ordering, schema fallbacks, property formatting and redaction, executed results, and compilation errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: mengw15

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the agent-service tests for the context serializer and workflow execution tools.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch replay/7505-head

Comment @coderabbitai help to get the list of available commands.

@sshiv012

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent-service/src/agent/tools/workflow-execution-tools.spec.ts`:
- Around line 330-365: Update the ordinal-resolution test around
executeOperatorAndFormat to use a declared source port instead of output-9, and
adjust its expected link accordingly. Add a separate test covering an unknown
port on a non-dynamic operator, asserting execution is blocked and fetch is not
called.

In `@agent-service/src/agent/util/context-utils.spec.ts`:
- Around line 206-219: Update serializeOperator and the assembleContext flow so
useRedact=true never includes operatorProperties, including for [ERROR]
execution results. Preserve the failed status and expose only non-sensitive
error details in the returned ModelMessage; update the affected test
expectations accordingly.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 75eaf20b-1ac7-4407-8c1f-8e8ddeae28f9

📥 Commits

Reviewing files that changed from the base of the PR and between 42d08a3 and d0d9cb1.

📒 Files selected for processing (2)
  • agent-service/src/agent/tools/workflow-execution-tools.spec.ts
  • agent-service/src/agent/util/context-utils.spec.ts

Comment on lines +330 to +365
state.addLink(makeLink("src", "output-1", "dst", "input-0"));
// An unknown source port falls back to ordinal 0 rather than -1.
state.addLink(makeLink("src", "output-9", "dst", "input-1"));
resolveFetch(fetchSpy, {
success: true,
state: "Completed",
operators: {
dst: { state: "Completed", inputTuples: 0, outputTuples: 1, resultMode: "table", result: [{ a: 1 }] },
},
});

await executeOperatorAndFormat(state, cfg({ workflowId: 7, computingUnitId: 3, executionTimeoutMs: 4200 }), "dst");

expect(String(fetchSpy.mock.calls[0][0])).toBe("http://localhost:8085/api/execution/7/3/run");
expect((fetchSpy.mock.calls[0][1] as RequestInit).headers).toMatchObject({ Authorization: "Bearer tok" });

const body = requestBody(fetchSpy);
expect(body.executionName).toBe("agent-execution");
// 4200 rather than a round 4500: with 4500 the assertion holds for ceil, round *and*
// floor-plus-one, so it would not notice the rounding being changed. 4200 separates them.
expect(body.timeoutSeconds).toBe(5);
expect(body.targetOperatorIds).toEqual(["dst"]);
expect(body.logicalPlan.opsToViewResult).toEqual(["dst"]);
expect(body.logicalPlan.links).toEqual([
{
fromOpId: "src",
fromPortId: { id: 1, internal: false },
toOpId: "dst",
toPortId: { id: 0, internal: false },
},
{
fromOpId: "src",
fromPortId: { id: 0, internal: false },
toOpId: "dst",
toPortId: { id: 1, internal: false },
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Reject an unknown static source port instead of mapping it to port 0.

src declares only output-0 and output-1. Line 332 creates output-9, but Lines 360-365 assert that it becomes ordinal 0. This changes an invalid link into a valid-looking link from the wrong output port.

Use a declared port in this ordinal-resolution test. Add a separate test that an unknown port on a non-dynamic operator blocks execution without calling fetch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent-service/src/agent/tools/workflow-execution-tools.spec.ts` around lines
330 - 365, Update the ordinal-resolution test around executeOperatorAndFormat to
use a declared source port instead of output-9, and adjust its expected link
accordingly. Add a separate test covering an unknown port on a non-dynamic
operator, asserting execution is blocked and fetch is not called.

Comment on lines +206 to +219
test("omits properties under redaction unless the operator's result reports an error", () => {
const workflowState = new WorkflowState();
workflowState.addOperator(makeOperator("op1", { operatorProperties: { secret: "s3cr3t" } }));

const redacted = contentOf(assembleContext([], workflowState, new Map(), true));
expect(redacted).toContain("(TestOp, not-executed)");
expect(redacted).not.toContain("Properties:");

// A failing operator keeps its properties even when redacting, so the model
// can see what caused the failure.
const failed = contentOf(assembleContext([], workflowState, new Map([["op1", "[ERROR] boom"]]), true));
expect(failed).toContain("(TestOp, failed)");
expect(failed).toContain(" secret: s3cr3t");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ast-grep outline agent-service/src/agent/util/context-utils.ts --items all
rg -n -C 8 'function serializeDag|useRedact|operatorProperties|operatorExecutionResults|Result:' \
  agent-service/src/agent/util/context-utils.ts \
  agent-service/src/agent/util/context-utils.spec.ts

Repository: sshiv012/texera

Length of output: 21291


Sensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor

Keep operator properties redacted when useRedact is true.

When an execution result contains [ERROR], serializeOperator includes all operatorProperties in the returned ModelMessage. Preserve redaction and include only non-sensitive error details.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent-service/src/agent/util/context-utils.spec.ts` around lines 206 - 219,
Update serializeOperator and the assembleContext flow so useRedact=true never
includes operatorProperties, including for [ERROR] execution results. Preserve
the failed status and expose only non-sensitive error details in the returned
ModelMessage; update the affected test expectations accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants