Skip to content

SPARQL endpoint + write-time index — make pods queryable #509

Open

Description

@melvincarvalho

Why

Right now JSS stores JSON-LD blobs but offers no way to ask questions of them. Every app re-implements its own walker: "fetch the container, parse ldp:contains, fetch each child, scan for the property I want." This is O(N) and brittle, and it's the single biggest reason Solid "feels like a file dump" rather than a database.

A pod with even a thousand resources becomes painful. A pod with serious archival data (photos, transcripts, messages, agent record-of-work) is unusable without query.

Adding a /sparql endpoint plus a write-time index turns every pod into a small queryable knowledge graph. That single addition unlocks:

  • Agent grounding — Charlie can SELECT ?x WHERE { ?x schema:type schema:Photo ; schema:dateCreated ?d FILTER(?d > "2025-01-01") } instead of walking the file tree.
  • Cross-app reads — vellum can find "all notes mentioning #project-x" without scanning every file.
  • Search UI in explorer — the Phase 8 search box becomes a SPARQL query under the hood.
  • Federated query — once one pod speaks SPARQL, asking across pods is plumbing rather than reinvention.
  • MCP tool — JSS already exposes 16 MCP tools; sparql_query becomes the 17th and makes pod data first-class to any agent.

Shape

POST /sparql
Content-Type: application/sparql-query
<query body>

→ application/sparql-results+json
  • Index lives at /.index/ inside the pod (writable only by owner).
  • Populated on every write (PUT, POST, PATCH, DELETE) — small, synchronous, indexes only the JSON-LD content that was just touched.
  • Backed by a tiny embedded store. Options:
    • SQLite + a tiny triple-table schema — boring, robust, single file, no native deps.
    • Quadstore (LevelDB-backed npm package) — SPARQL-aware out of the box.
    • N3.js + in-memory store — simplest spike but loses on restart.
  • ACL-aware: query results are filtered by the requesting agent's read access. No leaking private resources.

Scope (first cut)

Minimal but useful subset:

  • SELECT with BGPs, FILTER, LIMIT, OFFSET, ORDER BY
  • ASK
  • CONSTRUCT (optional in v1)
  • OPTIONAL, UNION
  • No UPDATE in v1 — writes go through the LDP/HTTP path so the index is always derived
  • No federation (SERVICE) in v1 — that's a separate issue

Things explicitly out of scope:

  • OWL reasoning / inferencing — a 10× project for marginal value
  • Custom function extensions
  • Full SPARQL 1.1 surface

Tradeoffs

  • ✓ Single addition that elevates "Solid pod" from file dump to knowledge graph
  • ✓ Every Solid-native app gets cheap cross-resource query
  • ✓ Pod-resident — no external triple store, no separate process
  • ✗ Write path slows slightly (index update)
  • ✗ Pod size grows (~5-15% overhead for the index)
  • ✗ Schema drift risks: if app-A writes weird JSON-LD, queries assuming app-B's shape may miss it. (Mitigation: SHACL at write time — separate future issue.)

Open questions

  • Sync vs async indexing: synchronous keeps consistency simple but couples write latency to index size. Async needs a queue + a way to surface "stale" reads.
  • Reindex command: jss reindex for cold-start or migrations. Walks /.well-known/index-roots or just everything under /.
  • Backup story: index is derived data; should jss backup skip it? Probably yes, with reindex on restore.
  • /sparql UI: lightweight YASGUI-style endpoint at /sparql for humans? Or keep it pure API and let apps ship their own?
  • ACL filtering granularity: per-resource read check is straightforward but slow for big result sets. Pre-filter the index by access patterns? Cache per-agent views?
  • Federation later: once /sparql exists, SERVICE <https://other.pod/sparql> is a small step. Worth designing the v1 result format to compose cleanly.

Effort

  • Spike on top of quadstore or similar: ~1 week to a working /sparql against a small pod, no auth.
  • Real cut with ACL filtering, sync indexing, reindex command, tests: ~3-4 weeks.

Related

Activity

  1. added
    plugin
    on Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions