Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
da339de
chore(quest): claim quest/m1/time/wall.md
kixelated Oct 22, 2026
275e7e5
refactor(time)!: use Wall for public Rust wall times
kixelated Oct 22, 2026
39124db
Merge remote-tracking branch 'origin/main' into quest/m1/time/wall
kixelated Oct 22, 2026
9b55b6e
fix(time): propagate Wall range errors through CLI admission
kixelated Oct 22, 2026
a6db91f
test(relay): keep portable-expiry admission fixtures in range
kixelated Oct 22, 2026
38f3909
Merge origin/main into quest/m1/time/wall
kixelated Oct 22, 2026
aa02293
Merge remote-tracking branch 'origin/main' into quest/m1/time/wall
kixelated Oct 22, 2026
b102864
refactor(time)!: saturate certificate and auth expiries to the Wall r…
kixelated Oct 22, 2026
eb8d4d1
style: format saturation tests
kixelated Oct 22, 2026
e71d8bd
doc(auth): note the saturated certificate expiry an auth server sees
kixelated Oct 22, 2026
12537bc
Merge remote-tracking branch 'origin/main' into quest/m1/time/wall
kixelated Oct 22, 2026
5b010db
fix(rtc): ignore sender reports outside the wall range
kixelated Oct 22, 2026
3edf5e6
Merge remote-tracking branch 'origin/main' into fix-6298
kixelated Oct 23, 2026
98f916d
Merge remote-tracking branch 'origin/main' into fix-6298b
kixelated Oct 23, 2026
9e4d914
Merge origin/main into quest/m1/time/wall
kixelated Oct 23, 2026
bb03cc1
Merge origin/main
kixelated Oct 23, 2026
1f6b5ae
Merge remote-tracking branch 'origin/main' into merge-6298
kixelated Oct 23, 2026
d8d83ac
Merge origin/main into quest/m1/time/wall
kixelated Oct 24, 2026
a8efddd
chore(lint): drop test clock expectations that Wall left unfulfilled
kixelated Oct 24, 2026
5cb79a0
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Oct 24, 2026
183e757
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Oct 24, 2026
e00e8d2
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Oct 24, 2026
ab9d93b
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Oct 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions quest/m1/time/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Controlled time
# [XS] Controlled time

## Goal

Expand Down Expand Up @@ -103,9 +103,9 @@ needed by the in-tree QUIC stack and clustering regressions. Unrelated test/priv
cleanup and the global lint ratchet belong to
[the follow-up sweep](/quest/m2/time-test-sweep.md).

## Required

- [Public wall times on moq_clock::Wall](/quest/m1/time/wall.md) - public `SystemTime`s become `moq_clock::Wall`, and the ratchets ban the type
Remaining: every child has landed, with public wall times on `moq_clock::Wall`
in [#6298](https://github.com/moq-dev/moq/pull/6298). Move the decisions the
m2 quests still cite into them, then retire this epic.

## Related

Expand Down
49 changes: 0 additions & 49 deletions quest/m1/time/wall.md

This file was deleted.

2 changes: 1 addition & 1 deletion rs/hang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ categories = ["multimedia", "network-programming", "web-programming"]
bytes = { workspace = true }
hex = { workspace = true }
kio = { workspace = true }
moq-clock = { workspace = true }
moq-json = { workspace = true }
moq-net = { workspace = true }
regex = "1"
Expand All @@ -31,7 +32,6 @@ features = ["from", "display", "debug"]

[dev-dependencies]
anyhow = { workspace = true }
moq-clock = { workspace = true }
moq-mux = { path = "../moq-mux" }
moq-tokio = { path = "../moq-tokio", default-features = false, features = ["quic", "aws-lc-rs", "websocket"] }
tokio = { workspace = true, features = ["macros", "fs"] }
Expand Down
2 changes: 1 addition & 1 deletion rs/hang/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Production uses the ambient clock; legacy test-only clock cleanup is tracked separately.
# `SystemTime` stays an allowed type until its wall times move to `moq_clock::Wall`.
disallowed-methods = [
{ path = "std::time::Instant::now", reason = "read the ambient clock: moq_clock::now()" },
{ path = "std::time::Instant::elapsed", reason = "read the ambient clock: moq_clock::Instant::elapsed()" },
Expand All @@ -16,6 +15,7 @@ disallowed-methods = [
]

disallowed-types = [
{ path = "std::time::SystemTime", reason = "use moq_clock::Wall" },
{ path = "std::time::Instant", reason = "use moq_clock::Instant" },
{ path = "tokio::time::Instant", reason = "use moq_clock::Instant" },
{ path = "tokio::time::Sleep", reason = "use moq_clock::Sleep" },
Expand Down
27 changes: 13 additions & 14 deletions rs/hang/src/catalog/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl Clock {
/// The wall-clock time of `pts` under this fixed mapping.
///
/// Exact down to the nanosecond; an instant finer than that (a 90 kHz tick) is floored.
/// Refuses a result past the JSON-safe range or one the system clock cannot represent.
pub fn wall_clock(&self, pts: moq_net::Timestamp) -> Result<std::time::SystemTime> {
/// Refuses a result past the JSON-safe range or the wall clock's 1970-2554 range.
pub fn wall_clock(&self, pts: moq_net::Timestamp) -> Result<moq_clock::Wall> {
let overflow = || crate::Error::TimestampOverflow(moq_net::TimeOverflow);
let wall_scale = self.wall.scale().as_u64() as u128;
let pts_scale = pts.scale().as_u64() as u128;
Expand All @@ -87,8 +87,8 @@ impl Clock {
let secs = u64::try_from(num / den).map_err(|_| overflow())?;
let nanos = (num % den).checked_mul(1_000_000_000).ok_or_else(overflow)? / den;
let since_moq_epoch = std::time::Duration::new(secs, nanos as u32);
// Windows' `SystemTime` cannot reach the furthest wall a catalog carries.
std::time::UNIX_EPOCH
// A catalog can name a wall beyond the clock's nanosecond range.
moq_clock::Wall::UNIX_EPOCH
.checked_add(std::time::Duration::from_millis(MOQ_EPOCH_UNIX_MILLIS))
.and_then(|moq_epoch| moq_epoch.checked_add(since_moq_epoch))
.ok_or_else(overflow)
Expand Down Expand Up @@ -171,28 +171,27 @@ mod test {
));
}

/// Regression: the furthest wall a catalog carries overflowed `SystemTime` on
/// Windows and panicked. Unix reaches it, so only Windows sees the error.
/// A JSON-safe catalog wall can still exceed Wall's nanosecond range.
#[test]
fn wall_clock_past_the_system_clock_is_an_error() {
fn wall_clock_past_the_wall_range_is_an_error() {
let wall = moq_net::Timestamp::new(MAX_SAFE_INTEGER, moq_net::Timescale::SECOND).unwrap();
let clock = Clock::new(wall).unwrap();
match clock.wall_clock(moq_net::Timestamp::ZERO) {
Ok(at) => assert!(at > std::time::UNIX_EPOCH + std::time::Duration::from_secs(MAX_SAFE_INTEGER)),
Err(err) => assert!(matches!(err, crate::Error::TimestampOverflow(_)), "{err}"),
}
assert!(matches!(
clock.wall_clock(moq_net::Timestamp::ZERO),
Err(crate::Error::TimestampOverflow(_))
));
}

#[test]
fn wall_clock_converts_across_timescales() {
let clock = Clock::new(moq_net::Timestamp::from_micros(1_000_000).unwrap()).unwrap();
let epoch = std::time::UNIX_EPOCH + std::time::Duration::from_millis(MOQ_EPOCH_UNIX_MILLIS + 1_000);
let epoch = moq_clock::Wall::UNIX_EPOCH + std::time::Duration::from_millis(MOQ_EPOCH_UNIX_MILLIS + 1_000);
assert_eq!(
clock.wall_clock(moq_net::Timestamp::from_millis(0).unwrap()).unwrap(),
epoch
);

let second = std::time::UNIX_EPOCH + std::time::Duration::from_millis(MOQ_EPOCH_UNIX_MILLIS + 2_000);
let second = moq_clock::Wall::UNIX_EPOCH + std::time::Duration::from_millis(MOQ_EPOCH_UNIX_MILLIS + 2_000);
assert_eq!(
clock
.wall_clock(moq_net::Timestamp::from_millis(1000).unwrap())
Expand All @@ -216,7 +215,7 @@ mod test {
/// Regression: the result was floored to the millisecond, dropping the sub-millisecond part.
#[test]
fn wall_clock_keeps_sub_millisecond_precision() {
let moq_epoch = std::time::UNIX_EPOCH + std::time::Duration::from_millis(MOQ_EPOCH_UNIX_MILLIS);
let moq_epoch = moq_clock::Wall::UNIX_EPOCH + std::time::Duration::from_millis(MOQ_EPOCH_UNIX_MILLIS);
let micros = |v| moq_net::Timestamp::from_micros(v).unwrap();
let nanos = std::time::Duration::from_nanos;

Expand Down
2 changes: 1 addition & 1 deletion rs/hang/src/catalog/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ mod test {
assert_eq!(archive.timescale, 1000);

// Archive PTS 2000 (ms) lands 2s after the wall epoch, whatever the track timescale.
let expected = std::time::UNIX_EPOCH
let expected = moq_clock::Wall::UNIX_EPOCH
+ std::time::Duration::from_millis(crate::catalog::MOQ_EPOCH_UNIX_MILLIS + 1_751_846_402_000);
assert_eq!(
clock
Expand Down
4 changes: 2 additions & 2 deletions rs/hang/src/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ pub struct Arrival {
pub timestamp: moq_net::Timestamp,
/// The arrival wall time, encoded in milliseconds since the MoQ epoch.
#[serde_as(as = "crate::snapshot::Wall")]
pub wall: std::time::SystemTime,
pub wall: moq_clock::Wall,
}

impl Arrival {
/// Pair a received media timestamp with the wall time it arrived.
pub fn new(timestamp: moq_net::Timestamp, wall: std::time::SystemTime) -> Self {
pub fn new(timestamp: moq_net::Timestamp, wall: moq_clock::Wall) -> Self {
Self { timestamp, wall }
}
}
Expand Down
39 changes: 31 additions & 8 deletions rs/hang/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@ impl<'de> DeserializeAs<'de, moq_net::Timestamp> for Millis {
}

pub(crate) struct Wall;
fn epoch() -> std::time::SystemTime {
std::time::UNIX_EPOCH + Duration::from_millis(crate::catalog::MOQ_EPOCH_UNIX_MILLIS)
fn epoch() -> moq_clock::Wall {
moq_clock::Wall::UNIX_EPOCH + Duration::from_millis(crate::catalog::MOQ_EPOCH_UNIX_MILLIS)
}
impl SerializeAs<std::time::SystemTime> for Wall {
fn serialize_as<S: serde::Serializer>(value: &std::time::SystemTime, serializer: S) -> Result<S::Ok, S::Error> {
let duration = value.duration_since(epoch()).map_err(serde::ser::Error::custom)?;
impl SerializeAs<moq_clock::Wall> for Wall {
fn serialize_as<S: serde::Serializer>(value: &moq_clock::Wall, serializer: S) -> Result<S::Ok, S::Error> {
let duration = value
.checked_duration_since(epoch())
.ok_or_else(|| serde::ser::Error::custom("snapshot wall is before the MoQ epoch"))?;
Millis::serialize_as(&duration, serializer)
}
}
impl<'de> DeserializeAs<'de, std::time::SystemTime> for Wall {
fn deserialize_as<D: serde::Deserializer<'de>>(deserializer: D) -> Result<std::time::SystemTime, D::Error> {
impl<'de> DeserializeAs<'de, moq_clock::Wall> for Wall {
fn deserialize_as<D: serde::Deserializer<'de>>(deserializer: D) -> Result<moq_clock::Wall, D::Error> {
epoch()
.checked_add(Millis::deserialize_as(deserializer)?)
.ok_or_else(|| serde::de::Error::custom("snapshot wall clock overflow"))
Expand All @@ -82,6 +84,27 @@ mod tests {
assert_eq!(serde_json::to_value(decoded).unwrap(), value);
}

#[test]
fn wall_range_and_epoch_are_checked() {
#[serde_with::serde_as]
#[derive(Debug, Serialize, Deserialize)]
struct Value {
#[serde_as(as = "Wall")]
wall: moq_clock::Wall,
}
let last_millis = (u64::MAX / 1_000_000) - crate::catalog::MOQ_EPOCH_UNIX_MILLIS;
let last = format!(r#"{{"wall":{last_millis}}}"#);
let value: Value = serde_json::from_str(&last).unwrap();
assert_eq!(serde_json::to_string(&value).unwrap(), last);
assert!(serde_json::from_str::<Value>(&format!(r#"{{"wall":{}}}"#, last_millis + 1)).is_err());
assert!(
serde_json::to_string(&Value {
wall: epoch() - Duration::from_nanos(1)
})
.is_err()
);
}

#[test]
fn shared_snapshots_roundtrip() {
roundtrip::<stats::Snapshot>(include_str!("../fixtures/stats-snapshot.json"));
Expand Down Expand Up @@ -188,7 +211,7 @@ mod tests {
let arrival = report.renditions["hd"].arrival.as_ref().unwrap();
assert_eq!(arrival.timestamp, moq_net::Timestamp::from_millis(30_000).unwrap());
assert_eq!(
arrival.wall.duration_since(epoch()).unwrap(),
arrival.wall.checked_duration_since(epoch()).unwrap(),
Duration::from_millis(175_184_640_000)
);
assert_eq!(report.renditions["hd"].stalled, Duration::from_millis(120));
Expand Down
Loading
Loading