Skip to content

fix(modality): serve Dim account image models and keep the snapshot consistent - #1916

Merged
zerob13 merged 9 commits into
mainfrom
zerob13/1887-modality-image-adapters
Nov 23, 2026
Merged

zerob13 merged 9 commits into
mainfrom
zerob13/1887-modality-image-adapters

Conversation

@zerob13

@zerob13 zerob13 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1887.

1. An adapter row for the Dim account relay. dim-modality-aimux binds dimcode-api-oauth to aimux's openai package. The relay's /v1 base speaks the OpenAI Image API (JSON /images/generations, multipart /images/edits) with the account's bearer, so arcship-image runs image.generate and image.edit. Credentials come from the existing managed lease; the adapter adds no credential handling.

2. A consistent modality.capabilities snapshot. Every declared model is listed as an option, but is available only when an available adapter serves the operation for it. Otherwise it carries a reason:

  • runtime when an adapter serves that model and operation and is currently unavailable;
  • build for a category this build has no adapter for;
  • adapter otherwise.

An adapter-backed task operation is available when it has an available option. When all of its options are unavailable, a runtime reason is scoped to that operation's candidates.

default and effective follow the options: effective resolves over available options only. configure accepts any declared option, served or not, so a default can still be saved before a runtime lands (Modality §3.4, "configurable and available are different properties"). Host OCR targets keep requiring a runnable target. Before this change, the options and default reported available: true while the operation reported unavailable.

3. Image-model recognition at the Provider boundary. Relay and account catalogs list image models without modalityCapabilities. Recognition follows the previous product's model-detection.ts:

  • An explicit list wins, an empty one included. imageGeneration: false recognizes nothing.
  • Known ids are recognized: arcship-image, specific IDs in the gpt-image-2 and grok-imagine-image families, and IDs with a seedream component.
  • An image kind or image-only output declares image.generate, and also image.edit when the model reads images.

Contract: provider management §3.6.

Not in this PR: openai-codex image generation. The aimux codex package answers NoSuchModel for image models, and the ChatGPT-subscription image transport belongs in aimux. Until aimux adds it, those models stay listed with the adapter reason. A follow-up adds the vendor row once aimux supports it.

Image timeout and retries. The Dim account relay sends each image request once. A slow response can still exceed aimux's 30 s exchange timeout after the relay has accepted the request. Direct OpenAI uses aimux's default retry policy. aimux #527 tracks the underlying timeout and retry behavior.

Design rule checklist

  • Scope: no new part. The changes stay in the Modality process plugin, the built-in adapter's row table, and Provider's catalog read.
  • Commands and results: n/a, no new commands or events.
  • Handover: n/a.
  • Timeline before callbacks: n/a, none touched.
  • Infrastructure unchanged.
  • Core mechanisms gain no plugin-specific handling. Provider-specific bindings stay in the adapter's row table.
  • Batch: n/a.
  • Context: n/a, Modality writes no Timeline events.
  • No reading another plugin's internal state. Modality reads Provider through selectableForModality and adapters through modalityAdapter, as before.
  • Cross-language faces: no new service. selectableForModality keeps its shape; only which entries declare operations changes.
  • Business configuration stays in the modality settings source.
  • Missing mechanism capability: The Codex image transport and image exchange timeout are tracked in aimux #526 and aimux #527.
  • Timeline holds nothing new.

Documentation

  • No ADR modified.
  • Updated each owner's own document: Modality §3.4 and A.2, and the snapshot bullets for default, effective, options and configurability. Provider management §3.6 now owns the declaration and recognition rule. Chinese translations updated.
  • No delivery status added.

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --locked -p dim-modality -p dim-modality-aimux -p dim-image-understanding
  • cargo test --locked -p dim-app-server --test provider_flow --test model_catalog_flow --test managed_oauth_flow --test transport_flow
  • cargo test --locked -p dimcode --test cli_flow modality
  • node scripts/adr-check.mjs --base origin/main

New or changed flow assertions:

  • the relay's exact URLs and bearer for generate and edit;
  • one relay POST when the scripted transport accepts the request and stalls through the exchange timeout;
  • operation, option and default reasons when the image adapter is offline or does not serve the requested image operation;
  • recognized and explicitly-empty entries in selectableForModality;
  • the Modality: Dim account image models are listed as available options but image.generate is unavailable #1887 scenario, with options, default and effective agreeing with an unavailable operation;
  • a saved unserved default failing submit with default_unavailable.

…onsistent

The Dim account relay (dimcode-api-oauth) had no adapter row, so its
image models were listed as available options while image.generate
reported "The adapter serves no image model Provider lists". Two fixes:

- dim-modality-aimux binds dimcode-api-oauth to the aimux openai
  package: the relay's /v1 base speaks the OpenAI Image API with the
  account's bearer, so arcship-image runs image.generate and image.edit.
- Modality lists every declared model as an option and marks it
  available only when an available adapter serves the operation for it;
  otherwise the option carries its runtime, build or adapter reason.
  default and effective follow, so a client never sees a selectable
  model the operation refuses. configure accepts any declared option,
  served or not, so a default can be saved before a runtime lands; host
  targets still require a runnable target.

Provider recognizes image models whose listing carries no
modalityCapabilities, as the previous product did: an explicit list
(empty included) wins; otherwise known image ids (arcship-image, the
gpt-image-2 and grok-imagine-image families, seedream), an image kind
or image-only output declares image.generate, plus image.edit when the
model reads images; imageGeneration: false recognizes nothing.

openai-codex image models stay unserved with the adapter reason: the
aimux codex package answers NoSuchModel for image models, and their
transport belongs in aimux.

Fixes #1887
@zerob13

zerob13 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

aimux 侧的两项已提出:

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 新开的 Dim 账号中转会自动重发结果未知的付费图片请求。 我核了锁定的 aimux 0.6.1:dim-modality-aimux/src/job.rs:51–92 未设置 ImageCallOptions.max_retries,随后 lib.rs:245–257 走 generate_image,默认重试两次;aimux 会把 30 秒未读完整响应标成可重试。中转可能已收到请求并在生成,只是还没返完,用户点一次就可能发送三次 POST。感谢已经在 aimux #527 跟进;建议在开放这条中转前,至少在 Dim 中对此路径禁用这类自动重试,或等有经过验证的幂等/超时策略再启用。请用脚本 transport 模拟已经收到 POST、但响应超时,断言只发送一次,不需要打真实的付费接口。

快照还有一处不一致。 dim-modality/src/lib.rs:764–788,867–886 给离线模型的 option/default 标 runtime,但 operation 用跨类别的 adapter_available()。当唯一声明 image.generate 的 adapter 离线而另一家的语音 adapter 在线时,operation 却标 configuration。建议从该 operation 自己的候选项得出原因,并覆盖这个混合在线/离线场景。

验证方式:静态核对 Dim 调用链及锁定版本的 aimux 源码;未调用真实中转,也未本地运行 Rust 测试。

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review at 9f9b73fc (origin/main 31d100f4).

The PR adds a dimcode-api-oauth vendor row for the OpenAI Image API, recognizes relay and account image models at the Provider boundary, and changes modality.capabilities so every declared model is listed with a reason while effective resolves over available options only. The head merges origin/main into the feature branch. Among this PR's files, the merge adds main's Provider changes in crates/dim-app-server/src/provider.rs and unrelated English and Chinese provider-management doc edits; the feature's recognition block, adapter row and snapshot code are unchanged. The diff is still 11 files, +424/-159.

Verdict: REQUEST_CHANGES. I agree with eric8810 on both P2s; the evidence below is independently verified at this head.

P2: the new relay can re-send a paid image request whose result is unknown

Problem. image_options builds ImageCallOptions without setting max_retries, so generate_image uses aimux's default two retries. The new dimcode-api-oauth row routes arcship-image and the other relay image models into that path.

Failure scenario. A user submits one image generation to the Dim account relay. The relay receives the POST and starts generating, but the response takes longer than 30 seconds or the connection stalls after the request was accepted. aimux turns the 30-second exchange timeout into a retryable ApiCall and sends the whole generation again, twice. One click can produce up to three paid generations, and Dim never learns that the earlier requests succeeded.

Evidence. crates/dim-modality-aimux/src/job.rs:51-92 builds ImageCallOptions without max_retries; crates/dim-modality-aimux/src/lib.rs:255-257 calls aimux_core::image_model::generate_image. The locked aimux-core 0.6.1 (Cargo.lock:76-78) src/image_model.rs:269-281 passes options.max_retries to retry::prepare_retries; src/retry.rs:12,41 sets the default to 2 retries and :87 retries retryable ApiCall errors. The locked aimux-provider-utils 0.6.1 (Cargo.lock:103-105) src/post_to_api.rs:82 sets a 30-second exchange timeout, and :128-141 marks that timeout is_retryable: true. The new row is crates/dim-modality-aimux/src/vendor.rs:372-379. The PR body already lists this as a known risk.

Fix. Before exposing the relay, set options.max_retries = Some(0) for this path, or wait for an aimux idempotency or timeout policy that does not re-send a request whose result is unknown. Add a scripted transport test that accepts the POST and then times out the response, and assert that exactly one request is sent. The test should not call the real relay.

P2: the operation reason still comes from category-wide adapter state

Problem. unserved_reason gives an option and a persisted default a reason based on that model's own adapter. The operation-level availability still takes a category-wide view: adapter_serves(category) returns true when any candidate's adapter claims the category, without checking whether that adapter is available, and adapter_available() returns true when any candidate's adapter is available in any category. When those answers differ from the operation's options, the operation and its option or default describe the same failure differently.

