Skip to content

feat(scorers): label delivered pull requests from their check, CI or protected paths before any judge runs - #1665

Merged
SaulMoro merged 26 commits into
Tencent:mainfrom
hz89Dev:saulmoro/1247-score-delivered-run
Nov 2, 2026
Merged

SaulMoro merged 26 commits into
Tencent:mainfrom
hz89Dev:saulmoro/1247-score-delivered-run

Conversation

@hz89Dev

@hz89Dev hz89Dev commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A scorer on a deliver: pr step had no way to label what the run actually handed over. Every pass went to a model judge, even when the pull request's tests or CI had already shown it was broken. Now three deterministic stages run first, in order. The first one that fails decides the label, and no judge launches. A pass that clears all three still goes to the judge, which now also reads the run's inputs and every step's outputs.

score pass of a deliver: pr step
  no delivered commit           -> judge
  scorer check fails            -> highest label below passingScore, decidedBy: check
  delivered commit's CI failed  -> same, decidedBy: ci
  pass hit a protected path     -> same, decidedBy: protected
  otherwise (or CI still running, or no CI) -> judge, decidedBy: judge
  • Check: the scorer's check.run runs in a fresh clone of the delivered commit, after its protect paths are restored to the starting commit. An agent that edits test/ to get green cannot pass this way. A check that cannot run fails as check_could_not_run and writes no label.
  • CI:
    • GitHub reads every check run and every commit-status context.
    • GitLab reads the newest pipeline.
    • CI that is still running counts as not finished, so the label waits for the judge rather than reporting a failure early.
  • On demand: teamai score --run <id> --scorer <name> infers --step from the run. It refuses with step_ambiguous when more than one step lists the scorer, and with evidence_missing when the pass's evidence is gone from the machine. When several scorers are asked for and one of them cannot be scored, the others are still judged. The error then names the labels they kept.
  • Labels:
    • Each label records decidedBy, plus an evidenceHash over what the judge would read, so a label can be traced to the exact evidence behind it.
    • A label decided by a stage carries no usage, because no judge ran.
  • Dashboard:
    • The Scorers page gains a "What decided these labels" panel: per stage, how many labels it decided and how many passed. Clicking a row filters the failing-labels table, which gains a DECIDED BY column.
    • In run detail, a score shows which stage decided it.
    • Stage-decided labels join the measurement for their scorer, rubric and judge tool, so stage results do not split the model comparison.

Docs, with worked examples: docs/guide/scorers.md ("Score what a run delivered", "On demand"), docs/guide/dashboard.md, their zh-CN pages, docs/dev/workflow-engine.md, and skill-data/workflow/references/judging.md.

Screenshots come from a fixture project with labels from all four deciders.

Desktop Tablet Mobile
What decided these labels
Failing labels, filtered to Pull request CI
Run detail steps, score with its stage

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

Proof: I ran the built CLI end to end on a real ship-issue workflow for three cases. A failing check, failing CI, and passing CI each produced the expected label and decider, and only the passing case launched the judge.

  • npx tsc --noEmit passes
  • npm run lint passes (0 warnings), node scripts/check-docs.mjs passes
  • npx vitest run passes (667 files, 20757 tests)
  • Added/updated tests for the change
    • Unit: the stage order and deciders, no delivered commit goes to the judge, check_could_not_run, step_ambiguous, evidence_missing, GitHub check runs and commit statuses (pending wins over failed, and a partial page counts as pending), GitLab pipelines, and the Scorers measurements and decided rows.
    • E2E: npm run test:e2e -- src/__tests__/e2e/score-delivered-run-1247.test.ts passes 4/4: CI failure, failing check, the same failing check on a workflow: step with deliver: pr, and CI success. benchmark-try and benchmark-checks (37 tests) pass after the check runner move.

Real-CLI record, after npm run build. The record comes from the E2E fixture. A ship-issue run has a read-issue command step and a change step with deliver: pr on a GitHub origin. It is followed by teamai score --run <id> --scorer delivered. Reasoning paths are omitted.

issue 13, scorer check fails (CI green)
  CLI:       {"label":"partial","score":0.5,"passed":false,"decidedBy":"check","published":true}
  published: "judge":{"kind":"model","tool":"claude","isolation":"verified","access":"full"}  (no usage)
             "evidenceHash":"sha256:8d676d0e..."
  judge launches: none

issue 42, delivered commit's CI failed
  CLI:       {"label":"partial","score":0.5,"passed":false,"decidedBy":"ci","published":true}
  published: no usage, "evidenceHash":"sha256:e27f8b46..."
  judge launches: none

issue 42, CI passed
  CLI:       {"label":"complete","score":1,"passed":true,"decidedBy":"judge","published":true}
  published: "judge":{"kind":"model","tool":"claude","model":{"reported":"fake-judge"},
             "usage":{"cost":{"amount":0.1,"unit":"USD"}},"isolation":"verified","access":"read"}

The published labels also contain none of the issue text, the prompt, the diff, or the reasoning. The E2E asserts this.

A workflow: step that delivers is labelled the same way. In the fourth E2E case, change runs a workflow whose write step makes the change, and the scorer's check decides partial with no judge.

Coverage gaps: the real-CLI run used Claude and a GitHub origin. GitLab CI reading and the Codex, CodeBuddy and OpenCode agents are covered by unit tests only. The rest of the matrix is left to CI.

Related Issues

Closes #1247

Notes for Reviewers

  • Check runner moved into the workflow layer. A scorer's check reuses the benchmark check runner, so it behaves exactly as a benchmark trial's check does. The workflow layer must never import src/benchmark/, so the check definitions and the runner now sit below both. No boundary disable remains, and the move is one commit of its own:

    - src/benchmark/check.ts                 # what a check is, its verdict
    + src/workflow/check.ts                  # same file, plus AddedSchema from benchmark/terms.ts
    + src/workflow/check-run.ts              # runCheckAt (was tryCheckAt), restoreProtected, writeAdded
      src/benchmark/trial.ts                 # keeps runCheckStep, commitCheckFiles, trialBlocker, progress lines

    The code moves unchanged. Only tryCheckAt is renamed, to runCheckAt, since it now runs scorer checks as well as teamai benchmark try. teamai/workflow-boundaries now lists check-run.ts as an importer of place.ts and setup.ts, and drops trial.ts from setup.ts. The benchmark end-to-end tests (benchmark-try, benchmark-checks: 37 tests) pass after the move.

  • Label shape.

    • Stage-decided labels keep judge: {kind: "model", tool} for the lease's judge, without model or usage, as the issue specifies.
    • decidedBy is the field that says no model ran.
    • scoringTotal and the "judge ran" counts skip stage-decided labels.
  • Dashboard scope. The decided panel and column extend the existing Scorers page from [feat] Show scorer results in the dashboard #1182. There is no new view.

  • CI reading. GitHub's combined status can say failure while another context is still pending, so the code reads each context. A pending context, or more results than one page holds, means not finished, and the judge decides.

A scorer file may set check: { run, protect }, the shape a benchmark task's
check has (Tencent#1180), so what a delivering step produced can be decided by a
command before any judge (Tencent#1247). The shared shape moves to
benchmark/check.ts; a task's check extends it with add.

Proof: scorers-definition and benchmark unit tests.
…nd every step's outputs

A scorer on a deliver: pr step judges what was delivered against what the run
was asked: the evidence now holds inputs.json and the outputs every step
reported, as the run stored them when each step reported, so a later edit to
the issue a step read changes neither. Other steps keep their own outputs only.

Proof: workflow-scoring-evidence test with a read-issue step.
…ts evidence

A workflow label now carries decidedBy (judge, until the deterministic stages
land) and evidenceHash, sha256 of the fenced evidence the judge read. Evidence
comes from what the run recorded, so scoring the same pass again after the
issue or main moved gives the same hash.

Proof: workflow-scoring-evidence test scores a delivered pass twice around a
commit on main and compares the hashes.
…fore any judge

Passes of deliver: pr steps now go through stages before their judge, in the
lease path every driver shares (score --next, the local judge loop, on demand,
the drain). The first stage is the delivery's own protected-path refusal
(Tencent#1090): it gives the scorer's best label below passingScore, with
decidedBy: protected, the lease's judge named without usage, and the reason
kept in the local reasoning file. score --next lists such labels under
decided.

Proof: workflow-scoring-evidence test rewrites the delivering step as refused
for .github/workflows/ci.yml; no lease is handed out and the label is partial.
PullRequestLookup gains a read-only checks member: GitHub reads a commit's
check runs and combined status, GitLab its newest pipeline. A failed one
fails it, a running one leaves it pending, a cancelled or skipped one says
nothing. Hosts TeamAI does not read leave it out. The lookup still has no
write member, and the pinned key set says so.

Proof: workflow-pr-providers tests over fetch and a fake gh.
… any judge

Before the protected-path stage, the CI of the pull request a pass delivered
is read once from the origin's host at the commit the pass delivered. A
failed CI gives the scorer's best label below passing with decidedBy: ci. A
pending CI, no CI, or a host whose CI TeamAI does not read hands the pass to
the judge; a host that did not answer is warned of and does the same.

Proof: workflow-scoring-evidence tests with a fake gh answering a failed and
a running check run.
…s judge

A scorer with check: { run, protect } on a deliver: pr step now runs it first,
the way a benchmark trial runs its check: a fresh clone of the delivered
commit, the protected paths put back as the commit the work started from has
them, then the command. A failed check gives the best label below passing
with decidedBy: check; a passing one hands on to CI and the protected stage.
A check that cannot start, is killed or times out settles the entry unscored
as check_could_not_run, with no judge and no label. Such a scorer is leased
alone, since the other stages decide every scorer of a pass alike. A label a
stage decided no longer counts as a judge call that stated no cost.

Proof: workflow-scoring-evidence tests: a failed check with the agent's own
copy of the protected test, a passing check, and a check command that does not
exist.
…er, and refuse when its evidence is gone

teamai score --run <id> --scorer <name> no longer needs --step when the run
lists the scorer on one step, as Tencent#1247's delivering step usually is; it asks
for --step when the run lists it on none or several. Before recording any
request, it checks the commits the pass's diff spans and the sessions its
passes recorded, and fails with evidence_missing naming each one that is no
longer on this machine, writing no label.

Proof: workflow-scoring-evidence tests: a samplingRate: 0 run scored with
--run and --scorer only, a scorer listed on no step, and a recorded session
that is gone. commands.md regenerated.
…l each

Pins Tencent#1247's criterion: a loop's two delivering passes, each with its own
pull request and a failed CI, give two labels told apart by subject.pass.
…Scorers page

A delivered pass is labelled by the first stage that fails it (check, CI,
protected paths) before any judge. The Scorers page now groups by that stage,
shows how many labels never reached a judge and the judge's pass rate on the
rest, and lists each failing label with its stage.

Proof: scorers-results and dashboard-ui tests.
…count no judge call for it

Workflow Runs listed a stage-decided label as a judge call in the run's
scoring total. It now counts only attempts and labels a judge produced, and
tags each pass score a stage decided.

Proof: workflow-scoring-evidence and workflow-scoring tests.
…eciding when it failed

A ship-issue run on a GitHub origin delivers a pull request; teamai score
--run --scorer labels it partial from a failed CI with no judge launch, and
publishes no prompt, diff or reasoning. With CI passing the judge decides.

Proof: npm run build && npm run test:e2e -- score-delivered-run-1247 (2 passed).
teamai score --run answered entry_leased, as if another driver held the
lease, when the scorer's check could not run on the delivered commit. It now
fails check_could_not_run with the check's own reason and writes no label.
score --next lists the same reason on the closed entry.

Proof: the new on-demand test went from entry_leased to check_could_not_run.
…e before the judge

Bilingual guide sections for a deliver: pr step's scorer: its check, the
stage order, decidedBy and evidenceHash on the label, scoring on demand with
only --run and --scorer, evidence_missing and check_could_not_run. The
dashboard guide shows the new Scorers panel and the stage on a run's pass
scores. The maintainer doc and the judging reference say where the stages run.

Proof: node scripts/check-docs.mjs passes; outputs copied from a real CLI run.
…surements

A measurement fixes the judge's tool and recorded model. A label a check, CI
or protected-path stage decided names the lease's judge but no reported
model, so it formed a measurement of its own, and the judge's measurement
never showed what failed before review. Such a label now counts in every
model judge's measurement of its rubric, and stands alone only while no judge
labelled that rubric.

Proof: scorers-results tests; a CI label requested haiku and judge labels
reported by claude and codex now give two measurements, each with the CI row.
…eck runner import

step_ambiguous and evidence_missing join the refusals of teamai score --run in
the failure-code policy. scoring-stages.ts runs a scorer's check through the
runner benchmark trials use, so its import names why it crosses the workflow
boundary. The CI readers keep their status lists in sets.

Proof: npm run lint exits 0 with no warnings; npx vitest run passes.
… it names

A label a check, CI or protected-path stage decided names its scorer's model
judge, so it belongs to that judge's measurement. It joined every model
judge's measurement of its rubric, so a CI failure named for claude also
counted under codex. It now joins only the measurements of the tool it
names. Whether a stage decided a label is answered in one place,
isStageDecider in label.ts.

Proof: scorers-results test with claude and codex judges: claude 9, codex 2.
- --step may be left out only when the workflow lists the scorer on one step,
  whether or not that step succeeded; a run listing it on two asks for --step.
- Stage verdicts are matched with a never check, and an entry settled unscored
  while a lease is looked for is kind closed, whatever closed it.
- Whether a pass delivered is answered once, in scoring-evidence.ts, and
  decideBeforeJudge says itself that only a delivered pass has stages.
- Each row of the stage breakdown carries its group key, so the Scorers page
  never rebuilds that format.
- deliveredCi takes a named object; originOf keeps its own doc comment.
- The evidence_missing message is one searchable literal.
- The score refusal shows --step as optional.

Proof: npm run lint, tsc, and the scoring, scorers, dashboard and provider
tests pass; the new on-demand test went from a silent label to step_ambiguous.
…run the full example end to end

A pass of a deliver: pr step that changed nothing delivered no commit. Its
scorer's check answered check_could_not_run with "Fix the check", which is
the wrong advice: the check has nothing of that pass to say, as CI has not.
It now hands the pass to the judge, and the check is unrunnable only when the
run recorded no starting commit or checkout for a delivered commit.

The real-CLI test now runs the guide's example: read-issue returns the issue
as a typed output, the scorer has a check, and three runs are decided by the
check, by CI and by the judge. Published labels hold none of the issue text,
the prompt, the diff or the reasoning.

Proof: npm run build && npm run test:e2e -- score-delivered-run-1247 (3 passed);
the new unit test went from a closed entry to a lease.
…g without its hash

evidenceHash read the fenced evidence and treated every read error as "no
evidence". Only an absent file means that; a permissions or I/O error now
throws, so a label never silently loses its evidenceHash.

Proof: tsc, lint, workflow-scoring-evidence and workflow-scoring tests.
…e workflow's steps

- A failed check run beside one still running, or beside a pending commit
  status, read as failed CI, so unfinished CI decided the label. CI that has
  not finished now reads as pending and hands the pass to the judge.
- --step was inferred from the steps that recorded a pass, so a second step
  listing the scorer that never ran was missed and the first was picked
  silently. It is now inferred from every step of the run, whatever its status.

Proof: workflow-pr-providers gains both CI cases (red before, green after); the
new on-demand test went from a silent label to step_ambiguous.
GitHub's combined commit status reads failure as soon as one context fails,
even while another is still pending, so unfinished CI still decided the
label. The CI read now looks at each status context, asks for 100 at a time,
and reads a commit with more contexts than one page shows as pending.

Proof: workflow-pr-providers gains a failed context beside a pending one and
an overflowing page (red before, green after); the real-CLI e2e passes.
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
  • [P1 blocking] Release the unused lease before returning a check error — src/workflow/scoring.ts:1467. With two requested scorers, if the first check cannot run and the second needs a judge, takeJudgeLease returns both the first scorer’s closed entry and a live lease for the second. This return abandons that lease without judging or releasing it, blocking another driver until it expires. Handle or release taken.lease before returning the error.

The PR description documents sufficient testing, including representative built-CLI runs. No additional provider × agent coverage is required. I only read the diff; I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

The stage order works as described. I ran the built CLI against this head and against main (8a84704), with a fake gh standing in for GitHub:

  • Protected edit: the agent rewrote a protected test.js to accept its wrong answer, and CI was green. The label is partial with decidedBy: check, and no judge launched. CI was not read, so the check really runs first.
  • Red CI: with CI failure, the label is partial with decidedBy: ci, and no judge launched. On main the same pass is judged complete.
  • CI green or still running: the pass goes to the judge, and the evidence includes inputs.json.
  • Rescoring: gives the same evidenceHash.
  • Missing session: evidence_missing names the session and writes no label.
  • Clean up: the check's clone is removed, and the member's checkout is untouched.

[P1 blocking] One scorer's check that cannot run strands the other scorers

src/workflow/scoring.ts:1458-1467: teamai score --run <id> --scorer plain --scorer delivered, where delivered has a check that cannot run (no-such-command):

exit 1
{"error":{"code":"check_could_not_run","message":"The check of scorer delivered, … could not run … No label was written."}}
attempt plain      leased
attempt delivered  failed check_could_not_run
$ teamai score --next --json …
{"data":{"idle":{"open":0,"leased":1}}}

The loop returns on taken.closed before it handles taken.lease. So plain is never judged, its attempt stays leased until the lease expires (30 minutes), and any other driver sees it as taken. This happens in either --scorer order. Judge or release taken.lease before returning. Even simpler: keep judging the other scorers and report the failed check at the end. A test with two scorers on one step would cover it.

[P3 nit]

  • After --step is inferred, step_not_found says "no step with a succeeded pass". The code checks step definitions, not passes.
  • A label decided before any judge runs still records judge.access: "full". Measurements are unaffected.
  • The delivering step's evidence includes outputs of steps that ran after it, so the automatic score and a later on-demand score can hash differently. This matches the spec's wording.

Notes

  • Not run here: real GitHub and GitLab hosts (GitLab only through the unit tests), a workflow: step with deliver: pr, and the dashboard in a browser.
  • This PR conflicts with #1664 in 12 files. Whichever lands second rebases.
  • Follow-up, outside this PR: moving the check runner out of benchmark/trial.ts into a shared module would remove the one workflow-boundaries lint disable.

A scorer's check reused the benchmark check runner through an import
the workflow boundary forbids: the workflow layer never imports
src/benchmark/. The check definitions (benchmark/check.ts, plus
AddedSchema from benchmark/terms.ts) move to workflow/check.ts, and the
runner (tryCheckAt, now runCheckAt, restoreProtected, writeAdded and
their helpers) to workflow/check-run.ts. Every dependency of that code
already lived in the workflow layer. The boundary disable in
scoring-stages.ts is gone; check-run.ts takes trial.ts's place as an
importer of place/setup.ts.

Verified: tsc, npm run lint, npx vitest run (667 files pass), and the
e2e tests score-delivered-run-1247, benchmark-try and benchmark-checks.
With two scorers, a first scorer whose check could not run returned
check_could_not_run at once, abandoning the live lease the same call
took for the second scorer until it lapsed. scoreOnDemand now records
the first closed entry, judges every lease left, and fails with that
error plus the labels the other scorers kept, as judge_model_unavailable
already did.

Verified: the new test failed with only the bare error before the fix;
npm run lint and npx vitest run (667 files) pass.
@hz89Dev

hz89Dev commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in c4ddea8. It was a real bug: with two scorers, the closed entry of the first returned early and dropped the live lease of the second.

scoreOnDemand (src/workflow/scoring.ts) now records the first closed entry (check_could_not_run or evidence_empty) and keeps taking and judging leases until none are left. It then returns that error along with the labels the other scorers got, the same way judge_model_unavailable already reports them:

The check of scorer quality, `teamai-no-such-check-1247`, could not run on commit 5b8b394... (not_found). Fix the check, then run this command again. No label was written. Kept the label of tests: complete.

The new test, "still judges a second scorer when the first one's check cannot run, and says which label it kept" in workflow-scoring-evidence.test.ts, failed before the fix with only the bare error. It passes now, and it asserts that no lease is left open.

…ep inference checks

The step_not_found message said "no step with a succeeded pass", but the
inference reads step definitions, not passes.
… CLI

The issue covers a workflow step with deliver: pr. The new case runs
ship-issue with change as a workflow step and checks that the scorer's
check decides its label, with no judge, as it does for a prompt step.
@hz89Dev

hz89Dev commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

[P1] Stranded scorers: fixed in c4ddea8, as described in the reply above. scoreOnDemand now judges every lease left before it fails. It then returns the first closed entry's error, plus the labels the other scorers kept (Kept the label of plain: complete.). The new two-scorer test asserts the error, the kept label, and idle: { open: 0, leased: 0 } afterwards.

[P3] nits:

  • step_not_found wording: fixed in 607a260. It now reads "Run R lists scorer S on no step."
  • judge.access: "full" on a stage-decided label: kept. access is required by the label schema (src/scorers/label.ts). A stage-decided label records the judge of the lease it settled, the same way it keeps tool, so the label stays in that judge's measurement. The value is what that lease declared: score --run declares no access, which counts as full.
  • Outputs of later steps in the evidence: kept, as you note. The issue asks for the outputs every step reported, and the docs only promise that the same evidence gives the same hash.

Notes:

  • workflow: step with deliver: pr: now covered through the real CLI (ab24de0). change runs a workflow whose write step makes the change, and the scorer's check decides partial with no judge.
  • Check runner: moved out of benchmark/trial.ts in d827cf1, so the workflow-boundaries disable is gone. The check definitions are in src/workflow/check.ts and the runner is in src/workflow/check-run.ts. benchmark-try and benchmark-checks (37 E2E tests) pass after the move.
  • ci(lint): enable the anti-slop lint rules, and fix the 23 bugs they found #1664: still open. Whichever lands second rebases.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

No new findings in the specified diff.

  • Resolved: The earlier lease-leak finding is fixed. The command now judges the remaining scorers before returning the check error and reports their retained labels.
  • Testing: The PR description documents sufficient testing, including representative built-CLI end-to-end runs. No additional provider × agent coverage is required.

I only read the diff and trusted base review criteria; I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

The blocking finding is fixed in c4ddea8. When one scorer's check cannot run, the command still judges the other scorers. It then returns the error together with the labels it kept, and leaves no lease open. The two-scorer test asserts leased: 0. The step_not_found wording is fixed in 607a260, and I accept the reasons for keeping the other two nits. ab24de0 adds a real-CLI case for a workflow: step with deliver: pr. CI is green at this head. Approving.

@SaulMoro
SaulMoro merged commit 862da74 into Tencent:main Nov 2, 2026
42 of 46 checks passed
hz89Dev added a commit to hz89Dev/teamai-cli that referenced this pull request Nov 2, 2026
Brings in Tencent#1665, which moved the benchmark check into src/workflow/check.ts
and check-run.ts and added scoring stages before the judge. Its new code is
written to the anti-slop rules: conditional spreads became assignments, with
the key order of every serialized object as main has it.

Checked: typecheck, lint, the unit suite (677 files, 21273 tests), and the
E2E files of the scorers and the benchmark, including main's new
score-delivered-run test (6 files, 58 tests).
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.

[feat] Score what a workflow run delivered

3 participants