Add chat-memory module: MessageWindowChatMemory, JDBC and Redis repositories, per-user conversation IDs

Real PostgreSQL 16 and Redis Stack 7.4; 24 tests write output/01-24. Covers the 20-message
default window with no property, the 36-character conversation_id, tool messages dropped by
JdbcChatMemoryRepository, concurrent add() on one conversation, a 1.x table under the 2.0
repository, the Redis repository silently backing off for a custom ChatMemory, and the
removal of PromptChatMemoryAdvisor.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ja4jkzrbQ4LQZBNrb5mkZE
This commit is contained in:
Claude
2026-09-24 15:56:47 +00:00
parent c1e36c6c09
commit 823f6fac5b
65 changed files with 2548 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Starts the three backing services the tests need, with no docker-compose:
# * PostgreSQL 16 on 127.0.0.1:5440 (apt: postgresql-16; runs as the postgres user)
# * Redis Stack on 127.0.0.1:6390 (docker: redis/redis-stack-server -- Redis + RediSearch + RedisJSON)
# * plain Redis on 127.0.0.1:6391 (apt: redis-server, NO modules; only used to capture a failure)
# If you already have these, skip this script and set CM_PG_URL / CM_REDIS_STACK_PORT / CM_REDIS_PLAIN_PORT.
set -euo pipefail
PGDATA="${PGDATA:-/tmp/pgchat/data}"; PGPORT="${PGPORT:-5440}"; SOCKDIR="$(dirname "$PGDATA")"
BIN="$(ls -d /usr/lib/postgresql/*/bin 2>/dev/null | sort -V | tail -1)"
as_pg() { if [ "$(id -u)" = 0 ]; then su postgres -c "$*"; else bash -c "$*"; fi; }
mkdir -p "$SOCKDIR"; [ "$(id -u)" = 0 ] && chown postgres "$SOCKDIR"
[ -d "$PGDATA/base" ] || as_pg "'$BIN/initdb' -D '$PGDATA' -A trust >'$SOCKDIR/initdb.log' 2>&1"
as_pg "'$BIN/pg_ctl' -D '$PGDATA' status" >/dev/null 2>&1 || \
as_pg "'$BIN/pg_ctl' -D '$PGDATA' -o \"-p $PGPORT -c listen_addresses=127.0.0.1 -c unix_socket_directories=$SOCKDIR\" -l '$SOCKDIR/pg.log' -w start"
PSQL="$BIN/psql -h $SOCKDIR -p $PGPORT -U postgres -v ON_ERROR_STOP=1 -q"
as_pg "$PSQL -d postgres -tc \"select 1 from pg_roles where rolname='chat'\"" | grep -q 1 || as_pg "$PSQL -d postgres -c \"create role chat login superuser password 'chat'\""
as_pg "$PSQL -d postgres -tc \"select 1 from pg_database where datname='chatdb'\"" | grep -q 1 || as_pg "$PSQL -d postgres -c 'create database chatdb owner chat'"
docker rm -f cm-redis-stack >/dev/null 2>&1 || true
docker run -d --name cm-redis-stack -p 6390:6379 redis/redis-stack-server:latest >/dev/null
redis-server --port 6391 --save "" --appendonly no --daemonize yes >/dev/null
echo "postgres 127.0.0.1:$PGPORT (chatdb / chat / chat), redis-stack :6390, plain redis :6391"