From c5db4551b874c80560845d25e6bc45fb38269020 Mon Sep 17 00:00:00 2001 From: Ernest Provo Date: Sat, 24 Oct 2026 09:17:33 +0000 Subject: [PATCH] corpus: read entries from locks/schema-/ (DSE-2143) The community corpus is append-only and locks////.lock had no slot for a second lock schema of one coordinate, so every schema-3 entry written by 1.x made 2.x fail closed with WRD-CONSENSUS-SCHEMA-MISMATCH. Coordinate.relative_dir() now prefixes locks/schema-/; legacy entries are never read (NOVEL). Fixture corpus moved, new regression test, COMMUNITY_CORPUS.md section 4, CHANGELOG. --- CHANGELOG.md | 8 +++++ SYSTEM_CONTEXT_DIAGRAM.md | 2 +- docs/COMMUNITY_CORPUS.md | 13 ++++++-- src/mcp_warden/corpus.py | 6 ++-- src/mcp_warden/corpus_coordinate.py | 10 ++++-- .../npm/@example__clean/1.0.0/alice.lock | 0 .../@example__clean/1.0.0/alice.lock.sigstore | 0 .../npm/@example__clean/1.0.0/bob.lock | 0 .../@example__clean/1.0.0/bob.lock.sigstore | 0 .../npm/@example__corrupt/1.0.0/alice.lock | 0 .../1.0.0/alice.lock.sigstore | 0 .../npm/@example__nosig/1.0.0/alice.lock | 0 .../npm/@example__other/1.0.0/alice.lock | 0 .../@example__other/1.0.0/alice.lock.sigstore | 0 .../npm/@example__other/1.0.0/bob.lock | 0 .../@example__other/1.0.0/bob.lock.sigstore | 0 .../npm/@example__solo/1.0.0/alice.lock | 0 .../@example__solo/1.0.0/alice.lock.sigstore | 0 .../npm/@example__split/1.0.0/alice.lock | 0 .../@example__split/1.0.0/alice.lock.sigstore | 0 .../npm/@example__split/1.0.0/bob.lock | 0 .../@example__split/1.0.0/bob.lock.sigstore | 0 .../npm/@example__stranger/1.0.0/mallory.lock | 0 .../1.0.0/mallory.lock.sigstore | 0 .../npm/@example__unpinned/1.0.0/carol.lock | 0 .../1.0.0/carol.lock.sigstore | 0 .../npm/@example__wrongsig/1.0.0/alice.lock | 0 .../1.0.0/alice.lock.sigstore | 0 tests/fixtures/gen_corpus.py | 5 +-- tests/test_corpus.py | 32 ++++++++++++------- 30 files changed, 55 insertions(+), 21 deletions(-) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__clean/1.0.0/alice.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__clean/1.0.0/alice.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__clean/1.0.0/bob.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__clean/1.0.0/bob.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__corrupt/1.0.0/alice.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__corrupt/1.0.0/alice.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__nosig/1.0.0/alice.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__other/1.0.0/alice.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__other/1.0.0/alice.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__other/1.0.0/bob.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__other/1.0.0/bob.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__solo/1.0.0/alice.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__solo/1.0.0/alice.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__split/1.0.0/alice.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__split/1.0.0/alice.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__split/1.0.0/bob.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__split/1.0.0/bob.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__stranger/1.0.0/mallory.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__stranger/1.0.0/mallory.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__unpinned/1.0.0/carol.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__unpinned/1.0.0/carol.lock.sigstore (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__wrongsig/1.0.0/alice.lock (100%) rename tests/fixtures/corpus/locks/{ => schema-4}/npm/@example__wrongsig/1.0.0/alice.lock.sigstore (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a686523..20545f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,14 @@ Streamable HTTP; the v0.3 `guard` proxy adds deterministic runtime *result* insp ## [Unreleased] +### Community corpus layout (DSE-2143) + +- `check --against-community` reads entries from `locks/schema-//...`, + where `` is the implemented lock schema (4). The schema-3 corpus written by 1.x + stays at `locks//...` and is no longer read: 2.0.0 and 2.1.0 refused every + entry there with `WRD-CONSENSUS-SCHEMA-MISMATCH`; it now reads as NOVEL until a + schema-4 entry exists. See `docs/COMMUNITY_CORPUS.md` §4. + ## [2.1.0] — 2026-10-23 ### Pagination (DSE-1539) diff --git a/SYSTEM_CONTEXT_DIAGRAM.md b/SYSTEM_CONTEXT_DIAGRAM.md index dcfe574..a37998d 100644 --- a/SYSTEM_CONTEXT_DIAGRAM.md +++ b/SYSTEM_CONTEXT_DIAGRAM.md @@ -281,7 +281,7 @@ sequenceDiagram CI->>S: initialize · tools/list · resources/list · prompts/list S-->>CI: declared surface → drift verdict vs warden.lock (unchanged path) CI->>C: https/ssh clone @ --corpus-ref (protocol.allow=never, hooks off, "--") or local path - C-->>CI: attesters.json (discovery only) + locks////.lock + .sigstore + C-->>CI: attesters.json (discovery only) + locks/schema-N////.lock + .sigstore CI->>CI: intersect with pin — unpinned id ignored (warn), divergent identity → exit 2 CI->>CI: confine paths under corpus root · size caps · schema_version == implemented CI->>SG: verify each bundle over build_statement(overall_digest, DIRECTORY coordinate) for the pinned identity/issuer diff --git a/docs/COMMUNITY_CORPUS.md b/docs/COMMUNITY_CORPUS.md index 8886869..b1d9ac2 100644 --- a/docs/COMMUNITY_CORPUS.md +++ b/docs/COMMUNITY_CORPUS.md @@ -109,11 +109,18 @@ written at a different `schema_version` than this mcp-warden implements is ## 4. Corpus layout ``` -attesters.json discovery list (NOT the trust root) -locks////.lock -locks////.lock.sigstore +attesters.json discovery list (NOT the trust root) +locks/schema-////.lock +locks/schema-////.lock.sigstore ``` +- `schema-` is the lock `schema_version`. mcp-warden reads and writes only the + subtree for the schema it implements (`schema-4` since 2.2.0), so one append-only + corpus can carry several lock formats side by side. Schema-3 entries written by + mcp-warden 1.x sit at the legacy `locks//...` path and read as NOVEL to + 2.x; a lock whose `schema_version` disagrees with its subtree is still + `WRD-CONSENSUS-SCHEMA-MISMATCH`. + - `ecosystem` ∈ `npm` | `pypi`. - `segment` is the package name with `/` replaced by `__`, so the scoped npm package `@example/clean` lives under `locks/npm/@example__clean/`. PyPI names are PEP 503 diff --git a/src/mcp_warden/corpus.py b/src/mcp_warden/corpus.py index 05f3afc..4db6c8b 100644 --- a/src/mcp_warden/corpus.py +++ b/src/mcp_warden/corpus.py @@ -10,8 +10,10 @@ Layout of a corpus checkout (``docs/COMMUNITY_CORPUS.md``):: attesters.json discovery list, NOT the trust root - locks////.lock - locks////.lock.sigstore + locks/schema-////.lock + locks/schema-////.lock.sigstore + +```` is the lock schema this mcp-warden implements; other schemas are never read. This module owns fetching the corpus and orchestrating a run; entry verification lives in :mod:`corpus_verify`, trust in :mod:`corpus_trust`. Every rule fails diff --git a/src/mcp_warden/corpus_coordinate.py b/src/mcp_warden/corpus_coordinate.py index 72fc290..a434b67 100644 --- a/src/mcp_warden/corpus_coordinate.py +++ b/src/mcp_warden/corpus_coordinate.py @@ -14,8 +14,14 @@ from dataclasses import dataclass from pathlib import PurePosixPath +from . import SCHEMA_VERSION from .checks_supply import _is_flag, _is_local_path +#: Corpus subtree for the lock schema this mcp-warden reads and writes. Entries at +#: another schema live beside it (schema 3 at the legacy ``locks//...``) +#: and are never looked at, so an append-only corpus can carry several formats. +CORPUS_SCHEMA_DIR = f"schema-{SCHEMA_VERSION}" + #: Explicit ``--coordinate`` grammar: ``:@``. _EXPLICIT = re.compile(r"(?Pnpm|pypi):(?P[^:]+)@(?P[^@/]+)\Z") #: A concrete version: leading digit, then version chars (never a tag/range). @@ -41,8 +47,8 @@ def path_segment(self) -> str: return self.name.replace("/", "__") def relative_dir(self) -> PurePosixPath: - """``locks///`` inside a corpus checkout.""" - return PurePosixPath("locks") / self.ecosystem / self.path_segment / self.version + """``locks/schema-///`` inside a corpus checkout.""" + return PurePosixPath("locks") / CORPUS_SCHEMA_DIR / self.ecosystem / self.path_segment / self.version def _clean(text: str) -> bool: diff --git a/tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/alice.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/alice.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/alice.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/alice.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/alice.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/alice.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/alice.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/alice.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/bob.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/bob.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/bob.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/bob.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/bob.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/bob.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__clean/1.0.0/bob.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__clean/1.0.0/bob.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__corrupt/1.0.0/alice.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__corrupt/1.0.0/alice.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__corrupt/1.0.0/alice.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__corrupt/1.0.0/alice.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__corrupt/1.0.0/alice.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__corrupt/1.0.0/alice.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__corrupt/1.0.0/alice.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__corrupt/1.0.0/alice.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__nosig/1.0.0/alice.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__nosig/1.0.0/alice.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__nosig/1.0.0/alice.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__nosig/1.0.0/alice.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__other/1.0.0/alice.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/alice.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__other/1.0.0/alice.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/alice.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__other/1.0.0/alice.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/alice.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__other/1.0.0/alice.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/alice.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__other/1.0.0/bob.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/bob.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__other/1.0.0/bob.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/bob.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__other/1.0.0/bob.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/bob.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__other/1.0.0/bob.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__other/1.0.0/bob.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__solo/1.0.0/alice.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__solo/1.0.0/alice.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__solo/1.0.0/alice.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__solo/1.0.0/alice.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__solo/1.0.0/alice.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__solo/1.0.0/alice.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__solo/1.0.0/alice.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__solo/1.0.0/alice.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__split/1.0.0/alice.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/alice.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__split/1.0.0/alice.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/alice.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__split/1.0.0/alice.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/alice.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__split/1.0.0/alice.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/alice.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__split/1.0.0/bob.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/bob.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__split/1.0.0/bob.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/bob.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__split/1.0.0/bob.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/bob.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__split/1.0.0/bob.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__split/1.0.0/bob.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__stranger/1.0.0/mallory.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__stranger/1.0.0/mallory.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__stranger/1.0.0/mallory.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__stranger/1.0.0/mallory.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__stranger/1.0.0/mallory.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__stranger/1.0.0/mallory.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__stranger/1.0.0/mallory.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__stranger/1.0.0/mallory.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__unpinned/1.0.0/carol.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__unpinned/1.0.0/carol.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__unpinned/1.0.0/carol.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__unpinned/1.0.0/carol.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__unpinned/1.0.0/carol.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__unpinned/1.0.0/carol.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__unpinned/1.0.0/carol.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__unpinned/1.0.0/carol.lock.sigstore diff --git a/tests/fixtures/corpus/locks/npm/@example__wrongsig/1.0.0/alice.lock b/tests/fixtures/corpus/locks/schema-4/npm/@example__wrongsig/1.0.0/alice.lock similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__wrongsig/1.0.0/alice.lock rename to tests/fixtures/corpus/locks/schema-4/npm/@example__wrongsig/1.0.0/alice.lock diff --git a/tests/fixtures/corpus/locks/npm/@example__wrongsig/1.0.0/alice.lock.sigstore b/tests/fixtures/corpus/locks/schema-4/npm/@example__wrongsig/1.0.0/alice.lock.sigstore similarity index 100% rename from tests/fixtures/corpus/locks/npm/@example__wrongsig/1.0.0/alice.lock.sigstore rename to tests/fixtures/corpus/locks/schema-4/npm/@example__wrongsig/1.0.0/alice.lock.sigstore diff --git a/tests/fixtures/gen_corpus.py b/tests/fixtures/gen_corpus.py index acf96bf..4f7e51c 100644 --- a/tests/fixtures/gen_corpus.py +++ b/tests/fixtures/gen_corpus.py @@ -17,6 +17,7 @@ sys.path.insert(0, "src") +from mcp_warden.corpus_coordinate import CORPUS_SCHEMA_DIR # noqa: E402 from mcp_warden.lockfile import read_lock # noqa: E402 from mcp_warden.signing import build_statement # noqa: E402 @@ -35,7 +36,7 @@ def attester(name: str) -> dict[str, str]: def entry(segment: str, who: str, lock_src: Path, sidecar: str = "ok") -> None: - d = ROOT / "locks" / "npm" / segment / "1.0.0" + d = ROOT / "locks" / CORPUS_SCHEMA_DIR / "npm" / segment / "1.0.0" d.mkdir(parents=True, exist_ok=True) lock_path = d / f"{who}.lock" shutil.copy(lock_src, lock_path) @@ -75,7 +76,7 @@ def main() -> None: entry("@example__nosig", "alice", CLEAN, sidecar="missing") # UNVERIFIABLE entry("@example__corrupt", "alice", CLEAN, sidecar="corrupt") # UNVERIFIABLE entry("@example__wrongsig", "alice", CLEAN, sidecar="wrong") # UNVERIFIABLE (verify fails) - stranger = ROOT / "locks" / "npm" / "@example__stranger" / "1.0.0" # undeclared attester + stranger = ROOT / "locks" / CORPUS_SCHEMA_DIR / "npm" / "@example__stranger" / "1.0.0" # undeclared attester stranger.mkdir(parents=True) shutil.copy(CLEAN, stranger / "mallory.lock") (stranger / "mallory.lock.sigstore").write_text("{}\n") diff --git a/tests/test_corpus.py b/tests/test_corpus.py index da36873..f89fd05 100644 --- a/tests/test_corpus.py +++ b/tests/test_corpus.py @@ -50,7 +50,7 @@ ATTESTERS = CORPUS / "attesters.json" CLEAN_LOCK = read_lock(FIXTURES / "clean.warden.lock") CLEAN_DIGEST = surface_digest(CLEAN_LOCK) -OTHER_DIGEST = surface_digest(read_lock(CORPUS / "locks/npm/@example__other/1.0.0/alice.lock")) +OTHER_DIGEST = surface_digest(read_lock(CORPUS / "locks/schema-4/npm/@example__other/1.0.0/alice.lock")) CLEAN = Coordinate("npm", "@example/clean", "1.0.0") OTHER = Coordinate("npm", "@example/other", "1.0.0") @@ -164,7 +164,7 @@ def test_resolve_coordinate_from_argv(command, args, expected): def test_explicit_coordinate_overrides_argv(): got = resolve_coordinate("node", ["./x.js"], explicit="npm:@example/clean@1.0.0") assert got == CLEAN and got.path_segment == "@example__clean" - assert str(got.relative_dir()) == "locks/npm/@example__clean/1.0.0" + assert str(got.relative_dir()) == f"locks/schema-{SCHEMA_VERSION}/npm/@example__clean/1.0.0" # --- trust (CSO C3) ----------------------------------------------------------- @@ -248,8 +248,8 @@ def test_relocated_sidecar_is_rejected(monkeypatch, tmp_path): install_fake_verify(monkeypatch) root = tmp_path / "corpus" shutil.copytree(CORPUS, root) - src = root / "locks/npm/@example__clean/1.0.0" - dst = root / "locks/npm/@example__other/1.0.0" + src = root / "locks/schema-4/npm/@example__clean/1.0.0" + dst = root / "locks/schema-4/npm/@example__other/1.0.0" shutil.copy(src / "alice.lock", dst / "alice.lock") shutil.copy(src / "alice.lock.sigstore", dst / "alice.lock.sigstore") with pytest.raises(CorpusError) as ei: @@ -257,6 +257,16 @@ def test_relocated_sidecar_is_rejected(monkeypatch, tmp_path): assert ei.value.rule_id == RULE_UNVERIFIABLE and "signature did not verify" in str(ei.value) +def test_legacy_layout_entries_are_never_read(monkeypatch, tmp_path): + # DSE-2143: schema-3 entries sit at the legacy locks//... path. A 2.x consumer + # looks only under locks/schema-/, so they are NOVEL, never a schema mismatch. + install_fake_verify(monkeypatch) + root = tmp_path / "corpus" + shutil.copytree(CORPUS, root) + (root / "locks/schema-4/npm").rename(root / "locks/npm") + assert verified_digests(root, CLEAN, consumer_pin()) == {} + + @pytest.mark.parametrize("name", ["@example/nosig", "@example/corrupt", "@example/wrongsig", "@example/stranger"]) def test_bad_entries_reject_the_whole_coordinate(monkeypatch, name): install_fake_verify(monkeypatch) @@ -287,7 +297,7 @@ def test_hostile_corpus_shapes_are_unverifiable_not_tracebacks(monkeypatch, tmp_ install_fake_verify(monkeypatch) root = tmp_path / "corpus" shutil.copytree(CORPUS, root) - d = root / "locks/npm/@example__clean/1.0.0" + d = root / "locks/schema-4/npm/@example__clean/1.0.0" shutil.rmtree(d) (d / "alice.lock").mkdir(parents=True) with pytest.raises(CorpusError) as ei: @@ -304,7 +314,7 @@ def test_size_caps(monkeypatch, tmp_path): install_fake_verify(monkeypatch) root = tmp_path / "corpus" shutil.copytree(CORPUS, root) - d = root / "locks/npm/@example__clean/1.0.0" + d = root / "locks/schema-4/npm/@example__clean/1.0.0" for target, cap in ( (d / "alice.lock", corpus_verify.MAX_LOCK_BYTES), (d / "alice.lock.sigstore", corpus_verify.MAX_SIDECAR_BYTES), @@ -348,7 +358,7 @@ def test_schema_version_mismatch_is_distinct(monkeypatch, tmp_path): install_fake_verify(monkeypatch) root = tmp_path / "corpus" shutil.copytree(CORPUS, root) - p = root / "locks/npm/@example__clean/1.0.0/alice.lock" + p = root / "locks/schema-4/npm/@example__clean/1.0.0/alice.lock" doc = json.loads(p.read_text()) doc["schema_version"] = SCHEMA_VERSION - 1 p.write_text(json.dumps(doc)) @@ -361,7 +371,7 @@ def test_pydantic_error_text_is_reduced_to_field_paths(monkeypatch, tmp_path): install_fake_verify(monkeypatch) root = tmp_path / "corpus" shutil.copytree(CORPUS, root) - p = root / "locks/npm/@example__clean/1.0.0/alice.lock" + p = root / "locks/schema-4/npm/@example__clean/1.0.0/alice.lock" doc = json.loads(p.read_text()) doc["overall_digest"] = "SECRET-LOOKING-VALUE-THAT-MUST-NOT-ECHO" del doc["tools"] @@ -622,7 +632,7 @@ def test_fetch_unreachable_url(monkeypatch, tmp_path): def test_fixture_sidecars_are_not_real_bundles(): # The fixture corpus must never pass REAL verification: its sidecars are fakes. - sc = CORPUS / "locks/npm/@example__clean/1.0.0/alice.lock.sigstore" + sc = CORPUS / "locks/schema-4/npm/@example__clean/1.0.0/alice.lock.sigstore" doc = json.loads(sc.read_text()) assert doc["over"] == build_statement(CLEAN_LOCK.overall_digest, "npm:@example/clean@1.0.0").decode() assert "mediaType" not in doc # a real sigstore bundle carries mediaType @@ -637,8 +647,8 @@ def test_surface_digest_is_launch_independent_and_signature_covers_it(): def test_tampered_entries_under_a_valid_signature_are_rejected(monkeypatch, tmp_path): install_fake_verify(monkeypatch) - src = CORPUS / "locks/npm/@example__clean/1.0.0" - dst = tmp_path / "locks/npm/@example__clean/1.0.0" + src = CORPUS / "locks/schema-4/npm/@example__clean/1.0.0" + dst = tmp_path / "locks/schema-4/npm/@example__clean/1.0.0" dst.mkdir(parents=True) shutil.copy(ATTESTERS, tmp_path / "attesters.json") shutil.copy(src / "alice.lock.sigstore", dst / "alice.lock.sigstore")