Skip to content

refactor: extract shared iac.provider discovery + grouping helpers used by plan and apply#549

Merged
intel352 merged 5 commits into
mainfrom
copilot/refactor-shared-iac-provider-helper
May 5, 2026
Merged

refactor: extract shared iac.provider discovery + grouping helpers used by plan and apply#549
intel352 merged 5 commits into
mainfrom
copilot/refactor-shared-iac-provider-helper

Conversation

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor

computePlanForInfraSpecs and applyInfraModules independently duplicated the same ~50 lines of iac.provider discovery, env-var resolution, disabled-provider tracking, type-count heuristic, and spec-grouping logic — creating silent drift risk between plan and apply outputs for the same input config.

What changed

New cmd/wfctl/infra_provider_dispatch.go

  • providerDef — shared type replacing identical local structs in both files
  • specGroup — shared struct replacing planGroup (plan) / provGroup (apply); named specGroup to avoid collision with the existing providerGroup in infra_status_drift.go (which groups ResourceRefs, not specs)
  • resolveProviderDefs(cfg, envName) — single source of truth for walking cfg.Modules, filtering iac.provider, expanding env vars, and returning defs + typeCounts + disabled
  • groupSpecsByProviderRef(specs, defs, disabled, envName) — groups specs by provider field in stable first-reference order, with consistent error messages for missing/disabled/unconfigured providers

infra_plan_provider.go / infra_apply.go

  • Remove ~35 and ~55 lines of duplicated discovery/grouping code respectively
  • Call the shared helpers instead; all error text, ordering semantics, and providerTypeCounts fallback heuristic are byte-identical to the pre-refactor implementations

New cmd/wfctl/infra_provider_dispatch_test.go

  • Unit tests for resolveProviderDefs (basic, env-disabled, duplicate type counts) and groupSpecsByProviderRef (ordering, all error paths)
  • TestPlanApplyGroupingEquivalence — regression gate asserting both paths produce identical group order and spec membership for the same input config
// Both paths now share a single implementation:
defs, typeCounts, disabled := resolveProviderDefs(cfg, envName)
groupOrder, groups, err := groupSpecsByProviderRef(specs, defs, disabled, envName)

Copilot AI requested review from Copilot and removed request for Copilot May 5, 2026 07:43
Extract resolveProviderDefs and groupSpecsByProviderRef from the
duplicated logic in computePlanForInfraSpecs (infra_plan_provider.go)
and applyInfraModules (infra_apply.go) into a new shared file
infra_provider_dispatch.go.

- Add shared types: providerDef, specGroup
  (specGroup chosen to avoid conflict with providerGroup in
  infra_status_drift.go which groups ResourceRefs, not ResourceSpecs)
- Add resolveProviderDefs: walks cfg.Modules, filters iac.provider,
  expands env vars, returns defs + typeCounts + disabled sets
- Add groupSpecsByProviderRef: groups specs by provider module ref,
  returns stable first-reference-in-specs order
- Remove duplicate local providerDef/planGroup types from plan path
- Remove duplicate local providerDef/provGroup types from apply path
- Add infra_provider_dispatch_test.go with unit tests covering both
  helpers and asserting plan-apply grouping equivalence

No behavior change: error messages, ordering, and fallback heuristics
are identical to the pre-refactor implementations.

Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/07eff01d-aa38-48bf-ada6-5faf96c7de5e

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 5, 2026 08:26
Copilot AI changed the title [WIP] Refactor shared iac.provider discovery and grouping helper refactor: extract shared iac.provider discovery + grouping helpers used by plan and apply May 5, 2026
Copilot AI requested a review from intel352 May 5, 2026 08:28
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

⏱ Benchmark Results

No significant performance regressions detected.

benchstat comparison (baseline → PR)
## benchstat: baseline → PR
baseline-bench.txt:260: parsing iteration count: invalid syntax
baseline-bench.txt:301914: parsing iteration count: invalid syntax
baseline-bench.txt:622726: parsing iteration count: invalid syntax
baseline-bench.txt:906974: parsing iteration count: invalid syntax
baseline-bench.txt:1179765: parsing iteration count: invalid syntax
baseline-bench.txt:1453036: parsing iteration count: invalid syntax
benchmark-results.txt:260: parsing iteration count: invalid syntax
benchmark-results.txt:569922: parsing iteration count: invalid syntax
benchmark-results.txt:898039: parsing iteration count: invalid syntax
benchmark-results.txt:1217087: parsing iteration count: invalid syntax
benchmark-results.txt:1525527: parsing iteration count: invalid syntax
benchmark-results.txt:1840987: parsing iteration count: invalid syntax
goos: linux
goarch: amd64
pkg: github.com/GoCodeAlone/workflow/dynamic
cpu: AMD EPYC 7763 64-Core Processor                
                            │ baseline-bench.txt │       benchmark-results.txt        │
                            │       sec/op       │    sec/op     vs base              │
InterpreterCreation-4              4.879m ± 127%   6.782m ± 54%       ~ (p=0.589 n=6)
ComponentLoad-4                    3.724m ±   1%   3.590m ± 11%       ~ (p=0.065 n=6)
ComponentExecute-4                 1.996µ ±   1%   1.931µ ±  1%  -3.26% (p=0.002 n=6)
PoolContention/workers-1-4         1.129µ ±   4%   1.075µ ±  1%  -4.87% (p=0.002 n=6)
PoolContention/workers-2-4         1.122µ ±   1%   1.081µ ±  3%  -3.61% (p=0.002 n=6)
PoolContention/workers-4-4         1.132µ ±   2%   1.077µ ±  1%  -4.86% (p=0.002 n=6)
PoolContention/workers-8-4         1.126µ ±   1%   1.077µ ±  1%  -4.40% (p=0.002 n=6)
PoolContention/workers-16-4        1.122µ ±   2%   1.103µ ±  2%  -1.74% (p=0.011 n=6)
ComponentLifecycle-4               3.769m ±   2%   3.629m ±  1%  -3.73% (p=0.002 n=6)
SourceValidation-4                 2.322µ ±   1%   2.286µ ±  2%  -1.55% (p=0.024 n=6)
RegistryConcurrent-4               815.0n ±   5%   834.6n ±  2%       ~ (p=0.132 n=6)
LoaderLoadFromString-4             4.013m ±   2%   3.641m ±  1%  -9.26% (p=0.002 n=6)
geomean                            18.74µ          18.64µ        -0.55%

                            │ baseline-bench.txt │        benchmark-results.txt         │
                            │        B/op        │     B/op      vs base                │
InterpreterCreation-4               2.027Mi ± 0%   2.027Mi ± 0%       ~ (p=0.974 n=6)
ComponentLoad-4                     2.180Mi ± 0%   2.180Mi ± 0%       ~ (p=0.331 n=6)
ComponentExecute-4                  1.203Ki ± 0%   1.203Ki ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-1-4          1.203Ki ± 0%   1.203Ki ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-2-4          1.203Ki ± 0%   1.203Ki ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-4-4          1.203Ki ± 0%   1.203Ki ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-8-4          1.203Ki ± 0%   1.203Ki ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-16-4         1.203Ki ± 0%   1.203Ki ± 0%       ~ (p=1.000 n=6) ¹
ComponentLifecycle-4                2.183Mi ± 0%   2.183Mi ± 0%       ~ (p=0.948 n=6)
SourceValidation-4                  1.984Ki ± 0%   1.984Ki ± 0%       ~ (p=1.000 n=6) ¹
RegistryConcurrent-4                1.133Ki ± 0%   1.133Ki ± 0%       ~ (p=1.000 n=6) ¹
LoaderLoadFromString-4              2.182Mi ± 0%   2.182Mi ± 0%       ~ (p=0.288 n=6)
geomean                             15.25Ki        15.25Ki       -0.00%
¹ all samples are equal

                            │ baseline-bench.txt │        benchmark-results.txt        │
                            │     allocs/op      │  allocs/op   vs base                │
InterpreterCreation-4                15.68k ± 0%   15.68k ± 0%       ~ (p=1.000 n=6)
ComponentLoad-4                      18.02k ± 0%   18.02k ± 0%       ~ (p=1.000 n=6)
ComponentExecute-4                    25.00 ± 0%    25.00 ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-1-4            25.00 ± 0%    25.00 ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-2-4            25.00 ± 0%    25.00 ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-4-4            25.00 ± 0%    25.00 ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-8-4            25.00 ± 0%    25.00 ± 0%       ~ (p=1.000 n=6) ¹
PoolContention/workers-16-4           25.00 ± 0%    25.00 ± 0%       ~ (p=1.000 n=6) ¹
ComponentLifecycle-4                 18.07k ± 0%   18.07k ± 0%       ~ (p=1.000 n=6) ¹
SourceValidation-4                    32.00 ± 0%    32.00 ± 0%       ~ (p=1.000 n=6) ¹
RegistryConcurrent-4                  2.000 ± 0%    2.000 ± 0%       ~ (p=1.000 n=6) ¹
LoaderLoadFromString-4               18.06k ± 0%   18.06k ± 0%       ~ (p=1.000 n=6) ¹
geomean                               183.3         183.3       +0.00%
¹ all samples are equal

pkg: github.com/GoCodeAlone/workflow/middleware
                                  │ baseline-bench.txt │       benchmark-results.txt        │
                                  │       sec/op       │    sec/op     vs base              │
CircuitBreakerDetection-4                  292.6n ± 5%   293.1n ± 11%       ~ (p=0.818 n=6)
CircuitBreakerExecution_Success-4          21.57n ± 0%   21.52n ±  0%       ~ (p=0.108 n=6)
CircuitBreakerExecution_Failure-4          65.94n ± 0%   66.79n ±  0%  +1.29% (p=0.002 n=6)
geomean                                    74.66n        74.96n        +0.41%

                                  │ baseline-bench.txt │       benchmark-results.txt        │
                                  │        B/op        │    B/op     vs base                │
CircuitBreakerDetection-4                 144.0 ± 0%     144.0 ± 0%       ~ (p=1.000 n=6) ¹
CircuitBreakerExecution_Success-4         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
CircuitBreakerExecution_Failure-4         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                              ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                  │ baseline-bench.txt │       benchmark-results.txt        │
                                  │     allocs/op      │ allocs/op   vs base                │
CircuitBreakerDetection-4                 1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=6) ¹
CircuitBreakerExecution_Success-4         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
CircuitBreakerExecution_Failure-4         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                              ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

pkg: github.com/GoCodeAlone/workflow/module
                                 │ baseline-bench.txt │        benchmark-results.txt        │
                                 │       sec/op       │    sec/op     vs base               │
JQTransform_Simple-4                     952.3n ± 30%   876.4n ± 28%        ~ (p=0.180 n=6)
JQTransform_ObjectConstruction-4         1.580µ ±  0%   1.449µ ±  2%   -8.32% (p=0.002 n=6)
JQTransform_ArraySelect-4                3.661µ ±  2%   3.283µ ±  0%  -10.34% (p=0.002 n=6)
JQTransform_Complex-4                    40.73µ ±  1%   38.75µ ±  2%   -4.86% (p=0.002 n=6)
JQTransform_Throughput-4                 1.916µ ±  1%   1.772µ ±  0%   -7.52% (p=0.002 n=6)
SSEPublishDelivery-4                     71.01n ±  1%   72.98n ±  1%   +2.77% (p=0.002 n=6)
geomean                                  1.768µ         1.659µ         -6.13%

                                 │ baseline-bench.txt │        benchmark-results.txt         │
                                 │        B/op        │     B/op      vs base                │
JQTransform_Simple-4                   1.273Ki ± 0%     1.273Ki ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_ObjectConstruction-4       1.773Ki ± 0%     1.773Ki ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_ArraySelect-4              2.625Ki ± 0%     2.625Ki ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_Complex-4                  16.22Ki ± 0%     16.22Ki ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_Throughput-4               1.984Ki ± 0%     1.984Ki ± 0%       ~ (p=1.000 n=6) ¹
SSEPublishDelivery-4                     0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                             ²                 +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                 │ baseline-bench.txt │       benchmark-results.txt        │
                                 │     allocs/op      │ allocs/op   vs base                │
JQTransform_Simple-4                     10.00 ± 0%     10.00 ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_ObjectConstruction-4         15.00 ± 0%     15.00 ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_ArraySelect-4                30.00 ± 0%     30.00 ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_Complex-4                    324.0 ± 0%     324.0 ± 0%       ~ (p=1.000 n=6) ¹
JQTransform_Throughput-4                 17.00 ± 0%     17.00 ± 0%       ~ (p=1.000 n=6) ¹
SSEPublishDelivery-4                     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                             ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

pkg: github.com/GoCodeAlone/workflow/schema
                                    │ baseline-bench.txt │       benchmark-results.txt       │
                                    │       sec/op       │   sec/op     vs base              │
SchemaValidation_Simple-4                   1.091µ ± 21%   1.086µ ± 7%       ~ (p=0.907 n=6)
SchemaValidation_AllFields-4                1.680µ ±  5%   1.677µ ± 5%       ~ (p=0.976 n=6)
SchemaValidation_FormatValidation-4         1.599µ ±  2%   1.579µ ± 2%       ~ (p=0.310 n=6)
SchemaValidation_ManySchemas-4              1.831µ ±  3%   1.841µ ± 2%       ~ (p=0.699 n=6)
geomean                                     1.522µ         1.516µ       -0.34%

                                    │ baseline-bench.txt │       benchmark-results.txt        │
                                    │        B/op        │    B/op     vs base                │
SchemaValidation_Simple-4                   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
SchemaValidation_AllFields-4                0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
SchemaValidation_FormatValidation-4         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
SchemaValidation_ManySchemas-4              0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                    │ baseline-bench.txt │       benchmark-results.txt        │
                                    │     allocs/op      │ allocs/op   vs base                │
SchemaValidation_Simple-4                   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
SchemaValidation_AllFields-4                0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
SchemaValidation_FormatValidation-4         0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
SchemaValidation_ManySchemas-4              0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

pkg: github.com/GoCodeAlone/workflow/store
                                   │ baseline-bench.txt │        benchmark-results.txt        │
                                   │       sec/op       │    sec/op     vs base               │
EventStoreAppend_InMemory-4                1.199µ ± 11%   1.158µ ± 18%        ~ (p=0.937 n=6)
EventStoreAppend_SQLite-4                  1.506m ±  6%   1.323m ±  3%  -12.18% (p=0.002 n=6)
GetTimeline_InMemory/events-10-4           13.78µ ±  3%   14.11µ ± 12%   +2.44% (p=0.041 n=6)
GetTimeline_InMemory/events-50-4           61.15µ ± 29%   79.00µ ±  5%  +29.19% (p=0.015 n=6)
GetTimeline_InMemory/events-100-4          122.1µ ±  0%   161.9µ ±  3%  +32.64% (p=0.002 n=6)
GetTimeline_InMemory/events-500-4          631.5µ ±  1%   666.4µ ± 22%   +5.52% (p=0.002 n=6)
GetTimeline_InMemory/events-1000-4         1.286m ±  0%   1.368m ±  1%   +6.37% (p=0.002 n=6)
GetTimeline_SQLite/events-10-4             111.4µ ±  1%   110.5µ ±  0%   -0.86% (p=0.041 n=6)
GetTimeline_SQLite/events-50-4             253.9µ ±  1%   259.8µ ±  1%   +2.35% (p=0.002 n=6)
GetTimeline_SQLite/events-100-4            423.9µ ±  1%   439.2µ ±  1%   +3.62% (p=0.002 n=6)
GetTimeline_SQLite/events-500-4            1.815m ±  0%   1.868m ±  1%   +2.95% (p=0.002 n=6)
GetTimeline_SQLite/events-1000-4           3.527m ±  1%   3.668m ±  2%   +3.99% (p=0.002 n=6)
geomean                                    218.1µ         229.9µ         +5.41%

                                   │ baseline-bench.txt │         benchmark-results.txt         │
                                   │        B/op        │     B/op       vs base                │
EventStoreAppend_InMemory-4                 757.5 ± 13%     785.5 ± 10%       ~ (p=0.288 n=6)
EventStoreAppend_SQLite-4                 1.984Ki ±  2%   1.984Ki ±  1%       ~ (p=0.855 n=6)
GetTimeline_InMemory/events-10-4          7.953Ki ±  0%   7.953Ki ±  0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-50-4          46.62Ki ±  0%   46.62Ki ±  0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-100-4         94.48Ki ±  0%   94.48Ki ±  0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-500-4         472.8Ki ±  0%   472.8Ki ±  0%       ~ (p=0.182 n=6)
GetTimeline_InMemory/events-1000-4        944.3Ki ±  0%   944.3Ki ±  0%       ~ (p=0.182 n=6)
GetTimeline_SQLite/events-10-4            16.74Ki ±  0%   16.74Ki ±  0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-50-4            87.14Ki ±  0%   87.14Ki ±  0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-100-4           175.4Ki ±  0%   175.4Ki ±  0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-500-4           846.1Ki ±  0%   846.1Ki ±  0%  +0.00% (p=0.011 n=6)
GetTimeline_SQLite/events-1000-4          1.639Mi ±  0%   1.639Mi ±  0%  -0.00% (p=0.022 n=6)
geomean                                   67.11Ki         67.31Ki        +0.30%
¹ all samples are equal

                                   │ baseline-bench.txt │        benchmark-results.txt        │
                                   │     allocs/op      │  allocs/op   vs base                │
EventStoreAppend_InMemory-4                  7.000 ± 0%    7.000 ± 0%       ~ (p=1.000 n=6) ¹
EventStoreAppend_SQLite-4                    53.00 ± 0%    53.00 ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-10-4             125.0 ± 0%    125.0 ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-50-4             653.0 ± 0%    653.0 ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-100-4           1.306k ± 0%   1.306k ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-500-4           6.514k ± 0%   6.514k ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_InMemory/events-1000-4          13.02k ± 0%   13.02k ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-10-4               382.0 ± 0%    382.0 ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-50-4              1.852k ± 0%   1.852k ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-100-4             3.681k ± 0%   3.681k ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-500-4             18.54k ± 0%   18.54k ± 0%       ~ (p=1.000 n=6) ¹
GetTimeline_SQLite/events-1000-4            37.29k ± 0%   37.29k ± 0%       ~ (p=1.000 n=6) ¹
geomean                                     1.162k        1.162k       +0.00%
¹ all samples are equal

Benchmarks run with go test -bench=. -benchmem -count=6.
Regressions ≥ 20% are flagged. Results compared via benchstat.

@intel352
intel352 marked this pull request as ready for review May 5, 2026 13:35
Copilot AI review requested due to automatic review settings May 5, 2026 13:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors wfctl infra planning and applying to share a single implementation for discovering iac.provider modules (including per-env resolution + env-var expansion) and for grouping infra resource specs by provider reference, reducing the risk of plan/apply drift for the same config.

Changes:

  • Added shared helpers (resolveProviderDefs, groupSpecsByProviderRef) and shared structs (providerDef, specGroup) in a new dispatch helper file.
  • Updated both the plan path (computePlanForInfraSpecs) and apply path (applyInfraModules) to use the shared helpers instead of duplicated logic.
  • Added unit tests covering provider discovery, grouping behavior, and error paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
cmd/wfctl/infra_provider_dispatch.go New shared provider discovery + spec grouping helpers used by both plan and apply.
cmd/wfctl/infra_provider_dispatch_test.go New unit tests for the shared helper functions and grouping behavior.
cmd/wfctl/infra_plan_provider.go Removes duplicated provider discovery/grouping and delegates to shared helpers.
cmd/wfctl/infra_apply.go Removes duplicated provider discovery/grouping and delegates to shared helpers; updates grouping type usage.

Comment thread cmd/wfctl/infra_provider_dispatch.go Outdated
Comment thread cmd/wfctl/infra_apply.go Outdated
Comment thread cmd/wfctl/infra_provider_dispatch_test.go Outdated
Comment thread cmd/wfctl/infra_provider_dispatch_test.go Outdated
@intel352

intel352 commented May 5, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

- Guard against nil spec.Config in groupSpecsByProviderRef to return
  the 'missing provider field' error instead of panicking
- Add TestGroupSpecsByProviderRef_NilConfigTreatedAsMissingProvider
- Fix comment in infra_apply.go: 'declaration order' → 'first-reference order'
- Fix test name typo: EmptyProvTyp → EmptyProvType
- Replace TestPlanApplyGroupingEquivalence with
  TestPlanApplyGroupingEquivalence_ViaRealEntryPoints, which exercises
  both computePlanForInfraSpecs and applyInfraModules via the real
  package-level computeInfraPlan and resolveIaCProvider seams rather
  than calling the shared helper twice

Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/f6d6cba5-fc43-43f4-bd3f-6624e7669eab

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 5, 2026 13:58

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Applied all four review changes in e466520:

  1. nil spec.Config panic guardgroupSpecsByProviderRef now checks spec.Config == nil before indexing, returning the "missing required 'provider' field" error consistently. Added TestGroupSpecsByProviderRef_NilConfigTreatedAsMissingProvider to pin the behaviour.

  2. Misleading comment — Fixed in infra_apply.go: "Apply each provider group in declaration order" → "Apply each provider group in first-reference order (the order in which each group's first spec appeared in infraSpecs, not iac.provider declaration order)."

  3. Equivalence test via real entry points — Replaced TestPlanApplyGroupingEquivalence with TestPlanApplyGroupingEquivalence_ViaRealEntryPoints. The new test writes a YAML config, stubs both the resolveIaCProvider and computeInfraPlan package-level seams to record (provType, specNames) per call, then runs computePlanForInfraSpecs and applyInfraModules separately and asserts the captured call sequences are identical. This will catch future drift if either path stops using the shared helpers.

  4. Typo fixEmptyProvTypEmptyProvType.

@intel352
intel352 merged commit 6ea6291 into main May 5, 2026
19 of 20 checks passed
@intel352
intel352 deleted the copilot/refactor-shared-iac-provider-helper branch May 5, 2026 14:28
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.

Refactor: extract shared iac.provider discovery + grouping helper used by plan and apply

3 participants