Skip to content

feat: add entity-linked agent harness and docs#39

Merged
BennettSchwartz merged 6 commits into
masterfrom
codex/agent-harness-docs
May 1, 2026
Merged

feat: add entity-linked agent harness and docs#39
BennettSchwartz merged 6 commits into
masterfrom
codex/agent-harness-docs

Conversation

@BennettSchwartz

@BennettSchwartz BennettSchwartz commented May 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • add entity-linked memory graph support across core storage, retrieval, protobuf, and SDKs
  • add the TypeScript agent harness with deterministic and live optional-tool LLM checks
  • migrate public docs from Mintlify config to Docusaurus/Cloudflare Workers and refresh the README

Verification

  • make build
  • make test
  • npm --prefix clients/typescript run build
  • npm --prefix clients/typescript test -- --hookTimeout=120000
  • .venv/bin/python -m pytest clients/python/tests
  • npm --prefix examples/agent-harness run typecheck
  • npm --prefix examples/agent-harness run test:deterministic
  • npm --prefix examples/agent-harness run test:llm
  • npm run docs:build
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added entity memory type and entity-aware graph retrieval with relationship linking.
    • Introduced CaptureMemory and RetrieveGraph APIs replacing multiple ingestion/retrieval methods.
    • Added graph-bounded traversal with configurable node/edge/hop limits.
    • Implemented entity resolution during capture with term-to-entity linking.
  • API Changes

    • Replaced JSON-encoded bytes with structured protobuf types throughout gRPC APIs.
    • Graph results now return strongly-typed nodes and edges instead of encoded blobs.
  • Documentation

    • Complete documentation rewrite with updated guides and quick start.
    • Added agent harness example for LLM integration.

@BennettSchwartz BennettSchwartz merged commit 453a2b6 into master May 1, 2026
6 of 10 checks passed
@BennettSchwartz BennettSchwartz deleted the codex/agent-harness-docs branch May 1, 2026 02:47
@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6561c8d0-9316-4080-8581-db153c24e494

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc4ef7 and 9c216cd.

⛔ Files ignored due to path filters (9)
  • api/grpc/gen/membranev1/membrane.pb.go is excluded by !**/*.pb.go, !**/gen/**, !**/*pb.go
  • api/grpc/gen/membranev1/membrane_grpc.pb.go is excluded by !**/*.pb.go, !**/gen/**, !**/*pb.go
  • docs/favicon.svg is excluded by !**/*.svg
  • docs/logo/dark.svg is excluded by !**/*.svg
  • docs/logo/light.svg is excluded by !**/*.svg
  • examples/agent-harness/package-lock.json is excluded by !**/package-lock.json, !**/package-lock.json
  • package-lock.json is excluded by !**/package-lock.json, !**/package-lock.json
  • static/img/favicon.svg is excluded by !**/*.svg
  • static/img/logo-mark.svg is excluded by !**/*.svg
📒 Files selected for processing (94)
  • .assetsignore
  • .env.example
  • .gitignore
  • README.md
  • api/grpc/handlers.go
  • api/proto/membrane/v1/membrane.proto
  • clients/openclaw/README.md
  • clients/python/README.md
  • clients/python/membrane/__init__.py
  • clients/python/membrane/client.py
  • clients/python/membrane/types.py
  • clients/python/membrane/v1/membrane_pb2.py
  • clients/python/pyproject.toml
  • clients/python/tests/test_client.py
  • clients/python/tests/test_types.py
  • clients/typescript/README.md
  • clients/typescript/proto/membrane/v1/membrane.proto
  • clients/typescript/src/client.ts
  • clients/typescript/src/index.ts
  • clients/typescript/src/internal/grpc.ts
  • clients/typescript/src/internal/json.ts
  • clients/typescript/src/types.ts
  • clients/typescript/test/client.unit.test.ts
  • clients/typescript/test/types.test.ts
  • docs/.mintignore
  • docs/LICENSE
  • docs/api/go/ingestion.mdx
  • docs/api/go/membrane.mdx
  • docs/api/go/retrieval.mdx
  • docs/api/ingestion.mdx
  • docs/api/metrics.mdx
  • docs/api/overview.mdx
  • docs/api/retrieval.mdx
  • docs/api/revision.mdx
  • docs/architecture.mdx
  • docs/concepts/competence-learning.mdx
  • docs/concepts/memory-types.mdx
  • docs/concepts/plan-graphs.mdx
  • docs/concepts/trust-and-sensitivity.mdx
  • docs/docs.json
  • docs/guides/configuration.mdx
  • docs/guides/deployment.mdx
  • docs/guides/go-library.mdx
  • docs/guides/llm-integration.mdx
  • docs/guides/observability.mdx
  • docs/index.mdx
  • docs/introduction.mdx
  • docs/quickstart.mdx
  • docs/sdks/openclaw-plugin.mdx
  • docs/sdks/python.mdx
  • docs/sdks/typescript.mdx
  • docusaurus.config.js
  • examples/agent-harness/.env.example
  • examples/agent-harness/.gitignore
  • examples/agent-harness/README.md
  • examples/agent-harness/package.json
  • examples/agent-harness/src/agent.ts
  • examples/agent-harness/src/deterministic.ts
  • examples/agent-harness/src/index.ts
  • examples/agent-harness/src/llm-test.ts
  • examples/agent-harness/src/llm.ts
  • examples/agent-harness/src/membrane-daemon.ts
  • examples/agent-harness/src/scenario.ts
  • examples/agent-harness/src/tools.ts
  • examples/agent-harness/tsconfig.json
  • package.json
  • pkg/consolidation/competence.go
  • pkg/consolidation/entity_links.go
  • pkg/consolidation/plangraph.go
  • pkg/consolidation/semantic.go
  • pkg/consolidation/semantic_extractor.go
  • pkg/ingestion/capture.go
  • pkg/ingestion/capture_test.go
  • pkg/ingestion/ingestion.go
  • pkg/ingestion/llm.go
  • pkg/retrieval/graph.go
  • pkg/retrieval/graph_test.go
  • pkg/retrieval/trust.go
  • pkg/retrieval/trust_test.go
  • pkg/schema/entity.go
  • pkg/schema/memory_test.go
  • pkg/schema/payloads.go
  • pkg/storage/postgres/postgres.go
  • pkg/storage/postgres/schema.sql
  • pkg/storage/postgres/schema_test.go
  • pkg/storage/sqlite/schema.sql
  • pkg/storage/sqlite/sqlite.go
  • pkg/storage/sqlite/sqlite_test.go
  • pkg/storage/store.go
  • sidebars.js
  • src/css/custom.css
  • src/theme/MDXComponents.js
  • tests/eval_grpc_test.go
  • wrangler.jsonc

📝 Walkthrough

Walkthrough

This PR migrates the gRPC API from JSON-encoded bytes to typed protobuf messages, introduces an entity-aware graph retrieval system, adds two-pass interpretation with candidate resolution during capture, implements entity linking and lookup infrastructure, and provides new documentation and agent harness example.

Changes

Cohort / File(s) Summary
Protocol Buffer Schema
api/proto/membrane/v1/membrane.proto, clients/typescript/proto/membrane/v1/membrane.proto
Converts request/response fields from JSON bytes to typed protobuf: CaptureMemoryRequest.content/context use google.protobuf.Value; CaptureMemoryResponse, RetrieveGraphResponse return typed MemoryRecord, GraphNode, GraphEdge, SelectionResult; revision requests use MemoryRecord; metrics snapshots use google.protobuf.Value. Adds 40+ new message types for typed memory graph structures.
gRPC Handlers
api/grpc/handlers.go
Replaces JSON-byte validation/parsing with protobuf structpb.Value and typed record conversions. Removes unmarshalRecord JSON deserializer; adds comprehensive typed mapping layer (memoryRecordToPB/fromPB, valueFromPB/valueToPB) for record/graph structures. Updates all RPC response marshaling to return typed protobuf messages.
Generated Protobuf Code
clients/python/membrane/v1/membrane_pb2.py
Regenerated schema with struct_pb2 imports and expanded type system covering new MemoryRecord, graph entities, and payload types.
Python Client
clients/python/membrane/client.py, clients/python/membrane/types.py, clients/python/membrane/__init__.py
Replaces JSON-bytes helpers with google.protobuf.Value conversions and typed protobuf parsing. Adds EntityType, GraphPredicate, EntityAlias, EntityIdentifier constants/types. Updates CaptureMemory, Supersede, Fork, Merge to send typed records; updates RetrieveGraph to parse typed graph structures. Enhances EntityPayload with primary_type, types, structured aliases/identifiers.
Python SDK Tests
clients/python/tests/test_client.py, clients/python/tests/test_types.py
Shifts from JSON-byte stubs to typed protobuf message fixtures. Validates typed record serialization, graph node/edge parsing, oneof payload unwrapping, and new entity/graph predicate constants. Tests backward compatibility for legacy entity_kind mapping.
TypeScript Client
clients/typescript/src/client.ts, clients/typescript/src/types.ts, clients/typescript/src/index.ts, clients/typescript/src/internal/grpc.ts
Replaces encodeJsonBytes with toProtoValue/fromProtoValue for arbitrary values and toRpcMemoryRecord for record payloads. Adds EntityType, GraphPredicate, BuiltinEntityTypes constants and updated EntityPayload schema. Updates gRPC envelope types to reflect typed fields and arrays.
TypeScript JSON Converters
clients/typescript/src/internal/json.ts
Adds comprehensive protobuf-value codec (toProtoValue/fromProtoValue), schema-aware parsing functions (parseRecord, parseGraphEdge, parseSelection, parsePayload variants), and payload transformers (toRpcMemoryRecord, toRpcPayload). Handles bidirectional conversion between plain JS objects and protobuf structures.
TypeScript SDK Tests
clients/typescript/test/client.unit.test.ts, clients/typescript/test/types.test.ts
Updates test fixtures from JSON buffers to typed structValue objects and array shapes. Validates ProtoValue payloads, graph node/edge structures including weight fields, and new entity/graph predicate string values.
Storage Interfaces & Implementations
pkg/storage/store.go, pkg/storage/sqlite/sqlite.go, pkg/storage/sqlite/schema.sql, pkg/storage/postgres/postgres.go, pkg/storage/postgres/schema.sql
Adds new EntityLookup interface with FindEntitiesByTerm and FindEntityByIdentifier. Both SQLite and PostgreSQL now include entity_terms, entity_types, entity_identifiers tables with indexes. Implements entity reindexing on record create/update and upsert-on-conflict for relation writes (preventing duplicates per source/predicate/target).
Entity Linking & Consolidation
pkg/consolidation/entity_links.go, pkg/consolidation/semantic.go, pkg/consolidation/semantic_extractor.go, pkg/consolidation/competence.go, pkg/consolidation/plangraph.go
Introduces canonicalizeSemanticRecordEntities, findEntityByTerm, linkRecordToEntityTerms to resolve semantic subject/object terms to entities and append graph edges. Consolidation flows now derive entity relations and persist them transactionally with semantic/competence/plan-graph records.
Capture & Interpretation
pkg/ingestion/capture.go, pkg/ingestion/capture_test.go, pkg/ingestion/ingestion.go, pkg/ingestion/llm.go
Refactors CaptureMemory into two-phase prepareCaptureResolution (compute interpretation/candidates) and captureMemory (transactional apply). Adds CandidateResolver.Resolve for bounded resolution. Implements mention/reference/relation candidate materialization with entity ID resolution and bidirectional edge creation. Updates IngestObservation to canonicalize semantic entities transactionally.
Graph Retrieval
pkg/retrieval/graph.go, pkg/retrieval/graph_test.go, pkg/retrieval/trust.go, pkg/retrieval/trust_test.go
Expands root selection with entityRootCandidates and entity-based scoring (alias/type/relation matching with weights). Adds relatedEntity resolution and predicate-weighted boosts. Strengthens AllowsRedacted to require scope visibility. Introduces scope authorization helper.
Schema & Domain Models
pkg/schema/entity.go, pkg/schema/payloads.go, pkg/schema/memory_test.go
Adds entity classification constants and BuiltinEntityTypes list. Defines NormalizeEntityTerm, EntityAliasValues, EntityTypes helpers. Refactors EntityPayload from enum-like entity_kind + string aliases to ontology-based primary_type, types, structured EntityAlias/EntityIdentifier with custom JSON marshal/unmarshal for backward compatibility.
Evaluation Tests
tests/eval_grpc_test.go
Shifts from JSON-byte record encoding to typed pb.MemoryRecord. Updates CaptureMemory/Supersede/Fork/Merge tests to use typed records and protobuf values. Adds assertions for entity→semantic linkage through graphs and redaction behavior. Removes JSON malformed-input negative tests.
Documentation - Core Concepts
docs/introduction.mdx, docs/index.mdx, docs/concepts/memory-types.mdx, docs/concepts/competence-learning.mdx, docs/concepts/plan-graphs.mdx, docs/concepts/trust-and-sensitivity.mdx
Updates to reflect entity as sixth memory type, CaptureMemory+RetrieveGraph APIs, graph-bounded retrieval with limits (RootLimit, NodeLimit, MaxHops), entity interpretation/linking semantics, and decay/reinforcement targeting graph roots.
Documentation - API Reference
docs/api/overview.mdx, docs/api/ingestion.mdx, docs/api/retrieval.mdx, docs/api/revision.mdx, docs/api/metrics.mdx, docs/api/go/ingestion.mdx, docs/api/go/retrieval.mdx, docs/api/go/membrane.mdx
Replaces Ingest*/Retrieve method docs with CaptureMemory/RetrieveGraph. Describes typed protobuf envelopes and google.protobuf.Value. Adds RetrieveGraph request/response fields, entity resolution mechanics, and new graph limit parameters. Updates metrics to include entity type counts.
Documentation - Guides & SDKs
docs/guides/configuration.mdx, docs/guides/deployment.mdx, docs/guides/go-library.mdx, docs/guides/llm-integration.mdx, docs/guides/observability.mdx, docs/quickstart.mdx, docs/sdks/openclaw-plugin.mdx, docs/sdks/python.mdx, docs/sdks/typescript.mdx, docs/architecture.mdx
Rewrites ingestion/retrieval examples to use CaptureMemory/RetrieveGraph with entity and graph context. Updates configuration sections with graph defaults and ingest-side LLM settings. Shifts prompt construction to use graph nodes and root-based reinforcement. Removes old method-by-method listings in favor of condensed flow-oriented guides.
Documentation Infrastructure
README.md, docusaurus.config.js, sidebars.js, src/css/custom.css, src/theme/MDXComponents.js, package.json, docs/docs.json, docs/LICENSE, docs/.mintignore
Migrates from Mintlify to Docusaurus. Adds Docusaurus config, sidebar navigation, custom CSS theme components (fields, expandable, steps, cards), and MDX component rendering. Simplifies main README to emphasize RetrieveGraph and CaptureMemory. Updates package dependencies.
Agent Harness Example
examples/agent-harness/*
New comprehensive agent harness implementation: scenario.ts seeds entities/memories with relations; tools.ts provides Membrane tool definitions and runtime; agent.ts runs LLM agent loops with tool calling and tracing; llm.ts configures OpenAI/OpenRouter clients; membrane-daemon.ts starts or connects to daemon; deterministic.ts validates graph structure/trust/decay/revision flows; llm-test.ts runs live LLM integration tests. Includes package.json, tsconfig.json, .env.example, .gitignore, and README.md.
Configuration Files
.assetsignore, .env.example, .gitignore, wrangler.jsonc
Adds .assetsignore for asset exclusions, updates .env.example to blank MEMBRANE_EMBEDDING_API_KEY, extends .gitignore for build/Docusaurus/Wrangler output, and adds wrangler.jsonc for Cloudflare Workers doc site deployment.
TypeScript README
clients/typescript/README.md, clients/openclaw/README.md
Updates LLM integration example model from gpt-5.2 to gpt-5.5. Adds entity to supported context_types in OpenClaw docs.
Python README
clients/python/README.md, clients/python/pyproject.toml
Updates dependency docs from JSON-bytes encoding to typed protobuf messages and google.protobuf.Value. Upgrades grpcio requirement from >=1.78.0 to >=1.80.0.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Service
    participant Interpreter
    participant CandidateResolver
    participant Storage as Storage/<br/>EntityLookup
    participant Consolidator

    Client->>Service: CaptureMemory(content, context, reason_to_remember)
    Service->>Interpreter: Interpret(content, context)
    Interpreter-->>Service: Interpretation (mentions, relations, entities)
    
    alt CandidateResolver Available
        Service->>CandidateResolver: Resolve(interpretation, candidates)
        CandidateResolver-->>Service: Resolved interpretation with target IDs
    end
    
    Service->>Storage: WithTransaction
    Service->>Storage: Create primary_record
    Service->>Storage: FindEntitiesByTerm(subject, scope)
    Storage-->>Service: entity_record_ids
    Service->>Storage: AddRelation(subject_entity, object_entity, etc.)
    
    alt Entity Resolution Success
        Service->>Consolidator: Entity linking (mentioned entities)
        Consolidator->>Storage: Create entity_record
        Consolidator->>Storage: AddRelation(linked edges)
        Consolidator-->>Service: edges
    end
    
    Service-->>Client: CaptureMemoryResponse(primary_record, created_records, edges)
Loading
sequenceDiagram
    participant Client
    participant Service as RetrieveGraph<br/>Service
    participant Retriever
    participant EntityLookup
    participant TrustContext
    participant Storage

    Client->>Service: RetrieveGraph(query, memory_types, limits, trust)
    Service->>Retriever: retrieve_records(query, trust)
    Retriever->>Storage: query(memory_types, limits)
    Storage-->>Retriever: candidate_records
    
    Retriever->>Service: entityRootCandidates(query)
    Service->>EntityLookup: FindEntitiesByTerm(query_term, scope)
    EntityLookup-->>Service: matching_entities
    
    Service->>Service: rerankGraphRoots(all_candidates, trust)
    Note over Service: Score by alias/type/relation<br/>with entity payload cache
    Service-->>Service: ranked_roots
    
    Service->>Storage: expand_graph_neighborhood<br/>(roots, node_limit, edge_limit, max_hops)
    Storage-->>Service: nodes[], edges[]
    
    Service->>TrustContext: Allows(node, record)
    TrustContext-->>Service: visible_or_redacted
    Note over Service: Redact payloads for<br/>lower-sensitivity access
    
    Service-->>Client: RetrieveGraphResponse(nodes, edges, root_ids, selection)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

A graph of memory takes shape at last,
With entities linked through present and past,
From capture to retrieval, TypeScript to Go,
The bunny hops through connections that grow! 🐰✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/agent-harness-docs

BennettSchwartz added a commit that referenced this pull request May 1, 2026
feat: add entity-linked agent harness and docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant