diff --git a/src/bootstrap/app/build.gradle b/src/bootstrap/app/build.gradle index 0ef49b8b..e0697407 100644 --- a/src/bootstrap/app/build.gradle +++ b/src/bootstrap/app/build.gradle @@ -340,7 +340,9 @@ def repositoryRootForContractTests = rootProject.projectDir def repositoryContractExcludes = ['**/build/**', '**/.gradle/**', '**/node_modules/**', '.claude/worktrees/**'] def repositoryContractInputs = files( fileTree(repositoryRootForContractTests) { - include '.gitea/**', '.github/**', 'compose/**', 'scripts/**', '*.yml', '*.yaml', '*.example', '.tool-versions' + // docs/registries/** are machine contracts, not prose: a malformed registry must fail + // the pull request (RegistrySchemaPullRequestGateTest), so the lane reruns when one changes. + include '.gitea/**', '.github/**', 'compose/**', 'scripts/**', '*.yml', '*.yaml', 'docs/registries/**', '*.example', '.tool-versions' exclude '**/*.md' exclude repositoryContractExcludes }, diff --git a/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ContractRegistrySchemaGovernanceTest.java b/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ContractRegistrySchemaGovernanceTest.java index bed07c83..337509ce 100644 --- a/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ContractRegistrySchemaGovernanceTest.java +++ b/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ContractRegistrySchemaGovernanceTest.java @@ -278,6 +278,16 @@ class ContractRegistrySchemaGovernanceTest { required_test: test:metric """, "compatibility_impact"); + // A row that simply OMITS compatibility_impact must fail with the same descriptive error, not a + // NullPointerException from Set.of(...).contains(null) (W4 BE-CONFIG-001 stranded this field). + assertInvalidUniversalMetric( + tempDir.resolve("missing-compatibility"), + """ + - name: metric + owner_branch: owner + required_test: test:metric + """, + "compatibility_impact"); assertInvalidUniversalMetric( tempDir.resolve("blank-required-test"), """ diff --git a/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java b/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java index 723b8a55..ccd86de7 100644 --- a/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java +++ b/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java @@ -37,6 +37,8 @@ import org.yaml.snakeyaml.Yaml; * env-keys.yaml). *
{@link ContractRegistrySchemaGovernanceTest} owns the registry schema — every universal row + * must carry a legal {@code compatibility_impact} and a non-blank {@code required_test} — but it is + * tagged {@code document-contract}, so it runs only in the main stage. A malformed registry (W4 red + * team BE-CONFIG-001 inserted {@code MANAGEMENT_SERVER_ADDRESS} mid-row and stranded {@code + * MANAGEMENT_SERVER_PORT}'s {@code compatibility_impact} and {@code required_test} onto it) + * therefore passes {@code prCheck} and fails only after merge, in {@code mainCheck} — found after + * the merge it should have blocked. + * + *
This runs the identical fail-closed {@link RegistryGovernanceCatalog} validation in the {@code + * repository-contract} lane, so the same defect blocks the pull request instead of landing on main. + * {@code docs/registries/**} is wired as a repository-contract input (this leaf's build.gradle) so + * the lane reruns whenever a registry changes rather than passing on a stale up-to-date result. + */ +@Tag("repository-contract") +class RegistrySchemaPullRequestGateTest { + + @Test + void everyContractRegistryPassesSchemaGovernanceBeforeMerge() throws Exception { + Path registriesDir = + RepositoryContractResources.fromSystemProperty().requireTrackedDirectory("docs/registries"); + RegistryGovernanceCatalog.validate(registriesDir); + } +}