fix(health): complete consultation evidence contract

This commit is contained in:
Jesse_Chen
2026-09-04 03:29:34 +08:00
parent cf6c8a9c36
commit 837bd0820d
4 changed files with 185 additions and 4 deletions
@@ -602,6 +602,7 @@ def _sections(**overrides: str) -> dict:
'D7': 'used',
'D8': 'used',
'D9': 'used',
'D30': 'used',
'D10': 'used',
'D11': 'used',
'D12': 'used',
@@ -724,6 +725,85 @@ def test_wealth_route_requires_the_hora_chart() -> None:
assert context['core_status'] == 'degraded'
def test_health_route_requires_d30_instead_of_d9() -> None:
context = _build_consumer_context(
question='请分析健康压力窗口',
route_packet={'question_type': 'health', 'primary_theme': 'health'},
chart={'success': True},
rectification=_confirmed_birth_time(),
machine_evidence_packet=_sections(D30='missing'),
vedastro_official={'status': 'blocked'},
)
assert context['missing_route_layers'] == ['D30']
assert context['core_status'] == 'degraded'
def test_health_workflow_keeps_three_windows_and_blocked_transit_visible(monkeypatch) -> None:
handler = _handler()
chart = _base_chart()
chart['modules']['transits'] = {
'status': 'blocked',
'reason': 'fixture_no_transit_runtime',
'boundary': 'observation windows, not guaranteed events',
}
monkeypatch.setattr(handler, '_compute_chart', lambda body: chart)
monkeypatch.setattr(handler, '_compute_rectification_gate', lambda body: {
'success': True,
'effective_accuracy': 'minute',
'lagna_boundary': {'is_sensitive': False},
'summary': {'recommended_events': [], 'warned': [], 'disabled': []},
})
monkeypatch.setattr(handler, '_compute_thematic_report', lambda body: {
'success': True,
'endpoint': 'thematic_report',
'themes': {},
})
monkeypatch.setattr(handler, '_compute_vedastro_gateway_run', lambda body: {
'scope': 'vedastro_gateway_run',
'status': 'official_blocked',
'official_closure_state': 'official_blocked',
'official_closure_reason': 'fixture_no_network',
})
result = handler._compute_consultation_workflow({
'entry_mode': 'direct_chart',
'question': '请看健康压力、风险和恢复窗口',
'theme': ['health'],
'year': _BIRTH['year'],
'month': _BIRTH['month'],
'day': _BIRTH['day'],
'hour': _BIRTH['hour'],
'minute': _BIRTH['minute'],
'lat': 39.9042,
'lon': 116.4074,
'tz': 8,
'current_date': _REFERENCE_DATE,
})
assert result['routing']['question_type'] == 'health'
assert result['unified_orchestrator']['route_profile_contract']['sections'] == [
'pressure_windows',
'event_risk_windows',
'recovery_support_windows',
'non_medical_boundary',
'verification_questions',
]
sections = result['machine_evidence_packet']['sections']
assert all(sections[layer]['status'] == 'used' for layer in ('D6', 'D8', 'D30'))
assert sections['transit']['status'] == 'blocked'
assert sections['non_medical_boundary']['status'] == 'used'
assert all(layer in result['consumer_context']['available_layers'] for layer in ('D6', 'D8', 'D30'))
assert 'health_non_medical_boundary' in result['consumer_context']['domain_boundaries']
audit = {
row['technique']: row['status']
for row in result['consumer_context']['technique_audit_table']
if isinstance(row, dict)
}
assert audit['Transits / Sade Sati'] == 'blocked'
def test_domain_boundary_follows_the_route_not_the_wording() -> None:
context = _build_consumer_context(
question=_relationship_shaped_question(),