chore: sync OpenAPI contract#2
Conversation
Source commit: trylitmus/litmus@25274156c014dca5bee2a4dd236a2b947dbe6fa2
|
| Filename | Overview |
|---|---|
| contract/openapi.yaml | Adds $sessionend event type with clarifying docs, and seven new generation-metadata fields (model, provider, input_tokens, output_tokens, total_tokens, duration_ms, ttft_ms, cost) to the Event schema; numeric fields are missing minimum: 0 constraints. |
Entity Relationship Diagram
%%{init: {'theme': 'neutral'}}%%
erDiagram
Event {
string id PK
string session_id
string type
string project_id
string prompt_id
string prompt_version
string generation_id
string user_id
string model "NEW"
string provider "NEW"
integer input_tokens "NEW"
integer output_tokens "NEW"
integer total_tokens "NEW"
integer duration_ms "NEW"
integer ttft_ms "NEW"
number cost "NEW"
object metadata
string timestamp
}
IngestRequest {
array events
}
IngestResponse {
integer accepted
}
IngestRequest ||--o{ Event : "contains (1-1000)"
Prompt To Fix All With AI
This is a comment left during a code review.
Path: contract/openapi.yaml
Line: 144-162
Comment:
**Missing `minimum: 0` on numeric fields**
All seven new numeric properties (`input_tokens`, `output_tokens`, `total_tokens`, `duration_ms`, `ttft_ms`, `cost`) accept negative values as written. Negative token counts, latencies, or costs are semantically invalid and would silently poison any aggregations or dashboards built on these fields.
Adding `minimum: 0` to each property enforces the invariant at the schema level and lets SDK codegen produce typed helpers with correct bounds.
```suggestion
input_tokens:
type: integer
minimum: 0
description: Number of input tokens consumed.
output_tokens:
type: integer
minimum: 0
description: Number of output tokens produced.
total_tokens:
type: integer
minimum: 0
description: Total tokens (input + output).
duration_ms:
type: integer
minimum: 0
description: End-to-end generation latency in milliseconds.
ttft_ms:
type: integer
minimum: 0
description: Time to first token in milliseconds.
cost:
type: number
format: double
minimum: 0
description: Generation cost in USD.
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "chore: sync OpenAPI contract from monore..." | Re-trigger Greptile
| input_tokens: | ||
| type: integer | ||
| description: Number of input tokens consumed. | ||
| output_tokens: | ||
| type: integer | ||
| description: Number of output tokens produced. | ||
| total_tokens: | ||
| type: integer | ||
| description: Total tokens (input + output). | ||
| duration_ms: | ||
| type: integer | ||
| description: End-to-end generation latency in milliseconds. | ||
| ttft_ms: | ||
| type: integer | ||
| description: Time to first token in milliseconds. | ||
| cost: | ||
| type: number | ||
| format: double | ||
| description: Generation cost in USD. |
There was a problem hiding this comment.
Missing
minimum: 0 on numeric fields
All seven new numeric properties (input_tokens, output_tokens, total_tokens, duration_ms, ttft_ms, cost) accept negative values as written. Negative token counts, latencies, or costs are semantically invalid and would silently poison any aggregations or dashboards built on these fields.
Adding minimum: 0 to each property enforces the invariant at the schema level and lets SDK codegen produce typed helpers with correct bounds.
| input_tokens: | |
| type: integer | |
| description: Number of input tokens consumed. | |
| output_tokens: | |
| type: integer | |
| description: Number of output tokens produced. | |
| total_tokens: | |
| type: integer | |
| description: Total tokens (input + output). | |
| duration_ms: | |
| type: integer | |
| description: End-to-end generation latency in milliseconds. | |
| ttft_ms: | |
| type: integer | |
| description: Time to first token in milliseconds. | |
| cost: | |
| type: number | |
| format: double | |
| description: Generation cost in USD. | |
| input_tokens: | |
| type: integer | |
| minimum: 0 | |
| description: Number of input tokens consumed. | |
| output_tokens: | |
| type: integer | |
| minimum: 0 | |
| description: Number of output tokens produced. | |
| total_tokens: | |
| type: integer | |
| minimum: 0 | |
| description: Total tokens (input + output). | |
| duration_ms: | |
| type: integer | |
| minimum: 0 | |
| description: End-to-end generation latency in milliseconds. | |
| ttft_ms: | |
| type: integer | |
| minimum: 0 | |
| description: Time to first token in milliseconds. | |
| cost: | |
| type: number | |
| format: double | |
| minimum: 0 | |
| description: Generation cost in USD. |
Prompt To Fix With AI
This is a comment left during a code review.
Path: contract/openapi.yaml
Line: 144-162
Comment:
**Missing `minimum: 0` on numeric fields**
All seven new numeric properties (`input_tokens`, `output_tokens`, `total_tokens`, `duration_ms`, `ttft_ms`, `cost`) accept negative values as written. Negative token counts, latencies, or costs are semantically invalid and would silently poison any aggregations or dashboards built on these fields.
Adding `minimum: 0` to each property enforces the invariant at the schema level and lets SDK codegen produce typed helpers with correct bounds.
```suggestion
input_tokens:
type: integer
minimum: 0
description: Number of input tokens consumed.
output_tokens:
type: integer
minimum: 0
description: Number of output tokens produced.
total_tokens:
type: integer
minimum: 0
description: Total tokens (input + output).
duration_ms:
type: integer
minimum: 0
description: End-to-end generation latency in milliseconds.
ttft_ms:
type: integer
minimum: 0
description: Time to first token in milliseconds.
cost:
type: number
format: double
minimum: 0
description: Generation cost in USD.
```
How can I resolve this? If you propose a fix, please make it concise.
Automated sync of `contract/openapi.yaml` from the monorepo.
Source commit: trylitmus/litmus@25274156c014dca5bee2a4dd236a2b947dbe6fa2
Review the diff, then merge. If the SDK has codegen (e.g. `pnpm generate`),
run it after merging to update generated types.