feat(ch12): phase 0 — snapshot rewire + workspace-trust gate - #30
Merged
Conversation
…rkspace-trust gate Closes the gap analysis' hard-fix-first blocker: the hook executor now reads the frozen HookConfigSnapshot via tool_use_context.hook_config_manager rather than the live tool_use_context.options.hooks. Both bypass sites (has_hook_for_event, _run_hooks_for_event) are converted; _get_hooks_from_settings remains as a back-compat alias that emits DeprecationWarning. Removal slated two CHANGELOG entries after the rename. Also scaffolds the workspace-trust gate (src/hooks/trust_gate.py): when workspace_trusted is False, _run_hooks_for_event strips non-policy hooks before execution, so untrusted-workspace settings.json cannot inject hooks. Trusted workspaces and HookSource.POLICY entries pass through unchanged. Tests: - test_snapshot_freezing.py (8): includes the regression that wins the on-disk TOCTOU case (mutate settings.json after snapshot, executor still fires the snapshotted hook) and the conflict case (real hook in snapshot + bogus hook in options.hooks -> snapshot wins). - test_trust_gate.py (7): full (trusted x policy) matrix plus the predicate fail-safe (missing workspace_trusted attr -> treated as untrusted). 15/15 new tests green; 88/88 hook tests green. Adds pytest-asyncio>=1.3.0 to deps (asyncio_mode = "auto" was already configured). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
ericleepi314
force-pushed
the
feat/ch12/phase0
branch
from
May 9, 2026 06:06
62a307c to
9bbeb1b
Compare
singlaamitesh
pushed a commit
to singlaamitesh/clawcodex
that referenced
this pull request
Jul 7, 2026
feat(ch12): phase 0 — snapshot rewire + workspace-trust gate
peroxider
pushed a commit
to peroxider/clawcodex
that referenced
this pull request
Jul 20, 2026
feat(orchestrator): F-118 task decomposition and F-124 issue clarifier MVP Created-by: qq_49552963 Commit-by: wukong;yeyunyao Merged-by: chadwweng Description: ## 这次做了什么 ### F-124:信息不够就先问,不再直接猜 - Issue 明确写了“细节未定 / 不要猜”时,先暂停派发并向作者追问。 - 只接受作者在追问之后的新回复;GitCode 评论按时间重新排序,避免把新回复当旧评论跳过。 - 机器人评论带隐藏 marker,即使机器人账号和 issue 作者是同一个,也不会把自己的追问当成作者回答。 - POST 没返回 comment ID 时不再靠相同正文猜游标;拿不到可靠游标就保持阻塞。 - GitCode token 改走 `Authorization: Bearer`,不再出现在 URL 和访问日志里。 ### F-118:真的拆任务、派 worker,并检查证据 - complex issue 会生成 task graph 和 wave;`mode:swarm` 会启动 coordinator。 - headless 现在不仅过滤工具,还会注入 coordinator 角色提示和 worker 能力上下文,因此模型会调用 `Agent`,不会反复撞不存在的 `Bash/Write`。 - 每个 task 由 write-capable worker 写独立的 `.orchestrator_control/task_evidence/task-N.json`,并行任务不会争写同一个文件。 - validator 检查状态、非空证据和依赖顺序;执行顺序使用 h144 文件系统记录的 evidence mtime,不信任模型自报的时间。 - swarm 未闭环时不会被 workspace-idle 早停抢先判完成。 ### 长工具调用不会再被误杀 - 内层 turn timeout 看到 `tool_use` 尚未对应 `tool_result` 时暂停。 - 外层 stream-stall watchdog 复用同一份 pending-tool 状态,不再把 worker 正在运行误判成 provider 卡死。 - 普通模型静默、单工具超时和总运行预算仍然保留。 ## click 仓实测 ### F-124:先追问,再继续实现 - Issue:[click agentforce314#30](https://gitcode.com/qq_49552963/click/issues/30) - 实际 PR:[click !24](https://gitcode.com/qq_49552963/click/merge_requests/24) - 页面上能看到来源 issue、实际分支、commit 和 `Verification: passed`。  ### F-118:四步 swarm 从 issue 跑到 PR - Issue:[click agentforce314#36](https://gitcode.com/qq_49552963/click/issues/36) - 实际 PR:[click !31](https://gitcode.com/qq_49552963/click/merge_requests/31) - 实际生成 4 个 task / 4 个 wave、4 份 task evidence;最终 `tests/test_testing.py` 为 `44 passed, 1 skipped`。 - 为了主动压测误杀问题,h144 上把 turn timeout 临时降到 30 秒;运行中多次记录 timeout deferred,worker 继续工作,最后 session complete、validator 通过并创建 PR。  ## h144 验证 - 环境:openEuler Linux / aarch64,Python 3.11;没有使用 Windows pytest。 - 最终相关回归:`251 passed in 65.64s`。 - click agentforce314#36 实际任务:`44 passed, 1 skipped`,session complete,创建 click PR !31。 - 更大范围回归:`1649 passed, 2 skipped, 18 subtests passed`;另有 3 个与本 MR 无关的既有环境/隔离失败(Linux 登录名假设、临时 session 路径补丁、无测试仓库 regression-guard 期望)。 - Python 编译、`git diff --check`、GitCode push hooks 通过。h144 环境未安装 Ruff,因此不把 Ruff 写成已通过。 ## 仍然保留的边界 - task 的状态和测试说明仍由 worker 写入;orchestrator 用独立文件、host mtime 和 fail-closed validator 复核,不把模型一句“完成了”当结果。 - 总运行预算和 per-tool timeout 仍会终止真正卡死的任务;本次只暂停会误伤健康 in-flight 工具的 stall/turn timeout。 See merge request: chadwweng/clawcodex!86
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.
Summary
Phase 0 of the ch12 (extensibility) chapter port. Closes the chapter's hard-fix-first blocker: the hook executor now reads the frozen
HookConfigSnapshotviatool_use_context.hook_config_managerrather than the livetool_use_context.options.hooks. Adds workspace-trust gate that strips non-policy hooks under untrusted workspace.What's new in this phase
src/hooks/hook_executor.py—_get_hooks_from_snapshot; both bypass sites rewired; legacy_get_hooks_from_settingsnow a back-compat alias emittingDeprecationWarning.src/hooks/trust_gate.py— newshould_skip_hook_due_to_trustpredicate; gate at top of_run_hooks_for_eventstrips non-policy hooks whenworkspace_trusted=False.src/tool_system/context.py— addshook_config_manager: Any | Noneandworkspace_trusted: bool.test_snapshot_freezing.py(including on-disk TOCTOU regression where settings.json is mutated after snapshot), 7 intest_trust_gate.py.pytest-asyncio>=1.3.0pinned in deps.Test plan
pytest tests/test_snapshot_freezing.py tests/test_trust_gate.py→ 15/15pytest -k hook→ all greenFirst of 10 PRs in the ch12 phase series. Each phase builds on the prior one (cumulative diff against main).
🤖 Generated with Claude Code