Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .agents/skills/remote-paper-curation/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,24 @@ write a JSON payload containing `evaluations` (each has this job's
`paper_id`) and submit it with `python3 jobs/curation_api.py apply payload.json`.
Always include `evaluation_removals`, `validation_evidence`, and
`benchmark_gaps` arrays. Updating an existing row requires its exact context
`before_state`, a field-level diff, and primary-paper evidence. Duplicate
`before_state`, a field-level diff, and primary-paper evidence. The server
recomputes the diff between the stored row and the row you submit in
`evaluations`, and `field_diff` must equal it exactly: one key per changed
top-level field, each `{"before": <stored value>, "after": <submitted value>}`,
with whole values (all of `metrics`, not one metric). Fields you leave
unchanged must be copied verbatim from `before_state`, or they become part of
the diff. To correct one score:

```json
{"evaluation_id": 38506, "before_state": {...},
"field_diff": {"metrics": {"before": {"Dice": 0.95}, "after": {"Dice": 0.948}}},
"evidence": [{"source_url": "...", "table": "Table 2", "snippet": "..."}]}
```

If the apply is rejected with `expected field_diff for evaluation <id>`, the
message contains the diff the server computed. Either use it as `field_diff`
or fix the submitted row so it no longer changes fields you did not mean to
change. Duplicate
consolidation additionally requires every matched row ID and the canonical-row
selection reason. Remove an invalid row only with its full before-state and
unambiguous primary-paper evidence.
Expand Down
5 changes: 4 additions & 1 deletion backend/services/codex_curation_callback_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import json
import math
import re
from datetime import UTC, datetime
Expand Down Expand Up @@ -2004,7 +2005,9 @@ def _validate_scheduled_policy(
audit["field_diff"] = supplied_diff
if audit.get("field_diff") != changes or not audit.get("evidence"):
raise ValueError(
"Evaluation update requires the exact field diff and primary evidence"
"Evaluation update requires the exact field diff and primary "
f"evidence; expected field_diff for evaluation {canonical.id}: "
f"{json.dumps(changes, sort_keys=True, default=str)}"
)
if len(matches) > 1:
duplicate_ids = sorted(
Expand Down
79 changes: 79 additions & 0 deletions backend/tests/curation/test_codex_callback_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,85 @@ def query(self, model):
}


def test_scheduled_existing_row_diff_mismatch_reports_the_expected_diff():
from backend.models.database import Evaluation, Metric, Paper, TaskDataset

paper = SimpleNamespace(
id=42,
source="arxiv",
source_url=None,
arxiv_id="2601.00001",
)
existing = _stored_evaluation(
methodology=None,
metrics={"GenEval Score": 0.9},
source_url="https://paperswithcode.co/paper/2601.00001",
external_source_url="https://paperswithcode.co/paper/2601.00001",
)

class Query:
def __init__(self, model):
self.model = model

def join(self, *_args):
return self

def filter(self, *_args):
return self

def one_or_none(self):
if self.model is TaskDataset:
return SimpleNamespace(supports_harness=False)
return None

def all(self):
if self.model is Metric:
return [SimpleNamespace(name="GenEval Score", scale="0-1")]
if self.model is Evaluation:
return [existing]
return []

class Database:
def get(self, model, _key):
return paper if model is Paper else None

def query(self, model):
return Query(model)

audit = {
"evaluation_id": existing.id,
"before_state": CodexCurationCallbackService._evaluation_state(existing),
"field_diff": {"metrics": {"GenEval Score": {"before": 0.9, "after": 0.91}}},
"evidence": [{"source_url": "https://arxiv.org/abs/2601.00001"}],
}
proposed = _evaluation(model_name="Existing Model")
proposed.metrics = {"GenEval Score": 0.91}
body = ApplyMutationRequest(
evaluations=[proposed],
validation_evidence=[audit],
score_evidence=[_score_evidence(source_value=91)],
)

with pytest.raises(ValueError) as error:
_scheduled_policy(
_service(Database(), SimpleNamespace()),
SimpleNamespace(
kind="add-evals",
paper_id=42,
trigger="hf-daily-cron",
trace_status="preapply_stored",
),
body,
)

assert str(error.value) == (
"Evaluation update requires the exact field diff and primary evidence; "
f"expected field_diff for evaluation {existing.id}: "
'{"metrics": {"after": {"GenEval Score": 0.91}, '
'"before": {"GenEval Score": 0.9}}}'
)


def test_scheduled_evaluation_rejects_multiple_models_per_leaderboard():
from backend.models.database import Paper

Expand Down
Loading