Skip to content

Commit 7a3705d

Browse files
authored
Merge pull request #2004 from tisnik/lcore-1404-database-and-compaction-models
LCORE-1404: database and compaction models
2 parents 19d6a85 + ab516bf commit 7a3705d

5 files changed

Lines changed: 149 additions & 7 deletions

File tree

Makefile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,41 +191,52 @@ generate-documentation: ## Generate documentation
191191
doc: ## Generate documentation for developers
192192
scripts/gen_doc.py
193193

194-
docs/models: docs/models/requests.puml docs/models/responses.puml docs/models/common.puml ## Generate documentation about models
194+
docs/models: docs/models/requests.puml docs/models/responses.puml docs/models/database.puml docs/models/common.puml ## Generate documentation about models
195195

196-
docs/models/requests.puml:
196+
docs/models/requests.puml: ## Generate PlantUML class diagram for requests data models
197197
uv run pyreverse src/models/api/requests/ --output puml --output-directory=docs/models/
198198
mv docs/models/classes.puml docs/models/requests.puml
199199

200-
docs/models/responses.puml:
200+
docs/models/responses.puml: ## Generate PlantUML class diagram for responses data models
201201
uv run pyreverse src/models/api/responses/ --output puml --output-directory=docs/models/
202202
mv docs/models/classes.puml docs/models/responses.puml
203203

204-
docs/models/common.puml:
204+
docs/models/common.puml: ## Generate PlantUML class diagram for common data models
205205
uv run pyreverse src/models/common/ --output puml --output-directory=docs/models/
206206
mv docs/models/classes.puml docs/models/common.puml
207207

208-
docs/models/requests.svg: docs/models/requests.puml
208+
docs/models/database.puml: ## Generate PlantUML class diagram for database data models
209+
uv run pyreverse src/models/database/ --output puml --output-directory=docs/models/
210+
mv docs/models/classes.puml docs/models/database.puml
211+
212+
docs/models/requests.svg: docs/models/requests.puml ## Generate an SVG with requests data models
209213
pushd docs/models && \
210214
java -jar ${PATH_TO_PLANTUML}/plantuml.jar requests.puml -tsvg && \
211215
xmllint --format classes.svg > requests.svg && \
212216
rm -f classes.svg && \
213217
popd
214218

215-
docs/models/responses.svg: docs/models/responses.puml
219+
docs/models/responses.svg: docs/models/responses.puml ## Generate an SVG with responses data models
216220
pushd docs/models && \
217221
java -jar ${PATH_TO_PLANTUML}/plantuml.jar responses.puml -tsvg && \
218222
xmllint --format classes.svg > responses.svg && \
219223
rm -f classes.svg && \
220224
popd
221225

222-
docs/models/common.svg: docs/models/common.puml
226+
docs/models/common.svg: docs/models/common.puml ## Generate an SVG with common data models
223227
pushd docs/models && \
224228
java -jar ${PATH_TO_PLANTUML}/plantuml.jar common.puml -tsvg && \
225229
xmllint --format classes.svg > common.svg && \
226230
rm -f classes.svg && \
227231
popd
228232

233+
docs/models/database.svg: docs/models/database.puml ## Generate a SVG with database data models
234+
pushd docs/models && \
235+
java -jar ${PATH_TO_PLANTUML}/plantuml.jar database.puml -tsvg && \
236+
xmllint --format classes.svg > database.svg && \
237+
rm -f classes.svg && \
238+
popd
239+
229240
docs/config.puml: src/models/config.py ## Generate PlantUML class diagram for configuration
230241
uv run pyreverse src/models/config.py --output puml --output-directory=docs/
231242
mv docs/classes.puml docs/config.puml

docs/models/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Documentation for all data models used in LCore
2+

docs/models/compaction.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Lightspeed Core Stack
2+
3+
4+
5+
## 🌍 Base URL
6+
7+
8+
| URL | Description |
9+
|-----|-------------|
10+
11+
12+
# 🛠️ APIs
13+
14+
---
15+
16+
# 📋 Components
17+
18+
19+
20+
## ConversationSummary
21+
22+
23+
A single compaction-produced summary chunk.
24+
25+
Attributes:
26+
summary_text: The natural-language summary produced by the
27+
summarization LLM call. Used directly as context for
28+
subsequent requests (alongside any later summary chunks
29+
and the buffer of recent turns kept verbatim).
30+
summarized_through_turn: Running total of conversation items
31+
consumed by this and all preceding summaries. Used by the
32+
caller to advance the partition boundary on the next
33+
compaction so the new summary only covers items that
34+
have not yet been summarized.
35+
token_count: Number of tokens in ``summary_text``. Tracked so
36+
the recursive-resummarize fallback can decide when the
37+
cumulative summary size itself approaches the context
38+
limit without re-tokenizing.
39+
created_at: ISO 8601 timestamp recording when this summary was
40+
produced. Kept as a string (not datetime) to match the
41+
cache schema convention used elsewhere in the codebase.
42+
model_used: Fully-qualified model identifier used for the
43+
summarization LLM call (e.g., ``"openai/gpt-4o-mini"``).
44+
Preserved for audit and for diagnostics when summary
45+
quality varies between models.
46+
47+
48+
| Field | Type | Description |
49+
|-------|------|-------------|
50+
| summary_text | string | Natural-language summary produced by the summarization LLM call. |
51+
| summarized_through_turn | integer | Running total of conversation items consumed by this and all preceding summaries. |
52+
| token_count | integer | Number of tokens in summary_text. |
53+
| created_at | string | ISO 8601 timestamp recording when this summary was produced. |
54+
| model_used | string | Fully-qualified model identifier used for the summarization call. |

docs/models/database.puml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@startuml classes
2+
set namespaceSeparator none
3+
class "Base" as src.models.database.base.Base {
4+
}
5+
class "UserConversation" as src.models.database.conversations.UserConversation {
6+
created_at : Mapped[datetime]
7+
id : Mapped[str]
8+
last_message_at : Mapped[datetime]
9+
last_response_id : Mapped[str]
10+
last_used_model : Mapped[str]
11+
last_used_provider : Mapped[str]
12+
message_count : Mapped[int]
13+
topic_summary : Mapped[str]
14+
user_id : Mapped[str]
15+
}
16+
class "UserTurn" as src.models.database.conversations.UserTurn {
17+
completed_at : Mapped[datetime]
18+
conversation_id : Mapped[str]
19+
model : Mapped[str]
20+
provider : Mapped[str]
21+
response_id : Mapped[str]
22+
started_at : Mapped[datetime]
23+
turn_number : Mapped[int]
24+
}
25+
@enduml

docs/models/database.svg

Lines changed: 50 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)