mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2026-03-24 22:16:31 +01:00
feat: add RandomService, seed diagnostics endpoint, and random mode docs (#59)
Some checks are pending
CI / build (push) Waiting to run
Some checks are pending
CI / build (push) Waiting to run
This commit is contained in:
parent
7e5a29dd74
commit
4aa41adb20
10 changed files with 697 additions and 4 deletions
|
|
@ -2177,6 +2177,27 @@ async def api_random_seed_favorite(request: Request):
|
|||
rid = getattr(request.state, "request_id", None)
|
||||
return {"ok": True, "favorites": favs, "request_id": rid}
|
||||
|
||||
@app.get("/api/random/diagnostics")
|
||||
async def api_random_diagnostics(request: Request):
|
||||
"""Seed verification diagnostics (requires WEB_RANDOM_DIAGNOSTICS=1)."""
|
||||
if not os.environ.get("WEB_RANDOM_DIAGNOSTICS"):
|
||||
raise HTTPException(status_code=404, detail="Diagnostics disabled")
|
||||
from code.web.services.random_service import RandomService
|
||||
service = RandomService()
|
||||
test_vectors = {
|
||||
"test-seed": service.derive_seed("test-seed"),
|
||||
"12345": service.derive_seed(12345),
|
||||
"zero": service.derive_seed(0),
|
||||
"empty-string-rejected": "N/A (empty string raises InvalidSeedError)",
|
||||
}
|
||||
rid = getattr(request.state, "request_id", None)
|
||||
return {
|
||||
"test_vectors": test_vectors,
|
||||
"seed_algorithm": "sha256-63bit",
|
||||
"version": "1.0",
|
||||
"request_id": rid,
|
||||
}
|
||||
|
||||
@app.get("/status/random_metrics_ndjson")
|
||||
async def status_random_metrics_ndjson():
|
||||
if not RANDOM_TELEMETRY:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue