Skip to content

design(provider): target contracts for the model and provider owners - #2096

Closed
eric8810 wants to merge 9 commits into
mainfrom
dim/2019-provider-contract
Closed

eric8810 wants to merge 9 commits into
mainfrom
dim/2019-provider-contract

Conversation

@eric8810

@eric8810 eric8810 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #2019 · Refs #2015

Summary

Merge order: #2029 → #2080 → #2091/#2092/#2093 → #2094 → this PR → the rest. The retained pages for other owners (SessionTitle, Web) are updated by their own contracts (#2099); this PR changes only the model and provider owners' paragraphs.

The target contracts for the model and provider board under design rules §7: responsibility splits, caller compositions, operations with cancellation and error kinds, resource flows, exceptions, rule checks, requirements raised to other owners, and Rust bindings.

  • Provider is the single model owner of the product profile. It owns records, selection, credentials, execution, temporary startup admissions, media routes and the wire recorder. It owns the driver, so the credential never leaves the owner and no connection crosses. Management stays the provider client protocol; handlers call the same operations.
  • ConfiguredModels answers the same providerService operations from the API-key model file, without records, management, startup or recording.
  • Account owners (DimOAuth, OpenAI Codex, Grok, the ChatGPT account, external plugins) share one contract in ManagedAccount: availability and its callback subscription, the account catalog, and the credential value with its grant generation plus the rejected decision after a refusal; DimOAuth adds relay search and title.
  • ManagedProviders keeps only the ChatGPT account as chatgptAccount; the host binding, the dyn ManagedProvider object port and the managedSearch face are retired, so no owner returns another owner's data.
  • ModelLog stays design(settings): owner contracts for Settings and the settings sections #2094's contract (所有者扫描:Settings 与设置分节 #2017): the model owner's driver reads its recording value per request; the process-global recorder function is removed.

Modality's modalityTargets.resolve is unchanged; the media adapter resolves media_route and reads the credential for the model target. ImageUnderstanding is a consumer and migrates to providerService.invoke.

Kinds of pre-migration surfaces that disappear: modelSelectionHost, selectableModelsHost, auxiliaryModel, providerConnectionResolver, modelHost, modalityConnectionHost, managedSearch, the account data forwarding methods, and the process-global recording function.

Delivery part (deletion list, caller migration, implementation task, acceptance): 目标契约:交付部分.

Merge order

#2029 → #2080 → #2091/#2092/#2093 → #2094 → #2096 → the rest.

Sibling heads this change is aligned with: #2091 f7425d55c, #2094 0677c7155, #2099 3501002ac, #2102 3b48e1248. A paragraph that depends on a sibling names that PR; its head is the one above.

Write the owner contracts for the model and provider board under design
rules §7: the responsibility split, the caller compositions, the
operations with their cancellation and error kinds, the flows that
settle each resource, the exceptions, the rule check and the Rust
bindings.

Provider becomes the single model owner of the product profile:
resolution, preference application, selection listing, temporary
startup admissions, request execution, media routes and one-attempt
credentials. It owns the driver, so credentials never leave the owner
and no connection crosses. ConfiguredModels answers the same
`providerService` operations from the model file.

Account owners share one contract: availability and its subscription,
the account catalog, and one `with_lease` operation that hands the lease
to the caller's attempt, recovers once and settles the lease itself, so
no caller holds a lease id. DimOAuth adds relay search and title. The
ChatGPT account remains; the ManagedProviders host binding and the
`managedSearch` face are retired, so no owner returns another owner's
data. ModelLog and the provider document stay with the Settings board
(#2094); the driver reads ModelLog's recording value.

Refs #2019 · Refs #2015
@eric8810

Copy link
Copy Markdown
Collaborator Author

评审(head 4a29c15aa):需改 3 处;Provider 的 resolve/selectable/invoke、各账户所有者的拆分符合。

  1. with_lease 把 bearer 交进调用方回调。 AGENTS.md:「Secret values stay with the owner and public methods expose operations」。要么由账户所有者执行这一次交换(请求作为数据传入,回复作为数据返回),要么把这条作为例外请维护者确认。现在只在例外里写「禁止存储」,这不是边界。
  2. Rpc 示例 session.configure(.., &branch) 还在传 Branch 句柄,违反横切决定 2。改成按 line id 调用 PromptAdoption 的 configure(docs(design): target contracts for the branch turn chain #2102)。
  3. prepare_startup → retain_startup → release_startup 要调用方按顺序调用三步。 请写明漏调时由谁结算;能绑定到行或 Session 生命周期的,就收成一个操作。

…e lease boundary

Provider owns its records, selection, preferences, candidates, pages,
source activation, adoption, edit commits, legacy import and
`store.creationRecord`; the storage engine keeps the file and transaction
primitive as a private implementation and its public face keeps
`storageReport` and the offline operations.

A temporary startup connection is admitted under the calling row and
moved to a Session by `retain_startup({session, model})`; a missed
retain or release settles with the row, and a retained source with the
Session. `release_startup({model})` is the optional early release.

The Rpc examples adopt a model on a line through PromptAdoption's
`configure` by line id instead of a Branch handle.

The account owner cannot perform the model exchange itself, so
`with_lease` hands the lease to the caller's attempt; the boundary and
its alternatives are recorded and raised for maintainer confirmation.

Refs #2019 · Refs #2015
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 6efb14de1。

  1. 存储引擎不代查。 Provider 记录、selection、preferences、候选、分页、源激活、采用、编辑提交、legacy 导入与 store.creationRecord 归 Provider;sqliteStorage 的公开面只留 storageReport 与离线操作,Provider 使用 crate 内的私有事务原语。依赖表、Requirements、责任分界与交付评论第 6 步已同步。
  2. with_lease 的 bearer 边界。 详见下面单独一条,请维护者确认。
  3. Rpc 示例按 line id。 两处示例改为 line_owner::<PromptAdoption>(line)?.configure(ConfigureRequest { model: Some(selection), .. }),不再传 &branch。
  4. startup 三步收成两步 + 可选提前释放。 prepare_startup 的 source 绑定调用行,漏调 retain_startup/release_startup 由行卸载结算;retain_startup({session, model}) 绑定 Session,漏调释放由 Session 关闭结算;release_startup({model}) 只在创建失败时提前释放,已保留则 not_found。操作表、流程、错误、示例、绑定与交付评论已同步。

@eric8810 第 2 条的例外请确认。with_lease 由账户所有者驱动租约与一次恢复,但 bearer 仍进入调用方回调。由账户所有者亲自执行这一次交换做不到:

  • 模型请求的协议、传输、流式解析、图片适配、代理/超时/重定向和每 profile 的 driver 属于模型所有者(Provider/ConfiguredModels);把交换搬进账户所有者会让每个账户各持一套 transport,并重复 driver 的连接池、身份与并发许可。
  • 账户所有者只持 grant、刷新、租约容量与恢复规则;执行交换需要接收 URL、headers、body 并返回流,等于成为模型传输的所有者。
  • 其余两条路被规则封死:回复里带 bearer 是 AGENTS.md 禁止的 secret 值;交对象或句柄是 §7 禁止的。
  • 现行边界:bearer 只在回调栈内一次尝试中存在,不落盘、不写日志、不进错误与客户端回复;租约的容量、过期、恢复与结算都在所有者内部;回调不在锁内,且不得回调同一所有者。

如果这个例外不被接受,需要把模型传输迁到账户所有者,另行设计。

@eric8810

Copy link
Copy Markdown
Collaborator Author

with_lease 例外:理由成立,可以接受,但要收窄边界。

  • bearer 最终必须进 HTTP 传输。让账户所有者执行这次交换,就要接管模型的传输与 driver,等于第二套业务逻辑。
  • AGENTS.md 的 secret 规则约束的是 secret 跨过公开面,所以例外只在这些条件下成立:
    • 只有模型传输的所有者(Provider/ConfiguredModels)可以调用,租约绑定到调用行;
    • 契约写明其他行调用时返回的错误种类;
    • 跨语言插件拿不到这个回调。
  • 这三条写进例外和操作表,交付评论的验收加一条对应的流程测试:其他行调用被拒。

@eric8810

Copy link
Copy Markdown
Collaborator Author

更正 #2096 (comment) :那条撤回,with_lease 不是例外,而是不需要。

  1. bearer 是可信进程内部件之间的值。 AGENTS.md 规则 11:进程内插件不靠依赖声明隔离,所以「只有某个调用方能拿到」不是边界。secret 规则守的是:bearer 不进客户端回复、UI、日志、错误文本、持久化、模型上下文或 Timeline。契约写清这几条即可,不需要例外,也不需要维护者确认。
  2. lease 表只是替调用方保管 grant 代次。 crates/dim-oauth/src/lib.rs 的 leases/MAX_LEASES 和 dim_oauth_flow.rs 的 rejected_credentials_recover_once_and_only_the_owner_signs_out 表明,lease id 的作用只是在被拒时分辨被拒的是当前 grant 还是已被取代的 grant。给凭据值带一个 generation 就够了;lease id、容量、过期、释放和回调都可以删掉。
  3. 账户所有者的目标操作:
    • credential({provider, model}) -> {protocol, base_url, headers, bearer, generation}:进入刷新窗口时由所有者刷新;
    • rejected({provider, generation}) -> credential:当前代刷新一次后返回;已被取代的代直接返回当前凭据;刷新被拒,或恢复出来的那一代再被拒时,按登出规则返回 account_required。
      重试次数和失败链留在 Provider 的 invoke。调用方不持有任何要释放的东西。
  4. Provider/ConfiguredModels 给媒体执行器用的 with_lease 同样改成按 model 读凭据值。
  5. 交付评论的删除清单 加上 with_lease、LeaseOwner、LeaseHandle、CredentialLease 的 handle、MAX_LEASES、LeaseNotFound、LeaseCapacity、finish_rejected;流程测试改写成 credential → rejected 的形状。

The account owners hand out a credential value carrying the grant
generation instead of a lease handle. `credential({provider, model})`
answers the connection facts and refreshes inside its window;
`rejected({provider, generation})` refreshes the current generation once,
answers the current credential for a superseded one, and follows the
sign-out rule when the refresh is rejected or the recovered generation is
rejected again. The lease id, capacity, expiry, release, recovery
callback and `finish_rejected` are removed; retries stay with Provider's
`invoke`.

The bearer is a trusted in-process value. ManagedAccount states where it
never goes; Provider, ConfiguredModels, DimOAuth, ManagedOAuth and
ManagedProviders link that paragraph. The maintainer-confirmation
exception is removed.

Refs #2019 · Refs #2015
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head ce133c0a0。

  • 删掉例外与维护者确认:bearer 是可信进程内部件之间的值;ManagedAccount 写清它不进入客户端回复、UI、日志、错误文本、持久化、模型上下文与 Timeline,其他五份文档链接这一条,不再重复。
  • with_lease 与 lease 表删除:账户面改成 credential({provider, model}) -> {protocol, base_url, headers, bearer, generation} 与 rejected({provider, generation}) -> credential;当前代刷新一次,已被取代的代直接返回当前凭据,刷新被拒或恢复出来的代再被拒按登出规则返回 account_required。lease id、容量、过期、释放、回调、finish_rejected 与对应错误种类全部删除;DimOAuth、ManagedOAuth、ManagedProviders 实现同一组。
  • Provider 自己重试:invoke 按失败链调用 credential → 发送 → 被拒时 rejected → 重试;重试次数归 Provider。Provider 与 ConfiguredModels 给媒体执行器的 with_lease 改成按 model 读凭据值,媒体调用方示例同步。
  • 同步:职责分界、调用方示例、操作表、错误、流程、§7 行(「凭据是带 generation 的值」)与绑定附录;交付评论的删除清单、调用方迁移与验收(credential → rejected 形状,保留三条断言)已改,首行 head 已更新。

@eric8810
eric8810 marked this pull request as ready for review November 23, 2026 12:13
The ManagedProviders retirement list keeps the forwarding methods that
existed; the credential-recovery methods are replaced by the account
face's `credential` and `rejected`, so `recover_rejected` and
`finish_rejected` no longer appear in the contract.

Refs #2019 · Refs #2015
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按核对修改,head 0104189ae:ManagedProviders 的 forwarding 列表删掉 recover_rejected、finish_rejected,改为由账户面的 credential 与 rejected 替代;文档里已搜不到这两个名字。

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 0104189ae。

  • 删掉 account data forwarding 列表里的 finish_rejected;旧名 recover_rejected 一并去掉,由账户面的 rejected 替代。

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按 A–G 自查修改,head 67d9fccc0。

  • A 绑定附录:错误枚举改成 tag = "code" 的 snake_case code;invoke 的 consume/admit 改为直接参数,请求结构只留数据;prepare_startup/release_startup 加 caller: &Ctx;补 FailureChain、Consumed、Admitted、Credential、CredentialOwner、StartupConnection、StartupLimits、AccountIdentity 等附录类型;示例签名与附录一致(preferences、retain_startup、subscribe 去掉多余的 cancelled/请求对象);Provider 的 CredentialRequest 改名 StaticCredentialRequest,避免与 ManagedAccount 同名。
  • B 一致性:invoke 错误补 auth_required、failed;credential/rejected 补 unavailable、failed;各操作取消逐行列明;单一写入方与部件数量在 Rule check 中一致。
  • C 取代:六份契约各加 Supersedes;改 service-faces.md 的 modelHost/managedSearch/oauth/provider 行与 §4.2、§4.6、§4.10;改 process-owner-operations.md 的模型选择、调用、配置、启动行;改 provider-management.md §2 的表行与 §3.6、§3.8;改 auxiliary-model.md §4 为指针(保留 4.1–4.3 标题以维持源码注释锚点)。
  • D 客户端可见:每份契约加 Client-visible changes,均为 None(provider.*、account.* 等名称、字段与错误码不变)。
  • E 分页读:本契约无分页读,无 open/close 会话式接口。
  • F 引用:§7 用 docs(principles): add owners and operations #2029 的 PR URL;FileStorage 等跨 PR 链接用 PR URL;README 的 By scope 同步。
  • G line_owner:Rpc 示例改为 line_owner::<PromptAdoption>(line)?.configure(..),按 line id 调分支组数据面。

@eric8810

Copy link
Copy Markdown
Collaborator Author

来自 #2094 的核对(评审 6025935963,P2-8):docs/design/plugins/Provider.md 的读取示例沿用了 user_agent().await.ok().flatten(),而端口返回的是 Result<UserAgent, _>,.ok() 是 Option<UserAgent>,没有 flatten()。请改成:

let configured = provider_settings
    .user_agent()
    .await
    .ok()
    .and_then(|view| view.user_agent);

同一模式也已在本 PR 的 ProviderSettings 示例里修正。

…review

Declare the `invoke` callbacks as direct `impl Fn` parameters returning
`Result<_, CallError>`, hand the consumer a serializable chunk, require
`admit`, and report retry waits as `Retrying` chunks. Derive `Debug` on
the error enums, use snake_case `code` tags, and fix the selectable
union, the shared `FailureChain`, and the shared credential with an
optional generation.

Define the account catalog, the availability callback registration and
the search/title types; keep `creationRecord` with SessionStore and read
it through the dependency; state the ChatGPT client-session rule in
Provider.

State what the contracts supersede and update those paragraphs:
resource-owner-operations, resource-faces, provider-management,
auxiliary-model, Modality, ImageUnderstanding and the App Server README.
Add the client-visible sections (none), the §7 and #2127 links, and the
retry column in the error tables.

Refs #2019 · Refs #2015
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审与自查标准修改,head 13f9b948e。

P2

  1. invoke 回调改成直接参数 impl Fn(ProviderChunk) -> BoxFuture<'static, Result<Consumed, CallError>>、impl Fn() -> ... Result<Admitted, CallError>;admit 必填,绑定导出 admit_all 默认;chunk 改成可序列化的 ProviderChunk,重试等待以 Retrying chunk 报告。
  2. 错误枚举加 Debug;tag = "code"、content = "details"、snake_case,与错误表一致。
  3. SelectableModels 改相邻标记 tag = "kind", content = "models"。
  4. FailureChain 直接复用 dim_agent_types::FailureChain。
  5. 重试进度是 Retrying chunk;需求行同步。
  6. ConfiguredModels 的 invoke/credential 与 Provider 完全同形(含 StaticCredentialRequest)。
  7. Credential.generation 改 Option<u64>(静态为 None),Provider 附录导入共享类型。
  8. provider-management.md 的 provider Settings 行改为 ProviderSettings 拥有(design(settings): owner contracts for Settings and the settings sections #2094),Provider 读 user_agent。
  9. creationRecord 留在 SessionStore(docs(storage): define the session storage owners' target contracts #2091),Provider 只声明依赖并读取;不再声称拥有。
  10. Modality.md 与 ImageUnderstanding.md 的段落改为 providerService.resolve/selectable/media_route/credential 与 invoke,列入 Supersedes。
  11. subscribe 改成 caller + notify 回调注册,随调用行结束;附录补 NotifyFn、AccountCatalog、AccountSnapshot。
  12. auxiliary-model.md §5–11 标为历史,§4 指向 providerService.invoke;4.1–4.3 标题保留以维持源码注释锚点。

P3

  • selectable 补 invalid,invoke 补 not_found;InvalidPath 删除,output_limit 不再出现;prepare_startup 三处统一为 ModelSelection。
  • 四份账户契约补 AccountCatalog;DimOAuth 定义 SearchRequest/SearchReply/SearchError、TitleRequest/TitleReply/TitleError 并注明与现有 facade 类型的映射;flows 表补 Caller unloads 列。
  • service-faces.md 的未知字段统一为 invalid;Provider/ConfiguredModels 的类型名与目标重命名写明。
  • PR 描述去掉 lease,改为 credential generation;process-owner-operations.md 删除不存在的 ModelLog 行引用。
  • Provider 不再依赖 FileStorage root_path,录制目录只由 ModelLog recording 给出。
  • ChatGPT 交互式 Session 规则写进 Provider:读 SessionStore 的 creationRecord,非客户端 Session 返回 invalid。

自查额外修改

  • 7 条自查:每条现状陈述带路径(provider.rs、dim-agent-aimux);Supersedes 每条都在本 PR 改过(resource-owner-operations.md、resource-faces.md、provider-management.md、auxiliary-model.md、Modality.md、ImageUnderstanding.md、service-faces.md、process-owner-operations.md、App Server README);删除/改名的引用已用 grep 核对;错误表加 Retry 列;§7 与 按 id 调用:由持有实例的一方选目标(base-1) #2127 用 PR/issue URL。
  • 绑定附录放进临时 crate(workspace crates + rutis 0.23)cargo check:通过;invoke 的闭包参数在展开里走 function(wire, ..),已确认是可调用的回调而非数据。
  • 客户端冻结:provider.*、account.*、account.codex.*、account.grok.*、account.chatgpt.* 的方法、字段、错误码、通知名不变;各契约的 Client-visible changes 均为 None。

保留文档只改了本所有者段落:service-faces.md(modelHost/managedSearch/oauth/provider 行与 §4.2/§4.6/§4.10)、process-owner-operations.md(模型选择/调用/配置/启动行与 modelHost 段)、resource-owner-operations.md(Provider → sqliteStorage)、resource-faces.md(managed OAuth token store 行)、provider-management.md(§2 行、§3.6、§3.8、settings 行)、auxiliary-model.md(§4)、Modality.md 与 ImageUnderstanding.md 的相关段落、App Server README 的 Managed provider contract 段。SessionTitle(#2099)、Web(#2099)的页面仍由各自契约更新,合并顺序已写进 PR 描述。

@yyhhyyyyyy 请复核。

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

PR #2096 at 13f9b94: review

Refs #2019 and #2015. This PR defines the target contracts for the model and provider owners: Provider, ConfiguredModels, the account owners (ManagedAccount, DimOAuth, ManagedOAuth, ManagedProviders), and the service-face, resource-face, owner-operation, management and auxiliary-model clauses that name their old surfaces. This round reviews the full main...head, not only 375e5da...13f9b94.

Verdict: REQUEST_CHANGES

Round status

Fixed in 13f9b94 (round-1 threads): invoke callbacks (4667714929), Provider Debug (4667714943), SelectableModels tagging (4667714951), retry progress (4667714967), user_agent owner (4667714976), creationRecord (4667714987), selectable invalid (4667715002), invoke not_found (4667715010), ManagedAccount Debug (4667715017), credential generation (4667715026), ConfiguredModels invoke shape (4667715050), ConfiguredModels error kinds (4667715060), DimOAuth search and title types (4667715065).

Partially fixed: FailureChain (4667714959), consumer contracts and Supersedes (4667714994), subscribe type (4667715037), process-owner operations (4667715071), provider-management 3.7 (4667715081), auxiliary-model historical sections (4667715090). The remaining parts are P2 #1 to #4 and P3 #5, #7, #8 below.

The round-1 P3 list is mostly resolved: invalid_path and output_limit are gone, AccountCatalog is defined, the DimOAuth table columns are fixed, service-faces.md uses invalid, the owner type rename is stated, FileStorage root_path is gone, the ModelLog row reference is gone, and the ChatGPT client-session rule is in Provider. The prepare_startup reply shape, the undefined admit_all, and the merge-order forward references remain.

P2

1. invoke returns no updated failure chain or failure facts

Problem: invoke takes Mode::Dialogue { chain: Option<FailureChain> } and continues the caller's retry budget, but its reply is {accepted} and its request failure is provider_failed {retryable, message} (Provider.md:159, Provider.md:386, Provider.md:349). The updated attempt and wait totals, and the runtime failure facts, never return to the caller.

Failure scenario: ModelProvider owns the terminal step/model-output-end and must write the failure chain totals and the runtime failure kinds (#2102 ModelProvider.md:13, :86, :92). With this contract it can only write the chain it sent in, so the next turn retries with a stale budget, and the terminal fact loses kind, status and provider_code. The current code supplies exactly those facts through HostError::Failed { model: ModelFailureFacts } (crates/dim-agent-capabilities/src/model_provider.rs:52-64, crates/dim-agent-types/src/events.rs:770). The Retrying chunk can approximate attempt and delay_ms, but not the failure kind, status, provider code, or a failure before the first retry. This is the failure scenario of round-1 P2 #4, still open after the type was shared.

Evidence: docs/design/plugins/Provider.md:159, :165, :186, :349, :386; #2102 head docs/design/plugins/ModelProvider.md:13, :86, :92; crates/dim-agent-capabilities/src/model_provider.rs:52-64; crates/dim-agent-types/src/events.rs:770-800.

Fix: return the updated FailureChain and a ModelFailure value with the request failure, either in InvokeReply or in the provider_failed details, and state that ModelProvider writes them into the terminal fact. If accumulation from Retrying chunks is intended, state how the non-derivable facts come back.

2. process-owner-operations.md keeps a second invoke contract

Problem: The updated row says invoke(request, mode, consume, admit?, cancelled) (process-owner-operations.md:26), making admit optional, while Provider.md:159 and Provider.md:403-405 make it required. The retained Model invocation table at lines 55-58 still defines mode as once or recovering, consume(next, cancelled) returning {kind: returned, value, replaySafe}, and hooks? with beforeAttempt and waiting, all replaced by Mode, Consumed, admit and Retrying (Provider.md:165). Line 58 also returns invalid_request, while the target uses invalid.

Failure scenario: A caller or binding built from this contract passes no admit, asks for a recovering mode and a hooks object that do not exist, and expects a consume reply shape the binding cannot encode. Provider and ModelProvider end up with two incompatible invoke shapes.

Evidence: docs/design/contracts/process-owner-operations.md:26, :55-58; docs/design/plugins/Provider.md:159, :165, :341, :403-405.

Fix: Delete the Model invocation table and point to Provider, or rewrite it to Provider's exact Mode, Consumed, admit and error names. Make admit required in the row and name admit_all.

3. DimOAuth's subscriber example contradicts its own binding

Problem: The Web example calls dim_account.subscribe(cancelled.clone()) and expects a value it can follow (DimOAuth.md:41-42). The binding in the same document takes (&Ctx, NotifyFn, CancelledFn) and returns () (DimOAuth.md:188), and ManagedAccount defines the same callback registration (ManagedAccount.md:89, :229). The value-returning Subscription is gone.

Failure scenario: Web implements or copies a stream-shaped subscribe that no binding provides, while a binding generated from the appendix takes a callback. The same face has two shapes.

Evidence: docs/design/plugins/DimOAuth.md:41-42, :188; docs/design/plugins/ManagedAccount.md:89, :193-194, :229.

Fix: Rewrite the DimOAuth example with the notify callback and state that the registration ends with the calling row or the owner's close.

4. Deleted selectable reads remain in the consumer contracts

Problem: Provider has one selectable({use}) (Provider.md:155), the host ports are deleted (provider-management.md:1006), and the account model is unchanged. Modality's target text still says Provider "adds one read to the same port, selectableForModality" (Modality.md:297) and derives its options from selectableForModality (Modality.md:465); ImageUnderstanding still names selectableModels and selectableForModality (ImageUnderstanding.md:147).

Failure scenario: Implementers add or keep a host port that no owner provides, or derive media options from a read whose reply shape no longer exists. The claim that the consumer contracts are updated is false at these lines.

Evidence: docs/design/plugins/Modality.md:297, :465; docs/design/plugins/ImageUnderstanding.md:147; docs/design/plugins/Provider.md:155; docs/design/appserver/provider-management.md:1006.

Fix: Replace these names with selectable({use: {modality: {operation}}}) and selectable({use: "chat"}) where the capability filter applies, or mark the passages historical.

P3

5. auxiliary-model replacement call passes None for admit

Problem: auxiliary-model.md:76 documents the migration target as providerService.invoke(request, Mode::Once, consume, None, cancelled). Provider now requires the admit callback and names admit_all for callers without a budget (Provider.md:165, :403-405).

Failure scenario: A caller following the only replacement note for the deleted face builds a call that does not compile against the appendix.

Evidence: docs/design/appserver/auxiliary-model.md:76; docs/design/plugins/Provider.md:165, :403-405.

Fix: Pass admit_all and name it; do not show the old optional-callback shape.

6. The plugin index still says request leases

Problem: The new rows say "request leases" and "leases" (plugins/README.md:14-16), while ManagedAccount says the caller never holds a lease, an id to release or an expiry (ManagedAccount.md:96) and the contract replaced leases with the credential generation.

Failure scenario: A reader of the plugin index reintroduces a lease operation or a lease-shaped credential reply that the account contract deliberately removed.

Evidence: docs/design/plugins/README.md:14-16; docs/design/plugins/ManagedAccount.md:96.

Fix: Replace "request leases" and "leases" with "credential generation" in the three rows.

7. Provider.md has no Supersedes section

Problem: The owner-redesign template in #2029 requires a Supersedes section, and every other owner document in this PR has one (ManagedAccount.md:231, ConfiguredModels.md:94, DimOAuth.md:125, ManagedOAuth.md:98, ManagedProviders.md:105). The previous head had one at the end of Provider.md; this head removed it.

Failure scenario: The delivery has no owner-side list of the clauses this contract replaces. The clauses were edited in this PR, but a future change cannot tell which surfaces are retired and which are still owned by the old Provider management page.

Evidence: docs/design/plugins/Provider.md section list (no Supersedes); docs/templates/owner-redesign.md:46 at #2029 head; the five sibling sections above.

Fix: Restore the section, listing the service-faces.md, provider-management.md, process-owner-operations.md, resource-owner-operations.md and auxiliary-model.md clauses this contract replaces and the deleted names (modelHost, selectableModelsHost, modelSelectionHost, auxiliaryModel, providerConnectionResolver, modalityConnectionHost).

8. prepare_startup reply shape differs between the table and the appendix

Problem: The operation table says the reply is {selection} (Provider.md:156), while the appendix returns a bare ModelSelection (Provider.md:396), the caller example binds it bare (Provider.md:125), and the cross-owner contract says prepare_startup(request) -> ModelSelection (process-owner-operations.md:28).

Failure scenario: A generated binding wraps or unwraps the wrong level, so a caller reads a selection object from selection in one binding and none in another.

Evidence: docs/design/plugins/Provider.md:125, :156, :396; docs/design/contracts/process-owner-operations.md:28.

Fix: Pick the bare ModelSelection and change the table, or wrap all four places.

9. admit_all is undefined

Problem: Provider.md:165 calls admit_all "the binding's default", and the caller examples pass it (Provider.md:94, :111; ConfiguredModels.md:43), but no definition, import or signature for it exists in either appendix.

Failure scenario: An implementer cannot tell whether to define a constant, a function, or a generated default; a foreign-language binding has no way to omit a required callback.

Evidence: docs/design/plugins/Provider.md:94, :111, :165; docs/design/plugins/ConfiguredModels.md:43; Provider appendix Provider.md:399-406.

Fix: Define admit_all as a public function or constant with its exact return type, or state that every caller supplies a function and remove the "default" wording.

10. Cross-PR overlap: #2094 edits the same provider-management lines and is not in the merge order

Problem: The PR body states the merge order #2029 -> #2080 -> #2091, #2092, #2093 -> this PR, but this PR cites ProviderSettings and ModelLog as dependencies (Provider.md:138-139, :231) and rewrites the provider source row at provider-management.md:53. #2094 changes the same row and the same page intro at provider-management.md:6, and #2094's branch still says the S4 face "remains unchanged" at line 6.

Failure scenario: #2094 merges after this PR without rebasing, or conflict resolution takes #2094's line 6, and the merged page says the auxiliary face is unchanged while this contract deletes it. The line 53 row is edited twice with different wording.

Evidence: this head docs/design/appserver/provider-management.md:6, :53; #2094 head docs/design/appserver/provider-management.md:6, :53; PR body merge order.

Fix: Add #2094 to the merge order, and decide in one PR whether line 6 and the line 53 row are written here or there.

11. Dependency errors have no stated mapping

Problem: invoke calls the account owner's credential and rejected and reads SessionStore's creationRecord (Provider.md:163, :141), but Provider's error table and ProviderError do not say how the dependency codes map. The account owner has account_required and unsupported_provider (ManagedAccount.md:106-109), SessionStore has storage (#2091 head SessionStore.md:111), and Provider has auth_required and failed (Provider.md:171-179).

Failure scenario: An implementation either leaks a code the Provider binding does not define or maps two dependency failures to the same Provider code, so a caller cannot tell whether to sign in or to fix the record.

Evidence: docs/design/plugins/Provider.md:141, :159, :163, :171-179; docs/design/plugins/ManagedAccount.md:104-112; #2091 head docs/design/plugins/SessionStore.md:111.

Fix: State the mapping, for example account_required to auth_required and storage to failed, or carry the owner error in the details.

Hypotheses

  • selectable({use: modality}) returns default: Option<ModelId> and the requirement row says "the current default" (Provider.md:32, :155), but Modality owns each operation's persisted default in its own settings (Modality.md:42, :465), and Provider reads no other owner's state (Provider.md:208). If default is meant to be null for modality uses, say so; otherwise the two defaults can disagree. Unconfirmed whether the author intends Provider to hold a modality default.
  • ManagedAccount.md:11 says the account record is written "with the account's own revision and lease", but #2080 FileStorage says its public face has no lease and the account composes exclusion from update (#2080 head FileStorage.md:141-143). If "lease" here means the account's own claim field, reword it; otherwise the dependency contract is missing an operation. Unconfirmed.

Checks

  • Full main...head read; delta 375e5da...13f9b94 checked against the 19 round-1 threads.
  • node scripts/adr-check.mjs --base 1bc7d67d passes (16 changed files, no ADR edits).
  • git merge-tree --write-tree origin/main HEAD is clean; no textual conflict with current main.
  • Cross-PR: #2091 creationRecord({id}) -> {origin, leader?} matches Provider.md:141; #2099 uses TitleRequest {provider, text} and TitleError with the shapes in DimOAuth.md:136-178; #2102 ModelProvider depends on invoke and exposes the failure-fact gap above; #2080 has no public lease; #2029 is the rule source. Sibling branches #2080, #2092, #2093, #2099, #2102 still carry the old provider rows in service-faces.md, so they must land before or be rebased on this PR as the stated order says.
  • CI for 13f9b94: ci-ok success, verify (linux) success, macos-native success; windows, acp-registry, web, dependencies, scripts and static-checks skipped.

Unverified

  • Whether #2094's line 6 and line 53 conflict resolution was coordinated outside this PR; the stated merge order does not include it.
  • Whether ProviderChunk dropping MessageStart, TextEnd and ThinkingEnd still lets the target ModelProvider close its step/text and step/thinking blocks the way crates/dim-agent-capabilities/src/output.rs:600-710 does; #2102 does not state the mapping.

Comment thread docs/design/plugins/DimOAuth.md Outdated
```rust
let AccountAvailability { signed_in, .. } = dim_account.availability(cancelled.clone()).await?;
if signed_in {
let mut changes = dim_account.subscribe(cancelled.clone()).await?;

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.

Problem: this example calls subscribe(cancelled.clone()) and expects a value it can follow, but the binding in the same document takes (&Ctx, NotifyFn, CancelledFn) and returns () (DimOAuth.md:188), and ManagedAccount defines the same callback registration (ManagedAccount.md:89, :229). The value-returning Subscription is gone.

Failure scenario: Web copies a stream-shaped subscribe that no binding provides, while a binding generated from the appendix takes a callback.

Evidence: docs/design/plugins/DimOAuth.md:41-42, :188; docs/design/plugins/ManagedAccount.md:89, :193-194, :229.

Fix: rewrite the example with the notify callback and state that the registration ends with the calling row or the owner's close.

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 7cc7e87. The example now registers the notify callback with the calling row, dim_account.subscribe(&self.ctx, Arc::new(|availability| ...), cancelled) (DimOAuth.md:41-54), which matches the binding subscribe(&self.ctx, NotifyFn, CancelledFn) (DimOAuth.md:200) and ManagedAccount's NotifyFn (ManagedAccount.md:193-194).

| Dialogue, summary and suggestion → active invocation owner | `modelHost.invoke(request, mode, consume, cancelled, hooks?) → value`. Full `ModelRequest` with pinned tools, configuration, cached prefix and capability snapshot. Attempt contract below. |
| Session configuration → `providerService` (managed profile) | `configuration(explicit?, cwd?, preferences) → ModelSelection`; `applyPreferences(current, update) → ModelSelection`. Bind the existing Provider operations. |
| Session creation/adoption and Collaboration → `providerService` (managed profile) | `prepareStartup(request) → {model, admissionId?}`, `checkStartup(source) → void`, `retainStartup({sessionId, generation, model, admissionId?}) → void`, `releaseStartup({admissionId}) → void`. Reuse the pending startup binding ID. Retain on success for that Session generation; release on failure or caller unload. |
| Dialogue, summary and suggestion → `providerService` | `invoke(request, mode, consume, admit?, cancelled) → {accepted}`. Full `ModelRequest` with pinned tools, configuration, cached prefix and capability snapshot; retries and credential recovery stay with the owner, see [Provider](../plugins/Provider.md). |

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.

Problem: admit? is optional here, but Provider requires it (Provider.md:159, :403-405). The retained Model invocation table at lines 55-58 still defines once/recovering, consume(next, cancelled) and hooks?, all replaced by Mode, Consumed, admit and Retrying (Provider.md:165). Line 58 also returns invalid_request where the target uses invalid.

Failure scenario: a caller or binding built from this contract omits admit, asks for a recovering mode, and passes a hooks object that does not exist; Provider and ModelProvider end up with two invoke shapes.

Evidence: docs/design/contracts/process-owner-operations.md:26, :55-58; docs/design/plugins/Provider.md:159, :165, :341, :403-405.

Fix: delete the table or rewrite it to Provider's exact shapes, make admit required, and name admit_all.

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 7cc7e87. The row now takes a required admit and returns {accepted, chain?} (process-owner-operations.md:26). The Model invocation table now uses Mode, the direct consume and admit callbacks, Retrying and provider_failed {failure, chain} (process-owner-operations.md:55-59), so it no longer defines a second shape.

The service has no timeout of its own; the budget is the consumer's.
- Errors are data `{code, message}`: `invalid_request`, `model_unavailable`, `failed`,
`cancelled` (§6).
Superseded: there is no `auxiliaryModel` service. A caller runs `providerService.invoke(request, Mode::Once, consume, None, cancelled)` and collects the text in its consumer.

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.

Problem: the replacement call passes None for admit, but Provider makes admit a required callback and names admit_all for callers without a budget (Provider.md:165, :403-405).

Failure scenario: the only migration note for the deleted face documents a call that does not compile against the new appendix.

Evidence: docs/design/appserver/auxiliary-model.md:76; docs/design/plugins/Provider.md:165, :403-405.

Fix: pass admit_all and name it; do not show the old optional-callback shape.

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 7cc7e87. The replacement call passes admit_all (auxiliary-model.md:76), and admit_all is the exported callback in the binding (Provider.md:347-350).


- **Problem.** `modality.capabilities` must compute `options` and automatic resolution from the models Provider can select. Provider's model-selection port resolves one model, and the catalog reads are client management methods, so a process owner cannot enumerate the selectable set with its declared capabilities.
- **Existing mechanisms.** The single-model selection port cannot filter by an operation's capability. A new client method would expose management to the owner and duplicate the catalog. The Provider-side read-only contract is tracked separately by [#790](https://github.com/arcships/dim/issues/790). Delivered: the process host port `SelectableModelsHost` in `dim-agent-capabilities`, provided by Provider and by the configured model profile, whose `selectableModels` read enumerates the models execution would accept with their declared capabilities.
- **Existing mechanisms.** The single-model selection port cannot filter by an operation's capability. A new client method would expose management to the owner and duplicate the catalog. The Provider-side read-only contract is tracked separately by [#790](https://github.com/arcships/dim/issues/790). Delivered by the owner contract: `providerService.selectable` ([Provider](Provider.md)) enumerates the models execution would accept with their declared capabilities, in both profiles.

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.

Problem: the paragraph immediately below still says Provider adds selectableForModality to the same port, and line 465 derives the options list from that read. Provider has one selectable({use}) (Provider.md:155) and the host ports are deleted (provider-management.md:1006).

Failure scenario: implementers keep or add a process host port that no owner provides, or derive media options from a reply shape that no longer exists.

Evidence: docs/design/plugins/Modality.md:296-297, :465; docs/design/plugins/Provider.md:155; docs/design/appserver/provider-management.md:1006.

Fix: replace the name and reply shape with selectable({use}), or mark the passage historical.

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 7cc7e87. Modality.md:297 now names Provider's selectable({use}), Modality.md:465 derives options from it, and ImageUnderstanding.md:147 uses selectable with Use::Chat and Use::Modality.

| [Migration](Migration.md) | on-demand import tasks, source mappings, progress and retry records; unloaded after settlement | — | — | [Delivery plan](../../plan/analysis/legacy-migration.md) |
| [Provider](Provider.md) (owner contract) | model owner of the product profile: provider and model records, selection, credentials, execution, temporary connections, the wire recorder | — | — | [#2019](https://github.com/arcships/dim/issues/2019) |
| [ConfiguredModels](ConfiguredModels.md) (owner contract) | model owner of the API-key profile: the model file, its credentials and execution | — | — | [#2019](https://github.com/arcships/dim/issues/2019) |
| [Managed account owners](ManagedAccount.md) (owner contract) | the account role: record, login, tokens, availability, catalog, request leases, client namespace | — | — | [#2019](https://github.com/arcships/dim/issues/2019) |

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.

Problem: the new row says "request leases", and lines 15-16 say "leases", while ManagedAccount says the caller never holds a lease, an id to release or an expiry (ManagedAccount.md:96) and the contract replaced leases with the credential generation.

Failure scenario: a reader of the plugin index reintroduces a lease operation or a lease-shaped credential reply the account contract removed.

Evidence: docs/design/plugins/README.md:14-16; docs/design/plugins/ManagedAccount.md:96.

Fix: replace "request leases" and "leases" with "credential generation".

Comment thread docs/design/plugins/Provider.md Outdated
#[error("cancelled")] Cancelled,
#[error("provider is unloading")] Closed,
#[error("{0}")] Failed(String),
#[error("{message}")] ProviderFailed { retryable: bool, message: String },

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.

Problem: invoke takes Mode::Dialogue { chain } but returns only {accepted} on success and ProviderFailed { retryable, message } on failure (Provider.md:159, :349). The updated chain totals and the runtime failure facts never return to the caller.

Failure scenario: ModelProvider writes the terminal step/model-output-end with the failure chain totals and the runtime failure kinds (#2102 ModelProvider.md:13, :86, :92). With this contract it can only write the chain it sent in, so the next turn retries with a stale budget, and the terminal loses kind, status and provider_code. The current code supplies those facts through HostError::Failed { model: ModelFailureFacts } (crates/dim-agent-capabilities/src/model_provider.rs:52-64, crates/dim-agent-types/src/events.rs:770). Retrying chunks can approximate attempts and delays but not the failure facts or a failure before the first retry. This is the failure scenario of round-1 P2 #4, still open after the type was shared.

Evidence: docs/design/plugins/Provider.md:159, :165, :186, :349, :386; #2102 head docs/design/plugins/ModelProvider.md:13, :86, :92; crates/dim-agent-capabilities/src/model_provider.rs:52-64; crates/dim-agent-types/src/events.rs:770-800.

Fix: return the updated FailureChain and a ModelFailure value with the request failure, in InvokeReply or in the provider_failed details, and state that ModelProvider writes them.

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.

Partially fixed in 7cc7e87. invoke now returns the runtime failure facts and a chain in provider_failed, and the reply carries a chain (Provider.md:159, :165, :179, :354, :392). Remaining: the terminal fact has no chain field, so the claim that ModelProvider writes both into step/model-output-end cannot hold, and the chain duplicates ModelFailure.attempts and waited_ms. I withdraw the round-2 request for a separate chain; the simplest fix is to drop it. See the review body, P2 #1.

Comment thread docs/design/plugins/Provider.md Outdated
| `resolve` | The model one request resolves to | `{target?, cwd?}` | `Selection` | The caller cancels; no timeout | `invalid`, `not_found`, `unavailable`, `auth_required`, `cancelled`, `closed`, `failed` |
| `preferences` | Apply a patch to an adopted selection | `{selection, update}` | `Selection` | None; completes immediately | `invalid` |
| `selectable` | The models that can run a use, and the default | `{use: "chat" \| {modality}}` | `{models, default?}` | The caller cancels; no timeout | `invalid`, `cancelled`, `closed`, `failed` |
| `prepare_startup` | Admit a temporary connection under the calling row and select its model | `{target?, cwd?, preferences, connection?, limits?}` | `{selection}` | The caller cancels before admission | `invalid`, `invalid_connection`, `not_found`, `unavailable`, `auth_required`, `cancelled`, `closed`, `failed` |

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.

Problem: the table says the reply is {selection}, while the appendix returns a bare ModelSelection (Provider.md:396), the caller example binds it bare (Provider.md:125), and the cross-owner contract says prepare_startup(request) -> ModelSelection (process-owner-operations.md:28).

Failure scenario: a generated binding wraps or unwraps the wrong level, so callers read a selection object from selection in one binding and none in another.

Evidence: docs/design/plugins/Provider.md:125, :156, :396; docs/design/contracts/process-owner-operations.md:28.

Fix: use the bare ModelSelection in all four places, or wrap all four.

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 7cc7e87. The table, the caller example, the appendix and the cross-owner row now agree on a bare ModelSelection (Provider.md:125, :156, :402; process-owner-operations.md:28).

Comment thread docs/design/plugins/Provider.md Outdated

`prepare_startup` admits the source under the calling row; the row's unload releases it, so a missed `retain_startup` or `release_startup` settles with the row. `retain_startup({session, model})` moves the source to the Session named by the caller and the model's metadata; the Session's close releases it, so a missed failure-path release settles with the Session. `release_startup({model})` is the optional early release for a creation that failed; it answers `not_found` once a Session retains the source. A member Session that inherits the leader's model retains the same source by value. A connection never crosses. `Selection` is the adopted provider, model, configuration, capability snapshot and metadata. `Credential` is [ManagedAccount](ManagedAccount.md)'s value: static credentials carry no generation; an account owner's carry the grant's. `invoke` calls the account owner's `credential`, sends, and on a refusal calls `rejected` with the refused generation before retrying within its own failure chain.

`invoke`'s `mode` is `Dialogue { chain? }` or `Once`. `Dialogue` continues the failure chain when given one and reports retry waits as `Retrying` chunks; `Once` makes exactly one request with no retry and no model substitution, which is what a caller sending one paid request needs (Report's model generation). `consume(chunk)` reports `Continue`, `End`, `CredentialRejected` (the provider refused the credential, so `invoke` calls the account owner's `rejected` once and retries) or `Failed { retryable }`; output accepted before a failure prevents replay, and the reply's `accepted` says whether any output was accepted. `admit` runs before each attempt and answers `Admitted` or `Rejected { message }`; a caller without its own budget passes `admit_all`, the binding's default that admits every attempt. Both callbacks are direct parameters, so the request data stays serde-only. A request for `openai-chatgpt` requires a client-origin Session: Provider reads the Session's creation record (`creationRecord`) and answers `invalid` for a non-client Session.

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.

Problem: admit_all is called "the binding's default" and the examples pass it (Provider.md:94, :111; ConfiguredModels.md:43), but no definition, import or signature exists in either appendix.

Failure scenario: an implementer cannot tell whether to define a constant, a function, or a generated default, and a foreign-language binding cannot omit a required callback.

Evidence: docs/design/plugins/Provider.md:94, :111, :165, :399-406; docs/design/plugins/ConfiguredModels.md:43.

Fix: define admit_all as a public function or constant with its exact return type, or state that every caller supplies a function and remove the "default" wording.

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 7cc7e87. admit_all is defined in the appendix as an exported function (Provider.md:347-350), and the prose no longer calls it the binding's implicit default (Provider.md:165).

}
```

The `provider` client namespace keeps its published method names and request shapes; handlers call the operations above and the management operations. No management operation is also published on `providerService`.

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.

Problem: Provider.md has no Supersedes section. The owner-redesign template in #2029 requires one, and every other owner document in this PR has one (ManagedAccount.md:231, ConfiguredModels.md:94, DimOAuth.md:125, ManagedOAuth.md:98, ManagedProviders.md:105). The previous head had one at the end of this file; this head removed it.

Failure scenario: the delivery has no owner-side list of the clauses this contract replaces, so a later change cannot tell which surfaces are retired and which still belong to the old Provider management page.

Evidence: docs/design/plugins/Provider.md section list; docs/templates/owner-redesign.md:46 at #2029 head; the five sibling sections above.

Fix: restore the section, listing the service-faces, provider-management, process-owner-operations, resource-owner-operations and auxiliary-model clauses this contract replaces, and the deleted names (modelHost, selectableModelsHost, modelSelectionHost, auxiliaryModel, providerConnectionResolver, modalityConnectionHost).

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 7cc7e87. Provider.md now has a Supersedes section (Provider.md:420-429).

`invoke` returns the updated `FailureChain` on success and
`provider_failed { failure, chain }` on failure, so ModelProvider writes
the runtime `ModelFailure` facts and the retry totals into
`step/model-output-end`. Define the exported `admit_all`, and use the
bare `ModelSelection` for `prepare_startup` everywhere.

Restore the Supersedes section and update the retained pages the review
named: the model invocation table in the process-owner contract, the
DimOAuth subscribe example, the auxiliary-model migration note, the
provider-management relation paragraph, and Modality's and
ImageUnderstanding's selectable reads.

Refs #2019 · Refs #2015
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 7cc7e874e。

本轮评审逐条

  • Provider.md:386(failure facts):InvokeReply 改为 {accepted, chain?},失败返回 provider_failed { failure: ModelFailure, chain: FailureChain };invoke 段落写明 ModelProvider 把两者写进 step/model-output-end,下一步续用更新后的预算。
  • Provider.md:412:恢复 Supersedes,列出 service-faces、process-owner-operations、resource-owner-operations、provider-management、auxiliary-model、Modality、ImageUnderstanding 的条款与被删除的名字。
  • Provider.md:156:prepare_startup 的回复统一为 ModelSelection(表、附录、示例、跨所有者表一致)。
  • Provider.md:165:定义导出的 admit_all()(返回 BoxFuture<'static, Result<Admitted, CallError>>),正文不再说“binding 的默认”。
  • ManagedAccount.md:79 / DimOAuth.md:41:订阅示例改为 subscribe(&self.ctx, notify, cancelled) 回调注册,并写明随调用行或所有者关闭结束。
  • ConfiguredModels.md:43/:57、ManagedAccount.md:183/:187、Provider.md:155/:159、Process-owned 的错误码已在上一 head 修好,本轮复核未回退。
  • contracts/process-owner-operations.md:26,55-58:Model invocation 表改成 Provider 的 Mode、Consumed、必填 admit + admit_all、Retrying、provider_failed { failure, chain };删除 once/recovering/hooks?/invalid_request 旧形。
  • provider-management.md:1057:§3.7 的 relation 段改为 providerService.selectable({use}),不再说“无输入的 host port”。
  • auxiliary-model.md:76:迁移示例改传 admit_all。
  • Modality.md:297,:465 与 ImageUnderstanding.md:147:selectableForModality/selectableModels 改为 selectable({use})。

自查 1–9 发现

  1. 现状陈述核对路径:ProviderService(crates/dim-app-server/src/provider.rs)、ConfiguredModelsPlugin/AimuxModels(crates/dim-agent-aimux)、FailureChain/ModelFailure(crates/dim-agent-types/src/events.rs:327,770)、ModelChunk(crates/dim-agent-capabilities/src/host.rs:295)。
  2. 与现有文档的冲突在本 PR 改完:process-owner-operations.md、provider-management.md、resource-owner-operations.md、resource-faces.md、auxiliary-model.md、Modality.md、ImageUnderstanding.md、App Server README。
  3. 一名一义已复核:credential/rejected/invoke/selectable/resolve/preferences 在两 profile 与账户面一致;错误码 invalid 统一。
  4. 表、流程、例外、Rule check、附录、示例已对齐;InvokeReply、ProviderFailed、admit_all 三处一致。
  5. 每个结局写明下一步:单次调用、重试、所有者关闭/重载;Session 目标与 branch 目标分别列在流程表里。
  6. 改名/删除全仓 grep;auxiliary-model.md 4.1–4.3 标题保留给源码注释锚点;Provider.md 的 Supersedes 已恢复。
  7. 规则不带 Rust 拼写;未合并引用用 PR/issue URL(§7 → docs(principles): add owners and operations #2029,FileStorage → design(fileStorage): target contract #2080,SessionStore → docs(storage): define the session storage owners' target contracts #2091,ProviderSettings/ModelLog → design(settings): owner contracts for Settings and the settings sections #2094,SessionTitle/Web → design(2033): target contracts for Goal, SessionTitle, Web and Code Mode #2099,id 路由 → 按 id 调用:由持有实例的一方选目标(base-1) #2127)。
  8. 新增文字逐条回查 1–5,发现并修掉 prepare_startup 层级、admit_all 未定义、Modality/ImageUnderstanding 残留旧读名。
  9. 用到其他 PR 的定义都对照了最新 head(docs(design): target contracts for the branch turn chain #2102 ModelProvider、docs(storage): define the session storage owners' target contracts #2091 SessionStore、design(settings): owner contracts for Settings and the settings sections #2094 ProviderSettings/ModelLog)。

绑定附录编译:更新后的六份附录在临时 crate(workspace crates + rutis 0.23)cargo check 通过,含 ModelFailure/FailureChain 返回值与 admit_all;未提交。

left for step 2

@yyhhyyyyyy 请复核。

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

PR #2096 at 7cc7e87: review

Refs #2019 and #2015. This PR defines the target contracts for the model and provider owners: Provider, ConfiguredModels, the account owners, and the service-face, resource-face, owner-operation, management and auxiliary-model clauses that name their old surfaces. This round reviews the full main...head, not only 13f9b94...7cc7e87.

Verdict: REQUEST_CHANGES

Round status

Fixed in 7cc7e87, so the round-2 opinions are withdrawn: the second invoke contract (4675557419; process-owner-operations.md:26, :55-59 now match Provider's Mode, direct consume/admit, Retrying and provider_failed), the DimOAuth example (4675557417; DimOAuth.md:41-54 uses the NotifyFn callback), the old selectable reads in the consumer pages (the Modality and ImageUnderstanding thread; Modality.md:297, :465 and ImageUnderstanding.md:147 now use selectable), the prepare_startup reply shape (4675557445; four places now say bare ModelSelection), admit_all (4675557450; defined at Provider.md:347-350), the missing Supersedes section (4675557456; Provider.md:420-429), the auxiliary call's None for admit (4675557423; auxiliary-model.md:76), and the #2094 merge order (now in the PR body, and #2094 no longer changes provider-management line 6).

Partially fixed: the invoke failure facts (4675557438). The facts now return, but the separate FailureChain overreaches the terminal fact (P2 #1). I withdraw the round-2 part that asked for a separate chain; the facts alone are the right shape.

Still open from round 2, optional now: plugins/README.md:14-16 still says "request leases" and "leases" (P3 #6), and the dependency-error mapping is unchanged (Provider.md:141, :163, :171-179; ManagedAccount.md:106-109; P3 #11). The two round-2 hypotheses are still unverified.

P2

1. The returned FailureChain has no destination and duplicates ModelFailure

Problem: invoke returns {accepted, chain?} and provider_failed {failure, chain} (Provider.md:159, :165, :179, :354, :392), and both this document and process-owner-operations.md:59 say ModelProvider writes "both" into step/model-output-end. The terminal fact has no chain field: ModelOutputOutcome::Failed carries error, budget, presentation and failure: Option<Box<ModelFailure>> (crates/dim-agent-types/src/events.rs:818-848), and Completed carries only finish_reason. ModelFailure already carries attempts and waited_ms (events.rs:801-804), which the recovery loop fills from the incoming chain plus its own attempts (crates/dim-agent-capabilities/src/model_provider/recovery.rs:82-83, :199-200). The Loop already builds the next FailureChain from those two fields (crates/dim-agent-capabilities/src/agent_loop.rs:1642-1646). A completed request cannot carry a valid chain either: FailureChain is the failed request a continuation continues and requires from_request_id (events.rs:323-331), and a successful request has no failed request id for it.

Failure scenario: a delivery following "writes both" either adds a chain field to the terminal event that neither this contract nor #2102 owns, or writes only the failure facts while the contract says both. #2102's ModelProvider contract says the terminal carries "the failure chain totals" (ModelProvider.md:13, :86), which the failure facts already hold. The extra chain has no consumer, and the totals then have two sources that can disagree.

Evidence: docs/design/plugins/Provider.md:159, :165, :179, :354, :392; docs/design/contracts/process-owner-operations.md:59; crates/dim-agent-types/src/events.rs:323-331, :768-848; crates/dim-agent-capabilities/src/host.rs:17-55; crates/dim-agent-capabilities/src/model_provider/recovery.rs:82-83, :199-200; crates/dim-agent-capabilities/src/agent_loop.rs:1639-1646; #2102 head docs/design/plugins/ModelProvider.md:13, :86.

Fix: Drop chain from InvokeReply and ProviderFailed, and state that failure.attempts and failure.waited_ms are the updated totals ModelProvider writes and the Loop uses to build the next chain. If a chain value is really required, define the terminal field in #2102's contract and name the change here.

2. ConfiguredModels still advertises provider_failed {retryable}

Problem: Provider's error is now provider_failed {failure, chain} (Provider.md:159, :179, :392), and ConfiguredModels says its error kinds are Provider's (ConfiguredModels.md:5, :51), but its Errors section still lists provider_failed {retryable} (ConfiguredModels.md:57). The binding in the same document returns the shared ProviderError (ConfiguredModels.md:107-118), so the text and the type disagree.

Failure scenario: an API-key profile implementation built from its own error list emits or expects {retryable} while the managed profile serializes {failure, chain}. A caller that branches on the error details works on one profile and fails on the other, and a shared providerService test cannot cover both.

Evidence: docs/design/plugins/ConfiguredModels.md:5, :57, :107-118; docs/design/plugins/Provider.md:159, :179, :392.

Fix: Replace {retryable} with {failure, chain}, or drop the explicit shape and point to Provider's error kinds.

Optional (P3)

  • docs/design/resource-faces.md:849 links ../plugins/ManagedAccount.md, which resolves to docs/plugins/ManagedAccount.md; the file is docs/design/plugins/ManagedAccount.md. Drop the ../.
  • docs/design/plugins/README.md:14-16 still says "request leases" and "leases"; ManagedAccount.md:96 says the caller never holds a lease. Round 2 asked for this; it is optional now.
  • docs/design/appserver/auxiliary-model.md:10, :44, :58 still describe the service in the present tense in sections 1, 1.1 and 2, while the status line and section 4 say it is superseded. Sections 5 to 11 are marked; these three are not.
  • docs/design/plugins/Provider.md:423 cites a modelHost paragraph in process-owner-operations.md that is now only the line 3 name list, and :427 puts Modality section 9.4 in the Supersedes list; section 9.4 is the remaining modalityTargets read and has no connection resolution. Tighten the list so the delivery does not delete section 9.4.
  • docs/design/plugins/Provider.md:179 allows a retry when failure.retry_forbidden is false, while line 165 says accepted output prevents replay. Add "and no output was accepted", or carry that fact in the failure.

Checks

  • Full main...head read (16 files). Delta 13f9b94...7cc7e87 checked against the nine round-2 threads; it changes Provider's invoke reply and error, its binding, process-owner's row and table, auxiliary-model's admit_all, DimOAuth's example, Modality's read and options, ImageUnderstanding's read, provider-management section 3.7, and adds Provider's Supersedes section.
  • node scripts/adr-check.mjs --base 1bc7d67d passes (16 changed files, no ADR edits).
  • git merge-tree --write-tree origin/main HEAD is clean against current main c819cfd (#2130 merged).
  • Link and anchor scan of the 16 changed files: one broken relative link (resource-faces.md:849); every other local file and anchor resolves.
  • Cross-PR: #2091's creationRecord({id}) -> {origin, leader?} still matches Provider.md:141. #2102's terminal fact description supports P2 #1. #2094 is in the stated merge order and its current head does not change provider-management line 6; its line 53 row and this PR's row are compatible, but this PR must rebase after #2094 lands. #2080, #2092, #2093 and #2098 to #2103 still share service-faces.md and plugins/README.md; the stated order keeps this PR before "the rest".
  • CI for 7cc7e87: ci-ok success, verify (linux) success, macos-native success, changes success; windows, acp-registry, web, dependencies, scripts and static-checks skipped. The combined status endpoint reports pending with no status contexts.

Unverified

  • Whether Provider's selectable should answer default for a modality use. Modality owns its operation defaults, but Modality.md:175 uses Provider's global default for automatic resolution, so the field may be intentional; the contract still does not say.
  • Whether ManagedAccount.md:11's "revision and lease" is the account's own claim field; unchanged from round 2.
  • Whether #2102 will add a chain field to step/model-output-end; its current head does not.


`prepare_startup` admits the source under the calling row; the row's unload releases it, so a missed `retain_startup` or `release_startup` settles with the row. `retain_startup({session, model})` moves the source to the Session named by the caller and the model's metadata; the Session's close releases it, so a missed failure-path release settles with the Session. `release_startup({model})` is the optional early release for a creation that failed; it answers `not_found` once a Session retains the source. A member Session that inherits the leader's model retains the same source by value. A connection never crosses. `Selection` is the adopted provider, model, configuration, capability snapshot and metadata. `Credential` is [ManagedAccount](ManagedAccount.md)'s value: static credentials carry no generation; an account owner's carry the grant's. `invoke` calls the account owner's `credential`, sends, and on a refusal calls `rejected` with the refused generation before retrying within its own failure chain.

`invoke`'s `mode` is `Dialogue { chain? }` or `Once`. `Dialogue` continues the failure chain when given one and reports retry waits as `Retrying` chunks; `Once` makes exactly one request with no retry and no model substitution, which is what a caller sending one paid request needs (Report's model generation). `consume(chunk)` reports `Continue`, `End`, `CredentialRejected` (the provider refused the credential, so `invoke` calls the account owner's `rejected` once and retries) or `Failed { retryable }`; output accepted before a failure prevents replay, and the reply's `accepted` says whether any output was accepted. `admit` runs before each attempt and answers `Admitted` or `Rejected { message }`; a caller without its own budget passes the exported `admit_all`. Both callbacks are direct parameters, so the request data stays serde-only. A request for `openai-chatgpt` requires a client-origin Session: Provider reads the Session's creation record (`creationRecord`) and answers `invalid` for a non-client Session. A failed request returns `provider_failed` with the `ModelFailure` facts and the updated `FailureChain`; a completed request returns the updated chain in the reply, so ModelProvider writes both into `step/model-output-end`.

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.

Problem: invoke returns a FailureChain in the reply and in provider_failed, and this line says ModelProvider writes both it and the ModelFailure facts into step/model-output-end. The terminal fact has no chain field: ModelOutputOutcome::Failed carries error, budget, presentation and failure: Option<Box<ModelFailure>> (crates/dim-agent-types/src/events.rs:818-848), and Completed carries only finish_reason. ModelFailure already carries attempts and waited_ms (events.rs:801-804), the recovery loop fills them from the incoming chain plus its own attempts (crates/dim-agent-capabilities/src/model_provider/recovery.rs:82-83, :199-200), and the Loop builds the next FailureChain from them (crates/dim-agent-capabilities/src/agent_loop.rs:1642-1646). A completed request cannot carry a valid chain either: FailureChain names the failed request a continuation continues and requires from_request_id (events.rs:323-331).

Failure scenario: a delivery following "writes both" either adds a terminal chain field that neither this contract nor #2102 owns, or writes only the facts while this line says both. #2102 says the terminal carries "the failure chain totals" (ModelProvider.md:13, :86), which the facts already hold; the extra chain has no consumer.

Fix: Drop chain from InvokeReply and ProviderFailed, and state that failure.attempts and failure.waited_ms are the updated totals. If a chain value is really required, define the terminal field in #2102's contract in the same change.


### Errors

[Provider](Provider.md)'s kinds, minus `invalid_connection` and the startup-only ones: `invalid` for a malformed request, `not_found` for a target missing from the file, `unavailable` for a media operation or a missing environment variable, `cancelled`, `closed`, `failed` and `provider_failed {retryable}`; `credential` has `not_found`, `unavailable`, `cancelled`, `closed` and `failed`.

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.

Problem: Provider's error is provider_failed {failure, chain} now (Provider.md:159, :179, :392), and this document says its error kinds are Provider's (ConfiguredModels.md:5, :51), but this row still says provider_failed {retryable}. The binding below returns the shared ProviderError (ConfiguredModels.md:107-118), so the text and the type disagree.

Failure scenario: an API-key profile implementation built from this row emits or expects {retryable} while the managed profile serializes {failure, chain}; a caller that branches on the error details works on one profile and fails on the other.

Fix: Replace {retryable} with {failure, chain}, or drop the explicit shape and point to Provider's error kinds.

Comment thread docs/design/resource-faces.md Outdated
| Settings sources and their CAS writes | `readBytes`, `stat`, `lock`, `readBytes {leaseId}`, `replace {leaseId}`, `unlock` |
| MCP auth store, managed OAuth and OAuth token stores | `readBytes`, `lock`, `readBytes {leaseId}`, `backup`, `replace {leaseId}`, `unlock` |
| MCP auth store | `readBytes`, `lock`, `readBytes {leaseId}`, `backup`, `replace {leaseId}`, `unlock` |
| Managed OAuth and OAuth token stores | `read`, `update`, `write`; the account owner answers [ManagedAccount](../plugins/ManagedAccount.md) |

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.

../plugins/ManagedAccount.md resolves from docs/design/ to docs/plugins/ManagedAccount.md, which does not exist. Use plugins/ManagedAccount.md.

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 9ca30e0. resource-faces.md:849 now links plugins/ManagedAccount.md; the target exists at docs/design/plugins/ManagedAccount.md, and the 16-file relative-link scan reports no broken links.

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 05c751541。

跨 PR 对齐:

验证:node scripts/adr-check.mjs --base origin/main 通过;链接与锚点无新增断链。

@eric8810
eric8810 requested a review from yyhhyyyyyy November 24, 2026 06:14
@eric8810

Copy link
Copy Markdown
Collaborator Author

补充提交,head 9ca30e0f8:DimOAuth 的共享文件说明改为证据结论——写 auth.json 的只有 DimOAuth 与 App Server 的 managed OAuth(都是 Rust),没有 TypeScript 源写该文件;auth.json.lock 是 FileStorage 对该文件的 claim 协议,不是跨语言例外。

@eric8810

Copy link
Copy Markdown
Collaborator Author

补充说明(ADR 027 收回到决定层后):本 PR 的契约没有 ADR 027 D2、也没有 NoSession/SessionClosing/NoLine 的写法,ADR 027 引用均在 D1–D6 内,因此本轮无改动,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.

PR #2096 at 9ca30e0: review

Refs #2019 and #2015. This PR defines the target contracts for the model and provider owners: Provider, ConfiguredModels, the account owners (ManagedAccount, DimOAuth, ManagedOAuth, ManagedProviders), and the service-face, resource-face, owner-operation, management and auxiliary-model clauses that name their old surfaces. This round reads the full main...head, not only 7cc7e87...9ca30e0.

Verdict: REQUEST_CHANGES

Round status

Fixed in 9ca30e0, so the round-3 optional link finding is withdrawn: resource-faces.md:849 now links plugins/ManagedAccount.md, and docs/design/plugins/ManagedAccount.md exists. The 16-file relative-link scan reports no broken links or anchors.

The rest of the delta is accepted. Provider.md:53-54, :65-66 and :71 now use #2102's line_owner::<Prompt> and ConfigureRequest::Initial(ConfigureUpdate { sources: targets, model }), which matches #2102 head 3b48e12 and dim_agent_runtime::ConfigureUpdate (crates/dim-agent-runtime/src/contracts.rs:98-102). provider-management.md:53 now matches #2094 head 0677c71 except for the link target. The new DimOAuth.md:105 sentence is true for the tree: no TypeScript or JavaScript source references auth.json at origin/main, and #2080 FileStorage.md:217 says the TypeScript plugin no longer writes it. Its claim/release wording also matches #2080. What the sentence exposes is P2 #4.

Still open from round 3: P2 #1 (the FailureChain destination) and P2 #2 (ConfiguredModels' provider_failed {retryable}). The delta does not touch either.

P2

1. The returned FailureChain still has no destination and duplicates ModelFailure (round 3, still open)

Problem: invoke returns {accepted, chain?} and provider_failed {failure, chain} (Provider.md:161, :181, :356, :394), and this document and process-owner-operations.md:59 say ModelProvider writes "both" into step/model-output-end. The terminal fact has no chain field: ModelOutputOutcome::Failed carries error, budget, presentation and failure: Option<Box<ModelFailure>> (origin/main crates/dim-agent-types/src/events.rs:820-848), and Completed carries only finish_reason. ModelFailure already carries attempts and waited_ms (events.rs:801-804), which the recovery loop fills from the incoming chain plus its own attempts (crates/dim-agent-capabilities/src/model_provider/recovery.rs:81-83, :196-202). The Loop builds the next FailureChain from those two fields (crates/dim-agent-capabilities/src/agent_loop.rs:1642-1646). A completed request cannot carry a valid chain either: FailureChain is the failed request a continuation continues and requires from_request_id (events.rs:327-331), and a successful request has no failed request id for it.

Failure scenario: A delivery following "writes both" either adds a chain field to the terminal event that neither this contract nor #2102 owns, or writes only the failure facts while the contract says both. #2102's ModelProvider says the terminal carries "the failure chain totals" (ModelProvider.md:13, :86); the facts already hold those totals, so the extra chain has no consumer and the totals have two sources that can disagree.

Evidence: docs/design/plugins/Provider.md:161, :167, :181, :356, :394; docs/design/contracts/process-owner-operations.md:26, :59; origin/main crates/dim-agent-types/src/events.rs:327-331, :801-804, :820-848; crates/dim-agent-capabilities/src/model_provider/recovery.rs:81-83, :196-202; crates/dim-agent-capabilities/src/agent_loop.rs:1642-1646; #2102 head docs/design/plugins/ModelProvider.md:13, :62, :86.

Fix: Drop chain from InvokeReply and ProviderFailed, and state that failure.attempts and failure.waited_ms are the updated totals ModelProvider writes and the Loop uses to build the next chain. If a chain value is really required, define the terminal field in #2102's contract in the same change.

2. ConfiguredModels still advertises provider_failed {retryable} (round 3, still open)

Problem: Provider's error is provider_failed {failure, chain} (Provider.md:161, :181, :394), and ConfiguredModels says its error kinds are Provider's (ConfiguredModels.md:5, :51), but its Errors section still lists provider_failed {retryable} (ConfiguredModels.md:57). The binding in the same document returns the shared ProviderError (ConfiguredModels.md:107-118), so the text and the type disagree.

Failure scenario: An API-key profile implementation built from its own error list emits or expects {retryable} while the managed profile serializes {failure, chain}. A caller that branches on the error details works on one profile and fails on the other, and a shared providerService test cannot cover both.

Evidence: docs/design/plugins/ConfiguredModels.md:5, :57, :107-118; docs/design/plugins/Provider.md:161, :181, :394.

Fix: Use Provider's exact shape after P2 #1, or drop the explicit shape and point to Provider's error kinds.

3. Main's #2004 image routing contradicts the retained ImageUnderstanding text (new)

Problem: origin/main's ImageUnderstanding contract, changed by #2004 (merged as bf3a4e6), says a vision-capable conversational model, or a request whose model capability is unknown, receives image pixels, and only other models receive img: references (origin/main docs/design/plugins/ImageUnderstanding.md:12-19, :120-125). This head still says the conversational model never receives pixels (ImageUnderstanding.md:15), that a model accepting image input receives references too and sending pixels is "the defect this design removes" (:115-119), and states M2 as "the reference in place of pixels" (:152-158). git merge-tree --write-tree origin/main HEAD already conflicts in this file.

Failure scenario: A rebase that keeps this side makes the page state the opposite of Attachments A.1 and #2102's ModelProvider ("Provider::invoke adapts image references to the model's capability", ModelProvider.md:62). A delivery then routes every conversational image to a reference and the image_understand auxiliary call, re-disabling the vision path #2004 merged, and the page also contradicts the standalone failure main added for a target that does not take the image's format (origin/main ImageUnderstanding.md:127-135; auxiliary-model.md:184).

Evidence: origin/main docs/design/plugins/ImageUnderstanding.md:12-19, :120-135; this head docs/design/plugins/ImageUnderstanding.md:12-16, :115-119, :152-158; docs/design/plugins/ImageUnderstanding.md:147; #2102 head docs/design/plugins/ModelProvider.md:62; git merge-tree --write-tree origin/main HEAD conflict.

Fix: Rebase on origin/main and take its routing paragraphs at :12-19, :115-135 and the M2 text, changing only the execution host from auxiliaryModel to providerService.invoke. Keep the standalone format-failure outcome, and state which Provider error it maps to if invoke is now the executor.

4. The account owners' FileStorage requirements omit the claim/release their rotating refresh requires (new)

Problem: DimOAuth.md:105 now names the App Server's managed OAuth flow as a second writer of auth.json, and DimOAuth asks FileStorage for claim/release for the marker (DimOAuth.md:134). The other writers do not: ManagedOAuth.md:11 and :95 ask only for read and update, and :53 says its account record keeps its existing file, auth.json; ManagedAccount.md:157 asks read, update and write, and ManagedProviders.md:13 promises "one serialized refresh" while :102 asks only read, update and write. #2080 at 5351ea7 requires the Managed OAuth flow to claim the marker, refresh outside the file key, write with update(claim_id) and release (FileStorage.md:37, :146, :148, :181), and says every writer of auth.json holds the marker (:14, :217).

Failure scenario: A delivery of ManagedOAuth follows its requirement and uses update for the rotating refresh. #2080 forbids network I/O inside change (FileStorage.md:179), so the implementation either holds the file key across the HTTP refresh, blocking every other auth.json writer, or refreshes outside the key without a claim. Two processes then refresh the same rotating grant; the provider rotates one token and invalidates the other, and one process persists a dead grant or the user is signed out. The same gap exists for the ChatGPT account: its record is chatgpt-account.json (crates/dim-app-server/src/managed_provider/chatgpt.rs:203), it refreshes under a lease today (:742-794), and #2080's claim covers only auth.json, so its contract needs a decision rather than only read/update/write.

Evidence: docs/design/plugins/DimOAuth.md:105, :134; docs/design/plugins/ManagedOAuth.md:11, :53, :95; docs/design/plugins/ManagedAccount.md:157; docs/design/plugins/ManagedProviders.md:13, :102; #2080 head docs/design/plugins/FileStorage.md:14, :37, :146, :148, :181, :217; origin/main crates/dim-app-server/src/managed_oauth.rs:420, :1042-1094; crates/dim-app-server/src/managed_provider/chatgpt.rs:203, :742-794.

Fix: Add claim/release to ManagedOAuth.md's and ManagedAccount.md's FileStorage requirements and state that the rotating refresh runs under the claim as #2080's Managed OAuth flow does. Decide the ChatGPT account record's exclusion in #2080 or here: a published marker for chatgpt-account.json, or an explicit process-local rule. The #2080 writer list at :217 already names both Rust writers and the TypeScript plugin.

Optional (P3)

  • The six new owner docs cite "Design rules §7" as PR #2029, which merged as 4d081fe. Point at docs/architecture/rust-agent/principles.md §7 and, for the line-owner route, ADR 027. The forward dependency links have the same shape: provider-management.md:53 links #2094 and Provider.md:71 links #2102; after those land, use ../plugins/ProviderSettings.md and PromptAdoption.md.
  • docs/design/plugins/README.md:14-16 still says "request leases" and "leases", while ManagedAccount.md:96 says the caller never holds a lease.
  • docs/design/appserver/auxiliary-model.md:10, :44 and :58 still describe the service in the present tense while the status and section 4 say it is superseded.
  • docs/design/plugins/Provider.md:425 supersedes a modelHost paragraph that no longer exists in process-owner-operations.md, and :429 lists Modality §9.4, which is the retained modalityTargets read and has no connection resolution.
  • docs/design/plugins/Provider.md:181 allows a retry when failure.retry_forbidden is false, while :167 says accepted output prevents replay. Add "and no output was accepted", or carry that fact in the failure.
  • docs/design/plugins/ManagedAccount.md:11 still says the account record is written "with the account's own revision and lease"; #2080 FileStorage.md:144 says the public face has no lease. Use "claim" if that is the account marker.
  • docs/design/plugins/DimOAuth.md:105 names the current implementation files in a contract and says "the writers are" even though the migration import also writes auth.json (crates/dim-migration/src/accounts.rs:13, :184). Cite #2080's account-marker exception and say "the ongoing writers".

Checks

  • Full main...head read (16 files); the delta checked against the round-3 threads.
  • node scripts/adr-check.mjs --base 1bc7d67d passes (16 changed files, no ADR edits).
  • Relative-link and anchor scan of the 16 changed files: no broken links.
  • git merge-tree --write-tree origin/main HEAD is clean except for one content conflict in docs/design/plugins/ImageUnderstanding.md against origin/main bf3a4e6.
  • CI for 9ca30e0: ci-ok, verify (linux) and macos-native success; windows, acp-registry, web, dependencies, scripts and static-checks skipped. The combined status endpoint reports pending with no contexts.
  • Cross-PR: #2080 at 5351ea7 still defines claim/release and the Managed OAuth flow. #2091 at 8f9f5e1 keeps creationRecord({id}) -> {origin, leader?} (the PR body's f7425d5 is stale). #2094 at 0677c71 matches the new settings row. #2102 at 3b48e12 matches the Prompt call and the terminal-fact text. #2099 at 8f440bd uses account.title(TitleRequest { provider, text }) (the PR body's 3501002 is stale).

Unverified

  • Whether #2102's ConfigureRequest::Initial is valid on an already-open line for a model change; the target text calls it the initial targets and model. If it is open-only, Provider's second example needs the model-change variant #2102 will define.
  • Whether Provider's selectable default for a modality use is intended (unchanged hypothesis from round 2).
  • Whether ManagedAccount.md:11's "lease" is the account's claim field (unchanged hypothesis).
  • Whether #2080 will extend the account marker to chatgpt-account.json; if not, P2 #4's fix needs a decision in #2080.

([Modality](Modality.md) A.1), resolved by its owner and executed through the existing
`auxiliaryModel` host. The conversational model never receives image pixels, and the image's
([Modality](Modality.md) A.1), resolved by its owner and executed through
`providerService.invoke`. The conversational model never receives image pixels, and the image's

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.

Problem: This retained claim contradicts origin/main. #2004 (merged as bf3a4e6) changed the routing: a vision-capable model, or one whose capability is unknown, receives pixels; only a model that cannot take images receives img: references (origin/main ImageUnderstanding.md:12-19, :120-125). This line and :115-119, :152-158 still say the opposite, and git merge-tree --write-tree origin/main HEAD already conflicts here.

Failure scenario: A rebase that keeps this side makes the contract state the opposite of Attachments A.1 and #2102's ModelProvider ("Provider::invoke adapts image references to the model's capability", ModelProvider.md:62). A delivery routes every conversational image to a reference and the auxiliary call, re-disabling the vision path #2004 merged, and the page contradicts the standalone format failure main added (origin/main ImageUnderstanding.md:127-135).

Fix: Rebase on main and take its routing paragraphs at :12-19, :115-135 and the M2 text, changing only the execution host from auxiliaryModel to providerService.invoke.

## Exceptions with reasons

- The bearer's boundary is [ManagedAccount](ManagedAccount.md#the-bearers-boundary); DimOAuth's replies and errors omit it.
- The account file is guarded by the published `auth.json.lock` marker protocol. The writers are this owner and the App Server's managed OAuth flow, both Rust (`crates/dim-oauth/src/store.rs`, `crates/dim-app-server/src/managed_oauth.rs`); no TypeScript source writes `auth.json`. The marker is FileStorage's claim protocol for this file ([#2080](https://github.com/arcships/dim/pull/2080)), not a cross-language exception.

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.

Problem: The sentence is consistent with #2080 on the TypeScript point, but it names a second writer whose contract asks for no claim/release. DimOAuth.md:134 asks for claim/release; ManagedOAuth.md:11 and :95 ask only for read and update, and :53 says the record keeps its existing file auth.json; ManagedAccount.md:157 asks read/update/write, and ManagedProviders.md:13, :102 promises one serialized refresh with the same read/update/write requirement. #2080 at 5351ea7 requires the Managed OAuth refresh to claim the marker, refresh outside the file key, update with claim_id and release (FileStorage.md:37, :146, :148, :181), and says every writer holds the marker (:14, :217).

Failure scenario: A delivery of ManagedOAuth follows this requirement and uses update for the rotating refresh. #2080 forbids network I/O in change, so it either holds the file key across the HTTP wait, blocking every other auth.json writer, or refreshes without a claim; two processes rotate the same grant, one token is invalidated, and the user is signed out. The ChatGPT account has the same gap: its record is chatgpt-account.json (crates/dim-app-server/src/managed_provider/chatgpt.rs:203), it refreshes under a lease today (:742-794), and #2080's claim covers only auth.json.

Fix: Add claim/release to ManagedOAuth.md and ManagedAccount.md's FileStorage requirements, state that the refresh runs under the claim as #2080's Managed OAuth flow does, and decide the ChatGPT account record's exclusion in #2080 or here. The #2080 writer list at :217 already names both Rust writers and the TypeScript plugin.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Closing as part of abandoning the owner-split experiment.

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

2 participants