memory

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memory persists immutable Markdown nodes in a project-local graph.

Memory storage supports Windows, Linux and macOS, excluding Android. NewStore fails with ErrInvalidInput on other platforms rather than using mutable pathnames. Supported stores require hard-link support because completed nodes are published with an atomic no-replace link operation. Linux also requires procfs access through /proc/self/fd. NewStore fails safely if that pinned-directory path is unavailable. macOS uses descriptor-relative operations instead of procfs. Stores retain the pinned nodes directory for their lifetime so concurrent path replacement cannot redirect reads or writes. Call Store.Close to release that platform resource.

Index

Constants

View Source
const (
	MaxTitleRunes = 200
	MaxBodyBytes  = 64 * 1024
	MaxTags       = 32
	MaxLinks      = 64
	DefaultLimit  = 20
	MaxLimit      = 100
)

Variables

View Source
var (
	ErrNotFound     = errors.New("memory node not found")
	ErrInvalidInput = errors.New("invalid memory input")
)

Functions

This section is empty.

Types

type GetResult

type GetResult struct {
	Node       Node     `json:"node"`
	Backlinks  []string `json:"backlinks"`
	ReplacedBy string   `json:"replaced_by,omitempty"`
}

type Node

type Node struct {
	ID         string    `json:"id"`
	Title      string    `json:"title"`
	Body       string    `json:"body"`
	CreatedBy  string    `json:"created_by"`
	CreatedAt  time.Time `json:"created_at"`
	Tags       []string  `json:"tags,omitempty"`
	Links      []string  `json:"links,omitempty"`
	Supersedes string    `json:"supersedes,omitempty"`
	Archived   bool      `json:"archived"`
}

type ProjectDirectory

type ProjectDirectory interface {
	CanonicalPath() string
	OperationPath() string
	Validate() error
}

ProjectDirectory is a pinned project-root capability. Implementations must expose a canonical path for identity checks and a handle-anchored operation path for child creation.

type PutInput

type PutInput struct {
	Title      string   `json:"title"`
	Body       string   `json:"body"`
	CreatedBy  string   `json:"created_by"`
	Tags       []string `json:"tags,omitempty"`
	Links      []string `json:"links,omitempty"`
	Supersedes string   `json:"supersedes,omitempty"`
	Archived   bool     `json:"archived,omitempty"`
}

type SearchInput

type SearchInput struct {
	Query          string   `json:"query,omitempty"`
	Tags           []string `json:"tags,omitempty"`
	LinkedTo       string   `json:"linked_to,omitempty"`
	CreatedBy      string   `json:"created_by,omitempty"`
	IncludeHistory bool     `json:"include_history,omitempty"`
	Limit          int      `json:"limit,omitempty"`
}

type SearchResult

type SearchResult struct {
	Nodes    []Summary `json:"nodes"`
	Warnings []Warning `json:"warnings"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(root string) (*Store, error)

func NewStoreInProject

func NewStoreInProject(project ProjectDirectory) (*Store, error)

NewStoreInProject creates the fixed "memory" child only through a pinned Registry project capability, then proves that the pinned memory root and nodes directory still match their canonical identities inside that project.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (GetResult, error)

func (*Store) Put

func (s *Store) Put(ctx context.Context, input PutInput) (Node, error)

func (*Store) Root

func (s *Store) Root() string

func (*Store) Search

func (s *Store) Search(ctx context.Context, input SearchInput) (SearchResult, error)

type Summary

type Summary struct {
	ID         string    `json:"id"`
	Title      string    `json:"title"`
	CreatedBy  string    `json:"created_by"`
	Snippet    string    `json:"snippet"`
	CreatedAt  time.Time `json:"created_at"`
	Tags       []string  `json:"tags,omitempty"`
	Links      []string  `json:"links,omitempty"`
	Supersedes string    `json:"supersedes,omitempty"`
	Archived   bool      `json:"archived"`
}

type Warning

type Warning struct {
	File  string `json:"file"`
	Error string `json:"error"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL