Skip to content

feat(spec): simplified executor field syntax#1525

Merged
yottahmd merged 2 commits intomainfrom
improve-executor-syntax
Dec 31, 2025
Merged

feat(spec): simplified executor field syntax#1525
yottahmd merged 2 commits intomainfrom
improve-executor-syntax

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Dec 31, 2025

Summary by CodeRabbit

  • New Features

    • Support for new executor specification using Type and Config fields, separate from legacy executor format.
    • Validation prevents simultaneous use of new and legacy formats with clear error messages.
    • Full backward compatibility maintained for existing workflows.
  • Tests

    • Added test coverage for new executor specification format and conflict detection scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 31, 2025

📝 Walkthrough

Walkthrough

This PR introduces a new executor specification format (type and config fields) for steps alongside maintaining backward compatibility with the legacy executor field. It includes conflict detection, type inference logic, and schema updates to centralize executor type and config definitions.

Changes

Cohort / File(s) Summary
Step Executor Format Logic
internal/core/spec/step.go
Added Type and Config fields to step struct for new executor format; introduced parseLegacyExecutor() helper; implemented conflict detection between new format (type/config) and legacy format (executor); reworked executor resolution to prioritize new format, handle legacy executor, and infer type from container/DAG settings.
Test Coverage
internal/core/spec/step_test.go
Added three test suites: TestBuildStepExecutorNewFormat() validating type-only, type-and-config, and config-only scenarios; TestValidateConflicts_NewVsLegacyFormat() checking conflict detection; TestStepExecutorNewFormat_Integration() with YAML-based integration tests covering SSH, HTTP, jq, and legacy formats.
Schema Definitions
schemas/dag.schema.json
Introduced top-level executorType enum definition and executorConfig object definition; replaced inline enum/type references in step and executorObject with $ref pointers to centralized definitions; removed redundant inline type specifications.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A format anew, yet the old still survives,
Type and Config dance, keeping backward compat alive!
Legacy paths merge with the fresh, pristine way,
Schemas aligned—harmony wins the day! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a new, simplified executor field syntax (Type and Config fields) while maintaining backward compatibility with the legacy executor format.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
schemas/dag.schema.json (1)

556-563: Consider adding schema-level mutual exclusivity validation.

The schema allows both type/config and executor fields to be present simultaneously. While the Go code validates this conflict, adding schema-level validation using oneOf or not would provide earlier feedback to users with schema-aware editors.

Example approach using allOf/not
// In step definition, add to allOf:
{
  "if": {
    "anyOf": [
      { "required": ["type"] },
      { "required": ["config"] }
    ]
  },
  "then": {
    "not": { "required": ["executor"] }
  }
}

Also applies to: 1709-1718

internal/core/spec/step.go (1)

1007-1011: Both "docker" and "container" are registered aliases with identical behavior; consider standardizing on one for consistency.

The inconsistency is confirmed: step-level container sets the executor type to "docker" (line 1009), while DAG-level container sets it to "container" (line 1016). Both are registered aliases in internal/runtime/builtin/docker/executor.go (lines 501–502) pointing to the same executor implementation, making them functionally equivalent. Using the same type in both cases would improve clarity and prevent potential confusion.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a88b73f and 2b9a763.

📒 Files selected for processing (3)
  • internal/core/spec/step.go
  • internal/core/spec/step_test.go
  • schemas/dag.schema.json
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Backend entrypoint in cmd/ orchestrates the scheduler and CLI; runtime, persistence, and service layers sit under internal/* (for example internal/runtime, internal/persistence)
Keep Go files gofmt/goimports clean; use tabs, PascalCase for exported symbols (SchedulerClient), lowerCamelCase for locals, and Err... names for package-level errors
Repository linting relies on golangci-lint; prefer idiomatic Go patterns, minimal global state, and structured logging helpers in internal/common

Files:

  • internal/core/spec/step_test.go
  • internal/core/spec/step.go
**/*_test.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*_test.go: Co-locate Go tests as *_test.go; favour table-driven cases and cover failure paths
Use stretchr/testify/require and shared fixtures from internal/test instead of duplicating mocks

Files:

  • internal/core/spec/step_test.go
🧬 Code graph analysis (2)
internal/core/spec/step_test.go (3)
internal/core/spec/builder.go (2)
  • StepBuildContext (25-28)
  • BuildContext (13-22)
internal/core/step.go (2)
  • ExecutorConfig (189-197)
  • Step (13-97)
internal/core/spec/loader.go (1)
  • Load (150-171)
internal/core/spec/step.go (3)
internal/core/spec/builder.go (1)
  • StepBuildContext (25-28)
internal/core/step.go (2)
  • Step (13-97)
  • ExecutorConfig (189-197)
internal/core/spec/errors.go (2)
  • ErrExecutorTypeMustBeString (23-23)
  • ErrExecutorConfigValueMustBeMap (24-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test on ubuntu-latest
🔇 Additional comments (9)
schemas/dag.schema.json (2)

1692-1708: LGTM! Clean centralization of executor type and config definitions.

The new executorType and executorConfig definitions provide a single source of truth for executor validation. The enum includes all supported executor types, and executorConfig correctly uses additionalProperties: true to allow flexible executor-specific configuration.


1023-1031: LGTM! New simplified executor syntax fields.

The new type and config fields at the step level properly reference the centralized definitions and include clear documentation that they cannot be used together with the legacy executor field.

internal/core/spec/step_test.go (3)

3096-3179: LGTM! Comprehensive unit tests for new executor format.

The test cases cover key scenarios:

  • Type-only specification
  • Type with config
  • Config-only (no type)
  • New format taking precedence over DAG-level container inference

Good use of table-driven tests following Go idioms.


3181-3237: LGTM! Conflict validation tests are thorough.

The tests correctly verify that:

  • New format only (type + config) is valid
  • Legacy format only (executor) is valid
  • Mixing type with executor produces an error
  • Mixing config with executor produces an error
  • Mixing both type and config with executor produces an error

3239-3357: LGTM! Integration tests validate end-to-end YAML loading.

The integration tests effectively verify:

  • SSH executor with new format
  • HTTP executor with headers config
  • jq executor with raw option
  • Legacy format backward compatibility
  • Conflict detection at load time

The tests use temporary files and the Load function, providing realistic coverage.

internal/core/spec/step.go (4)

97-103: LGTM! New fields for simplified executor syntax.

The new Type and Config fields are properly defined with appropriate YAML tags and align with the schema changes. The field placement after Container is logical as they represent alternative ways to configure executor behavior.


924-936: LGTM! Conflict validation between new and legacy formats.

The validation correctly:

  1. Detects when new format (type or config) conflicts with legacy format (executor)
  2. Provides clear error messages guiding users to use the new format
  3. Prioritizes reporting type conflict over config conflict when both are present

990-1023: LGTM! Clean executor resolution with correct precedence.

The refactored buildStepExecutor implements a clear priority chain:

  1. Step-level type and config (new format - highest priority)
  2. Legacy executor field (backward compatibility)
  3. Step-level container → infer "docker"
  4. DAG-level container → infer "container"
  5. DAG-level ssh → infer "ssh"

The early return on line 1010 after setting "docker" for container is correct.


1025-1066: Correct merge semantics in legacy executor parsing.

The parseLegacyExecutor function properly:

  • Only sets Type if not already set (line 1029-1031, 1041-1043)
  • Only adds config keys if not already present (line 1051-1053)

This ensures the new format fields take precedence when both are technically present (though validateConflicts should prevent this in practice).

However, note that the condition on line 1051 checks result.ExecutorConfig.Config[k] == nil which would allow overwriting zero-value entries but not nil entries. Since Config is initialized as make(map[string]any), missing keys will correctly trigger the assignment.

@yottahmd yottahmd merged commit 2788bc5 into main Dec 31, 2025
5 checks passed
@yottahmd yottahmd deleted the improve-executor-syntax branch December 31, 2025 14:53
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.00%. Comparing base (a88b73f) to head (2b9a763).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1525      +/-   ##
==========================================
+ Coverage   62.98%   63.00%   +0.01%     
==========================================
  Files         211      211              
  Lines       23885    23897      +12     
==========================================
+ Hits        15045    15057      +12     
- Misses       7394     7396       +2     
+ Partials     1446     1444       -2     
Files with missing lines Coverage Δ
internal/core/spec/step.go 85.03% <100.00%> (+0.59%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a88b73f...2b9a763. Read the comment docs.

🚀 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.

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