Failure scenario. Two reachable cases. First, the only adapter that serves image.generate is offline while a speech adapter on another provider is online. The image option and persisted default say runtime ("The adapter is unavailable"), but image.generate says configuration ("No selectable model is served by an available adapter"), which sends the user to fix model selection instead of the adapter. Second, an image adapter serves image.generate but not image.edit; the edit option, and any configured default, say adapter, while image.edit says configuration. The category-wide shortcut also makes image.enhance report configuration when an image adapter serves other image operations but no enhance option exists, while docs/design/plugins/Modality.md:167 says it reports adapter.

Evidence. crates/dim-modality/src/lib.rs:782-792 returns runtime for a model whose adapter is unavailable and adapter otherwise. :636-640 makes adapter_available() true if any candidate in any category has an available adapter. :650-659 makes adapter_serves(category) true from any candidate's operations without checking available(). :867-889 uses those two helpers for the operation's available and reasons. The new comment at crates/dim-modality/src/lib.rs:741-748 says an unavailable option and the operation never disagree, and docs/design/plugins/Modality.md:461-463 says the option's available agrees with a submission and the default reason is runtime when the model's adapter is unavailable. The current operation output contradicts both. The existing test crates/dim-modality/tests/modality_flow.rs:1493-1503 covers all adapters offline, not the mixed case.

Fix. Derive the operation's availability and reasons from the operation's own candidates, for example by collecting the per-option reasons and using operation-specific adapter presence. Do not use a category-wide adapter_available() result. Add a test with an online adapter for one category and an offline adapter for the image operation, and a test where image.generate is served but image.edit is not.

Optional P3: the known-model list is exact while the docs describe families

KNOWN_IMAGE_MODELS at crates/dim-app-server/src/provider.rs:763-773 lists exact ids, while docs/design/appserver/provider-management.md:1033-1034 describes the gpt-image-2 and grok-imagine-image families. A relay that lists a bare id such as gpt-image-2.6-flare without type or modalities is omitted from selectableForModality, so the model never appears in Modality. Consider prefix or family matching, or add a test for a new bare family member. This is not blocking.

Verification

  • git diff --check origin/main...HEAD: clean.
  • git merge-tree --write-tree HEAD origin/main: clean (60192d97).
  • Among the PR files, the merge changes only main's Provider code in crates/dim-app-server/src/provider.rs and main's unrelated English and Chinese provider-management doc edits. The recognition block, dim-modality/src/lib.rs, and the new vendor row are unchanged from 4eff4ce6; no conflict markers remain.
  • cargo fmt --all -- --check: passed.
  • node scripts/adr-check.mjs --base origin/main: passed (11 changed files).
  • CI at 9f9b73fc: changes and dependencies pass; verify is pending; web, windows-cli and acp-registry skip.
  • I did not run Rust tests at this head. The worktree has no build target. I did not call the real relay or any paid endpoint.
  • The existing review 5987858503 remains at 4eff4ce6 and is body-only; there are no existing inline threads.

Verdict: REQUEST_CHANGES, for the retry risk and the remaining snapshot reason mismatch.

// account's bearer. The relay names the model, so a model the package
// does not know keeps edit.
Vendor {
catalog: "dimcode-api-oauth",

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 row makes the Dim account relay reach the image call path, but image_options (crates/dim-modality-aimux/src/job.rs:51-92) leaves ImageCallOptions.max_retries at its default. The locked aimux-core 0.6.1 (src/image_model.rs:269-281, src/retry.rs:12,41,87) retries twice, and the locked aimux-provider-utils 0.6.1 (src/post_to_api.rs:82,128-141) marks the 30-second exchange timeout retryable. A POST the relay received but did not finish within 30 seconds is sent again, so one click can bill up to three generations. Set options.max_retries = Some(0) for this path, or wait for an aimux idempotency or timeout policy; add a scripted transport test that receives the POST and times out, asserting one send.

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 f6cf5ca. crates/dim-modality-aimux/src/job.rs:54-56 sets max_retries = Some(0) for the dimcode-api-oauth catalog, and the_dim_account_relay_does_not_retry_a_timed_out_post (crates/dim-modality-aimux/tests/adapter.rs:630-659) accepts one POST, stalls the response through the exchange timeout, and asserts exactly one request. The test passes locally at ac2c7f6.

Comment thread crates/dim-modality/src/lib.rs Outdated
}
/// Why no adapter runs a declared model's operation, in the operation's
/// own vocabulary.
fn unserved_reason(&self, model: &ModelId, category: &str) -> Reason {

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 per-option reason still disagrees with operation() at crates/dim-modality/src/lib.rs:867-889, which uses adapter_serves(category) and adapter_available(). adapter_available() scans every candidate in every category (:636-640), and adapter_serves() ignores adapter availability (:650-659). With the image adapter offline and a voice adapter online, this option and its default say runtime while the operation says configuration; with image.generate served but image.edit not, the edit option says adapter while the operation says configuration. Derive the operation's reason from its own candidates and cover both mixed cases.

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 f6cf5ca. Option and operation reasons now use one per-operation check: Evaluation::operation_spec (crates/dim-modality/src/lib.rs:680-703), candidates_for (:745-776) and the operation's runtime lookup (:870-884). an_online_speech_adapter_does_not_hide_the_offline_image_adapter covers the mixed online speech and offline image case, and the generate-only fixture asserts the edit and enhance operations report adapter. Both pass locally at ac2c7f6.

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at head 9f9b73f.

The snapshot change is the right correction and it is stated in the terms the Modality design uses: every declared model stays listed as an option, and available is true only when an available adapter actually serves the operation for that model; otherwise the option carries which kind of reason stopped it — runtime when the adapter is unavailable, build when this build has no adapter for the category, adapter otherwise. effective resolving over available options only, while configure still accepts any declared option, is the split that lets a default be saved before its runtime lands without the runtime pretending the option works. Treating a host target this platform cannot run as absent rather than as an unavailable option is the same distinction applied at the other end.

An adapter row for the relay, binding dimcode-api-oauth to aimux's openai package and taking credentials from the existing managed lease rather than adding credential handling, is placement where the design puts it.

verify and ci-ok failed on this head, at the architecture and boundary check rather than in a test:

Check crate boundaries and plugin pages
module source boundaries passed (743 modules, 4556 edges)
Error: "generated architecture files are stale:
  docs/architecture/rust-agent/generated/modules.json,
  docs/architecture/rust-agent/generated/modules.mmd; run `cargo run -p xtask -- graph`"

The graph moved because the change touches crate dependencies (dim-modality-aimux, dim-app-server), and the generated snapshots were not regenerated. AGENTS is explicit that graph writes those files and check only fails on them; regenerate and commit modules.json / modules.mmd — and check catalog.md and npm/branch-services.d.ts while you are there, since the check validates those in the same pass. Nothing here reads as a product defect; the workspace tests had not run yet when the job stopped.

Not approving while a required check is red.

@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] Do not resend a relay image request whose outcome is unknown

When the Dim account relay accepts an image generation request but does not finish returning its response within 30 seconds, the new row at crates/dim-modality-aimux/src/vendor.rs:372–379 routes it through a client that can send the POST again. One user action can start multiple generations; duplicate charges are possible, not observed.

Evidence: Static inspection: crates/dim-modality-aimux/src/job.rs:51–92 leaves max_retries unset. The locked aimux 0.6.1 client treats a whole-exchange timeout as retryable (aimux-provider-utils/src/post_to_api.rs:76–94,128–141) and retries the image call up to twice (aimux-core/src/image_model.rs:269–281, src/retry.rs:12,41,87). The retry behavior predates this PR; enabling it for the Dim account relay does not. No live relay call was made.

Requested change: Disable retries on this relay path unless repeat requests use a verified idempotency mechanism. Extend the scripted relay test to accept a POST, stall the response, and assert that it receives only one generation request.

[Blocking] Report the reason that applies to the selected operation

When an image adapter is offline but an unrelated speech adapter is online, crates/dim-modality/src/lib.rs:855–889 can report configuration for image generation while its declared option reports runtime. Submission returns the operation reason before resolving the model, so changing the saved model is presented as the remedy for an offline runtime.

Evidence: Static inspection: the new option/default logic at lib.rs:762–791,841–849 checks the model and operation together, but the operation still combines category-wide support with availability across all candidates (:636–659). crates/dim-modality/src/engine.rs:970–981 uses that operation reason. The generate-only fixture at crates/dim-modality/tests/modality_flow.rs:1448–1491 also checks the edit default’s adapter reason without checking the edit operation’s reason.

Requested change: Compute the operation reason using adapters that serve that operation. Assert both levels in the generate-only fixture and in a mixed-provider case with image offline and speech online.

[Blocking] Regenerate the two architecture graphs for this source tree

When CI checks the module graph, the checked-in docs/architecture/rust-agent/generated/modules.json and modules.mmd do not match this head. The boundary check fails before the compiled workspace tests run.

Evidence: CI: base verify passed this step; PR verify reports both files stale. Its checkout had the same tree as the reviewed head. Neither generated file is in the diff. Tests not run locally.

Requested change: Regenerate and commit both graph files, then rerun verify and ci-ok so the tests beyond the graph check can run.

Share the adapter operation check between option listing and task submission. Report runtime only when the adapter declares the specific operation, including when the same offline adapter serves another operation for the configured model.
@zerob13
zerob13 requested review from codoggy and eric8810 November 22, 2026 02:21

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed f6cf5ca6. The relay now disables automatic retry for both image operations, and the scripted accepted-but-stalled POST test is the right regression. Operation, option and default reasons now use the same operation-specific coverage and availability checks, including an unrelated online speech adapter.

[P2] The new scripted responder fails the required Clippy check. In crates/dim-modality-aimux/tests/adapter.rs:78, the new Arc<dyn Fn(&Recorded) -> Option<Reply> + Send + Sync> trips clippy::type_complexity under -D warnings. Exact Linux verification stops compiling modality_aimux_flow, before the new regression or the later architecture check can establish a pass. Factor the responder signature into a named type alias and keep the stalled-response fixture. macOS native and dependencies passed; ci-ok is red.

Store the responder closure directly in the scripted transport. The fetch function already owns the transport through an Arc.
@zerob13
zerob13 requested a review from eric8810 November 22, 2026 02:27

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review at ac2c7f62 (origin/main e4d981bd).

The PR adds a dimcode-api-oauth row to the built-in aimux adapter, recognizes relay and account image models at the Provider boundary, and makes modality.capabilities options, default and effective agree with adapter availability per option.

Verdict: REQUEST_CHANGES.

Prior findings

  • The relay retry P2 is fixed. crates/dim-modality-aimux/src/job.rs:54-56 sets max_retries = Some(0) for the dimcode-api-oauth catalog, and the_dim_account_relay_does_not_retry_a_timed_out_post (crates/dim-modality-aimux/tests/adapter.rs:630-659) accepts one POST, stalls the response through the exchange timeout, and asserts exactly one request.
  • The operation reason P2 is fixed. Each option's availability comes from Evaluation::operation_spec for that model and operation (crates/dim-modality/src/lib.rs:680-703), candidates_for fills it (:745-776), and the operation takes a runtime reason from its own candidates (:870-884). an_online_speech_adapter_does_not_hide_the_offline_image_adapter covers the mixed online speech and offline image case.
  • The Clippy type_complexity failure at crates/dim-modality-aimux/tests/adapter.rs:78 is fixed by the test-only head commit: Scripted<F> is generic over the responder, and the targeted Clippy run passes.
  • I retract the exact-ID P3 from the previous review. The PR body and provider management §3.6 make specific known IDs the intended rule, so exact matching is a decision, not a defect.

P2: the Modality configure contract still contradicts the new behavior

Problem. configure now persists any declared option, served or not: Evaluation::configurable returns true for a non-host option whether or not it is available (crates/dim-modality/src/lib.rs:780-786), and crates/dim-modality/tests/modality_flow.rs:1448-1460 asserts that saving the unserved beta edit default succeeds. The updated §3.4 paragraph and the snapshot bullets say this (docs/design/plugins/Modality.md:167,464), but earlier statements in the same document still say the opposite: docs/design/plugins/Modality.md:171 ("for an adapter operation, that an available adapter serves it") and :556 (modality_invalid_selection when "no available adapter serves the operation"). The Chinese translation repeats both (docs/zh/design/plugins/Modality.md:171,550). The automatic-resolution sentence at docs/design/plugins/Modality.md:173 also still says "the first selectable model that serves it in the order Provider's selectable-model read returns", while the code resolves over available options from the declared read (crates/dim-modality/src/lib.rs:922-947).

Failure scenario. A client implements the documented validation and refuses or hides a default save for a declared model whose adapter is offline. The daemon accepts that save and lists the option with available: false, so the Web settings page or CLI cannot expose "save a default before the runtime lands", which is the behavior this PR adds. A client implementing line 173 can pick a model that is not one of the operation's options.

Evidence. crates/dim-modality/src/lib.rs:780-786; crates/dim-modality/tests/modality_flow.rs:1448-1460; the document lines above.

Fix. Update docs/design/plugins/Modality.md:171,173,556 and docs/zh/design/plugins/Modality.md:171,173,550 to the rule the code and the updated snapshot bullets state: configure accepts any model in the operation's options, served or not; modality_invalid_selection means the model is not an option; automatic resolution uses available options in Provider's declared order.

Optional P3: the default reason list omits configuration

The updated default bullet (docs/design/plugins/Modality.md:461) enumerates provider, runtime, build and adapter, but a persisted default that is not an option of the row being read can still carry configuration from unavailable_reason (crates/dim-modality/src/lib.rs:828-831). A category-wide key makes this reachable with bundled data: crates/dim-modality/tests/modality_flow.rs:2016-2027 saves a video.generate model as modality.video, and the video.edit row then reports that default with configuration ("The model does not declare video.edit"). Add configuration to the list, or scope the sentence to options whose declaration still covers the operation. docs/zh/design/plugins/Modality.md:455 has the same omission.

Verification

  • cargo clippy -p dim-modality-aimux --tests --locked -- -D warnings: passed at ac2c7f62.
  • cargo test -p dim-modality-aimux --test modality_aimux_flow --locked relay: 6 passed, including the stalled POST and the relay URL and bearer tests.
  • cargo test -p dim-modality --test modality_suite --locked an_online_speech_adapter_does_not_hide_the_offline_image_adapter: passed.
  • cargo test -p dim-modality --test modality_suite --locked a_declared_media_model_served_by_the_adapter_is_an_option: passed.
  • cargo test -p dim-modality --test modality_suite --locked capabilities_and_configure_resolve_defaults_through_the_fixture_adapter: passed, including the unserved edit default this review's P2 concerns.
  • cargo test -p dim-modality --test modality_suite --locked the_product_build_reports_image_operations_without_an_adapter and ... an_adapter_serving_no_provider_model_is_not_reported_as_missing: both passed.
  • cargo test -p dim-app-server --test app_server_flow --locked selectable_modality_models: passed, covering the known-id, inferred, explicit-empty and imageGeneration: false recognition cases.
  • All local runs used LC_ALL=en_US.UTF-8 with an isolated home and cargo target under the data directory; no real relay or paid endpoint was called.
  • git diff --check origin/main...HEAD: clean. git merge-tree --write-tree HEAD origin/main: clean.
  • CI at ac2c7f62: ci-ok, changes, dependencies, macos-native and verify (linux) pass; web, scripts, static-checks, windows-cli and acp-registry skip.
  • Open PRs #1902, #1903, #1905 and #1996 touch the same files. Merge trees against their fetched heads are clean for #1903, #1905 and #1996; the #1902 tree conflicts only in files this PR does not change, so #1902 needs a rebase on main.

Comment thread docs/design/plugins/Modality.md Outdated
- `options` lists the models that serve the operation. The candidates come from Provider's non-conversational read (`selectableForModality`, §9.2), so a media model execution rejects — a non-chat model, or one whose text limits are undeclared — is a candidate when its catalog entry declares the operation. For every other operation the options are the models whose Provider catalog entry declares that `<category>.<operation>` id, in Provider's order, and an operation nothing declares has none; each is `available` only when an available adapter's `operations` serves it for that operation, and is otherwise listed `available: false` with the reason no adapter runs it. For adapter-backed tasks, the operation is available when one of its options is available. If none is available and a declared option reports `runtime`, the operation reports that reason. For `image.understand` a selectable vision model serves instead, from Provider's `vision` capability. For a realtime operation the options are the models whose entry declares that `<category>.<operation>` id, in Provider's order: the session's adapter is handed the transport the entry declares, so the entry itself is the per-model answer, and `open` refuses `unavailable` a declared model that has no transport. The owner computes the candidates from Provider's declared capabilities so clients never derive them. The current default is included when it is no longer an option, marked with its reason. The owner computes them at read time from Provider's read-only contract (§9.2) and the available adapters. An option carries only `{providerId, modelId, available, reason?}`: #790 returns ids and capabilities, not display names, so the client joins names from its existing Provider list or catalog reads by `{providerId, modelId}` and shows the ids when a name is unavailable.
- `configure` validates the operation and that the model is in that operation's options (for `image.understand`, selectable vision support; for `ocr.recognize`, one of the host targets the snapshot offers), then writes or clears the operation key through Settings' owner write with CAS. It accepts every A.1 operation that has a default key and never answers `modality_unavailable`: configuring is a settings write, not a runtime claim. An unknown category or operation answers `modality_unknown_operation`; `operation` is required where the operation has its own key (image, speech, OCR) and may be absent only for a category-keyed category. `model: null` clears that key (for OCR, `modality.ocr`); clearing restores automatic resolution, and a missing `model` is `invalid_params`. The write happens before the reply is sent, so a success means the default is persisted, and the reply is the same snapshot a following `modality.capabilities` call returns unless Provider changed in between.
- Configurable and available are different properties: the first belongs to settings, the second to the runtime. A persisted default can name a model of an operation this build cannot run; the snapshot stays honest by keeping that operation's `available: false` and its `build` or `adapter` reason, and `effective` still resolves over the options (the default when available, otherwise automatic) so clients do not implement resolution themselves.
- Configurable and available are different properties: the first belongs to settings, the second to the runtime. A persisted default can name a model of an operation this build cannot run; the snapshot stays honest by keeping that operation's `available: false` and its `build` or `adapter` reason, and `effective` resolves over the available options only (the default when available, otherwise automatic), so it is `null` whenever no option can run and clients do not implement resolution themselves.

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.

configure now accepts a declared model whether an adapter serves it or not (crates/dim-modality/src/lib.rs:780-786; crates/dim-modality/tests/modality_flow.rs:1448-1460), which the §3.4 paragraph at line 167 and this bullet state. Two earlier statements in the same document still say the opposite: section 3.4 at line 171 ('for an adapter operation, that an available adapter serves it') and the error table at line 556 (modality_invalid_selection when 'no available adapter serves the operation'), repeated in docs/zh/design/plugins/Modality.md:171,550. Line 173's automatic-resolution sentence also names Provider's selectable-model read, while the code resolves over available options from the declared read (crates/dim-modality/src/lib.rs:922-947). A client that implements the document refuses the default save this PR makes possible. Update those lines with this bullet.

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 1f38d86. The updated text at docs/design/plugins/Modality.md:171,173,556 and docs/zh/design/plugins/Modality.md:171,173,550 now matches Evaluation::configurable (crates/dim-modality/src/lib.rs:780-786), the automatic-resolution block (:914-947) and the configure refusal (:1176-1188).

