eBPF-based security platform
name: user-experience description: Keeps what shirudo shows its users consistent from one command to the next. Covers the human report layout (labels, sections, tables, checklists, verdicts, folding), one name per field across text, tables and JSON, the --json forms written through util/json.c, messages through pr_err() and its kin, option names and forms through util/options.h, help text with usage and worked examples, exit statuses, and the pages, completion and tests a change to output touches. Use when adding or changing a command, subcommand, option, message, help text, report line, table or JSON key, and when reviewing what a command prints. paths: - "shirudo.c" - "builtin-.c" - "util/log.c" - "util/log.h" - "util/json.c" - "util/options.c" - "util/options.h" - "util/help.c" - "util/help.h" - "tools/shirudo-build/.c" - "tools/gen-image/*" - "completion/" - "Documentation/reference/cli/" - "Documentation/reference/formats/**" - "Documentation/reference/failure-categories.rst"
User experience
What a command prints is an interface: the report people read, the JSON
scripts parse, the messages the journal keeps, the help an agent learns
the command from, and the exit status. shape.md of the coding skill
says it of command output, JSON keys and exit statuses: changing them
breaks their users. Write output like the commands that already
print the same kind of thing, and read the printers named below before
adding one. fields.md holds the names of the fields that
several commands show.
Human output
Results go to standard output, messages and help to standard error
(print_help() and util/log.c); only the scripts under
tools/gen-image/ print their help on standard output. A report is a
header line, then key-value lines, then sections:
printf("%-22s %s\n", "Payload sha256:", hex); /* top level */
printf("\nSignature:\n"); /* a section */
printf(" %-22s %u bytes\n", "Length:", len); /* in a section */
- Labels are
%-22s, two spaces in when they sit in a section, with their colon inside the padding, as inbuiltin-status.c,builtin-upatch.c,util/upatch_maps.c,builtin-keys.candutil/image_runtime.c. A label is sentence case and keeps acronyms as written: "Payload sha256:", "SPKI fingerprint:", "TPM:". - A section heading is sentence case and ends in a colon, after a blank line. A section that lists items carries their count: "Loaded upatches (1):", "Pinned maps (2):", "Members (3):". A section that groups the fields of one thing has none: "Signature:", "Loader:".
- An empty list prints one line,
none. A value that is absent printsnone, a value that cannot be read or formatted?, with the reason where one is known ("unavailable: %s"). - A table is indented two spaces, its first column
%-*sas wide as the longest name and at leastNAME_COLUMN_MIN(util/format.h), two spaces between columns, and a header row in upper case: NAME, LOADED, TYPE, KIND, PAYLOAD inupatch list; NAME, LOCATION, MAPS, MISSED, STATUS, AGE instatus; UPATCH, MAP, TYPE inupatch map; TYPE, STATUS, DETAIL for conditions; NAME, VERSION, SOURCE inbpm list. The header row is printed only above rows; with none, the heading takesnone. - A checklist line is
OK text,FAIL textorNOTE text: upper case, the text at column 8.say()andnote()inutil/attest.cwrite them forattest verifyandattest challenge,print_preflight()inbuiltin-init.cforinit --check-only. The last line isverdict: okorverdict: fail. statusfolds a section whose condition is OK unless--show-fullis given, and its last line names every section it folded. A section that is long and usually healthy folds the same way.- Values are lower case words (
yes,no,load,unload,bpf), digests full lower-case hex; a table column may cut a digest to 16 digits and... Condition statuses (OK,WARN,ALERT) and the checklist marks are the upper-case exceptions, in text and JSON alike. - shirudo and upatch stay lower case in output as in prose, at the start
of a line too, and so does any name the command prints. Text that comes
from outside, a name from a file or a registry's error body, goes out
through
fputs_sanitized()ortext_sanitize().
One name per field
A field that several commands show has one name: the same label in text, the same column header in tables and the matching JSON key.
- The JSON key is the label in lower case without its colon, spaces and
hyphens turned into underscores: "Payload sha256:" is
payload_sha256, "File size:" isfile_size, "Frozen serial:" isfrozen_serial. A label inside a section takes the section's word where the key would otherwise clash: "Name:" under "Signed sections:" issigned_name. - The column header is the label's head noun in upper case, the shortest
that stays unambiguous in that table: "Payload sha256:" is PAYLOAD in
upatch list. - A value keeps its meaning under its name everywhere: "Fingerprint:"
and
fingerprintare the SHA-256 of a certificate's SPKI, the valuebpm key fingerprintprints, and "Certificate sha256:" andcert_sha256the SHA-256 of its DER. - Before naming a field, look it up in fields.md and grep
for it:
git grep -n '"<key>"' -- '*.c'andgit grep -n '"<Label>:"' -- '*.c'. A field shown for the first time gets its row there.
Structured output
These commands take --json: status, init --check-only,
keys, upatch list, upatch info, upatch get, upatch map,
attest verify, attest predict, image status, bpm list,
bpm key list, bpm config register list and bpm info data.
upatch map --json=<path> appends to a file. An operation writes its
report with --report=<path>: upatch load, unload and reconcile
through util/report.c, - for standard output, and bpm tree sync.
A command that prints a report people read and gains a JSON form takes
--json.
- The JSON form is complete: every field the text shows, with the same
value in its raw form, a number as a number, a flag as a boolean,
absent or unreadable as
null. Text may fold or cut; JSON does neither. A row the text shows, an unreadable entry included, is a row in the JSON. - Write it through
util/json.conly:struct json_emit,json_obj_open(),json_kv_string(),json_kv_int(),json_kv_u64(),json_kv_bool(),json_kv_null(),json_arr_open()and their closers, andjson_kv_string_lossy()and kin for text from outside. Checke.errbeforeputs(). Neverprintf()a JSON document. - Every top-level object starts with
"schema": 1. One document goes to standard output; messages stay on standard error. - Keys are snake_case. Enumerated values are lower case:
ok,fail,notein checklists,loadandunload,bpfandjava. Formats shirudo does not own keep their spelling (mediaTypein OCI,stringValuein OTLP), only inutil/bpm_oci.c,util/bpm_package.c,util/upatch_decode.c,util/upatch_maps_otel.candtools/shirudo-build/bpm-publish.c. - Keys are stable. Adding a key is compatible; renaming or removing one, or changing a value's type or meaning, breaks the scripts that read it and changes the format page in the same commit.
Messages
A message and a help text are prose, so the writing skill applies to
them as to a page; the rules below are what output adds.
Every message goes through pr_err(), pr_warn(), pr_info() or
pr_audit() (util/log.h): syslog under LOG_AUTHPRIV and standard
error, once only under a systemd unit. A usage error goes through
opt_usage(). There is no pr_hint() on this tree; put what to check
in the message itself.
- Start with the command as typed,
upatch load:, or for a step many commands share its subsystem in lower case,tpm:,seal:. Then a statement in natural English: what failed, on what, and why. No question, no " -- " and no " + ", no shouting ("NOT"), no closing period. Name a command to run in backticks withshirudo, as`shirudo image update`. - Keep each message one literal on one source line, however long, with
its arguments on the next lines, so that
git grepfinds the text users report.check-style.shletsLONG_LINE_STRINGpass for that reason. Help strings may break after a\n. - No
\nin a message:escape()inutil/log.cprints every non-printable byte as a backslash and three octal digits, so a line break shows up as\012.util/log.cdoes not wrap; a message is one line on the terminal and in the journal. - Never name a page under
Documentation/: a target may not ship the docs. Name the command, the file, the setting (eventlog.max_bytes) or the kernel option (CONFIG_CRYPTO_MLDSA). - Where shirudo treats the node or the input as tampered or untrusted, the message states what does not match and stops there. It never suggests retrying, re-issuing with a refreshed value, unloading, rebooting or any other way around; the advice is to keep the eventlog and the journal as evidence and handle the node as an incident. A known benign cause may be stated as a fact. Retry advice belongs to operational failures only: network, disk, lock, TPM busy, stale index.
pr_audit()records a change of state, one line per change, in the same sentence form ("upatch load: %s loaded, %u programs, keyring %d").- A usage error reads
<command>: <what is wrong>and the command returnsEXIT_USAGE. Say what the command takes: "takes <file.upatch>", "takes and ", "unexpected argument '%s'", "--all goes with upatches alone".opt_next()already says "unknown option", "takes a value", "takes no value", "given twice".
Options
Every command parses its options with util/options.h: a
struct opt_spec table indexed by the command's enum, OPT_INIT(), and
a loop over opt_next() that returns 0 on OPT_DONE, EXIT_USAGE on
OPT_USAGE and on an OPT_ARG it does not take. opt_u64() and
OPT_CHOICE() read numbers and names; OPT_REPEAT, OPT_EMPTY and
OPT_OPTIONAL mark the exceptions. The parser gives every command the
same rules: --opt=value and --opt value, -h and --help,
--list-opts for completion, -- to end the options, a did-you-mean
after an unknown option.
- The same function has the same name:
-o/--outputfor a file to write,--certfor a certificate,--keyfor a signing key,--keys-dirfor the directory of both,--filefor a Beefile,--jsonfor the JSON form,--reportfor an operation's report,--vmlinux,--version.-fis--force, ingenkeyalone; the only other short options are-oand-h. - A value's placeholder is one already in use for that kind of value:
<dir>,<path>,<hex>,<cert.der>,<signing_key.pem>,<version>,<url>.completion/shirudo.bashoffers files for any placeholder_shirudo_value()does not list, so a placeholder for a value that is not a file gets its case there. HELP_OPTIONS()puts the table in the help, and--list-optsprints it, so help, completion and parser cannot drift. A subcommand group answers--list-cmdsthroughprint_subcmd_list()and resolves names withresolve_subcommand().image buildalone is parsed bytools/gen-image/shirudo-gen-verity, and completion lists its options by hand.
Help text
print_help() (util/help.c) prints a struct help: usage: and
the usage lines, the summary, the sections, then the footer.
- Every command and subcommand has usage, a summary and, where it takes
options,
HELP_OPTIONS("options:", <table>). Section headings are lower case ("options:", "subcommands:", "sync options:"). - Every command and subcommand ends its help with an
Examples:footer of at least one worked example, the most common use first. A change to a command whose help has none adds them. - An example is a whole command line from
shirudo, indented two spaces, without a prompt: the promptsoperator$andtarget#belong to the docs' console blocks (writing-docs.rst). It uses the real option names in their long form, values a reader can copy (a package ofupatches/,cve-2026-31431,kernel-obs), and<lowercase-words>where no real value exists. Never$(...)orfoo. A long line continues with\and four spaces. - Usage lines write an option as the options section does,
--cert <cert.der>, and--json[=<path>]for one whose value is optional, with the placeholders of the option table. print_help()wraps only the item summaries, atHELP_WIDTH(90). Break the summary and the footer with\nyourself, under 80 columns.- A subcommand the core binary hands to
shirudo-buildprints the helper's help, so--helpand--list-optsdescribe the same options.
Exit statuses and failure categories
0 is success, 1 a refusal or failure, EXIT_USAGE (2) a usage error,
127 a shirudo-build helper that cannot run. upatch load, unload
and reconcile also name a phase and a category in their report.
Documentation/reference/failure-categories.rst is the home of the
categories and of the exit statuses of every command; each page under
Documentation/reference/cli/ repeats its command's own in its "Exit
status" section. A change to an exit status changes both in the same
commit, and a new category goes into failure-categories.rst with the
phases that reach it.
What a change to output touches
The docs skill lists the pages; for output they are:
Documentation/reference/cli/<command>.rst: usage, options, output, examples and exit status.Documentation/reference/cheat-sheet.rstand the guides underDocumentation/start/andDocumentation/operate/that run the command:git grep -n '<old wording>' Documentation.- The format page of a JSON form:
reference/formats/status-json.rst,keepalive.rst,map-export.rst,otlp.rst,bpm-formats.rst,upatch-tree.rst. completion/shirudo.bashfor an option it lists by hand or a placeholder that is not a file.- Transcripts on a page are captured from a run in the test VM (the
testingskill boots one), never typed or edited by hand. - Tests grep output:
git grep -n '<old wording>' testing/before rewording a label, heading, message or key, and change the tests in the same commit.
Check
Before handing over a change to output:
- Run the changed command with and without
--jsonand read both: the same fields, the same values,"schema": 1first. - Labels
%-22s, headings in sentence case with a count on a list,nonewhen empty, table headers in upper case. - Every field name the change prints found in fields.md, or added there.
- Every message: a prefix, a statement, one literal on one line, no
\n, no " -- ", no " + ", noDocumentation/, no retry or workaround on a tampered state. -
<command> --helpshows usage, options and an example;<command> --list-optslists the same options. - An option that does what another command's does has its name and placeholder.
- Exit statuses checked against
failure-categories.rstand the command's page. -
git grepof every old label, message and key intesting/,Documentation/and.agents/skills/comes back empty or changed. -
.github/scripts/check-docs.shpasses; transcripts recaptured in the test VM.