Skip to content

fix(connect): honor upstream model restrictions - #255

Open
andya1lan wants to merge 3 commits into
dwgx:masterfrom
andya1lan:fix/devin-connect-catalog-parity
Open

fix(connect): honor upstream model restrictions#255
andya1lan wants to merge 3 commits into
dwgx:masterfrom
andya1lan:fix/devin-connect-catalog-parity

Conversation

@andya1lan

Copy link
Copy Markdown
Contributor

Summary

  • Treat a non-empty live Connect catalog as authoritative.
  • Use the frozen selector snapshot only during cold start or failed synchronization.
  • Validate aliases against the authoritative selector set.
  • Keep pool-wide discovery while enforcing each selected account's own catalog.
  • Deduplicate /v1/models by resolved upstream selector.
  • Add live-only selectors to the Dashboard.
  • Avoid downgrade warnings during read-only model discovery.

Why a follow-up is needed after #234

#234 correctly separated the Connect and Cascade namespaces and made the Dashboard and /v1/models share the same reachability predicate.

However, selector existence was still defined as:

frozen snapshot ∪ live catalog

That works when the upstream catalog only adds selectors. It does not work when upstream restrictions cause a non-empty live catalog to omit selectors.

In that case, entries retained by the frozen snapshot remain classified as known even though the upstream catalog no longer exposes them. This can cause:

  • /v1/models to advertise selectors omitted by upstream restrictions;
  • stale aliases to remain routable;
  • read-only discovery to emit misleading paid-request downgrade warnings;
  • mixed pools to select an account whose own catalog does not contain the requested selector;
  • aliases and canonical selectors to appear as duplicate discovery rows.

The views introduced by #234 therefore agree with each other, but can still agree on stale catalog data.

Fix

After a successful non-empty catalog synchronization:

  1. The live catalog becomes authoritative for selector existence.
  2. Frozen catalog data remains available only as a cold-start or failed-sync fallback.
  3. Alias targets must exist in the authoritative catalog.
  4. Discovery uses the union of active account catalogs.
  5. Request routing checks the selected account's own catalog.
  6. Discovery rows are deduplicated by resolved selector.
  7. Catalog inspection suppresses fallback warnings; real requests retain them.

Empty responses never replace the last known-good catalog.

Verification

  • Restricted selectors omitted by the live catalog are not advertised.
  • /v1/models contains the live selector set plus the universal free fallback.
  • Multiple aliases resolving to one selector produce one discovery row.
  • Dashboard live-only rows agree with /v1/models.
  • Mixed-pool routing remains inside each account's own catalog.
  • Reading /v1/models produces no paid-request downgrade warnings.
  • Strict requests for omitted selectors are rejected before upstream egress.
  • 296 focused Connect catalog, discovery, routing, Dashboard parity, and consistency tests pass.

Follow-up to #234.

Copilot AI lite review requested due to automatic review settings August 17, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the DEVIN_CONNECT model discovery + routing pipeline to treat a successful non-empty upstream Connect catalog as authoritative (instead of snapshot ∪ live), preventing stale snapshot-only selectors/aliases from remaining discoverable or routable after upstream restrictions omit them.

Changes:

  • Make selector existence/alias validity depend on the authoritative live catalog after first successful sync (snapshot becomes cold-start/failed-sync fallback).
  • Update /v1/models and Dashboard Connect views to (a) synthesize live-only selectors, (b) dedupe rows by resolved upstream selector, and (c) suppress paid-downgrade warnings during read-only discovery.
  • Enforce per-account routing boundaries by requiring a paid account’s own live catalog to contain the selector (mixed pools still discover the union).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/mutations/dashboard-connect-parity.json Updates mutation anchors/expectations to match the revised Dashboard + models reachability/dedupe behavior.
test/models-live-catalog.test.js Adds coverage for deduping live canonical selectors already represented by aliases.
test/devin-connect-models.test.js Adds coverage for retiring snapshot-only aliases once live catalog proves the target is absent.
test/dashboard-models-connect-parity.test.js Adds parity coverage for Dashboard inclusion of live-only selectors and dedupe vs alias-backed selectors; adds deterministic offline seams.
test/connect-discovery-rebuild.test.js Adds coverage for “live is authoritative” and suppressing downgrade warnings during discovery.
test/connect-catalog-delatch.test.js Adds coverage that routing stays within each account’s own live catalog contribution.
src/handlers/models.js Makes /v1/models Connect discovery authoritative, deduped by resolved selector, and live-catalog-synthesized.
src/devin-connect-models.js Introduces authoritative-live selector existence, validates aliases against it, and adds warnOnFallback control to suppress discovery-time warnings.
src/dashboard/api.js Mirrors /v1/models live-only selector synthesis and dedupe in the Dashboard Connect models view.
src/auth.js Enforces per-account routing: paid tier is necessary but not sufficient; selector must also be in that account’s live catalog once available.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/handlers/models.js Outdated
Comment thread src/dashboard/api.js
@andya1lan

Copy link
Copy Markdown
Contributor Author

Fixed copilot's comment, should be able for review.

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