diff --git a/AGENTS.md b/AGENTS.md index da1e5c9..58cbe9c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -415,7 +415,7 @@ Parent。此时 `boot_once` 为空。忽略 `next_action` 再调 `swarm_tick` `preserve_pending=true`、`abandon_run=false`、 `action_required=swarm_solidify`(boot/status 在仍要固化时同样带上)。有软缺口时, 第一次 tick 与保险丝都不带 `gate_soft_continue`(缺席不是 false;`ok` 第一次仍为 true, -没有 `error`;`tick_again=false` 表示不要再 tick)。两次 tick 都带 +没有 `error`;`tick_again=false` 与 `retryable=false` 都表示不要再 tick,第一次也写 `retryable=false`,缺席不再当成可以再 tick)。两次 tick 都带 `session_not_failed=true`:先读它,会话没有失败。`loop_fuse` 不在 `error` 里, preserve 三元组仍指向 `swarm_solidify`。 boot/status 的 `gate_soft_continue` 仍为 true,且不带 `session_not_failed`。 diff --git a/CHANGELOG.md b/CHANGELOG.md index c53cfc8..59a3b67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Fixed +- **MCP 宿主可用性:未完成 run 的第一次 tick 重定向也写 `retryable=false`**:同一条未完成 run 的两次默认 `swarm_tick` 都带 `retryable=false`。缺席不再被读成「可以再 tick」。第一次仍是 `ok=true`、没有 `error`、`gate_soft_continue` 仍缺席(缺席不是 false,不把严格 false 当成整段会话失败)。保险丝仍是 `ok=false` 与 `loop_fuse=pending_redirect_loop`。不写 Parent baseline,不放宽固化门。 - **2000 字现场切片留住未跟踪新文件(DEBUG #57 续)**:失败 episode 与成功事件不再对 `capture_diff_snapshot` 的结果做 `[:2000]`。两臂都传入 `max_chars=2000`,截断在 helper 内完成。已跟踪 diff 会占满预算时,先裁跟踪前缀,固定留 480 字(不超过预算的四分之一)给未跟踪新文件块;没有合格未跟踪文件时,这截尾部还给跟踪 diff。返回长度不超过预算。`.venv` / `node_modules` / `__pycache__` / `.git` / 受保护文件 / `memory/`、`.evolver/` 等运行态目录 / 含 NUL 的二进制仍不进入补充。不改固化门,不写 Parent baseline,不开 val 密封。 - **失败现场 diff 包含未跟踪新文件(DEBUG #57)**:`capture_diff_snapshot` 在 `git diff HEAD` 之后追加未跟踪新文件的 unified diff。失败侧 `_failure_diff` 与成功侧共用这一 helper。依赖树、缓存、运行态目录、受保护路径和含 NUL 的二进制不进入这份补充。不改固化门,不写 Parent baseline,不开 val 密封。 diff --git a/DEBUG.md b/DEBUG.md index d405569..14caf77 100644 --- a/DEBUG.md +++ b/DEBUG.md @@ -61,6 +61,7 @@ | 56 | 全量回归一次性失败无留存:36% 处红灯后无失败名留存,lastfailed 37 条 id 全陈旧、`--lf` 零命中静默变全量 | tests/测试治理 | 评估会话 | 未发版 | | 57 | 失败现场 diff 看不见未跟踪文件:MCP 验证脚本新建 notes.md 走拒绝后 episode diff 为空,成功侧同 helper 同盲区(未修,待单独一轮) | solidify/episode | 评估会话 | 未发版 | | 58 | 外部 MCP 评审 P1 四项全属实并修:solidify/propose 未取实例锁、journal 裸句柄、instructions 漏新工具、测试名实不符 + 版本硬编码 | swarm/mcp/tests | 评估会话 | 未发版 | +| 69 | 未完成 run 的第一次 tick 重定向不写 `retryable`,缺席被当成再 tick | mcp/swarm | MCP 易用性 | 未发版 | ## 条目 @@ -1213,6 +1214,13 @@ - **修复**:常驻 instructions 改成 `loop_fuse=pending_redirect_loop`,不写 `error=pending_redirect_loop`,也不把裸码当成 `next_action`,长度仍小于 1200。保险丝(无软缺口的早返回,以及有软缺口的返回)把 `redirect_reason` 写成 `pending_redirect_loop`。`dispatch_reason` 仍是 `pending_solidify`。`loop_fuse`、`ok=false`、`error` 缺席、`session_not_failed=true`、preserve 三元组、`tick_again=false` 不动。有软缺口时仍不写 `gate_soft_continue`。第一次重定向的 `redirect_reason` 仍是 `pending_solidify`,没有 `loop_fuse`。`next_action` 仍是 `swarm_solidify`。不写 Parent baseline,不放宽固化门。目录缓存(DEBUG #61)未做假修复。 - **经验**:**字段名要和码一起出现。** 裸码会被读成 `next_action`。`error` 不能再写回这个码,否则「任意 error 即放弃」的宿主又会丢掉 run。非失败的原因字段是保险丝上的 `redirect_reason`。 - **仍在的宿主摩擦**(#20 的 1、2、4,这次没有关): - 1. 把缺席的 `gate_soft_continue` 当成「继续 tick」(只在严格 false 时才停),并且不看 `tick_again` / `next_action` / `ok` 的宿主,仍可能再 tick。保险丝上 `ok=false` 仍能停住只看 `ok` 的宿主。 - 2. 把 `ok=false` 本身当成整段会话失败、且不读 `session_not_failed` 与 `loop_fuse` 的宿主,仍会在第二次 tick 上停掉会话。`ok=false` 留着,是因为只看 `ok` 的宿主靠它停止空转。 + 1. 把缺席的 `gate_soft_continue` 当成「继续 tick」(只在严格 false 时才停),并且不看 `tick_again` / `next_action` / `ok` / `retryable` 的宿主,仍可能再 tick。保险丝上 `ok=false` 仍能停住只看 `ok` 的宿主。`retryable=false` 能停住「缺席即再 tick、严格 false 才停」这一型里读这个字段的宿主(见 #69),但不能靠把 `gate_soft_continue` 写成 false 来停——那会让不读 `session_not_failed` 的宿主把整段会话判死。 + 2. 把 `ok=false` 本身当成整段会话失败、且不读 `session_not_failed` 与 `loop_fuse` 的宿主,仍会在第二次 tick 上停掉会话。`ok=false` 留着,是因为只看 `ok` 的宿主靠它停止空转。第一次重定向仍是 `ok=true`。 4. 宿主 `tools/list` 缓存滞后(DEBUG #61)没有做假修复。安全信号在返回体上。 + +### 69. 第一次 tick 重定向不写 `retryable`,缺席被当成再 tick(MCP 易用性,已修) + +- **症状**:#68 之后,有软缺口的第一次 `swarm_tick` 重定向不带 `gate_soft_continue`,`ok=true`,`tick_again=false`,`next_action=swarm_solidify`,并且没有 `retryable`。常驻 instructions 写 `retryable=true: swarm_tick again`。把缺席的继续位当成「再 tick」、只在严格 false 时才停、同时不看 `tick_again` / `next_action` / `ok` 的宿主,会再 tick 一次,落到保险丝的 `ok=false`。只看 `gate_soft_continue`、完全不读 `retryable` 的宿主仍会再 tick:把那个键写成 false 会让「任意严格 false 即整段会话失败、且不读 `session_not_failed`」的宿主在第一次就停掉会话。 +- **根因**:保险丝写了 `retryable=false`,第一次重定向没写。缺席不是 false。`gate_soft_continue` 不能借来当停 tick 的 false,那个名字在不读旁注的宿主那里就是会话失败。 +- **修复**:未完成 run 的两次默认 tick(有软缺口与无软缺口)都写 `retryable=false`。第一次仍是 `ok=true`、没有 `error`、没有 `loop_fuse`,`gate_soft_continue` 在软缺口上仍然缺席。`session_not_failed=true` 与 preserve 三元组不动。保险丝仍是 `ok=false`。不写 Parent baseline,不放宽固化门。目录缓存(DEBUG #61)未做假修复。 +- **经验**:**停 tick 的严格 false 要写在本来就表示「要不要再试」的字段上。** `gate_soft_continue=false` 和第一次就翻 `ok=false` 都会被另一类宿主读成整段失败。`retryable` 缺席必须当成「未说可以再 tick」,写上 false 才盖住把缺席默认成继续的那一型。只认 `gate_soft_continue` 的宿主这次仍覆盖不到。 diff --git a/README.md b/README.md index 0b70f94..ca986ed 100644 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ After `uv sync`, a pull, or any install, **restart the MCP server**. A long-live Live `tools/list` already publishes `swarm_tick` parameters `prompt_mode` (`full` or `short`) and `checklist_only`, with descriptions on those fields, and read-only `swarm_doctor`. A host catalog that still lists only `agent_name` and `include_prompt`, or that cannot find `swarm_doctor`, is a stale client session. Restarting the server reloads the code; start a new host session so the client reads `tools/list` again. -If a previous run is unfinished, `swarm_boot` keeps `next_action=swarm_solidify`, sets top-level `pending_solidify`, and adds `readonly_smoke` (`tools`: `swarm_doctor` and `swarm_status`, `settles_run`: false). `hint` says to solidify first. A soft gap (`no_baseline` / `pack_absent` / `unmeasured`) still attaches `warning` and `next_steps`, and it does not replace that hint or weaken the gate. A read-only smoke can call `swarm_doctor` or `swarm_status`; neither settles the run nor invents a Parent baseline. A `swarm_tick` in that state does not start a cycle. The first call stays soft (`ok` true, `severity` soft, `cycle_started` false, `progress` false, `redirect_count` 1, `next_action` still `swarm_solidify`, `last_run` unchanged). The same call again on that run returns `ok` false, `loop_fuse=pending_redirect_loop`, `redirect_reason=pending_redirect_loop`, `severity` soft, `retryable` false, and no `error` field. It still does not start a cycle. `loop_fuse` and that `redirect_reason` are the tick-loop fuse. The code is not an `error` and not a `next_action`. `next_action` stays `swarm_solidify`. `dispatch_reason` stays `pending_solidify`. The first redirect keeps `redirect_reason=pending_solidify` and does not set `loop_fuse`. Connect-time instructions name `loop_fuse=pending_redirect_loop` the same way. The fuse is not a gate failure and not an abandon signal; a soft gap stays on `warning` and `next_steps`. Both returns set `preserve_pending` true, `abandon_run` false, and `action_required` to `swarm_solidify` (boot and status do too while solidify is still next). Do not drop the unfinished run. When a soft gap is present, `gate_soft_continue` is omitted on the first redirect and on the fuse (`tick_again` is false). Omitted is not false: the first redirect keeps `ok` true and sets no `error`, so a host that treats only a strict false as session death stays in the session and does not tick again. Both tick returns set `session_not_failed` true. Read that field before other flags: true means the session is not failed, and `loop_fuse` does not abandon the run when the preserve flags say to call `swarm_solidify`. `next_steps` starts with `swarm_solidify`. Boot and status keep `gate_soft_continue` true while a run is still unfinished, and they do not set `session_not_failed`. Pass `supersede_pending=true` to replace that run. Pause and the compaction checkpoint still refuse the cycle. +If a previous run is unfinished, `swarm_boot` keeps `next_action=swarm_solidify`, sets top-level `pending_solidify`, and adds `readonly_smoke` (`tools`: `swarm_doctor` and `swarm_status`, `settles_run`: false). `hint` says to solidify first. A soft gap (`no_baseline` / `pack_absent` / `unmeasured`) still attaches `warning` and `next_steps`, and it does not replace that hint or weaken the gate. A read-only smoke can call `swarm_doctor` or `swarm_status`; neither settles the run nor invents a Parent baseline. A `swarm_tick` in that state does not start a cycle. The first call stays soft (`ok` true, `severity` soft, `cycle_started` false, `progress` false, `redirect_count` 1, `retryable` false, `next_action` still `swarm_solidify`, `last_run` unchanged). An omitted `retryable` is not a license to tick again. The same call again on that run returns `ok` false, `loop_fuse=pending_redirect_loop`, `redirect_reason=pending_redirect_loop`, `severity` soft, `retryable` false, and no `error` field. It still does not start a cycle. `loop_fuse` and that `redirect_reason` are the tick-loop fuse. The code is not an `error` and not a `next_action`. `next_action` stays `swarm_solidify`. `dispatch_reason` stays `pending_solidify`. The first redirect keeps `redirect_reason=pending_solidify` and does not set `loop_fuse`. Connect-time instructions name `loop_fuse=pending_redirect_loop` the same way. The fuse is not a gate failure and not an abandon signal; a soft gap stays on `warning` and `next_steps`. Both returns set `preserve_pending` true, `abandon_run` false, and `action_required` to `swarm_solidify` (boot and status do too while solidify is still next). Do not drop the unfinished run. When a soft gap is present, `gate_soft_continue` is omitted on the first redirect and on the fuse (`tick_again` is false). Omitted is not false: the first redirect keeps `ok` true and sets no `error`, so a host that treats only a strict false as session death stays in the session and does not tick again. Both tick returns set `session_not_failed` true. Read that field before other flags: true means the session is not failed, and `loop_fuse` does not abandon the run when the preserve flags say to call `swarm_solidify`. `next_steps` starts with `swarm_solidify`. Boot and status keep `gate_soft_continue` true while a run is still unfinished, and they do not set `session_not_failed`. Pass `supersede_pending=true` to replace that run. Pause and the compaction checkpoint still refuse the cycle. A cold `swarm_status` (this process has not called `swarm_boot`) returns `next_action=swarm_boot` and a short hint. After boot, status keeps `agent_name`, `source_revision`, and any soft `gap` / warnings. `tool_asset_search`, `tool_mailbox_poll`, `tool_cycle_timeline`, and `swarm_approvals` always return `{ok, items, hint}` — an empty match is not a blank body. `swarm_approvals` also keeps `pending` (the same rows as `items`) and `recent`. Read-only `swarm_doctor` mirrors `evolver doctor` without `--fix` (`ok`, soft warnings, command hints in `fixes`). `no_baseline` / `pack_absent` / `unmeasured` stay soft-continue. diff --git a/README.zh.md b/README.zh.md index c4116d2..c2649e4 100644 --- a/README.zh.md +++ b/README.zh.md @@ -277,7 +277,7 @@ uv run evolver migrate-state soft-accept 选用 minimal T0 探针(`determine_t0_mode` 返回 `minimal`;`skip` 也已实现)。验收钩子(`solidify_hook`)在本轮已标 `soft_accept` 时按这个深度跑。硬接受仍跑完整 T0。若结算裁决带了 skip 或 minimal 探针,warnings 里会有 `t0_skipped_soft` 或 `t0_probe=minimal`。 -`pending_solidify` 仅在 `last_run.run_id` 与 `last_solidify.run_id` 不同时为真。成功的 solidify(含 soft-accept)会写下 `last_solidify`,下一次 status 或 boot 报告 `pending_solidify: false`,开局动作回到 `swarm_tick`。仍有待固化 run 时,`boot_once` 为空,宿主先固化。此时再调 `swarm_tick` 默认不启新周期。第一次仍是软返回(`ok` 为 true,`severity=soft`,`cycle_started=false`,`progress=false`,`redirect_count=1`,`next_action` 仍是 `swarm_solidify`,不改 `last_run`)。同一条 run 再 tick 返回 `ok=false`、`loop_fuse=pending_redirect_loop`、`redirect_reason=pending_redirect_loop`、`severity=soft`、`retryable=false`,并且没有 `error` 字段,仍然不启周期。`loop_fuse` 与这个 `redirect_reason` 是 tick 空转保险丝,不是 `error`,也不是 `next_action`。`next_action` 仍是 `swarm_solidify`。`dispatch_reason` 仍是 `pending_solidify`。第一次重定向的 `redirect_reason` 仍是 `pending_solidify`,没有 `loop_fuse`。常驻 instructions 写 `loop_fuse=pending_redirect_loop`。这不是门禁失败,也不是放弃;软缺口留在 `warning` 与 `next_steps`。两次返回都带 `preserve_pending=true`、`abandon_run=false`、`action_required=swarm_solidify`(boot 与 status 在仍要固化时同样带上)。不要丢掉这条未完成 run。有软缺口时,第一次 tick 与保险丝都不带 `gate_soft_continue`(缺席不是 false;`ok` 第一次仍为 true,没有 `error`;`tick_again=false` 表示不要再 tick)。只把严格 false 当成整段会话失败的宿主因此不会停掉会话。两次 tick 都带 `session_not_failed=true`:先读这个字段,会话没有失败;`loop_fuse` 不在 `error` 里,preserve 三元组仍指向 `swarm_solidify`。`next_steps` 第一条是调用 `swarm_solidify`。boot 与 status 的 `gate_soft_continue` 仍为 true,且不带 `session_not_failed`。要替换这条 run 才传 `supersede_pending=true`。暂停与压缩检查点仍优先于这个参数。 +`pending_solidify` 仅在 `last_run.run_id` 与 `last_solidify.run_id` 不同时为真。成功的 solidify(含 soft-accept)会写下 `last_solidify`,下一次 status 或 boot 报告 `pending_solidify: false`,开局动作回到 `swarm_tick`。仍有待固化 run 时,`boot_once` 为空,宿主先固化。此时再调 `swarm_tick` 默认不启新周期。第一次仍是软返回(`ok` 为 true,`severity=soft`,`cycle_started=false`,`progress=false`,`redirect_count=1`,`next_action` 仍是 `swarm_solidify`,不改 `last_run`)。同一条 run 再 tick 返回 `ok=false`、`loop_fuse=pending_redirect_loop`、`redirect_reason=pending_redirect_loop`、`severity=soft`、`retryable=false`,并且没有 `error` 字段,仍然不启周期。`loop_fuse` 与这个 `redirect_reason` 是 tick 空转保险丝,不是 `error`,也不是 `next_action`。`next_action` 仍是 `swarm_solidify`。`dispatch_reason` 仍是 `pending_solidify`。第一次重定向的 `redirect_reason` 仍是 `pending_solidify`,没有 `loop_fuse`。常驻 instructions 写 `loop_fuse=pending_redirect_loop`。这不是门禁失败,也不是放弃;软缺口留在 `warning` 与 `next_steps`。两次返回都带 `preserve_pending=true`、`abandon_run=false`、`action_required=swarm_solidify`(boot 与 status 在仍要固化时同样带上)。不要丢掉这条未完成 run。有软缺口时,第一次 tick 与保险丝都不带 `gate_soft_continue`(缺席不是 false;`ok` 第一次仍为 true,没有 `error`;`tick_again=false` 与 `retryable=false` 都表示不要再 tick,第一次也写 `retryable=false`)。只把严格 false 当成整段会话失败的宿主因此不会停掉会话。两次 tick 都带 `session_not_failed=true`:先读这个字段,会话没有失败;`loop_fuse` 不在 `error` 里,preserve 三元组仍指向 `swarm_solidify`。`next_steps` 第一条是调用 `swarm_solidify`。boot 与 status 的 `gate_soft_continue` 仍为 true,且不带 `session_not_failed`。要替换这条 run 才传 `supersede_pending=true`。暂停与压缩检查点仍优先于这个参数。 下列情况仍硬停(不要重试同一次失败):diff 里的密钥或凭据、改写 `~/.evolver/` 下的引擎状态、`val_seal` 泄露。损坏的 bench 门(`gate_error`)以及验证面改动的 anchor 失败也会拒绝。没有假说时本轮仍被拒(`hypothesis_missing`),直到 `swarm_hypothesis` 成功。 diff --git a/examples/swarm-quickstart/README.md b/examples/swarm-quickstart/README.md index d70dc4b..51e4b0d 100644 --- a/examples/swarm-quickstart/README.md +++ b/examples/swarm-quickstart/README.md @@ -50,7 +50,7 @@ swarm_boot ─▶ swarm_status ─▶ swarm_hook_event(信号采集) | `claude-code.mcp.json` | Claude Code | 项目根 `.mcp.json` | | `cursor-mcp.json` | Cursor | `.cursor/mcp.json` | -连上之后,本条消息已有别的任务就做那件事。没有别的任务时宿主调用 `swarm_boot`,再用一句话说明实际状态。若只调了 `swarm_status` 且本进程还没 boot,`next_action` 是 `swarm_boot`。空的 `tool_asset_search` / `tool_mailbox_poll` / `tool_cycle_timeline` / `swarm_approvals` 返回 `{ok, items, hint}`(`swarm_approvals` 另含 `pending` 与 `recent`)。`swarm_tick` 的 `prompt_mode` 默认 `full`;短载荷须显式 `prompt_mode=short` 或 `checklist_only=true`,此时 `engine_log` 不再内联 GEP 全文。只读 `swarm_doctor` 等同 `evolver doctor`(不执行 `--fix`)。宿主工具目录若仍看不到 `prompt_mode` / `checklist_only` 或 `swarm_doctor`,那是客户端对 `tools/list` 的缓存:重启 MCP 进程后新开一次会话才会重读。有未完成 run 时 `swarm_boot` 的 `next_action` 仍是 `swarm_solidify`,`hint` 写明先固化,并带 `readonly_smoke`(`swarm_doctor` / `swarm_status` 不结算、不放宽门);软缺口留在 `warning`。此时直接 `swarm_tick` 不启新周期(第一次 `cycle_started=false`、`ok=true`、`progress=false`,不改 `last_run`;同一条 run 再 tick 得到 `ok=false`、`loop_fuse=pending_redirect_loop`、`redirect_reason=pending_redirect_loop`,没有 `error` 字段,`next_action` 仍是 `swarm_solidify`(保险丝码不是 `next_action`;`dispatch_reason` 仍是 `pending_solidify`;第一次的 `redirect_reason` 仍是 `pending_solidify`),仍不启周期,不是门禁失败,也不是放弃;两次都带 `preserve_pending=true`、`abandon_run=false`,不要丢掉这条 run。有软缺口时第一次 tick 与保险丝都不带 `gate_soft_continue`(缺席不是 false;`ok` 第一次仍为 true,没有 `error`;`tick_again=false` 表示不要再 tick;两次都带 `session_not_failed=true`,先读它,会话没有失败,`loop_fuse` 不放弃这条 run;`next_steps` 第一条是 `swarm_solidify`)。boot / status 的 `gate_soft_continue` 仍为 true,且不带 `session_not_failed`)。要替换才传 `supersede_pending=true`。`boot_once` 只登记会话,不在开机时同步技能。冻结包未装或没有基线时 boot / `swarm_tick` **soft-continue**(带 warnings + next_steps,可进入循环);Accept/publish 可 soft-accept(不伪造 Parent baseline、不打开 val 密封材料)。已暂停时仍返回 `await_supervisor_resume`。用户说「停」,宿主调用 `swarm_supervise` action=pause;说「继续」,宿主转达 resume。也可以对它说「启动蜂群进化」。返回的 instrument 按步执行 `swarm_tick → 执行 → swarm_distill → swarm_hypothesis → swarm_solidify → swarm_feedback`,直到终止条件。`swarm_hypothesis` 可带 `expected_outcome` 写预计通过的检查,结算时引擎对照实测写 `prediction_delta`;上一轮输出被截断时按问题调用 `episode_inspect` 读回原文;收到压缩信号或连续 4 次固化失败时先调 `swarm_checkpoint_working` 写下 `WORKING_SESSION.md`。`dispatch_prompt` 标 **PROPOSAL REQUIRED** 时改走 `swarm_propose`,不得自由编辑。`next_action=await_human_approval` 停住:`swarm_approvals` 读给人,人决定后才 `swarm_approval_resolve`。 +连上之后,本条消息已有别的任务就做那件事。没有别的任务时宿主调用 `swarm_boot`,再用一句话说明实际状态。若只调了 `swarm_status` 且本进程还没 boot,`next_action` 是 `swarm_boot`。空的 `tool_asset_search` / `tool_mailbox_poll` / `tool_cycle_timeline` / `swarm_approvals` 返回 `{ok, items, hint}`(`swarm_approvals` 另含 `pending` 与 `recent`)。`swarm_tick` 的 `prompt_mode` 默认 `full`;短载荷须显式 `prompt_mode=short` 或 `checklist_only=true`,此时 `engine_log` 不再内联 GEP 全文。只读 `swarm_doctor` 等同 `evolver doctor`(不执行 `--fix`)。宿主工具目录若仍看不到 `prompt_mode` / `checklist_only` 或 `swarm_doctor`,那是客户端对 `tools/list` 的缓存:重启 MCP 进程后新开一次会话才会重读。有未完成 run 时 `swarm_boot` 的 `next_action` 仍是 `swarm_solidify`,`hint` 写明先固化,并带 `readonly_smoke`(`swarm_doctor` / `swarm_status` 不结算、不放宽门);软缺口留在 `warning`。此时直接 `swarm_tick` 不启新周期(第一次 `cycle_started=false`、`ok=true`、`progress=false`,不改 `last_run`;同一条 run 再 tick 得到 `ok=false`、`loop_fuse=pending_redirect_loop`、`redirect_reason=pending_redirect_loop`,没有 `error` 字段,`next_action` 仍是 `swarm_solidify`(保险丝码不是 `next_action`;`dispatch_reason` 仍是 `pending_solidify`;第一次的 `redirect_reason` 仍是 `pending_solidify`),仍不启周期,不是门禁失败,也不是放弃;两次都带 `preserve_pending=true`、`abandon_run=false`,不要丢掉这条 run。有软缺口时第一次 tick 与保险丝都不带 `gate_soft_continue`(缺席不是 false;`ok` 第一次仍为 true,没有 `error`;`tick_again=false` 与 `retryable=false` 都表示不要再 tick,第一次也写 `retryable=false`;两次都带 `session_not_failed=true`,先读它,会话没有失败,`loop_fuse` 不放弃这条 run;`next_steps` 第一条是 `swarm_solidify`)。boot / status 的 `gate_soft_continue` 仍为 true,且不带 `session_not_failed`)。要替换才传 `supersede_pending=true`。`boot_once` 只登记会话,不在开机时同步技能。冻结包未装或没有基线时 boot / `swarm_tick` **soft-continue**(带 warnings + next_steps,可进入循环);Accept/publish 可 soft-accept(不伪造 Parent baseline、不打开 val 密封材料)。已暂停时仍返回 `await_supervisor_resume`。用户说「停」,宿主调用 `swarm_supervise` action=pause;说「继续」,宿主转达 resume。也可以对它说「启动蜂群进化」。返回的 instrument 按步执行 `swarm_tick → 执行 → swarm_distill → swarm_hypothesis → swarm_solidify → swarm_feedback`,直到终止条件。`swarm_hypothesis` 可带 `expected_outcome` 写预计通过的检查,结算时引擎对照实测写 `prediction_delta`;上一轮输出被截断时按问题调用 `episode_inspect` 读回原文;收到压缩信号或连续 4 次固化失败时先调 `swarm_checkpoint_working` 写下 `WORKING_SESSION.md`。`dispatch_prompt` 标 **PROPOSAL REQUIRED** 时改走 `swarm_propose`,不得自由编辑。`next_action=await_human_approval` 停住:`swarm_approvals` 读给人,人决定后才 `swarm_approval_resolve`。 ## 开箱 / Open box(首次准备的一条命令) diff --git a/src/evolver/mcp_server.py b/src/evolver/mcp_server.py index 9701b99..075a986 100644 --- a/src/evolver/mcp_server.py +++ b/src/evolver/mcp_server.py @@ -457,8 +457,9 @@ async def tool_swarm_tick( "Default false. While a run is unfinished, the first " "swarm_tick does not start a cycle: ok stays true, " "severity=soft, cycle_started=false, progress=false, " - "tick_again=false, next_action=swarm_solidify, and last_run " - "stays. A repeat on that same run returns ok=false, " + "tick_again=false, retryable=false, next_action=swarm_solidify, " + "and last_run stays. Absent retryable is not a license to tick " + "again. A repeat on that same run returns ok=false, " "severity=soft, retryable=false, " "loop_fuse=pending_redirect_loop, " "redirect_reason=pending_redirect_loop, and no error field. " @@ -490,9 +491,10 @@ async def tool_swarm_tick( If a run is unfinished, the first default call does not start a cycle (cycle_started=false, next_action=swarm_solidify, ok=true, severity=soft, - progress=false, tick_again=false). A repeat on that run returns ok=false - and loop_fuse=pending_redirect_loop with redirect_reason the same code - and no error field (severity=soft, retryable=false). next_action stays + progress=false, tick_again=false, retryable=false). A repeat on that + run returns ok=false and loop_fuse=pending_redirect_loop with + redirect_reason the same code and no error field (severity=soft, + retryable=false). next_action stays swarm_solidify. The fuse code is not an error and not a next_action value. It still does not start a cycle. dispatch_reason stays pending_solidify. The first redirect keeps diff --git a/src/evolver/swarm.py b/src/evolver/swarm.py index 892be36..2e8e27a 100644 --- a/src/evolver/swarm.py +++ b/src/evolver/swarm.py @@ -301,7 +301,8 @@ def build_instrument_prompt(state: dict[str, Any]) -> str: `redirect_count` 在涨,说明还是这一条 run。两次返回都带 `session_not_failed=true`、`preserve_pending=true`、`abandon_run=false`、 `action_required=swarm_solidify`。 `session_not_failed=true` 表示会话没有失败, - 先读它再读别的旗标。`tick_again=false` 表示不要再 tick。 + 先读它再读别的旗标。`tick_again=false` 与 `retryable=false` 都表示不要再 tick + (第一次重定向也写 `retryable=false`,`ok` 仍为 true)。 有软缺口时 `gate_soft_continue is omitted` (第一次也是,`ok` 仍为 true,没有 `error`):缺这个键不是 false, 不是失败的会话,软缺口仍在 `warning`。再 tick 才是 `ok=false`、 @@ -1022,7 +1023,8 @@ def _prefer_solidify_steps( "gate_soft_continue is omitted. " "Omitted is not false, so the session is not failed. " "tick_again=false means do not tick. " - "ok is still true and there is no error." + "ok is still true and there is no error. " + "retryable=false means do not tick." ) elif hold_tick and closed: lead += ( @@ -1102,6 +1104,7 @@ def _pending_redirect_note(count: int, closed: bool, *, gap: bool) -> str: "swarm_tick did not start a cycle because a run is still unfinished " f"(redirect_count={count}, progress=false). " "ok stays true and this is not a hard gate. " + "retryable=false means do not call swarm_tick. " f"{keep} " f"{omitted}" "Another swarm_tick on this same run returns " @@ -1142,7 +1145,9 @@ def _pending_tick_redirect(gap: str | None) -> dict[str, Any]: ``pending_solidify``. That fuse is not a gate and not a ``next_action`` value. Both calls set ``session_not_failed`` true, ``preserve_pending`` true, ``abandon_run`` - false, and ``action_required`` to ``swarm_solidify``. Read + false, and ``action_required`` to ``swarm_solidify``. Both calls set + ``retryable`` false. Absent is not a license to tick again; strict false + means do not tick. The first call still keeps ``ok`` true. Read ``session_not_failed`` before other flags. True means the session is not failed: call ``swarm_solidify`` and keep the run. When a soft gap is present, ``gate_soft_continue`` is omitted on the @@ -1173,6 +1178,7 @@ def _pending_tick_redirect(gap: str | None) -> dict[str, Any]: "progress": False, "redirect_count": count, "tick_again": False, + "retryable": False, "tick_closed": closed, "dispatch_prompt": None, "dispatch_reason": "pending_solidify", @@ -1673,8 +1679,10 @@ async def swarm_tick( (``severity`` soft, ``retryable`` false). ``next_action`` stays ``swarm_solidify``. That is not a gate failure and not an abandon signal. Both calls set - ``session_not_failed`` true, ``preserve_pending`` true, and - ``abandon_run`` false. Read ``session_not_failed`` before other flags. + ``session_not_failed`` true, ``preserve_pending`` true, + ``abandon_run`` false, and ``retryable`` false. An omitted ``retryable`` + is not permission to tick again. The first call still keeps ``ok`` true. + Read ``session_not_failed`` before other flags. A soft gap omits ``gate_soft_continue`` on the first redirect and on the fuse. The first call keeps ``ok`` true and sets no ``error``. Neither call starts a cycle or replaces ``last_run``. diff --git a/tests/test_mcp_host_usability_pending_smoke.py b/tests/test_mcp_host_usability_pending_smoke.py index a54ebb0..fee736d 100644 --- a/tests/test_mcp_host_usability_pending_smoke.py +++ b/tests/test_mcp_host_usability_pending_smoke.py @@ -77,6 +77,29 @@ def _host_ticks_only_on_gate_soft_continue(payload: dict[str, Any]) -> bool: return payload.get("gate_soft_continue") is True +def _host_ticks_unless_retryable_is_false(payload: dict[str, Any]) -> bool: + """Keep ticking unless ``retryable`` is strict false. + + An omitted ``retryable`` counts as continue. ``tick_again``, + ``next_action``, and ``ok`` are ignored. An omitted + ``gate_soft_continue`` is not a stop. Strict false of that flag would + stop this host too, and would also end the session for a host that + treats that false as death, so the redirect must not set it. + """ + if payload.get("gate_soft_continue") is False: + return False + return payload.get("retryable") is not False + + +def _host_dies_on_nonretryable_failed_ok(payload: dict[str, Any]) -> bool: + """``retryable=false`` ends the session only together with ``ok`` false. + + The first redirect stays ``ok`` true, so this host does not die there. + ``session_not_failed`` is ignored on purpose. + """ + return payload.get("retryable") is False and payload.get("ok") is False + + def _host_abandons_on_any_error(payload: dict[str, Any]) -> bool: """Drop the run whenever ``error`` is set. Preserve flags are ignored.""" return bool(payload.get("error")) @@ -210,7 +233,12 @@ def _assert_stop_is_not_failure(payload: dict[str, Any], *, closed: bool, gap: b assert "gate_soft_continue" not in payload assert "error" not in payload assert payload.get("tick_again") is False + assert payload.get("retryable") is False + assert "retryable=false" in str(payload.get("note") or "") assert _host_ticks_only_on_gate_soft_continue(payload) is False + assert _host_ticks_unless_retryable_is_false(payload) is False + if not closed: + assert _host_dies_on_nonretryable_failed_ok(payload) is False assert _host_dies_on_soft_continue_false_ignoring_new_flags(payload) is False assert _host_ends_session_on_soft_continue_false(payload) is False assert _host_abandons_on_any_error(payload) is False