Skip to content

Commit 0e77f9c

Browse files
committed
docs: Phase 3 SPARC planning - IP-safe fluent API approach
Major pivot from Cypher-like syntax to original fluent TypeScript API due to IP concerns. Added: - IP-ANALYSIS-PATTERN-MATCHING.md: Legal analysis, safe alternatives - PHASE-3-FLUENT-API-SPEC.md: Complete fluent API specification - PHASE-3-ARCHITECTURE.md: Implementation architecture and roadmap Decision: Original fluent API (not Cypher-like) - PatternQuery: .start().through().end().where().select().exec() - Bulk operations: createNodes(), createEdges(), updateNodes(), etc. - IP-safe, TypeScript-native, consistent with existing DSL Features specified: - Pattern matching with multi-hop traversal - Bulk CRUD operations with transactions - Type-safe with generics - Performance targets: <100ms patterns, 10k+ nodes/sec Next: TDD implementation (Refinement phase) Co-authored-by: Claude Code SPARC Agents
1 parent 0c1bfcf commit 0e77f9c

File tree

5 files changed

+3138
-2684
lines changed

5 files changed

+3138
-2684
lines changed
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# Intellectual Property Analysis: Pattern Matching for Graph Databases
2+
3+
**Date:** November 14, 2025
4+
**Project:** sqlite-graph Phase 3
5+
**Concern:** Cypher-like pattern matching may infringe on Neo4j IP
6+
7+
## Problem Statement
8+
9+
The original Phase 3 specification called for "Cypher-like declarative graph queries" with MATCH clause syntax. This raises IP concerns:
10+
11+
1. **Cypher** is a trademark of Neo4j, Inc.
12+
2. Cypher syntax may be protected intellectual property
13+
3. Even if openCypher is available, compatibility claims could be problematic
14+
4. Legal risk for an open-source project without legal counsel
15+
16+
## IP Risk Assessment
17+
18+
### High Risk: Cypher-Compatible Syntax
19+
```cypher
20+
// This syntax is associated with Neo4j's Cypher
21+
MATCH (j:Job)-[:POSTED_BY]->(c:Company)
22+
WHERE c.name = 'TechCorp'
23+
RETURN j, c
24+
```
25+
26+
**Risks:**
27+
- ❌ Uses Neo4j's trademarked language name
28+
- ❌ Mimics proprietary syntax structure
29+
- ❌ Could be seen as creating a competing implementation
30+
- ❌ May confuse users about Neo4j affiliation
31+
- ❌ Difficult to defend as "independent creation"
32+
33+
### Lower Risk: SQL-Based Pattern Queries
34+
```sql
35+
-- Standard SQL with graph extensions (GQL standard)
36+
SELECT * FROM nodes n1
37+
JOIN edges e ON e.from_id = n1.id
38+
JOIN nodes n2 ON e.to_id = n2.id
39+
WHERE n1.type = 'Job' AND n2.type = 'Company'
40+
AND e.type = 'POSTED_BY'
41+
AND n2.properties->>'name' = 'TechCorp'
42+
```
43+
44+
**Benefits:**
45+
- ✅ Based on SQL (public domain, ISO standard)
46+
- ✅ GQL (Graph Query Language) is an ISO standard (ISO/IEC 39075:2024)
47+
- ✅ No trademark issues
48+
- ✅ Clear lineage from standard SQL
49+
50+
### Safe: Fluent API (Library-Specific)
51+
```typescript
52+
// TypeScript fluent API - clearly original work
53+
db.pattern()
54+
.node('j', 'Job')
55+
.edge('POSTED_BY', 'out')
56+
.node('c', 'Company')
57+
.where({ c: { name: 'TechCorp' } })
58+
.select(['j', 'c'])
59+
.exec();
60+
```
61+
62+
**Benefits:**
63+
- ✅ Original TypeScript API design
64+
- ✅ No resemblance to Cypher syntax
65+
- ✅ Language-idiomatic (TypeScript/JavaScript)
66+
- ✅ Clearly independent implementation
67+
- ✅ Can't be confused with Neo4j
68+
69+
## Recommended Approaches (IP-Safe)
70+
71+
### Option 1: SQL-Based with GQL Alignment (RECOMMENDED)
72+
73+
**Rationale:** GQL is an ISO standard (39075:2024) that incorporates graph patterns into SQL. Using GQL-aligned syntax provides:
74+
- Legal safety (ISO standard, not proprietary)
75+
- Industry recognition
76+
- Future compatibility with standard databases
77+
78+
**API Design:**
79+
```typescript
80+
// SQL-like but type-safe
81+
db.select()
82+
.from('Job', 'j')
83+
.join('POSTED_BY', 'out', 'Company', 'c')
84+
.where({ 'c.name': 'TechCorp' })
85+
.exec();
86+
87+
// Or more graph-specific (GQL-inspired)
88+
db.graphQuery(`
89+
FROM (j:Job)-[:POSTED_BY]->(c:Company)
90+
WHERE c.name = 'TechCorp'
91+
SELECT j, c
92+
`);
93+
```
94+
95+
### Option 2: Fluent TypeScript API (SAFEST)
96+
97+
**Rationale:** Original library design, no IP concerns.
98+
99+
**API Design:**
100+
```typescript
101+
// Fully fluent, TypeScript-native
102+
const pattern = db.pattern()
103+
.node('j', { type: 'Job' })
104+
.relatedTo({ type: 'POSTED_BY', direction: 'out' })
105+
.node('c', { type: 'Company', properties: { name: 'TechCorp' } })
106+
.build();
107+
108+
const results = pattern.execute();
109+
```
110+
111+
### Option 3: SQL Query Builder (CONSERVATIVE)
112+
113+
**Rationale:** Stay close to SQLite, no new query language.
114+
115+
**API Design:**
116+
```typescript
117+
// SQL query builder with graph helpers
118+
db.query()
119+
.selectNodes('Job', 'j')
120+
.whereConnected('POSTED_BY', 'Company', 'c')
121+
.whereProperty('c', 'name', 'TechCorp')
122+
.exec();
123+
```
124+
125+
## Legal Considerations
126+
127+
### What We CAN Do:
128+
- ✅ Implement graph query functionality
129+
- ✅ Use SQL (public domain)
130+
- ✅ Reference GQL standard (ISO 39075:2024)
131+
- ✅ Create original fluent APIs
132+
- ✅ Implement common graph concepts (nodes, edges, patterns)
133+
134+
### What We SHOULD NOT Do:
135+
- ❌ Use "Cypher" in code, docs, or marketing
136+
- ❌ Claim "Cypher compatibility"
137+
- ❌ Copy Neo4j's specific syntax structure
138+
- ❌ Use openCypher branding without review
139+
- ❌ Implement a "Cypher parser"
140+
141+
### Gray Areas (Avoid Without Legal Counsel):
142+
- ⚠️ "Cypher-like" or "Cypher-inspired" language
143+
- ⚠️ Syntax that closely mimics MATCH...WHERE...RETURN
144+
- ⚠️ Using openCypher specification (may have license terms)
145+
- ⚠️ ASCII art patterns: `(a)-[:REL]->(b)` (too similar)
146+
147+
## Prior Art / Safe References
148+
149+
### ISO GQL (Graph Query Language)
150+
- **Status:** ISO/IEC 39075:2024 published April 2024
151+
- **Scope:** SQL extension for property graphs
152+
- **Safety:** International standard, free to implement
153+
- **Syntax:** SQL-based with graph extensions
154+
155+
### Apache TinkerPop / Gremlin
156+
- **Status:** Apache 2.0 license
157+
- **Scope:** Graph traversal language (Java-based)
158+
- **Safety:** Open source, permissive license
159+
- **Approach:** Functional/fluent API
160+
161+
### SPARQL (W3C Standard)
162+
- **Status:** W3C Recommendation
163+
- **Scope:** RDF graph queries
164+
- **Safety:** Open standard
165+
- **Approach:** SQL-like with graph patterns
166+
167+
## Recommendation for sqlite-graph
168+
169+
**Phase 3 Pattern Matching Implementation:**
170+
171+
### PRIMARY: GQL-Aligned SQL Extension
172+
```typescript
173+
// Based on ISO GQL standard, no IP issues
174+
db.gql(`
175+
FROM GRAPH
176+
MATCH (j:Job)-[:POSTED_BY]->(c:Company)
177+
WHERE c.name = 'TechCorp'
178+
RETURN j, c
179+
`);
180+
```
181+
182+
**Why:**
183+
- ISO standard (legally safe)
184+
- Industry credibility
185+
- Future-proof (standard adoption)
186+
- Clear non-Neo4j affiliation
187+
188+
### ALTERNATIVE: Original Fluent API
189+
```typescript
190+
// Original TypeScript design, zero IP risk
191+
db.findPattern()
192+
.start('j', 'Job')
193+
.through('POSTED_BY', 'outgoing')
194+
.end('c', 'Company')
195+
.filter({ 'c.name': 'TechCorp' })
196+
.execute();
197+
```
198+
199+
**Why:**
200+
- Completely original
201+
- TypeScript-idiomatic
202+
- Type-safe
203+
- No confusion with Neo4j
204+
205+
## Action Items
206+
207+
1. **STOP** implementing Cypher-like syntax
208+
2. **DELETE** any Cypher references from spec/architecture docs
209+
3. **RESEARCH** GQL standard (ISO 39075:2024) for safe syntax
210+
4. **DESIGN** either:
211+
- GQL-aligned API (SQL extension approach)
212+
- Original fluent API (safest, most TypeScript-native)
213+
5. **DOCUMENT** clearly: "Not affiliated with Neo4j, not Cypher-compatible"
214+
6. **TRADEMARK CHECK** on any query language names we create
215+
216+
## Conclusion
217+
218+
**Verdict:** PIVOT AWAY FROM CYPHER-LIKE SYNTAX
219+
220+
**Recommended Path:**
221+
1. Implement **GQL-aligned queries** (ISO standard, safe)
222+
2. OR implement **original fluent TypeScript API** (safest)
223+
3. Focus on **SQL-based** or **library-specific** patterns
224+
4. Avoid any Neo4j/Cypher association
225+
226+
**Legal Safety:** HIGH (with GQL or fluent API)
227+
**Feature Parity:** Can achieve same functionality without IP risk
228+
**Timeline Impact:** Minimal (design change, not functionality loss)
229+
230+
---
231+
232+
**Next Steps:**
233+
- Update Phase 3 spec to use GQL or fluent API
234+
- Remove all Cypher references
235+
- Proceed with IP-safe implementation

0 commit comments

Comments
 (0)