|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Seed the RustyRed public demo with a small epistemic knowledge graph about |
| 4 | +# RustyRed itself: Claim nodes carrying 8-dim embeddings, a Source, and |
| 5 | +# confidence-weighted epistemic edges (Supports / Cites). Designates the |
| 6 | +# embedding property for HNSW vector search and the text property for BM25 |
| 7 | +# full-text, so the read-only demo token can exercise vector search, full-text |
| 8 | +# search, epistemic traversal, and the graph algorithms. |
| 9 | +# |
| 10 | +# Usage: |
| 11 | +# BASE_URL=https://<service>.up.railway.app TOKEN=<graph:write token> ./scripts/demo/seed.sh |
| 12 | +# |
| 13 | +# Env: BASE_URL (required), TOKEN (required, needs graph:write), TENANT (default "demo"). |
| 14 | + |
| 15 | +set -euo pipefail |
| 16 | + |
| 17 | +BASE="${BASE_URL:?set BASE_URL}" |
| 18 | +TOKEN="${TOKEN:?set TOKEN (needs graph:write)}" |
| 19 | +TENANT="${TENANT:-demo}" |
| 20 | +base="${BASE%/}/v1/tenants/${TENANT}/graph" |
| 21 | + |
| 22 | +jpost() { |
| 23 | + curl -fsS -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" \ |
| 24 | + -X POST "${base}/$1" -d "$2" >/dev/null |
| 25 | +} |
| 26 | + |
| 27 | +echo "designating vector + full-text properties..." |
| 28 | +jpost vector/designate '{"label":"Claim","property":"embedding","dimension":8}' |
| 29 | +jpost fulltext/designate '{"label":"Claim","property":"text"}' |
| 30 | + |
| 31 | +echo "loading nodes..." |
| 32 | +curl -fsS -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/x-ndjson" \ |
| 33 | + -X POST "${base}/bulk/nodes" --data-binary @- >/dev/null <<'JSONL' |
| 34 | +{"id":"claim:graph","labels":["Claim"],"properties":{"text":"RustyRed is a graph and vector database in one engine","embedding":[0.90,0.10,0.20,0.00,0.10,0.00,0.00,0.00]}} |
| 35 | +{"id":"claim:vector","labels":["Claim"],"properties":{"text":"RustyRed runs HNSW vector search over node properties","embedding":[0.80,0.20,0.30,0.10,0.00,0.00,0.00,0.00]}} |
| 36 | +{"id":"claim:epistemic","labels":["Claim"],"properties":{"text":"RustyRed models confidence-weighted epistemic edges","embedding":[0.85,0.15,0.25,0.05,0.05,0.00,0.00,0.00]}} |
| 37 | +{"id":"claim:mcp","labels":["Claim"],"properties":{"text":"RustyRed exposes a first-class MCP agent port","embedding":[0.10,0.00,0.00,0.90,0.20,0.10,0.00,0.00]}} |
| 38 | +{"id":"claim:ram","labels":["Claim"],"properties":{"text":"RustyRed is RAM-first with append-only-file durability","embedding":[0.00,0.10,0.10,0.80,0.30,0.00,0.00,0.00]}} |
| 39 | +{"id":"claim:rust","labels":["Claim"],"properties":{"text":"RustyRed is written in Rust","embedding":[0.05,0.00,0.00,0.85,0.25,0.10,0.00,0.00]}} |
| 40 | +{"id":"source:readme","labels":["Source"],"properties":{"text":"RustyRed GraphDB README","embedding":[0.40,0.10,0.10,0.40,0.10,0.00,0.00,0.00]}} |
| 41 | +JSONL |
| 42 | + |
| 43 | +echo "linking epistemic edges..." |
| 44 | +edges=( |
| 45 | + 'e:cite:graph|source:readme|claim:graph|CITES|cites|1.0' |
| 46 | + 'e:cite:vector|source:readme|claim:vector|CITES|cites|1.0' |
| 47 | + 'e:cite:mcp|source:readme|claim:mcp|CITES|cites|1.0' |
| 48 | + 'e:sup:graph_vector|claim:graph|claim:vector|SUPPORTS|supports|0.95' |
| 49 | + 'e:sup:graph_epi|claim:graph|claim:epistemic|SUPPORTS|supports|0.9' |
| 50 | + 'e:sup:rust_ram|claim:rust|claim:ram|SUPPORTS|supports|0.9' |
| 51 | + 'e:sup:mcp_graph|claim:mcp|claim:graph|SUPPORTS|supports|0.85' |
| 52 | +) |
| 53 | +for spec in "${edges[@]}"; do |
| 54 | + IFS='|' read -r id from to type epi conf <<<"${spec}" |
| 55 | + jpost edges "{\"id\":\"${id}\",\"from_id\":\"${from}\",\"to_id\":\"${to}\",\"type\":\"${type}\",\"epistemic_type\":\"${epi}\",\"confidence\":${conf}}" |
| 56 | +done |
| 57 | + |
| 58 | +echo "demo seeded into tenant '${TENANT}'." |
0 commit comments