Commit a85ae05
feat: add preview-mode ingest backend with live index proof (OSS + SaaS) (#2051)
* feat: add preview-mode ingest backend with live index proof (OSS + SaaS)
Introduce preview ingest plumbing so the frontend can show ingest progress
and verify indexed chunks without persisting Docling layout JSON.
- Add preview=true on upload router and connector sync (enabled in OSS and
SaaS via is_ingest_preview_enabled; disabled on_prem)
- Thread preview_mode through UploadTask, task service, and connector sync
- Keep completed files in /tasks/enhanced for preview tasks (multi-file carousel)
- Add GET /ingest/preview/{task_id}/index-proof to query OpenSearch live for
chunk metadata (phase, text previews, embedding model/dimensions)
- Track document_id on FileTask for index-proof lookups (set in Langflow and
connector processors before ingest)
- Wire IngestPreviewService as a stateless helper (no in-memory Docling cache)
Intentionally excludes the spike's /docling endpoint and preview-only Docling
options (embedded page images). Layout skeleton stays frontend-only; backend
serves task phase + index proof only.
Tests: API guards, index proof service, router preview threading, enhanced
task serialization for preview vs normal tasks.
* Address code-review findings on the preview ingest backend:
- Pass the validated upload_task into IngestPreviewService instead of
re-fetching from TaskService (closes preview_mode TOCTOU gap)
- Add service-level preview_mode guard and map not_preview_task to 404
- Gate index-proof endpoint with require_permission(knowledge:upload)
- Return per-request JSONResponse instances (no shared response object)
- Sort chunks by page + numeric suffix instead of lexicographic _id
- Use OpenSearch hits.total for chunk_count; expose chunks_returned and
chunks_truncated when the 200-chunk cap applies
- Return file_not_found (404) for unknown ?file= paths in multi-file tasks
- Update Langflow processor comment for document_id threading
- Expand unit tests: single-fetch regression, ordering, totals, file_not_found,
document_id threading, and non-preview rejection
* fix lint ruff
* adding a feature of flag
* address minor issues raised by Mike P
* style: ruff autofix (auto)
* ci: fail fast on runner/image architecture mismatch in integration suite
* ci: free up runner disk space before building/loading images
The move to ubuntu-latest runners (#2081) dropped available disk from the
~40GB self-hosted runners to ~14GB, so `docker load` of all four OpenRAG
images ran out of space unpacking OpenSearch ("no space left on device").
Add a step to build-images, test-suite, and e2e-run that removes the large
preinstalled toolchains these jobs never use (Android SDK, .NET, GHC,
CodeQL), reclaiming ~25GB before any image build/load.
Co-authored-by: Cursor <cursoragent@cursor.com>
* ci: scope image cache keys by runner architecture
The image cache key used only runner.os (always "Linux") plus a source
hash, with no CPU arch. After the ubuntu-latest migration (#2081) the amd64
build-images job hit the cache from earlier arm64 self-hosted runs and
restored/re-tagged stale arm64 images, shipping arm64 images to the amd64
test jobs (caught by the arch guard as a host/image mismatch).
Add runner.arch to every image cache key so amd64 and arm64 caches never
collide, forcing a native rebuild per architecture.
Co-authored-by: Cursor <cursoragent@cursor.com>
* ci: relocate Docker data-root to /mnt to fix disk exhaustion
Trimming preinstalled toolchains alone did not free enough space on the
small ubuntu-latest root filesystem (~30GB), so `docker load` of all four
OpenRAG images still hit "no space left on device". Move Docker's data-root
onto the runner's large ephemeral /mnt disk (~70GB) before building/loading
images, and additionally clear swift/powershell caches and apt lists.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix: forward explicit preview flag from v1 ingest endpoint
The public /v1/documents ingest endpoint calls upload_ingest_router directly
(not through FastAPI form parsing), so Form-defaulted params must be passed
explicitly. The new preview param was omitted, leaking the Form("false")
sentinel into `preview.lower()` and raising AttributeError -> HTTP 500 on
every SDK ingest/delete/filter call (18 sdk-python + 6 sdk-typescript
failures).
Pass preview="false" (preview is frontend-only; v1 SDK does not expose it)
and add a regression test asserting the flag is forwarded as a string.
Co-authored-by: Cursor <cursoragent@cursor.com>
* revert: drop CI runner/disk/cache workflow changes
Revert the arch-mismatch guard, disk cleanup, arch-scoped image cache keys,
and Docker data-root relocation added in this branch. The underlying CI
infrastructure issues were fixed separately in another PR, so restore
scripts/ci/run_integration_suite.sh and .github/workflows/test-ci.yml to
their pre-change state. Keeps the v1 preview ingest code fix.
Co-authored-by: Cursor <cursoragent@cursor.com>
* resolve comment 2a
---------
Co-authored-by: Olfa Maslah <olfamaslah@Olfas-MacBook-Pro.local>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 31fdf1d commit a85ae05
26 files changed
Lines changed: 1127 additions & 13 deletions
File tree
- src
- api
- v1
- app
- routes
- config
- connectors
- models
- services
- utils
- tests/unit
- api
- config
- services
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
414 | 420 | | |
415 | 421 | | |
416 | 422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
592 | 593 | | |
593 | 594 | | |
594 | 595 | | |
| 596 | + | |
| 597 | + | |
595 | 598 | | |
596 | 599 | | |
597 | 600 | | |
| |||
925 | 928 | | |
926 | 929 | | |
927 | 930 | | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
928 | 935 | | |
929 | 936 | | |
930 | 937 | | |
| |||
1052 | 1059 | | |
1053 | 1060 | | |
1054 | 1061 | | |
| 1062 | + | |
1055 | 1063 | | |
1056 | 1064 | | |
1057 | 1065 | | |
| |||
1156 | 1164 | | |
1157 | 1165 | | |
1158 | 1166 | | |
| 1167 | + | |
1159 | 1168 | | |
1160 | 1169 | | |
1161 | 1170 | | |
| |||
1168 | 1177 | | |
1169 | 1178 | | |
1170 | 1179 | | |
| 1180 | + | |
1171 | 1181 | | |
1172 | 1182 | | |
1173 | 1183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| |||
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| 63 | + | |
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
| |||
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
| 78 | + | |
70 | 79 | | |
71 | 80 | | |
72 | 81 | | |
| |||
78 | 87 | | |
79 | 88 | | |
80 | 89 | | |
| 90 | + | |
81 | 91 | | |
82 | 92 | | |
83 | 93 | | |
| |||
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
| 155 | + | |
145 | 156 | | |
146 | 157 | | |
147 | 158 | | |
| |||
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
| 165 | + | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
| |||
180 | 192 | | |
181 | 193 | | |
182 | 194 | | |
| 195 | + | |
183 | 196 | | |
184 | 197 | | |
185 | 198 | | |
| |||
251 | 264 | | |
252 | 265 | | |
253 | 266 | | |
| 267 | + | |
254 | 268 | | |
255 | 269 | | |
256 | 270 | | |
| |||
260 | 274 | | |
261 | 275 | | |
262 | 276 | | |
| 277 | + | |
263 | 278 | | |
264 | 279 | | |
265 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| 237 | + | |
235 | 238 | | |
236 | 239 | | |
237 | 240 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
77 | 86 | | |
78 | 87 | | |
79 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
293 | 305 | | |
294 | 306 | | |
295 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
475 | 478 | | |
476 | 479 | | |
477 | 480 | | |
| |||
485 | 488 | | |
486 | 489 | | |
487 | 490 | | |
| 491 | + | |
488 | 492 | | |
489 | 493 | | |
490 | 494 | | |
| |||
662 | 666 | | |
663 | 667 | | |
664 | 668 | | |
665 | | - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
666 | 674 | | |
667 | 675 | | |
668 | 676 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
| |||
0 commit comments