decisions DECIDED

43. Reading the clock is a page, setting it is a page you may write, proposing is an endpoint

Built 2026-07-30 (milestone 51 lane A: the two RTC drivers and the clock service). Concept note: notes/clock.md. The contract is crates/clock_proto.

Before this, SystemTime was the monotonic counter offset from UNIX_EPOCH, so the machine reported January 1970 plus uptime and nothing in the interface said so. The defect was never the missing hardware; it was that a caller could not tell a wrong answer from a right one, which is §42's rule on a second axis.

Wall clock is counter plus offset, and that is what protects Instant

Instant stays the raw monotonic counter: ambient, one instruction, readable at EL0 because the kernel opened CNTKCTL_EL1.EL0VCTEN (and scounteren.TM on RISC-V). Wall-clock time is counter + offset, and the offset is the only thing anyone ever writes.

The payoff is that adjusting the wall clock cannot perturb monotonic time, by construction rather than by discipline. Unix reaches for adjtime slewing partly because stepping the clock backwards breaks code that assumed it only moved forward. Here the counter is not in the write path at all, so a step is an offset write and Instant never sees it. Slewing for wall-clock readers' benefit becomes a policy the service may adopt rather than a correctness requirement. A test asserts the property directly (adjusting_the_wall_clock_leaves_the_monotonic_counter_alone).

Three authorities, three different objects, and only one of them is a message

So the ladder is the kernel's own and needed nothing new: no capability, Frame with READ, Frame with WRITE, Endpoint with WRITE. No new system call, no new method number, no new object type, and the authority a process holds is already introspectable, which is what caps prints.

Why set is memory and not a message, which is the one judgment call here. A process has exactly one blocking wait point: this kernel has no wait-any primitive and no threads sharing an address space (the constraint compositor.rs records, and the same one §26.5 declines to lift). So a design where set and propose were both messages would have needed two server processes, and the second would have held full set authority anyway, moving the problem rather than solving it. Making set a page write is not a workaround for that: "set the offset outright" already means writing the offset, and §33 settled the same shape for the compositor, whose authority is memory rather than messages. The alternative worth naming is a minted endpoint carrying a badge the server can read (§25's tracked later step), which would let one endpoint carry two authorities. It is not built, and this design does not need it.

Propose is deliberately not set, and the bounds are public

The service applies four rules, stated in the contract crate so they are host-tested in milliseconds and so a well-behaved proposer can predict the answer:

rule value why
sanity floor 2026-01-01 no machine running this code existed earlier; also the build-era anchor the NTS chicken-and-egg needs, chosen on purpose rather than discovered halfway through
sanity ceiling 2100-01-01 a clock attack pushes past a certificate expiry rather than nudging
max step forward 1 hour absorbs a machine that slept or an RTC set to local time; will not walk past an expiry in one step
max step backward 1 second moving forward skips instants nobody observed; moving backward makes instants happen twice, which is what breaks log ordering, cache expiries and build stamps

The asymmetry is the substance, not timidity, and it has its own test so a later tidying of the two constants into one has to mean it. Publishing the bounds costs nothing: the authority was never secrecy about them, it is that the proposer cannot write the page.

When the clock is unknown there is nothing to step from, so a plausible proposal is accepted outright. That is the bootstrap, not a hole: a machine that does not know the time holds no belief a step limit could protect, and the sanity window still applies.

An accepted proposal lands as state::SYNCED rather than state::SET, because "an external source I bounded" and "a human told me" are different provenance, and the difference is exactly what a caller weighing a certificate expiry wants.

The unknown state is a real state, and 1970 is not a time

clock_proto::state has four values and the first is UNKNOWN. A page nobody has published to is zero, and zero reads as unknown, so the honest answer is the default rather than something initialization has to remember. An RTC that is absent, or whose reading falls outside the sanity window, leaves the clock unknown; the service does not publish a value it does not believe.

For std this is where the rule bites hardest, because SystemTime::now() has no error channel. The only loud refusal available is a panic, and that is what an unknown clock gets, with a message naming which of the two causes it was (no capability, or no believable RTC). A program that never asks the time is unaffected. Recorded as a real limitation rather than a clean win: std has no way to represent "I do not know", so a program cannot ask before it asks. The readable form of the state lives one level down in clock_proto for anything that wants to check first.

Two drivers, because parity is a gate, and the binding chooses between them

arm,pl031 at 0x9010000 (one 32-bit register, seconds) on aarch64 virt; google,goldfish-rtc at 0x101000 (two 32-bit registers, nanoseconds, low first because it latches high) on riscv64 virt. Both are in the one portable clock binary on both ISAs, both take a base address and know nothing else (rule 2), and both are found through crates/device_tree_blob.

Discovery is by compatible, not by node name, and this is where that shortcut finally ran out: the aarch64 board calls the node pl031@9010000 and the RISC-V board calls its RTC rtc@101000, so no name prefix finds both. DeviceTreeBlob::node_reg_compatible (in crates/device_tree_blob since 2026-09-19) is new for this, and node_reg's own comment had predicted needing it. The kernel passes the binding to the service at spawn, so the driver picks its register layout from what the machine said rather than from target_arch. That matters concretely rather than theoretically: the VisionFive 2 is riscv64 and has neither device, so an ISA-keyed driver would compile clean and read garbage on the first real board.

What this lane deliberately did not do