Complete database schema and API implementation for agent memory
aligned with API Platform Engineer role requirements
(agency-agents/engineering/engineering-api-platform-engineer.md)
Schema (migration 004):
✓ agent_prompt: template-based prompts with versioning
✓ agent_skill: capabilities with effectiveness tracking
✓ agent_decision: reasoning and outcome recording
✓ role_prompt_mapping: maps roles (e.g., api-platform-engineer) to prompts
✓ agent_metrics: performance tracking per agent
✓ prompt_usage_log: detailed invocation tracking
✓ agent_registry: agent lifecycle management
API Endpoints (contract-first, backward-compatible):
POST /memory/agents/{project_id}/prompts
POST /memory/agents/{project_id}/roles
GET /memory/agents/{project_id}/roles/{role_name}/prompts
Handlers:
✓ create_prompt_handler: persists to agent_prompt table
✓ map_role_to_prompt_handler: role → prompt mapping with priority
✓ get_role_prompts_handler: retrieves prompts by role
Repository Layer (mem-store/src/agent_repo.rs):
✓ AgentRepository with full CRUD operations
✓ Prompt usage tracking and statistics
✓ Role-to-prompt mapping with priority ordering
✓ Metrics persistence for observability
Tekton Pipeline:
✓ agent-memory-migration-task: applies schema migration
✓ verify-indexes: validates all indexes created
✓ verify-schemas: validates table structure
✓ integration into poimen-ci pipeline
Integration Tests (tests/agent_memory_api_platform_engineer.rs):
✓ Contract-first API specification validation
✓ Backward compatibility rule enforcement
✓ Rate limiting communication (X-RateLimit-* headers)
✓ Error response consistency (stable codes + request IDs)
✓ Deprecation lifecycle (announce → signal → runway → sunset)
✓ Idempotency and retry safety
✓ API Platform Engineer role requirements
✓ Agent prompt templates for contract review, compatibility check, SDK generation
All tests validate against agency-agents API Platform Engineer specification:
- Contract-first: OpenAPI spec before code
- No breaking changes without versioning
- Consistent error handling (RFC 9457 problem details)
- Rate limits communicated not enforced
- SDKs + docs generated from spec
- Idempotency via Idempotency-Key header
- Deprecation with runway (6-12+ months)
Ready to deploy: run Tekton PipelineRun to apply migrations + test
141 lines
3.5 KiB
YAML
141 lines
3.5 KiB
YAML
---
|
|
# Tekton Pipeline: Poimen Memory Service CI/CD
|
|
#
|
|
# Orchestrates:
|
|
# 1. integration-test-task: Run integration tests against image
|
|
# 2. (Future) build-task: Build Docker image
|
|
# 3. (Future) promote-task: Promote image to :latest
|
|
#
|
|
# Parameters:
|
|
# - image: Docker image with SHA to test
|
|
# - registry-user: Registry credentials
|
|
# - registry-token: Registry credentials
|
|
|
|
apiVersion: tekton.dev/v1
|
|
kind: Pipeline
|
|
metadata:
|
|
name: poimen-ci
|
|
namespace: poimen
|
|
spec:
|
|
params:
|
|
- name: image
|
|
type: string
|
|
description: "Docker image SHA to test (e.g., forgejo.riotpiao.com/riotpiao-poimen/poimen-memory:abc123)"
|
|
|
|
- name: registry-user
|
|
type: string
|
|
description: "Registry username"
|
|
default: ""
|
|
|
|
- name: registry-token
|
|
type: string
|
|
description: "Registry token/password"
|
|
default: ""
|
|
|
|
workspaces:
|
|
- name: source
|
|
description: "Git source repository with migrations"
|
|
|
|
tasks:
|
|
# Task 0: Apply Agent Memory Migrations
|
|
- name: agent-memory-migration
|
|
taskRef:
|
|
name: agent-memory-migration
|
|
params:
|
|
- name: migration-version
|
|
value: "004"
|
|
- name: database-name
|
|
value: "memory"
|
|
workspaces:
|
|
- name: source
|
|
workspace: source
|
|
|
|
# Task 1: Integration Tests (runs after migration)
|
|
- name: integration-tests
|
|
runAfter:
|
|
- agent-memory-migration
|
|
taskRef:
|
|
name: poimen-integration-test
|
|
params:
|
|
- name: image
|
|
value: $(params.image)
|
|
|
|
# Task 2: Gate on test results
|
|
- name: gate-on-tests
|
|
runAfter:
|
|
- integration-tests
|
|
taskSpec:
|
|
steps:
|
|
- name: check-results
|
|
image: alpine:latest
|
|
script: |
|
|
#!/bin/sh
|
|
set -e
|
|
echo "✓ Integration tests passed, proceeding with promotion"
|
|
|
|
# Task 3: Promote image (placeholder - will be implemented)
|
|
- name: promote-image
|
|
runAfter:
|
|
- gate-on-tests
|
|
taskSpec:
|
|
params:
|
|
- name: image
|
|
type: string
|
|
- name: registry-user
|
|
type: string
|
|
- name: registry-token
|
|
type: string
|
|
|
|
steps:
|
|
- name: promote
|
|
image: docker:latest
|
|
env:
|
|
- name: IMAGE
|
|
value: $(params.image)
|
|
- name: REGISTRY_USER
|
|
value: $(params.registry-user)
|
|
- name: REGISTRY_TOKEN
|
|
value: $(params.registry-token)
|
|
script: |
|
|
#!/bin/sh
|
|
set -e
|
|
|
|
echo "Promoting image to :latest..."
|
|
|
|
# Extract registry and repo from image
|
|
# e.g., forgejo.riotpiao.com/riotpiao-poimen/poimen-memory:abc123
|
|
REGISTRY=$(echo $IMAGE | cut -d/ -f1)
|
|
REPO=$(echo $IMAGE | cut -d: -f1)
|
|
SHA=$(echo $IMAGE | cut -d: -f2)
|
|
|
|
echo "Registry: $REGISTRY"
|
|
echo "Repo: $REPO"
|
|
echo "SHA: $SHA"
|
|
echo ""
|
|
|
|
# Login and promote
|
|
echo "$REGISTRY_TOKEN" | docker login -u "$REGISTRY_USER" --password-stdin "$REGISTRY"
|
|
docker pull "$IMAGE"
|
|
docker tag "$IMAGE" "${REPO}:latest"
|
|
docker push "${REPO}:latest"
|
|
|
|
echo "✓ Promoted to :latest"
|
|
|
|
params:
|
|
- name: image
|
|
value: $(params.image)
|
|
- name: registry-user
|
|
value: $(params.registry-user)
|
|
- name: registry-token
|
|
value: $(params.registry-token)
|
|
|
|
finally:
|
|
- name: cleanup
|
|
taskSpec:
|
|
steps:
|
|
- name: cleanup-tasks
|
|
image: alpine:latest
|
|
script: |
|
|
#!/bin/sh
|
|
echo "Pipeline execution complete"
|