# Standards and Conventions

> Peios Standards and Conventions (PSC): shared standards for version control, code, and documentation across Peios and its satellite projects.

---

# What Is PSC?

_Standards and Conventions / Introduction_

> Peios Standards and Conventions (PSC) is the home for shared standards and conventions across Peios and its satellite projects.

**Peios Standards and Conventions (PSC)** is the home for all standards and
conventions used across Peios and its satellite projects. It gives
contributors a shared reference for how to develop, maintain, and document
these projects, whether they are working on the operating system or on a
project that supports it.

## What PSC covers

PSC brings related standards together by subject:

- **PSC Git** defines how projects use Git for version control, including
  branching and how changes are prepared, reviewed, and integrated.
- **Code standards** define shared coding practices and conventions, with
  guidance for individual languages and projects where needed.
- **Documentation conventions** define how documentation is organized,
  written, and maintained, including writing style and the structure of
  specifications and technical reference manuals.

These subjects share one home so contributors can find the conventions
that apply to their work across project boundaries.

## Find a standard

Start with [Using Git](/psc/git-workflow/development-model.md) for the development model,
[Work Branches](/psc/git-workflow/work-branches.md) for task branches, and
[Commit Style](/psc/git-workflow/commit-style.md) for commit messages.

The technical writing and documentation guidance includes:

- [Documentation overview](/psc/documentation-overview/overview.md): the forms of Peios documentation
  and the purpose of each one.
- [Core Style](/psc/style/core-style.md): the writing rules shared by every form.
- [Conventions for Specifications and TRMs](/psc/conventions.md): how to
  structure and write specifications and technical reference manuals.

For code, start with [Coding Style](/psc/common-coding-rules/scope-and-precedence.md), then read
the [common formatting rules](/psc/common-coding-rules/formatting.md) and the
[language profiles](/psc/language-profiles/language-conventions.md). The guide also covers
engineering practices and tests.

---

# Overview

_Standards and Conventions / Documentation Overview_

> Peios is documented in seven forms (learn, man pages, command-line help, regman, evman, technical reference manuals, and specifications), each with its own reader, its own job, and its own place when two of them overlap.

Peios documentation comes in seven forms. Each one has a different reader
and answers a different question. Learn explains and help summarizes; each
of the other five forms is the authority for its own kind of fact.

| Form | Reader | Answers |
|---|---|---|
| **Learn** | Anyone getting oriented | Why does this exist, and how does it fit together? |
| **Man pages** | Users, administrators, and developers at the interface | Exactly what does this command, file, call, or function do? |
| **Command-line help** | Anyone at a prompt who needs a reminder | What does this program accept? |
| **regman** | Anyone reading or changing configuration | What does this registry key mean, and what values are valid? |
| **evman** | Anyone reading the event stream | What does this event, or this field, mean? |
| **Technical reference manuals** | Developers of one specific component | How does this component work inside? |
| **Specifications** | Anyone implementing or consuming a shared protocol or format | What must be true? |

## Learn

High-level, educational documentation. Learn is what you read when you want
to understand something: concepts, how the pieces fit, and guides that walk
through a task. Developer guides, such as how to package an application or
how to emit events, are learn, not reference.

Learn can describe an interface, but it is never the authority for one. Where
it touches a flag, a key, or an event, it links to the form that owns it.

## Man pages

Thorough technical documentation, still centered on the user. A man page is
where every flag, exit status, file, and environment variable is recorded,
including the edge cases learn leaves out. If you have forgotten something,
you read the man page.

Man pages are also the API reference: section 2 for system calls, section 3
for library functions.

Some overlap with learn is inevitable, and the set includes pages adopted
from other projects. Adopted pages are patched wherever Peios behaves
differently from upstream. Peios does not ship inaccurate documentation.

## Command-line help

The text a program prints for `--help`: one line for each command,
argument, and option, and a pointer to the man page. Help is a summary of
the man page, never a replacement for it, and the two must agree. The same
rules cover the version and error messages a program prints.

## regman

regman owns the documentation of every registry key and value: its type,
default, valid range, and what it applies to. Other forms do not document
configuration inline; they point at the regman page.

## evman

evman owns the documentation of every event and every event field. A field
with no evman definition is not part of the platform's vocabulary, and no
component is allowed to emit it.

## Technical reference manuals

Thorough systems documentation for the developers of one specific component:
its internal design, data structures, and behavior. A TRM describes one
implementation.

## Specifications

Specifications for the protocols and formats shared across Peios. A
specification states a contract that more than one party relies on.

The line between a TRM and a specification: if a second implementation, or a
consumer on the other side of the boundary, would need to know it, it belongs
in a specification. If it is true only of this implementation, it belongs in
the TRM. TRMs cite specifications rather than restating them.

## When forms overlap

Every fact has one authority:

- **Interface details** (flags, exit statuses, files, calls) belong to the man
  page. Help summarizes them and must agree with it.
- **Registry keys** belong to regman, and **events** to evman, without
  exception.
- **Shared contracts** belong to the specification, which wins over any TRM.
- **Learn** explains and links; it is never the source to quote.

---

# Publishing a Repository's Docs to Learn

_Standards and Conventions / Documentation Overview_

> Add a repository's docs/learn tree to the Learn site, and make each push that changes its documentation redeploy Learn.

Learn is built from the central `learn` repository and from a
`docs/learn/` tree in each component's repository. Follow these steps when
a repository first contributes pages, so that its documentation is
published and stays current.

## Before you start

- Lay out the repository's `docs/learn/` tree as Trail
  [merged trees](/trail/structuring-a-site/merged-trees.md) require: the same
  shelves, products, and containers as Learn, with identical metadata.
- Push the repository to GitHub.

## Add the repository to the site

1. In `learn/trail.toml`, add a `[[merge]]` table after the existing ones:

   ```toml
   [[merge]]
   repo = "https://github.com/peios/authd"
   dir = "docs/learn"
   path = "../authd/docs/learn"
   ```

   `repo` and `dir` are where Learn's deploy fetches the tree. `path` is
   the repository's checkout beside `learn/` in a workspace. Trail uses it
   when it exists, so `trail serve learn` shows local edits.

2. From the workspace root, build the combined site strictly:

   ```sh
   trail build learn --strict --out local/learn-site
   ```

   Fix any duplicate pages, mismatched containers, or broken links it
   reports.

3. Commit the change to `learn` and push it.

## Redeploy when its documentation changes

1. In the component's repository, add this file as
   `.github/workflows/update-learn.yml`:

   ```yaml
   name: Update Learn

   # Asks Learn to redeploy when this repository's documentation changes. The
   # same file goes in every repository that contributes to Learn.
   on:
       push:
           paths: ["docs/**"]

   permissions: {}

   jobs:
       dispatch:
           if: github.ref_name == github.event.repository.default_branch
           runs-on: ubuntu-latest
           steps:
               - run: gh api repos/peios/learn/dispatches -f event_type=docs-changed
                 env:
                     GH_TOKEN: ${{ secrets.LEARN_DISPATCH_TOKEN }}
   ```

   The file is the same in every repository. It runs only for pushes to
   the default branch that change `docs/`.

2. For a repository outside the `peios` organization, add a
   `LEARN_DISPATCH_TOKEN` repository secret. The `peios` organization
   provides the secret to its own repositories.

3. For a private repository, give Learn's `LEARN_READ_TOKEN` read access to
   its contents. Learn's deploy fetches the tree with that token.

## Check the result

Push a documentation change to the default branch. The repository's
**Update Learn** run succeeds, and a **Deploy to GitHub Pages** run starts
in `peios/learn`. When it finishes, the change is on learn.peios.org.

---

# Core Style

_Standards and Conventions / Style_

> The writing rules every form of Peios documentation shares, covering voice, word choice, spelling, capitalization, punctuation, numbers, formatting, page structure, procedures, and code examples.

These rules apply to every form of Peios documentation: learn, man pages,
command-line help, regman, evman, technical reference manuals, and
specifications. Each form has its own page that adds to them or adjusts
them, and where a form's page disagrees with this one, the form's page wins
for that form:

- [Learn](/psc/style/learn.md)
- [Man Pages](/psc/style/man-pages.md)
- [Command-Line Help and Errors](/psc/style/command-line-help-and-errors.md)
- [regman and evman](/psc/style/regman-and-evman.md)
- Specifications and technical reference manuals:
  [Conventions for Specifications and TRMs](/psc/conventions.md)

This page is the canonical source. If a rule is not written here or on a
form's page, it is not a Peios rule. When something comes up that no rule
covers, choose the clearest option for the reader and propose a rule.

## Voice and tone

**Be direct.** Say what something does, or what to do, in as few words as
possible. Lead with the point; put background after it, or link to it.

- Do: "Run `svctl restart netd` to apply the change."
- Don't: "In order to apply the change, it will be necessary to restart the
  netd service, which can be done using svctl."

**Use active voice.** Name who or what does the thing. Use passive voice
only when the actor is unknown or truly does not matter.

- Do: "The kernel rejects the request."
- Don't: "The request is rejected."

**Use present tense.** Documentation describes what the system does now.

- Do: "netd reads the configuration at startup."
- Don't: "netd will read the configuration at startup."

**Use the imperative for instructions.** Start the sentence with the verb.

- Do: "Open the Registry Editor."
- Don't: "You should open the Registry Editor." or "Please open the Registry
  Editor."

**Address the reader as "you"** in learn and in man page prose where a
person is the subject. Specifications and technical reference manuals
describe the system and do not address the reader; see their form pages.

**Don't use "we", "our", or "us".** The documentation speaks for Peios, not
for a team. Give recommendations directly.

- Do: "Use a group, not individual accounts, in the access control list."
- Don't: "We recommend using a group."

**Don't write about time.** Avoid "new", "now", "currently", "recently",
"soon", "in a future release", and "no longer". They go stale silently. When a
change in behavior matters to the reader, state the version it applies to.

**Don't condescend.** Avoid "simply", "just", "easily", "obviously", "of
course", and "it's easy to". If a step is not simple for the reader, the word
is wrong; if it is, the word is unnecessary.

**No humor, idioms, or cultural references.** They do not translate and they
date quickly.

- Do: "This setting has no effect until netd restarts."
- Don't: "This setting is a bit of a damp squib until netd restarts."

**Use contractions where they read naturally** in learn and man page prose:
"don't", "isn't", "you're". Don't use them in specifications or technical
reference manuals, and never contract a negative in a sentence that states a
requirement or a warning: "Do not remove the key", not "Don't remove the key".

## Sentences and paragraphs

**Keep sentences short.** Aim for under 25 words. Split a sentence that
carries two ideas into two sentences.

**Keep paragraphs short.** One idea per paragraph; three or four sentences is
usually enough. A paragraph that needs a fifth sentence often wants to be a
list.

**Put the condition before the instruction.** The reader should know whether
a sentence applies to them before they act on it.

- Do: "If the service is running, stop it first."
- Don't: "Stop the service first if it is running."

**Keep "that" when it helps the reader parse the sentence.** "Check that the
key exists", not "Check the key exists".

**Make every pronoun unambiguous.** If "it" or "this" could refer to two
things, name the thing.

- Do: "The token carries the user's SID. The kernel compares the SID with
  each access control entry."
- Don't: "The token carries the user's SID. It compares it with each entry."

**Avoid noun stacks.** Break up chains of three or more nouns.

- Do: "the cache for registry layer metadata"
- Don't: "the registry layer metadata cache"

**Avoid "there is" and "there are" openings.** Start with the subject.

- Do: "Three layers apply to every key."
- Don't: "There are three layers that apply to every key."

## Spelling and word choice

**Use US English spelling**: "behavior", "color", "initialize", "license"
(noun and verb), "canceled", "catalog". Identifiers, quoted output, and names
of external standards keep their own spelling.

**Prefer the short, common word.**

| Use | Instead of |
|---|---|
| use | utilize, leverage |
| start | initiate, commence |
| end, stop | terminate (unless it is the literal name of an operation) |
| help | facilitate, assist |
| about | approximately, in regard to |
| to | in order to |
| if | in the event that |
| because | due to the fact that |
| can | is able to |
| need, must | is required to |
| enough | sufficient |

**Don't use Latin abbreviations.** Write the English.

| Use | Instead of |
|---|---|
| for example | e.g. |
| that is | i.e. |
| and so on (or end the list) | etc. |
| through, by using | via |
| compared with, or | vs. |
| namely | viz. |
| about (for dates) | circa, ca. |

**Use "can", "might", and "must" for their one meaning each.**

- "can" is ability: "You can grant the privilege to a group."
- "might" is possibility: "The request might time out."
- "must" is necessity: "The value must be a string."
- Don't use "may" in prose. It is ambiguous between permission and
  possibility. Specifications use **MAY** as a defined keyword; outside that
  use, write "can" or "might".

**Use "select" for choosing anything in a graphical interface**, whether by
mouse, keyboard, or touch. Don't use "click", "tap", "hit", or "press" for UI
elements. Use "press" only for keys on a keyboard.

**Use "enter" for typing a value into a field**, and "type" only when the
reader types characters that are not submitted.

**Use "turn on" and "turn off"** for toggles and features. Don't use
"enable" and "disable" in learn prose; keep them where they are the literal
name of an option, flag, or registry value.

**Spell out an acronym on first use on each page**, followed by the acronym
in parentheses: "security identifier (SID)". After that, use the acronym.
Acronyms every reader knows (CPU, URL, USB, HTTP) need no expansion.

**Choose "a" or "an" by pronunciation.** "a SID" (said as a word), "an ACL"
(said as letters), "an HTTP request". The [word list](/psc/style/word-list.md)
records the decided form for Peios terms.

**Pluralize acronyms without an apostrophe**: "SIDs", "ACLs", "PIDs".

**Use Peios terms as the word list defines them.** Where Peios uses a word
that means something different in Windows, Linux, or elsewhere, the
[word list](/psc/style/word-list.md) is the authority.

## Inclusive language

**Use "they" for a person of unknown gender**, including the singular.
Better still, address the reader as "you" or name a role: "the
administrator".

**Don't use terms with harmful associations** when a neutral term is equally
precise.

| Use | Instead of |
|---|---|
| allowlist, denylist | whitelist, blacklist |
| primary, replica | master, slave |
| main | master (branch) |
| placeholder, sample value | dummy value |
| confidence check, quick check | sanity check |
| stop responding | hang (of a program, in prose) |

A literal identifier keeps its literal name. If an upstream command, flag, or
field uses one of these words, write it exactly as it is, in code
formatting.

**Don't refer to ability or disability unless it is the subject.** "Turn on
the screen reader", not "for blind users, turn on the screen reader", unless
the page is about accessibility.

## Capitalization

**Titles use title case.** A title is the name of a page, topic, shelf,
anthology, book, product, or chapter, wherever it is set: frontmatter
`title:`, a `trail.toml` `title`, or a man page `NAME` header. Capitalize the
first and last words and every major word. Lowercase these unless they are
the first or last word:

- articles: a, an, the
- coordinating conjunctions: and, but, or, nor, for, so, yet
- prepositions of any length: to, of, in, on, at, by, for, from, with,
  about, between, through, without
- "to" in infinitives and "as" in any role

So: "Developing for Peios", "Writing Policy for the Network Firewall", "What
an Event Is".

**Headings within a page use sentence case.** Capitalize the first word and
proper nouns only.

- Do: "## Choosing a registry layer"
- Don't: "## Choosing a Registry Layer"

**Lowercase common nouns, even important ones.** "access token", "security
descriptor", "registry key", "service". Capitalize product and component
names: "Peios", "GXWI", "Registry Editor" (the application). Components
whose names are written in lowercase keep it, even at the start of a
sentence: "netd", "peinit", "regman". Rephrase if that reads badly.

**Write identifiers exactly as they are.** Code formatting keeps the case:
`svctl`, `Machine\System\KMES`, `KACS_ACCESS_DENIED`.

**After a colon, lowercase the next word** unless it is a proper noun or
begins a complete sentence.

**Expanded acronyms are lowercase** unless the expansion is a proper noun:
"access control list (ACL)", not "Access Control List (ACL)".

## Punctuation

**Use the serial (Oxford) comma**: "users, groups, and services".

**Use em dashes sparingly, with a space on each side**:
"the kernel — not the service — makes the decision". Prefer commas,
parentheses, or a second sentence. Never
use more than one pair in a sentence. Write the em dash as the character
`—`, not as `--`.

**Use an en dash for ranges in tables and compact contexts**: "0–65535",
"pages 4–9". In running prose, write "from 0 through 65535".

**Use hyphens for compound modifiers before a noun**: "a read-only key", but
"the key is read only". Don't hyphenate after an adverb ending in "-ly": "a
widely used flag".

**Put commas and periods inside closing quotation marks** in prose. Text the
reader types or sees literally goes in code formatting, not quotation marks,
so its punctuation is never in doubt.

**Don't use exclamation points.**

**Don't use "and/or".** Write "A, B, or both".

**Don't use the ampersand** in prose or titles, except in a literal name.

**Use semicolons sparingly.** Usually a period is clearer.

**End list items with a period only when they are complete sentences.** In a
single list, either every item is a sentence or none is.

**Use one space after a period.**

**Use straight quotes and apostrophes** (`"` and `'`), not typographic ones.
Use a normal space and a normal hyphen, and no zero-width characters. They
render the same and search differently.

## Numbers and units

**In prose, spell out zero through nine and use numerals for 10 and above.**
Exceptions, which always take numerals:

- any technical quantity: sizes, counts in a specification, limits, ports,
  versions, offsets, durations ("3 seconds", "a 2-byte field")
- anything with a unit or symbol ("4 KiB", "5%")
- any number in a table, list of values, step, or code example
- a number that sits next to another number in the same sentence ("between
  2 and 12 entries")

**Don't start a sentence with a numeral.** Rephrase or spell it out.

**Use commas in numbers of five or more digits** in prose: "65,535", but
"4096". Never in code, values, hexadecimal, or anything the reader types.

**Use IEC binary prefixes for binary quantities**: KiB, MiB, GiB, TiB. Use
KB, MB, and GB only for decimal quantities, such as disk capacity as sold or
network throughput. Put a space between the number and the unit: "64 KiB",
"100 ms". Percentages take no space: "5%".

**Write hexadecimal with a `0x` prefix and uppercase digits** in prose and
tables: `0x1F`, `0xC0000022`. Code examples follow the code's own style.

**Write dates as "October 15, 2026"** in prose. Use ISO 8601 (`2026-10-15`,
`2026-10-15T08:30:00Z`) in tables, frontmatter, logs, and anything machine
read. Don't write dates as `15/10/2026` or `10/15/2026`.

**Write times in 24-hour form with a time zone** where one matters: "14:30
UTC".

## Formatting text

**Use code formatting for anything literal**: commands, flags, file names
and paths, registry paths and value names, event and field names,
identifiers, data types, constants, environment variables, and values the
reader enters or sees.

- Do: "Set `LogLevel` under `Machine\System\Network` to `3`."
- Don't: "Set LogLevel under Machine\System\Network to 3."

Code spans are not prose. Don't translate them, inflect them, or split them:
`size_installed`, not "size installed" or "`size_installed`s". Write "the
`--force` flag", "each `Precedence` value".

**Use bold for UI elements the reader acts on**, written exactly as they
appear: "Select **Apply**." Bold also marks the term being defined in a
definition list. Use it sparingly for anything else.

**Use italics only for a placeholder in prose** ("replace *name* with the
service's name") and for the titles of external books. Don't use italics
for emphasis; restructure the sentence instead.

**Write keyboard keys with a capital and join combinations with `+`**:
<kbd>Ctrl</kbd>+<kbd>C</kbd>, <kbd>Enter</kbd>, <kbd>Super</kbd>.

**Write placeholders in code as `<name>`**: lowercase, hyphenated, in angle
brackets: `svctl status <service-name>`. Explain each placeholder directly
after the example that uses it. Optional parts go in square brackets:
`[--verbose]`.

## Links

**Make the link text say where it goes.** The text should make sense read
on its own, as screen readers present it.

- Do: "Check the term in the [word list](/psc/style/word-list.md)."
- Don't: "To check the term, [click here](/psc/style/word-list.md)."

**Use `~` page references for links within the site**, never a pasted URL.
Trail checks them at build time.

**Link the first useful mention on a page**, not every mention.

**Don't use bare URLs in prose.** Give the link a name.

**Don't refer to position.** Avoid "above", "below", "the previous section",
and "the following". Name or link the thing instead: "the table of exit
statuses". The one exception is a sentence that directly introduces a list,
table, example, or set of steps.

## Page structure

**Every article has frontmatter with `title` and `description`.** Articles
in topics also carry `type`.

- `title` names the subject in title case. "Registry Layers", not "How
  Registry Layers Work" or "About Layers".
- `description` is one sentence saying what is on the page, naming the
  specific things it covers. It is what search results and link previews
  show. Don't restate the title.
- `type` is `concept` (explains how something works or why), `how-to`
  (walks through a task), or `reference` (lists facts to look up). Choose the
  one that describes most of the page; if a page is evenly two types, split
  it.

**Start with the point.** The first paragraph says what the page is about
and why the reader cares. Don't open with a heading; the title is already
there. Don't repeat the title as a heading.

**Use `##` for top-level headings and don't skip levels.** Use `###` only
under a `##`, and avoid `####`; a page that needs it should be split.

**Make headings short and specific.** No end punctuation, no code-only
headings unless the page is a reference to that identifier. Don't put two
headings in a row with no text between them.

**Wrap prose at 78 columns** in the source. Tables, code blocks, and lines
dominated by a link are exempt. A one-word change then produces a one-line
diff.

## Lists

**Use a bulleted list for items in no particular order** and a numbered
list for a sequence or a ranking.

**Introduce every list** with a sentence or fragment ending in a colon.

**Keep items parallel.** Every item starts with the same part of speech:
all verbs, all nouns, all complete sentences.

**Capitalize the first word of every item.**

**Keep lists short.** Two to seven items. A list with one item is a
sentence; a list with more than seven usually wants grouping, a table, or
subheadings.

**Use a list with bold lead-ins** when each item needs a label and a short
explanation:

- **Machine layer.** Settings that apply to every user.
- **User layer.** Settings that apply to one account.

## Tables

**Use a table when items share two or more attributes.** A list of names
with one description each is a list, not a table.

**Introduce every table** with a sentence.

**Give every table a header row.** Header cells use sentence case.

**Don't leave a cell empty.** Write "None", "Not applicable", or `—` (an em
dash alone means "none") and use that choice consistently within the table.

**Keep cells short.** If a cell needs more than one sentence, the content
probably belongs in prose with a heading.

## Procedures

**Number the steps of a procedure that has two or more steps.** A
single-step procedure is a sentence, not a list.

**Put prerequisites before the first step**, as a list headed by a short
sentence: "Before you start:" or a `## Before you start` heading.

**Write one action per step.** Two very short actions on the same screen
can share a step: "Select **Users**, then select **Add**."

**Say where before what.** "In the Registry Editor, select
**Machine**." The reader finds the place first, then acts.

**Start each step with the verb**, or with the location then the verb.

**State the result when it is not obvious**, as the last sentence of the
step or as a new step: "The service restarts and its status changes to
**Running**."

**Keep procedures to 10 steps or fewer.** Split a longer one into
procedures with their own headings.

**Put optional steps in the step itself**: "Optional: set a description."

## Code examples

**Every example works.** Copy it, run it, and it does what the text says.
Don't publish an example that has not been run against the version of
Peios the page describes.

**Tag every fenced block with its language**: `sh`, `c`, `rust`, `go`,
`toml`, `json`, and so on. Use `text` for output and for anything with no
language.

**Write shell commands without a prompt.** The copy button copies the whole
block, and a `$` breaks the pasted command.

```sh
svctl restart netd
```

**Put output in a separate `text` block** after the command, introduced by
a sentence such as "The output looks like this:".

**Show only what the example needs.** Cut unrelated lines and mark the cut
with a comment in the example's language.

**Use the placeholder rules in code**: `<service-name>`, never `foo`,
`bar`, or `example123`. Use realistic sample values where a placeholder
would make the example harder to follow, and use the reserved example
ranges: `example.com`, `192.0.2.0/24`, `2001:db8::/32`.

**Introduce every example** with a sentence saying what it does, and explain
anything non-obvious after it.

## Admonitions

Admonitions interrupt the reader. Use them only when the text would be
missed or misread without one, and never two in a row. Each type has one
job:

| Type | Use for |
|---|---|
| `> [!NOTE]` | An aside worth knowing that doesn't belong in the flow. |
| `> [!TIP]` | A better or faster way to do what the page describes. |
| `> [!IMPORTANT]` | Something a reader who skims will regret missing. |
| `> [!WARNING]` | Something that will go wrong if the reader ignores it. |
| `> [!CAUTION]` | Something that will go irreversibly wrong, such as data loss or lock-out. |

**State the consequence and the action.** "Removing this key locks every
account out of sign-in. Export the key before you change it."

**Don't use an admonition to hold ordinary content** that happens to be
important. If everything on a page is important, nothing is.

## Images and diagrams

**Use a diagram when a relationship is easier to see than to read**: a
flow, a hierarchy, a state machine. Don't use one to decorate.

**Give every image alt text** that says what it shows, not what it is:
"The token passes the DACL check, then the SACL check", not "Diagram".

**Don't use screenshots for anything the reader could copy.** Show commands,
output, and code as text.

**Crop screenshots to the relevant part of the window** and don't include
personal data.

## Sources

The rules on this page are based on the
[Microsoft Writing Style Guide](https://learn.microsoft.com/style-guide/welcome/)
and, for man page conventions, on
[man-pages(7)](https://man7.org/linux/man-pages/man7/man-pages.7.html).
They are restated here so that this page is the one place to look. Where
this page and either source differ, this page is correct for Peios.

---

# Word List

_Standards and Conventions / Style_

> How Peios documentation spells, capitalizes, and uses its own terms and common technical words, including logon and sign in, set up, back up, principal, token, and registry key, value, and layer.

This list records the decided form of words that Peios documentation uses
often or that are easy to get wrong. Where a term means something different
in Windows, Linux, or another project, the meaning here is the one Peios
documentation uses. Add to the list whenever a question about a word is
settled.

## Peios terms

| Term | Use | Notes |
|---|---|---|
| Peios | Peios | Not "PeiOS", "PEIOS", or "peios" in prose. |
| access control list | access control list (ACL) | "an ACL". |
| access token | access token, token | "token" alone once the context is clear. |
| principal | principal | Any entity that can be granted access: a user, a group, a service, or the machine. Not a synonym for "user". |
| registry key | key | A node in the registry tree. Not "folder". |
| registry value | value | A named, typed piece of data in a key. Not "entry" or "setting" when the value itself is meant. |
| registry layer | layer | One source of registry data that is merged with others. |
| discretionary access control list | discretionary access control list (DACL) | "a DACL". |
| logon frontend | logon frontend | A program a person signs in through, such as sshd or the console sign-in, which then asks authd for a logon. authd performs the logon; the frontend handles the sign-in. Not "login frontend". |
| logon | logon (noun and adjective) | The system creating a logon session and token for a principal: "logon session", "logon type", "logon SID", "each logon". A logon needs no sign-in; services and scheduled jobs get logons too. Not "login". There is no verb: the system "creates a logon", it does not "log the user on". |
| security descriptor | security descriptor (SD) | "an SD". |
| security identifier | security identifier (SID) | "a SID". |
| system access control list | system access control list (SACL) | "a SACL". |

## General terms

| Term | Use | Notes |
|---|---|---|
| afterwards, towards | afterward, toward | Also forward, backward, upward, and downward. No final "s". |
| back up, backup | back up (verb), backup (noun and adjective) | "Back up the key." "Restore the backup." |
| log in, login, log on | Don't use, except in literal names such as the `login` program. | Use "sign in" for providing credentials and "logon" for what the system creates. |
| set up, setup | set up (verb), setup (noun and adjective) | "Set up the network." "The setup program." |
| shut down, shutdown | shut down (verb), shutdown (noun and adjective) | |
| sign in, sign-in | sign in (verb), sign-in (noun and adjective) | Providing credentials to start a logon, by a person or a client acting for one: "Sign in to the desktop." "The sign-in screen." "An SSH client signs in with a key." A program using its own stored credentials does not sign in; it gets a logon. |
| sign out, sign-out | sign out (verb), sign-out (noun and adjective) | Not "log off" or "log out". |
| startup, start up | startup (noun and adjective), start (verb) | "At startup." "Start the service." Avoid "start up" as a verb. |
| file name | file name | Two words, except as a literal identifier. |
| home folder | home directory | Use "directory" for file system paths throughout. |
| command line | command line (noun), command-line (adjective) | |
| run, execute | run | "execute" only for the literal permission or operation. |

---

# Learn

_Standards and Conventions / Style_

> How to write learn pages, the educational form of Peios documentation, covering the three page types, titles, page openings, references to prior art, how-to structure, linking to the forms that own each fact, and when a page should be split.

Learn is the educational form of Peios documentation. It is what a reader
opens to understand something: how a part of Peios works, why it is built
that way, and how to get a task done with it. Everything in
[Core Style](/psc/style/core-style.md) applies; this page adds the rules specific to
learn.

## Who learn is for

Learn is written for a reader who is new to the subject, not new to
computers. Assume they can use a terminal and read a configuration file.
Don't assume they know any other operating system: every page has to make
sense to a reader who has used neither Windows nor Linux.

Address the reader as "you". Use contractions where they read naturally.
Explain the reason behind a rule or a design decision whenever the reader
would otherwise have to take it on trust.

## Learn explains; other forms own the facts

Learn is never the authority for an interface detail. When a learn page
touches a flag, a registry value, or an event, it says what the reader needs
for the task in hand and links to the form that owns the full detail:

- **Commands, files, system calls, and library functions:** the man page.
  Refer to it by name and section, as `svctl(8)`.
- **Registry keys and values:** the regman page. Give the path, as
  `Machine\System\Network`.
- **Events and fields:** the evman page. Give the event or field name, as
  `kacs.audit.access.checked`.
- **Shared protocols and formats:** the specification section.
- **How one component works inside:** its technical reference manual.

Show the one or two flags or values a task needs. Don't reproduce an option
table, a list of every value under a key, or every field of an event; those
go stale in the copy and stay correct in the original.

Don't use the specification keywords **MUST**, **SHOULD**, or **MAY** in
learn. A learn page that needs to state a requirement links to the
specification that makes it.

## Page types

Every learn article is one of three types, set in its `type:` frontmatter.
Choose the type before writing; a page that tries to be two types does
neither well.

| Type | Answers | Title form | Example title |
|---|---|---|---|
| `concept` | How does this work, and why? | Noun phrase naming the subject | Logon Sessions |
| `how-to` | How do I get this done? | Gerund phrase naming the task | Configuring Network Profiles |
| `reference` | What are the values or options? | Noun phrase naming the set | Logon Types |

### Concept pages

A concept page explains one idea. Start with what the thing is and why it
exists, in two or three sentences, before any detail.

Use a diagram when the idea is a flow, a hierarchy, or a set of states. Keep
procedures out of concept pages; link to the how-to page instead.

### How-to pages

A how-to page gets one task done. Use this structure:

1. **The goal.** One or two sentences saying what the reader will have
   achieved and when they would want to.
2. **Before you start.** Prerequisites as a list: required privileges,
   packages, and anything that must already be configured. Leave the
   section out if there are none.
3. **The steps.** A numbered procedure, following the procedure rules in
   Core Style. Use subheadings when the task has distinct stages, each with
   its own procedure.
4. **Check the result.** How the reader confirms it worked: a command and
   its expected output, or what they will see.
5. **See also.** Optional. Two to five related pages.

Write for the common case. Put variations after the main procedure under
their own headings, rather than branching inside the steps.

### Reference pages

A reference page in learn collects facts that support understanding: the
set of logon types, the well-known SIDs, and the privileges and what each one
allows. It is not an interface reference; that belongs to man, regman,
and evman.

Open with one paragraph saying what the set is and how it is used, then
present it as a table or a list with bold lead-ins. Sort entries in the
order a reader is most likely to look for them: alphabetical by default,
numeric where the values are numbers.

## Openings

The first paragraph of every learn page says what the page covers and why
the reader would care, in plain terms. It is the paragraph a reader uses to
decide whether they are on the right page.

- Do: "A security descriptor records who owns an object and who can do what
  to it. Every access check Peios makes reads one, so understanding them
  explains most access-denied errors you will meet."
  <!-- lint-disable-next-line spelling -->
- Don't: "In this article, we will discuss logon sessions."

## Prior art

The opening can orient the reader by pointing to something they have almost
certainly met: a Windows or Linux equivalent, or a Peios concept covered
elsewhere. One or two sentences are enough to say "this is like that", and
where the likeness stops if that would otherwise mislead.

- Do: "If you have used Windows, a security descriptor will be familiar:
  Peios uses the same model of an owner, a discretionary access control list,
  and a system access control list."

After the opening, the page stands alone. Explain Peios in its own terms,
and don't refer to other operating systems or alternative software again. A
reader who skipped the comparison, or never knew the system it names, has
to be able to follow everything that comes after it.

- Do: "A deny entry takes effect only if it comes before any entry that
  grants the same access."
- Don't: "As on Windows, a deny entry takes effect only if it comes before
  any entry that grants the same access."

Software that Peios ships or interoperates with is not prior art. A how-to
page about configuring sshd names sshd throughout.

## Size and splitting

Keep a page readable in about 10 minutes. Split a page when:

- it covers two ideas that a reader could want separately,
- a how-to has become two tasks, or
- it needs a heading deeper than `###`.

Give each topic a clear scope and order its articles so a reader can go
through them in sequence: concepts first, then how-to pages, then
reference.

## Links and related pages

Link the first useful mention of another Peios concept to its page. Use
`related:` frontmatter for two to four pages a reader is likely to want
next. End a page with a **See also** section only when the related pages
need a sentence of explanation each; otherwise `related:` is enough.

## Examples

Use realistic examples drawn from a real Peios system: real paths, real
service names, real output. Every command must work as written on the
version of Peios the page describes. When an example depends on earlier
state, such as a service being installed, say so in the text before it.

---

# Man Pages

_Standards and Conventions / Style_

> How to write Peios man pages, covering sections, the header and NAME lines, the required section order, roff formatting conventions, the CONFIGURATION, SECURITY, and EVENTS sections, API pages, and patching pages adopted from upstream.

Man pages are the thorough technical reference for everything a user,
administrator, or developer touches directly: commands, daemons, files,
system calls, and library functions. A man page records every flag, exit
status, file, environment variable, and error, including the edge cases
learn leaves out. [Core Style](/psc/style/core-style.md) applies to the prose; this page
adds the structure and formatting rules of the form.

## Where pages live

Each component keeps its man pages in its own repository, at
`man/<name>.<section>`, beside the code they describe. A change to the
behavior and the change to its page go in the same commit.

Pages are written in roff, using the `man(7)` macros (`.TH`, `.SH`, `.TP`,
`.B`, `.I`, `.BR`, and so on). Don't use the `mdoc(7)` macros.

## Sections

Put each page in the section that matches what it documents:

| Section | Contents |
|---|---|
| 1 | Commands any user can run |
| 2 | System calls, including Peios kernel interfaces |
| 3 | Library functions, including libpeios |
| 4 | Device and special files |
| 5 | File formats and configuration files |
| 7 | Overviews, conventions, and miscellaneous topics |
| 8 | Administration commands and daemons |

A command that only an administrator can usefully run goes in section 8,
even if any user can start it.

## The header and NAME lines

The `.TH` line gives the page name in uppercase, the section, the date of
the last change to the page's content in ISO 8601 form, and the source as
`Peios` followed by the package name and version:

```text
.TH NET 1 2026-09-14 "Peios netd 0.1.1"
```

Leave out the fifth argument; the formatter supplies the standard manual
title for the section.

The NAME section is one line: the name, an escaped dash, and a description
in lowercase with no final period. The description is what `apropos` and
`whatis` show, so make it specific.

```text
.SH NAME
net \- inspect and control the Peios network manager
```

## Section order

Use these sections, in this order, and only those that apply. Section
headings are in uppercase.

| Section | Required for | Contents |
|---|---|---|
| NAME | All | One line, as described in the header and NAME rules. |
| SYNOPSIS | All | Every form of invocation, or the declarations a program uses. |
| DESCRIPTION | All | What it is and what it does, starting with the common case. |
| COMMANDS | Commands with subcommands | Each subcommand, as a tagged paragraph. |
| OPTIONS | Commands with options | Every option, as a tagged paragraph. |
| CONFIGURATION | Programs that read the registry | The registry keys read, pointing to regman. |
| SECURITY | Anything that checks access | The rights, privileges, and descriptors involved. |
| EXIT STATUS | Sections 1 and 8 | Every exit status and what it means. |
| RETURN VALUE | Sections 2 and 3 | What the call returns on success and failure. |
| ERRORS | Sections 2 and 3 | Every error value and the condition that produces it. |
| ENVIRONMENT | Anything that reads environment variables | Every variable and its effect. |
| FILES | Anything that reads or writes files | Every path and what it holds. |
| SIGNALS | Daemons | Every signal handled and its effect. |
| EVENTS | Anything that emits events | The event types emitted, pointing to evman. |
| NOTES | Optional | Details that matter but fit nowhere else. |
| BUGS | Optional | Known defects that a user is likely to meet. |
| EXAMPLES | Commands beyond the trivial | Worked invocations with explanation. |
| SEE ALSO | All | Related pages. |

A page that needs a section not in this list can add one, placed where it
reads best. Keep its heading short and in the same style, such as
READINESS or MULTICALL NAMES.

## Writing the sections

**SYNOPSIS** shows syntax, not explanation. Literal text is bold, arguments
the reader replaces are italic, and optional parts are in square brackets.
Put each form of a command with subcommands on its own line.

**DESCRIPTION** opens with a sentence saying what the program does, with the
program's name as its subject: "**net** is the stateless operator client for
**netd**(8)." Describe behavior in the present tense. Address the reader as
"you" only where a sentence is about what the reader does.

**OPTIONS** documents every option. For each one, give:

- the short and long forms, and the argument it takes,
- what it does, including its default when not given,
- how it interacts with other options, and
- any right or privilege it needs.

Order options alphabetically by their long form, unless a different order
is clearer for the reader, such as grouping by purpose on a page with many
options.

**CONFIGURATION** names the registry keys the program reads and says what
they control as a whole. It doesn't document individual values; regman owns
those. End the section by pointing the reader there:
"Each value is documented in **regman**(1); run
**regman Machine\\System\\Network**."

**SECURITY** says what access the program checks, and against which security
descriptor: which rights each operation needs, which privileges change its
behavior, and what the default descriptor allows. Say also what the program
deliberately does not allow, when a reader coming from another system would
expect it.

**EXIT STATUS**, **RETURN VALUE**, and **ERRORS** list every value, each as a
tagged paragraph. Don't write "a non-zero value on failure" when the program
uses distinct values. A first-party program's exit statuses follow
[Command-Line Help and Errors](/psc/style/command-line-help-and-errors.md): 0 for
success, 1 for failure, 2 for a usage error, and 3 upward for anything more
specific.

**SYNOPSIS** and **OPTIONS** must agree with the program's `--help` output.
Change them in the same commit.

**EVENTS** lists the event types the program emits, one per line, and
points to **evman**(1) for their meaning and fields. Don't describe the
fields in the man page.

**EXAMPLES** gives each example as a command in bold, followed by a sentence
saying what it does and what to expect.

**SEE ALSO** lists related pages as `.BR name (section)`, separated by
commas, ordered by section number and then alphabetically, with no final
period. A relevant learn page can follow as a URL on its own line.

## Formatting conventions

roff has no code formatting, so the typeface rules differ from the rest of
Peios documentation:

| Bold (`.B`) | Italic (`.I`) |
|---|---|
| Command, program, and function names | Arguments and placeholders the reader replaces |
| Options and literal keywords | File and directory paths |
| Registry paths and value names | Titles of external documents |
| Event names, constants, rights, and privileges | |
| Environment variable names | |
| Literal input and output | |

Refer to another man page as the name in bold followed by the section in
parentheses: `.BR netd (8)`. Placeholders are italic words, such as
*interface*, not the `<name>` form used elsewhere.

Escape characters that roff treats specially:

- Write a hyphen-minus in an option or command as `\-`, so `--force` is
  `\-\-force`. A plain `-` can render as a hyphen that doesn't paste.
- Write a backslash as `\\`, so `Machine\System\Network` is
  `Machine\\System\\Network`.
- Start a line with `\&` when it would otherwise begin with a period or an
  apostrophe.

Start every sentence on a new line in the source. roff then spaces
sentences correctly, and a change to one sentence changes one line. This
replaces the 78-column wrapping rule for man page sources; still break a
sentence that runs past 78 columns at a natural phrase boundary.

Don't use admonitions, or tables built with `tbl` where a list of tagged
paragraphs would do. Avoid em dashes, because they render inconsistently in
terminals; where one is truly needed, write `\(em` with a space on each
side.

## API pages

Pages in sections 2 and 3 document programming interfaces.

- **One page per function**, or per group of functions that are always used
  together, such as a create and destroy pair. Give every function in a
  group its own NAME entry.
- **SYNOPSIS** shows the `#include` lines and full prototypes exactly as the
  header declares them.
- **DESCRIPTION** covers every argument, every flag value, ownership of
  memory and handles, and thread safety.
- **ERRORS** lists every error the call can return, with the condition that
  produces it. If the call can return errors the page does not list, the
  page is incomplete.
- Bindings for other languages, such as Rust or Go, document themselves with
  their language's own tools and point to the man page for the semantics.

## Pages adopted from upstream

Peios ships man pages from upstream projects, such as coreutils. Where Peios
behaves differently from upstream, the page is patched to describe Peios.
Peios does not ship a page it knows is inaccurate.

- **Correct, don't restyle.** Change only what is inaccurate for Peios.
  Leave upstream's wording, structure, and style alone, so the patch stays
  small and survives the next upstream update.
- **Describe Peios, not the difference.** Write the patched text as if the
  page had always described Peios. Don't add "On Peios, …" notes or a
  separate Peios section.
- **Keep the patch with the package.** The change lives in the package's
  patch series, beside any code patches, with a description saying what
  behavior it corrects.
- **Patch when the behavior changes.** A Peios change that makes an adopted
  page inaccurate includes the patch to that page.

Core Style's spelling and wording rules don't apply to upstream text you
leave unchanged. Text you add or replace follows them where it can do so
without reading oddly against the surrounding page.

---

# regman and evman

_Standards and Conventions / Style_

> How to write the prose in regman and evman records, covering summary lines for keys, values, events, and fields, what a body explains, header field wording, the markup each tool renders, and referring to other records without links.

regman and evman records document the registry and the event stream: every
key, value, event, and field. Each record is read in a terminal by someone
who has a specific path or event name in front of them and wants to know
what it means. [Core Style](/psc/style/core-style.md) applies to the prose; this
page adds the rules for writing it.

The file formats, the tools, and their lint checks are defined elsewhere:

- regman: [Writing regman pages](/peios/developing-for-peios/documenting-configuration/writing-regman-pages.md)
- evman: [Writing evman pages](/peios/developing-for-peios/documenting-events/writing-evman-pages.md)
  and PGSS §6.10, which defines the catalog normatively

## The first line is the summary

Each tool shows the first line or sentence of a record's body in its indexes
and search results, beside the name. Write it to stand on its own: someone
scanning a list of 50 values reads only this line. End it with a period.

The form of the summary depends on what the record documents:

| Record | Summary form | Example |
|---|---|---|
| Key | A noun phrase naming what the subtree holds | "Tuning parameters for the Exampled spooler." |
| Value | A noun phrase saying what the value is | "Maximum number of jobs held in the spool queue before new submissions are rejected." |
| Event | A past-tense sentence saying what happened | "A snapshot was written, or an attempt to write one failed." |
| Field | A noun phrase saying what the field holds | "The snapshot an event concerns, by the GUID the backup tool assigned it." |

Don't start a summary with the record's own name, or with "This value",
"This key", or "This event". The name is already printed beside it.

- Do: "Maximum number of jobs held in the spool queue."
- Don't: "MaxQueueDepth sets the maximum number of jobs in the queue."

## What the body explains

After the summary, explain what the reader needs to set the value or
interpret the event correctly:

- **For a value:** what changing it does, the trade-off involved, how it
  interacts with other values, and anything that makes a valid value a bad
  choice. Say why a limit exists when it is not obvious.
- **For a key:** the meaning shared by everything under it, such as how the
  owning component reads and validates the subtree, and where security is
  applied.
- **For an event:** when it is emitted and when it is not, what an operator
  would typically do on seeing it, and how it relates to other events.
- **For a field:** what the value means, its units, and when it is absent.

Don't describe the state of any particular machine. A record documents what
a value means and what it should be, never what it is set to now.

Don't record history. There is no "added in" or "previously"; the package
version records when a record changed.

When the meaning of each value of an enumeration is not obvious from its
name, document every value in the body as a list:

```text
- `full`: every file, regardless of earlier snapshots.
- `incremental`: files changed since the last snapshot of any kind.
```

In evman, the `values:` header line also lists the values. It says which
values exist; the body list says what each one means.

## Header fields

Header fields are shown verbatim in a fixed layout, so keep them short and
consistent.

- **`default`:** the exact value, as the reader would enter it. If there is
  no default, write `(required)` or say what absence means, in parentheses.
- **`valid`:** a short human-readable constraint. Write ranges with an en
  dash and no spaces (`16–65536`), sets with commas, and units in full after
  the number (`1–3600 seconds`).
- **`applies`:** exactly `live`, `restart`, or `reboot`. A short parenthetical
  is allowed when it helps: `live (at the next generation)`.

## Markup

Both tools render the same small set of Markdown: paragraphs, headings,
bullet lists, `**bold**`, and `` `code` ``. Prose is rewrapped to the
terminal width, so the source's line breaks within a paragraph don't show.

Use code formatting for every path, value name, event name, field name, and
literal value, as in any other form. Use bold sparingly, for the one warning
in a record that matters most. Don't use italics: both tools strip the
markers without styling the text, so the emphasis is lost.

## Referring to other records

Records are read in a terminal, so they cannot link. Refer to another
record by its full path or name in code formatting, and to a man page by name
and section. The reader can look up either directly.

<!-- lint-disable-next-line line-length -->
- Do: "The limit applies per interface; see `Machine\System\Network\Interfaces\<ifid> MaxRoutes`."
- Don't: "See the interface settings for the per-interface limit."

Document a key or event only in the package that owns it. When your
component reads another package's key, mention that key by path in your own
record's body; don't add a record for it.

## Wording

- Use the [word list](/psc/style/word-list.md) terms: a key holds values, a value
  has a type.
- Write "the value" or "the field", not "this setting", "this option", or
  "this parameter".
- Describe effects in the present tense, from the component's side: "netd
  rereads the key", not "the key will be reread".
- Write numbers as numerals, with units: "60 seconds", "4 KiB".

---

# Command-Line Help and Errors

_Standards and Conventions / Style_

> How first-party Peios programs print help, version, and error messages, covering the help layout, option descriptions, placeholders, the required flags, output streams, exit statuses, and the form of an error message.

Every first-party Peios program, from a command a user runs to a daemon,
prints help, its version, and error messages in the same way. Help is the
shortest form of Peios documentation: a reminder of what a program accepts,
printed by the program itself. [Core Style](/psc/style/core-style.md) applies to its
wording; this page adds the layout and the rules for output and exit
statuses.

These rules cover what a program writes to a terminal. Messages a daemon
logs are events, which evman documents, and this page doesn't cover them.

## Help summarizes the man page

The man page is the authority for a program's interface; help is a summary
of it. Help lists every command, argument, and option, with one line each,
and leaves explanation, examples, and edge cases to the man page.

Help and the man page must never disagree. Change both in the same commit.

Where the argument parser can generate help from its own definitions, as
clap can, let it. A program that writes its help by hand keeps one copy of
the text and builds any other usage message from it, so the two can't drift
apart.

## Layout

Help has these parts, in this order, separated by blank lines:

1. **Description.** One line: the description from the man page's NAME
   line, with its first letter capitalized and no final period.
2. **Usage.** `Usage:` followed by the program's invocation forms.
3. **Commands, arguments, and options.** One section each, for those that
   apply, headed `Commands:`, `Arguments:`, and `Options:`.
4. **Pointer.** One line saying where the full documentation is.

The help for a print spooler's control program looks like this:

```text
Inspect and control the Exampled print spooler

Usage: spoolctl [options] <command>

Commands:
  status            Show the spooler's state and queue length
  pause             Stop accepting new jobs
  resume            Start accepting jobs again
  cancel <job-id>   Cancel a queued or running job
  help [<command>]  Print help for spoolctl or one of its commands

Options:
  -j, --json        Print output as JSON
  -h, --help        Print help
  -V, --version     Print version

See spoolctl(8).
```

Indent entries by two spaces, and align the descriptions in a column at
least two spaces after the longest entry. Keep every line within 80
columns, or wrap to the terminal width when the parser does that.

## Usage lines

Write one usage form per line. When there are several, start the first on
the `Usage:` line and indent the rest to line up under it:

```text
Usage: spoolq list [--all]
       spoolq submit <file>
       spoolq cancel <job-id>
```

A program with many commands gives one general form, `<command>`, and lists
the commands in the `Commands:` section instead.

## Entries and descriptions

Write each description as a fragment that starts with a capital letter and
a verb in the imperative, with no final period: "Print output as JSON", not
"prints output as JSON." or "Output format". These are the same rules Core
Style gives for list items, and they match clap's own "Print help" and
"Print version".

Write placeholders in lowercase, in angle brackets, and hyphenated, as Core
Style requires: `<job-id>`, not `JOB_ID` or `<JOB-ID>`. Put optional parts
in square brackets. clap uppercases placeholders by default, so set the name
of each one explicitly.

Show the short and long forms of an option together, short first, and the
placeholder after the long form: `-f, --format <format>`. When an option
has a default, end its description with it in parentheses:
`Set the output format (default: text)`.

List commands and options in the same order as the man page, with `-h,
--help` and `-V, --version` last.

## Required flags

Every first-party program accepts these flags, including daemons:

| Flag | Prints | Stream | Exit status |
|---|---|---|---|
| `-h`, `--help` | The help | stdout | 0 |
| `-V`, `--version` | The program name and package version, such as `spoolctl 0.4.2` | stdout | 0 |

`-h` and `--help` print the same text. Don't give `--help` a longer version.

A program with commands also accepts `help` and `help <command>`, and
`<command> --help` prints the same text as `help <command>`. A command's help
follows the same layout, with a usage line for that command alone.

Running a program with commands and no arguments is a usage error, unless
the man page documents a default command.

## Error messages

Print every error to stderr, as one line in this form:

```text
<program>: <what went wrong>
```

Use the name the program was invoked as, without its directory. A
multicall binary uses the applet name.

Name the thing that failed before saying what went wrong, separated by a
colon, so the reader sees the object first:

```text
reg: Machine\System\Spooler: access denied
spoolctl: cancel 4127: no such job
```

- **Start in lowercase**, unless the first word is a proper noun or an
  identifier.
- **End without a period.**
- **Don't add a prefix** such as `Error:` or `error:`. The program name
  already marks the line as a message from the program.
- **Quote a value the reader supplied** with straight single quotes when it
  appears mid-message: `spoolctl: unknown command 'stauts'`. Don't quote it
  when it is the object at the start of the message.
- **Keep the system's own wording** for an error from the operating system,
  such as `No such file or directory`, so first-party messages match those
  of adopted tools. Don't add an error number such as `(os error 2)`.
- **Never print a debug representation**, such as Rust's `{:?}` output or a
  stack trace. A Rust `main` that returns `Result` prints `Error:` and the
  debug form, so handle the error and print the message instead.

When the reader can fix the problem and the fix isn't obvious, add one line
after the error, with no program-name prefix, saying what to do. Write it as
a sentence, ending in a period.

### Warnings

Print a warning to stderr as `<program>: warning: <message>`, following the
same rules. A warning doesn't change the exit status.

### Usage errors

A usage error is a problem with the arguments: an unknown option, a missing
argument, or a value of the wrong form. Print the error, then this line, to
stderr:

```text
spoolctl: unknown option '--jsno'
Try 'spoolctl --help' for more information.
```

Don't print the full help after a usage error; it pushes the error off the
screen. The one exception is running a program with commands and no
arguments, which prints the help to stderr in place of an error message.

Neither clap nor uucore prints usage errors in this form by default, so
render them yourself: use the error's kind and context to build the
message.

## Exit statuses

| Status | Meaning |
|---|---|
| 0 | Success, including printing help or the version |
| 1 | Failure |
| 2 | Usage error |

A program can define more specific failure statuses, from 3 upward, and
lists them in the man page's EXIT STATUS section. Don't use 2 for anything
but a usage error.

## The pointer line

End the help with a pointer to the full documentation:

- **A program installed on Peios** points to its man page: `See spoolctl(8).`
- **A tool that runs on a developer's machine**, such as pekit, points to its
  learn page by URL, because the man page might not be installed there.

Don't point to a path in a source repository. It doesn't exist on an
installed system.

---

# 1.1 Scope

_Standards and Conventions / Conventions / Introduction_

> The two classes of technical document this book governs, what it leaves to other documents, and how it relates to Core Style.

This document defines how the technical documents of Peios are written
and how they are read. It governs two classes of document:

- **Specifications.** The PCDS, PGSS, PSPK, and PSPU books, which state
  what must be true for a Peios system and for the parties that
  interoperate with one.
- **Technical reference manuals.** The per-component books that describe
  exhaustively how one piece of Peios actually behaves.

Together, the specifications and the technical reference manuals are the
corpus this book refers to.

It covers normative language, the structure a document of each class
takes, how any part of either is cited, and the style rules both share.

## 1.1.1 What this document does not cover

This document does not cover four things:

- **The other forms of Peios documentation.** Learn, man pages, regman,
  and evman follow [Core Style](/psc/style/core-style.md) and their own form
  pages. Neither the normative apparatus of a specification nor the
  exhaustiveness of a reference manual applies to them.
- **Any behavior of Peios itself.** Nothing here specifies what a
  Peios system does. This document constrains documents.
- **The renderer.** The static site generator that builds these books
  supplies the chapter and article numbering this document's addressing
  scheme relies on, and is specified separately.
- **Editorial process.** How a document is reviewed, by whom, and when
  it is considered ready are project conventions rather than document
  conventions.

## 1.1.2 Relationship to Core Style

This book sits in the Documentation shelf of Developing for Peios,
beside Core Style, and is the form-specific guide for specifications and
technical reference manuals. Core Style applies to specifications and
technical reference manuals too, except where this book says otherwise.
This book adds to it rather than repeating it, so an author reads Core
Style first and then the chapters here for the class they are writing.

This book departs from Core Style deliberately in five places:

- **Normative keywords.** A specification states each requirement with
  an RFC 2119 keyword (§2.1), and a technical reference manual uses
  none at all, in uppercase or in a lowercase form that reads as an
  obligation (§4.2).
- **Notes.** In a specification, a `[!NOTE]` callout marks informative
  text and carries the reasoning behind a rule, not only an aside (§2.2,
  §6.3).
- **Lowercase hexadecimal.** Hash values and byte sequences are written
  in lowercase hexadecimal, as they appear in the files and tool output
  a reader compares them with (§3.3).
- **Interim states.** A technical reference manual can describe the
  intended end state of deliberately provisional behavior, marked as
  such, as an exception to Core Style's rule against writing about time
  (§4.4).
- **This book's own rules.** This book is not a specification, but it
  states its rules with RFC 2119 keywords so that what it requires of a
  document is unambiguous (§1.3).

This book is not itself a specification: it defines no Peios behavior,
and no implementation conforms to it. What conforms to it are documents.

---

# 1.2 The Two Document Classes

_Standards and Conventions / Conventions / Introduction_

> The test that decides whether a document is a specification or a manual, based on how many independently written parties have to agree, and why most subsystems need both.

Every technical document in this corpus is either a **specification** or
a **technical reference manual**, and the difference is not a matter of
subject, length, or tone. It is a matter of how many independently
written parties have to reproduce the same computation to agree:

- If one party computes something and everyone else calls it, that is a
  manual.
- If a second party must reproduce it identically, or the two produce
  divergent results, that is a specification.

## 1.2.1 The sharper form of the test

A third party wanting to interact with something directly is necessary,
but it is not sufficient. What makes something a specification is a
second **role**: a party whose behavior the other side depends on.

A system-call surface has no second role. It has callers, and callers
are documented rather than specified. The question that settles it is
which party is the one asking. A registry source answers the kernel's
questions, and a package producer emits what a consumer validates, so
both of those are specifications. Nobody serves `mount(2)`, so that is a
manual.

## 1.2.2 Most subsystems split

The expected outcome for any given subsystem is both: a specification
stating the contract, and a manual covering the nuances of how one
implementation fulfills it.

Binary signing is a specification because a third party can sign
binaries; the kernel's verification machinery behind it is a manual.
Security descriptor inheritance is a specification even though there is
one kernel, because the kernel does not propagate a descriptor change
and every userspace tool that propagates one has to agree. A package's
manifest schema is a specification; how a package manager decides which
of several candidates to install is a manual.

A subsystem whose only external surface is its own syscalls contributes
no specification at all, and that is a legitimate outcome rather than an
oversight.

## 1.2.3 Consequences for the reader

A specification states what an implementation and its peers can rely
on. Its statements are commitments, and an implementation that
contradicts one has a defect.

A manual describes what a component does. Its authority comes from the
software: where the two disagree, the software is right and the manual
is stale. A manual makes no stability commitment, and nothing in one is
a promise about a future version.

That difference is why the two classes are written so differently, and
why a reader must be able to tell at a glance which one is in front of
them (§4.2).

---

# 1.3 How to Read This Book

_Standards and Conventions / Conventions / Introduction_

> The normative keywords this book uses, why its specification and manual halves carry different weight, and the order to read its chapters in.

This book states its rules with RFC 2119 keywords, and its chapters carry
different weight depending on the class of document they govern.

## 1.3.1 Normative keywords

The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY in this
document are to be interpreted as described in RFC 2119. Their meaning
within a specification is defined in §2.1.

Text set off as a note is informative.

## 1.3.2 The two halves carry different weight, deliberately

Chapters 2 and 3 govern specifications and are normative throughout.
A specification that violates one of their requirements is malformed,
and the requirement is stated as such.

Chapter 4 governs technical reference manuals and is deliberately
lighter. Most of it is SHOULD and MAY, and some of it is offered as
guidance carrying no normative weight at all. A manual is a description
of software rather than a contract, so prescribing its shape tightly
would be prescribing the shape of the software.

Two rules in chapter 4 are exceptions and are stated as MUST NOT,
because they are what makes the class a class rather than a matter of
taste: a manual carries no RFC 2119 keywords (§4.2), and a manual does
not narrate the difference between itself and a specification (§4.4).

Chapters 5 and 6 apply to both classes.

## 1.3.3 Reading order

An implementer needs §2.1 and chapter 5, and nothing else.

An author needs [Core Style](/psc/style/core-style.md), then the chapter for
the class they are writing, then chapters 5 and 6.

A reader trying to work out which class a document belongs to, or why a
given fact is documented in one place rather than another, wants §1.2.

---

# 2.1 RFC 2119 Keywords

_Standards and Conventions / Conventions / Normative Language_

> How uppercase MUST, SHOULD, and MAY carry their RFC 2119 meanings while lowercase forms carry none, why requirements are stated against a role, and what a SHOULD has to mean.

A specification MUST declare its use of RFC 2119 keywords in its
conventions article (§3.1).

The following keywords, when they appear in uppercase, MUST be
interpreted as described in RFC 2119:

| Keyword | Meaning |
|---|---|
| MUST, MUST NOT | An absolute requirement or prohibition |
| SHALL, SHALL NOT | Synonyms for MUST and MUST NOT |
| SHOULD, SHOULD NOT | A requirement that can be set aside for a stated reason, the consequences of which are understood |
| MAY | Genuinely optional |
| REQUIRED, OPTIONAL | Synonyms for MUST and MAY, used adjectivally |

A specification MAY use a subset. Its conventions article MUST list
which keywords it uses.

## 2.1.1 Lowercase is not a keyword

The same words in lowercase carry no normative weight. This is not a
loophole to be exploited: a lowercase "must" in a passage that reads as
a requirement is an editing defect, because the reader cannot tell
whether an obligation was intended.

<!-- lint-disable spelling -->
An author writing a requirement MUST use the uppercase form. An author
writing description SHOULD reach for a verb that is not a keyword at
all, such as "is," "carries," or "produces," rather than relying on case
to carry the distinction. Where a description needs a modal, the rule
in [Core Style](/psc/style/core-style.md) applies: "can" for ability, "might" for possibility, and
never a lowercase "may."
<!-- lint-enable spelling -->

## 2.1.2 Requirements are stated against a role

A specification with more than one party MUST state each requirement
against the role rather than the program (§3.2). An obligation on a
consumer binds whatever process is acting as the consumer, and one
program can serve different roles on different interfaces.

## 2.1.3 SHOULD means something

A SHOULD is not a soft MUST and not a decorative MAY. It marks a
requirement with a real exception, and a specification using one SHOULD
say what the exception is, either inline or in an adjacent note.

> [!NOTE]
> A SHOULD whose exception nobody can name is a MUST that the author
> was not confident enough to write. A SHOULD that nothing would ever
> satisfy is a MAY. Both are worth catching before publication, because
> an implementer reading either has to guess at an intent that was never
> formed.

---

# 2.2 Informative Text

_Standards and Conventions / Conventions / Normative Language_

> Why everything in a specification is normative unless marked otherwise, how to mark informative text, what it must not contain, and what it is for.

All text in a specification is normative unless it is explicitly marked
otherwise. Informative text is the exception, and it is marked so that a
reader never has to guess which kind of statement they are reading.

## 2.2.1 Marking

Informative text MUST be marked, using a note callout:

```markdown
> [!NOTE]
> This paragraph gives context and defines no behavior.
```

An inline aside introduced by "For example" or "Note:" is also
informative.

[Core Style](/psc/style/core-style.md) treats a note as an occasional aside. In a specification the
note callout also marks text as informative and carries the reasoning
behind a rule, which is a deliberate departure from Core Style (§1.1).

## 2.2.2 Limits on informative text

Informative text MUST NOT contain an RFC 2119 keyword used in its
normative sense. Where a note needs to refer to required behavior, it
MUST cite the normative statement that defines it rather than restating
it.

> [!NOTE]
> The restriction exists because a requirement stated twice is a
> requirement that can drift. When a note paraphrases a rule and the
> rule later changes, the note becomes a second, contradictory
> specification that a reader has no way to rank against the first.

## 2.2.3 What informative text is for

Rationale, worked examples, the attack a rule defends against, and the
alternative that was considered and rejected.

A specification SHOULD carry that material rather than omit it. A rule
whose reason is unrecorded is a rule that a later revision will remove
as redundant, or preserve for the wrong reason — and a wrong reason is
what the revision after that will reason from.

---

# 2.3 Pseudocode

_Standards and Conventions / Conventions / Normative Language_

> Why pseudocode in a specification is normative, and the symbols, operators, and comment syntax it is written in across the corpus.

A specification that includes pseudocode MUST document its conventions
in its conventions article (§3.1).

The conventions in this table are established across the corpus and
SHOULD be used, so that a reader moving between books does not have to
relearn the notation:

| Symbol | Meaning |
|---|---|
| `&` (parameter prefix) | In-out parameter: the caller's value is read and might be modified |
| `\|` | Bitwise OR |
| `&` (in an expression) | Bitwise AND |
| `~` | Bitwise NOT |
| `\|=`, `&=` | Augmented assignment |
| `=` | Assignment |
| `==` | Equality comparison |
| `->` | Field access through a pointer or reference |
| `→` | Return type in a signature |
| `//` | Single-line comment |

Pseudocode MUST appear in a fenced code block.

A specification MAY use further conventions — `and`, `or`, and `not`
for boolean operators, or named error returns — and MUST document any
it uses.

## 2.3.1 Pseudocode is normative

Pseudocode in a specification is a normative statement like any other,
and MUST be read as one. It is not an illustration of a rule stated
elsewhere; where it is meant as illustration, it belongs in a note
(§2.2).

> [!NOTE]
> This matters most for algorithms with an ordering that the prose does
> not make explicit. Two rules that can both fire on one input need a
> stated order, and pseudocode is often where that order actually lives.

---

# 3.1 Required Articles

_Standards and Conventions / Conventions / Specification Structure_

> The articles a specification book and each of its chapters open and close with, how terminology delegates, and what a scope article's exclusions must name.

A specification book and each of its chapters carry a fixed opening and
closing shape, so that a reader arriving at any chapter finds the same
things in the same places.

## 3.1.1 Book level

A book MUST open with an introduction chapter containing:

| Article | Purpose |
|---|---|
| Scope | What the book covers and what it does not, with each exclusion naming the document that does cover it |
| Conventions | The book's RFC 2119 declaration and any notation specific to it (§3.3) |

## 3.1.2 Chapter level

A chapter specifying a protocol or a format MUST open with:

| Article | Purpose |
|---|---|
| Scope and Roles | What the chapter specifies, and the roles that speak it (§3.2) |
| Terminology | Terms specific to the chapter |

and SHOULD close with an Extension article (§3.4) and a Conformance
article (§3.4), in that order, before any appendices.

A chapter defining a data structure rather than a protocol has no roles
and no conformance obligations of its own, and is exempt from both.

## 3.1.3 Terminology delegates rather than repeats

A terminology article MUST define the terms the chapter introduces. A
term already defined elsewhere in the corpus MUST be delegated by
reference rather than redefined:

```markdown
Terms defined in §5.2 (package, manifest, payload, and repository) are
used here with the same meaning and are not redefined.
```

<!-- lint-disable spelling -->
> [!NOTE]
> A redefinition is a second definition, and two definitions of one term
> drift. Delegation costs the reader one click and costs the corpus
> nothing.
<!-- lint-enable spelling -->

## 3.1.4 Scope names its exclusions

A scope article's exclusion list MUST identify, for each excluded item,
which document covers it. An exclusion that names nothing tells a reader
the subject is out of scope without telling them where to go, which is
the least useful thing a scope article can do.

---

# 3.2 Roles

_Standards and Conventions / Conventions / Specification Structure_

> How a multi-party specification names its roles, states every requirement against a role rather than a program, and organizes conformance by role.

A specification with more than one party MUST name its roles in its
scope article, and MUST state every requirement against a role rather
than against a program.

A role is a position in an interaction, not a piece of software. One
program frequently occupies several. A repository operator is usually
also a package producer, and a daemon that answers one protocol might
consume another.

## 3.2.1 Why the distinction is load-bearing

Naming a program in a requirement makes the requirement untestable
against anything else, which defeats the purpose of writing the
specification down. The whole reason a contract is published is that
somebody other than the current implementation might satisfy it.

## 3.2.2 Enumerating roles

A chapter's scope article SHOULD present its roles as a table giving,
for each, the obligation it carries:

| Role | Obligation |
|---|---|
| Producer | Builds the artifact. Everything the artifact contains is a producer obligation. |
| Consumer | Validates and applies it. Every validation and rejection rule binds the consumer. |

Two or three roles is typical. A specification finding itself with six
has probably merged two interactions that want separate chapters.

## 3.2.3 Conformance follows the roles

Because requirements attach to roles, a conformance article (§3.4)
states what each role must do, separately. A reader implementing one
side needs to know which requirements are theirs without reading the
other side's.

---

# 3.3 Data Conventions

_Standards and Conventions / Conventions / Specification Structure_

> The data conventions every specification book inherits, covering byte order, sizes, layout tables, notation, strings, hashes, and timestamps.

The conventions in this article hold across every specification book. A
book MUST NOT restate them, and MUST state any point on which it differs.

## 3.3.1 Byte order

All multi-byte integer fields are little-endian unless explicitly stated
otherwise.

## 3.3.2 Sizes

All sizes and offsets are in bytes. `u8`, `u16`, `u32`, and `u64` denote
unsigned integers of 8, 16, 32, and 64 bits.

## 3.3.3 Layout tables

A field layout is given as a table in declaration order. A layout table
is normative: fields appear on the wire in the order listed, with no
padding between them.

## 3.3.4 Notation

Hexadecimal values carry the `0x` prefix. Byte sequences are written as
space-separated lowercase hex pairs, `0a 0b 0c`, the form hex dump tools
print. Lowercase here is a deliberate departure from the uppercase
hexadecimal of [Core Style](/psc/style/core-style.md) (§1.1).

## 3.3.5 Strings

Strings are UTF-8 (RFC 3629). String comparison is byte-for-byte
equality unless stated otherwise.

## 3.3.6 Hashes and signatures

Hash values are lowercase hexadecimal unless stated otherwise, matching
the form hashing tools print and files carry, and hash algorithms are
named by their IANA-registered identifiers.

## 3.3.7 Timestamps

Timestamps are RFC 3339, in UTC, and end with `Z`.

## 3.3.8 What a book's conventions article carries

Because these conventions are shared, a book's conventions article
(§3.1) is short. It MUST carry the book's RFC 2119 declaration, and
SHOULD carry only:

- Notation the book introduces that this article does not list
- Any point on which the book departs from this article
- Pseudocode conventions, if the book uses pseudocode (§2.3)

> [!NOTE]
> A conventions chapter copied into each of four books does not stay
> identical. Duplicated text is where contradictions breed, and the
> contradiction is invisible because nobody reads two copies of the
> same thing side by side.

---

# 3.4 Extension and Conformance

_Standards and Conventions / Conventions / Specification Structure_

> How a format or protocol chapter states the ways it can grow, and how its closing conformance article summarizes each role's obligations and freedoms.

A format or protocol chapter closes with two articles: one saying how
the thing it specifies can grow, and one summarizing what conformance
requires of each role.

## 3.4.1 Extension

A chapter specifying a wire format, a file format, or a protocol SHOULD
close with an extension article stating how the thing can grow.

An extension article SHOULD distinguish three kinds of change:

- **Additive changes.** Changes an implementation of the current version
  can ignore safely, such as a new optional field or a new entry in an
  open-ended set.
- **Changes requiring a version bump.** Changes it cannot ignore, such
  as a new required field, a new value in a closed enumeration, or any
  change to an algorithm the format has frozen.
- **Reserved space.** Room the format deliberately leaves, and what an
  implementation does when it encounters a value there.

A specification MUST state, for every enumeration it defines, whether
that enumeration is closed. An implementation cannot decide whether to
ignore or reject an unknown value without being told.

> [!NOTE]
> The test for whether a change is additive is not whether it is small.
> It is whether an implementation that ignores it still behaves
> correctly. An optional field whose absence changes what gets
> installed is not additive, however optional it looks.

## 3.4.2 Conformance

A chapter SHOULD close with a conformance article summarizing, per role
(§3.2), what that role must do. The article is a summary and MUST NOT
introduce a requirement stated nowhere else.

A conformance article SHOULD also state plainly what conformance does
not require. A reader who has been given a list of obligations
benefits more from knowing where their freedom lies than from a longer
list.

> [!NOTE]
> The useful shape has two halves: what an implementation must agree on
> with everybody else, and everything it is free to do differently. A
> specification that never says the second half reads as though it
> constrains the whole implementation, and implementers respond by
> over-constraining themselves or by ignoring it.

---

# 4.1 What a TRM Is

_Standards and Conventions / Conventions / Technical Reference Manuals_

> What a technical reference manual is, why each component gets one book, where its authority comes from, and what belongs in one.

A **technical reference manual** (TRM) is an exhaustive descriptive
reference for one component: what it does, how it behaves at every
edge, and what happens when it fails.

The hardware analogy is deliberate. If the specification books are the
architecture reference manual, a TRM is the per-implementation technical
reference manual that sits beside them — the document that says what
one particular thing actually does, given that the architecture says
what any conforming thing must do.

## 4.1.1 One book per component

A TRM covers one component, where the boundary is drawn by what ships
and is maintained together rather than by subject matter. Several
subsystems that live in one codebase and version together are chapters
of one manual, not manuals of their own.

## 4.1.2 Its authority comes from the software

This is the property that governs everything else in this chapter. A
specification is authoritative over its implementations: where the two
disagree, the implementation has a defect. A TRM is the reverse. Where a
manual and the software disagree, the software is right and the manual
is stale.

A TRM therefore makes no stability commitment. Nothing in one is a
promise about a future version, and a reader who needs a promise needs a
specification instead.

## 4.1.3 What belongs in one

Everything about the component that is true and not documented
elsewhere: its architecture, its state, how it uses its configuration,
its algorithms where they are its own, its failure modes, its on-disk
artifacts, and the reasoning behind its design decisions.

A manual SHOULD carry rationale generously. It is the only document in
the corpus with room for it, and a component's design decisions are
otherwise recorded only in the history of the work that produced them.

## 4.1.4 What does not belong

Anything a third party must reproduce to interoperate. That is
a contract, and a contract belongs in a specification (§1.2). A manual
cites it (§4.6) rather than restating it.

Registry keys and values belong to regman, and events and their fields
to evman. A manual links to their pages rather than tabulating them
(§6.2).

---

# 4.2 Voice

_Standards and Conventions / Conventions / Technical Reference Manuals_

> Why a technical reference manual describes and never requires, covering normative keywords, the indicative mood, lowercase keyword hazards, and register.

A technical reference manual (TRM) describes what a component does. Its
voice follows from that: it never states a requirement, in any form.

## 4.2.1 No normative keywords

A TRM MUST NOT use RFC 2119 keywords, either in uppercase or in the
lowercase constructions that read as obligation.

This is the one rule in this chapter with no exceptions, because it is
what makes the class a class. A manual describes; it does not require.
A reader must be able to tell, from the first paragraph of any document
in this corpus, whether they are being told what something does or what
they must do.

## 4.2.2 The indicative mood

Write what the component does.

| Not this | This |
|---|---|
| The daemon MUST reject a malformed request | The daemon rejects a malformed request |
| A client SHOULD retry after a timeout | A client that times out can retry |
| The cache MAY be discarded | The cache can be discarded at any time |
| Callers must hold the lock | Callers hold the lock |

<!-- lint-disable-next-line spelling -->
The third and fourth rows are the ones that catch people. "May" and
"must" survive into descriptive prose readily, because an author
describing something real slips into obligation without noticing,
particularly when the source material was a specification.

## 4.2.3 Lowercase keywords are the actual hazard

Uppercase keywords are trivially caught by searching. Lowercase ones are
not, and they are far more common: a conversion from specification prose
typically leaves more than 10.

<!-- lint-disable spelling -->
An author SHOULD search a finished manual for lowercase `must`,
`should`, `shall`, `may`, and `must not`, and rewrite every instance
that reads as a requirement. Every `may` is rewritten, because
[Core Style](/psc/style/core-style.md) allows no lowercase "may" in prose. Idiomatic uses of the others
survive, such as "what the content should be," and the test is whether
a reader could mistake the sentence for an obligation.
<!-- lint-enable spelling -->

> [!NOTE]
> A validator that flags documents for lacking normative keywords is
> useless here, and worse than useless if it is trusted: for a manual
> the signal is inverted. The check has to be run deliberately and in
> the opposite direction.

## 4.2.4 Register

A manual is plain declarative prose for a competent engineer, neither
tutorial nor chatty. It describes the component and does not address
the reader as "you." A manual SHOULD assume its reader knows the
platform and wants the specifics.

---

# 4.3 Structure

_Standards and Conventions / Conventions / Technical Reference Manuals_

> Guidance on how a manual is shaped, covering the introduction, body chapters, a failure-modes chapter, appendices, and exhaustiveness.

A technical reference manual's (TRM's) chapter structure follows the
component rather than a template. The conventions in this article are
what has worked, offered as guidance.

## 4.3.1 The introduction

A manual SHOULD open with an introduction containing:

| Article | Purpose |
|---|---|
| Overview | What the component is, and what is unusual about it |
| What This Manual Covers | And what is covered elsewhere, naming where |
| Terminology | Terms specific to the component, delegating the rest |
| Compatibility | Versions, architectures, and what interoperates |

The overview article is the most valuable page in the book and the one
most often written last and least. It SHOULD say what is surprising
about the component — the two or three decisions that would not be
guessed from the name — rather than restating the component's purpose in
a paragraph.

## 4.3.2 Body chapters

Body chapters are ordered so that a reader following the component's
own flow reads them in order: what it is made of, then what it does, in
the sequence it does it.

## 4.3.3 A failure-modes chapter

A manual SHOULD close with a chapter describing what goes wrong: the
common failures, what each looks like from outside, what signal is
available, and how to get back to a known state.

This is the chapter readers arrive at from a search engine in the middle
of an incident, and it is the one most often omitted. A manual that
documents every success path and no failure path has documented the
easy half.

## 4.3.4 Appendices

Appendices hold consolidated reference material, such as constants,
paths, and on-disk state (§6.1). Registry keys and events are not
tabulated in a manual; it links to their regman and evman pages (§6.2).

## 4.3.5 Length is not a virtue, but exhaustiveness is

A manual SHOULD document the edge cases. The odd interaction, the
counter-intuitive default, the thing that happens only when two features
meet — those are why the manual exists. A summary of the happy path is
already in the component's README.

---

# 4.4 Describing the True State

_Standards and Conventions / Conventions / Technical Reference Manuals_

> Why a manual describes what the component does now, without narrating its divergences from a specification and without writing around them.

A technical reference manual (TRM) describes what the component does
now. This has a consequence that authors reliably find uncomfortable,
and it is worth stating directly.

## 4.4.1 Divergences are not narrated

A TRM MUST NOT frame anything as a difference between itself and a
specification. No "the specification requires X but the implementation
does Y," anywhere, in any form.

Where an implementation does not satisfy a contract, that is a defect.
It is recorded as one, in the project tracker, against the work that
would fix it — and the manual describes what the software does.

> [!NOTE]
> The reason is that a manual written as a divergence log rots into a
> second changelog nobody maintains, and undermines itself while doing
> it: a reader who is told the document is describing something wrong
> stops trusting the parts that are describing something right.
>
> It is also the wrong audience. The person who needs to know about a
> divergence is whoever will fix it, and they are looking at the
> tracker, not at a reference manual.

## 4.4.2 Which does not mean writing around it

Describing the true state is not the same as being vague about it. A
manual SHOULD state plainly what a component does not do, where a
reader would otherwise assume it did:

> peipkg does not check free space before it starts. Exhaustion is
> discovered when a write fails.

That sentence is descriptive, useful, and carries no comparison to any
contract. The distinction is between what is absent, which a reader
needs, and what was promised, which belongs in the tracker.

## 4.4.3 Interim states

Where behavior is deliberately provisional, a manual MAY say so and
describe the intended end state, provided it describes the current one
first and at greater length. A manual SHOULD NOT let a description of an
intention displace the description of what actually runs.

Describing an intended end state, marked as such, is a deliberate
exception to the rule in [Core Style](/psc/style/core-style.md) against writing
about time (§1.1). It applies only to behavior the component's own
design marks as provisional, and the marking is what keeps the
description from going stale silently.

---

# 4.5 Proposals

_Standards and Conventions / Conventions / Technical Reference Manuals_

> Why a manual can be written for software that does not exist yet, how such a proposal identifies itself, how it graduates in place, and how to review one.

A **technical reference manual proposal** is a technical reference
manual (TRM) for a component that does not exist yet.

It is written exactly as a TRM is written (in the indicative mood, with
no normative keywords, and exhaustively) and it describes software that
has not been built.

## 4.5.1 Why the class exists

A design that has been written out at reference-manual depth is a design
whose gaps are visible. Every field, limit, and interaction has to be
decided before it can be described, and describing it is how the
contradictions surface.

## 4.5.2 Saying what it is

A proposal MUST identify itself as one. It SHOULD do so in two places:
in its description, and in an opening article stating plainly that a
manual's authority comes from the software (§4.1) and that this one has
none of that yet — so a surprising statement in it is a design decision
that has not been tested against an implementation.

The document class carries that warning by itself, which is why no
banner on every page is needed.

## 4.5.3 It graduates in place

A proposal sits alongside the finished manuals and MUST NOT be moved
when the software lands. Moving it breaks every inbound link.
Graduating consists of correcting it against the implementation and
dropping the word "proposal."

## 4.5.4 Reviewing one

A proposal cannot be verified against code, so review is internal
composition instead: for each field, rule, limit, and configured value,
find every other place the document constrains it, and compose them by
hand.

The failure to look for is two rules that are individually right and
jointly wrong — a default stated in one chapter and a validity
constraint stated in another, which together reject the default. The
related one is two rules with no stated order, where both can fire on
one input and the document never says which runs first.

Composing every pair of independently configured size limits on one data
path, at their default values, is worth doing every time. A ceiling on
one side larger than the ceiling on the other is a common result, and
it lets one party accept what the other cannot carry.

A proposal MAY still contribute a specification chapter, where the
component owes one. Publishing a contract with no implementation to keep
it honest is a real cost, and it is a decision to take deliberately
rather than by default.

---

# 4.6 Citing a Specification

_Standards and Conventions / Conventions / Technical Reference Manuals_

> Why a manual cites the contract it implements rather than paraphrasing it, and how it adds the order, limits, and choices that only an implementation has.

Where a component implements a published contract, its manual cites the
contract rather than restating it.

## 4.6.1 Cite, do not paraphrase

A manual SHOULD state that the contract exists, name where it is, and
describe what the implementation it documents does about it:

> A dependency is satisfied by a candidate when the conditions of
> PSPU §5.21 hold. Three consequences of those rules shape how
> peipkg behaves.

A manual MUST NOT restate the contract's normative content in
descriptive prose. A paraphrase is a second copy that drifts, and
because the paraphrase carries no normative keywords, a reader cannot
tell which of the two they are supposed to rely on.

## 4.6.2 What the manual adds

A manual adds the nuances of one implementation: the order it does
things in, the limits it applies, what it does where the contract leaves
a choice, and what it does not implement.

A manual is the right place to say that a component is more restrictive
than the contract requires, or that it makes a choice the contract
leaves open. Those are facts about the software, not comparisons against
it.

## 4.6.3 Where the split falls

The recurring question is whether a given fact belongs in the manual or
in the specification, and the test in §1.2 answers it: if a second
independently written party must reproduce it, it is contract.

Worked, from one component: what satisfies a dependency is contract;
which of several satisfying candidates gets chosen is implementation.
The schema of a declaration is contract; the command-line flag that
overrides it is implementation. The layout of an artifact is contract;
where the tool keeps its own database is implementation.

> [!NOTE]
> The most reliable way to settle a borderline case is to read the
> target specification's own scope article. It states what that book
> excludes, and it has overturned a placement more often than any
> argument from first principles.

---

# 4.7 Citing a Manual

_Standards and Conventions / Conventions / Technical Reference Manuals_

> When a specification is allowed to defer to a manual, how the deferral must read, and the Kernel Access Control Subsystem as the standing case.

§4.6 covers the ordinary direction: a manual cites the contract it
implements. The reverse direction needs a rule of its own, because a
specification that defers to a manual has given something up, and a
reader is entitled to know that it did.

## 4.7.1 When it is allowed

A specification MAY cite a manual for material it deliberately does not
specify. It MUST NOT cite one for material within its own scope.

The test of §1.2 decides which case applies. If a second, independently
written party must reproduce the behavior, it is contract, and a
citation to a manual there is a specification failing at its job: the
other party has no manual for their own implementation. If no
second party is expected to reproduce it, because the component is
Peios' alone and is described rather than standardized, then the manual
is the only document that holds the material, and naming it beats
implying a standard exists somewhere.

## 4.7.2 Say that it is a deferral

A specification citing a manual MUST make the deferral legible rather
than let it read as an ordinary cross-reference. "Described in the
Peios Kernel TRM §3.8" says what it is; "see §3.8" does not.

Where a scope article excludes a whole area to a manual, it SHOULD say
why once, in that article, rather than re-arguing it at each citation
site. The sites then only need to name the article.

## 4.7.3 The standing case

The Kernel Access Control Subsystem (KACS) is the case that recurs.
Peios' access-control implementation is described in the Peios Kernel
TRM §3 and is not separately specified. PCDS, which specifies the
structures KACS consumes, therefore defers to that manual wherever a
structure's meaning depends on what KACS does with it. PCDS §1.1
records the arrangement; the individual citations name the articles.

> [!NOTE]
> This is not license to let a specification thin out over time. Each
> deferral is a decision that a given area will not be standardized,
> and the scope article is where that decision is visible. A citation
> to a manual appearing anywhere else, without a scope article behind
> it, is a defect.

---

# 4.8 Anchoring Testable Statements

_Standards and Conventions / Conventions / Technical Reference Manuals_

> Why named citations are the only handle a manual can offer a test suite, where an anchor goes, what deserves one, and why anchoring comes after the prose.

A specification's testable statements are already findable: they carry
RFC 2119 keywords, so `MUST` can be searched for and enumerated. A
manual has none, by the rule that defines the class (§4.2). Nothing in
its text distinguishes a behavioral claim from the prose around it.

A named citation (§5.3) is therefore not a convenience for a manual. It
is the only handle a manual can give a test suite, and the reason to
anchor one is usually that something outside the corpus needs to point
at it.

## 4.8.1 Anchor after writing, not during

An author SHOULD write a manual, or a chapter of one, to completion
first, and add anchors in a separate pass afterward.

Marking anchors while drafting interrupts the writing for a decision
that has nothing to do with the sentence being written. Choosing which
statements are testable is also a different kind of attention from
composing them: it reads the finished text as an implementer would,
looking for what could be observed, and that reading is easier when the
text is finished.

A component's manual is usually written before its tests exist. The
anchoring pass is still worth running, because it is what tells the
test author where to start.

## 4.8.2 Put the anchor on the heading

By default an anchor goes on a section's heading, and a section gets
one. A manual that is well structured already devotes a section to a
behavior, so the section is the thing a test wants to cite, and the
heading is where the anchor belongs:

```markdown
### `ro` [*strata.ro-is-independent-of-filesystem]
```

An anchor on a heading rides the document's structure rather than one
sentence of prose. A sentence gets rewritten in the ordinary course of
keeping a manual true; a section is a more stable thing to have named,
and the anchor moves with it.

The exception is a section that states several distinct behaviors, most
often a table of error conditions or a numbered list of rules that each
hold independently. There the section is the wrong unit: one name for 14
rules tells a test suite no more than the article number did. Anchor
those individually, in the table row or list item that states each rule.

The test is not a count. It is whether a reader asking "which behavior
does this name?" could get more than one answer.

## 4.8.3 Choosing what to anchor

Anchor a statement that could be observed: a rule about what is
accepted or refused, a value, an ordering, a returned error, or an
invariant that holds while the component runs.

Do not anchor rationale, comparison with prior art, an account of how
the source is organized where no behavior follows from it, or a
restatement of something already anchored nearby. An anchor on prose
that no test could ever cite is worse than no anchor: it will be
counted as uncovered forever.

## 4.8.4 Anchor where the rule is defined, once

A manual states its important rules more than once: in the article that
defines a rule, in a summary of consequences, and in a table collecting
every error condition. Only the defining occurrence carries the anchor.

A second anchor on a restatement does not add coverage; it splits it.
Two names for one behavior means two entries in a report, one test
between them, and no way for a reader to tell which name the other tests
were meant to cite.

The signals that a passage is a restatement rather than a definition are
usually explicit: it closes with a `§` reference to the article that
owns the rule, or it sits under a heading that disclaims authority. Where
a section says the articles it summarizes remain authoritative, it
carries no anchors at all.

The mirror of this also has to be checked. A summary left unanchored is
correct only if the rules it summarizes are anchored where they are
defined. A table of error conditions whose rows appear nowhere else in
prose is the definition, however much it looks like a summary, and an
author SHOULD anchor its rows rather than leave the most testable
surface in the manual uncitable.

## 4.8.5 One anchor is not one test

Coverage against a manual asks whether a citation has at least one
passing test. It is not a mapping.

In a specification a normative statement is often close to a single
testable behavior. In a manual it frequently is not. An anchor is as
much a way of dividing a long descriptive document into pieces a test
suite can reason about as it is a single assertion, and several tests
can reasonably cite one name. An author SHOULD move toward one anchor
per behavior where the prose allows it, and SHOULD NOT contort the
prose to achieve it.

> [!NOTE]
> The count of anchors in a manual is not a measure of its quality, and
> a chapter with few is not deficient. Descriptive chapters, such as an
> overview or a discussion of the model, legitimately carry almost none,
> because almost nothing in them is a claim a test could check.

---

# 5.1 Section Addressing

_Standards and Conventions / Conventions / Citation and Addressing_

> The four forms of § reference, how each number derives from the book's own structure, and how stable the numbers are across revisions.

Any part of any book in this corpus is addressable with the `§` symbol
followed by a number derived from the book's structure, in one of four
forms:

| Form | Means | Example |
|---|---|---|
| `§N` | Chapter N | PSPU `§5` |
| `§N.M` | Article M of chapter N | PSPU `§5.23` |
| `§N.A` | Appendix A of chapter N | PSPU `§5.A` |
| `§A` | Appendix A of the book | the peipkg TRM `§A` |

The examples are qualified because a bare `§` reference means "this
book" (§5.2). Within this document, `§2.1` is the RFC 2119 article and
`§A` is the normative-reference list.

## 5.1.1 Where the numbers come from

Chapter and article numbers derive from the ordering of directories and
files, and are supplied by the renderer. An author does not write them
into the text.

A chapter appendix (a file whose name marks it as an appendix, within a
chapter directory) is lettered rather than numbered, and cited in the
form `§N.A`. A book-level appendix, at the book root, is rendered as
"Appendix A" and is cited by its letter alone, with no chapter component
at all.

The two are easy to confuse and produce silently wrong references. An
author adding a second appendix to a chapter SHOULD check the rendered
index before relying on the citation.

## 5.1.2 Stability

Section numbers are positional. Inserting a chapter shifts every later
chapter, and inserting an article shifts the rest of its chapter.

A book that other documents cite SHOULD therefore append rather than
insert, where the choice exists. Where a restructure is unavoidable,
every inbound reference has to be revalidated (§5.4).

---

# 5.2 Citing between Books

_Standards and Conventions / Conventions / Citation and Addressing_

> How to cite within a book, between books, a whole book, and from code, and why the reference, not the prose beside it, is the durable part.

A citation's form depends on where it is written and what it points at.
The `§` reference is the part that has to stay correct.

## 5.2.1 Within a book

A reference to another part of the same book omits the book name:

```markdown
The claim-path set is the union defined in §5.23.
```

## 5.2.2 Between books

A reference to another book leads with that book's short name:

```markdown
A dependency is satisfied when the conditions of PSPU §5.21 hold.
```

The short name is the one declared in the book's own metadata: `PCDS`,
`PGSS`, `PSPK`, or `PSPU`. A reference to a manual names the component:
`the peipkg TRM §7.4`.

## 5.2.3 Referring to a whole book

A reference to a whole book uses the short name alone:

```markdown
All identifiers in this chapter conform to PCDS.
```

## 5.2.4 Prose and the reference are different things

A citation MAY be accompanied by prose naming what is at the other end:

```markdown
Sender authentication is performed by peer credential (§4.18).

The descriptor store article (§4.20) defines the retention rules.
```

The `§` reference is the durable part. The prose is a readability aid,
and it MAY drift across revisions without invalidating the reference.
That is also why prose alone is not a citation.

## 5.2.5 In code and in commit messages

A code comment or a test referring to a documented rule SHOULD carry the
full citation, so that a search finds every site depending on it:

```c
/* Per PCDS §5.6: inherited ACEs precede explicit ones. */
```

Where the rule carries a named citation (§5.3), cite it by name
instead. It resolves to the statement rather than to the article
holding it, so a test says exactly what it verifies:

```rust
// Verifies PCDS *sd.inherited-aces-precede-explicit
```

> [!NOTE]
> This is the mechanism that makes a specification change tractable.
> When a rule moves, the citations show which code was relying on it.
> Prose references — "as the security descriptor spec says" — do not
> survive a grep.

---

# 5.3 Granularity

_Standards and Conventions / Conventions / Citation and Addressing_

> Why the article is the unit a § reference addresses, how a named citation reaches one statement inside it, and why clause numbering and statement extents are not used.

The finest unit a `§` reference addresses is the article, in the `§N.M`
form of §5.1. Headings within an article are not numbered, and there is
no `§` form that reaches inside one.

For prose that is the right size. A reader following a reference wants
the surrounding argument, not one sentence stripped of it.

It is the wrong size for a test. A test verifies one statement, and an
article holds many, so "this test covers §5.9" cannot say which of
§5.9's statements remain unverified. For that there is a second scheme,
addressing a statement by name.

## 5.3.1 Named citations

A document MAY anchor an individual statement with a name:

```markdown
A source MUST reject a relative identifier outside its declared
range. [*psi.rejects-out-of-range-relative-id]
```

A test or a code comment outside the corpus then cites the name by
qualifying it with the book's short name:

```rust
// Verifies PGSS *psi.rejects-out-of-range-relative-id
```

An anchor is a locator, not a delimiter. It marks a place; it does not
record where the statement it names begins or ends, and nothing computes
that. A reader follows the name and reads.

The builder enforces four rules:

- A name MUST be unique within its book. Citations from outside are
  qualified by the book's short name, so book scope is enough.
- A name MUST be lowercase, in dot- or hyphen-separated segments,
  beginning and ending with an alphanumeric.
- An anchor MUST appear only in a book. A citation is addressed through
  its book, so an anchor anywhere else could never be cited.
- An anchor MUST NOT appear inside a code block or inline code, where
  it is shown rather than declared.

A retired name MUST NOT be reused for a different statement. Nothing can
detect the reuse, and every citation that already existed silently comes
to mean something else.

## 5.3.2 Why not clause numbers

A finer `§` form is possible: clauses numbered implicitly by counting
normative statements within the deepest enclosing heading, cited as
`§3.2.1(4)`, with a validation rule for checking that a clause number
still resolves.

The corpus does not use it. Specified in detail for 13 Peios documents,
it was used 18 times. Its cost is real: every editorial change to an
article renumbers the clauses after it, so every citation into that
article has to be checked against a count that nothing computes.

A name is not a count. It is written once, it does not shift when a
statement is inserted before it, and the one change that breaks it —
deleting the statement — is exactly the change that ought to break it.
The failure that rules out clause numbering does not reach the named
form.

## 5.3.3 Why a name and not an extent

A name identifies a statement; it does not describe one. Naming a
statement `copy-up.preserves-ownership` says which statement is meant,
not what it says, and the name does not grow when the statement gains an
exception. This is the same division as §5.2's: the reference is the
durable part, and the prose around it can drift.

An author might be tempted to mark where a statement ends as well as
where it is. The corpus does not offer that, deliberately. A name is
arbitrary, so nobody disputes it and nobody revises it. An extent
appears to have a correct answer, so it invites both, and every revision
of one buys nothing for the test or the code comment that cites it.
Statements also overlap and nest in prose — a rule and its exception —
in ways no bracketing scheme resolves cleanly.

## 5.3.4 Writing for citability

Because the article is the unit a `§` reference reaches, an author
SHOULD size articles so that one is a sensible thing to point at. An
article covering one rule is easy to cite; an article covering nine
unrelated rules forces every citation to be approximate.

The same applies one level down. Where a paragraph holds several
statements that need separate names, an author SHOULD split the
paragraph rather than crowd it, since a paragraph is also the unit of
context a tool can report around an anchor.

Where a single statement needs picking out and no anchor exists, a
citation MAY name it in prose alongside the article reference:

```markdown
the duplicate-key rule of §5.9
```

## 5.3.5 Reading a clause citation

A `(N)` clause suffix, in a document or a code comment, refers to the
clause-numbering scheme the corpus does not use. It SHOULD be resolved
to an article reference, or to a named citation, when the surrounding
text is next touched.

---

# 5.4 Validation

_Standards and Conventions / Conventions / Citation and Addressing_

> Why a published book must contain no reference that fails to resolve, how to check one, what the builder checks, and the two traps that survive a careless check.

A published book MUST NOT contain a reference that does not resolve. A
reference to a chapter, article, or appendix that does not exist is an
error, not a cosmetic defect: it is indistinguishable, to a reader, from
a reference to something that was deleted.

## 5.4.1 Checking

Because section numbers are positional (§5.1), any structural change
invalidates references. That includes references from other books,
which the author making the change is least likely to be looking at.

After a structural change, an author SHOULD:

1. Build the affected books and extract the actual chapter and article
   numbering from the rendered index.
2. Collect every `§` reference in the corpus.
3. Check each against that numbering.

These three steps are mechanical and worth automating. What is not
mechanical is whether a reference that still resolves still means what
the citing text implies. A reference to "the ordering rules of PSPU
`§5.6`" resolves happily after that article is rewritten to cover
something else.

> [!NOTE]
> The failure this catches is specific and common: an article count
> changes by one, every reference past that point is off by one, and
> every one of them still resolves — to the wrong article. Nothing
> reports an error, and the document is wrong in a way that reads as
> correct.

## 5.4.2 Named citations are checked by the builder

Unlike `§` references, named citations (§5.3) are validated by the
builder: a duplicated name, a malformed one, or an anchor outside a book
fails the build. What the builder cannot check is the other direction:
whether a citation from outside the corpus, in a test or a code comment,
still names a statement that exists. Deleting an anchor is therefore a
deliberate act. Search for the name across the repositories that cite
it before removing it.

## 5.4.3 Two traps

Two traps survive a careless check:

- **Line-wrapped references.** A citation split across a line break,
  with the book's short name at the end of one line and the `§` number
  at the start of the next, is easy for a checker to miss and easy for
  an author to introduce.
- **Appendix forms.** A chapter appendix and a book appendix take
  different forms (§5.1), and a reference using the wrong one resolves
  to nothing — or worse, to something.

---

# 6.1 Appendices

_Standards and Conventions / Conventions / Shared Style_

> What earns an appendix, why an appendix and the body must not duplicate each other, and how generated appendices are handled.

An appendix consolidates reference material that is defined in the body:
constants, limits, enumerated values, paths, and wire vocabularies.
Registry keys and events are not consolidated here, because regman and
evman own them (§6.2).

## 6.1.1 Appendices and the body do not duplicate

Where a constant, table, or layout is defined in an appendix, the body
MUST reference it rather than restate it. Where it is defined in the
body, the appendix MUST reference the body instead.

Exactly one of the two is the definition. The other points at it.

> [!NOTE]
> A value written down twice is a value that will eventually be written
> down differently. The appendix is where this bites hardest, because
> an appendix is exactly the kind of page that gets updated in isolation
> by someone who has not read the body — or skipped entirely by someone
> who has.

An appendix entry SHOULD carry a citation to the article that defines
what it lists, so that a reader who needs the semantics can get there in
one step.

## 6.1.2 What earns an appendix

An appendix earns its place with material a reader looks up rather than
reads through: something they arrive at knowing what they want.

A limits appendix is the clearest case. Every size bound, count cap, and
default in one table is genuinely more useful than the same figures
scattered across 20 articles, and the body articles then cite it
rather than repeating the number.

## 6.1.3 Generated appendices

An appendix listing values that exist in source, such as an application
binary interface (ABI) table, a constants list, or an error
enumeration, SHOULD be generated from that source rather than
transcribed, with a check mode that fails when the committed file is
stale.

> [!NOTE]
> The argument is empirical. In one case, a hand-written ABI appendix
> had every numeric value correct and a systematic error in the names.
> Transcription reproduces a wrong name faithfully and produces offsets
> nobody can cheaply re-check; generation cannot.

---

# 6.2 Tables and Enumerations

_Standards and Conventions / Conventions / Shared Style_

> Why every exhaustive table has exactly one home, how subsets are labeled, how disagreeing copies are resolved, and the formatting rules tables need beyond Core Style.

A table that exists in two places will eventually disagree with itself.
The rules in this article keep each exhaustive table in one place and
make every other copy visibly partial.

## 6.2.1 One canonical home

Every exhaustive table or enumeration lives in exactly one place.
Everywhere else that needs it gets a clearly framed subset and a
reference to the canonical one.

This applies across the whole corpus, not within a single book: a table
in a specification is not re-tabulated in a manual.

It also applies across the forms of Peios documentation. Registry
configuration is documented by regman, which owns it, and events by
evman. A technical reference manual does not have a configuration
reference of its own. It links to the regman and evman pages rather than
tabulating keys, values, events, or fields (see
[regman and evman](/psc/style/regman-and-evman.md)).

## 6.2.2 Subsets are labeled as subsets

A partial table MUST be framed as partial. A reader who cannot tell a
subset from the full set will treat the subset as exhaustive, which is
how a table that was correct becomes a document that is wrong.

## 6.2.3 Disagreeing copies are never averaged

Where two copies of a table disagree, the resolution is to check the
source (the implementation, or the specification that defines it) and
then to delete one of the copies. Splitting the difference produces a
third value that matches nothing.

## 6.2.4 Layout tables

A table describing a binary layout is normative in a specification
(§3.3) and descriptive in a manual, and in both cases gives fields in
declaration order.

## 6.2.5 Formatting

[Core Style](/psc/style/core-style.md) covers header rows, empty cells, and
cell length. Tables in this corpus add two rules.

A table row MUST NOT contain an unescaped `|`. A pipe inside a cell —
common when documenting bitwise expressions — silently eats a column,
and the resulting table renders as though it always had one fewer.

Very wide tables SHOULD be broken up or transposed. A table that needs
horizontal scrolling is a table nobody reads the right-hand end of.

---

# 6.3 Notes

_Standards and Conventions / Conventions / Shared Style_

> What a note carries that the surrounding text cannot, namely the reasoning behind a rule, what a note must not be used for, and how often to use one.

A note carries what the surrounding text cannot: why the rule is the way
it is, what it defends against, and what was tried instead. It is
written as a note callout:

```markdown
> [!NOTE]
> Text.
```

In a specification a note is informative and is bound by §2.2. In a
manual, where nothing is normative, a note is a change of register
rather than of authority.

This is a wider job than [Core Style](/psc/style/core-style.md) gives a note, which is an
occasional aside. The departure is deliberate (§1.1): rationale is what
keeps a rule from being removed or misread in a later revision, and the
callout keeps it visibly separate from the rule itself. Core Style's
other admonition rules still apply, including never placing two in a
row.

## 6.3.1 What a good note does

A good note does at least one of three things:

- **Names the failure the rule prevents.** Concretely, with the
  mechanism. "Without this, an attacker who controls a cache edge
  replays an older signed index and the consumer never notices" is worth
  10 lines of abstract rationale.
- **Records the alternative that was rejected, and why.** The next
  person to look at the design will otherwise propose it again.
- **Flags the counter-intuitive.** Where a reader's first instinct is
  wrong, a note is where to say so.

## 6.3.2 What a note is not

A note is never any of these:

- A restatement, in different words, of the rule it accompanies
- A place to hide a requirement (§2.2)
- An apology for a design

## 6.3.3 Density

Roughly one note per two or three articles is what has worked. A book
with a note under every heading has diluted the marker to the point
where readers skip them, which wastes the ones that matter.

---

# 6.4 Formatting

_Standards and Conventions / Conventions / Shared Style_

> What specifications and technical reference manuals add to Core Style's formatting rules, covering frontmatter without a type, descriptions that name specifics, headings, the strict build, and spelling.

[Core Style](/psc/style/core-style.md) sets the formatting rules every form of
Peios documentation shares, including line length, frontmatter titles,
heading levels and case, code formatting, and text hygiene. This article
records only what specifications and technical reference manuals add.

## 6.4.1 Frontmatter

Every article carries YAML frontmatter with a `title` and a
`description`:

```yaml
---
title: Freshness and Rollback Protection
description: Why an index that verifies is not necessarily current, and
  the monotonic versions, staleness limits, and defenses against rollback
  and freeze that address it.
---
```

The description is one sentence, wrapped at 78 columns with each
continuation line indented by two spaces.

An article in a specification or a manual is an article in a book, so it
carries no `type:` field. Core Style's page types apply to topics, and
the document class (§1.2) does the job for a book.

The description SHOULD name the specific things. "Monotonic versions,
staleness limits" beats "the freshness rules," because a corpus this
size has many articles called Overview, Structure, and Conventions, and
the description is what tells them apart.

The site build takes `--strict`, which fails on any article missing a
description; run it that way.

## 6.4.2 Headings

Because headings are not addressable (§5.3), they are navigation rather
than citation targets, and they SHOULD read as scannable labels.

## 6.4.3 Spelling

US English, as Core Style sets out. Identifiers, code, and the names of
external standards are reproduced exactly as their source spells them.

---

# 6.5 Naming External Constants

_Standards and Conventions / Conventions / Shared Style_

> Why each document uses its own reader's vocabulary for externally named constants, how divergences are tabulated once per book, and how structures are distinguished from the constants that select them.

Much of what this corpus documents already has names, given by an
external standard, by a published header, or by both, spelled
differently. A reader arrives holding one of those names and expects to
find it.

## 6.5.1 Each document uses its own reader's vocabulary

A specification is written for an implementer who has the external
standard and does not have this implementation's source. It uses the
external standard's spelling, exactly as that standard spells it.

A technical reference manual is written for someone reading alongside
the implementation. It uses the implementation's spelling, exactly as
the header declares it.

Neither adopts the other's vocabulary. A specification that named
private headers would be documenting something its reader cannot see,
and a manual that named only the standard would not match the code in
front of the reader.

## 6.5.2 Divergences are recorded once per book

Where the two vocabularies disagree, the disagreement is stated once, in
a table in an appendix, and not repeated at every use. Inline
double-naming makes prose unreadable to both audiences at once.

The table gives both spellings and nothing else. It is a lookup, not an
explanation.

## 6.5.3 Where a standard names a structure and its constant separately

Many standards give one name to a structure and another to the constant
that selects it: a record type and the numeric tag identifying that
record. A reader might arrive with either (one from a declaration, the
other from a hex dump), so a table that gives a value MUST name the
constant that carries it, not only the structure it selects.

Naming the structure in a column headed with the constant's value is the
common form of this mistake. It reads correctly and is unfindable by
half the people who need it.

## 6.5.4 The test

For any name a reader could plausibly arrive with, searching the corpus
for that exact string finds something. A name that appears only as
prose fails this test even though the surrounding text is correct. "The
offset to the owner security identifier (SID)," where the standard
calls the field `OffsetOwner`, is unfindable by the name a reader holds.

Correct and unfindable is the failure this rule exists to prevent.
Reference material is read by search.

---

# Appendix A Normative References

_Standards and Conventions / Conventions_

> The external standards this corpus depends on, and the citation format for referring to them.

This appendix lists the external standards this corpus depends on. A
book MUST NOT restate this list; it cites into it.

## A.1 Deferral

Where a document defers to an external standard, that standard's
requirements apply as though written out. A document citing one MUST
name the specific part it relies on where the whole would be ambiguous.

## A.2 Citation format

An external standard is cited in one of four forms:

| Form | Means |
|---|---|
| `RFC 2119` | The whole document |
| `RFC 8259 §7` | A specific section |
| `Unicode 16.0` | A version of a standard |
| `MS-DTYP §2.4.2` | A section of a Microsoft Open Specification |

## A.3 IETF

The corpus cites these Internet Engineering Task Force (IETF)
documents:

| Reference | Title | Used for |
|---|---|---|
| RFC 2119 | Key words for use in RFCs | Normative keywords (§2.1) |
| RFC 3339 | Date and Time on the Internet | Timestamps (§3.3) |
| RFC 3629 | UTF-8 | String encoding (§3.3) |
| RFC 3986 | Uniform Resource Identifier | URL syntax |
| RFC 4648 | Base16, Base32, Base64 Encodings | Base64, §4 alphabet |
| RFC 7468 | Textual Encodings of PKIX Structures | PEM key files |
| RFC 8032 | EdDSA | Ed25519 signing and verification |
| RFC 8259 | JSON | JSON documents |
| RFC 8478 | Zstandard | Compression |
| RFC 8915 | Network Time Security | Authenticated time |

## A.4 Microsoft Open Specifications

The Windows security model is the design source for several Peios
subsystems, and its documents are cited for parity mappings.

| Identifier | Title |
|---|---|
| MS-DTYP | Windows Data Types |
| MS-ERREF | Windows Error Codes |
| MS-LSAD | Local Security Authority (Domain Policy) Remote Protocol |
| MS-SAMR | Security Account Manager Remote Protocol |
| MS-ADTS | Active Directory Technical Specification |
| MS-GPOL | Group Policy: Core Protocol |
| MS-GPREG | Group Policy: Registry Extension Encoding |

## A.5 Unicode

The corpus cites the Unicode Standard for text handling:

<!-- lint-disable serial-comma -->
| Reference | Used for |
|---|---|
| Unicode 16.0 | Normalization forms, case folding |
| `CaseFolding.txt`, status `S` and `C` entries | Case-insensitive comparison |
<!-- lint-enable serial-comma -->

## A.6 POSIX and other standards

The corpus also cites these standards and specifications:

| Reference | Used for |
|---|---|
| IEEE Std 1003.1-2017, Chapter 14 | The pax interchange format |
| MessagePack specification | Event payload encoding |
| SPDX License List | License identifiers |

## A.7 External conventions

Some documents describe interoperation with conventions that have no
formal specification, such as the `sd_notify` readiness protocol and
the freedesktop `os-release` file. Where a document relies on
one, it MUST describe the behavior it depends on rather than citing the
convention alone, because there is no normative text at the other end of
the citation.

---

# Development Model

_Standards and Conventions / Git Workflow_

> The trial component-led development model and the role of Panorama.

Peios is trialing a component-led development model. Components develop and
release independently; monthly OS releases consolidate selected component
releases into a shared baseline. The model remains subject to revision if
experience shows that its integration or maintenance costs outweigh its
benefits.

Panorama is a development workspace for the OS. Its components remain
separate, independently versioned packages. A Git branch or tag always
identifies a whole repository state; a component name describes its purpose,
not a restriction Git enforces on the files or history it contains.

---

# Main and Component Branches

_Standards and Conventions / Git Workflow_

> How main and component version branches define development baselines.

In Panorama, `main` represents the consolidated source for the latest
qualified monthly OS release. Development for future component versions
happens on branches named `<component>/<version>`, such as `authd/0.8.0`.

A component's first development branch starts from the current `main`. When a
component version is released, its next development branch starts from the
exact released commit. For example, after tagging `authd/v0.8.0`, create
`authd/0.9.0` from that tag. Development can continue before the next monthly
includes 0.8.0.

Component versions use a semver-like `<MAJOR>.<MINOR>.<PATCH>` scheme.
Components do not have to share a version number or release on the monthly OS
schedule.

---

# Work Branches

_Standards and Conventions / Git Workflow_

> Task branch names, branch types, and where completed work is merged.

Feature work, fixes, and maintenance use task branches:

```text
<type>/<acta-task-number>-<brief-title>
```

The types are:

- `feat`: feature work.
- `fix`: bug fixes.
- `chore`: general maintenance.

Start a task branch from the component development or maintenance branch it
targets, and merge the completed work back there. Task branch names identify
the work rather than requiring a component prefix. Changes should be coherent
and include the relevant tests and documentation.

---

# Commit Style

_Standards and Conventions / Git Workflow_

> Commit subjects, scopes, task references, and breaking-change footers.

Use [Conventional Commits
1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) for Peios-authored
commits across Panorama, the kernel fork, and satellite repositories:

```text
<type>(<scope>): <imperative summary>

Optional explanation of the problem, resulting behavior, and significant
reasoning. Describe relevant validation and remaining limitations.

Refs: PEI-1234
```

Each commit should contain one coherent change, independently reviewable and
revertible where practical. Separate unrelated fixes, formatting, and
generated changes. A series can contain dependent commits when that makes the
work easier to review.

Use a concise, imperative subject: "preserve module paths", rather than
"updated packaging". Aim for 72 characters without sacrificing clarity. Use
these lowercase types:

| Type | Purpose |
| --- | --- |
| `feat` | Add functionality. |
| `fix` | Correct faulty behavior. |
| `refactor` | Restructure code without changing its behavior. |
| `perf` | Improve performance. |
| `docs` | Change documentation. |
| `test` | Add or change tests. |
| `build` | Change build tooling, dependencies, or packaging. |
| `ci` | Change continuous integration configuration or automation. |
| `chore` | Other maintenance that does not fit the types above. |
| `revert` | Revert an earlier change; identify the reverted commit in the body. |

Choose a meaningful scope. In Panorama, normally use the component. In a
dedicated repository, use the subsystem or area, such as `kacs`, `stratafs`,
or `packaging`. Omit the scope when no single scope meaningfully describes the
change. Commit types do not expand the types in
[Work Branches](/psc/git-workflow/work-branches.md).

Include a body when explanation matters. Describe the problem, resulting
behavior, and significant reasoning rather than repeating the diff. Small,
obvious changes do not need boilerplate. Validation statements must describe
what was actually checked and any relevant limitations.

Put related Acta task IDs in a `Refs:` footer, separated from the body by a
blank line. Do not append task IDs to the subject. For several tasks, use a
comma-separated list, for example `Refs: PEI-1234, PEI-1235`. A reference
records the association; it does not assert that the task is complete.
Work-branch names continue to include their Acta task number.

For a breaking change, append `!` before the subject's colon, for example
`feat(authd)!: require an explicit token audience`. Include a
`BREAKING CHANGE:` footer explaining the affected contract and how callers
or users should migrate.

Imported upstream commits and merge commits are exempt from subject-format
enforcement. Preserve upstream history and the integration ancestry required
by the branch model; do not rewrite existing history merely to adopt this
style.

Commit types can inform release notes, but package versions remain explicit
release decisions. Do not automatically bump every package touched by a
commit.

---

# Component Releases

_Standards and Conventions / Releases and Integration_

> Qualifying component releases, immutable tags, and starting the next version.

Stabilize a component on its version branch. Release candidates can be tagged
`<component>/v<version>-rc.1`, `-rc.2`, and so on. Tag the qualified final
release as `<component>/v<version>`.

Published candidate and final tags are immutable. Further corrections receive
a new candidate or version; an existing tag must not be moved to different
code. The release records the source revision and declared build inputs used
to produce its package artifacts.

After release, start the next version branch from the final tag. The release
tag remains the selection point for monthly integration, even when subsequent
work has advanced a branch.

---

# Preparing a Monthly OS Release

_Standards and Conventions / Releases and Integration_

> Selecting and qualifying component releases for a monthly OS baseline.

A monthly OS release combines qualified component releases into one Peios
baseline. Prepare each monthly on a temporary `monthly/<os-version>` branch
created from `main`:

1. Select the component releases to include, respecting their dependencies.
2. Merge their exact release tags into the monthly branch using ordinary Git
   merges. Do not merge moving development tips or unfinished component work.
   Components without an update retain their existing versions.
3. Update the Peios edition package and release lock to identify the selected
   package artifacts, source revisions, and dependency closure. Include the
   exact kernel revision from the separate kernel repository.
4. Build and qualify the assembled OS. Passing component tests alone does not
   qualify the selected combination.
5. Advance `main` to the qualified monthly result and tag it
   `peios/v<os-version>`. Publish the qualified artifacts. If the candidate
   changes during integration, repeat the affected validation before
   promotion.
6. Merge the resulting `main` into active forward-development component
   branches and validate those integrations. This gives them the new monthly
   baseline while retaining their ongoing work.

Keep `main` at the previous qualified monthly until the candidate is ready.
Preserve merge ancestry when consolidating releases and feeding the baseline
back into development; do not squash or rebase those integrations.

The monthly source tree should agree with the selected component releases. If
integration requires a change to already released component code, make a
corrected component release and update the selection. Do not silently ship
modified component code under an existing version.

Use temporary integration branches to test prospective combinations throughout
the month. Finding incompatibilities should not wait until the release cut.

---

# Changes Spanning Components

_Standards and Conventions / Releases and Integration_

> Coordinating component changes and testing explicit dependency combinations.

A component branch might need a change from another component. Merging that
component's development branch also incorporates its history, potentially
including work that is not ready for release.

Agree the integration plan before doing this. Either coordinate the affected
component releases as a group, or keep their development branches separate and
test the proposed combination on a temporary integration branch with explicit
dependency inputs. A component release must not accidentally carry unrelated,
unfinished changes into the monthly.

Builds must use declared dependencies. An unreleased sibling component must
not be substituted merely because it happens to be present in the checkout.

---

# Maintenance and Emergency Fixes

_Standards and Conventions / Releases and Integration_

> Maintaining released versions and carrying fixes into supported lines.

Create a maintenance version branch from the release being fixed. For example,
create `authd/0.8.1` from `authd/v0.8.0`, apply and qualify the correction,
then tag `authd/v0.8.1`. Do not start an older-line maintenance fix from newer
development.

Carry applicable fixes into forward development and other supported versions,
adapting and testing them as necessary. An urgent fix can land on the older
line first; carrying it forward remains part of the work.

To update an older OS monthly, create a maintenance branch from its
`peios/v<os-version>` tag, integrate the appropriate component fixes, update
its package selection and lock, and qualify a new OS patch release. Do not
merge the latest `main` into older component or OS maintenance branches: that
would import newer development or release content.

Retain published release tags and their referenced source. The duration of
support for older versions is a separate release policy; this branching model
allows maintenance without promising indefinite support.

---

# Kernel Repository

_Standards and Conventions / Releases and Integration_

> Preserving Linux ancestry and selecting exact Peios kernel revisions.

The kernel remains a separate Git repository with upstream Linux ancestry.
Panorama selects an exact retained kernel commit for each OS release.

Keep Peios kernel versions distinct from their upstream Linux base. Preserve
upstream tags such as `v7.0.9`, and use `peios/v<version>` for Peios kernel
release tags. Kernel maintenance fixes must also be selected and qualified in
the appropriate Panorama release; publishing a kernel commit alone does not
update an OS release.

---

# Scope and Precedence

_Standards and Conventions / Common Coding Rules_

> How common rules, language conventions, and repository exceptions interact.

This is the consolidated working draft developed with Jack under PEI-1506. It
records the agreed policies and applies them to the language profiles. An
unanswered proposal is not a rule. Requirements, preferences, and soft review
thresholds retain their stated strength; a formatter must not silently turn a
preference into a mandatory rule.

The [style tooling guide](/psc/style-tooling/style-tooling.md) explains the available
configurations and checks. These tools implement the policies; they do not
replace them. The kernel exception guide,
`kernel/peios/CODING_STYLE.md`, defines the scope of the kernel's deviations.
Git workflow and commit rules remain in [Using Git](/psc/git-workflow/development-model.md).

## Shared defaults and language conventions

Use the Peios default when a language's community has several reasonable
conventions. A merely popular preference does not override the Peios baseline.

Follow a language convention when it is strongly established across the
ecosystem. Jack's comparison of roughly 60% versus 90% adoption describes the
strength of consensus intended, not measured thresholds or a requirement to
invent adoption statistics.

Assess that strength using language guidance, standard tooling, and
established practice together. A configurable formatter's default or one
organization's styleguide alone does not establish an ecosystem-wide
convention. Record the reason for each language-specific departure from the
shared default; discuss unclear cases before adopting an exception.

## Rule organization

Keep common rules and per-language rules in the central Peios styleguide.
Repository-specific guides describe explicit, scoped deviations from that
baseline. A repository exception should identify the rule it overrides, the
files or language it covers, and its rationale.

Apply language syntax and required external contracts first, then explicit
repository exceptions for their stated scope, then language-specific rules,
then common defaults. An exception overrides only the rules it identifies; it
does not discard the rest of the guide. Bring unresolved conflicts back for
discussion instead of inferring an exemption.

The kernel has its own exception guide. Its kernel C conventions do not apply
to Peios-only Python scripts or Bazel files because they share a repository.

---

# Formatting

_Standards and Conventions / Common Coding Rules_

> Indentation, line length, whitespace, quoting, and brace placement.

## Indentation

Use four spaces per indentation level as the shared Peios default. Use spaces,
not hard tabs, unless a language or repository exception applies.

## Line length

Keep source lines within 100 columns as a strong expectation, not an absolute
limit. Wrap ordinary code and comments to fit. A longer line needs a concrete
readability or correctness reason; convenience alone is not an exception.

Examples include a URL that must remain intact, a diagnostic string whose
splitting would make it harder to find, or an expression that wrapping would
make materially harder to understand. Keep the exception local rather than
using it to justify long lines throughout a file.

Configure formatters to target 100 columns where supported, subject to the
agreed language and repository exceptions. Do not require awkward changes
solely to bring an otherwise justified exception under the limit.

## Text-file hygiene

Use UTF-8 encoding and LF line endings. End text files with a newline and
remove trailing whitespace. Preserve exceptions where the file format requires
a different representation or gives the whitespace meaning.

## Spacing and multiline lists

Prefer ordinary spacing rather than manually padding neighboring statements to
align columns. Allow alignment when it makes a genuine table clearer or is
produced by the agreed standard formatter. Avoid alignment that causes
unrelated lines to change merely because one identifier becomes longer.

Prefer a trailing comma after the final item of a multiline list where the
language permits it. Follow language-specific conventions and the agreed
formatter. Adding an item should not needlessly require changing the preceding
item's line.

## Quotes and statement terminators

Prefer double-quoted strings where single and double quotes are semantically
interchangeable. Allow alternative quoting when it reduces escaping. Preserve
language-specific distinctions, such as shell expansion and string
interpolation; this preference must not change a value's meaning. Use
semicolons in JavaScript and TypeScript.

## Braces

Use same-line opening braces as the common default for functions and control
flow, as in `if (ready) {`. Keep a closing brace and following `else` together
as `} else {`. Language and documented repository exceptions can override this
placement.

Where a language permits optional braces for conditionals or loops, braces can
be omitted only when the body contains one statement and the control clause
and body appear together on one line within 100 columns. Omitting braces is
permitted in that case, not required.

```c
if (!token) return INVALID_TOKEN;
```

Use braces for a body containing multiple statements, or when the condition or
body spans multiple lines. This includes a single statement placed on a line
below its condition:

```c
if (!token) {
    return INVALID_TOKEN;
}
```

If any branch in an `if` / `else if` / `else` chain needs braces, use braces
for every branch in that chain:

```c
if (!token) {
    record_failure();
    report_invalid_token();
} else {
    use_token(token);
}
```

Language requirements and documented repository exceptions still apply. Kernel
C deviations are specified in its repository guide. The optional-brace rule
applies where braces are optional control-flow delimiters; it does not replace
the block syntax of languages such as Python, Go, or Rust.

---

# Naming and Organization

_Standards and Conventions / Common Coding Rules_

> Names, units, constants, imports, visibility, and source organization.

## File organization

Group closely related code by purpose. Keep a small implementation and its
private helpers together when that makes them easier to understand; separate
unrelated features. Do not impose a blanket rule of one function or type per
file. Follow language-specific layout conventions where applicable.

## Naming

Use these shared defaults where there is no strong language convention or
documented repository exception:

| Identifier | Style | Example |
| --- | --- | --- |
| Variables | `snake_case` | `retry_count` |
| Functions | `snake_case` | `load_config` |
| Modules | `snake_case` | `package_store` |
| Types | `PascalCase` | `AccessToken` |
| Constants | `SCREAMING_SNAKE_CASE` | `MAX_RETRIES` |

Language-specific naming departures follow the [consensus
rule](/psc/common-coding-rules/scope-and-precedence.md); these defaults do not override a strongly
established language convention.

### Identifier wording

Prefer descriptive names that communicate the role of a value or operation.
Allow familiar abbreviations such as `id`, `fd`, and `url` when their meaning
is clear in context. Short local names such as `i` are acceptable in small
scopes where their purpose is obvious. A short name is not a reason to make
readers trace distant code to discover its meaning.

### Units and type information

Make units explicit in a value's name or type. For example, use `timeout_ms`
for a number of milliseconds, or `timeout` when its type conveys the unit or
duration semantics. Do not leave readers guessing whether a bare number means
seconds, milliseconds, bytes, or another unit.

In typed languages, do not encode a value's programming-language type in its
name. Use `timeout_ms`, not `timeout_ms_int`: the unit explains the meaning,
while the type declaration already supplies the representation. Name values
for their role and meaning rather than adding type prefixes or suffixes.

## Constants and literal values

Strongly avoid magic constants: fixed values whose meaning or significance is
unclear from the code. This applies to strings, numeric values, bit masks, and
other literals, not only numbers. Give them meaningful names or use
appropriate named choices so readers can understand their purpose. Explain the
reason for a particular value when its name alone cannot convey it.

For example, use `MAX_RETRIES` for a retry policy instead of an unexplained
number in the retry logic. A name should explain meaning, not merely repeat
the value. Obvious literals, such as starting a counter at `0`, do not need a
named constant solely because they are literals.

## Imports

Prefer explicit imports that make dependencies and the origins of names clear.
Avoid wildcard imports by default. This is a preference, not a hard rule:
allow exceptions when they improve clarity or follow a strongly established
language convention. Explain non-obvious exceptions where useful.

Group standard-library, third-party, and project-local imports in that order
where the language supports it. Preserve side-effect-sensitive ordering and
document narrow exceptions rather than blindly sorting imports.

## Visibility and encapsulation

Keep functions, types, and fields private or module-local by default where the
language supports it. Expose them more widely when other code needs that
interface. Keep implementation details behind the interface so they can change
without requiring changes in callers.

Encapsulation should serve a clear purpose. Do not add unnecessary getter,
setter, or forwarding wrappers solely to make simple code appear encapsulated.

## Unused and commented-out code

Remove unused code and old implementations left inside comments. Use version
control to recover previous implementations instead of retaining them in the
source for possible future use.

Keep useful documentation examples and code with a real supported purpose. An
implementation for another supported platform is not unused merely because the
current build does not select it. Establish that code is obsolete before
removing it.

---

# Interfaces and Data

_Standards and Conventions / Common Coding Rules_

> Arguments, dependencies, documentation, contracts, and data boundaries.

## Function arguments

Avoid positional arguments whose purpose is difficult to infer at the call
site. This applies to all argument types, especially booleans: a call such as
`save(file, true, false)` leaves the reader guessing what the switches
control.

Use named arguments where supported, meaningful named choices, or a clearer
interface to make the purpose apparent. Positional arguments remain
appropriate when their meaning is clear, as in `set_enabled(true)`. Do not
require readers to look up the function declaration merely to decipher an
ambiguous argument.

## Dependencies

Give a proportionate justification when adding a dependency. Explain what it
provides and consider maintenance, compatibility, licensing, build and runtime
footprint, and performance costs. Record the reasoning with the associated
work; a small, obvious choice does not need an elaborate report.

A maintained library can be appropriate for a complex parser, while a whole
package might be unnecessary for a trivial helper. There is no blanket rule to
reimplement functionality or always prefer a library.

## Documentation comments

Document public APIs and non-obvious internal contracts. Describe behavior,
errors, ownership, and locking requirements where relevant, using the
language's documentation-comment format. Explain constraints callers must
satisfy and guarantees they can rely on.

Use implementation comments to explain reasoning, invariants, or surprising
constraints that the code alone does not make clear. Keep comments accurate
when behavior changes. Do not add comments that merely repeat obvious code. An
internal function whose purpose and contract are clear from its code and names
does not need a documentation comment solely because it is a function.

## External contracts and style changes

Style cleanup must preserve behavior and externally consumed contracts. This
includes API and ABI names, calling conventions, and layouts, serialized field
names and values, configuration keys, and protocol-defined identifiers. Follow
required external names even when they differ from the naming table.

For example, renaming a local variable to match the guide must not silently
rename the JSON field it is serialized into. A symbol with no internal callers
might still be a supported public entry point; it is not obsolete on that
basis.

Intentional contract changes are functional work, not incidental formatting.
Apply the component's compatibility requirements and the breaking-change
documentation in [Commit Style](/psc/git-workflow/commit-style.md). This styleguide does not
establish a new ABI support period or authorize a breaking change during
cutover.

## Data representation

Prefer data structures that make contradictory states difficult to express.
For example, represent mutually exclusive connection states with one choice
between `connecting`, `connected`, and `disconnected`, rather than independent
boolean flags that can accidentally contradict one another. Apply this where
it simplifies the code; do not require elaborate types for every small value.

Represent missing values explicitly using the language's appropriate mechanism
rather than assigning a hidden meaning to an otherwise ordinary value. For
example, prefer an optional timeout to using `-1` for an unspecified timeout.
Respect established external APIs and formats that prescribe special values;
make their meaning clear where those representations are used.

## Validation boundaries

Make representations explicit at file-format and protocol boundaries. Specify
the text encoding and, for binary data, relevant field sizes, byte order, and
layout rather than accidentally depending on the current machine's in-memory
representation. Reference an existing format specification where it already
defines these details; do not duplicate or silently change its contract.

Deliberately platform-specific formats are permitted when their assumptions
are explicit. This rule does not require every format to be portable or choose
one universal encoding or byte order for Peios.

Validate incoming data at component boundaries and document the guarantees
internal code can rely on. For example, parse and check configuration values
before passing them around as valid settings. Internal helpers need not repeat
every check when the required guarantees already hold.

Revalidate when data can change in ways that invalidate those guarantees or
when it crosses another trust boundary. Boundary validation does not justify
trusting unchecked or subsequently changed data.

## Type annotations and inference

Where a language supports local type inference, prefer it when the type is
clear. For example, Rust's `let user = User::new()` need not repeat the `User`
type. Add an explicit annotation when it clarifies important information or
selects the intended type, such as a particular numeric representation.

Function interfaces follow their language's separate rules. Local inference
does not remove the requirement to make units and meaning clear.

---

# Errors and Resources

_Standards and Conventions / Common Coding Rules_

> Error handling and reporting, mutability, resource ownership, and cleanup.

## Error handling

Handle expected failures through the language's normal error mechanism.
Invalid input, missing files, and I/O failures are ordinary possibilities:
handle them where an appropriate response is known, or return/propagate the
error so the caller can decide what to do. Recovery is not required at every
layer.

Reserve assertions and panics for internal bugs or broken invariants:
conditions the implementation relies on being impossible during correct
operation. Do not use them as ordinary error handling for externally supplied
invalid input. Application boundaries can decide to report an error and exit.
Kernel and other component-specific requirements can impose stricter rules on
assertions or panics; this distinction does not require panicking on every
internal failure.

### Intentionally ignored errors

Make a deliberate error discard explicit in the code. Document why ignoring
the error is safe, either at the discard site or in the helper's contract. An
empty handler or an unchecked result must not conceal forgotten error
handling.

For example, after a document has been saved successfully, failure to update
an optional recent-files list can be deliberately ignored. The explanation
should make clear that the document is safely saved and that the list is
optional. This does not justify ignoring failure of the save itself.

## Error reporting

Normally report a failure once, with enough context to understand it. Add
relevant context as an error propagates, then report it at the layer
responsible for handling or presenting it. Avoid logging the same failure at
every layer.

For example, preserve the underlying file error while adding that it happened
while loading settings during application startup. Separate log entries remain
appropriate when they serve distinct operational purposes rather than merely
duplicating the same report.

## Mutability

Prefer read-only data and bindings where the language supports them. Permit
mutation when the implementation needs it, rather than making values mutable
for hypothetical future changes.

Account for changes made through helper functions or other references, not
only assignments in the current scope. Distinguish a binding that cannot be
reassigned from an object whose contents cannot change; language-specific
rules will describe the appropriate mechanisms.

## Resource ownership and cleanup

Every resource must have a clear owner responsible for releasing it. Resources
include memory, open files, and acquired locks. Make ownership transfers clear
when responsibility passes to another part of the program.

Prefer the language's automatic cleanup mechanisms where available. For
example, Go's `defer` can schedule cleanup after successful acquisition so it
runs when the surrounding function returns, including early returns. Choose
the cleanup lifetime to match the resource's actual use: function-exit cleanup
is not the same as cleanup at the end of a nested block.

Where cleanup is explicit, cover error paths and early returns as well as the
successful path. Cleanup errors still follow the error-handling rules in this
article; scheduling cleanup does not justify silently ignoring a meaningful
failure.

## Shared mutable state

Avoid mutable global state by default. Pass the data or services a function
needs explicitly so its dependencies and possible effects are visible. This
does not require a framework or elaborate wrappers.

Allow justified exceptions for genuinely shared facilities, such as a
system-wide device list. Document who owns the state, how long it lives, who
can change it and how concurrent access is coordinated.

---

# Design and Concurrency

_Standards and Conventions / Common Coding Rules_

> Control flow, review thresholds, shared code, concurrency, and performance.

## Control flow

Prefer guard clauses and early returns to handle invalid inputs, errors, and
special cases before the main path. Keep the main path shallow rather than
nesting it inside successive checks. There is no requirement to use a single
return point.

Use a shared cleanup path when resource management makes it clearer or safer.
Early returns must still release owned resources and locks correctly.

## Function size and nesting

Use soft numeric thresholds to prompt a review of function size and nesting,
not hard limits. When a threshold is exceeded, consider whether the function
still has a clear purpose and understandable control flow, and whether a
meaningful extraction or simpler structure would improve it.

Review a function when it exceeds either initial threshold:

- More than 50 nonblank, non-comment lines in its body.
- More than three nested control-flow levels.

For length, count physical body lines containing code, including
delimiter-only lines; exclude the function signature, blank lines, and
comment-only lines. Count a mixed code/comment line once. Do not compress
statements to reduce the count.

For nesting, the function body starts at level zero. Each nested conditional,
loop, switch/match, or exception-handling construct adds a level. An `else if`
chain or sibling switch/match arms are alternatives at the same level, not
successively deeper levels. Plain grouping braces do not add control-flow
levels. Assess nested functions and lambdas separately.

Do not split a cohesive function solely to satisfy a number. Crossing a
threshold alone is not an automatic CI failure.

## Shared code and duplication

Avoid duplication when repeated code represents the same concept or rule.
Share that behavior through a meaningful helper or abstraction so changes to
the common rule can be made consistently.

Similar-looking code does not necessarily represent the same idea. Allow
duplication when combining it would tie together unrelated behavior that needs
to change independently. Do not introduce a shared abstraction solely to
eliminate repeated lines.

## Background work

Give background work a clear owner, lifetime, and shutdown behavior. Define
how failures are handled. When the initiating component stops, stop its work
or deliberately transfer responsibility to an owner that remains alive.

For example, closing a window that started a download should either stop the
download or hand it to a longer-lived service. Do not leave work running
merely because its ownership or cleanup was forgotten.

## Locking

Keep locks held for as little work as practical while preserving correctness.
Avoid slow work and calls into unknown code while holding a lock where
possible. Document the acquisition order when multiple locks must be held, and
follow it consistently.

Holding a lock longer is appropriate when correctness requires it. Respect the
requirements of the particular lock and execution context; shortening a lock
hold must not expose inconsistent state or introduce races.

## Unsafe operations

Keep operations that bypass language safety checks in narrow, reviewable parts
of the code. Document why they are safe and the assumptions they depend on.
For a direct memory access, this includes the relevant guarantees about memory
lifetime and validity of the access.

Review the surrounding code that maintains those assumptions as well as the
unsafe operations themselves. A small unsafe block alone does not establish
safety if other code can invalidate its assumptions.

## Performance

Treat performance as a design concern from the outset, not an afterthought.
Choose suitable algorithms and data structures and account for known critical
paths while designing the implementation.

Permit and encourage minor to moderate increases in complexity proactively
when there is a clear reason to expect substantial relative performance gains,
especially on hot paths in critical components. A benchmark is not a
prerequisite for every such decision. Make the expected benefit and reasoning
clear; distinguish an anticipated improvement from a measured result.

Use measurements where practical to validate and refine performance decisions.
Require stronger evidence as the complexity and maintenance cost of an
optimization grow. Avoid elaborate speculative optimizations without adequate
justification. Do not require a benchmark for every straightforward
improvement or use the absence of measurements to excuse wasteful code.

---

# Tests

_Standards and Conventions / Common Coding Rules_

> Test behavior, regressions, repeatability, and useful failure details.

Prefer tests of observable behavior over tests of incidental implementation
steps. For example, check that saving and reopening a document preserves its
contents rather than requiring the save function to call particular helpers.
Internal restructuring that preserves the required behavior should not break
otherwise valid tests.

Test internal details when those details are themselves part of a real
requirement. This preference does not restrict tests to public APIs or prevent
focused tests of internal components.

## Regression tests

Strongly prefer adding a regression test when fixing a bug: a test that
catches the faulty behavior and passes with the fix. For example, a fix for a
crash on an empty filename should normally include a test of that case.

Allow justified exceptions when a useful automated test is impractical. Record
why the test was omitted and how the fix was checked in the associated work's
validation record.

## Independence and repeatability

Prefer tests that work independently and give repeatable results. Do not rely
on another test leaving files or other state behind. Control inputs such as
time, randomness, and external services where practical, and clean up
resources owned by the test.

Tests that genuinely require a network, special hardware, or randomness should
make those requirements explicit and provide enough information to investigate
failures. For example, report the seed or failing input for a randomized test
when that helps reproduce the failure.

## Names and failure details

Use descriptive test names or case descriptions that explain the behavior
being checked. For example, `empty_filename_returns_error` is more useful than
`test_7`.

Make failures informative, including relevant expected and actual values where
appropriate. Use the test framework's existing diagnostics; do not add
messages that merely repeat information it already reports.

---

# Language Conventions

_Standards and Conventions / Language Profiles_

> How language profiles apply common rules without adopting entire external guides.

These profiles apply the common rules through each language's syntax and
established conventions. They do not adopt every recommendation in an external
styleguide. An external guide's preferences do not override explicit Peios
decisions such as the shared 100-column target.

---

# Rust

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Rust.

Use four spaces, a 100-column formatter target, `snake_case`
functions/modules, `PascalCase` types, and `SCREAMING_SNAKE_CASE` constants.
Follow `rustfmt` for mechanical layout. Use the edition and formatter
version selected by the project. Required Rust braces remain required; a short
early return can be expanded by the formatter.

Apply the ownership and error rules using ordinary Rust mechanisms: `Option`
for absence, `Result` for expected failures, and ownership/`Drop` for resource
lifetimes. Use `mut` where mutation is needed and keep visibility narrow. An
`unsafe` block needs the safety explanation required by the common guide,
including assumptions maintained outside the block.

Reference: [Rust style guide](https://doc.rust-lang.org/style-guide/).

---

# Go

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Go.

Follow `gofmt`, including tab indentation and automatic alignment. Use
`mixedCaps` for unexported identifiers and `MixedCaps` for exported
identifiers, including types and constants; initial capitalization controls
visibility. Use short lowercase package names and conventional abbreviations
such as `ID` and `HTTP`. These are language exceptions to the common naming
table.

Keep the 100-column readability target where practical, but do not fight
`gofmt` or treat it as a hard limit; `gofmt` has no configurable wrapping
target. Go requires braces around control-flow bodies.

Apply the common cleanup rule using `defer` where its function-exit lifetime
is appropriate. Check meaningful cleanup errors. Ordinary failures use error
values; a goroutine still needs an owner and shutdown/failure handling.

References: [Effective Go](https://go.dev/doc/effective_go) and [Go code
review comments](https://go.dev/wiki/CodeReviewComments).

---

# Python

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Python.

Use four spaces and the shared naming conventions. Retain the Peios 100-column
target rather than adopting PEP 8's shorter line recommendation. Use
docstrings for the public interfaces and non-obvious contracts covered by the
common rule.

Give ordinary functions in maintained Python code type hints for parameters
and return values, including functions in maintained scripts. Allow justified
exceptions, and omit redundant annotations such as the usual `self` parameter.
For example, `def load_config(path: Path) -> Config` makes the interface
clear.

Type hints support readers and automatic checking; they do not validate
incoming data at runtime. The validation-boundary rules still apply.

Use context managers for scoped resource cleanup where appropriate. Use the
language's explicit absence value, `None`, without conflating it with valid
values such as zero or an empty collection.

References: [PEP 8](https://peps.python.org/pep-0008/) and [Python typing
guidance](https://typing.python.org/en/latest/guides/libraries.html).

---

# JavaScript and TypeScript

_Standards and Conventions / Language Profiles_

> Peios coding conventions for JavaScript and TypeScript.

Use conventional `camelCase` variables/functions and `PascalCase`
types/classes. Use the shared constant naming rule for named constants, not
for every local binding declared with `const`. Keep four spaces and the
100-column target: a formatter's two-space default alone does not override the
Peios baseline.

Apply read-only-by-default to bindings with `const`, and use `let` where
reassignment is needed. Remember that `const` does not freeze object contents.
The common optional-brace and explicit-argument rules apply.

In TypeScript, use strict type checking by default. Avoid `any` as a way to
bypass checking; use `unknown` for values that must be checked before use.
Allow narrow, explained exceptions where needed, such as integration with an
untyped third-party interface. Type declarations alone do not validate
external data.

That type-checking requirement concerns TypeScript; this guide does not itself
require converting JavaScript projects to TypeScript. Apply the approved
common quote preference and explicit semicolons using the pinned formatter
settings.

References: [TypeScript strict
checking](https://www.typescriptlang.org/tsconfig/strict.html) and [MDN
JavaScript
conventions](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Code_style_guide/JavaScript).

---

# C

_Standards and Conventions / Language Profiles_

> Peios coding conventions for C.

Prefer explicit struct names, such as `struct Buffer`, rather than introducing
a typedef solely to omit the `struct` keyword. Allow typedefs when they
provide a useful abstraction, such as an opaque library handle.
Kernel-specific rules remain separately scoped.

Write pointer declarations with the star next to the declared name, as in
`char *name`. Normally declare one variable per statement. Allow compact loop
declarations when their meaning remains clear. Avoid declarations such as
`char* first, second`, where only the first variable is a pointer.

Prefer ordinary functions, including inline functions where appropriate, over
function-like macros. Use function-like macros when preprocessor capabilities
are actually needed. Named constants and conditional compilation remain valid
uses of the preprocessor.

The common formatting and naming defaults apply outside documented repository
exceptions. This means, for example, four spaces and same-line function braces
for ordinary Peios C, but the Linux profile for kernel C.

---

# Shell

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Shell.

Keep shell focused on connecting existing commands. Move substantial parsing
or application logic to a more suitable language, considering complexity and
the available runtime rather than imposing a hard script-length cutoff.

Make the intended interpreter explicit and use syntax supported by that
interpreter. Apply the error and cleanup rules to command exit statuses,
pipelines, and temporary resources. Preserve argument boundaries when
expanding values: filenames containing spaces must not silently become several
arguments. Use four-space indentation where shell syntax permits it; syntax
that requires literal tabs retains them.

---

# Bazel and Starlark

_Standards and Conventions / Language Profiles_

> Peios coding conventions for Bazel and Starlark.

Use four spaces, `snake_case` functions/variables, and explicit `load`
imports. Use the language's underscore-prefixed private top-level names. Keep
the shared 100-column readability target, allowing intact labels where
splitting them is not useful. Starlark is not Python; Python-only typing and
syntax rules do not apply to it.

Use `buildifier` as the formatting baseline. Keep target declarations readable
and use shared abstractions for shared concepts rather than merely hiding
repeated declarations. Document public `.bzl` interfaces and their contracts.

Reference: [Bazel's Starlark guide](https://bazel.build/rules/bzl-style).

---

# Other Formats and Languages

_Standards and Conventions / Language Profiles_

> Peios coding conventions for other formats and languages.

Respect format-required syntax, such as tabs in Make recipes and the absence
of trailing commas in JSON. Do not apply a source-language rule mechanically
to a different format. Add a scoped language profile when a new language needs
choices that the common policy does not settle.

---

# Style Tooling

_Standards and Conventions / Style Tooling_

> Download and use the shared style configurations and qualification fixtures.

The style tooling bundle supplies pinned formatter and checker configurations,
setup scripts, and fixtures for the PSC language profiles. Component
maintainers select the applicable parts and integrate them with their own
build and CI commands.

## Download the bundle

- [Download PSC Style Tooling](/attachments/psc-style-tooling/psc-style-tooling.tar.gz).
- [Download metadata and SHA-256 checksum](/attachments/psc-style-tooling/metadata.json).

The metadata records the archive's exact byte size and SHA-256 digest. Compare
the downloaded file's digest with that record before unpacking it:

```sh
sha256sum psc-style-tooling.tar.gz
tar -xzf psc-style-tooling.tar.gz
cd psc-style-tooling
sha256sum -c MANIFEST.sha256
```

The archive contains configurations, scripts, fixtures, and dependency locks.
It excludes installed tools, caches, and local qualification results. The
download is rebuilt from the source bundle when its contents change.

## Prepare the required host

Read `runtimes.lock.json` before running the scripts. The bundle pins Linux
x86_64, Python 3.14.4, Node.js 22.22.1, npm 9.2.0, Go 1.26.0, Rust 1.98.1,
and the Rust 1.83.0 formatter for the kernel fixtures. These are fixture-host
requirements, not minimum versions for Peios components.

The bootstrap checks those versions. It fails on a mismatch and does not
install or replace the host runtime toolchains. Use a matching environment
to run the complete suite; reviewing or copying a configuration does not
require bootstrapping every language tool.

```sh
python3 scripts/bootstrap.py
python3 scripts/qualify.py
```

The bootstrap installs pinned tools beneath `.venv`, `node_modules`, `.bin`,
and `.cache`. It verifies download hashes and disables npm lifecycle scripts.
The qualification runner checks formatting stability, accepted and rejected
syntax, narrow suppressions, exclusions, and selected compiler diagnostics.
It writes the result to `results/qualification.json`.

For optional checks against a kernel checkout, supply its actual path:

```sh
python3 scripts/qualify.py --kernel /absolute/path/to/kernel
```

That mode checks the recorded kernel configuration hashes and formats copies
of selected wrappers. It does not rewrite the kernel checkout. A changed
kernel baseline needs a reviewed provenance update before those checks pass.

## Integrate a component

1. Select the configurations for the component's languages. Keep their exact
   tool versions and required lockfile entries together.
2. Set the actual source roots, language edition, runtime, module system,
   globals, and third-party stubs. The TypeScript fixture uses ES2022 and
   bundler resolution; that is not a default for Node.js applications.
3. List owned files explicitly. Exclude generated and imported code from
   formatting while retaining appropriate build and correctness checks.
4. Run the component's tests after formatting and checker changes. Add the
   same commands to developer workflows and CI.

The common EditorConfig template uses four spaces. Do not apply it over
inherited Linux code; the kernel retains its scoped formatting conventions.
The JavaScript brace checker is diagnostic only and does not rewrite control
flow.

## Keep manual review

Formatters do not establish API compatibility, ownership, naming quality, or
performance. The function-length and nesting thresholds remain review prompts.
Do not turn them into blanket build failures.

The pinned clang-tidy checks do not cover every multiline-condition or
mixed-chain brace case. C brace eligibility and those gaps still need review.
Use narrow, explained suppressions for justified exceptions, and preserve
side-effect-sensitive import order.
