diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/Dockerfile b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/Dockerfile +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/agent/Dockerfile b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/agent/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/agent/Dockerfile +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/agent/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/compatibility.json b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/compatibility.json index 0ba49cdfe32a5d6422cc2b7ee0407466d61632c4..16f5135bf8f353ddd428dd80433c053c44f251f0 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/compatibility.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946" + "source_sha256": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py index ea60d77683bd7048f2a57d23f02cc847e26b26d1..be8dcbc300da344c0be22317d11ddb31a0aa3c8b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py @@ -25,6 +25,10 @@ unchanged except as noted, to one configured upstream: not send; only ``anthropic-workspace-id``, ``openai-organization`` and ``openai-project`` are accepted (an unscoped Anthropic key needs the first). +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. + No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays ambiguous. The file keeps its historical name; it is no longer Google-specific. @@ -37,7 +41,10 @@ import http.client import ipaddress import json import os +import select +import socket import threading +import time from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from urllib.parse import urlsplit @@ -77,6 +84,40 @@ def remote_reference(value): return False +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + HOP_BY_HOP = { "host", "content-length", "connection", "transfer-encoding", "keep-alive", "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", @@ -183,24 +224,93 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + def call(): + try: + connection.request("POST", base_path + target, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the socket down (not just close it) so a read blocked in the worker returns and the + # provider sees the disconnect and can stop a generation nobody will read. + sock = connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() try: - connection.request("POST", base_path + target, payload, headers) - response = connection.getresponse() - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(self.path, message, status)) + self.wfile.flush() + self.close_connection = True + return while data := response.read1(65536): self.wfile.write(data) self.wfile.flush() self.close_connection = True except (OSError, http.client.HTTPException): - # No retry: an ambiguous upstream attempt stays ambiguous. self.close_connection = True finally: - connection.close() + abort_upstream() return ThreadingHTTPServer((host, port), Handler) diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.json b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.tar.gz b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.tar.gz +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/task.json b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/task.json index 3701a089d6da57e0139b63bb10a455a281f3a314..e3d73fcc547bc6fa4c07caf97c24d2401eddc038 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/task.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/task.json @@ -31,7 +31,7 @@ "agent": { "schema_version": 1, "files": { - "Dockerfile": "b5b27ff8c86de80bb485d465b7ae5947c474b9b84aacbe08ffa9c45b68bac1ef", + "Dockerfile": "304c4346b6339d0fdacfe2b27d19d5546028b4e5626e68bd114ad2f7fdb2d62b", "collab_harbor/__init__.py": "7df1d3de24dc22f6cf6ca1eb14111edc949558bbca98d01a6e29a093313e073b", "collab_harbor/cli.py": "a3ed01306b021e4784b24782e48903eb1b33edca19b8268a53fda47d75c4ce7e", "collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", @@ -40,7 +40,7 @@ "collab_harbor/relay.py": "70491ff1be0a428e2cfd02e70f8ee4f6ed3245a1cdb9b2d20e2b43a0684b0097", "team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a" }, - "sha256": "5ceba4c625b0732e959e8db98b005ce15f8acd48f6d2f1347d15e364eea25dc9" + "sha256": "8e2fe7bbd527086c488b171ca41691b7104cd69f136a99b619cd89b73acc1f9f" }, "team_adapter": { "schema_version": 1, @@ -55,8 +55,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -80,7 +80,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "verifier_adapter": { "schema_version": 1, @@ -95,8 +95,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -120,7 +120,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "team_upstream": { "schema_version": 1, @@ -246,26 +246,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "95dcfce366a86e2e76086ee3adf260cf38f0dee6d13404c7d0b073a3ecce7140" + "runtime-distribution.json": "188133f05f8cfb3648ef334187adb4b5290d9902c2ae8d9d337c9ccd8b822494" }, - "sha256": "a46b9608559ac1e9f1ecc0216edee15c3aabe788b46efd5d7a0cf66c4f62f141" + "sha256": "b1997306709c2737610eb9d9b0e9a9a01a106dcc84e98cc353fcb3da08f7ad5c" }, "environment_policy": { "schema_version": 1, @@ -311,10 +311,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "dd103d941b84c4f72429c7e937cd4b9ed3f1be99e43fc607a0897893e8429d77" + "sha256": "3259f49e406cc46278a8a2fa5a9192be152d0e96d629fc8999cef1ca1fa39402" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" } } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.json b/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.tar.gz b/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.tar.gz +++ b/tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/Dockerfile b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/Dockerfile +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/agent/Dockerfile b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/agent/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/agent/Dockerfile +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/agent/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/compatibility.json b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/compatibility.json index 0ba49cdfe32a5d6422cc2b7ee0407466d61632c4..16f5135bf8f353ddd428dd80433c053c44f251f0 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/compatibility.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946" + "source_sha256": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py index ea60d77683bd7048f2a57d23f02cc847e26b26d1..be8dcbc300da344c0be22317d11ddb31a0aa3c8b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py @@ -25,6 +25,10 @@ unchanged except as noted, to one configured upstream: not send; only ``anthropic-workspace-id``, ``openai-organization`` and ``openai-project`` are accepted (an unscoped Anthropic key needs the first). +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. + No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays ambiguous. The file keeps its historical name; it is no longer Google-specific. @@ -37,7 +41,10 @@ import http.client import ipaddress import json import os +import select +import socket import threading +import time from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from urllib.parse import urlsplit @@ -77,6 +84,40 @@ def remote_reference(value): return False +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + HOP_BY_HOP = { "host", "content-length", "connection", "transfer-encoding", "keep-alive", "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", @@ -183,24 +224,93 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + def call(): + try: + connection.request("POST", base_path + target, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the socket down (not just close it) so a read blocked in the worker returns and the + # provider sees the disconnect and can stop a generation nobody will read. + sock = connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() try: - connection.request("POST", base_path + target, payload, headers) - response = connection.getresponse() - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(self.path, message, status)) + self.wfile.flush() + self.close_connection = True + return while data := response.read1(65536): self.wfile.write(data) self.wfile.flush() self.close_connection = True except (OSError, http.client.HTTPException): - # No retry: an ambiguous upstream attempt stays ambiguous. self.close_connection = True finally: - connection.close() + abort_upstream() return ThreadingHTTPServer((host, port), Handler) diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.json b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.tar.gz b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.tar.gz +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/task.json b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/task.json index 5d7e6339b4d1ad23a778e535083596eb601642b9..e2ed19feffd0e669dff7cd1caff71b21315e7d3f 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/task.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/task.json @@ -31,7 +31,7 @@ "agent": { "schema_version": 1, "files": { - "Dockerfile": "b5b27ff8c86de80bb485d465b7ae5947c474b9b84aacbe08ffa9c45b68bac1ef", + "Dockerfile": "304c4346b6339d0fdacfe2b27d19d5546028b4e5626e68bd114ad2f7fdb2d62b", "collab_harbor/__init__.py": "7df1d3de24dc22f6cf6ca1eb14111edc949558bbca98d01a6e29a093313e073b", "collab_harbor/cli.py": "a3ed01306b021e4784b24782e48903eb1b33edca19b8268a53fda47d75c4ce7e", "collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", @@ -40,7 +40,7 @@ "collab_harbor/relay.py": "70491ff1be0a428e2cfd02e70f8ee4f6ed3245a1cdb9b2d20e2b43a0684b0097", "team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a" }, - "sha256": "5ceba4c625b0732e959e8db98b005ce15f8acd48f6d2f1347d15e364eea25dc9" + "sha256": "8e2fe7bbd527086c488b171ca41691b7104cd69f136a99b619cd89b73acc1f9f" }, "team_adapter": { "schema_version": 1, @@ -55,8 +55,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -80,7 +80,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "verifier_adapter": { "schema_version": 1, @@ -95,8 +95,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -120,7 +120,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "team_upstream": { "schema_version": 1, @@ -246,26 +246,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "95dcfce366a86e2e76086ee3adf260cf38f0dee6d13404c7d0b073a3ecce7140" + "runtime-distribution.json": "188133f05f8cfb3648ef334187adb4b5290d9902c2ae8d9d337c9ccd8b822494" }, - "sha256": "a46b9608559ac1e9f1ecc0216edee15c3aabe788b46efd5d7a0cf66c4f62f141" + "sha256": "b1997306709c2737610eb9d9b0e9a9a01a106dcc84e98cc353fcb3da08f7ad5c" }, "environment_policy": { "schema_version": 1, @@ -311,10 +311,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "fa67989588628cfdcdb6c05ec38e17cecd5baa45991422641e72c4af4b3b1bed" + "sha256": "b462d50f85579d426bfbc3b81115fe8d5a1ce5b146460325ab8de8d50e28081d" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" } } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.json b/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.tar.gz b/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.tar.gz +++ b/tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/Dockerfile b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/Dockerfile +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/agent/Dockerfile b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/agent/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/agent/Dockerfile +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/agent/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/compatibility.json b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/compatibility.json index 0ba49cdfe32a5d6422cc2b7ee0407466d61632c4..16f5135bf8f353ddd428dd80433c053c44f251f0 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/compatibility.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946" + "source_sha256": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py index ea60d77683bd7048f2a57d23f02cc847e26b26d1..be8dcbc300da344c0be22317d11ddb31a0aa3c8b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py @@ -25,6 +25,10 @@ unchanged except as noted, to one configured upstream: not send; only ``anthropic-workspace-id``, ``openai-organization`` and ``openai-project`` are accepted (an unscoped Anthropic key needs the first). +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. + No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays ambiguous. The file keeps its historical name; it is no longer Google-specific. @@ -37,7 +41,10 @@ import http.client import ipaddress import json import os +import select +import socket import threading +import time from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from urllib.parse import urlsplit @@ -77,6 +84,40 @@ def remote_reference(value): return False +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + HOP_BY_HOP = { "host", "content-length", "connection", "transfer-encoding", "keep-alive", "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", @@ -183,24 +224,93 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + def call(): + try: + connection.request("POST", base_path + target, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the socket down (not just close it) so a read blocked in the worker returns and the + # provider sees the disconnect and can stop a generation nobody will read. + sock = connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() try: - connection.request("POST", base_path + target, payload, headers) - response = connection.getresponse() - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(self.path, message, status)) + self.wfile.flush() + self.close_connection = True + return while data := response.read1(65536): self.wfile.write(data) self.wfile.flush() self.close_connection = True except (OSError, http.client.HTTPException): - # No retry: an ambiguous upstream attempt stays ambiguous. self.close_connection = True finally: - connection.close() + abort_upstream() return ThreadingHTTPServer((host, port), Handler) diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.json b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.tar.gz b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.tar.gz +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/task.json b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/task.json index 8fe8ce47ffa50c020db4afc4f584455c09d643f9..70fe6d67bdcb1a62391c69297392c7bdf3248e57 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/task.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/task.json @@ -31,7 +31,7 @@ "agent": { "schema_version": 1, "files": { - "Dockerfile": "b5b27ff8c86de80bb485d465b7ae5947c474b9b84aacbe08ffa9c45b68bac1ef", + "Dockerfile": "304c4346b6339d0fdacfe2b27d19d5546028b4e5626e68bd114ad2f7fdb2d62b", "collab_harbor/__init__.py": "7df1d3de24dc22f6cf6ca1eb14111edc949558bbca98d01a6e29a093313e073b", "collab_harbor/cli.py": "a3ed01306b021e4784b24782e48903eb1b33edca19b8268a53fda47d75c4ce7e", "collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", @@ -40,7 +40,7 @@ "collab_harbor/relay.py": "70491ff1be0a428e2cfd02e70f8ee4f6ed3245a1cdb9b2d20e2b43a0684b0097", "team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a" }, - "sha256": "5ceba4c625b0732e959e8db98b005ce15f8acd48f6d2f1347d15e364eea25dc9" + "sha256": "8e2fe7bbd527086c488b171ca41691b7104cd69f136a99b619cd89b73acc1f9f" }, "team_adapter": { "schema_version": 1, @@ -55,8 +55,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -80,7 +80,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "verifier_adapter": { "schema_version": 1, @@ -95,8 +95,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -120,7 +120,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "team_upstream": { "schema_version": 1, @@ -246,26 +246,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "95dcfce366a86e2e76086ee3adf260cf38f0dee6d13404c7d0b073a3ecce7140" + "runtime-distribution.json": "188133f05f8cfb3648ef334187adb4b5290d9902c2ae8d9d337c9ccd8b822494" }, - "sha256": "a46b9608559ac1e9f1ecc0216edee15c3aabe788b46efd5d7a0cf66c4f62f141" + "sha256": "b1997306709c2737610eb9d9b0e9a9a01a106dcc84e98cc353fcb3da08f7ad5c" }, "environment_policy": { "schema_version": 1, @@ -311,10 +311,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "ee4b1810b191bdfa774401632f1fa391420f9a2744f0759d2aed776ddd262dbb" + "sha256": "4aaea75a05a8e82b4bd6509c0192e267d210b6e97f159f6d0da9aa2e3f5b52a6" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" } } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.json b/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.json +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.tar.gz b/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.tar.gz +++ b/tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/Dockerfile b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/Dockerfile +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/agent/Dockerfile b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/agent/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/agent/Dockerfile +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/agent/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/compatibility.json b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/compatibility.json index 0ba49cdfe32a5d6422cc2b7ee0407466d61632c4..16f5135bf8f353ddd428dd80433c053c44f251f0 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/compatibility.json +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946" + "source_sha256": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa" } diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py index ea60d77683bd7048f2a57d23f02cc847e26b26d1..be8dcbc300da344c0be22317d11ddb31a0aa3c8b 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py @@ -25,6 +25,10 @@ unchanged except as noted, to one configured upstream: not send; only ``anthropic-workspace-id``, ``openai-organization`` and ``openai-project`` are accepted (an unscoped Anthropic key needs the first). +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. + No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays ambiguous. The file keeps its historical name; it is no longer Google-specific. @@ -37,7 +41,10 @@ import http.client import ipaddress import json import os +import select +import socket import threading +import time from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from urllib.parse import urlsplit @@ -77,6 +84,40 @@ def remote_reference(value): return False +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + HOP_BY_HOP = { "host", "content-length", "connection", "transfer-encoding", "keep-alive", "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", @@ -183,24 +224,93 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + def call(): + try: + connection.request("POST", base_path + target, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the socket down (not just close it) so a read blocked in the worker returns and the + # provider sees the disconnect and can stop a generation nobody will read. + sock = connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() try: - connection.request("POST", base_path + target, payload, headers) - response = connection.getresponse() - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(self.path, message, status)) + self.wfile.flush() + self.close_connection = True + return while data := response.read1(65536): self.wfile.write(data) self.wfile.flush() self.close_connection = True except (OSError, http.client.HTTPException): - # No retry: an ambiguous upstream attempt stays ambiguous. self.close_connection = True finally: - connection.close() + abort_upstream() return ThreadingHTTPServer((host, port), Handler) diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.json b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.json +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.tar.gz b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.tar.gz +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/task.json b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/task.json index c64bbca2ee57ab72b0b9c292d06266e6f9633888..1b6cfeedefad1c336a7adbf5fe3cb9bc22e2b852 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/task.json +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/task.json @@ -31,7 +31,7 @@ "agent": { "schema_version": 1, "files": { - "Dockerfile": "b5b27ff8c86de80bb485d465b7ae5947c474b9b84aacbe08ffa9c45b68bac1ef", + "Dockerfile": "304c4346b6339d0fdacfe2b27d19d5546028b4e5626e68bd114ad2f7fdb2d62b", "collab_harbor/__init__.py": "7df1d3de24dc22f6cf6ca1eb14111edc949558bbca98d01a6e29a093313e073b", "collab_harbor/cli.py": "a3ed01306b021e4784b24782e48903eb1b33edca19b8268a53fda47d75c4ce7e", "collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", @@ -40,7 +40,7 @@ "collab_harbor/relay.py": "70491ff1be0a428e2cfd02e70f8ee4f6ed3245a1cdb9b2d20e2b43a0684b0097", "team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a" }, - "sha256": "5ceba4c625b0732e959e8db98b005ce15f8acd48f6d2f1347d15e364eea25dc9" + "sha256": "8e2fe7bbd527086c488b171ca41691b7104cd69f136a99b619cd89b73acc1f9f" }, "team_adapter": { "schema_version": 1, @@ -55,8 +55,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -80,7 +80,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "verifier_adapter": { "schema_version": 1, @@ -95,8 +95,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -120,7 +120,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "team_upstream": { "schema_version": 1, @@ -246,26 +246,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "95dcfce366a86e2e76086ee3adf260cf38f0dee6d13404c7d0b073a3ecce7140" + "runtime-distribution.json": "188133f05f8cfb3648ef334187adb4b5290d9902c2ae8d9d337c9ccd8b822494" }, - "sha256": "a46b9608559ac1e9f1ecc0216edee15c3aabe788b46efd5d7a0cf66c4f62f141" + "sha256": "b1997306709c2737610eb9d9b0e9a9a01a106dcc84e98cc353fcb3da08f7ad5c" }, "environment_policy": { "schema_version": 1, @@ -311,10 +311,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "5aa81cad2840afc956b697aa232e51265a3784a4c984c4ddf6c8cd12ff372e22" + "sha256": "dbffbf3b12b87c123ad79c24d3a1dab6bf9a931c6fa592148aa53942fa24da87" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" } } diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.json b/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.json +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.tar.gz b/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.tar.gz +++ b/tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/Dockerfile b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/Dockerfile +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/agent/Dockerfile b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/agent/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/agent/Dockerfile +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/agent/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/compatibility.json b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/compatibility.json index 0ba49cdfe32a5d6422cc2b7ee0407466d61632c4..16f5135bf8f353ddd428dd80433c053c44f251f0 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/compatibility.json +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946" + "source_sha256": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa" } diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py index ea60d77683bd7048f2a57d23f02cc847e26b26d1..be8dcbc300da344c0be22317d11ddb31a0aa3c8b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py @@ -25,6 +25,10 @@ unchanged except as noted, to one configured upstream: not send; only ``anthropic-workspace-id``, ``openai-organization`` and ``openai-project`` are accepted (an unscoped Anthropic key needs the first). +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. + No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays ambiguous. The file keeps its historical name; it is no longer Google-specific. @@ -37,7 +41,10 @@ import http.client import ipaddress import json import os +import select +import socket import threading +import time from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from urllib.parse import urlsplit @@ -77,6 +84,40 @@ def remote_reference(value): return False +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + HOP_BY_HOP = { "host", "content-length", "connection", "transfer-encoding", "keep-alive", "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", @@ -183,24 +224,93 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + def call(): + try: + connection.request("POST", base_path + target, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the socket down (not just close it) so a read blocked in the worker returns and the + # provider sees the disconnect and can stop a generation nobody will read. + sock = connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() try: - connection.request("POST", base_path + target, payload, headers) - response = connection.getresponse() - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(self.path, message, status)) + self.wfile.flush() + self.close_connection = True + return while data := response.read1(65536): self.wfile.write(data) self.wfile.flush() self.close_connection = True except (OSError, http.client.HTTPException): - # No retry: an ambiguous upstream attempt stays ambiguous. self.close_connection = True finally: - connection.close() + abort_upstream() return ThreadingHTTPServer((host, port), Handler) diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.json b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.json +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.tar.gz b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.tar.gz +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/task.json b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/task.json index e57edcf05aec5cba5f5ef0d1b8aa7f82e5a2f924..1c82361f6b4658b2cec97bbab8feac2c64b76a62 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/task.json +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/task.json @@ -31,7 +31,7 @@ "agent": { "schema_version": 1, "files": { - "Dockerfile": "b5b27ff8c86de80bb485d465b7ae5947c474b9b84aacbe08ffa9c45b68bac1ef", + "Dockerfile": "304c4346b6339d0fdacfe2b27d19d5546028b4e5626e68bd114ad2f7fdb2d62b", "collab_harbor/__init__.py": "7df1d3de24dc22f6cf6ca1eb14111edc949558bbca98d01a6e29a093313e073b", "collab_harbor/cli.py": "a3ed01306b021e4784b24782e48903eb1b33edca19b8268a53fda47d75c4ce7e", "collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", @@ -40,7 +40,7 @@ "collab_harbor/relay.py": "70491ff1be0a428e2cfd02e70f8ee4f6ed3245a1cdb9b2d20e2b43a0684b0097", "team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a" }, - "sha256": "5ceba4c625b0732e959e8db98b005ce15f8acd48f6d2f1347d15e364eea25dc9" + "sha256": "8e2fe7bbd527086c488b171ca41691b7104cd69f136a99b619cd89b73acc1f9f" }, "team_adapter": { "schema_version": 1, @@ -55,8 +55,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -80,7 +80,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "verifier_adapter": { "schema_version": 1, @@ -95,8 +95,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -120,7 +120,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "team_upstream": { "schema_version": 1, @@ -246,26 +246,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "95dcfce366a86e2e76086ee3adf260cf38f0dee6d13404c7d0b073a3ecce7140" + "runtime-distribution.json": "188133f05f8cfb3648ef334187adb4b5290d9902c2ae8d9d337c9ccd8b822494" }, - "sha256": "a46b9608559ac1e9f1ecc0216edee15c3aabe788b46efd5d7a0cf66c4f62f141" + "sha256": "b1997306709c2737610eb9d9b0e9a9a01a106dcc84e98cc353fcb3da08f7ad5c" }, "environment_policy": { "schema_version": 1, @@ -311,10 +311,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "31a51a3cf2f6cfc3dbdc64b70f45add9ad869454b060cd2004c1b4ba352cd858" + "sha256": "e72890848dfd7b5bf8ea246ca01318b13fe5a937bd74a01c7f74a2737599473b" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" } } diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.json b/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.json +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.tar.gz b/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.tar.gz +++ b/tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/Dockerfile b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/Dockerfile +++ b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/agent/Dockerfile b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/agent/Dockerfile index 56b392c828360a8c244e24c57d10d186a664faac..404735de46aba22dcc38d955ca27ec657f31a63b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/agent/Dockerfile +++ b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/agent/Dockerfile @@ -8,6 +8,7 @@ ENV CI_PI_PROVIDER_PRIVATE_AUDIT=/logs/agent/pi/provider-private.jsonl ENV CI_PI_RESTORED_COMPLETED_TURNS=0 COPY collab_harbor/pi-bash-timeout.js /tmp/harbor-pi-agent/extensions/z-local-bash-timeout.js +ENV CI_PI_BASH_TIMEOUT_SEC=120 RUN chmod 755 /usr/local/bin/team ENV PYTHONPATH=/app TEAM_URL=http://team:8000 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/compatibility.json b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/compatibility.json index 0ba49cdfe32a5d6422cc2b7ee0407466d61632c4..16f5135bf8f353ddd428dd80433c053c44f251f0 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/compatibility.json +++ b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946" + "source_sha256": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa" } diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py index ea60d77683bd7048f2a57d23f02cc847e26b26d1..be8dcbc300da344c0be22317d11ddb31a0aa3c8b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py +++ b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py @@ -25,6 +25,10 @@ unchanged except as noted, to one configured upstream: not send; only ``anthropic-workspace-id``, ``openai-organization`` and ``openai-project`` are accepted (an unscoped Anthropic key needs the first). +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. + No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays ambiguous. The file keeps its historical name; it is no longer Google-specific. @@ -37,7 +41,10 @@ import http.client import ipaddress import json import os +import select +import socket import threading +import time from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from urllib.parse import urlsplit @@ -77,6 +84,40 @@ def remote_reference(value): return False +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + HOP_BY_HOP = { "host", "content-length", "connection", "transfer-encoding", "keep-alive", "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", @@ -183,24 +224,93 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + def call(): + try: + connection.request("POST", base_path + target, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the socket down (not just close it) so a read blocked in the worker returns and the + # provider sees the disconnect and can stop a generation nobody will read. + sock = connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() try: - connection.request("POST", base_path + target, payload, headers) - response = connection.getresponse() - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(self.path, message, status)) + self.wfile.flush() + self.close_connection = True + return while data := response.read1(65536): self.wfile.write(data) self.wfile.flush() self.close_connection = True except (OSError, http.client.HTTPException): - # No retry: an ambiguous upstream attempt stays ambiguous. self.close_connection = True finally: - connection.close() + abort_upstream() return ThreadingHTTPServer((host, port), Handler) diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.json b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.json index 142b5e9b83f1ffabaadac5d17bdbcf03d1966652..5cde2ea17699a00851c5906141eb8474d2f583aa 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.json +++ b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5", + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,8 +12,8 @@ "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "adapter/collab_harbor/google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "adapter/collab_harbor/generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "adapter/collab_harbor/google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -100,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1468959, + "uncompressed_bytes": 1475066, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.tar.gz b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.tar.gz index 28eaf5df8fe9edc867e68b6478792140041b7c1a..ad1ac2e52414f4301f306449ae8c97ed44a0336b 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.tar.gz +++ b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5 -size 391824 +oid sha256:97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c +size 393802 diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/task.json b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/task.json index 1394619c1122bfa3264f1c63e03366248d42def2..f308f2e002a8bdf936e1821170261a0713831df4 100644 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/task.json +++ b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/task.json @@ -31,7 +31,7 @@ "agent": { "schema_version": 1, "files": { - "Dockerfile": "b5b27ff8c86de80bb485d465b7ae5947c474b9b84aacbe08ffa9c45b68bac1ef", + "Dockerfile": "304c4346b6339d0fdacfe2b27d19d5546028b4e5626e68bd114ad2f7fdb2d62b", "collab_harbor/__init__.py": "7df1d3de24dc22f6cf6ca1eb14111edc949558bbca98d01a6e29a093313e073b", "collab_harbor/cli.py": "a3ed01306b021e4784b24782e48903eb1b33edca19b8268a53fda47d75c4ce7e", "collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", @@ -40,7 +40,7 @@ "collab_harbor/relay.py": "70491ff1be0a428e2cfd02e70f8ee4f6ed3245a1cdb9b2d20e2b43a0684b0097", "team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a" }, - "sha256": "5ceba4c625b0732e959e8db98b005ce15f8acd48f6d2f1347d15e364eea25dc9" + "sha256": "8e2fe7bbd527086c488b171ca41691b7104cd69f136a99b619cd89b73acc1f9f" }, "team_adapter": { "schema_version": 1, @@ -55,8 +55,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -80,7 +80,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "verifier_adapter": { "schema_version": 1, @@ -95,8 +95,8 @@ "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "b241df519ac589f9cdb3daa4457ccc01b2fee1142d6d5c4c9eb6b9c8575629cc", - "google_compat.py": "c776287e2976c03257686f1eadeac70d6537199673dfdfd2df5f3fb2b0645946", + "generate.py": "ed398645eea4ac258c4ba1cf470d918eb9e460196ba2bd082ab0f449fe4dde7d", + "google_compat.py": "1a7c8a54d504236a447ad12050aa7f753e8dbf26f8515ba72684c63c8d46eafa", "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", @@ -120,7 +120,7 @@ "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "e3afe7fc6a54b7391914759ff693da274540999eb779857d9c7e7c5ca4bf42b8" + "sha256": "8d1ce359662da6b61c83d91dddb6e465507db4884dc57815125d9446d280bb30" }, "team_upstream": { "schema_version": 1, @@ -246,26 +246,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "ad4350dc7a562a97985feeb4b5d2cb748048d404a012e0e1d357db09e476a3e7", - "runtime.tar.gz": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "runtime.json": "e251e5f2de6505f9bdcdabd148c2be096cd8a9bd24a49fb6e7dd602baf0cdeb5", + "runtime.tar.gz": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" }, - "sha256": "614f202c632587dbbf00a45f4c6db8de25b70fa10deb93ddaec47e4742d8bae0" + "sha256": "afd411b152dee0b7a83eeb4e5440d3a541834b555047f1e5591083550888517b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "95dcfce366a86e2e76086ee3adf260cf38f0dee6d13404c7d0b073a3ecce7140" + "runtime-distribution.json": "188133f05f8cfb3648ef334187adb4b5290d9902c2ae8d9d337c9ccd8b822494" }, - "sha256": "a46b9608559ac1e9f1ecc0216edee15c3aabe788b46efd5d7a0cf66c4f62f141" + "sha256": "b1997306709c2737610eb9d9b0e9a9a01a106dcc84e98cc353fcb3da08f7ad5c" }, "environment_policy": { "schema_version": 1, @@ -311,10 +311,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "a6a315f7d4cfd7121ec3daee2f00557be58f3a77c4ecd45dc38c6751e065cd82" + "sha256": "18e88069869ab8075504c3312ac379e3a006f6bb3f464fdc6b2803614254bb3b" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "ed858253fe6f0bb1946a8a380a52fec105befd6610766074fbbc062965d34dd5" + "archive_sha256": "97572dbafa572d3cac3799bb47f6cf2e6beccc1460608063794ec0b3b4f1ad9c" } }