Repository navigation
fix(modality): align missing image adapter reasons - #2075
Conversation
eric8810
left a comment
There was a problem hiding this comment.
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.
eric8810
left a comment
There was a problem hiding this comment.
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.
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
modalityTargets.resolveface.modalityAdapteris the in-process binding described in Modality A.2.Documentation
Verification
modality_suiteflows 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 --checkandnode scripts/adr-check.mjs --base origin/main.