Skip to content

feat(validate): grade semantic.verifier_determinism for separate Harbor verifiers - #1801

Open
yaokaiy wants to merge 1 commit into
openenv:mainfrom
yaokaiy:feat/harbor-verifier-determinism
Open

yaokaiy wants to merge 1 commit into
openenv:mainfrom
yaokaiy:feat/harbor-verifier-determinism

Conversation

@yaokaiy

@yaokaiy yaokaiy commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

openenv validate <task> --sandbox hf-sandbox now grades semantic.verifier_determinism (#778 test 39) for Harbor tasks with a separate verifier. On main this check is a SKIP for every Harbor task: "not implemented for the harbor_task binding". Closes #1775, following the design proposed there.

How it works

At the semantic level, the oracle trial now runs its verifier three times. Harbor collects the agent's artifacts once, and each call uploads that same copy into a fresh verifier job. So all three calls grade the same final state. Once runtime.episode_determinism passes, the check passes if the three reward maps are equal as exact rationals. Otherwise it fails, and measured lists each call's rewards.

  • The binding wraps the oracle trial's _run_verifier, the way it already overrides other Trial internals. The two extra calls run first and Harbor's own call runs last. The trial's result comes from Harbor's own call, so the replay comparison, reward parsing and teardown checks are unchanged.
  • After Harbor's own call succeeds, the binding checks the extra reward maps with _reward. A malformed extra reward, including an empty file or a numeric JSON scalar, fails runtime.reward_well_formed. With --output report.json, each extra call's available reward.json and reward.txt are saved under report.artifacts/harbor-trials/oracle/verifier-call-N/, with SHA-256 hashes in harbor-evidence.json.
  • A separate verifier only sees what Harbor collected. Before the extra calls, the binding runs Harbor's regrade coverage check, RegradeTrial._artifact_coverage_problems. It also covers /logs/artifacts, which Harbor collects even when the task doesn't declare it. If Harbor's record does not cover a declared artifact or the implicit /logs/artifacts directory, the binding omits the extra calls. When episode determinism passes, the check is then a SKIP with artifact_problems in measured.
  • A verifier timeout on an extra call fails runtime.startup and names the verifier phase, as on Harbor's own call. If episode determinism passes, an extra-call infrastructure failure such as a verifier job failing to start gives semantic.verifier_determinism an ERROR.

Shared verifiers get a named SKIP: "a shared verifier runs in the agent container, which Harbor stops after one verification". I propose the shared-verifier SKIP in #1775 because the first call can consume or change an input. A second call in the same container can then give a different reward, even for a deterministic verifier. Local Docker accepts only shared verifiers, so the check never grades there.

Each graded task adds two verifier jobs. In the live run, the three oracle verifier jobs on cpu-basic started 8.7 and 9.5 seconds apart.

This ties the binding to a Harbor internal. _artifact_coverage_problems is a private method of RegradeTrial, and the binding calls it with the trial as self. It only reads agent_env_paths and logger, which the trial also has. Harbor task validation already refuses any Harbor other than 0.25.0 (parsers/harbor_toml.py).

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • New environment
  • Refactoring

Alignment Checklist

Before submitting, verify:

  • I have read .claude/docs/PRINCIPLES.md and this PR aligns with our principles
  • I have checked .claude/docs/INVARIANTS.md and no invariants are violated
  • I have run /pre-submit-pr (or bash .claude/hooks/lint.sh and tests) and addressed all issues

RFC Status

The RFC 008 Harbor table, docs/source/reference/cli.md and the completion plan now describe the check.

Test Plan

  • 18 new test cases in test_harbor_validation.py. 17 of them fail against main's src/. The 18th checks that a runtime-level run still makes one verifier call per trial. That already holds on main, so it guards against a regression. They cover:
    • Three equal calls PASS, also with a recorded empty artifact directory.
    • Extra call 1 or 2 differs while the replay agrees. Episode determinism passes and this check fails.
    • An extra call returns {"reward":2}, an empty file or the JSON scalar 0. reward_well_formed fails. Episode determinism and this check are SKIPs. The raw file is kept.
    • The replay diverges, with a shared or a separate verifier. This check is a SKIP that names episode determinism.
    • An artifact is failed, skipped, missing or unrecorded. This check is a SKIP, and the oracle makes only one verifier call.
    • An extra call's verifier times out. runtime.startup fails and names the verifier phase.
    • An extra call's verifier environment does not start in time. This check is an ERROR.
    • A shared verifier gets the named SKIP and one call per trial.
  • The fake Trial in the tests now calls a wrappable _run_verifier and writes an artifact manifest. So the wrapper and Harbor's coverage check run as they do in a real trial.
  • The fake also raises ValidationError for a JSON scalar reward, as Harbor's VerifierResult does.
  • tests/test_validation: 2037 passed, 66 skipped. bash .claude/hooks/lint.sh passes.
  • Live check on HF Jobs (cpu-basic) with a private task: separate verifier, a /app directory artifact and a digest-pinned public python:3.12-slim image. The do-nothing trial scored 0, and the oracle and its replay scored 1. semantic.verifier_determinism passed with three {"reward": 1.0} calls. Eight labelled jobs ran: one agent job per trial, one verifier job each for the do-nothing and replay trials, and three for the oracle. Every job ended CANCELED, and cleanup was verified. Verdict WARN, the normal passing result for this binding.

Claude Code Review

/alignment-review report:

  • Lint: PASS (lint.sh).
  • Debug code: none added. check-debug.sh lists existing prints in providers/_pidns.py and two TODOs, all outside this diff.
  • Tier 1 fixes: none.
  • Tier 2: no principle or invariant conflicts. RFC 008 is In Review. The shared-verifier SKIP is the open question in RFC 008: grade semantic.verifier_determinism for Harbor tasks #1775.

Note

Medium Risk
Changes Harbor trial orchestration and depends on Harbor private regrade APIs; scope is limited to hf-sandbox separate-verifier semantic validation with broad new test coverage.

Overview
Harbor validation (--sandbox hf-sandbox, semantic level) now grades semantic.verifier_determinism (#778 test #39) instead of always SKIPing it. For tasks with a separate verifier, the first oracle trial grades the same collected artifacts three times in fresh verifier jobs; the check passes when all three reward maps match as exact rationals and still depends on runtime.episode_determinism.

The binding wraps the oracle trial’s _run_verifier: it runs Harbor’s artifact coverage check first, performs two extra verifier calls (then Harbor’s final call), records per-call rewards in OracleEvidence.verifier_rewards / harbor-evidence.json, and wires a new VerifierDeterminismGrader. Shared verifiers and local Docker get a named SKIP; incomplete artifact manifests SKIP with artifact_problems; verifier infra failures on extra calls surface as ERROR or runtime.startup FAIL. Docs (RFC 008, CLI, completion plan) are updated to match.

Reviewed by Cursor Bugbot for commit 55c49f3. Bugbot is set up for automated code reviews on this repo. Configure here.

…or verifiers

At the semantic level, the first oracle trial now runs its separate verifier
three times on the artifacts Harbor collected once. Each call starts a fresh
verifier environment, so every call grades the same final state. Once the
oracle replay agrees, the check passes when the three reward maps are equal
as exact rationals, and fails with each call's rewards otherwise.

Harbor's own call runs last, so the replay comparison, reward parsing and
teardown checks still read a single call. Every extra call's reward goes
through the same contract check, and its raw files are kept under
harbor-trials/oracle/verifier-call-N/. A verifier timeout on an extra call
fails the package, as it does on Harbor's own call.

The check is a named SKIP when Harbor's artifact record misses a verifier
input, using Harbor's regrade coverage check, which includes the implicit
artifact directory. It is also a named SKIP for shared verifiers: Harbor
stops the agent container right after verification, so no second call sees
the same final state. Any other failed extra call is an ERROR.

Refs openenv#1775
@yaokaiy
yaokaiy marked this pull request as ready for review December 4, 2026 05:09
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

The docs for this pull request built successfully. A maintainer can publish a preview of this commit by adding the docs-preview label and re-running the Docs check.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 55c49f3. Configure here.

# A final call that fails early must not inherit these.
path.unlink(missing_ok=True)
except Exception as exc:
outcome["failure"] = type(exc).__name__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reward cleanup masks verifier timeout

Medium Severity

In verify_repeatedly, the finally block reads and unlinks reward files before the outer except records the failure. If verify() raises VerifierTimeoutError and _read_output or unlink then raises, only the cleanup exception is stored. The later scan looks for VerifierTimeoutError, so the timeout never fails runtime.startup.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 55c49f3. Configure here.

raise NativeEvidenceError(
f"Harbor subject failed during verifier call {call} "
"(VerifierTimeoutError)"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later verifier error hides timeout

Medium Severity

Extra verifier calls swallow exceptions and keep going, while a VerifierTimeoutError is applied only after trial.run() returns with no exception_info. If a later call, including Harbor's own call, raises, that result is handled first and the earlier timeout is never read. A timed-out extra call can then show up as a reward failure with runtime.startup still passing.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 55c49f3. Configure here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC 008: grade semantic.verifier_determinism for Harbor tasks

1 participant