OCBrain v1 · current architecture
Resume small. Retrieve narrowly. Verify the finish.
OCBrain is one local, source-backed bridge for compatible MCP clients, including Codex, Claude Code, Hermes, and OpenClaw. It keeps an append-only evidence and outcome ledger, derives the current serving view, and gives each fresh context a deterministic orientation plus a small relevant dossier with exact sources on demand.
RAG is not dead here—and long context is not the database.
OCBrain's history is effectively unbounded and keeps changing. Re-reading it all for every question would waste compute and dilute attention. Pure top-k snippets are not enough either: models need a coherent local picture to compare sources, detect omissions, and understand what changed.
Retrieval filters
Scope-safe FTS5 works by itself. An optional loopback Ollama sidecar can add dense candidates without becoming authority.
Context assembles
ocbrain.context.v1 packages serving beliefs, contradictions, exclusion coverage, evidence counts, and source handles within 32 KB.
Sources expand
The model opens only the few exact sources it needs, within a size bound and after scope and content-hash checks. Hosted packets expose no local path.
Outcomes return
Feedback and closeout receipts link the decision, verification, action, and outcome back to what the model saw.
The index is replaceable infrastructure. The evidence and outcome ledger is the product.
The fresh-context loop
Briefing
brain.briefingdeterministically returns open goals, done and failed attempts, the latest closeout chain, and gotchas within 1,500 characters.Ledger
brain.ledgerchecks a stable task reference before search can convince an agent to build something twice.Context
brain.contextreturns a focused dossier and retrieval-use ID. Goals still point to versioned repo specs and executable finish lines.Source
brain.sourceexpands one issued handle in the same scope and verifies that the body has not changed.Work
The runtime treats context as evidence, not orders, verifies conflicts, and acts only within its existing authority.
Feedback
brain.feedbackrecords whether the retrieval was helpful, used, irrelevant, ignored, or harmful.Closeout
brain.closeoutappends status, decision impact, retrieval links, artifacts, verifiers, actions, outcomes, and provenance.
The default runtime profile exposes exactly thirteen tools: briefing, ledger, goal open/close, context, source, search, digest, get, feedback, ingest, closeout, and supersede. The explicit admin profile adds six local lifecycle/review controls for nineteen total. It adds no hosted judgment, hosted embedding, training, scheduler, watchdog, or bundle-transfer tool.
Dense retrieval is optional, local, and disposable.
v1.1.0 can combine lexical and dense candidate ranks with reciprocal-rank fusion. The dense index lives in a separate owner-only SQLite sidecar and uses only a loopback Ollama endpoint. It records the core event head, model digest, dimensions, and query-instruction hash so incompatible or stale vectors do not quietly participate.
Lexical baseline
FTS5 remains available with no extra service or package dependency.
Explicit build
vector-build snapshots current serving beliefs only when an operator invokes it. No background indexer is installed.
Fail-soft query
A missing model, stopped Ollama server, stale event head, bad dimension, or incompatible sidecar returns a visible dense_fallback reason and continues lexically.
No hosted fallback
The endpoint must be loopback HTTP. Failure never redirects source text to a hosted embedding provider.
Lifecycle, scope, visibility, and delivery checks create the eligible inventory before either lexical or dense candidates are ranked. Retrieval quality features cannot widen authority.
One semantic authority
brain_events is the append-only hash-chained authority. A correction, scope promotion, or tombstone is a later event; history is never silently rewritten.
Durable
Event payloads, source bodies and hashes, scope, provenance, actor/runtime, session, time, corrections, and aliases.
Projected
Evidence objects, current beliefs, evidence links, serving status, and search documents.
Operational receipts
Retrieval uses, source-handle issuance, egress audits, and closeouts survive semantic projection rebuilds.
Disposable features
Embeddings, FTS internals, rankings, summaries, classifications, and task-specific rewards can be rebuilt or replaced.
The strict v1 core contains no legacy relational knowledge/evidence plane and no dataset, trainer, judge, embedding, autopilot, scheduler, watchdog, deadman, or pager tables.
Scope controls affinity and privacy.
Each object carries scope type, scope ID, visibility, egress policy, and provenance. Local retrieval ranks every non-secret eligible scope by affinity and reports the actual scope_mix; the deprecated cross_scope flag no longer widens anything. Confidentiality remains a hard gate. For the ordinary hosted_model target, only non-confidential hosted_ok objects in the explicit scope list are eligible.
The server chooses the delivery target; tool arguments cannot downgrade it to local_model. Local packets report the eligible inventory and actual scope mixture. Hosted delivery stays explicitly scoped and reports delivery exclusions without exposing any excluded ID, body, path, or object sample. Every complete serialized packet is hard-bounded to 32 KB.
Direct get and source expansion enforce lifecycle, quarantine, confidentiality, and delivery boundaries, so knowing an object ID is not an access bypass. Hosted source handles use ocbrain:// locators instead of local paths and expand only in their original scope.
Migration maps only explicit legacy context. The placeholder value workspace becomes conservatively quarantined legacy_unscoped; it is not promoted into a fictional global project.
Historical at_ts retrieval is explicitly rejected in v1 until it can be implemented against event sequence correctly. It is never silently approximated.
Cross-machine exchange is evidence transfer, not brain cloning.
An unbounded private lake still needs backup and migration choices, but automatic replication would widen the privacy and authority surface. v1.0.1 therefore makes portable exchange an explicit file-only operation.
Export gate
An operator names exact evidence IDs; scope, egress policy, approval, size, redaction, and fresh-file checks run before publication.
Import gate
Validation and canonical payload hashing finish before SQLite opens; mutation requires a separate --apply.
Local authority
Sender IDs remain provenance. The receiving core derives local IDs and forces evidence into confidential local_only scope.
No semantic smuggling
Bundles cannot carry beliefs, retrieval receipts, closeouts, schedules, model state, or companion databases.
A click is not a universal reward.
The same physical action can mean different things on different sites. OCBrain keeps both a portable shape and the local meaning.
ocbrain.action.v1
Mechanism, local semantic role, target, pre-action context, policy/model, cost, provenance, and versioned features.
ocbrain.outcome.v1
Metric/value vector, role, unit, window, baseline, counterfactual, attribution, uncertainty, interpretation, and versioned features.
An experiment may derive one scalar reward for one policy. The append-only closeout keeps the components so a later model can reinterpret them without assuming a click, signup, subscription, deploy, or test pass means the same thing everywhere.
Procedural memory is earned from traces.
OCBrain's optional local procmine path normalizes tool-call traces into privacy-scrubbed episodes and mines repeated DAG shapes. A procedure is not promoted because one run looked plausible: the miner requires at least five episodes, a shared subsequence of at least three steps, and at least 50% task-family coverage. Below the floor it records an abstention.
Gotchas are shipped
Repeated failure → repair patterns can become short, local-only gotcha beliefs with evidence, expiry, and deterministic wording.
Procedures stay conservative
Procedure candidates use the ordinary belief shape and retrieval path; degraded or weakly supported procedures are excluded rather than injected.
Closeouts supply outcomes
Session identity, retrieval links, actions, outcomes, verifiers, and closeout chains make a trace useful without replaying the whole transcript.
No execution authority
OCBrain owns no loop, queue, scheduler, retry policy, or run state. The harness executes; the brain remembers evidence.
One distribution means one auditable boundary.
ocbrain is the whole product: ledger, projections, retrieval, MCP, receipts, backup/migration, curation scripts, diagnostics, and the public-safety scanner. The former ocbrain-training and ocbrain-ops companion distributions were deleted after their stores remained empty. There is no external CLI extension mechanism and no separate package installation.
Migration preserves before it transforms.
core-migrate-v1 creates a coherent immutable archive, preserves the exact event sequence and hashes, appends deterministic import events, extracts training and operations stores, bulk-rebuilds FTS, verifies counts and integrity, and publishes only fresh outputs plus a manifest.
The July 13 full rehearsal verified 671,580 events, 232,677 evidence objects, 137,530 beliefs, 241,185 evidence links, 108,222 serving/search documents, 1,725 retrievals, and four closeouts. It made no hosted or network call, started no scheduler, and did not activate or repoint the live database. The operator later activated a byte-identical live copy provisionally; fresh Codex, Claude Code, and OpenClaw processes all passed context → source → feedback → closeout, so the pointer was retained.
Training is not a runtime capability.
The current distribution contains no trainer, dataset pipeline, hosted judge, or prepared training pack. Adding that authority would require a reviewed source change; no credential or configuration flag can silently enable it.