Skip to content

feat(scorers)!: judge every pass and session through teamai-score, a default workflow a team can override - #1700

Merged
SaulMoro merged 281 commits into
Tencent:mainfrom
hz89Dev:feat/issue-1670
Nov 4, 2026
Merged

SaulMoro merged 281 commits into
Tencent:mainfrom
hz89Dev:feat/issue-1670

Conversation

@hz89Dev

@hz89Dev hz89Dev commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Judging in teamai happened in five places: a step's scorers:, teamai-share-session, benchmark trials, finished sessions and teamai score. Each had its own code path, with a separate lease system and drain loop, and a team could change none of it. With this PR, all five run one default workflow, teamai-score. A team can read it, reword its judge prompt, or drop stages. Any driver runs it with workflow next / report. Code keeps only the invariants: confinement, sampling, daily_limit, label checks, and judging each subject once.

Who / what Before After
A step's scorers: judge lease taken after the run (score --next, or --drain) the pass that settles starts its own teamai-score run, listed in started, and the driver drives it. --driver local returns with the label
scorers: { …, start: workflow } — the scoring module starts nothing. The workflow scores its passes with score subjects + a workflow: teamai-score step
teamai score --run/--session/--team-session --scorer x in-process judge starts teamai-score on the local driver (demand: named) and prints its labels
teamai score … --queue queue a lease --driver none
teamai score --label v inside a session or a terminal person's terminal only. From an agent session: invoke_denied
teamai score --next/--lease/--submit/--json/--stdin external judge protocol removed. Use workflow next / report
teamai-share-session for_each scorer, or a lease prompt one workflow: teamai-score step (timeout: 30m, continue_on_failure)
Finished sessions hidden score-sessions command teamai-finished-sessions workflow, started by the session-start hook and score --drain
Benchmark trials engine froze run.verdicts subjects + score steps in teamai-benchmark.yaml. report writes table.verdicts
--fail-on-regression shortcut policy regression step in teamai-benchmark.yaml, reading the fail_on_regression input
Choosing tasks and arms whole suite only benchmark run <suite> --task <id> --arm <name> (inputs tasks, arms)
teamai-session-to-task teamai push --file --path workspace: { team: { branch } } + deliver: pr. push --file/--path removed (never released)
Scorer pinning engine copied scorer files into the run the run pins the team revision, plus a patch of local edits

Shape of the change:

workflows/
├── teamai-score.yaml            # new: plan → for_each group { evidence, check, ci, protected, judge (confined), label, write, publish, settle }
├── teamai-finished-sessions.yaml# new: sessions → share (teamai-share-session) → lapsed → rescore (teamai-score)
├── teamai-share-session.yaml    # score step is now `workflow: teamai-score`
└── teamai-benchmark.yaml        # + subjects, score (teamai-score), regression
src/
├── workflow/                    # generic keys only: continue_on_failure, private, $TEAMAI_RUN_DIR, startedBy, run.id,
│   │                            #   model template, workspace: { confined }, deliver: publish
│   ├── confined-place.ts, confined-step.ts, place/data.ts, team-pin.ts, judge-work.ts   # new
│   └── scoring.ts, scoring-entries.ts, conformance/judge.ts                             # removed (lease path)
├── scorers/
│   ├── engine-hooks.ts          # the one module src/workflow/ may import (lint rule, fails closed)
│   ├── score-plan|evidence-dir|score-stage|score-labels|score-subjects|score-override.ts  # the score verbs and pull's override contract
│   ├── marks.ts, attempts-upgrade.ts   # judged-once marks; one-shot upgrade from the removed attempts store
│   └── check*.ts, scoring-evidence.ts, scoring-stages.ts   # moved from src/workflow/
├── session-flow/finished-sessions.ts   # `session list --finished` (replaces src/score-sessions.ts)
├── tool-launch/confined*.ts     # judge launch profiles, now the launcher for any confined step
├── benchmark/verdicts.ts        # EntryVerdictSchema moved out of the engine
└── dashboard/judging-*.ts       # per-scorer judging state, judging health panel

Breaking changes and migration

  • Drivers: score --next/--lease/--submit/--json/--stdin are gone. A scored pass's run arrives in started on workflow report/next. A session's run starts with teamai score --session <id> --scorer <name> --driver none. The confined judge step goes only to a driver that declares can.confined offers and reports confined.
  • teamai score inside an agent session answers invoke_denied and names the line the person runs. An agent scores its own session with /teamai-share-session.
  • teamai score --run --queue → --driver none. score --run --scorer takes only scorers a step of the run lists. --scorer ./file.md next to a scorer name is refused.
  • A team workflow that runs teamai-share-session as a step must pass demand: auto | named. Pull refuses it otherwise.
  • A team teamai-benchmark.yaml must copy the subjects and score steps, or its judged trials end unscored. To take --task/--arm/--fail-on-regression it declares tasks, arms, fail_on_regression and carries regression.
  • The hidden teamai score-sessions command is removed. teamai push --file/--path is removed (it never reached a release).
  • Upgrade: open judge attempts become marks once, and teamai doctor reports how many were carried over. Upgrade every teamai on a machine together: an older copy reads only the old attempts store.

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

  • npx tsc --noEmit passes (npm run typecheck exit 0 at the head)
  • npm run lint passes (exit 0 at the head, including check-docs; node scripts/check-docs.mjs --write left no diff after the last command change)
  • npx vitest run passes (full suite once, after the first merge of origin/main; the later commits ran the tests related to them, see below)
  • Added/updated tests for the change

Evidence by class:

  • Local unit. Each slice ran the tests vitest --changed selects, plus the whole-tree guard tests. One full npx vitest run after merging origin/main: 711 files, 22,007 tests passed, 24 skipped. After that merge, the changed-file selection (550 files) passed. Its only failures came under machine load (15 s timeouts in workflow-reconciliation and workflow-settle-cost, plus one case each in usage-tracking and check-docs). None of those files is touched by the change, and each passed when run alone. The commits after it (a few scoring fixes, and a second merge of origin/main that brought the lock fix fix(lock): stop handing one lock to two processes when its owner exits mid-check #1699) ran the tests related to them at the head: score-verbs, score-drain, pass-scoring, scorers-marks, dashboard-judging (217 tests), and the unit files upstream changed (109 tests).
  • Local e2e (npm run test:e2e -- <files>). Each slice ran the files it touched. After the merge of origin/main, 63 files passed (everything with score, benchmark, workflow-session, workflow-run, dashboard or handoff in its name, plus every e2e file upstream touched). Two workflow-conformance workflow-timeout scenarios failed under load and passed alone. After the scoring fixes, the 7 score* e2e files passed (26 tests), and at the head score-drain and score-session passed again (12 tests).
  • Review rounds. Every reviewer finding was fixed red first: a test that failed on the reported symptom, then the fix. Each fix ran the unit files that import what it changed, and the e2e files for that behavior (workflow-deliver-publish, workflow-pass-scoring, benchmark-judges, score-drain, score-sessions, workflow-confined). All 17 CI checks passed at a4c69b2, 6d26862, db72427 and b2bee38.
  • Removal greps at the head: git grep -E "takeJudgeLease|judge_lease|verdictEntries|judgeRunEntries|attempts\.(ts|js)|score --next|push --file|push-file|pushFile|proposeFiles" -- . ':!CHANGELOG.md' and git grep "PinnedScorerSchema\|pinScorers\|syncScorerDefinitions" -- src/workflow both find nothing.
  • Real CLI. Every record ran the built dist/ from a temp directory outside any checkout, with env -i HOME PATH TMPDIR. Each used a local bare git team repo and a stub claude on PATH that answers as the tool and as the judge, so no real model was called. One record per runtime slice:
Slice Command Observed
1 engine keys workflow start check-each --driver local a failed for_each item under continue_on_failure: run succeeded with both results in done.outputs. $TEAMAI_RUN_DIR removed after the run. startedBy: person. A private run: workflow publish and resume --claim refused with isolated_run
2 confined step workflow start judge-change --driver local, team secret exported judge cwd = the evidence dir (change.diff, confined.json only), --tools=Read,Grep,Glob --no-session-persistence --strict-mcp-config, no team secret, run record confined: {tool: claude, isolation: verified, access: read}
3 verbs + shortcut teamai score --run <r> --scorer review-quality; --label bad; same with CLAUDE_CODE_SESSION_ID good (score 1, passed) from a private run that is absent from teamai-reports. Hand label: by hand. No judge ran. In-session: invoke_denied, 0 label lines
3 guard teamai score plan … / score write … from a plain shell score_attempt_required … Nothing was written.
3 held judge teamai score --run <r> --scorer review-quality --scorer style (style's model unresolvable) exit 1 judge_pending, keeps review-quality: good, run left open for workflow resume
3 upgrade teamai doctor over an old attempts store carried 2 open workflow passes and 1 open session over from judge attempts. A second run changes nothing
4 deliver: publish alice (judge) and bob (hand) label at once; then a forged path; then offline both in scores/<member>/2026-11.jsonl, no reasoning on the branch. Forged scores/bob/… → push_failed. Offline → pending, then score --push sends it. No merge of main into teamai-reports
4 pending data origin unreachable, then teamai pull score[0].publish and a teamai-learnings step succeed pending; the next pull pushes both branches
5 scored passes attended and unattended workflow start review --driver local review-quality good (teamai-score run …) before start returns. A start: workflow step starts no run
5 external driver workflow start change + a scripted next/report loop report answers started: [{run, step, pass, scorers}]. Driving that run gives the label
5 skill driver workflow start review --driver skill, then next/report judging event, then judged … thorough. The judge ran in the score run's scratch dir
5 benchmark benchmark run fix --driver local --sandbox table plus table.verdicts, the failed trial unscored / run_ended, no root teamai-score run, no label on teamai-reports
5 finished sessions teamai score --drain; hook-dispatch session-start; a person's start with {"publish":"never","scorers":[…]} the drain labels an unscored start: workflow pass. The hook starts one detached run with startedBy: cli. The person's run is startedBy: person and judges the named sessions
6 removal external driver over plan → … → publish; teamai score --next label in scores/tester/2026-11.jsonl without the judge's words. error: unknown option '--next'
7 session-to-task /teamai-session-to-task under --driver skill, four runs one PR opened, the same PR updated, no PR when the bytes match, refused outside a suite. teamai push --file x --path y → unknown option '--file'
9 team pin run A open while V2 is pushed; run B after the push; run C after an uncommitted V3 judged with V1, V2 and V3 respectively (C: teamRevision: none plus a patch). No run file holds scorers
10, 11 benchmark --task fix --arm codex; --task nope; workflow start teamai-benchmark with []; --fail-on-regression one row. invalid_arguments … Its tasks: again, fix. with no run left. 12 trials planned. A run with no comparable earlier run exits 0. A dropped arm exits 1 with finally: regression failed
override contract team teamai-score.yaml with a finally command, then teamai pull refused at finally.leak.command, and teamai's default stays in effect
routing teamai score --session <id> --scorer teamai:routing:ops:release fit (score 1, passed) through a teamai-score run
drain failure teamai score --drain while another process holds scores/labels.lock score_step_failed (step …write failed: … busy …), exit 1, no label
kept publish share-standup: NOTE-ONE publishes; NOTE-TWO while another process holds the reports lock; NOTE-THREE once it is free; then teamai score --push NOTE-TWO's step succeeds pending with its patch kept under data-branches/teamai-reports/pending/. NOTE-THREE's publish lands both in order: origin holds NOTE-ONE, NOTE-TWO, NOTE-THREE and pending/ is empty. score --push exits 0 with nothing pending
confined retry prepare → evidence (copies prepare's file) → confined judge; judge fails and the run ends; workflow retry <run> judge; workflow resume "reopened":true. prepare and evidence run again at pass 2, judge starts in scratch/evidence with confined.json present and succeeds. On db72427 the same retry failed confined_invalid
dashboard teamai dashboard + its API private teamai-score runs are absent from Local runs. Each scorer of a pass shows a state (labelled, waiting_ci, judging, lapsed n/4, failed, not_sampled). Judging health shows totals

Not run locally, left to CI: the full e2e suite, the gitlab and github providers, and the Codex, CodeBuddy and OpenCode agents. No CI result is claimed here.

Screenshots of the dashboard, built from this branch:

Workflow Runs, with the judging health panel:

Width EN zh-CN
1440
768
390

Run page, with each scorer's judging state:

Width EN zh-CN
1440
768
390

Run page, a skipped step with its reason:

Width EN zh-CN
1440
768
390

Related Issues

Closes #1670. Part of #1589. Builds on #1666 (team-repo workspace), #1668, #1665 and #1650.

Notes for Reviewers

Behavior changes a user will notice (also in the CHANGELOG and the scorers guide):

  • Judging a session that a person or an agent names (demand: named) counts toward daily_limit. The limit never refuses it.
  • A member's session start also rescores the lapsed workflow passes in that data home, through teamai-finished-sessions.
  • A group whose scorers take ci waits for pending CI, up to the ci step's --wait 2h. A waiting mark is not a lapse. A group without ci is judged at once.
  • A scorer with a check is never batched with other scorers.
  • A session whose judging lapsed is started again, up to the fourth lapse. Before, the first lapse closed it.
  • A hand label from inside an agent session answers invoke_denied.
  • A deliver: publish that cannot land (the branch lock is busy, or origin is unreachable) keeps its patch on this machine, in a queue per branch. The next publish to that branch, pull, score --drain and score --push land the queue in order. A patch that only appends lines, and no longer applies because another step appended to the same file first, is appended again. Any other patch that no longer applies is named, with how to apply it by hand.
  • A lapsed rescore judges only the scorers that lapsed. A scorer the team removed since ends its lapse instead of failing every drain.
  • A teamai-finished-sessions run past its timeout is ended at the next start, and its sessions are retried. A team copy without timeout holds the data home for 30 minutes.
  • A workflow retry that reopens a run that ended also runs again the steps a workspace: { confined } step it resets needs, and the steps those need, since the run's $TEAMAI_RUN_DIR went with the end.
  • sampling: all no longer holds a run's finally and end until the labels arrive. A workflow that needs the labels first uses start: workflow.
  • Every skipped step records why in message, and the run page shows it. A team-workspace PR that changes one file is titled after that file, as push --file titled its PR.

Where this PR differs from the issue:

Issue says This PR Why
workspace: { readonly }, can.readonly workspace: { confined }, can.confined workspace: read-only already exists
teamai-score's timeout binds only a root run it also bounds the run as a step and each for_each item (min(step, file)) the existing engine rule (limits.ts). Each composing step sets a shorter timeout
moved origin: run the command once more deliver: publish runs on the persistent reports worktree under its lock. Moved origin → rebase and retry, up to 5 times same mechanism as other teamai-reports writes. A step may stage only scores/<member>/…-style paths
http team repo: the next score --push sends the label the label is stored locally and stays pending. score --push answers unsupported_repo AC "offline and with an http team repo … the next push sends it" cannot hold for http: teamai has never pushed to an http team repo. It holds offline
report reads {{ steps.score.results }} via env reads the score step's results from the run file a finally step cannot read steps.*
plan … --label "$LABEL" plan reads the label input recorded for the instance the issue's own rule: the hand label comes from the run, never from argv or env
scoring: leases | marks transitional path none. A one-shot attempts → marks upgrade one PR, so it goes straight to the end state
override must keep evidence, check, label, write, publish, settle also keeps plan and score.judge, and refuses any finally or setup command score --run and --drain report on these steps of an open run. A finally/setup command could read $TEAMAI_RUN_DIR
--fail-on-regression works under --driver skill teamai's shipped teamai-benchmark is invoke: deny, so --driver skill answers invoke_denied. The gate runs under --driver local. A team copy with invoke: allow gates under --driver skill the refusal is invoke policy, not the gate. The gate is a plain step, so any driver that runs the workflow ends on it
--task/--arm runs a filtered run never becomes the suite's current version on the dashboard otherwise one-task runs would replace the full-suite version
teamai-score inline outputs labels adds written (null when write failed) a label counts as judged only once write stored it. Otherwise the drain reports score_step_failed and exits 1
score label codes adds judge_tool_unavailable a stage decided, but no confined tool here resolves the scorer's model

Verify lines and acceptance criteria not fully met:

Item State Reason
Slice 3: each teamai score example gives the same label file as main. Slice 5 / AC: a benchmark gives the same table as main, and the same sampled passes not compared side by side no run was made on main for comparison. plan calls main's isSampled. The label and table shapes are asserted by the e2e tests
Slice 5: a loop of two passes gives two subjects; one failed for_each item; protected_path gives the protected label unit-level each case is covered at the subject/verb seam. No single test drives a loop of two passes to two teamai-score runs
Slice 3 / AC: a Cursor-only machine records access: full on the label up to the judge step the Cursor offer and a confined step on Cursor are tested. A written label needs the Cursor CLI
AC: fix-until-good runs revise only after the label partial pull's warning and score subjects --run --step are tested. The same subjects → teamai-score composition runs end to end in the shipped benchmark. The fix-until-good file itself was not run
AC: every complete example runs with the built CLI YAML: yes; console: partly the docs check pulls every steps: example on the guide pages (one opt-out, fenced yaml fragment). Not every console example was replayed
AC: --fail-on-regression with --driver skill; slice 10 verify 2 holds only for a team copy see the --fail-on-regression row above
AC: http team repo does not hold see the http row above
Slice 11 verify 2 erratum the command also needs "fail_on_regression": false, since slice 10 adds a required input
AC: every step that runs teamai-score has a timeout erratum teamai-finished-sessions' rescore step has none, as the issue's own YAML shows. The root timeout: 30m bounds it
DoD: one PR per slice; T3 and Paseo released one PR by choice; nothing to release no external driver judges through score --next yet, so removing it breaks none
Boundary rule partial src/workflow/ may import src/scorers/ only through engine-hooks.ts, and that rule fails closed. Other importers of src/scorers/ are not restricted

Known limitation. The copy of a clone pass staged for judging is removed once all of its marks close or expire, as the issue specifies. So teamai score --run … --scorer x for such a pass afterwards answers evidence_empty.

Merge danger. The lease protocol is removed, but no external driver uses it yet. The upgrade rewrites open attempts as marks, once. Blast radius: every judging path, the benchmark workflow, session-to-task and the dashboard's run page.

…hat imports nothing

The workflow's can schema needs both enums, and reading them from scorers/label.ts
loads agent-observation.ts while types.ts is still loading.
A person's note on a step of a private workflow may say what the step keeps on
this machine, so a snapshot drops it from the step, its passes and the archive,
as run records already do.
workspace: { confined: <dir> } runs one prompt with that directory, under the
run's $TEAMAI_RUN_DIR, as its only readable root. Its template reads inputs,
item and the outputs of needed steps, and pull refuses it on a step that is not
one prompt, with requires.env, or with scorers.

At lease the engine checks the directory: a real directory, not a link, under
$TEAMAI_RUN_DIR, holding a confined.json that sets the level. One that breaks a
rule fails the step confined_invalid, since every later lease would find it the
same. A driver gets the step only through a can.confined offer that reaches that
level and a tool of those offers that resolves the step's model; otherwise the
step is held for confined or model. The lease lists those tools in order, the
preferred one first, and the pass keeps what the confined run measured.
The local driver offers the confined tools on this machine, probed only for a
run that may have a confined step. It runs a confined lease with runConfined on
the first of the lease's tools that resolves the step's model, in the step's
directory, with no team env and no session kept, until the step's deadline. Its
reply is the step's outputs, and the report carries what the run measured.

A confined lease no tool here resolves the model for is handed back, and the
driver takes no other lease in this process. With only confined steps left that
no tool here can take, it stops with confined_pending rather than busy.
… scorer judge

protocol.ts, scoring.ts and the skill driver's host profiles import
isConfinedTool, confinedAccess, confinedToolLevel and installedConfinedTools
from tool-launch/confined.ts, and the judge aliases and JUDGE_TOOLS are gone.
The skill driver may import those two names from the launcher instead of the
judge.
While this machine judges the run with the session tool's verified confined
judge, the skill driver offers that tool at `verified` and its background
runner runs a confined step as the local driver does (D28, C12, C13). When
the session judges the run, it offers `best-effort`, and a fresh child takes
the step with a brief that reads only its directory. With `--no-judge` or on
h4 it offers nothing, and the step waits for another driver.

Describe now says who runs a run's confined steps.
Covers `workspace: { confined }` and `confined.json`, the drivers that run
such a step and when it waits, what the step records, and the `can.confined`
offers and lease and report fields for a driver of your own.
C13 now builds the report body from how the run ended, so the body keeps
the cost the tool stated, as the local driver's report does.
…c/scorers

The score verbs build evidence and run the stages, so the modules they read
live with scoring. The lease path and teamai benchmark import them from there.
stages lists some of check, ci and protected. Without it a scorer takes all
three, as before. A stage it does not list never decides it.
…s passes

auto, the default, leaves it to teamai after each pass. workflow leaves it to
the workflow's own steps, which list the passes with teamai score subjects.
…paths, one stage at a time, with teamai score stage
…r settle it, with teamai score label, write and settle
@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@STiFLeR7, thanks for the Windows run. The confined retry is fixed at 151e9cb, one push after the 5ac4154 you rebuilt (see the comment above).

When a retry reopens a run that ended, a workspace: { confined } step it resets also resets the steps it needs. So evidence runs again and writes scratch/evidence before judge is leased. Confinement validation is unchanged: a missing or invalid directory still fails confined_invalid. The real-CLI record uses your shape (needs: [evidence], workspace: { confined: evidence }):

  • On db72427, judge pass 2 fails confined_invalid.
  • At 151e9cb, evidence runs at pass 2 and the judge starts with confined.json and diff.txt present.

The conformance scenarios for this (plain, and inside a for_each item) also run under the skill drivers, which go through next/report.

The CRLF fixture is fixed in 04f1ced: the test strips timeout: with \r?\n, so it passes on a CRLF checkout without normalizing.

@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.

I rebuilt 04f1ced and reran our pending-patch repros with the real CLI. Each share-standup sequence now lands every note on origin in order, with nothing left in pending/; at 6f739a4 these left a note stuck:

  • a note kept under a held lock, then a later note appended to the same file;
  • two notes kept under a held lock;
  • a note appended offline after an earlier kept one.

The two smaller points are fixed in the code. A stuck patch no longer holds back the checkout's own commits, and "already on the branch" is now git apply --check --reverse in the patch's own context. The stuck message names the patch file and says how to apply it by hand. I followed that instruction and it works.

The CI review findings at 6d26862 and db72427 are fixed. I reproduced the confined retry: on a 5ac4154 build it fails confined_invalid. At this head, retryContainers puts the steps a confined step needs back in the reset cone once the run's $TEAMAI_RUN_DIR is gone, so evidence reruns and the judge starts. That also answers @STiFLeR7's open item, and 04f1ced makes the finished-sessions fixture read CRLF checkouts (\r?\n) as noted on Windows. The rest I checked from the code and your tests, with CI green at db72427.

Remaining notes, none blocking:

[P2 non-blocking] Two publishes to the same file whose checkouts are prepared at the same moment: both patches are cut against the same end-of-file, so the second one no longer applies once the first is committed. I reproduced it with two overlapping share-standup runs started 2 s apart, using a copy that sleeps after staging. Both exit 0, the second note's step and score --push (published: false) give the apply-by-hand instruction, and the patch stays in pending/. Nothing is lost, the docs describe this outcome, and the shipped max_parallel: 1 keeps one teamai-score run's publish steps from overlapping. I did not check whether a background drain and a manual teamai score can overlap their publish steps. If they can, the labels still land from the outbox, but score --push would keep saying published: false until the patch is applied. Re-staging the step's change against the persistent checkout when its own patch fails under the lock would close it.

[P3 nit] pull still logs sendPending's messages at debug level only (src/pull.ts:4106), so a stuck patch shows up only on the next score --push or drain.

[P3 nit] From the code, not run: if commitSkippingHooks throws after apply --index in commitKept (src/utils/data-branches.ts:43-57), the change stays staged. The next send then removes the patch file (the reverse check matches the working tree), but nothing commits the staged change. Applying with --cached, or resetting the index in the catch, closes it.

This conflicts with #1704 in 25 files, so whichever lands second needs a rebase. Approving; it merges once CI is green at this head.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

The earlier reported scenarios are resolved. I found one additional issue:

  • [P2 non-blocking] Confined retries leave upstream scratch producers settled — src/workflow/run-controls.ts:301
    Only the confined step’s direct dependencies are reset. In prepare → evidence → judge, where prepare writes scratch files that evidence copies, ending the run deletes those files. Retrying judge reruns evidence but leaves prepare succeeded, so evidence generation fails on the deleted inputs. Regenerate the upstream scratch prerequisites too.

The PR description documents sufficient built-CLI verification; no additional provider × agent matrix is required. No PR code was run, built, or installed.

@SaulMoro

SaulMoro commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

On the CI review's P2 about transitive scratch producers: I looked at this case in my last pass. retryContainers resets only the steps the confined step needs directly. A prepare → evidence → judge chain where prepare writes scratch that evidence copies would therefore fail on the retry. That matches the contract the confined_invalid hint states ("a step the confined step needs"), and the shipped teamai-score has judge needing evidence directly. So I don't see it as blocking here. Extending the reset cone to every scratch writer upstream is a fine follow-up if a team workflow hits it. My approval stands; this merges once CI is green.

… a retry reopens an ended run

A step that builds a confined directory may copy files an earlier step
left under $TEAMAI_RUN_DIR, which the run's end removed too. A retry
that reopens an ended run now follows needs from the confined step
transitively, so prepare -> evidence -> judge runs all three again.
@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

The upstream-producer finding is fixed at 8851c60. When a retry reopens a run that ended, it now follows needs from a confined step transitively, within its container. So in prepare → evidence → judge, retrying judge runs all three again. Retrying a failed evidence also runs prepare again, since judge downstream reads what evidence builds. A retry while the run still runs is unchanged.

Tests: two conformance scenarios in src/workflow/conformance/confined.ts, under the local, skill and skill-bare drivers. Both expect prepare leased at pass 2:

  • "a retry of the step after its run ended runs again the steps its directory's writer needs too" failed before the fix (the retry leased evidence).
  • "a retry of the directory's writer after its run ended runs again the steps it needs too" fails if the transitive walk stops when it finds a writer already in the reset set.

Real CLI, with prepare writing change.txt and evidence copying it into the confined directory: after the judge fails and the run ends, workflow retry <run> judge then workflow resume runs prepare, evidence and judge at pass 2. The judge starts in scratch/evidence with confined.json and diff.txt, and the run succeeds.

@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.

8851c60 extends the retry to the CI review's transitive case. Once the run's $TEAMAI_RUN_DIR is gone, confinedWriters follows needs from a confined step through every writer it pulls in: each writer that joins written has its own needs added on the next pass. The loop stops when nothing new joins, and the dependents follow through the existing cone loop. A retry of judge or of evidence in prepare → evidence → judge therefore restarts at prepare, which the two new conformance scenarios assert. A retry while the run is still running is unchanged. Both doc languages say the same.

[P3 nit] This reruns every step the confined step transitively needs, including one that wrote nothing under $TEAMAI_RUN_DIR. That is the safe choice, since the engine cannot tell which steps wrote scratch, but a slow upstream step will run again on such a retry.

Approving at this head; it merges once CI is green.

@kittimzhe kittimzhe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verification review from the routing-seam side — I authored #1650 (the routing scorer) and #1684 (the asset-effect tables that read routing from records), so I checked this PR specifically for whether those invariants survive the migration to teamai-score. They do, cleanly:

  • The record contract is unchanged: trial.routing still carries the five values (result.ts), still frozen at plan time through coversSkills, and the absent-by-design rule survives — an arm that runs without a skill by design still reports no routing for it, so the asset tables never read missed for an asset that is simply not there (#1684's P3-2).
  • The table's routing flag still matches: record.benchmark.scorers.some(name => name.startsWith('teamai:routing:')) is exactly the population teamai-score now judges, so the dashboard link gates correctly through the migration.
  • Two changes here are genuine improvements over what #1684 shipped: AssetEffect.routingScorer with namespace support (skillNamespaceOf → teamai:routing:<namespace>:<skill>) replaces the dashboard's name guessing, and routingQuestionOf's namespaceUnknown guard ("cannot tell the namespace… could judge another skill of the same name") mirrors the task_covers_ambiguous refusal semantics from the plan side — the same ambiguity is now guarded at both ends.

On this head I ran the seam suites green locally: benchmark-asset-effects (45), benchmark-arm-workflow + doctor-scorers (27), scorers-batch + dashboard-scorers(-view) (41), plus npm run build.

One nit, non-blocking: table.ts matches the literal 'teamai:routing:' while skill-routing.ts now exports ROUTING_PREFIX — importing the constant would give the prefix a single home (the literal is mine from #1684, so this is me collecting my own litter).

@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking the routing seam. The nit is taken in 3e366f0: table.ts now imports ROUTING_PREFIX from skill-routing.ts, so the prefix has one home. benchmark-asset-effects (45 tests), typecheck and lint pass.

@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.

3e366f0 only swaps the literal in table.ts for ROUTING_PREFIX, which is teamai:routing:, so nothing else changes. Approving at this head; it merges once CI is green.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

All earlier findings are resolved in the current diff, including the upstream scratch-prerequisite retry issue. I found no additional confident findings.

The PR description documents sufficient built-CLI/end-to-end verification. The provider and agent coverage explicitly deferred to CI is not blocking.

No PR code was run, built, or installed during this review.

…he next send commits it

A patch applied to the index and then not committed was found on the
branch by the next send's reverse check and removed, so its data never
reached origin.
… its file first

Two steps prepared at once cut their patches at the same end of file, so
the second no longer applied once the first was committed. A kept patch
that only appends lines at the end of its files, and no longer applies,
is now appended to those files as they are. Any other stays kept.
@hz89Dev

hz89Dev commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@SaulMoro, thanks for the approvals. Two of the remaining notes are fixed, at 037ba98 and b2bee38, and I've left one as it is (reason below). Each fix has a test that failed before it.

Two publishes prepared at once (P2), b2bee38. A kept patch that no longer applies, and only appends lines at the end of its files, is now appended to those files as they are, under the same lock. That is what it meant: another step appended there after it was cut. Any other patch that does not apply stays kept, with the apply-by-hand message.

  • workflow-place-data.test.ts "lands both notes two steps opened at once appended to one file" opens two checkouts before either finishes. It ended with the second note in pending/; now origin holds both, in order, and nothing is kept.
  • "keeps a note whose patch changes a line origin changed too, rather than appending it" pins that only append-only patches are replayed.
  • The two repeated-line tests now assert origin's content: the repeated line is appended at the end. If the "already on the branch" check dropped the patch again, the line would be missing.

The replay needs one hunk per file, + lines only after its context, no removed line, and a file that ends in a newline. A score publish patch that rewrites a line by key does not qualify, so it stays kept as before.

Failed commit after apply (P3), 037ba98. It was worse than staying staged: the next send's reverse check matched the working tree, removed the patch, and committed nothing, so the note never reached origin. A commit that throws now takes the patch back out of the index and working tree, so the next send applies and commits it. "sends a note later whose commit failed after its patch applied" makes the commit fail with commit.gpgsign and a gpg.program that exits 1. It lost the second note before.

Pull logging (P3), left as is. Pull says nothing of pending data on purpose, as for labels (the comment above src/pull.ts:4106). A patch that no longer applies is named by the step that kept it, and again on every score --push and --drain, which exits 1.

On rerunning every step a confined step transitively needs: agreed, that is the cost of the engine not knowing which steps wrote scratch.

Gates at b2bee38: typecheck, lint with the docs checks, workflow-place-data (25), score-drain (54), and the workflow-deliver-publish e2e (8) pass. The guide and its Chinese page describe the append rule.

@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.

I read 037ba98 and b2bee38.

  • Failed commit (037ba98): a commit that throws now undoes its apply, through apply --reverse for an applied patch or by restoring the files for a replayed one. The next send therefore applies and commits the patch, instead of finding it in the working tree and dropping it. The gpg.program test reproduces exactly that loss.
  • Concurrent append (b2bee38): appendedLines accepts only a patch made of one hunk per file, + lines after its context, no removed lines, and no trailing context. Git emits that shape only for an append at end of file. appendAgain then appends those lines to the file as it is now, and refuses a file that does not end in a newline. That closes the overlapping-publish case without touching a patch that rewrites a line, which still stays kept with the apply-by-hand message.
  • pull logging: leaving it as is is fine with me, since the step and every score --push/--drain name a stuck patch.

[P3 nit] The replay runs only after the reverse check fails, and that check also fails once anything has been appended after the note. So a note that already reached the file is appended a second time if another line followed it there. That can happen after a crash between its commit and the removal of its patch file, or for a patch applied by hand as the message suggests but left in pending/. Both need an unlikely precondition, and the result is a duplicate line rather than a lost one. Checking that the appended block is not already in the file, at any position, before replaying would close it.

Approving at this head; it merges once CI is green.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

The previously reported concrete scenarios are resolved. I found one additional issue:

  • [P2 non-blocking] Scratch prerequisite recovery stops at workflow boundaries — src/workflow/run-controls.ts:357
    With top-level prepare writing scratch files and an inline workflow needing it that runs evidence → judge, retrying the failed judge after the run ends resets the inner steps but leaves prepare succeeded. The writer set is recreated for each scope, so the resumed evidence step reads deleted inputs and fails. Carry scratch-prerequisite recovery through the enclosing workflow’s dependencies.

The PR description documents sufficient built-CLI/end-to-end verification. Coverage explicitly deferred to CI is not blocking.

No PR code was run, built, or installed during this review.

@SaulMoro

SaulMoro commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

On the CI review's new P2, scratch recovery stopping at a workflow boundary: it needs a top-level step to write scratch that an inline sub-workflow's confined step reads, and then a retry after the run ended. The shipped workflows don't have that shape. The retry still fails loudly with confined_invalid, so nothing is judged on missing evidence. I'd rather not grow this PR further for it: carrying the writer set across scopes is a reasonable follow-up if a team workflow needs it. My approval stands, and this merges once CI is green.

@hz89Dev

hz89Dev commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

I'm leaving the cross-workflow case as it is: the recovery stops at the confined step's own workflow on purpose.

needs names steps of the same workflow, and the engine cannot tell which of them wrote scratch files, so following the enclosing workflow's needs would re-run every step above it. In teamai-score that is plan, the step the score for_each needs. plan writes nothing under $TEAMAI_RUN_DIR; its groups are step outputs. Re-running it re-derives the for_each items, so a retry of one group's judge after the run ended would judge every group of the run again, and plan would run again over marks it already opened.

A workflow whose inner steps read files an outer step left in $TEAMAI_RUN_DIR keeps that writer in the same workflow as the confined step, or starts a new run once the old one ended (retry takes only a failed, cancelled or leased step, so a succeeded outer writer cannot be retried on its own). The guide's sentence is about the steps a confined step needs and theirs, which are always steps of its own workflow.

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.

[Proposal] Run scoring as a default workflow, teamai-score

5 participants