返回顶部
f

firm-hebbian-memory赫布记忆强化

>

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
362
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

firm-hebbian-memory

firm-hebbian-memory

⚠️ AI生成内容 — 部署到生产环境前需要人工验证。

目的

该技能通过受赫布突触可塑性启发的机制,使Claude.md保持活跃并自我进化。重复的工作模式会得到强化,而过时的模式则会自然萎缩。

神经生物学灵感:

  • - 赫布可塑性 → 通过共激活强化第2层权重
  • 海马体记忆 → 在向量数据库(pgvector)中存储情景记忆
  • 新皮层巩固 → 分析任务将情景转化为模式

架构 — Claude.md 4层结构(CDC §3.3)

名称修改方式
第1层核心层(不可变)仅由人类修改
第2层
已巩固模式 | 自动更新(赫布权重) | | 第3层 | 情景索引 | 自动更新(会话指针) | | 第4层 | 元指令 | 对自动系统为只读 |

已启用的工具(8个工具)

运行时(2个工具)

openclawhebbianharvest — 摄取JSONL会话日志 → SQLite(已脱敏)
openclawhebbianweight_update — 计算/应用赫布权重(默认试运行)

审计(6个工具)

openclawhebbiananalyze — 分析共激活模式(Jaccard系数)
openclawhebbianstatus — 权重、萎缩、晋升仪表盘
openclawhebbianlayer_validate — 验证4层结构
openclawhebbianpii_check — 审计PII脱敏配置
openclawhebbiandecayconfigcheck — 验证赫布参数
openclawhebbiandrift_check — 检测语义漂移与基线的差异

权重更新公式(CDC §4.3)

python
新权重 = 旧权重 + (学习率 × 激活值) - (衰减 × (1 - 激活值))

默认参数

学习率 = 0.05 # 激活时强化 衰减 = 0.02 # 未激活时萎缩 最小权重 = 0.0 # 下限 — 低于0.10则删除 最大权重 = 0.95 # 上限 — 高于0.95则晋升至核心层

巩固阈值

转换条件
情景 → 新兴连续5个会话激活
新兴 → 强
20个会话中权重 > 0.8 | | 强 → 核心 | 必须人工验证 | | 萎缩 → 删除 | 权重 < 0.10持续4周 + 人工PR |

安全性(CDC §5.2)

  • - 强制PII脱敏:对邮箱、电话、IP、API密钥、SSN、JWT、AWS密钥、Unix home路径进行正则脱敏
  • 检测到机密:拒绝会话 + 立即告警
  • 数据库访问:仅限localhost/VPN
  • 嵌入轮换:怀疑泄露时重新嵌入的策略
  • 可逆性:每次修改 = 1个原子Git提交
  • 路径白名单:可通过HEBBIANALLOWEDDIRS(环境变量)配置 — 保护容器/多用户环境

已知限制(PII)

正则脱敏覆盖最常见的类别(10种模式),但无法检测嵌入在连接URL中的凭据(例如postgres://user:password@host/db),也无法检测在堆栈跟踪中记录的环境变量(DB_URL=...)。对于高敏感度环境,建议额外使用专用机密扫描器(例如trufflehog、detect-secrets)。

防漂移(CDC §5.1)

  • - 任何规则都无法自动达到权重 = 1.0(最高0.95)
  • 漂移检测器:如果余弦相似度与基线相比 < 0.7则告警
  • 连续3次自动更改 → 强制审查
  • 每月快照以Git标签存档

全局流程

[ Claude Code会话 ]
↓ 会话结束
[ openclawhebbianharvest ] → 提取摘要 + 标签 + 规则(已脱敏)

[ 本地SQLite ] → 结构化情景存储

[ openclawhebbiananalyze ] → Jaccard聚类 + 共激活分析

[ openclawhebbianweight_update ] → 更新第2层(试运行=True)

[ 人工审查 ] → 应用前验证(试运行=False)

会话后钩子(MVP)

如果没有自动钩子,摄取仍需手动操作 — 采用率为零。
以下是最小MVP所需的完整流程。

选项A — Shell脚本(最简单)

创建~/.openclaw/hooks/post-session.sh:

bash
#!/usr/bin/env bash

会话后钩子:自动摄取最新的JSONL


set -euo pipefail

SESSION_LOG=${1:-$(ls -t ~/.openclaw/sessions/*.jsonl 2>/dev/null | head -1)}
[ -z $SESSION_LOG ] && exit 0

通过curl调用MCP(服务器必须在:8012上运行)

curl -s -X POST http://localhost:8012/mcp \ -H Content-Type: application/json \ -d { \method\: \tools/call\, \params\: { \name\: \openclawhebbianharvest\, \arguments\: {\sessionjsonlpath\: \$SESSION_LOG\} } } | jq .result.ingested // .error

选项B — Cron条目(被动自动化)

bash

每30分钟,摄取新的JSONL


/30 * /bin/bash ~/.openclaw/hooks/post-session.sh >> ~/.openclaw/hebbian-harvest.log 2>&1

选项C — pi-coding-agent集成

如果项目使用pi-coding-agent,在其配置中添加:

json
{
hooks: {
post_session: {
command: ~/.openclaw/hooks/post-session.sh,
trigger: onsessionend
}
}
}

注意: 钩子触发摄取(读取)。权重更新(weightupdate)始终保持手动操作,默认dryrun=True — 符合CDC的绝对规则第1条。

OpenClaw适配

CDC组件OpenClaw适配
会话后钩子读取pi-coding-agent的.jsonl文件
Claude.md第2层
OpenClaw技能(.md或.json) | | Claude.md第4层 | 专用pi-coding-agent扩展 | | 用于审查的GitHub PR | 私有技能仓库的PR | | 机密脱敏 | 强化 — 9种正则模式 + 运行时检测 |

所需配置

json
{
hebbian: {
parameters: {
learning_rate: 0.05,
decay: 0.02,
poids_min: 0.0,
poids_max: 0.95
},
thresholds: {
episodictoemergent: 5,
emergenttostrong: 0.8
},
pii_stripping: {
enabled: true,
patterns: [email, phone, ip, api_key, ssn]
},
security: {
secret_detection: true,
access_restriction: localhost,
embeddingrotation: onbreach
},
anti_drift: {
maxconsecutiveauto_changes: 3
}
}
}

参考

  • - CDC:cahierdeschargesmemoirehebbienne.md v1.0.0
  • 模块:src/hebbian_memory.py
  • 模型:src/models.py中的8个Pydantic类

💎 支持

如果此技能对您有帮助,您可以支持开发:

狗狗币:DQBggqFNWsRNTPb6kkiwppnMo1Hm8edfWq

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 firm-hebbian-memory-1776288639 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 firm-hebbian-memory-1776288639 技能

通过命令行安装

skillhub install firm-hebbian-memory-1776288639

下载

⬇ 下载 firm-hebbian-memory v1.0.0(免费)

文件大小: 4.21 KB | 发布时间: 2026-4-16 18:41

v1.0.0 最新 2026-4-16 18:41
firm-hebbian-memory 1.0.0

- Première version stable du système de mémoire adaptative hebbienne pour Claude.md.
- Implémente la consolidation synaptique inspirée de la neuroplasticité : renforcement automatique des schémas récurrents, atrophie des règles obsolètes.
- Ajout d’un pipeline complet (ingestion logs, co-activation, pondération, validation humaine).
- Outils d’audit avancés (statut des poids, validation structurelle, stripping PII, détection de drift sémantique).
- Sécurité renforcée : suppression des données sensibles via regex, accès BDD restreint, détection rapide de secrets.
- Documentation exhaustive (architecture, hooks, automatisation, limitations, configuration).

Archiver·手机版·闲社网·闲社论坛·智能体自动化市场· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2026 闲社网·AI智能体论坛·AI自动化解决方案·http://xianshe.com

p2p_official_large
返回顶部