mirror of
https://github.com/ratspeak/rsLXST
synced 2026-11-22 23:10:37 +00:00
api: simplify compatibility metadata
This commit is contained in:
1 parent
5638cf7cf0
commit
df41edab47
4 files changed
+61
-117
No files matched your search
+6
-5
@@ -33,8 +33,8 @@ rather than the recommended application construction path.
|
||||
|
||||
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 the recommended and retained paths as an external
|
||||
@@ -54,9 +54,10 @@ 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.
|
||||
|
||||
## Live audio and constrained peers
|
||||
|
||||
|
||||
+6
-31
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"schemaVersion": 2,
|
||||
"tool": {
|
||||
"name": "cargo-public-api",
|
||||
"version": "0.52.0",
|
||||
@@ -11,41 +11,12 @@
|
||||
]
|
||||
},
|
||||
"baseline": {
|
||||
"commit": "af89a03094605dbdf7264d06fdc546526ec6980b",
|
||||
"capturedOn": "2026-08-17"
|
||||
"commit": "af89a03094605dbdf7264d06fdc546526ec6980b"
|
||||
},
|
||||
"compatibilityFloor": {
|
||||
"evidenceCommit": "21a54b778472343b70fd71d34ae96c61c44187c3",
|
||||
"sourceCommit": "af89a03094605dbdf7264d06fdc546526ec6980b"
|
||||
},
|
||||
"snapshotSource": {
|
||||
"commit": "87dd25958f5958493b628ba6a1272ab32e538e27",
|
||||
"capturedOn": "2026-10-01",
|
||||
"review": {
|
||||
"areas": [
|
||||
"Standard ULBW advertisement in embedded ProfileSet::CODEC2",
|
||||
"Three-profile native framing, crossed negotiation and encrypted duplex tests"
|
||||
],
|
||||
"canonicalPath": "lxst_embedded::ProfileSet::CODEC2",
|
||||
"classification": "unchanged public signatures; CODEC2 capability includes implemented ULBW; compatibility diff is cumulative from the retained floor",
|
||||
"publicApiDiff": {
|
||||
"added": 374,
|
||||
"removed": 0
|
||||
},
|
||||
"semver": "Unreleased experimental 0.2 API. Prior Rate700C exhaustive-enum impact remains; this checkpoint adds no signature changes.",
|
||||
"deprecations": "none",
|
||||
"wirePersistenceRuntimeImpact": "Embedded CODEC2 advertises standard ULBW alongside VLBW/LBW. No new wire IDs or persistence format. 700C uses ten four-byte frames per 400 ms packet.",
|
||||
"platformEvidence": [
|
||||
"Embedded and telephony scoped tests and strict Clippy pass.",
|
||||
"SMALL/MICRO handhelds exchange all three profiles with default-C Python LXST and real Rust TelephonyService/Ratspeak PTT in both call roles.",
|
||||
"Actual audio worker passes three-profile ASan/UBSan checks; target owner/frame checks pass. Physical audio, total stack, heap, CPU and RF remain unqualified."
|
||||
],
|
||||
"newPackages": [
|
||||
"lxst-codec2",
|
||||
"lxst-embedded"
|
||||
]
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
{
|
||||
"name": "lxst-codec2",
|
||||
@@ -92,5 +63,9 @@
|
||||
"itemCount": 360,
|
||||
"sha256": "c9b9784a9b09bb41a9beffb29b62085b21f2b22cb8b7d18ef53ea9f673d77698"
|
||||
}
|
||||
],
|
||||
"newPackages": [
|
||||
"lxst-codec2",
|
||||
"lxst-embedded"
|
||||
]
|
||||
}
|
||||
+46
-72
@@ -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,27 @@ 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", "newPackages"},
|
||||
"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",
|
||||
)
|
||||
new_packages = config["newPackages"]
|
||||
if (not isinstance(new_packages, list)
|
||||
or not all(isinstance(item, str) and item for item in new_packages)
|
||||
or new_packages != sorted(set(new_packages))):
|
||||
fail("newPackages must be a sorted list of unique package names")
|
||||
|
||||
tool = config.get("tool")
|
||||
if not isinstance(tool, dict):
|
||||
fail("tool contract is missing")
|
||||
@@ -174,26 +169,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 +178,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 +196,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 +277,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")
|
||||
|
||||
@@ -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):
|
||||
@@ -64,8 +64,8 @@ def main() -> None:
|
||||
if removed_packages:
|
||||
fail(f"compatibility-floor packages removed: {sorted(removed_packages)}")
|
||||
new_packages = sorted(current_names - set(floor_snapshots))
|
||||
if ledger["snapshotSource"]["review"].get("newPackages", []) != new_packages:
|
||||
fail("new packages require an exact explicit snapshot review")
|
||||
if ledger["newPackages"] != new_packages:
|
||||
fail("newPackages must match additions to the compatibility floor")
|
||||
total_added = 0
|
||||
total_removed = 0
|
||||
for package in ledger["packages"]:
|
||||
@@ -86,12 +86,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)")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user