mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-11-22 23:10:35 +00:00
api: organize compatibility evidence
This commit is contained in:
1 parent
d58ea18011
commit
b2aab6940d
18 files changed
+167
-169
No files matched your search
@@ -10,7 +10,7 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
env:
|
env:
|
||||||
RSLXMF_RSRETICULUM_COMMIT: dc6bc4ee82daf66b3b40386f9777dbe62b08fec2
|
RSLXMF_RSRETICULUM_COMMIT: e0889f718894ead2f0deb37ad144d67c24fe6270
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
api-compat:
|
api-compat:
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
run: python3 tools/check-api-compatibility.py
|
run: python3 tools/check-api-compatibility.py
|
||||||
working-directory: rsLXMF
|
working-directory: rsLXMF
|
||||||
- name: Check canonical and legacy external consumer
|
- name: Check canonical and legacy external consumer
|
||||||
run: cargo check --manifest-path api-fixtures/Cargo.toml --locked
|
run: cargo check --manifest-path api/fixtures/Cargo.toml --locked
|
||||||
working-directory: rsLXMF
|
working-directory: rsLXMF
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ env:
|
|||||||
PACKAGE_ROOT: rsLXMF
|
PACKAGE_ROOT: rsLXMF
|
||||||
LXMF_BINS: lxmd-rs
|
LXMF_BINS: lxmd-rs
|
||||||
RSLXMF_RSRETICULUM_VERSION: 1.2.0
|
RSLXMF_RSRETICULUM_VERSION: 1.2.0
|
||||||
RSLXMF_RSRETICULUM_COMMIT: dc6bc4ee82daf66b3b40386f9777dbe62b08fec2
|
RSLXMF_RSRETICULUM_COMMIT: e0889f718894ead2f0deb37ad144d67c24fe6270
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
verify:
|
verify:
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
/target/
|
/target/
|
||||||
/api-fixtures/target/
|
/api/fixtures/target/
|
||||||
*.swp
|
*.swp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
proptest-regressions/
|
proptest-regressions/
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# API stability
|
|
||||||
|
|
||||||
rsLXMF is currently source-distributed with `publish = false`. The current
|
|
||||||
Rust module tree is useful to source consumers, but only part of it is an
|
|
||||||
intentional long-term library boundary.
|
|
||||||
|
|
||||||
`api-stability.json` classifies every library package and pins the exact
|
|
||||||
pre-boundary commit. `api-baseline/*.txt` contains the complete explicit public
|
|
||||||
surface observed by pinned `cargo-public-api` and rustdoc versions. CI rejects
|
|
||||||
unreviewed drift. These snapshots are compatibility evidence, not a promise
|
|
||||||
that every listed state-machine field or helper will remain public forever.
|
|
||||||
|
|
||||||
`lxmf-core` is **candidate stable** as a package. Its message, presentation,
|
|
||||||
ticket, routing, propagation, sync, and public delivery concepts are intended
|
|
||||||
consumer capabilities. Its current modules also expose handler plumbing,
|
|
||||||
persistence representations, admission machinery, Link-delivery state, and
|
|
||||||
other orchestration details that remain provisional until the API-boundary
|
|
||||||
checkpoint. `lxmf-tools` is **tool internal** and exists to support `lxmd-rs`;
|
|
||||||
it is not a library compatibility commitment.
|
|
||||||
|
|
||||||
[`lxmf_core::message_api`](MESSAGE_API.md) is the canonical candidate message
|
|
||||||
path. It re-exports existing identities without adaptation, and the original
|
|
||||||
module paths remain supported. Router, delivery, propagation, handler, and
|
|
||||||
persistence ownership are not promoted by this narrow facade.
|
|
||||||
|
|
||||||
No visibility, signature, serialization, wire, persistence, or runtime change
|
|
||||||
is made by establishing this baseline. Any later boundary reduction must first
|
|
||||||
show the public API diff, migrate Ratspeak and other first-party users, preserve
|
|
||||||
the supported facade, and make an explicit version/changelog decision.
|
|
||||||
|
|
||||||
The canonical snapshot uses all features on `aarch64-apple-darwin` and omits
|
|
||||||
auto-derived, auto-trait, and blanket implementations. Other target overlays
|
|
||||||
remain covered by existing build and interop gates rather than this first
|
|
||||||
host API snapshot.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cargo install cargo-public-api --version 0.52.0 --locked
|
|
||||||
rustup toolchain install nightly-2026-08-01 --profile minimal
|
|
||||||
python3 tools/check-api-baseline.py
|
|
||||||
python3 tools/check-api-manifest.py
|
|
||||||
python3 tools/check-api-compatibility.py
|
|
||||||
cargo check --manifest-path api-fixtures/Cargo.toml --locked
|
|
||||||
```
|
|
||||||
|
|
||||||
The immutable floor and current captured snapshot source are separate
|
|
||||||
identities in `api-stability.json`. A capture names its clean basis commit and
|
|
||||||
reviewed change record; CI renders the current tree and requires a byte-exact
|
|
||||||
snapshot, avoiding an impossible self-referential commit identifier. The
|
|
||||||
manifest contract covers features,
|
|
||||||
targets, MSRV, and non-development dependencies that one Apple/all-feature API
|
|
||||||
view cannot prove. The compatibility check currently rejects every removal
|
|
||||||
from the Wave C floor; it complements rather than replaces feature, platform,
|
|
||||||
wire, persistence, and interoperability evidence.
|
|
||||||
|
|
||||||
Run with `--update` only after reviewing and recording the compatibility
|
|
||||||
impact; refreshing a snapshot is never a substitute for that review.
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# LXMF message API
|
|
||||||
|
|
||||||
`lxmf_core::message_api` is the canonical application path for constructing
|
|
||||||
and inspecting LXMF message values. It contains exact re-exports of the
|
|
||||||
existing message, status, and identifier identities; all module-qualified
|
|
||||||
paths remain supported.
|
|
||||||
|
|
||||||
The compiled `lxmf-core` `message` example demonstrates construction, signing,
|
|
||||||
packing, and unpacking. Its imports are the facade conformance contract.
|
|
||||||
|
|
||||||
This first boundary is deliberately narrower than an LXMF router facade.
|
|
||||||
`LxmRouter`, delivery ownership, propagation clients/nodes, handlers,
|
|
||||||
persistence, and raw Reticulum transport channels remain provisional,
|
|
||||||
module-qualified orchestration APIs. The facade does not alter wire fields,
|
|
||||||
signatures, serialization, delivery methods, proofs, or persistence.
|
|
||||||
|
|
||||||
Compatibility is checked by the reviewed API snapshot, the manifest/feature
|
|
||||||
contract, an additions-only comparison with the immutable Wave C floor, and an
|
|
||||||
external crate that compiles both canonical and retained imports. Platform,
|
|
||||||
wire, persistence, and Python interoperability gates remain separate evidence.
|
|
||||||
@@ -27,7 +27,7 @@ LXMF daemons on `PATH` without worry.
|
|||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
- [Build It](#build-it)
|
- [Build It](#build-it)
|
||||||
- [Message API](MESSAGE_API.md)
|
- [Rust API](api/README.md)
|
||||||
- [Operating lxmd-rs](#operating-lxmd-rs)
|
- [Operating lxmd-rs](#operating-lxmd-rs)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
- [Delivery Model](#delivery-model)
|
- [Delivery Model](#delivery-model)
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"snapshotSourceCommit": "c934ccc5feaaddb55461404094ed6bb514aae2cc",
|
|
||||||
"capabilities": ["LXMF-01"],
|
|
||||||
"canonicalPath": "lxmf_core::message_api",
|
|
||||||
"retainedPaths": [
|
|
||||||
"lxmf_core::message",
|
|
||||||
"lxmf_core::constants",
|
|
||||||
"lxmf_core::types"
|
|
||||||
],
|
|
||||||
"internalSpiExcluded": [
|
|
||||||
"router",
|
|
||||||
"delivery ownership",
|
|
||||||
"propagation",
|
|
||||||
"handlers",
|
|
||||||
"persistence",
|
|
||||||
"raw Reticulum transport channels"
|
|
||||||
],
|
|
||||||
"classification": "additive-minor",
|
|
||||||
"publicApiDiff": {"added": 70, "removed": 0},
|
|
||||||
"semver": "compatible additive facade; version selection is deferred to Wave D",
|
|
||||||
"deprecations": "none",
|
|
||||||
"wirePersistenceRuntimeImpact": "none; exact re-exports only",
|
|
||||||
"consumers": [
|
|
||||||
"Ratspeak messaging",
|
|
||||||
"external canonical fixture",
|
|
||||||
"retained legacy fixture"
|
|
||||||
],
|
|
||||||
"platformEvidence": [
|
|
||||||
"host example/test/clippy/rustdoc",
|
|
||||||
"Rust 1.87 external fixture",
|
|
||||||
"downstream product target gates at dependency handoff"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Rust API
|
||||||
|
|
||||||
|
Application code that constructs or inspects LXMF messages should use
|
||||||
|
`lxmf_core::message_api`. It re-exports the existing message, status, and
|
||||||
|
identifier types without wrapping or replacing them. The original
|
||||||
|
module-qualified paths remain supported.
|
||||||
|
|
||||||
|
The compiled `lxmf-core` `message` example demonstrates message construction,
|
||||||
|
signing, packing, and unpacking through this path.
|
||||||
|
|
||||||
|
## Stability
|
||||||
|
|
||||||
|
`lxmf-core` is candidate stable, but that classification does not make every
|
||||||
|
public implementation detail a permanent API. The message facade is the
|
||||||
|
recommended application path. Router ownership, delivery orchestration,
|
||||||
|
propagation clients and nodes, handlers, persistence representations,
|
||||||
|
admission machinery, Link-delivery state, and raw Reticulum channels remain
|
||||||
|
provisional module-qualified APIs.
|
||||||
|
|
||||||
|
`lxmf-tools` supports the `lxmd-rs` binary and is not a public library
|
||||||
|
integration target.
|
||||||
|
|
||||||
|
The message facade changes no wire fields, signatures, serialization,
|
||||||
|
delivery methods, proofs, persistence, or runtime behavior. Later reductions
|
||||||
|
to the broader module tree require a reviewed API diff, downstream migration,
|
||||||
|
and an explicit version decision.
|
||||||
|
|
||||||
|
## Compatibility checks
|
||||||
|
|
||||||
|
The `api/` directory contains the evidence used by CI:
|
||||||
|
|
||||||
|
- `stability.json` records package tiers, source commits, snapshot hashes, and
|
||||||
|
the current review decision;
|
||||||
|
- `snapshots/` records the explicit all-feature Apple ARM64 Rust API and the
|
||||||
|
manifest, feature, dependency, target, and MSRV contract; and
|
||||||
|
- `fixtures/` compiles recommended and retained imports as an external
|
||||||
|
consumer.
|
||||||
|
|
||||||
|
These checks catch accidental changes, but they do not replace platform builds,
|
||||||
|
wire and persistence tests, Python interoperability, or manual review. The API
|
||||||
|
snapshot omits auto-derived, auto-trait, and blanket implementations and is not
|
||||||
|
by itself a complete SemVer verdict.
|
||||||
|
|
||||||
|
Run the checks with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 tools/check-api-baseline.py
|
||||||
|
python3 tools/check-api-manifest.py
|
||||||
|
python3 tools/check-api-compatibility.py
|
||||||
|
cargo check --manifest-path api/fixtures/Cargo.toml --locked
|
||||||
|
```
|
||||||
|
|
||||||
|
Snapshot updates require a clean source commit and an explicit review recorded
|
||||||
|
in `api/stability.json`. Additions, removals, deprecations, platform impact, and
|
||||||
|
version consequences must be reviewed before accepting new evidence.
|
||||||
File renamed without changes.
@@ -7,4 +7,4 @@ publish = false
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lxmf-core = { path = "../crates/lxmf-core" }
|
lxmf-core = { path = "../../crates/lxmf-core" }
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -21,7 +21,37 @@
|
|||||||
"snapshotSource": {
|
"snapshotSource": {
|
||||||
"commit": "c934ccc5feaaddb55461404094ed6bb514aae2cc",
|
"commit": "c934ccc5feaaddb55461404094ed6bb514aae2cc",
|
||||||
"capturedOn": "2026-08-17",
|
"capturedOn": "2026-08-17",
|
||||||
"changeRecord": "api-reviews/wave-c-message-api.json"
|
"review": {
|
||||||
|
"areas": [
|
||||||
|
"message construction and inspection",
|
||||||
|
"message status and identifiers"
|
||||||
|
],
|
||||||
|
"canonicalPath": "lxmf_core::message_api",
|
||||||
|
"retainedPaths": [
|
||||||
|
"lxmf_core::message",
|
||||||
|
"lxmf_core::constants",
|
||||||
|
"lxmf_core::types"
|
||||||
|
],
|
||||||
|
"excludedImplementationAreas": [
|
||||||
|
"router and delivery ownership",
|
||||||
|
"propagation and handlers",
|
||||||
|
"persistence",
|
||||||
|
"raw Reticulum transport channels"
|
||||||
|
],
|
||||||
|
"classification": "compatible additive facade",
|
||||||
|
"publicApiDiff": {
|
||||||
|
"added": 70,
|
||||||
|
"removed": 0
|
||||||
|
},
|
||||||
|
"semver": "compatible additive facade included in version 1.2.0",
|
||||||
|
"deprecations": "none",
|
||||||
|
"wirePersistenceRuntimeImpact": "none; exact re-exports only",
|
||||||
|
"platformEvidence": [
|
||||||
|
"compiled message example and external canonical and legacy fixtures",
|
||||||
|
"stable and Rust 1.87 strict Clippy",
|
||||||
|
"downstream desktop and mobile product gates"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
@@ -29,7 +59,7 @@
|
|||||||
"manifestPath": "Cargo.toml",
|
"manifestPath": "Cargo.toml",
|
||||||
"tier": "candidate-stable",
|
"tier": "candidate-stable",
|
||||||
"compatibility": "reviewed-snapshot",
|
"compatibility": "reviewed-snapshot",
|
||||||
"snapshot": "api-baseline/lxmf-core.txt",
|
"snapshot": "api/snapshots/lxmf-core.txt",
|
||||||
"itemCount": 1622,
|
"itemCount": 1622,
|
||||||
"sha256": "c958cfdcb53117b02d1dbe907af6afaf5017d5ba92364267e21d204fe5ef3023"
|
"sha256": "c958cfdcb53117b02d1dbe907af6afaf5017d5ba92364267e21d204fe5ef3023"
|
||||||
},
|
},
|
||||||
@@ -38,7 +68,7 @@
|
|||||||
"manifestPath": "Cargo.toml",
|
"manifestPath": "Cargo.toml",
|
||||||
"tier": "tool-internal",
|
"tier": "tool-internal",
|
||||||
"compatibility": "reviewed-snapshot",
|
"compatibility": "reviewed-snapshot",
|
||||||
"snapshot": "api-baseline/lxmf-tools.txt",
|
"snapshot": "api/snapshots/lxmf-tools.txt",
|
||||||
"itemCount": 185,
|
"itemCount": 185,
|
||||||
"sha256": "0427d0fab38f8061cbf7f11b701f29f438490478f133524b0a8e4e7cfe6f3924"
|
"sha256": "0427d0fab38f8061cbf7f11b701f29f438490478f133524b0a8e4e7cfe6f3924"
|
||||||
}
|
}
|
||||||
+40
-37
@@ -16,7 +16,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
CONFIG_PATH = ROOT / "api-stability.json"
|
CONFIG_PATH = ROOT / "api" / "stability.json"
|
||||||
SHA_PATTERN = re.compile(r"^[0-9a-f]{40}$")
|
SHA_PATTERN = re.compile(r"^[0-9a-f]{40}$")
|
||||||
HASH_PATTERN = re.compile(r"^[0-9a-f]{64}$")
|
HASH_PATTERN = re.compile(r"^[0-9a-f]{64}$")
|
||||||
TIERS = {
|
TIERS = {
|
||||||
@@ -60,32 +60,41 @@ def load_config() -> dict[str, object]:
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
def validate_change_record(path: str, snapshot_commit: str) -> None:
|
def validate_snapshot_review(record: object) -> None:
|
||||||
record_path = ROOT / path
|
if not isinstance(record, dict):
|
||||||
try:
|
fail("snapshot review is missing")
|
||||||
record = json.loads(record_path.read_text(encoding="utf-8"))
|
|
||||||
except (OSError, json.JSONDecodeError) as error:
|
|
||||||
fail(f"cannot read snapshot change record {path}: {error}")
|
|
||||||
required = {
|
required = {
|
||||||
"schemaVersion", "snapshotSourceCommit", "capabilities", "classification",
|
"areas",
|
||||||
"publicApiDiff", "semver", "deprecations", "platformEvidence",
|
"canonicalPath",
|
||||||
|
"classification",
|
||||||
|
"publicApiDiff",
|
||||||
|
"semver",
|
||||||
|
"deprecations",
|
||||||
|
"wirePersistenceRuntimeImpact",
|
||||||
|
"platformEvidence",
|
||||||
}
|
}
|
||||||
if not required.issubset(record) or record.get("schemaVersion") != 1:
|
if not required.issubset(record):
|
||||||
fail("snapshot change record is incomplete")
|
fail("snapshot review is incomplete")
|
||||||
if record.get("snapshotSourceCommit") != snapshot_commit:
|
if not isinstance(record.get("areas"), list) or not record["areas"]:
|
||||||
fail("snapshot change record does not match the snapshot source commit")
|
fail("snapshot review must name the affected API areas")
|
||||||
if not isinstance(record.get("capabilities"), list) or not record["capabilities"]:
|
if not all(isinstance(area, str) and area for area in record["areas"]):
|
||||||
fail("snapshot change record must name capability IDs")
|
fail("snapshot review API areas must be non-empty strings")
|
||||||
diff = record.get("publicApiDiff")
|
diff = record.get("publicApiDiff")
|
||||||
if not isinstance(diff, dict) or set(diff) != {"added", "removed"}:
|
if not isinstance(diff, dict) or set(diff) != {"added", "removed"}:
|
||||||
fail("snapshot change record must classify added and removed API lines")
|
fail("snapshot review must classify added and removed API lines")
|
||||||
if not all(isinstance(diff[key], int) and diff[key] >= 0 for key in diff):
|
if not all(isinstance(diff[key], int) and diff[key] >= 0 for key in diff):
|
||||||
fail("snapshot change record API counts must be non-negative integers")
|
fail("snapshot review API counts must be non-negative integers")
|
||||||
if not isinstance(record.get("platformEvidence"), list) or not record["platformEvidence"]:
|
if not isinstance(record.get("platformEvidence"), list) or not record["platformEvidence"]:
|
||||||
fail("snapshot change record must name platform evidence")
|
fail("snapshot review must name platform evidence")
|
||||||
for key in ("classification", "semver", "deprecations"):
|
for key in (
|
||||||
|
"canonicalPath",
|
||||||
|
"classification",
|
||||||
|
"semver",
|
||||||
|
"deprecations",
|
||||||
|
"wirePersistenceRuntimeImpact",
|
||||||
|
):
|
||||||
if not isinstance(record.get(key), str) or not record[key]:
|
if not isinstance(record.get(key), str) or not record[key]:
|
||||||
fail(f"snapshot change record must name {key}")
|
fail(f"snapshot review must name {key}")
|
||||||
|
|
||||||
|
|
||||||
def public_packages(manifest_path: str) -> set[str]:
|
def public_packages(manifest_path: str) -> set[str]:
|
||||||
@@ -183,10 +192,7 @@ def validate_metadata(
|
|||||||
)
|
)
|
||||||
if snapshot_ancestor.returncode != 0:
|
if snapshot_ancestor.returncode != 0:
|
||||||
fail(f"snapshot source commit {snapshot_commit} is not an ancestor of HEAD")
|
fail(f"snapshot source commit {snapshot_commit} is not an ancestor of HEAD")
|
||||||
change_record = snapshot_source.get("changeRecord")
|
validate_snapshot_review(snapshot_source.get("review"))
|
||||||
if not isinstance(change_record, str) or not change_record.startswith("api-reviews/"):
|
|
||||||
fail("snapshot source must name a reviewed change record")
|
|
||||||
validate_change_record(change_record, snapshot_commit)
|
|
||||||
|
|
||||||
packages = config.get("packages")
|
packages = config.get("packages")
|
||||||
if not isinstance(packages, list) or not packages:
|
if not isinstance(packages, list) or not packages:
|
||||||
@@ -209,7 +215,7 @@ def validate_metadata(
|
|||||||
fail(f"{name} has an unknown stability tier")
|
fail(f"{name} has an unknown stability tier")
|
||||||
if package.get("compatibility") != "reviewed-snapshot":
|
if package.get("compatibility") != "reviewed-snapshot":
|
||||||
fail(f"{name} must use the reviewed-snapshot compatibility policy")
|
fail(f"{name} must use the reviewed-snapshot compatibility policy")
|
||||||
if not isinstance(snapshot, str) or not snapshot.startswith("api-baseline/"):
|
if not isinstance(snapshot, str) or not snapshot.startswith("api/snapshots/"):
|
||||||
fail(f"{name} has an invalid snapshot path")
|
fail(f"{name} has an invalid snapshot path")
|
||||||
snapshot_path = ROOT / snapshot
|
snapshot_path = ROOT / snapshot
|
||||||
if not snapshot_path.is_file() and not updating:
|
if not snapshot_path.is_file() and not updating:
|
||||||
@@ -292,29 +298,26 @@ def main() -> None:
|
|||||||
parser.add_argument("--metadata-only", action="store_true")
|
parser.add_argument("--metadata-only", action="store_true")
|
||||||
parser.add_argument("--update", action="store_true")
|
parser.add_argument("--update", action="store_true")
|
||||||
parser.add_argument("--snapshot-source-commit")
|
parser.add_argument("--snapshot-source-commit")
|
||||||
parser.add_argument("--change-record")
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.metadata_only and args.update:
|
if args.metadata_only and args.update:
|
||||||
fail("--metadata-only and --update are mutually exclusive")
|
fail("--metadata-only and --update are mutually exclusive")
|
||||||
|
|
||||||
config = load_config()
|
config = load_config()
|
||||||
if args.update:
|
if args.update:
|
||||||
if not args.snapshot_source_commit or not args.change_record:
|
if not args.snapshot_source_commit:
|
||||||
fail("--update requires --snapshot-source-commit and --change-record")
|
fail("--update requires --snapshot-source-commit")
|
||||||
head = run(["git", "rev-parse", "HEAD"]).strip()
|
head = run(["git", "rev-parse", "HEAD"]).strip()
|
||||||
if args.snapshot_source_commit != head:
|
if args.snapshot_source_commit != head:
|
||||||
fail("snapshot source must be the clean source commit at HEAD")
|
fail("snapshot source must be the clean source commit at HEAD")
|
||||||
if not args.change_record.startswith("api-reviews/"):
|
|
||||||
fail("change record must be stored below api-reviews/")
|
|
||||||
status = run(["git", "status", "--porcelain=v1", "--untracked-files=all"])
|
status = run(["git", "status", "--porcelain=v1", "--untracked-files=all"])
|
||||||
dirty_paths = {line[3:] for line in status.splitlines() if len(line) > 3}
|
dirty_paths = {line[3:] for line in status.splitlines() if len(line) > 3}
|
||||||
if dirty_paths - {args.change_record}:
|
if dirty_paths - {"api/stability.json"}:
|
||||||
fail("snapshot source has uncommitted changes outside the review record")
|
fail("snapshot source has uncommitted changes outside api/stability.json")
|
||||||
config["snapshotSource"] = {
|
snapshot_source = config.get("snapshotSource")
|
||||||
"commit": args.snapshot_source_commit,
|
if not isinstance(snapshot_source, dict):
|
||||||
"capturedOn": date.today().isoformat(),
|
fail("snapshot source identity is missing")
|
||||||
"changeRecord": args.change_record,
|
snapshot_source["commit"] = args.snapshot_source_commit
|
||||||
}
|
snapshot_source["capturedOn"] = date.today().isoformat()
|
||||||
packages = validate_metadata(config, updating=args.update)
|
packages = validate_metadata(config, updating=args.update)
|
||||||
if args.metadata_only:
|
if args.metadata_only:
|
||||||
print("api baseline metadata: ok")
|
print("api baseline metadata: ok")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Reject removals from the immutable Wave C public-API compatibility floor."""
|
"""Reject removals from the reviewed public-API compatibility floor."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
LEDGER_PATH = ROOT / "api-stability.json"
|
LEDGER_PATH = ROOT / "api" / "stability.json"
|
||||||
|
|
||||||
|
|
||||||
def fail(message: str) -> None:
|
def fail(message: str) -> None:
|
||||||
@@ -32,21 +32,41 @@ def git_show(commit: str, path: str) -> str:
|
|||||||
return result.stdout
|
return result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def load_floor_ledger(commit: str) -> dict[str, object]:
|
||||||
|
for path in ("api/stability.json", "api-stability.json"):
|
||||||
|
result = subprocess.run(
|
||||||
|
["git", "show", f"{commit}:{path}"],
|
||||||
|
cwd=ROOT,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
return json.loads(result.stdout)
|
||||||
|
fail(f"cannot read API ledger at compatibility floor {commit}")
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
metadata = subprocess.run(
|
metadata = subprocess.run(
|
||||||
[sys.executable, "tools/check-api-baseline.py", "--metadata-only"], cwd=ROOT
|
[sys.executable, "tools/check-api-baseline.py", "--metadata-only"], cwd=ROOT
|
||||||
)
|
)
|
||||||
if metadata.returncode != 0:
|
if metadata.returncode != 0:
|
||||||
fail("snapshot metadata or reviewed change record is invalid")
|
fail("snapshot metadata or review is invalid")
|
||||||
ledger = json.loads(LEDGER_PATH.read_text(encoding="utf-8"))
|
ledger = json.loads(LEDGER_PATH.read_text(encoding="utf-8"))
|
||||||
floor = ledger.get("compatibilityFloor", {}).get("evidenceCommit")
|
floor = ledger.get("compatibilityFloor", {}).get("evidenceCommit")
|
||||||
if not isinstance(floor, str):
|
if not isinstance(floor, str):
|
||||||
fail("api-stability.json has no compatibility-floor commit")
|
fail("api/stability.json has no compatibility-floor commit")
|
||||||
|
floor_ledger = load_floor_ledger(floor)
|
||||||
|
floor_snapshots = {
|
||||||
|
package["name"]: package["snapshot"] for package in floor_ledger["packages"]
|
||||||
|
}
|
||||||
total_added = 0
|
total_added = 0
|
||||||
total_removed = 0
|
total_removed = 0
|
||||||
for package in ledger["packages"]:
|
for package in ledger["packages"]:
|
||||||
path = package["snapshot"]
|
path = package["snapshot"]
|
||||||
before = set(git_show(floor, path).splitlines())
|
floor_path = floor_snapshots.get(package["name"])
|
||||||
|
if not isinstance(floor_path, str):
|
||||||
|
fail(f"{package['name']} is absent from the compatibility floor")
|
||||||
|
before = set(git_show(floor, floor_path).splitlines())
|
||||||
after = set((ROOT / path).read_text(encoding="utf-8").splitlines())
|
after = set((ROOT / path).read_text(encoding="utf-8").splitlines())
|
||||||
added = sorted(after - before)
|
added = sorted(after - before)
|
||||||
removed = sorted(before - after)
|
removed = sorted(before - after)
|
||||||
@@ -58,17 +78,15 @@ def main() -> None:
|
|||||||
print(f"- {line}", file=sys.stderr)
|
print(f"- {line}", file=sys.stderr)
|
||||||
if total_removed:
|
if total_removed:
|
||||||
fail(
|
fail(
|
||||||
f"{total_removed} public API lines were removed from the Wave C floor; "
|
f"{total_removed} public API lines were removed from the compatibility floor; "
|
||||||
"the current policy permits additions only"
|
"the current policy permits additions only"
|
||||||
)
|
)
|
||||||
change_record = json.loads(
|
review = ledger["snapshotSource"]["review"]
|
||||||
(ROOT / ledger["snapshotSource"]["changeRecord"]).read_text(encoding="utf-8")
|
if review["publicApiDiff"] != {
|
||||||
)
|
|
||||||
if change_record["publicApiDiff"] != {
|
|
||||||
"added": total_added,
|
"added": total_added,
|
||||||
"removed": total_removed,
|
"removed": total_removed,
|
||||||
}:
|
}:
|
||||||
fail("reviewed change record does not match the measured API diff")
|
fail("snapshot review does not match the measured API diff")
|
||||||
print(f"api compatibility: additive-only (+{total_added}, -0)")
|
print(f"api compatibility: additive-only (+{total_added}, -0)")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
LEDGER_PATH = ROOT / "api-stability.json"
|
LEDGER_PATH = ROOT / "api" / "stability.json"
|
||||||
CONTRACT_PATH = ROOT / "api-baseline" / "manifest-contract.json"
|
CONTRACT_PATH = ROOT / "api" / "snapshots" / "manifest-contract.json"
|
||||||
|
|
||||||
|
|
||||||
def fail(message: str) -> None:
|
def fail(message: str) -> None:
|
||||||
|
|||||||
Reference in new issue
Block a user