velella-ebb 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Armin Azimi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: velella-ebb
3
+ Version: 0.1.0
4
+ Summary: Read Ebb lifecycle data and maintainer declarations
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/velella-sh/ebb-python
7
+ Project-URL: Ebb, https://github.com/velella-sh/ebb
8
+ Project-URL: Documentation, https://velella.sh/ebb/readers/
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Classifier: Typing :: Typed
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # Ebb Python reader
22
+
23
+ `velella_ebb` reads Ebb lifecycle registries, data bundles, and maintainer declarations. It uses the Python 3.11+ standard library at runtime. It reads data when you supply a file path or URL.
24
+
25
+ Install a wheel you built from this checkout.
26
+
27
+ ```sh
28
+ python -m build
29
+ python -m pip install dist/*.whl
30
+ ```
31
+
32
+ Evaluate a registry file from [velella-sh/ebb](https://github.com/velella-sh/ebb), for example `registry/npm.json`.
33
+
34
+ ```python
35
+ from velella_ebb import load
36
+
37
+ reader = load("registry/npm.json")
38
+ result = reader.check("pkg:npm/next", "12.3.4")
39
+ print(result.status, result.event, result.deadline)
40
+ for rule in result.matched_rules:
41
+ print(rule["id"], rule["sources"])
42
+ ```
43
+
44
+ Coverage is `affected`, `no-match` for a known component outside all matching ranges, or `unknown` when no component evidence was found. An applicable rule with an unparseable version gives `invalid-version`. Catch `UnsupportedScheme` when checking components outside SemVer, npm and PEP 440 (`pypi` and `pep440`). For a historical result, pass `as_of="2026-03-01"`.
45
+
46
+ The reader uses canonical PURL type, namespace and name. The shared upstream PURL vectors cover generic, GitHub, Go, npm and PyPI identities. Use `Reader(rules, aliases=...)` for a reviewed mapping from the stored PURL to its canonical alias. Optional predictions go in `Reader(rules, predictions=...)`. The result exposes predictions with their bounds and confidence.
47
+
48
+ For signed Ebb data releases, follow the [Sigstore verification commands](https://velella.sh/ebb/spec/1.0/distribution/#verify-a-published-ebb-bundle). Run `cosign verify-blob` against the exact bundle with the expected release-workflow identity and OIDC issuer. Pass the verified transport SHA-256 to `load(path, expected_sha256=...)`. The reader verifies each file's canonical SHA-256 and length, the manifest's content digest, and the optional exact-byte checksum. Supply a local path or trusted HTTP(S) URL.
49
+
50
+ Use `read_declaration(project_directory)` to read `lifecycle.json` and the Python manifest, or pass `format_="npm"` for an npm project. `project_declaration(declaration, evidence)` converts reviewed milestones to rules and CLE events. It retains an existing CLE URL for the caller to verify.
51
+
52
+ ## Conformance baseline
53
+
54
+ The shared conformance suite comes from `velella-sh/ebb` commit `96ee2af85063b430471775f819eba48d2bb99a48`, pinned in `conformance.lock`. Ebb v0.2.1 is not tagged yet, so CI builds the suite from that commit with `tools/conformance-asset.py`, verifies the archive with `sha256sum --check`, and runs it with the Ebb CLI built from the same commit. After the signed `ebb-conformance-<version>.tar.gz` release asset exists, the baseline moves to it (velella-sh/ebb#1200). Release notes record this SHA.
55
+
56
+ Run the unit tests and the suite after installing the wheel. You need `git`, `python3` and Node.js 22.
57
+
58
+ ```sh
59
+ tools/fetch-conformance.sh
60
+ python -m unittest discover -s tests
61
+ node .ebb/dist/src/cli.js conformance consumer \
62
+ --schemes semver,npm,pep440,pypi \
63
+ --profiles historical-projection,ebb.prediction.v1,purl-aliases \
64
+ -- python conformance_adapter.py
65
+ node .ebb/dist/src/cli.js conformance consumer \
66
+ --vectors conformance/vectors/declaration.json --profiles maintainer-declaration \
67
+ -- python conformance_adapter.py
68
+ ```
69
+
70
+ The upstream PURL and VERS fixtures and the two registry files under `tests/fixtures/` are vendored copies and must stay byte-for-byte identical to their sources.
71
+
72
+ ## Publishing the reader
73
+
74
+ For the first release, a maintainer registers a [pending Trusted Publisher](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/) in their PyPI account using the following settings.
75
+
76
+ | Field | Value |
77
+ | --- | --- |
78
+ | PyPI project name | `velella-ebb` |
79
+ | GitHub owner | `velella-sh` |
80
+ | Repository name | `ebb-python` |
81
+ | Workflow filename | `release.yml` |
82
+ | GitHub environment | `pypi` |
83
+
84
+ The [release workflow](https://github.com/velella-sh/ebb-python/actions/workflows/release.yml) publishes the tested wheel and source distribution with attestations when a `v<version>` tag matches both distribution filenames. Publishing to PyPI is tracked in velella-sh/ebb#978.
85
+
86
+ After publication, verify the released wheel locally from a virtual environment. Set `version` to the version shown in the release run.
87
+
88
+ ```sh
89
+ version=0.1.0
90
+ wheel_dir=$(mktemp -d)
91
+ python -m pip install pypi-attestations==0.0.32
92
+ python -m pip download --only-binary=:all: --no-deps --dest "$wheel_dir" "velella-ebb==$version"
93
+ python -m pypi_attestations verify pypi --repository https://github.com/velella-sh/ebb-python "$wheel_dir/velella_ebb-$version-py3-none-any.whl"
94
+ ```
@@ -0,0 +1,74 @@
1
+ # Ebb Python reader
2
+
3
+ `velella_ebb` reads Ebb lifecycle registries, data bundles, and maintainer declarations. It uses the Python 3.11+ standard library at runtime. It reads data when you supply a file path or URL.
4
+
5
+ Install a wheel you built from this checkout.
6
+
7
+ ```sh
8
+ python -m build
9
+ python -m pip install dist/*.whl
10
+ ```
11
+
12
+ Evaluate a registry file from [velella-sh/ebb](https://github.com/velella-sh/ebb), for example `registry/npm.json`.
13
+
14
+ ```python
15
+ from velella_ebb import load
16
+
17
+ reader = load("registry/npm.json")
18
+ result = reader.check("pkg:npm/next", "12.3.4")
19
+ print(result.status, result.event, result.deadline)
20
+ for rule in result.matched_rules:
21
+ print(rule["id"], rule["sources"])
22
+ ```
23
+
24
+ Coverage is `affected`, `no-match` for a known component outside all matching ranges, or `unknown` when no component evidence was found. An applicable rule with an unparseable version gives `invalid-version`. Catch `UnsupportedScheme` when checking components outside SemVer, npm and PEP 440 (`pypi` and `pep440`). For a historical result, pass `as_of="2026-03-01"`.
25
+
26
+ The reader uses canonical PURL type, namespace and name. The shared upstream PURL vectors cover generic, GitHub, Go, npm and PyPI identities. Use `Reader(rules, aliases=...)` for a reviewed mapping from the stored PURL to its canonical alias. Optional predictions go in `Reader(rules, predictions=...)`. The result exposes predictions with their bounds and confidence.
27
+
28
+ For signed Ebb data releases, follow the [Sigstore verification commands](https://velella.sh/ebb/spec/1.0/distribution/#verify-a-published-ebb-bundle). Run `cosign verify-blob` against the exact bundle with the expected release-workflow identity and OIDC issuer. Pass the verified transport SHA-256 to `load(path, expected_sha256=...)`. The reader verifies each file's canonical SHA-256 and length, the manifest's content digest, and the optional exact-byte checksum. Supply a local path or trusted HTTP(S) URL.
29
+
30
+ Use `read_declaration(project_directory)` to read `lifecycle.json` and the Python manifest, or pass `format_="npm"` for an npm project. `project_declaration(declaration, evidence)` converts reviewed milestones to rules and CLE events. It retains an existing CLE URL for the caller to verify.
31
+
32
+ ## Conformance baseline
33
+
34
+ The shared conformance suite comes from `velella-sh/ebb` commit `96ee2af85063b430471775f819eba48d2bb99a48`, pinned in `conformance.lock`. Ebb v0.2.1 is not tagged yet, so CI builds the suite from that commit with `tools/conformance-asset.py`, verifies the archive with `sha256sum --check`, and runs it with the Ebb CLI built from the same commit. After the signed `ebb-conformance-<version>.tar.gz` release asset exists, the baseline moves to it (velella-sh/ebb#1200). Release notes record this SHA.
35
+
36
+ Run the unit tests and the suite after installing the wheel. You need `git`, `python3` and Node.js 22.
37
+
38
+ ```sh
39
+ tools/fetch-conformance.sh
40
+ python -m unittest discover -s tests
41
+ node .ebb/dist/src/cli.js conformance consumer \
42
+ --schemes semver,npm,pep440,pypi \
43
+ --profiles historical-projection,ebb.prediction.v1,purl-aliases \
44
+ -- python conformance_adapter.py
45
+ node .ebb/dist/src/cli.js conformance consumer \
46
+ --vectors conformance/vectors/declaration.json --profiles maintainer-declaration \
47
+ -- python conformance_adapter.py
48
+ ```
49
+
50
+ The upstream PURL and VERS fixtures and the two registry files under `tests/fixtures/` are vendored copies and must stay byte-for-byte identical to their sources.
51
+
52
+ ## Publishing the reader
53
+
54
+ For the first release, a maintainer registers a [pending Trusted Publisher](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/) in their PyPI account using the following settings.
55
+
56
+ | Field | Value |
57
+ | --- | --- |
58
+ | PyPI project name | `velella-ebb` |
59
+ | GitHub owner | `velella-sh` |
60
+ | Repository name | `ebb-python` |
61
+ | Workflow filename | `release.yml` |
62
+ | GitHub environment | `pypi` |
63
+
64
+ The [release workflow](https://github.com/velella-sh/ebb-python/actions/workflows/release.yml) publishes the tested wheel and source distribution with attestations when a `v<version>` tag matches both distribution filenames. Publishing to PyPI is tracked in velella-sh/ebb#978.
65
+
66
+ After publication, verify the released wheel locally from a virtual environment. Set `version` to the version shown in the release run.
67
+
68
+ ```sh
69
+ version=0.1.0
70
+ wheel_dir=$(mktemp -d)
71
+ python -m pip install pypi-attestations==0.0.32
72
+ python -m pip download --only-binary=:all: --no-deps --dest "$wheel_dir" "velella-ebb==$version"
73
+ python -m pypi_attestations verify pypi --repository https://github.com/velella-sh/ebb-python "$wheel_dir/velella_ebb-$version-py3-none-any.whl"
74
+ ```
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "velella-ebb"
7
+ version = "0.1.0"
8
+ description = "Read Ebb lifecycle data and maintainer declarations"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ dependencies = []
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3 :: Only",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Programming Language :: Python :: 3.15",
21
+ "Typing :: Typed",
22
+ ]
23
+
24
+ [project.urls]
25
+ Repository = "https://github.com/velella-sh/ebb-python"
26
+ Ebb = "https://github.com/velella-sh/ebb"
27
+ Documentation = "https://velella.sh/ebb/readers/"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,29 @@
1
+ """Offline evaluation of Ebb lifecycle data."""
2
+
3
+ from .check import Reader as Reader
4
+ from .check import Result as Result
5
+ from .declaration import (
6
+ DeclarationError as DeclarationError,
7
+ )
8
+ from .declaration import (
9
+ project_declaration as project_declaration,
10
+ )
11
+ from .declaration import (
12
+ read_declaration as read_declaration,
13
+ )
14
+ from .declaration import (
15
+ resolve_declaration as resolve_declaration,
16
+ )
17
+ from .load import load as load
18
+ from .purl import Purl as Purl
19
+ from .purl import parse_purl as parse_purl
20
+ from .purl import purl_identity as purl_identity
21
+ from .vers import (
22
+ InvalidVersion as InvalidVersion,
23
+ )
24
+ from .vers import (
25
+ UnsupportedScheme as UnsupportedScheme,
26
+ )
27
+ from .vers import (
28
+ vers_contains as vers_contains,
29
+ )
@@ -0,0 +1,167 @@
1
+ """Evaluate package lifecycle rules from caller-supplied evidence."""
2
+
3
+ import re
4
+ from collections import defaultdict
5
+ from collections.abc import Iterable, Mapping
6
+ from dataclasses import dataclass
7
+ from datetime import date
8
+ from typing import Any, Literal
9
+
10
+ from .purl import purl_identity
11
+ from .vers import InvalidVersion, UnsupportedScheme, vers_contains
12
+
13
+ EVENTS = (
14
+ "end-of-life",
15
+ "removed",
16
+ "end-of-support",
17
+ "deprecated",
18
+ "scheduled-end-of-life",
19
+ "end-of-active-support",
20
+ "end-of-extended-support",
21
+ )
22
+ Rule = Mapping[str, Any]
23
+ Status = Literal["affected", "no-match", "unknown", "invalid-version"]
24
+ VERSION_LINE = re.compile(r"^v?(?:0+!)?([0-9]+)(?:\.([0-9]+))?", re.IGNORECASE)
25
+
26
+
27
+ def calendar_day(value: str) -> date:
28
+ result = date.fromisoformat(value)
29
+ if result.isoformat() != value:
30
+ raise ValueError(f"expected a UTC calendar day, got {value!r}")
31
+ return result
32
+
33
+
34
+ def _with_release_line_deadline(rule: Rule, version: str) -> Rule:
35
+ deadlines = rule.get("x-release-line-deadlines")
36
+ if not isinstance(deadlines, Mapping):
37
+ return rule
38
+ result = dict(rule)
39
+ result.pop("deadline", None)
40
+ line = VERSION_LINE.match(version.strip())
41
+ if line:
42
+ major = line[1].lstrip("0") or "0"
43
+ minor = (line[2].lstrip("0") or "0") if line[2] is not None else None
44
+ deadline = deadlines.get(f"{major}.{minor}", deadlines.get(major))
45
+ if isinstance(deadline, str):
46
+ calendar_day(deadline)
47
+ result["deadline"] = deadline
48
+ return result
49
+
50
+
51
+ @dataclass(frozen=True)
52
+ class Result:
53
+ status: Status
54
+ event: str | None = None
55
+ deadline: str | None = None
56
+ matched_rules: tuple[Rule, ...] = ()
57
+ prediction: Rule | None = None
58
+ matched_via: Literal["alias"] | None = None
59
+
60
+
61
+ class Reader:
62
+ """Index a registry or bundle's rules for offline lookup."""
63
+
64
+ def __init__(
65
+ self,
66
+ rules: Iterable[Rule],
67
+ *,
68
+ aliases: Mapping[str, str] | None = None,
69
+ predictions: Iterable[Rule] = (),
70
+ ) -> None:
71
+ self._aliases = {
72
+ purl_identity(key): purl_identity(value)
73
+ for key, value in (aliases or {}).items()
74
+ }
75
+ self._index: dict[str, list[Rule]] = defaultdict(list)
76
+ for rule in rules:
77
+ identity = purl_identity(rule["purl"])
78
+ self._index[self._aliases.get(identity, identity)].append(rule)
79
+ self._predictions: dict[str, list[Rule]] = defaultdict(list)
80
+ for prediction in predictions:
81
+ identity = purl_identity(prediction["purl"])
82
+ self._predictions[self._aliases.get(identity, identity)].append(prediction)
83
+
84
+ def check(
85
+ self,
86
+ purl: str,
87
+ version: str,
88
+ as_of: str | date | None = None,
89
+ *,
90
+ historical: bool = True,
91
+ ) -> Result:
92
+ """Check evidence, projecting history only when an as-of day is supplied."""
93
+ day = as_of.isoformat() if isinstance(as_of, date) else as_of
94
+ if day is not None:
95
+ calendar_day(day)
96
+
97
+ name = purl_identity(purl)
98
+ identity = self._aliases.get(name, name)
99
+ candidates = [
100
+ rule
101
+ for rule in self._index.get(identity, ())
102
+ if day is None or not historical or rule["provenance"]["observedAt"] <= day
103
+ ]
104
+
105
+ def effective_event(rule: Rule) -> str:
106
+ event = rule["event"]
107
+ deadline = rule.get("deadline")
108
+ if (
109
+ historical
110
+ and day
111
+ and event == "scheduled-end-of-life"
112
+ and deadline
113
+ and deadline <= day
114
+ ):
115
+ return "end-of-life"
116
+ return event
117
+
118
+ try:
119
+ matched = [
120
+ _with_release_line_deadline(rule, version)
121
+ for rule in candidates
122
+ if not rule.get("usage") and vers_contains(rule["vers"], version)
123
+ ]
124
+ except InvalidVersion:
125
+ return Result("invalid-version")
126
+
127
+ prediction = self._prediction(identity, version, matched)
128
+ if not matched:
129
+ return Result(
130
+ "no-match" if candidates else "unknown", prediction=prediction
131
+ )
132
+ matched.sort(
133
+ key=lambda rule: (
134
+ EVENTS.index(effective_event(rule)),
135
+ rule.get("deadline") or "9999-12-32",
136
+ )
137
+ )
138
+ top = matched[0]
139
+ return Result(
140
+ "affected",
141
+ effective_event(top),
142
+ top.get("deadline"),
143
+ tuple(matched),
144
+ prediction,
145
+ "alias" if purl_identity(top["purl"]) != name else None,
146
+ )
147
+
148
+ def _prediction(self, purl: str, version: str, matched: list[Rule]) -> Rule | None:
149
+ if any(
150
+ rule["event"] in {"end-of-life", "scheduled-end-of-life"}
151
+ and rule.get("deadline")
152
+ and rule.get("confidence", "confirmed") == "confirmed"
153
+ for rule in matched
154
+ ):
155
+ return None
156
+ for prediction in self._predictions.get(purl, ()):
157
+ try:
158
+ matches = vers_contains(prediction["lineVers"], version)
159
+ except (InvalidVersion, UnsupportedScheme):
160
+ continue
161
+ if matches:
162
+ return {
163
+ "kind": "predicted",
164
+ **prediction["predictedEnd"],
165
+ "confidence": prediction["confidence"],
166
+ }
167
+ return None