Skip to main content

Module context_trust

Module context_trust 

Source
Expand description

Context safety: provenance, trust, and pollution detection.

Everything the tiers/map/selection assemble eventually reaches a model. That makes context a trust boundary: a tool output, a fetched file, or a tampered data file can carry prompt-injection (“ignore previous instructions”), role-switching, hidden-unicode payloads, or exfiltration hints. This module tags each source with a provenance and trust level and scans its content for those patterns, so a human (and the assistant flow) can see what is in context, where it came from, and whether it looks poisoned before it is ever sent.

Structs§

InjectionFinding
A suspicious pattern found in context content.
TrustReport
A full trust assessment of one context source.

Enums§

SourceKind
Where a piece of context came from — the root of traceability.
TrustLevel
How much the content may be trusted to be inert data rather than instructions.

Functions§

analyze_source
Assemble a full trust report for one source.
scan_injection
Scan content for injection / pollution patterns. is_code relaxes the instruction-shaped rules (expected in prose) but keeps the data-file rules.
trust_level
Derive a trust level from provenance and content classification. Workspace Rust source is trusted; data/vendored files are only semi-trusted (they can be tampered and should never carry instructions); anything external or model-generated is untrusted.