fix(arena): olive-output scan routes and AbortError body-read handling

Merged
TO
4mo ago
+1841-364

Summary

Addresses still-valid review findings on the playground-tab Arena work:

  • Req 18.4 / Task 19.2: List (GET /api/arena/olive-outputs) scans server-owned roots without requiring an opaque id; download (/file?id=) resolves the id and revalidates containment, regular file, extension, and size. Path-related query params are rejected with empty 400/403 bodies.
  • Property 20b: Spec now requires rejecting (not ignoring) cacheDir / outputDir / path / absolutePath.
  • HANDOFF Task 19.5: Explicit fast-check gate for Properties 20, 20b, 21, 21b, 22 (≥100 iterations each) before Req 18 complete.
  • arena cloud proxy: AbortError from upstream.text() / json() is rethrown; clientDisconnected / writableEnded / destroyed checked after body reads.

Validation

  • pnpm exec tsc --noEmit
  • pnpm test:server (190 passed)
  • pnpm test (570 passed)
  • pnpm lint (exit 0, existing warnings only)

Notes

  • Task 19.1 (assistant-cloud snapshot / OpenAI-compat gate) remains incomplete; only the Olive path helpers needed for 19.2 were added.
  • Task 19.5 property tests are specified as a completion gate; not implemented in this change.
Open in Web Open in Cursor 

Summary by cubic

Adds secure Olive output list/download routes with opaque IDs and stricter cloud proxy body-read handling. Improves Windows handling (drive/UNC prefixes, Content‑Disposition tests) and keeps failures to 400/403 per spec.

  • New Features

    • GET /api/arena/olive-outputs: scans server-owned roots with depth/count/visit caps; returns { roots, recent≤10, entries } with stable opaque IDs and displayPath only (no absolute paths).
    • GET /api/arena/olive-outputs/file?id=<id>: re-validates in-root containment, regular file, .onnx/.ort, and size in (0, 512 MiB]; streams bytes with sanitized Content-Disposition; omits Content-Length; stops on client disconnect.
    • Both endpoints reject path, absolutePath, cacheDir, outputDir with empty 400; protected by arenaLocalOnly and arenaProxyRateLimit.
  • Bug Fixes

    • Cloud proxy: literal-interval abort timer preserves timeouts; caps buffered body and maps UpstreamBodyTooLargeError to 502; treats AbortError from text()/json() as a timeout (504); passes through non‑2xx; aborts upstream and avoids writes after disconnects.
    • Olive outputs: preserves Windows drive-letter/UNC prefixes; aligns failures to 400/403 (never 404); rejects zero‑byte models; PBTs use Windows‑legal basenames with a focused sanitization check for quotes/backslashes/control chars.