Skip to content

fix(modality): align missing image adapter reasons - #2075

Merged
zerob13 merged 2 commits into
mainfrom
dimagent/1916-image-adapter-reason
Nov 23, 2026
Merged

zerob13 merged 2 commits into
mainfrom
dimagent/1916-image-adapter-reason

Conversation

@zerob13

@zerob13 zerob13 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refs #1916.

When Modality resolves no adapter for any Provider candidate, the image task operation, its declared options and any default selected from them report adapter: No image adapter in this build. When a resolved adapter covers no image model, the operation and individual options still give the corresponding operation-wide and model-specific details. See Modality §3.4 and the review finding.

Design rule checklist

  • Scope. Modality computes the diagnostic in its existing process owner.
  • Commands and results, handover, Timeline callbacks, batch, context and Timeline facts. N/A for a diagnostic computed during a read.
  • Infrastructure, core mechanisms and consumers. The fix lives in Modality's evaluation of its existing adapter bindings.
  • Owner state and business configuration. Modality derives the reason from the Provider candidates and resolved adapters it already reads.
  • Service faces. The diagnostic is data on the existing management methods and modalityTargets.resolve face. modalityAdapter is the in-process binding described in Modality A.2.
  • Requirements to mechanism owners. N/A because Modality can derive the reason using its current reads.

Documentation

  • The English and Chinese Modality owner documents specify the diagnostic in §3.4. ADR freeze passed.

Verification

  • Focused modality_suite flows for a missing image adapter, an adapter that covers no listed image model, and task rejection with the snapshot's reasons.
  • rustfmt --check, git diff --check and node scripts/adr-check.mjs --base origin/main.

@zerob13
zerob13 requested a review from codoggy November 23, 2026 02:01

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

The reason strings and the missing-versus-unserved distinction look right. The new option path makes the exact missing-adapter case unnecessarily expensive.

[P2] Compute whether any candidate resolves an adapter once per evaluation. candidates_for calls operation_spec for each declared image option (lib.rs:765–781). Each unserved image option now calls image_adapter_reason, which walks all selectable and declared models and tries both binding keys (:622–649,704–705). On a build without an adapter, every probe misses, so N image options against an M-model catalog cause N×M candidate probes per row. The pre-change per-option path did not rescan the catalog. This affects modality.capabilities and the snapshots returned by configuration writes.

Keep the per-model check, but share the catalog-wide answer across image options and the operation reason, ideally lazily for each evaluation so unrelated operations do not pay for it. Keep the existing exact reason assertions; a counting fixture would also rule out reintroducing the repeated scan. Source review, not a benchmark.

@zerob13
zerob13 requested a review from eric8810 November 23, 2026 02:11

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

This answers the finding I left on #1916 (review 6009957017) in exactly the way I hoped it would be answered: rather than picking one of the two vocabularies and editing the other site to match, image_adapter_reason now answers both, with the caller's specific unserved detail and the "No image adapter in this build" substitution when no adapter serves any candidate at all. So a build with no image adapter stops giving the vaguer "No available adapter serves the model" through operation_spec while the snapshot said something better — the two paths now share one decision instead of agreeing by luck.

Caching the candidate scan in OnceLock<bool> is right for a snapshot that does not change after it is built, and it keeps the helper cheap enough that calling it from both sites costs nothing. The design §3.4 reference is the right owner for the wording, and the two-line doc additions keep the English and Chinese pages saying what the code now does.

Blocking: none.

Checks are green at this head. I read the lib.rs delta in full (21/13 — the helper, its two call sites and the cache), the PR body's checklist, and the finding it answers; I did not read the modality_flow.rs assertion change or the doc deltas, and ran nothing.

Non-blocking: none — this is the completion of a point I raised, and I have nothing further to add.

@zerob13
zerob13 merged commit cecf65f into main Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants