Documentation
¶
Overview ¶
Package banlist is abcd's two-layer banned-names store (itd-74, spc-20). It never prints and never exits — front doors under internal/surface/* format its results. Its I/O is reads and writes under a caller-supplied repo root, plus two subprocesses it must run to tell the truth about a pattern: `git check-ignore`, to refuse a private store git would track, and `grep`, to ask the private layer's ENFORCING engine whether an expression is usable there.
The two layers differ in visibility, and that difference is the whole design:
- The PRIVATE layer is a gitignored per-machine file under the local tier (PrivateRelPath). Its FIRST line declares its format — keyed (KEY<space-or-tab>PATTERN) or legacy (one whole-line pattern per line) — and the key is the only part any surface ever renders: a name that must never appear in public content cannot be written into public config to ban it there. The committed .githooks/pre-commit guard is the enforcement point, so this package's job is the store, the format, and validation against that guard's engine — parse, add, remove, list — not the matching. The one read-only matcher it holds, MatchPrivate, asks that same engine which of a few names the layer bans, so the load check can mask them before printing.
- The PUBLIC layer is the banned_tokens family of the committed docs-lint config (PublicConfigRelPath), enforced deterministically in CI with a per-line escape. There is exactly one banned-token primitive: the hand-curated families already in that file and the entries these verbs write are the same mechanism, and verb-written entries are namespaced under PublicIDPrefix so ownership is legible.
Neither layer's writer ever rewrites a whole file from a decoded structure: the private store is edited line-wise and the public one by byte surgery on the located array, so hand-written comments, ordering, and formatting survive an edit and a review diff shows only the entry that changed.
Index ¶
- Constants
- Variables
- func MatchPrivate(repoRoot string, names []string) ([]bool, error)
- func PhrasePattern(phrases ...string) (string, error)
- func PrimaryWorktreeRoot(repoRoot string) (string, bool)
- type AddPrivateRequest
- type AddPublicRequest
- type Entry
- type GeneratedResult
- type Hit
- type InheritedReport
- type KeyedPattern
- type MigrateResult
- type PrivateReport
- type PrivateResult
- type PrivateSummary
- type PublicEntry
- type PublicReport
- type PublicResult
- type Report
Constants ¶
const ( SeverityBlocker = "blocker" SeverityWarn = "warn" )
Severity values a public entry may carry.
const PrivateDirRelPath = ".abcd/.work.local"
PrivateDirRelPath is the local-ephemeral tier that holds the private store and its lock, repo-relative and slash-separated (an os.Root path).
const PrivateReachNote = "CI cannot enforce this layer — it protects only machines that have opted in, " +
"and only the commits git runs a hook for (e.g. a fast-forward `git pull`, a rebase, `git am`, " +
"`git revert` or a cherry-pick bypasses it, as does --no-verify)"
PrivateReachNote is the one sentence every surface that describes the private layer must state (AC7). It lives here, once, because the statement is a property of the layer rather than of any one renderer: a status board, a verb, and a JSON envelope that worded it differently would let a reader believe one of them meant something weaker. It is not a limitation awaiting a fix — a pattern written into CI config is a published pattern, which is the whole reason this layer is local.
It names the SECOND limit too, because "machines that have opted in" is necessary and not sufficient. A pre-commit hook sees the commits git asks it about, and a fast-forward `git pull` creates no commit at all — the commonest uncovered path of the lot, and the one a reader is least likely to think of. git runs no hook for a rebase, `git am`, `git revert` or a cherry-pick either, `--no-verify` switches it off, and a merge commit needs the separate pre-merge-commit half.
The list is explicitly non-exhaustive ("e.g.") and carries nothing that is actually covered: `git stash pop` followed by a commit runs pre-commit like any other commit, and a bypass list naming a covered path teaches a reader to distrust the rest of it. A sentence that stopped at opt-in would leave them believing an opted-in machine is fully covered, which is the belief that gets a name committed.
const PrivateRelPath = ".abcd/.work.local/private-names.txt"
PrivateRelPath is the gitignored per-machine private banlist, repo-relative. It sits in the local-ephemeral tier, which the three-tier layout gitignores as a whole — the one placement where a private pattern is safe from a `git add -A`.
const PublicConfigRelPath = ".abcd/docs-lint.json"
PublicConfigRelPath is the committed docs-lint config that holds the public layer, repo-relative.
const PublicIDPrefix = "names/"
PublicIDPrefix namespaces the banned_tokens entries these verbs own. Entries outside it (the hand-curated harness/* and present_tense/* families) are listed but never edited or removed by a verb: the prefix is the ownership boundary.
Variables ¶
var ( // ErrNoStore reports that the layer's file does not exist. It is never // flattened into an empty success: "no store" and "no entries" are different // states, and conflating them makes silence look like protection. ErrNoStore = errors.New("banlist store is absent") // ErrInvalidKey rejects a key outside the portable key charset. ErrInvalidKey = errors.New("invalid banlist key") // ErrInvalidPattern rejects an empty or uncompilable pattern. ErrInvalidPattern = errors.New("invalid banlist pattern") // ErrInvalidSeverity rejects a severity outside blocker|warn. ErrInvalidSeverity = errors.New("invalid banlist severity") // ErrDuplicateKey rejects a key the layer already carries. ErrDuplicateKey = errors.New("banlist key already exists") // ErrUnknownKey reports a key the layer does not carry. ErrUnknownKey = errors.New("unknown banlist key") // ErrNotManaged reports an entry outside the verb-owned id namespace. ErrNotManaged = errors.New("banlist entry is not verb-managed") // ErrMalformedStore reports a store whose bytes cannot be read as this layer's // format at all (as opposed to one unusable line, which is reported by number). ErrMalformedStore = errors.New("banlist store is malformed") // ErrLegacyStore reports a private store with no format declaration and at // least one entry. Its lines are whole-line patterns, so a verb may not write a // keyed line into it: doing so would change what every other line means. ErrLegacyStore = errors.New("banlist store predates the keyed format") // ErrStoreNotIgnored reports a private store at a path git would track. The // layer's whole safety rests on the file being untracked. ErrStoreNotIgnored = errors.New("banlist private store is not gitignored") // ErrStoreLocked reports that another process holds the store's lock. ErrStoreLocked = errors.New("banlist store is locked by another process") )
Sentinel errors. A message never contains a pattern value: on the private layer the pattern is the secret, and an error is output like any other.
var ErrNoEngine = errors.New("banlist: the private layer's engine (grep) cannot be run")
ErrNoEngine is MatchPrivate's refusal when no grep can be run: without the enforcing engine there is no answer that agrees with the guard, so the caller withholds what it would have asked about.
Functions ¶
func MatchPrivate ¶ added in v0.10.0
MatchPrivate reports which of names the private layer matches, one bool per name. It is the one read-only matcher this package holds: the load check (itd-2609231434459890) prints the caller's own program names, and a name the private layer bans must not reach a terminal or the run log.
It asks the enforcing engine itself, exactly as grepAccepts and the pre-commit guard do, so the scrub and the guard cannot disagree about a match: `grep -inE` under LC_ALL=C, each pattern on STDIN through `-f -` (never in argv, where /proc/<pid>/cmdline would expose it), against the names in a 0600 temporary file that is removed afterwards. Each name must be one line: a caller passes names already made terminal-safe.
An absent store matches nothing and is no error. A store that cannot be read for what it is (unreadable, a damaged declaration, a line that does not parse), a pattern the engine refuses, or no engine at all is an error, and the caller must treat every name as matched.
func PhrasePattern ¶ added in v0.11.1
PhrasePattern projects one or more literal phrases into ONE pattern the private layer's engine (POSIX ERE, `grep -iE` under LC_ALL=C) enforces. It is the only place a literal becomes a pattern, so the guard and every scan read the same one.
- Literal: every ERE metacharacter is neutralised, as a one-byte bracket expression where POSIX makes that portable and as `\^` for the one it does not. A title is never an expression.
- Whitespace-flexible: words are split on Unicode white space and joined by one or more ASCII spaces OR non-ASCII space separators, so a no-break or thin space between two words is still the phrase.
- Case-insensitive, Unicode-aware: the engine folds ASCII itself; a non-ASCII letter is written as the alternation of its simple case-fold orbit, which the byte-oriented C locale cannot fold.
- Bounded by NEIGHBOURS, never by `\b`: the match needs a line edge or a byte that is not an ASCII letter or digit on either side. `\b` is undefined in POSIX ERE, and RE2's ASCII-only `\b` finds no boundary before a non-ASCII initial at the start of a word — a silent miss. The neighbour test errs the other way: a non-ASCII letter beside the phrase counts as a boundary, so the ban can match more than the phrase, never less.
A phrase with fewer than three letters or digits is refused, as is one that is not valid UTF-8. The error never quotes the phrase.
func PrimaryWorktreeRoot ¶ added in v0.6.8
PrimaryWorktreeRoot reports the PRIMARY checkout's working-tree root when repoRoot is inside a LINKED git worktree, and ok=false everywhere else — a standalone checkout, a directory that is not a repository, or a git that cannot answer.
git tells the two shapes apart: in a linked worktree `--git-dir` resolves to <primary>/.git/worktrees/<name> while `--git-common-dir` resolves to <primary>/.git, and in a standalone checkout the two are the same path.
WHICH working tree is the primary one is then ASKED OF GIT, never computed from the common dir's path. The arithmetic ("the common dir's parent") is wrong wherever the git dir is not inside its own working tree — a bare repository, or one made with `--separate-git-dir` — because there the parent is merely the directory that happens to HOLD the git dir. Guarding that with a `.git` existence test does not close it: clone bare into a directory that sits inside somebody else's checkout (or point `--separate-git-dir` there) and the parent is a real working tree carrying a real `.git`, so the test passes and this resolver hands back an UNRELATED repository — whose private store the caller then reads and the committed guard then enforces. That is a match/no-match oracle over another repository's private patterns, disclosure of its keys, and a cross-repo denial of service from one malformed line over there.
So: `git worktree list --porcelain` (gitutil.ListWorktrees) names the main working tree in its first record, and the candidate is then required to CONFIRM the relationship from its own side, with git rediscovering the repository from that directory (gitutil.Run scrubs GIT_DIR and friends, so discovery is not short-circuited by an inherited environment):
- its `--show-toplevel` must be the candidate itself, which no directory that merely holds a git dir can satisfy — git answers "must be run in a work tree" for a bare repo and for a `--separate-git-dir` git dir alike; and
- its `--git-common-dir` must be OUR common dir, which is what makes the answer unspoofable by layout. A neighbour checkout discovers its own `.git`, never the mirror planted inside it, so the two common dirs differ and the candidate is refused.
Every rev-parse answer is held to one absolute path (gitutil.RevParseAbsPath): on a git older than 2.31, which echoes the unknown --path-format option, the resolution fails closed, as the guard's does (iss-2608291924452604).
It is the Go half of the resolution the committed pre-commit guard makes, and it is deliberately the same three-way answer: resolution failure is ok=false, never an error. A read surface that refused to render because it could not find a SECOND store would be less useful than one that renders the first.
Types ¶
type AddPrivateRequest ¶
AddPrivateRequest adds one private entry.
type AddPublicRequest ¶
type AddPublicRequest struct {
RepoRoot string
Key string
Pattern string
Severity string
Successor string
}
AddPublicRequest adds one public entry. Severity defaults to blocker; Successor defaults to defaultSuccessor.
type Entry ¶
Entry is one private banlist entry as any surface may see it: the key and the line it sits on. There is deliberately NO pattern field — the type is the redaction, so no future rendering can leak the value by accident (AC2/AC6).
type GeneratedResult ¶ added in v0.11.1
type GeneratedResult struct {
// Path is the private store, repo-relative.
Path string `json:"path"`
// Owner names the block synced.
Owner string `json:"owner"`
// Entries counts the lines the block now holds.
Entries int `json:"entries"`
// Created reports that the store did not exist and this sync created it.
Created bool `json:"created"`
// Changed reports that the store's bytes changed; an idempotent sync is false.
Changed bool `json:"changed"`
}
GeneratedResult is the outcome of a generated-block sync.
func RefreshGeneratedBlock ¶ added in v0.11.1
func RefreshGeneratedBlock(repoRoot, owner string, entries []KeyedPattern) (GeneratedResult, error)
RefreshGeneratedBlock is SyncGeneratedBlock for a caller that must never opt a machine in: the pre-commit guard's refresh. It updates a store that already exists AND declares the keyed format, and nothing else. An absent store is ErrNoStore, with no tier, lock or file created, because creating the store writes every projected string into the repository's local tier, which is an act the person takes by hand (SyncGeneratedBlock), not a side effect of a commit. A store that does not declare the keyed format is ErrLegacyStore even when it holds no entries: the by-hand sync would declare the format there, and a refresh changes the block, never the store's format.
func SyncGeneratedBlock ¶ added in v0.11.1
func SyncGeneratedBlock(repoRoot, owner string, entries []KeyedPattern) (GeneratedResult, error)
SyncGeneratedBlock regenerates the block owner owns in the private store from entries, and touches nothing outside it.
Every key must sit in the owner's namespace (`<owner>/…`), be unique, and not be carried by a hand-written line outside the block; every pattern must be one the guard's engine accepts as written and must round-trip through the store's format. All of that is checked before anything is written, and no refusal quotes a pattern. The store's own contract holds as for AddPrivate: a legacy store with entries is refused rather than reinterpreted, the store must be gitignored, the write is contained and atomic at 0600, and the load-modify-write runs under the store's lock.
An absent store with nothing to project stays absent — a machine that has not opted in is not opted in by an empty sync. An empty projection over an existing block empties the block and keeps its fence. A second sync of the same entries writes nothing (Changed is false).
type Hit ¶ added in v0.11.1
Hit is one match found by ScanText: the key, the 1-based line, and the 0-based byte offset of the start of the matched span, counted from the start of the WHOLE scanned text — grep -b's file offset, never a column in Line. The span may begin one byte before the phrase itself, where the leading boundary consumed a non-alphanumeric neighbour; which byte it is cannot be told apart from a phrase that itself begins with punctuation without a second matcher, and there is one matcher. There is deliberately no field for the matched text: the type is the redaction, so a scan's report is safe to relay.
func ScanText ¶ added in v0.11.1
func ScanText(patterns []KeyedPattern, text []byte) ([]Hit, error)
ScanText reports every place the given patterns match text, by key, line and text offset (see Hit), through the guard's own engine: `grep -inobaE` under LC_ALL=C, each pattern on STDIN (never argv), against the text in a 0600 temporary file removed afterwards. It is the read-only twin of the pre-commit guard, so a text this scan calls clean is a text the guard would pass, line for line.
No grep is ErrNoEngine; a pattern the engine refuses is ErrInvalidPattern naming the key. Neither the pattern nor any matched byte is returned or quoted.
type InheritedReport ¶ added in v0.6.8
type InheritedReport struct {
// Private is the primary checkout's private layer, read there. Its Path is
// repo-relative, so it names the store's location without naming the checkout.
Private PrivateReport `json:"private"`
}
InheritedReport is the private layer a LINKED git worktree inherits from its primary checkout: that checkout's private layer exactly as ListPrivate reads it there.
It exists because the local-ephemeral tier is PER-WORKTREE and gitignored, so a checkout made with `git worktree add` starts with no private store at all. The committed guard resolves the primary checkout's store and enforces it in the worktree (itd-150); a status surface that did not report the same layer would call a worktree unprotected while every commit made in it is being checked, which is the one thing a board about a guard must never do.
It carries NO absolute path, and that is the point. A checkout's directory name is very often the private name its own store bans — a project codename is the commonest entry there is — and this layer's whole contract is that no pattern value reaches output. The report is the datum that crosses to a front door, and every front door writes it somewhere durable: stdout, an agent transcript, a CI log, a redirected `--json` file. So the location the reader needs is said in words ("the primary checkout's <store path>"), exactly as the committed shell guard says it; the resolved root stays inside PrimaryWorktreeRoot's caller, where it is used to read the store and nothing else. Withholding the field is a stronger restraint than redacting it: RedactHome only rewrites a `$HOME` prefix and leaves the directory name — the banned string — standing.
func InheritedPrivate ¶ added in v0.6.8
func InheritedPrivate(repoRoot string) (*InheritedReport, error)
InheritedPrivate reports the private layer repoRoot inherits from its primary checkout, or nil when there is nothing to inherit — repoRoot is not a linked worktree, or the primary checkout has no store of its own.
An unreadable or malformed primary store IS an error: the guard refuses every commit in that state, so a surface that quietly rendered "nothing inherited" would report a repo as healthy while nothing in it can be committed.
type KeyedPattern ¶ added in v0.11.1
KeyedPattern is one entry a caller hands the private layer: a non-secret key and the POSIX ERE the guard's engine enforces. The pattern never reaches any output.
type MigrateResult ¶ added in v0.11.1
type MigrateResult struct {
// Path is the private store, repo-relative.
Path string `json:"path"`
// Migrated reports that the store was legacy and is now keyed; a store that
// already declared the keyed format is left byte-for-byte alone (false).
Migrated bool `json:"migrated"`
// Entries counts the entries the store holds after the call.
Entries int `json:"entries"`
}
MigrateResult is the outcome of a legacy-store migration.
func MigratePrivate ¶ added in v0.11.1
func MigratePrivate(repoRoot string) (MigrateResult, error)
MigratePrivate converts a legacy private store — no format declaration, every entry a whole-line pattern — to the keyed format in place, so the verbs that refuse a legacy store (add, remove, a generated-block sync) can act on it.
Nothing a line matches changes. Each entry keeps its exact pattern bytes under the key the guard already prints for it, entry-<its line in the legacy file>, so a refusal names the same key before and after. The declaration becomes line 1; every comment and blank line survives in place, and only a leading byte-order mark and the trailing blanks of an entry line (which neither reader ever matched) are dropped. Each composed line is proved to parse back to exactly its key and pattern before anything is written, and a line that would not is refused by number. A keyed store is left alone; an absent one is ErrNoStore. The store's contract holds as for AddPrivate: it must be gitignored, and the write is contained, atomic, 0600 and under the store's lock. No pattern is ever quoted.
type PrivateReport ¶
type PrivateReport struct {
// Path is the store's repo-relative location (reported whether or not it exists).
Path string `json:"path"`
// Present distinguishes "this machine has not opted in" from "opted in with no
// entries" — the layer is local by construction, so its absence is a fact a
// surface must be able to state plainly.
Present bool `json:"present"`
// Keyed reports the store's format: true when its first line declares the
// keyed format, false for a legacy whole-line-pattern store. It changes what
// every other line MEANS, so a diagnostic that hid it would be unreadable.
Keyed bool `json:"keyed"`
// Entries are the keys, in file order. A line that does not parse contributes
// none: it has no key, and its text may be the secret.
Entries []Entry `json:"entries"`
// Malformed lists the 1-based line numbers the enforcement engine cannot use —
// a line that does not parse in this store's format, or a pattern grep refuses.
// The guard refuses every commit until they are fixed. Line numbers only: the
// content of such a line is withheld like any other.
Malformed []int `json:"malformed_lines"`
// Inert lists the 1-based line numbers whose pattern the engine ACCEPTS but
// reads differently from the language it was written in (a Perl-style escape,
// an inline flag group). The guard does not refuse these — grep may read them
// differently than written, which is the more dangerous failure and a different
// remedy.
Inert []int `json:"inert_lines"`
// NotIgnored reports a present store at a path git does NOT ignore — the whole
// layer rests on the file being untracked, so a not-ignored store is one
// `git add -A` from committing the very patterns it exists to keep out of
// history. The read path surfaces it (AddPrivate refuses outright); it is only
// meaningful when the store is Present and inside a git repo.
NotIgnored bool `json:"not_ignored"`
// IgnoreUnanswerable reports a present store in a repo-shaped tree git cannot
// answer for (git absent from PATH, a corrupt .git, an ownership refusal): the
// store may or may not be ignored, and nothing can prove which. The warning
// direction is the same as NotIgnored — the proof the layer rests on is
// missing — but the remedy is restoring git's answer, not editing .gitignore.
IgnoreUnanswerable bool `json:"ignore_unanswerable"`
// Reach is the one-sentence statement of what the private layer does and does
// not protect (PrivateReachNote), carried on the report unconditionally. It is
// on the struct rather than added by a renderer so a surface that only
// summarises the JSON can relay the caveat verbatim rather than paraphrase a
// reach that CI cannot enforce — matching the ahoy status board, which carries
// the same note as `banlist.reach`.
Reach string `json:"reach"`
}
PrivateReport is the private layer's state.
func ListPrivate ¶
func ListPrivate(repoRoot string) (PrivateReport, error)
ListPrivate reports the private layer: its format, its keys, the lines the enforcement engine cannot use, the lines it accepts but reads differently, and whether this machine has opted in at all.
type PrivateResult ¶
type PrivateResult struct {
Path string `json:"path"`
Key string `json:"key"`
Entries int `json:"entries"`
}
PrivateResult is the outcome of a private-layer mutation.
func AddPrivate ¶
func AddPrivate(req AddPrivateRequest) (PrivateResult, error)
AddPrivate appends one entry, creating the store (and the local tier directory) when absent. Every check happens before the write, and the load-modify-write runs under the store's lock so a concurrent add or an out-of-band refresh cannot drop an entry.
func RemovePrivate ¶
func RemovePrivate(repoRoot, key string) (PrivateResult, error)
RemovePrivate drops the entry with the given key. The edit is a line deletion — every other byte of the store survives, so comments and alignment are preserved.
type PrivateSummary ¶
type PrivateSummary struct {
// Present distinguishes "this machine has not opted in" from "opted in with no
// entries" — the two check exactly as much, and both must be visible as distinct.
Present bool `json:"present"`
// Keyed reports the declared format, which decides what every line means.
Keyed bool `json:"keyed"`
// Entries counts the lines a reader can use. Unparsed counts the rest — the
// guard refuses every commit while any exists.
Entries int `json:"entries"`
Unparsed int `json:"unparsed"`
}
PrivateSummary is the private layer's SHAPE without its content: what a status board may say about it. Every field is non-secret by construction — a count, a format flag, and git's ignore verdict — and there is no way to reach a pattern from here.
It exists because ListPrivate is a diagnostic, not a status: ListPrivate asks the ENFORCEMENT engine about every entry, which is one grep subprocess per line. That is the right price for `abcd banlist list --private` during an incident and the wrong one for a detection pass that runs on every `abcd ahoy` and on the session hooks. The parser is shared, so the two cannot disagree about what an entry is; only the engine question is skipped, and Unparsed therefore counts lines that do not PARSE, not lines grep would refuse.
func SummarisePrivate ¶
func SummarisePrivate(repoRoot string) (PrivateSummary, error)
SummarisePrivate reports the private layer's shape for a status surface. An absent store is a zero-value summary and NO error: not opting in is a state, not a fault. A store that cannot be read for what it is — a damaged declaration, an unreadable file — is an error, because a status board must not render it as healthy.
It asks git NOTHING. The ignore question belongs to the caller, which is usually asking it about several paths at once and can batch them into one subprocess; a summariser that spawned its own would multiply forks across a detection pass that runs on every status render.
type PublicEntry ¶
type PublicEntry struct {
ID string `json:"id"`
Pattern string `json:"pattern"`
Severity string `json:"severity"`
// Key is the id with the managed prefix stripped, empty for an entry outside
// the verb-owned namespace.
Key string `json:"key"`
// Managed marks the entries these verbs own and may remove.
Managed bool `json:"managed"`
}
PublicEntry is one entry of the public banned-token family. Public entries render IN FULL: they are committed, reviewable config, and the pattern is the reviewable part (AC6).
type PublicReport ¶
type PublicReport struct {
Path string `json:"path"`
Present bool `json:"present"`
Entries []PublicEntry `json:"entries"`
}
PublicReport is the public layer's state.
func ListPublic ¶
func ListPublic(repoRoot string) (PublicReport, error)
ListPublic reports the whole banned_tokens family — the hand-curated entries as well as the verb-managed ones. There is one primitive, so a list that hid the hand-curated half would misrepresent what gates the repo.
type PublicResult ¶
type PublicResult struct {
Path string `json:"path"`
Entry PublicEntry `json:"entry"`
}
PublicResult is the outcome of a public-layer mutation.
func AddPublic ¶
func AddPublic(req AddPublicRequest) (PublicResult, error)
AddPublic inserts one entry into the banned_tokens family. The edit is byte surgery on the located array — one inserted line — so unrelated keys, entry order, and the file's formatting survive byte-for-byte and a review diff shows only the new entry.
func RemovePublic ¶
func RemovePublic(repoRoot, key string) (PublicResult, error)
RemovePublic drops the verb-managed entry with the given key. Entries outside the managed namespace are refused: the hand-curated families are edited in the config by a human, in a reviewable commit, never by a verb.
type Report ¶
type Report struct {
Private PrivateReport `json:"private"`
Public PublicReport `json:"public"`
// Inherited is the private layer a LINKED git worktree inherits from its primary
// checkout, and nil everywhere else — so a standalone checkout's envelope is
// exactly what it always was. It is carried on the one read every status surface
// makes, rather than left for each to remember to ask: the guard enforces that
// layer in a worktree (itd-150), and a surface that forgot it would report a
// worktree unprotected while every commit made in it is checked.
Inherited *InheritedReport `json:"inherited,omitempty"`
}
Report is both layers at once, for the read-only render.