[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AVXT7N1RW2A4GKQ6XP1BAX":3,"skill-same:01M7AVXT7N1RW2A4GKQ6XP1BAX":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7AVXT7N1RW2A4GKQ6XP1BAX","neo4j-knowledge-graph-architect",null,"Architect, ingest, query, and test production Neo4j property graphs (LPG) using backward schema modeling, idempotent batch ingestion, and traversal safety. Trigger for Neo4j graphs, Cypher queries, or epistemic graphs. Do not use for W3C RDF\u002FOWL (use \u002Fontological-engineering-coach) or SQL CTEs (use \u002Fsql-recursive-graph-traversal).","SpectreDeath\u002FBrain-Harness","SpectreDeath","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F207463416?v=4","01M7AVGR1D4X8ADT47APKGVH2Z","JL","01M7AVGR2HSGD23BA5DBTJJTVN",0,"MIT","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: neo4j-knowledge-graph-architect\ndescription: Architect, ingest, query, and test production Neo4j property graphs (LPG) using backward schema modeling, idempotent batch ingestion, and traversal safety. Trigger for Neo4j graphs, Cypher queries, or epistemic graphs. Do not use for W3C RDF\u002FOWL (use \u002Fontological-engineering-coach) or SQL CTEs (use \u002Fsql-recursive-graph-traversal).\n---\n\n# Neo4j Knowledge Graph Architect\n\n`neo4j-knowledge-graph-architect` operationalizes Neo4j as an enterprise-grade Labeled Property Graph (LPG) platform. It provides end-to-end guidance for schema design, idempotent batch ingestion, Cypher query engineering, index governance, and ephemeral integration testing. It incorporates epistemic browsing patterns, temporal evidence modeling, and strict boundaries separating primary graph facts from derived analytical inferences.\n\n```\n[1. Schema Design & Semantic Modeling] \n       ↓\n[2. Idempotent Batch Ingestion Engine] \n       ↓\n[3. Cypher Query Engineering & Traversal Safety] \n       ↓\n[4. Index Governance & Query Profiling] \n       ↓\n[5. Ephemeral Test Harnessing & Correctness Validation]\n```\n\nSee [CARD.md](CARD.md) for the companion summary card, 5-stage matrix, core pillars, and anti-pattern checklist.\nSee [REFERENCE.md](REFERENCE.md) for production Cypher templates, EXPLAIN profiling scripts, and test harness fixtures.\nSee [`scripts\u002F`](scripts\u002F) for executable tooling:\n- [`scripts\u002Fcypher_linter.py`](scripts\u002Fcypher_linter.py) — Static Cypher safety analyzer (detects unbounded traversals, trail traps, MERGE mutations).\n- [`scripts\u002Fevidence_model.py`](scripts\u002Fevidence_model.py) — Slotted 7-tuple temporal evidence reification engine (Rule 12).\n- [`scripts\u002Fbatch_ingest.py`](scripts\u002Fbatch_ingest.py) — High-throughput batch ingestion pipeline with chunking and double-load idempotency verification.\nConsult `\u002Fdata-topology-mapper` for structural blast radius mapping and `\u002Fepistemic-isnad-audit` for chain-of-custody lineage.\n\n---\n\n## Disambiguation: Graph Engine Selection\n\nBefore architecting a graph solution, route the domain problem to the appropriate engineering paradigm:\n\n| Requirement \u002F Paradigm | Engine \u002F Technology | Dispatched Skill |\n| :--- | :--- | :--- |\n| **Labeled Property Graph (LPG)**: Deep traversal, index-free adjacency, rich node\u002Frelationship properties, Cypher queries, pattern matching. | **Neo4j** (Bolt protocol) | `\u002Fneo4j-knowledge-graph-architect` (This Skill) |\n| **Relational Graph \u002F Hierarchy**: Direct trees, bill of materials, org charts, pathfinding inside existing PostgreSQL \u002F SQLite databases. | **Relational SQL** (`WITH RECURSIVE`) | `\u002Fsql-recursive-graph-traversal` |\n| **Formal Ontology & Reasoning**: W3C standards, RDF triples, OWL taxonomies, SPARQL endpoints, open-world description logics. | **RDF \u002F Triplestores** | `\u002Fontological-engineering-coach` |\n\n---\n\n## 1. Schema Design & Semantic Modeling\n\nDesign labeled property graph schemas **backwards from competency questions**, ensuring every node label, relationship type, and property serves an explicit query need:\n\n1. **Partition Graph Primitives**:\n   - **Nodes (`:` Label)**: Model distinct business or epistemic entities with independent lifecycles (`Person`, `Paper`, `Claim`, `Institution`).\n   - **Properties (`key: value`)**: Store scalar attributes, metrics, timestamps, and textual descriptions on nodes or edges.\n   - **Relationships (`-[:TYPE]->`)**: Model directed semantic connections as explicit, typed verbs (`AUTHORED`, `CITES`, `AFFILIATED_WITH`, `REFUTES`).\n2. **Apply Backward Competency Modeling**:\n   - Formulate target business\u002Fepistemic questions first (e.g., *\"Which authors published papers refuting claim X between 2024 and 2026?\"*).\n   - Derive the path pattern directly from the question: `(:Author)-[:AUTHORED]->(:Paper)-[:REFUTES]->(:Claim)`.\n   - Validate that relationship directions reflect the semantic action flow while remaining navigable in either direction during query time.\n3. **Model Temporal Evidence Objects**:\n   - For contested, dynamic, or empirical domains, do not use flat timeless edges.\n   - Reify the connection into a 7-tuple temporal evidence object: `(subject, predicate, object, time, source, confidence, status)`.\n   - Represent disputed claims with explicit properties (`confidence: 0.85`, `valid_from: date(\"2025-01-01\")`, `status: \"VERIFIED\"`).\n4. **Enforce the Relation-vs-Inference Boundary**:\n   - Separate **documented primary facts** (direct observations from source literature) from **derived graph analytics** (community clusters, inferred links, PageRank scores).\n   - Tag inferred edges with distinct types or metadata (`inferred: true`, `algorithm: \"louvain\"`, `run_id: \"20260907\"`) to prevent circular hallucinations.\n\n### Axis 3 Diagnostic Questions (Schema Design)\n- *What specific business or analytical competency questions must this graph answer on day one?*\n- *Have all entities with independent identities been isolated as nodes rather than serialized arrays in properties?*\n- *Are relationship types semantically specific verbs (`AUTHORED`, `SUPPORTS`) rather than generic links (`CONNECTED_TO`, `RELATED`)?*\n- *Does the schema distinguish primary observational facts from derived algorithmic inferences?*\n\n> **Completion Criterion**: Annotated schema diagram or Cypher schema contract answering all target competency questions, with unambiguous node\u002Frelationship partitions and temporal evidence properties.\n\n---\n\n## 2. Idempotent Batch Ingestion Engine\n\nConstruct high-throughput, restart-safe data ingestion pipelines utilizing parameterized batches and schema constraints:\n\n1. **Pre-Create Schema Constraints**:\n   - Always declare uniqueness and existence constraints before loading data:\n     ```cypher\n     CREATE CONSTRAINT cst_person_id IF NOT EXISTS\n     FOR (p:Person) REQUIRE p.id IS UNIQUE;\n     CREATE CONSTRAINT cst_paper_doi IF NOT EXISTS\n     FOR (p:Paper) REQUIRE p.doi IS UNIQUE;\n     ```\n   - Schema constraints automatically back properties with underlying range indexes, accelerating `MERGE` lookups from $O(N)$ scans to $O(\\log N)$ seeks.\n2. **Enforce Single Driver Instance Lifecycle**:\n   - Instantiate exactly one `GraphDatabase.driver` instance per application lifecycle.\n   - Manage connection pools through lightweight, short-lived sessions (`driver.session()`) and execute writes inside explicit transaction functions (`session.execute_write(tx_fn)`).\n3. **Execute Parameterized Cypher Exclusively**:\n   - Never use Python string interpolation or f-strings to inject values into Cypher queries.\n   - Pass row batches as structured query parameters (`$batch`) to enable query plan caching and eliminate Cypher injection vulnerabilities.\n4. **Implement Identity-Isolated `MERGE`**:\n   - Scope `MERGE` statements to a single immutable natural identity property.\n   - Set mutable attributes inside `ON CREATE SET` and `ON MATCH SET` clauses:\n     ```cypher\n     UNWIND $batch AS row\n     MERGE (p:Person {id: row.id})\n     ON CREATE SET p.name = row.name, p.created_at = datetime()\n     ON MATCH SET p.name = row.name, p.updated_at = datetime();\n     ```\n5. **Tune Chunk Sizes for Memory Bounding**:\n   - Ingest data in chunks of 1,000 to 5,000 items.\n   - Keep transaction sizes small enough to avoid Java Virtual Machine (JVM) garbage collection pauses and prevent transaction log memory blowout.\n\n### Axis 3 Diagnostic Questions (Ingestion)\n- *Are all `MERGE` target properties protected by unique schema constraints before batch execution begins?*\n- *Is the ingestion query fully parameterized, with zero string interpolation or concatenated values?*\n- *Does each `MERGE` isolate a single immutable natural key, setting other fields via `ON CREATE SET` \u002F `ON MATCH SET`?*\n- *Is the batch size tuned between 1,000 and 5,000 rows to ensure sub-second commit cycles?*\n\n> **Completion Criterion**: Executable Python ingestion script processing structured batches via `UNWIND $batch` with identity-isolated `MERGE`, completing double-runs with zero duplicate nodes or relationships.\n\n---\n\n## 3. Cypher Query Engineering & Traversal Safety\n\nAuthor declarative Cypher queries that leverage index-free adjacency while preventing combinatorial explosion and memory exhaustion:\n\n1. **Anchor Queries & Directional Traversal**:\n   - Anchor graph traversals on indexed start nodes using specific labels and property predicates:\n     ```cypher\n     MATCH (p:Person {id: $person_id})-[:AUTHORED]->(paper:Paper)\n     RETURN paper.title, paper.year;\n     ```\n2. **Mitigate the Cypher Trail Semantics Trap**:\n   - **Neo4j Trail Semantics Rule**: A single path pattern will never traverse the exact same relationship twice.\n   - *Trap*: In diamond patterns (`(a)-[:REL]->(b)-[:REL]->(d)` and `(a)-[:REL]->(c)-[:REL]->(d)`) or cyclic expansions, queries expecting to traverse shared edges across parallel paths may return zero rows if written as a single chained match.\n   - *Mitigation*: Split traversal steps across `WITH` clauses to reset relationship evaluation scopes:\n     ```cypher\n     MATCH (a:Node {id: $id})-[:STEP1]->(b:Node)\n     WITH a, b\n     MATCH (b)-[:STEP2]->(c:Node)\n     RETURN a, b, c;\n     ```\n3. **Bound Variable-Length Relationship Traversal**:\n   - Never write unbounded path patterns (`-[:CONNECTED*]->`).\n   - Always declare explicit lower and upper bounds: `-[:CITES*1..4]->`.\n   - Add inline filtering predicates or depth brakes to prevent factorial path explosions on dense nodes.\n4. **Apply `OPTIONAL MATCH` Semantics**:\n   - Use `OPTIONAL MATCH` for graph outer joins (e.g., retrieving an author whose affiliations may not yet be recorded).\n   - Place required graph anchors in the leading `MATCH` before introducing `OPTIONAL MATCH` branches to prevent full-graph scans.\n5. **Manage Pipeline Scope via `WITH`**:\n   - Use `WITH` to group, aggregate, filter, and page (`ORDER BY`, `SKIP`, `LIMIT`) intermediate rows before expanding to subsequent hops.\n\n### Axis 3 Diagnostic Questions (Query Engineering)\n- *Does every variable-length relationship traversal specify an explicit upper bound (e.g., `*1..4`)?*\n- *Are multi-hop diamond or cyclic traversals properly split across `WITH` boundaries to avoid trail semantics row drops?*\n- *Are optional relationships isolated in `OPTIONAL MATCH` clauses following indexed root anchors?*\n- *Are intermediate result sets pruned with `WITH ... WHERE ...` before secondary expansions?*\n\n> **Completion Criterion**: Cypher queries executing with bounded path depths, correct trail semantics handling, and verified deterministic result sets across test graph topologies.\n\n---\n\n## 4. Index Governance & Query Profiling\n\nGovern Neo4j index structures and profile Cypher execution plans to eliminate bottlenecks before production deployment:\n\n1. **Deploy Specialized Index Types**:\n   - **Range Index**: Default B-tree index for exact matches and scalar comparisons (`n.id`, `n.age > 30`).\n   - **Text Index**: Optimized for substring and regex lookups (`n.name STARTS WITH 'Dr.'`).\n   - **Point Index**: Optimized for 2D\u002F3D spatial coordinate queries (`distance(n.location, $point) \u003C 1000`).\n   - **Fulltext Index**: Lucene-backed full-text search across multiple node labels and string properties.\n   - **Vector Index**: Approximate Nearest Neighbor (ANN) index for high-dimensional embeddings.\n2. **Execute `EXPLAIN` in CI Quality Gates**:\n   - Run `EXPLAIN` on all query templates during static testing.\n   - Verify that queries use `NodeIndexSeek` or `NodeUniqueIndexSeek` rather than full `NodeByLabelScan` or `AllNodesScan`.\n   - Fail CI pipelines if any plan contains an unexpected `CartesianProduct` operator.\n3. **Profile Execution Plans via `PROFILE`**:\n   - Run `PROFILE` on staging environments to inspect actual row counts and database hits (`dbHits`).\n   - Read execution plans from the bottom up:\n     ```\n     ProduceResults\n          ↑\n        Filter\n          ↑\n      Expand(All)\n          ↑\n     NodeIndexSeek\n     ```\n   - Ensure the ratio of `dbHits` to returned rows remains linear ($O(k)$) rather than quadratic ($O(N^2)$).\n\n### Axis 3 Diagnostic Questions (Index & Profiling)\n- *Are query starting nodes resolving via `NodeIndexSeek` or `NodeUniqueIndexSeek`?*\n- *Does any query plan contain an unconstrained `CartesianProduct`?*\n- *Is the total number of `dbHits` proportional to the returned subgraph rather than the entire database size?*\n- *Are text, spatial, and vector searches backed by their respective dedicated index types?*\n\n> **Completion Criterion**: Documented `PROFILE` execution plan showing zero Cartesian products, verified index seek operators on anchor nodes, and bounded `dbHits` metrics.\n\n---\n\n## 5. Ephemeral Test Harnessing & Correctness Validation\n\nValidate graph data pipelines and Cypher queries against real ephemeral database instances:\n\n1. **Enforce Real Database Integration**:\n   - Never rely on in-memory mock libraries (such as mock Neo4j drivers) to validate graph queries.\n   - Spin up real ephemeral Neo4j containers using `Testcontainers` (Python: `testcontainers-neo4j`) or local Docker instances (`neo4j:5-community`).\n2. **Wipe Graph State Between Test Cases**:\n   - Implement teardown fixtures executing `MATCH (n) DETACH DELETE n` to guarantee isolation between unit tests.\n3. **Execute the Double-Load Idempotency Gate**:\n   - Load sample dataset once; record node count $N_1$ and relationship count $R_1$.\n   - Load identical sample dataset a second time; record counts $N_2$ and $R_2$.\n   - Assert $N_1 == N_2$ and $R_1 == R_2$ to confirm total ingestion idempotency.\n4. **Assert Structural and Epistemic Invariants**:\n   - Verify property types, date parsing, constraint violation handling, and path reachability across known edge topologies.\n\n### Axis 3 Diagnostic Questions (Testing)\n- *Is integration testing conducted against an actual Neo4j instance rather than driver mocks?*\n- *Do test suites verify that running batch ingestion twice produces zero duplicate nodes or edges?*\n- *Does the teardown fixture clean up all nodes and relationships between test runs?*\n- *Are unique constraint violations explicitly tested and handled gracefully?*\n\n> **Completion Criterion**: Passing pytest test suite validating schema creation, idempotent batch loading, query correctness, and constraint enforcement against an ephemeral Neo4j container.\n\n---\n\n## Visual Brief & Architectural Seams\n\nDuring complex graph modeling or refactoring workflows, generate an interactive visual brief in the `%TEMP%` directory (e.g. `%TEMP%\\book-to-skill-forge-*.html`). The brief must contain:\n1. Mermaid diagram of the target graph schema (Node labels, Relationship types, Key properties).\n2. Competency question matrix mapping queries to Cypher path expressions.\n3. Index coverage and constraint definitions.\n4. Epistemic evidence boundaries separating primary facts from derived inferences.\n\n---\n\n## Mandatory Checkpoint & Plan Submission\n\nBefore executing mutating Cypher scripts, schema drops, or database migrations:\n1. Submit an `implementation_plan.md` artifact specifying the planned schema modifications, migration scripts, and rollback procedures.\n2. Mark the plan with `RequestFeedback: true`.\n3. Halt execution and await explicit user review and approval before mutating persistent graph stores.\n\n---\n\n## In-File Reference: Core Graph Vocabulary\n\n- **Index-Free Adjacency (IFA)**: The core storage architecture where nodes maintain direct physical memory pointers to their adjacent relationships and neighbors, allowing traversals to execute in $O(k)$ time relative to degree $k$, independent of total graph size $N$.\n- **Trail Semantics**: Neo4j's graph traversal rule specifying that within a single path pattern, no relationship can be traversed more than once.\n- **Hop Count**: The distance or number of relationship edges traversed between two nodes in a graph path.\n- **Bolt Protocol**: The binary network protocol operating over TCP or WebSockets used for high-performance communication between client drivers and the Neo4j database engine.\n- **dbHits**: Neo4j execution metric representing the discrete storage engine operations required to retrieve or update an entity, property, or pointer.\n- **Anchor Query**: The initial matching clause that leverages an index or unique identifier to pinpoint the root nodes from which graph traversal begins.\n\n---\n\n## Anti-Patterns\n\n- **Generic Relationship Stagnation** — Use descriptive, semantically rich relationship types (`AUTHORED`, `VALIDATED_BY`, `CHALLENGES`) rather than generic links (`CONNECTED_TO`, `RELATED`).\n- **Connection as Property Anti-Pattern** — Model entity-to-entity associations as first-class directed relationships rather than embedding foreign ID arrays or serialized lists inside node properties.\n- **Everything as Node Sprawl** — Restrict nodes to entities with independent identity, lifecycle, or multi-edge connectivity; model scalar metadata, metrics, and timestamps as properties.\n- **Compound MERGE Duplicate Explosion** — Scope `MERGE` statements to a single immutable natural identity key, moving mutable properties to explicit `ON CREATE SET` and `ON MATCH SET` clauses.\n- **Unbounded Traversal Blowout** — Enforce strict upper path bounds (`[*1..4]`) and filtering predicates on all variable-length graph traversals to protect query memory and prevent server crashes.\n- **Relationship Uniqueness Silent Drop** — Split cyclic or diamond traversals across separate `MATCH ... WITH ... MATCH` clauses when edges must be revisited across different paths, circumventing Cypher trail semantics traps.\n- **Mock Database Testing Mirage** — Validate graph schema, Cypher syntax, and constraint enforcement against real ephemeral Neo4j containers rather than in-memory mocks that mask driver and query execution errors.\n- **Unconstrained Transaction OOM** — Ingest large graph datasets via parameterized `UNWIND $batch` transactions in chunks of 1,000 to 5,000 items rather than opening monolithic gigabyte-scale write transactions.\n- **Timeless Relationship Fallacy** — Model relationship lifecycles using explicit valid-time timestamps, versions, or reified temporal evidence objects rather than assuming static, permanent edges.\n- **Relation-Inference Conflation** — Maintain strict boundary layers separating primary observed facts from derived graph analytics, marking hypotheses with confidence scores and evidence status.\n","# Neo4j Knowledge Graph Architect\n\n`neo4j-knowledge-graph-architect` operationalizes Neo4j as an enterprise-grade Labeled Property Graph (LPG) platform. It provides end-to-end guidance for schema design, idempotent batch ingestion, Cypher query engineering, index governance, and ephemeral integration testing. It incorporates epistemic browsing patterns, temporal evidence modeling, and strict boundaries separating primary graph facts from derived analytical inferences.\n\n```\n[1. Schema Design & Semantic Modeling] \n       ↓\n[2. Idempotent Batch Ingestion Engine] \n       ↓\n[3. Cypher Query Engineering & Traversal Safety] \n       ↓\n[4. Index Governance & Query Profiling] \n       ↓\n[5. Ephemeral Test Harnessing & Correctness Validation]\n```\n\nSee [CARD.md](CARD.md) for the companion summary card, 5-stage matrix, core pillars, and anti-pattern checklist.\nSee [REFERENCE.md](REFERENCE.md) for production Cypher templates, EXPLAIN profiling scripts, and test harness fixtures.\nSee [`scripts\u002F`](scripts\u002F) for executable tooling:\n- [`scripts\u002Fcypher_linter.py`](scripts\u002Fcypher_linter.py) — Static Cypher safety analyzer (detects unbounded traversals, trail traps, MERGE mutations).\n- [`scripts\u002Fevidence_model.py`](scripts\u002Fevidence_model.py) — Slotted 7-tuple temporal evidence reification engine (Rule 12).\n- [`scripts\u002Fbatch_ingest.py`](scripts\u002Fbatch_ingest.py) — High-throughput batch ingestion pipeline with chunking and double-load idempotency verification.\nConsult `\u002Fdata-topology-mapper` for structural blast radius mapping and `\u002Fepistemic-isnad-audit` for chain-of-custody lineage.\n\n---\n\n## Disambiguation: Graph Engine Selection\n\nBefore architecting a graph solution, route the domain problem to the appropriate engineering paradigm:\n\n| Requirement \u002F Paradigm | Engine \u002F Technology | Dispatched Skill |\n| :--- | :--- | :--- |\n| **Labeled Property Graph (LPG)**: Deep traversal, index-free adjacency, rich node\u002Frelationship properties, Cypher queries, pattern matching. | **Neo4j** (Bolt protocol) | `\u002Fneo4j-knowledge-graph-architect` (This Skill) |\n| **Relational Graph \u002F Hierarchy**: Direct trees, bill of materials, org charts, pathfinding inside existing PostgreSQL \u002F SQLite databases. | **Relational SQL** (`WITH RECURSIVE`) | `\u002Fsql-recursive-graph-traversal` |\n| **Formal Ontology & Reasoning**: W3C standards, RDF triples, OWL taxonomies, SPARQL endpoints, open-world description logics. | **RDF \u002F Triplestores** | `\u002Fontological-engineering-coach` |\n\n---\n\n## 1. Schema Design & Semantic Modeling\n\nDesign labeled property graph schemas **backwards from competency questions**, ensuring every node label, relationship type, and property serves an explicit query need:\n\n1. **Partition Graph Primitives**:\n   - **Nodes (`:` Label)**: Model distinct business or epistemic entities with independent lifecycles (`Person`, `Paper`, `Claim`, `Institution`).\n   - **Properties (`key: value`)**: Store scalar attributes, metrics, timestamps, and textual descriptions on nodes or edges.\n   - **Relationships (`-[:TYPE]->`)**: Model directed semantic connections as explicit, typed verbs (`AUTHORED`, `CITES`, `AFFILIATED_WITH`, `REFUTES`).\n2. **Apply Backward Competency Modeling**:\n   - Formulate target business\u002Fepistemic questions first (e.g., *\"Which authors published papers refuting claim X between 2024 and 2026?\"*).\n   - Derive the path pattern directly from the question: `(:Author)-[:AUTHORED]->(:Paper)-[:REFUTES]->(:Claim)`.\n   - Validate that relationship directions reflect the semantic action flow while remaining navigable in either direction during query time.\n3. **Model Temporal Evidence Objects**:\n   - For contested, dynamic, or empirical domains, do not use flat timeless edges.\n   - Reify the connection into a 7-tuple temporal evidence object: `(subject, predicate, object, time, source, confidence, status)`.\n   - Represent disputed claims with explicit properties (`confidence: 0.85`, `valid_from: date(\"2025-01-01\")`, `status: \"VERIFIED\"`).\n4. **Enforce the Relation-vs-Inference Boundary**:\n   - Separate **documented primary facts** (direct observations from source literature) from **derived graph analytics** (community clusters, inferred links, PageRank scores).\n   - Tag inferred edges with distinct types or metadata (`inferred: true`, `algorithm: \"louvain\"`, `run_id: \"20260907\"`) to prevent circular hallucinations.\n\n### Axis 3 Diagnostic Questions (Schema Design)\n- *What specific business or analytical competency questions must this graph answer on day one?*\n- *Have all entities with independent identities been isolated as nodes rather than serialized arrays in properties?*\n- *Are relationship types semantically specific verbs (`AUTHORED`, `SUPPORTS`) rather than generic links (`CONNECTED_TO`, `RELATED`)?*\n- *Does the schema distinguish primary observational facts from derived algorithmic inferences?*\n\n> **Completion Criterion**: Annotated schema diagram or Cypher schema contract answering all target competency questions, with unambiguous node\u002Frelationship partitions and temporal evidence properties.\n\n---\n\n## 2. Idempotent Batch Ingestion Engine\n\nConstruct high-throughput, restart-safe data ingestion pipelines utilizing parameterized batches and schema constraints:\n\n1. **Pre-Create Schema Constraints**:\n   - Always declare uniqueness and existence constraints before loading data:\n     ```cypher\n     CREATE CONSTRAINT cst_person_id IF NOT EXISTS\n     FOR (p:Person) REQUIRE p.id IS UNIQUE;\n     CREATE CONSTRAINT cst_paper_doi IF NOT EXISTS\n     FOR (p:Paper) REQUIRE p.doi IS UNIQUE;\n     ```\n   - Schema constraints automatically back properties with underlying range indexes, accelerating `MERGE` lookups from $O(N)$ scans to $O(\\log N)$ seeks.\n2. **Enforce Single Driver Instance Lifecycle**:\n   - Instantiate exactly one `GraphDatabase.driver` instance per application lifecycle.\n   - Manage connection pools through lightweight, short-lived sessions (`driver.session()`) and execute writes inside explicit transaction functions (`session.execute_write(tx_fn)`).\n3. **Execute Parameterized Cypher Exclusively**:\n   - Never use Python string interpolation or f-strings to inject values into Cypher queries.\n   - Pass row batches as structured query parameters (`$batch`) to enable query plan caching and eliminate Cypher injection vulnerabilities.\n4. **Implement Identity-Isolated `MERGE`**:\n   - Scope `MERGE` statements to a single immutable natural identity property.\n   - Set mutable attributes inside `ON CREATE SET` and `ON MATCH SET` clauses:\n     ```cypher\n     UNWIND $batch AS row\n     MERGE (p:Person {id: row.id})\n     ON CREATE SET p.name = row.name, p.created_at = datetime()\n     ON MATCH SET p.name = row.name, p.updated_at = datetime();\n     ```\n5. **Tune Chunk Sizes for Memory Bounding**:\n   - Ingest data in chunks of 1,000 to 5,000 items.\n   - Keep transaction sizes small enough to avoid Java Virtual Machine (JVM) garbage collection pauses and prevent transaction log memory blowout.\n\n### Axis 3 Diagnostic Questions (Ingestion)\n- *Are all `MERGE` target properties protected by unique schema constraints before batch execution begins?*\n- *Is the ingestion query fully parameterized, with zero string interpolation or concatenated values?*\n- *Does each `MERGE` isolate a single immutable natural key, setting other fields via `ON CREATE SET` \u002F `ON MATCH SET`?*\n- *Is the batch size tuned between 1,000 and 5,000 rows to ensure sub-second commit cycles?*\n\n> **Completion Criterion**: Executable Python ingestion script processing structured batches via `UNWIND $batch` with identity-isolated `MERGE`, completing double-runs with zero duplicate nodes or relationships.\n\n---\n\n## 3. Cypher Query Engineering & Traversal Safety\n\nAuthor declarative Cypher queries that leverage index-free adjacency while preventing combinatorial explosion and memory exhaustion:\n\n1. **Anchor Queries & Directional Traversal**:\n   - Anchor graph traversals on indexed start nodes using specific labels and property predicates:\n     ```cypher\n     MATCH (p:Person {id: $person_id})-[:AUTHORED]->(paper:Paper)\n     RETURN paper.title, paper.year;\n     ```\n2. **Mitigate the Cypher Trail Semantics Trap**:\n   - **Neo4j Trail Semantics Rule**: A single path pattern will never traverse the exact same relationship twice.\n   - *Trap*: In diamond patterns (`(a)-[:REL]->(b)-[:REL]->(d)` and `(a)-[:REL]->(c)-[:REL]->(d)`) or cyclic expansions, queries expecting to traverse shared edges across parallel paths may return zero rows if written as a single chained match.\n   - *Mitigation*: Split traversal steps across `WITH` clauses to reset relationship evaluation scopes:\n     ```cypher\n     MATCH (a:Node {id: $id})-[:STEP1]->(b:Node)\n     WITH a, b\n     MATCH (b)-[:STEP2]->(c:Node)\n     RETURN a, b, c;\n     ```\n3. **Bound Variable-Length Relationship Traversal**:\n   - Never write unbounded path patterns (`-[:CONNECTED*]->`).\n   - Always declare explicit lower and upper bounds: `-[:CITES*1..4]->`.\n   - Add inline filtering predicates or depth brakes to prevent factorial path explosions on dense nodes.\n4. **Apply `OPTIONAL MATCH` Semantics**:\n   - Use `OPTIONAL MATCH` for graph outer joins (e.g., retrieving an author whose affiliations may not yet be recorded).\n   - Place required graph anchors in the leading `MATCH` before introducing `OPTIONAL MATCH` branches to prevent full-graph scans.\n5. **Manage Pipeline Scope via `WITH`**:\n   - Use `WITH` to group, aggregate, filter, and page (`ORDER BY`, `SKIP`, `LIMIT`) intermediate rows before expanding to subsequent hops.\n\n### Axis 3 Diagnostic Questions (Query Engineering)\n- *Does every variable-length relationship traversal specify an explicit upper bound (e.g., `*1..4`)?*\n- *Are multi-hop diamond or cyclic traversals properly split across `WITH` boundaries to avoid trail semantics row drops?*\n- *Are optional relationships isolated in `OPTIONAL MATCH` clauses following indexed root anchors?*\n- *Are intermediate result sets pruned with `WITH ... WHERE ...` before secondary expansions?*\n\n> **Completion Criterion**: Cypher queries executing with bounded path depths, correct trail semantics handling, and verified deterministic result sets across test graph topologies.\n\n---\n\n## 4. Index Governance & Query Profiling\n\nGovern Neo4j index structures and profile Cypher execution plans to eliminate bottlenecks before production deployment:\n\n1. **Deploy Specialized Index Types**:\n   - **Range Index**: Default B-tree index for exact matches and scalar comparisons (`n.id`, `n.age > 30`).\n   - **Text Index**: Optimized for substring and regex lookups (`n.name STARTS WITH 'Dr.'`).\n   - **Point Index**: Optimized for 2D\u002F3D spatial coordinate queries (`distance(n.location, $point) \u003C 1000`).\n   - **Fulltext Index**: Lucene-backed full-text search across multiple node labels and string properties.\n   - **Vector Index**: Approximate Nearest Neighbor (ANN) index for high-dimensional embeddings.\n2. **Execute `EXPLAIN` in CI Quality Gates**:\n   - Run `EXPLAIN` on all query templates during static testing.\n   - Verify that queries use `NodeIndexSeek` or `NodeUniqueIndexSeek` rather than full `NodeByLabelScan` or `AllNodesScan`.\n   - Fail CI pipelines if any plan contains an unexpected `CartesianProduct` operator.\n3. **Profile Execution Plans via `PROFILE`**:\n   - Run `PROFILE` on staging environments to inspect actual row counts and database hits (`dbHits`).\n   - Read execution plans from the bottom up:\n     ```\n     ProduceResults\n          ↑\n        Filter\n          ↑\n      Expand(All)\n          ↑\n     NodeIndexSeek\n     ```\n   - Ensure the ratio of `dbHits` to returned rows remains linear ($O(k)$) rather than quadratic ($O(N^2)$).\n\n### Axis 3 Diagnostic Questions (Index & Profiling)\n- *Are query starting nodes resolving via `NodeIndexSeek` or `NodeUniqueIndexSeek`?*\n- *Does any query plan contain an unconstrained `CartesianProduct`?*\n- *Is the total number of `dbHits` proportional to the returned subgraph rather than the entire database size?*\n- *Are text, spatial, and vector searches backed by their respective dedicated index types?*\n\n> **Completion Criterion**: Documented `PROFILE` execution plan showing zero Cartesian products, verified index seek operators on anchor nodes, and bounded `dbHits` metrics.\n\n---\n\n## 5. Ephemeral Test Harnessing & Correctness Validation\n\nValidate graph data pipelines and Cypher queries against real ephemeral database instances:\n\n1. **Enforce Real Database Integration**:\n   - Never rely on in-memory mock libraries (such as mock Neo4j drivers) to validate graph queries.\n   - Spin up real ephemeral Neo4j containers using `Testcontainers` (Python: `testcontainers-neo4j`) or local Docker instances (`neo4j:5-community`).\n2. **Wipe Graph State Between Test Cases**:\n   - Implement teardown fixtures executing `MATCH (n) DETACH DELETE n` to guarantee isolation between unit tests.\n3. **Execute the Double-Load Idempotency Gate**:\n   - Load sample dataset once; record node count $N_1$ and relationship count $R_1$.\n   - Load identical sample dataset a second time; record counts $N_2$ and $R_2$.\n   - Assert $N_1 == N_2$ and $R_1 == R_2$ to confirm total ingestion idempotency.\n4. **Assert Structural and Epistemic Invariants**:\n   - Verify property types, date parsing, constraint violation handling, and path reachability across known edge topologies.\n\n### Axis 3 Diagnostic Questions (Testing)\n- *Is integration testing conducted against an actual Neo4j instance rather than driver mocks?*\n- *Do test suites verify that running batch ingestion twice produces zero duplicate nodes or edges?*\n- *Does the teardown fixture clean up all nodes and relationships between test runs?*\n- *Are unique constraint violations explicitly tested and handled gracefully?*\n\n> **Completion Criterion**: Passing pytest test suite validating schema creation, idempotent batch loading, query correctness, and constraint enforcement against an ephemeral Neo4j container.\n\n---\n\n## Visual Brief & Architectural Seams\n\nDuring complex graph modeling or refactoring workflows, generate an interactive visual brief in the `%TEMP%` directory (e.g. `%TEMP%\\book-to-skill-forge-*.html`). The brief must contain:\n1. Mermaid diagram of the target graph schema (Node labels, Relationship types, Key properties).\n2. Competency question matrix mapping queries to Cypher path expressions.\n3. Index coverage and constraint definitions.\n4. Epistemic evidence boundaries separating primary facts from derived inferences.\n\n---\n\n## Mandatory Checkpoint & Plan Submission\n\nBefore executing mutating Cypher scripts, schema drops, or database migrations:\n1. Submit an `implementation_plan.md` artifact specifying the planned schema modifications, migration scripts, and rollback procedures.\n2. Mark the plan with `RequestFeedback: true`.\n3. Halt execution and await explicit user review and approval before mutating persistent graph stores.\n\n---\n\n## In-File Reference: Core Graph Vocabulary\n\n- **Index-Free Adjacency (IFA)**: The core storage architecture where nodes maintain direct physical memory pointers to their adjacent relationships and neighbors, allowing traversals to execute in $O(k)$ time relative to degree $k$, independent of total graph size $N$.\n- **Trail Semantics**: Neo4j's graph traversal rule specifying that within a single path pattern, no relationship can be traversed more than once.\n- **Hop Count**: The distance or number of relationship edges traversed between two nodes in a graph path.\n- **Bolt Protocol**: The binary network protocol operating over TCP or WebSockets used for high-performance communication between client drivers and the Neo4j database engine.\n- **dbHits**: Neo4j execution metric representing the discrete storage engine operations required to retrieve or update an entity, property, or pointer.\n- **Anchor Query**: The initial matching clause that leverages an index or unique identifier to pinpoint the root nodes from which graph traversal begins.\n\n---\n\n## Anti-Patterns\n\n- **Generic Relationship Stagnation** — Use descriptive, semantically rich relationship types (`AUTHORED`, `VALIDATED_BY`, `CHALLENGES`) rather than generic links (`CONNECTED_TO`, `RELATED`).\n- **Connection as Property Anti-Pattern** — Model entity-to-entity associations as first-class directed relationships rather than embedding foreign ID arrays or serialized lists inside node properties.\n- **Everything as Node Sprawl** — Restrict nodes to entities with independent identity, lifecycle, or multi-edge connectivity; model scalar metadata, metrics, and timestamps as properties.\n- **Compound MERGE Duplicate Explosion** — Scope `MERGE` statements to a single immutable natural identity key, moving mutable properties to explicit `ON CREATE SET` and `ON MATCH SET` clauses.\n- **Unbounded Traversal Blowout** — Enforce strict upper path bounds (`[*1..4]`) and filtering predicates on all variable-length graph traversals to protect query memory and prevent server crashes.\n- **Relationship Uniqueness Silent Drop** — Split cyclic or diamond traversals across separate `MATCH ... WITH ... MATCH` clauses when edges must be revisited across different paths, circumventing Cypher trail semantics traps.\n- **Mock Database Testing Mirage** — Validate graph schema, Cypher syntax, and constraint enforcement against real ephemeral Neo4j containers rather than in-memory mocks that mask driver and query execution errors.\n- **Unconstrained Transaction OOM** — Ingest large graph datasets via parameterized `UNWIND $batch` transactions in chunks of 1,000 to 5,000 items rather than opening monolithic gigabyte-scale write transactions.\n- **Timeless Relationship Fallacy** — Model relationship lifecycles using explicit valid-time timestamps, versions, or reified temporal evidence objects rather than assuming static, permanent edges.\n- **Relation-Inference Conflation** — Maintain strict boundary layers separating primary observed facts from derived graph analytics, marking hypotheses with confidence scores and evidence status.\n",{"name":5,"description":7},"main","eff3b00e36d1d233ad4a4389605c82fbfa0326d3",".agents\u002Fskills\u002Fneo4j-knowledge-graph-architect","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness","https:\u002F\u002Fgithub.com\u002FSpectreDeath","I'm here to manage stress so I wouldn't expect earth shattering break throughs I'm just an enthusiast that likes making stuff. ","2026-11-15 05:32:58",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add SpectreDeath\u002FBrain-Harness --skill neo4j-knowledge-graph-architect",{"tool":37,"command":38},"bunx","bunx skills add SpectreDeath\u002FBrain-Harness --skill neo4j-knowledge-graph-architect",{"tool":40,"command":41},"pnpm","pnpm dlx skills add SpectreDeath\u002FBrain-Harness --skill neo4j-knowledge-graph-architect","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002FSKILL.md",true,[45,51,55,59,65,69,73],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"CARD.md","REFERENCE","参考文档",6846,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002FCARD.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"config.default.yaml",360,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002Fconfig.default.yaml",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"REFERENCE.md",7496,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002FREFERENCE.md",{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"scripts\u002F__init__.py","SCRIPT","脚本",651,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002Fscripts\u002F__init__.py",{"path":66,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":67,"sourceHtmlUrl":68},"scripts\u002Fbatch_ingest.py",8461,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002Fscripts\u002Fbatch_ingest.py",{"path":70,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":71,"sourceHtmlUrl":72},"scripts\u002Fcypher_linter.py",10098,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002Fscripts\u002Fcypher_linter.py",{"path":74,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":75,"sourceHtmlUrl":76},"scripts\u002Fevidence_model.py",6689,"https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fneo4j-knowledge-graph-architect\u002Fscripts\u002Fevidence_model.py",[78,85,92,99,106,113],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7E0W6FR68J2N9CXCZTAQJFX","ui-behavior-primitive-architect","Architect, audit, and verify zero-dependency headless UI behavior primitives, WebMCP agent bridges, WAI-ARIA\u002FSSR\u002FRTL tri-modal checks, and framework expert routing. Do not use for static CSS theme styling or backend database migrations.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fui-behavior-primitive-architect\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7E0VZ7JQNW34G271DENFGYP","trustgraph-ontology-governor","Govern knowledge graphs, SHACL-AF triple policies, OntologyRAG subclass validation, PROV-O dual named graphs, and Laya entropy decision scoring. Do not use for relational SQL queries or generic web scraping.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftrustgraph-ontology-governor\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M7E0VQ6Z7R45Q8QAZ4MT39EK","shim-harness-governor","Govern universal CLI agent loops, 4-tier tool permissions, ancestor-symlink workspace sandboxes, deterministic-first command routing, collision-safe MCP namespacing, and layered skill loading. Do not use for static UI styling or external SQL analytics.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fshim-harness-governor\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M7E0VC18NMP1QBSRJ3TPQ7MB","graphiti-zep-memory-governor","Govern bi-temporal knowledge graphs with Graphiti future-edge clamping, MinHash\u002FLSH entity dedup, RRF\u002FMMR reranking, and Zep typed ontologies. Do not use for static SQL joins or generic web crawling.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fgraphiti-zep-memory-governor\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":19},"01M7E0V12ABE1RW3ZRCST8VH5Z","agora-mcp-workbench-architect","Architect, audit, and orchestrate Agora Workbench MCP servers, loopback sidecars, unified state graphs, gateway\u002Fdispatcher connectors, and policy-enforced data lakes. Do not use for static frontend CSS styling or non-MCP desktop GUI automation.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fagora-mcp-workbench-architect\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":19},"01M7BFYG6QT3484VC57TZ19V7P","skill-eval-assurance-runner","Evaluate and assure agent skills using small-N Wilson confidence intervals, unbiased pass^k reliability, deterministic trajectory graders, preflight boundary honesty, and sealed digest verification. Do not use for subjective prose review or unconstrained production deployment.","https:\u002F\u002Fgithub.com\u002FSpectreDeath\u002FBrain-Harness\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fskill-eval-assurance-runner\u002FSKILL.md",[],[]]