Skip to content

fix(hook): SessionEnd hook-bucket leak behind trust gate + document Hooks/Goal in all READMEs - #78

Merged
LeXwDeX merged 2 commits into
devfrom
docs/hooks-goal-readme-and-trust-cleanup
Jul 5, 2026
Merged

fix(hook): SessionEnd hook-bucket leak behind trust gate + document Hooks/Goal in all READMEs#78
LeXwDeX merged 2 commits into
devfrom
docs/hooks-goal-readme-and-trust-cleanup

Conversation

@LeXwDeX

Copy link
Copy Markdown
Owner

背景

HooksGoal 模块做了一次产品闭环审计:三条链路(goal continuation 失败可见化、session hooks HTTP producer、/trust 用户入口)均已闭环、业务正确,bun test test/hook test/goal210/210 全绿。审计中发现两处缺口,本 PR 修复。

改动

1. fix — SessionEnd hook 桶在 trust 门禁路径下泄漏 (hook/settings.ts)

SettingsHook.triggerSessionHooks.clear 延后到各 return 点执行(短路 / 空 matcher / 正常结尾都已覆盖),但 workspace-trust 提前返回requireTrust + 未信任目录)这一路径漏了清理。后果:一个未信任的 session 若通过 HTTP API 注册过 hook,其内存 hook 桶会在 SessionEnd 时泄漏到进程退出。在该 return 前补上 sessionHooks.clear,与其它三个 return 点对称。

  • 严重度:低(受泄漏 session 数量有界,需 requireTrust + 未信任 + 注册过 hook 的窄组合)。
  • 验证:test/hooktest/goal 210/210 全绿;全量 turbo typecheck 29 包通过。

2. docs — 全语言 README 补 Hooks/Goal 介绍

Hooks API 与 Goal Auto-Loop 此前只在英文 README 有说明,21 个翻译版 README 零 fork 内容。本 PR 为每个翻译版新增「Fork additions / 此分支新增」小节:

  • 简体/繁体中文zh / zht):原生中文翻译。
  • 其余 19 个语言:统一英文小节(含指向 configure-hooks.md 的链接)。

内容覆盖 hooks.json 链、session 级 HTTP 注册、/trust 工作区信任门禁、goal 循环(/goal/subgoal/goal resume)。同时把英文 README 的事件数从 27 修正为 26VALID_HOOK_EVENTS 实际大小)。

测试

  • bun test test/hook test/goal → 210 pass / 0 fail
  • turbo typecheck → 29/29 包通过(pre-commit 钩子已执行)

LeXwDeXand others added 2 commits July 5, 2026 14:59
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>
@LeXwDeX
LeXwDeX merged commit 4d1e294 into devJul 5, 2026
4 checks passed
@LeXwDeX
LeXwDeX deleted the docs/hooks-goal-readme-and-trust-cleanup branch July 5, 2026 11:30
Sign up for freeto 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.

1 participant

@LeXwDeX