From 855930e54c73c008b1289ecaf718e73fae1e980f Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Wed, 11 Nov 2026 07:25:01 -0600 Subject: [PATCH 1/6] Consumer entry: its protected_paths in the hooks' syntax, held by consumer/1 and read by the one matcher (#141) schemas/consumer.schema.json gives the entry of design section 3.12 a schema, its protected paths each config/hooks.json's own path. An example, three counter-examples, a test that the Kernel's matcher and the session hooks' read each pattern alike, and five mutants. Co-Authored-By: Claude Opus 5.5 --- docs/architecture/software-factory-design.md | 7 +- examples/consumer.json | 13 +++ .../consumer.a-glob-of-another-syntax.json | 24 +++++ .../consumer.a-path-from-the-root.json | 24 +++++ .../consumer.a-path-that-climbs-out.json | 24 +++++ schemas/consumer.schema.json | 88 +++++++++++++++++++ tests/test_tools.py | 32 +++++++ tools/check_examples.py | 2 +- tools/mutants.py | 11 +++ 9 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 examples/consumer.json create mode 100644 examples/invalid/consumer.a-glob-of-another-syntax.json create mode 100644 examples/invalid/consumer.a-path-from-the-root.json create mode 100644 examples/invalid/consumer.a-path-that-climbs-out.json create mode 100644 schemas/consumer.schema.json diff --git a/docs/architecture/software-factory-design.md b/docs/architecture/software-factory-design.md index 5677818cf..dafcbb3c3 100644 --- a/docs/architecture/software-factory-design.md +++ b/docs/architecture/software-factory-design.md @@ -1064,10 +1064,15 @@ ci_workflows: ["CI"] verify: setup: "scripts/factory-setup.sh" test: "scripts/factory-test.sh" - protected_paths: ["scripts/factory-setup.sh", "scripts/factory-test.sh", ".github/**", "CODEOWNERS"] + protected_paths: ["scripts/factory-setup.sh", "scripts/factory-test.sh", ".github/", "CODEOWNERS"] reviewers: [coderabbit, cubic, gemini-code-assist, sonarqube-cloud] ``` +Its `protected_paths` are in the one syntax of `config/hooks.json`, matched by the one matcher the Kernel and the +session hooks share: a final `/` is the directory and everything below it, `*` is any part of one name, `**` as a +whole name any run of names, and case is ignored. `schemas/consumer.schema.json` holds them to it ("Consumer entry: +its protected_paths in the hooks' syntax", issue 141). + Adopting the Factory is more than this entry. The repo also needs the two scripts, a ruleset that matches, the machine user as a code owner, and its Advisory reviewers configured. A **readiness check** in each pass compares every Consumer repo with that list and publishes what is missing, so diff --git a/examples/consumer.json b/examples/consumer.json new file mode 100644 index 000000000..7f51443e0 --- /dev/null +++ b/examples/consumer.json @@ -0,0 +1,13 @@ +{ + "schema": "consumer/1", + "repo": "combsmith/markets", + "ring": "next", + "owner_role": "devops-lead", + "ci_workflows": ["CI"], + "verify": { + "setup": "scripts/factory-setup.sh", + "test": "scripts/factory-test.sh", + "protected_paths": ["scripts/factory-setup.sh", "scripts/factory-test.sh", ".github/", "CODEOWNERS", "tests/**/conftest.py", "*.lock"] + }, + "reviewers": ["coderabbit", "cubic", "gemini-code-assist", "sonarqube-cloud"] +} diff --git a/examples/invalid/consumer.a-glob-of-another-syntax.json b/examples/invalid/consumer.a-glob-of-another-syntax.json new file mode 100644 index 000000000..aa0b2ad1f --- /dev/null +++ b/examples/invalid/consumer.a-glob-of-another-syntax.json @@ -0,0 +1,24 @@ +{ + "schema": "consumer/1", + "repo": "combsmith/markets", + "ring": "next", + "owner_role": "devops-lead", + "ci_workflows": [ + "CI" + ], + "verify": { + "setup": "scripts/factory-setup.sh", + "test": "scripts/factory-test.sh", + "protected_paths": [ + "scripts/factory-setup.sh", + "scripts/factory-test.sh", + "scripts/factory-?.sh" + ] + }, + "reviewers": [ + "coderabbit", + "cubic", + "gemini-code-assist", + "sonarqube-cloud" + ] +} diff --git a/examples/invalid/consumer.a-path-from-the-root.json b/examples/invalid/consumer.a-path-from-the-root.json new file mode 100644 index 000000000..e524a858a --- /dev/null +++ b/examples/invalid/consumer.a-path-from-the-root.json @@ -0,0 +1,24 @@ +{ + "schema": "consumer/1", + "repo": "combsmith/markets", + "ring": "next", + "owner_role": "devops-lead", + "ci_workflows": [ + "CI" + ], + "verify": { + "setup": "scripts/factory-setup.sh", + "test": "scripts/factory-test.sh", + "protected_paths": [ + "scripts/factory-setup.sh", + "scripts/factory-test.sh", + "/CODEOWNERS" + ] + }, + "reviewers": [ + "coderabbit", + "cubic", + "gemini-code-assist", + "sonarqube-cloud" + ] +} diff --git a/examples/invalid/consumer.a-path-that-climbs-out.json b/examples/invalid/consumer.a-path-that-climbs-out.json new file mode 100644 index 000000000..a34aa9225 --- /dev/null +++ b/examples/invalid/consumer.a-path-that-climbs-out.json @@ -0,0 +1,24 @@ +{ + "schema": "consumer/1", + "repo": "combsmith/markets", + "ring": "next", + "owner_role": "devops-lead", + "ci_workflows": [ + "CI" + ], + "verify": { + "setup": "scripts/factory-setup.sh", + "test": "scripts/factory-test.sh", + "protected_paths": [ + "scripts/factory-setup.sh", + "scripts/factory-test.sh", + "../CODEOWNERS" + ] + }, + "reviewers": [ + "coderabbit", + "cubic", + "gemini-code-assist", + "sonarqube-cloud" + ] +} diff --git a/schemas/consumer.schema.json b/schemas/consumer.schema.json new file mode 100644 index 000000000..1ccfc9cc5 --- /dev/null +++ b/schemas/consumer.schema.json @@ -0,0 +1,88 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "consumer/1: how one Consumer repo is served (design section 3.12). A data file: its path is its identity and the commit its Release. Its protected paths are in the one syntax of config/hooks.json, read by the one matcher the Kernel and the session hooks share (kernel/derive.py, matches; tools/hooks/protected.py, entries). What reads an entry, the readiness check and apply's refusal for a Consumer repo, is slice 3's.", + "type": "object", + "additionalProperties": false, + "required": [ + "schema", + "repo", + "ring", + "owner_role", + "ci_workflows", + "verify", + "reviewers" + ], + "properties": { + "schema": { + "const": "consumer/1" + }, + "repo": { + "type": "string", + "pattern": "^[A-Za-z0-9-]+/[A-Za-z0-9._-]+$" + }, + "ring": { + "description": "The Channel that serves the repo, as release/rings.json names it.", + "enum": [ + "next", + "stable" + ] + }, + "owner_role": { + "type": "string", + "pattern": "^[a-z][a-z-]*$" + }, + "ci_workflows": { + "description": "The name of each of the repo's own workflows whose checks the Factory reads, as GitHub shows it.", + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string", + "minLength": 1 + } + }, + "verify": { + "type": "object", + "additionalProperties": false, + "required": [ + "setup", + "test", + "protected_paths" + ], + "properties": { + "setup": { + "description": "The repo's setup script, by its path from the top of the repo.", + "$ref": "#/$defs/file" + }, + "test": { + "description": "The repo's test script, by its path from the top of the repo.", + "$ref": "#/$defs/file" + }, + "protected_paths": { + "description": "What apply refuses a Role's push to without a person, and a change to which a model Lens reviews: relative to the top of the repo; a path ending in / is a directory and all below it; * stands for any part of one name, and ** as a whole name for any run of names; case is ignored (issue 141, decision 0020).", + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "$ref": "hooks.schema.json#/$defs/path" + } + } + } + }, + "reviewers": { + "description": "The repo's Advisory reviewers, by the name the Factory gives each.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "pattern": "^[a-z][a-z0-9-]*$" + } + } + }, + "$defs": { + "file": { + "type": "string", + "pattern": "^(?!.*(^|/)\\.{1,2}(/|$))[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)*$" + } + } +} diff --git a/tests/test_tools.py b/tests/test_tools.py index 6eeacae12..42f60701d 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1217,6 +1217,38 @@ def test_what_the_machine_user_may_never_hold_has_a_counter_example(self): # is names = {path.name for path in (ROOT / "examples" / "invalid").glob("machine-user.*.json")} self.assertEqual(len(names), 6) + def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher(self): # issue 141 + # A Consumer entry's protected paths are config/hooks.json's own paths (decision 0020): the schema holds each + # to that syntax and refuses a list with none, and the Kernel and the session hooks read each alike. + from tools import jsonschema_lite + from tools.hooks import protected + self.assertEqual([p for p in check_examples.run(ROOT) if "consumer" in p], []) + schemas = {p.name[: -len(".schema.json")]: json.loads(p.read_text()) for p in (ROOT / "schemas").glob("*.schema.json")} + entry = json.loads((ROOT / "examples" / "consumer.json").read_text()) + patterns = entry["verify"]["protected_paths"] + for wrong in ([], ["CODEOWNERS", "CODEOWNERS"], ["/CODEOWNERS"], ["scripts/factory-?.sh"], ["../CODEOWNERS"], + ["docs//CODEOWNERS"], ["./CODEOWNERS"], ["scripts/{a,b}.sh"], ["C:\\scripts"]): + bad = copy.deepcopy(entry) + bad["verify"]["protected_paths"] = wrong + self.assertTrue(jsonschema_lite.validate(bad, schemas["consumer"], schemas=schemas), wrong) + bad = copy.deepcopy(entry) + del bad["verify"]["protected_paths"] + self.assertTrue(jsonschema_lite.validate(bad, schemas["consumer"], schemas=schemas)) + # Each the schema lets through is one the Kernel reads, and each the Kernel refuses the schema refuses too. + for pattern in patterns + ["*/__init__.*", "a/**/b/", "**"]: + self.assertTrue(derive.readable_pattern(pattern), pattern) + for pattern in ("/CODEOWNERS", "../CODEOWNERS", "docs//CODEOWNERS", "./CODEOWNERS"): + self.assertFalse(derive.readable_pattern(pattern), pattern) + # One matcher: what the Kernel finds each path to be, the session hooks find it to be, in any case. + hooks = protected.entries([(p, "") for p in patterns]) + for path, want in (("scripts/factory-setup.sh", ["scripts/factory-setup.sh"]), ("SCRIPTS/Factory-Test.sh", ["scripts/factory-test.sh"]), + (".github/workflows/ci.yml", [".github/"]), (".github", [".github/"]), ("CODEOWNERS", ["CODEOWNERS"]), + ("docs/CODEOWNERS", []), ("tests/conftest.py", ["tests/**/conftest.py"]), + ("tests/a/b/conftest.py", ["tests/**/conftest.py"]), ("poetry.lock", ["*.lock"]), + ("a/poetry.lock", []), ("scripts/other.sh", []), (".githubx/a", [])): + self.assertEqual([p for p in patterns if derive.matches(p, path)], want, path) + self.assertEqual([p for p, _, _, whole in hooks if whole.match(path.casefold())], want, path) + def machine_users_live_answers(self, held: dict) -> list: """What GitHub answers when nothing has drifted: the org's repos hold the two left out, an archived one and an advisory's fork, and each repo has another team beside the code owners'.""" diff --git a/tools/check_examples.py b/tools/check_examples.py index 03bc8890b..008d54c00 100644 --- a/tools/check_examples.py +++ b/tools/check_examples.py @@ -39,7 +39,7 @@ "config": "data", "hooks": "data", "lifecycle": "data", "authority": "data", "apps": "data", "rubric": "data", "checklist": "data", "acceptance": "data", "trial": "data", "role": "data", "feed": "data", "eval-case": "data", "eval-set": "data", "context-eval": "data", "controller": "data", "harness": "data", "rulesets": "data", "credential-ages": "data", "machine-user": "data", - "rings": "data", "release-fixture": "data", "release-exchanges": "record"} + "rings": "data", "consumer": "data", "release-fixture": "data", "release-exchanges": "record"} RELEASE = "^factory/v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" # What one Run carries, and what is written from it, holds codes, never text: a string in these schemas is held by an # enum, a const or a pattern anchored at both ends, unless it is a property named `body`, or sits under one named diff --git a/tools/mutants.py b/tools/mutants.py index 66ef5c88d..a2306a5f4 100644 --- a/tools/mutants.py +++ b/tools/mutants.py @@ -4717,6 +4717,17 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ('a preflight case keeps no mark in the ledger', 'harness/eval/__init__.py', ' alternates=beside, surplus=away, usages=spent)["cases"]]', ' usages=spent)["cases"]]', ('tests.test_evals.EvalJob.test_a_preflight_case_keeps_its_marks_in_the_ledger_as_the_sets_do',)), + # Issue 141: a Consumer entry's protected paths are in the hooks' syntax, one at least, each once. + ("a Consumer's protected path may be in any syntax", 'schemas/consumer.schema.json', + '"$ref": "hooks.schema.json#/$defs/path"', '"type": "string"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer may protect no path", 'schemas/consumer.schema.json', + ' "minItems": 1,\n "uniqueItems": true,\n "items": {\n "$ref"', ' "uniqueItems": true,\n "items": {\n "$ref"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer's protected path may be listed twice", 'schemas/consumer.schema.json', + ' "uniqueItems": true,\n "items": {\n "$ref"', ' "items": {\n "$ref"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry needs no protected paths", 'schemas/consumer.schema.json', + ' "test",\n "protected_paths"\n', ' "test"\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry is in no class of the envelope", 'tools/check_examples.py', + ' "consumer": "data",', '', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ('a ledger need hold no preflight', 'schemas/eval-ledger.schema.json', ' "cases",\n "preflight"\n', ' "cases"\n', ('tests.test_evals.TheSet.test_a_case_dropped_under_evals_in_any_file_is_caught',)), From 9804b52f648bde187095ec253861d149bf4a2368 Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Wed, 11 Nov 2026 07:45:21 -0600 Subject: [PATCH 2/6] The Claude review's findings: an entry's setup and test scripts are among its protected paths, a script is a path not a pattern, and the words say two matchers read alike Co-Authored-By: Claude Opus 5.5 --- docs/architecture/software-factory-design.md | 11 ++++---- .../consumer.a-script-left-unprotected.json | 24 ++++++++++++++++ .../consumer.a-script-named-by-a-pattern.json | 28 +++++++++++++++++++ schemas/consumer.schema.json | 6 ++-- tests/test_tools.py | 12 ++++++++ tools/check_examples.py | 14 +++++++++- tools/mutants.py | 12 +++++++- 7 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 examples/invalid/consumer.a-script-left-unprotected.json create mode 100644 examples/invalid/consumer.a-script-named-by-a-pattern.json diff --git a/docs/architecture/software-factory-design.md b/docs/architecture/software-factory-design.md index dafcbb3c3..13ca808fd 100644 --- a/docs/architecture/software-factory-design.md +++ b/docs/architecture/software-factory-design.md @@ -1068,10 +1068,11 @@ verify: reviewers: [coderabbit, cubic, gemini-code-assist, sonarqube-cloud] ``` -Its `protected_paths` are in the one syntax of `config/hooks.json`, matched by the one matcher the Kernel and the -session hooks share: a final `/` is the directory and everything below it, `*` is any part of one name, `**` as a -whole name any run of names, and case is ignored. `schemas/consumer.schema.json` holds them to it ("Consumer entry: -its protected_paths in the hooks' syntax", issue 141). +Its `protected_paths` are in the one syntax of `config/hooks.json`, read alike by the Kernel's matcher and the session +hooks': a final `/` is the directory and everything below it, `*` is any part of one name, `**` as a +whole name any run of names, and case is ignored. So `.github/*` leaves `.github/workflows/` open, and `CODEOWNERS` +leaves `.github/CODEOWNERS`. They name the setup and test scripts. `schemas/consumer.schema.json` and +`tools/check_examples.py` hold them to it ("Consumer entry: its protected_paths in the hooks' syntax", issue 141). Adopting the Factory is more than this entry. The repo also needs the two scripts, a ruleset that matches, the machine user as a code owner, and its Advisory reviewers configured. A **readiness @@ -2188,7 +2189,7 @@ Run by `factory / verify` over the manifests and the authority table. - An Intent that decides a gate and owns no category of Finding, as the readiness Intent does, has a promotion record of its own before any Effect of it is applied. - A Role named `owner` of a category has a promotion record. A `shadow` Role's decision is never read by the gate. -- Every Consumer entry names an owner Role, a setup command, a test command and protected paths. +- Every Consumer entry names an owner Role, a setup script, a test script and protected paths that name both. The interaction matrix in ยง5.1 is generated from this data in the Factory repo. A stale copy fails the check. diff --git a/examples/invalid/consumer.a-script-left-unprotected.json b/examples/invalid/consumer.a-script-left-unprotected.json new file mode 100644 index 000000000..48f81d2f6 --- /dev/null +++ b/examples/invalid/consumer.a-script-left-unprotected.json @@ -0,0 +1,24 @@ +{ + "schema": "consumer/1", + "repo": "combsmith/markets", + "ring": "next", + "owner_role": "devops-lead", + "ci_workflows": [ + "CI" + ], + "verify": { + "setup": "scripts/factory-setup.sh", + "test": "scripts/factory-test.sh", + "protected_paths": [ + "scripts/factory-setup.sh", + ".github/", + "CODEOWNERS" + ] + }, + "reviewers": [ + "coderabbit", + "cubic", + "gemini-code-assist", + "sonarqube-cloud" + ] +} diff --git a/examples/invalid/consumer.a-script-named-by-a-pattern.json b/examples/invalid/consumer.a-script-named-by-a-pattern.json new file mode 100644 index 000000000..ff833622d --- /dev/null +++ b/examples/invalid/consumer.a-script-named-by-a-pattern.json @@ -0,0 +1,28 @@ +{ + "schema": "consumer/1", + "repo": "combsmith/markets", + "ring": "next", + "owner_role": "devops-lead", + "ci_workflows": [ + "CI" + ], + "verify": { + "setup": "scripts/*-setup.sh", + "test": "scripts/factory-test.sh", + "protected_paths": [ + "scripts/factory-setup.sh", + "scripts/factory-test.sh", + ".github/", + "CODEOWNERS", + "tests/**/conftest.py", + "*.lock", + "scripts/" + ] + }, + "reviewers": [ + "coderabbit", + "cubic", + "gemini-code-assist", + "sonarqube-cloud" + ] +} diff --git a/schemas/consumer.schema.json b/schemas/consumer.schema.json index 1ccfc9cc5..20495a486 100644 --- a/schemas/consumer.schema.json +++ b/schemas/consumer.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "consumer/1: how one Consumer repo is served (design section 3.12). A data file: its path is its identity and the commit its Release. Its protected paths are in the one syntax of config/hooks.json, read by the one matcher the Kernel and the session hooks share (kernel/derive.py, matches; tools/hooks/protected.py, entries). What reads an entry, the readiness check and apply's refusal for a Consumer repo, is slice 3's.", + "title": "consumer/1: how one Consumer repo is served (design section 3.12). A data file: its path is its identity and the commit its Release. Its protected paths are in the one syntax of config/hooks.json, read alike by the Kernel's matcher (kernel/derive.py, matches) and the session hooks' (tools/hooks/protected.py, entries); and they name its setup and test scripts, which tools/check_examples.py holds. What reads an entry, the readiness check and apply's refusal for a Consumer repo, is slice 3's.", "type": "object", "additionalProperties": false, "required": [ @@ -29,7 +29,7 @@ }, "owner_role": { "type": "string", - "pattern": "^[a-z][a-z-]*$" + "pattern": "^[a-z][a-z-]*[a-z]$" }, "ci_workflows": { "description": "The name of each of the repo's own workflows whose checks the Factory reads, as GitHub shows it.", @@ -59,7 +59,7 @@ "$ref": "#/$defs/file" }, "protected_paths": { - "description": "What apply refuses a Role's push to without a person, and a change to which a model Lens reviews: relative to the top of the repo; a path ending in / is a directory and all below it; * stands for any part of one name, and ** as a whole name for any run of names; case is ignored (issue 141, decision 0020).", + "description": "What apply refuses a Role's push to without a person (slice 3's): relative to the top of the repo; a path ending in / is a directory and all below it; * stands for any part of one name, and ** as a whole name for any run of names; case is ignored (issue 141, decision 0020). Its setup and test scripts are among them.", "type": "array", "minItems": 1, "uniqueItems": true, diff --git a/tests/test_tools.py b/tests/test_tools.py index 42f60701d..55019d6dd 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1234,6 +1234,18 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o bad = copy.deepcopy(entry) del bad["verify"]["protected_paths"] self.assertTrue(jsonschema_lite.validate(bad, schemas["consumer"], schemas=schemas)) + # Its setup and test scripts are among its protected paths, read by the Kernel's matcher, in an example as in a + # counter-example, or an author could weaken the tests it is judged by. + self.assertEqual(check_examples._unprotected(entry), []) + for paths, said in ((["scripts/factory-setup.sh"], "protects neither its own scripts/factory-test.sh"), + (["CODEOWNERS"], "protects neither its own scripts/factory-setup.sh nor scripts/factory-test.sh"), + (["scripts/*-setup.sh", "SCRIPTS/"], "")): + bad = copy.deepcopy(entry) + bad["verify"]["protected_paths"] = paths + self.assertEqual(check_examples._unprotected(bad), ["$.verify: " + said] if said else [], paths) + bad["verify"]["protected_paths"] = ["scripts/factory-setup.sh"] + root = clone({"examples/consumer.json": json.dumps(bad)}) + self.assertTrue(caught(check_examples.run(root), "consumer.json: $.verify: protects neither its own scripts/factory-test.sh")) # Each the schema lets through is one the Kernel reads, and each the Kernel refuses the schema refuses too. for pattern in patterns + ["*/__init__.*", "a/**/b/", "**"]: self.assertTrue(derive.readable_pattern(pattern), pattern) diff --git a/tools/check_examples.py b/tools/check_examples.py index 008d54c00..abe3d6a82 100644 --- a/tools/check_examples.py +++ b/tools/check_examples.py @@ -5,7 +5,7 @@ import pathlib import re -from kernel import decide, issue +from kernel import decide, derive, issue from kernel.coverage import covered from tools import walk from tools.jsonschema_lite import ANNOTATIONS, FILE, SchemaError, _resolve, validate @@ -236,6 +236,15 @@ def _table(feed, decision_schema) -> list: return out +def _unprotected(value) -> list: + """What is wrong with `value`, a Consumer entry valid to its schema: nothing, or its setup or test script that none + of its protected paths names, by the Kernel's own matcher, so that an author could weaken the tests it is judged by + (design section 3.12, issue 141). One problem, naming each such script.""" + verify = value["verify"] + left = [verify[k] for k in ("setup", "test") if not any(derive.matches(p, verify[k]) for p in verify["protected_paths"])] + return ["$.verify: protects neither its own %s" % " nor ".join(left)] if left else [] + + def _uncovered(value, root: pathlib.Path) -> list: """What kernel/coverage.py says is wrong with `value`, a coverage example valid to its schema: nothing, or one problem naming what it left uncovered, or why it could not be judged.""" @@ -333,6 +342,7 @@ def load(path: pathlib.Path): errors = _uncovered(value, root) errors = errors or (_reason_unsuited(value) if kind == "result" else []) errors = errors or (_held(value) if kind == "eval-set" else []) + errors = errors or (_unprotected(value) if kind == "consumer" else []) for err in errors: problems.append("%s: %s" % (path.name, err)) for path in sorted((root / "examples" / "invalid").glob("*.json")): @@ -358,6 +368,8 @@ def load(path: pathlib.Path): errors = check_release.fixture_problems(value, "invalid/" + path.name) if kind == "result" and not errors: errors = _reason_unsuited(value) + if kind == "consumer" and not errors: + errors = _unprotected(value) if not errors: problems.append("invalid/%s: was accepted, and must be rejected" % path.name) elif len(errors) > 1: diff --git a/tools/mutants.py b/tools/mutants.py index a2306a5f4..96e93d8f3 100644 --- a/tools/mutants.py +++ b/tools/mutants.py @@ -4717,7 +4717,17 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ('a preflight case keeps no mark in the ledger', 'harness/eval/__init__.py', ' alternates=beside, surplus=away, usages=spent)["cases"]]', ' usages=spent)["cases"]]', ('tests.test_evals.EvalJob.test_a_preflight_case_keeps_its_marks_in_the_ledger_as_the_sets_do',)), - # Issue 141: a Consumer entry's protected paths are in the hooks' syntax, one at least, each once. + # Issue 141: a Consumer entry's protected paths are in the hooks' syntax, one at least, each once as written, and + # name its setup and test scripts. + ("a Consumer's script may be any string", 'schemas/consumer.schema.json', + ' "file": {\n "type": "string",\n "pattern": "^(?!.*(^|/)\\\\.{1,2}(/|$))[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)*$"\n }', + ' "file": {\n "type": "string"\n }', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may leave its scripts unprotected", 'tools/check_examples.py', + ' errors = errors or (_unprotected(value) if kind == "consumer" else [])\n', '', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a counter-example Consumer entry is not held to its scripts", 'tools/check_examples.py', + ' if kind == "consumer" and not errors:\n errors = _unprotected(value)\n', '', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry protecting one of its scripts protects both", 'tools/check_examples.py', + 'if not any(derive.matches(p, verify[k]) for p in verify["protected_paths"])]', 'if not any(derive.matches(p, verify[j]) for p in verify["protected_paths"] for j in ("setup", "test"))]', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer's protected path may be in any syntax", 'schemas/consumer.schema.json', '"$ref": "hooks.schema.json#/$defs/path"', '"type": "string"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer may protect no path", 'schemas/consumer.schema.json', From 4cc48016a19ff4c36247ee88549ba2e8f2c27a96 Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Wed, 11 Nov 2026 07:47:37 -0600 Subject: [PATCH 3/6] Carbon's finding: every field of consumer/1 is held by a case and a mutant, not its protected paths alone Co-Authored-By: Claude Opus 5.5 --- tests/test_tools.py | 18 ++++++++++++++++++ tools/mutants.py | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tests/test_tools.py b/tests/test_tools.py index 55019d6dd..0db17ff46 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1234,6 +1234,24 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o bad = copy.deepcopy(entry) del bad["verify"]["protected_paths"] self.assertTrue(jsonschema_lite.validate(bad, schemas["consumer"], schemas=schemas)) + # The rest of the entry is held whole too: each field there, each in its shape, nothing beside them. + for where, wrong in ((("repo",), "markets"), (("ring",), "canary"), (("owner_role",), "devops-"), (("ci_workflows",), []), + (("ci_workflows",), ["CI", "CI"]), (("verify", "setup"), "/bin/sh"), (("verify", "test"), "../t.sh"), + (("reviewers",), ["cubic", "cubic"]), (("reviewers",), ["Cubic"]), (("extra",), True), + (("verify", "extra"), True)): + bad = copy.deepcopy(entry) + parent = bad + for key in where[:-1]: + parent = parent[key] + parent[where[-1]] = wrong + self.assertTrue(jsonschema_lite.validate(bad, schemas["consumer"], schemas=schemas), (where, wrong)) + for where in (("repo",), ("ring",), ("owner_role",), ("ci_workflows",), ("verify",), ("reviewers",), ("verify", "setup"), ("verify", "test")): + bad = copy.deepcopy(entry) + parent = bad + for key in where[:-1]: + parent = parent[key] + del parent[where[-1]] + self.assertTrue(jsonschema_lite.validate(bad, schemas["consumer"], schemas=schemas), where) # Its setup and test scripts are among its protected paths, read by the Kernel's matcher, in an example as in a # counter-example, or an author could weaken the tests it is judged by. self.assertEqual(check_examples._unprotected(entry), []) diff --git a/tools/mutants.py b/tools/mutants.py index 96e93d8f3..434504113 100644 --- a/tools/mutants.py +++ b/tools/mutants.py @@ -4736,6 +4736,23 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ' "uniqueItems": true,\n "items": {\n "$ref"', ' "items": {\n "$ref"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry needs no protected paths", 'schemas/consumer.schema.json', ' "test",\n "protected_paths"\n', ' "test"\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may serve any ring", 'schemas/consumer.schema.json', + ' "enum": [\n "next",\n "stable"\n ]', ' "type": "string"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may read no workflow", 'schemas/consumer.schema.json', + ' "type": "array",\n "minItems": 1,\n "uniqueItems": true,\n "items": {\n "type": "string",\n "minLength": 1', + ' "type": "array",\n "uniqueItems": true,\n "items": {\n "type": "string",\n "minLength": 1', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry needs no setup script", 'schemas/consumer.schema.json', + ' "setup",\n "test",\n', ' "test",\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may name its repo in any form", 'schemas/consumer.schema.json', + '"pattern": "^[A-Za-z0-9-]+/[A-Za-z0-9._-]+$"', '"minLength": 1', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may name an owner Role in any form", 'schemas/consumer.schema.json', + '"pattern": "^[a-z][a-z-]*[a-z]$"', '"pattern": "^[a-z][a-z-]*$"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may name a reviewer twice", 'schemas/consumer.schema.json', + ' "uniqueItems": true,\n "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', + ' "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may carry any field", 'schemas/consumer.schema.json', + ' "type": "object",\n "additionalProperties": false,\n "required": [\n "schema",\n "repo"', + ' "type": "object",\n "required": [\n "schema",\n "repo"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry is in no class of the envelope", 'tools/check_examples.py', ' "consumer": "data",', '', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ('a ledger need hold no preflight', 'schemas/eval-ledger.schema.json', From 684412828163f374aaeb623a74a86bce687ad796 Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Wed, 11 Nov 2026 07:51:34 -0600 Subject: [PATCH 4/6] Astra's findings: a workflow named by nothing, and a test script named by a pattern, each refused, with a mutant Co-Authored-By: Claude Opus 5.5 --- tests/test_tools.py | 3 ++- tools/mutants.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_tools.py b/tests/test_tools.py index 0db17ff46..416425a3c 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1236,7 +1236,8 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o self.assertTrue(jsonschema_lite.validate(bad, schemas["consumer"], schemas=schemas)) # The rest of the entry is held whole too: each field there, each in its shape, nothing beside them. for where, wrong in ((("repo",), "markets"), (("ring",), "canary"), (("owner_role",), "devops-"), (("ci_workflows",), []), - (("ci_workflows",), ["CI", "CI"]), (("verify", "setup"), "/bin/sh"), (("verify", "test"), "../t.sh"), + (("ci_workflows",), ["CI", "CI"]), (("ci_workflows",), [""]), (("verify", "setup"), "/bin/sh"), + (("verify", "test"), "../t.sh"), (("verify", "test"), "scripts/factory-*.sh"), (("reviewers",), ["cubic", "cubic"]), (("reviewers",), ["Cubic"]), (("extra",), True), (("verify", "extra"), True)): bad = copy.deepcopy(entry) diff --git a/tools/mutants.py b/tools/mutants.py index 434504113..e0f35242c 100644 --- a/tools/mutants.py +++ b/tools/mutants.py @@ -4741,6 +4741,11 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ("a Consumer entry may read no workflow", 'schemas/consumer.schema.json', ' "type": "array",\n "minItems": 1,\n "uniqueItems": true,\n "items": {\n "type": "string",\n "minLength": 1', ' "type": "array",\n "uniqueItems": true,\n "items": {\n "type": "string",\n "minLength": 1', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may name a workflow by nothing", 'schemas/consumer.schema.json', + ' "type": "string",\n "minLength": 1\n }\n },\n "verify"', ' "type": "string"\n }\n },\n "verify"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer's test script may be a pattern", 'schemas/consumer.schema.json', + '"description": "The repo\'s test script, by its path from the top of the repo.",\n "$ref": "#/$defs/file"', + '"description": "The repo\'s test script, by its path from the top of the repo.",\n "$ref": "hooks.schema.json#/$defs/path"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry needs no setup script", 'schemas/consumer.schema.json', ' "setup",\n "test",\n', ' "test",\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry may name its repo in any form", 'schemas/consumer.schema.json', From 149142139a1f24d767cfd46c4c9ad38837d9c9cc Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Wed, 11 Nov 2026 07:55:48 -0600 Subject: [PATCH 5/6] Astra's re-read: a field of the wrong type, and a setup script alone left unprotected, each refused, with a mutant Co-Authored-By: Claude Opus 5.5 --- tests/test_tools.py | 3 +++ tools/mutants.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/tests/test_tools.py b/tests/test_tools.py index 416425a3c..b10b27684 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1239,6 +1239,8 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o (("ci_workflows",), ["CI", "CI"]), (("ci_workflows",), [""]), (("verify", "setup"), "/bin/sh"), (("verify", "test"), "../t.sh"), (("verify", "test"), "scripts/factory-*.sh"), (("reviewers",), ["cubic", "cubic"]), (("reviewers",), ["Cubic"]), (("extra",), True), + (("owner_role",), None), (("repo",), 1), (("reviewers",), "cubic"), (("ci_workflows",), "CI"), + (("verify",), "scripts/"), (("verify", "protected_paths"), "CODEOWNERS"), (("verify", "setup"), 1), (("verify", "extra"), True)): bad = copy.deepcopy(entry) parent = bad @@ -1258,6 +1260,7 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o self.assertEqual(check_examples._unprotected(entry), []) for paths, said in ((["scripts/factory-setup.sh"], "protects neither its own scripts/factory-test.sh"), (["CODEOWNERS"], "protects neither its own scripts/factory-setup.sh nor scripts/factory-test.sh"), + (["scripts/factory-test.sh"], "protects neither its own scripts/factory-setup.sh"), (["scripts/*-setup.sh", "SCRIPTS/"], "")): bad = copy.deepcopy(entry) bad["verify"]["protected_paths"] = paths diff --git a/tools/mutants.py b/tools/mutants.py index e0f35242c..23ff1fba7 100644 --- a/tools/mutants.py +++ b/tools/mutants.py @@ -4746,6 +4746,13 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ("a Consumer's test script may be a pattern", 'schemas/consumer.schema.json', '"description": "The repo\'s test script, by its path from the top of the repo.",\n "$ref": "#/$defs/file"', '"description": "The repo\'s test script, by its path from the top of the repo.",\n "$ref": "hooks.schema.json#/$defs/path"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry's owner Role may be of any type", 'schemas/consumer.schema.json', + ' "owner_role": {\n "type": "string",\n', ' "owner_role": {\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry's reviewers may be of any type", 'schemas/consumer.schema.json', + '"description": "The repo\'s Advisory reviewers, by the name the Factory gives each.",\n "type": "array",\n', + '"description": "The repo\'s Advisory reviewers, by the name the Factory gives each.",\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry leaving its setup script alone unprotected is read", 'tools/check_examples.py', + ' if left else []', ' if verify["test"] in left else []', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry needs no setup script", 'schemas/consumer.schema.json', ' "setup",\n "test",\n', ' "test",\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry may name its repo in any form", 'schemas/consumer.schema.json', From 97da046abf73c4d409e191901e5f80e0849ebc62 Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Wed, 11 Nov 2026 08:14:30 -0600 Subject: [PATCH 6/6] The bots' findings on #738: one script left unprotected is said so, the example protects docs/CODEOWNERS and lock files at any depth, an entry names a reviewer, and ** is said to be read by both matchers though config/hooks.json names none Co-Authored-By: Claude Opus 5.5 --- docs/architecture/software-factory-design.md | 9 ++++---- examples/consumer.json | 21 ++++++++++++++++--- .../consumer.a-script-named-by-a-pattern.json | 3 ++- schemas/consumer.schema.json | 5 +++-- tests/test_tools.py | 14 ++++++------- tools/check_examples.py | 4 +++- tools/mutants.py | 11 ++++++---- 7 files changed, 45 insertions(+), 22 deletions(-) diff --git a/docs/architecture/software-factory-design.md b/docs/architecture/software-factory-design.md index 13ca808fd..5c51cf3b6 100644 --- a/docs/architecture/software-factory-design.md +++ b/docs/architecture/software-factory-design.md @@ -1068,10 +1068,11 @@ verify: reviewers: [coderabbit, cubic, gemini-code-assist, sonarqube-cloud] ``` -Its `protected_paths` are in the one syntax of `config/hooks.json`, read alike by the Kernel's matcher and the session -hooks': a final `/` is the directory and everything below it, `*` is any part of one name, `**` as a -whole name any run of names, and case is ignored. So `.github/*` leaves `.github/workflows/` open, and `CODEOWNERS` -leaves `.github/CODEOWNERS`. They name the setup and test scripts. `schemas/consumer.schema.json` and +Its `protected_paths` are in the syntax of `config/hooks.json`'s paths, read alike by the Kernel's matcher and the +session hooks': a final `/` is the directory and everything below it, `*` is any part of one name, and case is +ignored. `**` as a whole name is any run of names, which both matchers read, as a rubric's paths use it (decision 0029), +though `config/hooks.json` itself names none. So `.github/*` leaves `.github/workflows/` open, and `CODEOWNERS` leaves +`.github/CODEOWNERS` open. They name the setup and test scripts. `schemas/consumer.schema.json` and `tools/check_examples.py` hold them to it ("Consumer entry: its protected_paths in the hooks' syntax", issue 141). Adopting the Factory is more than this entry. The repo also needs the two scripts, a ruleset that diff --git a/examples/consumer.json b/examples/consumer.json index 7f51443e0..a22f1ca91 100644 --- a/examples/consumer.json +++ b/examples/consumer.json @@ -3,11 +3,26 @@ "repo": "combsmith/markets", "ring": "next", "owner_role": "devops-lead", - "ci_workflows": ["CI"], + "ci_workflows": [ + "CI" + ], "verify": { "setup": "scripts/factory-setup.sh", "test": "scripts/factory-test.sh", - "protected_paths": ["scripts/factory-setup.sh", "scripts/factory-test.sh", ".github/", "CODEOWNERS", "tests/**/conftest.py", "*.lock"] + "protected_paths": [ + "scripts/factory-setup.sh", + "scripts/factory-test.sh", + ".github/", + "CODEOWNERS", + "docs/CODEOWNERS", + "tests/**/conftest.py", + "**/*.lock" + ] }, - "reviewers": ["coderabbit", "cubic", "gemini-code-assist", "sonarqube-cloud"] + "reviewers": [ + "coderabbit", + "cubic", + "gemini-code-assist", + "sonarqube-cloud" + ] } diff --git a/examples/invalid/consumer.a-script-named-by-a-pattern.json b/examples/invalid/consumer.a-script-named-by-a-pattern.json index ff833622d..ac84e8fef 100644 --- a/examples/invalid/consumer.a-script-named-by-a-pattern.json +++ b/examples/invalid/consumer.a-script-named-by-a-pattern.json @@ -14,8 +14,9 @@ "scripts/factory-test.sh", ".github/", "CODEOWNERS", + "docs/CODEOWNERS", "tests/**/conftest.py", - "*.lock", + "**/*.lock", "scripts/" ] }, diff --git a/schemas/consumer.schema.json b/schemas/consumer.schema.json index 20495a486..2c035be2f 100644 --- a/schemas/consumer.schema.json +++ b/schemas/consumer.schema.json @@ -59,7 +59,7 @@ "$ref": "#/$defs/file" }, "protected_paths": { - "description": "What apply refuses a Role's push to without a person (slice 3's): relative to the top of the repo; a path ending in / is a directory and all below it; * stands for any part of one name, and ** as a whole name for any run of names; case is ignored (issue 141, decision 0020). Its setup and test scripts are among them.", + "description": "What apply refuses a Role's push to without a person (slice 3's): relative to the top of the repo; a path ending in / is a directory and all below it; * stands for any part of one name; ** as a whole name for any run of names, which both matchers read, as a rubric's paths use it (decision 0029), though config/hooks.json itself names none; case is ignored (issue 141, decision 0020). Its setup and test scripts are among them.", "type": "array", "minItems": 1, "uniqueItems": true, @@ -70,8 +70,9 @@ } }, "reviewers": { - "description": "The repo's Advisory reviewers, by the name the Factory gives each.", + "description": "The repo's Advisory reviewers, by the name the Factory gives each, one at least: adopting the Factory needs them configured (design section 3.12).", "type": "array", + "minItems": 1, "uniqueItems": true, "items": { "type": "string", diff --git a/tests/test_tools.py b/tests/test_tools.py index b10b27684..49816dc72 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1238,7 +1238,7 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o for where, wrong in ((("repo",), "markets"), (("ring",), "canary"), (("owner_role",), "devops-"), (("ci_workflows",), []), (("ci_workflows",), ["CI", "CI"]), (("ci_workflows",), [""]), (("verify", "setup"), "/bin/sh"), (("verify", "test"), "../t.sh"), (("verify", "test"), "scripts/factory-*.sh"), - (("reviewers",), ["cubic", "cubic"]), (("reviewers",), ["Cubic"]), (("extra",), True), + (("reviewers",), ["cubic", "cubic"]), (("reviewers",), ["Cubic"]), (("reviewers",), []), (("extra",), True), (("owner_role",), None), (("repo",), 1), (("reviewers",), "cubic"), (("ci_workflows",), "CI"), (("verify",), "scripts/"), (("verify", "protected_paths"), "CODEOWNERS"), (("verify", "setup"), 1), (("verify", "extra"), True)): @@ -1258,16 +1258,16 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o # Its setup and test scripts are among its protected paths, read by the Kernel's matcher, in an example as in a # counter-example, or an author could weaken the tests it is judged by. self.assertEqual(check_examples._unprotected(entry), []) - for paths, said in ((["scripts/factory-setup.sh"], "protects neither its own scripts/factory-test.sh"), + for paths, said in ((["scripts/factory-setup.sh"], "does not protect its own scripts/factory-test.sh"), (["CODEOWNERS"], "protects neither its own scripts/factory-setup.sh nor scripts/factory-test.sh"), - (["scripts/factory-test.sh"], "protects neither its own scripts/factory-setup.sh"), + (["scripts/factory-test.sh"], "does not protect its own scripts/factory-setup.sh"), (["scripts/*-setup.sh", "SCRIPTS/"], "")): bad = copy.deepcopy(entry) bad["verify"]["protected_paths"] = paths self.assertEqual(check_examples._unprotected(bad), ["$.verify: " + said] if said else [], paths) bad["verify"]["protected_paths"] = ["scripts/factory-setup.sh"] root = clone({"examples/consumer.json": json.dumps(bad)}) - self.assertTrue(caught(check_examples.run(root), "consumer.json: $.verify: protects neither its own scripts/factory-test.sh")) + self.assertTrue(caught(check_examples.run(root), "consumer.json: $.verify: does not protect its own scripts/factory-test.sh")) # Each the schema lets through is one the Kernel reads, and each the Kernel refuses the schema refuses too. for pattern in patterns + ["*/__init__.*", "a/**/b/", "**"]: self.assertTrue(derive.readable_pattern(pattern), pattern) @@ -1277,9 +1277,9 @@ def test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_o hooks = protected.entries([(p, "") for p in patterns]) for path, want in (("scripts/factory-setup.sh", ["scripts/factory-setup.sh"]), ("SCRIPTS/Factory-Test.sh", ["scripts/factory-test.sh"]), (".github/workflows/ci.yml", [".github/"]), (".github", [".github/"]), ("CODEOWNERS", ["CODEOWNERS"]), - ("docs/CODEOWNERS", []), ("tests/conftest.py", ["tests/**/conftest.py"]), - ("tests/a/b/conftest.py", ["tests/**/conftest.py"]), ("poetry.lock", ["*.lock"]), - ("a/poetry.lock", []), ("scripts/other.sh", []), (".githubx/a", [])): + ("tests/conftest.py", ["tests/**/conftest.py"]), + ("tests/a/b/conftest.py", ["tests/**/conftest.py"]), ("poetry.lock", ["**/*.lock"]), + ("a/b/poetry.lock", ["**/*.lock"]), ("docs/CODEOWNERS", ["docs/CODEOWNERS"]), ("scripts/other.sh", []), (".githubx/a", [])): self.assertEqual([p for p in patterns if derive.matches(p, path)], want, path) self.assertEqual([p for p, _, _, whole in hooks if whole.match(path.casefold())], want, path) diff --git a/tools/check_examples.py b/tools/check_examples.py index abe3d6a82..fbb7789d3 100644 --- a/tools/check_examples.py +++ b/tools/check_examples.py @@ -242,7 +242,9 @@ def _unprotected(value) -> list: (design section 3.12, issue 141). One problem, naming each such script.""" verify = value["verify"] left = [verify[k] for k in ("setup", "test") if not any(derive.matches(p, verify[k]) for p in verify["protected_paths"])] - return ["$.verify: protects neither its own %s" % " nor ".join(left)] if left else [] + if len(left) > 1: + return ["$.verify: protects neither its own %s nor %s" % tuple(left)] + return ["$.verify: does not protect its own %s" % left[0]] if left else [] def _uncovered(value, root: pathlib.Path) -> list: diff --git a/tools/mutants.py b/tools/mutants.py index 23ff1fba7..5a7a28457 100644 --- a/tools/mutants.py +++ b/tools/mutants.py @@ -4749,8 +4749,8 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ("a Consumer entry's owner Role may be of any type", 'schemas/consumer.schema.json', ' "owner_role": {\n "type": "string",\n', ' "owner_role": {\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry's reviewers may be of any type", 'schemas/consumer.schema.json', - '"description": "The repo\'s Advisory reviewers, by the name the Factory gives each.",\n "type": "array",\n', - '"description": "The repo\'s Advisory reviewers, by the name the Factory gives each.",\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + '"description": "The repo\'s Advisory reviewers, by the name the Factory gives each, one at least: adopting the Factory needs them configured (design section 3.12).",\n "type": "array",\n', + '"description": "The repo\'s Advisory reviewers, by the name the Factory gives each, one at least: adopting the Factory needs them configured (design section 3.12).",\n', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry leaving its setup script alone unprotected is read", 'tools/check_examples.py', ' if left else []', ' if verify["test"] in left else []', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry needs no setup script", 'schemas/consumer.schema.json', @@ -4760,8 +4760,11 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ("a Consumer entry may name an owner Role in any form", 'schemas/consumer.schema.json', '"pattern": "^[a-z][a-z-]*[a-z]$"', '"pattern": "^[a-z][a-z-]*$"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry may name a reviewer twice", 'schemas/consumer.schema.json', - ' "uniqueItems": true,\n "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', - ' "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ' "minItems": 1,\n "uniqueItems": true,\n "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', + ' "minItems": 1,\n "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), + ("a Consumer entry may name no reviewer", 'schemas/consumer.schema.json', + ' "minItems": 1,\n "uniqueItems": true,\n "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', + ' "uniqueItems": true,\n "items": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)), ("a Consumer entry may carry any field", 'schemas/consumer.schema.json', ' "type": "object",\n "additionalProperties": false,\n "required": [\n "schema",\n "repo"', ' "type": "object",\n "required": [\n "schema",\n "repo"', ('tests.test_tools.Apps.test_a_consumer_entrys_protected_paths_are_in_the_hooks_syntax_and_read_by_one_matcher',)),