A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
fix daily stats delivery marker lookup (#3423)
kt39835a1d2348
diff --git a/.github/workflows/daily-stats.yml b/.github/workflows/daily-stats.ymlindex 6b79d5c634..199421b191 100644--- a/.github/workflows/daily-stats.yml+++ b/.github/workflows/daily-stats.yml@@ -67,7 +67,7 @@ jobs:REPORT_DAY: ${{ steps.day.outputs.date }}run: |marker="prime-agent-stats-$REPORT_DAY"- ids=$(gh api --paginate "repos/$GITHUB_REPOSITORY/actions/artifacts?per_page=100" \+ ids=$(gh api --paginate "repos/$GITHUB_REPOSITORY/actions/artifacts?name=$marker&per_page=100" \--jq ".artifacts[] | select(.name == \"$marker\" and .expired == false) | .id")if [[ -n "$ids" ]]; thenecho 'attempted=true' >> "$GITHUB_OUTPUT"diff --git a/scripts/test_daily_stats.py b/scripts/test_daily_stats.pyindex 489d8634b0..037f1555ba 100644--- a/scripts/test_daily_stats.py+++ b/scripts/test_daily_stats.py@@ -3,7 +3,10 @@import contextlibimport ioimport json+import os+import subprocessimport tempfile+import textwrapimport unittestfrom datetime import date, datetime, timedelta, timezonefrom pathlib import Path@@ -16,6 +19,55 @@ import daily_stats as statsDAY = date(2026, 10, 5)+class DeliveryLookupTests(unittest.TestCase):+ def lookup(self, ids="", status=0, error=""):+ workflow = (Path(__file__).resolve().parents[1] /+ ".github/workflows/daily-stats.yml").read_text()+ step = workflow.split(" - name: Check previous delivery attempt\n", 1)[1]+ script = textwrap.dedent(step.split(" run: |\n", 1)[1]+ .split(" - name:", 1)[0])+ # Stub only the API boundary; execute the workflow's actual Bash script.+ gh = r'''+gh() {+ [[ "$1" == api && "$2" == --paginate ]] || return 99+ [[ "$3" == "repos/test/repo/actions/artifacts?name=prime-agent-stats-2026-10-05&per_page=100" ]] || return 99+ [[ "$4" == --jq && "$5" == '.artifacts[] | select(.name == "prime-agent-stats-2026-10-05" and .expired == false) | .id' ]] || return 99+ printf '%s' "$API_IDS"+ printf '%s' "$API_ERROR" >&2+ return "$API_STATUS"+}+'''+ with tempfile.TemporaryDirectory() as directory:+ output = Path(directory) / "output"+ env = {"PATH": os.environ["PATH"], "REPORT_DAY": DAY.isoformat(),+ "GITHUB_REPOSITORY": "test/repo", "GITHUB_OUTPUT": str(output),+ "API_IDS": ids, "API_STATUS": str(status), "API_ERROR": error}+ result = subprocess.run(["bash", "--noprofile", "--norc", "-e", "-o",+ "pipefail", "-c", gh + script + "\necho lookup-complete"],+ env=env, capture_output=True, text=True, timeout=10)+ return result, output.read_text() if output.exists() else ""++ def test_successful_empty_lookup_allows_report_preparation(self):+ result, output = self.lookup()+ self.assertEqual((result.returncode, result.stdout, output),+ (0, "lookup-complete\n", ""))++ def test_existing_markers_prevent_duplicate_delivery(self):+ for ids in ("123\n", "123\n456\n"):+ with self.subTest(ids=ids):+ result, output = self.lookup(ids=ids)+ self.assertEqual((result.returncode, output), (0, "attempted=true\n"))+ self.assertIn("skipping", result.stdout)++ def test_api_errors_stop_before_report_preparation_even_after_partial_results(self):+ for ids, error in (("", "unexpected end of JSON input"),+ ("", "HTTP 500"), ("123\n", "HTTP 500 on later page")):+ with self.subTest(ids=ids, error=error):+ result, output = self.lookup(ids=ids, status=1, error=error)+ self.assertEqual((result.returncode, output), (1, ""))+ self.assertNotIn("lookup-complete", result.stdout)++def fixture():days = [(DAY - timedelta(days=offset)).isoformat() for offset in (30, 7, 1, 0)]values = ([20, 50, 80, 100], [120, 200, 220, 300], [500, 600, 650, 700],