← Back to Pull requests

fix(workflow): validate declared input and output schemas at publish and run boundaries (issue #274) #359

Closed
unknown closed this pull request without merging on Nov 12, 2026 14:44 UTC
View on GitHub
unknown unknown commented on Nov 08, 2026 03:01 UTC
Author

Describe what this PR does / why we need it

Issue #274 reported that WorkflowDefinition exposes inputSchema/outputSchema, but the validator only rejected blank strings and the runner never read either field — an illegal schema could be published, a run missing a required input still executed its tools, and the outcome came back COMPLETED. This PR makes the declared schemas real contracts at both the publish and the run boundary, using the same JSON Schema capability the agent layer already ships (networknt, draft 2020-12, version managed by the root pom), so no competing validation stack is introduced and no public API changes.

What is delivered

Publish and instantiation

WorkflowDefinitionValidator now parses every non-blank declared schema with the networknt registry (draft 2020-12) and rejects malformed ones with an error naming the field and the dialect. Blank schemas keep their existing rejection; definitions without schemas keep their existing behavior untouched.

Input boundary, before any side effect

On a fresh run, WorkflowAgent validates the request inputs against the declared input schema before the first step executes — the issue's reproduction (missing required input, tool executed, COMPLETED) now fails with zero tool executions. The failure is a WorkflowValidationException carrying one structured issue per violating location, reusing AgentResult.OutputValidationIssue(errorCode, fieldPath, message) and the existing SCHEMA_MALFORMED/SCHEMA_VIOLATION error codes.

Output boundary, no COMPLETED for a violating output

Before the COMPLETED outcome is delivered — on the single completion path shared by fresh runs and resumes — the output snapshot is validated against the declared output schema. A violation terminates the stream with the same structured exception, which matches the existing contract that errors terminate the stream exceptionally; AgentOutcome itself is unchanged.

Documented boundaries

Resumes do not re-validate inputs: the continuation owns the state and a resume request often carries no inputs, so re-validating would make suspended workflows impossible to finish — output acceptance still applies on resume. Subflows share the parent run's inputs, so a nested definition's input schema is a publish-time contract for its own callers and is not applied again inside the parent run. Both boundaries are covered by tests.

Two pre-existing bugs on the resume path, fixed

The workflow module had no suspend/resume tests, and the issue's acceptance criteria ask for that coverage — writing the tests surfaced two latent bugs. First, ExecutionResult.continueWith wrapped a suspension in a result whose data was null while the suspended-outcome construction reads that data, so any suspension NPE'd immediately; the wrapper now keeps the suspension-point snapshot. Second, resuming invoked the wrapped agent continuation twice (once inside continueWith, once again in the composed step lambda of executeSteps/Loop) — a real agent rejects a second call carrying the same resume token. The composed step now receives the resumed result instead of re-resuming, and the resume tests assert that the agent is invoked exactly once per resume.

Testing

New WorkflowSchemaContractTest with 10 cases: malformed input and output schemas rejected at publish, blank-schema regression, unchanged behavior without schemas, missing required input rejected with zero tool executions, type mismatch reporting the field path, valid input and output completing, output violation failing instead of completing, resume completing without input re-validation, resume output violation still failing, and subflow schema validation at publish without gating parent runs. Run against the unmodified code the suite fails 5F+2E (red, including the issue's reproduction); with the fix the whole argi-workflow-core module is 48/48 green, checkstyle clean.

Fixes #274

Diff: 494 lines (+370 / -124) across 6 files Reviewer: yuluo-yx Review duration: 6463m
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.47) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 494 lines diff across 6 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.371
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #359"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.4% (MEDIUM) · Higher = larger blast radius
47.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 20.5% · Safe to merge
20.5%