Skip to content

[Feat] Serve the knowledge base in Open Knowledge Format (OKF)#1617

Merged
MODSetter merged 17 commits into
MODSetter:devfrom
CREDO23:feature-okf
Jul 21, 2026
Merged

[Feat] Serve the knowledge base in Open Knowledge Format (OKF)#1617
MODSetter merged 17 commits into
MODSetter:devfrom
CREDO23:feature-okf

Conversation

@CREDO23

@CREDO23 CREDO23 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes the knowledge base natively serve Google's Open Knowledge Format (OKF v0.1), while keeping storage and the search index unchanged.

  • KB as OKF concepts — each Document serializes to a concept (YAML frontmatter derived from its columns, never stored); folders get index.md, exports get log.md, so the ZIP export is a full OKF bundle.
  • Content negotiationGET /documents/{id} returns the OKF concept for Accept: text/markdown, JSON otherwise. One endpoint, no separate path. MCP get_document consumes it.
  • Decoupled — OKF lives in a pure app/services/okf/ package (serializer, type mapping, validator); storage stays the source of truth, chunks/embeddings remain a derived, rebuildable index.

Test plan

  • Unit: per-type conformance, serializer self-checks, ingestion, bundle audit
  • Integration (real DB): export bundle validates, content-negotiated read, path-identity round-trip
  • MCP round-trip: get_document forwards Accept: text/markdown
  • Full backend suite: no regressions from these changes

High-level PR Summary

This PR makes the knowledge base natively serve Google's Open Knowledge Format (OKF v0.1) by implementing a pure serialization layer that converts documents to OKF concepts on-the-fly. The implementation adds content negotiation to the GET /documents/{id} endpoint (returning OKF concepts for Accept: text/markdown, JSON otherwise), builds OKF-compliant ZIP exports with index.md and log.md files, and ensures path identity for concept resolution. Storage remains unchanged as frontmatter is derived from document columns rather than stored, keeping OKF as a read-time view layer while the database stays the source of truth.

⏱️ Estimated Review Time: 30-90 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/app/services/okf/__init__.py
2 surfsense_backend/app/services/okf/type_mapping.py
3 surfsense_backend/app/services/okf/serializer.py
4 surfsense_backend/app/services/okf/validator.py
5 surfsense_backend/tests/unit/services/okf/test_conformance.py
6 surfsense_backend/tests/unit/services/okf/test_serializer.py
7 surfsense_backend/tests/unit/services/okf/test_ingestion.py
8 surfsense_backend/tests/unit/services/okf/test_audit.py
9 surfsense_backend/app/services/export_service.py
10 surfsense_backend/app/routes/documents_routes.py
11 surfsense_backend/tests/integration/test_okf_export_bundle.py
12 surfsense_backend/tests/integration/document_upload/test_okf_read.py
13 surfsense_backend/tests/integration/test_okf_path_identity.py
14 surfsense_backend/tests/unit/agents/new_chat/test_path_resolver.py
15 surfsense_mcp/mcp_server/core/client.py
16 surfsense_mcp/mcp_server/features/knowledge_base/search_tools.py
17 surfsense_mcp/tests/test_get_document_okf.py

Need help? Join our Discord

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

@CREDO23 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 55c4615c-d3cf-4e22-a04f-38d57380f6a8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CREDO23 CREDO23 changed the title [Feat] OKF-native knowledge base [Feat] Serve the knowledge base in Open Knowledge Format (OKF) Jul 21, 2026
@MODSetter
MODSetter merged commit 08d4314 into MODSetter:dev Jul 21, 2026
6 of 12 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.

2 participants