File size: 11,256 Bytes
21ff762 3fbbaab 21ff762 7609903 21ff762 7609903 7d77f3a 21ff762 7d77f3a 92305f9 7609903 21ff762 7609903 21ff762 92305f9 7609903 21ff762 3fbbaab 21ff762 7d77f3a 92305f9 21ff762 7d77f3a f2361ba 21ff762 f2361ba 21ff762 f2361ba 2eb06dc 92305f9 2eb06dc 21ff762 92305f9 21ff762 92305f9 21ff762 92305f9 21ff762 6a46743 21ff762 4022e96 21ff762 3fbbaab 2eb06dc 21ff762 3fbbaab f1745a4 3fbbaab 21ff762 f1745a4 21ff762 3fbbaab 21ff762 3fbbaab 21ff762 3fbbaab 21ff762 7d77f3a 3fbbaab 21ff762 3fbbaab 21ff762 92305f9 21ff762 4022e96 3fbbaab 21ff762 3fbbaab 21ff762 4022e96 21ff762 3fbbaab 21ff762 7609903 4022e96 21ff762 7609903 4022e96 92305f9 4022e96 7d77f3a 4022e96 7d77f3a 4022e96 92305f9 6a46743 92305f9 6a46743 3fbbaab 6a46743 3fbbaab 7609903 4022e96 7609903 21ff762 7609903 6a46743 7609903 3fbbaab f1745a4 6a46743 4022e96 21ff762 6a46743 21ff762 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | # Knowledge Graph Artifacts
This directory ships the pre-built ctx LLM-wiki and knowledge graph.
Current snapshot:
- **102,928 graph nodes**
- **2,913,960 graph edges**
- **52 Louvain communities**
- **91,464 skill entity pages**; **89,465** have hydrated catalog bodies
- **467 agent pages**
- **10,790 MCP server pages**
- **207 harness pages**
- **89,465 hydrated `SKILL.md` bodies**
- **28,612 long skill bodies converted through the micro-skill gate**
The runtime recommendation paths use this graph in two ways:
- Development recommendations return skills, agents, and MCP servers only.
- Custom/API/local model onboarding recommends harnesses using the higher harness fit floor in `src/config.json`.
## Files
| File | Contents |
|---|---|
| `wiki-graph-runtime.tar.gz` | Fast install artifact used by default `ctx-init --graph`: `graphify-out/*`, the skill index, 207 harness pages, wiki index files, and Obsidian metadata needed for recommendations and harness dry-runs without expanding every entity page |
| `wiki-graph.tar.gz` | Full LLM-wiki: entity pages, converted skill bodies, mirrored agent bodies, concept pages, `graphify-out/graph.json`, `graph-delta.json`, export manifest, communities, skill indexes, and Obsidian metadata |
| Skill catalog gzip | Compressed skill index for the 89,465 body-backed skill entries shipped in the wiki |
| `communities.json` | Current Louvain community export |
| `entity-overlays.jsonl` | Release overlay for first-class entities added after the base graph export; installed beside `graphify-out/graph.json` by `ctx-init --graph` |
| `graphify-out/dashboard-neighborhoods.sqlite3` inside both tarballs | Compact top-neighbor index used by `ctx-monitor` so `/api/graph/<slug>.json` does not cold-parse the 818 MiB graph JSON |
| `viz-overview.html` | Plotly overview of the graph |
| `viz-python.html` | Python-focused graph view |
| `viz-security.html` | Security-focused graph view |
| `viz-ai-agents.html` | AI-agent-focused graph view |
| `sample-top60.html` | Interactive top-degree sample |
Preview HTML files are generated from the shipped `graphify-out/graph.json`
and embed the graph export ID in `<meta name="ctx-graph-export-id">`. Static
PNG snapshots are intentionally not shipped because they can drift from the
current tarball without an executable freshness check.
## Runtime vs Full Wiki
`ctx-init --graph` installs `wiki-graph-runtime.tar.gz` by default. That is the
right path for recommendations and first-time installs because it avoids
expanding hundreds of thousands of markdown files while still shipping the
harness pages needed by `ctx-harness-install --dry-run`. Use
`ctx-init --graph --graph-install-mode full` or manual full extraction when you
want local wiki browsing, Obsidian, or the converted skill body tree.
## What Is Inside `wiki-graph.tar.gz`
- `entities/skills/` - all skill entity pages
- `entities/agents/` - agent entity pages
- `entities/mcp-servers/<shard>/` - sharded MCP server entity pages
- `entities/harnesses/` - harness entity pages
- `converted/` - installable skill bodies
- `converted-agents/` - mirrored agent bodies
- `concepts/` - community concept pages
- `external-catalogs/` - machine-readable skill index, summary, and coverage metadata
- `graphify-out/graph.json` - NetworkX node-link graph
- `graphify-out/graph-delta.json` - delta export for the latest graph generation
- `graphify-out/graph-export-manifest.json` - export manifest tying graph, delta, communities, and report to one generation
- `graphify-out/communities.json` - community export
- `SCHEMA.md`, `index.md`, `log.md`, `catalog.md` - wiki contract and indexes
- `.obsidian/` - vault metadata for local graph browsing
`SKILL.md.original` backups, transient `.lock` files, and `.ctx/` queue state
are not shipped. Local micro-skill conversion may keep `.original` files for
traceability, but the packaged tarball excludes them so users do not ingest raw
long bodies after conversion.
## Extract
Default runtime install:
```bash
ctx-init --graph
```
Full wiki extraction:
```bash
mkdir -p ~/.claude/skill-wiki
tar xzf graph/wiki-graph.tar.gz -C ~/.claude/skill-wiki/
```
On Windows PowerShell, use the built-in `tar.exe` without `--force-local`:
```powershell
New-Item -ItemType Directory -Force "$env:USERPROFILE\.claude\skill-wiki"
tar -xzf graph\wiki-graph.tar.gz -C "$env:USERPROFILE\.claude\skill-wiki"
```
With Git Bash or MSYS tar, use `--force-local` only when the `-C` target is a
drive-letter path:
```bash
tar --force-local xzf graph/wiki-graph.tar.gz -C C:/Users/<you>/.claude/skill-wiki/
```
## Validate
```bash
python src/validate_graph_artifacts.py --deep
python src/update_repo_stats.py --check
```
For release-count validation, pin the exact snapshot numbers:
```bash
python src/validate_graph_artifacts.py --deep \
--expected-nodes 102928 \
--expected-edges 2913960 \
--expected-semantic-edges 1683193 \
--expected-harness-nodes 207 \
--expected-skill-pages 91464 \
--expected-agent-pages 467 \
--expected-mcp-pages 10790 \
--expected-harness-pages 207
```
Manual sanity checks:
```bash
tar -tzf graph/wiki-graph.tar.gz | grep 'graphify-out/graph.json'
tar -tzf graph/wiki-graph.tar.gz | grep 'external-catalogs/.*/catalog.json'
tar -tzf graph/wiki-graph.tar.gz | grep 'SKILL.md.original' && exit 1 || true
tar -tzf graph/wiki-graph.tar.gz | grep '\.lock$' && exit 1 || true
tar -tzf graph/wiki-graph.tar.gz | grep '^\./\.ctx/' && exit 1 || true
```
Windows PowerShell equivalent for the exclusion checks:
```powershell
tar -tzf graph/wiki-graph.tar.gz | Select-String 'SKILL.md.original'
tar -tzf graph/wiki-graph.tar.gz | Select-String '\.lock$'
tar -tzf graph/wiki-graph.tar.gz | Select-String '^\./\.ctx/'
```
The PowerShell commands should print nothing.
## Rebuild
After adding or updating skills, agents, MCP servers, or harnesses:
```bash
ctx-wiki-worker --wiki ~/.claude/skill-wiki --limit 1
ctx-scan-repo --repo . --recommend
```
The worker path is the fast local update path. It validates the queued entity
page, updates the wiki index, and attempts incremental ANN attach into
`graphify-out/entity-overlays.jsonl` when the semantic vector index exists. It
also queues the normal incremental graph export job, so a full rebuild remains
the reconciliation path for release artifacts.
If the worker reports that incremental attach was skipped because no vector
index exists, build the exact portable index:
```bash
ctx-wiki-graphify \
--wiki-dir ~/.claude/skill-wiki \
--incremental \
--graph-only \
--semantic-vector-index numpy-flat
```
Then drain pending queue work again:
```bash
ctx-wiki-worker --wiki ~/.claude/skill-wiki
```
Before promoting an ANN backend or changed thresholds, run the shadow gate:
```bash
ctx-incremental-shadow \
--index-dir ~/.claude/skill-wiki/.embedding-cache/graph/vector-index \
--graph ~/.claude/skill-wiki/graphify-out/graph.json \
--sample-size 100 \
--min-overlap 0.85
```
It reports precision/recall, top-k agreement, score deltas, and bad examples;
the release gate fails when recall at the largest requested top-k is below the
overlap floor.
For release artifact rebuilds:
```bash
python scripts/graph_artifact_guard.py park
ctx-wiki-graphify
python src/validate_graph_artifacts.py --deep
python src/update_repo_stats.py --check
```
`park` sets Git's local `skip-worktree` bit for the heavyweight generated
archives: `graph/wiki-graph.tar.gz`, `graph/wiki-graph-runtime.tar.gz`, and
the compressed skill index. Keep them parked while graph/wiki generation,
validation, dashboard smoke, and stats checks are still in progress. This
prevents background Git integrations from repeatedly staging hundreds of
megabytes through the Git LFS clean filter. When the release candidate is final,
unpark and stage the artifacts exactly once:
```bash
python scripts/graph_artifact_guard.py unpark
git add graph/wiki-graph.tar.gz graph/wiki-graph-runtime.tar.gz \
graph/skills-sh-catalog.json.gz graph/communities.json graph/entity-overlays.jsonl
python scripts/graph_artifact_guard.py prune
```
If a local Git integration gets interrupted while artifacts are dirty,
`python scripts/graph_artifact_guard.py prune` removes prunable local LFS cache
entries. It does not delete tracked graph files, rewrite history, or change the
remote LFS store. Repo-wide `git prune --expire=now` is intentionally opt-in via
`--include-git-prune` because it can discard unrelated dangling recovery objects.
For a bulk skill refresh, update the existing shipped tarball through the
release refresh path:
```bash
python src/import_skills_sh_catalog.py \
--from-catalog <skill-catalog.json.gz> \
--catalog-out <skill-catalog.json.gz> \
--wiki-tar graph/wiki-graph.tar.gz \
--update-wiki-tar
```
For a full local wiki repack, write the tarball to the sibling staged path,
then promote that staged candidate after validation:
```bash
cd ~/.claude/skill-wiki
tar --force-local -czf /path/to/ctx/graph/wiki-graph.tar.gz.staged \
--exclude='.trash' \
--exclude='__pycache__' \
--exclude='./raw' \
--exclude='./.embedding-cache' \
--exclude='./.ingest-checkpoint' \
--exclude='./.enrich-checkpoint' \
--exclude='./.ctx' \
--exclude='./graphify-out/graph.pickle' \
--exclude='*.original' \
--exclude='*.lock' \
.
cd /path/to/ctx
python -c "from pathlib import Path; from ctx.core.wiki.artifact_promotion import promote_staged_artifact; from import_skills_sh_catalog import _validate_wiki_tarball_candidate; promote_staged_artifact(Path('graph/wiki-graph.tar.gz.staged'), Path('graph/wiki-graph.tar.gz'), validate=_validate_wiki_tarball_candidate)"
```
The repack command above is for Git Bash/MSYS. In Linux/macOS shells omit
`--force-local`; in PowerShell use `tar -czf` without `--force-local`.
Both flows validate candidates before atomic promotion. Each promoted artifact
gets a sibling `*.promotion.json` file with current, candidate, and `last_good`
hashes for review or rollback. The graph, delta, communities, report, and
export manifest are shipped together and carry the same export ID so validation
can reject mixed or partially refreshed graph generations. Raw `.original`
backups, transient `.lock` files, and `.ctx/` queue state must not appear in
the shipped tarball.
## Implementation Notes
The graph is built by `ctx.core.wiki.wiki_graphify` and the `ctx-wiki-graphify`
console script. Edges blend semantic similarity, explicit tag overlap,
slug-token overlap, source overlap, direct links, quality, usage, type affinity,
and graph-structure signals where available. The shipped default
`graph.min_edge_weight` is `0.03`, chosen from artifact calibration because it
keeps the current topology intact while recording the real shipped floor.
`nashsu/llm_wiki` was reviewed for design ideas around persistent wiki
contracts, queues, retrieval, and graph maintenance. ctx does not vendor that
code in this MIT repository.
|