name: cross-session-memory
description: >-
Cross-session persistent memory for security engagements. Provides tri-layer
indexing (semantic embeddings + BM25 keywords + structured metadata) with
reciprocal rank fusion retrieval. Stores findings, IOCs, TTPs, credentials,
host info, and analyst decisions. Supports memory decay, consolidation, and
engagement-scoped context loading.
domain: cybersecurity
subdomain: memory-system
tags:
- memory
- persistence
- tri-layer-indexing
- semantic-search
- engagement-context
- ioc-management
- knowledge-base
version: "1.0"
author: defconxt
license: AGPL-3.0
compatibility: Designed for Claude Code, GitHub Copilot, OpenAI Codex, Cursor, Gemini CLI, and any agentskills.io-compatible agent.
metadata:
frameworks: ["SimpleMem tri-layer", "ProjectDiscovery Neo persistent memory"]
Cross-Session Memory
When to Use
Activate when the operator needs persistent memory across sessions — loading
previous engagement context, searching past findings, managing IOC collections,
or building cumulative security knowledge. The memory system automatically
indexes entries across semantic, lexical, and symbolic layers.
Architecture
Query: "SQL injection on login endpoint"
│
├─── Semantic Layer (LanceDB)
│ Dense embedding similarity → finds conceptually related entries
│
├─── Lexical Layer (SQLite FTS5)
│ BM25 keyword matching → finds exact term matches
│
└─── Symbolic Layer (SQLite)
Structured metadata → filters by engagement, severity, type
│
▼
Reciprocal Rank Fusion (RRF)
Fuse ranked lists → unified result ranking
Memory Types
| Type |
Content |
Example |
finding |
Vulnerability or security issue |
"SQLi on /api/login allows auth bypass" |
ioc |
Indicator of compromise |
"C2 domain: evil.example.com" |
ttp |
Tactic, technique, procedure |
"T1558.003 Kerberoasting via GetUserSPNs" |
credential |
Credential reference (hashed) |
"Found default admin creds on Jenkins" |
host |
Asset information |
"10.0.0.5 runs Apache 2.4.49 (CVE-2021-41773)" |
network |
Topology or flow data |
"DMZ segment 10.0.1.0/24 → internal via port 8443" |
config |
Configuration or policy |
"S3 bucket public ACL on customer-data bucket" |
note |
Analyst observation |
"Client uses Okta SSO, MFA only for admins" |
decision |
Engagement decision |
"Decided to pivot to AD attack path after web assessment" |
artifact |
Evidence reference |
"Memory dump stored at /evidence/host01_mem.lime SHA256:abc..." |
Usage
from memory.core.engine import CipherMemory, MemoryEntry, MemoryType
memory = CipherMemory()
# Store a finding
memory.store(MemoryEntry(
content="SQL injection on /api/v2/login POST parameter 'username' allows authentication bypass and database access",
memory_type=MemoryType.FINDING,
engagement_id="pentest-2026-acme",
source_skill="web-application-attacks",
targets=["https://acme.com/api/v2/login"],
mitre_attack=["T1190"],
cve_ids=[],
severity="critical",
keywords=["sqli", "authentication", "bypass", "login"],
tags=["web", "api", "owasp-a03"],
))
# Search across all layers
results = memory.search("authentication bypass vulnerabilities")
# Search with filters
results = memory.search(
query="credential access",
engagement_id="pentest-2026-acme",
severity="critical",
)
# Load full engagement context
context = memory.get_engagement_context("pentest-2026-acme")
# Maintenance
memory.consolidate() # Decay, archive stale entries
print(memory.stats())
memory.close()
Retrieval Pipeline
- Query received (natural language or structured)
- Semantic search — embed query, find nearest vectors in LanceDB
- Lexical search — BM25 match in SQLite FTS5
- Symbolic search — filter by engagement, type, severity, MITRE technique
- Reciprocal Rank Fusion — fuse three ranked lists:
RRF(d) = Σ 1/(k + rank_i(d))
- Boost on access — accessed entries get decay score boost
- Return — unified ranked list of MemoryEntry objects
Memory Lifecycle
Store → Index (3 layers) → Search → Access (boost) → Decay → Archive/Prune
Consolidation (periodic):
├── Decay: multiply all scores by 0.98
├── Boost: accessed entries get +0.05
├── Archive: entries with score < 0.05 archived
└── Merge: duplicate IOCs/findings deduplicated (future)
Verification
1---2name: cross-session-memory3description: <!-- Copyright (c) 2026 defconxt. All rights reserved. -->4---5
6<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
7<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
8---
9name: cross-session-memory
10description: >-
11 Cross-session persistent memory for security engagements. Provides tri-layer
12 indexing (semantic embeddings + BM25 keywords + structured metadata) with
13 reciprocal rank fusion retrieval. Stores findings, IOCs, TTPs, credentials,
14 host info, and analyst decisions. Supports memory decay, consolidation, and
15 engagement-scoped context loading.
16domain: cybersecurity
17subdomain: memory-system
18tags:
19 - memory
20 - persistence
21 - tri-layer-indexing
22 - semantic-search
23 - engagement-context
24 - ioc-management
25 - knowledge-base
26version: "1.0"
27author: defconxt
28license: AGPL-3.0
29compatibility: Designed for Claude Code, GitHub Copilot, OpenAI Codex, Cursor, Gemini CLI, and any agentskills.io-compatible agent.
30metadata:
31 frameworks: ["SimpleMem tri-layer", "ProjectDiscovery Neo persistent memory"]
32---
33
34# Cross-Session Memory
35
36## When to Use
37
38Activate when the operator needs persistent memory across sessions — loading
39previous engagement context, searching past findings, managing IOC collections,
40or building cumulative security knowledge. The memory system automatically
41indexes entries across semantic, lexical, and symbolic layers.
42
43## Architecture
44
45```
46Query: "SQL injection on login endpoint"
47 │
48 ├─── Semantic Layer (LanceDB)
49 │ Dense embedding similarity → finds conceptually related entries
50 │
51 ├─── Lexical Layer (SQLite FTS5)
52 │ BM25 keyword matching → finds exact term matches
53 │
54 └─── Symbolic Layer (SQLite)
55 Structured metadata → filters by engagement, severity, type
56 │
57 ▼
58 Reciprocal Rank Fusion (RRF)
59 Fuse ranked lists → unified result ranking
60```
61
62## Memory Types
63
64| Type | Content | Example |
65|------|---------|---------|
66| `finding` | Vulnerability or security issue | "SQLi on /api/login allows auth bypass" |
67| `ioc` | Indicator of compromise | "C2 domain: evil.example.com" |
68| `ttp` | Tactic, technique, procedure | "T1558.003 Kerberoasting via GetUserSPNs" |
69| `credential` | Credential reference (hashed) | "Found default admin creds on Jenkins" |
70| `host` | Asset information | "10.0.0.5 runs Apache 2.4.49 (CVE-2021-41773)" |
71| `network` | Topology or flow data | "DMZ segment 10.0.1.0/24 → internal via port 8443" |
72| `config` | Configuration or policy | "S3 bucket public ACL on customer-data bucket" |
73| `note` | Analyst observation | "Client uses Okta SSO, MFA only for admins" |
74| `decision` | Engagement decision | "Decided to pivot to AD attack path after web assessment" |
75| `artifact` | Evidence reference | "Memory dump stored at /evidence/host01_mem.lime SHA256:abc..." |
76
77## Usage
78
79```python
80from memory.core.engine import CipherMemory, MemoryEntry, MemoryType
81
82memory = CipherMemory()
83
84# Store a finding
85memory.store(MemoryEntry(
86 content="SQL injection on /api/v2/login POST parameter 'username' allows authentication bypass and database access",
87 memory_type=MemoryType.FINDING,
88 engagement_id="pentest-2026-acme",
89 source_skill="web-application-attacks",
90 targets=["https://acme.com/api/v2/login"],
91 mitre_attack=["T1190"],
92 cve_ids=[],
93 severity="critical",
94 keywords=["sqli", "authentication", "bypass", "login"],
95 tags=["web", "api", "owasp-a03"],
96))
97
98# Search across all layers
99results = memory.search("authentication bypass vulnerabilities")
100
101# Search with filters
102results = memory.search(
103 query="credential access",
104 engagement_id="pentest-2026-acme",
105 severity="critical",
106)
107
108# Load full engagement context
109context = memory.get_engagement_context("pentest-2026-acme")
110
111# Maintenance
112memory.consolidate() # Decay, archive stale entries
113print(memory.stats())
114memory.close()
115```
116
117## Retrieval Pipeline
118
1191. **Query** received (natural language or structured)
1202. **Semantic search** — embed query, find nearest vectors in LanceDB
1213. **Lexical search** — BM25 match in SQLite FTS5
1224. **Symbolic search** — filter by engagement, type, severity, MITRE technique
1235. **Reciprocal Rank Fusion** — fuse three ranked lists: `RRF(d) = Σ 1/(k + rank_i(d))`
1246. **Boost on access** — accessed entries get decay score boost
1257. **Return** — unified ranked list of MemoryEntry objects
126
127## Memory Lifecycle
128
129```
130Store → Index (3 layers) → Search → Access (boost) → Decay → Archive/Prune
131
132Consolidation (periodic):
133├── Decay: multiply all scores by 0.98
134├── Boost: accessed entries get +0.05
135├── Archive: entries with score < 0.05 archived
136└── Merge: duplicate IOCs/findings deduplicated (future)
137```
138
139## Verification
140
141- [ ] Memory engine initializes without errors
142- [ ] Entries stored and retrievable across all three layers
143- [ ] RRF fusion returns results from multiple layers
144- [ ] Engagement-scoped queries filter correctly
145- [ ] Decay and consolidation maintain memory hygiene
146- [ ] Archived entries excluded from search results