{"id":50369252,"url":"https://github.com/aliumairdev/mempalace-rb","last_synced_at":"2026-05-30T06:03:23.982Z","repository":{"id":360863723,"uuid":"1252038349","full_name":"aliumairdev/mempalace-rb","owner":"aliumairdev","description":"Rails-native long-term memory for AI agents and Rails apps","archived":false,"fork":false,"pushed_at":"2026-05-28T06:26:05.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T08:10:30.682Z","etag":null,"topics":["ai","memory","pgvector","rails","rails-engine","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aliumairdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-28T06:15:22.000Z","updated_at":"2026-05-28T06:25:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aliumairdev/mempalace-rb","commit_stats":null,"previous_names":["aliumairdev/mempalace-rb"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aliumairdev/mempalace-rb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliumairdev%2Fmempalace-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliumairdev%2Fmempalace-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliumairdev%2Fmempalace-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliumairdev%2Fmempalace-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliumairdev","download_url":"https://codeload.github.com/aliumairdev/mempalace-rb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliumairdev%2Fmempalace-rb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33681809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","memory","pgvector","rails","rails-engine","ruby"],"created_at":"2026-05-30T06:03:23.188Z","updated_at":"2026-05-30T06:03:23.973Z","avatar_url":"https://github.com/aliumairdev.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mempalace-rb\n\nRails-native long-term memory for AI agents and Rails apps.\n\n`mempalace-rb` stores Rails app memory as original verbatim text, then makes it searchable through PostgreSQL full-text search, optional pgvector embeddings, and practical Rails APIs for prompt context. It supports simple apps with one memory space and multitenant apps with account-scoped isolation.\n\n## Why Verbatim Memory\n\nSummaries lose source detail. Mempalace stores drawers as the original text you gave it, then layers indexes, pointers, facts, tunnels, and diary entries around that source of truth.\n\n## Install\n\nFrom GitHub:\n\n```ruby\ngem \"mempalace-rb\", github: \"aliumairdev/mempalace-rb\"\n```\n\nAfter a RubyGems release, the shorter form will work:\n\n```ruby\ngem \"mempalace-rb\"\n```\n\nThen run:\n\n```bash\nbundle install\nbin/rails generate mempalace:install\nbin/rails db:migrate\n```\n\nThe installer creates `config/initializers/mempalace.rb` and copies the database migration.\n\n## Configure\n\n```ruby\nMempalace.configure do |config|\n  config.embedding_provider = :null\n  config.embedding_model = nil\n  config.vector_dimensions = 1536\n  config.tenant_mode = :multi\n  config.tenant_model = \"Account\"\n  config.tenant_foreign_key = :account_id\n  config.auto_embed = true\n  config.embedding_queue = :default\nend\n```\n\nThe null provider stores memories without remote calls. Set `config.null_provider_mode = :deterministic` in tests if you want local deterministic vectors.\n\nFor a simple, non-multitenant Rails app:\n\n```ruby\nMempalace.configure do |config|\n  config.tenant_mode = :single\nend\n```\n\nThen `tenant:` is optional:\n\n```ruby\nMempalace.remember(\n  wing: \"My App\",\n  room: \"architecture\",\n  content: \"Use SQLite first and pgvector later.\"\n)\n\nMempalace.search(query: \"What database did we choose?\", wing: \"My App\")\n```\n\n## Remember, Search, Context\n\n```ruby\nMempalace.remember(\n  tenant: current_account,\n  wing: \"AI Receptionist\",\n  room: \"architecture\",\n  content: \"Use Rails 8.1, RubyLLM, OpenRouter, pgvector, Sidekiq...\",\n  memory_type: \"decision\"\n)\n\nresults = Mempalace.search(\n  tenant: current_account,\n  query: \"What stack did we choose?\",\n  wing: \"AI Receptionist\",\n  limit: 5\n)\n\ncontext = Mempalace.context_for(\n  tenant: current_account,\n  query: user_message,\n  wing: \"AI Receptionist\",\n  max_tokens: 2_000\n)\n```\n\nSearch results return drawer content verbatim:\n\n```ruby\n{\n  drawer_id: 123,\n  content: \"Use Rails 8.1, RubyLLM, OpenRouter, pgvector, Sidekiq...\",\n  wing: \"ai-receptionist\",\n  room: \"architecture\",\n  memory_type: \"decision\",\n  score: 0.91,\n  metadata: {}\n}\n```\n\n## Project Mining\n\n```ruby\nMempalace.mine_project(\n  tenant: current_account,\n  path: Rails.root,\n  wing: \"My App\"\n)\n```\n\nThe project miner scans readable source files, skips generated/cache directories, chunks text, detects rooms from paths, and stores verbatim chunks as drawers.\n\n## Conversation Mining\n\n```ruby\nMempalace.mine_conversation(\n  tenant: current_account,\n  wing: \"Support Bot\",\n  conversation: [\n    { role: \"user\", content: \"What stack did we pick?\", id: \"m1\" },\n    { role: \"assistant\", content: \"Rails, PostgreSQL, pgvector.\", id: \"m2\" }\n  ]\n)\n```\n\nThe conversation miner groups user and assistant exchanges where possible and keeps message metadata.\n\n## Embedding Providers\n\nSupported adapters:\n\n- `:null`\n- `:ruby_llm`\n- `:openai`\n- `:openrouter`\n- `:ollama`\n\nEmbedding failures do not delete drawers. Failed jobs mark the drawer as `failed`, record `embedding_error`, and leave keyword search working.\n\n## pgvector\n\nThe migration tries to enable pgvector and creates a vector column/index when available. If pgvector is unavailable, it stores embeddings as JSON text and semantic search gracefully degrades. Keyword search continues to work.\n\nFor PostgreSQL:\n\n```sql\nCREATE EXTENSION IF NOT EXISTS vector;\n```\n\n## Tenant Isolation\n\nIn `:multi` mode, every public read/write API requires `tenant:` unless a tenant resolver is configured. In `:single` mode, the gem uses `config.single_tenant_id` internally so simple apps do not need an `Account` model.\n\n## Rake Tasks\n\n```bash\nTENANT_ID=1 bin/rails mempalace:status\nTENANT_ID=1 PATH=. bin/rails mempalace:mine_project\nTENANT_ID=1 QUERY=\"appointment safety\" bin/rails mempalace:search\nTENANT_ID=1 bin/rails mempalace:reembed_failed\n```\n\n## Limitations\n\n- v0.1 favors Rails-native storage over ChromaDB compatibility.\n- Knowledge graph extraction is manual/API-based, not automatic LLM extraction.\n- The simple fallback keyword search is intended for test/dev or non-Postgres setups.\n- No UI dashboard or MCP server is included yet.\n\n## Roadmap\n\nSee [docs/roadmap.md](docs/roadmap.md).\n\n## Development\n\n```bash\nbundle install\nbundle exec rake\n```\n\nPostgreSQL/pgvector integration coverage is gated behind:\n\n```bash\nMEMPALACE_POSTGRES_URL=postgres://user:pass@localhost/mempalace_test bundle exec rake test\n```\n\nSee [docs/development.md](docs/development.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliumairdev%2Fmempalace-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliumairdev%2Fmempalace-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliumairdev%2Fmempalace-rb/lists"}