📸 Snapshot Management

Version control for Knowledge Graph state.


Overview

Snapshots provide immutable, versioned states of the Knowledge Graph, enabling:


Create Snapshot

1
2
3
4
5
6
7
8
curl -X POST http://localhost:8000/graph/snapshots \
  -H "Content-Type: application/json" \
  -d '{
    "version": "1.0.0",
    "description": "Initial production snapshot",
    "tags": ["production", "release-1.0"],
    "createdBy": "release-pipeline"
  }'

Response

1
2
3
4
5
6
7
{
  "id": "ifl:snap:a3b8c9d2e1f4567890abcdef...",
  "version": "1.0.0",
  "timestamp": "2026-01-05T10:00:00Z",
  "tripleCount": 1523,
  "contentHash": "a3b8c9d2..."
}

List Snapshots

1
2
3
4
5
6
7
8
# All snapshots
curl http://localhost:8000/graph/snapshots

# Filter by tag
curl "http://localhost:8000/graph/snapshots?tags=production"

# Filter by version
curl "http://localhost:8000/graph/snapshots?version=1.0.0"

Query Against Snapshot

1
2
3
4
5
6
curl -X POST "http://localhost:8000/graph/snapshots/ifl:snap:abc.../query" \
  -H "Content-Type: application/json" \
  -d '{
    "language": "sparql",
    "query": "SELECT * WHERE { ?s ?p ?o } LIMIT 10"
  }'

Compare Snapshots

List Changes Between Versions

1
2
3
sea graph diff \
  --from ifl:snap:old... \
  --to ifl:snap:new...

Output

1
2
3
+ Added: <entity/new-warehouse> a sea:Entity
~ Modified: <entity/warehouse-a> sea:status "active" → "closed"
- Removed: <flow/old-delivery> a sea:Flow

Create Change Set

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
curl -X POST http://localhost:8000/graph/changesets \
  -H "Content-Type: application/json" \
  -d '{
    "sourceSnapshotId": "ifl:snap:current...",
    "description": "Add new warehouse entity",
    "operations": [
      {
        "type": "add",
        "triple": {
          "subject": "http://sea-forge.com/entity/warehouse-b",
          "predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
          "object": "http://sea-forge.com/schema/core#Entity"
        }
      }
    ]
  }'

Apply Change Set

1
2
3
4
5
6
7
curl -X POST "http://localhost:8000/graph/changesets/ifl:cs:abc.../apply" \
  -H "Content-Type: application/json" \
  -d '{
    "version": "1.1.0",
    "description": "Applied warehouse-b addition",
    "tags": ["development"]
  }'

Rollback to Snapshot

1
2
# Create new snapshot from old state
sea graph restore --snapshot ifl:snap:old... --new-version "1.2.0"

Best Practices

Practice Description
Tag releases Use production, staging tags
Version semantically Follow semver for versions
Document changes Include clear descriptions
Validate before snapshot Run SHACL validation first