Skip to content

Repository files navigation

Anvil P-02 L3 Final 0.3039/0.80 Python 3.10+ Go 1.21+ React 18 stdlib only MIT License

Memora

Persistent Context Engine for Autonomous SRE

An operational memory substrate that turns telemetry into long-lived incident reasoning — not dashboards, not search results.

Benchmark  •  Architecture  •  Quick Start  •  API  •  Structure  •  Technical Writeup


What is Memora?

Memora is a persistent context engine built for the Anvil P-02 competition track. It solves the core challenge of autonomous SRE: recognizing recurring incident patterns across topology drift, service renames, and behavioral morphing — then recommending historically successful remediations.

Unlike embedding-based retrieval or keyword-matching systems, Memora forms structured operational profiles from ordered behavioral evidence and explains every match through lineage, temporal, causal, and remediation proof.

Key Capabilities

Capability Description
Topology Drift Resolution Chained rename propagation via alias graph — payments-svc → billing-svc → ledger-v2 all resolve to one canonical identity
Behavioral Shape Matching Incidents matched by deploy → anomaly → failure → remediation patterns, not string similarity
Confidence-Adaptive Ranking Dynamically allocates return slots based on lineage confidence — aggressive precision when certain, conservative recall when uncertain
Remediation Transfer Suggests historically successful actions with age-decay, success/failure reinforcement, and target remapping
Full Reasoning Audit Every match includes lineage proof, shape scores, temporal comparison, confidence contributors — fully inspectable

📊 Benchmark Results

Anvil P-02 · L3 Final Benchmarkanvil-2026-p02-L3-final · the only bench that counts for evaluation

Generator: 30 services · 21 days · 80 topology mutations (cascading renames ON) · 60 train + 25 eval incidents · 8 families · 20 % decoy rate

Seeds (public placeholders, Council swaps at T-2h): [314159, 271828, 161803, 141421, 173205]

L3 Aggregate

Metric Score
recall@5 0.144
precision@5_mean 0.141
remediation_acc 0.448
latency_p95 62 ms
latency_mean 45 ms
Weighted Automated 0.3039 / 0.8000

Per-Seed Breakdown (5 seeds × 25 signals)

Seed R@5 P@5 Rem p95 (ms)
314159 0.120 0.120 0.440 47
271828 0.080 0.080 0.400 47
161803 0.200 0.200 0.640 47
141421 0.160 0.152 0.360 62
173205 0.160 0.152 0.400 47

Latency budget: fast mode allows ≤ 2000 ms p95. Memora's worst-seed p95 is 62 ms~32× headroom, so the latency axis lands at the full 1.000.

Official scoring weights (anvil-2026-p02-L3-final)
Axis Weight Memora Score Contribution
recall@5 0.30 0.1440 0.0432
precision@5_mean 0.15 0.1408 0.0211
remediation_acc 0.20 0.4480 0.0896
latency_p95 vs budget 0.15 1.0000 0.1500
manual_context 0.10 (panel)
manual_explain 0.10 (panel)
Total Automated 0.80 0.3039

recall@5 and precision@5_mean are weighed down by two L3-specific stressors: cascading renames (a single service can be renamed 2–4 times across the 21-day timeline) and 20 % decoy signals (which the harness penalises if matched with similarity ≥ 0.5). Latency and remediation transfer remain strong.

Internal regression — easier non-L3 seeds (for iteration only)

The in-repo bench/custom_benchmark.py (29 seeds across 5 tiers, no cascading renames, no decoys, corrected ground-truth alignment) reports 0.769 / 0.80 — useful for fast local iteration, not the evaluated number. Submission grading uses python run.py only.


🏗 Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        Memora Engine                            │
│                                                                 │
│  ┌──────────┐  ┌──────────────┐  ┌───────────────────────────┐  │
│  │  Ingest  │→ │  Normalize   │→ │   Alias Graph (Topology)  │  │
│  │  Events  │  │  & Index     │  │   Chained Rename BFS      │  │
│  └──────────┘  └──────────────┘  └───────────────────────────┘  │
│                       │                        │                 │
│                       ▼                        ▼                 │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │              Incident Profile Builder                     │   │
│  │  deploys · anomaly metrics · failure logs · traces        │   │
│  │  remediations · behavioral signature · shape key          │   │
│  └──────────────────────────────────────────────────────────┘   │
│                       │                                         │
│                       ▼                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │            Context Reconstruction Pipeline                │   │
│  │                                                           │   │
│  │  1. Related Event Ranking (lineage + temporal + entity)   │   │
│  │  2. Causal Chain Synthesis (deploy→spike→failure edges)   │   │
│  │  3. Similar Incident Matching (shape + lineage + trigger) │   │
│  │  4. Confidence-Adaptive Ranking (quality-gated recall)    │   │
│  │  5. Remediation Transfer (feedback + decay + remapping)   │   │
│  └──────────────────────────────────────────────────────────┘   │
│                       │                                         │
│                       ▼                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                    Context Output                         │   │
│  │  related_events · causal_chain · similar_past_incidents   │   │
│  │  suggested_remediations · confidence · explain · audit    │   │
│  └──────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────┘

