Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7288b2c8ea | ||
|
|
61633d0eea | ||
|
|
17c4712849 | ||
|
|
8d06fa83e2 | ||
|
|
1162c218ea | ||
|
|
f2cc704758 | ||
|
|
d0008932aa | ||
|
|
68f8084341 |
@@ -1,85 +0,0 @@
|
||||
name: DB Migration
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'crates/mem-store/migrations/**'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
DB_HOST: memory-db-rw.poimen.svc.cluster.local
|
||||
DB_PORT: "5432"
|
||||
DB_NAME: memory
|
||||
|
||||
jobs:
|
||||
migrate:
|
||||
name: Run Migrations
|
||||
runs-on: rust
|
||||
steps:
|
||||
- name: Install psql
|
||||
run: apt-get update && apt-get install -y postgresql-client
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Fetch previous migrations state
|
||||
run: |
|
||||
git fetch origin main --depth=2
|
||||
# List changed migration files
|
||||
CHANGED=$(git diff --name-only HEAD~1 HEAD -- crates/mem-store/migrations/ || echo "")
|
||||
echo "Changed migrations: $CHANGED"
|
||||
echo "CHANGED_MIGRATIONS=$CHANGED" >> $GITHUB_ENV
|
||||
|
||||
- name: Run changed migrations and verify schema
|
||||
if: env.CHANGED_MIGRATIONS != ''
|
||||
run: |
|
||||
export PGPASSWORD="${DB_PASSWORD}"
|
||||
|
||||
echo "=== Running changed migrations ==="
|
||||
for f in $CHANGED_MIGRATIONS; do
|
||||
if [ -f "$f" ]; then
|
||||
echo "--- Applying: $f ---"
|
||||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -f "$f" 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Migration $f failed!"
|
||||
exit 1
|
||||
fi
|
||||
echo "--- OK: $f ---"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "=== Verify schema ==="
|
||||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "\dt memory*"
|
||||
env:
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||
|
||||
- name: Run all migrations and verify schema (manual trigger)
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
export PGPASSWORD="${DB_PASSWORD}"
|
||||
|
||||
echo "=== Running all migrations in order ==="
|
||||
FAILED=0
|
||||
for f in $(ls crates/mem-store/migrations/*.sql | sort); do
|
||||
echo "--- Applying: $f ---"
|
||||
if ! psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -f "$f" 2>&1; then
|
||||
echo "ERROR: Migration $f failed!"
|
||||
FAILED=1
|
||||
else
|
||||
echo "--- OK: $f ---"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $FAILED -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Final schema ==="
|
||||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "\dt memory*"
|
||||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "\d memory_entity"
|
||||
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "\d memory_edge"
|
||||
env:
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||
@@ -121,7 +121,7 @@ pub async fn register_agent_handler(
|
||||
.bind(&body.agent_id)
|
||||
.bind(&body.capabilities)
|
||||
.bind(&body.webhook_url)
|
||||
.bind(body.rate_limit.unwrap_or(1000))
|
||||
.bind(body.rate_limit.unwrap_or(1000) as i32)
|
||||
.execute(&state.pool)
|
||||
.await;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ impl ExtractedEntity {
|
||||
#[async_trait]
|
||||
pub trait EntityExtractor: Send + Sync {
|
||||
async fn extract(&self, text: &str) -> Result<Vec<ExtractedEntity>>;
|
||||
async fn extract_with_auth(&self, text: &str, x_forward_user: Option<&str>) -> Result<Vec<ExtractedEntity>> {
|
||||
async fn extract_with_auth(&self, text: &str, _x_forward_user: Option<&str>) -> Result<Vec<ExtractedEntity>> {
|
||||
// Default: ignore auth header, use regular extract
|
||||
self.extract(text).await
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres-test:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
POSTGRES_USER: app
|
||||
POSTGRES_PASSWORD: testpass
|
||||
POSTGRES_DB: memory
|
||||
ports:
|
||||
- "5433:5432"
|
||||
volumes:
|
||||
- postgres-test-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U app -d memory"]
|
||||
interval: 2s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
volumes:
|
||||
postgres-test-data:
|
||||
@@ -142,9 +142,3 @@ spec:
|
||||
fi
|
||||
|
||||
resources:
|
||||
requests:
|
||||
memory: "1Gi"
|
||||
cpu: "500m"
|
||||
limits:
|
||||
memory: "2Gi"
|
||||
cpu: "2000m"
|
||||
|
||||
@@ -98,8 +98,7 @@ CREATE TABLE IF NOT EXISTS role_prompt_mapping (
|
||||
active BOOLEAN DEFAULT true,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
UNIQUE(project_id, role_name, prompt_id),
|
||||
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
|
||||
UNIQUE(project_id, role_name, prompt_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_role_prompt_mapping_role ON role_prompt_mapping(project_id, role_name, active);
|
||||
@@ -117,10 +116,12 @@ CREATE TABLE IF NOT EXISTS agent_metrics (
|
||||
p95_latency_ms FLOAT DEFAULT 0.0,
|
||||
p99_latency_ms FLOAT DEFAULT 0.0,
|
||||
error_rate FLOAT DEFAULT 0.0,
|
||||
recorded_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
UNIQUE(project_id, agent_id, DATE(recorded_at))
|
||||
recorded_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Note: Use daily rollup job or materialized view for DATE(recorded_at) unique constraint
|
||||
-- PostgreSQL doesn't allow functions in UNIQUE constraints, so we use trigger-based rollup instead
|
||||
|
||||
CREATE INDEX idx_agent_metrics_agent ON agent_metrics(project_id, agent_id, recorded_at DESC);
|
||||
|
||||
-- Prompt Usage Log: detailed invocation tracking
|
||||
@@ -140,3 +141,4 @@ CREATE TABLE IF NOT EXISTS prompt_usage_log (
|
||||
|
||||
CREATE INDEX idx_prompt_usage_log_prompt ON prompt_usage_log(prompt_id, created_at DESC);
|
||||
CREATE INDEX idx_prompt_usage_log_agent ON prompt_usage_log(agent_id, created_at DESC);
|
||||
CREATE INDEX idx_prompt_usage_log_project ON prompt_usage_log(project_id, created_at DESC);
|
||||
|
||||
Reference in New Issue
Block a user