feat: optimize server performance, SDK usability, and monorepo CI/CD#123
feat: optimize server performance, SDK usability, and monorepo CI/CD#123Olympusxvn wants to merge 39 commits intoMystenLabs:devfrom
Conversation
Server (Rust): - Add IVFFlat index for vector search (migration 004) - Add POST /api/remember/batch for batch memory storage - Add Redis-backed search cache (60s TTL) for recall endpoints - Add /embed-batch sidecar route for parallel text embedding - Add upload_batch() for parallel Walrus uploads - Increase DB pool to 20, add graceful SIGTERM shutdown SDK (TypeScript): - Add signedRequestWithRetry() with exponential backoff (429/network) - Add rememberBatch() method for batch operations - Add HttpClient wrapper with connection reuse (keep-alive) Monorepo: - Add Turborepo for cached builds with dependency graph - Add TypeScript composite mode for project references - Add GitHub Actions CI with pnpm + Rust caching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Set FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true to avoid deprecation warnings and bump project node-version from 20 to 22 (current LTS). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clone state before .with_state() consumes it, so shutdown handler can still access the DB pool for cleanup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Allow dead_code on batch embedding/upload structs (available for future use) - Replace as_bytes().len() with len() on strings - Remove redundant .into_iter() in stream::iter() - Allow clippy::too_many_arguments on upload_blob - Allow clippy::type_complexity on batch insert tuple Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… time Apps (chatbot, noter, researcher) run DB migrations during build which requires a live PostgreSQL connection. CI only validates the SDK. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pnpm --filter triggers turbo's global task graph (^build resolves all workspace packages). Using turbo run build --filter= properly scopes execution to only the target package. Verified: Tasks 1/1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Chatbot uses React 19.0.1 and Next.js 16 but had @types/react ^18, which lacks useActionState (introduced in React 19). Upgraded @types/react and @types/react-dom to ^19 to match the runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
turbo is a devDependency, not globally installed in the runner. pnpm exec resolves the binary from node_modules/.bin. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ixes Added lesson MystenLabs#8 (turbo not in PATH — use pnpm exec) and CHANGELOG entries MystenLabs#14 (@types/react upgrade) and MystenLabs#15 (turbo --filter for SDK). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: optimize server, SDK, and monorepo (v1)
…dy supports --provenance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 2 — HIGH security fixes: - Remove Sui private key from Walrus upload HTTP body; sidecar now loads its own key pool from SERVER_SUI_PRIVATE_KEYS at startup - Add x-sidecar-secret header to all sidecar calls (seal_decrypt was missing it) - Atomic rate limiting via Redis Lua script (fixes TOCTOU race) - remember_batch rate limit weight = 50 (was defaulting to 1) - Cap user-supplied limit param at 100 across all handlers - reqwest::Client: 30s request / 10s connect timeout Phase 3 — MEDIUM hardening: - CORS: replace permissive() with CORS_ORIGINS env-driven config - Registry scan: hard cap at 20 pages (1,000 accounts) with warning log - Search cache key: use full SHA-256 hash (was truncated to 16 chars) - generate_embedding: return error when OPENAI_API_KEY missing (remove mock) - Sidecar input validation: address/object-ID format, batch size caps (100), epochs range (1-200) Also removes KeyPool from AppState/Config (sidecar owns upload keys now). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Phase 1 item 1.1: stop accepting the client's private key over HTTP. The server now uses its own SERVER_SUI_PRIVATE_KEY for SEAL decryption. Removes the x-delegate-key header extraction and the delegate_key field from AuthInfo, fixing the cargo check compile error introduced when types.rs was cleaned up in the security/v1 commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
section with 16 numbered items covering all CRITICAL/HIGH/MEDIUM fixes across the Rust server and sidecar, cross-referencing the specific files and what changed.
|
Everything, a_busy_bee: review (verdict and fix plan), security
Olympusxvn
left a comment
There was a problem hiding this comment.
The pull request [PR #123] introduces performance optimizations and a major security overhaul regarding how SEAL credentials and Sui keys are handled.
Here is a concise summary of the changes across the key files:
- SDK & Frontend Logic
packages/sdk/src/memwal.ts: Updates the client to support the new x-seal-session authentication. It implements better error sanitization and adds an AbortController with a 15s timeout for recall requests.
services/server/scripts/sidecar-server.ts: Enables CORS for frontend sponsorship, tightens batch decryption limits (from 100 to 25 items) to prevent OOM errors, and enforces strict validation on Sui object IDs and epochs.
- Core Server Authentication & DB
services/server/src/auth.rs: Transitions from raw private keys to a dual-path authentication system. It now prioritizes x-seal-session (modern) but maintains x-delegate-key (legacy) for backward compatibility.
services/server/src/db.rs: Adds a new database migration (005) to handle expiration logic for the delegate key cache.
- Performance & Concurrency
services/server/src/types.rs: Introduces a KeyPool structure. This uses a round-robin (AtomicUsize) mechanism to select Sui keys, allowing the server to sign and pay for gas on parallel uploads without bottlenecking.
services/server/src/routes.rs: The "brain" of the update. It implements Concurrent Decryption (using join_all) for memories, caps DB search results to 100 (security fix MED-3), and integrates the KeyPool into the upload flow.
- Infrastructure & Security Updates
services/server/src/seal.rs: Updates encryption/decryption signatures to treat the sidecar secret as optional (Option<&str>), allowing for more flexible environment configurations.
services/server/src/walrus.rs: Modifies the Walrus upload request to include a key_index, ensuring the sidecar uses the specific key assigned by the server’s round-robin pool.
Error Handling: Updates AppError to generate a unique trace_id (UUID) for internal errors, masking sensitive system details from the end-user while allowing developers to track issues in logs.
Two bugs from the merge commit broke all CI checks: - TypeScript: constructor typed as MemWalConfig but accessed httpClient - Rust: Err(e) arm placed inside Ok block due to trailing comma after inner match Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Constructor now uses intersection type for httpClient access. Moves Err arm outside Ok block to fix mismatched delimiter in routes.rs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fixed: mismatched closing delimiter: 1260 | 1299 |
Refactor blob cleanup and decryption error handling.
Refactor decryption process and fix parameter passing.
Overview
This Pull Request introduces significant optimizations across the entire MemWal stack, focusing on database performance, SDK developer experience, and monorepo stability.
Key Changes
🚀 Rust Server & Database
004) to optimize write-heavy workloads.POST /api/remember/batchendpoint for atomic insertion of up to 100 items./embed-batchto the TypeScript sidecar for parallelized embeddings.📦 TypeScript SDK
rememberBatchmethod: Added support for the new batch endpoint.HttpClientto support keep-alive and connection pooling.🛠 Monorepo & CI/CD
turbo.jsonwith a dependency-aware pipeline to speed up builds.@types/reactto v19 to resolve build errors in the chatbot app.Documentation
Detailed changes and lessons learned are documented in the newly added
CHANGELOG.mdandlessons.mdfiles within the PR.update:
2026-04-29_memwal-code-review
2026-04-29_memwal-fix-plan
2026-04-29_memwal-lessons
OlympusXVN