Skip to content

feat(database): Implement PostgreSQL storage adapter for V1 Memact Memory #2

@keepsloading

Description

@keepsloading

Goal

Implement a PostgreSQL storage adapter for the Memact/Memory repository to support robust server-side database persistence, replacing the local JSON file adapter for production environments.

This should implement the load/save adapter contract defined in src/storage.mjs.

CC: @rach-kanc — this issue is aligned with the new V1 architecture to replace the deprecated design proposed in the closed Issue #42.

Proposed Database Schema

The database schema should store V1 Memory concepts aligned with the Supabase setup:

  1. memact_memory_entries (user-approved memory statements):

    • id (UUID, primary key)

    • user_id (UUID, link to user profile)

    • category (VARCHAR, e.g., 'fitness', 'learning')

    • content (TEXT, approved statement)

    • visibility (VARCHAR, 'private' | 'friends' | 'public')

    • is_starred (BOOLEAN)

    • created_at (TIMESTAMP WITH TIME ZONE)

    • updated_at (TIMESTAMP WITH TIME ZONE)

  2. memact_app_permissions (app category access grants):

    • id (UUID, primary key)

    • user_id (UUID)

    • app_id (VARCHAR)

    • category (VARCHAR)

    • allowed_visibility (VARCHAR)

    • granted_at (TIMESTAMP WITH TIME ZONE)

Work to Do

  • Create a new adapter src/adapters/postgresql.mjs utilizing pg (node-postgres) with connection pooling.

  • Implement the load() and save(store) methods matching the storage contract in src/storage.mjs.

  • Create a SQL installation/migration script database/migration_v1.sql containing table definitions and constraints.

  • Add unit tests in test/adapters/postgresql.test.mjs verifying connection, query retrieval, and update operations.

  • Document database setup and configuration in README.md.

Acceptance Criteria

  • PostgreSQL adapter can be initialized and loaded via connection string/URL configuration.

  • Storage reads/writes successfully persist to PostgreSQL.

  • All existing Memory engine tests pass with the database adapter loaded.


SSoC26 Contributor Notice:

Since this repository (Memact/Memory) is outside the main Context repository, and the registered project for tracking contributions is specifically Context (Memact/Context), please make sure to create a dummy PR in the Context repository linking to your actual PR or commits in this repository. This is required for your contribution to be correctly tracked and counted.

If you have already created a dummy PR in Memact/Context linking to your work here, please ignore this message!

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions