Skip to content

chore: sync OpenAPI contract#2

Closed
JasonLovesDoggo wants to merge 1 commit into
mainfrom
contract-sync/25274156
Closed

chore: sync OpenAPI contract#2
JasonLovesDoggo wants to merge 1 commit into
mainfrom
contract-sync/25274156

Conversation

@JasonLovesDoggo
Copy link
Copy Markdown
Member

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.

Source commit: trylitmus/litmus@25274156c014dca5bee2a4dd236a2b947dbe6fa2
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 17, 2026

Greptile Summary

This PR syncs the OpenAPI contract from the monorepo, adding the $sessionend event type (with clear documentation distinguishing it from $abandon) and seven new generation-metadata fields — model, provider, input_tokens, output_tokens, total_tokens, duration_ms, ttft_ms, and cost — to the Event schema. The changes are well-documented and structurally sound; the only suggestion is adding minimum: 0 to the numeric fields to prevent semantically invalid negative values from being accepted.

Confidence Score: 5/5

Safe to merge; the only finding is a P2 suggestion to add minimum: 0 constraints on numeric fields.

All changes are additive (new fields and a new event type), backward-compatible, and well-documented. The single finding is a style/best-practice suggestion that doesn't block correctness or break existing consumers.

No files require special attention beyond the optional minimum: 0 suggestion in contract/openapi.yaml.

Important Files Changed

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)"
Loading
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

Comment thread contract/openapi.yaml
Comment on lines +144 to +162
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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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.

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