fix(consult): race a bounded VedAstro gateway on the chat path
Foreground still skips the heavy overview stack, but overlaps a timed gateway so official evidence can merge when it finishes in budget. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2395,7 +2395,7 @@ def test_consultation_workflow_uses_unified_orchestrator_contract(monkeypatch) -
|
||||
assert result['reference_transparency']['similar_public_cases']['does_not_predict_user_outcome'] is True
|
||||
|
||||
|
||||
def test_consultation_foreground_defers_optional_vedastro_calls(monkeypatch) -> None:
|
||||
def test_consultation_foreground_skips_vedastro_main_entry_overview(monkeypatch) -> None:
|
||||
handler = _handler()
|
||||
seen = {}
|
||||
fake_chart = {
|
||||
@@ -2432,7 +2432,17 @@ def test_consultation_foreground_defers_optional_vedastro_calls(monkeypatch) ->
|
||||
monkeypatch.setattr(
|
||||
handler,
|
||||
'_compute_vedastro_gateway_run',
|
||||
lambda body: pytest.fail('foreground consultation must not call VedAstro gateway'),
|
||||
lambda body: {
|
||||
'scope': 'vedastro_gateway_run',
|
||||
'status': 'official_verified',
|
||||
'official_closure_state': 'official_verified',
|
||||
'official_raw_response': {
|
||||
'request_id': 'fg-ok',
|
||||
'natal': {'sun': 'Leo', 'moon': 'Taurus', 'ascendant': 'Cancer'},
|
||||
'lat': 25.03,
|
||||
'lon': 121.56,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
result = handler._compute_consultation_workflow({
|
||||
@@ -2452,10 +2462,95 @@ def test_consultation_foreground_defers_optional_vedastro_calls(monkeypatch) ->
|
||||
|
||||
assert seen['chart_body']['skip_vedastro_main_entry_overview'] is True
|
||||
assert result['success'] is True
|
||||
assert result['vedastro_gateway']['status'] == 'local_fallback'
|
||||
assert result['vedastro_gateway']['official_closure_reason'] == 'foreground_optional_evidence_deferred'
|
||||
assert result['vedastro_gateway']['official_closure_state'] == 'official_verified'
|
||||
assert result['vedastro_official']['official_closure_state'] == 'official_verified'
|
||||
assert result['consumer_context']['vedastro_cross_check']['status'] == 'executed'
|
||||
assert result['consumer_context']['vedastro_cross_check']['natal'] == {
|
||||
'sun': 'Leo',
|
||||
'moon': 'Taurus',
|
||||
'ascendant': 'Cancer',
|
||||
}
|
||||
assert 'lat' not in result['consumer_context']['vedastro_cross_check']
|
||||
assert 'lon' not in result['consumer_context']['vedastro_cross_check']
|
||||
assert result['consumer_context']['answer_policy']['can_answer_direction'] is True
|
||||
assert result['consumer_context']['answer_policy']['provider_unavailable_is_fatal'] is False
|
||||
audit = {
|
||||
row['technique']: row['status']
|
||||
for row in result['consumer_context']['technique_audit_table']
|
||||
if isinstance(row, dict)
|
||||
}
|
||||
assert audit.get('VedAstro Cloud State') == 'executed'
|
||||
assert audit.get('MEVG / Global Web Evidence') == 'blocked'
|
||||
|
||||
|
||||
def test_consultation_foreground_times_out_vedastro_without_failing_local(monkeypatch) -> None:
|
||||
handler = _handler()
|
||||
fake_chart = {
|
||||
'success': True,
|
||||
'birth_info': {'date': '1997-08-08', 'time': '05:00', 'tz': 8},
|
||||
'ascendant': {'lon': 92.0, 'sign': 'Cancer', 'sign_idx': 3},
|
||||
'planets': _sample_planets(),
|
||||
'dasha': {'periods': [{'lord': 'Sun', 'start': '2026-01-01', 'end': '2027-01-01'}]},
|
||||
'modules': {
|
||||
'varga_full': {'D9': {}, 'D10': {}},
|
||||
'arudha_padas': {'A10': {}, 'UL': {}},
|
||||
'narayana_dasha': {'periods': []},
|
||||
'ashtakavarga': {'sav': []},
|
||||
'kp_cusps': {'houses': []},
|
||||
},
|
||||
'special_lagnas': {'precision': 'sunrise_correct'},
|
||||
}
|
||||
|
||||
monkeypatch.setenv('JYOTISH_FOREGROUND_VEDASTRO_JOIN_SECONDS', '0.05')
|
||||
monkeypatch.setenv('JYOTISH_FOREGROUND_VEDASTRO_BUDGET_SECONDS', '2')
|
||||
monkeypatch.setattr(handler, '_compute_chart', lambda body: fake_chart)
|
||||
monkeypatch.setattr(handler, '_compute_rectification_gate', lambda body: {
|
||||
'success': True,
|
||||
'summary': {'recommended_events': [], 'warned': [], 'disabled': []},
|
||||
})
|
||||
monkeypatch.setattr(handler, '_compute_thematic_report', lambda body: {
|
||||
'success': True,
|
||||
'endpoint': 'thematic_report',
|
||||
'themes': {},
|
||||
})
|
||||
|
||||
def slow_gateway(body):
|
||||
time.sleep(0.4)
|
||||
return {
|
||||
'scope': 'vedastro_gateway_run',
|
||||
'status': 'official_verified',
|
||||
'official_closure_state': 'official_verified',
|
||||
'official_raw_response': {'request_id': 'too-late'},
|
||||
}
|
||||
|
||||
monkeypatch.setattr(handler, '_compute_vedastro_gateway_run', slow_gateway)
|
||||
|
||||
result = handler._compute_consultation_workflow({
|
||||
'entry_mode': 'direct_chart',
|
||||
'question': '应期与阶段问题:深入看今日',
|
||||
'theme': ['career'],
|
||||
'year': 1997,
|
||||
'month': 8,
|
||||
'day': 8,
|
||||
'hour': 5,
|
||||
'minute': 0,
|
||||
'lat': 36.420487,
|
||||
'lon': 114.209936,
|
||||
'tz': 8,
|
||||
'defer_optional_external_evidence': True,
|
||||
})
|
||||
|
||||
assert result['success'] is True
|
||||
assert result['vedastro_gateway']['official_closure_reason'] == 'foreground_optional_evidence_timeout'
|
||||
assert result['consumer_context']['vedastro_cross_check']['status'] == 'blocked'
|
||||
assert result['consumer_context']['answer_policy']['can_answer_direction'] is True
|
||||
audit = {
|
||||
row['technique']: row['status']
|
||||
for row in result['consumer_context']['technique_audit_table']
|
||||
if isinstance(row, dict)
|
||||
}
|
||||
assert audit.get('VedAstro Cloud State') == 'blocked'
|
||||
assert audit.get('MEVG / Global Web Evidence') == 'blocked'
|
||||
|
||||
|
||||
def test_consultation_workflow_accepts_western_oracle_payload(monkeypatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user