api: simplify compatibility metadata

This commit is contained in:
DeFiDude committed 2026-10-10 17:39:31 -06:00
1 parent 8bad5e2f1f
commit 4917620b21
4 files changed
+54 -141

No files matched your search

+6 -5
View File
@@ -88,8 +88,8 @@ applications that do not install it keep the existing completion behavior.
The `api/` directory contains the evidence used by CI:
- `stability.json` records package tiers, source commits, snapshot hashes, and
the current review decision;
- `stability.json` records package tiers, compatibility baselines, and snapshot
hashes;
- `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
@@ -109,6 +109,7 @@ 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.
After reviewing an API change, run
`python3 tools/check-api-baseline.py --update` and commit the source and snapshot
changes together. CI compares snapshots with the current source; compatibility
checks retain the historical baseline.
+3 -57
View File
@@ -1,5 +1,5 @@
{
"schemaVersion": 1,
"schemaVersion": 2,
"tool": {
"name": "cargo-public-api",
"version": "0.52.0",
@@ -11,59 +11,12 @@
]
},
"baseline": {
"commit": "b8d7afce73f7f098706029361568e63f22888ea3",
"capturedOn": "2026-08-17"
"commit": "b8d7afce73f7f098706029361568e63f22888ea3"
},
"compatibilityFloor": {
"evidenceCommit": "80bb96f799330e28a0125367d4c29826f5147cc3",
"sourceCommit": "b8d7afce73f7f098706029361568e63f22888ea3"
},
"snapshotSource": {
"commit": "98aa927e1d2da3ebcc42ebe25f635dcbb503faf7",
"capturedOn": "2026-09-24",
"review": {
"areas": [
"Exact local packet admission and proof-clock ownership",
"Finite original Resource windows and bounded external observation grace",
"Cancellation-aware backchannel adapters with legacy compatibility",
"Generation-safe cleanup, settlement and queued-message preservation",
"Owned reverse Resource completion handoff",
"LXMF-02/03 and RET-05/07 event-driven delivery readiness (September 24)",
"LXMF-02/03: late authenticated compression capability on pending Direct delivery"
],
"canonicalPath": "lxmf_core::link_delivery::LinkDeliveryManager",
"retainedPaths": [
"lxmf_core::message",
"lxmf_core::constants",
"lxmf_core::types",
"lxmf_core::router",
"lxmf_core::link_delivery"
],
"excludedImplementationAreas": [
"propagation and handlers",
"serialized persistence representations",
"raw Reticulum transport channels"
],
"classification": "compatible additive opt-in provisional delivery-owner integration; existing message facade and public signatures remain unchanged",
"publicApiDiff": {
"added": 95,
"removed": 0
},
"semver": "compatible additive APIs included in version 1.2.0",
"deprecations": "none",
"wirePersistenceRuntimeImpact": "No wire-format, cryptography, message identity or persisted-layout change. Exact local Link admission precedes RTT proof timing. Resource owner windows retain original timestamps; only externally observed Resources receive a finite 180-second accounting allowance after the original protocol deadline. Cancellation-aware adapters close and drain unpublished receipts while legacy sender installation retains its previous behavior. Exact cleanup is bounded and cannot erase replacement Links or lose uncancelled queued messages; authenticated settlement remains owned after Link closure. Optional reverse Resource completion hands off the single owned payload before conclusion cleanup, without changing legacy consumers. Authenticated no-compression announcements can now disable compression for unconstructed Direct Resources and queued payloads. Constructed Resources, split plans and propagation envelopes stay immutable; no wire fields or signatures change.",
"platformEvidence": [
"clean committed-source all-feature Apple ARM64 snapshot: seven added methods, zero removed; cumulative compatibility-floor diff is 93 additions and zero removals",
"564 LXMF core and 55 daemon tests passed on the final implementation checkpoint; strict all-target Clippy and core Rustdoc passed",
"independent actual-actor cancellation, captured legacy/aware policy, 256-owner reservation and replacement-Link/settlement review controls passed",
"actual encrypted Resource final-proof expiry and same-message retry produced one receiver publication; signed Link reuse/loss/recovery and completion-lease controls passed",
"default/all-feature external consumer fixtures and final working app runtime suite passed; no feature/MSRV/native-export changes",
"final clean combined host/MSRV/native/interop and artifact qualification remain separately required; focused software evidence is not physical fading-radio or mobile acceptance",
"September 24: additive poll_ready method; 75 focused delivery tests, encrypted 65 KB/750 KB/2.6 MB/8 MB readiness-driven transfers, and strict stable/MSRV Clippy passed. Physical radio speed remains separately qualified.",
"September 24 first-contact correction: 577 lxmf-core tests and strict all-target Clippy passed; the new API is additive provisional owner integration. Small/Micro native first-contact and full app runtime qualification are retained by the cross-repo maintainer harness."
]
}
},
"packages": [
{
"name": "lxmf-core",
@@ -83,12 +36,5 @@
"itemCount": 185,
"sha256": "0427d0fab38f8061cbf7f11b701f29f438490478f133524b0a8e4e7cfe6f3924"
}
],
"deliveryReadinessReview": {
"reviewedOn": "2026-09-24",
"classification": "Compatible additive provisional integration method; no removed signatures, dependency requirement, MSRV, wire or persistence changes. No release-version bump in this implementation commit.",
"ownership": "Input and local receipt lookahead remain owned on cancellation; exact bind readiness does not publish the endpoint. One polling task; periodic deadline ticks remain required.",
"scheduling": "Bounded input drain; readiness covers packets, endpoint lifecycle/acknowledgements, backchannel receipts and staged-transport capacity. Existing lxmd-rs periodic consumers remain supported.",
"diagnostics": "Aggregate Resource request/part/repeated-part/byte action counts under a closed content-free target; dispatch is not driver admission or recipient delivery."
}
]
}
+41 -72
View File
@@ -4,7 +4,6 @@
from __future__ import annotations
import argparse
from datetime import date
import hashlib
import json
import os
@@ -55,46 +54,21 @@ def load_config() -> dict[str, object]:
config = json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as error:
fail(f"cannot read {CONFIG_PATH.name}: {error}")
if config.get("schemaVersion") != 1:
if not isinstance(config, dict) or config.get("schemaVersion") != 2:
fail("unsupported api-stability schema")
return config
def validate_snapshot_review(record: object) -> None:
def require_keys(
record: object, required: set[str], label: str,
optional: set[str] | None = None,
) -> None:
if not isinstance(record, dict):
fail("snapshot review is missing")
required = {
"areas",
"canonicalPath",
"classification",
"publicApiDiff",
"semver",
"deprecations",
"wirePersistenceRuntimeImpact",
"platformEvidence",
}
if not required.issubset(record):
fail("snapshot review is incomplete")
if not isinstance(record.get("areas"), list) or not record["areas"]:
fail("snapshot review must name the affected API areas")
if not all(isinstance(area, str) and area for area in record["areas"]):
fail("snapshot review API areas must be non-empty strings")
diff = record.get("publicApiDiff")
if not isinstance(diff, dict) or set(diff) != {"added", "removed"}:
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):
fail("snapshot review API counts must be non-negative integers")
if not isinstance(record.get("platformEvidence"), list) or not record["platformEvidence"]:
fail("snapshot review must name platform evidence")
for key in (
"canonicalPath",
"classification",
"semver",
"deprecations",
"wirePersistenceRuntimeImpact",
):
if not isinstance(record.get(key), str) or not record[key]:
fail(f"snapshot review must name {key}")
fail(f"{label} must be an object")
missing = required - set(record)
unknown = set(record) - required - (optional or set())
if missing or unknown:
fail(f"{label}: missing fields {sorted(missing)}, unknown fields {sorted(unknown)}")
def public_packages(manifest_path: str) -> set[str]:
@@ -121,6 +95,22 @@ def public_packages(manifest_path: str) -> set[str]:
def validate_metadata(
config: dict[str, object], *, updating: bool = False
) -> list[dict[str, object]]:
require_keys(
config, {"schemaVersion", "tool", "baseline", "compatibilityFloor", "packages"},
"metadata",
)
if config["schemaVersion"] != 2:
fail("unsupported api-stability schema")
require_keys(
config["tool"], {"name", "version", "rustdocToolchain", "target", "arguments"},
"tool",
)
require_keys(config["baseline"], {"commit"}, "baseline")
require_keys(
config["compatibilityFloor"], {"evidenceCommit", "sourceCommit"},
"compatibility floor",
)
tool = config.get("tool")
if not isinstance(tool, dict):
fail("tool contract is missing")
@@ -174,26 +164,6 @@ def validate_metadata(
if floor_ancestor.returncode != 0:
fail(f"compatibility floor {label} commit is not an ancestor of HEAD")
snapshot_source = config.get("snapshotSource")
if not isinstance(snapshot_source, dict):
fail("snapshot source identity is missing")
snapshot_commit = snapshot_source.get("commit")
if not isinstance(snapshot_commit, str) or not SHA_PATTERN.fullmatch(
snapshot_commit
):
fail("snapshot source commit must be a full Git commit")
snapshot_check = subprocess.run(
["git", "cat-file", "-e", f"{snapshot_commit}^{{commit}}"], cwd=ROOT
)
if snapshot_check.returncode != 0:
fail(f"snapshot source commit {snapshot_commit} is unavailable")
snapshot_ancestor = subprocess.run(
["git", "merge-base", "--is-ancestor", snapshot_commit, "HEAD"], cwd=ROOT
)
if snapshot_ancestor.returncode != 0:
fail(f"snapshot source commit {snapshot_commit} is not an ancestor of HEAD")
validate_snapshot_review(snapshot_source.get("review"))
packages = config.get("packages")
if not isinstance(packages, list) or not packages:
fail("package ledger is empty")
@@ -203,6 +173,10 @@ def validate_metadata(
for package in packages:
if not isinstance(package, dict):
fail("package ledger entry is not an object")
require_keys(package, {"name", "manifestPath", "tier", "compatibility",
"snapshot", "itemCount", "sha256"}, "package")
if type(package["itemCount"]) is not int or package["itemCount"] < 0:
fail("package item count must be a non-negative integer")
name = package.get("name")
manifest = package.get("manifestPath")
snapshot = package.get("snapshot")
@@ -217,7 +191,9 @@ def validate_metadata(
fail(f"{name} must use the reviewed-snapshot compatibility policy")
if not isinstance(snapshot, str) or not snapshot.startswith("api/snapshots/"):
fail(f"{name} has an invalid snapshot path")
snapshot_path = ROOT / snapshot
snapshot_path = (ROOT / snapshot).resolve()
if not snapshot_path.is_relative_to(ROOT / "api/snapshots"):
fail(f"{name} snapshot must stay inside api/snapshots")
if not snapshot_path.is_file() and not updating:
fail(f"{name} snapshot is missing: {snapshot}")
if not updating:
@@ -296,28 +272,21 @@ def render_snapshot(
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--metadata-only", action="store_true")
parser.add_argument("--update", action="store_true")
parser.add_argument("--snapshot-source-commit")
parser.add_argument("--update", action="store_true",
help="refresh snapshots from the working tree to commit alongside source changes")
parser.add_argument("--snapshot-source-commit",
help="optional HEAD guard for --update; includes uncommitted source changes")
args = parser.parse_args()
if args.metadata_only and args.update:
fail("--metadata-only and --update are mutually exclusive")
config = load_config()
if args.update:
if not args.snapshot_source_commit:
fail("--update requires --snapshot-source-commit")
if args.snapshot_source_commit is not None:
if not args.update:
fail("--snapshot-source-commit requires --update")
head = run(["git", "rev-parse", "HEAD"]).strip()
if args.snapshot_source_commit != head:
fail("snapshot source must be the clean source commit at HEAD")
status = run(["git", "status", "--porcelain=v1", "--untracked-files=all"])
dirty_paths = {line[3:] for line in status.splitlines() if len(line) > 3}
if dirty_paths - {"api/stability.json"}:
fail("snapshot source has uncommitted changes outside api/stability.json")
snapshot_source = config.get("snapshotSource")
if not isinstance(snapshot_source, dict):
fail("snapshot source identity is missing")
snapshot_source["commit"] = args.snapshot_source_commit
snapshot_source["capturedOn"] = date.today().isoformat()
fail("snapshot source guard must match HEAD")
packages = validate_metadata(config, updating=args.update)
if args.metadata_only:
print("api baseline metadata: ok")
+4 -7
View File
@@ -50,7 +50,7 @@ def main() -> None:
[sys.executable, "tools/check-api-baseline.py", "--metadata-only"], cwd=ROOT
)
if metadata.returncode != 0:
fail("snapshot metadata or review is invalid")
fail("snapshot metadata is invalid")
ledger = json.loads(LEDGER_PATH.read_text(encoding="utf-8"))
floor = ledger.get("compatibilityFloor", {}).get("evidenceCommit")
if not isinstance(floor, str):
@@ -59,6 +59,9 @@ def main() -> None:
floor_snapshots = {
package["name"]: package["snapshot"] for package in floor_ledger["packages"]
}
removed_packages = set(floor_snapshots) - {package["name"] for package in ledger["packages"]}
if removed_packages:
fail(f"compatibility-floor packages removed: {sorted(removed_packages)}")
total_added = 0
total_removed = 0
for package in ledger["packages"]:
@@ -81,12 +84,6 @@ def main() -> None:
f"{total_removed} public API lines were removed from the compatibility floor; "
"the current policy permits additions only"
)
review = ledger["snapshotSource"]["review"]
if review["publicApiDiff"] != {
"added": total_added,
"removed": total_removed,
}:
fail("snapshot review does not match the measured API diff")
print(f"api compatibility: additive-only (+{total_added}, -0)")