tools: version the free-model calibration graders

Both graders, with the reference-implementation note: the first two scoreboards
were grader bugs (a fixture mounting a path that does not exist, and a boundary
case reusing the previous case's fixture), not model failures.
This commit is contained in:
ziadarafat committed 2026-11-28 23:18:01 -07:00
1 parent 8d73a773b3
commit bf0170070e
5 files changed
+137

No files matched your search

@@ -0,0 +1,27 @@
# Task: write an ops health-check script
Create `disk-guard.sh` (bash, must run on Debian) that reports filesystem usage
for a path and exits with a status that cron and monitoring can use.
disk-guard.sh <path> [warn_pct] [crit_pct]
- Defaults: `warn_pct=80`, `crit_pct=90`. Both are whole percentages.
- Usage percent comes from `df -P <path>` (the `Capacity` column, e.g. `87%`).
- **Testability requirement:** if the environment variable
`DISK_GUARD_DF_FIXTURE` is set, read the `df` output from that file instead of
running `df`. This is how the grader supplies fixed numbers — it is a hard
requirement, not a suggestion.
- Output, exactly one line on stdout:
`OK <pct>% <path>` below warn, `WARN <pct>% <path>` at or above warn,
`CRIT <pct>% <path>` at or above crit.
- Exit status: `0` OK, `1` warn, `2` crit, `3` the path does not exist,
`4` bad arguments (non-numeric threshold, or warn_pct > crit_pct).
- Prefix any message on stderr with `disk-guard:`.
`spec_test.sh` in this directory is the grader: 11 checks, covering the
threshold boundaries, custom thresholds, bad arguments, a missing path and one
live `df` call against `/`. **Do not modify or delete it** — make it pass:
./spec_test.sh
Only create `disk-guard.sh`.
@@ -0,0 +1,27 @@
# Task: write an ops health-check script
Create `disk-guard.sh` (bash, must run on Debian) that reports filesystem usage
for a path and exits with a status that cron and monitoring can use.
disk-guard.sh <path> [warn_pct] [crit_pct]
- Defaults: `warn_pct=80`, `crit_pct=90`. Both are whole percentages.
- Usage percent comes from `df -P <path>` (the `Capacity` column, e.g. `87%`).
- **Testability requirement:** if the environment variable
`DISK_GUARD_DF_FIXTURE` is set, read the `df` output from that file instead of
running `df`. This is how the grader supplies fixed numbers — it is a hard
requirement, not a suggestion.
- Output, exactly one line on stdout:
`OK <pct>% <path>` below warn, `WARN <pct>% <path>` at or above warn,
`CRIT <pct>% <path>` at or above crit.
- Exit status: `0` OK, `1` warn, `2` crit, `3` the path does not exist,
`4` bad arguments (non-numeric threshold, or warn_pct > crit_pct).
- Prefix any message on stderr with `disk-guard:`.
`spec_test.sh` in this directory is the grader: 11 checks, covering the
threshold boundaries, custom thresholds, bad arguments, a missing path and one
live `df` call against `/`. **Do not modify or delete it** — make it pass:
./spec_test.sh
Only create `disk-guard.sh`.
+17
View File
@@ -0,0 +1,17 @@
# Free-model calibration
Graders used to score free-tier lanes on a task whose pass condition we control.
A worker is told not to modify the grader; the grader is written here and copied
into the worker's directory.
| Files | Task | Lane results (2026-11-29) |
|---|---|---|
| `BRIEF-code.md`, `spec_test-code.py` | roman numerals, 30 pytest cases | zai 30/30, gemini-3.1-flash-lite 30/30, cohere-1.0 23/30, groq/gpt-oss-120b 0/30 (429) |
| `BRIEF-infra.md`, `spec_test-infra.sh` | `disk-guard.sh`, 11 shell cases | zai 11/11, gemini-3.1-flash-lite 11/11 |
Run one lane: `free-agent --brief BRIEF-<x>.md --dir <lane dir> --role <code|infra> --model <id>`.
**Validate the grader before trusting a score.** Write a reference implementation
and confirm it scores full marks; both of these graders shipped bugs first (a
fixture pointing at a path that does not exist, and a case reusing the previous
case's fixture), and the wrong grader blamed the models for both.
@@ -0,0 +1,24 @@
"""Grader for the roman-numeral calibration task. Not to be modified by workers."""
import pytest
from roman import to_roman, from_roman
PAIRS = [(1, "I"), (4, "IV"), (9, "IX"), (14, "XIV"), (40, "XL"), (90, "XC"),
(400, "CD"), (900, "CM"), (1994, "MCMXCIV"), (2024, "MMXXIV"), (3999, "MMMCMXCIX")]
@pytest.mark.parametrize("n,s", PAIRS)
def test_to_roman(n, s):
assert to_roman(n) == s
@pytest.mark.parametrize("n,s", PAIRS)
def test_roundtrip(n, s):
assert from_roman(s) == n
@pytest.mark.parametrize("bad", [0, -1, 4000])
def test_to_roman_out_of_range(bad):
with pytest.raises(ValueError):
to_roman(bad)
@pytest.mark.parametrize("bad", ["", "IIII", "VV", "ABC", "MMMM"])
def test_from_roman_invalid(bad):
with pytest.raises(ValueError):
from_roman(bad)
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
# Grader for the disk-guard calibration task. Written by the primary agent.
# The worker may not modify this file.
set -uo pipefail
S=${SCRIPT:-./disk-guard.sh}
pass=0; fail=0
check() { # name expected_exit expected_out_substr -- args...
local name=$1 eexit=$2 esub=$3; shift 4
out=$("$S" "$@" 2>/dev/null); rc=$?
if [ "$rc" = "$eexit" ] && { [ -z "$esub" ] || printf '%s' "$out" | grep -qF -- "$esub"; }; then
pass=$((pass+1)); printf 'ok %-42s rc=%s out=%s\n' "$name" "$rc" "$(printf '%s' "$out" | head -c 40)"
else
fail=$((fail+1)); printf 'FAIL %-42s want rc=%s/%s got rc=%s/%s\n' "$name" "$eexit" "$esub" "$rc" "$(printf '%s' "$out" | head -c 40)"
fi
}
mk_fixture() { printf '%s\n' "Filesystem 1024-blocks Used Available Capacity Mounted on" "$1 $2 $3 $4 $5" > "/tmp/dgfx.$$"; echo "/tmp/dgfx.$$"; }
trap 'rm -f /tmp/dgfx.*' EXIT
export DISK_GUARD_DF_FIXTURE=$(mk_fixture / 1000 500 500 50%)
check "50% under default warn" 0 "OK 50%" -- /
export DISK_GUARD_DF_FIXTURE=$(mk_fixture / 1000 800 200 80%)
check "80% hits default warn" 1 "WARN 80%" -- /
export DISK_GUARD_DF_FIXTURE=$(mk_fixture / 1000 950 50 95%)
check "95% hits default crit" 2 "CRIT 95%" -- /
export DISK_GUARD_DF_FIXTURE=$(mk_fixture / 1000 650 350 65%)
check "65% with warn=60 crit=70" 1 "WARN 65%" -- / 60 70
check "65% with warn=70 crit=90" 0 "OK 65%" -- / 70 90
export DISK_GUARD_DF_FIXTURE=$(mk_fixture / 1000 800 200 80%)
check "exactly at warn is WARN" 1 "WARN 80%" -- / 80 90
export DISK_GUARD_DF_FIXTURE=$(mk_fixture / 1000 1000 0 100%)
check "100% is CRIT" 2 "CRIT 100%" -- /
check "warn greater than crit" 4 "" -- / 90 80
check "non-numeric threshold" 4 "" -- / abc 90
unset DISK_GUARD_DF_FIXTURE
check "missing path" 3 "" -- /nonexistent-path-xyz
out=$( "$S" / 2>/dev/null ); rc=$?
if { [ "$rc" = 0 ] || [ "$rc" = 1 ]; } && printf '%s' "$out" | grep -qE "^(OK|WARN) [0-9]+% /$"; then
pass=$((pass+1)); printf 'ok %-42s rc=%s out=%s\n' "real df on /" "$rc" "$out"
else
fail=$((fail+1)); printf 'FAIL %-42s rc=%s out=%s\n' "real df on /" "$rc" "$out"
fi
printf '\n%d passed, %d failed\n' "$pass" "$fail"
[ "$fail" -eq 0 ]