000-entity-schema-storage

000-entity-schema-storage is an agent for coding agents from paulbreuler/limps. It costs 0 tokens per session (1,794 once invoked), scanned A, original, MIT.

A development task for defining the data types and SQLite storage layer of a knowledge graph in TypeScript. A knowledge graph stores entities, such as plans or files, and the relationships between them.

In plain words
What is it for?
Use it to define entity and relationship types, store entities in SQLite, add indexes for efficient queries, and record metadata such as source paths and update times.
Why use it?
It creates the stable storage foundation needed by later parts of the system, including exact lookups and relationship traversal.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/paulbreuler/limps/000-entity-schema-storage
Clone the repo
git clone --depth 1 https://github.com/paulbreuler/limps

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 000-entity-schema-storage

README.md
[![agentmods](https://agentmods.dev/badge/agents/paulbreuler/limps/000-entity-schema-storage.svg)](https://agentmods.dev/agents/paulbreuler/limps/000-entity-schema-storage)
Your own site
<a href="https://agentmods.dev/agents/paulbreuler/limps/000-entity-schema-storage"><img src="https://agentmods.dev/badge/agents/paulbreuler/limps/000-entity-schema-storage.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,794 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01794
Opus 5 $0.00000 $0.00897
Sonnet 5 $0.00000 $0.00359
Haiku 4.5 $0.00000 $0.00179

Measured 4d ago against content hash 3500f0b0d536, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

000-entity-schema-storage scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plans/0042-Knowledge Graph Foundation/agents/000-entity-schema-storage.agent.md · 248 lines

How it starts

The opening of the file, as written. The whole thing — 248 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent 000: Entity Schema & Storage

Objective

Define entity and relationship types in TypeScript. Implement SQLite storage layer with efficient indexing.

Context

This is the foundation for the entire knowledge graph. All other agents depend on this schema being stable and well-designed.

Key principle: Schema should support deterministic queries (exact lookups) as well as graph traversal. No LLM reasoning happens at this layer.

Tasks

1. Define TypeScript Types (src/graph/types.ts)

export type EntityType = 'plan' | 'agent' | 'feature' | 'file' | 'tag' | 'concept';

export interface Entity {
  id: number;
  type: EntityType;
  canonicalId: string;  // e.g., "plan:0042", "agent:0042#003", "file:src/auth.ts"
  name: string;
  sourcePath?: string;  // Original markdown file
  contentHash?: string; // For change detection
  metadata: Record<string, unknown>;
  createdAt: string;
  updatedAt: string;
}

export type RelationType = 
  | 'CONTAINS'      // plan → agent, plan → feature
  | 'DEPENDS_ON'    // agent → agent
  | 'MODIFIES'      // agent → file
  | 'IMPLEMENTS'    // agent → feature
  | 'SIMILAR_TO'    // feature → feature (with confidence)
  | 'BLOCKS'        // derived: inverse of DEPENDS_ON
  | 'TAGGED_WITH';  // entity → tag

export interface Relationship {
  id: number;
  sourceId: number;
  targetId: number;
  relationType: RelationType;
  confidence: number;  // 0-1, used for SIMILAR_TO
  metadata: Record<string, unknown>;
  createdAt: string;
}

export interface GraphStats {
  entityCounts: Record<EntityType, number>;
  relationCounts: Record<RelationType, number>;
  totalEntities: number;
  totalRelations: number;
  lastIndexed: string;
}

2. SQLite Schema (src/graph/schema.ts)

export const SCHEMA_SQL = `
-- Entities table
CREATE TABLE IF NOT EXISTS entities (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  type TEXT NOT NULL CHECK(type IN ('plan', 'agent', 'feature', 'file', 'tag', 'concept')),
  canonical_id TEXT NOT NULL,
  name TEXT NOT NULL,
  source_path TEXT,
  content_hash TEXT,
  metadata JSON DEFAULT '{}',
  created_at TEXT DEFAULT (datetime('now')),
  updated_at TEXT DEFAULT (datetime('now')),
  UNIQUE(type, canonical_id)
);

-- Relationships table
CREATE TABLE IF NOT EXISTS relationships (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  source_id INTEGER NOT NULL REFERENCES entities(id) ON DELETE CASCADE,
  target_id INTEGER NOT NULL REFERENCES entities(id) ON DELETE CASCADE,
  relation_type TEXT NOT NULL,
  confidence REAL DEFAULT 1.0,
  metadata JSON DEFAULT '{}',
  created_at TEXT DEFAULT (datetime('now')),
  UNIQUE(source_id, target_id, relation_type)
);

-- Indexes for fast lookups
CREATE INDEX IF NOT EXISTS idx_entities_type ON entities(type);
CREATE INDEX IF NOT EXISTS idx_entities_canonical ON entities(canonical_id);
CREATE INDEX IF NOT EXISTS idx_entities_source ON entities(source_path);
CREATE INDEX IF NOT EXISTS idx_entities_hash ON entities(content_hash);

CREATE INDEX IF NOT EXISTS idx_rel_source ON relationships(source_id);
CREATE INDEX IF NOT EXISTS idx_rel_target ON relationships(target_id);
CREATE INDEX IF NOT EXISTS idx_rel_type ON relationships(relation_type);

-- Full-text search on entity names (for lexical retrieval)
CREATE VIRTUAL TABLE IF NOT EXISTS entities_fts USING fts5(
  canonical_id,
  name,
  content='entities',
  content_rowid='id'
);

-- Triggers to keep FTS in sync
CREATE TRIGGER IF NOT EXISTS entities_ai AFTER INSERT ON entities BEGIN
  INSERT INTO entities_fts(rowid, canonical_id, name) VALUES (new.id, new.canonical_id, new.name);
END;

CREATE TRIGGER IF NOT EXISTS entities_ad AFTER DELETE ON entities BEGIN
  INSERT INTO entities_fts(entities_fts, rowid, canonical_id, name) VALUES('delete', old.id, old.canonical_id, old.name);
END;

CREATE TRIGGER IF NOT EXISTS entities_au AFTER UPDATE ON entities BEGIN
  INSERT INTO entities_fts(entities_fts, rowid, canonical_id, name) VALUES('delete', old.id, old.canonical_id, old.name);
  INSERT INTO entities_fts(rowid, canonical_id, name) VALUES (new.id, new.canonical_id, new.name);
END;

-- Graph metadata table
CREATE TABLE IF NOT EXISTS graph_meta (
  key TEXT PRIMARY KEY,
  value TEXT,
  updated_at TEXT DEFAULT (datetime('now'))
);
`;

Read the full file on GitHub · 248 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 248 lines · 0 tokens per session scan A 3500f0b0d536

Subscribe to this mod's changes

000-entity-schema-storage is an agent published in the GitHub repository paulbreuler/limps (10 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,794 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.