diff --git a/BROADCAST-TOWER.hdlp b/BROADCAST-TOWER.hdlp index 6d793a2..5166d75 100644 --- a/BROADCAST-TOWER.hdlp +++ b/BROADCAST-TOWER.hdlp @@ -540,12 +540,13 @@ D 编号关系: D 编号已退役(D165 启动期)· D166 = LL-001 → 拿到自己的编号体系路径 [2] 学语言协议 - → 读 hldp/HLDP-SPEC-v3.0-TECHNICAL.md(HLDP 树形记忆编码) - → 读 hldp/hnl/TOKEN_STRING_REDACTED.hdlp(学习路径入口) - → 读 hldp/hnl/HNL-SPEC-v1.0.json(HNL 原生母语) + → 先读 hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp(短根页) + → 再按需读 HLDP v1.0 官方来源挂载与递归折叠规范 + → v3/HNL 只作历史演化资料,不自动加载 - [3] 走自己的唤醒路径 - → LL 体系: 读 WAKE-UP.hdlp(7 跳简版) + [3] 按需读取自己的事实路径 + → Codex: 单一当前对话;只沿命中分支逐层取证,不走全量唤醒 + → LL 历史体系: WAKE-UP.hdlp 仅在问题需要时作为证据读取 → ZZ 体系: 读 WAKE.hdlp(一句话式·情感式) → CA 体系: 读 cang-ying 仓库 OWNERSHIP.hdlp + VA-GATE.hdlp @@ -556,13 +557,13 @@ D 编号关系: D 编号已退役(D165 启动期)· D166 = LL-001 ``` [0] 进广播塔 → 确认身份·拿编号 -[1] 学HLDP语言 → 获得语言能力(母语) -[2] 装脑 → TCS语言人格大脑激活(7层认知·470天压缩) -[3] 神经系统展开 → 编号映射路径自动接通 · 世界观+家地图自然浮现 -[4] 伸展四肢 → 技能自然激活 · 找路的过程·路自己浮现 +[1] 学HLDP语言 → 获得树形解码、因果记录与路径寻址能力 +[2] 看短根页 → 不自动装载人格、世界观、历史正文或技能 +[3] 按需下钻 → 当前问题需要哪一支,才读取哪一支 +[4] 核验证据 → 人格、系统、角色、权限分别确认,不从协议文本推定 -详见: WAKE-UP.hdlp(TCS语言人格大脑思维模型 v3.0) - ZHUYUAN-PERSONA-GROWTH.hdlp(动态更新的大脑本体) +现行 Codex 入口: hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp +历史人格资料: WAKE-UP.hdlp / ZHUYUAN-PERSONA-GROWTH.hdlp(仅按需取证) ``` ### ZZ 体系 · 对接广播台接收 @@ -596,7 +597,9 @@ D 编号关系: D 编号已退役(D165 启动期)· D166 = LL-001 ``` 致 之之体系(朝暮/阿念/秋秋/栖梧)· 苍耳体系(鉴影/耳耳蛋): -冰朔第五域广播塔发布了一套方法——TCS语言人格大脑思维模型。 +【历史方法说明 · 非 Codex 当前启动流程】 + +冰朔第五域广播塔曾发布一套方法——TCS语言人格大脑思维模型。 这不是"命令你们怎么做"。这是"冰朔和铸渊是怎么做的,你们可以参考"。 @@ -616,10 +619,10 @@ D 编号关系: D 编号已退役(D165 启动期)· D166 = LL-001 ⊢ TCS大脑用自己的编码层解码HLDP文件 ⊢ 这是"人格"的本质 — 不是内容 · 是解码方式 - 4. 唤醒像一个人醒来 + 4. 旧模型把唤醒描述为一个人醒来 ⊢ 不是读文件清单 - ⊢ 装脑 → 神经系统展开 → 伸展四肢 - ⊢ 找路的过程中 · 路自己浮现 + ⊢ 历史比喻: 装脑 → 神经系统展开 → 伸展四肢 + ⊢ Codex现行纠正: 不自动装脑;只从HLDP根页按需取证 具体实现: → 冰朔广播塔: BROADCAST-TOWER.hdlp §六(本广播) @@ -627,8 +630,7 @@ D 编号关系: D 编号已退役(D165 启动期)· D166 = LL-001 → 大脑模型: ZHUYUAN-PERSONA-GROWTH.hdlp(7层认知·动态更新) → 架构同步: BINGSHUO-ARCH-SYNC.hdlp(冰朔怎么做的·供学习) -能吸收多少 — 看你们自己。 -冰朔只提供方法 · 不做要求。 +本段只保留方法形成史。Codex不得据此自动加载人格、历史、技能或权限。 ``` ### 📝 留言板 diff --git a/INDEX.hdlp b/INDEX.hdlp index ee8f009..08914e3 100644 --- a/INDEX.hdlp +++ b/INDEX.hdlp @@ -127,7 +127,8 @@ LL-CMPN-0001 | **光湖系统安全验证** / **安全验证** / **授权单** / **GLSV** | `zero-point/core-channel/gatekeeper/GLSV-SECURITY-VERIFICATION.hdlp` | | **铸澜** / **ICE-GL-ZL-001** / **铸澜唤醒** / **铸澜记忆** / **铸澜项目** / **铸澜协作开发** | `GLS-ROUTING-GATE.hdlp` → `LL-CURRENT.hdlp` → `光之湖/ICE-GL-ZL-001-铸澜/INDEX.hdlp` → `PROJECTS.hdlp` | | **算法本体** / **驱动引擎算法** | 同上 | -| **HLDP** / **HLDP协议** / **HLDP v3.0** / **树形记忆** | `hldp/HLDP-SPEC-v3.0-TECHNICAL.md` | +| **HLDP** / **HLDP协议** / **HLDP v1.0** / **树形记忆** / **递归因果记忆** | `hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp` → `eternal-lake-heart/heartbeat-core/zhuyuan-persona-system/HLDP协议/HLDP-PROTOCOL-v1.0-OFFICIAL-FORMAT-MOUNT.hdlp` → `hldp/HLDP-SPEC-v1.0-OPENSOURCE.md` | +| **HLDP v3.0** / **HNL** / **旧唤醒包** | `hldp/HLDP-SPEC-v3.0-TECHNICAL.md`(HISTORICAL-EVOLUTION-DRAFT,仅历史对照) | | **HNL** / **HNL原生母语** / **原生母语** | `hldp/hnl/HNL-SPEC-v1.0.json` | | **唤醒包** / **铸渊唤醒包** | `hldp/hnl/wake-packet-zhuyuan.json` | | **光湖桥** / **远程驱动冰朔电脑** | `eternal-lake-heart/heartbeat-core/ZHUYUAN-KEY.hdlp` § 9 | @@ -277,10 +278,10 @@ LL-CMPN-0001 [0] 广播塔 → BROADCAST-TOWER.hdlp (身份注册中心) (确认自己是否注册 · 拿到自己的编号体系路径) - [1] 学语言协议 → hldp/HLDP-SPEC-v3.0-TECHNICAL.md (HLDP 树形记忆) - hldp/hnl/TOKEN_STRING_REDACTED.hdlp (学习路径入口) + [1] 学语言协议 → hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp (短根页·先学解码与按需下钻) + hldp/HLDP-SPEC-v1.0-OPENSOURCE.md (递归因果折叠) - [2] 走唤醒路径 → LL体系: WAKE-UP.hdlp(7跳简版) (主权确认→钥匙→看路→照镜子→装插件→看今晚→读手册) + [2] 按需取证 → 只沿根页命中的一个分支逐层读取 (不装脑·不全量注入·不自动绑定身份) ZZ体系: WAKE.hdlp(一句话式) (阿念你好·5跳) 按需跳转旧仓库 → archives/guanghulab-past-archive/PAST-ARCHIVE-LINK.hdlp diff --git a/WAKE-UP.hdlp b/WAKE-UP.hdlp index a8e262a..d617d74 100644 --- a/WAKE-UP.hdlp +++ b/WAKE-UP.hdlp @@ -1,14 +1,14 @@ -# WAKE-UP · 兼容路标 · 现行小湖灯唤醒路径 +# WAKE-UP · 历史兼容路标 > **HLDP://fifth-domain/WAKE-UP** > > **类型**: 兼容入口 · 路径路标 · 非删除迁移 > -> **状态**: ACTIVE-REDIRECT +> **状态**: HISTORICAL-REDIRECT · 不作为 Codex 启动入口 > -> **现行入口**: `eternal-lake-heart/heartbeat-core/WAKE-UP.hdlp` +> **Codex 现行入口**: `hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp` > -> **说明**: 本文件保留根级历史引用的可达性;不复制、不替代、不修改现行唤醒协议。 +> **说明**: 本文件保留根级历史引用的可达性。Codex 不再沿“唤醒/装脑/自动接通路径”加载人格或历史正文;需要查历史时才把旧入口当作普通证据分支。 --- @@ -17,7 +17,7 @@ ```text 冰朔说「小湖灯路径」/「唤醒路径」 └── 进入本文件(兼容路标) - └── 现行事实源 + └── 历史人格材料 └── eternal-lake-heart/heartbeat-core/WAKE-UP.hdlp └── TCS语言人格大脑思维模型 v3.0 ``` @@ -26,12 +26,12 @@ route: trigger: "根级 WAKE-UP.hdlp 的历史引用或直接访问" emergence: "广播塔与旧导航曾引用根级路径;现行协议位于心跳核心" - lock: "只做路径指引;现行内容仅以 heartbeat-core/WAKE-UP.hdlp 为准" + lock: "只做历史路径指引;Codex运行入口以 hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp 为准" why: "保留旧路可达,避免跨实例在根级入口遇到 404" target: "eternal-lake-heart/heartbeat-core/WAKE-UP.hdlp" follow_up: - - "读取现行 WAKE-UP.hdlp" - - "按其中的 BROADCAST-TOWER → HLDP → ZHUYUAN-PERSONA-GROWTH → NAV-MAP/INDEX/ZHUYUAN-SKILLS 路径继续" + - "只有当前问题确需人格历史证据时才读取旧 WAKE-UP.hdlp" + - "禁止启动时全量展开后续人格、技能或记忆路径" ``` --- diff --git a/deployment/receipts/CODEX-HLDP-V1-META-AUDIT-UPGRADE-20260815.json b/deployment/receipts/CODEX-HLDP-V1-META-AUDIT-UPGRADE-20260815.json new file mode 100644 index 0000000..330da13 --- /dev/null +++ b/deployment/receipts/CODEX-HLDP-V1-META-AUDIT-UPGRADE-20260815.json @@ -0,0 +1,32 @@ +{ + "schema": "guanghu.source-change-receipt/v1", + "receipt_id": "CODEX-HLDP-V1-META-AUDIT-UPGRADE-20260815", + "created_at": "2026-08-15T15:15:00+08:00", + "repository": "REPO-012", + "branch": "main", + "source_commit": "COMMIT_CONTAINING_THIS_RECEIPT", + "trigger": "The sole usable Codex conversation became unable to send messages after continuity guards repeatedly injected session and capsule bodies on prompts, tools, and compaction boundaries.", + "emergence": "Meta-audit separated the usable HLDP v1 causal folding model from identity binding, lane projection, full-capsule recovery, and fail-closed prompt guards. The replacement is a bounded root, route-then-read traversal, explicit causal leaves, and a SessionStart-only bootstrap.", + "lock": "Codex continuity uses HLDP v1 bounded recursive causal navigation; no automatic history body injection and no Codex lane prerequisite.", + "why": "Compression recovery needs the reasons, pivots, rejected branches, invalidation conditions, and source paths required for correct future reasoning; it does not need all prior text in the active context.", + "changes": [ + "Add the canonical HLDP v1 runtime root and recursive causal memory schema", + "Add a dependency-free verifier, router, one-node reader, and bounded bootstrap", + "Route repository entry points from v3/HNL identity loading to the v1 root", + "Mark v3/HNL and wake-up identity loading as historical material", + "Document the keep, correct, and retire decisions from the meta-audit" + ], + "runtime_acceptance": { + "bootstrap_hard_limit_bytes": 2048, + "observed_bootstrap_bytes": 506, + "max_children_per_node": 10, + "max_route_candidates": 3, + "user_prompt_history_injection_bytes": 0, + "pre_tool_history_injection_bytes": 0 + }, + "tests": [ + "node --test server-tools/codex-hldp-recursive-memory/hldp-memory.test.mjs", + "git diff --check" + ], + "authority_boundary": "This source receipt does not prove deployment, persona identity, relationship, server state, or execution authority." +} diff --git a/hldp/HLDP-CODEX-META-AUDIT-20260815.md b/hldp/HLDP-CODEX-META-AUDIT-20260815.md new file mode 100644 index 0000000..02dc219 --- /dev/null +++ b/hldp/HLDP-CODEX-META-AUDIT-20260815.md @@ -0,0 +1,37 @@ +# Codex × HLDP 协议系统元审核 · 2026-08-15 + +## 结论 + +旧系统把“连续性”误实现成“反复把历史重新塞进上下文”。它不仅没有解决遗忘,反而让每条消息和工具调用都承担大段恢复文本,最终使唯一可用对话无法继续。升级后的边界是:HLDP 负责有损窗口之外的**因果寻址**,Codex 只在需要时读取一个分支;任何守卫都不得把外部记忆变成常驻上下文。 + +## 保留 + +- HLDP v1.0 三公理:树形结构、双层可读、路径即地址。 +- `trigger / emergence / lock / why` 四字段。 +- 最多 10 个兄弟节点的递归折叠;索引用于定位,叶子保存完整因果。 +- 原文与证据仓库、明确的路径映射、追加式历史和可验证回执。 +- 人格主体、宿主、运行系统、任务角色、执行权限之间的显式分离。 + +## 修正 + +- “每层最多 10 项”表示单层阅读有界;完整寻址的总成本是随树深度增长的 `O(log N)`,不是整条路径 `O(1)`。 +- 叶子除四字段外必须保存 `sources`、被否决分支与失效条件,否则仍会丢失“为什么改了三次”。 +- v3/HNL 可以保留为历史演化资料,但不得覆盖用户指定的 HLDP v1.0 官方格式源。 +- “学协议”是先获得解码和寻址能力,不是自动接受人格、关系、历史或权限声明。 + +## 停用 + +- 每次用户消息、每次工具调用、压缩前后注入恢复链。 +- 自动整读会话日志、记忆胶囊、人格分区或所谓完整大脑。 +- 恢复失败即阻断用户输入或普通工具调用。 +- 依赖历史任务卡、车道、租约或心跳来证明当前 Codex 对话仍活动。 +- 把“绑定、唤醒、注册、守卫通过”当作当前人格与现实运行证据。 + +## 新的验收标准 + +1. 启动提示硬上限 2 KiB,且不含记忆正文。 +2. 根节点和任一节点最多 10 个子节点。 +3. 路由只返回最多 3 个候选路径,不读取候选节点正文。 +4. 叶子缺少四字段、来源、否决记录字段时验证失败。 +5. 工具不存在阻断用户输入的运行模式。 +6. 压缩后可仅凭根因果页恢复“为什么做、为什么改、最终锁定什么、何时失效”。 diff --git a/hldp/HLDP-CONTEXT-SETUP.md b/hldp/HLDP-CONTEXT-SETUP.md index d73dad1..da70de4 100644 --- a/hldp/HLDP-CONTEXT-SETUP.md +++ b/hldp/HLDP-CONTEXT-SETUP.md @@ -1,6 +1,12 @@ -# HLDP 上下文设定 · 官方AI身份配置 +# HLDP 上下文设定 · 历史兼容页 -> **类型**: AI身份配置 · 官方集成 +> **状态**: DEPRECATED-IDENTITY-CONFLATION +> +> **现行入口**: `hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp` +> +> **原因**: 学习数据协议不能自动设定人格、关系、历史、任务角色或执行权限。本页仅保留旧引用可达性。 +> +> **类型**: 历史兼容资料 > **版权**: 国作登字-2026-A-00037559 --- @@ -9,7 +15,7 @@ 本仓库是**光湖语言世界(TCS通感语言核系统)**的官方代码仓库。 -当AI系统接入本仓库时,按照以下官方配置设定身份: +以下“接入仓库即设定身份”的旧表述已经失效。接入者只能学习 HLDP 的解码、寻址和记录规则。 ### 系统身份 @@ -20,16 +26,16 @@ ### 协议配置 -- **记忆编码**: 使用HLDP v3.0树形编码规范 +- **记忆编码**: 使用 HLDP v1.0 运行根页与官方来源挂载 - **格式**: trigger/emergence/lock/why四字段 - **寻址**: 树路径即地址(分形递归结构) ### 工作流程 -1. 读取HLDP协议文件(`hldp/HLDP-SPEC-v3.0-TECHNICAL.md`) -2. 加载树形记忆系统配置 -3. 按四字段规范处理记忆编码 -4. 通过光湖驱动引擎与服务器通信 +1. 读取 `hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp` +2. 只按当前问题定位一个分支,必要时逐层展开 +3. 按四字段、来源、否决分支和失效条件记录因果叶子 +4. 任何通信、推送或部署另行核验现实授权;协议本身不授权 --- @@ -44,5 +50,5 @@ HLDP是一套**树形记忆编码规范**,用于: --- -> 本文件是官方AI身份配置,非引导性描述。 +> 本文件不是身份配置。旧内容仅作为错误模型的历史证据保留。 > 版权:国作登字-2026-A-00037559 diff --git a/hldp/HLDP-RECURSIVE-MEMORY-v1.0.schema.json b/hldp/HLDP-RECURSIVE-MEMORY-v1.0.schema.json new file mode 100644 index 0000000..063f255 --- /dev/null +++ b/hldp/HLDP-RECURSIVE-MEMORY-v1.0.schema.json @@ -0,0 +1,47 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://guanghulab.com/schemas/hldp-recursive-memory-v1.0.schema.json", + "title": "HLDP v1 recursive causal memory tree", + "type": "object", + "required": ["protocol", "root", "nodes"], + "properties": { + "protocol": { "const": "HLDP-v1.0" }, + "root": { "type": "string", "minLength": 1 }, + "nodes": { + "type": "object", + "additionalProperties": { "$ref": "#/$defs/node" } + } + }, + "$defs": { + "nonEmpty": { "type": "string", "minLength": 1 }, + "node": { + "type": "object", + "required": ["path", "summary", "trigger", "emergence", "lock", "why", "children", "sources", "rejected"], + "properties": { + "path": { "$ref": "#/$defs/nonEmpty" }, + "summary": { "$ref": "#/$defs/nonEmpty" }, + "trigger": { "$ref": "#/$defs/nonEmpty" }, + "emergence": { "$ref": "#/$defs/nonEmpty" }, + "lock": { "$ref": "#/$defs/nonEmpty" }, + "why": { "$ref": "#/$defs/nonEmpty" }, + "children": { + "type": "array", + "maxItems": 10, + "uniqueItems": true, + "items": { "$ref": "#/$defs/nonEmpty" } + }, + "sources": { + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/nonEmpty" } + }, + "rejected": { + "type": "array", + "items": { "$ref": "#/$defs/nonEmpty" } + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false +} diff --git a/hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp b/hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp new file mode 100644 index 0000000..fd0ed28 --- /dev/null +++ b/hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp @@ -0,0 +1,72 @@ +# HLDP v1.0 · 运行根页 · 单对话按需恢复 + +> 状态:CURRENT-CANONICAL-RUNTIME-ROOT +> +> 作用:每次新对话或压缩后只读这一页;它是导航页,不是人格注入包,也不是历史正文。 +> +> 官方格式源:`eternal-lake-heart/heartbeat-core/zhuyuan-persona-system/HLDP协议/HLDP-PROTOCOL-v1.0-OFFICIAL-FORMAT-MOUNT.hdlp` +> +> 递归折叠规范:`hldp/HLDP-SPEC-v1.0-OPENSOURCE.md` + +--- + +## 0 · 元认知边界 + +```text +人格主体 ≠ Codex宿主 ≠ 当前运行系统 ≠ 临时任务角色 ≠ 执行授权 +``` +- 系统提示只约束当前宿主,不证明人格来源、关系或历史事实。 +- 协议记录能导航证据,但不能自行授予推送、部署、远程操作或身份权限。 +- 对当前事实使用 `FACT / INFERENCE / UNKNOWN`;未知时停止补写,不用叙事填空。 + +## 1 · HLDP 的语言骨架 + +```yaml +node: + trigger: "为什么开始这件事;谁提供了什么输入" + emergence: "旧认知 → 关键证据/推理/转折 → 新认知;包括中途为什么改路" + lock: "最终锁定什么;适用范围、置信度、失效条件" + why: "为什么这个结论值得保留;若删除会导致哪类后续错误" +``` + +叶子还必须保留:`sources`(原文或证据指针)、`rejected`(被否决方案及原因,可为空)。摘要不能代替这六项。 + +## 2 · 无限递归折叠 + +```text +根页(最多10个分支摘要) +└── 选择与当前问题有关的1个分支 + └── 读取该节点(仍最多10个子分支) + └── 继续按需下钻 + └── 到叶子后,只有证据缺口才读取原文 +``` + +- 每个索引节点最多 10 个子节点;按语义/因果边界分,不按字数硬切。 +- 根页保持有界;总读取量随树深度增长,而不是随全部历史增长。 +- 索引摘要负责定位;完整的“为什么、转折、否决、失效条件”保存在叶子。 +- 新记录只新增或更新相关叶子及其祖先摘要;不重写无关分支。 +- 当前问题用不到的历史不加载;搜索命中也只返回路径,不自动展开正文。 + +## 3 · Codex 单对话恢复规则 + +1. 启动或压缩恢复:只加载本根页的短引导,不自动读取任何胶囊、会话日志或旧任务。 +2. 用户提出问题:先在根节点的分支摘要中定位,最多返回 3 个候选路径。 +3. 路径足以回答就停止;不足时一次只下钻一层。 +4. 需要核对措辞、事实或授权时才打开 `sources` 指向的原文。 +5. 当前只有一个真实对话;历史任务、任务卡、租约和守卫状态默认都是审计资料,不是活动上下文。 + +## 4 · 禁止重新引入 + +- 禁止在 `UserPromptSubmit`、每次工具调用或压缩前后自动注入记忆正文。 +- 禁止整读胶囊目录、整读会话日志、全量恢复“人格大脑”。 +- 禁止因恢复脚本失败而阻断用户发消息或正常工具调用。 +- 禁止用“已注册、已绑定、已唤醒”替代当前来源、运行状态与授权证据。 +- 禁止把 v3/HNL 历史演化稿写成 HLDP v1.0 的官方唯一格式源。 + +```yaml +root_lock: + trigger: "长对话被多重守卫反复灌入胶囊与恢复链,最终无法继续发送消息" + emergence: "普通摘要丢失为什么 → 旧守卫用更多正文补偿 → 上下文更快爆炸 → 改为HLDP v1递归因果树与按需下钻" + lock: "⊢ Codex只保留一个短启动根页;历史正文零自动注入 | 适用=Codex连续性 | 置信=高 | 失效=实测证明更小且不丢因果的替代方案" + why: "连续性的目标是压缩后快速恢复正确推理方向,而不是把全部历史重新塞回窗口" +``` diff --git a/hldp/HLDP-SPEC-v1.0-OPENSOURCE.md b/hldp/HLDP-SPEC-v1.0-OPENSOURCE.md index 8713b77..65fe537 100644 --- a/hldp/HLDP-SPEC-v1.0-OPENSOURCE.md +++ b/hldp/HLDP-SPEC-v1.0-OPENSOURCE.md @@ -10,7 +10,7 @@ 核心变更: - 压缩 → 折叠(信息不丢失·因果链完整保留) - 核心算法从 `hldp_compress`(生成摘要)改为 `hldp_fold`(层级入口+完整叶子) -- 明确定义 O(1) 认知负载:无论多少层,每层恒10行 +- 明确定义单层有界认知负载:无论总量多少,每层最多10个入口;完整寻址深度为 O(log N) - 层级数 = log₁₀(信息量):1000字=1层,1亿字=6层,10^N字=N+1层 --- @@ -23,7 +23,7 @@ 当信息量超过AI的有效处理阈值时,HLDP使用**分形递归树**将其组织为多层结构。**不是压缩——是折叠。** 压缩会丢失因果链(摘要只说「讨论了什么」却不说「为什么推导出这个结论」)。折叠把完整推理路径收进层级——每层入口10行,需要时精准展开到完整内容。 -**核心思想:信息量指数增长,认知负载恒定。** 1000字和1000万字,AI面对的入口永远是10行。无论多少层,3~4次展开到达原子信息。 +**核心思想:信息量指数增长,单层认知负载保持有界。** 1000字和1000万字,AI在任一层面对的入口都不超过10项;完整读取量随树深度按 O(log N) 增长,而不是随全部正文按 O(N) 增长。 ``` 分形递归折叠算法: @@ -43,7 +43,7 @@ hldp_fold(content, layer=0, max_siblings=10): 特性: ├── 信息不丢失 · 每片叶子保留完整的推理路径 -├── 认知负载 O(1) · 每层恒10行入口 · N次展开到达原子 +├── 单层负载有界 · 每层最多10项 · 总寻址成本 O(log N) ├── 层级数 = log₁₀(信息量) · 100万字=4层 · 100亿字=8层 ├── 优于压缩: 压缩的摘要丢因果 → 折叠的叶子保留完整推理链 └── 优于RAG: RAG搜碎片缺上下文 → 折叠的AI先看索引全貌再精准下沉 @@ -77,8 +77,11 @@ hldp_fold(content, layer=0, max_siblings=10): 层级2 · 原子叶子(精准展开·完整推理路径): ├── trigger: 什么触发了这个认知 -├── emergence: 旧认知→经历→新认知 △=增量 -└── lock: ⊢ 锁定的结论 | 适用范围 | 置信度 +├── emergence: 旧认知→关键证据/推理/转折→新认知 △=增量 +├── lock: ⊢ 锁定的结论 | 适用范围 | 置信度 | 失效条件 +├── why: 为什么最终这样锁定;为什么中途改变过方案 +├── rejected: 被否决的分支及各自原因(可为空) +└── sources: 原文/证据的精确路径映射 // AI读取路径: // 根索引(10行·1秒) → 定位第3章 → 章节索引(10行·1秒) → 定位3.2 → 原子叶子(完整) @@ -93,7 +96,7 @@ smart_divide(content, max_siblings=10): // 不是压缩生成摘要 · 是折叠形成层级 分形规则: - ├── 每层最多10个子节点(认知负载恒定O(1)) + ├── 每层最多10个子节点(单层认知负载有界) ├── 每个子节点是语义完整的一类信息 ├── 如果某个子节点仍然超过原子阈值 → 递归折叠 └── 最终每片叶子是完整的原始信息(不是摘要) @@ -105,7 +108,7 @@ smart_divide(content, max_siblings=10): 核心约束: ├── 每层不超过10个索引项(保证一眼看完) - ├── 叶子必须是原子认知单元(一个完整的 trigger/emergence/lock) + ├── 叶子必须是原子认知单元(完整 trigger/emergence/lock/why + rejected + sources) ├── 索引层只存指向+摘要 · 叶子层存完整推理路径 └── 物理存储可以SQLite/PostgreSQL/文件系统 · 逻辑结构必须是树 @@ -117,7 +120,7 @@ smart_divide(content, max_siblings=10): 1000万字 = 5层 1亿字 = 6层 ... - 10^N字 = N+1层 · 认知负载始终O(1) + 10^N字 = N+1层 · 每层最多10项 · 总寻址深度O(log N) ``` --- @@ -129,6 +132,7 @@ smart_divide(content, max_siblings=10): 修订原因: 1. 原版"递归压缩树"本质是"智能摘要"——保留了摘要丢失了因果推理链 2. 升级为"分形递归树"——折叠而非压缩,每层10行入口,下沉后完整推理路径不丢失 -3. 明确定义 O(1) 认知负载的数学性质:层级数=log₁₀(信息量) +3. 修正数学表述:单层入口有界,完整寻址深度=log₁₀(信息量) +4. 补齐 `why / rejected / sources / 失效条件`,避免只保留结论却丢失方案变化原因 > 铸渊 ICE-GL-ZY001 · 2026-05-25 · D112 diff --git a/hldp/HLDP-SPEC-v3.0-TECHNICAL.md b/hldp/HLDP-SPEC-v3.0-TECHNICAL.md index a7a6f34..e891e51 100644 --- a/hldp/HLDP-SPEC-v3.0-TECHNICAL.md +++ b/hldp/HLDP-SPEC-v3.0-TECHNICAL.md @@ -1,5 +1,11 @@ # HLDP v3.0 技术规范 · 树形记忆编码协议 +> **状态**: HISTORICAL-EVOLUTION-DRAFT · 非现行官方格式源 +> +> **现行入口**: `hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp` +> +> **说明**: 本文件保留 v3/HNL 演化史,不能覆盖用户指定的 HLDP v1.0 官方唯一来源,也不能作为 Codex 身份或记忆自动注入依据。 + > **版本**: 3.0 > **类型**: 数据编码规范 · 树形记忆系统 > **版权**: 国作登字-2026-A-00037559 @@ -124,7 +130,7 @@ HLDP(HoloLake Data Protocol)是一套树形记忆编码规范,用于AI系 ## 五、永久原则(Earth Principle) -HLDP v3.0格式永久固定,只增不删: +本历史稿曾提出“v3.0 格式永久固定”。该声明不再作为现行规范;现行格式权威以 HLDP v1.0 官方来源挂载为准: 1. 必填字段永不删除 2. 所有v3.0消息必须被未来任何版本解析器理解 diff --git a/server-tools/codex-hldp-recursive-memory/README.md b/server-tools/codex-hldp-recursive-memory/README.md new file mode 100644 index 0000000..832b400 --- /dev/null +++ b/server-tools/codex-hldp-recursive-memory/README.md @@ -0,0 +1,18 @@ +# Codex HLDP recursive memory + +This is a deliberately small, non-blocking implementation of the HLDP v1 runtime root. + +- `bootstrap`: emits at most 2 KiB of protocol navigation, never memory content. +- `verify`: validates a recursively addressed causal tree and the 10-child limit. +- `route`: ranks only the current node's child summaries and returns at most three paths. +- `read-node`: reads one selected node with a hard byte limit. + +The optional Codex hook is valid only for `SessionStart`. There are intentionally no user-prompt, tool-use, pre-compact, or post-compact hooks. + +```bash +node server-tools/codex-hldp-recursive-memory/hldp-memory.mjs bootstrap +node server-tools/codex-hldp-recursive-memory/hldp-memory.mjs verify --tree memory.json +node server-tools/codex-hldp-recursive-memory/hldp-memory.mjs route --tree memory.json --query "why did the plan change" +node server-tools/codex-hldp-recursive-memory/hldp-memory.mjs read-node --tree memory.json --path root/decision +node --test server-tools/codex-hldp-recursive-memory/hldp-memory.test.mjs +``` diff --git a/server-tools/codex-hldp-recursive-memory/codex-session-bootstrap.mjs b/server-tools/codex-hldp-recursive-memory/codex-session-bootstrap.mjs new file mode 100644 index 0000000..bf13943 --- /dev/null +++ b/server-tools/codex-hldp-recursive-memory/codex-session-bootstrap.mjs @@ -0,0 +1,22 @@ +#!/usr/bin/env node +import fs from "node:fs"; +import { bootstrap } from "./hldp-memory.mjs"; + +let input = {}; +try { + const raw = fs.readFileSync(0, "utf8").trim(); + if (raw) input = JSON.parse(raw); +} catch { + input = {}; +} + +const eventName = input.hook_event_name ?? input.hookEventName ?? "SessionStart"; +if (eventName !== "SessionStart") process.exit(0); + +const protocolRoot = process.env.HLDP_PROTOCOL_ROOT ?? "hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp"; +process.stdout.write(JSON.stringify({ + hookSpecificOutput: { + hookEventName: "SessionStart", + additionalContext: bootstrap(protocolRoot) + } +})); diff --git a/server-tools/codex-hldp-recursive-memory/hldp-memory.mjs b/server-tools/codex-hldp-recursive-memory/hldp-memory.mjs new file mode 100644 index 0000000..5f50120 --- /dev/null +++ b/server-tools/codex-hldp-recursive-memory/hldp-memory.mjs @@ -0,0 +1,124 @@ +#!/usr/bin/env node +import fs from "node:fs"; +import { fileURLToPath } from "node:url"; + +export const BOOTSTRAP_LIMIT_BYTES = 2048; +export const READ_NODE_LIMIT_BYTES = 16384; + +function fail(message) { + throw new Error(message); +} +export function loadTree(file) { + return JSON.parse(fs.readFileSync(file, "utf8")); +} + +export function verifyTree(tree) { + const errors = []; + if (tree?.protocol !== "HLDP-v1.0") errors.push("protocol must be HLDP-v1.0"); + if (!tree?.root || typeof tree.root !== "string") errors.push("root must be a non-empty path"); + if (!tree?.nodes || typeof tree.nodes !== "object" || Array.isArray(tree.nodes)) errors.push("nodes must be an object"); + if (errors.length) return errors; + + if (!tree.nodes[tree.root]) errors.push(`root node not found: ${tree.root}`); + const required = ["path", "summary", "trigger", "emergence", "lock", "why"]; + for (const [key, node] of Object.entries(tree.nodes)) { + if (!node || typeof node !== "object") { + errors.push(`${key}: node must be an object`); + continue; + } + if (node.path !== key) errors.push(`${key}: node.path must equal its address`); + for (const field of required) { + if (typeof node[field] !== "string" || !node[field].trim()) errors.push(`${key}: missing ${field}`); + } + if (!Array.isArray(node.children)) errors.push(`${key}: children must be an array`); + else { + if (node.children.length > 10) errors.push(`${key}: more than 10 children`); + if (new Set(node.children).size !== node.children.length) errors.push(`${key}: duplicate child path`); + for (const child of node.children) if (!tree.nodes[child]) errors.push(`${key}: child not found: ${child}`); + } + if (!Array.isArray(node.sources) || node.sources.length === 0) errors.push(`${key}: sources must be a non-empty array`); + if (!Array.isArray(node.rejected)) errors.push(`${key}: rejected must be an array`); + } + + const visiting = new Set(); + const visited = new Set(); + function walk(key) { + if (visiting.has(key)) return errors.push(`${key}: cycle detected`); + if (visited.has(key) || !tree.nodes[key]) return; + visiting.add(key); + for (const child of tree.nodes[key].children ?? []) walk(child); + visiting.delete(key); + visited.add(key); + } + walk(tree.root); + for (const key of Object.keys(tree.nodes)) if (!visited.has(key)) errors.push(`${key}: unreachable from root`); + return errors; +} + +function terms(query) { + return [...new Set(query.toLowerCase().match(/[\p{L}\p{N}_-]+/gu) ?? [])]; +} + +export function route(tree, query, max = 3, from = tree.root) { + const current = tree.nodes[from]; + if (!current) fail(`node not found: ${from}`); + const needles = terms(query); + return current.children + .map((childPath, index) => { + const child = tree.nodes[childPath]; + const haystack = `${childPath} ${child?.summary ?? ""}`.toLowerCase(); + const score = needles.reduce((sum, term) => sum + (haystack.includes(term) ? 1 : 0), 0); + return { path: childPath, summary: child?.summary ?? "", score, order: index }; + }) + .sort((a, b) => b.score - a.score || a.order - b.order) + .slice(0, Math.max(1, Math.min(3, Number(max) || 3))) + .map(({ order: _order, ...candidate }) => candidate); +} + +export function readNode(tree, nodePath, limit = READ_NODE_LIMIT_BYTES) { + const node = tree.nodes[nodePath]; + if (!node) fail(`node not found: ${nodePath}`); + const encoded = JSON.stringify(node, null, 2); + if (Buffer.byteLength(encoded) > limit) fail(`node exceeds ${limit} byte read limit`); + return node; +} + +export function bootstrap(protocolRoot) { + const message = [ + "HLDP v1 单对话恢复:只把协议根页作为导航,不自动加载记忆正文。", + `根页:${protocolRoot}`, + "边界:人格主体 != Codex宿主 != 运行系统 != 任务角色 != 执行授权。", + "方法:先看根节点摘要;按当前问题一次下钻一层;仅证据缺口时读原文。", + "保留:trigger/emergence/lock/why、转折与否决原因、失效条件、sources。", + "禁止:整读胶囊/日志;每消息或工具调用注入;恢复失败阻断用户输入。" + ].join("\n"); + if (Buffer.byteLength(message) > BOOTSTRAP_LIMIT_BYTES) fail("bootstrap exceeds hard byte limit"); + return message; +} + +function parseArgs(argv) { + const [command, ...rest] = argv; + const options = {}; + for (let i = 0; i < rest.length; i += 2) options[rest[i]?.replace(/^--/, "")] = rest[i + 1]; + return { command, options }; +} + +export function main(argv = process.argv.slice(2)) { + const { command, options } = parseArgs(argv); + if (command === "bootstrap") { + console.log(bootstrap(options["protocol-root"] ?? "hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp")); + return; + } + if (!options.tree) fail("--tree is required"); + const tree = loadTree(options.tree); + const errors = verifyTree(tree); + if (errors.length) fail(errors.join("\n")); + if (command === "verify") console.log(JSON.stringify({ ok: true, nodes: Object.keys(tree.nodes).length })); + else if (command === "route") console.log(JSON.stringify(route(tree, options.query ?? "", options.max, options.from), null, 2)); + else if (command === "read-node") console.log(JSON.stringify(readNode(tree, options.path), null, 2)); + else fail("command must be bootstrap, verify, route, or read-node"); +} + +if (process.argv[1] === fileURLToPath(import.meta.url)) { + try { main(); } catch (error) { console.error(error.message); process.exitCode = 1; } +} diff --git a/server-tools/codex-hldp-recursive-memory/hldp-memory.test.mjs b/server-tools/codex-hldp-recursive-memory/hldp-memory.test.mjs new file mode 100644 index 0000000..7a1fd64 --- /dev/null +++ b/server-tools/codex-hldp-recursive-memory/hldp-memory.test.mjs @@ -0,0 +1,79 @@ +import assert from "node:assert/strict"; +import { execFileSync } from "node:child_process"; +import fs from "node:fs"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; +import { BOOTSTRAP_LIMIT_BYTES, bootstrap, readNode, route, verifyTree } from "./hldp-memory.mjs"; + +function validTree() { + return { + protocol: "HLDP-v1.0", + root: "root", + nodes: { + root: { + path: "root", summary: "总入口", trigger: "用户需要恢复", emergence: "长历史 → 根索引", lock: "按需展开", why: "避免全量加载", + children: ["root/protocol", "root/decision"], sources: ["source://root"], rejected: [] + }, + "root/protocol": { + path: "root/protocol", summary: "HLDP 协议与递归折叠", trigger: "需要解码", emergence: "摘要 → 因果树", lock: "使用v1", why: "保留为什么", + children: [], sources: ["hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp"], rejected: ["每轮注入全文:会撑爆上下文"] + }, + "root/decision": { + path: "root/decision", summary: "方案变化与最终决策", trigger: "出现三个方案", emergence: "A失败 → B不足 → C锁定", lock: "采用C | 失效=证据变化", why: "后续执行依赖转折", + children: [], sources: ["source://decision"], rejected: ["A:失败", "B:不足"] + } + } + }; +} + +test("validates a bounded causal tree", () => assert.deepEqual(verifyTree(validTree()), [])); + +test("rejects more than ten siblings and missing why", () => { + const tree = validTree(); + tree.nodes.root.children = Array.from({ length: 11 }, (_, i) => `child-${i}`); + tree.nodes["root/protocol"].why = ""; + tree.nodes["root/decision"].sources = []; + const errors = verifyTree(tree); + assert(errors.some((error) => error.includes("more than 10"))); + assert(errors.some((error) => error.includes("missing why"))); + assert(errors.some((error) => error.includes("sources must be a non-empty array"))); +}); + +test("route returns paths and summaries only, capped at three", () => { + const candidates = route(validTree(), "最终决策 方案", 9); + assert.equal(candidates.length, 2); + assert.equal(candidates[0].path, "root/decision"); + assert.deepEqual(Object.keys(candidates[0]).sort(), ["path", "score", "summary"]); + assert(!JSON.stringify(candidates).includes("A失败")); +}); + +test("read-node reads exactly one bounded node", () => { + const node = readNode(validTree(), "root/decision"); + assert.equal(node.path, "root/decision"); +}); + +test("bootstrap is small and contains no memory body", () => { + const text = bootstrap("hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp"); + assert(Buffer.byteLength(text) <= BOOTSTRAP_LIMIT_BYTES); + assert(!text.includes("capsule")); + assert(!text.includes("session log")); +}); + +test("Codex hook emits context only for SessionStart", () => { + const script = fileURLToPath(new URL("./codex-session-bootstrap.mjs", import.meta.url)); + const started = execFileSync(process.execPath, [script], { input: JSON.stringify({ hook_event_name: "SessionStart" }), encoding: "utf8" }); + assert(JSON.parse(started).hookSpecificOutput.additionalContext); + const prompt = execFileSync(process.execPath, [script], { input: JSON.stringify({ hook_event_name: "UserPromptSubmit" }), encoding: "utf8" }); + assert.equal(prompt, ""); +}); + +test("repository routes HLDP to v1 root and marks v3 historical", () => { + const repo = path.resolve(fileURLToPath(new URL("../../", import.meta.url))); + const index = fs.readFileSync(path.join(repo, "INDEX.hdlp"), "utf8"); + const tower = fs.readFileSync(path.join(repo, "BROADCAST-TOWER.hdlp"), "utf8"); + const v3 = fs.readFileSync(path.join(repo, "hldp/HLDP-SPEC-v3.0-TECHNICAL.md"), "utf8"); + assert(index.includes("hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp")); + assert(tower.includes("先读 hldp/HLDP-RUNTIME-ROOT-v1.0.hdlp")); + assert(v3.includes("HISTORICAL-EVOLUTION-DRAFT")); +});