Repository navigation
Conversation
This was referenced Oct 13, 2026
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
from
October 14, 2026 12:42
2bb1898 to
fca688a
Compare
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
from
October 15, 2026 07:53
fca688a to
1c1f8ee
Compare
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
from
October 15, 2026 11:12
1c1f8ee to
3f3c081
Compare
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
from
October 16, 2026 10:22
3f3c081 to
f2a98ad
Compare
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
from
October 19, 2026 08:56
f2a98ad to
dbad92e
Compare
SasSwart
added a commit
that referenced
this pull request
Oct 19, 2026
… validation (#30716) Moves request body decoding and per-price validation out of the site-wide `upsertAIModelPrices` handler, so the organization price handler later in this stack can reuse them. - The handler still reads the body and writes the HTTP errors. `writeAIModelPricesBodyReadError` picks 413 or 400. - `decodeAIModelPricesBody` only decodes, and returns an error. - `aiModelPriceKeys` holds the JSON keys present in one price, so validation can tell an explicit `null` apart from a missing price. - `validateAIModelPriceValues` checks the four prices of one model price. It takes them as an `aiModelTokenPrices` struct, so callers set each price by name and cannot pass them in the wrong order. No behavior change. The existing `TestUpsertAIModelPrices`, `TestListAIModelPrices` and `TestValidateAIModelPrices` cover the site-wide handler. **Used later:** #30720 reuses the body read error, the price keys and the value validation for its single-price upsert. --- *This PR was generated by Coder Agents on behalf of @SasSwart.*
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
2 times, most recently
from
October 19, 2026 12:22
19145a1 to
d280997
Compare
Organization prices are only per configured provider, so remove the upsert and delete queries for provider type prices and their listing branch.
Org admins edit prices one model at a time, so the upsert takes typed params instead of a JSON batch. The org price listing tells organization and site-wide rows apart by provider_id instead of a price kind.
Replace GetOrganizationAIModelPrices, which listed every price that applies to an organization, with GetOrganizationAIProviderModelPrice, which reads one price by organization, provider and model. Queries target the renamed ai_model_configs table. Split the tests per query, and cover that an identical upsert leaves updated_at unchanged and that an empty model is rejected. Leave a TODO to authorize these queries against a resource for AI Governance model config rather than ResourceAiModelPrice.
DeleteOrganizationAIProviderModelPrice now flags the live row as deleted instead of removing it. Reads and upserts only match live rows, so an upsert after a delete inserts a new live row and leaves the soft-deleted one untouched.
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
from
October 21, 2026 06:38
d280997 to
09b9751
Compare
…elper The get helper captured the parent test's context and testing.T, which paralleltestctx flags once the subtests call t.Parallel.
…okup The lookup now ranks an organization's price for the configured provider, then site-wide custom and default prices.
Drop the price kind from the lookup and token usage records, remove the unused GetAIModelPriceByProviderModel query, and stop counting organization prices in the unpriced-models report until they apply at runtime.
Follow the rename of the organization price table to ai_model_configs. Link the TODO for passing the organization to the price lookup to AIGOV-716.
GetAIModelPriceForProvider read ai_model_configs without the deleted filter, so a deleted organization price kept pricing token usage instead of falling back to the site-wide price.
Organization upserts and deletes take a required provider_id. The provider type field and the organization_provider_type scope are gone.
POST on the organization route takes a single price for one configured provider, matching how org admins edit prices. The listing scope comes from provider_id now that the price kind is gone.
GetOrganizationAIModelPrices is gone, so the organization GET route now returns one price, keyed like DELETE by the provider_id and model query parameters, and 404s when the organization has no such price. OrganizationAIModelPrice drops the fields that only described a merged listing: scope, provider type, provider name, and source. Validate the organization price through aiModelTokenPrices.
SasSwart
force-pushed
the
sdlcgraph/aigov-612-5-api
branch
from
October 21, 2026 07:20
09b9751 to
753930e
Compare
…ID as a UUID TestSDKFieldsFormatted requires uuid.UUID fields to carry format:"uuid".
SasSwart
added a commit
that referenced
this pull request
Oct 22, 2026
Adds the store queries for organization AI model prices in `ai_model_configs`, with authorization. They cover basic CRUD on one price, keyed by `(organization_id, provider_id, model)`. - `GetOrganizationAIProviderModelPrice` reads one price. - `UpsertOrganizationAIProviderModelPrice` sets one price, with typed params. It rewrites an existing row only when a price differs, so `updated_at` records the last change. - `DeleteOrganizationAIProviderModelPrice` soft deletes one price. Reads and upserts only match live rows, so setting a price after a delete inserts a new live row. All three authorize against `ResourceAiModelPrice.InOrg(org)`. The new `AiModelPriceInOrg` case in `TestRolePermissions` pins that only owners and org admins pass. A TODO in dbauthz notes that this should become a resource for AI Governance model config. Each query has its own test. The upsert tests cover that identical prices leave `updated_at` unchanged, that changed prices advance it, and that an empty model is rejected. **Used later:** #30719 seeds its lookup tests with the upsert. #30720 serves all three through the org price API. --- *This PR was generated by Coder Agents on behalf of @SasSwart.*
SasSwart
added a commit
that referenced
this pull request
Oct 22, 2026
Prices token usage by the most specific match: the organization's price for the configured provider, then a site-wide custom price, then the price book. The requested model is still preferred over the model the provider reports. - `GetAIModelPriceForProvider` replaces `GetAIModelPriceByProviderModel`, which is removed. It is one `UNION ALL` of primary-key lookups, ordered by requested model first, then by specificity. dbauthz checks `ResourceAiModelPrice`, scoped to the org when one is given. - `coderd/aibridge/prices` tests read seeded prices through `GetAIModelPrices`. Interceptions don't carry an organization yet, so `resolveTokenUsageCost` passes none and only site-wide prices apply at runtime for now (AIGOV-716). Org matching is covered by database tests with explicit org IDs. For the same reason, the unpriced-models report still counts only site-wide prices. **Used later:** prices set through the API in #30720 take effect here once interceptions carry an organization. --- *This PR was generated by Coder Agents on behalf of @SasSwart.*
Collaborator
Author
|
Closing at the author's request. This comment was generated by Coder Agents. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds experimental, AI Gateway licensed routes to manage an organization's AI model prices:
GET,POSTandDELETEon/api/experimental/organizations/{organization}/ai/model-prices. They authorize againstResourceAiModelPrice.InOrg(org), so only owners and org admins can use them. The site-wide routes are unchanged.GETreturns one of the organization's prices, keyed byprovider_idandmodelin the query string. It returns404when there is no such price.POSTsets one price:provider_id(a live provider),modeland the four prices. Invalid requests return400and write nothing.DELETEtakes the same key asGET. The key is in the query string because model names can contain slashes.Adds the matching
codersdktypes andExperimentalClientmethods. Swagger, API docs and TypeScript types are regenerated.This is the top of the stack. Closes AIGOV-612. Replaces #30690 and #30396.
This PR was generated by Coder Agents on behalf of @SasSwart.