[AZ-307] c6 FreshnessGate: active-conflict reject + stable-rear downgrade

Replaces the AZ-305 pass-through _evaluate_freshness hook with the
production FreshnessGate. Loads tile_freshness_rules + sector
classifications once at construction, builds an rtree index, and on
every evaluate() either returns metadata unchanged (FRESH), stamps
freshness_label=DOWNGRADED (stable_rear + stale), or raises
FreshnessRejectionError carrying tile_id / age_seconds /
classification / rule diagnostics (active_conflict + stale).

Constructed inside PostgresFilesystemStore.from_config; the public
storage_factory signature is preserved so AZ-305 unit tests still
build the store with freshness_gate=None for the pass-through path.

FDR schema bumped to v1.2.0: adds c6.freshness.rejected and
c6.freshness.downgraded kinds (non-breaking; v1.1 readers route them
opaquely). Operator CLI `python -m c6_tile_cache.freshness_gate
explain` dry-runs the decision for a (lat, lon, capture_ts).

Adjacent hygiene: c6_tile_cache.tools._dump_tile now passes
os.environ to load_config (AZ-305 regression — load_config requires
the env mapping).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-12 19:29:11 +03:00
parent d1c1cd9ab4
commit 39ff47087f
12 changed files with 1622 additions and 17 deletions
+6
View File
@@ -50,6 +50,12 @@ dependencies = [
# `requests` because httpx ships `MockTransport` natively, so the
# FlightsApi unit tests need no extra HTTP-mocking dep.
"httpx>=0.28,<1.0",
# AZ-307 / E-C6: FreshnessGate uses an in-memory R-tree to look up
# the sector classification for a (lat, lon) at every write_tile
# call. `rtree` is the libspatialindex Python wrapper — small,
# stable, sub-microsecond point-in-rect queries at the few-hundred-
# sector scale operators ship per flight (NFR p99 ≤ 100 µs).
"rtree>=1.0,<2.0",
]
[project.optional-dependencies]