Implementation Plan: Temporal Memory and Pattern Oracle

Learn from history and feed recommendations into synthesis and governance by implementing the Temporal Database subsystem (VectorStore + PatternOracle + MetricIndexer). This plan operationalizes institutional memory as deterministic, queryable artifacts.

Provenance & Traceability

Architectural Decisions (ADRs)

ADR ID Decision Title Impact on This Plan
ADR-030 VibesPro™ Foundation Integration Temporal AI is adopted as the foundational pattern oracle implementation.
ADR-029 Observability Stack Architecture MetricIndexer ingests operational telemetry for pattern weighting.

Product Requirements (PRDs)

PRD ID Requirement Title Satisfied By (SDS) Acceptance Criteria
PRD-020 VibesPro™ Foundation Platform Requirements SDS-045, SDS-015 US-001..US-002 (pattern query + learning)

Software Design Specifications (SDS)

SDS ID Service/Component Bounded Context SEA-DSL Spec File Implementation Status
SDS-015 Temporal Database Service semantic-core N/A Designed
SDS-045 VibesPro™ Foundation Integration shared N/A Proposed

Provenance Chain

graph TD
  ADR30[ADR-030: VibesPro™ Foundation] --> PRD20[PRD-020: VibesPro™ Foundation Platform]
  PRD20 --> SDS15[SDS-015: Temporal Database Service]
  PRD20 --> SDS45[SDS-045: Foundation Integration]
  ADR29[ADR-029: Observability] --> SDS15

Architecture and Design

Design Principles Applied

Dependency Justification

Updated 2025-12-30: Added specific dependencies from gap analysis section 1.3 (Temporal Database / Semantic Memory).

Dependency Type Version Package Justification ADR/SDS Reference
pgvector PostgreSQL Extension 0.8.x pgvector PostgreSQL-native vector storage with ACID guarantees, hybrid queries, and simpler ops than dedicated vector DBs. Sufficient for SEA™’s scale (<1M vectors). SDS-015
timescaledb PostgreSQL Extension 2.17.x timescaledb Track metric evolution and pattern detection with native PostgreSQL integration. SDS-015
llama.cpp Runtime latest llama-cpp-python, llama.cpp CLI Run EmbeddingGemma locally for deterministic embeddings. SDS-015
EmbeddingGemma Model 300M 4-bit GGUF EmbeddingGemma-300M-Q4_K_M.gguf Local-first, deterministic embeddings. 300M params + 4-bit quantization = fast inference (<100ms) with low resource usage. Fine-tunable on SEA-DSL corpus. SDS-015

Installation Commands

1
2
3
4
5
6
7
8
9
10
11
12
# PostgreSQL extensions (in Docker or migration)
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS timescaledb;

# Python dependencies
pip install pgvector psycopg[binary] llama-cpp-python

# llama.cpp CLI (via mise)
mise use llama-cpp@latest

# Download embedding model
wget -P models/ https://huggingface.co/google/EmbeddingGemma-7B-GGUF/resolve/main/EmbeddingGemma-300M-Q4_K_M.gguf

Semantic Memory Port Architecture

1
2
3
4
5
6
// Semantic Memory Port (wraps pgvector + llama.cpp)
interface SemanticMemoryPort {
  storeObservation(content: string, metadata: Metadata): Promise<VectorId>;
  findSimilar(query: string, limit: number): Promise<ScoredObservation[]>;
  generateEmbedding(text: string): Promise<Float32Array>;
}

Expected Filetree

1
2
3
4
/
├── docs/specs/semantic-core/sds/015-temporal-database-service.md
├── docs/specs/shared/prd/020-vibespro-foundation-platform.md
└── docs/specs/shared/sds/045-vibespro-foundation-integration.md

Proposed Cycles

Cycle Branch Wave Files Modified Files Created Specs Implemented
C1A cycle/p010-c1a-temporal-api-contract 1 docs/specs/semantic-core/sds/015-temporal-database-service.md Entities/resources/flows/policies
C1B cycle/p010-c1b-governance-signals 1 docs/specs/shared/adr/029-observability-stack-architecture.md (if needed) Telemetry ingestion expectations
C2A cycle/p010-c2a-integration-hooks 2 docs/specs/shared/sds/045-vibespro-foundation-integration.md RecommendPatterns + embedding hooks

Task Breakdown

Wave 1 (Parallel)

Wave 2 (Depends on Wave 1)


Validation & Verification

Spec Validation

Implementation Validation


Open Questions

  1. Where are the “success rate” and “risk level” metrics sourced from (OpenObserve vs governance evidence vs both)? Both (spans + evidence)
  2. What is the canonical embedding model and dimensionality (and where is it configured)? text-embedding-3-small (1536 dims)
  3. What is the retention policy for embeddings and telemetry-derived aggregates? Embeddings indefinite, aggregates 1yr

Risks & Mitigation

Risk Likelihood Impact Mitigation Strategy
Privacy leakage via embeddings Medium High Enforce local-first; scrub PII before embedding; store only derived features when needed.
Recommendation instability Medium Medium Deterministic ranking inputs; version model + scoring weights; record provenance of recommendations.

Rollback Strategy

  1. If MetricIndexer is unstable, run PatternOracle in “similarity-only” mode until telemetry ingestion is reliable.

Linked Specifications

Type ID/Doc Document
PRD PRD-020 docs/specs/shared/prd/020-vibespro-foundation-platform.md
SDS SDS-015 docs/specs/semantic-core/sds/015-temporal-database-service.md
SDS SDS-045 docs/specs/shared/sds/045-vibespro-foundation-integration.md