Skip to main content

Module context_gateway

Module context_gateway 

Source
Expand description

Context Gateway v1 — the canonical, public decision contract.

Every governed piece of context carries a ContextObjectPassportV1; the gateway records one ContextDecisionV1 per object and summarises a delivery in one ContextDecisionReceiptV1, which is the single source for audit, HUD and SDK surfaces. The contract never carries content, secret values or detector matches — only digests, counts and reason codes.

Field-level invariants (principal, coverage, reason codes) are enforced at construction and deserialization; cross-field invariants by validate(), which derive and canonical_digest call. All of them fail closed:

  • an unknown principal is explicit and never carries an identity;
  • classification only ever rises through derivation (ClassificationV1::join);
  • destination constraints only accumulate;
  • a detector may not report more coverage than it inspected;
  • a receipt’s security counts must equal its per-object decisions.

Structs§

ContextDecisionReceiptV1
One governed delivery: who asked, for what, what was considered, what was withheld and why, what reached which destination under which policy.
ContextDecisionV1
The gateway’s decision about one object. Anything but a plain Allow must say why.
ContextObjectPassportV1
Security and optimisation metadata that travels with one object. Content is referenced by digest, never embedded.
ContextQualitySectionV1
Deterministic context-quality evidence for one round.
DestinationV1
Where the compiled context is delivered. Models LeanCTX itself uses (detectors, summarisers) are destinations too.
DetectorCoverageV1
What a detector actually looked at. A result never implies more coverage than recorded here.
DetectorRefV1
DetectorSignalV1
One detector’s normalised result. Carries counts only — never the matched value — so telemetry and receipts cannot leak what was detected.
EgressAdmissionReceiptV1
A versioned, content-addressable admission record for outbound request bytes.
EgressTransportObservationV1
Append-only observation of one transport attempt, linked to its admission receipt.
PolicyRefV1
The exact policy that decided: identity, optional version, content digest.
PrincipalV1
Who requested the context. Unknown never carries an id; every other kind must.
QualityRecoveryV1
QualityRetentionV1
ReasonCodeV1
Stable, machine-readable reason: [a-z][a-z0-9_.]{2,63}.
ReceiptObjectDigestV2
The key a version 2 receipt’s decision objects are digested under: its algorithm and a public identifier, never the key.
RetentionCountsV1
SecurityCountsV1
SourceCountsV1
SourceRefV1
TokenAccountV1
TransformationRecordV1
One step in an object’s lineage: which transformation turned which input digest into which output digest, and what it cost or saved.

Enums§

ClassificationV1
The one classification lattice: Public < Internal < Confidential < Restricted.
ContextDispositionV1
Per-object outcome, ordered from least to most restrictive.
CoverageKindV1
DeliveryOutcomeV1
DestinationConstraintV1
Placement constraints that only ever accumulate through derivation.
DestinationLocalityV1
DetectorCategoryV1
DetectorStatusV1
EgressAdmissionOutcomeV1
The admission lifecycle for one exact request body. This does not change the legacy ContextDecisionReceiptV1 wire format or its outcome semantics.
EgressTransportFailureV1
Bounded error classes only; raw transport errors may contain sensitive data.
EgressTransportObserverV1
EgressTransportResultV1
EgressTransportV1
GatewayModeV1
Operating posture of the gateway.
ObjectDigestAlgorithmV2
How the decision objects of a version 2 receipt are digested.
PrincipalKindV1
QualityEvidenceTierV1
How strong the quality evidence is, weakest first.
QualityProbeKindV1
Kinds of critical facts a retention probe checks — kinds only, never values.
QualityStateV1
SeverityV1
SourceKindV1
TransformationKindV1
TrustLevelV1
How far the source is trusted, least trusted first.

Constants§

MAX_DECISIONS
MAX_LINEAGE
MAX_POLICY_REFS
MAX_REASON_CODES
Bounds keep untrusted receipts from growing without limit.
MAX_SIGNALS
RECEIPT_V2_SCHEMA_VERSION
Receipt schema version 2 (AP10-C4, context-gateway-v2.md): every decisions[].object is keyed under the installation’s receipt key and the receipt names that key in ContextDecisionReceiptV1::object_digest. Version 1 receipts (plain SHA-256 objects) stay readable and valid.

Functions§

project_via_classification
Projection of the VIA classification onto the two gateway axes. VIA mixes sensitivity with placement (LocalOnly, EnterprisePrivate); the gateway keeps placement as a DestinationConstraintV1 so locality never depends on a sensitivity estimate.