Skip to content

fix: preserve native gateway discovery during background refresh - #1798

Merged
JAORMX merged 1 commit into
mainfrom
fix/native-gateway-discovery-publication
Sep 23, 2026
Merged

JAORMX merged 1 commit into
mainfrom
fix/native-gateway-discovery-publication

Conversation

@JAORMX

@JAORMX JAORMX commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix a fresh-startup race that could reject the first prompt with context window discovery unavailable even after successful native-gateway discovery.

The TUI's on-demand model listing can publish live native-provider metadata before an unrelated background refresh finishes. That background refresh skips authenticated native discovery, but previously included the configured native-model placeholder in its publication. Publishing it replaced the live inventory and cleared successful-listing evidence.

  • Omit skipped native providers from the background publication map. Existing merge semantics preserve their seeded floor or newer on-demand discovery.
  • Add deterministic, channel-gated regression tests for both publication orders and native-only startup.
  • Assert preserved context windows, full native picker inventory, cold configured defaults, and first admission without another native discovery call.

Development stage

  • Plan / Interface
  • Implementation
  • Combined
  • Spike / Routine / Cleanup

Contract linkage

  • Work classification: Routine
  • Classification rationale: a one-line production deletion restores the existing fetched-only publication contract. Configured defaults are already seeded; no new policy or interface is introduced.
  • Decision record: None — no new durable architectural decision.
  • Human waiver of spine: No — Routine exemption applies.
  • Acceptance plan / Plan PR: N/A.
  • Human decisions resolved and recorded: N/A — preserves established behavior.
  • Baseline: b0cf03a423df907e07269e085105fda2dc81ea47.

Interface conformance

No API, configuration, authentication, retry/cooldown, or admission-policy changes. Native authenticated discovery remains on demand. Failed/empty discovery is not made admissible by this fix.

Issue relationship

Reported and reproduced during fresh-startup debugging; no linked GitHub issue.

Type of change

  • Bug fix

Test plan

  • Regression was observed failing before the production deletion, then passing with targeted native/gateway/admission tests under -race -count=10.
  • Subsequent review strengthened picker assertions and bounded synchronization waits; the final version is submitted for CI validation.
  • Offline demo (go run ./cmd/mecademo): passed, including tool execution, permission approval, and terminal result.
  • Final implementation review: spec, standards, test adequacy, architecture, reuse, and duplication reviewed; test-review findings addressed and re-reviewed.
  • git diff --check.
  • Linting (task lint): local run exceeded its 600-second limit; CI required.
  • Full offline suite (task test GOPROXY=off): local run exceeded its 600-second limit; CI required.

The operator explicitly requested submitting the PR and relying on CI rather than continuing heavyweight local gates. Local timeouts are not reported as passes. No tracked Markdown, generated contracts, or engine API changes; docs/site/API-update gates are not applicable to this internal repair.

User-facing change

A late unrelated background refresh no longer erases already-discovered native-gateway metadata and causes a spurious first-prompt context-window error.

Special notes for reviewers

The tests establish publication ordering with channels, not sleeps. They cover the real refresh/publication/admission functions; existing native-gateway Build tests cover the authenticated on-demand wiring. This fixes the reproduced metadata-loss race, not every possible discovery outage. Retry and cooldown behavior intentionally remain unchanged.

Do not publish a configured native-provider floor as freshly fetched data.
A late background refresh could otherwise overwrite successful on-demand
model discovery, erase context-window metadata and listing evidence, and
reject the first prompt on a fresh startup.

Add deterministic regressions for both publication orders, native-only
startup, picker inventory, and admission without an extra discovery call.

Co-Authored-By: mecatl <[email protected]>
@JAORMX
JAORMX merged commit ca993a6 into main Sep 23, 2026
35 checks passed
@JAORMX
JAORMX deleted the fix/native-gateway-discovery-publication branch September 23, 2026 10:55
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.

1 participant