memory: derive the L3 and L4 paths and citation ids from a track tag #108

Merged
JakeHillion merged 1 commits from jj/pxqtwqrulmxp into main 2026-07-28 18:25:49 +01:00
1 Commits
Author SHA1 Message Date
JakeHillion 7530203346 memory: derive the L3 and L4 paths and citation ids from a track tag
CI / nix (push) Successful in 6m11s
The `u` in `l3u`/`l4u` was spelled out inline everywhere it mattered:
two directory names in `nightly`, two output filenames in `mod`, two
filename parsers and two id builders across `l3`/`l4`/`doc`, and the
`USER-` prefix on archived documents. Adding a second track would mean
finding every one of those `format!`s and prefix checks.

A new `memory::layout` module owns every place the tag is spelled out --
directory names, filenames, filename parsers, prefix checks, and the
`l2-`/`l3{tag}-` citation ids -- and `PersonalityFile` gains
`track_tag()` and `stem()` to supply it. The match in `track_tag` is
exhaustive rather than a lookup table, so two tracks cannot collide on a
tag by construction. L2 is shared across tracks and so stays untagged.

Call sites pass `PersonalityFile::User.track_tag()` explicitly for now;
threading a `Track` through in place of the bare tag comes later in the
stack. Nothing about the names changes: `layout`'s first test pins the
user track's directories and filenames to the exact strings already on
disk, so a regression here fails loudly rather than silently writing to
a new path.

`PeriodTag` and `PeriodSpan` were the same struct in two modules and
both become aliases of `layout::Span`.

Test plan:
- CI
- The filename and id-format tests move into `layout`, which covers what
  the per-level copies did plus the cases they could not express: that a
  parser rejects the neighbouring level, and that track `t` does not
  claim track `u`'s files. 8 removed, 7 added, so `cargo test` goes
  181 -> 180 passing with the same 19 pre-existing calendar failures
  (those need a container runtime).
- `layout::user_track_names_match_the_established_layout` is the
  load-bearing one: it asserts `l3u`/`l4u` and
  `l3u-{first}-{last}.jsonl.zst` verbatim.
2026-07-28 17:43:32 +01:00