From e0889f718894ead2f0deb37ad144d67c24fe6270 Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:46:21 -0600 Subject: [PATCH] api: organize compatibility evidence --- .github/workflows/ci.yml | 4 +- .gitignore | 2 +- API_STABILITY.md | 72 --------------- APPLICATION_API.md | 61 ------------- README.md | 2 +- api-reviews/wave-c-application-prelude.json | 16 ---- api/README.md | 88 +++++++++++++++++++ {api-fixtures => api/fixtures}/Cargo.lock | 0 {api-fixtures => api/fixtures}/Cargo.toml | 2 +- {api-fixtures => api/fixtures}/src/lib.rs | 0 .../snapshots}/manifest-contract.json | 0 .../snapshots}/rns-crypto.txt | 0 .../snapshots}/rns-identity.txt | 0 .../snapshots}/rns-interface.txt | 0 {api-baseline => api/snapshots}/rns-link.txt | 0 .../snapshots}/rns-protocol.txt | 0 .../snapshots}/rns-ratkey.txt | 0 .../snapshots}/rns-runtime.txt | 0 {api-baseline => api/snapshots}/rns-tools.txt | 0 .../snapshots}/rns-transport.txt | 0 {api-baseline => api/snapshots}/rns-wire.txt | 0 api-stability.json => api/stability.json | 44 +++++++--- tools/check-api-baseline.py | 73 ++++++++------- tools/check-api-compatibility.py | 38 +++++--- tools/check-api-manifest.py | 4 +- 25 files changed, 191 insertions(+), 215 deletions(-) delete mode 100644 API_STABILITY.md delete mode 100644 APPLICATION_API.md delete mode 100644 api-reviews/wave-c-application-prelude.json create mode 100644 api/README.md rename {api-fixtures => api/fixtures}/Cargo.lock (100%) rename {api-fixtures => api/fixtures}/Cargo.toml (74%) rename {api-fixtures => api/fixtures}/src/lib.rs (100%) rename {api-baseline => api/snapshots}/manifest-contract.json (100%) rename {api-baseline => api/snapshots}/rns-crypto.txt (100%) rename {api-baseline => api/snapshots}/rns-identity.txt (100%) rename {api-baseline => api/snapshots}/rns-interface.txt (100%) rename {api-baseline => api/snapshots}/rns-link.txt (100%) rename {api-baseline => api/snapshots}/rns-protocol.txt (100%) rename {api-baseline => api/snapshots}/rns-ratkey.txt (100%) rename {api-baseline => api/snapshots}/rns-runtime.txt (100%) rename {api-baseline => api/snapshots}/rns-tools.txt (100%) rename {api-baseline => api/snapshots}/rns-transport.txt (100%) rename {api-baseline => api/snapshots}/rns-wire.txt (100%) rename api-stability.json => api/stability.json (69%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 326ca5d..6ad15db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,8 +35,8 @@ jobs: run: python3 tools/check-api-compatibility.py - name: Check canonical and legacy external consumer run: | - cargo check --manifest-path api-fixtures/Cargo.toml --locked - cargo check --manifest-path api-fixtures/Cargo.toml --all-features --locked + cargo check --manifest-path api/fixtures/Cargo.toml --locked + cargo check --manifest-path api/fixtures/Cargo.toml --all-features --locked test: name: Test (${{ matrix.os }}) diff --git a/.gitignore b/.gitignore index 72d28b0..6334e38 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ proptest-regressions/ /tools/* !/tools/check-api-manifest.py !/tools/check-api-compatibility.py -/api-fixtures/target/ +/api/fixtures/target/ diff --git a/API_STABILITY.md b/API_STABILITY.md deleted file mode 100644 index 88e6631..0000000 --- a/API_STABILITY.md +++ /dev/null @@ -1,72 +0,0 @@ -# API stability - -rsReticulum is currently distributed as source with `publish = false`. Its -package versions describe protocol/source compatibility; they do not mean that -every reachable Rust item is already a permanent stable API. - -`api-stability.json` is the machine-readable package ledger. The corresponding -`api-baseline/*.txt` files record every explicit public item visible with all -features on the canonical Apple ARM64 rustdoc target. CI regenerates those -snapshots with exact `cargo-public-api` and nightly versions. A diff is a review -barrier, not an automatic verdict: additions, removals, and signature changes -must be classified before a snapshot is deliberately updated. - -## Tiers - -- **Candidate stable:** intended protocol or integration surface, but not yet a - final SemVer promise. Compatibility is the default while boundaries are - curated. -- **Provisional:** externally reachable low-level or mixed surface. Consumers - may use it, but boundary work and a migration decision are still required. -- **Experimental:** incomplete or optional surface that may change with an - explicit version and changelog decision. -- **Tool internal:** support code for repository binaries, not a library API - commitment. - -The package ledger currently classifies `rns-identity`, `rns-link`, -`rns-protocol`, and `rns-interface` as candidate stable. `rns-crypto`, -`rns-wire`, and `rns-transport` remain provisional low-level packages. -`rns-runtime` is also provisional because it mixes the intended application -facade (`rns_runtime::prelude`, lifecycle handles, destination resolution, and -Link sessions) with broad actor, RPC, manager, and command modules. `rns-ratkey` -is experimental, and the `rns-tools` library target is tool internal. - -The existing [`rns_runtime::prelude`](APPLICATION_API.md) is the canonical -application spine. It re-exports the original type identities, and all current -module-qualified paths remain supported. Actor, mailbox, RPC, transport-table, -concrete-driver, and endpoint-ownership modules remain provisional SPI; their -reachability in a snapshot does not promote them. - -No existing module is hidden, moved, or made private by this baseline. That -work requires the next explicit API-boundary checkpoint, downstream migration -evidence from rsLXMF/rsLXST/Ratspeak, and a versioning decision. - -## Baseline scope and use - -The canonical snapshot is all-features `aarch64-apple-darwin`. It intentionally -omits auto-derived, auto-trait, and blanket implementations to keep diffs -reviewable. Target-only Linux, Android, and Windows overlays remain protected -by their existing compile, package, and integration gates; they are not yet a -stable cross-target Rust API promise. - -To verify the baseline: - -```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 -cargo check --manifest-path api-fixtures/Cargo.toml --all-features --locked -``` - -The immutable floor and current captured snapshot source are separate -identities in `api-stability.json`. The compatibility check currently enforces -an additions-only Wave C policy. Snapshot equality remains only one layer of -SemVer evidence: feature/cfg contracts, external fixtures, platform builds, -and behavioral tests remain mandatory. - -Use `--update` only after reviewing the generated API diff and recording the -compatibility/version decision. Snapshot updates do not by themselves make a -breaking change acceptable. diff --git a/APPLICATION_API.md b/APPLICATION_API.md deleted file mode 100644 index b7926af..0000000 --- a/APPLICATION_API.md +++ /dev/null @@ -1,61 +0,0 @@ -# Reticulum application API - -`rns_runtime::prelude` is the canonical application-facing import path for an -owned Reticulum runtime. It gathers existing identities from the protocol, -identity, Link, interface, and runtime crates; it does not wrap or replace -them. Module-qualified paths remain supported. - -The compiled examples under `crates/rns-runtime/examples/` are the executable -application guide. They cover runtime startup and shutdown, Destinations, -announces, packets and receipts, persistent Links, requests, Channels, Buffer -streams, Resources, and RNode observation. - -```rust -use std::sync::Arc; -use std::sync::atomic::AtomicBool; - -use rns_runtime::prelude::*; - -#[tokio::main] -async fn main() -> Result<(), ReticulumError> { - let shutdown = ShutdownSignal::new(); - let runtime = init( - None, - None, - shutdown, - Arc::new(AtomicBool::new(true)), - ) - .await?; - let identity = Identity::new(); - - // Application work owns `runtime`; shutdown is explicit and awaitable. - runtime.shutdown_and_wait().await; - drop(identity); - Ok(()) -} -``` - -Finite destination discovery uses `resolve_destination_on_transport` with one -deadline and validated identity recall. Long-lived observation uses -`ReticulumHandle::subscribe_announces`, whose returned -`AnnounceSubscription` owns exactly one registration. A finite lookup never -installs or removes an announce handler. - -The prelude is intentionally not a blanket stability promise. Low-level actor, -mailbox, RPC, transport-table, concrete-driver, and Link endpoint ownership -paths remain provisional SPI. Advanced integrations may continue using those -module-qualified paths, but application code should start with the prelude and -the compiled examples. - -Compatibility is checked in layers: - -- `api-baseline/*.txt` records the explicit all-feature Apple ARM64 surface; -- `api-baseline/manifest-contract.json` records features, targets, MSRV, and - non-development dependencies; -- `api-fixtures` compiles canonical and retained legacy imports as an external - consumer; and -- `tools/check-api-compatibility.py` rejects removals from the immutable Wave C - floor. - -These checks complement platform builds and protocol/interoperability tests; -they do not replace them. diff --git a/README.md b/README.md index cb2df60..4cf1e25 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ rsReticulum can live beside other Reticulum tools on `PATH` without worry. ## Contents - [Build It](#build-it) -- [Application API](APPLICATION_API.md) +- [Rust API](api/README.md) - [Tool Usage](#tool-usage) - [Configuration](#configuration) - [Interface Support](#interface-support) diff --git a/api-reviews/wave-c-application-prelude.json b/api-reviews/wave-c-application-prelude.json deleted file mode 100644 index a6ae084..0000000 --- a/api-reviews/wave-c-application-prelude.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 1, - "snapshotSourceCommit": "51763a97dcd3d348ce3e3c44c86da089cc895ea6", - "capabilities": ["RET-01", "RET-02", "RET-03", "RET-04", "RET-05", "RET-06", "RET-07", "RET-08", "RET-09", "RET-11"], - "canonicalPath": "rns_runtime::prelude", - "classification": "existing candidate application prelude", - "publicApiDiff": {"added": 0, "removed": 0}, - "semver": "no version consequence; documentation, fixtures, and compatibility tooling only", - "deprecations": "none", - "wirePersistenceRuntimeImpact": "none", - "platformEvidence": [ - "compiled application examples and external canonical/legacy fixture", - "stable and Rust 1.87 strict Clippy", - "downstream desktop and mobile product gates" - ] -} diff --git a/api/README.md b/api/README.md new file mode 100644 index 0000000..747e414 --- /dev/null +++ b/api/README.md @@ -0,0 +1,88 @@ +# Rust API + +Application code should begin with `rns_runtime::prelude`. It collects the +runtime handle and the commonly used identity, destination, packet, Link, +request, Channel, Resource, interface, and shutdown types without wrapping or +replacing them. Existing module-qualified imports remain supported. + +The examples in `crates/rns-runtime/examples/` are compiled as part of CI and +show complete flows for runtime startup, Destinations, announces, receipts, +Links, requests, Channels, Buffer streams, Resources, and RNode observation. + +```rust +use std::sync::Arc; +use std::sync::atomic::AtomicBool; + +use rns_runtime::prelude::*; + +#[tokio::main] +async fn main() -> Result<(), ReticulumError> { + let runtime = init( + None, + None, + ShutdownSignal::new(), + Arc::new(AtomicBool::new(true)), + ) + .await?; + + let identity = Identity::new(); + // Use `runtime` and `identity` to create application Destinations. + + runtime.shutdown_and_wait().await; + Ok(()) +} +``` + +Finite destination discovery uses `resolve_destination_on_transport` with one +deadline and validated identity recall. Long-lived announce observation uses +`ReticulumHandle::subscribe_announces`; the returned `AnnounceSubscription` +owns exactly one registration. Finite lookups do not install or remove +announce handlers. + +## Stability + +The application prelude is the recommended integration path, but the workspace +is not yet a blanket stability promise for every public Rust item. + +- `rns-identity`, `rns-link`, `rns-protocol`, and `rns-interface` are candidate + stable. +- `rns-crypto`, `rns-wire`, and `rns-transport` are provisional low-level + packages. +- `rns-runtime` is provisional because it contains both the application + prelude and lower-level actor, RPC, manager, and command APIs. +- `rns-ratkey` is experimental, and the `rns-tools` library target supports the + repository's binaries rather than a public library integration. + +Low-level actor, mailbox, RPC, transport-table, concrete-driver, and Link +endpoint ownership APIs remain available for compatibility. They should not be +treated as stable merely because they are publicly reachable. + +## 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 import paths as an external + consumer. + +These checks catch accidental changes, but they do not replace platform builds, +protocol interoperability tests, or manual review. In particular, 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 +cargo check --manifest-path api/fixtures/Cargo.toml --all-features --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. diff --git a/api-fixtures/Cargo.lock b/api/fixtures/Cargo.lock similarity index 100% rename from api-fixtures/Cargo.lock rename to api/fixtures/Cargo.lock diff --git a/api-fixtures/Cargo.toml b/api/fixtures/Cargo.toml similarity index 74% rename from api-fixtures/Cargo.toml rename to api/fixtures/Cargo.toml index cb34b8f..1b7f8d5 100644 --- a/api-fixtures/Cargo.toml +++ b/api/fixtures/Cargo.toml @@ -11,4 +11,4 @@ default = [] all = ["rns-runtime/ble", "rns-runtime/rnode-tcp", "rns-runtime/serial"] [dependencies] -rns-runtime = { path = "../crates/rns-runtime", default-features = false } +rns-runtime = { path = "../../crates/rns-runtime", default-features = false } diff --git a/api-fixtures/src/lib.rs b/api/fixtures/src/lib.rs similarity index 100% rename from api-fixtures/src/lib.rs rename to api/fixtures/src/lib.rs diff --git a/api-baseline/manifest-contract.json b/api/snapshots/manifest-contract.json similarity index 100% rename from api-baseline/manifest-contract.json rename to api/snapshots/manifest-contract.json diff --git a/api-baseline/rns-crypto.txt b/api/snapshots/rns-crypto.txt similarity index 100% rename from api-baseline/rns-crypto.txt rename to api/snapshots/rns-crypto.txt diff --git a/api-baseline/rns-identity.txt b/api/snapshots/rns-identity.txt similarity index 100% rename from api-baseline/rns-identity.txt rename to api/snapshots/rns-identity.txt diff --git a/api-baseline/rns-interface.txt b/api/snapshots/rns-interface.txt similarity index 100% rename from api-baseline/rns-interface.txt rename to api/snapshots/rns-interface.txt diff --git a/api-baseline/rns-link.txt b/api/snapshots/rns-link.txt similarity index 100% rename from api-baseline/rns-link.txt rename to api/snapshots/rns-link.txt diff --git a/api-baseline/rns-protocol.txt b/api/snapshots/rns-protocol.txt similarity index 100% rename from api-baseline/rns-protocol.txt rename to api/snapshots/rns-protocol.txt diff --git a/api-baseline/rns-ratkey.txt b/api/snapshots/rns-ratkey.txt similarity index 100% rename from api-baseline/rns-ratkey.txt rename to api/snapshots/rns-ratkey.txt diff --git a/api-baseline/rns-runtime.txt b/api/snapshots/rns-runtime.txt similarity index 100% rename from api-baseline/rns-runtime.txt rename to api/snapshots/rns-runtime.txt diff --git a/api-baseline/rns-tools.txt b/api/snapshots/rns-tools.txt similarity index 100% rename from api-baseline/rns-tools.txt rename to api/snapshots/rns-tools.txt diff --git a/api-baseline/rns-transport.txt b/api/snapshots/rns-transport.txt similarity index 100% rename from api-baseline/rns-transport.txt rename to api/snapshots/rns-transport.txt diff --git a/api-baseline/rns-wire.txt b/api/snapshots/rns-wire.txt similarity index 100% rename from api-baseline/rns-wire.txt rename to api/snapshots/rns-wire.txt diff --git a/api-stability.json b/api/stability.json similarity index 69% rename from api-stability.json rename to api/stability.json index 8faecad..a4d1701 100644 --- a/api-stability.json +++ b/api/stability.json @@ -21,7 +21,29 @@ "snapshotSource": { "commit": "51763a97dcd3d348ce3e3c44c86da089cc895ea6", "capturedOn": "2026-08-17", - "changeRecord": "api-reviews/wave-c-application-prelude.json" + "review": { + "areas": [ + "runtime application facade", + "identity and destination construction", + "announces and destination resolution", + "packets, receipts, Links, requests, Channels, and Resources", + "interface lifecycle and RNode observation" + ], + "canonicalPath": "rns_runtime::prelude", + "classification": "existing candidate application facade", + "publicApiDiff": { + "added": 0, + "removed": 0 + }, + "semver": "no version consequence; documentation, fixtures, and compatibility tooling only", + "deprecations": "none", + "wirePersistenceRuntimeImpact": "none", + "platformEvidence": [ + "compiled application examples and external canonical and legacy fixtures", + "stable and Rust 1.87 strict Clippy", + "downstream desktop and mobile product gates" + ] + } }, "packages": [ { @@ -29,7 +51,7 @@ "manifestPath": "Cargo.toml", "tier": "provisional", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-crypto.txt", + "snapshot": "api/snapshots/rns-crypto.txt", "itemCount": 91, "sha256": "4d1e3c0a13e48a84f2510c6586024b3d8f5781b367459bc17d714ca485f1aa63" }, @@ -38,7 +60,7 @@ "manifestPath": "Cargo.toml", "tier": "provisional", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-wire.txt", + "snapshot": "api/snapshots/rns-wire.txt", "itemCount": 369, "sha256": "e82cf03eeed3f13ccde7fda8d87e58de0a9403a98860f8c576d84922ef2336c9" }, @@ -47,7 +69,7 @@ "manifestPath": "Cargo.toml", "tier": "candidate-stable", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-identity.txt", + "snapshot": "api/snapshots/rns-identity.txt", "itemCount": 374, "sha256": "f2b692070a3fa1a2cc98edbb40bc75d205daadfa9da9d9994ee194e8436e00c9" }, @@ -56,7 +78,7 @@ "manifestPath": "Cargo.toml", "tier": "provisional", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-transport.txt", + "snapshot": "api/snapshots/rns-transport.txt", "itemCount": 1574, "sha256": "d4377c893fe8a140a6c3d154f4a4f1004756856ccf462127c8bcc7c096b406ec" }, @@ -65,7 +87,7 @@ "manifestPath": "Cargo.toml", "tier": "candidate-stable", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-link.txt", + "snapshot": "api/snapshots/rns-link.txt", "itemCount": 358, "sha256": "9fe7901e33a3c5b4adc6492751187cdb48cd31f564a425a249d6f8831319b3ca" }, @@ -74,7 +96,7 @@ "manifestPath": "Cargo.toml", "tier": "candidate-stable", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-protocol.txt", + "snapshot": "api/snapshots/rns-protocol.txt", "itemCount": 623, "sha256": "fc12a8e4a0b457f2391308573c194b4633a2041d10ec9ae03247491b5b162aa1" }, @@ -83,7 +105,7 @@ "manifestPath": "Cargo.toml", "tier": "candidate-stable", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-interface.txt", + "snapshot": "api/snapshots/rns-interface.txt", "itemCount": 1405, "sha256": "362144086c716b98383543912e7bed1e8281709de07957aeb89af1c40eb371e7" }, @@ -92,7 +114,7 @@ "manifestPath": "Cargo.toml", "tier": "provisional", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-runtime.txt", + "snapshot": "api/snapshots/rns-runtime.txt", "itemCount": 1994, "sha256": "8bcad2034f13b8edd6fa0d3583988674765eb0b12ff9ec6b6863f72f2f18cf6c" }, @@ -101,7 +123,7 @@ "manifestPath": "Cargo.toml", "tier": "tool-internal", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-tools.txt", + "snapshot": "api/snapshots/rns-tools.txt", "itemCount": 15, "sha256": "662566afbf8a21928529a33dcec4a23b0a4686e9b2d94a7721b111738a5b4a6b" }, @@ -110,7 +132,7 @@ "manifestPath": "Cargo.toml", "tier": "experimental", "compatibility": "reviewed-snapshot", - "snapshot": "api-baseline/rns-ratkey.txt", + "snapshot": "api/snapshots/rns-ratkey.txt", "itemCount": 618, "sha256": "f2ab796d37f18d7d5d7a515e4b6c28900f6f1c214aec4142fed069275793fdfd" } diff --git a/tools/check-api-baseline.py b/tools/check-api-baseline.py index 604d3d1..85f6bb4 100644 --- a/tools/check-api-baseline.py +++ b/tools/check-api-baseline.py @@ -16,7 +16,7 @@ from pathlib import Path 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}$") HASH_PATTERN = re.compile(r"^[0-9a-f]{64}$") TIERS = { @@ -60,38 +60,41 @@ def load_config() -> dict[str, object]: return config -def validate_change_record(path: str, snapshot_commit: str) -> None: - record_path = ROOT / path - try: - 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}") +def validate_snapshot_review(record: object) -> None: + if not isinstance(record, dict): + fail("snapshot review is missing") required = { - "schemaVersion", - "snapshotSourceCommit", - "capabilities", + "areas", + "canonicalPath", "classification", "publicApiDiff", "semver", "deprecations", + "wirePersistenceRuntimeImpact", "platformEvidence", } - if not required.issubset(record) or record.get("schemaVersion") != 1: - fail("snapshot change record is incomplete") - if record.get("snapshotSourceCommit") != snapshot_commit: - fail("snapshot change record does not match the snapshot source commit") - if not isinstance(record.get("capabilities"), list) or not record["capabilities"]: - fail("snapshot change record must name capability IDs") + 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 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): - 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"]: - fail("snapshot change record must name platform evidence") - for key in ("classification", "semver", "deprecations"): + 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 change record must name {key}") + fail(f"snapshot review must name {key}") def public_packages(manifest_path: str) -> set[str]: @@ -189,10 +192,7 @@ def validate_metadata( ) if snapshot_ancestor.returncode != 0: fail(f"snapshot source 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") - validate_change_record(change_record, snapshot_commit) + validate_snapshot_review(snapshot_source.get("review")) packages = config.get("packages") if not isinstance(packages, list) or not packages: @@ -215,7 +215,7 @@ def validate_metadata( fail(f"{name} has an unknown stability tier") if package.get("compatibility") != "reviewed-snapshot": 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") snapshot_path = ROOT / snapshot if not snapshot_path.is_file() and not updating: @@ -298,29 +298,26 @@ def main() -> None: parser.add_argument("--metadata-only", action="store_true") parser.add_argument("--update", action="store_true") parser.add_argument("--snapshot-source-commit") - parser.add_argument("--change-record") 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 or not args.change_record: - fail("--update requires --snapshot-source-commit and --change-record") + if not args.snapshot_source_commit: + fail("--update requires --snapshot-source-commit") head = run(["git", "rev-parse", "HEAD"]).strip() if args.snapshot_source_commit != 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"]) dirty_paths = {line[3:] for line in status.splitlines() if len(line) > 3} - if dirty_paths - {args.change_record}: - fail("snapshot source has uncommitted changes outside the review record") - config["snapshotSource"] = { - "commit": args.snapshot_source_commit, - "capturedOn": date.today().isoformat(), - "changeRecord": args.change_record, - } + 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() packages = validate_metadata(config, updating=args.update) if args.metadata_only: print("api baseline metadata: ok") diff --git a/tools/check-api-compatibility.py b/tools/check-api-compatibility.py index 946a7d4..d474877 100644 --- a/tools/check-api-compatibility.py +++ b/tools/check-api-compatibility.py @@ -1,5 +1,5 @@ #!/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 @@ -10,7 +10,7 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] -LEDGER_PATH = ROOT / "api-stability.json" +LEDGER_PATH = ROOT / "api" / "stability.json" def fail(message: str) -> None: @@ -32,6 +32,19 @@ def git_show(commit: str, path: str) -> str: 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: metadata = subprocess.run( [sys.executable, "tools/check-api-baseline.py", "--metadata-only"], cwd=ROOT @@ -41,12 +54,19 @@ 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") + 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_removed = 0 for package in ledger["packages"]: 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()) added = sorted(after - before) removed = sorted(before - after) @@ -58,17 +78,15 @@ def main() -> None: print(f"- {line}", file=sys.stderr) if total_removed: 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" ) - change_record = json.loads( - (ROOT / ledger["snapshotSource"]["changeRecord"]).read_text(encoding="utf-8") - ) - if change_record["publicApiDiff"] != { + review = ledger["snapshotSource"]["review"] + if review["publicApiDiff"] != { "added": total_added, "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)") diff --git a/tools/check-api-manifest.py b/tools/check-api-manifest.py index edff6a1..481d461 100644 --- a/tools/check-api-manifest.py +++ b/tools/check-api-manifest.py @@ -12,8 +12,8 @@ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] -LEDGER_PATH = ROOT / "api-stability.json" -CONTRACT_PATH = ROOT / "api-baseline" / "manifest-contract.json" +LEDGER_PATH = ROOT / "api" / "stability.json" +CONTRACT_PATH = ROOT / "api" / "snapshots" / "manifest-contract.json" def fail(message: str) -> None: