diff --git a/generated/bundled_spec.yaml b/generated/bundled_spec.yaml index c68cd6773..9248920db 100644 --- a/generated/bundled_spec.yaml +++ b/generated/bundled_spec.yaml @@ -13370,9 +13370,9 @@ components: type: object required: - name - - value - scope - tenantId + - value properties: value: description: Full value of this cluster variable. @@ -13392,11 +13392,11 @@ components: description: Cluster variable search response item. type: object required: + - isTruncated + - name - scope - tenantId - - isTruncated - value - - name properties: value: description: Value of this cluster variable. Can be truncated. @@ -14648,25 +14648,25 @@ components: ' required: - - evaluationDate + - decisionDefinitionId - decisionDefinitionKey - - result - - matchedRules - - rootDecisionDefinitionKey - - evaluatedInputs - - rootProcessInstanceKey - - decisionDefinitionVersion - decisionDefinitionName - - tenantId - - processDefinitionKey - - elementInstanceKey - - state - - decisionEvaluationKey - - evaluationFailure - decisionDefinitionType - - decisionDefinitionId + - decisionDefinitionVersion - decisionEvaluationInstanceKey + - decisionEvaluationKey + - elementInstanceKey + - evaluatedInputs + - evaluationDate + - evaluationFailure + - matchedRules + - processDefinitionKey - processInstanceKey + - result + - rootDecisionDefinitionKey + - rootProcessInstanceKey + - state + - tenantId EvaluatedDecisionInputItem: required: - inputId @@ -16342,13 +16342,13 @@ components: GlobalTaskListenerResult: type: object required: + - afterNonGlobal - eventTypes - - retries + - id - priority + - retries - source - type - - id - - afterNonGlobal properties: id: $ref: '#/components/schemas/GlobalListenerId' @@ -19560,9 +19560,9 @@ components: description: The name of the mapping rule. required: - claimName - - name - claimValue - mappingRuleId + - name MappingRuleUpdateRequest: type: object properties: @@ -19576,9 +19576,9 @@ components: type: string description: The name of the mapping rule. required: - - name - - claimValue - claimName + - claimValue + - name MappingRuleCreateUpdateResult: type: object properties: @@ -19615,10 +19615,10 @@ components: type: string description: The unique ID of the mapping rule. required: - - name - - claimValue - claimName + - claimValue - mappingRuleId + - name MappingRuleUpdateResult: type: object properties: @@ -19635,10 +19635,10 @@ components: type: string description: The unique ID of the mapping rule. required: - - name - - claimValue - claimName + - claimValue - mappingRuleId + - name MappingRuleSearchQueryResult: required: - items @@ -22989,11 +22989,11 @@ components: maxLength: 25 UsageMetricsResponse: required: - - tenants - - decisionInstances - activeTenants - - processInstances - assignees + - decisionInstances + - processInstances + - tenants type: object properties: activeTenants: @@ -24316,14 +24316,14 @@ components: $ref: '#/components/schemas/SearchQueryPageResponse' VariableSearchResult: required: - - rootProcessInstanceKey - - tenantId - isTruncated - - value - name - - variableKey - processInstanceKey + - rootProcessInstanceKey - scopeKey + - tenantId + - value + - variableKey description: Variable search response item. type: object properties: @@ -24405,13 +24405,13 @@ components: description: Variable search response item. type: object required: + - name + - processInstanceKey - rootProcessInstanceKey + - scopeKey - tenantId - - name - value - variableKey - - processInstanceKey - - scopeKey properties: value: description: Full value of this variable. @@ -25576,8 +25576,8 @@ components: $ref: '#/components/schemas/MigrateProcessInstanceMappingInstruction' description: The mapping instructions. required: - - targetProcessDefinitionKey - mappingInstructions + - targetProcessDefinitionKey title: ProcessInstanceMigrationBatchOperationRequestMigrationPlan ClusterVariableSearchQueryRequestFilter: description: The cluster variable search filters. @@ -25880,11 +25880,11 @@ components: minLength: 1 maxLength: 25 required: - - resourceName + - processDefinitionId + - processDefinitionKey - processDefinitionVersion + - resourceName - tenantId - - processDefinitionKey - - processDefinitionId title: DeploymentMetadataResultProcessDefinition DeploymentMetadataResultDecisionDefinition: nullable: true @@ -25954,12 +25954,12 @@ components: minLength: 1 maxLength: 25 required: - - decisionRequirementsId - - decisionDefinitionKey - - tenantId - decisionDefinitionId - - name + - decisionDefinitionKey + - decisionRequirementsId - decisionRequirementsKey + - name + - tenantId - version title: DeploymentMetadataResultDecisionDefinition DeploymentMetadataResultDecisionRequirements: @@ -26004,11 +26004,11 @@ components: minLength: 1 maxLength: 25 required: + - decisionRequirementsId + - decisionRequirementsKey - decisionRequirementsName - resourceName - - decisionRequirementsId - tenantId - - decisionRequirementsKey - version title: DeploymentMetadataResultDecisionRequirements DeploymentMetadataResultForm: @@ -26049,10 +26049,10 @@ components: minLength: 1 maxLength: 25 required: - - resourceName + - formId - formKey + - resourceName - tenantId - - formId - version title: DeploymentMetadataResultForm DeploymentMetadataResultResource: @@ -26085,10 +26085,10 @@ components: - $ref: '#/components/schemas/DecisionDefinitionKey' format: ResourceKey required: + - resourceId - resourceKey - resourceName - tenantId - - resourceId - version title: DeploymentMetadataResultResource DeleteResourceResponseBatchOperation: @@ -26556,16 +26556,16 @@ components: minLength: 1 maxLength: 25 required: + - action + - assignee + - candidateGroups - candidateUsers + - changedAttributes - dueDate - - assignee + - followUpDate - formKey - - userTaskKey - priority - - changedAttributes - - followUpDate - - candidateGroups - - action + - userTaskKey title: ActivatedJobResultUserTask JobSearchQueryFilter: description: The job search filters. @@ -27423,8 +27423,8 @@ components: type: integer format: int64 required: - - decisionInstances - assignees + - decisionInstances - processInstances title: UsageMetricsResponseTenants TenantSearchQueryRequestFilter: diff --git a/hooks/pre_gen/0100_patch_bundled_spec.py b/hooks/pre_gen/0100_patch_bundled_spec.py index ced8255a4..2ba4826b6 100644 --- a/hooks/pre_gen/0100_patch_bundled_spec.py +++ b/hooks/pre_gen/0100_patch_bundled_spec.py @@ -291,7 +291,14 @@ def flatten_schema(self, schema: SpecNode) -> SpecNode: if merged_props: new_schema["properties"] = merged_props if merged_required: - new_schema["required"] = list(merged_required) + # Deterministic ordering — merged_required is a set + # whose Python iteration order is hash-randomised + # across processes. Without sorting, every + # regeneration flips `required:` array order in the + # bundled spec, producing perpetual content-free + # merge conflicts. Mirrors the same fix applied + # upstream in camunda-schema-bundler 2.4.2 (#35). + new_schema["required"] = sorted(merged_required) # If we have a oneOf, removing the explicit type: object allows the union to work # even if some options are primitives (like string vs object filter) diff --git a/tests/unit/test_patch_bundled_spec_determinism.py b/tests/unit/test_patch_bundled_spec_determinism.py new file mode 100644 index 000000000..aa28dfb21 --- /dev/null +++ b/tests/unit/test_patch_bundled_spec_determinism.py @@ -0,0 +1,51 @@ +"""Generation must be deterministic: the allOf flattener's merged `required` list.""" + +import importlib.util +from pathlib import Path +from typing import Any + +_HOOK = ( + Path(__file__).resolve().parents[2] + / "hooks" + / "pre_gen" + / "0100_patch_bundled_spec.py" +) +_spec = importlib.util.spec_from_file_location("patch_bundled_spec", _HOOK) +assert _spec is not None and _spec.loader is not None +patch_bundled_spec = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(patch_bundled_spec) + + +def test_flattened_allof_required_is_sorted() -> None: + # A set's iteration order depends on PYTHONHASHSEED, so emitting it unsorted + # reorders `required:` in generated/bundled_spec.yaml on every regeneration. + names = [ + "zeta", + "alpha", + "kappa", + "beta", + "omega", + "delta", + "eta", + "gamma", + "iota", + "theta", + ] + schema: dict[str, Any] = { + "allOf": [ + { + "type": "object", + "properties": {n: {"type": "string"} for n in names[:5]}, + "required": names[:5], + }, + { + "type": "object", + "properties": {n: {"type": "string"} for n in names[5:]}, + "required": names[5:], + }, + ] + } + + flattened = patch_bundled_spec.SpecFlattener({}).flatten_schema(schema) + + assert flattened["required"] == sorted(names)