Skip to content

Adopt SDK parsed-document storage for chunk reads, sync, and chat assets#127

Merged
suguanYang merged 12 commits into
stagingfrom
feature/wangbinqi/notebook-parsed-document-storage
Jul 5, 2026
Merged

Adopt SDK parsed-document storage for chunk reads, sync, and chat assets#127
suguanYang merged 12 commits into
stagingfrom
feature/wangbinqi/notebook-parsed-document-storage

Conversation

@suguanYang

@suguanYang suguanYang commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates the Notebook onto the Knowhere SDK's ParsedDocumentStorage model so chunk read/display/sync and chat citation-asset hardening share one path with the SDK/CLI/MCP, replacing the hand-rolled Blob snapshot machinery.

  • Vercel-Blob ParsedDocumentStorage adapter (parsed-document-blob-storage.ts) keyed workspaces/{ws}/parsed-documents/{documentId}/{revisionKey}/… with traversal guards and an injectable blob-store seam.
  • QStash-backed resumable sync: parsed-document-sync-scheduler.ts + parsed-sync-route-workflow.ts + POST /api/sources/parsed-sync, reusing the deterministic-workflowRunId continuation pattern; loops syncParsedDocument until completed.
  • Client wiring: makeKnowhereClientWithParsedStorage configures withParsedStorage({storage, scheduler, limits}) with Vercel-safe limits.
  • Read path: route-chunks.ts delegates to knowledge.readChunks({assetUrlPolicy:"durable"}) (paged + load-all) and getDocumentOutline, via chunks/read.ts. Gating is status !== "ready" → 202, else always serve (remote fallback guarantees non-empty for ready docs).
  • Parse flow: reconcile syncs to Blob before markReady; sync failures stage as failure_stage: "storage_sync". Retry resumes the sync from the stored documentId+revisionKey without reparsing.
  • Chat: citation/media asset hardening unified onto the durable read path (media-asset-hardening.ts shrinks to owned-URL passthrough + durable-map resolution; agentic retrieval.query unchanged).
  • DB: migration 0011 adds revision_key/sync_status/sync_error to source_parse_results and failure_stage to sources; relaxes result_blob_url to nullable.
  • Deleted: chunks/server.ts, remote-parsed-snapshot-sync.ts, parse-result-storage-adapter.ts.

Also includes the page-citation-asset support commits this branch builds on.

Testing

  • pnpm typecheck — clean
  • pnpm lint — clean
  • pnpm test — 618 passed, 14 skipped
  • pnpm db:generate — confirms only 0011 added, no drift
  • Live: verified end-to-end against a local Knowhere API — materialized a demo document, then exercised the SDK remote-read → scheduler-fire → syncParsedDocument → storage-hit fast path, plus the Notebook read.ts helpers (page read, load-all, durable asset map).

Blocked / not covered

  • Full in-browser app smoke test (real Vercel Blob + QStash + pnpm dev: upload → ready → chunk panel → chat citation) not run here.

🤖 Generated with Claude Code


Companion PRs (coordinated parsed-storage rollout):

suguanYang and others added 10 commits July 3, 2026 11:34
Replace the hand-rolled Blob snapshot machinery with the SDK's
ParsedDocumentStorage: a Vercel-Blob adapter, a QStash-backed resumable
sync scheduler + /api/sources/parsed-sync route, and chunk reads routed
through knowledge.readChunks/getDocumentOutline (assetUrlPolicy:"durable").

Parse flow syncs to storage before markReady and stages sync failures as
failure_stage="storage_sync"; retry resumes sync without reparsing. Chat
citation hardening is unified onto the durable read path. Adds migration
0011 (revision_key/sync_status/sync_error on source_parse_results,
failure_stage on sources). Deletes chunks/server, remote-parsed-snapshot-sync,
and parse-result-storage-adapter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
knowhere-notebook-staging Ready Ready Preview, Comment Jul 5, 2026 7:48am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
knowhere-notebook Ignored Ignored Preview Jul 5, 2026 7:48am

Request Review

@suguanYang
suguanYang merged commit c9c6f28 into staging Jul 5, 2026
7 checks passed
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