notes

touch: create if absent, and now the mtime half

Milestone 47. The create half built 2026-08-22; the mtime half built 2026-08-24 (DECISIONS §112). The contract side is file_system_contract::file_system::CREATE (milestone 31 (a capability shell: designation is authorization) phase 2), GETMTIME, SETMTIME and SETMTIME_AT. The mtime verbs come from the mtime lane of milestone 47 (navigation and naming: cd, pwd, ls, mkdir, rm, paths, and environment), and all four names are provisional except CREATE. The builtin is Nav::touch in components/src/swish/navigation.rs, parsed by grant_plan::CommandLine::Touch into a TouchOperands.

What this does

touch <name> creates an empty file at <name> if it is not there (a no-op if it already is, whatever kind it is), then bumps its modification time to now.

touch -t <RFC-3339-instant> <name> does the same create-if-absent step, then sets the modification time to the instant you assert rather than to now: touch -t 2030-01-01T00:00:00Z report.txt backdates or postdates the name, deliberately, which is the ability DECISIONS §112 calls "the ability to lie about history."

A builtin, in mkdir's category rather than rm's, for both halves. Even -t takes no more than a directory capability (dir::WRITE for the bare form, dir::WRITE | dir::SET_MODIFICATION_TIME_AT for -t). So there is nothing to attenuate and nothing gained by confining it to a program with its own grant. mkdir already established the shape (file_system::MKDIR mints a name and hands the capability straight back); the create half is the same call with the handle closed instead of kept. There is nothing useful to do with a handle to an empty file the moment after making it. Setting the time is a second, separate wire request. It is resolved directly under the directory handle exactly as UNLINK's name is: neither mtime verb opens what it acts on.

Rights: DECISIONS §112, and why it needed a decision at all

touch does two different things to a timestamp, and the question milestone 47 left open for two days was whether they are the same authority. They are not. Setting a name's mtime to now is bounded by what the server itself observed: the value recorded is one nothing the caller supplied, the same way a WRITE's byte count is a fact rather than an assertion. Setting it to an arbitrary instant is unbounded: the caller can claim the file is older or newer than it has any reason to be, which matters for anything reasoning from mtime, backups included.

So:

Two independent precedents converge on this split rather than inventing it. POSIX's own utime() needs only write permission to set the current time and ownership to set an arbitrary one. This tree's own DECISIONS §43 already treats reading the wall clock as broadly grantable and setting it as a separate, more tightly held authority. touch's two behaviors are the same shape one level down, applied to a file's timestamp instead of the machine's clock. See design/decisions/0112-touch-mtime-authority.md for the full argument.

What "now" is, honestly

"Now" for SETMTIME is the wall clock. The FS server holds the clock page read-only, the same authority date holds (DECISIONS §43 (reading the clock is a page)), and reads it as date does: clock_contract::wall_nanoseconds(offset, monotonic_nanoseconds()). Every stamp the server writes comes from one function. That covers WRITE, CREATE, TRUNCATE, SETMTIME and the extended attribute verbs. The function returns the wall time as seconds and nanoseconds. When the reading is not strictly later than the previous stamp, it returns the previous stamp plus one nanosecond.

So a touch after a WRITE never lands earlier than the write. Two touches in sequence see strictly increasing times, which a make-style staleness check depends on. A clock that steps backward does not move a stamp backward. The wire carries whole seconds, so a stamp agrees with a date reading taken at the same instant to the second, except while a step backward holds it ahead.

Until the clock page reports a set clock, and when the server has no clock page, "now" is a counter that adds one per stamp. The server reads the counter as Unix seconds (see BUGS).

The wire: three verbs, and why not one

file_system_contract::file_system:

Three verbs rather than one with a "now or arbitrary" flag, because the rights differ per verb and file_system_contract::verb::TABLE (the table every caretaker's dispatch is built from) encodes one fixed needs_all per opcode. A single opcode would need dynamic, per-call rights outside that table's model. This is the same reasoning that gave rm (UNLINK) and the structural bound (RMDIR) two verbs instead of one that tries to do both.

SETMTIME_AT takes no range check on the seconds value. Any u64 is accepted, including one that predates this image or postdates the machine's own clock: asserting an impossible history is the same authority as asserting a merely surprising one, and this contract does not referee which lies are plausible.

-t's syntax: RFC 3339, not Unix's [[CC]YY]MMDDhhmm[.ss]]

grant_plan's parser does not interpret the -t operand's text at all; it only recognizes the -t flag and hands the following token, unparsed, to TouchOperands::at. Converting it to Unix seconds happens where the grant is made (Nav::touch in components/src/swish/navigation.rs). Its rfc3339_unix_seconds checks RFC 3339's grammar and hands the date and time of day to jiff, the crate date itself uses for the read side. date's own FMT_RFC3339 output is therefore a valid -t operand: touch -t "$(date ...)" name round-trips through this shell without either side inventing a format.

This is an earned divergence from Unix's compact -t [[CC]YY]MMDDhhmm[.ss] format, not an oversight. There is no existing parser for that format in this tree, and RFC 3339 is what date already emits. Building a second, redundant date grammar for one flag was not worth it. See BUGS.

EXAMPLES

$ touch report.txt
$ ls
  report.txt
$ touch report.txt
$ ls
  report.txt

The second touch is silent and changes nothing to the file's bytes. Its modification time still moves, which is the mtime half this section is about.

$ mkdir logs
$ touch logs
$ ls
  logs/

touch on a name that already exists as a directory is also a no-op for the create half (ls still just shows logs/). Its mtime still bumps, because mtime is part of what a node is, not a property files alone carry.

$ touch -t 2030-01-01T00:00:00Z report.txt
$ touch -t not-a-date report.txt
  -t needs an RFC 3339 instant, e.g. 2030-01-01T00:00:00Z

A malformed -t operand is refused before the create half runs, so a caller does not see a file appear and then learn its -t text was unusable.

Tests

crates/grant_plan and crates/swish host suites: touch and touch -t <instant> <name> both parse correctly (including the -template guard: a name that merely starts with -t is not the flag). touch is reserved from the program namespace like every other builtin, and both forms appear in help.

redoxfs_server's host suite (cargo test --manifest-path redoxfs_server/Cargo.toml --features hosttest) covers the rights logic directly against the in-process Server, no emulator. each_rung_of_the_ ladder_gates_exactly_its_own_verb isolates dir::READ (GETMTIME), dir::WRITE (SETMTIME) and dir::SET_MODIFICATION_TIME_AT (SETMTIME_AT, alongside WRITE) each against a handle that lacks only that one bit. setting_mtime_to_now_twice_observes_two_different_times_and_neither_is_the_callers_choice proves two bare touches in sequence never read back equal. setting_an_arbitrary_mtime_round_ trips_exactly_and_is_not_now proves the caller's value comes back byte-for-byte and that a following bare touch does not preserve it.

kernel::user::shell_navigation_tests, both ISAs, over the real wire (a real swish binary behind a real fs_subtree_caretaker in front of a real redoxfs_server):

Witnessed from the host by xtask's shell_navigation_landed for the create half, as before; the mtime probes are not (yet) independently witnessed from the host. See BUGS.

BUGS