Skip to content

Fix workflow YAML structural validation before normalization - #3708

Open
AbigailDeng wants to merge 1 commit into
feature/integratefrom
feat/2026-10-27_yaml-structure-validation
Open

AbigailDeng wants to merge 1 commit into
feature/integratefrom
feat/2026-10-27_yaml-structure-validation

Conversation

@AbigailDeng

@AbigailDeng AbigailDeng commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

工作流 YAML 中的 branches: oops 和缺少条件/目标的分支条目,原先可能在映射时变成空分支或被直接丢弃。后续语义校验看到的是归一化后的定义,无法再发现原文结构错误;children: [null] 等输入则可能产生空引用异常。

本次在资源限制与 YAML 语法解析之后、反序列化和默认值处理之前,增加共享的原始 AST 结构校验。Core 运行时和 Studio 文档解析复用同一组规则,非法结构必须先报错,不能生成可继续归一化的部分文档。

后端集成基线:feature/integrate(0cc82b0ad)。

方案与影响路径

  • 从现有 Raw 强类型合约派生静态字段与容器形状;检查根对象、roles/steps/children、configuration、retry、capability、response projection 等结构。
  • 分支必须完整,拒绝无效形状、缺失条件/目标、重复条件及重复语义别名,避免转换时静默丢失控制流。
  • 工具权限和交互字段使用既有格式及 Protobuf descriptor 校验;JSON 编码的交互树解码后也受资源限制,非法交互 bool 不再默认为 false。
  • 通过 WorkflowYamlStructureException 保留 yaml_structure / unknown_field 与 JSON Pointer 字段路径。Studio 在构造文档和图之前返回错误,IWorkflowYamlValidator 的诊断也保留字段路径。
  • 保留合法复杂参数、支持的字段别名、可选 null 与 YAML anchors;修正显式字符串 tag 被旧 null reader 当作空值的问题,使 AST 校验与实际映射一致。
  • 更新 docs/canon/workflow-runtime.md 的阶段定义、边界和流程图。目标/角色引用、步骤类型与控制流语义仍由后续 WorkflowValidator 负责;IWorkflowYamlValidator 保持原有 parse-only 契约。

例如 branches: [{ condition: ready }] 现在会在 /steps/0/branches/0 返回结构错误。原先依赖忽略不完整分支的 YAML 将被明确拒绝;分支目标只支持 scalar 或单层目标别名 mapping。

验证

环境:.NET SDK 10.0.100;门禁使用 Python 3.12,并将本机 .NET SDK 加入 PATH。

dotnet test test/Aevatar.Workflow.Core.Tests/Aevatar.Workflow.Core.Tests.csproj --nologo --filter 'FullyQualifiedName~WorkflowParser|FullyQualifiedName~WorkflowYamlResourceGuardTests|FullyQualifiedName~WorkflowYamlValidateModuleTests' --verbosity quiet
dotnet test test/Aevatar.Studio.Tests/Aevatar.Studio.Tests.csproj --nologo --filter 'FullyQualifiedName~WorkflowEditorServiceStructureTests|FullyQualifiedName~EditorControllerSerializationTests|FullyQualifiedName~WorkflowCompatibilityProfileTests|FullyQualifiedName~WorkflowAuthoringPreviewGeneratorTests|FullyQualifiedName~StudioAuthoringPreviewApplicationServiceTests|FullyQualifiedName~WorkflowDocumentNormalizerTests' --verbosity quiet
dotnet test test/Aevatar.Workflow.Host.Api.Tests/Aevatar.Workflow.Host.Api.Tests.csproj --nologo --filter 'FullyQualifiedName~WorkflowDefinitionParserResourceLimitTests|FullyQualifiedName~WorkflowDefinitionParserExternalCapabilityTests' --verbosity quiet
bash tools/ci/test_stability_guards.sh
DIFF_RANGE='origin/feature/integrate...HEAD' bash tools/ci/architecture_guards.sh
bash tools/ci/workflow_saga_compensation_guard.sh
bash tools/docs/lint.sh
git diff --check origin/feature/integrate...HEAD
  • Core parser / resource / YAML validation module:237 passed。
  • Studio editor / HTTP serialization / compatibility / authoring preview / normalization:132 passed。
  • Definition admission / external capability / resource limit:16 passed。
  • Architecture 总门禁:未通过,命中 feature/integrate 已有的 studio_fact_owner_guard.sh 违规,详见下方基线问题。
  • WorkflowSagaCompensation 专项门禁:19 passed。
  • Test stability guard:通过。
  • Docs lint:95 files,0 errors。
  • Branch diff whitespace check:通过。

本地使用受影响后端项目的聚焦测试;未运行全量 solution 测试。

已确认的基线门禁问题

DIFF_RANGE=origin/feature/integrate...HEAD bash tools/ci/architecture_guards.sh 在 studio_fact_owner_guard.sh 处退出:src/platform/Aevatar.GAgentService.Hosting/Endpoints/WorkflowApiEndpoints.cs:103 传递 request.Layout,第 204 行仍声明 WorkflowLayoutDocument,违反 UI/layout 字段由客户端持有的现有规则。

已使用 git archive origin/feature/integrate src tools 导出的纯基线快照单独运行同一门禁,复现完全相同的两处命中(exit 1)。该文件在基线与本 PR 中的 Git blob 均为 fa18f8566f1b180e1554ecd046c23bf208e5ebf5,本 PR 没有修改该文件。该基线问题使架构总门禁未能完成,不将本次聚焦测试通过等同于所有门禁通过。

@AbigailDeng
AbigailDeng force-pushed the feat/2026-10-27_yaml-structure-validation branch from f9cf419 to b1254a3 Compare October 27, 2026 04:32
@AbigailDeng
AbigailDeng changed the base branch from dev to feature/integrate October 27, 2026 04:33

This branch has not been deployed

No deployments
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.

1 participant