mirror of
https://github.com/ratspeak/rsLXST
synced 2026-11-22 23:10:37 +00:00
api: qualify experimental telephony service seam
This commit is contained in:
1 parent
9ef5fb3a4d
commit
68df322377
16 files changed
+2139
No files matched your search
@@ -41,6 +41,15 @@ jobs:
|
||||
- name: Check reviewed public API baseline
|
||||
run: python3 tools/check-api-baseline.py
|
||||
working-directory: rsLXST
|
||||
- name: Check manifest and feature contract
|
||||
run: python3 tools/check-api-manifest.py
|
||||
working-directory: rsLXST
|
||||
- name: Check additions-only compatibility floor
|
||||
run: python3 tools/check-api-compatibility.py
|
||||
working-directory: rsLXST
|
||||
- name: Check canonical and retained external consumers
|
||||
run: cargo check --manifest-path api-fixtures/Cargo.toml --locked
|
||||
working-directory: rsLXST
|
||||
|
||||
lint:
|
||||
name: Lint and Docs
|
||||
@@ -80,6 +89,9 @@ jobs:
|
||||
working-directory: rsLXST
|
||||
- run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
|
||||
working-directory: rsLXST
|
||||
- name: Build embedding examples
|
||||
run: cargo build -p lxst-telephony --examples --locked
|
||||
working-directory: rsLXST
|
||||
- run: cargo doc --workspace --no-deps --locked
|
||||
working-directory: rsLXST
|
||||
env:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
.DS_Store
|
||||
target/
|
||||
api-fixtures/target/
|
||||
|
||||
# Runtime data and local identities
|
||||
.reticulum/
|
||||
|
||||
@@ -15,6 +15,15 @@ version, changelog, and interop reasoning.
|
||||
- `lxst-telephony` currently exposes both useful service controls and extensive
|
||||
runtime/state-machine machinery.
|
||||
|
||||
[`TelephonyService`](TELEPHONY_API.md), constructed with `registered` or
|
||||
`registered_with_config`, is the selected canonical **experimental** embedding
|
||||
boundary. `TelephonyServiceParts`, `TelephonyControl`, and
|
||||
`TelephonyServiceEvent` retain their exact existing ownership, bounded-channel,
|
||||
backpressure, cancellation, event-order, and shutdown behavior. Manual
|
||||
`TelephonyRnsEndpoint`/`TelephonyRuntimeCore` assembly remains available for
|
||||
compatibility but is experimental SPI, not a second recommended application
|
||||
path.
|
||||
|
||||
All three are classified **experimental**. Future work may promote a small
|
||||
facade while hiding orchestration internals, but this checkpoint does not move,
|
||||
rename, hide, or change anything. Ratspeak voice integration and the Python
|
||||
@@ -30,6 +39,16 @@ gates rather than treated as stable Rust API by this host snapshot.
|
||||
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 compatibility floor is separate from the current reviewed
|
||||
capture. The manifest contract covers features, targets, MSRV, and
|
||||
non-development dependencies that the Apple/all-feature snapshot cannot see.
|
||||
The compatibility check rejects removals from the Wave C floor. Selecting the
|
||||
existing service boundary changes no public API, version, wire, or runtime
|
||||
behavior.
|
||||
|
||||
Use `--update` only after reviewing and recording the compatibility impact.
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Document the existing registered `TelephonyService` seam as the canonical
|
||||
experimental embedding boundary, with compiled canonical/retained consumer
|
||||
contracts and no public API or runtime behavior change.
|
||||
|
||||
- Classified all three pre-1.0 packages as experimental and added pinned,
|
||||
CI-enforced public API snapshots without changing visibility or signatures.
|
||||
- Replace the locally modified Opus 0.1.19 snapshot with exact upstream
|
||||
|
||||
@@ -39,6 +39,7 @@ the reference implementation LXST.
|
||||
- [Test It](#test-it)
|
||||
- [Crate Layout](#crate-layout)
|
||||
- [Using Telephony](#using-telephony)
|
||||
- [Telephony API boundary](TELEPHONY_API.md)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
- [Third-party licenses](#third-party-licenses)
|
||||
@@ -213,6 +214,10 @@ traffic. Outgoing announce/path discovery runs asynchronously inside the
|
||||
service, so an unreachable or non-LXST peer does not block hangup, announce,
|
||||
media, or shutdown controls while discovery times out.
|
||||
|
||||
The compiled `lxst-telephony` `service` example is the conformance example for
|
||||
this embedding boundary. The lower-level endpoint and runtime types remain
|
||||
available for compatible specialist use, but are experimental SPI.
|
||||
|
||||
An initial Reticulum `LINKREQUEST` still follows normal destination routing.
|
||||
After proof validation, rsLXST binds the call to the exact interface that
|
||||
established the Link. Signalling, identification, keepalives, media, and close
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# Experimental telephony service API
|
||||
|
||||
The current canonical application boundary is the existing
|
||||
`lxst_telephony::TelephonyService` service seam:
|
||||
|
||||
- construct it with `TelephonyService::registered` or
|
||||
`TelephonyService::registered_with_config`;
|
||||
- retain the `TelephonyServiceParts::control_tx` and `event_rx` handles;
|
||||
- drive the owned service with `TelephonyService::run`;
|
||||
- use `TelephonyControl`, `request_answer`, and `TelephonyServiceEvent` without
|
||||
translating raw Reticulum events in the application.
|
||||
|
||||
This boundary is experimental. Selection does not stabilize the whole package
|
||||
or alter the existing channel capacities, backpressure, event ordering,
|
||||
cancellation, timeout, media, exact-Link, or shutdown behavior.
|
||||
|
||||
`TelephonyRnsEndpoint`, `TelephonyRuntimeCore`, `TelephonyCommand`,
|
||||
`TelephonyDriveStep`, `TelephonyService::new`, and
|
||||
`TelephonyService::with_config` remain public for compatibility and specialist
|
||||
testing. They are experimental implementation SPI and are not the recommended
|
||||
application construction path. No compatibility path is deprecated in this
|
||||
Wave C milestone.
|
||||
|
||||
The compiled `service` example and external fixture exercise the selected and
|
||||
retained paths. API snapshots, manifest/feature contracts, Android/Apple target
|
||||
builds, and Python Telephone interoperability are separate evidence layers;
|
||||
none is replaced by this documentation boundary.
|
||||
@@ -0,0 +1,323 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"scope": "library Cargo manifests, public features, targets, and non-dev dependencies",
|
||||
"packages": [
|
||||
{
|
||||
"name": "lxst-core",
|
||||
"version": "0.1.2",
|
||||
"rustVersion": "1.87",
|
||||
"edition": "2024",
|
||||
"features": {},
|
||||
"targets": [
|
||||
{
|
||||
"name": "lxst_core",
|
||||
"kind": [
|
||||
"lib"
|
||||
],
|
||||
"crateTypes": [
|
||||
"lib"
|
||||
],
|
||||
"requiredFeatures": []
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "half",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
"name": "opus-rs",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "=0.1.29",
|
||||
"optional": false,
|
||||
"defaultFeatures": false,
|
||||
"features": [
|
||||
"heap"
|
||||
],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
"name": "rmpv",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
"name": "thiserror",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "registry"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "lxst-rns",
|
||||
"version": "0.1.2",
|
||||
"rustVersion": "1.87",
|
||||
"edition": "2024",
|
||||
"features": {},
|
||||
"targets": [
|
||||
{
|
||||
"name": "lxst_rns",
|
||||
"kind": [
|
||||
"lib"
|
||||
],
|
||||
"crateTypes": [
|
||||
"lib"
|
||||
],
|
||||
"requiredFeatures": []
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "bytes",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
"name": "lxst-core",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^0.1.2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-link",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-transport",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-wire",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "thiserror",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
"name": "tokio",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [
|
||||
"macros",
|
||||
"rt",
|
||||
"sync",
|
||||
"time"
|
||||
],
|
||||
"sourceKind": "registry"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "lxst-telephony",
|
||||
"version": "0.1.2",
|
||||
"rustVersion": "1.87",
|
||||
"edition": "2024",
|
||||
"features": {},
|
||||
"targets": [
|
||||
{
|
||||
"name": "lxst_telephony",
|
||||
"kind": [
|
||||
"lib"
|
||||
],
|
||||
"crateTypes": [
|
||||
"lib"
|
||||
],
|
||||
"requiredFeatures": []
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "bytes",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
"name": "lxst-core",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^0.1.2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "lxst-rns",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^0.1.2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-crypto",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-identity",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-link",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-runtime",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-transport",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "rns-wire",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1.1.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
"name": "thiserror",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
"name": "tokio",
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^1",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [
|
||||
"macros",
|
||||
"rt",
|
||||
"sync",
|
||||
"time"
|
||||
],
|
||||
"sourceKind": "registry"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Generated
+1368
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "lxst-telephony-api-fixture"
|
||||
version = "0.0.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
lxst-telephony = { path = "../crates/lxst-telephony" }
|
||||
rns-identity = { path = "../../rsReticulum/crates/rns-identity" }
|
||||
rns-transport = { path = "../../rsReticulum/crates/rns-transport" }
|
||||
tokio = { version = "1", features = ["sync"] }
|
||||
@@ -0,0 +1,28 @@
|
||||
//! External-consumer compile contract for selected and retained LXST paths.
|
||||
|
||||
use rns_identity::identity::Identity;
|
||||
use rns_transport::messages::TransportMessage;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
pub mod canonical {
|
||||
use super::*;
|
||||
use lxst_telephony::{Error, TelephonyService, TelephonyServiceParts};
|
||||
|
||||
pub fn register(
|
||||
transport_tx: mpsc::Sender<TransportMessage>,
|
||||
identity: &Identity,
|
||||
) -> Result<TelephonyServiceParts, Error> {
|
||||
TelephonyService::registered(transport_tx, identity)
|
||||
}
|
||||
}
|
||||
|
||||
pub mod retained {
|
||||
use lxst_telephony::{TelephonyRnsEndpoint, TelephonyRuntimeCore};
|
||||
|
||||
pub fn raw_assembly_types(
|
||||
endpoint: TelephonyRnsEndpoint,
|
||||
runtime: TelephonyRuntimeCore,
|
||||
) -> (TelephonyRnsEndpoint, TelephonyRuntimeCore) {
|
||||
(endpoint, runtime)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"capabilities": ["LXST-01", "LXST-02", "LXST-03", "LXST-04"],
|
||||
"canonicalPath": "lxst_telephony::TelephonyService",
|
||||
"canonicalConstruction": [
|
||||
"TelephonyService::registered",
|
||||
"TelephonyService::registered_with_config",
|
||||
"TelephonyServiceParts"
|
||||
],
|
||||
"retainedPaths": [
|
||||
"TelephonyRuntimeCore",
|
||||
"TelephonyRnsEndpoint",
|
||||
"TelephonyService::new",
|
||||
"TelephonyService::with_config"
|
||||
],
|
||||
"internalSpi": [
|
||||
"TelephonyCommand",
|
||||
"TelephonyDriveStep",
|
||||
"manual runtime and endpoint assembly"
|
||||
],
|
||||
"classification": "existing experimental service boundary",
|
||||
"publicApiDiff": {"added": 0, "removed": 0},
|
||||
"semver": "no version consequence; documentation and consumer migration only",
|
||||
"deprecations": "none",
|
||||
"wirePersistenceRuntimeImpact": "none",
|
||||
"consumerMigration": "Ratspeak uses registered service assembly with identical default 32/128 bounded channels",
|
||||
"platformEvidence": [
|
||||
"host service tests and compiled example",
|
||||
"Rust 1.87 strict Clippy",
|
||||
"Android and Apple compile gates at product handoff",
|
||||
"Python Telephone interoperability at milestone close"
|
||||
]
|
||||
}
|
||||
@@ -14,6 +14,15 @@
|
||||
"commit": "af89a03094605dbdf7264d06fdc546526ec6980b",
|
||||
"capturedOn": "2026-08-17"
|
||||
},
|
||||
"compatibilityFloor": {
|
||||
"evidenceCommit": "21a54b778472343b70fd71d34ae96c61c44187c3",
|
||||
"sourceCommit": "af89a03094605dbdf7264d06fdc546526ec6980b"
|
||||
},
|
||||
"snapshotSource": {
|
||||
"basisCommit": "9ef5fb3a4da0d960846e5a8e23707e401caebd46",
|
||||
"capturedOn": "2026-08-17",
|
||||
"changeRecord": "api-reviews/wave-c-telephony-service.json"
|
||||
},
|
||||
"packages": [
|
||||
{
|
||||
"name": "lxst-core",
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//! Construct the canonical experimental telephony service boundary.
|
||||
|
||||
use lxst_telephony::{TelephonyControl, TelephonyService, TelephonyServiceEvent};
|
||||
use rns_identity::identity::Identity;
|
||||
use rns_transport::messages::TransportMessage;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let (transport_tx, _transport_rx) = mpsc::channel::<TransportMessage>(32);
|
||||
let identity = Identity::new();
|
||||
let parts = TelephonyService::registered(transport_tx, &identity)?;
|
||||
|
||||
let _service: TelephonyService = parts.service;
|
||||
let _control: mpsc::Sender<TelephonyControl> = parts.control_tx;
|
||||
let _events: mpsc::Receiver<TelephonyServiceEvent> = parts.event_rx;
|
||||
Ok(())
|
||||
}
|
||||
@@ -112,6 +112,54 @@ def validate_metadata(
|
||||
if ancestor_check.returncode != 0:
|
||||
fail(f"baseline commit {commit} is not an ancestor of HEAD")
|
||||
|
||||
compatibility_floor = config.get("compatibilityFloor")
|
||||
if not isinstance(compatibility_floor, dict):
|
||||
fail("compatibility floor identity is missing")
|
||||
floor_evidence = compatibility_floor.get("evidenceCommit")
|
||||
floor_source = compatibility_floor.get("sourceCommit")
|
||||
for label, floor_commit in (
|
||||
("evidence", floor_evidence),
|
||||
("source", floor_source),
|
||||
):
|
||||
if not isinstance(floor_commit, str) or not SHA_PATTERN.fullmatch(
|
||||
floor_commit
|
||||
):
|
||||
fail(f"compatibility floor {label} commit must be a full Git commit")
|
||||
floor_check = subprocess.run(
|
||||
["git", "cat-file", "-e", f"{floor_commit}^{{commit}}"], cwd=ROOT
|
||||
)
|
||||
if floor_check.returncode != 0:
|
||||
fail(f"compatibility floor {label} commit {floor_commit} is unavailable")
|
||||
floor_ancestor = subprocess.run(
|
||||
["git", "merge-base", "--is-ancestor", floor_commit, "HEAD"], cwd=ROOT
|
||||
)
|
||||
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("basisCommit")
|
||||
if not isinstance(snapshot_commit, str) or not SHA_PATTERN.fullmatch(
|
||||
snapshot_commit
|
||||
):
|
||||
fail("snapshot source basis 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 basis 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 basis commit {snapshot_commit} is not an ancestor of HEAD")
|
||||
change_record = snapshot_source.get("changeRecord")
|
||||
if not isinstance(change_record, str) or not change_record.startswith("api-reviews/"):
|
||||
fail("snapshot source must name a reviewed change record")
|
||||
if not (ROOT / change_record).is_file():
|
||||
fail(f"snapshot source change record is missing: {change_record}")
|
||||
|
||||
packages = config.get("packages")
|
||||
if not isinstance(packages, list) or not packages:
|
||||
fail("package ledger is empty")
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Reject removals from the immutable Wave C public-API compatibility floor."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LEDGER_PATH = ROOT / "api-stability.json"
|
||||
|
||||
|
||||
def fail(message: str) -> None:
|
||||
print(f"api compatibility: {message}", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
def git_show(commit: str, path: str) -> str:
|
||||
result = subprocess.run(
|
||||
["git", "show", f"{commit}:{path}"],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
if result.stderr:
|
||||
print(result.stderr, file=sys.stderr, end="")
|
||||
fail(f"cannot read compatibility floor {commit}:{path}")
|
||||
return result.stdout
|
||||
|
||||
|
||||
def main() -> None:
|
||||
ledger = json.loads(LEDGER_PATH.read_text(encoding="utf-8"))
|
||||
floor = ledger.get("compatibilityFloor", {}).get("evidenceCommit")
|
||||
if not isinstance(floor, str):
|
||||
fail("api-stability.json has no compatibility-floor commit")
|
||||
total_added = 0
|
||||
total_removed = 0
|
||||
for package in ledger["packages"]:
|
||||
path = package["snapshot"]
|
||||
before = set(git_show(floor, path).splitlines())
|
||||
after = set((ROOT / path).read_text(encoding="utf-8").splitlines())
|
||||
added = sorted(after - before)
|
||||
removed = sorted(before - after)
|
||||
total_added += len(added)
|
||||
total_removed += len(removed)
|
||||
print(f"{package['name']}: +{len(added)} -{len(removed)}")
|
||||
if removed:
|
||||
for line in removed:
|
||||
print(f"- {line}", file=sys.stderr)
|
||||
if total_removed:
|
||||
fail(
|
||||
f"{total_removed} public API lines were removed from the Wave C floor; "
|
||||
"the current policy permits additions only"
|
||||
)
|
||||
print(f"api compatibility: additive-only (+{total_added}, -0)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify the reviewed Cargo manifest and feature contract for library packages."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import difflib
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LEDGER_PATH = ROOT / "api-stability.json"
|
||||
CONTRACT_PATH = ROOT / "api-baseline" / "manifest-contract.json"
|
||||
|
||||
|
||||
def fail(message: str) -> None:
|
||||
print(f"api manifest contract: {message}", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
def metadata(manifest_path: str) -> dict[str, object]:
|
||||
result = subprocess.run(
|
||||
[
|
||||
"cargo",
|
||||
"metadata",
|
||||
"--format-version",
|
||||
"1",
|
||||
"--no-deps",
|
||||
"--manifest-path",
|
||||
manifest_path,
|
||||
],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
if result.stderr:
|
||||
print(result.stderr, file=sys.stderr, end="")
|
||||
fail(f"cargo metadata failed for {manifest_path}")
|
||||
return json.loads(result.stdout)
|
||||
|
||||
|
||||
def dependency_contract(dependency: dict[str, object]) -> dict[str, object]:
|
||||
source = dependency.get("source")
|
||||
return {
|
||||
"name": dependency["name"],
|
||||
"rename": dependency.get("rename"),
|
||||
"kind": dependency.get("kind"),
|
||||
"target": dependency.get("target"),
|
||||
"requirement": dependency["req"],
|
||||
"optional": dependency["optional"],
|
||||
"defaultFeatures": dependency["uses_default_features"],
|
||||
"features": sorted(dependency["features"]),
|
||||
"sourceKind": "registry" if source else "path",
|
||||
}
|
||||
|
||||
|
||||
def package_contract(package: dict[str, object]) -> dict[str, object]:
|
||||
targets = []
|
||||
for target in package["targets"]:
|
||||
if "lib" not in target["kind"]:
|
||||
continue
|
||||
targets.append(
|
||||
{
|
||||
"name": target["name"],
|
||||
"kind": sorted(target["kind"]),
|
||||
"crateTypes": sorted(target["crate_types"]),
|
||||
"requiredFeatures": sorted(target.get("required-features", [])),
|
||||
}
|
||||
)
|
||||
dependencies = [
|
||||
dependency_contract(dependency)
|
||||
for dependency in package["dependencies"]
|
||||
if dependency.get("kind") != "dev"
|
||||
]
|
||||
dependencies.sort(
|
||||
key=lambda item: (
|
||||
str(item["kind"]),
|
||||
str(item["target"]),
|
||||
str(item["rename"]),
|
||||
str(item["name"]),
|
||||
)
|
||||
)
|
||||
return {
|
||||
"name": package["name"],
|
||||
"version": package["version"],
|
||||
"rustVersion": package.get("rust_version"),
|
||||
"edition": package["edition"],
|
||||
"features": {
|
||||
name: sorted(values)
|
||||
for name, values in sorted(package["features"].items())
|
||||
},
|
||||
"targets": sorted(targets, key=lambda item: str(item["name"])),
|
||||
"dependencies": dependencies,
|
||||
}
|
||||
|
||||
|
||||
def render_contract() -> str:
|
||||
ledger = json.loads(LEDGER_PATH.read_text(encoding="utf-8"))
|
||||
manifests = sorted({entry["manifestPath"] for entry in ledger["packages"]})
|
||||
recorded_names = {entry["name"] for entry in ledger["packages"]}
|
||||
packages: list[dict[str, object]] = []
|
||||
for manifest in manifests:
|
||||
for package in metadata(manifest)["packages"]:
|
||||
if package["name"] in recorded_names:
|
||||
packages.append(package_contract(package))
|
||||
actual_names = {entry["name"] for entry in packages}
|
||||
if actual_names != recorded_names:
|
||||
fail(
|
||||
f"package inventory differs: expected={sorted(recorded_names)}, "
|
||||
f"actual={sorted(actual_names)}"
|
||||
)
|
||||
contract = {
|
||||
"schemaVersion": 1,
|
||||
"scope": "library Cargo manifests, public features, targets, and non-dev dependencies",
|
||||
"packages": sorted(packages, key=lambda item: str(item["name"])),
|
||||
}
|
||||
return json.dumps(contract, indent=2) + "\n"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--print",
|
||||
action="store_true",
|
||||
dest="print_contract",
|
||||
help="print the current canonical contract for reviewed application",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--update",
|
||||
action="store_true",
|
||||
help="write the current reviewed manifest contract",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if args.print_contract and args.update:
|
||||
fail("--print and --update are mutually exclusive")
|
||||
rendered = render_contract()
|
||||
if args.print_contract:
|
||||
print(rendered, end="")
|
||||
return
|
||||
if args.update:
|
||||
CONTRACT_PATH.write_text(rendered, encoding="utf-8")
|
||||
print("api manifest contract updated")
|
||||
return
|
||||
if not CONTRACT_PATH.is_file():
|
||||
fail(f"missing {CONTRACT_PATH.relative_to(ROOT)}")
|
||||
expected = CONTRACT_PATH.read_text(encoding="utf-8")
|
||||
if expected != rendered:
|
||||
print(
|
||||
"".join(
|
||||
difflib.unified_diff(
|
||||
expected.splitlines(keepends=True),
|
||||
rendered.splitlines(keepends=True),
|
||||
fromfile=str(CONTRACT_PATH.relative_to(ROOT)),
|
||||
tofile="current Cargo metadata",
|
||||
)
|
||||
),
|
||||
file=sys.stderr,
|
||||
end="",
|
||||
)
|
||||
fail("manifest, feature, target, or dependency contract drift")
|
||||
print("api manifest contract: ok")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user