Skip to content

[One Workflow] Restore compact validation telemetry for generate_workflow#271980

Draft
Kiryous wants to merge 1 commit into
elastic:mainfrom
Kiryous:kir/restore-generate-workflow-validation-telemetry
Draft

[One Workflow] Restore compact validation telemetry for generate_workflow#271980
Kiryous wants to merge 1 commit into
elastic:mainfrom
Kiryous:kir/restore-generate-workflow-validation-telemetry

Conversation

@Kiryous
Copy link
Copy Markdown
Contributor

@Kiryous Kiryous commented May 29, 2026

Closes https://github.com/elastic/security-team/issues/17641

Follow-up to #269351 — addresses @yiannisnikolopoulos's review comment.

Summary

The old low-level edit tools (deleted in #269351) ran a compact validation pass against the resulting YAML and surfaced the outcome via WorkflowsAiTelemetryClient.reportEditResult, emitting:

  • validation_passed: boolean
  • validation_error_count: number (when invalid)
  • is_self_correction: boolean (when a previously-failed conversation produced a valid YAML)

When generate_workflow became the single entry point, reportEditResult started being called without a validation field, so those telemetry fields are permanently undefined and we can't track generation-quality regressions over time.

This PR reintroduces the helper, calls api.validateWorkflow against the stringified generated YAML, and passes the result through to telemetry on the success path. The failure path (generation threw) still has no YAML to validate, so it keeps the existing behavior.

Test plan

  • generate_workflow.test.ts unit suite (10 cases, including new coverage):
    • passes a compact validation result to telemetry when the generated YAML is valid
    • passes compact errors to telemetry when the generated YAML fails validation (error-only diagnostic flattening, drops warnings)
    • omits validation in telemetry when validateWorkflow throws
  • Manual smoke check that the workflows_ai_edit_result event now carries validation_passed in dev tools (not required for merge, but worth confirming once on a deployed env).

…flow

Closes elastic/security-team#17641.

The old low-level edit tools (deleted in elastic#269351) ran a compact
validation pass against the generated YAML and surfaced the result via
WorkflowsAiTelemetryClient.reportEditResult, which emits
validation_passed, validation_error_count, and is_self_correction. The
single-entry-point generate_workflow tool stopped doing that, leaving
those telemetry fields permanently undefined and removing our ability to
track generation-quality regressions.

This commit reintroduces the helper, calls api.validateWorkflow against
the stringified YAML after generation, and passes the result through to
telemetry on the success path. The failure path (generation threw) still
has no YAML to validate, so it keeps the existing behavior.

Tests cover the valid case, the invalid case (with error-only
diagnostic flattening), and the validator-throwing case.

Spotted by @yiannisnikolopoulos on elastic#269351 review.
@Kiryous Kiryous added Team:One Workflow Team label for One Workflow (Workflow automation) release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels May 29, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

@Kiryous
Copy link
Copy Markdown
Contributor Author

Kiryous commented May 29, 2026

/ci

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #130 / Cloud Security Posture - Group 5 (KSPM + Flyouts) Security Alerts Page - Graph visualization expanded flyout - filter by node

Metrics [docs]

✅ unchanged

@Kiryous Kiryous self-assigned this May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:One Workflow Team label for One Workflow (Workflow automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants