Co Occurrence Engine

v1.0.0

独立的 Hebbian 共现图引擎,记录记忆共现,计算关联权重,支持关联查询和数据库维护,服务星型记忆架构。

0· 152·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for whoisme007/co-occurrence-engine.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Co Occurrence Engine" (whoisme007/co-occurrence-engine) from ClawHub.
Skill page: https://clawhub.ai/whoisme007/co-occurrence-engine
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install co-occurrence-engine

ClawHub CLI

Package manager switcher

npx clawhub@latest install co-occurrence-engine
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (Hebbian co-occurrence engine) matches the included implementation: a Python tracker that records co-occurrence edges in a local SQLite DB under ~/.config/cortexgraph. No unrelated services, credentials, or binaries are requested.
Instruction Scope
SKILL.md and the Python file confine operations to local DB read/write, queries, decay, and maintenance. Instructions reference only the DB path and optional half-life setting; they do not instruct reading unrelated system files or sending data externally.
Install Mechanism
No install spec or remote downloads are present. The skill is instruction-only with a bundled Python script, so nothing is fetched from external URLs during install.
Credentials
No required environment variables or credentials are declared. SKILL.md documents optional env vars (CO_OCCURRENCE_DB_PATH, CO_OCCURRENCE_HALF_LIFE_DAYS) that are reasonable for configuration. The code writes only to a per-user config path.
Persistence & Privilege
always is false and the skill does not request elevated privileges or modify other skills. It creates/uses a local DB file under the user's config directory (normal for this kind of tool).
Assessment
This skill appears coherent and local-only: it creates and updates a SQLite DB at ~/.config/cortexgraph/co_occurrence.db and does not contact external endpoints or request secrets. Before installing, consider: (1) any memory IDs you pass to the tracker will be stored on disk — avoid feeding sensitive secrets if you don't want them persisted; (2) the code optionally imports a third-party 'forgetting_curve' module if installed — only install/allow that package from a trusted source; (3) confirm the DB path is acceptable or override CO_OCCURRENCE_DB_PATH if you prefer a different location; (4) if you integrate this with other components (adapter_factory or external adapters), review those adapter implementations to ensure they don't leak data. Overall the skill is internally consistent and low-risk, but treat stored memory contents as persistent data you control.

Like a lobster shell, security has layers — review code before you run it.

latestvk977k5df1wnctq1sg6ga7rvnw9835g7q
152downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

co-occurrence-engine

独立的 Hebbian 共现图引擎,为星型记忆架构提供记忆关联发现与权重计算服务。

功能

  • 共现记录:自动记录同时被检索的记忆对,建立关联边
  • 关联查询:查询与指定记忆最相关的其他记忆
  • 权重计算:基于使用频率与时间衰减计算关联强度
  • 统计信息:提供边数、唯一记忆数、平均权重等统计
  • 维护工具:清理过旧的边,保持数据库健康

架构

┌─────────────────────────────────────────────────────┐
│               共现图引擎 (独立插件)                  │
│                                                     │
│  • CoOccurrenceEngine 类                            │
│  • SQLite 数据库 (共现图)                            │
│  • 遗忘曲线集成 (可选)                               │
└─────────────────────────────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────┐
│               适配器 (co_occurrence_adapter)         │
│                                                     │
│  • 实现统一记忆接口                                   │
│  • 注册到星型架构适配器框架                           │
└─────────────────────────────────────────────────────┘

核心类

CoOccurrenceEngine

主引擎类,提供共现图的所有操作。

engine = CoOccurrenceEngine(db_path="~/.config/cortexgraph/co_occurrence.db")

主要方法

  • record_co_occurrence(memory_ids: List[str], context: str = "")
  • get_co_occurrence_score(memory_id: str, related_ids: List[str] = None) -> float
  • get_related_memories(memory_id: str, top_k: int = 10) -> List[Tuple[str, float]]
  • get_stats() -> Dict
  • decay_old_edges(days: int = 90) -> int

## 数据库

默认数据库位置:`~/.config/cortexgraph/co_occurrence.db`

表结构:
```sql
CREATE TABLE co_occurrence (
    memory_a TEXT,
    memory_b TEXT,
    weight REAL,
    last_updated TEXT,
    created_at TEXT,
    PRIMARY KEY (memory_a, memory_b)
)

集成

1. 独立使用

from scripts.co_occurrence_tracker import CoOccurrenceEngine

engine = CoOccurrenceEngine()
engine.record_co_occurrence(["mem_001", "mem_002"])
related = engine.get_related_memories("mem_001")

2. 通过适配器集成

from adapter_factory import AdapterFactory

factory = AdapterFactory()
adapter = factory.get_adapter("co_occurrence")
results = adapter.search("mem_001", max_results=10)

配置

通过环境变量或配置文件:

  • CO_OCCURRENCE_DB_PATH:数据库路径(默认:~/.config/cortexgraph/co_occurrence.db
  • CO_OCCURRENCE_HALF_LIFE_DAYS:衰减半衰期(默认:30天)

依赖

  • Python 3.8+
  • SQLite3(内置)
  • 可选forgetting-curve 插件(提供更精确的衰减计算)

版本历史

  • v0.1.0(初始版本):从 memory-sync-enhanced 中提取的共现图引擎

Comments

Loading comments...