feat(usage): add api_kind field to microdollar_usage_metadata#1126
Merged
chrarnoldus merged 3 commits intomainfrom Mar 16, 2026
Merged
feat(usage): add api_kind field to microdollar_usage_metadata#1126chrarnoldus merged 3 commits intomainfrom
chrarnoldus merged 3 commits intomainfrom
Conversation
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (9 files)
Reviewed by gpt-5.4-20260305 · 2,154,116 tokens |
markijbema
approved these changes
Mar 16, 2026
jrf0110
reviewed
Mar 16, 2026
| 'api_kind', | ||
| { | ||
| api_kind_id: serial().notNull().primaryKey(), | ||
| api_kind: text().notNull(), |
Contributor
There was a problem hiding this comment.
If this is a known enum, we can express it via typescript:
Suggested change
| api_kind: text().notNull(), | |
| api_kind: text().$type<'chat_completions' | 'responses' | 'fim_completions' | 'embeddings' | 'messages'>().notNull(), |
Contributor
There was a problem hiding this comment.
alright, I'll do it in a follow-up because I'll probably need to move the type
jrf0110
approved these changes
Mar 16, 2026
b3425cb to
4fdb052
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an
api_kindfield (e.g.chat_completions,responses,fim_completions,embeddings,messages) tomicrodollar_usage_metadata, using the same normalized lookup-table pattern aseditor_name.api_kindlookup table with a unique index and serial PKapi_kind_idFK column onmicrodollar_usage_metadatamicrodollar_usage_viewextended withapi_kindvia aLEFT JOINUsageMetaDatatype updated withapi_kind: string | nullextractUsageContextInfonow forwardsapi_kindfromMicrodollarUsageContext(already present there)insertUsageAndMetadataWithBalanceUpdateCTE extended withcreateUpsertCTEforapi_kindVerification
pnpm typecheckpasses (all packages)pnpm format:checkpassesVisual Changes
N/A
Reviewer Notes
api_kindwas already present onMicrodollarUsageContext(used for branching logic) but was never persisted to the database. This PR closes that gap using the established normalized storage pattern.