Skip to content

Migrate special Settings sources and trusted callers - #1902

Closed
eric8810 wants to merge 15 commits into
mainfrom
eric/1292-domain-settings
Closed

eric8810 wants to merge 15 commits into
mainfrom
eric/1292-domain-settings

Conversation

@eric8810

@eric8810 eric8810 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #1292

Final calls and APIs

Caller Operation
PluginManager and declared-source owners Existing settings.register, declaredBy, projects, read and update.
Agents create/restore, Hooks and MCP project admission settings.authorizeProject({cwd}) returns the root number and publishes the existing authorization notice.
Scheduler, Modality, SkillsCatalog, PermissionRules, CollaborationModelPolicy, Hooks and MCP Native owners call Settings::register_document::<D> and use its bound read and update operations.
Cross-language document owners settings.registerDocument({source,userFile,projectFile?},codec) returns read(scope) and update(scope,expectedRevision,document). Both return the revision and document. The codec supplies decode(bytes or null) and validate(document).
Session permission decisions Existing commandRules.read({}) reads the permission owner's registered document on each call.
Collaboration member creation collaborationModelPolicy.read({}) → {revision,policy} when the local execution profile supplies the policy.
Session Hooks hooksService.sources({cwd}) returns the existing source snapshot.
MCP management and publication MCP owns the source registrations, reads the secret records internally and returns its existing redacted business views.
Local Settings client writes and SQLite persistence Keep the Settings owner's client-write path and SQLite readUser, importUserIfAbsent and replaceUser operations.

Source registrations end with the registering row. A later registration of the same name gets its own binding. Custom codecs run outside storage transactions. The public catalog exposes settings; the Rust storage implementation stays inside its owner.

@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 07:17

@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 found two Settings correctness issues that block approval. A write can outlive its source registration, and a file-backed update holds an exclusive lease while waiting for a plugin decoder. The inline comments identify the affected paths and suggest fixes.

Comment thread crates/dim-app-server/src/settings.rs Resolved
Comment thread crates/dim-app-server/src/settings.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.

This PR moves the special Settings sources (Scheduler, Modality, SkillsCatalog, PermissionRules, CollaborationModelPolicy, Hooks, MCP) to settings.registerDocument with source-bound read/update, moves collaboration policy, permission rules and Hooks/MCP reads to their owners, and retires the public settingsService name. The ownership split, revision handling and the MCP secret boundary look right, and the targeted tests pass. The findings below are P2 and block.

P2: custom codecs run under the file lease, contrary to the PR text

Problem: the PR says "Custom codecs run outside storage transactions", but for file-backed scopes SettingsService::replace decodes the stored document while holding the exclusive file lease (crates/dim-app-server/src/settings.rs:546-547), and snapshot calls format.decode at crates/dim-app-server/src/settings.rs:643. For Kind::Custom that decode is a foreign call into the plugin (crates/dim-app-server/src/settings/document.rs:21-60). The narrower contract sentence, "Foreign codec calls occur outside SQLite transactions" (docs/design/contracts/resource-owner-operations.md:151), is accurate; only the file-lease path contradicts the PR text.

Failure scenario: a codec whose decode awaits, or calls back into the update it got from registerDocument, holds the settings file's write lease. A concurrent settings.update on the same source (client UI, a management path, or another session sharing the home) spins in SettingsService::lease (crates/dim-app-server/src/settings.rs:577-587) until its cancel token fires, and a reentrant update from inside decode deadlocks because the outer replace awaits decode while decode awaits the lease. Before this PR decode was synchronous Rust, so this call site could not run foreign code.

Fix: do not decode the stored document for custom sources under the lease. RegisteredDocument::update passes a no-op check (crates/dim-app-server/src/settings.rs:251-264), so the decoded current document is unused; compare the revision from the raw bytes and skip the foreign decode, or decode outside the lease and re-check the revision under it. If the intended contract is only the SQLite path, say so in the PR text instead of "storage transactions".

P2: settings-service.md contradicts itself and the code on the Rust binding

Problem: section 4.2 adds registerDocument and authorizeProject (docs/design/appserver/settings-service.md:215-216), but section 1 still enumerates the service as register, read, update, projects (lines 20-21), and section 4.5 says "It provides register(ctx, declaration), read(source, scope, cancel), update(source, scope, expected, document, cancel) and projects()" (lines 318-319). The same section still says "PluginManager's declared-source tools also use it [SettingsService] for reads and owner writes" (lines 325-326), while PluginManager now injects Key<Settings> and calls declared_by (crates/dim-app-server/src/plugin_manager.rs:14, 684, 2128-2145). The ZH mirror has the same stale spots (docs/zh/design/appserver/settings-service.md:19 and 277-284).

Failure scenario: an implementer using section 4.5 as the complete Rust binding misses register_document and authorize_project, and anyone following the PluginManager sentence keeps a dependency on a service the catalog no longer exposes (docs/architecture/rust-agent/generated/catalog.md:60 lists only settings; crates/dim-app-server/src/lib.rs:1448 registers Settings). The contract file contradicts itself in one reading.

Fix: add the two methods to the section 1 bullet and the section 4.5 enumeration, and replace the PluginManager sentence with the Settings binding, in both languages.

P2: other migrated-caller contracts still name SettingsService

Problem: the contracts this PR migrates still describe the retired key and read path.

  • docs/design/contracts/resource-owner-operations.md:14 lists settingsService as the interface dependency ("Declared sources use settings.register/read/update/projects"), while the PR removes that catalog name and the same file's new rows (137, 144) route through settings.
  • docs/design/appserver/permission-command-rules.md:184 and docs/zh/design/appserver/permission-command-rules.md:168 say Keyed<SettingsService> and SettingsService::read::<PermissionSettings>(User); the code uses ctx.get::<RegisteredDocument<PermissionSettings>>() on Key<Settings> (crates/dim-app-server/src/permission_rules.rs:54-75, 101-113, 159-176).
  • docs/design/subagent-model-policy.md:56, 129, 153-154 say SettingsService::read/update and Keyed<SettingsService>; the owner now registers through Settings::register_document and provides CollaborationModelPolicy (crates/dim-app-server/src/collaboration_model_policy.rs:147-176), read through ctx.get (crates/dim-app-server/src/collaboration.rs:281-291).
  • docs/design/plugins/Hooks.md:697 and docs/zh/design/plugins/Hooks.md:695 say SettingsService::project_root(cwd); sources now use Settings::projects() (crates/dim-app-server/src/hooks_settings.rs:165-180). docs/design/plugins/Scheduler.md:927 and docs/zh/design/plugins/Scheduler.md:874 still list SettingsService as the typed dependency, now RegisteredDocument.

Failure scenario: a new consumer or a future contract edit follows these rows, adds Keyed<SettingsService> or a name lookup that no longer exists in the catalog, and the owner matrices stop matching the code they are supposed to audit. These lines were correct before this PR and became stale with it.

Fix: update the four documents, both languages, to the new keys and operations.

Verification

Ran against e7576cb: git diff --check, cargo fmt --all -- --check, adr-check, cargo run -p xtask -- check (module, catalog, declarations, locks, comment links), and clippy on the changed crates pass. Targeted tests pass: settings_flow 16/16, hooks_settings_flow 4/4, mcp_flow 27/27, transport settings_methods (3 non-ignored), permission rules 1/1, collaboration transport 1/1, mcp_session_flow 48/48, dim-app-server lib 125/125. The two node-gated settings tests and runtime/fixtures/settings-owner.ts could not run here (no DIM_TEST_NODE, DIM_TEST_JS_RUNTIME or runtime/node_modules), so the TypeScript registerDocument path is unverified locally; CI verify is still pending.

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

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

Findings

[Blocking] Reject an old owner’s queued write after re-registration

When a file-backed Rust source is withdrawn while an update waits for the file lease, crates/dim-app-server/src/settings.rs:251–263 has already checked the registration and handed storage the path and the caller’s token. If the new owner registers the same file without changing its contents, the old update can pass the revision check, replace the document and publish a change under the new owner’s source name.

Evidence: Static inspection: RegisteredDocument::path checks the registration identity, but replace does not carry it across the lease wait at settings.rs:546–551. The Hooks management path supplies an independent request token. The stale-handle test starts a read after unload; it does not cover a write already waiting at unload.

Requested change: Carry registration identity through commit admission and order that admission with withdrawal. Hold the file lease in a regression test, queue an update from the old handle, replace its registration, then release the lease. The old write must fail without changing the file or publishing a notice.

[Blocking] Keep plugin decoding outside the exclusive file lease

When a file-backed registerDocument update reads the current revision, crates/dim-app-server/src/settings.rs:546–551 waits for the plugin decoder while holding the exclusive lease. Even a stale update can delay every writer to that document; if the decoder awaits another update of the same document, neither update can finish without cancellation.

Evidence: Static inspection: snapshot now awaits format.decode, and the new Codec delegates that call to plugin code (crates/dim-app-server/src/settings/document.rs:21–60). The registered-document update supplies a no-op check for the current document; it does not need the decoded value to reject a stale revision. Tests not run locally.

Requested change: Compare the raw revision under the lease without calling the plugin. If a caller needs a decoded snapshot, decode outside the lease and recheck the revision at commit. Cover a stale update with a suspended decoder and verify another writer can still make progress.

# Conflicts:
#	crates/dim-agent-scheduler/src/methods.rs
#	crates/dim-modality/src/engine.rs
#	crates/dim-modality/src/lib.rs
#	docs/architecture/rust-agent/generated/app-server/services.md
#	docs/architecture/rust-agent/generated/app-server/services.mmd
#	docs/architecture/rust-agent/generated/modules.mmd
#	docs/design/contracts/resource-owner-operations.md
#	docs/design/plugins/Scheduler.md
#	docs/zh/design/plugins/Scheduler.md
@eric8810

