GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(proof): cap per-trial logs at 2kib under 256kib · CortexLM/cortex@46a9ce1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • crates/proof-results/src
    • lib.rs
  • deploy
    • guest/runners/rlm_fc_in_guest_harbor
      • README.md
      • harness
        • summarize.py
      • tests
        • test_summarize.py
    • scripts
      • assert-harbor-runner-results-emit.sh
  • docs/external-miner
    • proof-tbench.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎crates/proof-results/src/lib.rs‎

Copy file name to clipboardExpand all lines: crates/proof-results/src/lib.rs
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ pub const WRITE_RESULTS_EMIT: &str = "write_results_next_to_report";
5353

5454
/// Largest results document accepted (bytes).
5555
///
56-
/// Sized for a typical Harbor pack (~10 trials) with optional 8 KiB
57-
/// `agent_log` + `verifier_log` bodies after JSON escaping. A pack that
58-
/// still overflows is fail-closed (`TooLarge`), never truncated here.
59-
pub const MAX_RESULTS_BYTES: u64 = 512 * 1024;
56+
/// Guest Harbor logs are sized to stay under this cap at 33 scored trials:
57+
/// 2 KiB `agent_log` + 2 KiB `verifier_log` per trial (132 KiB) plus
58+
/// `logs.harbor_run_tail` (8 KiB) and envelope. Overflow is fail-closed
59+
/// (`TooLarge`), never truncated here. 8 KiB per field would not fit.
60+
pub const MAX_RESULTS_BYTES: u64 = 256 * 1024;
6061

6162
/// Signed `constraints.params` key pinning the results contract id.
6263
pub const PARAM_RESULTS_CONTRACT: &str = "results_contract";
@@ -518,7 +519,9 @@ fn validate_harbor(obj: &Map<String, Value>, primary: f64) -> Result<(), Results
518519
Ok(())
519520
}
520521

