|
| 1 | +# UX Methods Graph |
| 2 | + |
| 3 | +This folder contains the knowledge graph assets for UX Methods: the core ontology, exported instance data, SPARQL queries, and scripts for exporting/pushing RDF to Fuseki. |
| 4 | + |
| 5 | +The near-term goals: |
| 6 | + |
| 7 | +- prototype an integrated knowledge graph locally (Protégé + SPARQL) |
| 8 | +- keep ontology (TBox), taxonomy (SKOS), and content instance data (ABox) cleanly separated |
| 9 | +- load the same artifacts into Fuseki as named graphs |
| 10 | + |
| 11 | +Long-term goals include: |
| 12 | + |
| 13 | +- maintain UX Methods content quality/consistency over time |
| 14 | +- generate semantically rich connections between resources (methods, artifacts, steps, dependencies) |
| 15 | +- expose a queryable SPARQL endpoint |
| 16 | +- support graph-driven "plan builder" / "method stack generator" tooling |
| 17 | + |
| 18 | +## Directory structure |
| 19 | + |
| 20 | +``` |
| 21 | +graph/ |
| 22 | + build/ # GENERATED RDF outputs (do not edit by hand) |
| 23 | + ontologies/ |
| 24 | + uxmethods-core.ttl # curated ontology (TBox) |
| 25 | + workspace.ttl # local entrypoint ontology for testing and development (imports only) |
| 26 | + catalog-v001.xml # Protégé catalog: maps ontology IRIs -> local files |
| 27 | + queries/ # SPARQL queries for testing & validation |
| 28 | + scripts/ # tools for generating RDF and loading to Fuseki |
| 29 | + .env # local config (ignored) |
| 30 | + package.json |
| 31 | + README.md |
| 32 | +``` |
| 33 | + |
| 34 | +**Source vs generated** |
| 35 | + |
| 36 | +- Curated / versioned by hand: `ontologies/*`, `queries/*`, `scripts/*` |
| 37 | +- Generated / replaceable: `build/*` |
| 38 | + |
| 39 | +Treat `build/*` as disposable outputs: regenerate them from Sanity whenever content changes. |
| 40 | + |
| 41 | +## IRIs and naming conventions |
| 42 | + |
| 43 | +### IO taxonomy (SKOS) |
| 44 | + |
| 45 | +- Concept Scheme IRI (slash): `https://uxmethods.org/taxonomies/io` |
| 46 | +- Named graph IRI (slash): `https://uxmethods.org/taxonomies/io` |
| 47 | +- Concept namespace (hash): `https://uxmethods.org/taxonomies/io#<conceptId>` |
| 48 | + |
| 49 | +### Methods |
| 50 | + |
| 51 | +- Method instance IRIs: `https://uxmethods.org/method/<slug>` |
| 52 | + |
| 53 | +### Methods export ontology IRI |
| 54 | + |
| 55 | +- Methods data ontology IRI: `https://uxmethods.org/graph/methods` |
| 56 | + |
| 57 | +## Named graph strategy |
| 58 | + |
| 59 | +Different “kinds” of knowledge in kept in separate **named graphs** so that each collection can: |
| 60 | +- evolve schemas independently from content |
| 61 | +- import/replace curated terms without touching core semantics |
| 62 | +- load/unload entire domains of data cleanly |
| 63 | +- write queries that target only the graph(s) they need |
| 64 | + |
| 65 | +**Note:** IRIs identify resources globally; named graphs are storage context. A method can reference a SKOS concept by IRI even if its descriptive triples live in a different named graph. |
| 66 | + |
| 67 | +## Local Protégé workflow |
| 68 | + |
| 69 | +The most reliable way to work locally is to open one entrypoint ontology and let imports + a catalog resolve everything. |
| 70 | + |
| 71 | +`workspace.ttl` imports: |
| 72 | + |
| 73 | +- uxmethods-core ontology |
| 74 | +- io-taxonomy export |
| 75 | +- methods-data export |
| 76 | + |
| 77 | +Protégé + the SPARQL plugin then behave like a "merged model over the imports closure", which works for iteration and testing. |
| 78 | + |
| 79 | +### SPARQL behavior note |
| 80 | + |
| 81 | +Protégé's SPARQL Query plugin typically queries a merged model (active ontology + imports closure), so you can write queries without `GRAPH {}` blocks locally. In Fuseki, you will usually need `GRAPH` unless you configure union default graph. |
| 82 | + |
| 83 | +## Scripts |
| 84 | + |
| 85 | +Your pnpm doesn't support `-C`, so use `pnpm --dir graph …` or `cd graph` first. |
| 86 | + |
| 87 | +### Export methods (local file) |
| 88 | + |
| 89 | +From repo root: |
| 90 | + |
| 91 | +```bash |
| 92 | +pnpm --dir graph exec node scripts/method-export.js |
| 93 | +``` |
| 94 | + |
| 95 | +**Output:** |
| 96 | + |
| 97 | +- `graph/build/methods-data.ttl` |
| 98 | + |
| 99 | +### Export taxonomy + push to Fuseki |
| 100 | + |
| 101 | +**Dry run (no PUT):** |
| 102 | + |
| 103 | +```bash |
| 104 | +DRY_RUN=1 pnpm --dir graph exec node scripts/push-io-taxonomy.js |
| 105 | +``` |
| 106 | + |
| 107 | +**Write file + push to Fuseki:** |
| 108 | + |
| 109 | +```bash |
| 110 | +pnpm --dir graph exec node scripts/push-io-taxonomy.js |
| 111 | +``` |
| 112 | + |
| 113 | +This does a Graph Store Protocol PUT to: |
| 114 | + |
| 115 | +- `.../ds/data?graph=https://uxmethods.org/taxonomies/io` |
| 116 | + |
| 117 | +with header: |
| 118 | + |
| 119 | +- `X-API-Token: <FUSEKI_API_TOKEN>` |
| 120 | + |
| 121 | +## Generated file requirements (Protégé-friendly) |
| 122 | + |
| 123 | +Generated TTL files include an ontology header so Protégé can import them by logical IRI (not `file:`): |
| 124 | + |
| 125 | +- `build/io-taxonomy.ttl` declares: |
| 126 | + - `<https://uxmethods.org/taxonomies/io> a owl:Ontology .` |
| 127 | +- `build/methods-data.ttl` declares: |
| 128 | + - `<https://uxmethods.org/graph/methods> a owl:Ontology .` |
| 129 | + |
| 130 | +This prevents Protégé's "Import using supplied physical URI (not recommended)" warning and enables clean catalog mappings. |
| 131 | + |
| 132 | +## Queries |
| 133 | + |
| 134 | +Queries live in `graph/queries/*.rq`. These are intended for: |
| 135 | + |
| 136 | +- quick iteration in Protégé (copy/paste into SPARQL Query tab) |
| 137 | +- later automation/regression tests against Fuseki |
| 138 | + |
| 139 | +**Example (method output enables another method input):** |
| 140 | + |
| 141 | +- `queries/method-output-enables-method-input*.rq` |
| 142 | + |
| 143 | +## Troubleshooting |
| 144 | + |
| 145 | +### Protégé import tries to fetch a web URL and fails |
| 146 | + |
| 147 | +- Add `ontologies/catalog-v001.xml` under Protégé's Ontology Catalogs |
| 148 | +- Ensure the imported files declare an `owl:Ontology` IRI (generated scripts now do this) |
| 149 | + |
| 150 | +### Fuseki write returns 403 Forbidden |
| 151 | + |
| 152 | +- nginx requires `X-API-Token`; confirm `FUSEKI_API_TOKEN` is set and the script sends the header |
| 153 | +- confirm you're writing to `/ds/data` (not `/ds/`) |
| 154 | + |
| 155 | +### Protégé still "sees" an import after you remove it |
| 156 | + |
| 157 | +Protégé may keep ontologies loaded in memory for the session. Restart/reload if you need a clean imports-closure test. |
0 commit comments