Skip to content

Implement dependency graph for compile --watch to minimize recompilation - #5908

Merged
pelikhan merged 4 commits into
mainfrom
copilot/update-workflows-recompilation
Dec 8, 2025
Merged

Implement dependency graph for compile --watch to minimize recompilation#5908
pelikhan merged 4 commits into
mainfrom
copilot/update-workflows-recompilation

Conversation

Copilot AI commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Implementation Plan for Compile --Watch Dependency Graph

  • Understand the current watch mode implementation
    • Review watchAndCompileWorkflows function in compile_command.go
    • Understand how imports are resolved and tracked
    • Identify what files are currently being watched and recompiled
  • Design the dependency graph system
    • Define data structures for tracking workflow dependencies
    • Implement graph building from imports
    • Distinguish between top-level workflows and shared workflows
  • Implement reverse dependency tracking
    • Track which top-level workflows import each shared workflow
    • When a shared workflow changes, identify all parent workflows
  • Modify watch mode to use dependency graph
    • Build dependency graph on startup
    • On file change, determine if it's a top-level or shared workflow
    • Recompile affected workflows based on dependency graph
  • Add tests for dependency tracking
    • Test graph building from imports
    • Test reverse dependency lookup
    • Test nested imports and transitive dependencies
    • Test workflow updates and removals
    • Test multiple top-level importers
    • Test circular import detection
    • Test new file addition
    • Test empty graph scenarios
    • Test complex dependency chains
    • Test imports with inputs
  • Validate and test the implementation
    • All tests pass (10 test functions, 18 subtests)
    • Linting passes
    • Code formatting applied
    • Ready for review

Summary

Successfully implemented a dependency graph system for compile --watch mode with comprehensive test coverage:

New Tests Added (6 additional test functions)

  1. TestDependencyGraph_MultipleTopLevelImporters: Verifies that a deeply nested shared workflow correctly affects all top-level workflows that import it

  2. TestDependencyGraph_CircularImportDetection: Ensures the graph handles circular imports gracefully without infinite loops

  3. TestDependencyGraph_NewFileAddition: Tests behavior when new workflow files are added (both top-level and shared)

  4. TestDependencyGraph_EmptyGraph: Validates graph initialization and operations on an empty graph

  5. TestDependencyGraph_ComplexDependencyChain: Tests a complex multi-level dependency chain (top1 → a → b → c) and verifies correct propagation

  6. TestDependencyGraph_ImportsWithInputs: Ensures imports using object format with inputs field are tracked correctly

Test Coverage Summary

  • Total test functions: 10
  • Total subtests: 18
  • All tests passing: ✅

Key Test Scenarios Covered

  • Top-level vs shared workflow detection
  • Dependency graph building from imports
  • Affected workflow identification
  • Nested imports and transitive dependencies
  • Workflow updates and removals
  • Multiple importers of the same shared workflow
  • Circular import handling
  • New file additions during watch mode
  • Empty graph initialization
  • Complex dependency chains (3+ levels deep)
  • Imports with inputs object format
Original prompt

The "compile --watch" should build the graph of workflows and imports such that it always recompile all the dominator top agentic workflows. Shared agentic workflows (leafs of the project) do not need to be recompiled as they are meant to be imported.
When a shared agentic workflow is modified, all top level parent workflows should be recompiled


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 8, 2025 22:21
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update recompilation logic for top agentic workflows Implement dependency graph for compile --watch to minimize recompilation Dec 8, 2025
Copilot AI requested a review from pelikhan December 8, 2025 22:32
@pelikhan
pelikhan marked this pull request as ready for review December 8, 2025 22:33
@pelikhan

pelikhan commented Dec 8, 2025

Copy link
Copy Markdown
Collaborator

@copilot add more tests

- Test multiple top-level importers
- Test circular import detection
- Test new file addition handling
- Test empty graph initialization
- Test complex dependency chains
- Test imports with inputs object format

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@copilot add more tests

Added 6 comprehensive test functions covering:

  • Multiple top-level importers
  • Circular import detection
  • New file addition handling
  • Empty graph scenarios
  • Complex dependency chains (3+ levels deep)
  • Imports with inputs object format

All 10 test functions with 18 subtests now pass. Commit: 4acc6d1

@pelikhan
pelikhan merged commit 6a246a5 into main Dec 8, 2025
5 checks passed
@pelikhan
pelikhan deleted the copilot/update-workflows-recompilation branch December 8, 2025 22:40
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.

2 participants