Repository navigation
Port the form rules to core (operator audits step 5, slice 4a) - #4545
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
FormRules is a Java port of the audits FormEquivalence, held to it by shared golden vectors. The case runner applies a scenario's declared rules to both sides of the serialization check, and overrides with rules can now migrate; cond/condExpressionOperator is converted.
This branch has not been deployed
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.
Step 5, slice 4a of the operator audits (design). Stacked on #4544.
Problem
The generated-case runner (#4542) compares Morphia's emitted pipeline with the documented one byte for byte. Many documented examples use a different but equivalent spelling than Morphia emits, which the lock migration already reviewed as declared form rules (
COND_ARRAY,EQ_SHORTHAND,REGEX_FORM, ...). Those rules lived only in the audits module (FormEquivalence), so any fixture with a declared rule could not move to the runner. For example,cond/condExpressionOperatordocuments$cond: {if, then, else}while Morphia emits$cond: [a, b, c]. Under strict comparison the serialization check fails, even though the review has already accepted the two forms as the same expression.Changes
FormRules(core test code) portsFormEquivalenceto Java. It covers every rule that rewrites a form.ALTERNATIVE_COMMANDSpicks among documented commands rather than rewriting one, so it is not ported, and the runner still treats it as unsupported. An unknown rule name also counts as unsupported.generated/vectors/rules.jsoncover positive and negative cases for each rule: 25 in all. Both the Kotlin and the Java implementations are tested against them (RuleVectorsTest,FormRulesTest), and the audits test requires a vector for every rewriting rule. Expected outputs come from the Kotlin rules.OperatorCaseRunnerapplies the scenario'scomparison.rulesto both the documented and the emitted pipeline before the serialization check.FormMigration.documentednow allows overrides with rules. Overrides with retypes, corrections, collections orALTERNATIVE_COMMANDSstill cannot migrate.FixtureMigration.scenariowrites the override's rules intoscenario.json.cond/condExpressionOperatoris converted underCOND_ARRAYand passes under both mappers. Form report: 135 overrides. Inventory: 555 examples, 137 OVERRIDDEN, 98 locked.Decisions for review
{$regex: "p", $options: "i"}read back from JSON becomes a regular expression, so the canonical document form could not survive a round trip. For the same reason, an input key that starts with#is read with$in its place. That lets a vector feed{$regex: "p", $options: "mi"}as a document and check that its options are sorted.RuleVectorsTestuntil it has a vector.Printed-result constraints come in the next slice (4b).