Skip to content

Add comprehensive business logic architecture documentation - #97

Merged
malibio merged 1 commit into
mainfrom
feature/business-logic-documentation
Sep 25, 2025
Merged

malibio merged 1 commit into
mainfrom
feature/business-logic-documentation

Conversation

@malibio

@malibio malibio commented Sep 25, 2025

Copy link
Copy Markdown
Collaborator

This PR adds detailed architecture documentation for the NodeSpace business logic layer, including:

  • Overview: Complete architecture with hybrid package structure and core components
  • Database Schema: Hybrid schema approach with SQLx integration patterns
  • Node Behavior System: Trait-based extensible node type system
  • MCP Integration: AI agent access via stdio server

These documents establish the foundation for implementing the Rust backend business logic layer with clear patterns for:

  • Universal node model with type-specific behaviors
  • Database operations using SQLx with compile-time safety
  • Dynamic entity support for user-defined node types
  • Multi-platform integration (Tauri desktop + MCP for AI agents)

Ready for review and merge to enable implementation phase.

- overview.md: Complete architecture with package structure and design decisions
- database-schema.md: Hybrid schema design with SQLx integration patterns
- node-behavior-system.md: Trait-based system for extensible node types
- mcp-integration.md: AI agent access via MCP stdio protocol

Addresses business logic layer design for NodeSpace core implementation
@malibio
malibio merged commit 1541f9c into main Sep 25, 2025
@malibio
malibio deleted the feature/business-logic-documentation branch September 25, 2025 09:15
malibio added a commit that referenced this pull request Feb 4, 2026
- overview.md: Complete architecture with package structure and design decisions
- database-schema.md: Hybrid schema design with SQLx integration patterns
- node-behavior-system.md: Trait-based system for extensible node types
- mcp-integration.md: AI agent access via MCP stdio protocol

Addresses business logic layer design for NodeSpace core implementation

Co-authored-by: Container Dev <[email protected]>
malibio added a commit that referenced this pull request Feb 5, 2026
- overview.md: Complete architecture with package structure and design decisions
- database-schema.md: Hybrid schema design with SQLx integration patterns
- node-behavior-system.md: Trait-based system for extensible node types
- mcp-integration.md: AI agent access via MCP stdio protocol

Addresses business logic layer design for NodeSpace core implementation

Co-authored-by: Container Dev <[email protected]>
mstomar125 added a commit that referenced this pull request Jun 15, 2026
The Pro daemon's upcoming pgvector push needs to read locally-stored
vectors, but core only exposed embedding *search* (KNN) and *write*
(upsert) — no plain read. Add two read methods, both decoding the
little-endian f32 blob written by `upsert_embeddings` back into the
`Embedding` model via a new `row_to_embedding` helper:

- `SqliteStore::get_embeddings(node_id)` — a node's embeddings, by chunk.
- `SqliteStore::embeddings_modified_since(since)` — embeddings modified at
  or after a cursor, across all nodes, ordered by `modified_at`; this is
  what the daemon will sweep to push newly (re)computed vectors.

Both are surfaced as `NodeService` wrappers (the daemon holds an
`Arc<NodeService>`). They are deliberately NOT behind the `nlp` feature:
they read the persisted `embedding` table, which exists whether or not
embedding *generation* (llama-cpp) is compiled in — so a daemon built
without NLP can still sync vectors.

The recurring sweep gets a covering index: `idx_emb_modified ON embedding
(modified_at, node_id, chunk_index)`. The existing idx_emb_stale_mod
leads with `stale`, so it can't serve the stale-agnostic modified_at range
scan — without the new index every sweep full-scans + filesorts. Also
pinned the lexicographic-cursor invariant (UTC rfc3339 modified_at) in a
doc comment.

Test: upsert two synthetic 768-dim chunk vectors, assert both round-trip
out of the blob in chunk order, the modified-since cursor includes them
at epoch and excludes them in the future, the sweep's query plan uses
idx_emb_modified with no filesort, and a node with no embeddings reads
back empty.

Co-authored-by: Mayank  Tomar <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
mstomar125 added a commit that referenced this pull request Jun 15, 2026
#1417)

The Pro daemon's upcoming embedding PULL needs to apply vectors synced
from another device into the local store, but `upsert_embeddings` /
`delete_embeddings` were store-only (the read API from #1416 added reads;
this adds the symmetric writes). Surface both as `NodeService` wrappers:

- `NodeService::upsert_embeddings(node_id, Vec<NewEmbedding>)` — replace a
  node's vectors wholesale (mirrors the local generation path).
- `NodeService::delete_embeddings(node_id)` — clear a node's vectors.

Like the read wrappers, both are deliberately NOT behind the `nlp`
feature: applying a received vector doesn't need the generation engine,
so a daemon built without llama-cpp can still receive embeddings.

Test: upsert a synthetic 768-dim vector via the wrapper, read it back via
get_embeddings (round-trip), then delete and assert empty.

Co-authored-by: Mayank  Tomar <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
malibio pushed a commit that referenced this pull request Jun 22, 2026
The Pro daemon's upcoming pgvector push needs to read locally-stored
vectors, but core only exposed embedding *search* (KNN) and *write*
(upsert) — no plain read. Add two read methods, both decoding the
little-endian f32 blob written by `upsert_embeddings` back into the
`Embedding` model via a new `row_to_embedding` helper:

- `SqliteStore::get_embeddings(node_id)` — a node's embeddings, by chunk.
- `SqliteStore::embeddings_modified_since(since)` — embeddings modified at
  or after a cursor, across all nodes, ordered by `modified_at`; this is
  what the daemon will sweep to push newly (re)computed vectors.

Both are surfaced as `NodeService` wrappers (the daemon holds an
`Arc<NodeService>`). They are deliberately NOT behind the `nlp` feature:
they read the persisted `embedding` table, which exists whether or not
embedding *generation* (llama-cpp) is compiled in — so a daemon built
without NLP can still sync vectors.

The recurring sweep gets a covering index: `idx_emb_modified ON embedding
(modified_at, node_id, chunk_index)`. The existing idx_emb_stale_mod
leads with `stale`, so it can't serve the stale-agnostic modified_at range
scan — without the new index every sweep full-scans + filesorts. Also
pinned the lexicographic-cursor invariant (UTC rfc3339 modified_at) in a
doc comment.

Test: upsert two synthetic 768-dim chunk vectors, assert both round-trip
out of the blob in chunk order, the modified-since cursor includes them
at epoch and excludes them in the future, the sweep's query plan uses
idx_emb_modified with no filesort, and a node with no embeddings reads
back empty.

Co-authored-by: Mayank  Tomar <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
malibio pushed a commit that referenced this pull request Jun 22, 2026
#1417)

The Pro daemon's upcoming embedding PULL needs to apply vectors synced
from another device into the local store, but `upsert_embeddings` /
`delete_embeddings` were store-only (the read API from #1416 added reads;
this adds the symmetric writes). Surface both as `NodeService` wrappers:

- `NodeService::upsert_embeddings(node_id, Vec<NewEmbedding>)` — replace a
  node's vectors wholesale (mirrors the local generation path).
- `NodeService::delete_embeddings(node_id)` — clear a node's vectors.

Like the read wrappers, both are deliberately NOT behind the `nlp`
feature: applying a received vector doesn't need the generation engine,
so a daemon built without llama-cpp can still receive embeddings.

Test: upsert a synthetic 768-dim vector via the wrapper, read it back via
get_embeddings (round-trip), then delete and assert empty.

Co-authored-by: Mayank  Tomar <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant