refactor: accept the ecosystem stdlib Bundle and remove the in-repo sources
Phase B of ADR-0070 (issue #11): the CLI no longer owns standard-library sources. The pin names the accepted ecosystem Bundle (marqdo-stdlib@0.2.0, root commit + tree/alias digests); tools/ci/fetch_ecosystem_bundle.py materializes it from the pinned root commit and stdlib gitlinks and verifies the digests. bundle.py and the test harness require an explicit verified Bundle for the accepted identity, and runtime discovery has no compile-time source fallback in any profile. Delete stdlib/ (modules, self-tests, aliases manifest). Module and domain tests stay with their component owners; the CLI product lane now verifies the external Bundle's public surface, std: resolution and official print/打印 alias routing (tests/product-stdlib). Composition assertions whose owner is the ecosystem (Table split, print-format equivalence) moved to the root Bundle acceptance; the generic TCP round-trip stays a CLI test. Spawned-CLI tests name the verified Bundle explicitly. CI (Woodpecker + GitHub) materializes the pinned Bundle before product tests, packaging and performance lanes; packaging and release take --stdlib-dir from that artifact. Docs, STATUS, ADR-0070 and a Phase B evidence record updated. Refs cflmy/marqdo#9, cflmy/marqdo-cli#11
This commit is contained in:
1 parent
f8b82d4143
commit
72f57beee0
85 files changed
+796
-5939
No files matched your search
Executable
+166
@@ -0,0 +1,166 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Materialize the pinned ecosystem stdlib Bundle for CI and local verification.
|
||||
|
||||
Phase B removes the standard-library sources from this repository. The one
|
||||
accepted Bundle identity lives in `tools/stdlib/bundle-pin.json` and names the
|
||||
ecosystem root commit that pinned the component gitlinks. This helper fetches
|
||||
exactly that root commit and the stdlib component gitlinks it records, runs the
|
||||
root-owned producer from the pinned commit, and verifies the produced Bundle
|
||||
against the pin (name, version, tree digest, alias digest).
|
||||
|
||||
Nothing is resolved from a branch: the pin commit and every gitlink are fixed.
|
||||
The output path is printed on success; a mismatch, missing repository or missing
|
||||
module fails closed. The result is a build artifact under `target/`, never a
|
||||
source checkout that upstreams into this repository.
|
||||
|
||||
Usage:
|
||||
|
||||
python3 tools/ci/fetch_ecosystem_bundle.py [--out target/ecosystem-stdlib]
|
||||
|
||||
Environment overrides are intentionally absent: CI and maintainers edit the pin.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
PIN = ROOT / "tools" / "stdlib" / "bundle-pin.json"
|
||||
FORGE = "https://git.cflmy.cn"
|
||||
COMPONENTS = (
|
||||
"stdlib/collections",
|
||||
"stdlib/data",
|
||||
"stdlib/fs",
|
||||
"stdlib/io",
|
||||
"stdlib/system",
|
||||
"stdlib/text",
|
||||
)
|
||||
|
||||
|
||||
class FetchError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def run(command, cwd=None):
|
||||
result = subprocess.run(command, cwd=cwd, capture_output=True)
|
||||
if result.returncode != 0:
|
||||
raise FetchError(
|
||||
f"command failed ({result.returncode}): {' '.join(map(str, command))}\n"
|
||||
f"{result.stderr.decode(errors='replace').strip()}"
|
||||
)
|
||||
return result.stdout.decode(errors="replace")
|
||||
|
||||
|
||||
def load_pin() -> dict:
|
||||
try:
|
||||
pin = json.loads(PIN.read_text(encoding="utf-8"))
|
||||
except (OSError, json.JSONDecodeError) as error:
|
||||
raise FetchError(f"cannot read Bundle pin {PIN}: {error}") from error
|
||||
source = pin.get("source")
|
||||
if not isinstance(source, dict) or source.get("kind") != "ecosystem":
|
||||
raise FetchError(
|
||||
f"{PIN} does not name an ecosystem Bundle source; Phase B requires "
|
||||
"source.kind = 'ecosystem'"
|
||||
)
|
||||
for field in ("repository", "commit"):
|
||||
if not isinstance(source.get(field), str) or not source[field]:
|
||||
raise FetchError(f"{PIN} has no source.{field}")
|
||||
for field in ("name", "version", "tree_digest", "aliases_digest"):
|
||||
if not isinstance(pin.get(field), str) or not pin[field]:
|
||||
raise FetchError(f"{PIN} has no non-empty `{field}`")
|
||||
return pin
|
||||
|
||||
|
||||
def fetch_root(pin: dict, cache: Path) -> Path:
|
||||
source = pin["source"]
|
||||
url = f"{FORGE}/{source['repository']}.git"
|
||||
if not cache.is_dir():
|
||||
run(["git", "init", "-q", str(cache)])
|
||||
run(["git", "-C", str(cache), "remote", "add", "origin", url])
|
||||
else:
|
||||
run(["git", "-C", str(cache), "remote", "set-url", "origin", url])
|
||||
commit = source["commit"]
|
||||
try:
|
||||
run(["git", "-C", str(cache), "cat-file", "-e", f"{commit}^{{commit}}"])
|
||||
except FetchError:
|
||||
run(["git", "-C", str(cache), "fetch", "--no-tags", "origin", commit])
|
||||
run(["git", "-C", str(cache), "checkout", "-q", "--detach", commit])
|
||||
for component in COMPONENTS:
|
||||
run(
|
||||
[
|
||||
"git",
|
||||
"-C",
|
||||
str(cache),
|
||||
"submodule",
|
||||
"update",
|
||||
"--init",
|
||||
"--depth",
|
||||
"1",
|
||||
"--",
|
||||
component,
|
||||
]
|
||||
)
|
||||
return cache
|
||||
|
||||
|
||||
def build_bundle(root: Path, out: Path) -> Path:
|
||||
if out.exists():
|
||||
raise FetchError(f"output already exists: {out}")
|
||||
run(
|
||||
[
|
||||
sys.executable,
|
||||
str(root / "scripts" / "build-stdlib.py"),
|
||||
"--out",
|
||||
str(out),
|
||||
],
|
||||
cwd=root,
|
||||
)
|
||||
return out
|
||||
|
||||
|
||||
def verify(pin: dict, bundle: Path) -> dict:
|
||||
result = run(
|
||||
[
|
||||
sys.executable,
|
||||
str(ROOT / "tools" / "stdlib" / "bundle.py"),
|
||||
"--stdlib-dir",
|
||||
str(bundle),
|
||||
"--dump-pin",
|
||||
]
|
||||
)
|
||||
pinned = json.loads(result)
|
||||
for field in ("name", "version", "tree_digest", "aliases_digest"):
|
||||
if pinned[field] != pin[field]:
|
||||
raise FetchError(
|
||||
f"produced Bundle does not match the pin field {field}: "
|
||||
f"{pinned[field]!r} != {pin[field]!r}"
|
||||
)
|
||||
return pinned
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--out", default=str(ROOT / "target" / "ecosystem-stdlib"))
|
||||
parser.add_argument("--cache", default=str(ROOT / "target" / "ecosystem-root"))
|
||||
args = parser.parse_args(argv)
|
||||
out = Path(args.out).resolve()
|
||||
cache = Path(args.cache).resolve()
|
||||
try:
|
||||
pin = load_pin()
|
||||
root = fetch_root(pin, cache)
|
||||
bundle = build_bundle(root, out)
|
||||
verify(pin, bundle)
|
||||
except FetchError as error:
|
||||
print(f"fetch-ecosystem-bundle: error: {error}", file=sys.stderr)
|
||||
return 1
|
||||
print(bundle)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
@@ -2,7 +2,7 @@
|
||||
"""Prove the CLI and Provider Worker build without any stdlib source (ADR-0070).
|
||||
|
||||
The script exports one committed revision with `git archive`, removes the
|
||||
`stdlib/` tree (there is no ecosystem checkout either), builds
|
||||
source tree (there is no ecosystem checkout either), builds
|
||||
`marqdo-cli` + `marqdo-provider-worker` with `--locked`, and then:
|
||||
|
||||
* runs a language-only program through the freshly built CLI (`check` + `call`);
|
||||
@@ -126,15 +126,11 @@ def main(argv: list[str]) -> int:
|
||||
source = work / "source"
|
||||
try:
|
||||
source_sha = export_revision(repo, args.source, source)
|
||||
stdlib = source / "stdlib"
|
||||
if not stdlib.is_dir():
|
||||
if (source / "stdlib").exists():
|
||||
raise BuildError(
|
||||
"the exported revision has no stdlib/ tree; the lane must remove a "
|
||||
"real Bundle to prove the build does not need it"
|
||||
"Phase B forbids an in-repo stdlib source tree; the independent "
|
||||
"build lane proves the CLI compiles with no Bundle checkout at all"
|
||||
)
|
||||
shutil.rmtree(stdlib)
|
||||
if stdlib.exists():
|
||||
raise BuildError(f"failed to remove {stdlib}")
|
||||
|
||||
env = os.environ.copy()
|
||||
env.pop("MARQDO_STDLIB_DIR", None)
|
||||
@@ -195,7 +191,7 @@ def main(argv: list[str]) -> int:
|
||||
"target_dir": str(target),
|
||||
"binaries": binaries,
|
||||
"checks": {
|
||||
"stdlib_source_removed": True,
|
||||
"stdlib_source_absent": True,
|
||||
"language_only_check": "PASS",
|
||||
"language_only_call": "PASS:3",
|
||||
"stdlib_dependent_missing_bundle": "PASS",
|
||||
|
||||
@@ -12,12 +12,33 @@ import contextlib
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
BUNDLE_ENV = "MARQDO_TEST_STDLIB_BUNDLE"
|
||||
|
||||
|
||||
def product_bundle() -> Path:
|
||||
"""The explicit verified Bundle for product-level unit tests.
|
||||
|
||||
Phase B no longer ships a Bundle in this repository; CI and maintainers pass
|
||||
one produced from the pinned ecosystem commit. Missing input is an explicit
|
||||
skip here (this is a unit-test fixture, not release acceptance), while the
|
||||
product lane itself fails closed.
|
||||
"""
|
||||
value = os.environ.get(BUNDLE_ENV)
|
||||
if not value:
|
||||
raise unittest.SkipTest(
|
||||
f"set {BUNDLE_ENV} to a verified Bundle (tools/ci/fetch_ecosystem_bundle.py)"
|
||||
)
|
||||
root = Path(value)
|
||||
if not (root / "stdlib.json").is_file():
|
||||
raise AssertionError(f"{BUNDLE_ENV} does not name a Bundle: {root}")
|
||||
return root
|
||||
|
||||
|
||||
def load_module(name: str, path: Path):
|
||||
@@ -32,15 +53,20 @@ class ReleaseArchiveContractTest(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.package = load_module("release_package", ROOT / "tools/release/package.py")
|
||||
self.smoke = load_module("release_smoke", ROOT / "tools/release/smoke.py")
|
||||
self.manifest = json.loads((ROOT / "stdlib/stdlib.json").read_text(encoding="utf-8"))
|
||||
self.pin = json.loads((ROOT / "tools/stdlib/bundle-pin.json").read_text(encoding="utf-8"))
|
||||
self.bundle = product_bundle()
|
||||
self.manifest = json.loads(
|
||||
(self.bundle / "stdlib.json").read_text(encoding="utf-8")
|
||||
)
|
||||
self.pin = json.loads(
|
||||
(ROOT / "tools/stdlib/bundle-pin.json").read_text(encoding="utf-8")
|
||||
)
|
||||
|
||||
def test_tree_digest_matches_manifest(self) -> None:
|
||||
self.assertEqual(
|
||||
self.package.stdlib_tree_digest(ROOT / "stdlib"), self.manifest["digest"]
|
||||
self.package.stdlib_tree_digest(self.bundle), self.manifest["digest"]
|
||||
)
|
||||
self.assertEqual(
|
||||
self.smoke.stdlib_tree_digest(ROOT / "stdlib"), self.manifest["digest"]
|
||||
self.smoke.stdlib_tree_digest(self.bundle), self.manifest["digest"]
|
||||
)
|
||||
|
||||
def test_alias_digest_matches_manifest(self) -> None:
|
||||
@@ -55,7 +81,7 @@ class ReleaseArchiveContractTest(unittest.TestCase):
|
||||
|
||||
def test_verify_record_names_required_files_and_count(self) -> None:
|
||||
record = self.package.verify_stdlib(
|
||||
ROOT / "stdlib", ROOT / "tools/stdlib/bundle-pin.json"
|
||||
self.bundle, ROOT / "tools/stdlib/bundle-pin.json"
|
||||
)
|
||||
self.assertEqual(record["name"], self.manifest["name"])
|
||||
self.assertEqual(record["version"], self.manifest["version"])
|
||||
@@ -66,10 +92,10 @@ class ReleaseArchiveContractTest(unittest.TestCase):
|
||||
self.assertIn("io/console.mq.md", record["files"])
|
||||
self.assertEqual(record["file_count"], len(record["files"]))
|
||||
self.assertEqual(record["source"]["commit"], self.pin["source"]["commit"])
|
||||
self.assertEqual(record["source"]["kind"], "in-repo")
|
||||
self.assertEqual(record["source"]["kind"], "ecosystem")
|
||||
|
||||
def test_verify_record_has_no_source_without_a_pin(self) -> None:
|
||||
record = self.package.verify_stdlib(ROOT / "stdlib")
|
||||
record = self.package.verify_stdlib(self.bundle)
|
||||
self.assertNotIn("source", record)
|
||||
|
||||
def test_missing_explicit_input_fails_closed(self) -> None:
|
||||
@@ -84,7 +110,7 @@ class ReleaseArchiveContractTest(unittest.TestCase):
|
||||
def test_tampered_explicit_input_and_wrong_pin_fail_closed(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
copy = Path(tmp) / "stdlib"
|
||||
shutil.copytree(ROOT / "stdlib", copy)
|
||||
shutil.copytree(self.bundle, copy)
|
||||
(copy / "io.mq.md").write_text("## @knowledge tampered\n", encoding="utf-8")
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
with self.assertRaises(SystemExit) as raised:
|
||||
@@ -92,7 +118,7 @@ class ReleaseArchiveContractTest(unittest.TestCase):
|
||||
self.assertEqual(raised.exception.code, 1)
|
||||
|
||||
shutil.rmtree(copy)
|
||||
shutil.copytree(ROOT / "stdlib", copy)
|
||||
shutil.copytree(self.bundle, copy)
|
||||
restamped = json.loads((copy / "stdlib.json").read_text(encoding="utf-8"))
|
||||
restamped["version"] = "9.9.9"
|
||||
(copy / "stdlib.json").write_text(json.dumps(restamped), encoding="utf-8")
|
||||
@@ -110,7 +136,7 @@ class ReleaseArchiveContractTest(unittest.TestCase):
|
||||
self.assertIn('copy_tree(stdlib_dir, stage_dir / "stdlib")', source)
|
||||
self.assertIn('"stdlib": stdlib_info', source)
|
||||
self.assertIn("verify_stdlib(", source)
|
||||
self.assertNotIn('STDLIB = ROOT / "stdlib"', source)
|
||||
self.assertNotIn('ROOT / "stdlib"', source)
|
||||
self.assertIn('"math-backend"', source.replace("math_backend", "math-backend"))
|
||||
|
||||
def test_archive_declares_only_current_analysis_revision(self) -> None:
|
||||
@@ -120,14 +146,14 @@ class ReleaseArchiveContractTest(unittest.TestCase):
|
||||
with self.assertRaises(SystemExit):
|
||||
self.smoke.verify_analysis_metadata(malformed)
|
||||
|
||||
def test_release_discovery_does_not_fall_back_to_the_source_tree(self) -> None:
|
||||
def test_release_discovery_has_no_source_tree_fallback(self) -> None:
|
||||
source = (ROOT / "crates/cli/src/stdlib.rs").read_text(encoding="utf-8")
|
||||
fallback = source.index("CARGO_MANIFEST_DIR")
|
||||
self.assertIn("#[cfg(debug_assertions)]", source[:fallback])
|
||||
# The compile-time path must be inside the debug-only block: a release
|
||||
# build cannot reach it.
|
||||
debug_block = source[fallback - 200 : fallback + 400]
|
||||
self.assertIn("#[cfg(debug_assertions)]", debug_block)
|
||||
# Phase B: no build profile may reach a compile-time source tree; only the
|
||||
# explicit override and the installed sibling Bundle remain.
|
||||
self.assertNotIn("CARGO_MANIFEST_DIR", source)
|
||||
self.assertNotIn("debug_assertions", source)
|
||||
self.assertIn("STDLIB_DIR_ENV", source)
|
||||
self.assertIn("parent.join(\"stdlib\")", source)
|
||||
|
||||
def test_smoke_verifies_and_fails_closed_without_stdlib(self) -> None:
|
||||
source = (ROOT / "tools/release/smoke.py").read_text(encoding="utf-8")
|
||||
|
||||
@@ -111,13 +111,14 @@ class BundleResolverTest(unittest.TestCase):
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.dir = Path(self.tmp.name)
|
||||
|
||||
def test_repository_bundle_matches_the_pin(self) -> None:
|
||||
root, record, pin = self.bundle.resolve()
|
||||
self.assertEqual(root, (ROOT / "stdlib").resolve())
|
||||
self.assertEqual(record["tree_digest"], pin["tree_digest"])
|
||||
self.assertEqual(record["aliases_digest"], pin["aliases_digest"])
|
||||
self.assertEqual(record["name"], "marqdo-stdlib")
|
||||
self.assertIn("io.mq.md", record["files"])
|
||||
def test_accepted_ecosystem_pin_requires_an_explicit_bundle(self) -> None:
|
||||
pin = self.bundle.load_pin()
|
||||
self.assertEqual(pin["source"]["kind"], "ecosystem")
|
||||
self.assertNotIn("path", pin["source"])
|
||||
with self.assertRaisesRegex(
|
||||
self.bundle.BundleError, "not vendored in this repository"
|
||||
):
|
||||
self.bundle.resolve(None, ROOT / "tools/stdlib/bundle-pin.json")
|
||||
|
||||
def test_explicit_valid_bundle_still_has_to_match_the_pin(self) -> None:
|
||||
other = self.dir / "other-bundle"
|
||||
@@ -188,11 +189,26 @@ class BundleResolverTest(unittest.TestCase):
|
||||
with self.assertRaisesRegex(self.bundle.BundleError, "schema_version"):
|
||||
self.bundle.load_pin(pin_path)
|
||||
|
||||
def test_cli_prints_the_resolved_path(self) -> None:
|
||||
def test_cli_prints_the_resolved_explicit_path(self) -> None:
|
||||
bundle = self.dir / "explicit"
|
||||
manifest = make_bundle(bundle)
|
||||
pin_path = self.dir / "explicit-pin.json"
|
||||
write_pin(pin_path, manifest, str(bundle))
|
||||
stdout = io.StringIO()
|
||||
with contextlib.redirect_stdout(stdout):
|
||||
self.assertEqual(self.bundle.main(["--print-path"]), 0)
|
||||
self.assertEqual(Path(stdout.getvalue().strip()), (ROOT / "stdlib").resolve())
|
||||
self.assertEqual(
|
||||
self.bundle.main(
|
||||
[
|
||||
"--stdlib-dir",
|
||||
str(bundle),
|
||||
"--pin",
|
||||
str(pin_path),
|
||||
"--print-path",
|
||||
]
|
||||
),
|
||||
0,
|
||||
)
|
||||
self.assertEqual(Path(stdout.getvalue().strip()), bundle.resolve())
|
||||
|
||||
def test_cli_fails_for_an_invalid_explicit_input(self) -> None:
|
||||
stderr = io.StringIO()
|
||||
@@ -297,17 +313,22 @@ class PackStdlibTest(unittest.TestCase):
|
||||
archive.extractfile("io.mq.md").read(), (bundle / "io.mq.md").read_bytes()
|
||||
)
|
||||
|
||||
def test_repository_bundle_packs_against_the_committed_pin(self) -> None:
|
||||
def test_explicit_bundle_packs_against_a_matching_pin(self) -> None:
|
||||
bundle = self.dir / "pack-bundle"
|
||||
manifest = make_bundle(bundle)
|
||||
pin_path = self.dir / "pack-pin.json"
|
||||
write_pin(pin_path, manifest, str(bundle))
|
||||
out = self.dir / "out"
|
||||
self.assertEqual(
|
||||
self.run_pack(
|
||||
"--stdlib-dir", str(ROOT / "stdlib"), "--out-dir", str(out),
|
||||
"--bundle-pin", str(ROOT / "tools/stdlib/bundle-pin.json"),
|
||||
"--stdlib-dir", str(bundle), "--out-dir", str(out),
|
||||
"--bundle-pin", str(pin_path),
|
||||
),
|
||||
0,
|
||||
)
|
||||
descriptor = json.loads((out / "marqdo-stdlib-0.1.0.json").read_text())
|
||||
manifest = json.loads((ROOT / "stdlib/stdlib.json").read_text())
|
||||
descriptor = json.loads(
|
||||
(out / f"marqdo-stdlib-{manifest['version']}.json").read_text()
|
||||
)
|
||||
self.assertEqual(descriptor["tree_digest"], manifest["digest"])
|
||||
self.assertEqual(descriptor["aliases_digest"], manifest["aliases_digest"])
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
"schema": "marqdo.stdlib-bundle-pin",
|
||||
"schema_version": 1,
|
||||
"name": "marqdo-stdlib",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"source": {
|
||||
"kind": "in-repo",
|
||||
"repository": "cflmy/marqdo-cli",
|
||||
"commit": "2cbde54602c07f62a62f341400bc9cb4764a93f8",
|
||||
"path": "stdlib",
|
||||
"note": "Phase A (ADR-0070): the pinned Bundle is the checkout tree at this commit. Phase B replaces this record with the accepted ecosystem Bundle commit and digest; do not change it in the same commit as test fixtures."
|
||||
"kind": "ecosystem",
|
||||
"repository": "cflmy/marqdo",
|
||||
"commit": "48189243f747d5f73d5a38a565010e64e2db74e7",
|
||||
"producer": "scripts/build-stdlib.py",
|
||||
"note": "Phase B (ADR-0070): the accepted Bundle is assembled by the ecosystem root commit that pins the component gitlinks. No stdlib source tree exists in this repository."
|
||||
},
|
||||
"tree_digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
|
||||
"tree_digest": "sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7",
|
||||
"aliases_digest": "sha256:5f513c0fdbb3c1e9829be3c9fa23a2d1e89cb8510073fb5eb1e8e2f5265a83bb"
|
||||
}
|
||||
+20
-3
@@ -217,8 +217,18 @@ def load_pin(path: Path = PIN_PATH) -> dict:
|
||||
f"Bundle pin {path} must be {PIN_SCHEMA} schema_version {PIN_SCHEMA_VERSION}"
|
||||
)
|
||||
source = pin.get("source")
|
||||
if not isinstance(source, dict) or not isinstance(source.get("path"), str):
|
||||
raise BundleError(f"Bundle pin {path} has no source.path")
|
||||
if not isinstance(source, dict):
|
||||
raise BundleError(f"Bundle pin {path} has no source object")
|
||||
kind = source.get("kind")
|
||||
if kind in ("in-repo", "test"):
|
||||
if not isinstance(source.get("path"), str) or not source["path"]:
|
||||
raise BundleError(f"Bundle pin {path} has no source.path")
|
||||
elif kind == "ecosystem":
|
||||
for field in ("repository", "commit"):
|
||||
if not isinstance(source.get(field), str) or not source[field]:
|
||||
raise BundleError(f"Bundle pin {path} has no source.{field}")
|
||||
else:
|
||||
raise BundleError(f"Bundle pin {path} has unknown source.kind: {kind!r}")
|
||||
for field in ("name", "version", "tree_digest", "aliases_digest"):
|
||||
if not isinstance(pin.get(field), str) or not pin[field]:
|
||||
raise BundleError(f"Bundle pin {path} has no non-empty `{field}`")
|
||||
@@ -248,8 +258,15 @@ def resolve(
|
||||
default location is valid; there is no fallback.
|
||||
"""
|
||||
pin = load_pin(pin_path)
|
||||
source = pin["source"]
|
||||
if explicit is None:
|
||||
root = ROOT / pin["source"]["path"]
|
||||
if source.get("kind") not in ("in-repo", "test") or "path" not in source:
|
||||
raise BundleError(
|
||||
"the accepted Bundle is not vendored in this repository; pass an "
|
||||
"explicit --stdlib-dir or MARQDO_TEST_STDLIB_BUNDLE produced from "
|
||||
f"{source.get('repository')}@{source.get('commit')}"
|
||||
)
|
||||
root = ROOT / source["path"]
|
||||
else:
|
||||
root = Path(explicit)
|
||||
record = verify(root)
|
||||
|
||||
Reference in new issue
Block a user