From 15f3404b975217c2370372e8c633be2c0b00cb49 Mon Sep 17 00:00:00 2001 From: 732642856 <732642856@qq.com> Date: Tue, 14 Jul 2026 20:29:11 +0800 Subject: [PATCH] enforce parity visibility in high rigor workflow --- docs/research/pre_work_error_ledger.md | 1 + scripts/jyotish_api_server.py | 27 +++++++++++++++++++ tests/test_high_rigor_external_parity_gate.py | 9 +++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/test_high_rigor_external_parity_gate.py diff --git a/docs/research/pre_work_error_ledger.md b/docs/research/pre_work_error_ledger.md index fa21b4bd..c1b2c1d9 100644 --- a/docs/research/pre_work_error_ledger.md +++ b/docs/research/pre_work_error_ledger.md @@ -93,6 +93,7 @@ For large architecture or release work, also read: | ERR-060 | Legacy Sphuta functions combined approximate Gulika with interpretive signals, while the exact formula could not be inspected in the production question context. | mitigated 2026-07-14 | `prashna_sphuta.py` exposes formula-only Trisphuta/Catusphuta/Pancasphuta from the partial Gulika evidence. It is supporting-only; Kunda, life-sensitive Sphutas and Prashna verdicts remain blocked pending external numeric parity. | | ERR-061 | Full-reading passed longitude-only data to the Tajika layer, permanently blocking its speed-dependent seven-planet interaction evidence. | mitigated 2026-07-14 | Pass actual Swiss longitude/speed pairs. The output may expose only partial Ithasala/Easarapha candidates; named chains and event verdicts stay blocked pending golden cases. | | ERR-062 | A release gate could validate a parity manifest's shape without requiring all external engines to actually match, allowing “contract valid” to be mistaken for “oracle verified.” | mitigated 2026-07-14 | `three_engine_parity_replay_validator.py --require-pass` fails unless parity status is pass; `run_quality_gate.py --require-external-parity` exposes this as an explicit high-standard release requirement. | +| ERR-063 | High-rigor API output could omit the three-engine parity state, especially on plan-only responses, allowing downstream UI or MCP callers to overstate verification. | mitigated 2026-07-14 | Every high-rigor execution and plan response carries `high_rigor_external_parity`; `require_external_parity=true` sets `success=false` unless parity is pass. | ## Fragment Sweep Command Set diff --git a/scripts/jyotish_api_server.py b/scripts/jyotish_api_server.py index e50edc23..3abab4dc 100644 --- a/scripts/jyotish_api_server.py +++ b/scripts/jyotish_api_server.py @@ -184,6 +184,13 @@ def execute_consultation_workflow( question = body.get('question') or '' entry_mode = body.get('entry_mode', 'direct_chart') high_rigor = bool(body.get('return_high_rigor_shape')) + try: + from scripts.three_engine_parity_replay_validator import validate_manifest + except ModuleNotFoundError: # pragma: no cover - direct script execution + from three_engine_parity_replay_validator import validate_manifest + external_parity_gate = validate_manifest( + Path(__file__).resolve().parents[1] / 'references/oracle/three_engine_parity_replay_manifest.json' + ) route_packet = _UNIFIED_CONSULTATION_ORCHESTRATOR.resolve_route(question, themes) western_evidence_packet = _western_evidence_packet_from_body(body, route_packet) unified_contract = _UNIFIED_CONSULTATION_ORCHESTRATOR.shared_contract( @@ -235,6 +242,15 @@ def execute_consultation_workflow( result['western_evidence_packet'] = western_evidence_packet if body.get('return_high_rigor_shape'): result['endpoint'] = 'high_rigor_workflow' + result['high_rigor_external_parity'] = { + 'status': 'pass' if external_parity_gate.get('status') == 'pass' else 'blocked', + 'parity_status': external_parity_gate.get('status'), + 'reason': external_parity_gate.get('blocked_reason') or 'three_engine_parity_not_passed', + 'require_external_parity': bool(body.get('require_external_parity')), + } + if body.get('require_external_parity') and external_parity_gate.get('status') != 'pass': + result['success'] = False + result['blocked_reason'] = 'external_parity_not_passed' return result chart = dict(chart_override) if isinstance(chart_override, dict) else {} @@ -386,6 +402,7 @@ def execute_consultation_workflow( 'audited_remedies': audited_remedies, 'vedastro_official': vedastro_official, 'runtime_truth': runtime_truth, + 'external_parity_gate': external_parity_gate, 'interpretation_source_runtime_coverage': interpretation_source_runtime_coverage, 'machine_evidence_packet': machine_evidence_packet, 'western_evidence_packet': western_evidence_packet or {}, @@ -398,6 +415,16 @@ def execute_consultation_workflow( 'domain-relevant routes execute according to the configured sample/network limits.' ), } + if high_rigor: + result['high_rigor_external_parity'] = { + 'status': 'pass' if external_parity_gate.get('status') == 'pass' else 'blocked', + 'parity_status': external_parity_gate.get('status'), + 'reason': external_parity_gate.get('blocked_reason') or 'three_engine_parity_not_passed', + 'require_external_parity': bool(body.get('require_external_parity')), + } + if body.get('require_external_parity') and external_parity_gate.get('status') != 'pass': + result['success'] = False + result['blocked_reason'] = 'external_parity_not_passed' if body.get('return_high_rigor_shape'): result['endpoint'] = 'high_rigor_workflow' return result diff --git a/tests/test_high_rigor_external_parity_gate.py b/tests/test_high_rigor_external_parity_gate.py new file mode 100644 index 00000000..31625622 --- /dev/null +++ b/tests/test_high_rigor_external_parity_gate.py @@ -0,0 +1,9 @@ +from pathlib import Path + + +def test_high_rigor_workflow_exposes_external_parity_for_plan_and_execution() -> None: + source = (Path(__file__).resolve().parents[1] / "scripts" / "jyotish_api_server.py").read_text(encoding="utf-8") + + assert source.count("'high_rigor_external_parity'") >= 2 + assert source.count("'external_parity_not_passed'") >= 2 + assert "'external_parity_gate': external_parity_gate" in source