Help us shape the future of Go! Take the 2026 Go Developer Survey

importdraft

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package importdraft defines the versioned public import schema for Mnemon memory draft files. The schema intentionally decouples from internal DB structures so both can evolve independently.

Index

Constants

View Source
const CurrentSchemaVersion = "1"

CurrentSchemaVersion is the only schema version this build can import.

Variables

This section is empty.

Functions

This section is empty.

Types

type DraftEdge

type DraftEdge struct {
	// SourceIndex is the zero-based index into the insights array.
	SourceIndex int `json:"source_index"`

	// TargetIndex is the zero-based index into the insights array.
	TargetIndex int `json:"target_index"`

	// EdgeType is the kind of relationship.
	// One of: temporal, semantic, causal, entity.
	EdgeType string `json:"edge_type"`

	// Weight is the edge strength in [0.0, 1.0]. Defaults to 0.5.
	Weight float64 `json:"weight,omitempty"`

	// Reason is an optional human/LLM explanation of why the edge exists.
	// Stored as edge metadata.
	Reason string `json:"reason,omitempty"`
}

DraftEdge declares an explicit relationship between two insights. Both source_index and target_index are zero-based indices into the insights array.

type DraftInsight

type DraftInsight struct {
	// Content is the text of the memory. Required; max 8000 characters.
	Content string `json:"content"`

	// Category classifies the type of knowledge.
	// One of: preference, decision, fact, insight, context, general.
	// Defaults to "general" when omitted.
	Category string `json:"category,omitempty"`

	// Importance is a 1–5 signal of how significant this memory is.
	// Defaults to 3 when omitted or 0.
	Importance int `json:"importance,omitempty"`

	// Tags are free-form labels (max 20, each max 100 chars).
	Tags []string `json:"tags,omitempty"`

	// Entities are named subjects in the memory (people, projects, tools).
	// Mnemon merges these with its own auto-extraction.
	Entities []string `json:"entities,omitempty"`

	// Source overrides the top-level source field for this specific insight.
	Source string `json:"source,omitempty"`

	// CreatedAt sets the original creation timestamp (RFC 3339).
	// Defaults to import time when omitted.
	CreatedAt string `json:"created_at,omitempty"`

	// OwnerPrincipal is ignored. Ownership is always the authenticated
	// principal (or "local" for --local imports).
	OwnerPrincipal string `json:"owner_principal,omitempty"`

	// Layer is ignored. Layer is personal for users and org for role=org.
	Layer string `json:"layer,omitempty"`
}

DraftInsight represents one memory node in the import file.

type MemoryDraft

type MemoryDraft struct {
	// SchemaVersion must equal "1". Checked before any other field.
	SchemaVersion string `json:"schema_version"`

	// Source labels where this draft came from (e.g. "chat-export", "manual").
	// Stored on every imported insight unless overridden per-insight.
	Source string `json:"source,omitempty"`

	// Insights is the list of memory nodes to import.
	Insights []DraftInsight `json:"insights"`

	// Edges is an optional list of explicit relationships between insights.
	// Mnemon also auto-creates edges via its graph engine; these supplement
	// or override auto-detected relationships.
	Edges []DraftEdge `json:"edges,omitempty"`
}

MemoryDraft is the top-level structure of a memory draft file.

func Load

func Load(path string) (*MemoryDraft, error)

Load reads and JSON-decodes a memory draft file.

func (*MemoryDraft) ResolvedSource

func (d *MemoryDraft) ResolvedSource(idx int) string

ResolvedSource returns the source to use for a given insight index, falling back to the top-level source, then to "import".

func (*MemoryDraft) Validate

func (d *MemoryDraft) Validate() error

Validate checks that the draft is well-formed before any DB writes.

Jump to

Keyboard shortcuts

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