[Bug]: Classic CodeBuddy ignores `auto_mode: false` when PyYAML is not installed, so manual gates are skipped
Host
CodeBuddy
Edition
Classic
LoopForge version
0.2.2 (main 136d37c)
What happened?
.codebuddy/hooks/devflow-auto-dispatch.py reads devflow.defaults.yaml and devflow.config.yaml with PyYAML. When the python3 that runs the hook has no PyYAML, import yaml raises inside _read_config(), except Exception: pass swallows it, the config stays {}, and multi.auto_mode falls back to True.
So with multi.auto_mode: false in .codebuddy/devflow.config.yaml, the hook still auto-dispatches TASK-02_completed, CODE-REVIEW_passed and TASK-04_completed to the next role instead of returning to main for confirmation, and nothing tells the user.
Expected: with auto_mode: false, manual gates return to main. If the config cannot be read, the hook should not assume auto mode.
PyYAML is not declared in pyproject.toml, setup.py or the README. The CI workflows install it explicitly (pip install pyyaml==6.0.3 in e2e.yml, validate.yml and release.yml), which is why CI passes. The macOS system /usr/bin/python3 (3.9.6) does not ship it.
Possible fix (happy to send a PR if this direction works for you):
- When the config cannot be read, treat events in
MANUAL_GATESasfallback_to_mainwith a reason such asconfig_unreadable, instead of assuming auto mode. The worst case becomes one extra stop, not a skipped confirmation. - The hook only needs
multi.auto_mode, so a small fallback reader for that key would keep manual mode working without PyYAML. - Mention the requirement in the README or
loopforge doctor. Declaring it inpyproject.tomlalone may not help, since the hook runs with the host'spython3.
Reproduction
On main (136d37c), with a python3 that has no PyYAML (macOS system Python 3.9.6):
LOOPFORGE_E2E_SOURCE=1 bash scripts/e2e.sh -k unsafe- The
[manual gate]subtest oftest_auto_dispatch_falls_back_to_main_when_routing_is_unsafefails (output below). python3 -m venv .venv && .venv/bin/pip install pyyaml==6.0.3, then rerun withPATH=.venv/bin:$PATH: the test passes.
Sanitized diagnostics
$ python3 --version
Python 3.9.6
$ python3 -c "import yaml"
ModuleNotFoundError: No module named 'yaml'
FAIL: test_auto_dispatch_falls_back_to_main_when_routing_is_unsafe (test_e2e_classic_runtime.ClassicCodeBuddyE2E) [manual gate]
File "tests/e2e/test_e2e_classic_runtime.py", line 55, in test_auto_dispatch_falls_back_to_main_when_routing_is_unsafe
self.assertNotIn("modifiedInput", json.dumps(gated))
AssertionError: 'modifiedInput' unexpectedly found in '{"continue": true, "hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "allow", "modifiedInput": {"type": "message", "from": "architect", "recipient": "developer", "content": "continue as developer", "summary": "[auto-dispatch] TASK-02_completed \u2192 developer"}}}'
Ran 26 tests: 1 failure (this one), 1 skipped (browser test, Playwright not installed).
Safety checks
- [x] I removed credentials, private endpoints, internal identifiers, and personal data.
- [x] I searched existing issues for duplicates.
@MertensMing are you still planning to send the PR you offered here? If not, I have a fix along the lines you suggested (points 1 and 2: a stdlib fallback that reads only multi.auto_mode, and fallback_to_main with config_unreadable for manual gates when the config cannot be read), with two e2e cases that run the hook with yaml blocked. Happy to open it, or to leave it to you.
Triage: Rejected — cannot reproduce on current main
Checked against main @ 6b25d20 this round:
.codebuddy/hooks/devflow-auto-dispatch.pyand thedevflow.config.yaml/devflow.defaults.yamlreader described in this report no longer exist in the repository (find . -iname 'devflow-auto-dispatch.py'returns nothing).- The Classic devflow implementation has moved to
local/skills/devflow/(per-CLI adapters underadapters/{codex,dsh,codebuddy,hermes,cursor,claude,pi},scripts/workflow_state.py,scripts/build_stage_prompt.py, etc.). grep -rn "import yaml"acrosslocal/skills/devflowandlocal/srcreturns no matches — the current implementation does not depend on PyYAML at all, so the specific failure mode (import yamlraising inside_read_config(), swallowed by a bareexcept Exception: pass, silently falling back toauto_mode: true) cannot occur on current main.
This looks like it was already superseded by the devflow skill refactor rather than fixed point-wise, so there's no single "fix version" commit to cite — the whole hook/YAML-config mechanism this report targets is gone.
If you can still reproduce a manual-gate being silently auto-dispatched on a recent build, please share the exact LoopForge version/commit and the config file path your installation actually reads — happy to re-open with that evidence.
Confirmed on main @ c87694a
Verified the reported root cause by reading local/.codebuddy/hooks/devflow-auto-dispatch.py directly from the git object store (git show HEAD:local/.codebuddy/hooks/devflow-auto-dispatch.py):
_read_config()wrapsimport yamlandyaml.safe_load(f)in a bareexcept Exception: pass. When PyYAML is missing (or either YAML file fails to parse), it silently returnsconfig = {}.main()then doesauto_mode = multi_cfg.get("auto_mode", True)— with an emptyconfig, this defaults toTrueregardless of what the user wrote in.codebuddy/devflow.config.yaml.- The manual-gate check
if not auto_mode and event in MANUAL_GATESis then skipped, soTASK-02_completed/CODE-REVIEW_passed/TASK-04_completedget auto-dispatched (modifiedInputrewritesrecipientto the next role) instead of falling back to main for confirmation.
Expected: multi.auto_mode: false in .codebuddy/devflow.config.yaml always routes MANUAL_GATES events back to main, independent of whether PyYAML happens to be installed on the host python3.
Actual: without PyYAML, the config read silently fails and auto_mode falls back to True, so manual gates are bypassed — matching this issue's reproduction with test_auto_dispatch_falls_back_to_main_when_routing_is_unsafe's [manual gate] subtest.
Tracked internally as backlog item #189 (references this issue) for a fix along the lines you proposed (fail closed to fallback_to_main on unreadable config, or add a YAML-free fallback reader for the single auto_mode key), plus a regression test that exercises the no-PyYAML path. Will post the PR link here once implemented.
分诊更新:已定位开放修复 PR
核实结论与之前一致。本轮新进展:已找到开放社区 PR #63(fix(local): preserve manual gates without PyYAML,branch codex/loopforge-49-config-gates,state=open),明确写 Fixes #49,改动 local/.codebuddy/hooks/devflow-auto-dispatch.py(+91/-19)与 local/tests/e2e/test_e2e_classic_runtime.py(+64/-0),与内部 backlog #189 的建议方案(配置不可读时 fail closed、补充 PyYAML 缺失用例)高度吻合。
建议优先评审/合并 PR #63,避免重复实现。内部 backlog #189 已转为 blocked,等待该 PR 进展;若该 PR 关闭或长期不合入,将转回自行实现。