Skip to content

Migrate worktree and process loader callers - #1907

Closed
eric8810 wants to merge 14 commits into
mainfrom
eric/1292-domain-worktrees-loader
Closed

eric8810 wants to merge 14 commits into
mainfrom
eric/1292-domain-worktrees-loader

Conversation

@eric8810

@eric8810 eric8810 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #1292

Caller Owner and API
Session creation and worktree management managedWorktrees.create({source,base?,branch?}), discard(created), list({}), pruneSelection({olderThanMs?,keep?,force}), remove({taskId,force}). The execution node creates or discards the worktree. SessionStore owns its Session association.
PluginManager Reload an installed row through rutis/loader.reload(id). Installation and removal reconcile the configured plugin layer.
Foreign plugins The existing rutis/loader.status() reports loader state. Dim configures no editable layer.
Native assembly and RPC Agents creates group instances with their original parent and profile. RPC reads the native instance chain and distinguishes inactive, unloading and stopped rows for method admission. PluginManager reads row options, provider instance identities and structured waits to report configured plugins. These use the loader’s private runtime handle.

The public catalog contains managedWorktrees; the native loader catalog entry is removed.

Local verification includes 61 transport tests across PluginManager, worktrees and Session namespace reload, the Agent profile flow, three Node flows (worktree operations, installed plugin replacement and loader operations), strict TypeScript on the worktree fixture and xtask check.

@eric8810 eric8810 mentioned this pull request Nov 20, 2026
6 of 45 tasks
@eric8810
eric8810 marked this pull request as ready for review November 20, 2026 13:18

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

Static review of 6528215a0507a5f5ed869add7ee43d22862da7c8 against main at ffd3e11623267f15e11421aa419532e131da82cb.

  1. [P1] Verify the preparation identity in worktree cleanup. Resolve the preparation from state held by ManagedWorktrees and validate its identity at the cleanup boundary. Keep the existing SessionStore ownership exclusion around the cleanup. Worktree dispatch · Owner cleanup
  2. [P2] Keep the preparation owned through handoff. The owner should retain responsibility for a prepared worktree until the result is handed off or the owner completes uncancelled cleanup. Make that settlement part of the wire creation lifecycle. Worktree dispatch · Worktree ownership contract
  3. [P2] Scope failed reload settlement to the requested operation. Preserve PluginManager’s reply boundary by settling the target reload on failure without a process-wide settlement barrier. PluginManager reload · rutis loader service

Strict TypeScript on the new fixture, the ADR freeze check, and git diff --check passed locally. Rust checks were not run locally. Latest exact-head CI was queued on Linux and queued on macOS. Linux job · macOS job

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

Moves managed-worktree operations and installed-plugin reload onto their owner faces: managedWorktrees becomes a shared data face, PluginManager reloads through rutis/loader.reload, and the native loader catalog name is removed. The typed owner stays private wiring, read by type key. Reviewed the full ffd3e116...6528215a diff, the new face and fixture, the generated catalog and service graph, the contracts, and the overlapping owner-move PRs.

No blocking findings. Approving with one docs note and two optional inline notes.

P3, docs. docs/design/worktree-management.md:137 says the only new public content is the managementMethods worktree namespace and the hello.features entries; :83 describes only the three management methods, and :39 names session.create and sessions.launch as the entries. The public catalog now also exposes managedWorktrees with create/discard/list/pruneSelection/remove (docs/architecture/rust-agent/generated/catalog.md:32), the binding already listed in docs/design/contracts/process-owner-operations.md:29. The contract row predates this PR, but the design doc matched the code until the face landed, so this is the change that makes section 4.7 stale. A plugin author following the worktree design would not learn the face exists, and a maintainer could later treat section 4.7 as still authoritative and refuse or remove it. Fix: name the face in sections 3 and 5, and either add it to the 4.7 answer or scope that answer to client-facing content.

Verification: cargo check --workspace --all-targets --locked; cargo clippy -p dim-app-server --all-targets --locked -- -D warnings; CI-style cargo fmt --all -- --check --config error_on_line_overflow=true; cargo run -p xtask -- check; node scripts/adr-check.mjs --base ffd3e116; transport_flow worktree (10 passed, 2 ignored); transport_flow plugin_manager (51 passed, 3 ignored); dim-app-server --lib (125 passed); dim-agent-runtime --tests (25 passed); merge-tree against ffd3e116 clean. Node-backed flows were not run because this checkout has no runtime/node_modules; CI covers them. CI is still pending on verify (linux) and macos-native.

Conflicts: merge-tree is clean against ffd3e116, #1910, #1913, and #1902. It conflicts textually with #1904 (npm/plugin.d.ts), #1911 and #1900 (crates/dim-app-server/src/lib.rs), and #1908 (crates/dim-app-server/src/connection.rs). These shared files and the generated catalog and service docs need the usual regeneration after rebase.

Comment thread crates/dim-app-server/src/lib.rs Resolved
Comment thread npm/plugin.d.ts Resolved
@eric8810

Copy link
Copy Markdown
Collaborator Author

Worktree cleanup now matches the returned descriptor to the owner’s preparation. Under SessionStore’s ownership exclusion, rollback checks the directory, Git repository, checked-out branch and original commit before removing the worktree.

Wire creation keeps the preparation until the caller accepts the result. Abandoning delivery rolls back the checkout with an independent cancellation token. The handoff regression exercises this window with a real Git repository and verifies both the directory and branch disappear. The Node fixture also verifies that changing the branch in the descriptor is refused and that the original preparation can still be discarded.

All 10 transport worktree tests, the handoff regression, strict TypeScript and App Server Clippy passed. The separate review item on failed loader reload settlement remains open.

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

Moves managed-worktree operations and installed-plugin reload onto their owner faces: managedWorktrees becomes a shared data face, PluginManager reloads through rutis/loader.reload, and the native loader catalog name is removed. At this head the owner also keeps the preparation through the create handoff, closes its tracker before unload, and verifies the directory, repository, branch and creation commit before rollback. Re-reviewed the full ffd3e116...9faa3d78 diff, not only the delta, plus the new handoff and rollback code, the fixture, the contracts and the generated catalog.

The two round 1 inline notes are fixed: the misleading lib.rs comment is removed, and CreatedWorktreeReply is gone in favor of WorktreeReply. The preparation identity and handoff ownership items from the earlier review are addressed at this head.

One P2, inline at crates/dim-app-server/src/worktrees.rs:363: an annotated tag used as worktree.base makes the new rollback identity check fail, so a failed Session creation or an abandoned face create silently leaves the checkout and branch behind with no record. Details and fix are in the thread.

P3, optional, docs. docs/design/worktree-management.md:125 still says ManagedWorktrees acts only on user commands or Session creation, while the new section 5 (:86) and 4.7 (:142) say plugins call managedWorktrees.create/discard/list/pruneSelection/remove. A plugin can call these outside either flow, so the section 6 summary is now narrower than the face. Fix: include plugin calls through the face in that cell, or scope it to the client entries.

On the open loader failure-settlement item I would not block: rutis/loader.reload waits for the loader to settle on failure inside the owner service (rutis-loader-0.23.0/src/loader/service.rs:98), so the wait is the owner's contract rather than a Dim caller bug; changing it needs an upstream loader change.

Verification at 9faa3d78: cargo fmt --all -- --check --config error_on_line_overflow=true; node scripts/adr-check.mjs --base ffd3e116; cargo test -p dim-app-server --lib worktrees (the new handoff regression passed); cargo test -p dim-app-server --test transport_flow worktree (10 passed, 2 ignored); cargo test -p dim-app-server --test transport_flow plugin_manager (51 passed, 3 ignored); cargo run -p xtask -- check; cargo clippy -p dim-app-server --all-targets -- -D warnings. Node-backed flows were not run locally because this checkout has no runtime/node_modules; CI's transport_flow node_ --ignored step covers the new ignored test. CI at this head: macos-native passed, verify (linux) queued.

Conflicts: merge-tree is clean against ffd3e116, #1910, #1913, #1951, #1952 and #1902. It conflicts textually with #1908 (crates/dim-app-server/src/connection.rs), #1904 (npm/plugin.d.ts), and #1911 and #1900 (crates/dim-app-server/src/lib.rs); these are shared-file conflicts, and the generated catalog and service docs need regeneration after rebase.

Comment thread crates/dim-app-server/src/worktrees.rs Resolved

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

Moves managed-worktree operations and installed-plugin reload onto their owner faces: managedWorktrees becomes a shared data face, PluginManager reloads through rutis/loader.reload, and the native loader catalog name is removed. Reviewed the full origin/main...9eafe690 diff, not only the 2-line delta, plus the worktree face and its preparation state, the rollback path, the loader callers, the fixture, the contracts and the generated catalog.

The round 2 P2 is fixed and should be withdrawn. create now resolves the base as <base>^{commit} and stores that commit (crates/dim-app-server/src/worktrees.rs:200-205), so the rollback identity check at line 363 compares the checked-out commit for annotated tags, lightweight tags, branches, remote refs and raw SHAs alike. I reproduced the old mismatch locally: rev-parse --verify returned the tag object while git worktree add checked out the tagged commit, and the old comparison failed; with the new peel the stored base equals the worktree HEAD and the rollback proceeds. The round 1 preparation identity and handoff ownership fixes also remain in place: face discard resolves the preparation by task id and compares the full delivered reply (crates/dim-app-server/src/worktrees/face.rs:129-143), and the owner retains a preparation through handoff and discards it when delivery is not accepted (crates/dim-app-server/src/worktrees/face.rs:70-87).

One blocking finding.

P2, CI. verify (linux) at 9eafe69 fails rustfmt on the new call at crates/dim-app-server/src/worktrees.rs:202, and ci-ok fails with it. cargo fmt --all -- --check --config error_on_line_overflow=true reproduces the same diff locally. The required check stops before clippy and tests run, so the PR cannot land as it is even though the body says formatting passed locally. Fix: run cargo fmt --all and push; the logic otherwise passes the targeted checks below.

P3, optional, docs. The round 2 docs note is still open. docs/design/worktree-management.md:125 says ManagedWorktrees acts only on user commands or Session creation, while section 5 (line 86) and section 4.7 (line 142) say plugins call managedWorktrees.create/discard/list/pruneSelection/remove. A plugin can call these outside either flow, so the section 6 summary is narrower than the face. Fix: include plugin calls through the face in that cell, or scope it to the client entries.

P3, optional, test gap. The round 2 thread asked for an annotated-tag rollback test; the fix has none. The existing rollback test covers a failed association with the default HEAD base (crates/dim-app-server/tests/transport_flow/sessions_launch_worktree.rs:245-340), and no test passes a tag as worktree.base. A regression test would pin the peel and the rollback identity. I verified the behavior with local Git only.

On the open loader failure-settlement item from the earlier review I would not block, as in round 2: rutis/loader.reload waits for the loader to settle on failure inside the owner service (rutis-loader 0.23.0 src/loader/service.rs:98), so the wait is the owner's contract rather than a Dim caller defect; changing it needs an upstream loader change.

Verification at 9eafe69: fmt fails as above; node scripts/adr-check.mjs --base ffd3e116 passes; cargo run -p xtask -- check passes; cargo test -p dim-app-server --lib worktrees (1 passed); cargo test -p dim-app-server --test transport_flow worktree (10 passed, 2 ignored); cargo test -p dim-app-server --test transport_flow plugin_manager (51 passed, 3 ignored); cargo clippy -p dim-app-server --all-targets --locked -- -D warnings passes. Node-backed flows were not run locally because this checkout has no runtime/node_modules; CI's transport_flow node_ --ignored step covers them once the format failure is fixed. CI at this head: macos-native passed, verify (linux) failed, ci-ok failed.

Conflicts: merge-tree is clean against origin/main (currently 44f0dd4, newer than the stated e6833df), #1910, #1913, #1951, #1952 and #1902. It conflicts textually with #1908 (crates/dim-app-server/src/connection.rs), #1911 and #1900 (crates/dim-app-server/src/lib.rs), and #1904 (npm/plugin.d.ts); these are shared-file conflicts, and the generated catalog and service docs need regeneration after rebase.

Verdict: REQUEST_CHANGES for the format failure. The annotated-tag fix and the rest of the PR are otherwise ready.

Comment thread crates/dim-app-server/src/worktrees.rs Resolved

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

Moves managed-worktree operations and installed-plugin reload onto their owner faces: managedWorktrees becomes a shared data face with create, discard, list, pruneSelection and remove, PluginManager reloads through rutis/loader.reload, and the native loader catalog entry is removed. Reviewed the full origin/main...0cae1803 diff, not only the delta since 9eafe69, plus the face and its preparation state, the rollback path, the loader callers, the fixture, the contracts and the generated catalog.

The round 3 format finding is fixed and should be withdrawn: cargo fmt --all -- --check --config error_on_line_overflow=true passes at this head, and CI verify (linux) passed. The round 2 annotated-tag finding stays fixed: create resolves the base as <base>^{commit} (crates/dim-app-server/src/worktrees.rs:200-209), so the rollback comparison at crates/dim-app-server/src/worktrees.rs:362-367 sees the checked-out commit for annotated tags, lightweight tags, branches, remote refs and raw SHAs. I reproduced the peel locally: the annotated tag object SHA differs from the tagged commit, so the old stored base could not equal the worktree HEAD, while the peeled value does. The round 1 inline notes remain fixed: no stale managedWorktrees comment in lib.rs, and no duplicate CreatedWorktreeReply in npm/plugin.d.ts. zerob13's preparation identity and handoff ownership items remain fixed: face discard matches the full delivered reply before resolving the preparation (crates/dim-app-server/src/worktrees/face.rs:128-146), and the owner retains it until delivery is accepted, discarding on abandonment (crates/dim-app-server/src/worktrees/face.rs:70-97).

No blocking findings.

P3, optional, docs. The round 2 docs note is still open. docs/design/worktree-management.md:125 still says ManagedWorktrees acts only on user commands or Session creation, while section 3 (line 39), section 5 (line 86) and section 4.7 (line 142) say plugins call managedWorktrees.create/discard/list/pruneSelection/remove. A plugin can call these outside either flow, so the section 6 summary is narrower than the face; a maintainer reading the impact table would not learn that plugin calls are supported. Fix: include the face operations in that cell, or scope the sentence to the client entries.

P3, optional, test gap. The round 2 request for an annotated-tag rollback test is still open. The rollback test covers a failed association with the default HEAD base (crates/dim-app-server/tests/transport_flow/sessions_launch_worktree.rs:245-340), and no test passes a tag as worktree.base. A later change to the base resolution or to the identity check could reintroduce the silent residue with no test failure. Fix: add an annotated-tag case that fails the association and asserts the checkout and branch are gone.

On the open loader failure-settlement item from zerob13's review I would not block: rutis/loader.reload waits for the loader to settle on failure inside the owner service (rutis-loader 0.23.0 src/loader/service.rs:92-100), so the wait is the owner's contract rather than a Dim caller defect; changing it needs an upstream loader change.

Verification at 0cae180: cargo fmt --all -- --check --config error_on_line_overflow=true; node scripts/adr-check.mjs --base origin/main; cargo run -p xtask -- check; cargo test -p dim-app-server --lib worktrees (1 passed); cargo test -p dim-app-server --test transport_flow worktree (10 passed, 2 ignored); cargo test -p dim-app-server --test transport_flow plugin_manager (51 passed, 3 ignored); cargo clippy -p dim-app-server --all-targets --locked -- -D warnings. Node-backed flows were not run locally because this checkout has no runtime/node_modules; CI verify (linux) passed, including the Verify public Node bindings step, which runs the new ignored test through transport_flow node_ --ignored (the runtime/ and npm/ changes select the node group). CI at this head: verify (linux), macos-native and static-checks passed; ci-ok was still pending when I checked.

Conflicts: the head merges origin/main at 9d1d2e3, so there is no conflict with main. merge-tree is clean against #1899, #1900, #1902, #1903, #1904, #1905, #1906, #1908, #1910, #1911, #1912, #1913, #1917, #1970 and #1306. It conflicts textually with draft #1909 on crates/dim-app-server/src/lib.rs. The generated catalog and service docs need the usual regeneration after a rebase.

Verdict: APPROVE.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Addressed the two remaining worktree notes in 1052c75. The association-failure flow now starts from an annotated tag and verifies that both the branch and the checkout are removed. The focused test passed locally. The impact table now includes plugin calls. For the reload concern, Dim awaits one public rutis/loader.reload call for the requested row. The pinned loader itself calls settled() after a reload error, before returning its diagnostic. Dim cannot narrow that wait through this API. Keeping the owner call preserves the agreed migration. Please re-review this point and the worktree changes.

@eric8810
eric8810 requested a review from yyhhyyyyyy November 21, 2026 15:23

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

Moves managed-worktree operations and installed-plugin reload onto their owner faces: managedWorktrees becomes a shared data face with create, discard, list, pruneSelection and remove, PluginManager reloads through rutis/loader.reload, and the native loader catalog entry is removed. Reviewed the full origin/main...1052c758 diff, not only the delta since 0cae180, plus the face and its preparation state, the rollback identity check, the loader callers, the fixture, the contracts and the generated catalog.

Both round 4 P3s are fixed and should be withdrawn. The rollback test now creates an annotated launch-base tag, fails the association through a SQLite trigger, and asserts the managed root is empty, the failed-launch branch is gone, and the retry succeeds (crates/dim-app-server/tests/transport_flow/sessions_launch_worktree.rs:299-351). I reproduced with Git that git worktree add peels the tag object to the commit, so without the ^{commit} resolution at crates/dim-app-server/src/worktrees.rs:200-209 the identity check at crates/dim-app-server/src/worktrees.rs:366-367 would refuse the rollback and the new assertions would catch the residue. The docs note is also fixed: docs/design/worktree-management.md:125 now includes plugin calls through managedWorktrees, consistent with section 3 (line 39), section 5 (line 86) and section 4.7 (line 142).

The earlier fixes remain in place. The round 3 format failure is gone. The round 2 base resolution peels the requested revision to the checked-out commit. The round 1 inline notes are gone: no stale managedWorktrees comment in crates/dim-app-server/src/lib.rs and no duplicate CreatedWorktreeReply in npm/plugin.d.ts. zerob13's preparation identity and handoff ownership items hold: face discard matches the full delivered reply before resolving the preparation (crates/dim-app-server/src/worktrees/face.rs:128-143), and the owner retains the preparation until delivery is accepted, discarding it on abandonment (crates/dim-app-server/src/worktrees/face.rs:70-98).

On zerob13's loader failure-settlement item I would not block, as in the earlier rounds: rutis/loader.reload waits for the loader to settle on failure inside the owner service (rutis-loader 0.23.0 src/loader/service.rs:92-101), so the wait is the owner's contract and changing it needs an upstream loader change. No other findings, blocking or optional.

Verification at 1052c75: cargo fmt --all -- --check --config error_on_line_overflow=true; node scripts/adr-check.mjs --base origin/main; cargo run -p xtask -- check; cargo clippy -p dim-app-server --all-targets --locked -- -D warnings; cargo test -p dim-app-server --lib worktrees (1 passed); cargo test -p dim-app-server --test transport_flow managed_launch_refuses_conflicts (1 passed, the new annotated-tag case); cargo test -p dim-app-server --test transport_flow worktree (10 passed, 2 ignored); cargo test -p dim-app-server --test transport_flow plugin_manager (51 passed, 3 ignored). Node-backed flows were not run locally because this checkout has no runtime/node_modules; CI runs the new ignored test through transport_flow node_ --ignored.

CI at this head: macos-native and static-checks passed; verify (linux) was still running when I checked.

Conflicts: the head merges origin/main at 9d1d2e3, so there is no conflict with main. merge-tree is clean against #1902, #1903, #1905, #1910, #1913 and #1917. It conflicts textually with #1899, #1900, #1906, #1909, #1911 and #1912 on crates/dim-app-server/src/lib.rs, with #1904 on npm/plugin.d.ts, and with #1908 on crates/dim-app-server/src/connection.rs and docs/design/contracts/process-owner-operations.md. These are shared registration lists, declarations and generated files; no other PR changes the loader catalog or managedWorktrees, so the conflicts are textual and need the usual regeneration after a rebase.

Verdict: APPROVE.

@eric8810

Copy link
Copy Markdown
Collaborator Author

未完成所有者调查就开始的改动,关闭。后续按 #2015 的扫描结论重新设计,对应 #2018。分支保留,供重新设计时参考。

@eric8810 eric8810 closed this Nov 23, 2026
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.

3 participants