New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

weavatrix-memory

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weavatrix-memory

Bitemporal, evidence-carrying Rust memory and bounded context for Node.js and Bun

latest
Source
npmnpm
Version
0.3.5
Version published
Weekly downloads
13
62.5%
Maintainers
1
Weekly downloads
 
Created
Source

weavatrix-memory

Bitemporal, evidence-carrying agent memory with a hard token budget — written in Rust, exposed to Node.js and Bun through Node-API.

It answers two different questions that most memory systems conflate: what was true at time T, and what did the agent know at time T. Every fact carries both axes plus the evidence behind it, so a wrong answer can be traced to the fact that caused it.

No LLM, no vector database, no network service, no async runtime, no external graph database.

npm install weavatrix-memory
# or
bun add weavatrix-memory
const { Memory } = require('weavatrix-memory')

const memory = new Memory({
  knownAt: 20,
  nodes: [
    { id: 'task:1', kind: 'task', label: 'Fix query' },
    { id: 'file:1', kind: 'file', label: 'query.js' },
  ],
  facts: [{
    id: 'fact:1',
    source: 'task:1',
    relation: 'depends_on',
    target: 'file:1',
    validFrom: 10,
    recordedAt: 12,
    agentId: 'agent:1',
    sessionId: 'session:1',
    evidence: [{ kind: 'test', source: 'query-suite' }],
  }],
})

const context = memory.compileContext({
  seeds: ['task:1'],
  validAt: 20,
  knownAt: 20,
  tokenBudget: 2_000,
  maxDepth: 2,
})

context.view      // the facts and nodes that survived both time filters
context.graph     // their projected provenance graph
context.receipt   // exactly why this bundle looks the way it does

The two time axes

AxisFieldQuestion it answers
Valid timevalidFrom, validUntilWhen was this true in the world?
Known timerecordedAtWhen did the system learn it?

A query supplies both (validAt, knownAt). Asking "what did we believe last Tuesday about the state of the repository last Monday" is a single query, not a reconstruction.

All timestamps are integer Unix microseconds and must stay inside JavaScript's safe-integer range; a non-integer or out-of-range value is rejected, never rounded.

Input

MemoryNode

FieldTypeNotes
idstringStable identity.
kindstringEntity category.
labelstringHuman-readable name.
repository, branchstring?Scope, filterable at query time.
attributesRecord<string, string>?

MemoryFact

FieldTypeNotes
idstring
source, targetstringNode ids.
relationstringRelation type; filterable at query time.
validFromnumberStart of valid time.
validUntilnumber?Open-ended when omitted.
observedAtnumber?
recordedAtnumberKnown time.
agentId, sessionIdstringWho asserted it, in which session.
confidencenumber?Basis points, 0 … 10000.
evidenceEvidence[]{ kind, source, locator?, digest? }
supersedesstring?The fact this one replaces.

MemoryInput

{ nodes, facts, knownAt, sourcePosition? }

API

new Memory(input)

Validates the whole projection up front: unknown node references, a confidence above 10,000 basis points, and malformed timestamps all throw here rather than at query time.

MemberReturnsNotes
nodeCountnumber
factCountnumber
view(validAt, knownAt)MemoryView{ nodes, facts } after both time filters.
graph(validAt, knownAt)objectThe projected provenance graph for that same instant.
compileContext(request)ContextBundleSee below.

ContextRequest

FieldTypeDefaultEffect
seedsstring[]requiredWhere the walk starts.
validAtnumberrequiredValid-time instant.
knownAtnumberrequiredKnown-time instant.
tokenBudgetnumberrequiredHard ceiling. The compiler stops selecting facts before exceeding it.
maxDepthnumber2Traversal depth from the seeds.
relationsstring[]allRestricts which relations may be traversed.
repositories, branchesstring[]allScope filters.

ContextBundle

{ view, graph, receipt }.

The receipt is the point. It states what the compiler did, so a context can be audited rather than guessed at:

FieldMeaning
validAt, knownAt, sourcePositionThe instant this bundle describes.
estimator, tokenBudget, estimatedTokensWhich estimator ran, the ceiling, and what was actually spent.
examinedFacts, selectedFactsHow much was considered versus kept.
omittedByBudgetFacts dropped because the budget ran out.
excludedByScopeFacts dropped by relation, repository, or branch filters.

A context that is missing something always says which of the two reasons applies.

Errors

codeCause
InvalidArgUnknown field, fact referencing an undeclared node, confidence above 10,000 basis points, timestamp that is not a safe integer, empty seed list.
GenericFailureNode or fact count exceeding the addressable range.

What ships

RuntimesNode.js 18+ (Node-API 8), Bun 1.4+
PlatformsWindows x64/arm64, macOS x64/arm64, glibc Linux x64/arm64
Install scriptnone
Network at installnone
Runtime dependenciesnone
Platform packagesnone — all six bindings are in this one tarball

Measured, without fake equivalence

benchmark/RESULTS.md is generated from the weavatrix-benchmarks harness.

There is no zero-network npm package that returns this contract, so the comparison uses graphology as a topology-only floor — and it wins:

ContractNode 24Bun 1.3
Depth-2 neighborhood node ids on a 10,000-node chaingraphology 20x fastergraphology 9x faster

That row is published rather than hidden, and it is not a like-for-like result. graphology performs the overlapping topology query and nothing else. Weavatrix additionally filters valid time and known time, checks scope and relations, enforces the token budget, selects evidence-carrying facts, materializes the provenance graph and the receipt, crosses Node-API, and serializes the bundle. A depth-2 walk on a chain also reaches only five nodes, so the competitor's median sits at timer resolution: read it as "graphology wins the topology-only query", not as a calibrated multiple.

The Rust repository separately keeps equal-contract comparisons against agentic-memory, where the depth-2 context kernel at 100,000 nodes returned the same result 26.1x faster — and where the bulk constructor lost by 1.68x. That losing row is published too.

Memory owns its repository, package, release evidence, and MIT license, and can be used entirely on its own.

Repository: Weavatrix/weavatrix-memory · Rust crate: crates.io/crates/weavatrix-memory · License: MIT

Keywords

agents

FAQs

Package last updated on 15 Sep 2026

Related posts