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``):
1616 yaz, bir ``Greeting`` oku, akışı hayat boyu açık tut (kapanması = kayıttan
1717 düşme sinyali).
1818 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.
2022
2123 Çerçeveleme: 4 bayt big-endian uzunluk + o kadar bayt JSON.
2224
@@ -201,21 +203,28 @@ class BridgeProtocol(QuicConnectionProtocol):
201203 return
202204
203205 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", "")
204210 capability = request.get("capability", "")
205211 payload = request.get("payload") or {}
206212 deadline_ms = request.get("deadline_ms")
207213 try:
208214 timeout = (deadline_ms / 1000.0) if isinstance(deadline_ms, (int, float)) else None
209215 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+ }
211219 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)}
213222 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",
215224 "message": "motor süre içinde cevap veremedi"}
216225 except Exception as exc: # pragma: no cover - beklenmeyen
217226 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",
219228 "message": "beklenmeyen hata"}
220229
221230 try: