Repository navigation
In review
Description
Follow-up hardening items spotted in scripts/turbo_fieldfare_server.py and the companion shell scripts after #106 (fc3ecfc) and #107 (a028ab0) merged (tracking alongside #108). Worth landing before switching turbo-fieldfare to the default local engine in #110.
Line numbers below are on main at a028ab0.
Wire contract and parity
/v1/systemoneaccepts a custom{"schema", "state"}payload and returns rawdecide()output (scripts/turbo_fieldfare_server.py:567-584).deploy/cloudrun/server/structured_server.py:1834-1880expects{"state", "questions"}parsed viajev_schemaandjev_state, and returnsjev_answershapes. Direct callers using the documented/v1/systemonecontract get HTTP 422. Portjev_schema,jev_state,check_media_keys, andjev_answer(refusing images with 400), or drop the route until it matches./v1/systemonesilently ignoresimages,audio, andvideokeys instead of callingss.check_media_keysand rejecting non-emptyimageswith HTTP 400.steps > 1is silently dropped in_run_probe_read(scripts/turbo_fieldfare_server.py:294-313), whilediagnostics.stepsstill echoes the requested step count. Rejectsteps > 1with 4xx (likethink > 0) until multi-step readout exists.json.dumps(state_content)atscripts/turbo_fieldfare_server.py:366omitsensure_ascii=False, escaping non-Latin text to\uXXXX(regressingstructured_server.py:1573-1574).- Chat route parity gaps (
scripts/turbo_fieldfare_server.py:396-430): ignores thedeveloperrole (structured_server.py:1886), treats text-only content part lists as multimodal, accepts arbitrary message counts, and returns{"error": "<str>"}instead of{"error": {"message", "type"}}.
HTTP/1.1 hardening and input validation
Handlersetsprotocol_version = "HTTP/1.1"with notimeout(scripts/turbo_fieldfare_server.py:436-437). This reintroduces issue perf(decisionindex,gateway): parallelize independent multi-pass /v1/systemone batches and Round-1 brackets #96, where idle or half-open sockets pin handler threads indefinitely (structured_server.py:1659-1662setsHTTP_IDLE_TIMEOUT, default 120 s).do_POSTreturns 401 on auth failure (scripts/turbo_fieldfare_server.py:503-505) and 400 on invalidContent-Length(:507-511) without draining the body or settingself.close_connection = True. On a keep-alive socket, the unread body gets parsed as the next request. Port_discard_body()fromstructured_server.py:1719-1741.rfile.read(length)(scripts/turbo_fieldfare_server.py:512) has no maximum body size, and a negativeContent-Lengthsilently readsb"{}"instead of returning 400.- Requests queue without bound on
self._decide_lock(noMAX_INFLIGHT/ 503 overloaded cap likestructured_server.py:1810-1813). AnyContent-Typeis parsed as JSON (allowing no-preflighttext/plaincross-origin POSTs to127.0.0.1:8080), and binding a non-loopback--addr(0.0.0.0) does not requireDGEM_SERVER_KEY. seed = int(req_body.get("seed") or 42)(scripts/turbo_fieldfare_server.py:429, 571) coercesseed=0to42. Line 571 sits outsidetry:, so a non-integerseedon/v1/systemonedrops the connection with an unhandled exception, and a non-scalarseedon/v1/chat/completionsraisesTypeError(HTTP 500 instead of 400).parse_addr(scripts/turbo_fieldfare_server.py:591-595) usesrpartition(":"), leaving brackets on"[::1]:8080"and breaking IPv6 loopback binds.
Probe lifecycle and shell scripts
read_canvas(scripts/turbo_fieldfare_server.py:187-223) holdsself._lockduring a blockingstdout.readline()with no timeout (one hung read wedges the server and deadlocksclose()), never checks responseid, never pre-checkslen(prompt_tokens) + len(canvas_tokens) <= max_context(returning 500 instead of 422/400), raisesKeyError(HTTP 500) on{"error": ...}probe replies, and leaves_ready = Falsepermanently on crash with no auto-restart.- Startup readiness checks
"ready" in line.lower()(scripts/turbo_fieldfare_server.py:172), which matches"already"or"not ready". Match an exact sentinel line instead. _boot_worker(scripts/turbo_fieldfare_server.py:679-691) logs fatal probe startup errors and exits the background thread while leavinghttpd.serve_forever()alive serving 503. As a result,scripts/serve_turbo_fieldfare.sh:118-139waits 60 s and exits 0, somake local-upcontinues against a dead engine.scripts/stop_turbo_fieldfare.sh:20-41signals the PID file without checking the command line and runspkill -f "TurboFieldfareDiffusionProbe", which can also killswift buildor open editors.scripts/setup_turbo_fieldfare.sh:47-60builds../turbo-fieldfare-dgemwith no public fork URL or pinned commit, andscripts/download_turbo_fieldfare.sh:36passes the.gturbopath positionally to--verify-install(upstreamdrumih/turbo-fieldfareexpects--verify-install --input-gturbo <path>). Bothdownload_turbo_fieldfare.shandserve_turbo_fieldfare.shalso ignore$TURBO_FIELDFARE_SRC.
Telemetry and #107 follow-ups
self._tls.timing_acc(scripts/turbo_fieldfare_server.py:282, 324-328) dropsprefill_ms,denoise_ms, andhead_msto0.0wheneversamples > 1or isolated question groups run on worker threads (also flagged on feat(local): propagate TurboFieldfareDiffusionProbe reusedTokens into diagnostics.timing.reused_tokens #111).scripts/test_turbo_fieldfare_server.pyis not run in.github/workflows/build.yml:84-105, usesAnywithout importingfrom typing import Any(lines 79, 96, 105, 356), andload_structured_server()writespybase64andtransformersstubs into process-widesys.modules(scripts/turbo_fieldfare_server.py:58-65).cmd/mcp.go:1063-1065overwrites an explicit--modelflag with the first entry from local/v1/models.ss.DEFAULT_SEED_TOKEN = "fixed"(scripts/turbo_fieldfare_server.py:289, added in fix(local): set CANVAS_STEP=64 and DEFAULT_SEED_TOKEN=fixed in turbo_fieldfare_server #107) overrides an operator'sDEFAULT_SEED_TOKEN=randomenv var (structured_server.py:171), andsamples=4templates (such astemplates/support_triage.json.tmpl:27) run 4 identical slow reads locally under"fixed". Also worth asserting inscripts/test_turbo_fieldfare_server.py:410-427that"random"produces non-PAD canvas tokens.pkg/client/turbo_fieldfare_test.goandcmd/backend_local_test.gotest against hand-written mocks; adding one contract test fed fromturbo_fieldfare_server.pyoutput would catch response drift.
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix(local): harden turbo-fieldfare adapter, /v1/systemone parity, and…