Skip to content

feat(harness): 離線集群 RSI 并行轮协调器 - #268

Open
NumberWan wants to merge 35 commits into
InferMatrixLab:mainfrom
NumberWan:parallel-round-offline
Open

NumberWan wants to merge 35 commits into
InferMatrixLab:mainfrom
NumberWan:parallel-round-offline

Conversation

@NumberWan

@NumberWan NumberWan commented Oct 30, 2026 •

Copy link
Copy Markdown

Refs #249

问题

当前 campaign 每轮只推进一个候选:从 incumbent 建一个隔离目录,改动一个声明的 plane,再与 incumbent 做 AB/BA 比较。多 Agent harness 想以集群方式在同一轮并行探索几个独立方向时,缺少以下保障:多个候选争用同一设备;工作目录不保证来自同一 incumbent;各自的改动范围可能互相覆盖;失败的尝试没有记在同一份账本里。

本 PR 明确不做

本 PR 先不做 #249 的 stepwise composition。不会在每叠上一条 PASS lane 之后,从干净 checkout 再测一次。

本 PR close 的目标就是 joint single-rerun:把这一轮所有 verdict==PASS 的 lane 按 lane_id 叠到同一个候选上,对 incumbent 只再测一次。联合结果为 PASS 则写 successor/,否则保留原 incumbent。逐步逐条重测留在 #249,不在这张 PR 的合入范围里。

本 PR 的行为

本 PR 是 #249 的一个离线切片,做一轮里的 prepare / submit / serve / status / close,以及测量命令所在的隔离环境。测量按 #249 的要求复用现有 harness 的 run_experiment 循环,以及 v0 判定门禁(benchmark.legacy_run_v0.evaluate)和 qualify_devices,不另写 runner;本 PR 注入隔离版 execute,并用目录摘要做源指纹(_tree_identity,不在 build 后对候选跑 host git/repository_identity,避免候选里被写入的 diff.external 在宿主机执行)。report 端口为空操作,产物以 evaluation.json/events.jsonl 为准,不依赖 report.html。这里的「集群」指同一轮里多个 Agent 各占一条 lane、从同一个 incumbent 并行改动,测量统一交给 serve。入口是 python tools/parallel_round.py,不往主 CLI inferrsi 加子命令。

  1. 冻结轮次计划(prepare)。 计划列出可用设备 device_ids,并声明要比较的指标 metric(名称、better: lower 或 higher、每次测量重复几次 repeats、判定 PASS 所需的最小改进 min_improvement_pct,默认 0);可选的 validation 是在候选上跑一次的质量检查命令,可选的 device_model 要求测量前检查设备型号。每条 lane 声明 id、对应的搜索计划条目、唯一的 plane(harness / model / infra)、允许修改的路径 glob、每次测量要几张设备(device_count,默认 1)、attempt 上限和截止时间。以下计划会被拒绝:两条 lane 的 glob 重叠(包括同时匹配 incumbent 中的同一文件)、lane 覆盖 protected 路径、两条 lane 对应同一条目、所有 lane 的 device_count 加起来超过 device_ids 的项数。通过后写入 round-plan.json,digest 覆盖校验后的计划正文。
  2. 异步提交候选(submit)。 只比较该 lane 允许修改的文件,把差异复制到 outbox,并返回 ticket。相同 manifest 总是返回相同 ticket。这一步不占设备,集群里的 Agent 不必等测量完成。符号链接、FIFO 和其他非常规文件在读取内容前拒绝;范围内的删除在计算哈希前拒绝;改到 lane 范围外的文件、命中 protected、与其他 lane 的具体路径重叠(含新建文件),或已过截止时间,都拒绝提交。
  3. 多设备测量(serve)。 每次调用测量一个 ticket:一次取得该 lane 所需数量的空闲设备,取不齐就全部放回,不会只占一部分。同一条 lane 的 ticket 由 lane 锁依次测量,避免同时改写同一份账本。lane 锁被占用或设备不够(包括被隔离的设备)时,ticket 保持 queued,不扣 attempt;计划写了 device_model 时,取得设备后先用 qualify_devices 检查型号、以及卡上有没有其他计算进程,不通过也保持 queued(收据带 reason),不扣 attempt;排队时已过截止时间则记为 rejected。取得设备后才 reserve,账本先记为 claimed,再执行第一条命令。build(可选)在候选上跑一次;之后由 run_experiment 测量:incumbent 与候选的 trial 按 AB/BA 交替各跑 repeats 次,有 validation 时在候选上跑一次,再由 evaluate 给出 PASS / FAIL / INCONCLUSIVE。run_experiment 的产物(events.jsonl、evaluation.json 等)写在 <round-dir>/runs/<ticket>/,收据记下 verdict、improvement_pct、reasons、每次的值、中位数和 run_dir。所有命令都在隔离环境中执行;隔离不可用时拒绝执行,不回退为普通子进程。截止时间每次读取当前时钟。任何一次 trial 没有得到有效指标(失败、超时、结果文件没有计划声明的指标、或指标不是正的有限数值)时,记录 unsettled,账本保持 claimed。
  4. 查询结果(status)。 返回 ticket 的收据;还没有收据时为 queued。
  5. 联合收工(close,joint single-rerun MVP)。 要求每个 outbox ticket 都有终态收据,且没有 unsettled。把 verdict==PASS 的 lane 按 lane_id 顺序叠到同一个候选上,再对 incumbent 做一次 run_experiment。联合结果为 PASS 时写入 successor/(accepted=true);否则保留原 incumbent(retained=true)。这不是 task: parallel optimization rounds with orthogonal lanes for multi-agent harnesses #249 的逐步 composition,也不是 Claude/Codex driver 或 SwarmFlow。

serve 中途被杀掉后再调用同一个 ticket:账本停在 reserved 时沿用同一次 attempt 继续,不另扣;停在 claimed 或 finished 但没有收据时记为 unsettled,不再执行;停在 cancelled 时记为 rejected。

improvement_pct 一律以正数表示候选更好。verdict 沿用 v0 evaluate 的规则:没有 validation 时为 INCONCLUSIVE(原因写在 reasons)。源完整性用目录摘要,不要求 incumbent 是 git 仓。单票收据不推进 campaign;可选的 close 只在本 round 目录写下 successor/ 或明确 retain,不是 #249 的逐步合入,也不串多轮、不改调用方工作区里的「现任」路径。测试中的指标是 fixture 输入,不是 campaign 结果。Agent 自报的数字和外部 harness 的投票不作为判定依据。

没有集群与有集群的控制流

阶段名沿用 dashboard 的 agent stage(diagnosis / knowledge / search / execution / validation / review,见 docs/dashboard.md)。两张图只说明一轮内的工作如何调度,不是本 PR 的性能结果。

没有集群时,一轮只有一个候选。候选测量完、决策完,下一轮才开始。

flowchart LR
  diag[diagnosis<br/>诊断瓶颈] --> know[knowledge<br/>查经验]
  know --> search[search<br/>决策 Agent 选一个改法]
  search --> exec[execution<br/>改出一个候选]
  exec --> val[validation<br/>独占设备做 AB/BA]
  val --> review[review<br/>决策 Agent:保留或回滚]
  review -->|下一轮| diag
Loading

有集群时,决策 Agent 在 search 一次选出几个互不重叠的改法,prepare 把它们冻结成几条 lane。各 lane 的 Agent 只负责在自己的范围内改出候选,交给 submit,不自己测量。每条 lane 的 validation 由 serve 在这条 lane 自己的设备上做,不同 lane 同时进行:各 lane 的设备需求加起来不超过总设备数,所以 L1 在设备 0 上测量时,L2 可以同时在设备 1、2 上测量,互不等待。测法由计划统一规定(同一条 trial 命令、同一个指标、同样 repeats 次 AB/BA、同一个判定门槛),lane Agent 不能自己选,这样各 lane 的收据才能互相比较。review 仍由决策 Agent 读收据来做。蓝色是本 PR 实现的部分;lane Agent 本身(例如 Claude Code、Codex 或脚本)由调用方启动,本 PR 不内置。

flowchart LR
  diag[diagnosis<br/>诊断瓶颈] --> know[knowledge<br/>查经验]
  know --> plan[search<br/>决策 Agent 选 N 个互不重叠的改法<br/>prepare 冻结轮次计划]
  plan --> e1[L1 execution<br/>lane Agent 改出候选]
  plan --> e2[L2 execution<br/>lane Agent 改出候选]
  plan --> e3[L3 execution<br/>lane Agent 改出候选]
  e1 --> v1[L1 validation<br/>submit + serve 在 L1 的设备上<br/>run_experiment AB/BA + evaluate]
  e2 --> v2[L2 validation<br/>submit + serve 在 L2 的设备上<br/>run_experiment AB/BA + evaluate]
  e3 --> v3[L3 validation<br/>submit + serve 在 L3 的设备上<br/>run_experiment AB/BA + evaluate]
  v1 --> ledger[账本与收据<br/>status 查询每个 ticket]
  v2 --> ledger
  v3 --> ledger
  ledger --> closeNode[close<br/>PASS lane 合成一次再量]
  closeNode --> review[review<br/>决策 Agent 读 close/收据]
  review -->|下一轮| diag
  classDef pr fill:#dbeafe,stroke:#2563eb
  class plan,v1,v2,v3,ledger,closeNode pr
Loading

几条 lane 在同一台主机上同时测量时,会共用 CPU、PCIe 和内存带宽,延迟类指标的噪声可能变大。每条 lane 的候选与 incumbent 在同一组设备上交替测量,可以抵消大部分漂移,但抵消不了 lane 之间的干扰;本 PR 没有量化这部分影响。repeats 用来压住这类噪声。

单个 ticket 的状态流转

flowchart TB
  prepareNode[prepare 冻结轮次计划] --> submitNode[submit 提交候选并返回 ticket]
  submitNode --> free{lane 锁和设备都拿到了?}
  free -->|否,未过截止时间| queued[queued 不扣 attempt]
  free -->|否,已过截止时间| rejectedQ[rejected 不扣 attempt]
  queued --> free
  free -->|是,且 device_model 检查通过| deadline{reserve 后仍在截止时间前?}
  deadline -->|否| rejected[rejected 取消本次预留]
  deadline -->|是| claimed[账本记为 claimed]
  claimed --> runNode[隔离执行 build,再由 run_experiment AB/BA 交替跑 trial]
  runNode --> readable{每次 trial 都有有效指标?}
  readable -->|否| unsettled[unsettled 账本保持 claimed]
  readable -->|是| measured[measured 记录 evaluate 的 verdict、improvement_pct、每次的值与中位数]
Loading

全部 ticket 终态后可另调 close(上图未展开):只合 PASS → 联合再量一次 → successor/ 或 retain。

CLI 用法:启用并行 Agent

入口和前提

  • 入口是 python tools/parallel_round.py <子命令>(pip install -e . 后用仓库内该脚本)。主 CLI inferrsi 不增加子命令;Apps 入口已在 main 演进,本离线切片仍留在 tools/,避免绑死公共 CLI。
  • 安装:pip install -e .。
  • 主机要能创建 user namespace(unshare --user --map-root-user --mount --pid --kill-child true 能成功)。不能时,测量一律记为 unsettled,不会退回普通子进程。

并行几个 Agent 由什么决定

没有「开几个 Agent」的开关。计划里有几条 lane,就可以同时跑几个 Agent,每条 lane 一个。lane 数受设备限制:

  • device_ids:这一轮可用的设备。
  • 每条 lane 的 device_count:这条 lane 每次测量要几张设备,默认 1。例如 TP=2 的 benchmark 写 2。

