From 2aff1b333e702ec08abca2c2040c73516f5d117e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 3 Nov 2026 02:02:00 +0000 Subject: [PATCH] fix(mcp): set tick_again false on unfinished soft-gap boot and status Hosts that stop only on a strict tick_again=false still re-ticked after readonly swarm_boot and swarm_status. Those envelopes kept gate_soft_continue true and omitted tick_again. Write the stop bit beside next_action=swarm_solidify without turning the soft gap into a hard failure. Co-authored-by: Steper Lin --- AGENTS.md | 2 +- CHANGELOG.md | 1 + DEBUG.md | 8 +++++ README.md | 2 +- README.zh.md | 4 +-- examples/swarm-quickstart/README.md | 2 +- src/evolver/mcp_server.py | 10 +++++- src/evolver/swarm.py | 34 ++++++++++++++----- tests/test_mcp_host_usability_p0.py | 2 ++ .../test_mcp_host_usability_pending_smoke.py | 27 +++++++++++++-- 10 files changed, 75 insertions(+), 17 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 9023c50..f1584c4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -422,7 +422,7 @@ Parent。软缺口(`soft_continue=true`)下 `swarm_doctor` 同样给出 没有 `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`。 +boot/status 的 `gate_soft_continue` 仍为 true,且不带 `session_not_failed`。未完成 run 的软缺口 boot/status 同时写 `tick_again=false`(只看 `gate_soft_continue=true` 的宿主仍可能再 tick)。 `next_steps` 第一条是调用 `swarm_solidify`。 要替换这条 run 才传 `supersede_pending=true`。暂停与压缩检查点仍优先,且不消耗这次计数。 首次准备见 `examples/swarm-quickstart/README.md`。 diff --git a/CHANGELOG.md b/CHANGELOG.md index 97ce7b8..f3e48c6 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 的软缺口 boot/status 写 `tick_again=false`**:`swarm_boot` 与 `swarm_status` 在未完成 run 且软缺口、`next_action=swarm_solidify` 时带 `tick_again=false`。`gate_soft_continue` 仍为 true,不写 `session_not_failed`。preserve 三元组不动。没有未完成 run 的 soft-continue,以及压缩检查点盖过固化时,不写 `tick_again`。doctor、第一次 tick 与保险丝本来的 `tick_again=false` 不动。不结算这条 run,不写 Parent baseline,不放宽固化门。 - **MCP 宿主可用性:未完成 run 的软缺口 doctor 写 `tick_again=false`**:只在 `soft_continue=true` 且有未完成 run、没有硬阻断时,`swarm_doctor` 带 `tick_again=false`。缺席不再被读成「可以再 tick」。`soft_continue` 仍为 true,不写 `gate_soft_continue`,不写 `session_not_failed`。`next_action` 仍是 `swarm_solidify`,preserve 三元组不动。hint 写明 `fixes` 里的 `evolver doctor --fix` 本工具不执行。没有未完成 run,或 doctor 是硬阻断时,不写 `tick_again`。第一次 tick 与保险丝本来就有 `tick_again=false`,这次不改。不结算这条 run,不写 Parent baseline,不放宽固化门,不执行 `--fix`。 - **MCP 宿主可用性:未完成 run 的软缺口 doctor 指向固化**:`readonly_smoke` 点名的 `swarm_doctor` 在 `soft_continue=true` 且有未完成 run 时带 `next_action=swarm_solidify`、`pending_solidify` 与 preserve 三元组。`hint` 先写现在固化,软缺口仍是建议。不写 `gate_soft_continue`,不写 `session_not_failed`,不结算这条 run,不写 Parent baseline,不执行 `--fix`。没有未完成 run,或 doctor 本身是硬阻断(`ok=false`)时,不另给这个动作。 - **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,不放宽固化门。 diff --git a/DEBUG.md b/DEBUG.md index 4979ec5..f3b52c8 100644 --- a/DEBUG.md +++ b/DEBUG.md @@ -1240,3 +1240,11 @@ - **修复**:仅当未完成 run 且 `soft_continue=true`、没有硬 `blockers` 时,doctor 写 `tick_again=false`。`soft_continue` 仍为 true。不写 `gate_soft_continue`,不写 `session_not_failed`。hint 写明 `tick_again=false`,并写明 `fixes` 里的 `evolver doctor --fix` 本工具不执行、固化前不要跑。没有未完成 run,或硬阻断(`ok=false`),不写 `tick_again`。第一次 tick 与保险丝的 `tick_again=false` 不动。不结算,不写 Parent baseline,不放宽固化门,不执行 `--fix`。目录缓存(DEBUG #61)未做假修复。 - **经验**:**同一个「不要再 tick」要写在宿主已经认识的字段上。** doctor 不能借 `soft_continue=false` 来停,也不能借 `gate_soft_continue=false`。 - **仍在**:只读 `soft_continue=true`、完全不看 `tick_again` / `next_action` / `ok` / `retryable` 的宿主,冒烟之后仍可能再 tick。把缺席的 `gate_soft_continue` 当成继续、且不看 `tick_again` 的 tick 重定向(DEBUG #68 余项 1)仍可能再 tick。把保险丝 `ok=false` 当成整段失败、且不读 `session_not_failed` 与 `loop_fuse` 的宿主(余项 2)仍会停掉会话;`ok` 留着 false,是只看 `ok` 的宿主靠它停止空转。`fixes` 仍列出 `evolver doctor --fix`;本工具不执行它。目录缓存(DEBUG #61)没有做假修复。 + +### 72. 软缺口 boot/status 不写 `tick_again`,缺席被当成再 tick(MCP 易用性,已修) + +- **症状**:#71 之后,未完成 run 的软缺口 `swarm_doctor` 已写 `tick_again=false`。同一条 run 上的 `swarm_boot` / `swarm_status` 仍是 `gate_soft_continue=true`、`next_action=swarm_solidify`、preserve 三元组在,没有 `tick_again`。只在 `tick_again` 严格为 false 时才停、把缺席当成再 tick、同时不看 `next_action` 的宿主,只读 boot 或 status 之后仍会 tick。只看 `gate_soft_continue=true` 的宿主也会再 tick;把这个键写成 false 会重开 DEBUG #67。 +- **根因**:停 tick 的严格 false 写在 tick 与 doctor 上。boot / status 的软缺口信封没写这个键。缺席不是 false。`gate_soft_continue=true` 的原义是开局 soft-continue,不能改成 false 来停 tick。 +- **修复**:仅当未完成 run、软缺口已经挂上(`gate_soft_continue` 仍为 true)、`next_action=swarm_solidify` 时,boot 顶层与 status 写 `tick_again=false`。不写 `session_not_failed`。preserve 三元组不动。没有未完成 run 的 soft-continue 不写 `tick_again`。压缩检查点盖过固化时,boot 顶层与嵌套 status 副本都不留这个键。doctor、第一次 tick 与保险丝的 `tick_again=false` 不动。不结算,不写 Parent baseline,不放宽固化门,不执行 `evolver doctor --fix`。目录缓存(DEBUG #61)未做假修复。 +- **经验**:**同一个「不要再 tick」要写在宿主已经认识的字段上,包括只读开机回执。** boot / status 不能借 `gate_soft_continue=false` 来停。 +- **仍在**:只看 `gate_soft_continue=true`、完全不看 `tick_again` / `next_action` 的宿主,boot 或 status 之后仍可能再 tick。只读 `soft_continue=true`、完全不看 `tick_again` 的 doctor 冒烟(DEBUG #71 余项)仍可能再 tick。把保险丝 `ok=false` 当成整段失败、且不读 `session_not_failed` 与 `loop_fuse` 的宿主(DEBUG #68 余项 2)仍会停掉会话;`ok` 留着 false,是只看 `ok` 的宿主靠它停止空转。`fixes` 仍列出 `evolver doctor --fix`;本工具不执行它。目录缓存(DEBUG #61)没有做假修复。 diff --git a/README.md b/README.md index 44b890f..a364bb0 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, `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. +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). On a soft gap it also sets `tick_again=false` while `gate_soft_continue` stays true. `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, set `tick_again` false on that soft gap, 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. When a run is unfinished and that report is soft-continue, doctor also sets `next_action=swarm_solidify`, `tick_again=false`, `pending_solidify`, and the preserve triad (`preserve_pending`, `abandon_run=false`, `action_required=swarm_solidify`). `soft_continue` stays true. It still does not settle the run, write a Parent baseline, or execute `evolver doctor --fix`. `gate_soft_continue` and `session_not_failed` stay absent. A hard blocker keeps `ok` false and does not add that action or `tick_again`. The first unfinished-run tick and the fuse already set `tick_again` false. diff --git a/README.zh.md b/README.zh.md index ce5a75d..870addb 100644 --- a/README.zh.md +++ b/README.zh.md @@ -240,7 +240,7 @@ uv run evolver migrate-state 现网 `tools/list` 已经公布 `swarm_tick` 的 `prompt_mode`(`full` 或 `short`)和 `checklist_only`,参数上带说明,并注册只读 `swarm_doctor`。宿主目录若仍只列出 `agent_name` 与 `include_prompt`,或搜不到 `swarm_doctor`,那是客户端会话缓存。重启进程只重载代码;要重读 `tools/list`,需要新开一次宿主会话。 -若上一轮 run 还没固化,`swarm_boot` 的 `next_action` 仍是 `swarm_solidify`,顶层带 `pending_solidify`,并多一个 `readonly_smoke`(`tools` 为 `swarm_doctor` 与 `swarm_status`,`settles_run` 为 false)。`hint` 写明先固化。软缺口(`no_baseline` / `pack_absent` / `unmeasured`)仍附 `warning` 与 `next_steps`,但不盖掉这句 hint,也不放宽固化门。只读冒烟可以调 `swarm_doctor` 或 `swarm_status`:它们不结算这条 run,也不伪造 Parent baseline。 +若上一轮 run 还没固化,`swarm_boot` 的 `next_action` 仍是 `swarm_solidify`,顶层带 `pending_solidify`,并多一个 `readonly_smoke`(`tools` 为 `swarm_doctor` 与 `swarm_status`,`settles_run` 为 false)。软缺口上同时写 `tick_again=false`,`gate_soft_continue` 仍为 true。`hint` 写明先固化。软缺口(`no_baseline` / `pack_absent` / `unmeasured`)仍附 `warning` 与 `next_steps`,但不盖掉这句 hint,也不放宽固化门。只读冒烟可以调 `swarm_doctor` 或 `swarm_status`:它们不结算这条 run,也不伪造 Parent baseline。 本进程尚未 `swarm_boot` 时,`swarm_status` 返回 `next_action=swarm_boot` 和一句 hint。boot 之后 status 仍带 `agent_name`、`source_revision`,以及软缺口的 `gap` / warnings。`tool_asset_search`、`tool_mailbox_poll`、`tool_cycle_timeline`、`swarm_approvals` 一律返回 `{ok, items, hint}`,没有命中也不是空正文。`swarm_approvals` 另外保留 `pending`(与 `items` 同一队列)和 `recent`。只读 `swarm_doctor` 等同 `evolver doctor` 且不执行 `--fix`(`ok`、软警告、`fixes` 里的命令提示)。`no_baseline` / `pack_absent` / `unmeasured` 仍是 soft-continue。有未完成 run 且这份报告是 soft-continue 时,doctor 也给出 `next_action=swarm_solidify`、`tick_again=false`、`pending_solidify` 和 preserve 三元组(`preserve_pending`、`abandon_run=false`、`action_required=swarm_solidify`)。`soft_continue` 仍为 true。它仍不结算这条 run,不写 Parent baseline,也不执行 `evolver doctor --fix`。`gate_soft_continue` 与 `session_not_failed` 缺席。硬阻断保持 `ok=false`,不另给这个动作,也不写 `tick_again`。第一次未完成 run 的 tick 与保险丝本来就写了 `tick_again=false`。 @@ -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` 与 `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`。暂停与压缩检查点仍优先于这个参数。 +`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,未完成软缺口同时写 `tick_again=false`,且不带 `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 b0dbea2..2ca9a60 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`)。有未完成 run 且 doctor 为 soft-continue 时,它的 `next_action` 也是 `swarm_solidify`,并写 `tick_again=false`(`soft_continue` 仍为 true;不写 `gate_soft_continue` / `session_not_failed`,不结算,不写 Parent,不执行 `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`。 +连上之后,本条消息已有别的任务就做那件事。没有别的任务时宿主调用 `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`)。有未完成 run 且 doctor 为 soft-continue 时,它的 `next_action` 也是 `swarm_solidify`,并写 `tick_again=false`(`soft_continue` 仍为 true;不写 `gate_soft_continue` / `session_not_failed`,不结算,不写 Parent,不执行 `evolver doctor --fix`)。宿主工具目录若仍看不到 `prompt_mode` / `checklist_only` 或 `swarm_doctor`,那是客户端对 `tools/list` 的缓存:重启 MCP 进程后新开一次会话才会重读。有未完成 run 时 `swarm_boot` 的 `next_action` 仍是 `swarm_solidify`,软缺口同时写 `tick_again=false`(`gate_soft_continue` 仍为 true),`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,未完成软缺口同时写 `tick_again=false`,且不带 `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 25db9d2..bad214c 100644 --- a/src/evolver/mcp_server.py +++ b/src/evolver/mcp_server.py @@ -421,6 +421,9 @@ def tool_swarm_boot( project binds only an existing directory. bound_paths states repo_root (code root) and workspace_root. A difference, or a label that is not a directory, is a soft warning; the loop still continues. + An unfinished run on a soft gap keeps next_action=swarm_solidify, + gate_soft_continue=true, and tick_again=false. This call does not + settle the run or write a Parent baseline. """ from evolver.swarm import swarm_boot @@ -643,7 +646,12 @@ def tool_swarm_report( ) def tool_swarm_status() -> dict[str, Any]: - """Read-only. Lightweight engine status for swarm agents (no cycle side effects).""" + """Read-only. Lightweight engine status for swarm agents (no cycle side effects). + + After boot, an unfinished run on a soft gap keeps next_action=swarm_solidify, + gate_soft_continue=true, and tick_again=false. This call does not settle + the run or write a Parent baseline. + """ from evolver.swarm import swarm_status return swarm_status() diff --git a/src/evolver/swarm.py b/src/evolver/swarm.py index fa3b0aa..7bcd8c4 100644 --- a/src/evolver/swarm.py +++ b/src/evolver/swarm.py @@ -651,6 +651,9 @@ def _attach_host_session(status: dict[str, Any]) -> dict[str, Any]: A missing claim is the whole signal. Soft gaps (no pack / no baseline) are attached only after boot, and they stay ``severity=soft`` — not an ``error``. + An unfinished run on that soft gap keeps ``next_action=swarm_solidify``, + ``gate_soft_continue`` true, and sets ``tick_again`` false. Absent is not + false, so a host that stops only on strict false would tick again. """ claim = _session_claim if not claim: @@ -687,6 +690,10 @@ def _attach_host_session(status: dict[str, Any]) -> dict[str, Any]: surfaced["next_action"] = action if steer_solidify: _prefer_solidify_steps(surfaced, hold_tick=False, run_id=pending_run) + # Keep gate_soft_continue true. Write tick_again false so a host that + # stops only on strict false does not tick again after this status. + if surfaced.get("gate_soft_continue") is True: + surfaced["tick_again"] = False return surfaced @@ -805,10 +812,11 @@ def _attach_unfinished_run_to_doctor(report: dict[str, Any]) -> dict[str, Any]: ``gate_soft_continue`` stays absent: a strict false is session death for hosts that do not read ``session_not_failed``. That flag stays absent too. It belongs on the tick redirect, not on a doctor health bit. - ``tick_again`` is false on this envelope only. Absent is not false, so a - host that stops only on strict false would tick again. ``soft_continue`` - stays true: that bit means the gap is not a hard stop. This does not run - ``--fix`` and does not write a Parent baseline. + ``tick_again`` is false here. Absent is not false, so a host that stops + only on strict false would tick again. ``soft_continue`` stays true: that + bit means the gap is not a hard stop. Unfinished soft-gap boot and status + set the same ``tick_again`` false and keep ``gate_soft_continue`` true. + This does not run ``--fix`` and does not write a Parent baseline. """ if not _pending_solidify_state(): return report @@ -1052,7 +1060,8 @@ def _prefer_solidify_steps( not false, so a host that ends the session on strict false stays up even when it ignores ``session_not_failed``. ``tick_again`` stays false. ``ok`` and ``error`` are left alone. Boot and status keep the flag that - ``apply_soft_gap`` set. + ``apply_soft_gap`` set, and those unfinished soft-gap envelopes also set + ``tick_again`` false. """ rid = str(run_id if run_id is not None else payload.get("run_id") or "").strip() who = f"run_id={rid}" if rid else "this unfinished run" @@ -1201,9 +1210,9 @@ def _pending_tick_redirect(gap: str | None) -> dict[str, Any]: is not false, so a host that treats strict false as session death stays up even if it ignores ``session_not_failed``. ``tick_again`` is false. The first call keeps ``ok`` true and sets no ``error``. - The gap itself stays in ``warning``. Elsewhere, including boot and - status, a soft gap still sets ``gate_soft_continue`` true, and - ``session_not_failed`` stays absent. + The gap itself stays in ``warning``. An unfinished soft-gap boot or + status keeps ``gate_soft_continue`` true and sets ``tick_again`` false. + ``session_not_failed`` stays absent there. ``supersede_pending=true`` is the explicit replace. No Parent baseline is written. """ @@ -1538,7 +1547,9 @@ def swarm_boot( instrument prompt's first-action branch (round-57: it was unconditionally ``swarm_tick`` while the prompt said "solidify first" when pending — hosts reading the structured field got the wrong first action; the - round-4 fix only covered the prose). + round-4 fix only covered the prose). An unfinished soft gap keeps + ``gate_soft_continue`` true and sets ``tick_again`` false beside + ``next_action=swarm_solidify``. """ from evolver.gep.paths import ensure_workspace_meta @@ -1593,6 +1604,7 @@ def swarm_boot( embedded.pop("preserve_pending", None) embedded.pop("abandon_run", None) embedded.pop("action_required", None) + embedded.pop("tick_again", None) gap = _gate_gap(state.get("bench_pack_gate")) if gap is not None and str(payload.get("next_action") or "") != "await_supervisor_resume": from evolver.ops.open_box import apply_soft_gap @@ -1621,6 +1633,10 @@ def swarm_boot( hold_tick=False, run_id=_pending_solidify_meta()["run_id"], ) + # Status already set tick_again on the nested copy. The top-level + # boot envelope is a separate dict. Keep gate_soft_continue true. + if payload.get("gate_soft_continue") is True: + payload["tick_again"] = False bound = describe_bound_paths(bind) if isinstance(payload.get("state"), dict): payload["state"]["bound_paths"] = bound diff --git a/tests/test_mcp_host_usability_p0.py b/tests/test_mcp_host_usability_p0.py index 525cf0d..d1b9d8f 100644 --- a/tests/test_mcp_host_usability_p0.py +++ b/tests/test_mcp_host_usability_p0.py @@ -106,6 +106,7 @@ def test_status_after_boot_keeps_agent_revision_and_soft_gap( assert boot.get("error") not in _SOFT_GAPS assert boot.get("severity") == "soft" assert boot.get("gap") == "pack_absent" + assert "tick_again" not in boot status = swarm_status() assert status["session_claimed"] is True @@ -115,6 +116,7 @@ def test_status_after_boot_keeps_agent_revision_and_soft_gap( assert status.get("gap") == "pack_absent" assert status.get("severity") == "soft" assert status.get("gate_soft_continue") is True + assert "tick_again" not in status assert status.get("warnings") assert status.get("error") not in _SOFT_GAPS assert status["ok"] is True diff --git a/tests/test_mcp_host_usability_pending_smoke.py b/tests/test_mcp_host_usability_pending_smoke.py index f75b99b..448c31b 100644 --- a/tests/test_mcp_host_usability_pending_smoke.py +++ b/tests/test_mcp_host_usability_pending_smoke.py @@ -368,6 +368,13 @@ def test_prompt_mode_and_doctor_are_listed_with_descriptions(self) -> None: assert "session_not_failed" in description assert "tick_again=false" in description + boot_desc = " ".join((tools["swarm_boot"].description or "").split()) + status_desc = " ".join((tools["swarm_status"].description or "").split()) + assert "tick_again=false" in boot_desc + assert "gate_soft_continue" in boot_desc + assert "tick_again=false" in status_desc + assert "gate_soft_continue" in status_desc + class TestPendingBootSmokeHint: def test_pending_boot_keeps_solidify_and_names_a_read_only_smoke( @@ -406,12 +413,25 @@ def test_pending_boot_keeps_solidify_and_names_a_read_only_smoke( assert status["readonly_smoke"]["tools"] == smoke["tools"] _assert_preserve_pending(boot) _assert_preserve_pending(status) - # Session start stays soft-continue. The tick redirect is what stops - # another tick. The step list already names swarm_solidify. + # Soft gap stays gate_soft_continue=true. tick_again=false stops a + # host that only halts on strict false. A host that loops only while + # gate_soft_continue is true still ticks; do not flip that flag. + state = boot["state"] + assert isinstance(state, dict) + assert boot["tick_again"] is False + assert status["tick_again"] is False + assert state["tick_again"] is False + assert _host_ticks_unless_tick_again_is_false(boot) is False + assert _host_ticks_unless_tick_again_is_false(status) is False + assert _host_ticks_unless_tick_again_is_false(state) is False + assert _host_ticks_only_on_gate_soft_continue(boot) is True + assert _host_ticks_only_on_gate_soft_continue(status) is True assert boot.get("gate_soft_continue") is True assert status.get("gate_soft_continue") is True + assert state.get("gate_soft_continue") is True assert "session_not_failed" not in boot assert "session_not_failed" not in status + assert "session_not_failed" not in state assert "loop_fuse" not in boot assert "loop_fuse" not in status assert boot.get("redirect_reason") != "pending_redirect_loop" @@ -433,6 +453,7 @@ def test_soft_boot_without_a_pending_run_does_not_grow_a_smoke_block( assert "readonly_smoke" not in boot assert boot.get("severity") == "soft" assert boot.get("gate_soft_continue") is True + assert "tick_again" not in boot assert "preserve_pending" not in boot assert "abandon_run" not in boot assert "session_not_failed" not in boot @@ -449,9 +470,11 @@ def test_checkpoint_outranks_the_smoke_block(self, isolated_swarm_env: Path) -> boot = swarm_boot("checkpoint-host") assert boot["next_action"] == "call_swarm_checkpoint_working" assert "readonly_smoke" not in boot + assert "tick_again" not in boot state = boot.get("state") assert isinstance(state, dict) assert "readonly_smoke" not in state + assert "tick_again" not in state def test_pending_doctor_on_a_soft_gap_names_solidify( self, isolated_swarm_env: Path, monkeypatch: pytest.MonkeyPatch