mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-11-27 13:52:18 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e49a8b3d88 | ||
|
|
2ab8fdf22b | ||
|
|
eac0feaced | ||
|
|
a446ee21b6 | ||
|
|
b2aab6940d |
No files matched your search
@@ -10,7 +10,7 @@ permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
RSLXMF_RSRETICULUM_COMMIT: dc6bc4ee82daf66b3b40386f9777dbe62b08fec2
|
||||
RSLXMF_RSRETICULUM_COMMIT: a1639cc065a9f1744562b95818a583e20a609b11
|
||||
|
||||
jobs:
|
||||
api-compat:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
run: python3 tools/check-api-compatibility.py
|
||||
working-directory: rsLXMF
|
||||
- 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
|
||||
|
||||
test:
|
||||
|
||||
@@ -18,7 +18,7 @@ env:
|
||||
PACKAGE_ROOT: rsLXMF
|
||||
LXMF_BINS: lxmd-rs
|
||||
RSLXMF_RSRETICULUM_VERSION: 1.2.0
|
||||
RSLXMF_RSRETICULUM_COMMIT: dc6bc4ee82daf66b3b40386f9777dbe62b08fec2
|
||||
RSLXMF_RSRETICULUM_COMMIT: a1639cc065a9f1744562b95818a583e20a609b11
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
@@ -98,7 +98,7 @@ jobs:
|
||||
cp "target/release/${bin}" "dist/${PACKAGE_ROOT}/bin/${bin}"
|
||||
fi
|
||||
done
|
||||
cp README.md LICENSE CHANGELOG.md RELEASING.md "dist/${PACKAGE_ROOT}/"
|
||||
cp README.md LICENSE CHANGELOG.md "dist/${PACKAGE_ROOT}/"
|
||||
- name: Create tar archive
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
/target/
|
||||
/api-fixtures/target/
|
||||
/api/fixtures/target/
|
||||
*.swp
|
||||
.DS_Store
|
||||
__pycache__/
|
||||
*.pyc
|
||||
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
|
||||
|
||||
- [Build It](#build-it)
|
||||
- [Message API](MESSAGE_API.md)
|
||||
- [Rust API](api/README.md)
|
||||
- [Operating lxmd-rs](#operating-lxmd-rs)
|
||||
- [Configuration](#configuration)
|
||||
- [Delivery Model](#delivery-model)
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# Source release policy
|
||||
|
||||
rsLXMF source releases are built from immutable Git history. A release is
|
||||
identified by an annotated `vX.Y.Z` tag whose version matches the workspace
|
||||
package version and a dated `X.Y.Z` section in `CHANGELOG.md`.
|
||||
|
||||
Before creating a tag:
|
||||
|
||||
1. Move the relevant `Unreleased` changelog entries into a dated version
|
||||
section.
|
||||
2. Set the workspace version to that same semantic version and keep the
|
||||
declared rsReticulum compatibility version accurate.
|
||||
3. Record the exact rsReticulum commit used by the release workflow. The
|
||||
compatibility version describes the manifest contract; the commit is the
|
||||
source actually built and must be proven in an isolated sibling checkout.
|
||||
4. Run `python3 scripts/ci/check_source_release_contract.py` and the normal CI
|
||||
suite with the committed `Cargo.lock`.
|
||||
5. Create the tag only after the release commit is final. Published tags are
|
||||
immutable and must not be retargeted.
|
||||
|
||||
The release workflow checks out the requested existing tag, verifies that the
|
||||
tag, manifest, changelog, dependency checkout, and release commit agree, and
|
||||
builds with `--locked` on Rust 1.87.0. Release artifacts include this policy
|
||||
and the changelog alongside the README and license.
|
||||
|
||||
All workspace packages are intentionally marked `publish = false`. Changing
|
||||
that safeguard requires a separate package-distribution decision; a source
|
||||
release does not change it.
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"tool": {
|
||||
"name": "cargo-public-api",
|
||||
"version": "0.52.0",
|
||||
"rustdocToolchain": "nightly-2026-08-01",
|
||||
"target": "aarch64-apple-darwin",
|
||||
"arguments": [
|
||||
"--all-features",
|
||||
"-sss"
|
||||
]
|
||||
},
|
||||
"baseline": {
|
||||
"commit": "b8d7afce73f7f098706029361568e63f22888ea3",
|
||||
"capturedOn": "2026-08-17"
|
||||
},
|
||||
"compatibilityFloor": {
|
||||
"evidenceCommit": "80bb96f799330e28a0125367d4c29826f5147cc3",
|
||||
"sourceCommit": "b8d7afce73f7f098706029361568e63f22888ea3"
|
||||
},
|
||||
"snapshotSource": {
|
||||
"commit": "c934ccc5feaaddb55461404094ed6bb514aae2cc",
|
||||
"capturedOn": "2026-08-17",
|
||||
"changeRecord": "api-reviews/wave-c-message-api.json"
|
||||
},
|
||||
"packages": [
|
||||
{
|
||||
"name": "lxmf-core",
|
||||
"manifestPath": "Cargo.toml",
|
||||
"tier": "candidate-stable",
|
||||
"compatibility": "reviewed-snapshot",
|
||||
"snapshot": "api-baseline/lxmf-core.txt",
|
||||
"itemCount": 1622,
|
||||
"sha256": "c958cfdcb53117b02d1dbe907af6afaf5017d5ba92364267e21d204fe5ef3023"
|
||||
},
|
||||
{
|
||||
"name": "lxmf-tools",
|
||||
"manifestPath": "Cargo.toml",
|
||||
"tier": "tool-internal",
|
||||
"compatibility": "reviewed-snapshot",
|
||||
"snapshot": "api-baseline/lxmf-tools.txt",
|
||||
"itemCount": 185,
|
||||
"sha256": "0427d0fab38f8061cbf7f11b701f29f438490478f133524b0a8e4e7cfe6f3924"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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]
|
||||
|
||||
[dependencies]
|
||||
lxmf-core = { path = "../crates/lxmf-core" }
|
||||
lxmf-core = { path = "../../crates/lxmf-core" }
|
||||
File renamed without changes.
@@ -498,7 +498,10 @@ pub fn lxmf_core::link_delivery::LinkDeliveryManager::set_inbound_resource_limit
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::start_backchannel_delivery(&mut self, lxmf_core::message::LxMessage, [u8; 16]) -> core::result::Result<lxmf_core::link_delivery::BackchannelStartReport, lxmf_core::link_delivery::BackchannelStartFailure>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::start_delivery(&mut self, lxmf_core::message::LxMessage, [u8; 16], u8) -> core::result::Result<[u8; 16], lxmf_core::link_delivery::LinkDeliveryStartFailure>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::start_delivery_with_report(&mut self, lxmf_core::message::LxMessage, [u8; 16], u8) -> core::result::Result<lxmf_core::link_delivery::DirectLinkStartReport, lxmf_core::link_delivery::LinkDeliveryStartFailure>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::start_delivery_with_report_and_timing(&mut self, lxmf_core::message::LxMessage, [u8; 16], u8, lxmf_core::link_delivery::LinkEstablishmentTiming) -> core::result::Result<lxmf_core::link_delivery::DirectLinkStartReport, lxmf_core::link_delivery::LinkDeliveryStartFailure>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::start_delivery_with_timing(&mut self, lxmf_core::message::LxMessage, [u8; 16], u8, lxmf_core::link_delivery::LinkEstablishmentTiming) -> core::result::Result<[u8; 16], lxmf_core::link_delivery::LinkDeliveryStartFailure>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::start_packed_delivery(&mut self, lxmf_core::message::LxMessage, [u8; 16], u8, alloc::vec::Vec<u8>, bool) -> core::result::Result<[u8; 16], lxmf_core::link_delivery::LinkDeliveryStartFailure>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::start_packed_delivery_with_timing(&mut self, lxmf_core::message::LxMessage, [u8; 16], u8, alloc::vec::Vec<u8>, bool, lxmf_core::link_delivery::LinkEstablishmentTiming) -> core::result::Result<[u8; 16], lxmf_core::link_delivery::LinkDeliveryStartFailure>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::stats(&self) -> lxmf_core::link_delivery::LinkDeliveryStats
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::take_backchannel_resource_cancellations(&mut self) -> alloc::vec::Vec<lxmf_core::link_delivery::BackchannelResourceCancelRequest>
|
||||
pub fn lxmf_core::link_delivery::LinkDeliveryManager::take_delivery_events(&mut self) -> alloc::vec::Vec<lxmf_core::link_delivery::LxmfDeliveryEvent>
|
||||
@@ -521,6 +524,15 @@ pub lxmf_core::link_delivery::LinkDeliveryStats::pending_backchannel_deliveries:
|
||||
pub lxmf_core::link_delivery::LinkDeliveryStats::pending_backchannel_starts: usize
|
||||
pub lxmf_core::link_delivery::LinkDeliveryStats::queued_deliveries: usize
|
||||
pub lxmf_core::link_delivery::LinkDeliveryStats::sessions: usize
|
||||
pub struct lxmf_core::link_delivery::LinkEstablishmentTiming
|
||||
impl lxmf_core::link_delivery::LinkEstablishmentTiming
|
||||
pub const fn lxmf_core::link_delivery::LinkEstablishmentTiming::first_hop_timeout(self) -> core::time::Duration
|
||||
pub fn lxmf_core::link_delivery::LinkEstablishmentTiming::from_first_hop_bitrate(u64) -> Self
|
||||
pub fn lxmf_core::link_delivery::LinkEstablishmentTiming::from_first_hop_bitrate_and_mtu(u64, u32) -> Self
|
||||
pub const fn lxmf_core::link_delivery::LinkEstablishmentTiming::from_first_hop_timeout(core::time::Duration) -> Self
|
||||
pub fn lxmf_core::link_delivery::LinkEstablishmentTiming::timeout_for_hops(self, u8) -> core::time::Duration
|
||||
impl core::default::Default for lxmf_core::link_delivery::LinkEstablishmentTiming
|
||||
pub fn lxmf_core::link_delivery::LinkEstablishmentTiming::default() -> Self
|
||||
pub struct lxmf_core::link_delivery::LxmfDeliveryEvent
|
||||
pub lxmf_core::link_delivery::LxmfDeliveryEvent::attempts: u32
|
||||
pub lxmf_core::link_delivery::LxmfDeliveryEvent::delivery_state: lxmf_core::link_delivery::DeliveryState
|
||||
@@ -1414,6 +1426,7 @@ pub fn lxmf_core::router::LxmRouter::set_retain_node_lxms(&mut self, bool)
|
||||
pub fn lxmf_core::router::LxmRouter::set_stamp_cost(&mut self, [u8; 16], u8)
|
||||
pub fn lxmf_core::router::LxmRouter::set_stamp_requirements(&mut self, u8, u8)
|
||||
pub fn lxmf_core::router::LxmRouter::set_transport(&mut self, tokio::sync::mpsc::bounded::Sender<rns_transport::messages::TransportMessage>)
|
||||
pub fn lxmf_core::router::LxmRouter::state_snapshot(&self) -> lxmf_core::router::RouterStateSnapshot
|
||||
pub fn lxmf_core::router::LxmRouter::stats(&self) -> lxmf_core::router::RouterStats
|
||||
pub fn lxmf_core::router::LxmRouter::sync_peer_policies_for_store(&self, u64) -> alloc::vec::Vec<lxmf_core::peer::OutboundOfferPolicy>
|
||||
pub fn lxmf_core::router::LxmRouter::sync_peers(&mut self) -> alloc::vec::Vec<[u8; 16]>
|
||||
@@ -1484,6 +1497,9 @@ pub lxmf_core::router::RouterConfigExt::propagation_cost_min: u8
|
||||
pub lxmf_core::router::RouterConfigExt::retain_synced_on_node: bool
|
||||
impl core::default::Default for lxmf_core::router::RouterConfigExt
|
||||
pub fn lxmf_core::router::RouterConfigExt::default() -> Self
|
||||
pub struct lxmf_core::router::RouterStateSnapshot
|
||||
impl lxmf_core::router::RouterStateSnapshot
|
||||
pub fn lxmf_core::router::RouterStateSnapshot::save_state(&self, &std::path::Path) -> core::io::error::Result<()>
|
||||
pub struct lxmf_core::router::RouterStats
|
||||
pub lxmf_core::router::RouterStats::peers: usize
|
||||
pub lxmf_core::router::RouterStats::pending_deferred_stamps: usize
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"tool": {
|
||||
"name": "cargo-public-api",
|
||||
"version": "0.52.0",
|
||||
"rustdocToolchain": "nightly-2026-08-01",
|
||||
"target": "aarch64-apple-darwin",
|
||||
"arguments": [
|
||||
"--all-features",
|
||||
"-sss"
|
||||
]
|
||||
},
|
||||
"baseline": {
|
||||
"commit": "b8d7afce73f7f098706029361568e63f22888ea3",
|
||||
"capturedOn": "2026-08-17"
|
||||
},
|
||||
"compatibilityFloor": {
|
||||
"evidenceCommit": "80bb96f799330e28a0125367d4c29826f5147cc3",
|
||||
"sourceCommit": "b8d7afce73f7f098706029361568e63f22888ea3"
|
||||
},
|
||||
"snapshotSource": {
|
||||
"commit": "2ab8fdf22b55bf18708c7181da5d4e07801e7699",
|
||||
"capturedOn": "2026-08-21",
|
||||
"review": {
|
||||
"areas": [
|
||||
"message construction and inspection",
|
||||
"message status and identifiers",
|
||||
"owned router persistence snapshots",
|
||||
"Link establishment timing and timing-aware delivery starts"
|
||||
],
|
||||
"canonicalPath": "lxmf_core::message_api",
|
||||
"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 facade and provisional integration APIs",
|
||||
"publicApiDiff": {
|
||||
"added": 86,
|
||||
"removed": 0
|
||||
},
|
||||
"semver": "compatible additive APIs included in version 1.2.0",
|
||||
"deprecations": "none",
|
||||
"wirePersistenceRuntimeImpact": "no wire-format or persisted-layout change; exact message re-exports are behavior-neutral, owned router snapshots preserve the existing MessagePack layout, and Link establishment deadlines now follow authoritative first-hop timing while existing start methods remain available with the Reticulum fallback",
|
||||
"platformEvidence": [
|
||||
"compiled message example and external canonical and legacy fixtures",
|
||||
"lxmf-core owned router snapshot and upstream-compatible Link timing unit tests",
|
||||
"macOS and Ubuntu workspace test jobs for source commit 2ab8fdf22b55bf18708c7181da5d4e07801e7699"
|
||||
]
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
{
|
||||
"name": "lxmf-core",
|
||||
"manifestPath": "Cargo.toml",
|
||||
"tier": "candidate-stable",
|
||||
"compatibility": "reviewed-snapshot",
|
||||
"snapshot": "api/snapshots/lxmf-core.txt",
|
||||
"itemCount": 1638,
|
||||
"sha256": "5b59de793250e211cd206c06e8e70147d91e40c45ba1d28fb659a4a354e2fd96"
|
||||
},
|
||||
{
|
||||
"name": "lxmf-tools",
|
||||
"manifestPath": "Cargo.toml",
|
||||
"tier": "tool-internal",
|
||||
"compatibility": "reviewed-snapshot",
|
||||
"snapshot": "api/snapshots/lxmf-tools.txt",
|
||||
"itemCount": 185,
|
||||
"sha256": "0427d0fab38f8061cbf7f11b701f29f438490478f133524b0a8e4e7cfe6f3924"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -40,6 +40,103 @@ const BACKCHANNEL_DELIVERY_TIMEOUT: Duration = Duration::from_secs(360);
|
||||
const BACKCHANNEL_EARLY_PROOF_LIMIT: usize = 256;
|
||||
const LINK_PENDING_TRANSPORT_LIMIT: usize = 1024;
|
||||
|
||||
/// Authority-derived first-hop timing for an outbound Link.
|
||||
///
|
||||
/// Python Reticulum computes an initiator's establishment deadline as the
|
||||
/// first-hop timeout plus six seconds for every hop to the destination. The
|
||||
/// first-hop timeout is one full Reticulum MTU at the next-hop interface's
|
||||
/// bitrate, plus the same six-second baseline. When no authoritative bitrate
|
||||
/// is available, Reticulum falls back to the baseline alone.
|
||||
///
|
||||
/// Keeping this input independent of interface type is intentional: BLE,
|
||||
/// serial, TCP and every future adapter use the same Link timing rule. It does
|
||||
/// not pause or reset the protocol clock when an interface goes offline.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct LinkEstablishmentTiming {
|
||||
first_hop_timeout: Duration,
|
||||
}
|
||||
|
||||
impl LinkEstablishmentTiming {
|
||||
/// Construct timing from an already-authoritative Reticulum first-hop
|
||||
/// timeout (for example `ReticulumHandle::first_hop_timeout`).
|
||||
pub const fn from_first_hop_timeout(first_hop_timeout: Duration) -> Self {
|
||||
Self { first_hop_timeout }
|
||||
}
|
||||
|
||||
/// Derive Python-compatible first-hop timing from the effective next-hop
|
||||
/// interface bitrate. A zero bitrate has the standard six-second fallback.
|
||||
pub fn from_first_hop_bitrate(bitrate: u64) -> Self {
|
||||
Self::from_first_hop_bitrate_and_mtu(bitrate, rns_wire::constants::MTU as u32)
|
||||
}
|
||||
|
||||
/// Derive first-hop timing from the effective next-hop bitrate and an
|
||||
/// already-normalised Reticulum protocol MTU.
|
||||
///
|
||||
/// Callers normally want [`Self::from_first_hop_bitrate`], which uses the
|
||||
/// canonical 500-byte Reticulum MTU exactly like Python Reticulum and the
|
||||
/// trusted rsReticulum runtime. `normalised_mtu` exists for callers that
|
||||
/// already have an authoritative *protocol* MTU. It must never be a BLE
|
||||
/// ATT MTU, an RNode serial chunk size, or a raw hardware-interface MTU.
|
||||
pub fn from_first_hop_bitrate_and_mtu(bitrate: u64, normalised_mtu: u32) -> Self {
|
||||
let serialization_secs = if bitrate == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(f64::from(normalised_mtu.min(rns_wire::constants::MTU as u32)) * 8.0) / bitrate as f64
|
||||
};
|
||||
Self {
|
||||
first_hop_timeout: Duration::from_secs_f64(
|
||||
serialization_secs + rns_wire::constants::DEFAULT_PER_HOP_TIMEOUT,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn first_hop_timeout(self) -> Duration {
|
||||
self.first_hop_timeout
|
||||
}
|
||||
|
||||
pub fn timeout_for_hops(self, hops: u8) -> Duration {
|
||||
self.first_hop_timeout
|
||||
+ Duration::from_secs_f64(ESTABLISHMENT_TIMEOUT_PER_HOP * f64::from(hops.max(1)))
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for LinkEstablishmentTiming {
|
||||
fn default() -> Self {
|
||||
Self::from_first_hop_bitrate(0)
|
||||
}
|
||||
}
|
||||
|
||||
struct LinkDeliveryStartOptions {
|
||||
timing: LinkEstablishmentTiming,
|
||||
packed_override: Option<Vec<u8>>,
|
||||
auto_compress: bool,
|
||||
reusable: bool,
|
||||
}
|
||||
|
||||
impl LinkDeliveryStartOptions {
|
||||
fn direct(timing: LinkEstablishmentTiming) -> Self {
|
||||
Self {
|
||||
timing,
|
||||
packed_override: None,
|
||||
auto_compress: true,
|
||||
reusable: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn packed(
|
||||
timing: LinkEstablishmentTiming,
|
||||
packed_payload: Vec<u8>,
|
||||
auto_compress: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
timing,
|
||||
packed_override: Some(packed_payload),
|
||||
auto_compress,
|
||||
reusable: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type InboundResourceAcceptHandler =
|
||||
Arc<dyn Fn([u8; 16], &ResourceAdvertisement) -> bool + Send + Sync>;
|
||||
type InboundResourceConcludedHandler = Arc<dyn Fn([u8; 16], [u8; 32]) + Send + Sync>;
|
||||
@@ -777,7 +874,24 @@ impl LinkDeliveryManager {
|
||||
dest_hash: [u8; 16],
|
||||
hops: u8,
|
||||
) -> Result<[u8; 16], LinkDeliveryStartFailure> {
|
||||
self.start_delivery_with_report(message, dest_hash, hops)
|
||||
self.start_delivery_with_timing(
|
||||
message,
|
||||
dest_hash,
|
||||
hops,
|
||||
LinkEstablishmentTiming::default(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Start a direct delivery with authoritative first-hop timing and return
|
||||
/// the tracking `link_id`.
|
||||
pub fn start_delivery_with_timing(
|
||||
&mut self,
|
||||
message: LxMessage,
|
||||
dest_hash: [u8; 16],
|
||||
hops: u8,
|
||||
timing: LinkEstablishmentTiming,
|
||||
) -> Result<[u8; 16], LinkDeliveryStartFailure> {
|
||||
self.start_delivery_with_report_and_timing(message, dest_hash, hops, timing)
|
||||
.map(|report| report.link_id)
|
||||
}
|
||||
|
||||
@@ -789,7 +903,24 @@ impl LinkDeliveryManager {
|
||||
dest_hash: [u8; 16],
|
||||
hops: u8,
|
||||
) -> Result<DirectLinkStartReport, LinkDeliveryStartFailure> {
|
||||
self.start_direct_delivery(message, dest_hash, hops)
|
||||
self.start_delivery_with_report_and_timing(
|
||||
message,
|
||||
dest_hash,
|
||||
hops,
|
||||
LinkEstablishmentTiming::default(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Start a Direct delivery with authoritative first-hop timing and return
|
||||
/// whether it created, reused, or queued on reusable Link state.
|
||||
pub fn start_delivery_with_report_and_timing(
|
||||
&mut self,
|
||||
message: LxMessage,
|
||||
dest_hash: [u8; 16],
|
||||
hops: u8,
|
||||
timing: LinkEstablishmentTiming,
|
||||
) -> Result<DirectLinkStartReport, LinkDeliveryStartFailure> {
|
||||
self.start_direct_delivery(message, dest_hash, hops, timing)
|
||||
}
|
||||
|
||||
/// Start a link delivery with an already-packed payload.
|
||||
@@ -803,14 +934,32 @@ impl LinkDeliveryManager {
|
||||
hops: u8,
|
||||
packed_payload: Vec<u8>,
|
||||
auto_compress: bool,
|
||||
) -> Result<[u8; 16], LinkDeliveryStartFailure> {
|
||||
self.start_packed_delivery_with_timing(
|
||||
message,
|
||||
dest_hash,
|
||||
hops,
|
||||
packed_payload,
|
||||
auto_compress,
|
||||
LinkEstablishmentTiming::default(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Start a packed Link delivery with authoritative first-hop timing.
|
||||
pub fn start_packed_delivery_with_timing(
|
||||
&mut self,
|
||||
message: LxMessage,
|
||||
dest_hash: [u8; 16],
|
||||
hops: u8,
|
||||
packed_payload: Vec<u8>,
|
||||
auto_compress: bool,
|
||||
timing: LinkEstablishmentTiming,
|
||||
) -> Result<[u8; 16], LinkDeliveryStartFailure> {
|
||||
self.start_delivery_inner(
|
||||
message,
|
||||
dest_hash,
|
||||
hops,
|
||||
Some(packed_payload),
|
||||
auto_compress,
|
||||
false,
|
||||
LinkDeliveryStartOptions::packed(timing, packed_payload, auto_compress),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -923,6 +1072,7 @@ impl LinkDeliveryManager {
|
||||
message: LxMessage,
|
||||
dest_hash: [u8; 16],
|
||||
hops: u8,
|
||||
timing: LinkEstablishmentTiming,
|
||||
) -> Result<DirectLinkStartReport, LinkDeliveryStartFailure> {
|
||||
if let Some(link_id) = self.direct_links.get(&dest_hash).copied() {
|
||||
let idle_expired = self
|
||||
@@ -1024,7 +1174,12 @@ impl LinkDeliveryManager {
|
||||
|
||||
let msg_hash = message.hash;
|
||||
let attempts = message.delivery_attempts;
|
||||
let link_id = self.start_delivery_inner(message, dest_hash, hops, None, true, true)?;
|
||||
let link_id = self.start_delivery_inner(
|
||||
message,
|
||||
dest_hash,
|
||||
hops,
|
||||
LinkDeliveryStartOptions::direct(timing),
|
||||
)?;
|
||||
let snapshot = self.direct_link_snapshot(dest_hash);
|
||||
let report = DirectLinkStartReport {
|
||||
link_id,
|
||||
@@ -1060,12 +1215,17 @@ impl LinkDeliveryManager {
|
||||
message: LxMessage,
|
||||
dest_hash: [u8; 16],
|
||||
hops: u8,
|
||||
packed_override: Option<Vec<u8>>,
|
||||
auto_compress: bool,
|
||||
reusable: bool,
|
||||
options: LinkDeliveryStartOptions,
|
||||
) -> Result<[u8; 16], LinkDeliveryStartFailure> {
|
||||
let LinkDeliveryStartOptions {
|
||||
timing,
|
||||
packed_override,
|
||||
auto_compress,
|
||||
reusable,
|
||||
} = options;
|
||||
let msg_hash = message.hash;
|
||||
let (link, request_data) = Link::new_initiator(dest_hash, hops);
|
||||
let (mut link, request_data) = Link::new_initiator(dest_hash, hops);
|
||||
link.extend_establishment_timeout(timing.first_hop_timeout().as_secs_f64());
|
||||
let link_id = link.link_id;
|
||||
let pending_count = self.pending_count();
|
||||
|
||||
@@ -1137,7 +1297,8 @@ impl LinkDeliveryManager {
|
||||
destination_hash: dest_hash,
|
||||
}));
|
||||
|
||||
let establishment_timeout_secs = ESTABLISHMENT_TIMEOUT_PER_HOP * (hops.max(1) as f64);
|
||||
let establishment_timeout = timing.timeout_for_hops(hops);
|
||||
let establishment_timeout_secs = establishment_timeout.as_secs_f64();
|
||||
// Full transfer timeout keeps the previous keepalive allowance once
|
||||
// establishment has succeeded.
|
||||
let timeout_secs = establishment_timeout_secs + KEEPALIVE_DEFAULT;
|
||||
@@ -1154,7 +1315,7 @@ impl LinkDeliveryManager {
|
||||
transfer: None,
|
||||
remaining_segments: None,
|
||||
packet_proof_hash: None,
|
||||
establishment_timeout: Duration::from_secs_f64(establishment_timeout_secs),
|
||||
establishment_timeout,
|
||||
timeout: Duration::from_secs_f64(timeout_secs),
|
||||
msg_hash,
|
||||
failure_reason: None,
|
||||
@@ -4830,6 +4991,78 @@ mod tests {
|
||||
use std::collections::HashMap;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
#[test]
|
||||
fn link_establishment_timing_matches_upstream_medium_fast_one_and_multi_hop() {
|
||||
// RNode Firmware's Medium Fast preset is SF9/BW250/CR5. The firmware's
|
||||
// integer bitrate calculation yields 3515 bit/s, while Reticulum uses
|
||||
// its normalised 500-byte protocol MTU for first-hop timing.
|
||||
let timing = LinkEstablishmentTiming::from_first_hop_bitrate(3_515);
|
||||
let expected_first_hop = 6.0 + (500.0 * 8.0 / 3_515.0);
|
||||
let expected_one_hop = expected_first_hop + 6.0;
|
||||
let expected_three_hops = expected_first_hop + 18.0;
|
||||
|
||||
assert!((timing.first_hop_timeout().as_secs_f64() - expected_first_hop).abs() < 1e-9);
|
||||
assert!((timing.timeout_for_hops(1).as_secs_f64() - expected_one_hop).abs() < 1e-9);
|
||||
assert!((timing.timeout_for_hops(3).as_secs_f64() - expected_three_hops).abs() < 1e-9);
|
||||
assert!((timing.timeout_for_hops(1).as_secs_f64() - 13.137_980_085).abs() < 1e-9);
|
||||
|
||||
// The explicit constructor accepts a *normalised Reticulum protocol*
|
||||
// MTU, never a raw BLE ATT or hardware-interface MTU. Values above the
|
||||
// protocol maximum normalise back to the canonical 500-byte boundary.
|
||||
assert_eq!(
|
||||
timing,
|
||||
LinkEstablishmentTiming::from_first_hop_bitrate_and_mtu(3_515, 1_024)
|
||||
);
|
||||
|
||||
let unknown_interface = LinkEstablishmentTiming::default();
|
||||
assert_eq!(
|
||||
unknown_interface.first_hop_timeout(),
|
||||
Duration::from_secs(6)
|
||||
);
|
||||
assert_eq!(
|
||||
unknown_interface.timeout_for_hops(1),
|
||||
Duration::from_secs(12)
|
||||
);
|
||||
assert_eq!(
|
||||
unknown_interface.timeout_for_hops(3),
|
||||
Duration::from_secs(24)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn timed_start_applies_one_clock_and_preserves_establishing_cancel() {
|
||||
let (tx, _rx) = mpsc::channel(64);
|
||||
let mut mgr = LinkDeliveryManager::new(tx, None, None);
|
||||
let signing_key = Ed25519PrivateKey::generate();
|
||||
let mut message = LxMessage::new(
|
||||
[0xAA; 16],
|
||||
[0xBB; 16],
|
||||
"Timed",
|
||||
"cancel remains local",
|
||||
crate::constants::DeliveryMethod::Direct,
|
||||
);
|
||||
message.sign(&signing_key).unwrap();
|
||||
let message_hash = message.hash.unwrap();
|
||||
let timing = LinkEstablishmentTiming::from_first_hop_bitrate(3_515);
|
||||
let expected = timing.timeout_for_hops(3);
|
||||
|
||||
let link_id = mgr
|
||||
.start_delivery_with_timing(message, [0xCC; 16], 3, timing)
|
||||
.unwrap();
|
||||
let pending = mgr.pending.get(&link_id).unwrap();
|
||||
assert_eq!(pending.establishment_timeout, expected);
|
||||
assert_eq!(pending.link.establishment_timeout, expected);
|
||||
|
||||
assert!(mgr.cancel_delivery_by_message_hash(message_hash));
|
||||
assert!(!mgr.cancel_delivery_by_message_hash(message_hash));
|
||||
assert_eq!(mgr.pending_count(), 0);
|
||||
assert!(
|
||||
mgr.take_delivery_events()
|
||||
.iter()
|
||||
.all(|event| event.kind != LxmfDeliveryEventKind::Failed)
|
||||
);
|
||||
}
|
||||
|
||||
fn next_outbound(rx: &mut mpsc::Receiver<TransportMessage>) -> Vec<u8> {
|
||||
while let Ok(message) = rx.try_recv() {
|
||||
match message {
|
||||
@@ -6680,7 +6913,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_establishment_timeout_deregisters() {
|
||||
fn test_establishment_timeout_deregisters_and_remains_retryable() {
|
||||
let (tx, mut rx) = mpsc::channel(64);
|
||||
let mut mgr = LinkDeliveryManager::new(tx, None, None);
|
||||
|
||||
@@ -6691,7 +6924,17 @@ mod tests {
|
||||
"timeout test",
|
||||
crate::constants::DeliveryMethod::Direct,
|
||||
);
|
||||
let link_id = mgr.start_delivery(msg, [0xDD; 16], 1).unwrap();
|
||||
let timing = LinkEstablishmentTiming::from_first_hop_bitrate(3_515);
|
||||
let link_id = mgr
|
||||
.start_delivery_with_timing(msg, [0xDD; 16], 1, timing)
|
||||
.unwrap();
|
||||
|
||||
let delivery = mgr.pending.get(&link_id).unwrap();
|
||||
assert_eq!(delivery.establishment_timeout, timing.timeout_for_hops(1));
|
||||
assert_eq!(
|
||||
delivery.link.establishment_timeout,
|
||||
timing.timeout_for_hops(1)
|
||||
);
|
||||
|
||||
while let Ok(message) = rx.try_recv() {
|
||||
if let TransportMessage::SendLinkEndpoint { result_tx, .. } = message {
|
||||
@@ -6711,7 +6954,9 @@ mod tests {
|
||||
);
|
||||
assert!(results.iter().any(|r| matches!(
|
||||
r,
|
||||
DeliveryResult::Failed { reason, .. } if reason == "link establishment timeout"
|
||||
DeliveryResult::Failed { reason, .. }
|
||||
if reason == "link establishment timeout"
|
||||
&& is_retryable_link_delivery_failure(reason)
|
||||
)));
|
||||
assert_eq!(mgr.pending_count(), 0);
|
||||
|
||||
|
||||
+126
-15
@@ -20,7 +20,7 @@ use crate::peer::{LxmPeer, OutboundOfferPolicy};
|
||||
use crate::propagation::PropagationStore;
|
||||
use crate::propagation_client::PropagationTransferStatus;
|
||||
use crate::stamper;
|
||||
use crate::ticket::{Ticket, TicketStore};
|
||||
use crate::ticket::{Ticket, TicketStore, TicketStoreSnapshot};
|
||||
use crate::types::PropagationTransientId;
|
||||
|
||||
/// Router configuration.
|
||||
@@ -352,6 +352,37 @@ pub struct StampCostEntry {
|
||||
pub recorded_at: f64,
|
||||
}
|
||||
|
||||
/// Owned, coherent snapshot of the router state written by [`LxmRouter::save_state`].
|
||||
///
|
||||
/// Creating the snapshot only clones in-memory state. The caller can therefore
|
||||
/// release any lock that protects the router before calling [`Self::save_state`],
|
||||
/// keeping filesystem I/O out of the router's critical section.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RouterStateSnapshot {
|
||||
outbound_stamp_costs: HashMap<[u8; 16], StampCostEntry>,
|
||||
tickets: TicketStoreSnapshot,
|
||||
local_deliveries: HashMap<PropagationTransientId, f64>,
|
||||
locally_processed: HashMap<PropagationTransientId, f64>,
|
||||
node_stats: crate::persist::PersistedNodeStats,
|
||||
}
|
||||
|
||||
impl RouterStateSnapshot {
|
||||
/// Persist this owned snapshot using the router's MessagePack layout.
|
||||
///
|
||||
/// Each file is written atomically via rename, matching
|
||||
/// [`LxmRouter::save_state`].
|
||||
pub fn save_state(&self, state_dir: &std::path::Path) -> std::io::Result<()> {
|
||||
use crate::persist;
|
||||
|
||||
persist::save_stamp_costs(state_dir, &self.outbound_stamp_costs)?;
|
||||
persist::save_tickets(state_dir, &self.tickets)?;
|
||||
persist::save_local_deliveries(state_dir, &self.local_deliveries)?;
|
||||
persist::save_locally_processed(state_dir, &self.locally_processed)?;
|
||||
persist::save_node_stats(state_dir, &self.node_stats)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl LxmRouter {
|
||||
pub fn new(config: RouterConfig) -> Self {
|
||||
Self {
|
||||
@@ -1129,25 +1160,29 @@ impl LxmRouter {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Persist runtime state to `state_dir` using MessagePack. Safe to call
|
||||
/// periodically; each file is written atomically via rename.
|
||||
pub fn save_state(&self, state_dir: &std::path::Path) -> std::io::Result<()> {
|
||||
use crate::persist;
|
||||
|
||||
persist::save_stamp_costs(state_dir, &self.outbound_stamp_costs)?;
|
||||
persist::save_tickets(state_dir, &self.ticket_store.snapshot())?;
|
||||
persist::save_local_deliveries(state_dir, self.propagation_store.locally_delivered_ids())?;
|
||||
persist::save_locally_processed(state_dir, self.propagation_store.locally_processed_ids())?;
|
||||
persist::save_node_stats(
|
||||
state_dir,
|
||||
&persist::PersistedNodeStats {
|
||||
/// Clone all runtime state written by [`Self::save_state`] into one owned
|
||||
/// value. Embedders can take this snapshot while holding the router lock,
|
||||
/// release the lock, and perform persistence through
|
||||
/// [`RouterStateSnapshot::save_state`].
|
||||
pub fn state_snapshot(&self) -> RouterStateSnapshot {
|
||||
RouterStateSnapshot {
|
||||
outbound_stamp_costs: self.outbound_stamp_costs.clone(),
|
||||
tickets: self.ticket_store.snapshot(),
|
||||
local_deliveries: self.propagation_store.locally_delivered_ids().clone(),
|
||||
locally_processed: self.propagation_store.locally_processed_ids().clone(),
|
||||
node_stats: crate::persist::PersistedNodeStats {
|
||||
client_propagation_messages_received: self.client_propagation_messages_received,
|
||||
client_propagation_messages_served: self.client_propagation_messages_served,
|
||||
unpeered_propagation_incoming: self.unpeered_propagation_incoming,
|
||||
unpeered_propagation_rx_bytes: self.unpeered_propagation_rx_bytes,
|
||||
},
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Persist runtime state to `state_dir` using MessagePack. Safe to call
|
||||
/// periodically; each file is written atomically via rename.
|
||||
pub fn save_state(&self, state_dir: &std::path::Path) -> std::io::Result<()> {
|
||||
self.state_snapshot().save_state(state_dir)
|
||||
}
|
||||
|
||||
/// Return peer destination hashes that are due for sync and mark each as
|
||||
@@ -3051,6 +3086,82 @@ mod tests {
|
||||
assert_eq!(r2.unpeered_propagation_rx_bytes, 13);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_state_snapshot_is_an_owned_coherent_copy() {
|
||||
let dest = [0xA1; 16];
|
||||
let transient = [0xB2; 32];
|
||||
|
||||
let mut router = LxmRouter::new(RouterConfig::default());
|
||||
router.set_stamp_cost(dest, 8);
|
||||
router.remember_ticket(dest, [0xC3; 16], 4_102_444_800.0);
|
||||
router.propagation_store.mark_locally_delivered(transient);
|
||||
router.propagation_store.mark_locally_processed(transient);
|
||||
router.client_propagation_messages_received = 10;
|
||||
router.client_propagation_messages_served = 11;
|
||||
router.unpeered_propagation_incoming = 12;
|
||||
router.unpeered_propagation_rx_bytes = 13;
|
||||
|
||||
let snapshot = router.state_snapshot();
|
||||
|
||||
// Mutating every persisted router dataset after capture must not alter
|
||||
// the snapshot that a background persistence task owns.
|
||||
router.set_stamp_cost(dest, 42);
|
||||
router.remember_ticket(dest, [0xD4; 16], 4_102_444_800.0);
|
||||
router
|
||||
.propagation_store
|
||||
.replace_locally_delivered(HashMap::new());
|
||||
router
|
||||
.propagation_store
|
||||
.replace_locally_processed(HashMap::new());
|
||||
router.client_propagation_messages_received = 20;
|
||||
router.client_propagation_messages_served = 21;
|
||||
router.unpeered_propagation_incoming = 22;
|
||||
router.unpeered_propagation_rx_bytes = 23;
|
||||
|
||||
assert_eq!(snapshot.outbound_stamp_costs[&dest].cost, 8);
|
||||
assert_eq!(snapshot.tickets.outbound.len(), 1);
|
||||
assert_eq!(snapshot.tickets.outbound[0].token, [0xC3; 16]);
|
||||
assert!(snapshot.local_deliveries.contains_key(&transient));
|
||||
assert!(snapshot.locally_processed.contains_key(&transient));
|
||||
assert_eq!(snapshot.node_stats.client_propagation_messages_received, 10);
|
||||
assert_eq!(snapshot.node_stats.client_propagation_messages_served, 11);
|
||||
assert_eq!(snapshot.node_stats.unpeered_propagation_incoming, 12);
|
||||
assert_eq!(snapshot.node_stats.unpeered_propagation_rx_bytes, 13);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_state_snapshot_persists_after_router_is_dropped() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let dest = [0xA5; 16];
|
||||
let transient = [0xB6; 32];
|
||||
|
||||
let snapshot = {
|
||||
let mut router = LxmRouter::new(RouterConfig::default());
|
||||
router.set_stamp_cost(dest, 9);
|
||||
router.remember_ticket(dest, [0xC7; 16], 4_102_444_800.0);
|
||||
router.propagation_store.mark_locally_delivered(transient);
|
||||
router.propagation_store.mark_locally_processed(transient);
|
||||
router.client_propagation_messages_received = 30;
|
||||
router.client_propagation_messages_served = 31;
|
||||
router.unpeered_propagation_incoming = 32;
|
||||
router.unpeered_propagation_rx_bytes = 33;
|
||||
router.state_snapshot()
|
||||
};
|
||||
|
||||
snapshot.save_state(tmp.path()).unwrap();
|
||||
|
||||
let mut restored = LxmRouter::new(RouterConfig::default());
|
||||
restored.load_state(tmp.path()).unwrap();
|
||||
assert_eq!(restored.outbound_stamp_costs[&dest].cost, 9);
|
||||
assert_eq!(restored.get_outbound_ticket(&dest), Some([0xC7; 16]));
|
||||
assert!(restored.propagation_store.is_locally_delivered(&transient));
|
||||
assert!(restored.propagation_store.is_locally_processed(&transient));
|
||||
assert_eq!(restored.client_propagation_messages_received, 30);
|
||||
assert_eq!(restored.client_propagation_messages_served, 31);
|
||||
assert_eq!(restored.unpeered_propagation_incoming, 32);
|
||||
assert_eq!(restored.unpeered_propagation_rx_bytes, 33);
|
||||
}
|
||||
|
||||
/// T1-10: persisted dedup timestamps are the REAL first-seen times —
|
||||
/// restored on load (not reset to save-time), so age-based expiry is
|
||||
/// stable across arbitrarily many save/load cycles.
|
||||
|
||||
+40
-37
@@ -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,32 +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", "classification",
|
||||
"publicApiDiff", "semver", "deprecations", "platformEvidence",
|
||||
"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]:
|
||||
@@ -183,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:
|
||||
@@ -209,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:
|
||||
@@ -292,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")
|
||||
|
||||
@@ -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,21 +32,41 @@ 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
|
||||
)
|
||||
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"))
|
||||
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)")
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user