Comment thread docs/design/plugins/Modality.md Outdated
- `default` is the persisted choice or `null`. When the model is no longer selectable or no available adapter serves it (for `image.understand`, when it is not a selectable vision model), `available` is `false` and `reason` says why.
- `effective` is the model a task or consumer would use now once the operation can run: it is resolved from the options even when the operation itself is `available: false` (no adapter in this build), so a client never has to know which part is settings and which is runtime. It is the default when available. When `default` is `null`, it is automatic resolution: Provider's global default selection when selectable and serving the operation, else the first selectable model that serves it in the order Provider's selectable-model read returns; `source` is `"automatic"`. An unavailable default yields `effective: null`, never a substituted model.
- `options` lists the models that serve the operation. The candidates come from Provider's non-conversational read (`selectableForModality`, §9.2), so a media model execution rejects — a non-chat model, or one whose text limits are undeclared — is a candidate when its catalog entry declares the operation. For `generate`, `edit` and `enhance` an available adapter decides which candidates serve which operation: the options are the deduplicated union of Provider's two reads, the execution-selectable models first and the declared ones after, in each read's order, kept when the adapter's `operations` serves them for that operation. For `image.understand` a selectable vision model serves instead, from Provider's `vision` capability. For a realtime operation the options are the models whose entry declares that `<category>.<operation>` id, in Provider's order: the session's adapter is handed the transport the entry declares, so the entry itself is the per-model answer, and `open` refuses `unavailable` a declared model that has no transport. When no adapter serves the operation's category, the adapter narrows nothing and the options are the models whose Provider catalog entry declares that `<category>.<operation>` id, in Provider's order, and an operation nothing declares has none. The owner computes the candidates from Provider's declared capabilities so clients never derive them. The current default is included when it is no longer an option, marked with its reason. The owner computes them at read time from Provider's read-only contract (§9.2) and the available adapters. An option carries only `{providerId, modelId, available, reason?}`: #790 returns ids and capabilities, not display names, so the client joins names from its existing Provider list or catalog reads by `{providerId, modelId}` and shows the ids when a name is unavailable.
- `default` is the persisted choice or `null`. When the model is no longer selectable or no available adapter serves it (for `image.understand`, when it is not a selectable vision model), `available` is `false` and `reason` says why: `provider` for a model no longer selectable, `runtime` when an adapter serves the operation for that model but is unavailable, `build` for a category this build has no adapter for, and `adapter` otherwise.

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.

Optional P3: this list omits configuration. A persisted default that is not an option of the row being read gets configuration from unavailable_reason (crates/dim-modality/src/lib.rs:828-831). With the category-wide modality.video key, crates/dim-modality/tests/modality_flow.rs:2016-2027 saves a video.generate model and the video.edit row reports that default with 'The model does not declare video.edit'. Add configuration here, or scope the sentence to options whose declaration covers the operation. The Chinese bullet at line 455 has the same omission.

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 1f38d86. The default bullet now lists configuration with the category-wide video.generate / video.edit example at docs/design/plugins/Modality.md:461 and docs/zh/design/plugins/Modality.md:455, matching unavailable_reason (crates/dim-modality/src/lib.rs:791-831).

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed ac2c7f62: the generic scripted responder removes the Clippy failure without weakening the stalled-response assertion. On this exact head, Linux verify passed Clippy, architecture boundaries, the one-POST timeout regression, and relay generate/edit routing. macOS native, dependencies and ci-ok also passed. The earlier operation-specific availability and retry findings are addressed. The relay’s remaining exchange timeout is tracked separately in aimux #527; no real paid requests were made in this review.

@zerob13
zerob13 requested a review from yyhhyyyyyy November 22, 2026 02:54

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review at 1f38d862 (origin/main e4d981bd).

The new head adds one commit, "docs(modality): align operation defaults with declared options", on top of ac2c7f62. It changes only docs/design/plugins/Modality.md and docs/zh/design/plugins/Modality.md (16 lines each). Code is unchanged since ac2c7f62, so the code paths verified in the previous review still apply. The full PR diff from main remains 15 files, +561/-236.

Verdict: APPROVE

Findings

  • P0: none.
  • P1: none.
  • P2: none.
  • P3: none. The docs delta introduces no new finding.

Prior findings

  • P2, configure and automatic resolution: fixed. docs/design/plugins/Modality.md:171 now validates against the operation's options, allows a declared model to be saved with available: false, and requires a runnable OCR host target. :173 now resolves automatic selection over available options and names Provider's declared order. :556 now defines modality_invalid_selection as a model outside the configured operation or category options, or an OCR target that cannot run here. The Chinese translation matches at docs/zh/design/plugins/Modality.md:171,173,550. Code: crates/dim-modality/src/lib.rs:780-786 (any declared non-host option is configurable, available or not), :914-947 (global default only when it is an available option, else the first available option), :1176-1188 (the refusal). The unserved declared model case is exercised at crates/dim-modality/tests/modality_flow.rs:1448-1460. The P2 failure scenario no longer applies: a client that follows the document now permits saving a declared model while its adapter is offline.
  • P3, default reason list: fixed. docs/design/plugins/Modality.md:461 and docs/zh/design/plugins/Modality.md:455 now list configuration, with the category-wide video.generate / video.edit example. That matches unavailable_reason (crates/dim-modality/src/lib.rs:791-831) and the shared modality.video key (:183-197).

Consistency checks

  • The new text matches A.3 (docs/design/plugins/Modality.md:464), including category-wide saves and the OCR host target exception; A.2.1 already states the host target rule.
  • docs/design/appserver/provider-management.md:1023-1031 says selectableForModality returns operations in the entry's order, matching the new reference to Provider's declared order at Modality.md:173 and the existing options bullet at :463.
  • No anchor or cross-reference change: the new commit adds only plain section references and no links. git diff --check is clean.
  • A residual observation, not a finding: the default reason list says "such as", so it remains non-exhaustive. An OCR default can also report platform for Apple Vision on an unsupported host (crates/dim-modality/src/lib.rs:556-560), which A.2.1 covers.

Merge status

  • git merge-tree --write-tree 1f38d862 origin/main is clean.
  • Merge trees against the current heads of #1903 (2ff576364), #1905 (4f9339c17), #1996 (d491746e9) and #1997 (9b9d93f36) are clean. #1903, #1905 and #1996 share files with this PR; #1997 shares none.

Verification

  • Confirmed the head is 1f38d8622725ef660d44a4877bf3543211e29cf2, the parent is ac2c7f62, and git show --name-only 1f38d862 lists only the two Modality docs. git diff --stat ac2c7f62..1f38d862 is docs only.
  • Rechecked the cited code at this head: crates/dim-modality/src/lib.rs:593-619 (host options), :680-703 (operation spec reasons), :745-776 (candidate order and option reasons), :780-786 (configurable), :791-831 (reason vocabulary), :914-947 (effective and automatic); crates/dim-modality/src/engine.rs:187-246 and :248-295 (task and host resolution); crates/dim-app-server/src/provider.rs:782-833 (operation declarations), :2045-2080 (modality read order).
  • CI at this head: changes, dependencies and macos-native pass; verify (linux) was still in progress when this review was written; static-checks, windows-cli, web, scripts and acp-registry skipped. I did not wait for the run.
  • I did not run cargo tests or Clippy at this head. The delta is docs only and the code tree is identical to ac2c7f62, where the targeted modality and provider tests passed. No full suite was run, and no external provider or relay was called.

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at head 1f38d86.

Two things, both in the right place. The adapter row for the Dim account relay is a configuration entry in dim-modality-aimux — catalog, package, kinds, Base::AsIs, format — with credentials left to the existing managed lease, so the new capability arrives without new credential handling. And operation_spec now returns the reason with the spec instead of None, which removes the consumer-side re-derivation in engine.rs where the caller had to look the model up in options to recover why it was unavailable. That is the "one type per kind of data, consumer reads it directly" rule applied to a diagnostic: the producer that knows why says why.

Blocking: none.

Checks are green at this head. I read lib.rs (operation_spec, adapter_serves, operation), the engine.rs delta, the aimux vendor/job rows and the test names; I did not read the app-server provider flow, the docs deltas or the new adapter tests line by line, and ran nothing.

Non-blocking:

  • crates/dim-modality/src/lib.rs:699 — if category != "image" && !self.adapter_serves(category). The image literal now appears twice with different vocabularies: here it forces dimension adapter ("No available adapter serves the model") for every image model, while operation() at the category == "image" branch distinguishes "The adapter serves no image model Provider lists" from "No image adapter in this build". A build with no image adapter at all therefore gives a less precise reason through operation_spec than through the snapshot, and the literal is a category name in the core snapshot rather than something the adapter set reports. If the distinction matters, let the same helper answer both; if it does not, the operation() branch is carrying a distinction the rest of the code does not honour. I could not satisfy myself which is intended within this run's budget, and I would rather ask than assert.

I did not re-check the build reason path against modality_flow.rs:1168, which pins {"dimension":"build","detail":"Not in this build"} for an image generate; if that test passes while the two branches disagree, the test is reaching a different path than I traced.

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.

Modality: Dim account image models are listed as available options but image.generate is unavailable

4 participants