Skip to content

Commit 727212c

Browse files
authored
Expose public submission diagnostics (#524)
1 parent b3879a0 commit 727212c

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎src/kernelbot/api/main.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,18 @@ async def get_user_submission(
11331133
response_run = {key: run[key] for key in run_fields}
11341134
if not run["secret"] and run["mode"] in ("test", "benchmark"):
11351135
response_run["result"] = run["result"]
1136+
# Runtime tracebacks, compiler errors, and process failures are
1137+
# stored separately from the structured evaluator result. Expose
1138+
# them only for the authenticated owner's public runs; secret-run
1139+
# diagnostics can contain private validation details.
1140+
meta = run.get("meta") or {}
1141+
response_run["diagnostics"] = {
1142+
key: meta[key]
1143+
for key in ("stdout", "stderr", "success", "exit_code", "duration")
1144+
if key in meta
1145+
}
1146+
if run.get("compilation") is not None:
1147+
response_run["diagnostics"]["compilation"] = run["compilation"]
11361148
runs.append(response_run)
11371149
runner_queue = await get_submission_runner_queue_status(submission)
11381150
return {

‎tests/test_admin_api.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ def test_submission_details_include_stored_run_results(self, test_client, mock_b
289289
"score": None,
290290
"passed": False,
291291
"result": test_result,
292+
"meta": {
293+
"stdout": "",
294+
"stderr": "Traceback: public test failure",
295+
"success": False,
296+
"exit_code": 1,
297+
"duration": 1.25,
298+
},
299+
"compilation": None,
292300
},
293301
{
294302
"start_time": "2026-07-06T12:00:00Z",
@@ -299,6 +307,18 @@ def test_submission_details_include_stored_run_results(self, test_client, mock_b
299307
"score": None,
300308
"passed": True,
301309
"result": benchmark_result,
310+
"meta": {
311+
"stdout": "benchmark output",
312+
"stderr": "",
313+
"success": True,
314+
"exit_code": 0,
315+
"duration": 2.5,
316+
},
317+
"compilation": {
318+
"success": True,
319+
"stdout": "",
320+
"stderr": "",
321+
},
302322
},
303323
{
304324
"start_time": "2026-07-06T12:00:00Z",
@@ -309,6 +329,13 @@ def test_submission_details_include_stored_run_results(self, test_client, mock_b
309329
"score": None,
310330
"passed": True,
311331
"result": {"secret-result": "must not be exposed"},
332+
"meta": {
333+
"stderr": "SECRET_TRACEBACK_SENTINEL",
334+
"exit_code": 1,
335+
},
336+
"compilation": {
337+
"stderr": "SECRET_COMPILER_SENTINEL",
338+
},
312339
},
313340
{
314341
"start_time": "2026-07-06T12:00:00Z",
@@ -353,14 +380,26 @@ def test_submission_details_include_stored_run_results(self, test_client, mock_b
353380
assert response.status_code == 200
354381
runs = response.json()["runs"]
355382
assert runs[0]["result"] == test_result
383+
assert runs[0]["diagnostics"] == {
384+
"stdout": "",
385+
"stderr": "Traceback: public test failure",
386+
"success": False,
387+
"exit_code": 1,
388+
"duration": 1.25,
389+
}
356390
assert runs[1]["result"] == benchmark_result
391+
assert runs[1]["diagnostics"]["stdout"] == "benchmark output"
392+
assert runs[1]["diagnostics"]["compilation"]["success"] is True
357393
assert "result" not in runs[2]
394+
assert "diagnostics" not in runs[2]
358395
assert runs[2]["secret"] is True
359396
assert runs[2]["passed"] is True
360397
assert "result" not in runs[3]
361398
assert "result" not in runs[4]
362399
assert "must not be exposed" not in response.text
363400
assert "PROFILE_SENTINEL" not in response.text
401+
assert "SECRET_TRACEBACK_SENTINEL" not in response.text
402+
assert "SECRET_COMPILER_SENTINEL" not in response.text
364403

365404

366405
class TestAdminStats:

0 commit comments

Comments
 (0)