layout-mismatch

A directory holds an entry its declared layout does not name, or lacks one it requires.

Group
Code
Runs
Optional: run it with ur lint --rule layout-mismatch
Level
warning
Reads
Every file
Fix
None: whether the file moves or the layout changes is a design choice

Why

The [architecture.layouts] table in .ur/ur.toml says what each directory of a kind holds: each key is a glob of directories from the project's root, whose whole segments <name> capture the names of the directories they match, and each value is a table of entries, globs of the names such a directory may hold, a directory's ending in /, required, those it must hold, and except, globs of directories and files it leaves alone. In an entry, <name> stands for what the key captured, exactly, so targets/<target>/findings with <target>-[0-9][0-9][0-9][0-9].md keeps each target's findings named after it. A directory takes the first layout whose glob matches it, and is known by the files under it.

The fix, as Ur suggests it: name the entry as the layout says, move it, or add it to the layout's entries if the design allows it.

For agents

Before adding a file or directory, check [architecture.layouts] in .ur/ur.toml, and name it as its directory's layout says; never add an entry the layout does not name.

Example

.ur/ur.toml
[architecture.layouts."targets/<target>"]
entries = ["target.md", "{findings,runs}/"]
required = ["target.md"]

[architecture.layouts."targets/<target>/findings"]
entries = ["<target>-[0-9][0-9][0-9][0-9].md"]
targets/postgres/target.md
# postgres
targets/postgres/findings/postgres-0001.md
# A heap overflow in the session parser

Found by the fuzzer on the second run.
targets/postgres/findings/heap-overflow.md
# A heap overflow in the session parser

Found by the fuzzer on the second run.
targets/mysql/notes.md
# what to try next
What Ur prints
$ ur lint --rule layout-mismatch
warning[layout-mismatch]: `targets/mysql/notes.md` is not in the layout of `targets/<target>`, which holds `target.md`, `{findings,runs}/`
  --> targets/mysql/notes.md:1:1 not in the layout
  = step 1: .ur/ur.toml:1:1 the layout of `targets/<target>`
  = hint: name the entry as the layout says, move it, or add it to the layout's `entries` if the design allows it
warning[layout-mismatch]: `targets/mysql` lacks `target.md`, which the layout of `targets/<target>` requires
  --> targets/mysql/notes.md:1:1 in a directory that lacks an entry
  = step 1: .ur/ur.toml:1:1 the layout of `targets/<target>`
  = hint: name the entry as the layout says, move it, or add it to the layout's `entries` if the design allows it
warning[layout-mismatch]: `targets/postgres/findings/heap-overflow.md` is not in the layout of `targets/<target>/findings`, which holds `<target>-[0-9][0-9][0-9][0-9].md`
  --> targets/postgres/findings/heap-overflow.md:1:1 not in the layout
  = step 1: .ur/ur.toml:5:1 the layout of `targets/<target>/findings`
  = hint: name the entry as the layout says, move it, or add it to the layout's `entries` if the design allows it
0 clone classes and 3 `layout-mismatch` findings in 3 files

Try it in the playground →