521-
/// Optional per-trial Harbor logs. Absent is fine; a wrong type is not.
522+
/// Optional per-trial Harbor logs. Not required (`agent_log` / `verifier_log`
523+
/// / `log_sources` may be omitted). A present value of the wrong JSON type
524+
/// is fail-closed so the frontend never treats a non-string as a log body.
522525
fn optional_trial_log_fields(t: &Map<String, Value>) -> Result<(), ResultsError> {
523526
if t.get("agent_log").is_some_and(|v| !v.is_string()) {
524527
return Err(ResultsError::Shape(
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/README.md‎

Copy file name to clipboardExpand all lines: deploy/guest/runners/rlm_fc_in_guest_harbor/README.md
+2-1Lines changed: 2 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ runs. The guest refuses Done when this file is missing or does not bind
323323
the scored report. Frontend consumers read the same object on
324324
`GET /v1/submissions/{id}` as `results` and at the artefact zip root as
325325
`results.json`. Each `trials[]` row may also carry bounded, redacted
326-
`agent_log` / `verifier_log` harvested from Harbor's native trial dir
326+
`agent_log` / `verifier_log` (last 2 KiB each, so 33 trials stay under the
327+
256 KiB `results.json` cap) harvested from Harbor's native trial dir
327328
(`trial.log`, else `agent/trajectory.json`, else `terminus_2.pane`;
328329
verifier `verifier/test-stdout.txt`). Missing files are omitted, never
329330
invented. Job-level `logs.harbor_run_log` / `logs.harbor_run_tail` stay
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/harness/summarize.py‎

Copy file name to clipboardExpand all lines: deploy/guest/runners/rlm_fc_in_guest_harbor/harness/summarize.py
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
from typing import Any
5151

5252
MAX_TAIL_CHARS = 8 * 1024
53+
# 33 trials × 2 KiB × 2 fields = 132 KiB, which fits proof-results
54+
# MAX_RESULTS_BYTES (256 KiB) with harbor_run_tail (8 KiB) and envelope.
55+
# 8 KiB per field would be 528 KiB and overflow that cap.
56+
MAX_TRIAL_LOG_CHARS = 2 * 1024
5357
MAX_EVIDENCE_TRIALS = 256
5458
MAX_REWARD_TXT_BYTES = 64 * 1024
5559
MAX_EXCEPTION_CHARS = 400
@@ -480,15 +484,15 @@ def redact(text: str, secrets: list[str]) -> str:
480484
return out
481485

482486

483-
def read_tail(path: Path | None, secrets: list[str]) -> str:
487+
def read_tail(path: Path | None, secrets: list[str], max_chars: int = MAX_TAIL_CHARS) -> str:
484488
if path is None or not path.is_file():
485489
return ""
486490
try:
487491
data = path.read_bytes()
488492
except OSError:
489493
return ""
490-
if len(data) > MAX_TAIL_CHARS:
491-
data = data[-MAX_TAIL_CHARS:]
494+
if len(data) > max_chars:
495+
data = data[-max_chars:]
492496
text = data.decode("utf-8", errors="replace")
493497
return redact(text, secrets)
494498

@@ -504,8 +508,8 @@ def _trial_pane_path(trial_dir: Path) -> tuple[str, Path]:
504508
def attach_trial_logs(row: dict[str, Any], trial_dir: Path, secrets: list[str]) -> None:
505509
"""Fill ``agent_log`` / ``verifier_log`` from Harbor's native trial dir.
506510
507-
Agent sources, first available, each already ≤ ``MAX_TAIL_CHARS`` and
508-
redacted: ``trial.log``, then ``agent/trajectory.json``, then
511+
Agent sources, first available, each already ≤ ``MAX_TRIAL_LOG_CHARS``
512+
and redacted: ``trial.log``, then ``agent/trajectory.json``, then
509513
``terminus_2.pane`` (optional third). Verifier is only
510514
``verifier/test-stdout.txt``. Missing files are omitted — never invented.
511515
Runs for measured, agent-exception, FAIL, and incomplete Harbor alike.
@@ -517,14 +521,16 @@ def attach_trial_logs(row: dict[str, Any], trial_dir: Path, secrets: list[str])
517521
("agent/trajectory.json", trial_dir / "agent" / "trajectory.json"),
518522
(pane_rel, pane_path),
519523
):
520-
text = read_tail(path, secrets)
524+
text = read_tail(path, secrets, MAX_TRIAL_LOG_CHARS)
521525
if not text:
522526
continue
523527
row["agent_log"] = text
524528
sources.append(rel)
525529
break
526530
verifier_rel = "verifier/test-stdout.txt"
527-
verifier_log = read_tail(trial_dir / "verifier" / "test-stdout.txt", secrets)
531+
verifier_log = read_tail(
532+
trial_dir / "verifier" / "test-stdout.txt", secrets, MAX_TRIAL_LOG_CHARS
533+
)
528534
if verifier_log:
529535
row["verifier_log"] = verifier_log
530536
sources.append(verifier_rel)
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/tests/test_summarize.py‎

Copy file name to clipboardExpand all lines: deploy/guest/runners/rlm_fc_in_guest_harbor/tests/test_summarize.py
+43-2Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ def test_trial_logs_are_redacted_and_capped(self) -> None:
10831083
(secrets / "inference_key").write_text("sk-secret-owner\n", encoding="utf-8")
10841084
trial = root / "jobs" / "job" / "t__1"
10851085
write_complete_trial(trial, "t__1", 1.0)
1086-
huge = "keep-me\n" + ("x" * (summarize.MAX_TAIL_CHARS + 64)) + "sk-secret-owner tail\n"
1086+
huge = "keep-me\n" + ("x" * (summarize.MAX_TRIAL_LOG_CHARS + 64)) + "sk-secret-owner tail\n"
10871087
(trial / "trial.log").write_text(huge, encoding="utf-8")
10881088
(trial / "verifier" / "test-stdout.txt").write_text(
10891089
"verifier saw sk-secret-owner\n", encoding="utf-8"
@@ -1100,10 +1100,51 @@ def test_trial_logs_are_redacted_and_capped(self) -> None:
11001100
row = trials[0]
11011101
self.assertNotIn("sk-secret-owner", row["agent_log"])
11021102
self.assertIn("[REDACTED]", row["agent_log"])
1103-
self.assertLessEqual(len(row["agent_log"]), summarize.MAX_TAIL_CHARS)
1103+
self.assertLessEqual(len(row["agent_log"]), summarize.MAX_TRIAL_LOG_CHARS)
11041104
self.assertNotIn("sk-secret-owner", row["verifier_log"])
11051105
self.assertIn("[REDACTED]", row["verifier_log"])
11061106

1107+
def test_thirty_three_trials_with_max_logs_fit_results_cap(self) -> None:
1108+
"""33 scored trials × 2 KiB × 2 fields must stay under 256 KiB results.json."""
1109+
with tempfile.TemporaryDirectory() as tmp:
1110+
root = Path(tmp)
1111+
jobs = root / "jobs"
1112+
body_a = "A" * summarize.MAX_TRIAL_LOG_CHARS
1113+
body_v = "V" * summarize.MAX_TRIAL_LOG_CHARS
1114+
for i in range(33):
1115+
trial = jobs / "job" / f"task-{i:02d}__1"
1116+
write_complete_trial(trial, f"task-{i:02d}__1", 0.0)
1117+
(trial / "trial.log").write_text(body_a, encoding="utf-8")
1118+
(trial / "verifier" / "test-stdout.txt").write_text(body_v, encoding="utf-8")
1119+
out = root / "report.json"
1120+
rc = summarize.main(
1121+
[
1122+
"--jobs-dir",
1123+
str(jobs),
1124+
"--output",
1125+
str(out),
1126+
"--harbor-exit",
1127+
"23",
1128+
]
1129+
)
1130+
self.assertEqual(rc, 0)
1131+
results_path = root / "results.json"
1132+
size = results_path.stat().st_size
1133+
self.assertLessEqual(
1134+
size,
1135+
256 * 1024,
1136+
f"results.json {size} bytes exceeds proof-results 256 KiB cap",
1137+
)
1138+
results = json.loads(results_path.read_text(encoding="utf-8"))
1139+
self.assertEqual(len(results["trials"]), 33)
1140+
for row in results["trials"]:
1141+
self.assertEqual(len(row["agent_log"]), summarize.MAX_TRIAL_LOG_CHARS)
1142+
self.assertEqual(len(row["verifier_log"]), summarize.MAX_TRIAL_LOG_CHARS)
1143+
self.assertEqual(
1144+
row["log_sources"],
1145+
["trial.log", "verifier/test-stdout.txt"],
1146+
)
1147+
11071148
def test_empty_log_files_are_omitted_never_invented(self) -> None:
11081149
with tempfile.TemporaryDirectory() as tmp:
11091150
root = Path(tmp)
Collapse file

‎deploy/scripts/assert-harbor-runner-results-emit.sh‎

Copy file name to clipboardExpand all lines: deploy/scripts/assert-harbor-runner-results-emit.sh
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ need "$SUMMARIZE" 'atomic_write(out, dumped + "\n")'
3737
need "$SUMMARIZE" 'def attach_trial_logs'
3838
need "$SUMMARIZE" 'agent_log'
3939
need "$SUMMARIZE" 'verifier/test-stdout.txt'
40-
need "$SUMMARIZE" '"trial.log"'
40+
need "$SUMMARIZE" 'MAX_TRIAL_LOG_CHARS = 2 * 1024'
4141
need "$LIB_SH" 'proof_require_harbor_results'
4242
need "$RUN_HARBOR" 'proof_require_harbor_results'
4343

Collapse file

‎docs/external-miner/proof-tbench.md‎

Copy file name to clipboardExpand all lines: docs/external-miner/proof-tbench.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ replaces it.
511511
A scored evaluate also carries **`results`**: the complete Harbor job
512512
summary (`contract` `tbench-harbor-v1` / `harbor-trials-v1`). That is
513513
what the Arcade frontend renders — every trial's reward and outcome,
514-
optional bounded `agent_log` / `verifier_log` (UTF-8 from Harbor's
514+
optional bounded `agent_log` / `verifier_log` (UTF-8 last 2 KiB from Harbor's
515515
`trial.log` / `agent/trajectory.json` / `terminus_2.pane` and
516516
`verifier/test-stdout.txt`; missing files are omitted, never invented),
517517
`n_scored` / `n_measured` / `n_agent_exceptions`, `mean_reward` (equals

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.