Skip to main content
Read and write memory files through one small contract, and switch the store without touching the step that uses it. Use the Memory port from @obversa/api when a job needs files it can open again in a later run; the runtime accepts any adapter that implements it. For what memory is for, read Memory; for the adapters that ship, Memory adapters. The port has a scope and one execute method that takes a command. The smallest use creates a file and reads it back:
examples/memory-simple.ts (excerpt)
Every path starts with /memories. A result has ok: true and a typed value, or ok: false and a typed error with the command, the error code and a message; some errors also carry the path and structured details. Every adapter uses the same error codes, and a conformance kit checks the contract without a network service. A command needs:
  • command, one of the six below.
  • path, under /memories, or oldPath and newPath for rename.
  • The command’s own fields: text, viewRange, oldText and newText, or insertLine.

Run a command

Set storage limits

@obversa/memory-simple and @obversa/memory-git use these defaults:
  • One file can contain 65,536 bytes.
  • One scope can contain 1,048,576 bytes and 256 files.
  • File types: .txt, .md, .json, .py, .yaml and .yml.
When a write takes a scope past a limit, the adapter removes files in order of earliest write time until the write fits. A read doesn’t change a file’s write time, and the adapter never removes the file being written.

Name a path

A path can contain letters, numbers, periods, underscores and hyphens. Each segment can contain 128 characters, and a complete path 1,024 bytes. A scope and all written text must be complete Unicode: the adapters reject malformed Unicode instead of replacing incomplete characters. The memory root can’t be a file, and you can’t delete or rename it.

Failure

Next steps

  • Memory adapters: the in-process store, the Git store, and how to pass one to run().
  • Memory mechanics: ground, curate and consolidate over the port.
  • API: the Memory contract and the conformance kit.