roadmap BUILT

51. Wall-clock time, the date command, and an NTP service

Lane A built 2026-07-30 (the two RTC drivers and the clock service; DECISIONS §43, notes/clock.md). The machine knows what time it is, on both ISAs, and SystemTime is real. What the build settled that this block left open, and one place it went somewhere the block did not predict:

In brief. The machine does not know what time it is, and says so in a way that is easy to miss: SystemTime is the monotonic counter offset from UNIX_EPOCH, so it reports January 1970 plus uptime. Give it a real clock, a date command, and a network time client, and take the chance to put the authority in the right place.

Why it matters. Time is where a capability system gets to make a distinction Unix cannot afford to. Reading the clock is near-harmless; setting it is a genuine authority over certificate validation, log ordering, filesystem timestamps and build reproducibility. In Unix ntpd runs as root and may set the clock to anything. Here the network client should not be able to set it at all.

The starting position, which is honest but wrong

notes/std.md already records the caveat: "SystemTime is monotonic-since-boot, not wall-clock. No RTC, no NTP, so 'system time' honestly measures 'since this machine came up'." Differencing two SystemTimes gives a correct duration; any absolute reading is a fiction. It is also why file times are Unsupported in the std PAL, per that file: "there is no wall clock to interpret it against anyway". Milestone 47's mkdir/create work will want them, so this unblocks that.

The time source, and it is two drivers because parity is a gate

Verified from the DTB fixtures in crates/machine_discovery/tests/fixtures/, not assumed:

Platform Device Address
QEMU virt, aarch64 arm,pl031 0x9010000
QEMU virt, riscv64 google,goldfish-rtc 0x101000
VisionFive 2 its own RTC (board bring-up, milestone 16a) via DTB

Two small drivers, both discovered through the device_tree_blob package rather than hardcoded, both following rule 2 (a driver takes a base address and knows nothing else). Neither is large; the point is that shipping one and not the other is the bug rule 5 exists to catch.

The design: an offset, which makes NTP safe for free

Keep the split the code already has. Instant stays the raw monotonic counter, ambient and one instruction (see the §10 exception recorded in arch/aarch64/timer.rs and its riscv twin). Wall-clock time becomes counter + offset, and the clock service owns the offset.

§43 (reading the clock is a page, setting it is a page you may write) states the payoff. Unix needs adjtime slewing partly because stepping the clock backwards breaks things that assumed it only moves forward; here Instant never sees the adjustment, so a step is just an offset write. Whether to also slew for the benefit of wall-clock readers is then a policy choice the service can make, not a correctness requirement.

Where the authority sits

That attenuation is the milestone's demonstrable claim, and it is one Unix cannot make: a compromised NTP client here can lie within the service's bounds and can do nothing else. It cannot set the clock to 2038, and it holds no authority over anything but the network socket it was given.

date, the deliverable

Built 2026-07-31 (notes/date.md; components/src/date.rs, kernel::user::date_tests).

Reachable from a test, not from the prompt, and that is why this milestone is PARTIAL and not BUILT (found by calef, 2026-07-31, by typing date at script/server and getting "unknown command"). The binary is in the initrd and tested on both ISAs, but grant_plan::Prog knows only worker, budgeter, heeder and spinner, so the shell cannot spawn it. The lane deferred that as "milestone 31's manifest machinery", which is a defensible scope call that nonetheless leaves the command half of "the date command" undone. A program a user cannot invoke is not a command, and the status said otherwise until he checked. Being folded into the milestone 47 grammar lane, which owns grant_plan and is removing run: after which date at the prompt is exactly what he typed. A hundred lines, most of them comments, because the design had settled everything interesting first: read the page, add the counter, hand the number to calendar. Five formats, a fixed UTC offset in minutes, and an optional second line naming the clock's provenance, which renders clock_proto's four states for a person and is a distinction no Unix date can print. Three things the build is worth recording for:

