Why: The N1 harness phase needs the kernel to resolve ask decisions
through the host (paired HITL), emit the full hook lifecycle the plan
promises, and carry mode/rules/session-allow in one named object.
Evidence: go vet clean; go test ./... 24 packages ok, including new
loop_hooks_lifecycle_test.go (lifecycle order, prompt text, ask
allow/deny/legacy paths, stop continuation counts) and three new
policy tests (struct-form parity, session-allow store, nil store).
Impact: hooks adds PostToolBatch and SessionEnd events; loop emits
SessionStart/UserPromptSubmit/PostToolBatch/SessionEnd and PreCompact
lands in AgentSession.Compact; gateTool consults PermissionAsk on ask
and keeps ask=reject when the port is unset; policy gains Policy,
SessionAllows, and MemoryAllows. SubagentStart/Stop emissions are
deferred to the adapters assembly increment (factory site has no bus
access yet).
Refs: Documents proposal 2026-10-07-agent-stack-n1q1i1-plans.md WP2/WP3
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
N1 增量一:ask 回路、生命周期事件与 Policy 类型(WP2/WP3 库侧)
按 Documents 提案
2026-10-07-agent-stack-n1q1i1-plans.md§2.2 的 WP2/WP3 落地库侧部分。改动
runtime/policy新增Policy{Mode, Rules, SessionAllows}(Decide/Visible 方法,与函数形态完全一致)、SessionAllows接口与进程内MemoryAllows实现(按工具名+原样参数串精确匹配)。runtime/hooks新增PostToolBatch、SessionEnd事件。runtime/loop.go在 Run 入口发SessionStart/UserPromptSubmit(带用户正文)、工具批后发PostToolBatch、Run 出口(defer)发SessionEnd(带末轮文本与工具计数);AgentSession.Compact前发PreCompact。Stop事件已有的Continuations字段即方案所称「续跑标志」,测试补齐可见性断言。Config.PermissionAsk端口——钩子对工具表态 ask 时先发PermissionRequest,再向宿主要裁决;Allow 则照常执行,拒绝则写配对错误结果(宿主理由优先)。端口为 nil 时保持旧行为(ask 按拒绝处理)——默认行为不变,行为变化严格限制在「宿主注册了裁决端口」的场景。rejectToolMessage助手。范围裁定
SubagentStart/Stop的发射点在 adapters(subagent.Factory 调用侧暂无总线访问),留到装配增量(WP6/backend PR)。PermissionAsk的宿主实现(接 HITL 卡)与三条路径装配拉齐属 Backend PR。验证
go vet ./...通过;go test -count=1 ./...24 包全 ok。runtime/loop_hooks_lifecycle_test.go:生命周期顺序(SessionStart→UserPromptSubmit→PreToolUse→PostToolUse→PostToolBatch→Stop→SessionEnd)、UserPromptSubmit 正文、ask 放行/拒绝/无端口三条路径、续跑计数可见性。runtime/policy/policy_test.go新增三测:结构体形态与函数形态等价、会话放行存储跨调用存活且精确匹配、nil 存储与 Visible。主任务:Dev 仓
feature/agent-stack-n1(任务卡随 Dev 分支携带)。