8000 docs: simplify the README and project guidance (v2.x) by adityamukho · Pull Request #975 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Fixes # (issue number, if applicable)
- [ ] `cargo clippy -- -D warnings` is clean
- [ ] `cargo fmt --check` passes
- [ ] New code has tests (unit and/or integration)
- [ ] Error paths are tested, not just happy paths
- [ ] Tests cover success and error paths, including relevant invalid input and I/O errors
- [ ] No `unwrap()` / `expect()` in library code paths
- [ ] `CHANGELOG.md` updated under `Unreleased`
- [ ] I have read [PHILOSOPHY.md](../PHILOSOPHY.md) and this change aligns with it
Expand Down
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ See `ROADMAP.md` for planned work and current direction. See `CHANGELOG.md` for
**Before implementing ANY feature or change, you MUST assess it against the design philosophy in PHILOSOPHY.md.**

Minigraf follows the "SQLite for bi-temporal graph databases" philosophy:
- **Zero-configuration** - No setup, no config files, just works
- **Zero configuration** - Open a database file without a server or configuration file
- **Embedded-first** - Library not server, in-process execution
- **Single-file database** - One portable `.graph` file
- **Self-contained** - Minimal dependencies, small binary (~1.2MB budget as of #277; see PHILOSOPHY.md §4)
- **Cross-platform** - Native, WASM, mobile, embedded
- **Reliability over features** - Do less, do it perfectly
- **Bi-temporal first-class** - Time travel is a core feature, not addon
- **Bi-temporal queries** - Both transaction time and valid time are part of the core API
- **Datalog queries** - Simpler, more powerful for graphs than SQL/GQL
- **Stability** - Backwards compatibility, stable file format
- **Long-term support** - Decades-long commitment
Expand Down Expand Up @@ -224,7 +224,7 @@ Applies to all `#[cfg(test)]` modules and all `tests/*.rs` files.

1. **Always use git worktrees for new features/bugfixes** — Never make changes directly on main. Create an isolated worktree (in `.worktrees/` directory) using the `using-git-worktrees` skill before implementing any feature or fixing any issue.
2. **Datalog is the query language** — no other query language
2. **Bi-temporal is first-class** — not an afterthought
2. **Preserve both timelines** in storage and queries: transaction time and valid time
3. **Single file is sacred** — never break this
4. **Simplicity over features** — do less, do it perfectly
5. **Test everything** — no untested code
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Run branch coverage to check overall project health before submitting a PR.
- **Every new feature needs tests** — unit tests in the relevant `src/` module plus integration tests in `tests/` where applicable
- **Clippy must pass** — `cargo clippy -- -D warnings` must be clean
- **Format your code** — `cargo fmt` before committing
- **Error paths matter** — test failure cases, not just happy paths
- **Error handling** — Test success and error paths, including relevant invalid input and I/O errors

## Pull Request Process

Expand Down Expand Up @@ -128,7 +128,7 @@ Releases are managed by the project maintainer. The process is documented in iss
5. From a clean checkout of the final candidate commit, run `cargo publish --dry-run --locked` before creating the tag. Record the commit SHA and result in the release issue; a failure must be resolved before tagging. `Cargo.lock` is currently untracked, so this check does not establish that CI and publishing used the same dependency resolution.
6. Confirm successful push runs of Rust, WASM, Lint, Coverage Gates, Policy and Binary Size on that exact SHA. A successful PR run or a run on an earlier commit is insufficient. Workflows absent from the candidate branch are skipped; a present workflow with no successful latest push run blocks the cascade.
7. Push the version tag, including the prerelease suffix when applicable (for example, `v3.0.0-alpha`). After Release succeeds, Release Cascade validates the official tag-push run and its commit, checks CI, then waits up to 60 minutes for the exact, unyanked crate version in the Cargo sparse index before dispatching bindings.
8. Every binding, including Tier 2, publishes every core release in lock-step, including prereleases; a binding that cannot publish blocks the release until it is fixed or successfully re-dispatched (see [support tiers](PHILOSOPHY.md#support-tiers))
8. Publish every binding, including Tier 2, at the matching core version. Use the registry’s version spelling for prereleases. A binding that cannot publish blocks the release until the problem is fixed or a retry succeeds (see [support tiers](PHILOSOPHY.md#support-tiers)).
9. Known-issues issue updated, and `data-integrity`/`corruption`/`durability` issues fixed by this release closed with a link to it (see above)

Release uses cargo-dist's `local-artifacts-jobs` hook to run Release Gate. Failed or cancelled CI on the tagged commit blocks GitHub hosting and crates.io publishing. The gate records the accepted run URLs in its log; after CI succeeds, retry the failed Release run. To update release automation, edit `dist-workspace.toml` and the reusable workflows, then run `dist generate --mode ci` and `dist generate --mode ci --check` with the pinned cargo-dist version. Do not edit `release.yml` by hand.
Expand Down
108 changes: 34 additions & 74 deletions PHILOSOPHY.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
# Minigraf Design Philosophy

> "Minigraf is not trying to replace Neo4j. It's trying to replace `serde_json` for graph data."

Minigraf aims to be **the embedded graph memory layer for AI agents, mobile apps, and the browser** — built on the SQLite philosophy: small, fast, reliable, zero-configuration, single-file.
Minigraf is a Rust library for applications that need to store and query a local graph without running a database server.

## Why Datalog?

Minigraf uses Datalog as its query language. Here's why it's the right choice:
<a id="1-better-philosophy-alignment"></a>

### 1. Better Philosophy Alignment
### 1. Keep the query engine small

**Datalog is simpler** → Aligns with "do less, do it perfectly":
- Datalog spec: ~50 pages of core concepts
- Smaller surface area = fewer bugs, faster to production
The core query language has a small set of forms for matching facts and combining rules.

**Datalog is proven** → 40+ years of production use (Datomic since 2012, XTDB, LogicBlox)
**Datalog is reliable** → Well-understood semantics, extensive research
<a id="2-natural-fit-for-temporal-databases"></a>

### 2. Natural Fit for Temporal Databases
### 2. Query facts by time

**Bi-temporal support was always the plan.** Datalog makes it natural:
- Facts are tuples: `(Entity, Attribute, Value, ValidFrom, ValidTo, TxTime)`
- Time is just another dimension in relations
- Temporal queries use simple predicates: `[(<= ?valid-from ?query-time)]`
- No special temporal syntax needed - it's just data
A fact includes the time range it applies to and the time it was recorded. A query can select facts that applied at one time and ask which of them the database had recorded by a particular transaction.

Bi-temporal is 3-4 months of proven patterns (Datomic/XTDB model).
<a id="3-graph-traversal-is-more-powerful"></a>

### 3. Graph Traversal is MORE Powerful
### 3. Follow links with recursive rules

**Recursive rules are first-class in Datalog:**
The first rule finds a direct link. The second takes one link to an intermediate entity, then calls `reachable` from there:
```datalog
[(reachable ?from ?to)
[?from :connected ?to]]
Expand All @@ -39,54 +30,39 @@ Bi-temporal is 3-4 months of proven patterns (Datomic/XTDB model).
(reachable ?intermediate ?to)]
```

Transitive closure is native, not bolted on.
The rules keep finding new reachable pairs until no more can be added.

### 4. Faster Path to a Reliable Core

**Datalog**: proven implementation patterns (semi-naive evaluation, stratified negation) mean less of the engine is novel.

A smaller, well-understood query engine leaves more effort for the storage engine, which is where the data-integrity risk is.

### 5. Unique Market Position
<a id="5-unique-market-position"></a>

**Datalog space**: Gap exists for single-file embedded bi-temporal DB
### 5. Store both timelines in one file

Minigraf = embedded graph memory for agents/mobile/browser + SQLite's simplicity + Datomic's temporal model (no one else offers this combination)
Minigraf stores a graph, its valid-time history, and its transaction-time history in a local database file.

---

## Core Inspiration: SQLite

SQLite's success comes from a clear philosophy: be a library, not a server. Be small, not feature-complete. Be reliable, not cutting-edge. Minigraf adopts these same principles for graph databases.
Like SQLite, Minigraf runs inside the application. We limit what the database does so we can spend more time testing storage and recovery.

## Guiding Principles

### 1. Zero-Configuration

**Philosophy**: It should just work, immediately, with no setup.
<a id="1-zero-configuration"></a>

**Implementation**:
- No installation process beyond adding a dependency
- No server process to start or manage
- No configuration files to edit
- No connection strings or authentication for local use
- `Minigraf::open("data.graph")` and you're done
### 1. Open a local database without configuration

**Anti-pattern**: Requiring users to install external dependencies, start services, or edit config files.
Add Minigraf as a dependency and call `Minigraf::open("data.graph")`. You do not need a server, a connection string, or a configuration file.

### 2. Embedded-First Design
<a id="2-embedded-first-design"></a>

**Philosophy**: Minigraf is a library you link against, not a server you connect to.
### 2. Run in the application process

**Implementation**:
- In-process execution - direct function calls, no network overhead
- Runs in the same address space as your application
- No client-server architecture for embedded use
- Network protocols are opt-in extensions, not core features

**Anti-pattern**: Designing for client-server first and retrofitting embedded mode.

**Target statement**: "The graph database you compile into your app, not connect to."
The library runs in the same process as your application. Calls go directly to the library rather than over a network. The core library includes no network protocol. Extensions can add one for applications that need it.

### 3. Single-File Database

Expand Down Expand Up @@ -155,7 +131,7 @@ SQLite's success comes from a clear philosophy: be a library, not a server. Be s
- Every feature must be crash-safe
- Prefer proven algorithms over novel ones

**Anti-pattern**: Adding features before existing ones are bulletproof.
**Anti-pattern**: Adding a feature before the existing ones meet the quality bar above.

### 7. Stability & Backwards Compatibility

Expand All @@ -172,7 +148,7 @@ This section is a policy, not a promise of a frozen format. Minigraf has changed

**Migration guarantee**: migration runs on open or checkpoint and needs no separate tool or configuration. Back up the file before the first open with a new major release. A migration that loses or alters facts is a data-integrity bug and is handled as one (see the support policy below).

**API stability**: semantic versioning. No breaking API changes in minor or patch releases; the `Policy` CI workflow checks this on every PR to `main`. Deprecations are announced at least one minor release before removal in the next major.
**API stability**: semantic versioning. No breaking API changes in minor or patch releases; the `Policy` CI workflow checks this on pull requests targeting `v2.x`. Deprecations are announced at least one minor release before removal in the next major.

**Anti-pattern**: silent format changes, format changes in minor releases, migrations that need a separate tool.

Expand Down Expand Up @@ -241,7 +217,7 @@ Data-integrity bugs stay visible until they are fixed in a published release; se

#### Support tiers

"Supported" depends on which binding and which platform. Every binding, including Tier 2, releases in lock-step with core and publishes every core release, including prereleases. A binding that cannot publish blocks the release until it is fixed or successfully re-dispatched. Tiers differ in testing and support: Tier 1 is fully tested; Tier 2 is experimental, built and smoke-tested in its own repo.
"Supported" depends on which binding and which platform. All bindings, including Tier 2, publish for each core release. Their versions match the core version, using each package registry’s version spelling for prereleases. A binding that cannot publish blocks the release until the problem is fixed or a retry succeeds. Tiers differ in testing and support: Tier 1 is fully tested; Tier 2 is experimental, built and smoke-tested in its own repo.

| Tier | Bindings | What it means |
|---|---|---|
Expand Down Expand Up @@ -270,8 +246,8 @@ Browser (IndexedDB) and WASI storage follow the tier of their binding.
✅ **A bi-temporal database**
- Track when facts were recorded (transaction time)
- Track when facts were valid in the real world (valid time)
- Time travel queries: see any point in history
- Audit trails and compliance built-in
- Query recorded history by transaction time or valid time
- Use that history as one input to an audit; the application remains responsible for compliance

✅ **A Datalog query engine**
- Recursive rules for graph traversal
Expand All @@ -280,10 +256,7 @@ Browser (IndexedDB) and WASI storage follow the tier of their binding.
- Proven semantics (40+ years of research)

✅ **A local-first storage solution**
- Perfect for desktop applications
- Ideal for mobile apps
- Great for WASM in browsers
- Suitable for embedded devices
- See the [platform support table](README.md#platform-support) for available targets and their support tiers

✅ **A single-file graph store**
- One `.graph` file, easy to manage
Expand All @@ -295,10 +268,8 @@ Browser (IndexedDB) and WASI storage follow the tier of their binding.
- Crash recovery via WAL
- Data integrity guarantees

✅ **A learning-friendly implementation**
- Readable Rust code
- Well-documented internals
- Clear architecture
✅ **A Rust library**
- See the [Rust source](src/) for the implementation.

## What Minigraf IS NOT

Expand All @@ -317,28 +288,17 @@ Browser (IndexedDB) and WASI storage follow the tier of their binding.
- No authentication/authorization layer
- No multi-user access control (use OS permissions)

❌ **Not enterprise-focused**
- No role-based access control (RBAC)
- No audit logging
- No high-availability features
- (These can be built on top if needed)

❌ **Not trying to be Neo4j**
- Different use case (embedded vs. server)
- Different scale (millions vs. billions of nodes)
- Different philosophy (library vs. service)
❌ **No built-in access controls, audit logging, or high availability**
- The database records fact history. The application must log operational events such as who opened the database or changed a fact.

❌ **Not chasing feature parity with XTDB/Datomic**
- Simpler scope: single-file only
- No distributed features
- No vector search (separate crate if needed)
- Focus on reliability over features
❌ **No built-in vector search**
- An application can use a separate library for vector search.

## Target Use Cases

**Primary use cases** (optimize for these):

1. **Audit-heavy applications** - Finance, healthcare, legal (bi-temporal = compliance)
1. **Audit-heavy applications** - See what the database recorded at the time and what was corrected later
2. **Event sourcing** - Full history, time travel debugging
3. **Personal knowledge bases** - Obsidian, Logseq, Roam-like apps with provenance
4. **Mobile applications** - Local graph storage on phones/tablets
Expand Down
Loading
Loading
0