Skip to content

test: cover third-party backend routing and model rewrite (#74)#79

Merged
MagicalTux merged 1 commit into
masterfrom
test/third-party-backend-coverage
Jul 6, 2026
Merged

test: cover third-party backend routing and model rewrite (#74)#79
MagicalTux merged 1 commit into
masterfrom
test/third-party-backend-coverage

Conversation

@MagicalTux

Copy link
Copy Markdown
Member

Follow-up to #74, which shipped the third-party-backend feature (per-account upstream / modelMap / models) with no tests. Adds test/third-party-backend.test.js covering both surfaces.

Model-ownership routing (AccountManager)

  • Ownership is inert until some account declares a models list.
  • A request for an owned model routes only to accounts that own it.
  • The [Nm] suffix is stripped when matching, so a bare model name still routes to its owner.
  • A Claude model claims no owner → Claude accounts stay eligible.
  • The third-party account acts as a priority fallback (used once Claude accounts are exhausted).
  • An owned model whose only owner is unavailable selects nothing.
  • Two accounts can co-own the same model.

Request-body model rewrite (server.rewriteModel)

  • Maps a known model and returns re-serialized JSON.
  • Updates the byte length so Content-Length can be corrected (validates the fix in forwardRequest).
  • Passes the body through unchanged for an unmapped model, a non-JSON body, or a body with no model field.

rewriteModel is now exported from server.js for the unit test (mirrors readWithIdleTimeout). No behavior change.

163 tests pass, lint clean.

🤖 Generated with Claude Code

#74 shipped the third-party-backend feature (per-account upstream/modelMap/
models) with no tests. Add coverage for both surfaces:

- Model-ownership routing in AccountManager: ownership is inert until some
  account declares a `models` list; an owned model routes only to owning
  accounts; the [Nm] suffix is stripped when matching; a Claude model claims
  no owner so Claude accounts stay eligible; the third-party account acts as a
  priority fallback; an owned model whose only owner is unavailable selects
  nothing; two accounts can co-own a model.
- Request-body model rewrite (server.rewriteModel, now exported for tests):
  maps a known model, updates the byte length so Content-Length can be
  corrected, and passes through unchanged for an unmapped model, a non-JSON
  body, or a body with no model field.

163 tests pass, lint clean. No behavior change beyond exporting rewriteModel.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MagicalTux MagicalTux merged commit 24231bb into master Jul 6, 2026
5 checks passed
@MagicalTux MagicalTux deleted the test/third-party-backend-coverage branch July 6, 2026 07:28
@MagicalTux MagicalTux mentioned this pull request Jul 6, 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.

1 participant