fix(zfc): reject Worker generation outside scaffolded projects by jay23606 · Pull Request #155 · YearsAlso/zoo-framework · GitHub
Skip to content

fix(zfc): reject Worker generation outside scaffolded projects - #155

Merged
YearsAlso merged 2 commits into
YearsAlso:devfrom
jay23606:fix/zfc-worker-project-root
Oct 11, 2026
Merged

YearsAlso merged 2 commits into
YearsAlso:devfrom
jay23606:fix/zfc-worker-project-root

Conversation

@jay23606

Copy link
Copy Markdown
Contributor

变更描述 / What changed

在项目外运行 zfc --worker <name> 会静默创建无法被项目入口加载的 Worker 并返回成功。现在命令会从当前目录向上查找最近的 src/main.py;找不到时在写入前报错并给出下一步指引。从项目子目录调用时会将 Worker 写入最近项目并接入其入口。

关联 issue / Related issue

Closes #131

变更类型 / Type of change

  • fix —— Bug 修复 / bug fix
  • feat —— 新功能 / new capability
  • docs —— 文档 / documentation only
  • refactor —— 重构,行为不变 / behaviour-preserving refactor
  • test —— tests only
  • chore / perf —— build, tooling, performance

测试 / Testing

  • python -m pytest -q: 999 passed, 1 skipped

  • Ruff check and format check passed for changed Python files.

  • mypy zoo_framework --show-error-codes: passed (107 source files).

  • Bandit: no issues identified.

  • openspec validate --strict fix-zfc-worker-project-root: valid.

  • git diff --check: passed.

  • The repository-wide pre-commit command reports existing whitespace/line-ending fixes and four B905 findings in bench/measure_boundary.py. The same failures reproduce on the clean dev base; changed Python files pass their focused checks.

  • All template commands above pass exactly as written locally.

  • New behaviour is covered by regression tests.

  • This is documentation-only.

  • Not verifiable by automated tests.

破坏性变更 / Breaking change

  • 否 / No
  • 是 / Yes —— invoking --worker outside a scaffolded project now exits non-zero instead of creating an unconnected workers/ directory. Run zfc --create <name> first, or run the command inside an existing project (or its subdirectory).

文档同步 / Documentation

  • README.md and README.zh.md updated.
  • docs/*.md deep-dive documentation changed.
  • Docstring updated.
  • openspec/ delta spec included.

自检 / Self-review checklist

  • No debugging leftovers or temporary files.
  • No quality gate bypassed.
  • Documentation matches the behaviour.
  • Changes are on a feature branch, not committed to dev or main.

@jay23606
jay23606 requested a review from YearsAlso as a code owner October 10, 2026 14:39
合入前审查整改(PR #155 / 变更 fix-zfc-worker-project-root):

- resolve_worker_dir docstring 恢复英文:它在 zoo_framework.cli.__all__ 导出面内,
  bbf06ae(变更 api-docstring-english)已将其英文化,本 PR 曾改回中文
- 新增的报错消息改英文:用户可见控制台输出 MUST 为英文(cross-platform-io),
  中文消息在 GBK 控制台乱码,且会使该变更验证门 4.1(raise/log/print 零 CJK)失效
- 项目外用例的“零产出”断言补上目录维度:_snapshot 原先只登记文件,注入
  “先建目录再报错”的违规实现时断言仍绿(已实测),修后该注入变红
- design.md 增补 Language 一节,并把 issue #131 第 4 点(--create 目标不可创建时
  抛裸异常栈)显式列入 Non-goals:存量缺陷,另立变更处理
- CHANGELOG 条目改中文,补(变更 fix-zfc-worker-project-root / #131)与 BREAKING 标注

验证:pytest 1011 passed;ruff / mypy(107 files) / bandit / openspec --strict 全绿;
cp936 控制台下报错输出为纯 ASCII;tasks 3.1 的套件计数按实测更正。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@YearsAlso

Copy link
Copy Markdown
Owner

Sign up for free to 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.

2 participants