Skip to content

Commit 9804a7e

Browse files
authored
Cleanup for v0.3.0 Release (#97)
1 parent 406e33d commit 9804a7e

File tree

11 files changed

+102
-80
lines changed

11 files changed

+102
-80
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "prollytree"
33
description = "A prolly (probabilistic) tree for efficient storage, retrieval, and modification of ordered data."
44
authors = ["Feng Zhang <[email protected]>"]
5-
version = "0.2.1-beta"
5+
version = "0.3.0"
66
edition = "2021"
77

88
license = "Apache-2.0"

README.md

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ Add to your `Cargo.toml`:
2323

2424
```toml
2525
[dependencies]
26-
prollytree = "0.2.0"
26+
prollytree = "0.3.0"
2727

2828
# Optional features
29-
prollytree = { version = "0.2.0", features = ["git", "sql", "rig"] }
29+
prollytree = { version = "0.3.0", features = ["git", "sql", "rig"] }
3030
```
3131

3232
## Examples
3333

3434
### Basic Tree Operations
3535

3636
```rust
37-
use prollytree::tree::ProllyTree;
37+
use prollytree::tree::{ProllyTree, Tree};
3838
use prollytree::storage::InMemoryNodeStorage;
3939

4040
let storage = InMemoryNodeStorage::<32>::new();
@@ -44,89 +44,87 @@ let mut tree = ProllyTree::new(storage, Default::default());
4444
tree.insert(b"user:alice".to_vec(), b"Alice Johnson".to_vec());
4545
tree.insert(b"config:timeout".to_vec(), b"30".to_vec());
4646

47-
// Query data
48-
let value = tree.find(b"user:alice")?;
49-
println!("Found: {}", String::from_utf8(value)?);
47+
// Query data - find returns a node, extract the value
48+
if let Some(node) = tree.find(b"user:alice") {
49+
for (i, key) in node.keys.iter().enumerate() {
50+
if key == b"user:alice" {
51+
let value = &node.values[i];
52+
println!("Found: {}", String::from_utf8(value.clone())?);
53+
break;
54+
}
55+
}
56+
}
5057

5158
// Generate cryptographic proof
52-
let proof = tree.generate_proof(b"user:alice")?;
53-
let is_valid = tree.verify_proof(&proof, b"user:alice", b"Alice Johnson");
59+
let proof = tree.generate_proof(b"user:alice");
60+
let is_valid = tree.verify(proof, b"user:alice", Some(b"Alice Johnson"));
5461
```
5562

5663
### Git-backed Versioned Storage
5764

5865
```rust
5966
use prollytree::git::GitVersionedKvStore;
67+
use std::process::Command;
68+
use std::fs;
6069

61-
let mut store = GitVersionedKvStore::init("./data")?;
70+
// Setup: Create a temporary Git repository (in real use, you'd have an existing repo)
71+
let repo_path = "/tmp/demo_git_repo";
72+
fs::create_dir_all(repo_path)?;
73+
Command::new("git").args(&["init"]).current_dir(repo_path).output()?;
6274

63-
// Version your data like Git
64-
store.set(b"config/api_key", b"secret123")?;
65-
store.commit("Initial config")?;
66-
67-
// Branch for experiments
68-
store.checkout_new_branch("feature/optimization")?;
69-
store.set(b"config/timeout", b"60")?;
70-
store.commit("Increase timeout")?;
71-
72-
// Three-way merge back to main
73-
store.checkout("main")?;
74-
store.merge("feature/optimization")?;
75-
```
75+
// Switch to repo directory and create dataset
76+
std::env::set_current_dir(repo_path)?;
77+
fs::create_dir_all("data")?;
78+
let mut store = GitVersionedKvStore::<32>::init("data")?;
7679

77-
### SQL Interface with Time Travel
78-
79-
```rust
80-
use prollytree::sql::ProllyStorage;
81-
use gluesql_core::prelude::Glue;
82-
83-
let storage = ProllyStorage::<32>::init("./data")?;
84-
let mut glue = Glue::new(storage);
80+
// Now use Git-backed versioned storage
81+
store.insert(b"config/api_key".to_vec(), b"secret123".to_vec())?;
82+
store.commit("Initial config")?;
8583

86-
// Standard SQL operations
87-
glue.execute("CREATE TABLE users (id INTEGER, name TEXT)").await?;
88-
glue.execute("INSERT INTO users VALUES (1, 'Alice')").await?;
84+
// Retrieve data
85+
if let Some(value) = store.get(b"config/api_key") {
86+
println!("Retrieved: {}", String::from_utf8(value)?);
87+
}
8988

90-
// Time travel queries
91-
glue.storage.commit("v1.0").await?;
92-
glue.execute("UPDATE users SET name = 'Alice Smith' WHERE id = 1").await?;
89+
// Add more data and commit
90+
store.insert(b"config/timeout".to_vec(), b"30".to_vec())?;
91+
store.commit("Add timeout config")?;
9392

94-
// Query historical data
95-
let v1_data = glue.storage.query_at_commit("v1.0",
96-
"SELECT * FROM users WHERE id = 1").await?;
93+
// Create branches for parallel development
94+
store.create_branch("experimental")?;
95+
println!("Git-backed storage with full version control!");
9796
```
9897

99-
### AI Agent Memory
98+
### Multiple Storage Backends
10099

101100
```rust
102-
use prollytree::agent::{AgentMemorySystem, MemoryQuery};
103-
104-
let mut memory = AgentMemorySystem::init_with_thread_safe_git(
105-
"./agent_memory", "agent_001".to_string(), None
106-
)?;
107-
108-
// Store conversation context
109-
memory.short_term.store_conversation_turn(
110-
"session_123", "user", "What's the weather today?", None
111-
).await?;
112-
113-
// Store persistent knowledge
114-
memory.semantic.store_fact(
115-
"weather", "temperature",
116-
json!({"location": "Tokyo", "temp": "22°C"}),
117-
0.9, "weather_api"
118-
).await?;
119-
120-
// Query and checkpoint
121-
let memories = memory.semantic.query(MemoryQuery::text("Tokyo")).await?;
122-
let checkpoint = memory.checkpoint("Weather conversation").await?;
101+
use prollytree::tree::{ProllyTree, Tree};
102+
use prollytree::storage::{InMemoryNodeStorage, FileNodeStorage};
103+
104+
// In-memory storage (fast, temporary)
105+
let mem_storage = InMemoryNodeStorage::<32>::new();
106+
let mut mem_tree = ProllyTree::new(mem_storage, Default::default());
107+
mem_tree.insert(b"session:abc123".to_vec(), b"active".to_vec());
108+
109+
// File-based storage (persistent)
110+
let file_storage = FileNodeStorage::<32>::new("./tree_data".into());
111+
let mut file_tree = ProllyTree::new(file_storage, Default::default());
112+
file_tree.insert(b"user:alice".to_vec(), b"Alice Johnson".to_vec());
113+
114+
// Both trees support the same operations
115+
if let Some(node) = mem_tree.find(b"session:abc123") {
116+
println!("Session found in memory storage");
117+
}
118+
119+
// For SQL functionality, see examples/sql.rs
120+
println!("Multiple storage backends working!");
123121
```
124122

125123
## Feature Flags
126124

127125
```toml
128126
[dependencies.prollytree]
129-
version = "0.2.0"
127+
version = "0.3.0"
130128
features = [
131129
"git", # Git-backed versioned storage
132130
"sql", # SQL interface via GlueSQL
@@ -148,22 +146,24 @@ Run benchmarks: `cargo bench`
148146

149147
## Documentation & Examples
150148

151-
- **[📖 Full API Documentation](https://docs.rs/prollytree)**
152-
- **[💡 Use Cases & Examples](examples/README.md)** - AI agents, version control, distributed systems
153-
- **[🐍 Python Bindings](python/README.md)** - Complete Python API
154-
- **[Performance Guide](docs/performance.md)** - Optimization tips
149+
- **[Full API Documentation](https://docs.rs/prollytree)**
150+
- **[Use Cases & Examples](examples/README.md)** - AI agents, version control, distributed systems
151+
- **[Python Bindings](python/README.md)** - Complete Python API
152+
- **[Performance Guide](docs/performance.md)** - Optimization tips
155153

156154
## CLI Tool
157155

158156
```bash
159157
# Install git-prolly CLI
160158
cargo install prollytree --features git
161159

162-
# Use like Git for key-value data
163-
git-prolly init my-data
160+
# Setup git repository and create dataset
161+
git init my-repo && cd my-repo
162+
mkdir my-data && git-prolly init my-data # Create dataset directory
163+
cd my-data
164164
git-prolly set "user:alice" "Alice Johnson"
165165
git-prolly commit -m "Add user"
166-
git-prolly checkout -b feature/updates
166+
git checkout -b feature/updates # Use regular git for branching
167167
git-prolly merge main
168168
```
169169

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "prollytree"
7-
version = "0.2.1"
7+
version = "0.3.0"
88
description = "Python bindings for ProllyTree - a probabilistic tree for efficient storage and retrieval"
99
readme = "python/README.md"
1010
requires-python = ">=3.8"

python/docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
author = 'ProllyTree Contributors'
2727

2828
# The full version, including alpha/beta/rc tags
29-
release = '0.2.1'
30-
version = '0.2.1'
29+
release = '0.3.0'
30+
version = '0.3.0'
3131

3232
# -- General configuration ---------------------------------------------------
3333
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

python/prollytree/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@
6262
if git_available:
6363
__all__.extend(["WorktreeManager", "WorktreeVersionedKvStore"])
6464

65-
__version__ = "0.2.1"
65+
__version__ = "0.3.0"

src/agent/embedding_search.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ impl MockEmbeddingGenerator {
8484
/// Advanced search functionality for memory stores
8585
pub struct MemorySearchEngine<T: SearchableMemoryStore> {
8686
store: T,
87+
/// Cache for embeddings to reduce API calls
88+
/// Note: Reserved for future optimization features
8789
#[allow(dead_code)]
8890
embedding_cache: HashMap<String, Vec<f32>>,
8991
}

src/bin/prolly-ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::path::{Path, PathBuf};
2222
#[derive(Parser)]
2323
#[command(name = "prolly-ui")]
2424
#[command(about = "Generate static HTML visualization for git-prolly repositories")]
25-
#[command(version = "0.1.0")]
25+
#[command(version = "0.3.0")]
2626
struct Cli {
2727
/// Path to the main git repository containing datasets as subdirectories
2828
#[arg(help = "Repository path (defaults to current directory)")]

src/diff.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl AgentPriorityResolver {
124124

125125
/// Extract agent ID from key (assumes key format includes agent info)
126126
/// This is a simple implementation - in practice you might have more sophisticated key parsing
127+
/// Note: Reserved for future agent-based conflict resolution features
127128
#[allow(dead_code)]
128129
fn extract_agent_id(&self, key: &[u8]) -> Option<String> {
129130
let key_str = String::from_utf8_lossy(key);
@@ -136,6 +137,8 @@ impl AgentPriorityResolver {
136137
None
137138
}
138139

140+
/// Get priority for a given key based on its agent ID
141+
/// Note: Reserved for future agent-based conflict resolution features
139142
#[allow(dead_code)]
140143
fn get_priority_for_key(&self, key: &[u8]) -> u32 {
141144
self.extract_agent_id(key)

src/git/versioned_store.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,12 @@ where
250250

251251
// Create tree object in Git using git commands
252252
// Get the git root directory
253-
let git_root = Self::find_git_root(self.git_repo.path().parent().unwrap()).unwrap();
253+
let parent_path =
254+
self.git_repo.path().parent().ok_or_else(|| {
255+
GitKvError::GitObjectError("Repository path has no parent".into())
256+
})?;
257+
let git_root = Self::find_git_root(parent_path)
258+
.ok_or_else(|| GitKvError::GitObjectError("Could not find git root".into()))?;
254259

255260
// Stage all files in the current directory recursively
256261
let add_cmd = std::process::Command::new("git")
@@ -476,7 +481,7 @@ where
476481
// Get the current time
477482
let now = std::time::SystemTime::now()
478483
.duration_since(std::time::UNIX_EPOCH)
479-
.unwrap()
484+
.map_err(|e| GitKvError::GitObjectError(format!("System time error: {e}")))?
480485
.as_secs() as i64;
481486

482487
// Get git user configuration

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ limitations under the License.
3636
//!
3737
//! ```toml
3838
//! [dependencies]
39-
//! prolly = "0.1.0"
39+
//! prollytree = "0.3.0"
4040
//! ```
4141
//!
4242
//! Follow examples in the github repository to get started.

0 commit comments

Comments
 (0)