run-parity

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Run pull request parity

运行拉取请求一致性检查

Run the pull request base and head against the same repository commits. Write deterministic newline-delimited JSON (NDJSON) artifacts and compare them.
针对同一仓库提交记录,运行拉取请求的基准版本和头部版本。生成确定性的换行分隔JSON(NDJSON)工件并进行对比。

Prepare the run

准备运行

Require
DAYTONA_API_KEY
, authenticated
gh
, and a pushed pull request head. Do not push changes without permission. Use
ni
and
nr
in this repository.
Resolve the pull request:
sh
gh pr view <pr-number-or-url> \
  --json number,url,baseRefOid,headRefOid,headRepository,headRepositoryOwner
Derive the base repository from the pull request URL. Derive the head repository from
headRepositoryOwner.login
and
headRepository.name
. Use the returned commit hashes, not branch names.
Create
tmp/parity-pr-<number>-<head-short-sha>
and preserve it after the run. Run
ni
before evaluation.
需要
DAYTONA_API_KEY
、已认证的
gh
工具,以及已推送的拉取请求头部版本。未经许可请勿推送更改。在本仓库中使用
ni
nr
命令。
解析拉取请求:
sh
gh pr view <pr-number-or-url> \
  --json number,url,baseRefOid,headRefOid,headRepository,headRepositoryOwner
从拉取请求URL中推导基准仓库信息。从
headRepositoryOwner.login
headRepository.name
中推导头部仓库信息。使用返回的提交哈希值,而非分支名称。
创建
tmp/parity-pr-<number>-<head-short-sha>
目录,并在运行后保留该目录。在评估前运行
ni
命令。

Run both revisions

运行两个版本

Run from
packages/evals
. The default corpus contains the 2,000 highest-ranked repositories, and the initial concurrency is 200. Sandbox creation is capped at 20 to avoid overloading Daytona. The evaluator cleans up resources and retries failed projects at concurrency 50, then 10.
sh
nr --silent eval \
  --react-doctor-repository <base-repository-url> \
  --react-doctor-ref <baseRefOid> \
  > <absolute-run-directory>/baseline.ndjson

nr --silent eval \
  --repositories <absolute-run-directory>/baseline.ndjson \
  --react-doctor-repository <head-repository-url> \
  --react-doctor-ref <headRefOid> \
  > <absolute-run-directory>/candidate.ndjson
The baseline records resolved repository hashes. Reusing the baseline as the candidate corpus prevents default branches from moving between runs.
Before the candidate run, stream-validate every baseline record. This rejects unpinned repositories, evaluation errors, malformed reports, and incomplete projects without loading the NDJSON corpus into memory:
sh
jq -e -n \
  -f <repository-root>/.agents/skills/run-parity/scripts/validate-parity-input.jq \
  <absolute-run-directory>/baseline.ndjson >/dev/null
If the baseline command exits non-zero or the check fails, inspect its failed records and stop. Candidate runs reject unpinned evaluation NDJSON.
Require both commands to exit zero and report 100% completion. Otherwise, report the failed projects and stop the comparison.
packages/evals
目录执行命令。默认语料库包含2000个排名最高的仓库,初始并发数为200。沙箱创建上限为20,以避免Daytona过载。评估器会清理资源,并以并发数50、随后10的设置重试失败的项目。
sh
nr --silent eval \
  --react-doctor-repository <base-repository-url> \
  --react-doctor-ref <baseRefOid> \
  > <absolute-run-directory>/baseline.ndjson

nr --silent eval \
  --repositories <absolute-run-directory>/baseline.ndjson \
  --react-doctor-repository <head-repository-url> \
  --react-doctor-ref <headRefOid> \
  > <absolute-run-directory>/candidate.ndjson
基准记录会存储解析后的仓库哈希值。复用基准作为候选语料库可防止默认分支在两次运行之间变动。
在运行候选版本前,流式验证每条基准记录。这会拒绝未固定的仓库、评估错误、格式错误的报告以及未完成的项目,且无需将NDJSON语料库加载到内存中:
sh
jq -e -n \
  -f <repository-root>/.agents/skills/run-parity/scripts/validate-parity-input.jq \
  <absolute-run-directory>/baseline.ndjson >/dev/null
如果基准命令返回非零值或检查失败,请检查失败记录并停止运行。候选运行会拒绝未固定的评估NDJSON。
要求两个命令均返回零值并报告100%完成率。否则,报告失败的项目并停止对比。

Compare results

对比结果

Run from the repository root:
sh
node .agents/skills/run-parity/scripts/compare-parity.mjs \
  <run-directory>/baseline.ndjson \
  <run-directory>/candidate.ndjson \
  > <run-directory>/parity.json
Interpret exit codes:
  • 0
    : diagnostics match
  • 1
    : comparison succeeded with diagnostic changes
  • 2
    : inputs are incomplete or invalid
The evaluator retries incomplete reports instead of recording them as successful. The comparator validates both inputs again and exits with invalid-input status if either side contains an evaluation error, a malformed report, a missing completion marker, or a partial legacy report. It canonicalizes diagnostics to report-relative identities across legacy and v3 report schemas, so overlapping workspace scans do not inflate counts and schema upgrades do not appear as diagnostic churn.
The comparator streams both NDJSON inputs, stages baseline records in the system temporary directory, and writes large detail arrays incrementally. It retains changed diagnostic entries only long enough to sort them deterministically, so leave temporary-disk and output capacity proportional to the run size.
For exit code
1
, inspect affected source locations before classifying changes.
Validate comparator changes from the repository root:
sh
node --test .agents/skills/run-parity/scripts/compare-parity.test.mjs
node --test .agents/skills/run-parity/scripts/validate-parity-input.test.mjs
从仓库根目录执行命令:
sh
node .agents/skills/run-parity/scripts/compare-parity.mjs \
  <run-directory>/baseline.ndjson \
  <run-directory>/candidate.ndjson \
  > <run-directory>/parity.json
解释退出码:
  • 0
    :诊断结果匹配
  • 1
    :对比成功,但诊断结果有变化
  • 2
    :输入不完整或无效
评估器会重试未完成的报告,而非将其记录为成功。对比器会再次验证两个输入,如果任意一侧包含评估错误、格式错误的报告、缺失完成标记或部分旧版报告,则会以无效输入状态退出。它会将诊断项规范化为跨旧版和v3报告 schema 的报告相对标识,因此重叠的工作区扫描不会增加计数,schema升级也不会被视为诊断项变动。
对比器会流式处理两个NDJSON输入,将基准记录暂存到系统临时目录,并逐步写入大型详情数组。它仅在需要确定性排序时保留已更改的诊断条目,因此请确保临时磁盘和输出容量与运行规模成正比。
如果退出码为
1
,请在分类变更前检查受影响的源代码位置。
从仓库根目录验证对比器变更:
sh
node --test .agents/skills/run-parity/scripts/compare-parity.test.mjs
node --test .agents/skills/run-parity/scripts/validate-parity-input.test.mjs

Report results

报告结果

Report the pull request URL, commit hashes, compared and skipped project counts, diagnostic totals, added and removed counts, largest rule deltas, and artifact paths.
报告拉取请求URL、提交哈希值、已对比和已跳过的项目数量、诊断项总数、新增和移除的数量、规则变动最大的项,以及工件路径。