feat(#62): IMP-46 cache fingerprint forwarding u1~u4 (router kwarg + step12 forward + 8 scenarios)
This commit is contained in:
@@ -50,6 +50,7 @@ def route_ai_fallback(
|
||||
internal_region: dict[str, Any],
|
||||
mdx_text: str,
|
||||
client: AiFallbackClient | None = None,
|
||||
fingerprints: dict | None = None,
|
||||
) -> AiFallbackProposal | None:
|
||||
"""Route a fallback request through cache → prompt → client → validate.
|
||||
|
||||
@@ -57,13 +58,18 @@ def route_ai_fallback(
|
||||
not ``ai_adaptation_required`` — both gates short-circuit BEFORE any
|
||||
prompt/client work, so the normal-path AI call count stays at 0
|
||||
(PZ-1).
|
||||
|
||||
``fingerprints`` is forwarded into ``read_proposal`` so that
|
||||
contract / partial / catalog SHA mismatches invalidate stale cache
|
||||
entries (IMP-46 #62 Axis R). When ``None`` the cache layer skips
|
||||
fingerprint comparison (legacy behaviour).
|
||||
"""
|
||||
if not settings.ai_fallback_enabled:
|
||||
return None
|
||||
route = v4_result.get("route") or v4_result.get("imp05_route_hint")
|
||||
if route != V4_ROUTE_AI_ADAPTATION:
|
||||
return None
|
||||
cached = read_proposal(cache_key)
|
||||
cached = read_proposal(cache_key, fingerprints=fingerprints)
|
||||
if cached is not None:
|
||||
validate_proposal(
|
||||
cached,
|
||||
|
||||
@@ -200,6 +200,7 @@ def gather_step12_ai_repair_proposals(
|
||||
figma_partial_json=figma_partial_json,
|
||||
internal_region=internal_region,
|
||||
mdx_text=mdx_text,
|
||||
fingerprints=fingerprints,
|
||||
)
|
||||
except Exception as exc: # noqa: BLE001 — record + continue, no AI re-raise
|
||||
record["ai_called"] = True
|
||||
|
||||
Reference in New Issue
Block a user