← Catalog

@4242labs/pi-memento

MEMENTO for Pi — persistent memory for a Pi session: recall at start, journal as you go, consolidate on exit.

Extension

Install

Install with PiG

pig install npm:@4242labs/pi-memento

Install with Pi

pi install npm:@4242labs/pi-memento
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.1 (README.md). PiG does not review it.

@4242labs/pi-memento

Project Status: WIP Maintenance License: Apache-2.0 npm

MEMENTO for Pi — persistent memory for a Pi session. Recall what matters at session start, journal decisions as they are made, consolidate later so the next session starts where this one ended.

Pre-v1. The lifecycle is wired and tested against a scripted engine. It has not yet run a live consolidation end to end — that is the specific thing still missing.

What it wraps

The MEMENTO engine — a file-backed memory store with an explicit consolidation loop. This package is a thin lifecycle wrapper: it owns when the loop runs inside a Pi session, never how the store works. The engine is a separate program, invoked as a subprocess through its memento CLI. It is not bundled, linked, or vendored here.

Two things in that CLI are contractual — the exit code and the --json payload — and this wrapper reads nothing else. Console prose is never parsed, never matched, and never surfaced as a reason.

The lifecycle

WhenWhat happens
session startprovenance check → crash recovery → read the prefix
first requestthe prefix is injected in front of the conversation
during/memento journal <text> appends to this session's pile
/memento consolidateone bounded pass over the oldest pending session
session exitenqueue, and nothing else — no distillation, no git

Session exit is deliberately the cheap half. An exit that does real work is an exit the operator waits on.

The consolidation pass

In the engine's order, and no other:

gate-check → claim → prefix + journal + fingerprint → distill → consolidate --expect
           → commit → done → release
  • The gate check is mandatory. Exit 7 means later, not louder. The wrapper never passes --prefix-materialized it did not observe, and never lowers the idle bar to get past a refusal.
  • The compare-and-swap is not optional. Every submission carries --expect; --unchecked is not reachable from this wrapper at all.
  • The claim always comes back. The pass is bounded at ten minutes against a TTL of an hour, and every exit path releases. A release that is refused is reported as a FLAG, never swallowed.
  • The marker is last — after the commit, so a crash between them loses the marker (cheap to redo) rather than the backup (not).

What each exit code does

CodeMeaningThis wrapper
0finecontinue
1usage / IOsurface it; never retry blind
2malformedreport — it never reached the gates
3gates rejectedone corrected resubmit with the violations as the brief, then leave it pending
4secretsnever retried, in any form
5stalere-read and redrive once against the new fingerprint
6claimedskip it; another front-end holds it
7gate refusescome back later

Who distils

You do — the host session's own model. It is handed the current prefix, this session's journal, and (on a correction) the gates' own violations, and it replies with a proposal. That makes it precisely the writer the gates were built to distrust, which is why the compare-and-swap and the anti-erosion floor apply to it exactly as they do to anyone else.

Provenance

The engine is installed from a git pin, and the pin is where its identity comes from:

uv tool install "memento @ git+https://github.com/4242labs/memento@<sha>"

At session start the wrapper reads uv's own install receipt and reports the commit. If your project pins expectedRev and the installed engine is a different commit — or cannot be traced to one at all — the wrapper refuses to consolidate rather than gating your memory with an engine you did not ask for.

Configuration

.pi/memento.json, all optional:

{
  "store": "./memento",
  "queue": "./memento/.queue",
  "adapterFile": "./adapter.json",
  "minIdleSeconds": 5,
  "journalTurns": true,
  "expectedRev": "02a31e8d1fdce1616bba3cfbca60f8af5eae8e4a",
  "binary": "memento"
}

An unknown field is refused, never ignored: a typo must not silently disable the thing it was meant to declare. Gitignore the store — it is your memory, not the repository's.

Install

pi install npm:@4242labs/pi-memento

Requires the MEMENTO CLI on PATH (see Provenance above).

As a library

The same code is importable, for a supervisor that wants the loop without the Pi extension:

import { MementoCli, consolidateOnce } from "@4242labs/pi-memento";

Requirements

  • pi 0.84.1 or later
  • MEMENTO engine 0.1.0 or later

The engine's own terms

The MEMENTO engine this wrapper invokes is licensed separately (AGPL-3.0-only, commercial on request). Installing it is your choice and its terms are its own; this package is the wrapper only.

License

Open source — Apache-2.0.


If it earned its keep, coffee is appreciated. ☕