Expand description
Policy events and their JSON Lines rendering.
What:
The events one policy pass produces,
and their JSON Lines rendering.
Why:
Agents and scripts read these lines from wrapper standard error and from
git cli-git check|fix standard output.
Each event is one compact JSON object with
the incumbent’s field names and field order,
so existing readers parse native
events unchanged.
Events are numbered when rendered,
so a list of events always
prints with consecutive numbers in emission order.
In TS you’d write (pseudocode):
// process.stderr.write(renderPolicyEvents(result.events));Structs§
- Finding
Event - What:
One policy finding as it is reported.
Stringis owned UTF-8 text (sibling&strborrows);Option<T>is “a value or nothing”;&'static stris text baked into the program. Why: The record owns its message and path because events outlive the check that made them. The code is compiled-in text, so a shipped policy cannot emit an empty or misspelled code at run time. - Finding
Location - What:
A byte range inside a candidate.
A
structis a record with named fields;u64is an unsigned 64-bit integer (siblingsu32,usize). Why: Content policies point at the exact bytes of a finding.u64holds any file offset on every platform, whereusizewould be 32 bits on a 32-bit system.
Enums§
- Policy
Event - What:
Every event a policy pass can produce.
An
enumis a closed set of named alternatives; each variant carries its own fields.Vec<EventPath>is an owned list of pathnames in their event form. Why: One list of events is rendered in order, whatever mixture of kinds it holds.
Constants§
- WARN_
UNSAFE_ CODE - The code of the warning for a
warnseverity on a policy whose protectionwarnremoves.
Functions§
- event_
blocks - What:
Whether an event blocks the command.
&PolicyEventborrows the event read-only. Why: An error finding and a fixed-transform rejection keep Git from running; a warning finding and a configuration warning do not. - render_
policy_ event - What:
Render one event as a line-terminated JSON object.
&PolicyEventborrows the event; the result is owned text. Why: One function owns every field order, so two events of one kind can never differ in shape. - render_
policy_ events - What:
Render a list of events,
numbered consecutively from
first_sequence.&[PolicyEvent]borrows the list. Why: An invocation numbers its events once: events printed before the pass (a legacy configuration notice) take the first numbers and the pass continues after them.