Reads the wall clock and formats it. Timezone and calendar conversion are pure computation and belong in a host-tested library crate, not in the service (§14's rule about what compiles for the host). Setting the time is a separate verb with a separate capability, and date -s in one binary that does both is exactly the conflation this design refuses.

The library half is built (2026-07-30): crates/calendar, host-tested and Kani-proved, holds the civil-date arithmetic, the weekday and day-of-year, five formats and an RFC 3339 parser, and depends on nothing in this milestone. Eleven harnesses, ten of them over the full ten-thousand-year range. Two scope calls are recorded in notes/calendar.md rather than left ambiguous. A fixed UTC offset is in and the IANA tzdata is out (zone rules are a data-distribution problem, not a calendar one). There is no strftime, five named formats instead. The command itself still waits on the service. The lane also produced a verification finding worth more than the crate: a 64-bit division by 86,400 is what bounded model checking chokes on here, not the calendar, and the &str boundary costs more than the parser behind it (notes/verification.md).

NTP, and the chicken-and-egg worth recording before it is discovered

Buildable today: net_stack runs smoltcp, and NTP is UDP on port 123. Two honest problems:

  1. Plain NTP is unauthenticated and trivially spoofable. NTS (RFC 8915) is the answer, and it needs TLS, which needs certificate validation, which needs a roughly correct clock. The standard escape is a build-time "not before" timestamp plus the RTC's rough value, and it should be chosen deliberately rather than discovered halfway through.
  2. The RTC may be wrong or absent, so the service needs a defined state for "I do not know what time it is" rather than confidently reporting 1970. That state should be visible to readers, not papered over, which is the same rule §42 sets for filesystems: no silent degradation.

The wire format is built (crates/ntp_proto, notes/ntp.md). It has the 48-byte NTPv4 packet and the 1900-epoch fixed-point timestamp with a fixed era pivot for the 2036 rollover. It has the offset and delay arithmetic in modular form so an exchange across that rollover comes out right, and the seven response checks that are the whole of plain NTP's spoofing resistance. Host-tested and Kani-proved (the era pivot over all 4.2 billion seconds from 1970 to 2104; parse/serialise and the origin-nonce check over all 2^384 packets). Problem 1 above is recorded, not solved: the crate is unauthenticated NTPv4 and says so in its own documentation, NTS stays a separate decision, and the crate does not implement half of it.

The client is built (2026-07-31, components/src/ntp.rs, notes/ntp.md). It holds five capability slots and none of them is the clock page, so the block's claim above is now a fact the machine enforces rather than a design intention. an_ntp_client_holds_no_writable_clock_page gives the same binary the same five slots plus the exact address a setter maps the page at, and it faults. Four things the build settled or found:

The test server is a second role of the same binary holding READ on the endpoint the client holds WRITE on, so the client's network path is substituted at the capability boundary and its code has no test-only branch. What that leaves unproven is recorded rather than glossed: smoltcp, UDP and the NIC are milestone 30's to prove, and nothing in slirp answers UDP 123, so there is no offline real server to point a gate at.

The fork this exposes, which is bigger than the milestone

There is no timed wait anywhere in the kernel. The system call surface is EXIT, YIELD, INVOKE, CAP_DELETE, and sched.rs twice calls out its own "no-timeout limitation". So thread::sleep is a yield-spin, which is the correct implementation given what exists (it does not monopolize a core), but it keeps a thread runnable for the whole sleep and costs scheduler work proportional to duration.

Three candidate shapes, and this is a design fork to settle before building:

Worth separating clearly: reading time is ambient and harmless, blocking on time is a scheduler interaction and is the part that wants a capability.

Sequencing. The RTC drivers and the clock service are independent of the shell milestones and could start any time; date follows the service; NTP follows date and wants the network stack settled. The timed-wait fork is separable and should be decided on its own, since it serves more than this milestone. Effort: 3 lanes estimated (drivers plus service, date plus the calendar crate, NTP), noting estimates for unbuilt work are guesses on a history-calibrated scale.

Follow-on

Index row

the machine knows what time it is: two RTC drivers, the clock service (§43), crates/calendar, crates/ntp_proto, date, and an NTP client holding propose and not set. date prints the time at the interactive prompt on both ISAs, the clock delegated read-only by both boot paths. Continuous polling waits on the timed-wait kernel fork, which the block records as tracked separately