Skip to content
Sauhard74Public

About

Deterministic procedural memory for agents

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

memJev

Deterministic procedural memory for agents.

Website · Quickstart · Agent setup · API · Architecture

CI Go 1.26+ AGPL v3


Successful runs should compound.

Record what worked. Verify it. Give the next agent a deterministic head start.


memJev turns successful agent runs into versioned, evidence-backed procedures and retrieves the right procedure for future tasks. It sits around your existing agent stack—capturing tool traces after execution and returning advisory plans before the next run.

Capture Verify Reuse
Record sanitized tool calls in execution order. Promote runs only after independent outcome evidence. Retrieve a compatible procedure or safely abstain.

Unlike a fuzzy trace cache, memJev checks tools, resources, policies, environment, freshness, and risk before a procedure can be returned. Every decision remains inspectable and replayable.

Quickstart

You need Go 1.26+, Docker with Compose v2, OpenSSL, curl, and Python 3.

git clone https://github.com/Sauhard74/mem-jev.git
cd mem-jev
make quickstart

That command creates local credentials, starts the stack, waits for readiness, and demonstrates the complete public API flow:

  1. Retrieve an advisory procedure.
  2. Record the agent's tool trace.
  3. Submit independently verified outcome evidence.

A new corpus has no reusable procedures yet, so the first retrieval abstains. The run is still recorded, and because the quickstart's demo tool has a registered contract and the outcome is verified, memJev learns it in the background. Run make quickstart again a few seconds later: the retrieval is SELECTED with a plan (steps, injectionId, taskExecutionId) marked advisoryOnly: true, because the routine has not been promoted yet. Each verified run of that plan counts toward promotion; after three, the routine is promoted to trial and served as a normal plan.

Recall is switched on automatically in local development: once a tenant (or person) has learned something, its first retrieval activates memJev's default serving configuration, and the worker promotes learned routines from verified outcomes and demotes them on verified failures (trial back to candidate, active to retired). An outcome reported unsafe quarantines the routine immediately, in every environment. A routine is learned only when every tool it uses has a registered contract (see below). Operators who publish their own manifests are never overridden; set MEMJEV_RETRIEVAL_AUTO_ACTIVATE=false to turn the default off. See the retrieval runbook.

Register your tools

memJev learns a routine only when every tool in it has a tool contract: a description of its inputs, side effects, risk, and how success is verified. Without one, the tool is opaque and its runs are recorded but never learned. Write the contracts as JSON (see examples/tool-contracts/quickstart.json) and register them:

scripts/register-tool-contracts.sh my-tools.json

The script prints each contract's contract_version_id. Send it as the tool's contractVersionId in retrieval requests. See tool contracts.

One memory per person

By default every token in a tenant shares one memory. To keep each person's routines separate, either issue each person their own token:

scripts/add-person.sh alice

or issue one token to a trusted service that names the person on every request:

scripts/add-person.sh --service
# then send: Memjev-Subject: <person id>

Either way, everything a person records and recalls stays in their own scope, and other people in the same tenant never see it. Person IDs can be up to 256 characters. Tool contracts registered for the tenant apply to all its people.

Useful commands

make setup            # Start the local stack
make quickstart       # Run the retrieve → trace → outcome example
make onboarding-test  # Verify the setup and API lifecycle
make learning-test    # Prove a learned routine becomes a plan, then gets promoted (starts its own stack)
make test             # Run the Go test suite with the race detector
make verify           # Run all repository quality checks
make dev-down         # Stop the stack and keep its data

Add memJev to an agent

memJev wraps an agent execution in three calls:

plan = memjev.retrieve(task, tools, resources, constraints)
result, events = agent.run(task, advisory_plan=plan)
trace = memjev.ingest(task, events)
evidence = verifier.check(task, result)
memjev.record_outcome(trace.id, evidence, plan.injection_id)

The plan is advisory. Your agent keeps its existing authorization, tool execution, and safety controls. If memJev abstains or retrieval is unavailable, the agent can continue normally.

See the agent integration guide for the lifecycle and safety contract, or run the compiling Go example:

set -a
source .env.local
set +a

MEMJEV_URL="$MEMJEV_E2E_API_URL" \
MEMJEV_TOKEN="$MEMJEV_E2E_TOKEN" \
go run ./examples/go-agent "write a hello file"

API

memJev exposes Connect/Protobuf services with JSON-compatible HTTP endpoints.

Service Method Purpose
RetrievalService Retrieve Find an eligible advisory plan for a task.
RetrievalService ExplainRetrieval Inspect candidates, gates, scores, and provenance.
IngestService IngestTrace Record the ordered events from an agent run.
OutcomeService RecordOutcome Attach independently verified evidence to a trace.
HealthService Check Report service readiness.

Every mutating operation is idempotent. Authentication determines the tenant and allowed scopes; request bodies cannot choose a tenant.

Copy-paste requests are available in the HTTP API walkthrough. The versioned contracts live in proto/memjev/v1.

How it works

                     ┌──────────────────────────┐
agent / harness ────►│ retrieve advisory memory │
        │            └────────────┬─────────────┘
        │                         │
        ▼                         ▼
 ordered trace              deterministic gates
        │                  + stable rank fusion
        ▼                         │
 verified outcome                ▼
        │                   procedure or abstain
        ▼
 procedure synthesis
        │
        ▼
 immutable graph + retrieval indexes

The system stores canonical evidence and immutable procedure revisions. Retrieval takes a consistent snapshot, generates candidates, rejects incompatible options, applies stable integer scoring, and persists the complete decision before returning it.

SurrealDB provides graph, document, text, and vector storage. Temporal runs durable evidence and synthesis workflows. An S3-compatible archive stores canonical traces.

Optional Jev judgments

TypeSafe Jev can judge ambiguous candidates after deterministic eligibility gates have run. It is optional and never required for availability. Accepted judgments are recorded with their model, rubric, features, and content hash so replays do not call the provider again.

scripts/setup.sh --jev-key-file /absolute/path/to/jev-api-key   # optional: --jev-model jev-1.14.0

This starts the Jev overlay, allows external model calls for the local credentials, and makes the default ranker use Jev features. The setting is saved in .env.local, so later scripts/setup.sh runs keep Jev on. The model is pinned: new installs default to jev-1.14.0, and an existing .env.local keeps the model it was set up with until you pass --jev-model.

Read the Jev guide before enabling it.

Documentation

Contributing

Issues and pull requests are welcome. Before opening a PR:

make onboarding-test
make verify

Please include tests for behavior changes and keep generated Protobuf files in sync. For larger changes, open an issue first so the API and evidence model can be discussed before implementation.

Security

Do not open a public issue for a vulnerability. Use GitHub's private vulnerability reporting for this repository. Never commit API keys, bearer tokens, production credentials, or raw trace data containing secrets.

License

memJev is open source under the GNU Affero General Public License v3.0.

About

Deterministic procedural memory for agents

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages