The Storage Layer handles persistence of concepts, theories, and audit logs. It provides a uniform interface through the StorageAdapter, with pluggable backends for disk, memory, or custom storage systems.

Specification: DS(/storage/adapter) · DS(/storage/persistence)

Directory Structure

By default, AGISystem2 stores all data in a .AGISystem2/ directory in the working directory:

.AGISystem2/
├── data/
│   ├── concepts/           # Binary concept data
│   │   ├── Dog.bin
│   │   ├── Cat.bin
│   │   └── Animal.bin
│   ├── index.json          # Concept name index
│   └── audit/              # Operation logs
│       └── 2024-01-15.log
└── theories/
    ├── base.sys2dsl        # Optional base theory
    ├── medical.sys2dsl     # Named theory files
    └── legal.sys2dsl

StorageAdapter

The StorageAdapter provides a uniform interface for storage operations:

MethodDescription
saveConcept(name, data)Persist concept to storage
loadConcept(name)Retrieve concept from storage
deleteConcept(name)Remove concept from storage
listConcepts()List all stored concept names
saveTheory(name, facts)Save theory to file
loadTheory(name)Load theory from file
appendAudit(entry)Append to audit log

Storage Backends

Disk Backend (Default)

Stores concepts as binary files and theories as text. Suitable for persistent, file-based workflows.

Memory Backend

In-memory storage for testing and ephemeral sessions. Data is lost when the process exits.

Custom Backends

Implement the StorageAdapter interface to connect to databases, cloud storage, or other systems.

File Formats

Binary Format (.bin)

Efficient storage for concept vectors. Contains: header, vector data, metadata.

Theory Format (.sys2dsl)

Human-readable text format. One fact per line, comments start with #:

# Medical knowledge base
ASSERT Aspirin IS_A Drug
ASSERT Aspirin REDUCES Inflammation
ASSERT Ibuprofen IS_A Drug

Related Documentation