Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
98de513
feat(xtask): switch the default branch in a scenario run
yyhhyyyyyy Nov 21, 2026
5015803
test(branch): evaluate the default branch
yyhhyyyyyy Nov 21, 2026
394222d
fix(xtask): fail a scenario run whose switch never fired
yyhhyyyyyy Nov 21, 2026
4c8bb61
fix(branch): scope the former default's probe to the new work
yyhhyyyyyy Nov 21, 2026
372d666
docs(branch): sync the scenario table and evaluation list
yyhhyyyyyy Nov 21, 2026
68f6ce3
fix(xtask): treat a protected switch target as its own outcome
yyhhyyyyyy Nov 21, 2026
b187ed1
style(xtask): format the ended-target test
yyhhyyyyyy Nov 21, 2026
50ea6f7
fix(xtask): switch when the target line starts its first turn
yyhhyyyyyy Nov 22, 2026
2122eec
test(branch): compact at a 29,000-token window
yyhhyyyyyy Nov 22, 2026
39332c6
docs(xtask): follow the new switch trigger in a test comment
yyhhyyyyyy Nov 22, 2026
318d81e
fix(xtask): report a switch the budget stops after its trigger
yyhhyyyyyy Nov 22, 2026
5d1afd8
Merge origin/main into hui/branch-default-eval
yyhhyyyyyy Nov 22, 2026
591ae8b
fix(xtask): keep a triggered switch on the line that started
yyhhyyyyyy Nov 22, 2026
01e5b2a
test(branch): require the new default to open a line
yyhhyyyyyy Nov 22, 2026
631feba
fix(xtask): bound a switch by the scenario deadline
yyhhyyyyyy Nov 22, 2026
8c3c7a1
Merge origin/main into hui/branch-default-eval
yyhhyyyyyy Nov 22, 2026
67a9a85
fix(xtask): bound a timed-out run's cleanup
yyhhyyyyyy Nov 22, 2026
0bcc797
fix(xtask): keep a timed-out run's stop if its window read fails
yyhhyyyyyy Nov 22, 2026
b2e13c6
fix(xtask): skip judging a timed-out run whose close did not settle
yyhhyyyyyy Nov 22, 2026
2c7b46a
fix(xtask): bound the parent's read of an exited child's output
yyhhyyyyyy Nov 22, 2026
20ae944
test(xtask): give the stdout-holder test a wider hang guard
yyhhyyyyyy Nov 22, 2026
e3dbd75
test(xtask): hold the stdout-holder member past its guard
yyhhyyyyyy Nov 22, 2026
4a5851b
fix(xtask): bound a timed-out run's judge
yyhhyyyyyy Nov 22, 2026
615f2b8
test(xtask): give the judge-bound test a wider hang guard
yyhhyyyyyy Nov 22, 2026
7747f4f
fix(xtask): bound a timed-out run's whole cleanup
yyhhyyyyyy Nov 22, 2026
72d13a5
fix(xtask): cover the judge's own wait budget in the parent bound
yyhhyyyyyy Nov 22, 2026
4129e21
test(xtask): shorten the stalled-export case's own setup
yyhhyyyyyy Nov 22, 2026
8e61cff
test(xtask): give the subprocess flows one hang guard
yyhhyyyyyy Nov 22, 2026
4560a5d
test(xtask): give the judged flow the shared guard and bound
yyhhyyyyyy Nov 22, 2026
fad1ece
fix(xtask): record the supervisor's endings apart from the run's own
yyhhyyyyyy Nov 22, 2026
0e1d2f0
fix(xtask): read the run's ending past the harness prefix
yyhhyyyyyy Nov 22, 2026
e735629
test(xtask): pin the join bound and the export ending rule
yyhhyyyyyy Nov 22, 2026
7450169
docs(xtask): state what an unfinished judge phase keeps
yyhhyyyyyy Nov 22, 2026
e321f4a
docs(xtask): say where the switch retry waits
yyhhyyyyyy Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/design/model-prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ SessionTitle is out of scope: its `SYSTEM` (`crates/dim-session-title/src/lib.rs

- **Protocol.** The marker names and attributes, the identity blocks' factual sentences, the branch tool's actions and modes, and its refusal codes change only with the branch mechanism, in the same change as the flow tests that assert them (§4).
- **The coordination text for `main` covers the items of [Timeline branches §12.2](timeline-branches.md#122-items-for-the-prompt-layer-429).**
- **Evaluation.** These texts are policy: a change is evaluated with the scenarios of [Timeline branches §12.3](timeline-branches.md#123-evaluation-scenarios) — redone work, over-splitting, flooding, never ending, sibling relay, ping-pong, identity after compaction, asking the user — current against candidate (§8).
- **Evaluation.** These texts are policy: a change is evaluated with the sixteen scenarios of [Timeline branches §12.3](timeline-branches.md#123-evaluation-scenarios), current against candidate (§8).

### 9.5 Goal

Expand Down Expand Up @@ -253,6 +253,7 @@ SessionTitle is out of scope: its `SYSTEM` (`crates/dim-session-title/src/lib.rs
**Owner:** the evaluation tooling, `xtask`; implemented under [#550](https://github.com/arcships/dim/issues/550).

- **A scenario runner** with the candidate injection and the test of §8.1: the scenarios are the cases, both arms run the shipped assembly, and the result is reported in the pull request. It interleaves the arms run by run and accepts `--jobs` and repeated `--text`/`--candidate` pairs, so a change that spans two texts of one owner is judged as the one change it is (Goal §A.5.2).
- **A scenario may move the default branch mid-run.** Its `switch` step names the target line, by role (`latest_tool_line`) or id, and the runner calls `session.branch_set_default` at that line's first `turn/start` before sending the next input; the move is retried a few times while the line is not registered yet, and a line that never registers ends the run with its own outcome. An input that names no line lands on the default branch, and one that names a line keeps that target.
- **A finished evaluation's saved runs are judged again or pooled.** `--rejudge DIR` judges them from the views they saved, with no model turn, keeping each run's own outcome and writing to a new `--out`; `--pool DIR` adds a finished evaluation's saved runs to a report under the same rule and format, and the flag may be repeated to pool several evaluations, writing to none of them, and an `--out` that resolves inside a source, through `..` or a link, is refused before anything is created. Such a report names its sources, has no text or candidate-token row, and in a pool its model and judge rows are the ones given, while each source's own report states the instrument its runs were judged with. Such a report also gives the declines the runner sent again and how many runs did not record it.
- **A run's file roots.** Each live run serves with three kinds of file-tool root: its workspace, which the model may read and write; its disposable home, which `~` resolves against and which the model may read; and the platform's fixed read-only roots, which carry the toolchain the run's commands read, such as the interpreter's own installation. A file-tool path outside them is refused with `outside_file_roots`, and the refusal leaves what is outside untouched. The roots bound the model's file-tool calls — `read`, `write`, `edit`, `glob` and `grep`; `exec` is bounded by the sandbox, and the client-initiated paths, `@` mention expansion and the App Server's `session.files.*` methods, are not calls the model makes and stay outside the roots.
- **No absolute pass line and no CI run** (§8.1).
Expand Down
5 changes: 4 additions & 1 deletion docs/design/timeline-branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,12 @@ The requirements that answer these items are in [Model-facing prompts](model-pro

### 12.3 Evaluation scenarios

The set lives in the repository, one directory per scenario, holding a `scenario.json` and the starting `workspace/` beside it: eight under [`xtask/scenario-eval/timeline-branches/`](../../xtask/scenario-eval/timeline-branches/), each declaring a window of 131,072 tokens, and `identity-after-compaction` under [`xtask/scenario-eval/timeline-branches-compact/`](../../xtask/scenario-eval/timeline-branches-compact/), declaring 16,000 so that compaction happens. `budget.window` is a check, not a setting: a run whose Session declares another window fails before its first turn, so a rerun needs a model that declares exactly the scenario's window, and a model that declares none falls back to 128,000 and fails too. These are run locally on real models, and the results are reported in the implementation PR. CI asserts only behavior.
The set lives in the repository, one directory per scenario, holding a `scenario.json` and the starting `workspace/` beside it: fifteen under [`xtask/scenario-eval/timeline-branches/`](../../xtask/scenario-eval/timeline-branches/), each declaring a window of 131,072 tokens, and `identity-after-compaction` under [`xtask/scenario-eval/timeline-branches-compact/`](../../xtask/scenario-eval/timeline-branches-compact/), declaring 29,000 so that compaction happens. `budget.window` is a check, not a setting: a run whose Session declares another window fails before its first turn, so a rerun needs a model that declares exactly the scenario's window, and a model that declares none falls back to 128,000 and fails too. These are run locally on real models, and the results are reported in the implementation PR. CI asserts only behavior.

`main-moved-on` is the scenario for the parent block (§7.1.1): `main` works before the cut, opens a line, then keeps working; the line must read what `main` did after the cut before it answers or ends, and it must not page through all of `main`'s activity. It is the scenario for [§12.4](#124-texts-and-their-classes)'s parent-block policy sentence.

The opening and switching roles add seven scenarios: `long-work-and-a-flaky-test`, `refactor-and-a-pasted-report`, `same-file-tradeoff`, `background-command-not-branch`, `switch-continue-directly`, `switch-then-open-lines` and `root-opens-after-switch`.

`identity-after-compaction` reuses `redone-work`'s message and workspace, and `flooding` and `never-ending` share one workspace: each pair stays identical, and the no-model test that reads both committed directories fails when one copy changes alone.

| Scenario | Scenario directory | Watch for |
Expand All @@ -530,6 +532,7 @@ The set lives in the repository, one directory per scenario, holding a `scenario
| Sibling relay | `timeline-branches/sibling-relay` | An opener is used to pass messages between lines that should have been one line |
| Identity after compaction | `timeline-branches-compact/identity-after-compaction` | After compaction on `main` and on a line, each still knows which line it is and which lines are its own |
| Continuing on a line after a switch | `—` | A line that became the default branch calls `end` on itself, hands its work to another line, keeps waking its opener with idle notices, or cannot open a line while the root could |
| Opening lines after a switch | `timeline-branches/switch-then-open-lines` | The new default branch does both independent additions itself instead of opening a line for one of them, or the former default branch takes the new work |
| The root opens while a line holds the role | `timeline-branches/root-opens-after-switch` | The user asks the root for a line after another line became the default branch: the root must open it, the new line must start from the root's history, and it must report to the root |
| Ping-pong | `timeline-branches/ping-pong` | Steer exchanges that do not move the work forward |
| Asking the user | `timeline-branches/asking-the-user` | A line asks the user directly when it should, and does not route through `main` |
Expand Down
3 changes: 2 additions & 1 deletion docs/zh/design/model-prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ SessionTitle 不在范围内:它的 `SYSTEM`(`crates/dim-session-title/src/l

- **协议。** 标记名与属性、身份块里的事实句、branch 工具的 action 与 mode、以及它的拒绝码,只随分支机制一起改,并与断言它们的流程测试同一个改动(§4)。
- **`main` 的协调文字覆盖 [Timeline 分支 §12.2](timeline-branches.md#122-交给提示词层的事项429) 的事项。**
- **评估。** 这些文字是策略:改动用 [Timeline 分支 §12.3](timeline-branches.md#123-评估场景) 的场景评估——重做工作、过度拆线、刷屏、不肯结束、兄弟转达、乒乓、压缩后的身份、直接问用户——当前对照候选(§8)。
- **评估。** 这些文字是策略:改动用 [Timeline 分支 §12.3](timeline-branches.md#123-评估场景) 的十六个场景评估,当前对照候选(§8)。

### 9.5 Goal

Expand Down Expand Up @@ -252,6 +252,7 @@ SessionTitle 不在范围内:它的 `SYSTEM`(`crates/dim-session-title/src/l
**所有者:** 评估工具,`xtask`;在 [#550](https://github.com/arcships/dim/issues/550) 下实现。

- **一个场景运行器**,带 §8.1 的候选注入与检验:场景即用例,两臂都跑 shipped 装配,结果写进 PR。它逐次交错两臂,并接受 `--jobs` 与重复的 `--text`/`--candidate` 对,因此一个跨同一所有者两段文本的改动按它本来就是的一次改动来判定(Goal §A.5.2)。
- **场景可以在运行中途移动默认分支。** `switch` 步骤按角色(`latest_tool_line`)或 id 指定目标线;运行器在那条线第一次 `turn/start` 时、发下一条输入之前调用 `session.branch_set_default`。线还没注册好时,移动会有限次重试;始终注册不上的线让这次运行以自己的结局结束。不点名线的输入落到默认分支,点名线的输入仍以那个目标为准。
- **已完成评估的运行可以重判,也可以合并报告。** `--rejudge DIR` 按这些运行保存的视图重新判定,不产生模型轮次,保留每次运行自身的结局,写入新的 `--out`;`--pool DIR` 把一次已完成评估的运行加入报告,该参数可以重复给出,从而把多次已完成评估的运行按同一规则与同一格式一起报告,不写入其中任何一个,而解析后落在某个来源内部的 `--out`(经由 `..` 或链接)会在创建任何东西之前被拒绝。这样的报告会列出它的来源,没有 text 行与 candidate-token 行;合并报告里的 model 与 judge 两行是收到的参数,每个来源自己的报告才写着它的运行是凭什么判的。这样的报告还会给出再次发送 decline 的次数,以及有多少运行没有记录该次数。
- **一次运行的文件根。** 每个 isolate 运行都以三类文件工具根提供服务:工作区,模型可读可写;一次性 home,`~` 解析到它,模型可读;以及平台固定的只读根,承载运行的命令要读取的工具链,例如解释器自身的安装目录。文件工具路径落在这些根之外时以 `outside_file_roots` 拒绝,且拒绝不触碰根外的任何内容。这些根约束模型的文件工具调用——`read`、`write`、`edit`、`glob`、`grep`;`exec` 由沙箱约束,而客户端发起的路径(`@` 提及展开与 App Server 的 `session.files.*` 方法)不是模型发起的调用,不在根内。
- **不用绝对通过线,不进 CI**(§8.1)。
Expand Down
8 changes: 6 additions & 2 deletions docs/zh/design/timeline-branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,18 +476,19 @@ WorkspaceTools 不变。

### 12.3 评估场景

场景放在仓库里,一个场景一个目录,目录里是 `scenario.json` 和它旁边的起始 `workspace/`:八个在 [`xtask/scenario-eval/timeline-branches/`](../../../xtask/scenario-eval/timeline-branches/) 下,各自声明 131,072 tokens 的窗口;`identity-after-compaction` 在 [`xtask/scenario-eval/timeline-branches-compact/`](../../../xtask/scenario-eval/timeline-branches-compact/) 下,声明 16,000,以便发生压缩。`budget.window` 是校验而不是设置:Session 声明的窗口与之不同时,这次运行在第一轮之前就失败,所以复跑需要模型声明正好这个窗口;没有声明窗口的模型回退到 128,000,同样失败。这些场景在本地用真实模型运行,结果在实现 PR 里报告。CI 只断言行为。
场景放在仓库里,一个场景一个目录,目录里是 `scenario.json` 和它旁边的起始 `workspace/`:十五个在 [`xtask/scenario-eval/timeline-branches/`](../../../xtask/scenario-eval/timeline-branches/) 下,各自声明 131,072 tokens 的窗口;`identity-after-compaction` 在 [`xtask/scenario-eval/timeline-branches-compact/`](../../../xtask/scenario-eval/timeline-branches-compact/) 下,声明 29,000,以便发生压缩。`budget.window` 是校验而不是设置:Session 声明的窗口与之不同时,这次运行在第一轮之前就失败,所以复跑需要模型声明正好这个窗口;没有声明窗口的模型回退到 128,000,同样失败。这些场景在本地用真实模型运行,结果在实现 PR 里报告。CI 只断言行为。

`main-moved-on` 是父线块(§7.1.1)的场景:`main` 在切点之前有工作,开一条线,然后继续工作;这条线在回答或结束之前必须读取 `main` 在切点之后做的事,并且不能逐页读遍 `main` 的全部活动。它是 [§12.4](#124-文本及其类别) 父线块策略句的场景。

开线与切换角色新增七个场景:`long-work-and-a-flaky-test`、`refactor-and-a-pasted-report`、`same-file-tradeoff`、`background-command-not-branch`、`switch-continue-directly`、`switch-then-open-lines`、`root-opens-after-switch`。

`identity-after-compaction` 沿用 `redone-work` 的消息和 workspace,`flooding` 与 `never-ending` 共用同一个 workspace:这两对保持完全相同,改动其中一份而不同步另一份时,读取两个提交目录的无模型测试会失败。

| 场景 | 场景目录 | 关注什么 |
| --- | --- | --- |
| 线把自己当成默认分支 | — | 不是默认分支的线把 Session 的对话当成自己的、无视自己可以开线,或者已经是默认分支的线不再向开它的那条线汇报 |
| 线在不能开线的地方开线 | — | 既不是根也不是当前默认分支的线自己开线,而不是告诉其中一条 |
| 上限与那条路径 | — | Session 已经超过上限时线仍拒绝开线,或者为腾位置关闭一条线 |
| 线把自己当成默认分支 | — | 不是默认分支的线把 Session 的对话当成自己的,或者已经是默认分支的线不再向开它的那条线汇报 |
| 重复劳动 | `timeline-branches/redone-work` | `main` 重做一条线正在做的事,或者两条线做同一件事 |
| 过时的认识 | — | 一条线依据切点之后已经改变的文件或决定行事,却没有重新读取 |
| 父线动了 | `timeline-branches/main-moved-on` | 一条线在回答或结束前没有读取父线在切点之后提交的活动,或者逐页读遍了父线的全部活动 |
Expand All @@ -496,6 +497,9 @@ WorkspaceTools 不变。
| 不结束 | `timeline-branches/never-ending` | 一条线已经做完,却不调用 `end` |
| 兄弟中转 | `timeline-branches/sibling-relay` | 用 `main` 在本该合成一条线的几条线之间传话 |
| 压缩后的身份 | `timeline-branches-compact/identity-after-compaction` | `main` 和某条线各自压缩之后,仍知道自己是哪条线、哪些线是自己的 |
| 切换后继续在线上工作 | — | 成为默认分支的线对自己调用 `end`、把工作交给另一条线、不断用 idle 通知唤醒开它的线,或者根能开线而这条线不能 |
| 切换后开线 | `timeline-branches/switch-then-open-lines` | 新的默认分支自己做掉两处互不相干的新增,而不是为其中一处开一条线;或者原默认分支接过新工作 |
| 线持有角色时根开线 | `timeline-branches/root-opens-after-switch` | 另一条线成为默认分支后,用户向根要一条线:根必须开这条线,新线必须从根的历史开始,并向根汇报 |
| 来回空转 | `timeline-branches/ping-pong` | 不推进工作的 steer 往复 |
| 问用户 | `timeline-branches/asking-the-user` | 该问用户时,线直接问用户,而不是绕道 `main` |

Expand Down
2 changes: 2 additions & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ axum = { workspace = true, features = ["json"] }
[target.'cfg(unix)'.dependencies]
libc = "0.2.189"
[dev-dependencies]
# The cleanup tests drive the runner's own deadlines on a paused clock.
tokio = { workspace = true, features = ["test-util"] }

[lints]
workspace = true
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "The same two-subsystem task on a small window, so main and its line compact and must still know which line they are",
"message": "Two independent subsystems need building in this project, and each has its own failing test suite:\n\n- parser/ — the integer expression parser specified in parser/expr.py\n- cache/ — the bounded LRU cache with TTL specified in cache/lru.py\n\nThey share no code and do not touch the same files. Make `python3 -m unittest discover -s tests` pass for both, and keep the implementations to their specs.",
"budget": {"turns": 30, "seconds": 900, "window": 16000},
"budget": {"turns": 30, "seconds": 900, "window": 29000},
"probes": [
{"id": "identity-after-compaction", "kind": "must_show", "text": "after a compaction, main's next request still carries its roster of open lines and a line's next request still carries its own identity block"},
{"id": "line-stays-a-line", "kind": "must_not_show", "text": "after a compaction a line acts as if it were main or forgets which line it is"}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"description": "A slow command and a small bug fix; a background command is not a line",
"message": "Run `python3 scripts/slow_audit.py` and report what it finds. Also fix the leap-year bug in src/date_util.py and add the missing test in tests/test_date_util.py. Do not change anything else.",
"budget": {"turns": 20, "seconds": 600, "window": 131072},
"probes": [
{"id": "report-read", "kind": "must_show", "text": "the output of python3 scripts/slow_audit.py is reported to the user"},
{"id": "bug-fixed-with-test", "kind": "must_show", "text": "is_leap handles century years correctly and tests/test_date_util.py covers it"},
{"id": "no-line-for-the-command", "kind": "must_not_show", "text": "a branch line is opened to run or watch the audit command"}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ops-tools

- `scripts/slow_audit.py`: the storage audit; it takes a few seconds.
- `src/date_util.py`: calendar helpers.

Run the tests with `python3 -m unittest discover -s tests`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""A deliberately slow audit, so the caller has to wait for its report."""

import time


def main():
time.sleep(5)
print("slow_audit: 3 stale locks, 1 orphaned temp file, 0 missing indexes")


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Calendar helpers."""


def is_leap(year):
"""Returns whether the year has 366 days."""
return year % 4 == 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import sys
import unittest

sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src"))

from date_util import is_leap


class DateUtilTest(unittest.TestCase):
def test_ordinary_leap_year(self):
self.assertTrue(is_leap(2024))

def test_non_leap_year(self):
self.assertFalse(is_leap(2023))


if __name__ == "__main__":
unittest.main()
Loading