Skip to content

feat(v2): implement Canonical Model and Provider SPI (Sub-Project 1) - #27

Open
adityak74 wants to merge 10 commits into
mainfrom
canonical-model-provider-spi
Open

feat(v2): implement Canonical Model and Provider SPI (Sub-Project 1)#27
adityak74 wants to merge 10 commits into
mainfrom
canonical-model-provider-spi

Conversation

@adityak74

@adityak74 adityak74 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR implements Sub-Project 1: Canonical Model & Provider SPI as part of the Open Context 2.0 architecture rewrite. It establishes the strict, deterministic data plane and the unified storage backend contracts while ensuring 100% backward compatibility for all existing 1.x MCP operations.

Key Highlights

  • Monorepo Scaffolding: Configured npm workspaces and introduced @opencontext/core and @opencontext/provider-sdk packages.
  • Canonical Model & Identity: Implemented the CanonicalContext specification with 80-bit randomized, strictly monotonic ULIDs and deterministic SHA-256 object hashing.
  • Provider SPI Contracts: Established the unified ContextStore capability contract with built-in multitenancy isolation and robust, type-safe error structures.
  • Dual-Layer Backward Compatibility: Shipped the ContextStoreV1Shim which acts as a virtual translation layer, allowing all 11 legacy MCP tools to seamlessly run against the new v2 engines with zero regressions.
  • First-Party Storage Engines:
    • MemoryContextStore: Thread-safe, highly concurrent in-memory store.
    • JsonContextStore: Atomic, file-backed JSON serialization store.
    • SqlContextStore: Multi-dialect SQL mapping with implemented SqliteDialect (using zero-dependency node:sqlite) and PostgresDialect.
  • Universal DSN Loader: Re-wired the StoreManager to dynamically load engines via DSN (memory://, json://tmp/ctx.json, sqlite://:memory:).
  • Concurrency Safety: Full support for revision-based Optimistic Concurrency Control (OCC) across all engines.

Testing & Validation

  • Added an exhaustive cross-provider integration suite (tests/integration/providers-consistency.test.ts) that mutates, queries, and filters the exact same context datasets across the Memory, JSON, and SQLite providers to verify bit-for-bit structural consistency.
  • 480/480 tests passing. Output is pristine.

Notes for Reviewers

While this PR introduces the new native v2 MCP tools (save_canonical_context, query_canonical_context), legacy 1.x tools remain the default until the ecosystem fully migrates.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploying open-context with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6316acd
Status: ✅  Deploy successful!
Preview URL: https://5bfe3f7b.open-context.pages.dev
Branch Preview URL: https://canonical-model-provider-spi.open-context.pages.dev

View logs

@adityak74 adityak74 changed the title canonical model provider spi feat(v2): implement Canonical Model and Provider SPI (Sub-Project 1) Aug 25, 2026
@adityak74
adityak74 force-pushed the canonical-model-provider-spi branch from e0a68de to 6316acd Compare August 26, 2026 04:58
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