fix(hook): SessionEnd hook-bucket leak behind trust gate + document Hooks/Goal in all READMEs - #78
Merged
Merged
Conversation
Untrack the local-only hooks file and ignore it going forward so future pulls never touch the working-tree copy. Co-Authored-By: Lex's Agent <lex-agent@noreply.local>
…ent Hooks/Goal in all READMEs Audit of the Hooks and Goal modules found the product loops closed and correct (210/210 tests green), with two gaps: fix(hook): SettingsHook.trigger deferred SessionHooks.clear to each return point, but the workspace-trust early-return (requireTrust + untrusted dir) was missing it. An untrusted session that registered hooks over the HTTP API would leak its in-memory hook bucket for the process lifetime on SessionEnd. Add the clear on that return path, mirroring the short-circuit / empty-matcher / normal-end paths. docs(readme): the Hooks API + Goal Auto-Loop features were documented only in the English README; the 21 translated READMEs had zero fork content. Add a "Fork additions" section to each (native zh/zht, uniform English for the other 19) covering the hooks.json chain, session-scoped HTTP registration, /trust workspace-trust gating, and the goal loop (/goal, /subgoal, /goal resume). Also correct the event count in README.md from 27 to 26 (actual VALID_HOOK_EVENTS size). Co-Authored-By: Lex's Agent <lex-agent@noreply.local>
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 freeto 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.
背景
对 Hooks 与 Goal 模块做了一次产品闭环审计:三条链路(goal continuation 失败可见化、session hooks HTTP producer、/trust 用户入口)均已闭环、业务正确,
bun test test/hook test/goal210/210 全绿。审计中发现两处缺口,本 PR 修复。改动
1. fix — SessionEnd hook 桶在 trust 门禁路径下泄漏 (
hook/settings.ts)SettingsHook.trigger把SessionHooks.clear延后到各 return 点执行(短路 / 空 matcher / 正常结尾都已覆盖),但 workspace-trust 提前返回(requireTrust+ 未信任目录)这一路径漏了清理。后果:一个未信任的 session 若通过 HTTP API 注册过 hook,其内存 hook 桶会在 SessionEnd 时泄漏到进程退出。在该 return 前补上sessionHooks.clear,与其它三个 return 点对称。test/hooktest/goal210/210 全绿;全量turbo typecheck29 包通过。2. docs — 全语言 README 补 Hooks/Goal 介绍
Hooks API 与 Goal Auto-Loop 此前只在英文 README 有说明,21 个翻译版 README 零 fork 内容。本 PR 为每个翻译版新增「Fork additions / 此分支新增」小节:
zh/zht):原生中文翻译。configure-hooks.md的链接)。内容覆盖 hooks.json 链、session 级 HTTP 注册、
/trust工作区信任门禁、goal 循环(/goal、/subgoal、/goal resume)。同时把英文 README 的事件数从 27 修正为 26(VALID_HOOK_EVENTS实际大小)。测试
bun test test/hook test/goal→ 210 pass / 0 failturbo typecheck→ 29/29 包通过(pre-commit 钩子已执行)