Expand description
The unit’s interfaces.lock (lock design §2): the line table that gives
every interface of a unit its number.
The file lives in the unit’s manifest directory, beside its ridl.toml,
one per unit, and only ridl lock writes it. Its form is a line table:
# interfaces.lock — written by ridl lock; do not edit by hand.
next 6
CruiseControl 1
LaneAssist 2 retired
LaneKeeping 3
DoorControl 4
service:veh.hvac.cabin 5- The first content line is
next N: N is greater than every number in the file, live or retired, and is never lowered.ridl lockallocates from N upward. The line is found by position — the first line the reader does not skip — so every later line is an entry, one keyednextincluded:nextis not a keyword, and an interface may be named so (plan decision PD-19). - Every later line is one entry,
Key number, with the wordretiredafter the number for a retired entry. Fields are separated by one space. An entry’s number never changes and no entry is ever removed (lock design §4): a rename rewrites the key in place, a retire adds the word. - The key is a declared interface’s catalog name, or
service:followed by the dotted name of the service whose inline shape the entry numbers (lock design §3). A catalog name is the interface’s source package path relative to the unit, then its name, joined by.(cluster.Speed); an interface of the unit’s root source package keeps its short name. Theservice:prefix is needed becauseinterface cabinandservice cabincheck clean together in one package.
The reader (parse) skips an empty line and every line whose first
non-blank byte is #, and trims trailing whitespace (plan decision PD-7);
everything else must parse. A git conflict marker line does not parse. The
writer (InterfaceLock::render) always emits the header, next N, and
the entries in number order, one \n after each line, so a rendered lock
parses back to the same table.
This module is pure text in, table out, and compiles without the fs
feature so the wasm32-unknown-unknown build carries the reader; only
read and [write] touch the filesystem. The compiler reports a
malformed file as RIDL-410 on the offending line (lock design §8): the
loader wraps the LockError this module returns, which is why the error
carries a byte range and no diagnostic code.
Structs§
- Interface
Lock - The parsed table.
- Invalid
Lock Key - Why a token is not a
LockKey. - Lock
Entry - One line of the table.
- Lock
Error - Why a text is not a lock file: the first malformed shape found, reading
top to bottom, and the byte range of the offending line — or the empty
range at 0 when the text is empty or has no
nextline (plan decision PD-3).
Enums§
- Lock
Edit Error - Why an in-memory edit cannot be applied.
- LockKey
- One entry’s key: which interface body the entry numbers.
- Merge
Outcome - What
ridl lock mergewrites to OURS (lock design §6).
Constants§
- FILE_
NAME - The file’s name inside the unit’s manifest directory.
- HEADER
- The first line of every written file. The reader ignores it like any other
#line; the writer and the merge driver both emit it.
Functions§
- merge
- A three-way merge over entries, not lines (lock design §6): the git merge driver’s whole computation, with no file access.
- parse
- Parses the text of an
interfaces.lock. - read
- The raw text of
dir/interfaces.lock, orNonewhen the file does not exist. Parsing is the caller’s, so a malformed file can be reported with its text (RIDL-410 needs the line). Any other I/O failure — a file that is not valid UTF-8 included — is the error. - write
- Writes
locktodir/interfaces.lock, replacing any existing file.