fix: preserve scoped infra plan hashes#716
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a stale-hash false-positive for plans generated with wfctl infra plan --include=<subset>. Previously the scope wasn't persisted in the plan file, so applying the plan against a config containing additional (unscoped) resources rehashed the full desired set and rejected the plan as stale. The fix persists the include scope on the plan and reapplies it before rehashing.
Changes:
- Add
Include []stringtoIaCPlan(JSON-roundtrippable, sorted) recording the plan-time--includescope. - During
infra apply --plan, reconstruct the include set, validate it, and filter both desired specs and current state to that scope before computing the comparison hash. - Add unit (JSON roundtrip) and integration (
TestInfraApplyConsumesScopedPlan) tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| interfaces/iac_state.go | New Include field on IaCPlan with docstring describing semantics. |
| interfaces/iac_state_test.go | JSON roundtrip test for the new field. |
| cmd/wfctl/infra.go | Persist scope at plan time; rehydrate, validate, and filter scope at apply time before stale-hash check. |
| cmd/wfctl/infra_apply_include.go | New sortedIncludeNames / includeSetFromNames helpers to convert between persisted slice and runtime set. |
| cmd/wfctl/infra_apply_plan_test.go | Integration test exercising scoped plan apply against a config with additional unscoped resources. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
509c95d to
3b4cf8c
Compare
Summary
wfctl infra plan --includeresource scope into savedplan.jsonfiles.wfctl infra apply --planstale-hash validation.Verification
GOWORK=off go test ./cmd/wfctl -run TestInfraApplyConsumesScopedPlan -count=1failed before the fix withplan stale: config hash mismatch.GOWORK=off go test ./cmd/wfctl -run 'TestInfraApplyConsumesScopedPlan|TestInfraApplyConsumesPlan|TestInfraApplyPlanSkipBootstrap|TestApplyInclude' -count=1\n-GOWORK=off go test ./interfaces -count=1\n-GOWORK=off go test ./cmd/wfctl -run 'TestInfraApply|TestInfraPlan|TestApplyInclude|TestPlanInclude|TestIaCPlan|TestParseInfraConfig_AutoBootstrap' -count=1\n-GOWORK=off go build ./cmd/wfctl\n-git diff --check