Skip to content

Commit ecb0390

Browse files
committed
chore(config): raise max_code_bytes for zip submissions
1 parent 140f114 commit ecb0390

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

src/prism_challenge/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PrismSettings(ChallengeSettings):
3636
allow_insecure_signatures: bool = False
3737
signature_ttl_seconds: int = 300
3838
epoch_seconds: int = 21_600
39-
max_code_bytes: int = 200_000
39+
max_code_bytes: int = 7_500_000
4040
max_parameters: int = 150_000_000
4141
max_layers: int = 96
4242
max_sequence_length: int = 512

tests/test_api.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,52 @@
55
import json
66
import zipfile
77

8+
import pytest
89
from conftest import VALID_CODE, signed_headers
10+
from fastapi.testclient import TestClient
911

12+
from prism_challenge.app import create_app
13+
from prism_challenge.config import PrismSettings
1014
from prism_challenge.sdk.executors.docker import DockerRunResult
1115

1216

17+
@pytest.fixture
18+
def small_cap_client(tmp_path) -> TestClient:
19+
settings = PrismSettings(
20+
database_url=f"sqlite+aiosqlite:///{tmp_path / 'prism.sqlite3'}",
21+
shared_token="secret",
22+
allow_insecure_signatures=True,
23+
fineweb_sample_count=4,
24+
max_code_bytes=2_000,
25+
)
26+
with TestClient(create_app(settings)) as test_client:
27+
yield test_client
28+
29+
30+
def _post_code(client: TestClient, code: str):
31+
payload = {"code": code, "filename": "model.py"}
32+
body = json.dumps(payload, separators=(",", ":")).encode()
33+
return client.post(
34+
"/v1/submissions",
35+
content=body,
36+
headers={**signed_headers("secret", body), "Content-Type": "application/json"},
37+
)
38+
39+
40+
def test_size_check_accepts_just_under_cap(small_cap_client):
41+
cap = small_cap_client.app.state.settings.max_code_bytes
42+
response = _post_code(small_cap_client, "A" * (cap - 1))
43+
assert response.status_code == 200, response.text
44+
45+
46+
def test_size_check_rejects_just_over_cap(small_cap_client):
47+
cap = small_cap_client.app.state.settings.max_code_bytes
48+
response = _post_code(small_cap_client, "A" * (cap + 1))
49+
assert response.status_code == 413, response.text
50+
assert response.json()["detail"] == "submission too large"
51+
52+
53+
1354
def test_health_version_and_internal_auth(client):
1455
assert client.get("/health").json()["slug"] == "prism"
1556
assert "nas" in client.get("/version").json()["capabilities"]

tests/test_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ def test_internal_token_requires_secret() -> None:
7373

7474

7575

76+
def test_max_code_bytes_holds_five_mib_zip_base64() -> None:
77+
# 5 MiB raw zip -> base64 length 6,990,508; cap must comfortably exceed it.
78+
raw_five_mib = 5 * 1024 * 1024
79+
base64_len = 4 * ((raw_five_mib + 2) // 3)
80+
81+
settings = PrismSettings()
82+
83+
assert settings.max_code_bytes == 7_500_000
84+
assert settings.max_code_bytes > base64_len
85+
86+
7687
def test_example_config_parses_with_nas_defaults() -> None:
7788
payload = yaml.safe_load(Path("config.example.yaml").read_text(encoding="utf-8"))
7889

0 commit comments

Comments
 (0)