Skip to content

Add cycle detection to AI flow config#23589

Merged
AAraKKe merged 5 commits intoloa/openmetrics-ai-genfrom
loa/no-cycles
May 7, 2026
Merged

Add cycle detection to AI flow config#23589
AAraKKe merged 5 commits intoloa/openmetrics-ai-genfrom
loa/no-cycles

Conversation

@luisorofino
Copy link
Copy Markdown
Contributor

@luisorofino luisorofino commented May 5, 2026

What does this PR do?

Adds cycle detection to FlowConfig validation in the AI framework's phase configuration.

A new _detect_cycle function runs DFS over the phase dependency graph and returns the first cycle found as an ordered list of phase IDs. FlowConfig.cross_references calls it after all other dependency checks pass and raises a ValidationError with a readable -separated cycle path (e.g. p1 → p2 → p3 → p1).

New test coverage for this cycle detection has also been added to tests/ai/phases/test_config.py.

Also adds from __future__ import annotations to config.py and updates forward-reference string annotations (e.g. -> "TaskConfig") to plain annotations (-> TaskConfig).

Motivation

Without cycle detection, a flow config with circular dependencies (e.g. p1 depends on p2 which depends on p1) would pass validation silently and cause the orchestrator to deadlock at runtime. Failing fast at load time with a clear error message is strictly better.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@dd-octo-sts dd-octo-sts Bot added the ddev label May 5, 2026
@luisorofino luisorofino added the qa/skip-qa Automatically skip this PR for the next QA label May 5, 2026
@luisorofino luisorofino changed the title Add cycles detection to flow config Add cycle detection to AI flow config May 5, 2026
@luisorofino luisorofino marked this pull request as ready for review May 5, 2026 10:21
@luisorofino luisorofino requested a review from a team as a code owner May 5, 2026 10:21
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 94.80519% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (loa/openmetrics-ai-gen@6ffec98). Learn more about missing BASE report.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official Bot commented May 5, 2026

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 6 Tests failed

❄️ Known flaky: test_config[Metric collection disabled] from test_config.py   View in Datadog   (Fix with Cursor)
RetryError[<Future at 0x7ff918173b10 state=finished raised RetryError>]
❄️ Known flaky: test_config[Resource stats collection disabled; message_flows enabled] from test_config.py   View in Datadog   (Fix with Cursor)
RetryError[<Future at 0x7ff918173b10 state=finished raised RetryError>]
❄️ Known flaky: test_config[Resource stats collection enabled; message_flows disabled] from test_config.py   View in Datadog   (Fix with Cursor)
RetryError[<Future at 0x7ff918173b10 state=finished raised RetryError>]
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 94.81%
Overall Coverage: 87.58%

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 50c56fe | Docs | Datadog PR Page | Give us feedback!

Copy link
Copy Markdown
Contributor

@AAraKKe AAraKKe left a comment

Choose a reason for hiding this comment

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

Thanks @luisorofino , added just a couple comments which I think we already discussed. Once done lets merge.

Comment thread ddev/tests/ai/phases/test_config.py Outdated
Comment thread ddev/tests/ai/phases/test_config.py
Comment thread ddev/src/ddev/ai/phases/config.py Outdated
Copy link
Copy Markdown
Contributor

@AAraKKe AAraKKe left a comment

Choose a reason for hiding this comment

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

Hi @luisorofino, this review was generated with Claude Code and has been looked over and approved before posting. I believe the comments below are valid — feel free to discuss any you disagree with.


Thanks for the update! I have been trying to understand the algorithm and going back and forght with Claude and Codex and came up with a couple of comments. See below, once they are addressed I am ok to merge!


Comment legend

praise: no action needed, just celebrate!
note: informational, no action required.
question: seeking clarification or understanding your approach.
nit: minor, non-blocking (style, typo). Feel free to ignore.
suggestion: optional improvement, recommended but not required.
request: a change I believe is necessary before merging.

Comment thread ddev/src/ddev/ai/phases/config.py Outdated
Comment thread ddev/src/ddev/ai/phases/config.py Outdated
Comment thread ddev/src/ddev/ai/phases/config.py Outdated
Comment thread ddev/tests/ai/phases/test_config.py Outdated
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 7, 2026

Validation Report

All 20 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@AAraKKe AAraKKe merged commit f36bc51 into loa/openmetrics-ai-gen May 7, 2026
342 of 344 checks passed
@AAraKKe AAraKKe deleted the loa/no-cycles branch May 7, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddev qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants