feat: list VedAstro official raw archives

This commit is contained in:
732642856
2026-07-08 20:35:42 +08:00
parent 99d00c4124
commit 09dcfb9bcc
5 changed files with 78 additions and 0 deletions
+1
View File
@@ -50,6 +50,7 @@ For large architecture or release work, also read:
| ERR-017 | Pre-work gate could pass without checking the older Round 25 fragment sweep or aggregate external-engine adapter diagnostics. | mitigated 2026-07-05 | `scripts/pre_work_check.py` must require both whole-machine sweep docs and run `scripts/diagnose_external_engine_adapters.py --json` before substantial work. |
| ERR-018 | External engine blockers can be described verbally but not carried into diagnostics. | mitigated 2026-07-05 | `diagnose_external_engine_adapters.py` must expose VedAstro closure plan and PyJHora/JHora install/license/ephemeris boundary; keep `docs/research/external_engine_blocker_research_2026_07_05.md` current. |
| ERR-019 | WorkBuddy/cloud/local acceptance summaries can invent pass counts, stale asset counts, non-existent error docs, or wrong dasha windows. | mitigated 2026-07-06 | Read `docs/research/user_invocation_acceptance_error_log_2026_07_06.md`; run `scripts/user_invocation_acceptance_check.py` and `tests/test_user_invocation_acceptance_contract.py` before accepting ordinary-user skill invocation validation claims. |
| ERR-020 | VedAstro official raw responses can be archived but hard to audit if no manifest/API listing exposes them. | mitigated 2026-07-08 | Keep `list_official_raw_response_archives()` and `GET /api/vedastro_gateway/archives`; tests must prove archived official raw responses are enumerable. |
## Fragment Sweep Command Set
+7
View File
@@ -877,6 +877,8 @@ class JyotishAPIHandler(BaseHTTPRequestHandler):
self._json(self._vedastro_status())
elif path == '/api/vedastro_gateway/status':
self._json(self._compute_vedastro_gateway_status())
elif path == '/api/vedastro_gateway/archives':
self._json(self._compute_vedastro_gateway_archives())
elif path.startswith('/api/vedastro_gateway/jobs/'):
job_id = path.rsplit('/', 1)[-1]
result = self._compute_vedastro_gateway_job(job_id)
@@ -1766,6 +1768,11 @@ class JyotishAPIHandler(BaseHTTPRequestHandler):
return gateway_status()
def _compute_vedastro_gateway_archives(self):
from scripts.vedastro_gateway import list_official_raw_response_archives
return list_official_raw_response_archives()
def _compute_vedastro_gateway_job(self, job_id):
from scripts.vedastro_gateway import get_gateway_job
+29
View File
@@ -169,6 +169,35 @@ def complete_gateway_job(job_id: str, result: dict[str, Any]) -> dict[str, Any]:
return _write_job(job)
def list_official_raw_response_archives() -> dict[str, Any]:
archives: list[dict[str, Any]] = []
queue_dir = _queue_dir()
if queue_dir.exists():
for path in sorted(queue_dir.glob("*.json")):
if path.name.endswith(".official_raw_response.json"):
continue
try:
job = json.loads(path.read_text(encoding="utf-8"))
except json.JSONDecodeError:
continue
archive = job.get("raw_response_archive") if isinstance(job, dict) else {}
if not isinstance(archive, dict) or not archive.get("official_raw_response_available"):
continue
archives.append(
{
"job_id": job.get("job_id"),
"status": archive.get("status"),
"official_raw_response_available": True,
"official_raw_response_path": archive.get("official_raw_response_path"),
}
)
return {
"scope": "vedastro_official_raw_response_archive_manifest",
"archive_count": len(archives),
"archives": archives,
}
def run_gateway_job(job_id: str) -> dict[str, Any] | None:
job = get_gateway_job(job_id)
if job is None:
+21
View File
@@ -347,6 +347,27 @@ def test_vedastro_gateway_poll_rejects_invalid_job_id(monkeypatch, tmp_path) ->
assert poller.payload()['error_code'] == 'ERR_NOT_FOUND'
def test_vedastro_gateway_archive_manifest_route(monkeypatch, tmp_path) -> None:
from scripts import vedastro_gateway
monkeypatch.setenv('VEDASTRO_GATEWAY_QUEUE_DIR', str(tmp_path))
job = vedastro_gateway.enqueue_gateway_job({'year': 1955}, question='x')
vedastro_gateway.complete_gateway_job(
job['job_id'],
{'status': 'ok', 'official_raw_response': {'source': 'vedastro_official'}},
)
reader = _ResponseCaptureHandler()
reader.path = '/api/vedastro_gateway/archives'
reader.do_GET()
assert reader.status_code == 200
payload = reader.payload()
assert payload['scope'] == 'vedastro_official_raw_response_archive_manifest'
assert payload['archive_count'] == 1
assert payload['archives'][0]['job_id'] == job['job_id']
def test_vedastro_gateway_job_run_route_executes_worker(monkeypatch, tmp_path) -> None:
from scripts import vedastro_gateway
+20
View File
@@ -138,6 +138,26 @@ def test_gateway_completion_archives_official_raw_response(monkeypatch, tmp_path
assert '"vedastro_official"' in path.read_text(encoding="utf-8")
def test_gateway_lists_official_raw_response_archives(monkeypatch, tmp_path):
from scripts import vedastro_gateway
monkeypatch.setenv("VEDASTRO_GATEWAY_QUEUE_DIR", str(tmp_path))
empty = vedastro_gateway.list_official_raw_response_archives()
assert empty["archive_count"] == 0
job = vedastro_gateway.enqueue_gateway_job({"year": 1955}, question="x")
vedastro_gateway.complete_gateway_job(
job["job_id"],
{"status": "ok", "official_raw_response": {"source": "vedastro_official"}},
)
manifest = vedastro_gateway.list_official_raw_response_archives()
assert manifest["scope"] == "vedastro_official_raw_response_archive_manifest"
assert manifest["archive_count"] == 1
assert manifest["archives"][0]["job_id"] == job["job_id"]
assert manifest["archives"][0]["official_raw_response_available"] is True
def test_gateway_run_job_executes_queued_request(monkeypatch, tmp_path):
from scripts import vedastro_gateway