memnote

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 20 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 memnote is the memory-notes store (itd-2610091918433290, spc-2610111627213138 step 1): short lessons an agent keeps so a later session does not relearn them. Notes live in a memory.json beside each rules.json layer — the machine's ~/.abcd.noindex/memory.json holds personal notes, and a repository's .abcd/memory.json holds the notes a person promoted into the project — and are read with the trust checks the rules layers get.

Agents write only the machine layer, and only through the write gate (gate.go): the shared scanner and the private-names banlist refuse a note that would hold a secret, a private name or a network address, and every note is stamped with who wrote it, when and in which session. Nothing in this package writes the repository layer, and nothing here promotes a note: that is a later dashboard's act (itd-2610111655362931). Nothing here writes to stdout or knows a transport; the `abcd memory` verb is the front door.

Index

Constants

View Source
const (
	// MaxTitleChars is a title's length in characters, on one line.
	MaxTitleChars = 120
	// MaxBodyBytes is a body's length in bytes.
	MaxBodyBytes = 2 << 10
	// MinRecall and MaxRecall bound the recall list's length.
	MinRecall = 1
	MaxRecall = 12
	// MaxRecallChars is one recall word or short phrase's length in characters.
	MaxRecallChars = 64
	// MaxSessionChars is a session id's length.
	MaxSessionChars = 128
)

The note's figures, set in one place (the spec's starting points). A write past one is refused naming the limit.

View Source
const (
	// OriginAgent is a note an agent wrote of its own accord.
	OriginAgent = "agent"
	// OriginHostMemoryMove is a lesson the person pointed at in the host's own
	// memory files, moved by hand with `memory add --moved-from-host`.
	OriginHostMemoryMove = "host-memory-move"
)

The two origins a note can carry.

View Source
const Family = "mem"

Family is the record-id family a note's id is minted in (recordid.Minter, adr-45): mem-<yymmddHHMMSS><rrrr>.

View Source
const RepoRelPath = ".abcd/memory.json"

RepoRelPath is the repository layer, beside the repository's rules.json: the notes a person promoted into the project.

View Source
const SchemaVersion = 1

SchemaVersion is the one memory.json schema both layers carry.

Variables

View Source
var ErrMalformed = errors.New("malformed memory file")

ErrMalformed wraps every refusal of a file's contents.

View Source
var ErrNoHome = errors.New("the home directory is unresolved, so there is no machine layer to write")

ErrNoHome refuses a write with no absolute home to hold the machine layer.

View Source
var ErrNoRoot = errors.New("this repository has no root commit to tie the note to; pass --everywhere for a lesson that holds in every project")

ErrNoRoot refuses a note tied to its repository where the repository has no root commit to tie it to.

View Source
var ErrNotFound = errors.New("no personal note has that id")

ErrNotFound is Remove's answer for an id the machine layer does not hold.

View Source
var MachineDisplayPath = abcdhome.Display("memory.json")

MachineDisplayPath is how the machine layer is named in a message: the tilde form, never the expanded home.

View Source
var MachineRelPath = abcdhome.Rel("memory.json")

MachineRelPath is the machine layer, beside ~/.abcd.noindex/rules.json: the person's own notes, written by agents through Add.

Functions

This section is empty.

Types

type AddRequest

type AddRequest struct {
	// Home is the account's home directory; RepoRoot is the repository the
	// note is written from (the rules loader's root), whose root commit ties
	// the note to it and whose scanner and private names judge it.
	Home, RepoRoot string
	Title, Body    string
	Recall         []string
	// By is the writer, <Vendor>:<model-version>; Session the host's id for
	// the session, or "".
	By, Session string
	// Everywhere recalls the note in every repository (root null).
	Everywhere bool
	// MovedFromHost stamps the origin host-memory-move.
	MovedFromHost bool
}

AddRequest is one note to write. Session "" records the session as unknown.

type FieldError

type FieldError struct {
	Field string
	Why   string
}

FieldError is a refusal of one field of one note, naming the field and the limit or shape it broke, never echoing the value.

func (*FieldError) Error

func (e *FieldError) Error() string

type File

type File struct {
	SchemaVersion int
	Notes         []Note
}

File is one memory.json.

func ReadMachine

func ReadMachine(home string) (f File, present bool, err error)

ReadMachine reads the machine layer under home through the rules user layer's guarded read (rules.ReadUserLayerFile, over fsutil.ReadHomeDeclaration): a regular file this account owns that no one else can write, within 256 KiB, never behind a symlinked ~/.abcd.noindex. present is false when there is no file, or no absolute home; nothing is created by a read. A file failing a check or failing to parse is an error naming the file in tilde form.

func ReadRepo

func ReadRepo(repoRoot string) (f File, present bool, err error)

ReadRepo reads the repository layer under repoRoot — the root the rules loader resolved (rules.ResolveRoot) — through the repository layer's guarded read (rules.ReadRepoLayerFile): a symlinked .abcd or leaf refused, a regular file within 256 KiB. present is false when the file is absent.

type GateError

type GateError struct {
	Field string
	Kind  string
}

GateError is the gate's refusal of one field: the field and the kind of span it carries, never the span.

func (*GateError) Error

func (e *GateError) Error() string

type Note

type Note struct {
	ID        string
	Title     string
	Body      string
	Recall    []string
	Root      *string
	Origin    string
	WrittenBy string
	WrittenAt string
	Session   *string
}

Note is one memory note. Root is nil for a note recalled in every repository (`--everywhere`) and for every note in the repository layer, which carries no root; Session is nil where the host supplied none.

func Add

func Add(req AddRequest) (Note, error)

Add judges and writes one note to the machine layer and returns it. Every refusal comes before anything is created: a malformed field (*FieldError), a tied note with no root commit (ErrNoRoot) or one whose root commit git did not answer for (gitutil.ErrNoRootAnswer, wrapped), the gate (*GateError, or an error when the gate cannot judge), or a machine file the guarded read refuses.

func Remove

func Remove(home, id string) (Note, error)

Remove removes the personal note id from the machine layer, whoever wrote it, and returns it. ErrNotFound when the machine layer holds no such note.

Jump to

Keyboard shortcuts

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