Skip to content

🤖 refactor: move per-provider Coder catalog merge rules into a tested module - #6305

Merged
ThomasK33 merged 1 commit into
mainfrom
crap/coder-catalog-merge
Oct 13, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
crap/coder-catalog-merge

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

CoderOauthService.refreshBridgeModelsSerializedEffect decides, inside the providers-file lock, what each AI Gateway provider contributes to the next model catalog write. Those per-provider rules (carry-forward, type gating, conclusiveness) and the read of the prior catalog state now live in src/node/services/coderGatewayCatalogMerge.ts, with direct unit tests. Behavior is unchanged.

Background

This PR is part of the CRAP campaign on src/node/services/coderOauthService.ts. CRAP = CC² × (1 − coverage)³ + CC.

Function CC before CC after
refreshBridgeModelsSerializedEffect 54 30
reconcileProviderCatalog (new) 18
readPriorCoderCatalog (new) 5
stringEntries (new) 2
idsUnderProvider (new) 1

Scoring method: make crap with the 9 CI crap-lcov-* reports of PR run 38364731596 plus a local lcov of coderOauthService.test.ts and the new test file (bun test --coverage). With it, refreshBridgeModelsSerializedEffect goes from CRAP 54 to 30, and no function in the file is above 30. make crap-check with that coverage: PASS, 0 violations, 1 warning (reconcileProviderCatalog CC 18, move relief: the kept function lost CC 24, the new functions hold 22 decision points).

Note: CI's Quality / CRAP shows this file at about 0% coverage, because scripts/test-unit-ci.sh runs coderOauthService.test.ts as an isolated file without --coverage. The new test file runs in the shared shards, so CI does see its coverage.

Implementation

  • readPriorCoderCatalog(section) returns the prior catalog markers (known, discovered, stale, providers). It reads the same fields with the same string filter as before.
  • reconcileProviderCatalog(provider, result, prior, authoritative) returns one provider's contribution: the model IDs, the provider metadata to persist on the probe path (zero or one entry), and whether it makes the catalog inconclusive. Each branch and its comment moved verbatim from the loop body.
  • The locked mutation maps the results through it and concatenates the IDs and providers in result order, as the loop did. catalogInconclusive is true when any provider is inconclusive. updateProviderSection calls the mutation once, so assigning the flag instead of only setting it to true changes nothing.

Validation

  • coderGatewayCatalogMerge.test.ts (16 cases) covers the marker parsing and every ok / error / unavailable branch, on the listing and the probe path, including type changes and the name-as-type default.
  • 9 mutants of the moved rules (type gate, name default, stale type gate, stored-metadata preference, prefix match, empty-catalog knowledge, and others) each fail at least one new test.
  • coderOauthService.test.ts passes unchanged (101 tests).

Risks

Low. The change is a pure move of catalog merge rules behind the same lock. A mistake would show as a wrong catalog after a refresh (models missing or carried forward wrongly). The existing service tests for those flows pass unchanged.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T08:22:04.694688Z 9e84555 PR opened
🔒 Security Review ✅ Completed 2026-10-13T08:23:29.007412Z 9e84555 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 32364fb Oct 13, 2026
33 checks passed
@ThomasK33
ThomasK33 deleted the crap/coder-catalog-merge branch October 13, 2026 08:42
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