7.4 KiB
7.4 KiB
Plan: Expose SQLite /api/v1/meta/* REST Endpoints, HTTP ETag (304 Not Modified), hs_query_sqlite_catalog MCP Tool & sync-vps-repos.sh Hydration (v2.0.18)
- Document ID:
PLAN-SQLITE-META-REST-ENDPOINTS-ETAG-AND-VPS-SYNC(v2.0.18) - Roadmap Status: LONG-TERM INACTIVE PLAN (Deferred) — Extracted from
PLAN-SQLITE-REST-API-METADATA-DBand preserved as a long-term architectural specification alongsidePLAN-LLM-TOKEN-ECONOMIZER-AND-VARIANCE-ROUTING,PLAN-MEMETIC-GALLERY-SUBPAGE, andEpisodes 06–09of The Encyclopedia Expeditions; not scheduled for active implementation unless explicitly activated. - Prerequisite Module:
hyperstitionstud_io.db.sqlite_meta(hs-db-buildCLI,hyperstition-catalog.db, andapi-telemetry.dbautomatically populated bydispatch_rest_v1()anddispatch_jsonrpc(), defined in the active plan/workspace/encyclopedia-knowledge-graph/docs/PLAN-SQLITE-REST-API-METADATA-DB.{md,pdf}). - Target Modules (When Activated):
/workspace/hyperstitionstudio-core/src/hyperstitionstud_io/mcp/rest.py&server.py/workspace/hyperstitionstudio-core/src/hyperstitionstud_io/mcp/tools.py/workspace/hyperstitionstudio-core/deploy/hyperstition-mcp.service/workspace/hyperstitionstudio-core/deploy/sync-vps-repos.sh&deploy/test-first-deployment.sh
1. Scope of Deferred Integration
Once the standalone hyperstitionstud_io.db.sqlite_meta engine (hyperstition-catalog.db + api-telemetry.db) is built, this long-term plan specifies how to expose it over the public /api/v1/meta/* HTTP REST surface and /mcp JSON-RPC server and wire automatic RAM-tmpfs database hydration into the VPS deployment pipeline:
- Five
/api/v1/meta/*HTTP REST Endpoints: Expose/api/v1/meta/{manifests,search,coordinate/{aq_int},timeseries/query,telemetry}onhyperstitionstud_io.mcp.restandserver.py. - HTTP
ETag/If-None-Match(304 Not Modified) Conditional Caching Middleware: Serve deterministicETagheaders backed byregistry_manifests.dag_json_cidv1(or SHA-256) and short-circuit matchingIf-None-Matchrequests withHTTP 304 Not Modifiedin< 0.1 ms. - MCP Tool
hs_query_sqlite_catalog: Registerhs_query_sqlite_cataloginMCP_TOOLS_SCHEMA(src/hyperstitionstud_io/mcp/tools.py) and expose it at/mcp(tools/call) and/api/v1/tools/hs_query_sqlite_catalog. - VPS
tmpfsHydration indeploy/sync-vps-repos.sh& Systemd Sandboxing: Runhs-db-build("${PYTHON_BIN}" -m hyperstitionstud_io.db.sqlite_meta --build) insidedeploy/sync-vps-repos.shso/var/www/hyperstitionstud.io/repos/hyperstition-catalog.dbrefreshes in the512 MBRAMtmpfsmount on every pull while keepingProtectSystem=strictandReadOnlyIsolationGuardintact.
2. /api/v1/meta/* REST Endpoints & hs_query_sqlite_catalog MCP Tool Specification
2.1 REST Endpoints (src/hyperstitionstud_io/mcp/rest.py)
| HTTP Method & Path | Query Parameters | What It Queries in SQLite (< 1 ms) |
|---|---|---|
GET /api/v1/meta/manifests |
?registry=glossary-registry (optional) |
Calls query_registry_manifests() on registry_manifests for all compiled schemas/registries, their record counts, raw_sha256, dag_json_cidv1, and ETag headers. |
GET /api/v1/meta/search |
?q=envideea+137&type=all|glossary|equation|node&limit=25 |
Calls query_fts_catalog() to execute a ranked FTS5 BM25 full-text search across fts_catalog (searching glossary terms, 1,850+ equations, 388 graph nodes, and 24 tickers in < 0.6 ms). |
GET /api/v1/meta/coordinate/{aq_int} |
aq_int in 1..999 (e.g. /api/v1/meta/coordinate/137 or /api/v1/meta/coordinate/125) |
Calls query_coordinate_join(aq_int) for a Unified Cross-Corpus Coordinate Join: in a single indexed SQL query, returns every glossary term, bilingual specimen, Knowledge Graph node/edge, 333/666/777 archive equation, and /quant/ closing-bell bar that locks onto integer coordinate {aq_int}. |
GET /api/v1/meta/timeseries/query |
?symbol=NVDA&start=2026-11-10&end=2026-11-30&min_points=1.5 |
Calls query_timeseries_bars() to execute indexed range queries over quant_timeseries_bars (WHERE symbol = ? AND date_utc BETWEEN ? AND ? AND contingent_points >= ?). |
GET /api/v1/meta/telemetry |
None | Calls get_api_telemetry_summary() on api-telemetry.db, returning live server uptime, total calls, cache hit rate (304), mean/max latency (\mu\text{s}) per endpoint, and 100% isolation verification counts. |
2.2 MCP Tool hs_query_sqlite_catalog (src/hyperstitionstud_io/mcp/tools.py)
- Tool Name:
hs_query_sqlite_catalog - Input Schema (
inputSchema):mode:"manifests" | "search" | "coordinate" | "timeseries" | "telemetry"(default"search")query:str(FTS5BM25search query whenmode == "search")doc_type:"all" | "glossary" | "equation" | "node" | "dossier" | "instrument"(default"all")aq_int:int(1..999, required whenmode == "coordinate")symbol:str(optional ticker filter whenmode == "timeseries")start_date,end_date:str(YYYY-MM-DDbounds whenmode == "timeseries")min_points:float(default0.0)limit:int(1..100, default25)
- Execution Guarantees: Runs strictly inside
ReadOnlyIsolationGuardagainstfile:/.../hyperstition-catalog.db?mode=ro(PRAGMA query_only = ON;).
3. HTTP ETag / If-None-Match (304 Not Modified) & VPS Systemd Sandboxing
- HTTP
ETag&If-None-Match(304 Not Modified) Middleware in_MCPHTTPHandler(mcp/server.py):- Every
GET /api/v1/*response computes or looks up its deterministicETag("<dag_json_cidv1>"fromregistry_manifestsor SHA-256 payload digest). - If the client sends
If-None-Match: "<etag>"(or a comma-separated list containing"<etag>"),_MCPHTTPHandlerrecords astatus_304hit inapi-telemetry.dband returnsHTTP 304 Not Modifiedwith an empty body immediately (~95%bandwidth reduction on repeat polls).
- Every
- Read-Only Catalog DB Hydration in
deploy/sync-vps-repos.sh:- During Step 2 of
deploy/sync-vps-repos.sh, invoke"${PYTHON_BIN}" -m hyperstitionstud_io.db.sqlite_meta --build --db "${LIVE_REPOS}/hyperstition-catalog.db"so the512 MBRAM-backedtmpfsmount always holds an up-to-date catalog DB after every repository pull.
- During Step 2 of
- Preserving
ProtectSystem=strict&ReadOnlyIsolationGuardindeploy/hyperstition-mcp.service:- Configure
RuntimeDirectory=hyperstition-mcp(orPrivateTmp=truewriting to/tmp/hyperstition-api-telemetry.db) sohyperstition-mcp.servicewritesapi-telemetry.dbonly to an ephemeral tmpfs path while/srv/hyperstitionstud.io/reposand/var/www/hyperstitionstud.io/reposremain 100% read-only.
- Configure
4. Activation & Verification Checklist (When Promoted from Inactive Backlog)
- Wire
/api/v1/meta/{manifests,search,coordinate/{aq_int},timeseries/query,telemetry}andETag/If-None-Match(304 Not Modified) intosrc/hyperstitionstud_io/mcp/rest.pyandserver.py. - Add
hs_query_sqlite_catalogtoMCP_TOOLS_SCHEMAinsrc/hyperstitionstud_io/mcp/tools.py. - Wire
hs-db-buildintodeploy/sync-vps-repos.shand add HTTP checks for/api/v1/meta/manifests,/api/v1/meta/search?q=envideea,/api/v1/meta/coordinate/137,If-None-Match->304 Not Modified, and/api/v1/meta/telemetrytotests/test_core_suite.pyanddeploy/test-first-deployment.sh.