fix: propagate consultation evidence before audit
Staging Backend Quality Gate / validate (push) Successful in 12m37s
Staging Backend Quality Gate / publish (push) Successful in 8m25s

This commit is contained in:
Jesse_Chen
2026-08-10 19:39:52 +08:00
parent 2697d16ef1
commit b637528f14
5 changed files with 91 additions and 13 deletions
+62 -13
View File
@@ -653,12 +653,33 @@ def _attach_local_consultation_layers(handler, chart: dict, birth_payload: dict,
except Exception as exc:
diagnostics.append({'layer': 'narayana_dasha', 'status': 'unavailable', 'reason': exc.__class__.__name__})
if planets and ascendant and not isinstance(modules.get('ashtakavarga'), dict):
try:
response = handler._compute_ashtakavarga({'planets': planets, 'ascendant': ascendant})
result = response.get('result') if isinstance(response, dict) else None
if isinstance(result, dict):
modules['ashtakavarga'] = result
except Exception as exc:
diagnostics.append({'layer': 'ashtakavarga', 'status': 'unavailable', 'reason': exc.__class__.__name__})
if planets and ascendant and not isinstance(modules.get('kp_cusps'), dict):
try:
normalized, _, asc_sign_idx = handler._normalized_planets_from_body({
'planets': planets,
'ascendant': ascendant,
})
kp_result = handler._compute_kp({'planets': normalized, 'asc_sign_idx': asc_sign_idx})
if isinstance(kp_result, dict):
modules['kp_cusps'] = kp_result
except Exception as exc:
diagnostics.append({'layer': 'kp_cusps', 'status': 'unavailable', 'reason': exc.__class__.__name__})
chart['local_consultation_layers'] = {
'status': 'ready' if not diagnostics else 'partial',
'source': 'repository_local_engines',
'available': [
name
for name in ('varga_full', 'arudha_padas', 'narayana_dasha')
for name in ('varga_full', 'arudha_padas', 'narayana_dasha', 'ashtakavarga', 'kp_cusps')
if isinstance(modules.get(name), dict) and modules.get(name)
],
'diagnostics': diagnostics,
@@ -970,7 +991,47 @@ def execute_consultation_workflow(
})
executed_steps.append('run_thematic_report')
vedastro_gateway = rectification.get('vedastro_gateway') if isinstance(rectification, dict) else None
if not isinstance(vedastro_gateway, dict):
try:
vedastro_gateway = handler._compute_vedastro_gateway_run(body)
except Exception as exc: # Gateway evidence must not block the local chart result.
vedastro_gateway = {
'scope': 'vedastro_gateway_run',
'status': 'official_blocked',
'official_closure_reason': 'gateway_invocation_error',
'error_type': type(exc).__name__,
}
vedastro_official = handler._high_rigor_vedastro_official_summary(chart)
gateway_raw = (
vedastro_gateway.get('official_raw_response')
or vedastro_gateway.get('raw_response')
or vedastro_gateway.get('vedastro_official_raw_response')
) if isinstance(vedastro_gateway, dict) else None
gateway_closure = (
vedastro_gateway.get('official_closure_state') or vedastro_gateway.get('status')
) if isinstance(vedastro_gateway, dict) else None
if gateway_closure == 'official_verified' and gateway_raw:
prior_truth = vedastro_official.get('runtime_truth') if isinstance(vedastro_official.get('runtime_truth'), dict) else {}
prior_layers = prior_truth.get('official_execution_layers') if isinstance(prior_truth.get('official_execution_layers'), dict) else {}
vedastro_official = {
**vedastro_official,
'status': 'ok',
'official_closure_state': 'official_verified',
'raw_response': gateway_raw,
'runtime_truth': {
**prior_truth,
'status': 'ok',
'official_closure_state': 'official_verified',
'official_execution_layers': {**prior_layers, 'chart_core': 'ok'},
'fallback_active': False,
},
}
elif isinstance(vedastro_gateway, dict):
vedastro_official.setdefault('official_closure_state', gateway_closure or 'official_blocked')
vedastro_official.setdefault('official_closure_reason', vedastro_gateway.get('official_closure_reason'))
vedastro_archive_manifest = handler._compute_vedastro_gateway_archives()
runtime_truth = vedastro_official.get('runtime_truth') if isinstance(vedastro_official.get('runtime_truth'), dict) else {}
interpretation_source_runtime_coverage = handler._interpretation_source_runtime_coverage(chart)
@@ -1007,18 +1068,6 @@ def execute_consultation_workflow(
blind=bool(body.get('blind') or body.get('blind_technical_mode')),
)
vedastro_gateway = rectification.get('vedastro_gateway') if isinstance(rectification, dict) else None
if not isinstance(vedastro_gateway, dict):
try:
vedastro_gateway = handler._compute_vedastro_gateway_run(body)
except Exception as exc: # Gateway evidence must not block the local chart result.
vedastro_gateway = {
'scope': 'vedastro_gateway_run',
'status': 'official_blocked',
'official_closure_reason': 'gateway_invocation_error',
'error_type': type(exc).__name__,
}
result = {
'success': True,
'endpoint': 'consultation_workflow',