Skip to content
Back to skills

Hamster Context Graph Perf

ASecurity

Context graph performance validation for Hamster Studio. Use when changing context graph RPCs, indexes, RLS/security modes, live-docs search, code search / search_code_with_neighbors behavior, or SQL migrations that can affect query plans.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
databasesgobashsqlnodedatabasebackendsecurityperformance

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 27, 2026

npx -y skills add gethamster/skills --skill hamster-context-graph-perf --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Hamster Context Graph Perf?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Hamster Context Graph Perf
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gethamster-hamster-context-graph-perf/badge)](https://www.skillsdirectory.com/skills/gethamster-hamster-context-graph-perf)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: hamster-context-graph-perf
description: "Context graph performance validation for Hamster Studio. Use when changing context graph RPCs, indexes, RLS/security modes, live-docs search, code search / search_code_with_neighbors behavior, or SQL migrations that can affect query plans."
version: "1.0.0"
---

# Hamster Context Graph Perf

Use this with `hamster-database` whenever context graph search SQL, RPCs,
indexes, RLS policies, or live-docs retrieval changes.

## What To Validate

Run the full safety net after `pnpm supabase:web:reset`:

```bash
pnpm seed:context-graph-perf
PGPASSWORD=postgres psql -h 127.0.0.1 -p 54322 -U postgres -d postgres \
  -v ON_ERROR_STOP=1 \
  -f apps/web/supabase/scripts/validate-context-graph-perf.sql
PGPASSWORD=postgres psql -h 127.0.0.1 -p 54322 -U postgres -d postgres \
  -v ON_ERROR_STOP=1 \
  -f .agents/skills/hamster-context-graph-perf/scripts/validate-context-graph-rpc-indexes.sql
```

Also run:

```bash
pnpm supabase:web:diff:drift-check
pnpm --filter hamster-ai test -- search-hamster-docs.tool.spec.ts context-graph-retrieval-backend.service.spec.ts hybrid-merge.spec.ts
pnpm --filter hamster-ai typecheck
```

## Interpreting Results

- `search_fts_only` must move `idx_context_node_segments_fts` on a selective
  term like `synthetic-perf-12345`.
- Vector search is split by segment type into two partial HNSW indexes (a
  minority segment type post-filtered out of a shared graph forces pgvector's
  iterative scan to walk tens of thousands of tuples and blow the 5s
  statement_timeout — this is what timed out code search). Each path carries a
  *constant* `segment_type` guard so the planner picks the right index:
- Non-code semantic (`search_semantic_only`, live-docs) must move
  `idx_context_node_segments_noncode_embedding_hnsw` (predicate
  `segment_type <> 'code_chunk'`).
- Code search (`search_code_with_neighbors`/`hybrid_search_code_segments`
  and `match_code_segments`) must move
  `idx_context_node_segments_code_embedding_hnsw` (predicate
  `segment_type = 'code_chunk'`). A scan delta of 0 here means code search
  fell back onto the shared/non-code index — the regression this guards.
- `get_context_graph_neighborhood` must move both
  `idx_context_edges_source` and `idx_context_edges_target`.
- `search_code_with_neighbors` is the production bundled code-retrieval entry
  point (SECURITY DEFINER hybrid + neighborhood); keep it fast and validate it
  under an authenticated JWT context.
- Live-docs search must use the split RPC path (`search_fts_only` +
  `search_semantic_only`) or otherwise prove that the direct hybrid path does
  not regress. Direct `hybrid_search_code_segments` as `authenticated` can
  benchmark the wrong RLS context and look much slower than the definer
  production path.

## Gotchas

- Do not use `pg_stat_reset()` in local Supabase validation. It can be denied;
  snapshot `pg_stat_user_indexes` before and after the RPC calls instead.
- Do not call `kit.system_global_account_id()` after `SET ROLE authenticated`
  inside ad hoc SQL; use the application constant
  `00000000-0000-0000-0000-00000000d0c5` in caller SQL.
- Broad fixture terms like `synthetic` can match almost every seeded row, so
  Postgres may reasonably choose a sequential scan for FTS. Use a selective
  node term for index assertions.
- Keep schema and migration in sync. If SQL changes, use the normal diff
  workflow and finish with `pnpm supabase:web:diff:drift-check`.

Files in this skill

  • SKILL.md3.4 KB
  • scripts/benchmark-context-graph-inference-buckets.sql2.9 KB
  • scripts/benchmark-context-graph-inference-recall.sql12.2 KB
  • scripts/benchmark-context-graph-inference-sparse.sql3.6 KB
  • scripts/validate-context-graph-rpc-indexes.sql15.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…