graph-knowledge-doc-parser 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. graph_knowledge_doc_parser-0.1.0.dist-info/METADATA +326 -0
  2. graph_knowledge_doc_parser-0.1.0.dist-info/RECORD +38 -0
  3. graph_knowledge_doc_parser-0.1.0.dist-info/WHEEL +4 -0
  4. graph_knowledge_doc_parser-0.1.0.dist-info/entry_points.txt +3 -0
  5. kg_doc_parser/__init__.py +9 -0
  6. kg_doc_parser/cast_hinting.py +19 -0
  7. kg_doc_parser/document_ingester_logger.py +766 -0
  8. kg_doc_parser/models.py +277 -0
  9. kg_doc_parser/ocr.py +752 -0
  10. kg_doc_parser/pdf2png.py +286 -0
  11. kg_doc_parser/semantic_document_splitting_layerwise_edits.py +3302 -0
  12. kg_doc_parser/text_processing_utils.py +30 -0
  13. kg_doc_parser/utils/__init__.py +0 -0
  14. kg_doc_parser/utils/bounded_threadpool_executor.py +37 -0
  15. kg_doc_parser/utils/file_loaders.py +405 -0
  16. kg_doc_parser/utils/langchain.py +220 -0
  17. kg_doc_parser/utils/log.py +135 -0
  18. kg_doc_parser/utils/version_chaining.py +1278 -0
  19. kg_doc_parser/workflow_ingest/__init__.py +187 -0
  20. kg_doc_parser/workflow_ingest/_kogwistar.py +13 -0
  21. kg_doc_parser/workflow_ingest/adapters.py +212 -0
  22. kg_doc_parser/workflow_ingest/cache.py +63 -0
  23. kg_doc_parser/workflow_ingest/cli.py +324 -0
  24. kg_doc_parser/workflow_ingest/clients.py +444 -0
  25. kg_doc_parser/workflow_ingest/demo_harness.py +427 -0
  26. kg_doc_parser/workflow_ingest/design.py +208 -0
  27. kg_doc_parser/workflow_ingest/handlers.py +617 -0
  28. kg_doc_parser/workflow_ingest/models.py +575 -0
  29. kg_doc_parser/workflow_ingest/ocr_pipeline.py +1581 -0
  30. kg_doc_parser/workflow_ingest/page_index.py +473 -0
  31. kg_doc_parser/workflow_ingest/parser_core.py +862 -0
  32. kg_doc_parser/workflow_ingest/parsing.py +249 -0
  33. kg_doc_parser/workflow_ingest/probe.py +164 -0
  34. kg_doc_parser/workflow_ingest/providers.py +412 -0
  35. kg_doc_parser/workflow_ingest/runners.py +546 -0
  36. kg_doc_parser/workflow_ingest/semantics.py +231 -0
  37. kg_doc_parser/workflow_ingest/service.py +112 -0
  38. kg_doc_parser/workflow_ingest/smoke_assets.py +62 -0
@@ -0,0 +1,575 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Annotated, Any, ClassVar, Literal, Optional
4
+
5
+ from pydantic import BaseModel, Field, model_validator
6
+ from pydantic_extension.model_slicing import BackendField, FrontendField
7
+ from pydantic_extension.model_slicing.mixin import DtoField, ExcludeMode, LLMField, ModeSlicingMixin
8
+
9
+ from .semantics import HydratedTextPointer
10
+
11
+
12
+ class BoundingBox(ModeSlicingMixin, BaseModel):
13
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
14
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
15
+
16
+ y_min: Annotated[float, DtoField(), BackendField(), FrontendField(), LLMField()]
17
+ x_min: Annotated[float, DtoField(), BackendField(), FrontendField(), LLMField()]
18
+ y_max: Annotated[float, DtoField(), BackendField(), FrontendField(), LLMField()]
19
+ x_max: Annotated[float, DtoField(), BackendField(), FrontendField(), LLMField()]
20
+
21
+
22
+ class SourceUnit(ModeSlicingMixin, BaseModel):
23
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
24
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
25
+
26
+ unit_id: Annotated[Optional[str], DtoField(), BackendField(), FrontendField()] = None
27
+ modality: Annotated[
28
+ Literal["text", "ocr_text", "non_text", "image_region", "pure_image"],
29
+ DtoField(),
30
+ BackendField(),
31
+ FrontendField(),
32
+ LLMField(),
33
+ ]
34
+ page_number: Annotated[Optional[int], DtoField(), BackendField(), FrontendField(), LLMField()] = None
35
+ cluster_number: Annotated[Optional[int], DtoField(), BackendField(), FrontendField()] = None
36
+ text: Annotated[Optional[str], DtoField(), BackendField(), FrontendField(), LLMField()] = None
37
+ description: Annotated[Optional[str], DtoField(), BackendField(), FrontendField(), LLMField()] = None
38
+ bbox: Annotated[Optional[BoundingBox], DtoField(), BackendField(), FrontendField(), LLMField()] = None
39
+ source_uri: Annotated[Optional[str], DtoField(), BackendField(), FrontendField()] = None
40
+ # This is a logical embedding-space label, not a guarantee that a separate
41
+ # embedder is already wired for the unit.
42
+ embedding_space: Annotated[str, DtoField(), BackendField(), FrontendField(), ExcludeMode("llm")] = "default_text"
43
+ parser_hint_text: Annotated[
44
+ Optional[str],
45
+ DtoField(),
46
+ BackendField(),
47
+ FrontendField(),
48
+ ExcludeMode("llm"),
49
+ ] = None
50
+ metadata: Annotated[
51
+ dict[str, Any],
52
+ DtoField(),
53
+ BackendField(),
54
+ FrontendField(),
55
+ ExcludeMode("llm"),
56
+ ] = Field(default_factory=dict)
57
+
58
+ @model_validator(mode="after")
59
+ def _check_content(self) -> "SourceUnit":
60
+ if self.modality in {"text", "ocr_text"} and not (self.text and self.text.strip()):
61
+ raise ValueError(f"{self.modality} units require non-empty text")
62
+ if self.modality in {"non_text", "image_region", "pure_image"} and not (
63
+ (self.description and self.description.strip()) or self.source_uri
64
+ ):
65
+ raise ValueError(f"{self.modality} units require description or source_uri")
66
+ return self
67
+
68
+ @property
69
+ def parser_text(self) -> str:
70
+ if self.parser_hint_text:
71
+ return self.parser_hint_text
72
+ if self.text:
73
+ return self.text
74
+ if self.description:
75
+ return self.description
76
+ return ""
77
+
78
+
79
+ class NormalizedPage(ModeSlicingMixin, BaseModel):
80
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
81
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
82
+
83
+ page_number: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
84
+ units: Annotated[list[SourceUnit], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
85
+ metadata: Annotated[
86
+ dict[str, Any],
87
+ DtoField(),
88
+ BackendField(),
89
+ FrontendField(),
90
+ ExcludeMode("llm"),
91
+ ] = Field(default_factory=dict)
92
+
93
+
94
+ class NormalizedSourceCollection(ModeSlicingMixin, BaseModel):
95
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
96
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
97
+
98
+ collection_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
99
+ title: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
100
+ modality: Annotated[Literal["text", "ocr", "multimodal"], DtoField(), BackendField(), FrontendField(), LLMField()]
101
+ pages: Annotated[list[NormalizedPage], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
102
+ embedding_spaces: Annotated[
103
+ list[str],
104
+ DtoField(),
105
+ BackendField(),
106
+ FrontendField(),
107
+ ExcludeMode("llm"),
108
+ ] = Field(default_factory=lambda: ["default_text"])
109
+ metadata: Annotated[
110
+ dict[str, Any],
111
+ DtoField(),
112
+ BackendField(),
113
+ FrontendField(),
114
+ ExcludeMode("llm"),
115
+ ] = Field(default_factory=dict)
116
+
117
+ @model_validator(mode="after")
118
+ def _check_pages(self) -> "NormalizedSourceCollection":
119
+ if not self.pages:
120
+ raise ValueError("collection must include at least one page")
121
+ return self
122
+
123
+
124
+ class WorkflowIngestInput(ModeSlicingMixin, BaseModel):
125
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
126
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
127
+
128
+ request_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()] = "ingest-request"
129
+ collections: Annotated[list[NormalizedSourceCollection], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
130
+ metadata: Annotated[
131
+ dict[str, Any],
132
+ DtoField(),
133
+ BackendField(),
134
+ FrontendField(),
135
+ ExcludeMode("llm"),
136
+ ] = Field(default_factory=dict)
137
+
138
+ @model_validator(mode="after")
139
+ def _check_collections(self) -> "WorkflowIngestInput":
140
+ if not self.collections:
141
+ raise ValueError("at least one collection is required")
142
+ return self
143
+
144
+ @classmethod
145
+ def from_text(cls, *, document_id: str, text: str, title: Optional[str] = None) -> "WorkflowIngestInput":
146
+ return cls(
147
+ request_id=document_id,
148
+ collections=[
149
+ NormalizedSourceCollection(
150
+ collection_id=document_id,
151
+ title=title or document_id,
152
+ modality="text",
153
+ pages=[
154
+ NormalizedPage(
155
+ page_number=1,
156
+ units=[SourceUnit(modality="text", text=text, page_number=1, cluster_number=0)],
157
+ )
158
+ ],
159
+ )
160
+ ],
161
+ )
162
+
163
+
164
+ class GroundedSourceRecord(ModeSlicingMixin, BaseModel):
165
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
166
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
167
+
168
+ unit_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
169
+ collection_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
170
+ modality: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
171
+ page_number: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
172
+ cluster_number: Annotated[Optional[int], DtoField(), BackendField(), FrontendField()] = None
173
+ text: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
174
+ parser_text: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
175
+ source_uri: Annotated[Optional[str], DtoField(), BackendField(), FrontendField()] = None
176
+ # This is carried for future routing / projection. The current engine still
177
+ # uses one configured embedding function per engine instance.
178
+ embedding_space: Annotated[str, DtoField(), BackendField(), FrontendField(), ExcludeMode("llm")] = "default_text"
179
+ participates_in_semantic_text: Annotated[
180
+ bool,
181
+ DtoField(),
182
+ BackendField(),
183
+ FrontendField(),
184
+ ExcludeMode("llm"),
185
+ ] = True
186
+ bbox: Annotated[Optional[BoundingBox], DtoField(), BackendField(), FrontendField(), LLMField()] = None
187
+ metadata: Annotated[
188
+ dict[str, Any],
189
+ DtoField(),
190
+ BackendField(),
191
+ FrontendField(),
192
+ ExcludeMode("llm"),
193
+ ] = Field(default_factory=dict)
194
+
195
+
196
+ class ValidationReport(ModeSlicingMixin, BaseModel):
197
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
198
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
199
+
200
+ overall_text_coverage: Annotated[float, DtoField(), BackendField(), FrontendField(), LLMField()]
201
+ per_cluster_coverage: Annotated[dict[str, float], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=dict)
202
+ corrected_pointer_count: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
203
+ validation_notes: Annotated[list[str], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
204
+
205
+
206
+ class ParseSessionState(ModeSlicingMixin, BaseModel):
207
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
208
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
209
+
210
+ collection_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
211
+ root_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
212
+ current_depth: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
213
+ max_depth: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 10
214
+ allow_review: Annotated[bool, DtoField(), BackendField(), FrontendField(), LLMField()] = True
215
+ split_strategy: Annotated[
216
+ Literal["excerpt_first", "boundary_first"],
217
+ DtoField(),
218
+ BackendField(),
219
+ FrontendField(),
220
+ LLMField(),
221
+ ] = "excerpt_first"
222
+ fallback_split_strategy: Annotated[
223
+ Literal["excerpt_first", "boundary_first"],
224
+ DtoField(),
225
+ BackendField(),
226
+ FrontendField(),
227
+ LLMField(),
228
+ ] = "boundary_first"
229
+ strategy_history: Annotated[
230
+ list[Literal["excerpt_first", "boundary_first"]],
231
+ DtoField(),
232
+ BackendField(),
233
+ FrontendField(),
234
+ ExcludeMode("llm"),
235
+ ] = Field(default_factory=lambda: ["excerpt_first"])
236
+ strategy_switch_count: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
237
+ mode: Annotated[
238
+ Literal["workflow_layered", "legacy_compat"],
239
+ DtoField(),
240
+ BackendField(),
241
+ FrontendField(),
242
+ LLMField(),
243
+ ] = "workflow_layered"
244
+ layer_attempts: Annotated[
245
+ dict[str, int],
246
+ DtoField(),
247
+ BackendField(),
248
+ FrontendField(),
249
+ ExcludeMode("llm"),
250
+ ] = Field(default_factory=dict)
251
+ compat_full_tree: Annotated[
252
+ Optional[dict[str, Any]],
253
+ DtoField(),
254
+ BackendField(),
255
+ FrontendField(),
256
+ ExcludeMode("llm"),
257
+ ] = None
258
+ metadata: Annotated[
259
+ dict[str, Any],
260
+ DtoField(),
261
+ BackendField(),
262
+ FrontendField(),
263
+ ExcludeMode("llm"),
264
+ ] = Field(default_factory=dict)
265
+
266
+
267
+ class LayerFrontierItem(ModeSlicingMixin, BaseModel):
268
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
269
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
270
+
271
+ parent_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
272
+ depth: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
273
+ order: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
274
+
275
+
276
+ class LayerSpanConflict(ModeSlicingMixin, BaseModel):
277
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
278
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
279
+
280
+ parent_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
281
+ left_child_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
282
+ right_child_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
283
+ source_cluster_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
284
+ left_span: Annotated[HydratedTextPointer, DtoField(), BackendField(), FrontendField(), LLMField()]
285
+ right_span: Annotated[HydratedTextPointer, DtoField(), BackendField(), FrontendField(), LLMField()]
286
+ overlap_start: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
287
+ overlap_end: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
288
+ conflict_kind: Annotated[
289
+ Literal["overlap", "duplicate"],
290
+ DtoField(),
291
+ BackendField(),
292
+ FrontendField(),
293
+ LLMField(),
294
+ ] = "overlap"
295
+
296
+
297
+ class LayerCoverageGap(ModeSlicingMixin, BaseModel):
298
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
299
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
300
+
301
+ parent_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
302
+ source_cluster_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
303
+ gap_start: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
304
+ gap_end: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
305
+ expected_text: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()] = ""
306
+
307
+
308
+ class LayerDuplicateChildNote(ModeSlicingMixin, BaseModel):
309
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
310
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
311
+
312
+ parent_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
313
+ child_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
314
+ duplicate_of_child_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
315
+ reason: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
316
+
317
+
318
+ class LayerChildCandidate(ModeSlicingMixin, BaseModel):
319
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
320
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
321
+
322
+ node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
323
+ parent_node_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
324
+ title: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
325
+ node_type: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
326
+ total_content_pointers: Annotated[
327
+ list[HydratedTextPointer],
328
+ DtoField(),
329
+ BackendField(),
330
+ FrontendField(),
331
+ LLMField(),
332
+ ] = Field(default_factory=list)
333
+ expandable: Annotated[bool, DtoField(), BackendField(), FrontendField(), LLMField()] = True
334
+ metadata: Annotated[
335
+ dict[str, Any],
336
+ DtoField(),
337
+ BackendField(),
338
+ FrontendField(),
339
+ ExcludeMode("llm"),
340
+ ] = Field(default_factory=dict)
341
+
342
+
343
+ class CurrentLayerContext(ModeSlicingMixin, BaseModel):
344
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
345
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
346
+
347
+ depth: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()]
348
+ parent_node_ids: Annotated[list[str], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
349
+ parent_titles: Annotated[list[str], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
350
+ parent_content_pointers_by_id: Annotated[
351
+ dict[str, list[HydratedTextPointer]],
352
+ DtoField(),
353
+ BackendField(),
354
+ FrontendField(),
355
+ LLMField(),
356
+ ] = Field(default_factory=dict)
357
+ split_strategy: Annotated[
358
+ Literal["excerpt_first", "boundary_first"],
359
+ DtoField(),
360
+ BackendField(),
361
+ FrontendField(),
362
+ LLMField(),
363
+ ] = "excerpt_first"
364
+ retry_count: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
365
+ max_retries: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 3
366
+ metadata: Annotated[
367
+ dict[str, Any],
368
+ DtoField(),
369
+ BackendField(),
370
+ FrontendField(),
371
+ ExcludeMode("llm"),
372
+ ] = Field(default_factory=dict)
373
+
374
+
375
+ class CurrentLayerResult(ModeSlicingMixin, BaseModel):
376
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
377
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
378
+
379
+ children: Annotated[list[LayerChildCandidate], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
380
+ satisfied: Annotated[Optional[bool], DtoField(), BackendField(), FrontendField(), LLMField()] = None
381
+ reasoning_history: Annotated[list[dict[str, Any]], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(default_factory=list)
382
+ review_rounds: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
383
+ metadata: Annotated[
384
+ dict[str, Any],
385
+ DtoField(),
386
+ BackendField(),
387
+ FrontendField(),
388
+ ExcludeMode("llm"),
389
+ ] = Field(default_factory=dict)
390
+
391
+
392
+ class CurrentLayerReview(ModeSlicingMixin, BaseModel):
393
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
394
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
395
+
396
+ updated_result: Annotated[
397
+ Optional[CurrentLayerResult],
398
+ DtoField(),
399
+ BackendField(),
400
+ FrontendField(),
401
+ LLMField(),
402
+ ] = None
403
+ coverage_ok: Annotated[Optional[bool], DtoField(), BackendField(), FrontendField(), LLMField()] = None
404
+ satisfied: Annotated[Optional[bool], DtoField(), BackendField(), FrontendField(), LLMField()] = None
405
+ strategy_used: Annotated[
406
+ Literal["excerpt_first", "boundary_first"],
407
+ DtoField(),
408
+ BackendField(),
409
+ FrontendField(),
410
+ LLMField(),
411
+ ] = "excerpt_first"
412
+ overlap_conflicts: Annotated[list[LayerSpanConflict], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(
413
+ default_factory=list
414
+ )
415
+ coverage_gap_notes: Annotated[list[LayerCoverageGap], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(
416
+ default_factory=list
417
+ )
418
+ duplicate_child_notes: Annotated[
419
+ list[LayerDuplicateChildNote],
420
+ DtoField(),
421
+ BackendField(),
422
+ FrontendField(),
423
+ LLMField(),
424
+ ] = Field(default_factory=list)
425
+ review_notes: Annotated[list[str], DtoField(), BackendField(), FrontendField(), LLMField()] = Field(
426
+ default_factory=list
427
+ )
428
+ metadata: Annotated[
429
+ dict[str, Any],
430
+ DtoField(),
431
+ BackendField(),
432
+ FrontendField(),
433
+ ExcludeMode("llm"),
434
+ ] = Field(default_factory=dict)
435
+
436
+
437
+ class CanonicalGraphWriteResult(ModeSlicingMixin, BaseModel):
438
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
439
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
440
+
441
+ persistence_mode: Annotated[
442
+ Literal["local_debug", "server_canonical"],
443
+ DtoField(),
444
+ BackendField(),
445
+ FrontendField(),
446
+ LLMField(),
447
+ ]
448
+ kg_authority: Annotated[
449
+ Literal["local", "server"],
450
+ DtoField(),
451
+ BackendField(),
452
+ FrontendField(),
453
+ LLMField(),
454
+ ]
455
+ canonical_write_confirmed: Annotated[bool, DtoField(), BackendField(), FrontendField(), LLMField()] = False
456
+ nodes_written: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
457
+ edges_written: Annotated[int, DtoField(), BackendField(), FrontendField(), LLMField()] = 0
458
+ transport: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()] = "direct_runtime"
459
+ server_parser_used: Annotated[bool, DtoField(), BackendField(), FrontendField(), LLMField()] = False
460
+ error: Annotated[Optional[str], DtoField(), BackendField(), FrontendField(), LLMField()] = None
461
+
462
+
463
+ class WorkflowExportBundle(ModeSlicingMixin, BaseModel):
464
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
465
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
466
+
467
+ graph_payload: Annotated[dict[str, Any], DtoField(), BackendField(), FrontendField(), LLMField()]
468
+ authoritative_source_map: Annotated[
469
+ dict[str, GroundedSourceRecord],
470
+ DtoField(),
471
+ BackendField(),
472
+ FrontendField(),
473
+ ExcludeMode("llm"),
474
+ ]
475
+ embedding_spaces: Annotated[list[str], DtoField(), BackendField(), FrontendField(), ExcludeMode("llm")] = Field(default_factory=list)
476
+ consolidation_candidates: Annotated[
477
+ list[dict[str, Any]],
478
+ DtoField(),
479
+ BackendField(),
480
+ FrontendField(),
481
+ ExcludeMode("llm"),
482
+ ] = Field(default_factory=list)
483
+ retrieval_metadata: Annotated[
484
+ dict[str, Any],
485
+ DtoField(),
486
+ BackendField(),
487
+ FrontendField(),
488
+ ExcludeMode("llm"),
489
+ ] = Field(default_factory=dict)
490
+ persistence_mode: Annotated[
491
+ Literal["local_debug", "server_canonical"],
492
+ DtoField(),
493
+ BackendField(),
494
+ FrontendField(),
495
+ LLMField(),
496
+ ] = "local_debug"
497
+ kg_authority: Annotated[
498
+ Literal["local", "server"],
499
+ DtoField(),
500
+ BackendField(),
501
+ FrontendField(),
502
+ LLMField(),
503
+ ] = "local"
504
+ canonical_write_confirmed: Annotated[
505
+ bool,
506
+ DtoField(),
507
+ BackendField(),
508
+ FrontendField(),
509
+ LLMField(),
510
+ ] = False
511
+ parser_owner: Annotated[
512
+ Literal["local"],
513
+ DtoField(),
514
+ BackendField(),
515
+ FrontendField(),
516
+ LLMField(),
517
+ ] = "local"
518
+ server_parser_used: Annotated[
519
+ bool,
520
+ DtoField(),
521
+ BackendField(),
522
+ FrontendField(),
523
+ LLMField(),
524
+ ] = False
525
+ canonical_write_result: Annotated[
526
+ Optional[CanonicalGraphWriteResult],
527
+ DtoField(),
528
+ BackendField(),
529
+ FrontendField(),
530
+ LLMField(),
531
+ ] = None
532
+ persisted_to_knowledge_engine: Annotated[
533
+ bool,
534
+ DtoField(),
535
+ BackendField(),
536
+ FrontendField(),
537
+ ExcludeMode("llm"),
538
+ ] = False
539
+
540
+
541
+ class IngestRunHandle(ModeSlicingMixin, BaseModel):
542
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
543
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
544
+
545
+ run_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
546
+ workflow_id: Annotated[str, DtoField(), BackendField(), FrontendField(), LLMField()]
547
+ execution_mode: Annotated[
548
+ Literal["direct_runtime", "server_canonical_client"],
549
+ DtoField(),
550
+ BackendField(),
551
+ FrontendField(),
552
+ LLMField(),
553
+ ]
554
+
555
+
556
+ class IngestRunResult(ModeSlicingMixin, BaseModel):
557
+ default_include_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
558
+ include_unmarked_for_modes: ClassVar[set[str]] = {"dto", "backend", "frontend", "llm"}
559
+
560
+ handle: Annotated[IngestRunHandle, DtoField(), BackendField(), FrontendField(), LLMField()]
561
+ status: Annotated[
562
+ Literal["succeeded", "failed", "failure", "suspended"],
563
+ DtoField(),
564
+ BackendField(),
565
+ FrontendField(),
566
+ LLMField(),
567
+ ]
568
+ bundle: Annotated[Optional[WorkflowExportBundle], DtoField(), BackendField(), FrontendField(), LLMField()] = None
569
+ final_state: Annotated[
570
+ dict[str, Any],
571
+ DtoField(),
572
+ BackendField(),
573
+ FrontendField(),
574
+ ExcludeMode("llm"),
575
+ ] = Field(default_factory=dict)