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 — feat(proof): harvest bounded per-trial harbor logs · CortexLM/cortex@92508b2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • crates/proof-results
    • fixtures
      • harbor-trials-v1.json
    • src
      • lib.rs
  • deploy
    • guest/runners/rlm_fc_in_guest_harbor
      • README.md
      • harness
        • summarize.py
      • tests
        • fixtures/harbor-trial-logs/jobs/job
          • hello-world__1
            • agent
              • trajectory.json
            • result.json
            • verifier
              • reward.txt
              • test-stdout.txt
          • no-logs__1
            • result.json
            • verifier
              • reward.txt
          • pane-only__1
            • result.json
            • terminus_2.pane
            • verifier
              • reward.txt
          • traj-only__1
            • agent
              • trajectory.json
            • result.json
            • verifier
              • reward.txt
        • test_summarize.py
    • scripts
      • assert-harbor-runner-results-emit.sh
  • docs
    • external-miner
      • proof-tbench.md
      • proof.md
    • runbooks
      • proof-experiment-vms.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎crates/proof-results/fixtures/harbor-trials-v1.json‎

Copy file name to clipboardExpand all lines: crates/proof-results/fixtures/harbor-trials-v1.json
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,24 @@
1717
"agent_exception_policy": "zero",
1818
"harbor_exit": 0,
1919
"trials": [
20-
{"name": "hello-world__1", "reward": 1.0, "outcome": "measured"},
20+
{
21+
"name": "hello-world__1",
22+
"reward": 1.0,
23+
"outcome": "measured",
24+
"agent_log": "hello-world agent stdout: ran ls\n",
25+
"verifier_log": "verifier: reward=1.0\n",
26+
"log_sources": ["trial.log", "verifier/test-stdout.txt"]
27+
},
2128
{"name": "fix-git-diff__1", "reward": 1.0, "outcome": "measured"},
2229
{"name": "csv-to-parquet__1", "reward": 0.0, "outcome": "measured"},
2330
{
2431
"name": "build-tmux__1",
2532
"reward": 0.0,
2633
"outcome": "agent_exception",
2734
"exception_type": "RuntimeError",
28-
"exception_message": "Command timed out after 120 seconds"
35+
"exception_message": "Command timed out after 120 seconds",
36+
"agent_log": "build-tmux agent raised during harness\n",
37+
"log_sources": ["trial.log"]
2938
},
3039
{"name": "nginx-config__1", "reward": 1.0, "outcome": "measured"},
3140
{"name": "sqlite-query__1", "reward": 1.0, "outcome": "measured"},
Collapse file

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

Copy file name to clipboardExpand all lines: crates/proof-results/src/lib.rs
+94-2Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ pub const ORCH_RESULTS_ATTACH_HINT: &str =
5252
pub const WRITE_RESULTS_EMIT: &str = "write_results_next_to_report";
5353

5454
/// Largest results document accepted (bytes).
55-
pub const MAX_RESULTS_BYTES: u64 = 256 * 1024;
55+
///
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;
5660

5761
/// Signed `constraints.params` key pinning the results contract id.
5862
pub const PARAM_RESULTS_CONTRACT: &str = "results_contract";
@@ -470,6 +474,7 @@ fn validate_harbor(obj: &Map<String, Value>, primary: f64) -> Result<(), Results
470474
));
471475
}
472476
}
477+
optional_trial_log_fields(t)?;
473478
rewards.push(reward);
474479
}
475480
let n_scored = uint_field(obj, "n_scored")?;
@@ -513,6 +518,31 @@ fn validate_harbor(obj: &Map<String, Value>, primary: f64) -> Result<(), Results
513518
Ok(())
514519
}
515520

521+
/// Optional per-trial Harbor logs. Absent is fine; a wrong type is not.
522+
fn optional_trial_log_fields(t: &Map<String, Value>) -> Result<(), ResultsError> {
523+
if t.get("agent_log").is_some_and(|v| !v.is_string()) {
524+
return Err(ResultsError::Shape(
525+
"trial.agent_log must be a string when present",
526+
));
527+
}
528+
if t.get("verifier_log").is_some_and(|v| !v.is_string()) {
529+
return Err(ResultsError::Shape(
530+
"trial.verifier_log must be a string when present",
531+
));
532+
}
533+
if let Some(v) = t.get("log_sources") {
534+
let arr = v.as_array().ok_or(ResultsError::Shape(
535+
"trial.log_sources must be an array of strings when present",
536+
))?;
537+
if arr.iter().any(|item| !item.is_string()) {
538+
return Err(ResultsError::Shape(
539+
"trial.log_sources must be an array of strings when present",
540+
));
541+
}
542+
}
543+
Ok(())
544+
}
545+
516546
fn str_field<'a>(obj: &'a Map<String, Value>, key: &'static str) -> Result<&'a str, ResultsError> {
517547
obj.get(key)
518548
.and_then(Value::as_str)
@@ -621,7 +651,14 @@ mod tests {
621651
"agent_exception_policy": "zero",
622652
"harbor_exit": 0,
623653
"trials": [
624-
{"name": "task-a__1", "reward": 1.0, "outcome": "measured"},
654+
{
655+
"name": "task-a__1",
656+
"reward": 1.0,
657+
"outcome": "measured",
658+
"agent_log": "agent: hello\n",
659+
"verifier_log": "verifier: ok\n",
660+
"log_sources": ["trial.log", "verifier/test-stdout.txt"]
661+
},
625662
{
626663
"name": "task-b__1",
627664
"reward": 0.0,
@@ -731,6 +768,36 @@ mod tests {
731768
);
732769
}
733770

771+
#[test]
772+
fn harbor_optional_trial_logs_are_typed() {
773+
let b = bind();
774+
validate(&harbor_ok(&b), &b, None).expect("optional logs allowed");
775+
let mut omitted = harbor_ok(&b);
776+
let trial0 = omitted["trials"][0].as_object_mut().expect("trial 0");
777+
trial0.remove("agent_log");
778+
trial0.remove("verifier_log");
779+
trial0.remove("log_sources");
780+
validate(&omitted, &b, None).expect("omitted logs allowed");
781+
let mut bad_agent = harbor_ok(&b);
782+
bad_agent["trials"][0]["agent_log"] = serde_json::json!(1);
783+
assert!(
784+
validate(&bad_agent, &b, None).is_err(),
785+
"agent_log must be a string when present"
786+
);
787+
let mut bad_verifier = harbor_ok(&b);
788+
bad_verifier["trials"][0]["verifier_log"] = serde_json::json!(true);
789+
assert!(
790+
validate(&bad_verifier, &b, None).is_err(),
791+
"verifier_log must be a string when present"
792+
);
793+
let mut bad_sources = harbor_ok(&b);
794+
bad_sources["trials"][0]["log_sources"] = serde_json::json!([1]);
795+
assert!(
796+
validate(&bad_sources, &b, None).is_err(),
797+
"log_sources must be strings when present"
798+
);
799+
}
800+
734801
#[test]
735802
fn generic_requires_displayable_content() {
736803
let b = bind();
@@ -792,6 +859,31 @@ mod tests {
792859
validate(&value, &b, Some(CONTRACT_TBENCH_HARBOR)).expect("fixture");
793860
assert_eq!(value["n_scored"], 10);
794861
assert_eq!(value["trials"].as_array().expect("trials").len(), 10);
862+
let trials = value["trials"].as_array().expect("trials");
863+
assert_eq!(
864+
trials[0]["agent_log"].as_str().expect("agent_log"),
865+
"hello-world agent stdout: ran ls\n"
866+
);
867+
assert_eq!(
868+
trials[0]["verifier_log"].as_str().expect("verifier_log"),
869+
"verifier: reward=1.0\n"
870+
);
871+
assert_eq!(
872+
trials[0]["log_sources"],
873+
serde_json::json!(["trial.log", "verifier/test-stdout.txt"])
874+
);
875+
assert!(
876+
trials[2].get("agent_log").is_none(),
877+
"missing Harbor files stay omitted"
878+
);
879+
assert_eq!(
880+
trials[3]["exception_type"].as_str().expect("exc"),
881+
"RuntimeError"
882+
);
883+
assert_eq!(
884+
trials[3]["agent_log"].as_str().expect("exc agent_log"),
885+
"build-tmux agent raised during harness\n"
886+
);
795887
}
796888

797889
#[test]
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
+16-2Lines changed: 16 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,14 @@ passed the suffix as `model_name`.
279279
"claim_holds": true,
280280
"evidence": {
281281
"trials": [
282-
{"name": "task-a__1", "reward": 1.0, "outcome": "measured"},
282+
{
283+
"name": "task-a__1",
284+
"reward": 1.0,
285+
"outcome": "measured",
286+
"agent_log": "…",
287+
"verifier_log": "…",
288+
"log_sources": ["trial.log", "verifier/test-stdout.txt"]
289+
},
283290
{"name": "task-b__1", "reward": 0.0, "outcome": "agent_exception",
284291
"exception_type": "RuntimeError", "exception_message": "Command timed out after 120 seconds"}
285292
],
@@ -315,7 +322,14 @@ miner-authored results file is deleted with `report.json` before Harbor
315322
runs. The guest refuses Done when this file is missing or does not bind
316323
the scored report. Frontend consumers read the same object on
317324
`GET /v1/submissions/{id}` as `results` and at the artefact zip root as
318-
`results.json`.
325+
`results.json`. Each `trials[]` row may also carry bounded, redacted
326+
`agent_log` / `verifier_log` harvested from Harbor's native trial dir
327+
(`trial.log`, else `agent/trajectory.json`, else `terminus_2.pane`;
328+
verifier `verifier/test-stdout.txt`). Missing files are omitted, never
329+
invented. Job-level `logs.harbor_run_log` / `logs.harbor_run_tail` stay
330+
as today. This harvest lives in the in-guest adaptor — a live pin
331+
needs a guest rebake + RE-LOCK; tipping gateway/challenge alone does not
332+
update `/opt/proof/runners`.
319333

320334
`inspect` writes `$PROOF_OUTPUT_DIR/checklist.json` (no Harbor, no keys).
321335

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
+53-4Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def collect_trials(
347347
jobs_dir: Path,
348348
allow: frozenset[str] | None = None,
349349
agent_exception_policy: str = POLICY_FAIL,
350+
secrets: list[str] | None = None,
350351
) -> list[dict[str, Any]]:
351352
"""Load every scored Harbor trial. Do not cap here — the cap is evidence only.
352353
@@ -363,12 +364,17 @@ def collect_trials(
363364
When ``allow`` is a non-empty set, trials whose name is not a filtered
364365
task (or ``task__attempt``) are dropped so a script that ran the
365366
unfiltered pack cannot score excluded ids.
367+
368+
Each scored row also harvests bounded, redacted ``agent_log`` /
369+
``verifier_log`` from the trial dir when those files exist (FAIL /
370+
incomplete Harbor included). Missing files are omitted.
366371
"""
367372
if agent_exception_policy not in EXCEPTION_POLICIES:
368373
_fail(f"agent_exception_policy must be one of {EXCEPTION_POLICIES}, got {agent_exception_policy!r}")
369374
by_dir: dict[str, dict[str, Any]] = {}
370375
if not jobs_dir.is_dir():
371376
return []
377+
redact_secrets = secrets if secrets is not None else load_redact_values()
372378

373379
for result_path in sorted(jobs_dir.rglob("result.json")):
374380
obj = _load_json(result_path)
@@ -378,23 +384,27 @@ def collect_trials(
378384
continue
379385
reward = trial_complete_reward(trial_dir, obj)
380386
if reward is not None:
381-
by_dir[key] = {
387+
row: dict[str, Any] = {
382388
"name": _trial_name(obj, trial_dir),
383389
"reward": reward,
384390
"outcome": "measured",
385391
}
392+
attach_trial_logs(row, trial_dir, redact_secrets)
393+
by_dir[key] = row
386394
continue
387395
if agent_exception_policy != POLICY_ZERO:
388396
continue
389397
crashed = agent_phase_exception(trial_dir, obj)
390398
if crashed is None:
391399
continue
392-
by_dir[key] = {
400+
row = {
393401
"name": _trial_name(obj, trial_dir),
394402
"reward": 0.0,
395403
"outcome": "agent_exception",
396404
**crashed,
397405
}
406+
attach_trial_logs(row, trial_dir, redact_secrets)
407+
by_dir[key] = row
398408

399409
rows = [by_dir[k] for k in sorted(by_dir)]
400410
if not allow:
@@ -483,6 +493,45 @@ def read_tail(path: Path | None, secrets: list[str]) -> str:
483493
return redact(text, secrets)
484494

485495

496+
def _trial_pane_path(trial_dir: Path) -> tuple[str, Path]:
497+
"""Owner lock is ``terminus_2.pane``; metal retain also has ``agent/terminus_2.pane``."""
498+
root_pane = trial_dir / "terminus_2.pane"
499+
if root_pane.is_file():
500+
return "terminus_2.pane", root_pane
501+
return "agent/terminus_2.pane", trial_dir / "agent" / "terminus_2.pane"
502+
503+
504+
def attach_trial_logs(row: dict[str, Any], trial_dir: Path, secrets: list[str]) -> None:
505+
"""Fill ``agent_log`` / ``verifier_log`` from Harbor's native trial dir.
506+
507+
Agent sources, first available, each already ≤ ``MAX_TAIL_CHARS`` and
508+
redacted: ``trial.log``, then ``agent/trajectory.json``, then
509+
``terminus_2.pane`` (optional third). Verifier is only
510+
``verifier/test-stdout.txt``. Missing files are omitted — never invented.
511+
Runs for measured, agent-exception, FAIL, and incomplete Harbor alike.
512+
"""
513+
sources: list[str] = []
514+
pane_rel, pane_path = _trial_pane_path(trial_dir)
515+
for rel, path in (
516+
("trial.log", trial_dir / "trial.log"),
517+
("agent/trajectory.json", trial_dir / "agent" / "trajectory.json"),
518+
(pane_rel, pane_path),
519+
):
520+
text = read_tail(path, secrets)
521+
if not text:
522+
continue
523+
row["agent_log"] = text
524+
sources.append(rel)
525+
break
526+
verifier_rel = "verifier/test-stdout.txt"
527+
verifier_log = read_tail(trial_dir / "verifier" / "test-stdout.txt", secrets)
528+
if verifier_log:
529+
row["verifier_log"] = verifier_log
530+
sources.append(verifier_rel)
531+
if sources:
532+
row["log_sources"] = sources
533+
534+
486535
def mean_reward(trials: list[dict[str, Any]]) -> float:
487536
rewards = [float(t["reward"]) for t in trials]
488537
return sum(rewards) / float(len(rewards))
@@ -685,7 +734,8 @@ def main(argv: list[str] | None = None) -> int:
685734
f"allow-tasks-dir {args.allow_tasks_dir} has no task directories; "
686735
"refusing to invent a primary_value"
687736
)
688-
trials = collect_trials(jobs_dir, allow, policy)
737+
secrets = load_redact_values()
738+
trials = collect_trials(jobs_dir, allow, policy, secrets)
689739
if not trials:
690740
_fail(
691741
f"no measured Harbor trials under {jobs_dir} "
@@ -701,7 +751,6 @@ def main(argv: list[str] | None = None) -> int:
701751
f"{', '.join(missing)}; agent_exception_policy={policy}); "
702752
"refusing a partial primary_value"
703753
)
704-
secrets = load_redact_values()
705754
log_path = Path(args.log) if args.log else None
706755
report = build_report(
707756
trials,
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/tests/fixtures/harbor-trial-logs/jobs/job/hello-world__1/agent/trajectory.json‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ignored": "trajectory must not displace trial.log"}
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/tests/fixtures/harbor-trial-logs/jobs/job/hello-world__1/result.json‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"trial_name": "hello-world__1", "verifier_result": {"rewards": {"reward": 1.0}}}
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/tests/fixtures/harbor-trial-logs/jobs/job/hello-world__1/verifier/reward.txt‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/tests/fixtures/harbor-trial-logs/jobs/job/hello-world__1/verifier/test-stdout.txt‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
verifier: reward=1.0
2+
pytest passed
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/tests/fixtures/harbor-trial-logs/jobs/job/no-logs__1/result.json‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"trial_name": "no-logs__1", "verifier_result": {"rewards": {"reward": 0.0}}}
Collapse file

‎deploy/guest/runners/rlm_fc_in_guest_harbor/tests/fixtures/harbor-trial-logs/jobs/job/no-logs__1/verifier/reward.txt‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0

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.