feat(runtime): P3 Repo Hooks + Workspace Trust Gate (#491)#506
Merged
phantom5099 merged 4 commits into1024XEngineer:mainfrom Apr 28, 2026
Merged
feat(runtime): P3 Repo Hooks + Workspace Trust Gate (#491)#506phantom5099 merged 4 commits into1024XEngineer:mainfrom
phantom5099 merged 4 commits into1024XEngineer:mainfrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Collaborator
Author
|
/code 提高测试率到100 |
处理结果已按“提高测试率到100”补充并提交测试,改动已推送到当前工作分支。 已完成:
提交信息:
已推送:
未完成:
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
test: improve coverage for hook P3 branches
Collaborator
|
/review |
|
|
||
| loaded, loadErr := buildRepoHookExecutorForWorkspace(e.service, workspace, e.hooksCfg) | ||
| if loadErr != nil { | ||
| return runtimehooks.RunOutput{} |
There was a problem hiding this comment.
High: 这里直接吞掉 loadErr 并返回空输出,会把 repo hooks 配置错误(例如 hooks.yaml 解析失败、同来源重复 ID)静默降级为“没 hooks”,上层看不到任何失败信号。这样与文档中的“同来源重复 ID 会报错”不一致,也会让运维很难定位问题。建议至少发出 error/专用 runtime event(包含 workspace 和错误摘要),并避免静默忽略。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
实现父任务中 P3 阶段(#491):在 P2 user builtin hooks 基础上,新增项目级 repo hooks,并通过 workspace trust gate 默认拒绝执行,确保“可扩展”与“默认安全”同时成立。
变更摘要
<workspace>/.neocode/hooks.yaml~/.neocode/trusted-workspaces.jsoninternal -> user -> reposcope/source双字段语义并全链路透传(runtime -> gateway -> TUI)详细实现
1) Hooks 元模型扩展(scope/source 分离)
sourcescope保持“权限/上下文裁剪等级”语义source用于“配置来源/可观测”语义internal|user|repo,但实现未将两者硬绑定2) Registry 冲突与并存策略
Resolve维持优先级与稳定顺序语义3) Repo hooks + Trust Gate
<workspace>/.neocode/hooks.yamlkind=builtinmode=syncbefore_tool_call / after_tool_result / before_completion_decisionrequire_file_exists / warn_on_tool_call / add_context_note~/.neocode/trusted-workspaces.json4) 事件与 UI 可观测
repo_hooks_discoveredrepo_hooks_loadedrepo_hooks_skipped_untrustedrepo_hooks_trust_store_invalidsource<source>:<id>,消除跨源同 ID 歧义5) 安全边界
测试
新增/更新覆盖包括:
internal -> user -> reposcope/source字段、repo hooks 事件解码<source>:<id>与 repo hooks 生命周期事件处理已验证(针对本次改动相关包):
go test ./internal/runtime/hooksgo test ./internal/runtimego test ./internal/tui/servicesgo test ./internal/tui/core/app -run "TestRuntimeEventHookHandlers|TestRuntimeEventRepoHookLifecycleHandlers|TestRuntimeEventHandlerRegistryContainsRenamedEvents"文档
docs/runtime-hooks-design.md:补充 P3 边界、trust gate、source 可观测docs/guides/configuration.md:补充 repo hooks 与 trust 文件示例兼容性与约束
runtime.hooks.enabled=false时关闭全部 hooks(internal/user/repo)Closes #491