Skip to content

fix(wfctl): honor explicit resource adoption#626

Merged
intel352 merged 1 commit into
mainfrom
codex/adopt-existing-config
May 10, 2026
Merged

fix(wfctl): honor explicit resource adoption#626
intel352 merged 1 commit into
mainfrom
codex/adopt-existing-config

Conversation

@intel352

Copy link
Copy Markdown
Contributor

Summary

  • treats adopt_existing: true as an explicit adoption signal when resolving resource drivers
  • preserves built-in DNS adoption refs before generic name-based adoption
  • lets typed IaC resource drivers use explicit config adoption while rejecting unsupported in-process drivers
  • adds regression coverage for DO-style database adoption, unsupported drivers, and DNS preservation

Verification

  • GOWORK=off go test ./cmd/wfctl
  • GOWORK=off go test ./...

Review

  • adversarial reviewer pass: SHIP-IT; remaining notes are non-blocking typed capability/test-hardening follow-ups

Copilot AI review requested due to automatic review settings May 10, 2026 22:07

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

Updates wfctl infra apply adoption behavior so adopt_existing: true is treated as an explicit signal to adopt resources (including for typed IaC resource drivers), while preserving the special built-in adoption reference behavior for DNS resources.

Changes:

  • Treat adopt_existing: true as an explicit adoption signal when resolving resource drivers and computing adoption refs.
  • Preserve built-in DNS adoption refs ahead of generic name-based adoption.
  • Add regression tests covering config-based adoption, unsupported drivers, and DNS preservation; mark typed drivers as supporting config adoption.

Reviewed changes

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

File Description
cmd/wfctl/infra_apply.go Extends adoption resolution to honor adopt_existing and adds driver capability probing for config-based adoption.
cmd/wfctl/infra_apply_test.go Adds coverage for explicit config adoption, unsupported driver rejection, and DNS built-in ref preservation.
cmd/wfctl/iac_typed_adapter.go Declares typed resource drivers as supporting config-based adoption.
Comments suppressed due to low confidence (1)

cmd/wfctl/infra_apply.go:652

  • When ResourceDriver() returns (nil, nil) (which is treated elsewhere as “no driver”), the current logic caches the nil driver in drivers[spec.Type] and adoptionRefForSpec will silently skip adoption even if adopt_existing: true (or a built-in adoptable type like infra.dns) was explicitly requested. This can result in the resource being created instead of adopted, and also prevents later specs of the same type from re-resolving a now-available driver because the nil is cached.

Suggested fix: treat driver == nil as a resolution failure when explicitAdoptable is true (return an error), and avoid caching nil drivers (only write to drivers when non-nil).

		explicitAdoptable := hasBuiltInAdoptionRef(spec.Type) || boolFromAny(spec.Config["adopt_existing"])
		driver, ok := drivers[spec.Type]
		if !ok {
			var err error
			driver, err = provider.ResourceDriver(spec.Type)
			if err != nil {
				if !explicitAdoptable {
					continue
				}
				return nil, fmt.Errorf("%s/%s: resolve resource driver: %w", spec.Type, spec.Name, err)
			}
			drivers[spec.Type] = driver
		}

@github-actions

github-actions Bot commented May 10, 2026

Copy link
Copy Markdown

⏱ Benchmark Results

No significant performance regressions detected.

benchstat comparison (baseline → PR)
## benchstat: baseline → PR
baseline-bench.txt:262: parsing iteration count: invalid syntax
baseline-bench.txt:342677: parsing iteration count: invalid syntax
baseline-bench.txt:655923: parsing iteration count: invalid syntax
baseline-bench.txt:973027: parsing iteration count: invalid syntax
baseline-bench.txt:1469954: parsing iteration count: invalid syntax
baseline-bench.txt:1789617: parsing iteration count: invalid syntax
benchmark-results.txt:262: parsing iteration count: invalid syntax
benchmark-results.txt:300950: parsing iteration count: invalid syntax
benchmark-results.txt:559377: parsing iteration count: invalid syntax
benchmark-results.txt:898657: parsing iteration count: invalid syntax
benchmark-results.txt:1198934: parsing iteration count: invalid syntax
benchmark-results.txt:1533915: 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              3.334m ± 202%   3.547m ± 196%       ~ (p=0.485 n=6)
ComponentLoad-4                    3.568m ±   2%   3.701m ±   1%  +3.74% (p=0.002 n=6)
ComponentExecute-4                 1.956µ ±   1%   2.007µ ±   1%  +2.58% (p=0.002 n=6)
PoolContention/workers-1-4         1.086µ ±   1%   1.115µ ±   1%  +2.72% (p=0.002 n=6)
PoolContention/workers-2-4         1.079µ ±   6%   1.123µ ±   1%       ~ (p=0.065 n=6)
PoolContention/workers-4-4         1.079µ ±   1%   1.131µ ±   2%  +4.77% (p=0.002 n=6)
PoolContention/workers-8-4         1.077µ ±   1%   1.130µ ±   0%  +4.92% (p=0.002 n=6)
PoolContention/workers-16-4        1.085µ ±   3%   1.126µ ±   2%  +3.73% (p=0.009 n=6)
ComponentLifecycle-4               3.559m ±   1%   3.677m ±   2%  +3.33% (p=0.002 n=6)
SourceValidation-4                 2.300µ ±   1%   2.321µ ±   1%  +0.93% (p=0.006 n=6)
RegistryConcurrent-4               794.7n ±   3%   801.9n ±   1%       ~ (p=0.394 n=6)
LoaderLoadFromString-4             3.588m ±   2%   3.761m ±   2%  +4.83% (p=0.002 n=6)
geomean                            17.46µ          18.08µ         +3.57%

                            │ baseline-bench.txt │        benchmark-results.txt         │
                            │        B/op        │     B/op      vs base                │
InterpreterCreation-4               2.027Mi ± 0%   2.027Mi ± 0%       ~ (p=0.729 n=6)
ComponentLoad-4                     2.180Mi ± 0%   2.180Mi ± 0%       ~ (p=0.485 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.420 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.853 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                  286.4n ± 4%   292.3n ± 4%  +2.08% (p=0.026 n=6)
CircuitBreakerExecution_Success-4          21.55n ± 0%   21.65n ± 1%       ~ (p=1.000 n=6)
CircuitBreakerExecution_Failure-4          66.23n ± 1%   66.30n ± 0%       ~ (p=0.485 n=6)
geomean                                    74.21n        74.86n       +0.87%

                                  │ 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                     905.0n ± 24%   888.7n ± 30%       ~ (p=0.485 n=6)
JQTransform_ObjectConstruction-4         1.431µ ±  0%   1.472µ ± 24%  +2.87% (p=0.002 n=6)
JQTransform_ArraySelect-4                3.276µ ±  2%   3.413µ ±  2%  +4.18% (p=0.002 n=6)
JQTransform_Complex-4                    38.20µ ±  0%   39.37µ ±  0%  +3.06% (p=0.002 n=6)
JQTransform_Throughput-4                 1.758µ ±  0%   1.803µ ±  0%  +2.59% (p=0.002 n=6)
SSEPublishDelivery-4                     66.99n ±  7%   66.08n ±  0%  -1.37% (p=0.002 n=6)
geomean                                  1.635µ         1.660µ        +1.56%

                                 │ 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.108µ ± 3%   1.102µ ± 8%       ~ (p=0.812 n=6)
SchemaValidation_AllFields-4                 1.670µ ± 7%   1.654µ ± 2%       ~ (p=0.165 n=6)
SchemaValidation_FormatValidation-4          1.573µ ± 4%   1.601µ ± 2%       ~ (p=0.258 n=6)
SchemaValidation_ManySchemas-4               1.834µ ± 3%   1.817µ ± 5%       ~ (p=1.000 n=6)
geomean                                      1.520µ        1.517µ       -0.16%

                                    │ 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.144µ ± 14%   1.336µ ± 20%       ~ (p=0.093 n=6)
EventStoreAppend_SQLite-4                  1.389m ±  4%   1.486m ±  3%  +6.96% (p=0.009 n=6)
GetTimeline_InMemory/events-10-4           14.48µ ±  4%   14.47µ ±  5%       ~ (p=0.937 n=6)
GetTimeline_InMemory/events-50-4           79.45µ ±  3%   81.87µ ±  5%  +3.04% (p=0.039 n=6)
GetTimeline_InMemory/events-100-4          160.9µ ±  4%   160.4µ ± 21%       ~ (p=0.937 n=6)
GetTimeline_InMemory/events-500-4          660.2µ ± 13%   662.3µ ±  1%       ~ (p=0.699 n=6)
GetTimeline_InMemory/events-1000-4         1.358m ±  1%   1.376m ±  1%  +1.37% (p=0.004 n=6)
GetTimeline_SQLite/events-10-4             109.6µ ±  0%   112.1µ ±  1%  +2.25% (p=0.002 n=6)
GetTimeline_SQLite/events-50-4             258.5µ ±  1%   261.7µ ±  1%  +1.27% (p=0.002 n=6)
GetTimeline_SQLite/events-100-4            435.8µ ±  0%   444.5µ ±  1%  +1.99% (p=0.002 n=6)
GetTimeline_SQLite/events-500-4            1.850m ±  0%   1.904m ±  1%  +2.92% (p=0.002 n=6)
GetTimeline_SQLite/events-1000-4           3.599m ±  0%   3.685m ±  3%  +2.40% (p=0.002 n=6)
geomean                                    229.8µ         237.1µ        +3.16%

                                   │ baseline-bench.txt │        benchmark-results.txt         │
                                   │        B/op        │     B/op      vs base                │
EventStoreAppend_InMemory-4                  805.5 ± 8%     790.0 ± 6%       ~ (p=0.818 n=6)
EventStoreAppend_SQLite-4                  1.984Ki ± 3%   1.985Ki ± 3%       ~ (p=0.574 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.545 n=6)
GetTimeline_InMemory/events-1000-4         944.3Ki ± 0%   944.3Ki ± 0%       ~ (p=0.210 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%       ~ (p=0.675 n=6)
GetTimeline_SQLite/events-1000-4           1.639Mi ± 0%   1.639Mi ± 0%       ~ (p=0.535 n=6)
geomean                                    67.45Ki        67.35Ki       -0.16%
¹ 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 force-pushed the codex/adopt-existing-config branch from 1b2dbb6 to b4f3714 Compare May 10, 2026 22:23
@intel352 intel352 merged commit 68507fc into main May 10, 2026
20 checks passed
@intel352 intel352 deleted the codex/adopt-existing-config branch May 10, 2026 22:35
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