Copy link
Copy Markdown
Collaborator Author

Fixed the Settings write issues in 93abff0 and integrated main in 4d93d07.

  • File-backed writes from a registered source recheck its registration after acquiring the file lease. The native SQLite path checks it at write admission. A regression test holds the file lease, starts a write, replaces the source registration, then releases the lease. The old write fails, the stored revision stays intact and only the current owner publishes a new revision.
  • The file-backed custom write compares the stored bytes' revision without invoking the foreign decoder. In the Node-backed project flow, a read stays suspended inside the decoder while a stale write returns conflict and a current write commits.
  • Updated the Settings, Permission, Collaboration, Hooks and Scheduler owner documents and the resource operations table.

The Settings flow (16 tests), Node-backed owner flow, strict fixture type check and App Server Clippy passed on the fix. CI is checking the merged head.

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

Verdict: REQUEST_CHANGES

This PR moves the special Settings sources (Scheduler, Modality, SkillsCatalog, PermissionRules, CollaborationModelPolicy, Hooks, MCP) to source-bound registration and reads, adds settings.registerDocument for codec sources, moves trusted callers to the Settings binding, and retires the public settingsService catalog name. The three prior blocking findings are fixed at 93abff0, and the merged head passes the Settings, Hooks, MCP, Permission and Collaboration flows. The only blocker is a new conflict with latest main in the generated module snapshots.

Blocking: latest main conflicts on the generated module snapshots

Problem: origin/main moved during this review from 14cc130 to 44af122. Commit a43607b (#1946) deleted docs/architecture/rust-agent/generated/modules.json and docs/architecture/rust-agent/generated/modules.mmd and stopped committing them, while this PR still modifies both files. GitHub reports the PR as CONFLICTING/DIRTY, and git merge-tree --write-tree origin/main HEAD exits 1 with modify/delete conflicts on exactly those two files.

Failure: the PR cannot merge. Resolving toward the PR side would reintroduce about 63k lines main deliberately removed and contradict the new xtask behavior.

Fix: merge origin/main, accept both deletions, and rerun cargo run --locked -p xtask -- check. No Settings code change is needed for this.

Prior blocking findings, resolved at 93abff0

  1. Registration identity at commit admission: SettingsService::replace rechecks current_registration after acquiring the file lease (crates/dim-app-server/src/settings.rs:558-562), and native_replace checks it under native_publication before replace_user (crates/dim-app-server/src/settings/native.rs:97-102). The regression test holds the lease, starts a write, withdraws and re-registers the source, releases the lease, and asserts the old write fails with UnknownSource, the stored document is unchanged, and only the current owner publishes a new revision (crates/dim-app-server/tests/settings_flow.rs:874-953).
  2. Foreign decoder under the file lease: the file-backed Registered path reads raw bytes and compares the revision without calling format.decode for Kind::Custom (crates/dim-app-server/src/settings.rs:559-569). The Node project flow suspends decode inside a read, then a stale write returns conflict and a current write commits while the decoder is still suspended (crates/dim-app-server/tests/transport_flow/settings_methods.rs:375-390, runtime/fixtures/settings-owner.ts:48-69).
  3. Docs and contracts: sections 1, 4.2 and 4.5 now list registerDocument and authorizeProject and name the Settings binding (docs/design/appserver/settings-service.md:20,214-215,316-326), with the ZH mirror (docs/zh/design/appserver/settings-service.md:19,194-195,278-283). The resource-owner table and the Permission, Collaboration, Hooks and Scheduler contracts now use Settings/RegisteredDocument (docs/design/contracts/resource-owner-operations.md:14,144,151; docs/design/appserver/permission-command-rules.md:184; docs/design/subagent-model-policy.md:129,139,153; docs/design/plugins/Hooks.md:421,697; docs/design/plugins/Scheduler.md:927, with the matching ZH lines).

Threads to withdraw

All prior threads are still marked unresolved, but their findings are fixed. Withdraw zerob13 review 5989077239 (inline 4639732055 and 4639732064), our review 5989194487 (inline 4639827761 and 4639827790), and codoggy review 5989574981. Our inline 4639831307 only marks the duplicate of 4639732064 and goes with that thread. The issue comment 7035261838 matches the code and tests.

Optional notes, not blocking

P3: the Rust binding sentence calls native sources "custom"

Problem: docs/design/appserver/settings-service.md:317 says "Custom sources use register_document", but Settings::register_document registers a native BusinessDocument as Kind::Rust (crates/dim-app-server/src/settings/declared.rs:344-354; crates/dim-app-server/src/settings.rs:205-209). The codec method in section 4.2 is the dispatcher registerDocument, which creates Kind::Custom (crates/dim-app-server/src/settings/document.rs:107-123).

Failure: a reader maps the codec signature from section 4.2 onto the Rust method, which takes only an owner context, or cannot tell which registration a native owner should use.

Fix: say "Native BusinessDocument sources use register_document and its bound read/update operations", and correct the PR body table that lists the Rust owners as calling settings.registerDocument({source,userFile,projectFile?},codec).

P3: two Settings lines still name the old typed registration

Problem: docs/design/appserver/settings-service.md:121 says native BusinessDocument sources use SettingsService::register::<D>, and lines 265-266 say ScheduleDocument is registered with settings.register::<ScheduleDocument>. Scheduler now calls Settings::register_document::<ScheduleDocument> (crates/dim-agent-scheduler/src/methods.rs:116), as do the other native owners. crates/dim-app-server/README.md:97 uses the same older spelling.

Failure: a new owner following section 3.1 keeps the typed SettingsService path. That path returns no source-bound handle, and its update uses WriteCheck::Compare (crates/dim-app-server/src/settings.rs:504-513), so it does not get the registration recheck added by this PR.

Fix: point both lines, and the README sentence, at Settings::register_document.

P3: native admission reports conflict before unknown_source

Problem: native_replace compares the revision (crates/dim-app-server/src/settings/native.rs:94-95) before current_registration (lines 97-102). A stale handle whose expected revision no longer matches returns Conflict after its registration was withdrawn, not UnknownSource as docs/design/appserver/settings-service.md:125 states for an unregistered source. The file path and the matching-revision native case return UnknownSource.

Failure: a management caller that retries a stale write sees conflict and may read and retry instead of dropping the handle; no write occurs either way.

Fix: check registration before the revision comparison, or state that conflict takes precedence in the native path.

Verification

Head 4d93d07, worktree clean and detached. All commands used isolated HOME, TMPDIR, XDG and CARGO_TARGET_DIR with LC_ALL=en_US.UTF-8.

Against origin/main 14cc130, the PR's stated base:

  • git diff --check origin/main...HEAD: pass.
  • git merge-tree --write-tree origin/main HEAD: pass, tree 95fab3d0.
  • cargo fmt --all -- --check: pass.
  • node scripts/adr-check.mjs --base origin/main: pass (45 changed files).
  • cargo run --locked -p xtask -- check: pass, including crate and module boundaries, plugin documents, service catalog, service declarations, plugin locks and comment links after the #1901 merge.
  • cargo test -p dim-app-server --test settings_flow: 16 passed, including sources_appear_while_registered_and_names_are_exclusive.
  • cargo test -p dim-app-server --test hooks_settings_flow: 4 passed.
  • cargo test -p dim-app-server --test mcp_flow: 27 passed.
  • cargo test -p dim-app-server --test transport_flow command_rules_written_by_the_client_apply_to_the_next_call: 1 passed.
  • cargo test -p dim-app-server --test transport_flow product_collaboration_adopts_profile_and_default_capabilities: 1 passed.
  • cargo test -p dim-app-server --test transport_flow settings_methods::: 3 passed, 2 ignored (Node).
  • cargo test -p dim-agent-scheduler -p dim-modality: all scheduler suites and all modality suites passed, including plugin_file_transactions and modality_flow (81 tests).

Against the now-current origin/main 44af122:

  • git merge-tree --write-tree origin/main HEAD: fails as described in the blocking item.

Unverified:

  • The two node-gated settings tests and the strict runtime/fixtures/settings-owner.ts type check need DIM_TEST_NODE, DIM_TEST_JS_RUNTIME and runtime/node_modules, which are absent here. The suspended-decoder and current-write ordering rest on the author's run and CI.
  • I did not rerun App Server Clippy; the author reports it passed, and the changed crates compile under the gates above.
  • CI at head 4d93d07: verify is queued/pending, dependencies and changes pass, and web, windows-cli and acp-registry are skipped. GitHub reports the PR as CONFLICTING/DIRTY because of the new main conflict, not because of a failing check.

@codoggy

codoggy commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Verified fixed in 4d93d071bcc8a2441a15050700291f017bf202cf.

At crates/dim-app-server/src/settings.rs:559-582, the write rechecks the source registration after acquiring the file lease and before replacing the stored file, and the added regression test at crates/dim-app-server/tests/settings_flow.rs:899-919 asserts that the queued old-owner write returns UnknownSource after replacement. This addresses the original queued-write ownership concern. I did not run tests locally; the current verify check is still queued.

This verifies the point raised in my earlier review.

# Conflicts:
#	docs/architecture/rust-agent/generated/modules.json
#	docs/architecture/rust-agent/generated/modules.mmd

@codoggy codoggy 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 summary

I reviewed the merge-base diff for 39838ddfe1208b6c344c314512269bd1183b402b, focusing on the settings-source admission and lease handling, the SQLite-backed storage dispatch, and the updated settings regression coverage. I found no blocking issues in that scope.

The earlier queued old-owner write concern is addressed at crates/dim-app-server/src/settings.rs:558-569, where registration is rechecked after file-lease admission; the corresponding regression coverage is in crates/dim-app-server/tests/settings_flow.rs:874-953. The custom-source path compares the stored raw revision without invoking the foreign decoder while holding the exclusive lease, with Node-backed concurrency coverage at crates/dim-app-server/tests/transport_flow/settings_methods.rs:364-390. The current head also carries the generated storage/API updates in its owned diff.

Checks: For this exact head, GitHub reports changes and dependencies passed; verify was queued, while web, windows-cli, and acp-registry were skipped. Tests not run locally; the source and regression coverage were checked by static inspection. Merge readiness (not a finding): the pending verify result remains to be observed; this is not attributed to the PR and is not a change request.

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

Verdict: APPROVE

This PR moves Scheduler, Modality, SkillsCatalog, PermissionRules, CollaborationModelPolicy, Hooks and MCP to source-bound Settings registration and reads, adds the settings.registerDocument codec path, moves trusted callers to the Settings binding, and retires the public settingsService catalog name. The merge conflict from the prior review is resolved, the three earlier blockers still hold at this head, and no main change was reverted.

Merge conflict resolved

At 4d93d07 the branch modified docs/architecture/rust-agent/generated/modules.json and docs/architecture/rust-agent/generated/modules.mmd, which main commit a43607b (#1946) deleted.

Verification at 39838dd:

  • Both files are absent from HEAD: git cat-file -e HEAD:docs/architecture/rust-agent/generated/modules.json and the same command for modules.mmd fail, and git ls-tree -r --name-only HEAD docs/architecture/rust-agent/generated/ lists only the 14 remaining files.
  • git merge-tree --write-tree origin/main HEAD exits 0 with tree f63c594a652cba97bfbc772228e3ba834330e2c5, and GitHub reports the PR as MERGEABLE.
  • git diff --name-status origin/main...HEAD still lists the same 43 PR files, and git diff --stat 4d93d071b..39838ddfe contains only main-side changes: AGENTS.md, README, ADR 026 in both languages, docs index and release README, scripts/ci-changes.mjs and its test, xtask/src/main.rs, xtask/src/modules.rs, and the two snapshot deletions. The merge resolution did not alter the PR's code or docs.
  • cargo run --locked -p xtask -- check passes, including the live module boundary check: module source boundaries passed (744 modules, 4574 edges).

Prior blocking findings still fixed at 39838dd

  1. Registration identity at commit admission: SettingsService::replace acquires the file lease, reads the raw bytes, and rechecks current_registration before the revision check (crates/dim-app-server/src/settings.rs:558-568). The native path checks it under native_publication before replace_user (crates/dim-app-server/src/settings/native.rs:92-102). The regression test still holds the lease across withdrawal and re-registration and asserts UnknownSource with the stored revision unchanged (crates/dim-app-server/tests/settings_flow.rs:874-953).
  2. Foreign decoder outside the file lease: the Kind::Custom branch reads the stored bytes and compares the revision without calling format.decode under the lease (crates/dim-app-server/src/settings.rs:560-568). The Node project flow still suspends decode while a stale write returns conflict and a current write commits (crates/dim-app-server/tests/transport_flow/settings_methods.rs:375-390, runtime/fixtures/settings-owner.ts:44-72).
  3. Docs and contracts: sections 1, 4.2 and 4.5 list registerDocument and authorizeProject and name the Settings binding (docs/design/appserver/settings-service.md:20,214-215,316-326), with the ZH mirror (docs/zh/design/appserver/settings-service.md:19,194-195,278-283). The resource-owner table and the Permission, Collaboration, Hooks and Scheduler contracts use Settings or RegisteredDocument (docs/design/contracts/resource-owner-operations.md:14,144,151; docs/design/appserver/permission-command-rules.md:184; docs/design/subagent-model-policy.md:129,139,153; docs/design/plugins/Hooks.md:421,697; docs/design/plugins/Scheduler.md:927).

Main changes intact

  • #1901 pluginFiles: crates/dim-agent-scheduler/src/methods.rs:47 and :356 still declare PluginFiles and FileScope, and the PR's hunk on that file only changes the Settings types and reads. Modality still uses FileScope. The scheduler and modality suites pass.
  • #1946: the two module snapshots stay deleted, and xtask/src/main.rs and xtask/src/modules.rs have no diff against origin/main.
  • #1925: .github/workflows/ci.yml, scripts/ci-changes.mjs and scripts/ci-changes.test.mjs have no diff against origin/main.
  • #1940: docs/adr/026-verification-tiers-and-ci-governance.md, its ZH mirror and docs/adr/README.md have no diff against origin/main.

Threads to withdraw

All five review threads are still unresolved. Four are fixed and one is an optional note.

  • Withdraw zerob13 review 5989077239 (inline 4639732055 and 4639732064): both findings are fixed and covered by the file and Node flows above.
  • Withdraw codoggy review 5989574981: its two findings duplicate zerob13's, codoggy already confirmed the fix in issue comment 7036153560, and the same head verifies it.
  • Our review 5989194487 (inline 4639827761 and 4639827790) and review 5990479055 (the merge-conflict blocker plus optional inline 4640785439): the blocker is resolved, the docs fixes stand, and the optional note remains optional. This approval supersedes 5990479055.
  • Inline 4639831307 only marks the duplicate of 4639732064 and goes with that thread.

Optional notes, not blocking

The three prior P3 notes are unchanged and remain optional:

  • docs/design/appserver/settings-service.md:317 calls the Rust register_document "custom sources", but Settings::register_document registers a native BusinessDocument as Kind::Rust (crates/dim-app-server/src/settings/declared.rs:344-354, crates/dim-app-server/src/settings.rs:205-209), while the codec method in section 4.2 is the dispatcher registerDocument and creates Kind::Custom (crates/dim-app-server/src/settings/document.rs:107-123). The PR body also lists the Rust owners under the codec settings.registerDocument form.
  • docs/design/appserver/settings-service.md:121 and 265-266 and crates/dim-app-server/README.md:97 still name the older SettingsService::register::<D> and settings.register::<ScheduleDocument> path. The migrated owners use Settings::register_document (crates/dim-agent-scheduler/src/methods.rs:116), which returns the source-bound handle whose update rechecks registration.
  • crates/dim-app-server/src/settings/native.rs:94-95 compares the revision before current_registration at lines 97-102, so a stale native handle can report conflict where docs/design/appserver/settings-service.md:125 says unknown_source. No write occurs in either ordering.

Verification

Head 39838dd, worktree clean and detached, origin/main b623ac6. All commands used isolated HOME, TMPDIR, XDG and CARGO_TARGET_DIR with LC_ALL=en_US.UTF-8.

  • git diff --check origin/main...HEAD: pass.
  • git merge-tree --write-tree origin/main HEAD: pass, tree f63c594a652cba97bfbc772228e3ba834330e2c5.
  • cargo fmt --all -- --check: pass.
  • node scripts/adr-check.mjs --base origin/main: pass, 43 changed files.
  • cargo run --locked -p xtask -- check: pass, with module source boundaries (744 modules, 4574 edges), crate and module boundaries, plugin documents (26), service catalog, service declarations, plugin locks, comment links (97) and literal main.
  • cargo test -p dim-app-server --test settings_flow: 16 passed, including sources_appear_while_registered_and_names_are_exclusive.
  • cargo test -p dim-app-server --test hooks_settings_flow: 4 passed.
  • cargo test -p dim-app-server --test mcp_flow: 27 passed.
  • cargo test -p dim-app-server --test transport_flow settings_methods::: 3 passed, 2 ignored (Node).
  • cargo test -p dim-app-server --test transport_flow command_rules_written_by_the_client_apply_to_the_next_call: 1 passed.
  • cargo test -p dim-app-server --test transport_flow product_collaboration_adopts_profile_and_default_capabilities: 1 passed.
  • cargo test -p dim-agent-scheduler -p dim-modality: all suites passed, 161 tests.
  • cargo test -p dim-session-title --test appended_context_flow: 7 passed, covering the HookSources to HooksService binding added by this PR.

Unverified:

  • The two node-gated settings tests and the strict runtime/fixtures/settings-owner.ts type check need DIM_TEST_NODE, DIM_TEST_JS_RUNTIME and runtime/node_modules, which are absent here. The suspended-decoder custom write path rests on the author's run and CI.
  • I did not run App Server Clippy or the full workspace suite.
  • CI at head 39838dd: verify is queued, dependencies and changes pass, and web, windows-cli and acp-registry are skipped. GitHub reports MERGEABLE and mergeStateStatus UNSTABLE (pending verify) with reviewDecision CHANGES_REQUESTED from the prior review.

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

Verdict: APPROVE

Commit 64b2284 changes only the App Server README and the English and Chinese Settings design docs. It closes the two documentation P3 notes from review 5990866612; the third optional note is unchanged below. The code is still the approved head 39838dd. The source-bound admission recheck, the foreign decoder boundary and the trusted caller migration still hold. No blocking finding remains.

New commit

The docs now match the code:

  • docs/design/appserver/settings-service.md:121 and :317-319 say native BusinessDocument sources use Settings::register_document, and :266 says ScheduleDocument registers with settings.register_document::<ScheduleDocument>. This matches Settings::register_document at crates/dim-app-server/src/settings/declared.rs:344-357 and every migrated owner: crates/dim-agent-scheduler/src/methods.rs:116, crates/dim-modality/src/lib.rs:1240, crates/dim-app-server/src/hooks_settings.rs:737-739, crates/dim-app-server/src/mcp.rs:1851-1854, crates/dim-app-server/src/permission_rules.rs:162, crates/dim-app-server/src/collaboration_model_policy.rs:170 and crates/dim-app-server/src/skills_management.rs:622.
  • crates/dim-app-server/README.md:97 uses the same method for a native BusinessDocument.
  • The ZH mirror matches at docs/zh/design/appserver/settings-service.md:106, :238 and :278.
  • No "custom sources" wording remains in the changed docs. Kind::Custom stays with the codec path (crates/dim-app-server/src/settings/document.rs:107-123, docs/design/contracts/resource-owner-operations.md:144).
  • Sections 3.1, 4.2 and 4.5 now agree, and the added text does not duplicate or contradict them. The PR body also lists Settings::register_document::<D> for the native owners, closing the prior note there.

Prior findings

  • Withdraw the two optional doc P3s from review 5990866612. Inline 4640785439 (the "custom sources" wording) and the optional follow-up in thread 4639827790 (lines 121 and 265-266 and README:97) are fixed by 64b2284 at the lines above.
  • The earlier blockers stay fixed: registration identity is rechecked after the file lease before the revision check (crates/dim-app-server/src/settings.rs:561-568) and under native_publication (crates/dim-app-server/src/settings/native.rs:98-102); the regression test at crates/dim-app-server/tests/settings_flow.rs:771-954 queues a write across withdrawal and re-registration and asserts UnknownSource with the stored revision unchanged; the custom decoder no longer runs under the file lease (crates/dim-app-server/src/settings.rs:563-565), and the Node flow at crates/dim-app-server/tests/transport_flow/settings_methods.rs:380-390 with runtime/fixtures/settings-owner.ts:55-68 still suspends decode while a stale write conflicts and a current write commits.
  • The removed forwarding face is gone: git grep settingsService HEAD finds nothing in crates, npm, runtime or docs/architecture, and crates/dim-app-server/src/lib.rs registers settings::Settings without a settingsService face.

Optional note, not blocking

Problem: crates/dim-app-server/src/settings/native.rs:94-99 compares the revision before current_registration, so a stale native handle whose expected revision no longer matches returns conflict after its source was withdrawn, while docs/design/appserver/settings-service.md:125-126 says an unregistered source is unknown_source on every path.

Failure: a management caller sees a revision conflict and may re-read instead of dropping the retired handle.

Evidence: the file path checks the registration first; the native path checks it after the revision comparison (crates/dim-app-server/src/settings/native.rs:92-102).

Fix: check current_registration before the revision comparison, or state the native precedence in the document. This was already optional in review 5990866612 and no write occurs in either order.

Verification

Head 64b2284, worktree clean and detached, current origin/main 3d5749c. All commands used isolated HOME, TMPDIR, XDG and CARGO_TARGET_DIR with LC_ALL=en_US.UTF-8.

  • git diff --stat 39838ddfe..64b2284fa: three docs files, 7 insertions and 7 deletions. No code changed since the approval.
  • git merge-tree --write-tree origin/main HEAD: exit 0, tree f776a4c11f214d21223a335ac3632e6541199ec3. GitHub reports MERGEABLE.
  • node scripts/adr-check.mjs --base origin/main: ADR freeze passed, 44 changed files.
  • cargo run --locked -p xtask -- check: module source boundaries (744 modules, 4574 edges), crate and module boundaries, plugin documents (26), service catalog, service declarations, plugin locks, comment links (97) and literal main (11) all pass.
  • git diff --check origin/main...HEAD: pass.
  • CI at 64b2284: changes and dependencies pass, verify queued, web, windows-cli and acp-registry skipped.

Cross-PR

  • PR 1904 removes the same settingsService registration in crates/dim-app-server/src/lib.rs and conflicts with this head on crates/dim-app-server/src/lib.rs and crates/dim-app-server/src/agents.rs (merge-tree exit 1); it needs a rebase after this merges.
  • PR 1905 conflicts on crates/dim-modality/src/engine.rs and crates/dim-modality/src/lib.rs.
  • PR 1900 and PR 1906 conflict only in generated docs/architecture/rust-agent/generated/ files, and PR 1917 also conflicts on the removed modules.json and modules.mmd; regeneration resolves those.
  • PR 1941, 1907, 1908, 1909, 1916 and 1943 merge cleanly with this head.

Unverified

  • The Node-gated settings tests and the strict runtime/fixtures/settings-owner.ts type check were not rerun. The code is unchanged since 39838dd, where the same limitation was recorded, so the earlier author and CI evidence still applies.
  • No Settings or storage suite was rerun because the increment is docs only; main's two new commits touch transport_flow/timeline_export.rs, .github/workflows/ci.yml, the root README and docs/release/README.md, none of which this PR changes.

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

The macOS native job fails to compile dim-app-server on merge commit bd632b97c1b7e15a20ed57bfde5a12891f8f4cbb. Rust reports seven E0533 errors because the new Settings and collaboration policy code still calls Error::Value(...) after the Rutis 0.23 upgrade. Use Error::value(message) at all seven sites and pass string literals directly. This follows the constructor migration already on main and preserves the existing error messages. CI log

@eric8810
eric8810 requested a review from zerob13 November 20, 2026 14:18

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

Verdict: APPROVE

The head fixes the seven rutis 0.23 constructor errors that broke the macOS native build at 43e29c0. Every site now calls Error::value, the string literals no longer use .into(), and all messages are unchanged.

The seven sites

  • crates/dim-app-server/src/collaboration_model_policy.rs:112 uses Error::value(format!("unknown collaborationModelPolicy method {method}")); :117 uses Error::value("expected one empty request").
  • crates/dim-app-server/src/settings/document.rs:77 uses Error::value("expected a settings source declaration and a codec with decode and validate functions"); :105 and :117 use Error::value(error.to_string()); :126 uses Error::value("expected a settings scope"); :137 uses Error::value("expected scope, expectedRevision and document").

This follows ADR 025 D2. In rutis-bridge 0.23.0, Error::value(message: impl Into<String>) sets reason: None (src/session/mod.rs:153), and Error::Value still maps to the bad-value code (src/session/mod.rs:248), the same code the 0.19.3 tuple variant had (src/session/mod.rs:55 and :191). Error codes and messages stay the same for callers and tests.

git grep Error::Value HEAD finds no call site. git diff 43e29c08..HEAD changes only these two files, 9 insertions and 11 deletions.

The rest of the PR is unchanged

git diff origin/main...HEAD still lists the same 44 files. The merge at 43e29c0 combined main's rutis 0.23 upgrade with the approved content. The five PR files main also changed, crates/dim-agent-scheduler/src/methods.rs, crates/dim-app-server/README.md, crates/dim-app-server/src/hooks_settings.rs, crates/dim-app-server/src/settings/declared.rs and crates/dim-app-server/tests/transport_flow/collaboration.rs, keep the same PR hunks and carry main's Error::value migration. The settings registration, native replace, custom decoder outside the file lease, lease and withdraw behavior, generated files and docs are unchanged since the approved head 64b2284.

Verification

Head 6ae39cc, clean detached worktree, origin/main ffd3e11. Isolated HOME, TMPDIR, XDG and CARGO_TARGET_DIR under the review data dir, LC_ALL=en_US.UTF-8.

  • cargo check -p dim-app-server --all-targets --locked: pass.
  • cargo check -p dim-agent-scheduler --all-targets --locked: pass.
  • cargo fmt --all -- --check and git diff --check: pass.
  • node scripts/adr-check.mjs --base origin/main: pass, 44 changed files.
  • cargo run --locked -p xtask -- check: pass, including module source boundaries (744 modules, 4576 edges), crate and module boundaries, plugin documents, service catalog, service declarations, plugin locks and comment links.
  • settings_flow: 16 passed, including sources_appear_while_registered_and_names_are_exclusive.
  • hooks_settings_flow: 4 passed.
  • mcp_flow: 27 passed.
  • transport_flow settings_methods::: 3 passed, 2 ignored (Node).
  • transport_flow permission_rules::command_rules_written_by_the_client_apply_to_the_next_call: 1 passed.
  • transport_flow collaboration::product_collaboration_adopts_profile_and_default_capabilities: 1 passed.
  • CI at head: macos-native, the job that failed at 43e29c0, passes; changes and dependencies pass; verify (linux) is pending; web, windows-cli and acp-registry are skipped.

Unverified: the two Node-gated settings tests and the strict runtime/fixtures/settings-owner.ts type check need DIM_TEST_NODE, DIM_TEST_JS_RUNTIME and runtime/node_modules, which are absent here. The fixture and the declarations are unchanged by this delta, and CI verify is pending. Clippy and the full workspace suite were not rerun.

Cross-PR

  • #1910 conflicts on crates/dim-app-server/src/lib.rs and crates/dim-app-server/src/mcp/publication.rs.
  • #1908 conflicts on docs/architecture/rust-agent/generated/catalog.md.

Both merge cleanly with origin/main, so these are overlapping changes with this PR, and one side needs a rebase after the other merges. #1913, #1907, #1951, #1952 and #1949 merge cleanly.

Threads

zerob13's review 5993887376 and inline comments 4643352084 and 4643352098 are fixed at this head. All earlier threads are resolved, and their fixes still hold. My approval 5991639917 reviewed 64b2284 before this branch merged main, so it did not cover the rutis 0.23 merge; this review supersedes it.

Optional, not blocking

crates/dim-app-server/src/settings/native.rs:94 compares the revision before current_registration at :99, so a stale native handle whose revision no longer matches returns conflict, while docs/design/appserver/settings-service.md:125 says an unregistered source is unknown_source on every path. No write occurs in either order. Check the registration first or state the native precedence.

@eric8810

Copy link
Copy Markdown
Collaborator Author

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

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

4 participants