feat(运维): 新增 oj2-api rediagnose,旧提交的运行时错误说明也能用上新规则

诊断是判题时写进库的,规则改了旧提交不跟着变。这个子命令把库里的诊断按现在的规则重做:
Python 只重做已经有诊断的(重跑第一个失败测试点拿回溯,所以要在线上 oj-api 容器里跑),
C / C++ 用 info 里存着的信号和退出码直接补上(原来一条都没有)。比赛提交不诊断,
重跑不出来的保留原样,只写 runtime_error 这一个键。默认只读预演,--apply 才写。

本机验过:dev 与编译两种形态都跑通,--apply 之后再跑是 0 条变化。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-09-30 10:51:54 +08:00
1 parent fa0e1ab66c
commit 79ca8ac3bd
4 files changed
+113 -2

No files matched your search

+7 -1
View File
@@ -13,6 +13,7 @@
* oj2-api sql-child # SQL 判题子进程,由服务自己 spawn,不该手动调
* oj2-api migrate # 执行待办的数据库迁移,部署时由 docker/deploy.sh 调
* oj2-api recount # 把题目/用户的计数列、成就的已解锁数重算回与明细一致,默认只读预演
* oj2-api rediagnose # 运行时错误的诊断按现在的规则重做,默认只读预演
*
* 用动态 import 而非顶层 import:这几个模块都有导入即执行的副作用
* (Bun.serve、连 Redis 开消费者),静态导入会让 sql-child 也把整个服务拉起来。
@@ -40,6 +41,11 @@ switch (command) {
const { recount } = await import("./scripts/recount")
process.exit(await recount({ apply: process.argv.slice(3).includes("--apply") }))
}
// 同上:诊断规则改了之后,把库里已有的诊断重做一遍(要连判题机和测试点,只能在线上跑)
case "rediagnose": {
const { rediagnose } = await import("./scripts/rediagnose")
process.exit(await rediagnose({ apply: process.argv.slice(3).includes("--apply") }))
}
case "sql-child": {
const { runSqlChild } = await import("./judge/sql/child")
await runSqlChild()
@@ -61,7 +67,7 @@ switch (command) {
}
default:
console.error(
`未知子命令:${command}\n可用:serve | worker | migrate | recount | healthcheck | sql-child`,
`未知子命令:${command}\n可用:serve | worker | migrate | recount | rediagnose | healthcheck | sql-child`,
)
process.exit(2)
}