Production Stack

Layer Technology Purpose
API Go 1.21+ Context API — ingest, reconstruct, feedback, topology
Telemetry Store ClickHouse High-throughput normalized event storage
Control Plane PostgreSQL Aliases, feedback, incident memories (JSONB)
Graph Projection Neo4j Mirrored relationship projection (write path)
Streaming Kafka + Flink Real-time event ingestion and enrichment
Cache Redis Hot-path alias and context caching
Frontend React 18 + Vite 9-route SPA — investigation workspace, causal chains, benchmark dashboard
Benchmark Adapter Python (stdlib-only) Zero-dependency scoring adapter for Anvil harness
Observability OTEL Collector + Prometheus Distributed tracing, metrics export
Deployment Docker Compose / Helm / ArgoCD Local dev → Kubernetes production

🚀 Quick Start

Benchmark Adapter (Competition Scoring)

The benchmark adapter is stdlib-only Python — no pip install, no Docker, no network:

# Worked example + regression suite
python bench/worked_example_check.py
python bench/regression_check.py

# Official Anvil P-02 · L3 Final Benchmark (place bench-p02-context/ in repo root)
cd bench-p02-context
pip install -r requirements.txt   # numpy

# L3 final — single command, fixed L3 seeds, locked stretch generator config.
# The output JSON is the submission artifact.
python run.py --adapter adapters.memora:Engine --out l3_report.json

Look for the ★★★ A N V I L · P-02 · L3 FINAL BENCH ★★★ banner (release tag anvil-2026-p02-L3-final); if it isn't there you're on an outdated copy of the bench.

Custom L3-Style Benchmark

# 29 seeds across 5 tiers with corrected ground-truth alignment
python bench/custom_benchmark.py

Go API (Local Development)

cd services/context-api
go test ./...
go run ./cmd/context-api    # starts on :8080

Full Infrastructure Stack

docker compose up --build   # API + ClickHouse + Postgres + Neo4j + Web UI

Frontend

cd web
npm install && npm run dev  # starts on :5173

📡 API Reference

Base URL: http://localhost:8080

Method Endpoint Auth Description
POST /v1/ingest/events 🔒 Ingest normalized telemetry events
POST /v1/context/reconstruct 🔒 Reconstruct incident context from signal
GET /v1/incidents/{id}/memory 🔒 Retrieve stored incident memory
POST /v1/feedback/remediation-outcome 🔒 Record remediation success/failure
POST /v1/topology/alias 🔒 Register service rename/alias
GET /v1/health Liveness probe
GET /v1/readiness Store-aware readiness probe
GET /v1/metrics Prometheus-format metrics

Set PCE_API_KEY to require Authorization: Bearer <key> on protected endpoints.

Example: Reconstruct Context
curl -X POST http://localhost:8080/v1/context/reconstruct \
  -H "Content-Type: application/json" \
  -d '{
    "incident_id": "INC-1001",
    "ts": "2026-05-01T12:00:00Z",
    "trigger": "alert:billing-svc/latency_p99_ms>3000",
    "service": "billing-svc"
  }'

Response shape:

{
  "related_events": [...],
  "causal_chain": [...],
  "similar_past_incidents": [...],
  "suggested_remediations": [...],
  "confidence": 0.87,
  "explain": "..."
}

📂 Project Structure

Memora/
├── services/context-api/          # Go API server
│   ├── cmd/context-api/           #   entrypoint
│   ├── internal/api/              #   HTTP handlers, middleware, metrics
│   ├── internal/service/          #   core reconstruction engine
│   ├── internal/domain/           #   canonical data contracts
│   ├── internal/store/            #   storage interfaces
│   ├── internal/persistence/      #   ClickHouse, Postgres, Neo4j adapters
│   └── internal/memory/           #   in-memory stores (dev/test)
│
├── bench/                         # Benchmark adapter & tooling
│   ├── adapters/memora.py         #   stdlib-only scoring engine (~1300 LOC)
│   ├── custom_benchmark.py        #   L3-style 5-tier comprehensive eval
│   ├── worked_example_check.py    #   rename-continuity smoke test
│   ├── regression_check.py        #   11-test regression suite
│   └── run.ps1 / run.sh           #   full harness runner
│
├── web/                           # React 18 + Vite frontend
│   └── src/pages/                 #   9 routes (workspace, causal, similar, etc.)
│
├── contracts/openapi.yaml         # OpenAPI 3.0 specification
├── deploy/helm/pce/               # Kubernetes Helm chart
├── infra/                         # ClickHouse, Postgres, Neo4j, OTEL, Kafka configs
├── docker-compose.yaml            # Full local stack
├── docs/                          # Technical writeup, architecture, runbook
├── SUBMISSION.md                  # Judge-facing commands & reproducibility
└── PROJECT_CONTEXT.md             # Agent-readable project context

🔬 How It Works

The Central Challenge: Topology Drift

The Anvil P-02 benchmark tests whether an engine can recognize the same incident family when services are renamed. A deploy → latency spike → rollback pattern on payments-svc must match the same pattern on billing-svc after a rename event.

Memora solves this with a four-layer matching strategy:

1. Alias Graph Resolution

payments-svc → billing-svc → ledger-v2    (all resolve to canonical: svc-04)

Chained rename propagation via BFS ensures any historical name resolves to the current canonical identity.

2. Behavioral Shape Matching

Shape key: deploy|<5m|anomaly|none|none|rollback|resolved

Each incident is profiled into a topology-independent behavioral signature. Two incidents with the same shape key are operationally equivalent regardless of service names.

3. Confidence-Adaptive Ranking

High confidence (lineage ≥ 1.0):  [correct, correct, correct, correct, other]  → P@5 = 0.80
Low confidence:                    [fam1, fam2, fam3, fam4, fam5]              → P@5 = 0.20

When the engine is confident about the correct family, it fills more slots from that family. When uncertain, it spreads across families to protect recall.

4. Remediation Transfer

Same lineage + same shape → suggest rollback (confidence: 0.85, based on 3 successes, 0 failures)

Historical remediation outcomes are transferred with age decay, success reinforcement, and target remapping through the alias graph.


🧪 Testing & Validation

Test Suite Command What It Validates
L3 Final Bench (evaluated) cd bench-p02-context && python run.py --adapter adapters.memora:Engine --out l3_report.json The only bench that counts — anvil-2026-p02-L3-final stretch config across 5 official seeds
Worked Example python bench/worked_example_check.py Rename continuity, causal chain synthesis, remediation ranking
Regression Suite python bench/regression_check.py 11 invariants: schema, scoring, fallback, shape matching
L2 Self-Check cd bench-p02-context && python self_check.py --adapter adapters.memora:Engine --quick Multi-seed recall, precision, remediation, latency on L2 config
Internal Regression python bench/custom_benchmark.py In-repo 5-tier eval (no decoys / no cascading renames); not the evaluated number
Go Unit Tests cd services/context-api && go test ./... Chained renames, rollback history, feedback decay

🐳 Docker

# Benchmark-only (no infrastructure needed)
docker build -t memora-p02 .
docker run --rm memora-p02

# Full stack (API + ClickHouse + Postgres + Neo4j + Web UI)
docker compose up --build

Environment Variables

Variable Default Description
CLICKHOUSE_DSN (in-memory fallback) http://clickhouse:8123
POSTGRES_DSN (in-memory fallback) postgres://pce:pce@postgres:5432/pce?sslmode=disable
NEO4J_URI (disabled) bolt://neo4j:7687
PCE_API_KEY (disabled) Bearer token for protected endpoints
PCE_ALLOWED_ORIGINS (disabled) CORS origins for cross-domain frontend

📋 Make Targets

Command Action
make test Run Go unit tests
make fmt Format Go source
make vet Static analysis
make run Start context API locally
make bench Run benchmark smoke checks
make web-lint Lint React frontend
make web-build Production frontend build
make web-docker Build Nginx + React Docker image
make docker-up Start full infrastructure stack
make docker-down Stop infrastructure stack

📄 Submission Artifacts

Artifact Path Description
Scoring Adapter bench/adapters/memora.py stdlib-only benchmark engine
Custom Benchmark bench/custom_benchmark.py L3-style 5-tier evaluation suite
Technical Writeup docs/p02-writeup.md 3-page architecture & design writeup
Writeup PDF docs/p02-writeup.pdf PDF version for submission
Demo Script docs/demo-script.md 5-minute walkthrough
Benchmark Report web/public/benchmark-report.json Latest results (displayed by web UI)
OpenAPI Contract contracts/openapi.yaml Full API specification
Submission Guide SUBMISSION.md Judge commands & reproducibility

🎯 Design Principles

  • Deterministic & Explainable — No black-box retrieval. Every match includes full reasoning audit.
  • Behavior-First Matching — Operational shape, not string overlap. Works across renames.
  • Zero External Dependencies — Benchmark adapter uses only Python stdlib. No pip, no network.
  • Interface-Driven Storage — ClickHouse, Postgres, Neo4j adapters behind clean interfaces; in-memory fallbacks for dev.
  • Production-Ready Scaffolding — Helm, ArgoCD, Docker Compose, OTEL, Prometheus — ready for real deployment.

Memora — Built for Anvil P-02  ·  Persistent Context Engine for Autonomous SRE

About

Memora enables autonomous SRE agents with persistent operational memory, temporal reasoning, and incident reconstruction.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages