Skip to content

Runtime Architecture

Source mirrored from seocho/docs/RUNTIME_ARCHITECTURE.md

This page explains the HTTP runtime and local service boundary. Read /docs/architecture/ first if you only need the product overview. Read /docs/runtime_deployment/ if you only want to run the stack.

SEOCHO has one canonical engine under src/seocho/ and one deployment shell under runtime/.

LayerOwnsMain paths
SDK engineontology, indexing, query, answer contractssrc/seocho/
Runtime shellHTTP routes, request policy, readiness, service compositionruntime/
Compatibility shelllegacy imports and batch compatibilityextraction/
UI shelllocal evaluation frontend and proxyevaluation/

The runtime should not become a second copy of the engine. When a route needs canonical behavior, it should call the SDK/query/indexing seam rather than reimplementing that behavior in a FastAPI file.

The supported local stack is intentionally small:

ServicePurpose
neo4jlocal graph database, compatible with DozerDB-style Cypher workflows
extraction-serviceruntime API container name kept for compatibility
evaluation-interfacelocal chat and inspection UI

extraction-service is still the compose service name, but the long-term code owner is runtime/. The default image bakes extraction/, runtime/, and src/seocho/ into one known source snapshot. Live bind mounts are reserved for explicit development loops such as make up-live or make dev-up.

Runtime service composition should start in runtime/server_runtime.py.

ConcernOwner
route registration and request validationruntime/agent_server.py
shared runtime service constructionruntime/server_runtime.py
memory-first ingest and search facaderuntime/memory_service.py
raw text runtime ingestionruntime/runtime_ingest.py
request policyruntime/policy.py
agent readiness summaryruntime/agent_readiness.py
request ID propagationruntime/middleware.py
public memory routesruntime/public_memory_api.py

Routers should prefer lazy service getters over eager singleton boot at import time. This keeps tests, local development, and degraded startup states easier to reason about.

extraction/ is a historical name. New runtime-facing behavior should move toward this package shape:

PackageDirection
src/seocho/canonical SDK and engine modules
runtime/deployment shell, HTTP routes, policy, readiness, registries
extraction/extraction helpers and compatibility wrappers during migration

Use docs/RUNTIME_PACKAGE_MIGRATION.md for the staged migration contract. Use docs/MODULE_OWNERSHIP_MAP.md when deciding whether a change belongs in src/seocho/, runtime/, or extraction/.

EndpointPurpose
POST /run_agentlegacy router mode
POST /run_agent_semanticsemantic graph QA mode
POST /run_debatemulti-graph debate mode
POST /indexes/fulltext/ensureensure graph fulltext index exists
POST /platform/chat/sendlocal platform chat endpoint
POST /platform/ingest/rawraw record ingestion into a graph target
GET /platform/chat/session/{session_id}read platform session history
DELETE /platform/chat/session/{session_id}reset platform session
POST /semantic/artifacts/draftssave draft ontology/SHACL/vocabulary artifacts
GET /semantic/artifactslist semantic artifacts
GET /semantic/artifacts/{artifact_id}read one semantic artifact
POST /semantic/artifacts/{artifact_id}/approvepromote a draft artifact
POST /semantic/artifacts/{artifact_id}/deprecatedeprecate an approved artifact
GET /databaseslist registered databases
GET /agentslist active database-bound agents

The user activation path for runtime changes is:

  1. ingest raw data through /platform/ingest/raw
  2. ensure the fulltext index through /indexes/fulltext/ensure
  3. ask through /platform/chat/send
  4. inspect trace and response metadata
  5. pass the runtime smoke gate

The runtime must distinguish “API process is up” from “every graph agent is ready.”

StateMeaningRuntime behavior
readytarget graph and tools are usableroute normally
degradedsome graph targets are missing or unavailablereturn partial state and avoid unsafe fan-out
blockedrequired target or policy gate is unavailablefail with an explicit reason

Debate mode should only create agents for graph targets that exist and are reachable. If some targets are skipped, the response payload should expose that state instead of pretending the comparison was complete.

ArtifactLocation
local graph statedata/neo4j/
semantic artifactsoutputs/semantic_artifacts/
rule profile registryoutputs/rule_profiles/rule_profiles.db
semantic run metadataoutputs/semantic_metadata/
JSONL tracesSEOCHO_TRACE_JSONL_PATH

See /docs/files_and_artifacts/ for inspection commands.

SEOCHO supports a vendor-neutral trace contract:

BackendUse
nonedisable trace export
consolelocal debugging
jsonldurable local evidence
opikteam evaluation and span inspection

Opik is optional. The runtime should still be explainable through JSONL traces and response metadata when Opik is disabled.

SurfaceRole
local platform UIinteractive chat, candidate override loop, raw ingest controls
runtime response payloadrequest result, trace steps, readiness metadata
JSONL traceportable evidence for local runs and CI artifacts
Opikoptional team-grade evaluation, span trees, cost and latency inspection

Do not make a feature depend on the frontend trace view alone. The runtime payload or trace artifact should carry the same operational evidence.

Common environment variables:

Terminal window
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o-mini
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=password
SEOCHO_TRACE_BACKEND=none
SEOCHO_TRACE_JSONL_PATH=./traces/seocho-runtime.jsonl
SEOCHO_TRACE_OPIK_MODE=self_host
OPIK_URL=http://opik-backend:8080
OPIK_WORKSPACE=default
OPIK_PROJECT_NAME=seocho
OPIK_API_KEY=

The runtime should stay environment-first. Reference YAML under extraction/conf/ is useful for compatibility and examples, but runtime deployment should not require editing source-controlled config files.

Run the narrowest relevant check first:

ChangeValidation
runtime routes, policy, readinessbash scripts/ci/check-runtime-shell-contract.sh
runtime docs onlybash scripts/ci/check-doc-contracts.sh
behavior or API payload shapebash scripts/ci/run_basic_ci.sh
public runtime guidewebsite docs checks after mirroring

Mocks can validate contracts and deterministic failures. They are not evidence for throughput, latency, scalability, or production readiness.