Adopt typed compare engine output and remove legacy violation contract#105
Adopt typed compare engine output and remove legacy violation contract#105
Conversation
|
This change is part of the following stack:
Change managed by git-spice. |
guineveresaenger
left a comment
There was a problem hiding this comment.
I've got a few comments but they may be because I haven't worked my way all the way down the PR stack yet.
internal/compare/engine.go
Outdated
| *changes = append(*changes, newChange(category, name, path, ChangeKindTypeChanged, fmt.Sprintf("type changed from %q to %q", oldType, newType))) | ||
| } | ||
|
|
||
| appendTypeChanges(changes, category, name, append(slicesClone(path), "items"), old.Items, new.Items) |
There was a problem hiding this comment.
is slicesClone just for safety?
There was a problem hiding this comment.
Yep, exactly for path-slice safety during recursive append(...) calls. I’ve now switched this over to stdlib slices.Clone so we keep the safety behavior without a custom helper.
internal/compare/engine.go
Outdated
| appendTypeChanges(changes, category, name, append(slicesClone(path), "additional properties"), old.AdditionalProperties, new.AdditionalProperties) | ||
| } | ||
|
|
||
| func slicesClone(xs []string) []string { |
There was a problem hiding this comment.
Any reason not to use the stdlib https://pkg.go.dev/slices#Clone?
There was a problem hiding this comment.
Good catch, I thought I replaced all usages of this type of thing, but missed one!
| Changes: changes, | ||
| NewResources: newResources, | ||
| NewFunctions: newFunctions, | ||
| Violations: BreakingChanges(oldSchema, newSchema), |
There was a problem hiding this comment.
Are we looking at getting rid of this further down the PR stack? I'd think that breaking changes would ultimately be part of Changes? I'm asking because buildChanges is effectively the same walk that BreankingChanges does.
There was a problem hiding this comment.
Yes, that’s the direction. This PR introduces typed Changes while still keeping Violations to make this PR diff smaller. The downstream stack PRs remove the legacy path.
| for _, req := range f.Outputs.Required { | ||
| _, stillExists := f.Outputs.Properties[req] | ||
| stillExists := false | ||
| if newFunc.Outputs != nil { |
There was a problem hiding this comment.
Should this be fixed separately?
There was a problem hiding this comment.
I kept this here because it’s a correctness fix in the same compare logic path touched by this refactor. Without it, we can incorrectly report “required -> optional” when the output is actually removed. I added regression coverage for this case in engine_test.go.
| newRequired := set.FromSlice(newTyp.Required) | ||
| for _, r := range typ.Required { | ||
| _, stillExists := typ.Properties[r] | ||
| _, stillExists := newTyp.Properties[r] |
There was a problem hiding this comment.
same - isn't this an unrelated change?
There was a problem hiding this comment.
Similar reasoning here: this is a bug fix in requiredness gating (newTyp.Properties is the right source of truth for “still exists”). Keeping it with this change avoided carrying known-bad behavior into the typed engine transition, and it now has test coverage.
Squash details: - Branch: st-ac3.17.3.1-typed-change-engine - Base: st-ac3.17-011-normalize-metadata-contract - Squashed commits: 5 Original commits: - d437c23 internal/compare: emit typed change report - b1c2126 internal/compare: make analyze typed-first contract - b92c677 internal/compare: remove violations shim from report - cc68ad5 internal/compare: restore compatibility and fix requiredness gating - e576846 Fix requiredness gating for removed outputs and properties
5048446 to
cf2f789
Compare
## Summary This PR rebuilds compare projections and renderers to consume typed change data directly. It removes legacy rendering assumptions and aligns JSON/text output contracts with the typed engine introduced in #105. ## What Changed - Reworked compare projection logic to build structured `changes` and `grouped` views from typed events. - Updated JSON and text renderers to use the structured model consistently. - Removed dead legacy-engine artifacts from compare internals. - Added/updated golden fixtures and renderer tests for deterministic contract coverage. - Added compare-level structured golden coverage for fixture parity. ## Why Renderer/projection behavior should be derived from one typed source of truth. Doing this here makes later normalization lookups additive, instead of requiring command-layer patchups. ## Context - Builds directly on #105. - Provides the projection baseline that later lookup-focused PRs rely on.
…antics (#112) ## Summary This PR finalizes the compare structured-output wave by aligning contracts, goldens, and harness coverage across compare and cmd paths. It also captures finalized output semantics for capped text rendering and full structured JSON output. ## What Changed - Finalized structured compare/cmd golden harness coverage for AWS mini fixtures. - Updated compare/cmd tests and fixture expectations to the finalized contracts. - Kept JSON structured output uncapped while keeping text output capped. - Refined requiredness/remap severity/breaking classification to match the final policy. - Updated README/docs and supporting command/test plumbing required for end-to-end parity. ## Why This closes the loop on behavior, tests, and documentation so reviewers can validate a stable end-state at the stack tip. It ensures the same semantics are exercised by both compare package tests and command harness tests. ## Context - Final stack tip on top of #111. - Consolidates contract/golden alignment after upstream engine and lookup integrations (#105–#111). closes #83 closes #84
Summary
This PR establishes typed
Changeitems as the canonical output of the internal compare engine.It replaces violation plumbing with a typed-first contract that downstream renderers can consume directly.
What Changed
internal/comparemodel and engine output to emit typed change records.Why
The stack needs a single canonical change model before projection/rendering and lookup normalization can be simplified safely.
This is the foundation for follow-up projection and lookup integration work in #106 and above.