jeevesagent.data¶
Data certification: provenance, freshness, and lineage policies.
Every value the agent reasons over can carry a CertifiedValue
wrapper from jeevesagent.core.types (already there). This
module adds the policies that decide whether a certified value is
acceptable in context.
Submodules¶
Classes¶
Maximum age for certified values from each source. |
|
Allow-list of source prefixes for the entire lineage chain. |
Functions¶
|
Return |
|
Return |
|
Raise |
|
Raise |
Package Contents¶
- class jeevesagent.data.FreshnessPolicy[source]¶
Maximum age for certified values from each source.
per_sourcemaps a source-prefix (matched withstartswith) to atimedelta. The first prefix that matches wins.defaultis used when no prefix matches; if alsoNone, the policy treats all values as fresh.- classmethod from_dict(per_source: dict[str, datetime.timedelta] | None = None, *, default: datetime.timedelta | None = None) FreshnessPolicy[source]¶
- max_age_for(source: str) datetime.timedelta | None[source]¶
- default: datetime.timedelta | None = None¶
- per_source: tuple[tuple[str, datetime.timedelta], Ellipsis] = ()¶
- class jeevesagent.data.LineagePolicy[source]¶
Allow-list of source prefixes for the entire lineage chain.
A
CertifiedValueis acceptable if every entry invalue.lineage(interpreted as a source prefix) starts with one of the allowed prefixes.
- jeevesagent.data.check_freshness(value: jeevesagent.core.types.CertifiedValue, policy: FreshnessPolicy, *, now: datetime.datetime | None = None) bool[source]¶
Return
Trueifvaluesatisfiespolicyatnow.Logic:
If
valid_untilis set on the value, fail ifnow > valid_until.Look up
policy.max_age_for(source). IfNone(no rule), the value is fresh by default.Otherwise fail if
now - fetched_at > max_age.
- jeevesagent.data.check_lineage(value: jeevesagent.core.types.CertifiedValue, policy: LineagePolicy) bool[source]¶
Return
Trueif every lineage source is allowed.The value’s own
sourceis also required to be in the allow-list — there’s no point trusting a chain whose tip you don’t.
- jeevesagent.data.require_freshness(value: jeevesagent.core.types.CertifiedValue, policy: FreshnessPolicy, *, now: datetime.datetime | None = None) None[source]¶
Raise
FreshnessErrorwhencheck_freshness()fails.
- jeevesagent.data.require_lineage(value: jeevesagent.core.types.CertifiedValue, policy: LineagePolicy) None[source]¶
Raise
LineageErrorwhencheck_lineage()fails.