Documentation
¶
Overview ¶
Package schema holds LadyM's core data models.
All memory items — episodic events, consolidated facts, code symbols, and procedural playbooks — are represented by a single Memory record. This unification is what lets the recall pipeline treat "memory" and "codebase RAG" as one system (see ARCHITECTURE.md §1).
Index ¶
- Variables
- func ContentHash(text string) string
- func EvidenceKind(kind string) bool
- func IsRetired(m *Memory) bool
- func IsSystemType(t MemoryType) bool
- func IsUsable(m *Memory) bool
- func KnowledgeFingerprint(m *Memory) string
- func MaintenanceInputFingerprint(m *Memory) (string, error)
- func ManagedRevision(m *Memory) int64
- func ManagedRevisionKey(m *Memory) string
- func NewID() string
- func Now() float64
- func ProjectedEdgeID(src, relation, dst string) string
- func SetClaimData(c *Claim)
- func SourceFingerprint(m *Memory) (string, error)
- func ValidateClaim(content string, refs []EvidenceRef, scope ClaimScope, until float64) error
- func ValidateEvidenceRef(ref EvidenceRef, source *Memory) error
- type BootstrapRequest
- type BootstrapResponse
- type BuildTopicRequest
- type Claim
- type ClaimFeedback
- type ClaimFeedbackRequest
- type ClaimScope
- type CodeRef
- type CodeSymbol
- type CreateClaimRequest
- type Edge
- type EmbeddingIdentity
- type EvidenceRef
- type HybridRecallRequest
- type Layer
- type MaintenanceJob
- type MaintenanceReport
- type Memory
- type MemoryType
- type MigrationStatus
- type RecallResponse
- type RecallResult
- type RecordEvidenceRequest
- type ScheduleMaintenanceRequest
- type SetTaskStateRequest
- type Stats
- type User
- type Verification
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidClaim = errors.New("invalid claim")
var ErrMemoryNotFound = errors.New("memory not found")
Functions ¶
func ContentHash ¶
ContentHash returns the blake2b-16 hex digest of text, mirroring ladym.layers.semantic.content_hash.
func EvidenceKind ¶ added in v0.9.0
func IsRetired ¶ added in v0.9.0
IsRetired preserves the supersedes metadata semantics used by existing data.
func IsSystemType ¶ added in v0.9.0
func IsSystemType(t MemoryType) bool
func KnowledgeFingerprint ¶ added in v0.9.0
func MaintenanceInputFingerprint ¶ added in v0.9.0
Accounting stamps are not knowledge inputs to the operation that wrote them.
func ManagedRevision ¶ added in v0.9.0
func ManagedRevisionKey ¶ added in v0.9.0
func NewID ¶
func NewID() string
NewID returns a fresh 32-hex-char id, mirroring Python's uuid4().hex.
func Now ¶
func Now() float64
Now returns the current Unix time as a float64 (seconds since epoch), mirroring Python's time.time().
func ProjectedEdgeID ¶ added in v0.7.0
ProjectedEdgeID returns the deterministic id for machine-projected edges so re-running a projection upserts instead of duplicating.
func SetClaimData ¶ added in v0.9.0
func SetClaimData(c *Claim)
func SourceFingerprint ¶ added in v0.9.0
SourceFingerprint captures trust, scope and TTL as well as literal content. Access statistics are deliberately excluded so reads cannot stale a topic.
func ValidateClaim ¶ added in v0.9.0
func ValidateClaim(content string, refs []EvidenceRef, scope ClaimScope, until float64) error
func ValidateEvidenceRef ¶ added in v0.9.0
func ValidateEvidenceRef(ref EvidenceRef, source *Memory) error
Types ¶
type BootstrapRequest ¶ added in v0.9.0
type BootstrapRequest struct {
TopicIDs []string `json:"topic_ids"`
Environment string `json:"environment"`
CodeVersion string `json:"code_version"`
Conditions []string `json:"conditions"`
TaskID string `json:"task_id"`
Unit string `json:"unit"`
Limit int `json:"limit"`
Workspace string `json:"workspace"`
}
type BootstrapResponse ¶ added in v0.9.0
type BuildTopicRequest ¶ added in v0.9.0
type Claim ¶ added in v0.9.0
type Claim struct {
Memory *Memory `json:"memory,omitempty"`
Revision int64 `json:"revision"`
Status string `json:"status"`
Evidence []EvidenceRef `json:"evidence_refs"`
CounterEvidence []EvidenceRef `json:"counter_evidence"`
Scope ClaimScope `json:"scope"`
Verification *Verification `json:"verification,omitempty"`
ValidUntil float64 `json:"valid_until"`
}
func ClaimFromMemory ¶ added in v0.9.0
type ClaimFeedback ¶ added in v0.9.0
type ClaimFeedbackRequest ¶ added in v0.9.0
type ClaimFeedbackRequest struct {
ClaimFeedback
Workspace string `json:"workspace"`
}
type ClaimScope ¶ added in v0.9.0
type CodeRef ¶
type CodeRef struct {
SrcSymbol string `json:"src_symbol"`
DstSymbol string `json:"dst_symbol"`
RefKind string `json:"ref_kind"`
}
CodeRef is a cross-reference between two symbols (calls/imports/defines).
type CodeSymbol ¶
type CodeSymbol struct {
MemoryID string `json:"memory_id"`
FilePath string `json:"file_path"`
SymbolKind string `json:"symbol_kind"`
QualifiedName string `json:"qualified_name"`
Signature string `json:"signature"`
Docstring string `json:"docstring"`
LineStart int `json:"line_start"`
LineEnd int `json:"line_end"`
Language string `json:"language"`
}
CodeSymbol is a structured projection of a code-bearing Memory.
type CreateClaimRequest ¶ added in v0.9.0
type CreateClaimRequest struct {
Content string `json:"content"`
Evidence []EvidenceRef `json:"evidence_refs"`
Scope ClaimScope `json:"scope"`
Status string `json:"status"`
ValidUntil float64 `json:"valid_until"`
Workspace string `json:"workspace"`
}
type Edge ¶
type Edge struct {
ID string `json:"id"`
SrcID string `json:"src_id"`
Relation string `json:"relation"`
DstID string `json:"dst_id"`
Weight float64 `json:"weight"`
ValidFrom float64 `json:"valid_from"`
ValidTo *float64 `json:"valid_to"` // nil = still valid
Metadata map[string]any `json:"metadata"`
}
Edge is a Zettelkasten-style link between two memories (L4 associative).
type EmbeddingIdentity ¶ added in v0.9.0
type EmbeddingIdentity struct {
Provider string `json:"provider"`
Model string `json:"model"`
Tokenizer string `json:"tokenizer"`
Dim int `json:"dim"`
}
EmbeddingIdentity names a vector space, including the tokenizer/version.
func (EmbeddingIdentity) Fingerprint ¶ added in v0.9.0
func (i EmbeddingIdentity) Fingerprint() string
func (EmbeddingIdentity) Validate ¶ added in v0.9.0
func (i EmbeddingIdentity) Validate() error
type EvidenceRef ¶ added in v0.9.0
type HybridRecallRequest ¶ added in v0.9.0
type Layer ¶
type Layer string
Layer is one of LadyM's seven memory layers (ARCHITECTURE.md §1).
const ( LayerWorking Layer = "L0_working" // in-process scratch LayerEpisodic Layer = "L1_episodic" // time-stamped events LayerSemantic Layer = "L2_semantic" // consolidated facts + code analysis LayerProcedural Layer = "L3_procedural" // how-to playbooks LayerAssociative Layer = "L4_associative" // graph edges (handled via Edge) LayerL5Mental Layer = "L5_mental" // mental models LayerL6Predictive Layer = "L6_predictive" // forward intent )
type MaintenanceJob ¶ added in v0.9.0
type MaintenanceJob struct {
ID string `json:"id"`
Workspace string `json:"workspace"`
Operation string `json:"operation"`
TargetID string `json:"target_id"`
State string `json:"state"`
Priority int `json:"priority,omitzero"`
Owner string `json:"owner,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
InputIDs []string `json:"input_ids"`
Fingerprints map[string]string `json:"fingerprints"`
InputRevisions map[string]int64 `json:"input_revisions"`
Args map[string]any `json:"args"`
Revision int64 `json:"revision"`
Attempt int `json:"attempt"`
NotBefore float64 `json:"not_before"`
LeaseUntil float64 `json:"lease_until"`
Checkpoint map[string]any `json:"checkpoint,omitempty"`
}
func MaintenanceJobFromMemory ¶ added in v0.9.0
func MaintenanceJobFromMemory(m *Memory) (*MaintenanceJob, error)
func (*MaintenanceJob) SetMemory ¶ added in v0.9.0
func (j *MaintenanceJob) SetMemory(m *Memory)
type MaintenanceReport ¶ added in v0.9.0
type MaintenanceReport struct {
CandidateCount int `json:"candidate_count"`
Calls int `json:"calls"`
ReservedBytes int `json:"reserved_bytes"`
MeasuredInputBytes int `json:"measured_input_bytes"`
MeasuredOutputBytes int `json:"measured_output_bytes"`
CompletedJobs int `json:"completed_jobs"`
PendingJobs int `json:"pending_jobs"`
FailedJobs int `json:"failed_jobs"`
ElapsedMS float64 `json:"elapsed_ms"`
StopReason string `json:"stop_reason"`
Unit string `json:"unit"`
}
type Memory ¶
type Memory struct {
ID string `json:"id"`
Layer Layer `json:"layer"`
Type MemoryType `json:"type"`
Content string `json:"content"`
Summary string `json:"summary"`
Tags []string `json:"tags"`
Metadata map[string]any `json:"metadata"`
Source string `json:"source"`
Workspace string `json:"workspace"`
CreatedAt float64 `json:"created_at"`
UpdatedAt float64 `json:"updated_at"`
LastAccessAt float64 `json:"last_access_at"`
AccessCount int `json:"access_count"`
Activation float64 `json:"activation"`
ContentHash string `json:"content_hash"`
// Embedding is stored separately (BLOB) but kept on the model for
// in-memory flows. Omitted from JSON when unset.
Embedding []float32 `json:"embedding,omitempty"`
}
Memory is a single memory item; it maps to one row in the memories table.
func NewMemory ¶
func NewMemory(layer Layer, typ MemoryType) *Memory
NewMemory returns a Memory with the id/timestamps pre-populated. Layer and Type are required; everything else defaults.
func (*Memory) Clone ¶
Clone returns a shallow copy with independent Tags and Metadata containers. Tags is always non-nil; Metadata preserves nil.
func (*Memory) MetaFloat ¶
MetaFloat returns the float value for key (accepting JSON numbers) and ok.
func (*Memory) MetaString ¶
MetaString returns the string value for key in Metadata, or "".
type MemoryType ¶
type MemoryType string
MemoryType is a sub-type within a layer. L2 is the most polymorphic.
const ( TypeNote MemoryType = "note" // free-form working/semantic note TypeEvent MemoryType = "event" // episodic (agent, action, observation, outcome) TypeFact MemoryType = "fact" // consolidated semantic fact TypeCodeFile MemoryType = "code_file" // whole-file summary TypeCodeSymbol MemoryType = "code_symbol" // function/class/method/doc TypePlaybook MemoryType = "playbook" // procedural steps TypeSnippet MemoryType = "snippet" // verified reusable code TypeMentalModel MemoryType = "mental_model" // L5 mental model TypeForwardIntent MemoryType = "forward_intent" // L6 forward intent TypeResource MemoryType = "resource" // L2 resource entity (operated-on target) TypeClaim MemoryType = "claim" TypeEvidence MemoryType = "evidence" TypeTopicView MemoryType = "topic_view" TypeMaintenanceJob MemoryType = "maintenance_job" TypeTaskState MemoryType = "task_state" )
type MigrationStatus ¶ added in v0.9.0
type MigrationStatus struct {
State string `json:"state"`
ActiveFingerprint string `json:"active_fingerprint"`
TargetFingerprint string `json:"target_fingerprint,omitempty"`
Generation string `json:"generation,omitempty"`
Cursor string `json:"cursor,omitempty"`
Processed int `json:"processed"`
RollbackAvailable bool `json:"rollback_available"`
AutoFinalize bool `json:"auto_finalize,omitempty"`
ActiveIdentity EmbeddingIdentity `json:"active_identity"`
TargetIdentity EmbeddingIdentity `json:"target_identity"`
}
type RecallResponse ¶
type RecallResponse struct {
Query string `json:"query"`
Results []*RecallResult `json:"results"`
TierReached int `json:"tier_reached"`
ReflectedSufficient bool `json:"reflected_sufficient"`
ElapsedMs float64 `json:"elapsed_ms"`
}
RecallResponse is the full response from a recall call.
type RecallResult ¶
type RecallResult struct {
Memory *Memory `json:"memory"`
Score float64 `json:"score"`
Tier int `json:"tier"`
Via []string `json:"via"`
}
RecallResult is one hit returned by recall.
type RecordEvidenceRequest ¶ added in v0.9.0
type ScheduleMaintenanceRequest ¶ added in v0.9.0
type SetTaskStateRequest ¶ added in v0.9.0
type Stats ¶
type Stats struct {
TotalMemories int `json:"total_memories"`
ByLayer map[string]int `json:"by_layer"`
ByType map[string]int `json:"by_type"`
Edges int `json:"edges"`
CodeSymbols int `json:"code_symbols"`
Workspaces []string `json:"workspaces"`
DBPath string `json:"db_path"`
AvgTokensPerMemory float64 `json:"avg_tokens_per_memory"`
}
Stats holds aggregate statistics for the stats tool/command.
type User ¶ added in v0.4.0
type User struct {
Username string `json:"username"`
PasswordHash string `json:"password_hash"`
Workspace string `json:"workspace"`
Admin bool `json:"admin"`
CreatedAt float64 `json:"created_at"`
}
User is one row in the users table: a database-level account for the HTTP data-plane's Basic auth (see docs/superpowers/specs /2026-08-19-auth-console-client.md §2). PasswordHash holds a bcrypt hash; "" means the user is passwordless (only an empty password authenticates). Workspace is the forced workspace for non-admin users. The hash is produced and checked in the api/cli layers — the Store only persists the string.
type Verification ¶ added in v0.9.0
type Verification struct {
Method string `json:"method"`
Actor string `json:"actor"`
CheckedAt float64 `json:"checked_at"`
Evidence []EvidenceRef `json:"evidence_refs"`
}