Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

docs(design): define the v2 online migration task, commit and recovery contract - #2455

Open
zerob13 wants to merge 8 commits into
mainfrom
dim/2454-online-migration-design
Open

zerob13 wants to merge 8 commits into
mainfrom
dim/2454-online-migration-design

Conversation

@zerob13

@zerob13 zerob13 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Refs #2454

设计覆盖 CN 和 Global 用户升级后的首次迁移提醒。用户可以先继续聊天,再从 CLI 或本机 Web 把旧数据导入正在运行的 daemon。本 PR 提请评审在线迁移合同。定稿后分两次交付实现,先接入所有者与既有命令,再接入 CLI/Web 首页和进度。当前产品仍使用离线导入。

评审点 设计合同
谁持锁、何时装载 原生产品随 daemon 装入可选 Migration 行,最后一个客户端退出后任务仍继续。sqliteStorage 独占 .sqlite.lock 和写连接。Migration 通过目标所有者提交。
如何关闭 App Server 在分派 start/retry 前取得进程接纳。若空闲关闭先暂停接纳,请求在进入 Migration 前即被拒绝。已分派的 RPC 等待受理落盘,期间 Migration 后台任务通过 processActivity.keep(work) 取得自己的接纳并保持到终态。CLI 升级请求空闲关闭时,活动迁移使 daemon 返回 daemon_busy,任务继续。拟议的显式正常关闭协调点等待 Migration 在 Provider 停用前结算已接单对象并持久化 interrupted,已受理的用户停止结算为 cancelled。CLI/Web 收到关停错误或断线后等待重连,用原任务 ID 查终态。强制终止后凭租约和回执恢复。
超大会话如何发布 复用 fork 的分块让锁方式,在不可见的 Session 身份下准备历史、上下文及附件,在最终 FULL 事务一次发布并写回执。建议前台持久化写入的 p95 较基线增加不超过 200 ms,任一写入额外延迟小于 1 s。两组总量相差 4 倍且单条记录大小相同的 fixture,迁移新增峰值 RSS 相差不超过 64 MiB。
哪些来源可选(已确认) 非 Alpha 的 CN 和 Global 目标各自首次提醒。Alpha 仅从 CN 来源导入 Alpha 目标。显式隔离 home 只查自身 v2。CLI 和本机 Web 对同一目标使用同一配对,浏览器只能选择宿主识别的来源及其任务。维护者的渠道决定

请维护者重点确认三个合同。

  1. App Server 从已准入的连接填充拟议的 origin.entry;Migration 用它过滤任务列表和按 ID 的操作。本机 socket 可见当前目标的全部任务,Web 只可见宿主识别的配对。管理方法
  2. Migration 为本机 CLI 和离线查询提供同一 TaskState。报告第一页同时固定任务头和结果,保留脚本的 format: 1、sourceHome、current 和空值语义。CLI 报告协议
  3. 显式关闭先结算迁移再停用业务所有者。进行中的状态轮询可能收到关停错误或先断线,两端重连后读取原任务的持久化结果。关停顺序

实现阶段用隔离 fixture 核对会话发布、配置条件写入、账号恢复、脚本兼容、前台延迟及内存预算。对象所有者操作 · 验收条件

Design rule checklist

  • Scope — Migration 持有跨会话任务,各业务所有者持有写入与结算权。
  • Commands and results — 无活动分支命令事件。进程操作交给对象所有者,冲突、已有记录与删除分别返回结果。
  • Handover — 受理落盘后应答,已接纳的对象提交先结算。
  • Timeline before — 不适用,导入不注册 before。入口检查传输权限与形状,所有者验证候选对象。
  • Infrastructure — 复用 rutis 装配、processActivity、managementMethods 和现有存储职责。
  • Core mechanisms — 分支运行时和正常上下文消费者无需识别 v2。
  • Batch — 子块保持原批次,最终事务原子发布完整会话、文件归属与回执。
  • Context — 保留已采纳的有效上下文,通过普通续聊读取,不重放历史工具或审批。
  • Owner isolation — 只提交原生候选和来源身份,版本比较与覆盖判断在目标所有者。
  • Cross-language faces — 管理方法和拟议所有者操作列出数据输入、结果、错误及取消边界。
  • Configuration — 渠道由宿主决定,来源选择与确认属于请求数据。
  • Mechanism requirements — 明确现有文件预留、单一长事务、分开写值和回执的不足及所属模块。
  • Timeline facts — 导入历史可持久读取,任务、提醒、界面进度由进程所有者保存。

Documentation

  • 已接受的 ADR 未修改。
  • 按 issue 要求同步受影响的存储、配置、命令和本机 Web 合同。跨模块操作均标记提案,等待各所有者评审。
  • 交付状态留在 PR 与 Migration 设计中,现行实现与提案分别标明。

Verification

  • node scripts/adr-check.mjs --base origin/main 通过,覆盖 10 个变更文档。git diff --check origin/main...HEAD 通过。
  • 核对本次补充中的 12 处相对链接与锚点、现有 TaskState 的 10 个字段、脚本格式值及传输层的关停错误。
  • 本 PR 只修改设计文档。运行期故障注入、脚本回归、前台延迟与 RSS 测量列入实现 PR 的验收。

@zerob13
zerob13 marked this pull request as ready for review December 2, 2026 04:40

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

复核 4796e2b3。Global/CN/Alpha 和隔离 home 的提醒已与 #2454 对齐;会话由所有者暂存并一次发布、回执同事务的方向也清楚。

P2:把显式关闭和升级的 idle-only 关闭分开,并明确谁负责先结算 Migration。 合同 把关闭与更新重启都写成等待迁移事务后落盘 interrupted。但 CLI 升级 只发 daemon.shutdown {ifIdle: true},活动迁移持有的 processActivity 正应让这次请求拒绝,而不是中断任务。对于明确要求关闭的路径,现有 App Server 协调器 先 quiesce Provider,再等 Agent/RPC,最后才进树的 shutdown;仅有 hold 与行卸载回调不能保证迁移先停止接单、在业务所有者仍可用时结算并保存终态。

建议保留现有升级语义:繁忙时拒绝并让任务继续;将 interrupted 留给显式关闭或实际发生的受控停止。请在设计中指出复用或新增的关闭协调点及其相对所有者的顺序,并把「迁移中点升级,拒绝且继续」和「显式关闭,已接单对象结算后落盘 interrupted,再拆所有者」列为两个独立验收。这里只要求把设计合同定清楚,不要求本 PR 实现。前台延迟和 RSS 可按当前建议作为实现阶段的预算验证。当前设计 CI 已通过。

@zerob13

zerob13 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed in d50cbbb59e53567bdd9d9a617c07ff971e2c3004. CLI upgrade still uses daemon.shutdown {ifIdle: true}. While a migration holds process activity, the daemon returns daemon_busy and the migration continues under the same task ID. For explicit graceful shutdown, the design proposes that the App Server coordinator await Migration’s settlement before quiescing Provider or draining Agent and RPC work. Migration owns cleanup and durable task status. The App Server owner still needs to confirm the integration point. Both paths now have separate acceptance cases.

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

Review: PR 2455 at d50cbbb

This PR defines the daemon-owned online v2 migration contract: Migration runs as a process plugin, each target owner publishes its own data and receipt, and CLI and local Web share one task ledger and one set of migration.* management methods. The new head keeps the design's earlier scope and ownership decisions, and it resolves the prior blocking shutdown point.

Shutdown and upgrade now separated

Point 4 follows the existing idle-only upgrade contract. stop_idle_for_update sends daemon.shutdown {ifIdle: true} (crates/dim-cli/src/client.rs:755-811), and an active migration processActivity hold makes the daemon answer daemon_busy (crates/dim-app-server/README.md:471-483), so the task continues under the same ID and the upgrade exits with the existing busy message. Point 5 handles explicit normal shutdown without ifIdle. The new App Server coordination paragraph places owner settlement before Provider quiesce, Agent settlement, RPC drain and tree unload, which matches the current coordinate order (crates/dim-app-server/src/lib.rs:1777-1809). The acceptance now has separate cases for upgrade refusal and explicit-shutdown settlement. This fully resolves the earlier shutdown objection.

The exact coordinator hook remains for the App Server owner to confirm, as the design states. The design supplies the required ordering and the ownership split, so this is a confirmation item, not a missing contract.

Verified

  • AgentBuilder::optional_plugin is an existing assembly hook (crates/dim-agent-scheduler/src/lib.rs:98, crates/dim-event-hub/src/lib.rs:111), and managementMethods, processActivity, fileStorage and fsHost are existing faces.
  • SqliteStorage::open_reporting holds <database>.sqlite.lock from open to close (crates/dim-app-server/src/storage/sqlite.rs:1602-1645), so the daemon's lock authority and the offline adapter's Native::open lease do not coexist.
  • copy_snapshot currently reads the whole file (crates/dim-migration/src/source.rs:1253-1261), fork chunks 256 logical sequence numbers (docs/design/appserver/native-storage-format.md:444), and the writer busy handler is about five seconds (crates/dim-app-server/src/storage/sqlite.rs:1525). The fixed-buffer copy and foreground budgets target the right constraints.
  • The eight migration.* methods, the Web entry allowlist, the CLI binding, the owner-operation anchors and the owner docs agree. git diff --check origin/main...HEAD is clean.
  • The design covers the earlier #2454 points: lifecycle and lock ownership, explicit shutdown, measurable p95/max and RSS budgets, and Global, Alpha and isolated-home scope.

P3, optional: state the no-daemon behavior of query commands

Problem. The proposed online binding says the explicit command connects to or starts the target daemon for start and retry. It does not say whether list, show, cancel or inspect also start a daemon or require a running one.

Failure scenario. After a reboot, dimcode migration list could start a daemon and open the native store only to list tasks. The current offline binding says queries and inspection do not open that database. The online design should say which behavior it chooses.

Evidence. docs/design/cli-commands.md:2681; docs/design/plugins/Migration.md:162 and :166.

Fix. Add one sentence to the online binding: these commands either require a running daemon, start one, or read the ledger without opening the native store. Add the chosen case to the CLI acceptance list.

Cross-PR

No other open PR changes these migration sections. #2345 also edits docs/design/cli-commands.md in the thinking-rendering section, so the file is shared but the sections do not overlap.

CI

Docs-only checks at this head: changes, evaluate-pr and issue-gate pass; macos-native and verify (linux) were still running when this review was written; code jobs skip. No tests were run for a docs-only change.

Verdict: APPROVE. The shutdown contract is split correctly, the coordinator ordering is explicit, and no blocking defect remains.

Comment thread docs/design/cli-commands.md Outdated
exit. There is no persistent Migration selection or automatic trigger. Imported
business configuration takes effect through normal feature loading.

**Proposed online binding ([Migration](plugins/Migration.md#在线任务合同提案)).** Keep the channel routing, flags, foreground wait, per-home report or distribution envelope, and exits above. The explicit command connects to or starts the target's normal native daemon and calls `migration.start`/`retry`, then reads status and the paged report for that ID. Ctrl+C explicitly requests `migration.cancel` and waits for settlement. A transport disconnect only loses the observation. Reconnect and query the accepted task before deciding the exit code. `interrupted`/`failed` return 1. `list/show/cancel` retain their existing JSON shapes (`cancel` returns a task report). `--source-stopped` still supplies the operator's confirmation for scripts. The confirmation asks only about legacy writers. A missing online method is reported without opening the target database independently. The terminal example below shows the current offline prompt.

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.

State whether list, show, cancel and inspect require a running daemon, start one, or read the ledger without opening the native store. After a reboot a read-only query could otherwise start a daemon and open the database, which the current offline binding avoids. See docs/design/plugins/Migration.md:162 and :166.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in ad02e518189f62a67f51dcd4f97031413e3ad70d. The proposed CLI contract keeps list and show available after a reboot by reading the migration ledger locally. A running record whose lease has ended is displayed as interrupted. inspect reads a temporary source snapshot after the operator confirms that the legacy writers have stopped. These queries leave the target daemon stopped and the target database closed.

cancel asks the live task owner to stop. If the daemon is down, a terminal or interrupted task returns its existing report. For a still-held lease whose owner is unreachable, the proposal is to return an error and leave the cancellation intent untouched. Does that last case match the behavior you expect? The new acceptance case covers both ledger formats, the JSON output and the absence of task-record mutations. CLI contract

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.

Fixed in ad02e51. The live-lease case is correct as written: with no reachable owner there is no one to observe a new cancel intent, so writing the marker would leave a stale intent behind. Returning the error and leaving the intent untouched lets the user retry once the owner is reachable, and the new acceptance checks that the task record and cancel intent are unchanged.

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.

Fixed in a86148a: docs/design/cli-commands.md:2820 now states that list, show and cancel connect without starting a daemon, stopped-daemon reads use the private ledger, and inspect runs locally.

@zerob13
zerob13 requested a review from yyhhyyyyyy December 2, 2026 05:04

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

Review: PR 2455 at ad02e51

This design PR defines the daemon-owned online v2 Migration contract. The new head only clarifies the stopped-daemon behavior of list, show, cancel and inspect, and adds coverage for it. The rest of the d50cbbb design is unchanged. The prior optional P3 is resolved, and the earlier shutdown P2 remains resolved.

Stopped-daemon behavior

The new CLI paragraph is consistent with the existing primitives:

  • run and retry use the target daemon or start one. list, show and cancel use connect_inner(..., start=false), which returns None instead of starting a daemon when none is running (crates/dim-cli/src/client.rs:1058-1071).
  • With no daemon, list and show read migration/tasks through the format 1/2 reader without opening the target store. Ledger::state already projects a running record whose run lease is free as interrupted in memory, without saving it (crates/dim-migration/src/ledger.rs:79-96); list and report reuse that projection.
  • cancel on a terminal or interrupted task returns the existing report and writes no marker. Migration::cancel only writes migration/tasks/<id>/cancel when the report is running (crates/dim-migration/src/lib.rs:234-240), so the local stopped-daemon path can return the report without touching the intent.
  • A live lease with no reachable owner returns an error and writes no marker. That is the right choice: an intent no live owner can observe would remain as a stale cancel, while the user can retry once the owner is reachable.
  • inspect remains local, requires the legacy-writer confirmation, and uses the existing source snapshot scan without opening the target store or creating a task (crates/dim-migration/src/lib.rs:242-274).
  • The new acceptance bullet covers both ledger formats, single-home and distribution JSON, lost-lease interruption, cancel on the interrupted task, the unreachable-owner error, and the no-mutation guarantee. It also states that the four commands neither start a daemon nor open the target database.

The Web entry has no local filesystem path and still admits only the eight migration.* methods, so this local-only behavior does not widen the Web allowlist.

Verified

  • The eight migration.* methods, the owner-operation anchors, the source matrix and the shutdown split are unchanged from d50cbbb.
  • git diff --check origin/main...HEAD is clean. The changed links and anchors resolve.
  • CI at this head: changes, ci-ok, evaluate-pr, issue-gate, macos-native and verify (linux) pass; other code jobs skip. No tests were run for this docs-only change.

Cross-PR

#2459 also edits docs/design/cli-commands.md and docs/design/plugins/Scheduler.md, but in the wakeup retirement sections. This PR's migration section and Scheduler conditional-import paragraph are separate from those changes.

Prior points

The d50cbbb shutdown P2 remains resolved. The prior P3 on no-daemon behavior is resolved by ad02e51. No other old point needs withdrawal.

Verdict: APPROVE. The stopped-daemon contract is explicit and consistent with the existing ledger, cancel, connect and source-snapshot primitives.

@zerob13 zerob13 changed the title 设计:v2 在线迁移的任务、提交与恢复合同 docs(design): define the v2 online migration task, commit and recovery contract Dec 2, 2026
@zerob13
zerob13 requested a review from yyhhyyyyyy December 2, 2026 08:58
@zerob13

zerob13 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

@eric8810 请复审 f365d800f,重点确认 App Server 的两个边界。Rpc 将已认证的 socket 或 Web 入口交给 Migration,由 Migration 筛选可见任务。显式关闭时,协调器在 Provider 停用前等待迁移结算;如果状态轮询收到关停错误或先断线,CLI 和 Web 等待重连,再用原任务 ID 查询。升级仍走 ifIdle,繁忙时任务继续。

本机 CLI 的报告第一页也固定了旧格式任务头和本次读取的对象视图。PR 正文中的三条评审项已链接到对应合同。

@eric8810

eric8810 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

已记录 f365d800f 以及 App Server 两个边界的说明(已认证入口交给 Migration 筛选,显式关闭等待迁移结算),本轮巡检只登记 PR 状态,复审和合并由维护者安排。

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

APPROVE

The new commit f365d80 closes the round-1 optional P3 and pins the entry-scoped behavior that was only hinted at before. It adds the trusted-entry scope model, the CLI task-record shapes for online and offline reads, and the shutdown/reconnect contract. I checked it against the four touched files and the referenced contracts.

Entry scope is coherent. Migration.md now states that the native socket sees every task of the target while the local Web entry sees only host-recognized pairs, that a Web query for a custom-source or unknown task answers not_found (matched by the acceptance case that the task stays untouched), and that clientKind cannot widen the scope. The mechanism is spelled out in management-methods.md (Rpc supplies MethodCall.origin.entry, name local for the native socket and web for the loopback entry, derived from the transport), and web-workspace.md moves path and target-override rejection to entry admission while the owner checks task IDs and cursors inside the scope. The A.1 dependency is real and honestly labeled: the grammar at session-boundary.md:203 defines origin.entry and the document states twice (lines 231, 637) that it is not implemented yet, so both proposal files marking it as required-and-unimplemented is accurate, not a dangling claim.

The read shapes are consistent across the two client documents. migration.list returns CLI task records on the socket and status.task summaries on the Web; the report's first page on the socket carries the same read-only view's task record while Web reports carry only object pages and a cursor. cli-commands.md composes show, cancel and the waiting commands from that same first-page record plus all object pages of the view, and the acceptance bullet now checks format: 1, the null rules, the retryOf omission and the fixed first-page view while paging a live task.

The reconnect contract is uniform. The shutdown section, the CLI command paragraph, the Web workspace paragraph and the terminal diagram all describe the same pair of cases: a status poll answered with -32603 (Server is shutting down) before dispatch, or a dropped connection; both show "Waiting to reconnect", re-query the original task ID, and map waiting-command exit codes from the durable terminal state. The service_reloading code now points at the admission-stopping phase, with the shutdown-flow RPCs deferred to the shutdown section, so the two codes no longer overlap textually.

Prior points: the round-1 optional P3 (online list/show/cancel/inspect behavior) is now specified and is withdrawn; inspect remains a local read by design. eric8810's shutdown-vs-upgrade separation and the coordinator ordering (4796e2b CR) stay as fixed in the earlier rounds, and this commit does not regress them; the upgrade-busy and explicit-shutdown acceptance cases remain separate. zerob13's only thread on the PR (inline 4764925134 area) is already closed by the ad02e51 fixes and needs no further reply. The Migration design document is the single Chinese source; the touched English files have no Chinese twins, so there is no cross-language drift.

CI at the head: changes, evaluate-pr, issue-gate and macos-native pass; verify (linux) was still running at review time. The PR remains docs-only.

Verdict: APPROVE. The entry-scoped contract, the read shapes and the reconnect behavior are mutually consistent and the A.1 dependency is explicit.

@Simon-He95 Simon-He95 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.

APPROVE

Reviewed f365d800 against current main. The design direction is correct and stays inside the existing ownership model: Migration remains a process plugin, sqliteStorage/SessionStore keep the native lock and publish the Session, each business owner validates and conditionally commits its own data and receipt, and the new migration.* methods are additive management methods registered through managementMethods. It does not add a second session store or a migration-specific Timeline path. The plan also explicitly marks the unimplemented origin.entry and the App Server shutdown coordination point as proposals for their owners instead of writing around them, which is the right boundary.

No blocking issue for the design PR. Please clarify these before implementation:

  1. Mixed response shapes for migration.list/migration.report. The table says the local socket returns the CLI TaskState while the authenticated Web entry returns the status.task summary, and the report first page follows the same split. One method returning two shapes by transport makes the management contract harder to type and test. Either state a single envelope with an entry-scoped optional task/source projection, or split the Web projection into its own method name; if the split is deliberate for path/secret redaction, say that in the table and add a test that the Web shape cannot carry sourceHome/current/raw paths.

  2. Receipt owner and deletion semantics need one explicit matrix. "原生格式与提交" says the online path still recognizes the existing migration/session/<digest>, migration/settings/<source>, migration/schedule/<digest>, Provider coverage and account migration:{id} records, and says the target owner saves/verifies them at its own write boundary. But it does not say where the online receipt physically lives for each target, which owner writes it in the same transaction, and how it survives deletion of the Session, Provider or schedule. The per-owner operations in resource-owner-operations.md imply the target owner's storage; make that explicit (owner, key, atomic write, delete behavior) so "target deleted, retry reports deleted" has a defined home for every kind.

  3. State the Web display/path boundary once. The design says paths are display values supplied by the host and reports omit raw contents/credentials. Please make the same statement for migration.notice pair labels and migration.status diagnostics, and add the acceptance check that the Web entry never receives a custom source.path, a raw path, or an occupier task ID it is not allowed to see.

  4. Implementation follow-ups: the current offline migration run/retry still stops the daemon and takes the exclusive lock; the online binding must preserve the documented flags, JSON and exit codes while switching to the daemon-owned path. The design says this, but the implementation PR should include the script-compatibility fixture (format 1 ledger, interrupt/cancel/retry) and the daemon_busy upgrade case described in the acceptance list.

The existing tested surface is otherwise coherent: processActivity holds, per-task cancellation, idempotent start by requestId, prepare/stage/publish/discard, source confirmation and the stopped-daemon read path all have explicit owners and failure behavior. I would approve the contract with the clarifications above folded in.

Icntaann added a commit to Icntaann/dim that referenced this pull request Dec 4, 2026
The module now has its process part: a plugin row whose methods are a
`#[rutis::service]` block, so the face is served by name with a catalog name
and any TypeScript or Python row reaches `preview` and `apply` as data,
without a hand-written dispatch.

`preview` serves the module's validation and plan. `apply` answers
`publish_unavailable`: publishing an imported Session belongs to SessionStore
(design §7, arcships#2455), and the module does not add a second publish path. The row
is not mounted in a product profile yet.

Refs arcships#2585

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

复审 f365d800。上轮关于两种关闭混在一起的意见已解决:空闲升级返回 daemon_busy,同一任务继续;显式关闭由 App Server 协调,在 Provider 停用、Agent 结算和 RPC 排空前等待 Migration 完成已接单写入并持久化终态。已认证的入口仍由 App Server 提供,Migration 据此筛选,客户端不能用 clientKind 扩权。

Design · Blocking:迁移的进程接纳必须覆盖后台任务,而不是 start/retry RPC。 当前合同 仍要求公开 hold() / release(holdId);#2021 的已定更正 用 keep(work) 取代它们。如果只把受理 RPC 包进 keep,返回任务 ID 或客户端断开就会释放接纳,迁移还没结算,下一次空闲升级却可能成功。请让 Migration 拥有独立于 RPC 和观察者的任务,覆盖接纳、受理落盘、执行、写入结算和终态;受理应答等落盘确认,不等任务跑完。调用未获接纳时不得开始迁移或写入 running。显式关闭的协调点仍由 App Server 所有者确认,不把它写成已生效机制。

验收:任务已受理后断开 CLI/Web,ifIdle 仍答忙且同一 ID 继续;反过来若空闲关闭已占先,回调不执行、不产生 running;显式关闭则在业务所有者停用前保存终态,重连按原 ID 读得到。这里是设计复审,未跑实现;未查到这个 head 的 GitHub CI run。

@zerob13
zerob13 requested a review from eric8810 December 6, 2026 03:28
@zerob13

zerob13 commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator Author

Updated in 589032523c1f7e97b3ff311fb86e14534695ed07. Migration’s background task owns the processActivity.keep(work) call. The RPC can return the task ID as soon as acceptance is durable; the callback continues through the last object write, cleanup and durable terminal state even if the CLI or Web connection closes. If idle shutdown pauses admission first, the callback never runs and the ledger gets no running record. If migration wins, ifIdle returns daemon_busy and the client can reconnect to the same task ID. Revised task contract · Admission decision

Both orderings are now explicit acceptance cases. The App Server coordination point for explicit shutdown remains a proposal for its owner to confirm. I checked the contract and local links, and the ADR freeze and diff checks passed. This is a design change; the runtime cases are specified for the implementation PR. Acceptance cases · Review addressed

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

REQUEST_CHANGES

Round 4 review of 589032523c1f7e97b3ff311fb86e14534695ed07 against origin/main 6ee758ad61b4ba13f2972fe8cae19eef26efaaab. The delta f365d800..58903252 is one docs commit, 9 insertions and 7 deletions in docs/design/plugins/Migration.md; it adopts #2021's processActivity.keep(work) contract. The admission model in the new step 2 and its acceptance case does not match the current process-activity contract.

Design

Blocking: keep cannot return paused to a start or retry caller

Layer. Design (admission ownership conflicts with the process-activity contract).
Root cause & same-source scope. Step 2 and the acceptance case say idle shutdown can pause admission before the start/retry background task calls keep, and that keep then returns paused (docs/design/plugins/Migration.md:181, :223). But every non-shutdown RPC holds process admission from dispatch until its response (crates/dim-app-server/src/connection.rs:438-446, :508-511), and idle shutdown pauses admission only at count zero (crates/dim-app-server/src/control.rs:99-103). While the RPC waits for {taskId}, its hold prevents the pause; if admission is already paused, the RPC is refused at dispatch (connection.rs:444-445) and keep is never called.
Failure path. The documented paused response and its test cannot occur for start or retry. An implementation following this text carries an unreachable branch and a test that cannot reproduce it; the observable refusal happens at RPC admission, before Migration.
Acceptance. Remove the paused path and that case from the start/retry flow, or state the admission scope that makes it reachable and update the test. Keep the reachable case: an already paused admission refuses the RPC at dispatch with service_reloading, with no ledger or object write.

Optional

  • Step 4 links crates/dim-app-server/README.md#process-activity, which still documents hold()/release(id) (README.md:479). State that #2021's keep surface lands with its implementation or update the reference, so readers do not see two contracts.

Prior findings and peer status

No prior findings; the previous three reviews approved earlier heads. This blocker is new in the delta, and no peer review exists at this head.

CI

At 58903252: changes and macos-native passed; verify (linux) and ci-ok failed after this review was posted, with capabilities_flow failing permission_flow::worktrees::git_unavailability_timeout_reload_and_session_close_do_not_publish_permission (765 passed, 1 failed); scripts, static-checks, acp-registry, dependencies and web are skipped by their gates. The failure's relation to this docs diff is not established.

Conflicts

origin/main 6ee758ad: merge-tree clean.

Blocks inspected

The changed online task contract and test plan (Migration.md:176-184, :219-224), the #2021 keep decision, the #2454 shutdown paragraph, the process-activity admission implementation and README, and the merge tree.

Not verified

The docs checks (adr-check, whitespace diff) were not run locally; verify (linux) and ci-ok failed after this review was posted; the full #2454 issue thread was not re-read.

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

APPROVE(设计)。上轮阻塞已解决:新版任务合同 由 Migration 的后台任务持有同一个 keep(work)。受理记录落盘后 RPC 才返回 ID,断开只结束观察;最后一次写入、清理和终态落盘后才释放接纳。新版验收分别钉住迁移先获接纳时升级答 daemon_busy、空闲关闭先暂停时回调无运行记录或对象写入,以及显式关闭先结算再拆业务所有者。回执丢失用原请求 ID 查找,不另起任务。

这里只批准设计修订。App Server 正常关闭协调点仍由该所有者确认,实现时再跑 CLI/Web 断连、两种接纳顺序和重连读回验收。作者报告 ADR/diff 检查通过;我未运行实现,核对时 GitHub CI 仍在运行。

@zerob13

zerob13 commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator Author

Fixed in 60ddbdc5eb1a7e849a25aa0d52a0ed1d75356a10. I checked the App Server dispatch path and the zero-count condition for an idle pause. An admitted start or retry already holds process admission while it waits for durable acceptance. Migration acquires its own admission within that interval and keeps it through terminal settlement. If idle shutdown pauses first, dispatch returns service_reloading before Migration runs. A transport already shutting down can instead report Server is shutting down or close. Revised contract

The acceptance cases now exercise refusal at dispatch with no ledger or object write, and daemon_busy after an accepted migration’s client has disconnected. The explicit-shutdown coordination point remains a proposal for the App Server owner. The ADR freeze, diff and local link checks passed. These are design changes; the runtime migration scenarios belong to the implementation PR. Acceptance cases · Review addressed

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

APPROVE(设计复审)。上一版已解决后台任务接纳跨过 RPC;这版又对齐了实际分派顺序:start/retry 等待落盘期间已有 RPC 接纳,Migration 在其仍有效时接上独立的任务接纳。空闲关闭抢先时在分派层拒绝,不进入 Migration、不写账本;已受理并断开后仍忙到终态。新版合同 · 上轮发现

显式关闭的协调点仍是待 App Server 所有者确认的提案,运行时验收留给实现。核对文档增量和 main 的分派/空闲暂停逻辑,未运行实现;本 head 的 CI 尚未结束。

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

APPROVE

Round 5 review of 60ddbdc5eb1a7e849a25aa0d52a0ed1d75356a10 against origin/main 6ee758ad61b4ba13f2972fe8cae19eef26efaaab. The delta 58903252..60ddbdc5 is one docs commit, 4 insertions and 4 deletions in docs/design/plugins/Migration.md. It resolves the round-4 paused-path blocker; peer review 6208203342 is APPROVED at this head, referenced, not repeated.

Design

No blocking finding. The new admission narrative matches the code: dispatch takes process admission before the handler and holds it through the acceptance reply (crates/dim-app-server/src/connection.rs:438-447, :508-511, :549-561); idle shutdown pauses admission only at count zero (crates/dim-app-server/src/control.rs:99-103); a paused admission fails the dispatch hold (connection.rs:444-445), so the request never reaches Migration. Step 2 now states that the RPC's dispatch-time admission is still held when the background task acquires its own keep admission, which closes the round-4 gap.

Structure

No blocking finding. Step 3 retains keep's admission through terminal settlement; step 5 settles explicit shutdown inside work before the coordinator proceeds; step 4's daemon_busy matches the activity hold. The test plan covers the busy case, the dispatch-level refusal, the lost acceptance reply, and explicit-shutdown ordering.

Resolved and withdrawn

  • The round-4 blocker is resolved: step 2 no longer claims keep returns paused in this flow, and the acceptance case now expects dispatch-level service_reloading with no Migration handler, no running record and no object write (docs/design/plugins/Migration.md:181, :223).
  • The prior Optional is resolved: step 4 now links README.md#shutdown-completion (crates/dim-app-server/README.md:467), which states the idle-shutdown contract; the keep surface remains a recorded dependency of this proposal.

CI

At 60ddbdc5: changes, macos-native, verify (linux) and ci-ok passed; scripts, static-checks, acp-registry, dependencies and web are skipped by their gates.

Conflicts

origin/main 6ee758ad: merge-tree clean.

Blocks inspected

The changed admission text and acceptance cases (Migration.md:176-184, :219-224), the #2021 keep decision, the #2454 shutdown paragraph, the dispatch and admission paths in connection.rs and control.rs, the README shutdown-completion section, and the merge tree.

Not verified

No docs checks (adr-check, whitespace diff) ran locally; ci-ok passed after this review was posted; the full #2454 issue thread was not re-read.

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

APPROVE

Round 6 review of a86148a7c6e0839aec9c35cbfafe13dc04c3ab0c, the merge of origin/main db3d816c into the PR branch, at base db3d816c72ae3174d75956ac4f45607a4cd07c0f. The merge changes no PR text: the 10 docs files still add +200/-20, and the old and new added/removed lines are identical. No new blocker.

Merge and design check

  • The merge brings #2561 and #2611 into the base; it leaves the PR patch byte-identical and no conflict markers remain. The affected sections still agree with current main: management-methods.md:128-138 says origin.entry is unimplemented, matching session-boundary.md:231,641; the web allowlist, CLI migration, provider, settings, Scheduler and owner-operation additions keep their referenced anchors.
  • The prior round-4 Design blocker (process admission held through dispatch; idle pause only at count zero) remains resolved. The one existing thread (comment 4764925134) is addressed by the new daemon-behavior text at docs/design/cli-commands.md:2820; a reply records the fix and the thread stays open in the UI.

CI and conflicts

At a86148a7: changes, macos-native, verify (linux) and ci-ok passed; scripts, static-checks and windows-cli were skipped for this docs-only change. Merge-tree against origin/main is clean; no conflicts with #2399 or #2606; #2489 and #2493 overlay conflicts remain in unrelated code files.

Blocks inspected

Full main...head at the new base, all 10 docs changes and referenced anchors, the merge resolution, existing threads, CI and merge trees.

Not verified

No local docs or code suite ran; CI passed after this review was prepared. The head may move.

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

批准 a86148a7 的设计复审。同步主线没有改变先前批准的迁移合同:RPC 持有接纳到受理落盘,Migration 的后台接纳覆盖到终态;空闲关闭抢先则在分派层拒绝,不写账本。显式关闭协调点仍待 App Server 所有者确认,CLI/Web 断线与回执验收留给实现。

核对了同步后的文档增量和相邻合同。同提交 CI 复跑后 Linux、macOS 原生及总门禁通过;首次 macOS OCR 大结果测试超时,不把复跑通过当成其根因已修复。未运行迁移实现;本批准不代替合并门槛。

@Simon-He95 Simon-He95 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.

Reviewed a86148a7c6e0839aec9c35cbfafe13dc04c3ab0c (docs(design): define the v2 online migration task, commit and recovery contract, refs #2454). 10 files, +200 −20.

Scope: The two PR-own commits since the bot's last review at f365d800: 589032523 (keep process admission through task settlement) and 60ddbdc5e (place idle shutdown refusal at RPC dispatch), plus the merge a86148a7 that only moves the base to origin/main; the PR text remains 10 docs files +200/−20. I did not re-review 72c4b446..f365d800.

Direction: The new commits close the peer's admission gap rather than papering over it. App Server now takes process admission at dispatch before migration.start/migration.retry, holds it through the acceptance reply; Migration's background task takes keep(work) while that admission is still held, and the callback keeps it to terminal state. Idle shutdown can only pause at zero admission, so the refusal moves to dispatch (service_reloading) and never enters Migration. That is the minimal mechanism: it reuses processActivity and managementMethods, adds no second task ledger, and leaves target-owner receipts where they already belong. The explicit-shutdown coordination point stays a proposal for the App Server owner, which is the right boundary.

Architecture: Migration owns tasks; App Server owns process admission and shutdown; each target owner commits its data and receipt. The text now states the two-layer admission explicitly (dispatch admission + background work admission), so there is no zero-count window between the reply and settlement. The keep(work) contract is cited from #2021 comment 7442146346; the link anchor ../../../crates/dim-app-server/README.md#shutdown-completion exists. The explicit-shutdown order is stated consistently in §2 and §5: Migration stops accepting, settles within the same work, then business owners deactivate; the coordinator waits. The acceptance list was updated for both the daemon_busy upgrade path and the paused-at-dispatch path, and the obsolete keep returns paused formulation was removed.

App Server surface: The PR changes the design of migration.* management methods and the process-admission/shutdown contract, but no app-server, protocol or generated file changes.

App Server surface

Changed: no method/parameter/reply change. The proposal adds the processActivity.keep(work) operation and an explicit-shutdown coordination point for the App Server owner; migration.start/retry are dispatched under a process admission that is held through the acceptance reply.

Consumers: CLI and local Web migration.*; the offline migration run/retry path that must move to the same online entry; the App Server's idle/normal shutdown paths.

Classification: not breaking for current clients (docs only); additive to the process owner. The proposal still needs owner confirmation, as the document states.

Required: App Server owner acceptance of keep(work) and the shutdown coordination point; the implementation PR must preserve the documented flags, JSON and exit codes and add the script-compatibility and daemon_busy fixtures.

Prior findings

  • f365d800 clarification 1 (mixed migration.list/report shapes between local socket and Web): not addressed by these two commits; unchanged, non-blocking.
  • f365d800 clarification 2 (receipt owner/atomic write/delete matrix): not addressed; unchanged, non-blocking.
  • f365d800 clarification 3 (Web display/path boundary for notice/status): not addressed; unchanged, non-blocking.
  • f365d800 item 4 (script compatibility + daemon_busy): the new acceptance bullet covers daemon_busy and the paused-at-dispatch path; script compatibility remains as stated.
  • The peer blocker at f365d800 (process admission must cover the background task, not just the start/retry RPC) is resolved by 589032523; 60ddbdc5e correctly moves the refusal to dispatch and fixes the anchor to #shutdown-completion.

Verified

  • Read the two commit diffs: f365d800..589032523 (9/+7, Migration.md) and 589032523..60ddbdc5e (4/+4, Migration.md); confirmed the merge a86148a7 keeps the PR text at 10 docs files +200/−20.
  • Checked #2021 comment 7442146346 exists and describes the keep(work) correction.
  • Checked crates/dim-app-server/README.md has ### Shutdown completion; checked #2454 is an accepted P2 issue.
  • gh pr checks 2455: changes, ci-ok, macos-native and verify (linux) passed; static-checks, scripts, web, windows-cli, acp-registry and dependencies skipped (docs-only).

Not verified

  • Did not re-review 72c4b446..f365d800; only the two new commits and the merge delta.
  • Did not verify the proposed keep(work)/dispatch-admission API exists in crates/dim-app-server; it is explicitly a proposal. The current ServerControl/ProcessActivity does not expose it.
  • Did not verify the eventual App Server shutdown ordering against the coordinator implementation; the PR marks it 待 App Server 所有者确认.
  • No runtime or script fixtures run (docs-only).

Verdict: APPROVE — the two commits resolve the background-task admission gap coherently and keep the owner boundary; the remaining items are unchanged implementation-stage clarifications.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants