Stevesolun commited on
Commit
04416c2
·
verified ·
1 Parent(s): 1b56ed2

Sync ctx v1.0.7 release metadata and dashboard fix

Browse files
CHANGELOG.md CHANGED
@@ -3,11 +3,21 @@
3
  All notable changes to the `ctx` project will be documented in this file.
4
  Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
 
6
- ## [Unreleased]
7
-
8
- - No unreleased changes yet.
9
-
10
- ## [1.0.6] - 2026-05-14
 
 
 
 
 
 
 
 
 
 
11
 
12
  ### Fixed
13
 
@@ -1548,7 +1558,8 @@ pass. Full test suite: **1316 passed, 2 skipped**.
1548
  - 5 dead imports removed (`os`, `Mapping`, `timedelta` from
1549
  `ctx_lifecycle`; `Path` from `intake_gate`, `intake_pipeline`).
1550
 
1551
- [1.0.6]: https://github.com/stevesolun/ctx/releases/tag/v1.0.6
 
1552
  [1.0.5]: https://github.com/stevesolun/ctx/releases/tag/v1.0.5
1553
  [1.0.4]: https://github.com/stevesolun/ctx/releases/tag/v1.0.4
1554
  [1.0.3]: https://github.com/stevesolun/ctx/releases/tag/v1.0.3
 
3
  All notable changes to the `ctx` project will be documented in this file.
4
  Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
 
6
+ ## [Unreleased]
7
+
8
+ - No unreleased changes yet.
9
+
10
+ ## [1.0.7] - 2026-05-15
11
+
12
+ ### Fixed
13
+
14
+ - Fixed dashboard graph cold starts for `ctx-init --graph` installs by keeping
15
+ the SQLite neighborhood index fast path when the installed release overlay is
16
+ already represented in the shipped graph index.
17
+ - Preserved the safe full-graph merge path for local/user runtime overlays so
18
+ newly attached entity edges still appear immediately in the dashboard.
19
+
20
+ ## [1.0.6] - 2026-05-14
21
 
22
  ### Fixed
23
 
 
1558
  - 5 dead imports removed (`os`, `Mapping`, `timedelta` from
1559
  `ctx_lifecycle`; `Path` from `intake_gate`, `intake_pipeline`).
1560
 
1561
+ [1.0.7]: https://github.com/stevesolun/ctx/releases/tag/v1.0.7
1562
+ [1.0.6]: https://github.com/stevesolun/ctx/releases/tag/v1.0.6
1563
  [1.0.5]: https://github.com/stevesolun/ctx/releases/tag/v1.0.5
1564
  [1.0.4]: https://github.com/stevesolun/ctx/releases/tag/v1.0.4
1565
  [1.0.3]: https://github.com/stevesolun/ctx/releases/tag/v1.0.3
README.md CHANGED
@@ -1,16 +1,21 @@
1
  ---
2
  license: mit
3
  pretty_name: ctx
 
 
4
  tags:
5
- - agents
6
- - mcp
7
- - skills
8
- - knowledge-graph
9
- - llm-wiki
10
- - recommendation-system
11
- - harness
12
- - codex
13
- - claude-code
 
 
 
14
  ---
15
 
16
  # ctx — Skill, Agent, MCP & Harness Recommendations
@@ -18,7 +23,7 @@ tags:
18
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
19
  [![Python 3.11+](https://img.shields.io/badge/Python-3.11+-green.svg)](https://python.org)
20
  [![PyPI](https://img.shields.io/pypi/v/claude-ctx.svg)](https://pypi.org/project/claude-ctx/)
21
- [![Tests](https://img.shields.io/badge/Tests-3818_collected-brightgreen.svg)](#)
22
  [![Graph](https://img.shields.io/badge/Graph-102%2C717_nodes_/_2.9M_edges-red.svg)](graph/)
23
  [![Docs](https://img.shields.io/badge/docs-MkDocs_Material-blue.svg)](https://stevesolun.github.io/ctx/)
24
 
 
1
  ---
2
  license: mit
3
  pretty_name: ctx
4
+ language:
5
+ - en
6
  tags:
7
+ - agents
8
+ - mcp
9
+ - skills
10
+ - knowledge-graph
11
+ - llm-wiki
12
+ - recommendation-system
13
+ - harness
14
+ - codex
15
+ - claude-code
16
+ - python
17
+ release: v1.0.7
18
+ github_commit: dbd6de3daaba0ec4715c7c13125c6f2c5929f419
19
  ---
20
 
21
  # ctx — Skill, Agent, MCP & Harness Recommendations
 
23
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
24
  [![Python 3.11+](https://img.shields.io/badge/Python-3.11+-green.svg)](https://python.org)
25
  [![PyPI](https://img.shields.io/pypi/v/claude-ctx.svg)](https://pypi.org/project/claude-ctx/)
26
+ [![Tests](https://img.shields.io/badge/Tests-3821_collected-brightgreen.svg)](#)
27
  [![Graph](https://img.shields.io/badge/Graph-102%2C717_nodes_/_2.9M_edges-red.svg)](graph/)
28
  [![Docs](https://img.shields.io/badge/docs-MkDocs_Material-blue.svg)](https://stevesolun.github.io/ctx/)
29
 
docs/index.md CHANGED
@@ -188,8 +188,8 @@ ones are flagged. New ones self-ingest.
188
 
189
  ---
190
 
191
- **v1.0.6** — MIT, CI-matrixed (Ubuntu 3.12 plus Windows/macOS 3.11/3.12),
192
- 3,818 tests collected. Ships console scripts including `ctx-init`,
193
  `ctx-monitor` (local dashboard with graph + wiki + load/unload for
194
  skills, agents, and MCP servers, plus Harness Setup for user-owned LLMs),
195
  `ctx-incremental-attach`, `ctx-incremental-shadow`, `ctx-dedup-check`
 
188
 
189
  ---
190
 
191
+ **v1.0.7** — MIT, CI-matrixed (Ubuntu 3.12 plus Windows/macOS 3.11/3.12),
192
+ 3,821 tests collected. Ships console scripts including `ctx-init`,
193
  `ctx-monitor` (local dashboard with graph + wiki + load/unload for
194
  skills, agents, and MCP servers, plus Harness Setup for user-owned LLMs),
195
  `ctx-incremental-attach`, `ctx-incremental-shadow`, `ctx-dedup-check`
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
 
5
  [project]
6
  name = "claude-ctx"
7
- version = "1.0.6"
8
  description = "Skill and agent recommendation system for Claude Code — knowledge graph, wiki, and intake quality gates"
9
  authors = [{ name = "Steve Solun" }]
10
  license = "MIT"
 
4
 
5
  [project]
6
  name = "claude-ctx"
7
+ version = "1.0.7"
8
  description = "Skill and agent recommendation system for Claude Code — knowledge graph, wiki, and intake quality gates"
9
  authors = [{ name = "Steve Solun" }]
10
  license = "MIT"
src/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
  """ctx — skill and agent recommendation for Claude Code."""
2
 
3
- __version__ = "1.0.6"
 
1
  """ctx — skill and agent recommendation for Claude Code."""
2
 
3
+ __version__ = "1.0.7"
src/ctx/__init__.py CHANGED
@@ -30,7 +30,7 @@ Package layout:
30
  ctx.utils - low-level primitives (safe names, atomic IO)
31
  """
32
 
33
- __version__ = "1.0.6"
34
 
35
 
36
  # Public library surface — anything listed here is safe for third-
 
30
  ctx.utils - low-level primitives (safe names, atomic IO)
31
  """
32
 
33
+ __version__ = "1.0.7"
34
 
35
 
36
  # Public library surface — anything listed here is safe for third-
src/ctx_monitor.py CHANGED
@@ -57,6 +57,7 @@ starting point.
57
  from __future__ import annotations
58
 
59
  import argparse
 
60
  import html
61
  import ipaddress
62
  import json
@@ -88,6 +89,8 @@ _MONITOR_TOKEN = ""
88
  _MONITOR_MUTATIONS_ENABLED = True
89
  _GRAPH_CACHE_KEY: tuple[Any, ...] | None = None
90
  _GRAPH_CACHE_VALUE: Any | None = None
 
 
91
  _SIDECAR_INDEX_CACHE_KEY: tuple[tuple[Path, float, int], ...] | None = None
92
  _SIDECAR_INDEX_CACHE_VALUE: dict[tuple[str, str], dict] | None = None
93
  _WIKI_INDEX_LIMIT_PER_TYPE = 500
@@ -2337,6 +2340,129 @@ def _dashboard_graph_has_runtime_overlays() -> bool:
2337
  return False
2338
 
2339
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2340
  def _dashboard_graph_index_archives() -> list[Path]:
2341
  module_root = Path(__file__).resolve().parent.parent
2342
  roots = (module_root,)
@@ -2702,7 +2828,10 @@ def _graph_neighborhood(
2702
  if "/" in slug or "\\" in slug or ".." in slug:
2703
  return {"nodes": [], "edges": [], "center": None}
2704
  normalized_entity_type = _normalize_dashboard_entity_type(entity_type)
2705
- if not _dashboard_graph_has_runtime_overlays():
 
 
 
2706
  indexed = _graph_neighborhood_from_index(
2707
  slug,
2708
  hops=hops,
@@ -3287,14 +3416,18 @@ def _render_skill_detail(slug: str, entity_type: str | None = None) -> str:
3287
 
3288
 
3289
  def _top_degree_seeds_from_index(limit: int = 18) -> list[dict]:
3290
- if _dashboard_graph_has_runtime_overlays():
 
 
 
 
3291
  return []
3292
- index_path = _ensure_dashboard_graph_index()
3293
- if index_path is None or not index_path.is_file():
3294
  return []
3295
  conn: sqlite3.Connection | None = None
3296
  try:
3297
- conn = sqlite3.connect(f"file:{index_path.as_posix()}?mode=ro", uri=True)
3298
  conn.row_factory = sqlite3.Row
3299
  rows = conn.execute(
3300
  "SELECT id,label,type,degree FROM nodes ORDER BY degree DESC,id LIMIT ?",
 
57
  from __future__ import annotations
58
 
59
  import argparse
60
+ import hashlib
61
  import html
62
  import ipaddress
63
  import json
 
89
  _MONITOR_MUTATIONS_ENABLED = True
90
  _GRAPH_CACHE_KEY: tuple[Any, ...] | None = None
91
  _GRAPH_CACHE_VALUE: Any | None = None
92
+ _OVERLAY_INDEX_COVERAGE_CACHE_KEY: tuple[Any, ...] | None = None
93
+ _OVERLAY_INDEX_COVERAGE_CACHE_VALUE: bool | None = None
94
  _SIDECAR_INDEX_CACHE_KEY: tuple[tuple[Path, float, int], ...] | None = None
95
  _SIDECAR_INDEX_CACHE_VALUE: dict[tuple[str, str], dict] | None = None
96
  _WIKI_INDEX_LIMIT_PER_TYPE = 500
 
2340
  return False
2341
 
2342
 
2343
+ def _overlay_index_coverage_key(index_path: Path, overlay: Path) -> tuple[Any, ...] | None:
2344
+ try:
2345
+ index_stat = index_path.stat()
2346
+ overlay_stat = overlay.stat()
2347
+ except OSError:
2348
+ return None
2349
+ return (
2350
+ index_path.resolve(),
2351
+ index_stat.st_mtime,
2352
+ index_stat.st_size,
2353
+ overlay.resolve(),
2354
+ overlay_stat.st_mtime,
2355
+ overlay_stat.st_size,
2356
+ _dashboard_graph_manifest_export_id(),
2357
+ )
2358
+
2359
+
2360
+ def _active_dashboard_overlay_records(overlay: Path) -> list[dict[str, Any]] | None:
2361
+ try:
2362
+ from ctx.core.graph.entity_overlays import active_overlay_records
2363
+
2364
+ rows = []
2365
+ for line in overlay.read_text(encoding="utf-8").splitlines():
2366
+ line = line.strip()
2367
+ if not line:
2368
+ continue
2369
+ payload = json.loads(line)
2370
+ if not isinstance(payload, dict):
2371
+ return None
2372
+ rows.append(payload)
2373
+ return [dict(row) for row in active_overlay_records(rows)]
2374
+ except (OSError, json.JSONDecodeError, TypeError, ValueError):
2375
+ return None
2376
+
2377
+
2378
+ def _dashboard_overlay_matches_known_release(overlay: Path) -> bool:
2379
+ try:
2380
+ from ctx_init import _GRAPH_ENTITY_OVERLAY_SHA256
2381
+ except (ImportError, AttributeError):
2382
+ return False
2383
+ if not isinstance(_GRAPH_ENTITY_OVERLAY_SHA256, str) or not _GRAPH_ENTITY_OVERLAY_SHA256:
2384
+ return False
2385
+ try:
2386
+ data = overlay.read_bytes().replace(b"\r\n", b"\n")
2387
+ return hashlib.sha256(data).hexdigest() == _GRAPH_ENTITY_OVERLAY_SHA256
2388
+ except OSError:
2389
+ return False
2390
+
2391
+
2392
+ def _dashboard_index_covers_runtime_overlays(index_path: Path) -> bool:
2393
+ """Return True when the shipped SQLite index already includes overlays.
2394
+
2395
+ ``ctx-init`` may install ``entity-overlays.jsonl`` beside a graph export.
2396
+ Older dashboard code treated any overlay file as runtime-only and skipped
2397
+ the SQLite fast path. Current release artifacts can already contain those
2398
+ overlay nodes and edges in ``dashboard-neighborhoods.sqlite3``; in that
2399
+ case loading the full graph just to merge the same small known-release
2400
+ overlay is wasted cold-start work. Local/user overlays still fall back to
2401
+ the full graph merge so newly attached edges remain visible.
2402
+ """
2403
+ overlay = _wiki_dir() / "graphify-out" / "entity-overlays.jsonl"
2404
+ try:
2405
+ if not overlay.is_file() or overlay.stat().st_size == 0:
2406
+ return True
2407
+ except OSError:
2408
+ return True
2409
+ if not index_path.is_file() or not _dashboard_index_matches_manifest(index_path):
2410
+ return False
2411
+
2412
+ global _OVERLAY_INDEX_COVERAGE_CACHE_KEY, _OVERLAY_INDEX_COVERAGE_CACHE_VALUE
2413
+ cache_key = _overlay_index_coverage_key(index_path, overlay)
2414
+ if (
2415
+ cache_key is not None
2416
+ and _OVERLAY_INDEX_COVERAGE_CACHE_KEY == cache_key
2417
+ and _OVERLAY_INDEX_COVERAGE_CACHE_VALUE is not None
2418
+ ):
2419
+ return _OVERLAY_INDEX_COVERAGE_CACHE_VALUE
2420
+
2421
+ if not _dashboard_overlay_matches_known_release(overlay):
2422
+ coverage = False
2423
+ else:
2424
+ records = _active_dashboard_overlay_records(overlay)
2425
+ if records is None:
2426
+ coverage = False
2427
+ else:
2428
+ coverage = True
2429
+ try:
2430
+ conn = sqlite3.connect(f"file:{index_path.as_posix()}?mode=ro", uri=True)
2431
+ conn.row_factory = sqlite3.Row
2432
+ try:
2433
+ for record in records:
2434
+ nodes = record.get("nodes", [])
2435
+ edges = record.get("edges", [])
2436
+ if not isinstance(nodes, list) or not isinstance(edges, list):
2437
+ coverage = False
2438
+ break
2439
+ if not nodes and edges:
2440
+ coverage = False
2441
+ break
2442
+ for node in nodes:
2443
+ if not isinstance(node, dict):
2444
+ coverage = False
2445
+ break
2446
+ node_id = node.get("id")
2447
+ if not isinstance(node_id, str) or not conn.execute(
2448
+ "SELECT 1 FROM nodes WHERE id=? LIMIT 1",
2449
+ (node_id,),
2450
+ ).fetchone():
2451
+ coverage = False
2452
+ break
2453
+ if not coverage:
2454
+ break
2455
+ finally:
2456
+ conn.close()
2457
+ except (OSError, sqlite3.Error, KeyError, TypeError):
2458
+ coverage = False
2459
+
2460
+ if cache_key is not None:
2461
+ _OVERLAY_INDEX_COVERAGE_CACHE_KEY = cache_key
2462
+ _OVERLAY_INDEX_COVERAGE_CACHE_VALUE = coverage
2463
+ return coverage
2464
+
2465
+
2466
  def _dashboard_graph_index_archives() -> list[Path]:
2467
  module_root = Path(__file__).resolve().parent.parent
2468
  roots = (module_root,)
 
2828
  if "/" in slug or "\\" in slug or ".." in slug:
2829
  return {"nodes": [], "edges": [], "center": None}
2830
  normalized_entity_type = _normalize_dashboard_entity_type(entity_type)
2831
+ if (
2832
+ not _dashboard_graph_has_runtime_overlays()
2833
+ or _dashboard_index_covers_runtime_overlays(_dashboard_graph_index_path())
2834
+ ):
2835
  indexed = _graph_neighborhood_from_index(
2836
  slug,
2837
  hops=hops,
 
3416
 
3417
 
3418
  def _top_degree_seeds_from_index(limit: int = 18) -> list[dict]:
3419
+ index_path = _dashboard_graph_index_path()
3420
+ if (
3421
+ _dashboard_graph_has_runtime_overlays()
3422
+ and not _dashboard_index_covers_runtime_overlays(index_path)
3423
+ ):
3424
  return []
3425
+ ensured_index_path = _ensure_dashboard_graph_index()
3426
+ if ensured_index_path is None or not ensured_index_path.is_file():
3427
  return []
3428
  conn: sqlite3.Connection | None = None
3429
  try:
3430
+ conn = sqlite3.connect(f"file:{ensured_index_path.as_posix()}?mode=ro", uri=True)
3431
  conn.row_factory = sqlite3.Row
3432
  rows = conn.execute(
3433
  "SELECT id,label,type,degree FROM nodes ORDER BY degree DESC,id LIMIT ?",
src/tests/test_ctx_monitor.py CHANGED
@@ -3,6 +3,7 @@
3
  from __future__ import annotations
4
 
5
  import http.client
 
6
  import json
7
  import os
8
  import sqlite3
@@ -17,6 +18,7 @@ from pathlib import Path
17
  import pytest
18
 
19
  import ctx_monitor as cm
 
20
  from ctx.core.wiki import wiki_queue
21
 
22
 
@@ -1532,6 +1534,175 @@ def test_graph_neighborhood_uses_dashboard_index_without_full_graph_load(
1532
  }
1533
 
1534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1535
  def test_graph_index_honors_requested_type_on_exact_slug(
1536
  fake_claude: Path,
1537
  ) -> None:
 
3
  from __future__ import annotations
4
 
5
  import http.client
6
+ import hashlib
7
  import json
8
  import os
9
  import sqlite3
 
18
  import pytest
19
 
20
  import ctx_monitor as cm
21
+ import ctx_init as ci
22
  from ctx.core.wiki import wiki_queue
23
 
24
 
 
1534
  }
1535
 
1536
 
1537
+ def test_graph_neighborhood_uses_dashboard_index_when_overlay_is_already_indexed(
1538
+ fake_claude: Path,
1539
+ monkeypatch: pytest.MonkeyPatch,
1540
+ ) -> None:
1541
+ _write_graph_manifest(fake_claude, "test-export")
1542
+ graph_dir = fake_claude / "skill-wiki" / "graphify-out"
1543
+ index_path = graph_dir / "dashboard-neighborhoods.sqlite3"
1544
+ overlay_path = graph_dir / "entity-overlays.jsonl"
1545
+ graph_dir.mkdir(parents=True, exist_ok=True)
1546
+ conn = sqlite3.connect(index_path)
1547
+ try:
1548
+ conn.execute("CREATE TABLE meta(key TEXT PRIMARY KEY, value TEXT NOT NULL)")
1549
+ conn.execute(
1550
+ "CREATE TABLE nodes(id TEXT PRIMARY KEY,label TEXT,type TEXT,tags TEXT,"
1551
+ "description TEXT,quality_score REAL,usage_score REAL,degree INTEGER)"
1552
+ )
1553
+ conn.execute(
1554
+ "CREATE TABLE slug_index(slug TEXT,type TEXT,node_id TEXT,"
1555
+ "PRIMARY KEY(slug,type,node_id))"
1556
+ )
1557
+ conn.execute("CREATE TABLE neighbors(source TEXT PRIMARY KEY, payload BLOB NOT NULL)")
1558
+ conn.executemany(
1559
+ "INSERT INTO meta VALUES(?,?)",
1560
+ [
1561
+ ("max_degree", "10"),
1562
+ ("top_k", "40"),
1563
+ ("export_id", json.dumps("test-export")),
1564
+ ("nodes_count", "2"),
1565
+ ("edges_count", "1"),
1566
+ ],
1567
+ )
1568
+ conn.executemany(
1569
+ "INSERT INTO nodes VALUES(?,?,?,?,?,?,?,?)",
1570
+ [
1571
+ ("harness:mirage", "mirage", "harness", '["sandbox"]', "", 0.82, 0.0, 10),
1572
+ ("skill:codex-review", "codex-review", "skill", '["review"]', "", 0.7, 0.0, 5),
1573
+ ],
1574
+ )
1575
+ conn.executemany(
1576
+ "INSERT INTO slug_index VALUES(?,?,?)",
1577
+ [
1578
+ ("mirage", "harness", "harness:mirage"),
1579
+ ("codex-review", "skill", "skill:codex-review"),
1580
+ ],
1581
+ )
1582
+ conn.execute(
1583
+ "INSERT INTO neighbors VALUES(?,?)",
1584
+ (
1585
+ "harness:mirage",
1586
+ zlib.compress(json.dumps([
1587
+ {
1588
+ "target": "skill:codex-review",
1589
+ "weight": 0.18,
1590
+ "shared_tags": ["sandbox"],
1591
+ },
1592
+ ]).encode("utf-8")),
1593
+ ),
1594
+ )
1595
+ conn.commit()
1596
+ finally:
1597
+ conn.close()
1598
+ overlay_path.write_text(
1599
+ json.dumps({
1600
+ "overlay_id": "mirage-overlay",
1601
+ "nodes": [{"id": "harness:mirage", "type": "harness"}],
1602
+ "edges": [{"source": "harness:mirage", "target": "skill:codex-review"}],
1603
+ })
1604
+ + "\n",
1605
+ encoding="utf-8",
1606
+ )
1607
+ monkeypatch.setattr(cm, "_dashboard_overlay_matches_known_release", lambda overlay: True)
1608
+ monkeypatch.setattr(
1609
+ cm,
1610
+ "_load_dashboard_graph",
1611
+ lambda: (_ for _ in ()).throw(AssertionError("full graph loaded")),
1612
+ )
1613
+
1614
+ result = cm._graph_neighborhood("mirage", entity_type="harness")
1615
+
1616
+ assert result["center"] == "harness:mirage"
1617
+ assert [node["data"]["id"] for node in result["nodes"]] == [
1618
+ "harness:mirage",
1619
+ "skill:codex-review",
1620
+ ]
1621
+
1622
+
1623
+ def test_dashboard_overlay_release_hash_normalizes_crlf(
1624
+ tmp_path: Path,
1625
+ monkeypatch: pytest.MonkeyPatch,
1626
+ ) -> None:
1627
+ overlay = tmp_path / "entity-overlays.jsonl"
1628
+ overlay.write_bytes(b'{"overlay_id":"release"}\r\n')
1629
+ expected = hashlib.sha256(b'{"overlay_id":"release"}\n').hexdigest()
1630
+ monkeypatch.setattr(ci, "_GRAPH_ENTITY_OVERLAY_SHA256", expected)
1631
+
1632
+ assert cm._dashboard_overlay_matches_known_release(overlay)
1633
+
1634
+
1635
+ def test_graph_neighborhood_bypasses_index_for_local_overlay_even_when_node_exists(
1636
+ fake_claude: Path,
1637
+ monkeypatch: pytest.MonkeyPatch,
1638
+ ) -> None:
1639
+ import networkx as nx
1640
+
1641
+ _write_graph_manifest(fake_claude, "test-export")
1642
+ graph_dir = fake_claude / "skill-wiki" / "graphify-out"
1643
+ index_path = graph_dir / "dashboard-neighborhoods.sqlite3"
1644
+ overlay_path = graph_dir / "entity-overlays.jsonl"
1645
+ graph_dir.mkdir(parents=True, exist_ok=True)
1646
+ conn = sqlite3.connect(index_path)
1647
+ try:
1648
+ conn.execute("CREATE TABLE meta(key TEXT PRIMARY KEY, value TEXT NOT NULL)")
1649
+ conn.execute(
1650
+ "CREATE TABLE nodes(id TEXT PRIMARY KEY,label TEXT,type TEXT,tags TEXT,"
1651
+ "description TEXT,quality_score REAL,usage_score REAL,degree INTEGER)"
1652
+ )
1653
+ conn.execute(
1654
+ "CREATE TABLE slug_index(slug TEXT,type TEXT,node_id TEXT,"
1655
+ "PRIMARY KEY(slug,type,node_id))"
1656
+ )
1657
+ conn.execute("CREATE TABLE neighbors(source TEXT PRIMARY KEY, payload BLOB NOT NULL)")
1658
+ conn.executemany(
1659
+ "INSERT INTO meta VALUES(?,?)",
1660
+ [
1661
+ ("max_degree", "10"),
1662
+ ("top_k", "40"),
1663
+ ("export_id", json.dumps("test-export")),
1664
+ ("nodes_count", "1"),
1665
+ ("edges_count", "0"),
1666
+ ],
1667
+ )
1668
+ conn.execute(
1669
+ "INSERT INTO nodes VALUES(?,?,?,?,?,?,?,?)",
1670
+ ("skill:existing", "existing", "skill", "[]", "", 0.7, 0.0, 0),
1671
+ )
1672
+ conn.execute(
1673
+ "INSERT INTO slug_index VALUES(?,?,?)",
1674
+ ("existing", "skill", "skill:existing"),
1675
+ )
1676
+ conn.execute(
1677
+ "INSERT INTO neighbors VALUES(?,?)",
1678
+ ("skill:existing", zlib.compress(b"[]")),
1679
+ )
1680
+ conn.commit()
1681
+ finally:
1682
+ conn.close()
1683
+ overlay_path.write_text(
1684
+ json.dumps({
1685
+ "kind": "ann_attach",
1686
+ "nodes": [{"id": "skill:existing", "type": "skill"}],
1687
+ "edges": [{"source": "skill:existing", "target": "skill:new-runtime-edge"}],
1688
+ })
1689
+ + "\n",
1690
+ encoding="utf-8",
1691
+ )
1692
+ monkeypatch.setattr(
1693
+ cm,
1694
+ "_graph_neighborhood_from_index",
1695
+ lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("index used")),
1696
+ )
1697
+ G = nx.Graph()
1698
+ G.add_node("skill:existing", label="existing", type="skill", tags=[])
1699
+ monkeypatch.setattr(cm, "_load_dashboard_graph", lambda: G)
1700
+
1701
+ result = cm._graph_neighborhood("existing", entity_type="skill")
1702
+
1703
+ assert result["center"] == "skill:existing"
1704
+
1705
+
1706
  def test_graph_index_honors_requested_type_on_exact_slug(
1707
  fake_claude: Path,
1708
  ) -> None: