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 ¶
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.
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.
const Family = "mem"
Family is the record-id family a note's id is minted in (recordid.Minter, adr-45): mem-<yymmddHHMMSS><rrrr>.
const RepoRelPath = ".abcd/memory.json"
RepoRelPath is the repository layer, beside the repository's rules.json: the notes a person promoted into the project.
const SchemaVersion = 1
SchemaVersion is the one memory.json schema both layers carry.
Variables ¶
var ErrMalformed = errors.New("malformed memory file")
ErrMalformed wraps every refusal of a file's contents.
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.
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.
var ErrNotFound = errors.New("no personal note has that id")
ErrNotFound is Remove's answer for an id the machine layer does not hold.
var MachineDisplayPath = abcdhome.Display("memory.json")
MachineDisplayPath is how the machine layer is named in a message: the tilde form, never the expanded home.
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 ¶
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 ¶
File is one memory.json.
func ReadMachine ¶
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 ¶
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 ¶
GateError is the gate's refusal of one field: the field and the kind of span it carries, never the span.
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), the gate (*GateError, or an error when the gate cannot judge), or a machine file the guarded read refuses.