forge
Explore
Log in

Don't you dare go Hollow

🔌 echo the request school so hab/2 frames validate

Browse files at this commit

e6921b4591ad98f3fc3efa45afec916967a6d8bfAhmet Kaan GümüşParent: 2ddc9e8
  • fix
    • 🔌 echo the request school so hab/2 frames validate
Show full message
fix: 🔌 echo the request school so hab/2 frames validate
- hab/2 Request carries a required school field and Response must echo it;
  without it the backend fails every message with error_code=protocol even
  though the registration handshake succeeded
- the school rides through to every Response branch (ok, capability error,
  timeout, internal) so a refusal is attributed to the right school too
src/bridge.pymodified+14 -5
@@ -16,7 +16,9 @@ Akış (bkz. backend ``src/ai/mod.rs`` ve ``server.rs``):
16 yaz, bir ``Greeting`` oku, akışı hayat boyu açık tut (kapanması = kayıttan16 yaz, bir ``Greeting`` oku, akışı hayat boyu açık tut (kapanması = kayıttan
17 düşme sinyali).17 düşme sinyali).
18 4. Her istek backend'in açtığı *server-initiated* çift yönlü bir akıştır: tek18 4. Her istek backend'in açtığı *server-initiated* çift yönlü bir akıştır: tek
19- ``Request`` gelir, motoru çalıştırıp tek ``Response`` yazarız.19+ ``Request`` gelir, motoru çalıştırıp tek ``Response`` yazarız. hab/2'de
20+ ``Request.school`` zorunludur ve ``Response`` onu yankılar; ikisi de eksikse
21+ backend çerçeveyi reddeder.
20 22
21 Çerçeveleme: 4 bayt big-endian uzunluk + o kadar bayt JSON.23 Çerçeveleme: 4 bayt big-endian uzunluk + o kadar bayt JSON.
22 24
@@ -201,21 +203,28 @@ class BridgeProtocol(QuicConnectionProtocol):
201 return203 return
202 204
203 req_id = request.get("id", "")205 req_id = request.get("id", "")
206+ # hab/2: her istek kendi OKULUNU adıyla taşır ve cevap onu yankılar.
207+ # Bu alan eksikse backend çerçeveyi reddeder (mesaj error_code=protocol
208+ # ile düşer) — sürüm dizesi tek başına yetmez.
209+ school = request.get("school", "")
204 capability = request.get("capability", "")210 capability = request.get("capability", "")
205 payload = request.get("payload") or {}211 payload = request.get("payload") or {}
206 deadline_ms = request.get("deadline_ms")212 deadline_ms = request.get("deadline_ms")
207 try:213 try:
208 timeout = (deadline_ms / 1000.0) if isinstance(deadline_ms, (int, float)) else None214 timeout = (deadline_ms / 1000.0) if isinstance(deadline_ms, (int, float)) else None
209 text = await asyncio.wait_for(self._reply(capability, payload), timeout=timeout)215 text = await asyncio.wait_for(self._reply(capability, payload), timeout=timeout)
210- response: dict[str, Any] = {"status": "ok", "id": req_id, "payload": {"text": text}}216+ response: dict[str, Any] = {
217+ "status": "ok", "id": req_id, "school": school, "payload": {"text": text},
218+ }
211 except CapabilityError as exc:219 except CapabilityError as exc:
212- response = {"status": "err", "id": req_id, "code": exc.code, "message": str(exc)}220+ response = {"status": "err", "id": req_id, "school": school,
221+ "code": exc.code, "message": str(exc)}
213 except asyncio.TimeoutError:222 except asyncio.TimeoutError:
214- response = {"status": "err", "id": req_id, "code": "timed_out",223+ response = {"status": "err", "id": req_id, "school": school, "code": "timed_out",
215 "message": "motor süre içinde cevap veremedi"}224 "message": "motor süre içinde cevap veremedi"}
216 except Exception as exc: # pragma: no cover - beklenmeyen225 except Exception as exc: # pragma: no cover - beklenmeyen
217 print(f"[bridge] istek {req_id} işlenemedi: {exc}", flush=True)226 print(f"[bridge] istek {req_id} işlenemedi: {exc}", flush=True)
218- response = {"status": "err", "id": req_id, "code": "internal",227+ response = {"status": "err", "id": req_id, "school": school, "code": "internal",
219 "message": "beklenmeyen hata"}228 "message": "beklenmeyen hata"}
220 229
221 try:230 try: