Skip to content

Tests overhaul - #700

Merged
jdchawla29 merged 348 commits into
mainfrom
test-overhaul
Oct 27, 2026
Merged

jdchawla29 merged 348 commits into
mainfrom
test-overhaul

Conversation

@jdchawla29

@jdchawla29 jdchawla29 commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Rebuilds the test suite around what a user observes, runs it in lanes that match what each test needs, and fixes the product defects the new tests found.

Breaking changes

  • hud.agents.browser_use (BrowserUseAgent) and the hud[browseruse] extra are removed. The adapter now lives in cookbooks/browser-use as an example of wrapping an agent framework over a capability; copy it into your project and install browser-use there.
  • PlatformClient.put() and PlatformClient.patch() are removed; nothing called them. get() and post() take an optional reply type, and hud.imports.get_report() requires one.
  • hud requires anthropic>=2.1,<3 (and google-genai>=2.30.1). anthropic 2.0 broke every Claude rollout on the old code.
  • hud deploy, hud qa run, hud models fork, hud models head --set and hud project create now confirm before acting. In a non-interactive terminal they refuse without --yes, as hud eval already did; scripts calling them need --yes.
  • hud eval exits 1 when no run was graded (every run errored); it exited 0 before. A job with some graded runs, or a low reward, still exits 0.

Tests

  • Tests move from hud/**/tests into one tests/ tree that mirrors the SDK's subsystems.
  • Tests drive the SDK the way a user does (the CLI, the public API, a served environment, a rollout) and assert what the user sees: rewards, statuses, errors, files, exit codes, and what the platform records. ruff's SLF001 now keeps tests off hud internals.
  • tests/fixtures holds fakes only for what CI cannot run: the HUD platform, model providers and the gateway, Docker, a DevTools endpoint, a screen, a scripted control-channel peer.
  • Real agents run against real models through the gateway, and the Claude and Codex CLI agents run as real CLIs. Fixture environments under tests/fixtures/envs each take every agent family to a known reward.
  • Every hud init template runs from hud init to a graded rollout: scripted on every PR, on a real model in the live lane, and deployed to HUD in the release gate.
  • tests/cli/test_every_command.py holds every mutating CLI command to the --dry-run / --yes contract.
  • Coverage no longer gates CI.

CI

  • ci.yml (path-filtered): unit tests on 3.11 and 3.12, ruff, ty, Docker scenarios, the bubblewrap sandbox scenarios in a container with HUD's seccomp profile, and cookbooks.
  • live.yml: real-model scenarios on PRs and main. Modal, Harbor and LeRobot run nightly and on dispatch. The live and Modal jobs fail without their credentials instead of skipping every scenario.
  • The pre-release gate deploys each template and runs it on HUD as a pytest scenario, replacing the hand-written lifecycle script, and calls live.yml, so every Live lane (real models, Modal, Harbor, LeRobot) runs on the commit being released.

Fixes

Agents

  • Claude 5 models get the computer_toolset_20260801 toolset, which they require; older models keep the single computer tool.
  • Gemini 3 computer use: handle the desktop action set, scale coordinates from Gemini's 1000x1000 grid to the screen, send key chords for the environment rather than the host, and pass excluded_predefined_functions through.
  • ClaudeToolSearchTool.threshold defers custom tools.
  • A tool builds itself from the agent's config (AgentTool.from_config), replacing an untyped options dict.
  • create_agent, hud eval and hud models list request a catalog model by its model_name, the only name the gateway routes.
  • The auto-responder builds its client per call.

Environments

  • Task calls run beside the control channel's read loop, so a cancel or a hang-up ends a grade that is still running.
  • A finished session's route is removed from the running sandbox at once.
  • hud serve stops cleanly on SIGTERM and promptly when a session is still open.
  • Clearer errors: a missing .py source, a template's own KeyError, falsy non-object tasks.start args, a non-UTF-8 task.toml, Compose include/extends.

Eval

  • A cancelled rollout's trace is closed on the platform, and a hosted rollout stops polling once cancellation is requested.
  • A rollout that fails before launch keeps its traceback and exports its failure step.
  • A child or Docker env that exits before serving is reported with its exit code and output.
  • A rollout's parent trace is named by one rule, local or hosted; duplicate task slugs name their rows; a task moved to another env counts as changed when syncing.
  • Each block of a multi-block prompt turn becomes its own message.

CLI and platform client

  • Platform replies are parsed at the client; a misshapen reply raises HudReplyError (exit 1) instead of surfacing as a usage error.
  • hud eval --json reports errored runs consistently; a dry run reports the model from the toml section.
  • Local hud trace output shows tool calls.
  • CLI analytics report the exception a command failed with.

Harbor and robot

  • hud harbor export checks every task before writing any.
  • The robot bridge's tick loop stops on Python 3.11; camera frames too small for the video encoder are refused; tool observations never show negative zero.

Docs

AGENTS.md, CONTRIBUTING.md and the new REVIEW.md set the test and review policy. The runtime, task, job, CLI and verifier references are updated to match the code.


Note

High Risk
Large breaking surface (CLI confirmations, eval exit codes, removed browser-use extra, dependency floors) plus security-sensitive Docker/sandbox CI and widespread agent/runtime behavior changes.

Overview
Rebuilds validation around user-visible behavior: tests consolidate under tests/ (with tests/fixtures fakes), environment examples drive SubprocessRuntime + the control channel instead of in-process mocks, and CI splits into path-filtered unit/lint (ci.yml: parallel pytest, Docker/sandbox/cookbook e2e lanes) plus a new live.yml for gateway/Modal/Harbor/LeRobot and credential-gated scenarios. The pre-release gate deploys each hud init template via pytest hosted scenarios and reuses live.yml instead of the old lifecycle shell script.

Breaking / contract changes: removes hud.agents.browser_use and the hud[browseruse] extra (adapter moves to cookbooks/browser-use); bumps anthropic>=2.1 and tightens gateway model resolution; mutating CLI commands (deploy, qa run, models fork/head, project create, etc.) now confirm or require --yes; hud eval exits 1 when no run received a valid grade.

Product fixes bundled with the new tests: Claude computer toolset + deferred tool search; Gemini 3 desktop computer-use actions/coordinates; eval/job reporting (Job.errors, evaluation subscore shaping); environment serving/cancel/teardown; Harbor/verifier docs and robot dataset frame limits; docs/policy updates in AGENTS.md, CONTRIBUTING.md, REVIEW.md.

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

The fake modal, daytona and asyncssh modules record every SDK call as plain
data and connect each sandbox to an environment served in-process, so each
acquisition row also runs a graded rollout. Tables cover image resolution,
sizing, timeouts, secrets, Compose in a Docker VM with its uploaded archive,
session transfer for images and Compose, snapshot builds that follow their
image, the refusals each provider makes before creating a sandbox (the fake
modal is always installed, so they never import the real SDK), and output
streaming. test_docker_provider.py's rows now live in test_docker.py and
test_cloud.py; the Harbor-only Compose relocation rows are left to the
Harbor area.
One taskset carrying every row shape (template rows, metadata, full
resources, TPU, a verifier with an explicit null, a local Compose project) is
written to JSON and JSONL, snapshotted, and read back row for row. Every
malformed row, runtime config, Compose project, bind mount and file is a row
of one rejection table. Taskset.from_api runs against the fake platform by
name, by id and for a vanished export, without patching make_request_sync.
test_task.py's placement rows moved to the scheduler and tunnel files;
test_sync.py's upload and diff rows belong to the CLI area's hud sync.
Rows run a rollout on env.workspace(track_files=True), a server predating
setup diffs, an oversized deliverable, a large workspace, an untracked
workspace, an unreachable tracker and telemetry off, then read the
filetracking spans back from the local span file: their order, their schema
and run id, and what each reports. The patched observer internals, settings
and private frame constants go.
One scripted conversation sends text, a list of blocks, a turn with
citations and a failing turn, asserting the replies, the snapshotted history,
the prompt the environment saw and one job across every turn; a chat without
a runtime keeps its user turn and says how to place it. The private content
helpers and the child-process environment go.

The multi-block turn fails: Chat stores it as a list of blocks, which the
run's prompt normalization cannot read.
Chat keeps a user turn of several content blocks as a list, and chat
environments yield it back as the prompt, but Run.prompt_messages validated
the turn as one PromptMessage, which holds a single block, so every
multi-block chat turn failed at task start. A turn now becomes one message
per block, in order and with its role.
…ce row

ty now passes over the rebuilt scenarios: rows minted by a live environment
come from a typed template, SDK stand-ins are typed as what they stand in
for, and identity rows pass their ids explicitly. The row asserting that an
agent deadline kills a running workspace command depended on the workspace
starting the command within a fixed budget and failed under coverage; the
kill belongs to the workspace and agent areas, and the deadline itself stays
pinned by the rollout table.
…holds stdout

SubprocessRuntime learned that the child died only from stdout reaching EOF.
A daemon started from @env.initialize inherits stdout, so a child that crashed
after starting one left the runtime waiting out its 120 s ready timeout and
raising a bare TimeoutError. Linux passed only because asyncio kills the
daemon while the dying interpreter finalizes its transport. The port read now
races the child's exit, and an exit without a port reports the exit code and
output at once.
…narios

REVIEW.md pointed reviewers at sandbox scenario rows the suite does not have.
Help, version, hud set, the text and --json error contract, platform error
mapping, deprecation warnings and the upgrade notice now run the real hud
CLI in a subprocess against the fake platform. The harness Hud gains start()
for commands that run until signalled and a terminal width, so CLI snapshots
fit the line limit.
Typer turns every failure into a bare sys.exit(code) before the invocation
recorder sees it, so every event posted error_class null: a missing key, a
usage error, an unknown command, a platform 403 and Ctrl-C alike. The
recorder now walks the cause and context chain under the exits to the
original exception. The analytics scenarios run real failing commands and
a SIGINT against the fake telemetry service; the tests that fed the
recorder hand-built exceptions are removed.
The jobs scenarios run the real CLI: table and quiet output, option
placement around a bare job id, canonical links, malformed ids, and the
cancel requests the platform receives. Cancelling without --yes in a
non-interactive terminal and dry runs post nothing.
The local span reader looked for chat messages with role "tool" on tool
steps, which a step never holds: a tool step carries the originating call
and its MCP result. Local traces therefore listed agent turns only. The
reader now emits one tool_call event per tool step with the tool name,
arguments and result text, marking results flagged isError as errors. The
scenario runs a rollout whose scripted model writes a file through a tool
and reads the trace back with hud trace get.
QA scenarios run the real CLI: the checks table and its quiet and JSON
forms, usage errors that post nothing, the run request body, waiting with
real polling until every requested check settles, the exit status when any
check fails, a real timeout, and how each result shape renders. The helper
tests on presentation_for_result become rows of the results table.
The catalog table and its quiet and JSON forms, checkpoint and head
commands addressing the model the catalog resolves (by id, name or slug),
the PUT that promotes a head, forks with and without --if-not-exists, dry
runs, and unknown models all run the real CLI against the fake platform.
hud project, project list, create and use, and hud sync env run against a
fake platform whose Project search matches substrings the way the
platform's does (the old fake ignored the search, so name resolution was
never tested). Scenarios pin .hud/config.json after each step, refusal of a
link made under other credentials or another origin, migration of the
camelCase config, untouched corrupt and legacy files, and which Project a
directory selects from its link, HUD_DEFAULT_PROJECT, or the team default.
test_project.py's helper-level tests are replaced.
Deploy scenarios run the real CLI against a fake platform that hands out a
presigned upload URL pointing back at the fake services, accepts the build
trigger, streams build-log frames over a WebSocket, and reports the build
status. They pin the trigger body (runtime provider and config, build args
and secrets, environment variables, project, no-cache), the uploaded
tarball for each .dockerignore pattern class with secrets never included,
removal of the temporary tarball, the directory link across redeploys, the
error document for every refusal before upload (including the
non-interactive first deploy with a .env), rejected build requests, and a
failed build, a refused or closed log stream.
The sync scenarios run the real CLI against a fake platform that keeps
tasksets: lookup by name or id, export, and upload. One round trip plans,
uploads, finds nothing to do, uploads an edit, follows a remote rename
through the stored id with a bare hud sync, filters by --task, syncs to
another taskset with and without --link, and never recreates a deleted
stored taskset. Further tables pin exports to csv, json and jsonl, every
refusal that uploads nothing, rejected uploads, Project placement without
pinning the directory, the linked-environment mismatch warning, and
hud sync env by name, id and search.
The eval scenarios run real rollouts: the CLI spawns each environment from
files in a temporary project and the agent reaches a scripted model behind
the fake gateway. Tables cover every project layout (hooks prove each
rollout ran in a fresh process that shut down), environment selection by
name, nested verifiers, attaching to a served environment over tcp://, task
selection and grouping, and how the agent reaches its model: the key, model,
max_tokens and temperature each request carries for gateway, provider-key,
catalog-alias, TOML and custom-endpoint configurations. Dry-run plans and
every invalid configuration are error documents that run nothing. The old
tests replaced Taskset.run and asserted runtime types and mock identities.
hud eval --json counted error_count from job.errors (which includes runs
whose grade is an error) but read runs[].is_error from the trace alone, so a
run the environment graded as an error showed error_count 1 with every run
is_error false, and the command exited 0. Each run's is_error now reports
membership in job.errors, and hud eval exits 1 when any run errored while a
low reward still exits 0. The CLI reference documents the exit status.
Task scenarios list a Python and a JSON source (text, quiet, JSON), start
and grade tasks spawned from their source with --answer, --answer-file and
stdin, attach with --url to an environment served in the test (a source
resolving a slug to its template and args, or a raw id with --args), resume
or refuse parked sessions, and pin each error document. The old tests
called the private _resolve helper directly.
hud serve had no tests. The scenarios start it as a subprocess for a file,
the default env.py, a module attribute and a factory with --arg, read the
announced port, start and grade a task over the control channel, stop it
with SIGINT and check the banner and the clean Stopped exit. A malformed
--arg and a missing target are error documents.
Init scenarios copy each example from this checkout into a new directory
and check the renamed Environment declaration and that caches are not
copied; the blank example then runs under hud eval with a scripted model
and earns its reward. Refusals (a non-empty directory, symlinks inside or
as the target, an unknown example, nothing to create) leave every existing
file untouched. The old tests called init_command directly and patched the
module's __file__ and copytree.
Every contract these pinned now runs through the real hud CLI in the
scenario files: the shell contract, analytics and notices in test_shell,
jobs, trace, qa and models in their own files, init in test_init. What is
dropped pinned private structure or mocks: main() calling a patched app,
existence and help-prose checks, and a uv-tool install layout faked by
patching sys.prefix.
test_workspace.py and test_capability_backing.py still patch hud internals;
their counts may only fall from here.
The event reports sys.platform, so the row only held on Linux.
pydantic's message links to docs under its own version, which differs between
locks.
The loader names a missing .py source as missing; the row predated that fix.
The uv image tagged python3.12-bookworm ships uv 0.9, below the project's
required-version floor, so uv refused to run.
…e coding scenario in the Sandbox job

Codex runs shell commands in its own bubblewrap sandbox, which Ubuntu 24.04
runners block until the userns sysctl is lifted; Live lifted it only after the
agent scenarios, so Codex's commands failed and the workspace scenario graded 0.
The coding template's live scenario now runs in the Sandbox job, which gets the
HUD key, instead of a second copy of that job's container in Live.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread .github/workflows/ci.yml Resolved
The coding template's live scenario times itself out at 30 minutes, the whole
Sandbox job's limit, so a stuck rollout would cancel the job before pytest
reported it. The job now has the 45 minutes Live gave that scenario.
An eval with a few errored runs among graded ones still measured something, and
exiting 1 for it would stop any script that chains on hud eval. hud eval now
exits 1 only when every run errored; error_count and each run's is_error still
mark the errored runs.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 33efa6a9c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hud/utils/platform.py Resolved
Modal, Harbor and LeRobot ran only nightly, so a release could ship a commit
they never ran on, and a red nightly blocked nothing. Pre-release now calls
live.yml, so the gate runs the real-model, Modal, Harbor and LeRobot lanes on
the commit it validates.
Repository secrets reach any branch's workflow; the pre-release environment
serves its secrets only to main.
…e model

The secret fixture's file was secret.txt in a hud-fixture-secret directory, and
gpt-6-luna refused to read a file labeled secret in about half its runs, so the
cell graded 0 although the shell worked. The file is now note.txt in a
hud-fixture-note directory; eight sequential runs all scored 1.
Modal reads its config file once, when first imported, and a scenario imported
modal while HOME was the test's empty home, so MODAL_CONFIG_PATH set afterwards
went unread and a developer with only ~/.modal.toml got Token missing. The
fixture now passes the file's active profile as MODAL_TOKEN_ID and
MODAL_TOKEN_SECRET, which Modal reads on every call.
uv run --with adds lerobot to an overlay interpreter, but the pytest script
runs the project's own, so every LeRobot scenario skipped and the nightly job
passed with nothing run. python -m pytest runs under the overlay; all ten
scenarios pass.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread tests/conftest.py Resolved
The fixture took only a profile marked active, so a file whose profile came
from MODAL_PROFILE or was named default gave no token. It now follows Modal's
order: MODAL_PROFILE, else the active profile, else default.
The Modal fixture and the collection check each decided on their own where a
token comes from, and neither matched Modal: one followed a copy of its profile
rules, the other took any config file as an account. Both now ask Modal, in a
process with the real environment, which token it resolves; the fixture passes
it as variables, since Modal reads its file only once, at import.
An eval with no tasks is refused before it runs, so a job reaching the exit
rule always has runs; the guard only made an impossible empty job exit 0.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff57a54692

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hud/imports.py Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread tests/conftest.py Resolved
The shared-network case asserted that the text "\tdb" was absent from
/etc/hosts, and Docker writes the container's own hostname there, a random hex
id; one starting with db failed the test. Entries are now parsed into address
and name pairs and compared whole.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 high effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit a4d35f2. Configure here.

The skip hook ran before -m deselected, so the default unit run probed Docker
and Modal for e2e tests it would never run, and a malformed Modal config
crashed its collection. The hook now runs last, after deselection, and the
Modal probe leaves Modal's own error on stderr when a selected run hits one.
The shared-network case looked for db at 127.0.0.2, the address it gets only
when its port is reserved; without that it would land on 127.0.0.1 and pass
unseen. The test now reads each name's addresses, expects an address among
them, and requires an absent name to resolve to none.
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.

1 participant