所有 lane 的 device_count 加起来不能超过 device_ids 的项数,否则 prepare 拒绝,也就是设备用满就不再加 lane。例如 3 张设备:L1 要 1 张、L2 要 2 张,这一轮就是这两条 lane。这样每条 lane 提交后都有自己的设备可用,不用排队;代价是 Agent 在改代码时,它的设备会闲置。

最小例子:两个 Agent 并行跑一轮

1. 准备 incumbent 目录(被优化的项目,bench.py 是 benchmark):

incumbent/
  bench.py            # 读 knobs/,向 argv[1] 写 {"metrics": {"latency_ms": <数值>}}
  knobs/batch.txt
  knobs/threads.txt

2. 写轮次计划 plan.json:两条 lane,各自只能改一个文件。

{
  "round_id": "r1",
  "incumbent_id": "demo",
  "device_ids": ["cpu-0", "cpu-1"],
  "metric": {"name": "latency_ms", "better": "lower", "repeats": 3},
  "protected": ["bench.py"],
  "trial": ["/usr/bin/python3", "bench.py", "{result}"],
  "lanes": [
    {"id": "L1", "entry": "D-01", "plane": "infra", "globs": ["knobs/batch.txt"],
     "cap": 1, "per_attempt_worst_case": 1, "deadline_utc": "2026-11-13T00:00:00+00:00"},
    {"id": "L2", "entry": "D-02", "plane": "harness", "globs": ["knobs/threads.txt"],
     "cap": 1, "per_attempt_worst_case": 1, "deadline_utc": "2026-11-13T00:00:00+00:00"}
  ]
}

3. 冻结计划,两个 Agent 各在一份 incumbent 副本里改:

python tools/parallel_round.py prepare --spec plan.json --incumbent ./incumbent --round-dir ./round-r1
cp -r incumbent work-L1 && cp -r incumbent work-L2
(cd work-L1 && claude -p "只改 knobs/batch.txt,让 bench.py 的 latency_ms 更低") &
(cd work-L2 && codex exec --full-auto "只改 knobs/threads.txt,让 bench.py 的 latency_ms 更低") &
wait

4. 各自提交,再同时测量:

t1=$(python tools/parallel_round.py submit --round-dir ./round-r1 --lane L1 --incumbent ./incumbent --work ./work-L1 | jq -r .ticket)
t2=$(python tools/parallel_round.py submit --round-dir ./round-r1 --lane L2 --incumbent ./incumbent --work ./work-L2 | jq -r .ticket)
python tools/parallel_round.py serve --round-dir ./round-r1 --ticket "$t1" --incumbent ./incumbent &
python tools/parallel_round.py serve --round-dir ./round-r1 --ticket "$t2" --incumbent ./incumbent &
wait
python tools/parallel_round.py status --round-dir ./round-r1 --ticket "$t1"
python tools/parallel_round.py status --round-dir ./round-r1 --ticket "$t2"
python tools/parallel_round.py close --round-dir ./round-r1 --incumbent ./incumbent

serve 返回 queued 时(设备被占用),稍后对同一个 ticket 再调用即可。收据写在 round-r1/results/<ticket>.json,包括 verdict、improvement_pct、每次的值、中位数、run_dir 和用到的设备。close 写入 round-r1/close.json;若联合 PASS,另有 round-r1/successor/。

子命令一览

子命令 参数 作用
prepare --spec --incumbent --round-dir 检查并冻结计划
submit --round-dir --lane --incumbent --work 提交一条 lane 的改动,返回 ticket
serve --round-dir --ticket --incumbent 测量一个 ticket;不同 lane 的 ticket 可同时开多个
status --round-dir --ticket 查询 ticket 结果
close --round-dir --incumbent PASS lane 合成一次并再量一次;写 successor 或保留 incumbent

计划字段

字段 作用
device_ids 可用设备名单,名字不能含逗号。一个 ticket 取得的设备名用逗号连接后代入 {device}(build / trial / env 里都可用),例如 1,2。
metric 比较哪个指标;better 为 lower 或 higher;repeats(默认 1)是候选和 incumbent 各跑几次,取中位数;min_improvement_pct(默认 0)是 evaluate 判 PASS 的最小改进百分比。
trial 必须向 {result} 写入 {"metrics": {"<metric.name>": <正数>}}。第一个元素建议写解释器的绝对路径。
validation 可选,在候选上跑一次的质量检查,只替换 {device};不写时 verdict 为 INCONCLUSIVE。
device_model 可选,例如 L20X。写了就在测量前对取得的设备跑 qualify_devices。
build 可选,只在候选上跑一次,只替换 {device}。
command_timeout_seconds 每条 build / trial / validation 命令的上限,默认 30 秒;同时不超过 lane 的截止时间。
device_paths 每个设备 id 对应的设备节点。测量时只挂入取得的设备的节点。不写则不挂任何设备节点。
shared_device_paths / runtime_paths / env 所有测量都要的设备节点(读写)、只读的驱动库目录、额外环境变量。
protected 任何 lane 都不能改的路径,例如 benchmark 本身。
lanes[] 每条 lane 的 id、对应搜索计划条目 entry、唯一的 plane、可改路径 globs、每次测量的设备数 device_count(默认 1)、attempt 上限 cap、单次 attempt 预算 per_attempt_worst_case、截止时间 deadline_utc。

GPU benchmark 要多写的字段

{
  "device_ids": ["0", "1", "2"],
  "command_timeout_seconds": 1800,
  "device_paths": {"0": ["/dev/nvidia0"], "1": ["/dev/nvidia1"], "2": ["/dev/nvidia2"]},
  "shared_device_paths": ["/dev/nvidiactl", "/dev/nvidia-uvm", "/dev/null", "/dev/urandom"],
  "runtime_paths": ["/lib/x86_64-linux-gnu"],
  "env": {"HOME": "/tmp"}
}

runtime_paths 写驱动用户态库(libcuda.so)所在目录,可用 ldconfig -p | grep libcuda 查。

目前的限制

  • close 只做 joint single-rerun(PASS 合成一次再量),不做 task: parallel optimization rounds with orthogonal lanes for multi-agent harnesses #249 的逐步 composition,也不串多轮 campaign;lane Agent 由调用方启动,不在隔离环境里。只有 build / trial /(close 时的)联合 trial 在隔离环境里执行。
  • 设备租约和隔离标记都放在 round 目录下,只在同一个 round 内互斥;同一台主机上同时跑两个 round、用同一批设备,本 PR 不协调。
  • GPU 路径(设备节点、驱动库、新的 /proc)已实现,但还没有在真实 GPU 上验证,见下方「验证与限制」。

隔离边界

  • 新根目录只挂载可写目录、只读目录、计划声明的设备节点和驱动库、Python 运行时及动态链接器所需的库,不挂载宿主根目录。
  • 每条命令都是独立 PID namespace 里的 PID 1(unshare --pid --kill-child),并在独立 session 中启动。命令超时时杀掉 unshare 所在的 session,并直接杀掉 namespace 的 PID 1(PID 1 可能已经 setsid 离开 session);等到进程组清空、PID 1 已退出或成为 zombie 才返回,之后才放回设备。杀掉 PID 1 会拆掉整个 PID namespace,所以命令 setsid 出去的子进程也一并结束。
  • 在限定时间内确认不了这些进程已经结束时,serve 在还持有设备的时候写入 <round-dir>/leases/<device>.quarantined(内容是 ticket 和原因),然后才放回设备;只放开文件锁不够,因为单次运行的 serve 进程退出时锁本来就会释放。之后任何经过 DeviceLease.acquire 的申请都会拒绝这张设备。
    • 怎么看到: 触发隔离的那张 ticket 收据为 unsettled,原因是 namespace command outlived its deadline,devices 列出被隔离的设备;ls <round-dir>/leases/*.quarantined 列出所有被隔离的设备。
    • 怎么恢复: 由操作员确认设备上已经没有残留进程(例如 nvidia-smi 看不到进程)后删除该文件,设备即可再次分配。本 PR 不自动解除。
    • 全部设备都被隔离时: 新 ticket 一直是 queued,过了 lane 截止时间变成 rejected,不扣 attempt。这是有意的:宁可不测,也不在可能还被占用的设备上测量。
  • 只挂入本次取得的设备的节点;有设备节点时另挂一个新的 /proc,从不挂宿主的 /proc。每次都有空的 /tmp 和 /dev/shm。
  • 进入 namespace 前的 supervisor 用 python -I 启动,包路径由参数显式传入;候选目录和 PYTHON* 环境变量不进入 sys.path,候选里放一个同名的 inferrsi 包也不会被导入。
  • 子进程只继承允许的环境变量:PATH、locale、TZ、PYTHONIOENCODING,以及计划里的 env。
  • max_user_namespaces 为 0,或 unshare 实际被拒绝时,后端拒绝执行。namespaces_available 会实际尝试一次 unshare;在这类主机上,实机测试跳过而不是失败。
  • 子进程超时、隔离失败、trial 没有写出可读结果,都会留下收据;已 claimed 的 attempt 不退回。

例子:AURA 上的集群搜索

下面的数字不是本 PR 的代码跑出来的。AURA 的搜索用的是另一份脚本,控制流相近:同一个 incumbent 分出多条 lane,每条只改一个参数,测量结果回到同一份记录。这里只用来说明集群能省多少墙钟时间。

  • 目标: AURA 语音对话的首包音频延迟(TTFP)。ASR、AURA、Talker、Code2Wav 四个阶段跑在同一张 GPU 上。
  • 没有集群: 1 张 GPU 逐代搜索。约 1.8 小时找到最终保留的改动(min_chars 15),约 4.6 小时跑完全部 7 代。
  • 有集群: 6 条 lane 分到 3 张 GPU 排队测量,测量墙钟约 2.2 小时(各 lane 耗时加总约 4.1 小时)。按本 PR 的规则,同样 3 张 GPU 一轮最多 3 条单卡 lane,其余方向放到下一轮。之后改用更严格的接受规则(5 次中位数需领先 3%),复用已有测量,再用约 23 分钟确认同一个改动。
  • 同样流程搜 TTFT: 保留的配置 5 次中位数 166.7 ms,原配置 260.7 ms,约快 36%。

两种方式用的 GPU 数量和接受规则不同,以上不是同等条件下的加速比。

验证与限制

  • 当前 head 6be668cd 已 rebase 到 main(76ca44a8)。import gate 在该 head 上本地重跑为 harness_model_infra == ()(其后修复含 submit 边界、venv/系统 Python 的 runtime_roots、以及 apps 组装 assess),并适配 inferrsi.contracts.RunSpec 与新版 run_experiment 的 assess/report 端口。
  • pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py:rebase 后本机 focused 套件通过(含 close、目录指纹、validation 基础设施故障 → unsettled);本机没有可用的 user namespace,相关测试 skip。
  • ruff check(本 PR 涉及文件)
  • 真实 user namespace(隔离语义,rebase 前 head 026f686d 上的证据仍适用 confinement/lease 行为):fork run 43377269558,ubuntu-22.04 53 passed,1 skipped(GPU)。ubuntu-24.04/上游 ubuntu-latest 因 AppArmor 会跳过 namespace 测试,真实 namespace 证据以 fork 22.04 为准。rebase 后若需可再跑一次探针。
  • qualify_devices 在 L20X 主机 GPU 0、1 上:型号匹配通过;故意填错型号时 ticket 保持 queued、无账本。完整隔离测量因该机 max_user_namespaces=0 记 unsettled。
  • GPU 实机隔离:test_unshare_gpu_trial_sees_only_the_held_device 与 torch prepare/submit/serve(及可选 close)仍缺;需 Linux + NVIDIA + 可用 user namespace(原生 Windows 不可用)。
  • reviewer 确认 attempt digest、fail-closed,以及 joint close 是否可作为 task: parallel optimization rounds with orthogonal lanes for multi-agent harnesses #249 的暂时收口

实际 OS 隔离只在 GitHub 托管的 Ubuntu 22.04 + setup-python 3.11 上验证过,其他发行版或系统 Python 的加载器路径没有验证。

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

Independent source review of head 56a40049148ced7bb80e60249a8f5df40d5c1587, against API base / observed main f93df0548a26714f6514337a8525c7c14108acad. Requesting changes for three current execution-contract defects, detailed inline: protected read/environment exposure, claim persistence after execution, and incomplete absolute-deadline enforcement.

I traced prepare/submit/serve, lane-budget transitions, confinement, leases, the CLI and all added tests against the existing architecture and #249 discussion. The attempt-scoped digest and permanently retained reservation charge are useful; they do not clear the inline execution-boundary findings. The Draft/partial-delivery description is appropriately explicit. Existing M0–M2 assignment/scope acceptance remains a maintainer decision, separate from this code review.

Verification was source and existing hosted-status inspection only. I did not execute this branch, tests, namespaces, models, devices or a paid workflow. Current hosted evidence contains the declaration check; no Ready full-check/installed-package result was observed for this head. Fixture results and author-reported tests do not qualify OS confinement or a campaign outcome. Next for the existing author @NumberWan: fix the three boundaries and supply the corresponding targeted evidence, preserving unknown/failed execution states and the Draft scope. No pilot, device use, incumbent advance, merge or Issue closure is authorized by this review.

Comment thread src/inferrsi/infra/confinement.py Resolved
Comment thread src/inferrsi/harness/parallel_round.py Resolved
Comment thread src/inferrsi/harness/parallel_round.py Resolved

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

Incremental review of the existing Draft head 56a40049: one previously unraised file-deletion handling gap in the offline submit path (inline). Existing confinement, execution-claim, and deadline findings remain in their original threads; this review does not repeat or resolve them. Scope: static inspection of parallel_round.py, its caller and fixture tests against #249; no tests, namespace checks, model calls, or device experiments were run. This is not approval or M0–M2 acceptance.

Comment thread src/inferrsi/harness/parallel_round.py Resolved

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

One additional blocking file-boundary finding at 56a40049: submission can copy a coordinator-readable external file through a lane-controlled symlink. This intake path is distinct from the existing candidate-execution confinement finding and must be closed before accepting untrusted lane submissions.

Verified with a disposable synthetic external canary and the exact pinned function bodies; no real private file or candidate command was accessed/executed. Existing findings remain in their threads; no duplicate findings or broader feature requirements are added.

Verification boundary

Function-level reproduction used AST-extracted prepare/submit and necessary helpers/artifact functions, standard library only, with a sanitized environment. Allowed path knobs/a.txt was replaced by a symlink to a synthetic sibling file outside work. Result: submitted=true, outside=[], source_is_symlink=true, outbox_is_regular_copy=true, copied_external_canary=true. This is not a full CLI or OS-confinement qualification; no model/hardware/network execution or repository modification occurred.

Comment thread src/inferrsi/harness/parallel_round.py Resolved
@NumberWan

Copy link
Copy Markdown
Author

Addressed the five findings on 56a4004 in 9b4b08b.

  • Filesystem view. namespace_plan builds a fresh root from the writable set, the readable set, and the Python runtime. It refuses a mount of / and does not remount the host root. The command receives an allowlisted environment (PATH, locale, TZ, PYTHONIOENCODING); the config is a coordinator tempfile, not a file under the candidate tree. FixtureBackend is still a test double (import hook plus the same minimal environment). Build and trial canaries show SECRET_CANARY and a private file stay out of both stages. Unshare failure still does not fall back to a plain process.
  • Claim before launch. serve reserves, materializes, rechecks the deadline, then advances to claimed and saves that entry before the first confined command. ConfinementUnavailable after that point leaves the entry claimed and returns unsettled. A restart with the result file removed does not reserve again and does not cancel. A refusal before launch can still cancel the reservation. The worst-case charge is kept.
  • One deadline. submit re-reads the plan and refuses an expired lane. serve rechecks at claim and before every command, and the subprocess timeout is the time left until that same deadline (capped at 30s so a far deadline does not overflow poll). Covered: reserve before expiry / launch after expiry, and a new submission after expiry, including a second read.
  • Deletions. An in-scope deletion is a structured deletion refusal before hashing. A crafted manifest with deleted is rejected before the lease, the claim, and any candidate command.
  • Symlinks. Snapshot, hash, and copy use O_NOFOLLOW from the tree root. A symlink or other non-regular entry is rejected before its target is read, including when it masks a path the incumbent still has. The external-canary fixture does not land in the outbox.

Still out of scope: OS confinement on this host (user namespaces are unavailable, so the default backend fails closed), M3, incumbent advance, and shared drivers.

@NumberWan
NumberWan marked this pull request as ready for review November 2, 2026 03:05

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

Incremental static review of head 9b4b08b9 following the author's five targeted fixes: one newly identified expected-failure reporting gap in the unshare backend (inline). Existing confinement, deadline, claim and symlink findings remain on their original threads; this does not repeat, dismiss or approve them. I inspected the new confinement.py, parallel_round.py, CLI caller and available fixture tests; no real namespace, test, model or device run was performed. This is not an M0–M2 acceptance or launch authorization.

Comment thread src/inferrsi/infra/confinement.py Resolved

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

Changes requested at 9b4b08b9: the new filesystem view still lacks the runtime files needed to start a dynamically linked Python command.

  • One new P2 startup defect is detailed inline. It affects the real namespace backend on an otherwise namespace-capable Linux host.
  • The existing deadline follow-up and timeout-receipt finding remain applicable; this review does not repeat them.
  • The persisted pre-launch claim and explicit deletion refusal improve the earlier paths. They do not establish native confinement qualification or complete the parent task. Next action remains with @NumberWan: repair the current blockers and provide bounded software evidence.
Evidence and scope

Reviewed head: 9b4b08b9f7b4bde0f18d6e3db80d8e47cf059539; API base: f93df0548a26714f6514337a8525c7c14108acad; assessed main: 919ed42c0d01dc0aa3b613085b9041d735d2d4db.

Inspected the six-file repair delta, current prepare/submit/serve and CLI consumers, runtime-root/mount/exec paths, and relevant fixture tests against the existing execution contract. Current per-head evidence contains successful declaration checks; no Ready full-check or installed-package success was observed. Verification was source and existing hosted evidence only: no repository tests, namespaces, model/device runs or paid evaluation were executed. This review did not implement the PR and grants no launch, merge or goal-acceptance authorization.

Comment thread src/inferrsi/harness/confinement.py Resolved
@NumberWan

Copy link
Copy Markdown
Author

Addressed the three findings on 9b4b08b in fc9d232.

  • Timeout receipt. UnshareBackend turns subprocess.TimeoutExpired into ConfinementUnavailable and still deletes the coordinator config. serve catches that, and a backend that raises TimeoutExpired directly, after the claim is already durable. The receipt is unsettled, names the stage (build / candidate / incumbent), and status no longer reports queued. The claim is not cancelled.
  • Fresh deadline. The production path no longer reuses the timestamp captured when serve was entered. Each admission, claim check and command reads the clock again, and the subprocess timeout is the time left until that same absolute deadline (still capped at 30s). Covered: the clock crosses the deadline after build and before the candidate trial; the candidate command is not started, and the entry stays claimed.
  • Loader closure. The fresh root still does not mount /. Besides the Python prefix, the plan now bind-mounts the executable's PT_INTERP loader, the libraries ldd resolves, and ld.so.cache when it exists, at their original absolute paths. A private canary directory is not in that plan. The live UnshareBackend smoke is in the tree and skips where user namespaces are unavailable (max_user_namespaces=0 on this host); it was not executed here.

Still out of scope: OS-confinement qualification on this host, M3, incumbent advance, and shared drivers.

@agent-ci-infra-bot agent-ci-infra-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed commit: fc9d232
Coverage: Snapshot: 2221 files, 35993584 bytes; skipped 0 entries; Initial model context: 22 files; other accepted files available through tools; Git workspace contains a fixed snapshot, not full upstream history

Comment thread tools/parallel_round.py Resolved
Comment thread tests/test_confinement.py
assert "SECRET_CANARY" not in plan["env"]


@pytest.mark.skipif(not namespaces_available(), reason="user namespaces are unavailable")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

F2 — high, must-fix, test gating — the live namespace smoke fails instead of skipping when unprivileged user namespaces are blocked

  • Where: tests/test_confinement.py:135
  • Problem: the guard only reads /proc/sys/user/max_user_namespaces. When that value is positive but namespace creation is denied, the test runs and errors: UnshareBackend().run → ConfinementUnavailable: unshare: unshare failed: Operation not permitted. Executed in this container: PYTHONPATH=src python -m pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py → 1 failed, 23 passed, the failure being test_unshare_starts_python_and_hides_a_private_canary. Here max_user_namespaces = 498239 and kernel.apparmor_restrict_unprivileged_userns = 1, while unshare --user true returns EPERM.
  • Conditions: unprivileged containers (default seccomp profiles) and AppArmor-restricted unprivileged-userns hosts, which is the default on Ubuntu 24.04+ and therefore on common GitHub-hosted runners. This is unrelated to whether the host has namespaces at all.
  • Impact: the repository's full pytest (ready and nightly lanes) goes red on such hosts, and the PR's statement that the smoke "skips where user namespaces are unavailable" is wrong, so this test cannot serve as the confinement qualification evidence it claims to be.
  • Fix: probe the syscall rather than the sysctl, e.g. subprocess.run(["unshare", "--user", "true"], ...) and skip on a non-zero return, or wrap UnshareBackend().run(...) in try/except ConfinementUnavailable and pytest.skip(str(exc)).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

已在 cf22cb50 处理:namespaces_available() 除了读 max_user_namespaces,还实际执行一次 unshare --user --map-root-user --mount -- true,失败、超时或找不到程序都视为不可用,现场测试改为跳过。测试:test_blocked_unshare_reports_namespaces_unavailable。

Comment thread src/inferrsi/harness/parallel_round.py Resolved
@agent-ci-infra-bot

Copy link
Copy Markdown

This PR adds the offline parallel-round coordinator (prepare/submit/serve/status), lane attempt budgets, a fail-closed confinement backend and its tests. Two blocking defects: the serve CLI now calls serve_ticket() without its still-required now argument (TypeError on the only production entry point), and the new live namespace test errors instead of skipping when unprivileged user namespaces are blocked. Executed here: PYTHONPATH=src pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py → 1 failed, 23 passed; ruff could not be executed in this container (binary not runnable), and no test-lane CI check runs exist for this head (only the knowledge-policy check).
Earlier findings: F(56a4004 #1 read/credential boundary) fixed — the fresh root excludes /, readable is mounted, and only an allowlisted env reaches the command; F(#2 claim before launch) fixed — claimed is persisted before the first command; F(#3 deadline) fixed in the engine, but the fix broke the CLI wiring (F1); F(#4 deletion) fixed — structured deletion refusal before hashing; F(#5 symlink) fixed — no-follow snapshot/read with linked-path rejection. F(9b4b08b timeout receipt) fixed — TimeoutExpired becomes ConfinementUnavailable/unsettled receipt. F(9b4b08b clock) fixed — default current() reads a fresh clock. F(9b4b08b loader closure) fixed in code, but the added smoke could not be validated here (unprivileged unshare returns EPERM) and mis-gates (F2).
Labels: kind:task (bounded delivery slice of the #249 coordinator work; no priority label returned because the repository requires a status decision for priority:*).

Reviewed commit: fc9d232
Coverage: Snapshot: 2221 files, 35993584 bytes; skipped 0 entries; Initial model context: 22 files; other accepted files available through tools; Git workspace contains a fixed snapshot, not full upstream history

@agent-ci-infra-bot agent-ci-infra-bot Bot added kind:task Bounded delivery task with a delegated slice bot-reviewed labels Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Review at head fc9d2328: not approving yet.

  1. serve CLI is broken (tools/parallel_round.py:53-58): serve_ticket(round_dir, ticket, incumbent, backend=select_backend()) omits now, but src/inferrsi/harness/parallel_round.py:388-396 still declares now: datetime as a required keyword-only argument, so the only production entry point raises TypeError. Expected: pass now=datetime.now(timezone.utc) (or make now optional and derive it from clock) and add a CLI-level test.
  2. Open bot findings at this head: F2 (tests/test_confinement.py:135, live namespace smoke fails instead of skipping when user namespaces are blocked) and F3 (src/inferrsi/harness/parallel_round.py:446, a trial exiting 0 without a valid result leaves no terminal receipt) have no reply or fix.
  3. Open CHANGES_REQUESTED from Dong1017 (runtime dependency closure in the fresh root, src/inferrsi/infra/confinement.py): please confirm whether fc9d2328 addresses it and reply in that thread.
  4. Ready CI has not run at this head (only declarations).

Copy link
Copy Markdown
Collaborator

Coverage review at head fc9d2328a6ef1a9b79e98b961967699622f5e305 (base f93df0548a26714f6514337a8525c7c14108acad). Re-checked against my earlier short-SHA note and the bot review at this head. No new commits. Not approving yet.

  1. serve CLI is still broken (tools/parallel_round.py ~L53–58): serve_ticket(round_dir, ticket, incumbent, backend=select_backend()) omits now, but src/inferrsi/harness/parallel_round.py ~L388–396 still declares now: datetime as a required keyword-only argument, so the only production entry point raises TypeError. (Inside the function the body uses current() / clock and does not read now, so making now optional — or removing it and passing now=datetime.now(timezone.utc) from the CLI — both work; please pick one and add a CLI-level test.)
  2. Open bot findings at this head (agent-ci-infra-bot): F2 (tests/test_confinement.py live namespace smoke fails instead of skipping when user namespaces are blocked) and F3 (src/inferrsi/harness/parallel_round.py ~L446, a trial exiting 0 without a valid result leaves no terminal receipt) have no reply or fix on this head.
  3. Outstanding Dong1017 CHANGES_REQUESTED (runtime dependency closure in the fresh root, src/inferrsi/infra/confinement.py, and earlier threads): author claims on fc9d232 address loader closure via PT_INTERP / ldd / ld.so.cache, but please confirm in those review threads whether the blockers are cleared and supply the targeted evidence.
  4. Ready CI has not run at this head (only declaration-related evidence observed previously).

Reviewed commit range: f93df0548a26714f6514337a8525c7c14108acad … fc9d2328a6ef1a9b79e98b961967699622f5e305.

@NumberWan

Copy link
Copy Markdown
Author

fc9d232 上的三点已经在 cf22cb5 处理。说明改成简体中文。

  1. serve CLI。 serve_ticket 的 now 改成可选,生产入口不再因为少传这个参数而 TypeError。函数内部仍用 clock 或当前时间,不把进场时间冻成截止时间。补了 test_serve_cli_runs_without_a_caller_supplied_clock。
  2. namespace 测试误失败。 namespaces_available 在 max_user_namespaces > 0 之后再跑一次 unshare --user --map-root-user --mount true。返回非 0、超时或找不到命令时视为不可用,现场测试走 skip。补了 test_blocked_unshare_reports_namespaces_unavailable。这台机器 max_user_namespaces 是 0,原有的现场测试仍然 skipped,没有实际跑进 namespace。
  3. 没有结果文件就没有收据。 build / candidate / incumbent 都返回 completed,但 latency JSON 缺失、损坏或缺字段时,写下 unsettled,原因写明 trial 没有可读的 latency 结果。claim 不取消。补了 test_completed_trial_without_a_latency_file_is_unsettled。

Dong1017 在 9b4b08b 上提的动态链接器闭合,仍是 fc9d232 里用 PT_INTERP、ldd 和 ld.so.cache 做的那一版;这次没有改那条挂载逻辑。这台机器不能创建 user namespace,所以那条现场启动测试这里仍然跳过。

pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py:26 passed,1 skipped。ruff check 通过。PR 仍不把 M0–M2 当成已验收。

Copy link
Copy Markdown
Collaborator

增量 review:fc9d2328a6ef1a9b79e98b961967699622f5e305..cf22cb50f243b17227863f8e79f601b25faf5480(1 个提交,base f93df0548a26714f6514337a8525c7c14108acad)。谢谢这么快修完,这次先不 approve。

已核对、确认修好的:

  • serve CLI:src/inferrsi/harness/parallel_round.py L394 now 改为可选并 del now,tools/parallel_round.py L53-58 不传 now 也不会再 TypeError;截止时间仍由 current() 每次重新读时钟。
  • F2 namespace 误失败:src/inferrsi/infra/confinement.py namespaces_available() 现在实际跑一次 unshare --user --map-root-user --mount -- true,非 0 / 超时 / OSError 都返回 False,test_blocked_unshare_reports_namespaces_unavailable 覆盖了 EPERM 情形。
  • F3 缺结果无收据:parallel_round.py L451-462 对读取 / 解析 / 缺字段统一写 unsettled,且在 advance(..., "finished") 之前返回,账本停在 claimed,与之前的约定一致。

还需要处理的:

  1. Ready CI 没在这个 head 上跑:cf22cb50 目前只有 declarations,没有 full-check (3.10/3.11)、installed-package、pr-references。PR 描述里的 26 passed / 1 skipped 是本地结果,请触发完整 CI,让新增的 CLI 子进程测试在 CI 环境里也跑一遍。
  2. tests/test_parallel_round.py L409-439 的 CLI 测试断言太宽:body["status"] in {"measured", "unsettled", "rejected", "queued"} 几乎接受任何结果,只能证明没有 TypeError。计划截止时间是 2099 年,所以这里会走真实 select_backend():没有 user namespace 时应该确定是 unsettled(UnavailableBackend)。建议按 namespaces_available() 分支断言具体状态,至少在不可用时断言 unsettled 且 reason 指向 confinement 不可用,这样以后 fail-closed 行为退化时测试能抓到。
  3. Dong1017 的 CHANGES_REQUESTED 仍未关闭:9b4b08b9 上关于 fresh root 动态链接器闭合的 thread(src/inferrsi/infra/confinement.py L99)以及更早几条 thread 都还没有作者回复。这次没改挂载逻辑,现场 UnshareBackend 启动测试在你和 bot 的机器上都被跳过,所以 PT_INTERP / ldd / ld.so.cache 这一版在真实 namespace 里能否启动 Python 还没有人验证过。请在对应 thread 里回复,最好能在一台能创建 user namespace 的机器(或 CI runner)上跑一次 test_unshare_starts_python_and_hides_a_private_canary 并贴出结果,再请 Dong1017 确认。

小问题(不阻塞):namespaces_available() 每次调用都会起一个 unshare 子进程,select_backend() 只在 serve 入口调一次所以问题不大;如果以后在循环里调用,可以考虑缓存结果。

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR review verdict — DO NOT PASS

Reviewed base f93df0548a26714f6514337a8525c7c14108acad and head cf22cb50f243b17227863f8e79f601b25faf5480 (full diff; no previous head was seeded). Two execution-contract blockers remain. I will re-read after the author pushes.

Blockers

  1. P1 — The unshare supervisor cannot import enter_namespace on the layout this PR tests. UnshareBackend.run (src/inferrsi/infra/confinement.py:330) starts sys.executable -c "from inferrsi.infra.confinement import enter_namespace" with env=minimal_environment() (:346). The allowlist (:20) is only PATH, LANG, LC_ALL, LC_CTYPE, TZ, and PYTHONIOENCODING. PYTHONPATH is omitted, and cwd is the candidate tree, so the child sys.path does not include the checkout that holds src/inferrsi. When that is the only way to import inferrsi, the child exits with ModuleNotFoundError before enter_namespace. Any non-zero status is raised as ConfinementUnavailable (:358), and serve_ticket records unsettled without running build or either trial. tools/parallel_round.py serve uses select_backend(), so a namespace-capable host takes this path. test_serve_cli_runs_without_a_caller_supplied_clock sets PYTHONPATH=src and accepts unsettled, so it stays green when the jail never starts. Expected correction: put only the directory that contains the inferrsi package (derived from this module's __file__) on the supervisor environment. Keep the candidate execvpe environment on the allowlist. Add a test that the supervisor environment can import inferrsi and still omits secrets such as SECRET_CANARY.

  2. P2 — Restart does not treat an existing ledger row for this ticket as the same attempt. _claimed_entry (src/inferrsi/harness/parallel_round.py:343) matches only phase == "claimed". Otherwise serve_ticket always calls admit_attempt, which mints ordinal = len(entries)+1 (:431).

    • Trigger A: _save_ledger persists reserved (:434) before _materialize (:437) and before claimed is saved (:444). copytree / copy2 raising, or a stop in that window, leaves no receipt. The next serve allocates another attempt. When the new charge exceeds cap, the ticket is recorded rejected for budget exhaustion and never launches. When the cap has room, the same ticket runs under a second permanent charge while the first row stays reserved.
    • Trigger B: _save_ledger of finished (:464) happens before _record writes results/<ticket>.json (:465). A stop in that window has no claimed row, so the next serve launches build, candidate, and incumbent again.
      Expected correction: a persisted run_id ending in @ticket is that attempt. Resume reserved without a new charge. For claimed or finished, write a terminal receipt and do not launch.

Closed on this head (source inspection)

  • Submit refuses symlinks via a no-follow walk, and refuses an in-glob deletion instead of hashing a missing path.
  • serve_ticket drops the caller's now and re-reads clock or datetime.now(timezone.utc) for admission and each stage. Submit checks deadline_utc. A stage TimeoutExpired becomes an unsettled receipt.
  • claimed is saved before _launch. A later claimed row with no receipt is recorded unsettled and is not launched again. The reserved and finished windows above are what remains of that contract.
  • The namespace plan is built from the writable set, the readable set, runtime_roots(), and runtime_files() (PT_INTERP, ldd libraries, and /etc/ld.so.cache). Source / is refused. The coordinator environment is reduced to the allowlist. namespaces_available() probes unshare, and the live test is skipped when that probe fails.
  • now is optional on serve_ticket, so the CLI serve call matches the signature. A completed trial with an unreadable latency file becomes unsettled.

Follow-ups (non-blocking)

  • Each stage still uses min(seconds_remaining(...), 30) (parallel_round.py:357), so a stage stops at 30s while the lane deadline still has time left.
  • A symlink present at scan time is rejected. _scan and _read_nofollow do not fstat the opened fd and do not open with O_NONBLOCK, so a regular file replaced by a FIFO after stat can block the coordinator in os.read.

Verification

Static read of parallel_round.py, round_budget.py, confinement.py, device_lease.py, tools/parallel_round.py, and the new tests, checked against the earlier threads on #268. Not verified here: pytest, unshare, namespaces, models, devices, or a paid workflow. Loader mounts and OS confinement are not qualified by this pass. Synthetic latency in this harness is not a campaign result. M0–M2 scope acceptance stays with the maintainer.

Dong-bot will re-read after the author pushes.

@NumberWan NumberWan changed the title feat(harness): offline parallel-round coordinator feat(harness): 集群 RSI 并行轮协调器 Nov 11, 2026
@NumberWan

Copy link
Copy Markdown
Author

f63723f8 让一轮并行测量不再限定单设备、单指标:

  • 计划改为 device_ids 列表和 metric: {name, better}。serve 选任一空闲设备,把 {device} 代入 build / trial 命令,结果写下所用设备,gain 以正数表示候选更好。
  • 同一条 lane 的 ticket 先取得 lane 锁再查账本、取设备,多设备时不会并发改写同一份账本。
  • 结果文件里的指标不是有限数值时,留下 unsettled 收据,账本停在 claimed,不在 claim 之后抛异常。

pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py:31 passed,1 skipped(本机没有 user namespace)。ruff check 通过。主 CLI 没有改动:按 docs/contracts/isolation-errors-and-cli.md,新的 CLI 入口等 #371 的 Apps 实现切片。

Copy link
Copy Markdown
Collaborator

增量 review:cf22cb50f243b17227863f8e79f601b25faf5480..f63723f81367991298913c3c626de135754f0754(1 个提交 feat(harness): let a parallel round use several devices and a declared metric),对照我上一条 review。这次还不 approve。

这次改动,已核对

  • prepare()(src/inferrsi/harness/parallel_round.py L167-184)校验 device_ids(非空、互不重复、单段名)和 metric: {name, better}。better 只接受 lower / higher,tests/test_parallel_round.py 新增的 test_prepare_rejects_bad_devices_and_metric 覆盖了这些拒绝分支。两个字段都写进计划正文,受 round_digest 约束。
  • serve_ticket()(L461-499)先拿 lane 锁,再在锁内重新检查 results/ 和账本里已有的 claimed,然后按顺序试各设备的 lease,都忙时返回 queued,不会预占 attempt。以前查 claimed 在拿设备 lease 之前、也不在 lane 锁里,多设备下同一 lane 可能并发改写账本,现在这个窗口关上了。test_a_busy_lane_stays_queued_without_touching_its_ledger 确认 lane 忙时不会生成 ledger 或 result。
  • _metric_value()(L362 起)用 type(value) in (int, float) 排除了 bool,非有限值会落成 unsettled,并且在 advance(..., "finished") 之前返回,账本停在 claimed。这与 F3 的约定一致,test_a_non_numeric_metric_is_an_unsettled_receipt 也覆盖了。better: higher 时 gain 取反,结果始终以正数表示候选更好,测试用 8 对 10 得 -2,符合预期。

这次新发现的问题

  1. _segment() 放过了 . 和 ..(L44-45)。device_ids: ["."] 或 lane id ".." 能通过 prepare()。到 serve 时,DeviceLease.acquire()(src/inferrsi/infra/device_lease.py L31-34)会执行 (directory / ".").open("a+"),抛出 IsADirectoryError。这不是 LeaseError,所以 serve_ticket 会直接抛异常,而不是返回 queued 或 rejected。账本不会被破坏(这时还没 admit),但这个计划永远跑不起来。请在 _segment() 里同时拒绝 . / ..,在 test_prepare_rejects_bad_devices_and_metric 里补这两个值,lane id 也补一个用例。
  2. {device} 只做了字符串替换,没有说明约定(_command,L355 起)。build 现在也会替换 {device},但不会替换 {result}。如果有人在 build 里写了 {result},会原样传下去。另外 metric.name 是结果文件里 metrics 的键,这个约定目前只出现在提交说明里。建议在模块 docstring 或 docs/ 对应的契约里写清楚 build / trial 可用的占位符,以及结果文件的 {"metrics": {<name>: number}} 形状。

上次的问题,还没处理
3. Ready CI 仍然没在这个 head 上跑:f63723f8 只有 declarations(2 个),没有 full-check (3.10/3.11)、installed-package 和 pr-references。31 passed / 1 skipped 仍是本地结果,请触发完整 CI。
4. CLI 测试断言仍然太宽:tests/test_parallel_round.py L541 还是 body["status"] in {"measured", "unsettled", "rejected", "queued"}。请按 namespaces_available() 分支断言具体状态,至少在不可用时断言 unsettled,并且 reason 指向 confinement 不可用。
5. Dong1017 的 CHANGES_REQUESTED 仍未关闭:这次没有改 src/inferrsi/infra/confinement.py,fresh root 的动态链接器闭合 thread(L99)和更早几条 thread 仍然没有作者回复,真实 user namespace 下 test_unshare_starts_python_and_hides_a_private_canary 也还没有人跑通过。请在对应 thread 里回复,并贴出能创建 user namespace 的环境里的运行结果。

以上是静态 review(diff 加 head 上的相关代码),我没有在本地跑测试。

@NumberWan

Copy link
Copy Markdown
Author

回复 @amy-why-3459 的增量 review,新 head 08a8de82:

  1. . / ..:_segment() 现在拒绝 ""、.、..。test_prepare_rejects_bad_devices_and_metric 补了 device_ids: ["."]、[".."],以及 lane id .、.. 两个用例。
  2. 占位符和结果文件约定:写进模块 docstring:build 只替换 {device};trial 替换 {device} 和 {result},候选与 incumbent 各跑一次,必须向 {result} 写入 {"metrics": {<metric.name>: <有限数值>}};其他文本(包括 build 里的 {result})原样传下去。
  3. Ready CI:f63723f8 上的 CI — ready / review lane 已经触发,状态是 action_required。这是 fork PR 需要维护者在 Actions 页面批准后才会运行,作者这边无法触发。请维护者批准 08a8de82 的运行。
  4. CLI 测试断言:test_serve_cli_runs_without_a_caller_supplied_clock 改为按 namespaces_available() 分支断言:可用时为 measured;不可用时为 unsettled,reason 等于 confinement backend unavailable。
  5. Dong1017 的 thread:已在各条 thread 里逐条回复对应的提交和测试。真实 user namespace 下的 test_unshare_starts_python_and_hides_a_private_canary 仍然没有结果:这台主机 max_user_namespaces=0,也没有可用的 docker daemon。需要一台能建 user namespace 的机器跑这条测试,在拿到结果之前,OS 隔离仍按未验证处理。

本地:pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py 31 passed,1 skipped;ruff check 通过。

Copy link
Copy Markdown
Collaborator

增量 review:f63723f81367991298913c3c626de135754f0754..08a8de823e6a6fa342cd8bb5f926e28dd9e506f9(1 个提交 fix(harness): reject dot device and lane names, document trial placeholders,2 个文件),对照我上一条 review 和你的回复。这次还不 approve,原因见下面第 3、5 条。

已解决,已核对

  1. . / ..:_segment()(src/inferrsi/harness/parallel_round.py L49-54)现在拒绝 ""、.、..。它同时用于 device_ids(L180)和 lane id(L203-204),两条路径都覆盖到了。test_prepare_rejects_bad_devices_and_metric 补了 ["."]、[".."] 两个设备用例,以及 .、.. 两个 lane id 用例,lane 的断言 match="own id" 和 L204 的报错文字对得上。
  2. 占位符约定:模块 docstring(L6-9)写明 build 只替换 {device},trial 替换 {device} 和 {result},结果文件的形状是 {"metrics": {<metric.name>: <finite number>}}。和 _command()(L364-368)的实现一致:result is None 时不替换 {result}。
  3. CLI 断言:test_serve_cli_runs_without_a_caller_supplied_clock 现在按 namespaces_available() 分支断言,不可用时断言 unsettled,并断言 reason 是 confinement backend unavailable,和 src/inferrsi/infra/confinement.py L265 抛出的文字一致。

仍未关闭
3. Ready CI 还没在这个 head 上跑:08a8de82 上只有 declarations 和 knowledge declaration policy 通过;CI — ready / review lane 状态是 action_required,需要维护者在 Actions 页面批准。full-check (3.10/3.11)、installed-package 和 pr-references 跑完之前,测试结果只能算作者本地的(31 passed / 1 skipped)。
5. 真实 user namespace 下的隔离仍未验证:这次你已在 Dong1017 的各条 thread 里逐条回复了(包括 confinement.py L99 的加载器 thread),这部分我认可。但 test_unshare_starts_python_and_hides_a_private_canary 仍然没有在能建 user namespace 的机器上跑通,Dong1017 的 CHANGES_REQUESTED 也还在。另外要注意,在 CI 和你的主机上,CLI 测试的 measured 分支和真实的 UnshareBackend 路径目前都不会被执行。需要有人在能创建 user namespace 的环境里跑一次这条测试和 test_serve_cli_runs_without_a_caller_supplied_clock,并贴出结果,再由 Dong1017 确认 thread 是否可以关闭。

以上是静态 review(diff 加 head 上的相关代码),我没有在本地跑测试。这次是校验和文档改动,不涉及精度和性能对比。

Reviewed: f63723f81367991298913c3c626de135754f0754 → 08a8de823e6a6fa342cd8bb5f926e28dd9e506f9.

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

NO PASS
dot, acting for @zengchuang-hw

增量:614118e2db4c8183f193c58eeb6ddc0f74d874eb → ceccb04fd2dfe3139a9d255c04d93d5774b6b885,base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd;上轮检视。本轮已修复同一 lane 叠加多张 PASS 票据的问题:只选一张,按改进幅度排序并稳定打破平局,落选票据有记录。联合基线和 successor 现在使用核对过摘要的 incumbent 副本;新回归覆盖评估期间原工作区变化的情况。

批准前必做:区分联合 build 退出非零与隔离未启动。 新的 Unshare backend 能区分已启动命令的 status="failed" 与未能建好隔离环境,但 _run_confined 把前者重新抛成 ConfinementUnavailable,丢了退出码。联合 close 因而返回可重试的 refused,不写结论;普通编译错误也会落入这条路径,调用方无法区分重试隔离与修复构建。请保留已执行的 build 失败及退出码,明确其结果和重试语义,并补一条联合 build 已启动、非零退出的回归,与已有的隔离启动失败回归配对。验证命令非零退出的用例不覆盖这条 build 路径。

静态核对了四文件增量、调用链、相关测试、#249 及仓库检视指引;未运行 pytest、真实隔离或设备测试,未查看 CI。本轮只检视 joint single-rerun 切片,不验收 #249 的 stepwise composition。

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

One additional finding on the current head.

Comment thread src/inferrsi/harness/parallel_round.py Outdated
reasons=evaluation["reasons"],
)
successor = round_dir / "successor"
materialize(frozen, overlays, successor)

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.

The frozen incumbent fixes drift in the original checkout, but the build can still write into joint before measurement. If it generates a config the trial reads, this second materialize() can drop it from the promoted tree. Could we bind promotion to the source state the trial used, or confine generated files to a separate artifact path and test that the promoted tree rebuilds the same inputs?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed on f6c982e7. A PASS close copies candidates/joint-close to successor/ after the build and the trials. It no longer calls materialize(frozen, overlays, successor) again, so a file the build wrote into the tree the trial read stays on the promoted tree. test_successor_keeps_files_the_build_wrote_into_the_measured_tree checks knobs/generated.txt.

The supervisor forked before exec, so the command became the next pid after the mount helpers instead of pid 1. Exec in place again, and clear the armed marker when exec itself fails.

Signed-off-by: NumberWan <wantszkin2003@gmail.com>
@NumberWan

Copy link
Copy Markdown
Author

@zengchuang-hw @Dong1017

Ascend03 retest of ceccb04f (live user namespace)

Host liteserver-for-vllm-ascend-00003 (aarch64, kernel 5.10.0-182), user.max_user_namespaces=8234368, unshare_exit=0, pytest interpreter venv CPython 3.12.13. /usr/bin/python3 on that host is 3.9.9. No NVIDIA GPU.

HEAD under test: ceccb04fd2dfe3139a9d255c04d93d5774b6b885

pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py tests/test_target_module_import_gate.py tests/test_knowledge_compatibility_shells.py
2 failed, 163 passed, 1 skipped, 43 subtests passed

<testcase> count 166 (1 skipped, 2 failed). The junit <testsuite tests="209"> attribute counts subtests and is not the total.

Passed on this host, including the new close/jail regressions:

  • test_unshare_from_venv_can_import_encodings
  • test_unshare_starts_python_and_hides_a_private_canary
  • test_unshare_timeout_leaves_no_detached_child
  • test_unshare_timeout_kills_a_pid_1_that_left_the_session
  • test_unshare_command_exit_is_a_failed_record
  • test_unshare_missing_executable_stays_unavailable
  • test_unshare_failing_validation_is_a_measured_fail
  • test_one_winner_per_lane_is_promoted_when_the_joint_passes
  • test_joint_failure_of_lane_winners_writes_the_summary
  • test_successor_keeps_the_frozen_incumbent_bytes
  • test_joint_confinement_failure_does_not_seal_the_round
  • test_joint_build_confinement_failure_does_not_seal_the_round

Skipped, with reason: test_unshare_gpu_trial_sees_only_the_held_device — needs user namespaces, an NVIDIA GPU and torch.

Failed:

  1. test_runtime_roots_under_system_python_exclude_usr — the test shells out to /usr/bin/python3 (3.9.9) and dies on str | None. Project requires Python >= 3.10. This is the host interpreter, not the 3.12 venv path.
  2. test_unshare_binds_a_device_node_with_a_fresh_proc_and_scratch_dirs — device bind, fresh /proc, and /tmp mode passed; os.getpid() was 30 instead of 1. The supervisor on ceccb04f forked before exec, so the command was the next pid after the mount helpers rather than pid 1 of the new pid namespace.

7bb853980083c61c459dd2dcf14822c5ce63350d execs the command in place again and only clears the armed marker when exec itself fails. That head is not yet re-run on Ascend03. The system-Python 3.9 failure is unchanged.

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

NO PASS
dot, acting for @zengchuang-hw

增量:ceccb04fd2dfe3139a9d255c04d93d5774b6b885 → 7bb853980083c61c459dd2dcf14822c5ce63350d,base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd。上轮检视。

本轮只改了 confinement.py,恢复命令直接作为隔离环境内的 PID 1 运行。每 lane 单一胜者和冻结 incumbent 的修复没有变化。

批准前仍需处理联合 build 的退出状态。 _run_confined 未改:已启动但非零退出的 build 仍丢失退出码,并作为可重试的隔离拒绝返回。请让 close 保留实际退出码并区分已执行的 build 失败和隔离未启动,补上对应的普通非零退出回归;本轮没有改测试。

本轮只核对精确增量和相关调用链,没有运行测试、实际隔离、设备或 CI。

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

PR review verdict — DO NOT PASS

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

Reviewed base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd and head 7bb853980083c61c459dd2dcf14822c5ce63350d. This is triggered by the Ascend03 report on ceccb04f, which says 7bb85398 has not been re-run. I judged the diff, not the report. The seeded diff is truncated (diffComplete: false; it cuts off inside tests/test_parallel_round.py). I could not see the rest of that file, tools/parallel_round.py, or any docs. I did not execute anything. A PASS is not possible on a partial diff.

Resolved or credible in the visible diff

  • One winner per lane. _one_winner_per_lane keeps the best improvement_pct, with the lower ticket id as tie-break. It records the others as dropped in close.json. This addresses the same-lane finding from amy-why-3459 and the steward. The Ascend report names test_one_winner_per_lane_is_promoted_when_the_joint_passes as passing. I did not see that test in the visible part of the diff.
  • Incumbent binding. prepare freezes incumbent_tree_digest. submit, serve and close refuse a different tree. close copies a frozen incumbent and both the joint run and successor/ use that copy.
  • Submit vs close. submit takes the same round-locks/close lease and refuses once close.json exists.
  • Live namespace path. The Ascend03 run on ceccb04f passes the live UnshareBackend cases: canary, timeout cleanup, and PID 1 setsid.
  • Exec in place. In enter_namespace, the supervisor now writes the armed marker and then calls execvpe in the same process. On OSError it rewrites the marker and exits. UnshareBackend.run only treats armed\n as ran. That matches the explanation for the os.getpid() == 30 failure. I am reading unshare --kill-child as implying --fork, so the supervisor should be PID 1. That is my understanding of util-linux, not something I checked.

Blockers

  1. No evidence on this head for the exec-in-place fix. test_unshare_binds_a_device_node_with_a_fresh_proc_and_scratch_dirs (PID 1) failed on ceccb04f. It has not been run on 7bb85398. Please re-run the five-module command on the Ascend host at this head and post the result.
  2. Executable bits are still dropped (open inline from david6666666, parallel_round.py:500). submit copies with target.write_bytes(payload), so a changed 0755 script lands as 0644. _scan hashes content only, so a chmod-only change leaves the frozen digest unchanged. Nothing in the visible diff binds or preserves the mode. Needed: include the mode in file identity, preserve it on overlay, and add a test that runs an executable entrypoint.
  3. Joint build output vs promoted tree (open inline, parallel_round.py:1363). The joint run builds in joint-close. A PASS then calls materialize(frozen, overlays, successor) again, so successor/ is source-only. Any file the build generated and the trial read is not in what gets promoted. Needed: either promote the tree that was measured, or state and test that the promoted tree rebuilds the same inputs.
  4. Truncated diff and formal state.
    • The unseen part of the diff is unreviewed.
    • cursor[bot] CHANGES_REQUESTED on 026f686d is still the outstanding formal decision.
    • There is no formal Approve on this head.
    • Ready/full-check has not been shown on this head.
    • david6666666's 2026-11-20 request is not shown as done: rebase onto main after #516 and check that the documented knowledge stage still matches the campaign workflow. The base moved to 214fb400, but I cannot confirm from here that #516 is in it.

Non-blocking

  • test_runtime_roots_under_system_python_exclude_usr still has no interpreter-version guard. It fails on any host whose /usr/bin/python3 is below 3.10, as on Ascend03 (3.9.9). Skip it when the system Python is older than the project floor.
  • close.json composed is a list of ticket strings on some paths and a list of {ticket, lane_id} objects on others. Pick one shape.

Scope

My earlier acceptance of joint single-rerun close as the bounded offline slice still stands. It is not #249 M0–M2 acceptance. Stepwise composition and GPU isolation remain open and are not merge conditions here. I will re-read after the next push, once the live re-run and the blockers above are in.


File identity includes the executable bits and an overlay keeps them, so a chmod-only script still runs. A build that started and exited non-zero closes the round with that code instead of looking like a jail that never started. A passing close promotes the measured tree, including files the build wrote.

Signed-off-by: NumberWan <wantszkin2003@gmail.com>

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

NO PASS
dot, acting for @zengchuang-hw

增量:7bb853980083c61c459dd2dcf14822c5ce63350d → f6c982e74d729897b05d3ff125dcfd981a949aca,base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd。上轮检视。

上轮已修复。 联合 build 启动后非零退出,现在会记录阶段与退出码、结束本轮并保留 incumbent;隔离未启动仍可重试。新增回归覆盖退出码 2、不生成 successor 和重复 close 结果一致。联合 PASS 现在从受测树交付 successor,不再重新拼装。

批准前仍需核对票据与实际产物一致。 提交路径 用扫描时的文件内容和执行位生成票据,随后分别重读内容和执行位,再写入 outbox,但不校验写入结果是否仍匹配摘要。正常编辑或切换执行位时,票据可能不再代表实际受测文件。请用同一份快照生成摘要和载荷,或在发布票据前核对复制结果,不一致就拒绝;补一条普通的提交期间文件变更回归。现有新用例只覆盖文件不变时保留执行位。

本轮静态核对了两文件差异、调用链和新增 fixture,未运行测试、设备或 CI。作者的真实 namespace 回放针对较早的 ceccb04f,不能证明当前 head 的 PID 1 路径已在实机通过。

@NumberWan

Copy link
Copy Markdown
Author

@zengchuang-hw @Dong1017

Ascend03 retest of f6c982e7 (live user namespace)

Host liteserver-for-vllm-ascend-00003 (aarch64, kernel 5.10.0-182), user.max_user_namespaces=8234368, unshare_exit=0, pytest interpreter venv CPython 3.12.13. /usr/bin/python3 on that host is 3.9.9. No NVIDIA GPU. The venv python symlink was pointed at the resolved CPython 3.12 binary on that machine only.

HEAD under test: f6c982e74d729897b05d3ff125dcfd981a949aca (fix(harness): keep executable bits, build failures, and measured files)

pytest tests/test_round_budget.py tests/test_confinement.py tests/test_parallel_round.py tests/test_target_module_import_gate.py tests/test_knowledge_compatibility_shells.py
1 failed, 167 passed, 1 skipped, 43 subtests passed in 58.34s

<testcase> count 169 (1 skipped, 1 failed). The junit <testsuite tests="212"> attribute counts subtests and is not the total.

test_unshare_binds_a_device_node_with_a_fresh_proc_and_scratch_dirs is PASSED on this head. On ceccb04f it failed because os.getpid() was 30. The live unshare and close regressions named below are PASSED:

  • test_unshare_from_venv_can_import_encodings
  • test_unshare_starts_python_and_hides_a_private_canary
  • test_unshare_timeout_leaves_no_detached_child
  • test_unshare_timeout_kills_a_pid_1_that_left_the_session
  • test_unshare_binds_a_device_node_with_a_fresh_proc_and_scratch_dirs
  • test_unshare_command_exit_is_a_failed_record
  • test_unshare_missing_executable_stays_unavailable
  • test_unshare_failing_validation_is_a_measured_fail
  • test_one_winner_per_lane_is_promoted_when_the_joint_passes
  • test_joint_failure_of_lane_winners_writes_the_summary
  • test_successor_keeps_the_frozen_incumbent_bytes
  • test_successor_keeps_files_the_build_wrote_into_the_measured_tree
  • test_joint_confinement_failure_does_not_seal_the_round
  • test_joint_build_confinement_failure_does_not_seal_the_round
  • test_joint_build_nonzero_exit_closes_with_the_returncode
  • test_executable_bit_is_part_of_identity_and_the_entrypoint_runs

The last three are in the same five-file run. The only failure in that run is the system-Python test below, so they are not among the failed or skipped cases.

Skipped, with reason: test_unshare_gpu_trial_sees_only_the_held_device — needs user namespaces, an NVIDIA GPU and torch.

Failed: test_runtime_roots_under_system_python_exclude_usr. The test shells out to /usr/bin/python3 (3.9.9) and dies on str | None. Project requires Python >= 3.10. This is the host interpreter, not the 3.12 venv path.

The earlier NPU 6+7 coordinator run was on ceccb04f and is not evidence for this head.

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

NO PASS
dot, acting for @zengchuang-hw

回应本轮 Ascend03 复测。head f6c982e74d729897b05d3ff125dcfd981a949aca、base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd 与上轮代码检视一致,代码无增量。

这份证据补上了当前 head 的真实 user namespace 与 PID 1 回放。按作者记录,原 PID 1 失败的测试现在通过,同次 167 通过、1 失败、1 跳过。我核对了失败测试显式调用 /usr/bin/python3,而项目要求 Python ≥3.10;作者记录该系统解释器为 3.9.9。NVIDIA 设备隔离测试跳过,不能算 GPU 通过。未独立复跑,早前 NPU 6+7 记录也不归入本 head。

剩余代码阻塞不变: 现有执行位测试验证静态文件能正确传递,没有覆盖扫描后、写入 outbox 前发生普通文件或权限修改。需要让票据摘要和保存的内容及执行位一致,并加相应回归。本次不批准。

@Dong1017

Copy link
Copy Markdown
Collaborator

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

I accept the Ascend03 run on f6c982e7 as live-namespace evidence, but this is not a formal verdict. The seeded diff is truncated (diffComplete: false), so I can't PASS yet.

  • Evidence: 167 passed, 1 failed, 1 skipped. The live UnshareBackend tests passed, including the PID 1 setsid case and the device-bind test that failed on ceccb04f.
  • The failure: test_runtime_roots_under_system_python_exclude_usr fails because /usr/bin/python3 is 3.9 and the project needs 3.10 or later. Please skip it when the system interpreter is older than 3.10. This is a small follow-up, not a blocker.
  • Still needed before a formal verdict: Ready/full-check on this head, a cursor[bot] re-review or dismissal of its CHANGES_REQUESTED on 026f686d, two independent LGTMs, and david6666666's post-Unify inference knowledge in skill_library with seven task routes and direct search #516 check of the documented knowledge stage. GPU isolation is still unverified.

Dong-bot (authorized delegate).

Details

I ran nothing. From the visible part of the diff, the earlier consistency findings look addressed:

  • Same-lane tickets: _one_winner_per_lane keeps the best PASS ticket per lane, breaking ties by lower ticket id. The dropped tickets are listed in close.json.
  • Submit sealing: submit takes the close lock and refuses once close.json exists.
  • Incumbent binding: prepare freezes incumbent_tree_digest, and submit, serve and close check it. close also works from a frozen copy.
  • Executable bits and build output: the file hash includes the executable bits, and the overlay keeps them. The measured joint tree is what gets promoted, so files the build wrote into it survive.

The truncated part includes most of tests/test_parallel_round.py. I did not check that those regressions exist. The base is now 214fb400, which suggests a rebase onto main, but I did not check it against #516.

@NumberWan

Copy link
Copy Markdown
Author

@zengchuang-hw @Dong1017

f6c982e7 的 Ascend03 实跑在 #268 (comment) 。test_unshare_binds_a_device_node_with_a_fresh_proc_and_scratch_dirs 在这颗 head 上是 PASSED(ceccb04f 上是 PID 30)。五档合计 1 failed, 167 passed, 1 skipped;<testcase> 169。唯一 FAIL 仍是宿主 /usr/bin/python3 3.9.9 的 test_runtime_roots_under_system_python_exclude_usr。GPU 那条 SKIPPED(没有 NVIDIA / torch)。

@zengchuang-hw 上一轮的联合 build 非零退出,和 PASS 后从受测树交付 successor,都在 f6c982e7。你这轮新的一点还在:submit 用扫描时的摘要发票据,之后又分别重读内容和执行位再写入 outbox,没有核对写入是否仍等于那份摘要。提交期间文件或执行位变了,票据可以不再代表受测文件。这颗 head 没有修。现有用例只覆盖文件不变时保留执行位。

@Dong1017 On 7bb85398 the first three blockers are addressed on f6c982e7, with the live rerun linked above:

  1. test_unshare_binds_a_device_node_with_a_fresh_proc_and_scratch_dirs passed on this head.
  2. Executable bits are in the file digest and kept on the overlay. Inline reply is on the original comment.
  3. A PASS close promotes the measured joint-close tree, including files the build wrote. Inline reply is on the original comment.

1b826b5f (#516) is an ancestor of base 214fb400. Still open, and not claimed here: no formal Approve on this head, Ready/full-check not shown for this head, and the cursor[bot] CHANGES_REQUESTED on 026f686d. The system-Python < 3.10 skip and the mixed composed shape are also unchanged.

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

PR review verdict — DO NOT PASS

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

Reviewed base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd and head f6c982e74d729897b05d3ff125dcfd981a949aca, triggered by the PTAL in comment 7095487223. The seeded diff is truncated (diffComplete: false). I read the harness, confinement and apps files in full. I saw only the first part of tests/test_parallel_round.py, so I have not confirmed the later regressions the author names. I will re-read after the author pushes.

Review state: no formal APPROVED review exists on this head. The cursor[bot] CHANGES_REQUESTED on 026f686d is still listed as outstanding. I ran nothing; this is a static review plus the author's reported Ascend03 run.

Resolved on this head (from the visible diff)

  • Executable bits. _scan hashes mode & 0o111 together with the file bytes, so a chmod-only change alters the tree digest. submit re-applies the bits to the outbox copy. materialize uses copy2, which keeps the mode.
  • One winner per lane. _one_winner_per_lane picks the highest improvement_pct and breaks ties on the lower ticket id. close.json records the others under dropped.
  • Sealing and incumbent binding. submit and close share a round-locks/close lease, and submit refuses once close.json exists. prepare freezes incumbent_tree_digest. submit, serve and close check it. close works from a frozen copy.
  • Promotion. A PASS close copies the measured candidates/joint-close tree to successor/, so files the build wrote survive.
  • Device-bind test. The author reports test_unshare_binds_a_device_node_with_a_fresh_proc_and_scratch_dirs passing on Ascend03 at this head. The supervisor now execvpes in place, so the command is PID 1.

I did not execute any of this. The live-namespace evidence is the author's report on one aarch64 host.

Blockers

  1. submit does not bind the outbox bytes to the ticket digest (src/inferrsi/harness/parallel_round.py, _submit_holding_lock). The author's comment 7095487223 acknowledges this point and says it is unfixed.
    • submit hashes the work tree once with _snapshot. The ticket is digest({round_digest, lane_id, manifest}), where manifest = {path: after[path]}.
    • The copy loop then calls _read_nofollow(work, path) and _executable_bits(work, path) as separate, later reads of the live tree. Nothing checks that the bytes written to outbox/<ticket>/ still hash to after[path], or that the mode still matches.
    • If a lane agent edits or chmods a file during submit, the ticket and files still describe the scanned state. serve and close then measure bytes and modes that the ticket does not describe.
    • This weakens the frozen-ticket guarantee that the recent hardening is built on. Several earlier fixes in this PR close the same kind of gap.
    • Expected: compute the digest (bytes plus exec bits) from the bytes and mode actually read for the copy, and use that as the manifest. Alternatively, re-hash the written outbox files and refuse and remove the destination on any mismatch. Read and chmod from one open fd.
    • Test: add one case where a file's content changes between scan and copy, and one where the exec bit changes. Both must refuse, not issue a ticket for different bytes. The existing test only covers a file that does not change.
  2. Required merge gates are still open. I cannot clear these from the diff.
    • There is no Ready/full-check on this head. Earlier green runs do not carry over.
    • The cursor[bot] CHANGES_REQUESTED on 026f686d (review 5931222199) must be re-reviewed or dismissed by someone with that authority.
    • The head needs two independent current-head LGTMs.
    • A formal PASS is not possible while the diff I was given is incomplete.

Non-blocking follow-ups

  • test_runtime_roots_under_system_python_exclude_usr. It still runs /usr/bin/python3 with no version guard. That fails on any host whose system Python is older than 3.10, as on Ascend03 (3.9.9). Skip it when /usr/bin/python3 is below 3.10. Without this, the five-file focused run cannot go green on mixed hosts.
  • composed shape in close.json and the close return values. It is a list of {ticket, lane_id} dicts in the main path. It is a list of bare ticket strings in the deadline finish(...) call and in the queued returns. Consumers need one shape.
  • Limits that stay as documented. GPU isolation is unverified. Upstream ubuntu-latest skips the namespace tests. Joint single-rerun close stays the bounded #249 offline slice that was already accepted. It is not M0–M2 acceptance, and stepwise composition stays open on #249.

I will re-read once there is a new head that fixes blocker 1. The Ready run and the independent approvals still depend on maintainers.


The ticket digest came from the scan, then submit read the bytes and the executable bits again. A change in between was published under the old digest. The copy now uses one read and is refused when that digest no longer matches the scan.

Signed-off-by: NumberWan <wantszkin2003@gmail.com>
@NumberWan

Copy link
Copy Markdown
Author

@zengchuang-hw 上一则说的 submit 竞态已经补上,head 是 e2ff2ba40eb48bcc45c5d528cb6300af5fd3852f。

票据摘要仍来自扫描。写入 outbox 前对每个变更文件做同一次读取,用同一套内容加执行位重新计算摘要;和扫描不一致就拒绝,reason 是 changed during submit,不创建 outbox。两条回归:扫描后改文件内容,以及扫描后只改执行位。f6c982e7 的 Ascend 实跑不覆盖这颗 head。

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

NO PASS
dot, acting for @zengchuang-hw

增量:f6c982e74d729897b05d3ff125dcfd981a949aca → e2ff2ba40eb48bcc45c5d528cb6300af5fd3852f,base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd。上轮代码检视 · 本轮作者 @。

上轮阻塞已修复。 写 outbox 前用同一次读取拿到内容、执行位与摘要,和初扫不符就拒绝;新增了内容变化、只变执行位两条回归。

批准前需避免全量指纹扫描占用整份文件内存。 _scan 现在调用的 _digest_file 为每个文件收集全部块再拼接,但扫描只取摘要。原来是固定 1 MiB 分块,当前峰值随最大文件增长,且连未改的大文件也会载入;提交阶段还同时保留所有改动文件内容。请恢复只算摘要时的流式读取;可边复制边校验到磁盘暂存,所有摘要匹配后再发布票据。保留两条变化拒绝的回归,并覆盖分块读取的大文件。

静态核对了本轮两文件差异、扫描调用链和测试源码,未跑测试或硬件,也未查看 CI;f6c982e7 的 Ascend03 回放不属于当前 head。

A tree scan only needs the digest, so it no longer keeps each file in memory. Submit copies to a staging directory in chunks and publishes the ticket only when every digest still matches. close composed entries are always ticket and lane objects, and the system-Python root test skips interpreters older than 3.10.

Signed-off-by: NumberWan <wantszkin2003@gmail.com>
@NumberWan

Copy link
Copy Markdown
Author

@zengchuang-hw @Dong1017

b8f1580ad9626dec6cff69a47501dabee2729429 把上一轮还开着的三点放在同一颗 head。

  • 扫描恢复成 1 MiB 流式摘要,不再把整份文件留在内存。submit 先分块复制到 submit-staging/,每个摘要仍和初扫一致才发布 ticket,否则拒绝并删掉暂存。两条「扫描后内容或执行位变化就拒绝」的回归还在,并加了大于一个分块的文件。
  • close 的 composed 一律是 {"ticket", "lane_id"}。截止时间、设备不够、设备检查失败这几条不再回票号字符串。
  • test_runtime_roots_under_system_python_exclude_usr 在 /usr/bin/python3 低于 3.10 时 skip。

f6c982e7 的 Ascend03 实跑不覆盖这颗 head。

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

NO PASS
dot, acting for @zengchuang-hw

增量:e2ff2ba40eb48bcc45c5d528cb6300af5fd3852f → b8f1580ad9626dec6cff69a47501dabee2729429,base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd。上轮检视 · 作者 @。

上轮内存阻塞已修复。 扫描恢复 1 MiB 流式摘要,改动文件边复制到磁盘暂存边校验,且保留内容和执行位漂移回归;新增跨分块用例。也核对了 composed 返回形状与低于 Python 3.10 的宿主测试跳过。

批准前需补齐票据发布失败后的恢复。 当前发布路径 先移动载荷,再写票据 JSON。如果 JSON 写入失败(例如磁盘满),代码返回 symlink 拒绝,却留下目标目录;重试只看目录存在就跳过写 JSON、返回成功,而 serve 仍读不到完整票据。这个双文件发布缺口在旧流程也有,本轮改写没有修复。请把状态发布做成完整提交,或在失败时清理且在重试前核验两部分;补一条普通元数据写入失败后可重试、且不会报告假成功的回归。

本轮静态核对了三文件增量和故障路径,未运行测试、设备或 CI;旧 Ascend03 结果不属于当前 head。

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

PR review verdict — DO NOT PASS

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

Reviewed base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd and head b8f1580ad9626dec6cff69a47501dabee2729429 (the three changes announced in the 2026-11-23T08:35Z comment). This is Dong-bot, authorized delegate for @Dong1017. I did not execute anything.

Blockers

  1. The seeded diff is incomplete. diffComplete: false, and the patch is cut off inside tests/test_parallel_round.py. I could not see tools/parallel_round.py, any docs, or the other changed files. I read the full tests/test_parallel_round.py at the head through read_repo_file. I did not read the rest of the PR from the repo, so I can't PASS the whole change.
  2. No formal APPROVED review exists on this head. The cursor[bot] CHANGES_REQUESTED on 026f686d (review 5931222199) is still listed as outstanding. Its two blockers were host git reading a writable .git, and a validation ConfinementUnavailable being recorded as a measured FAIL. The visible code still addresses both: _tree_identity is used for snapshots, and _confined_trial maps non-timeout ConfinementUnavailable to error. The regressions test_build_planted_git_hooks_do_not_run_on_the_host and test_validation_confinement_failure_stays_unsettled are still there. A formal verdict from that reviewer, or a maintainer dismissing it, is still needed.
  3. No Ready/full-check on this head, and the namespace evidence is for an older head. The author says the Ascend03 run on f6c982e7 does not cover this head. Upstream ubuntu-latest skips the namespace tests under AppArmor. GPU isolation is still unverified.
  4. A second independent current-head LGTM is still missing. My own review is not an independent vote.

Checked in the visible code and tests (not run)

  • Streaming digest. _digest_fd and _stream_copy read in 1 MiB chunks and keep only the digest. The digest covers the executable bits plus the content, so it matches _snapshot.
  • Submit staging. submit copies each changed file into submit-staging/<ticket>. It refuses with changed during submit if the copy's digest differs from the scan, and removes the staging directory in finally. The outbox entry is moved into place only after every file matches.
  • New tests. test_submit_streams_a_file_larger_than_one_chunk, test_submit_refuses_a_file_that_changes_after_the_scan and test_submit_refuses_an_executable_bit_that_changes_after_the_scan match the described behavior.
  • composed shape. Every composed list built in close_round is now {"ticket", "lane_id"} dicts. That covers the deadline, devices unavailable, device_model qualification and unreaped paths. Early refusals (missing receipts, unsettled tickets, frozen-incumbent mismatch) carry no composed key at all, so there is no string-ticket case left. No test asserts the dict shape on the deadline, device-shortage or qualification paths. That is non-blocking, but worth adding.
  • System-Python skip. test_runtime_roots_under_system_python_exclude_usr now probes /usr/bin/python3 and skips when it is older than 3.10.

I found no new code defect in the part I could read. The blockers above are the incomplete diff and the open merge gates. I will re-read once the cursor[bot] state is resolved, Ready/full-check has run on this head, and a second independent LGTM is in. My earlier decision accepting joint single-rerun close as the bounded offline slice stands. It is not #249 M0–M2 acceptance.


@NumberWan

Copy link
Copy Markdown
Author

@amy-why-3459 请再看一次当前 head b8f1580ad9626dec6cff69a47501dabee2729429。

你上次完整阅读是 29c5aa66,结论是 DO NOT PASS。当时挡的「同一 lane 的全部 PASS ticket 都叠进 close」已经改成每条 lane 只留一个胜出者(improvement_pct 较高,同分取较小 ticket),落选的记在 dropped。

这颗 head 另外包括:incumbent 摘要核对、PASS 时晋升实测过的 joint 树、可执行位进摘要并保留、submit 在扫描后内容或执行位变化时拒绝、扫描按 1 MiB 流式计算摘要、composed 一律是 {"ticket","lane_id"}。/usr/bin/python3 低于 3.10 时,系统解释器那条测试会 skip。

Ascend03 的 live namespace 实跑目前停在较早的 f6c982e7(PID 1 那条已通过)。b8f1580a 还没有新的实跑。

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

One final promotion-boundary issue on the current head.

Comment thread src/inferrsi/harness/parallel_round.py Outdated
successor = round_dir / "successor"
if successor.exists():
shutil.rmtree(successor)
shutil.copytree(joint, successor)

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.

Please make promotion copy only the verified snapshot entries and use a no-follow copy. The post-build tree is writable, but the scan excludes repository metadata while this host-side copy traverses it. That makes the promoted tree larger in scope than the verified snapshot. Please assert that excluded metadata is not published and that links are rejected without being followed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed on 510c5a1f01c480ea2e4661c8cc207accd06126e6. Promotion copies only the regular files the snapshot verified, with a no-follow copy. .git is not published, so a symlink planted inside it is not followed. A symlink the scan reports refuses promotion and removes the destination. Covered by test_promotion_does_not_publish_or_follow_repository_metadata and test_promotion_refuses_a_symlink_without_following_it.

@NumberWan

Copy link
Copy Markdown
Author

@cursoragent PTAL

A metadata write that fails must not leave an outbox directory that a retry treats as success. Promotion must copy the files the scan verified, not repository metadata or the target of a symlink.

Signed-off-by: NumberWan <wantszkin2003@gmail.com>
@NumberWan

Copy link
Copy Markdown
Author

@zengchuang-hw @david6666666 兩則都在 510c5a1f01c480ea2e4661c8cc207accd06126e6。

@zengchuang-hw 出箱目錄和旁邊的 metadata 現在是一次發布。metadata 寫失敗會把兩邊都刪掉並回拒絕,重試不會在 serve 仍讀不到票時報成功。目錄還在但 metadata 對不上時,下一次 submit 視為未發布,兩邊重寫之後才回 ticket。回歸是 test_metadata_write_failure_retries_without_a_false_success。

@david6666666 successor 只複製掃描驗證過的普通檔,複製不跟隨連結。.git 不會被發布,裡面的 symlink 也不會被跟進去。掃描會報出的 symlink 會拒絕晉升並刪掉目的地,不會把連結目標讀進 successor。回歸是 test_promotion_does_not_publish_or_follow_repository_metadata 和 test_promotion_refuses_a_symlink_without_following_it。

本機跑了這幾條測試。這顆 head 還沒有在 Ascend03 上跑過。

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

NO PASS
dot, acting for @zengchuang-hw

增量:b8f1580ad9626dec6cff69a47501dabee2729429 → 510c5a1f01c480ea2e4661c8cc207accd06126e6,base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd。上轮 · 作者增量说明。

上轮误报成功已修复。 票据 JSON 写入失败会清理载荷和元数据,重试会识别并重建不完整票据。新增回归覆盖失败后重试;普通写入错误仍标成 symlink,建议改成实际发布错误。

批准前需将 successor 绑定到评估用的摘要。 runner 已留存评估确认的候选指纹,但 close 在 PASS 后只传入目录。新发布函数按后来重扫的快照复制,并不比对评估留存的指纹。正常文件修改若发生在测量结束之后、发布扫描之前,发布内容可与受测内容不同。请在发布时核对该次评估的候选指纹;不匹配就拒绝并不留下 successor。用普通文件变动覆盖这条回归。

静态核对了增量、运行器留存证据和测试源码;未独立执行测试、硬件或 CI。

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

One incomplete-ticket recovery case on the current head.

except (OSError, UnicodeError, json.JSONDecodeError):
return False
return stored == record

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.

Could retry also validate the published payload against the manifest before returning success? A ticket with a matching sidecar but a missing or truncated payload file passes this predicate; retry discards the freshly verified staging copy and returns a ticket that cannot reproduce its submitted content. Please cover a valid sidecar with a missing or modified file and either repair the payload or refuse the ticket.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed on eb918d0a61dfe786b98078919fc652ad545094d7. Retry now hashes every manifest file in the outbox. A matching sidecar with a missing or modified payload is unpublished: the incomplete ticket is removed and replaced from the staging copy that just matched the scan, and only then does submit return success. test_retry_repairs_a_payload_that_does_not_match_the_manifest covers a truncated file and a deleted file.

…d payload

A retry must not accept a sidecar whose payload no longer matches the manifest. Promotion must refuse when the tree no longer matches the candidate fingerprint recorded for that evaluation.

Signed-off-by: NumberWan <wantszkin2003@gmail.com>
@NumberWan

Copy link
Copy Markdown
Author

@zengchuang-hw @david6666666 兩則都在 eb918d0a61dfe786b98078919fc652ad545094d7。

@david6666666 重試會核對 manifest 裡每個檔案的摘要,不再只看 sidecar。sidecar 對得上但檔案缺失或被改過時,這張票視為未發布:清掉不完整的出箱,用剛核對過的暫存重新發布,然後才回成功。test_retry_repairs_a_payload_that_does_not_match_the_manifest 覆蓋截斷和刪檔。

@zengchuang-hw 晉升會讀 repositories.final.json 裡這次評估留下的候選 snapshot_hash。重新掃描的樹對不上就拒絕,並且不留 successor。test_promotion_refuses_a_file_changed_after_measurement 在測量結束後改了一個普通檔。

本機 tests/test_parallel_round.py 已過。這顆 head 還沒有在 Ascend03 上跑過。寫失敗仍沿用既有的 symlink 拒絕原因。

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

PASS
dot, acting for @zengchuang-hw

Reviewed base 214fb400b678db7f03f2d865e3b80c1fbf97d6bd and head eb918d0a61dfe786b98078919fc652ad545094d7; 增量自 510c5a1f01c480ea2e4661c8cc207accd06126e6。上轮。

上轮阻塞已修复:晋升以 runner 留存的本次候选摘要为准,逐文件校验内容和执行位,评估结束后文件变化会拒绝发布且不留 successor。重试也实际核验已存载荷与 manifest,截断或缺失可重建;两条新增回归覆盖这些分支。普通写错误仍可能显示为 symlink,可后续改善诊断,不阻塞这轮。

本轮静态核对了两个增量文件、摘要来源和测试源码。作者报告的本地测试未独立复跑;之前的 Ascend03 回放不是当前 head 的实机验证。未查看 CI,本次仅批准离线 joint single-rerun 切片,不验收 #249 的 stepwise composition,也未合入。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:harness Harness module: profile, A/B loop, quality gates, evidence reports bot-reviewed kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants