code View on GitHub
api REST API Reference

Tropelex API Reference

Complete HTTP REST API documentation for the Tropelex agent memory system. This reference describes the API — it isn't a live instance. Once you're running Tropelex yourself, the base URL is http://localhost:8766; native JSON endpoints provide state management, causal Q&A, safety auditing, deep research, and Git sync.

database 1. Core Projects & Decisions

GET /api/projects
List All Projects

Returns a list of all active project memory containers in Tropelex.

curl -s http://localhost:8766/api/projects
Response (200 OK): ["Tropelex", "MyProject"]
GET /api/memory/{project}
Read Project Memory

Returns full memory details for a project including all decisions, sessions, safety score, and pattern tags.

curl -s http://localhost:8766/api/memory/Tropelex
POST /api/memory/{project}/decisions
Add Decision

Records a new architectural decision. Requires an explicit safety_metadata.safety_category — no silent default. Optionally takes context, citation_ids, and goal_id.

curl -X POST http://localhost:8766/api/memory/Tropelex/decisions   -H "Content-Type: application/json"   -d '{"decision": "Using FastAPI for REST endpoints", "context": "Provides high performance async processing", "safety_metadata": {"safety_category": "general"}}'
PATCH /api/memory/{project}/decisions/{id}/context
Update Context

Backfills or updates rationale context for an existing decision.

curl -X PATCH http://localhost:8766/api/memory/Tropelex/decisions/dec-123/context   -H "Content-Type: application/json"   -d '{"context": "Updated context with benchmark justification"}'

high_quality 2. Quality & Analysis

GET /api/memory/{project}/insights
Project Insights

Computes decision stats, untagged ratios, ghost drift alerts, and friction metrics.

curl -s http://localhost:8766/api/memory/Tropelex/insights
GET /api/patterns
Learned Patterns

Auto-detected usage/workflow patterns (e.g. recurring decision categories) and next-step suggestions. Pass ?project= to scope to one project; omitted, aggregates across every project.

curl -s "http://localhost:8766/api/patterns?project=Tropelex"
GET /api/memory/{project}/similar
Similar Projects

Finds other projects with similar tech stacks or learned patterns — not similar decisions within one project (see POST .../rag/context below for that).

curl -s http://localhost:8766/api/memory/Tropelex/similar

account_tree 3. Lineage & Decision Graph

GET /api/memory/{project}/decision-tree
Decision Graph (DAG)

Returns decision nodes and causal directional links for graph visualization.

curl -s http://localhost:8766/api/memory/Tropelex/decision-tree
POST /api/memory/{project}/rag/context
RAG Context Retrieval

Retrieves the top_k most relevant decisions for a query, formatted as a single context string ready to inject into a prompt.

curl -X POST http://localhost:8766/api/memory/Tropelex/rag/context   -H "Content-Type: application/json"   -d '{"query": "why did we choose FastAPI", "top_k": 5}'

shield_lock 4. Safety & Governance

GET /api/memory/{project}/safety-dashboard
Safety Dashboard

Returns composite safety score, active budget balances, and alignment status.

curl -s http://localhost:8766/api/memory/Tropelex/safety-dashboard
GET /api/memory/{project}/needs-attention
Needs Attention

Aggregates everything currently waiting on a human for this project: pending reviews, untagged decisions, decayed-confidence items, flagged content, unacknowledged handoffs, and agent-surface findings. Live state meant to be revisited, not a one-time checklist. One source (flagged citations) is intentionally global rather than project-scoped, since Tropebook's citation store isn't split per project.

curl -s http://localhost:8766/api/memory/Tropelex/needs-attention

history_toggle_off 5. Sessions & Compaction

GET /api/memory/{project}
List Work Sessions

There's no dedicated /sessions endpoint — session history is the session_history field on the full project memory response, alongside decisions, patterns, and everything else.

curl -s http://localhost:8766/api/memory/Tropelex | jq '.session_history'
POST /api/memory/{project}/sessions/record
Record End of Session

Records a session summary, triggers pattern learning, and (optionally, via session_shape) baselines this session's tool-call/latency profile against the agent's own history.

curl -X POST http://localhost:8766/api/memory/Tropelex/sessions/record   -H "Content-Type: application/json"   -d '{"summary": "Built the safety budget endpoint", "agent_name": "Claude"}'
POST /api/compress
Compress Prompt

Compresses a prompt via the configured LLM backend (falls back to a deterministic dict/concatenation strategy with no key configured). level (1-3) controls aggressiveness.

curl -X POST http://localhost:8766/api/compress   -H "Content-Type: application/json"   -d '{"prompt": "A very long prompt to shrink...", "level": 2}'

science 6. Deep Research & Feeds

POST /api/research/auto
Auto Research

Runs a search query against the Tropebook citation pipeline and imports results. Global, not project-scoped — citations land in the shared Tropebook store.

curl -X POST http://localhost:8766/api/research/auto   -H "Content-Type: application/json"   -d '{"query": "vector search reranking strategies", "max_results": 5}'
GET /api/research-feeds
List Research Feeds

Lists scheduled research feeds. Global by default; pass ?project= to filter to feeds visible to one project (global feeds, feeds it owns, and feeds shared with it).

curl -s "http://localhost:8766/api/research-feeds?project=Tropelex"
POST /api/memory/{project}/decisions/promote
Promote Research to Decision

Promotes a candidate decision (typically surfaced by POST .../research/promote-candidates) into a real, recorded decision with citation provenance — goes through the same safety-category gate as any manually-added decision.

curl -X POST http://localhost:8766/api/memory/Tropelex/decisions/promote   -H "Content-Type: application/json"   -d '{"decision": "Adopt vector search", "context": "Recall was the bottleneck", "citation_ids": ["cit_456"], "safety_metadata": {"safety_category": "general"}}'