Expand description
Core data model for cargo-allow source-tree exception governance.
This crate defines the shared finding, policy-entry, selector, lifecycle, match-outcome, path-normalization, and stable fingerprint primitives used by the cargo-allow crate family. It does not scan source files, invoke Cargo, compile code, or execute repository artifacts.
Structs§
- Allow
Config - Allow
Entry - Cargo
Allow Action V1 - One typed next action bound to a diagnostic.
- Cargo
Allow Diagnostic - Structured validation or execution detail.
- Cargo
Allow Diagnostic Batch V1 - A versioned batch of diagnostics computed against one repository snapshot.
- Cargo
Allow Diagnostic V1 - One semantic diagnostic. Its four judgment dimensions are independent fields; none is derived from another.
- Cargo
Allow Error - The unified error type for the cargo-allow workspace.
- Cargo
Allow Error Location - One-based source location attached to a parse or validation diagnostic.
- File
Family Rule - Finding
- Lane
Config - Last
Seen - Ledger
Posture - Orthogonal movement and posture delta for a ledger-state projection.
- Ledger
Provenance - Lifecycle
- Match
Outcome - Partial
Data Boundary - Whether a diagnostic batch covers the intended scope or was bounded by partial data / an instrument limit.
- Related
Location - A typed related location (e.g. the requirement, seam, test subject, or receipt connected to this diagnostic).
- Required
Proof - The proof a caller should rerun after applying an action.
- Requirements
- Per-ledger requirements toggles. Defaults are intentionally strict on
ownership/accountability (
owner/reason/classification/lifecycle required) and on unsafe findings (unsafe_evidence_required: true) while ordinary evidence is advisory by default (evidence_required: false). - Selector
- Simple
Date - Source
Position - A line/column position.
column == Noneis an explicit line-only (degraded) location rather than a fabricated precise column. - Source
Range - An exact source location. A
Nonerange with a path is a file-level location; aSomestart with a line-onlySourcePositionis an explicit degraded result, not a precise range pretending to be one. - Span
- Structural
Identity - Workspace
Config
Enums§
- Action
Applicability - How an action may be applied.
- Action
Kind - The closed vocabulary of what the next action is. Only deterministic,
non-inventive changes may be
ActionApplicability::Automatic. - Capped
Read Error - Why a capped text read failed.
- Cargo
Allow Diagnostic Severity - Severity for a machine-readable diagnostic carried by a command error.
- Cargo
Allow Error Kind - Structured kind for
CargoAllowError, enabling programmatic consumers (CI tooling, sibling tools) to branch on error class instead of string-matching the rendered message. - Diagnostic
Confidence - How sure the judgment is, independent of severity and posture.
- Diagnostic
Result Class - What kind of result this is. An instrument crash is not a repository defect, and unsupported capability is not a clean pass — each stays distinct.
- Diagnostic
Severity - Likely defect / user impact of a diagnostic. Independent of
RulePosture: a high-severity judgment recommendation is not automatically blocking. - Finding
Kind - Lane
Enforcement Mode - Match
Status - Missing
Obligation - The closed vocabulary of why a diagnostic’s obligation is unmet. Each names what remains unproven after structural repair.
- NetPosture
- Aggregate PR diff net posture for summary surfaces (
diff.net_posture). - Position
Base - Whether line/column offsets are zero- or one-based. Explicit so conversions are contractual rather than assumed.
- Posture
Delta - Canonical posture quality delta for a retained ledger entry or finding.
- Presence
Movement - Canonical presence movement for ledger entries and findings in a diff context.
- Related
Role - The typed role a related location plays relative to the primary diagnostic.
- Rule
Posture - How the rule gates, independent of severity.
Shadowobserves without affecting exit posture;Blockingis a deterministic gate. - Source
Encoding - Column-offset encoding for a source position. Made explicit so an LSP (UTF-16) and CLI (UTF-8) never silently disagree on a column number.
- Source
Provenance - Whether the source is authored or a generated artifact. A generated location carries different repair semantics (regenerate vs. edit).
- Workspace
Mode - The supported workspace default check modes, mirroring the CLI
--modeflag and the[workspace] default_modepolicy field. A typo’d or unsupported value (e.g."no_new") is rejected at validation time rather than silently treated as a string that never matches a real mode.
Constants§
- BUILTIN_
FILE_ FAMILY_ CODES - Built-in non-Rust family codes that repository rules must not redefine.
- DIAGNOSTIC_
KERNEL_ SCHEMA - Semantic schema/generation tag for the diagnostic kernel.
- GLOB_
MATCH_ MAX_ STEPS - Maximum recursive match steps for one glob evaluation.
- MAX_
IDENTITY_ FIELD_ LEN - Maximum length (bytes) of any source-derived string field in a
StructuralIdentity. Caps the DoS / noisy-diff surface from a scanned file with a megabyte-long identifier (#1919). Generous enough for realistic Rust paths/identifiers (e.g. deeply-qualified module paths), small enough that an artifact cannot be inflated by a single field. - POLICY_
NAME - The only recognized policy name.
- REPOSITORY_
WIDE_ FAMILIES - Finding families whose evidence is derived from repository-wide context.
- SOURCE_
FILE_ READ_ MAX_ BYTES - Maximum bytes cargo-allow will load from one source-tree text file.
- STRUCTURAL_
IDENTITY_ SCHEMA_ ID - SUPPORTED_
SCHEMA_ VERSION - Supported policy schema versions.
"1"is accepted as a legacy alias. - SUPPORTED_
SCHEMA_ VERSION_ ALIAS
Functions§
- allow_
entry_ broad_ scope - allow_
entry_ content_ fingerprint - Deterministic content fingerprint of an allow entry’s full state, for
mutation-receipt provenance (CARGO-ALLOW-SPEC-0008 “Mutation Receipt
Envelope”). The
v1canonical serialization is length-prefixed and has a fixed field order, so it is independent of Rust’sDebugformatting and platform path separators —path,glob, andselector.globare all slash-normalized before hashing, so semantically identical entries authored on Windows and Unix fingerprint identically. The SHA-256 digest is provenance evidence, not an identity or matching key. - effective_
lane_ posture_ for_ findings - finding_
identity_ key - glob_
matches - glob_
matches_ str - is_
repository_ wide_ family - json_
escape - lane_
enforcement_ mode_ for_ kind - normalize_
path - Normalize a path for source-tree identity and matching.
- normalize_
snippet - read_
file_ capped - Read arbitrary file bytes within the source-tree per-file limit.
- read_
file_ capped_ with_ limit - Read arbitrary file bytes only when the file stays within
limit. - read_
text_ file_ capped - Read a UTF-8 text file only when its size is within
SOURCE_FILE_READ_MAX_BYTES. - read_
text_ file_ capped_ with_ limit - Read a UTF-8 text file only when its size is within
limitbytes. - sha256_
v1_ bytes - Versioned SHA-256 digest for exact artifact byte bindings.
- source_
tree_ path_ is_ ignored - source_
tree_ path_ matches_ filter - source_
tree_ scope_ has_ wildcard - stable_
hash_ hex - strip_
win32_ verbatim_ prefix - Strip Win32 verbatim path prefixes (
\\?\and\\?\UNC\) from a path string for clean display in error messages and JSON output (#3180-#3187).