Skip to content

feat(core): 三连逆向借鉴的独立模块 - Claude Code/Codex/PenguinHarness - #181

Open
raymondginger2018-sudo wants to merge 4 commits into
HKUDS:mainfrom
raymondginger2018-sudo:pr/reverse-landing
Open

feat(core): 三连逆向借鉴的独立模块 - Claude Code/Codex/PenguinHarness#181
raymondginger2018-sudo wants to merge 4 commits into
HKUDS:mainfrom
raymondginger2018-sudo:pr/reverse-landing

Conversation

@raymondginger2018-sudo

@raymondginger2018-sudo raymondginger2018-sudo commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

概述

从三个开源 coding agent 的逆向分析中提炼的独立新模块(零依赖 core 其他改动,可直接在 upstream 架构上运行):

模块 借鉴来源 功能
core/harness/classifier.py Claude Code Auto-mode LLM 风险分类器 (env: DEEPCODE_RISK_CLASSIFIER)
core/keyring.py Codex keyring-store 系统密钥环 + JSON 兜底 (env: DEEPCODE_KEYRING)
core/memory_distill.py Claude Code autoDream / Codex Phase-1 会话→cerebellum 记忆桥接 + secrets 脱敏 + 结构化提取
core/observability/events.py Claude Code 遥测 规范命名事件 EventName/emit_event
core/loop/goal_file.py PenguinHarness goal-file GOAL.yaml 模型可写状态协议 (信箱+容错归一化)
core/loop/optimizer.py PenguinHarness agent-optimization 自进化接受/回滚闭环
core/loop/evaluation.py PenguinHarness agent-evaluation 评测隔离协议 (public/private + 快照变更检测)
core/loop/cerebellum_optimizer.py PenguinHarness 端到端 skill 进化闭环 (提案→apply→MRR→接受/回滚)

设计要点

  • 全部独立: 不修改任何 upstream 现有文件, 新模块自包含
  • 无硬编码路径: 外部依赖 (cerebellum) 走 env 覆盖 + 仓库相对解析, 缺失时优雅降级
  • 可观测: events.py 提供统一事件入口

测试

97 个测试 (8 个新测试文件), 全部通过, 基于 upstream/main 验证

@raymondginger2018-sudo
raymondginger2018-sudo force-pushed the pr/reverse-landing branch 3 times, most recently from 6ce4fe9 to 485c993 Compare August 16, 2026 00:20
@raymondginger2018-sudo raymondginger2018-sudo changed the title feat(core): ??????????? - Claude Code/Codex/PenguinHarness feat(core): 三连逆向借鉴的独立模块 - Claude Code/Codex/PenguinHarness Aug 16, 2026
@Zongwei9888

Copy link
Copy Markdown
Collaborator

感谢这份工作量可观的贡献!已在最新 main(合并后)上试合验证:无冲突,全量 1572 passed(含你新增的约 97 个用例),ruff 通过。

全部为新增文件、不修改任何既有代码,并且用环境变量(DEEPCODE_RISK_CLASSIFIERDEEPCODE_KEYRING)做了开关 —— 这个边界处理得很好,对 review 和回滚都友好。

一个流程上的建议:8 个模块放在同一个 PR 里(+3031 行)评审周期会比较长。如果能拆成几个独立 PR(例如 keyring / classifier / loop 系列分开),我们可以更快逐个合入,你也不必等最慢的那一个。

raymondginger2018-sudo pushed a commit to raymondginger2018-sudo/DeepCode that referenced this pull request Aug 19, 2026
- 恢复 cerebellum_optimizer.py / events.py 为 HKUDS#181 版本(P1 提交不修改 HKUDS#181 新文件)
- 新增 core/loop/retrieval_evaluation.py: split_held_out_qa / evaluate_retrieval / cerebellum 适配器 (自包含 _import_cerebellum)
- test_retrieval_evaluation.py 改引 retrieval_evaluation
从三连逆向分析(Claude Code v2.1.233 / Codex v0.145.0 / PenguinHarness)提炼的独立新模块,全部零依赖 core 其他改动,可直接在 upstream 架构上运行:

- core/harness/classifier.py: LLM 风险分类器 (env: DEEPCODE_RISK_CLASSIFIER) — Claude Code Auto-mode 借鉴
- core/keyring.py: 系统密钥环 + JSON 兜底 (env: DEEPCODE_KEYRING) — Codex keyring-store 借鉴
- core/memory_distill.py: 会话→cerebellum 记忆桥接 + secrets 脱敏 + Phase-1 结构化提取 (env: DEEPCODE_MEMORY_DISTILL / DEEPCODE_MEMORY_DISTILL_STRUCTURED / DEEPCODE_CEREBELLUM_SCHEDULER)
- core/observability/events.py: 规范命名事件 EventName/emit_event — Claude Code 遥测借鉴
- core/loop/goal_file.py: GOAL.yaml 模型可写状态协议 (信箱+容错归一化) — PenguinHarness 借鉴
- core/loop/optimizer.py: ArtifactOptimizer 自进化接受/回滚闭环 — PenguinHarness agent-optimization 借鉴
- core/loop/evaluation.py: 评测隔离协议 (public/private + 快照变更检测) — PenguinHarness 借鉴
- core/loop/cerebellum_optimizer.py: 端到端 skill 进化闭环 (提案→apply→MRR→接受/回滚) — 接 cerebellum

路径全部 env 可覆盖 + 仓库相对解析, 无硬编码绝对路径; 缺失 cerebellum 优雅降级。
97 测试全绿 (独立模块, 基于 upstream/main)
依据 microsoft/generative-ai-for-beginners 22 课学习报告(F:\DS-HARNESS\genai-course-learning.md)与借鉴计划(F:\DS-HARNESS\genai-borrow-plan.md)落地 P1 九项,全部零冲突、不重复已吸收营养:

- P1-1 anti-fabrication 子句: agent_setup SYSTEM_PROMPT 增加不编造证据声明
- P1-4 温度 per-task: session 工具循环默认 0.1 (profile 显式优先, 0.0 不被误替换)
- P1-3 记忆注入数据-指令隔离+restrict: MEMORY.md 经 <untrusted-data> 边界注入 (lesson 13 prompt injection 防护)
- P1-8 提示注入回归测试集: loop/injection_regression.py (9 样本 x 4 注入面) + 12 测试
- P1-2 工具 description 质量: base.py description_quality_issues/sanitize_description + MCP 远端 description 清洗
- P1-6 检索失败三模式缓解: loop/memory_retrieval.py 阈值 0.45 + 无记忆回退 + assert_all_injected 链路自检
- P1-7 检索评估强化: cerebellum_optimizer split_held_out_qa (异源留出) + evaluate_retrieval (余弦打分, weak 显式标记)
- P1-5 压缩即记忆: runner compaction_summary_sink (auto+manual, 锚点) -> session 后台线程 -> memory compactions.md (bound 32k) + memory.compaction.deposited 事件
- P1-9 MCP server 白名单: naming.server_allowed (env DEEPCODE_MCP_SERVER_ALLOWLIST) + runtime 注册过滤 (供应链加固)

新增 79 项测试全绿; 全量 134 失败均为 baseline pre-existing (Windows 路径/symlink 特权), 本次改动 0 新失败。
- 恢复 cerebellum_optimizer.py / events.py 为 HKUDS#181 版本(P1 提交不修改 HKUDS#181 新文件)
- 新增 core/loop/retrieval_evaluation.py: split_held_out_qa / evaluate_retrieval / cerebellum 适配器 (自包含 _import_cerebellum)
- test_retrieval_evaluation.py 改引 retrieval_evaluation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants