1. Executive Summary
Post-Cortex is the memory module of PCX, an agent harness written in Rust: one daemon serving MCP, gRPC and REST over RocksDB or SurrealDB, with a Claude Code plugin, Cursor and Gemini hooks, and Python and TypeScript SDKs. An agent writes typed records — decisions, problems solved, code changed, concepts, requirements, questions answered — with the entities and relations it names. Nothing on the write path calls a model.
Notable: validity is derived from the records, in one function. A
record's interval starts at the writer's valid_from or its
timestamp, and ends where a later record that supersedes, contradicts or
restates it begins, or where forget retired it
(crates/post-cortex-core/src/graph/temporal.rs:138-248).
Assembled context and every graph view keep only records whose interval
is open. Reach is checked by one rule on every way in.
Weak: semantic_search returns ended records, labelled
with why they ended, and halves the score only of those superseded,
contradicted or forgotten. Restatement ends a prior decision,
requirement or concept on title-word overlap alone. A call with no reach
header reaches every workspace. forget rewrites the stored
record in place.
Three marks are present and four are withheld (section 9).
Licence. MIT in LICENSE (copyright 2025
Julius ML) and in the workspace Cargo.toml.
SECURITY.md asks for vulnerabilities to go through GitHub's
private advisories, not a public issue, with a disclosure window of up
to 90 days.
2. Mental Model
A record is something the agent decided to remember, in a kind it
chose. It carries three clocks, in the words of its own doc comment: the
timestamp is when Post-Cortex learnt it, and the validity interval is
when it held in the world
(crates/post-cortex-core/src/core/context_update.rs:105-111).
Only the start of that interval is written. The end is a consequence of
what came after.
Four things end a record. An explicit supersedes list
names the records a new one replaces. A ConflictsWith
relation between two entities ends every record that asserted a relation
between that pair. A decision, requirement or concept about the same
entities whose title shares at least half its words with an open one
restates it, and at 80% overlap of title and description it is a
duplicate. A forget call sets retired_at
(crates/post-cortex-core/src/graph/temporal.rs:35-56,
:184-246).
Diagram source
%% caption: only the start of validity is written; the end is derived from the records on each read, and assembly keeps only open intervals while search halves the score
flowchart TD
AG["Agent MCP call"] --> W["update_conversation<br/>_context"]
W --> VAL{"validate meta:<br/>no retired_at"}
VAL --> REC["Record appended<br/>valid_from, supersedes"]
REC --> DB["RocksDB or<br/>SurrealDB rows"]
FG["forget"] --> RET["retired_at set<br/>on the stored record"]
RET --> DB
DB --> DER["validity derived<br/>per read"]
RCH["x-pcx-reach from<br/>gateway or tunnel"] --> GATE{"within_reach?"}
GATE -- "no" --> REF["refused"]
GATE -- "yes" --> SR["Search<br/>vectors + BM25"]
DER --> SR
SR -- "ended" --> HALF["score x 0.5,<br/>labelled ended"]
SR --> ASM{"Assembly:<br/>interval open?"}
ASM -- "yes" --> CTX["Agent context"]
ASM -- "no" --> OUT["left out"]3. Architecture
The memory sits in three crates. post-cortex-core holds
the record type, the session and the temporal derivation.
post-cortex-memory holds the capabilities — records,
search, assembly, scope, workspaces, cards, documents, graph views,
transfer — and the reach rule. post-cortex-storage adapts
the storage ports to RocksDB and SurrealDB.
post-cortex-transport serves the capabilities over gRPC,
REST and a browser path, and post-cortex-compose wires the
daemon, its tunnel to a hosted gateway, and the MCP handlers.
The other forty-odd crates are the PCX harness: a module host with
manifests, grants and a per-turn reach (crates/pcx-host), a
board with tasks and decisions (crates/pcx-board), an
agent, workflows, a Discord adapter and a code-approval module. The
README presents PCX as the harness and Post-Cortex as its memory module,
usable on its own.
Deployment and ergonomics
One pcx binary runs the daemon; a Homebrew formula,
release binaries and a Docker image ship it. The Claude Code plugin
injects cards on session start, a file's memory on its first read or
edit, the context again after compaction, and checks at stop for changes
the agent did not log
(integrations/claude-code/hooks/hooks.json). Embeddings
default to Model2Vec static vectors; BERT models and a local reranker
are build features.
4. Essential Implementation Paths
- Write.
update_conversation_contextbuilds requests from the agent's arguments, includingvalid_fromandsupersedes(crates/post-cortex-memory/src/tools/handlers/update_context.rs:94-95). Validation refuses aretired_aton write, with the message that forget sets it (crates/post-cortex-memory/src/capabilities/records/validate.rs:96-97). - Derive validity.
validity()sorts a session's records by time and walks them once, ending prior intervals by supersession, contradiction and restatement, then applying retirements (crates/post-cortex-core/src/graph/temporal.rs:138-248). - Search. The scope resolves to sessions, records
without vectors are embedded, vector and BM25 rankings are fused, and
each hit's score is scaled by
0.5 + 0.5 × confidenceand by 0.5 if it ended by supersession, contradiction or forgetting (crates/post-cortex-memory/src/memory_system/neighbours.rs:176-196). - Assemble. Cards first, then the graph around the
query, then search hits filtered to open intervals, then conversation
excerpts, within a token budget
(
crates/post-cortex-memory/src/capabilities/assembly.rs:198-206). - Forget and purge.
forgetcallsretire_update, which replaces the record in the session with a copy whoseretired_atis set (crates/post-cortex-core/src/session/active_session/mutate.rs:101-111);purgeremoves it (crates/post-cortex-memory/src/capabilities/records/changes.rs:46,:75). - Reach.
Memory::within_reachdecides every call that carries a reach (crates/post-cortex-memory/src/reach.rs:78-160).
5. Memory Data Model
ContextUpdate holds an id, a timestamp, one of six
UpdateType values, a title and description, code
references, a parent, an importance flag, the entities and relations it
creates or references, an author, the ids of conversation turns it was
derived from, and meta
(crates/post-cortex-core/src/core/context_update.rs:33,
:105-127). meta holds valid_from,
supersedes, a confidence in [0, 1] that defaults to full
trust, and retired_at.
Validity is not stored. It holds
valid_from, valid_to, the id of the record
that ended it and an EndReason of Superseded,
Contradicted, Restated, Duplicate
or Forgotten
(crates/post-cortex-core/src/graph/temporal.rs:43-75). A
cache keeps it per version of a session
(crates/post-cortex-memory/src/memory_system/neighbours.rs:102-150).
Around the records sit workspaces of sessions with roles, cards
scoped to a user, workspace or session, and documents. Cards and
documents keep a version history with an expected version on write
(crates/post-cortex-ports/src/storage/cards.rs:42,
crates/post-cortex-ports/src/storage/documents.rs:79);
records do not.
6. Retrieval Mechanics
Search has four scopes: one session, a list of sessions, a workspace,
or every session
(crates/post-cortex-memory/src/capabilities/search.rs:56-60).
A workspace resolves to its member sessions, and the search reads only
those
(crates/post-cortex-memory/src/capabilities/scope.rs:84-126).
Vector and BM25 rankings are fused by reciprocal rank
(crates/post-cortex-memory/src/content_vectorizer/fusion.rs),
and a term graph reaches records two hops away.
What happens to an ended record depends on the path. Search keeps it,
halves its score and labels it with its end in the response
(crates/post-cortex-memory/src/tools/responses/records.rs:170).
Assembly drops it
(crates/post-cortex-memory/src/capabilities/assembly.rs:204).
The radar and the entity views keep only open records, and the file view
does when asked
(crates/post-cortex-memory/src/graph_views/radar.rs:137,
entity_views.rs:95, file_view.rs:148). An
agent that calls semantic_search sees superseded decisions
beside their replacements; an agent that calls
assemble_context does not.
With embeddings off, every search scope is refused alike, and assembly returns cards and the graph without records.
7. Write Mechanics
The agent writes what it decides to write, in the kind it picks, naming entities and relations itself; the hooks remind it at stop when a change went unlogged. There is no extraction model, so a record's quality is the agent's.
Supersession is explicit when the agent names the record it replaces,
and implicit otherwise. Two decisions about the same entities whose
titles share half their words end the prior one as restated
(crates/post-cortex-core/src/graph/temporal.rs:200-235).
The test that pins this behaviour also pins its boundary: unrelated
titles both stay open (:375). A decision that refines a
prior one under a similar title ends it, whatever the agent meant.
Operational cost
No model call on write. Each new record is embedded locally in the background pipeline; validity is recomputed once per session version and cached.
8. Agent Integration
The MCP tools write records, search, assemble context, manage
sessions and workspaces, and act on entities and records, including
forget and purge
(crates/post-cortex-memory/src/tools/handlers/entity.rs:90-106).
gRPC and REST expose the same capabilities. Inside PCX, modules reach
memory through the host, and an agent's call in a turn carries no more
reach than the turn was asked with
(crates/pcx-host/src/route.rs:235-242).
9. Reliability, Safety, and Trust
Derived, not written
Because the end of validity is derived, a correction takes effect on the next read without rewriting the prior record, and every view that asks for current records asks the same function. The cost is that the derivation's rules are the policy: title overlap, entity pairs and record kinds decide what holds, and nothing records the decision as a fact anyone can inspect apart from the response that carries it.
Search and assembly disagree
Search treats ended as a ranking signal; assembly treats it as a
filter. A superseded record with a strong lexical match can outrank its
replacement in semantic_search. The response labels it. A
record ended by restatement or duplication is labelled and not demoted
at all, as the doc comment on weigh_by_validity states
(crates/post-cortex-memory/src/memory_system/neighbours.rs:160-164).
Reach
The reach rule is one function on every transport, and its refusals
name what fell outside. It holds only when a reach is present.
docs/connect.md states that the header is set by a trusted
forwarder — a gateway for a limited grant, or the daemon's tunnel — and
that its absence means every workspace
(docs/connect.md:158-166). A local client talking to the
daemon directly carries none.
Decisions on the board
A board decision an agent makes waits for a person unless team rules
approve it at once, and only a person's app can approve it
(crates/pcx-board/src/specs.rs:36-42). The decision's text
is written into memory when it is made, pending or not, and an approval
writes a second record that begins "Approved:"
(crates/pcx-board/src/service/decisions.rs:40-100,
:204-245). The gate governs the task, not what memory
holds.
Marks
bitemporal— present. Statedvalid_fromapart from the timestamp, an end derived from the records, and current-only reads; no as-of query.scope_enforced— present. Member sessions on every search and assembly, and one reach rule on every transport; absent reach reaches all.negative_eval— present. A superseded record and a deleted session's record asserted absent from assembled context beside populated results.trust_state— withheld.confidenceis a float that scales scores, and the end reason is derived per read;retired_atis a retirement time, not an epistemic status.audit_log— withheld. The change feed is an in-process broadcast of at most 1,024 pending changes (crates/post-cortex-memory/src/memory_system/change_log.rs:24),forgetrewrites the record, andpurgedeletes it.human_review— withheld. Records have no waiting state; a board decision enters memory before anyone approves it.tombstone— withheld. A forgotten record's text written again is a new open record; the tombstones incrates/post-cortex-memory/src/memory_system/persister/lineage.rsstop a deleted session's stale handles writing, not a value returning.
10. Tests, Evals, and Benchmarks
The tree carries 1,787 Rust test attributes. CI runs
cargo test --workspace --lib under default, no-default and
all features, doc tests, clippy with warnings as errors,
cargo audit, cargo deny, an architecture check
and coverage (.github/workflows/ci.yml). I ran none of
them.
The temporal rules are tested one by one: explicit supersession ends
at the new record's valid_from, restatement replaces,
identical text is a duplicate and unrelated titles stay,
ConflictsWith ends the pair's assertions, retirement ends a
record, and aliases resolve to one subject
(crates/post-cortex-core/src/graph/temporal.rs:306-443).
Search ranking of ended and uncertain records is pinned
(crates/post-cortex-memory/src/memory_system/neighbours/tests.rs:149).
The negative cases are on assembly. One writes a rollout date, its
correction and an unrelated record, and asserts the old date absent
beside the other two
(crates/post-cortex-memory/src/capabilities/assembly/tests.rs:301-362).
Another deletes one of two sessions in a workspace and asserts its
record absent beside the kept one's (:107-161). The reach
tests assert a refusal beside a permitted call, and a workspace list cut
to exactly the reach
(crates/post-cortex-compose/src/daemon/connect_tests.rs:252-294).
Cases to want first: a restatement the writer did not intend, asserted against assembly; and a call without a reach header on the transport a hosted deployment exposes.
No paper describes Post-Cortex.
11. For Your Own Build
Steal
- Write the start, derive the end. A record that names what it supersedes needs no update to the old row, and one derivation function keeps every view consistent.
- Name the reason an interval ended. Superseded, contradicted, restated, duplicate and forgotten each tell a reader something different.
- One reach rule, called from every transport. A refusal that names the workspace it fell outside is easy to test and to explain.
- Narrow an agent's reach to its turn. The call a person started bounds the calls the agent makes in it.
Avoid
- Do not let two read paths disagree on what ended means. Pick filter or rank per path on purpose, and say which in the tool description.
- Do not end facts on word overlap without the writer. A restatement rule needs an opt-out, or a test that shows what it ends by mistake.
- Do not make an absent header mean everything where the daemon can be reached by anything other than its own client.
Fit
Fits a coding agent or a small team that wants typed, entity-linked project memory with correction by supersession, served locally to several clients. The temporal derivation is worth reading whatever the product.
Walk away if a person must approve what memory holds, if every change to memory must leave a durable trail, or if past states must be queried as of a date.
12. Open Questions
- Whether
semantic_searchis meant to return ended records by default, given that assembly drops them. - Whether restatement on title overlap has a writer-side way to say "this does not replace that".
- Whether a record mutation log is planned, given that cards and documents keep version history.
Appendix: File Index
- Record and validity:
crates/post-cortex-core/src/core/context_update.rs,crates/post-cortex-core/src/graph/temporal.rs,crates/post-cortex-core/src/session/active_session/mutate.rs - Capabilities:
crates/post-cortex-memory/src/capabilities/records/,crates/post-cortex-memory/src/capabilities/search.rs,crates/post-cortex-memory/src/capabilities/assembly.rs,crates/post-cortex-memory/src/capabilities/scope.rs - Ranking:
crates/post-cortex-memory/src/memory_system/neighbours.rs,crates/post-cortex-memory/src/content_vectorizer/fusion.rs - Reach:
crates/post-cortex-memory/src/reach.rs,crates/post-cortex-transport/src/reach.rs,crates/pcx-host/src/route.rs,docs/connect.md - Change feed and persistence:
crates/post-cortex-memory/src/memory_system/change_log.rs,crates/post-cortex-memory/src/memory_system/persister/ - Board decisions:
crates/pcx-board/src/service/decisions.rs,crates/pcx-board/src/specs.rs - Agent surface:
crates/post-cortex-memory/src/tools/,integrations/claude-code/ - Tests:
crates/post-cortex-memory/src/capabilities/assembly/tests.rs,crates/post-cortex-compose/src/compose_reach_tests.rs,crates/post-cortex-compose/src/daemon/connect_tests.rs
Recorded searches
Run from the repository root at the pinned commit with
/usr/bin/git grep.
- No as-of query.
git grep -n -E 'holds_at|as_of' -- cratesreturns the definition atcrates/post-cortex-core/src/graph/temporal.rs:79and two assertions in its tests at:322-323. - Search ranks ended records; other paths filter.
git grep -n -F 'ENDED_FACTOR' -- cratesreturnscrates/post-cortex-memory/src/memory_system/neighbours.rs:100,:163and:194.git grep -n -F 'is_current()' -- crates, outside tests andtemporal.rs, returns the assembly filter atassembly.rs:204, the graph views, the end label intools/responses/records.rs:170, and the ranking cache inneighbours.rs:145. - Nothing blocks a forgotten value on write.
git grep -n -i -E 'retired|forgot|tombstone' -- crates/post-cortex-memory/src/capabilities/records crates/post-cortex-memory/src/memory_system/persister/lineage.rs, outside tests, returns the refusal of a statedretired_atatvalidate.rs:96-97, a doc line atchanges.rs:42, and the session-handle tombstones inlineage.rs. - Approval is not an agent verb.
git grep -n -E '"approve' -- crates/pcx-board/srcreturnscrates/pcx-board/src/specs.rs:39, declared withVisibility::App. - No paper.
CITATION.cffis absent;git grep -n -i -E 'arxiv|doi\.org|bibtex' -- . ':!third_party' ':!Cargo.lock'returns nothing.
History
2026-12-03 — dc8d59cd….
First reading, from the 2026-12-03 triage shortlist, at the head of
main. Screened: five auto-run surfaces (the Claude Code
plugin manifest, its MCP file and its hooks); eight build-time execution
surfaces (seven build.rs files and a Python SDK
conftest.py); seven floating dependency surfaces; the
cooldown count inflated by a shallow clone. Nothing was installed, built
or run, and none of the 1,787 tests was run. Three marks (section 9).