Repository navigation
Conversation
findings routing-rules|transformation-rules create treats priority/
evaluationOrder as an exact, unique order: creating a rule whose order
collides with an existing one 400s ("order N is already used by
another rule") with no way to insert before another rule.
--insert-at N lists the rule family's existing rules, shifts every one
at or after N down one (highest order first, so no two ever collide
mid-move), then creates the new rule at N. A failure part-way through
names exactly which rules already shifted; nothing is rolled back.
The plain create path's own collision 400 now points at --insert-at.
The list-then-shift sequence needs a read before sendMutationSequence's
step count can be known, so it lives in cmd/mutation.go (the one place
allowed to read before a write) as sendRuleInsertSequence, with a
cursorGuardExemptions entry for its one-shot, non-paginated list read.
Shared between routing-rules (priority) and transformation-rules
(evaluationOrder) via newFindingRulesCmd's existing per-family
parameters.
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.
What
findings routing-rules|transformation-rules create --insert-at Nmakes room for the new rule at priority/evaluation_order N instead of 400ing on a collision: every existing rule at or after N shifts one down first (highest order first, so none collide mid-move), then the new rule is created at N.--insert-atoverrides anypriority/evaluationOrderalready in--body-file. A failure part-way through names exactly which rules already shifted (nothing is rolled back). The plaincreatepath's own collision 400 ("order N is already used by another rule") now points at--insert-at. Shared between routing-rules and transformation-rules via `newFindingRulesCmd's existing per-family parameters.The list-then-shift sequence needs a read before
sendMutationSequence's step count can be known, which the usualwithPreReadpattern cannot provide (it validates/transforms one mutation, not a dynamic step list). It lives incmd/mutation.goassendRuleInsertSequence— the one file allowed to read before a write — with acursorGuardExemptions` entry for its one-shot, non-paginated list read.Why
Bead: global-w291.6
Verification
go build ./...,go vet ./...: cleango test ./...: passgo test -count=1 -shuffle=on ./...: passgolangci-lint run --timeout=3m ./...: 0 issuesgo mod tidy && git diff --exit-code go.mod go.sum: cleangosec -quiet ./...: cleancmd/findings_rules_insert_test.goconfirmed to fail on origin/main (compile/flag errors) before this change and pass after; cover the shift order, partial-failure reporting,--insert-atvalidation, the collision-error hint,--dry-run, the body-file override, and transformation-rules sharing the same path.-shuffle=onsweep (required sincecmd/mutation.gochanged) showed failures, but every one is pre-existing: reproduced identically on a cleanorigin/maincheckout (ephemeral-port exhaustion under this shared machine's load, one unrelatedsetgidfilesystem flake) — none touch findings/routing-rules/mutation.go or any new test. A single-process-shuffle=onrun and the plaingo test ./...both pass cleanly on this branch.Fixes #299