feat: add ordered --add field mutations - #255
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Design
When builtin set is enabled, the CLI exposes set, del, and add together without inspecting endpoint strategies or field types. A command-local pflag collector preserves every explicit operation in flag order; positional sets follow explicit flags. The field-type mutator receives the operation kind and owns its semantics: map additions insert without overwriting (same value is idempotent; a conflicting value errors), string-set additions ensure membership, and scalar additions error. The KV update path applies the same ordered map operations. Legacy SetArgs and DelArgs views remain for existing consumers. Body construction normalizes a touched field once, applies all of its operations, and encodes once before writing; an error prevents the write.
Validation
Direct mutation-body table tests cover map and set additions, existing/conflicting values, empty values, invalid operands, opposite operation orders, preserving unrelated fields, and no input mutation. A separate lifecycle test checks repeated additions across one normalization/encoding pass. Existing KV tests now include ordered mixed operations and a conflict that prevents PUT. A focused Cobra-context test checks interleaved flag capture and positional precedence. go test ./... -count=1 and task check:specs:main passed; the spec check emitted only the existing pr_label/repo_label warnings. No live API mutation was performed.
Also records the agreed test-selection guidance in AGENTS.md: test plausible non-obvious failures rather than mechanical pass-through.