Repository navigation
docs(hooks): document public APIs and privatize internals ahead of ruff D and N - #133
Merged
Merged
Conversation
…ff D and N Make module-internal functions private and document the remaining public API. Rename UnsupportedPattern and _VerificationFailure to the Error suffix. Move idle workspace detection to lib/primary_workspaces.py (file length limit). Refs #74 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Owner
|
@codex review |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Review summary: no findings. This PR is a behavior-preserving refactor (private renames, docstrings, N818 renames, and moving the idle-primary-workspace query to
Blocking findings: 0. 🤖 Generated with Claude Code |
furedea
approved these changes
Nov 10, 2026
furedea
added a commit
that referenced
this pull request
Nov 10, 2026
## 概要 ruff の D (pydocstyle, google),DOC,N (pep8-naming) を有効化する最終 PR (#74 stage 1B の持ち越し分).設定は template-python / dotfiles と同じ形にした.先行 lane (#130, #131, #132, #133) の修正は既にマージ済みで,この PR は残りの違反を直したうえで設定を有効化する. `ruff check .` は有効化後の設定で 0 件.ブランチは 1 コミットで,lefthook の全フックを除外なしで通過している. Refs #74 ## 設定 (pyproject.toml) - `select` に `D`,`DOC`,`N` を `W` と `F` の間に追加 (template-python / dotfiles と同じ並び).`DOC` による新規指摘は 0 件を確認済み - `ignore` に `D104`,`D105`,`D107` を追加 - `per-file-ignores` の `tests/**` に `D` を追加 - `[tool.ruff.lint.pydocstyle] convention = "google"` を追加 既存の ignore は削除していない. ## この PR での修正 ### 改名 (N818) ドメイン概念はそのまま,`Error` 接尾辞のみ追加し,agents と tests の全使用箇所を更新した. - `UnexpandableGlob` → `UnexpandableGlobError` - `UnsupportedSyntax` → `UnsupportedSyntaxError` - `UnplacedCommit` → `UnplacedCommitError` - `UnknownTestCommand` → `UnknownTestCommandError` ### 非公開化 (外部から使われないことを `git grep` で agents/ scripts/ tests/ に対して確認) | ファイル | 件数 | 名前 | | ---------------- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `guard_file.py` | 10 | `_policy_path`, `_load_policy`, `_protected_reason`, `_validate_filename_rule`, `_commit_reason`, `_content_match`, `_scan_content`, `_judged_commit`, `_context`, `_session` | | `shell_paths.py` | 1 | `_brace_words` | ### docstring を書いた公開 API | ファイル | 件数 | 名前 | 理由 | | ---------------- | ---- | ----------------------------------------------- | ------------------------------------------------------------------ | | `guard_file.py` | 3 | `commit_filename_rules`, `content_text`, `main` | テストと CLI から使われる公開 API | | `shell_words.py` | 1 | `home_directory` | `tests/hooks/test_shell_words.py` が直接呼ぶため非公開化しなかった | docstring は名前の言い換えではなく,返す値・拒否する入力・例外を述べている. ## リポジトリ全体の内訳 (ac-dn の全 lane) | PR | 非公開化 | docstring 追加 | 改名 (N818) | | -------------------------------------------- | -------: | -------------: | -----------------: | | #130 (hooks/lib) | 38 | 23 | 0 (他に表記修正 2) | | #131 (session_store ほか 4 ファイル) | 48 | 20 | 0 | | #133 (hooks/\*.py, scripts, skills, tests) | 44 | 15 | 2 | | #132 (verification_session, check_execution) | 8 | 7 | 0 | | この PR | 11 | 4 | 4 | | 合計 | 149 | 69 | 6 | #130 と #133 の件数は各 PR 本文の表,#131 は本文の合計行,#132 は ac-dn の表 (非公開化 7 + `collect`,文書化 `main`/`dispatch`/`failure`/`Status`/`Result`/`Result.failed`/`execute`) による. ## 検証 - `ruff check .`: All checks passed - `ruff format --check .`: 239 files already formatted - `ty check`: All checks passed - `pytest`: 手元 (sandbox) では 2 件を除き通過.失敗は `tests/hooks/test_formatter_config.py` の dprint 統合テスト 2 件のみで,sandbox が `plugins.dprint.dev` への通信を遮断するため (この PR の変更とは無関係).CI で確認する - pre-commit (lefthook) は `LEFTHOOK_EXCLUDE` なしで全フック通過 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.
概要
#74 段階 1B のうち,ruff
D(google)とNを有効化する前段として,lane dn-c の範囲(agents/hooks/*.pyのうちguard_file.pyとverification_session.pyを除くもの,scripts/,agents/skills/,tests/ere_to_z3.py)の違反を設計から直す.pyproject.tomlの ruff 設定は変えない(有効化は最後の PR).対象:
cleanup_worktrees.py,guard_command.py,guard_git.py,guard_suppression.py,scripts/replay_commands.py,tests/ere_to_z3.py,agents/skills/explain-visually/scripts/verify_page.py.修正の内訳
_を付け,呼び出しを更新UnsupportedPattern→UnsupportedPatternError,_VerificationFailure→_VerificationErrorlib/primary_workspaces.pyを新設private 化した名前と根拠
git grepでagents/,scripts/,tests/を横断し,同一ファイル外から参照がないことを確認した.cleanup_worktrees.py(12):primary_checkout,lane_primary,real_primary,git_file_target,is_merged,has_branch,local_branches,current_branch(テストはtoplevel,linked_worktrees,worktree_is_clean,remove_worktree,sandbox_writable_paths,run,HERDR_WORKTREESだけを使う.これらは公開のまま docstring を付けた).残り 4 つ(recorded_primary_workspaces,primary_workspace_idle,herdr_itemsとidle_primary_workspacesの内部)は,分割でlib/primary_workspaces.pyに移り private になった(下記).guard_git.py(6):judged,segment_reason,hides_verdict,gh_hides_verdict,git_hides_verdict,session(テストはdecide,RULE,audit_logだけを使う).guard_suppression.py(5):Change,new_markers,changes,patch_changes,existing_text(テストはdecideだけを使う).guard_command.py(1):record(listing_rulesはcommand_objectionsが使うので公開のまま docstring を付けた).scripts/replay_commands.py(20): テストが使うReplayer,RecordedCommandと CLI のmain,Judgment(Replayer.judgeの戻り値)以外のすべて.docstring を付けた公開 API
Worktree,main(cleanup / guard_command / guard_git / guard_suppression / replay_commands),toplevel,worktree_is_clean,linked_worktrees,run,Policy.listing_rules,guard_suppression.decide,RecordedCommand,Judgment.いずれも名前の言い換えではなく,失敗時の扱い(fail closed,終了コード)や,環境の遮断など名前から読めない契約を書いた.名前の変更
UnsupportedPattern→UnsupportedPatternError: ERE を z3 に変換できないときの例外.使用箇所(tests/test_ere_to_z3.py,tests/test_rule_overlap.py)も更新._VerificationFailure→_VerificationError:verify_page.pyが終了コードと一緒に投げる検証失敗.新モジュール
lib/primary_workspaces.pyが必要だった理由設計上の必要からではなく,file-length 上限(500 行)に当たったためである.docstring 追加で 528 行になったが,コメントや docstring を削らず,責務で分けた(「サイズ上限は設計の信号」).新モジュールが持つ責務は「エージェントが作った primary checkout の Herdr workspace のうち,誰も使っていないものを特定する読み取り専用の問い合わせ」である.これは session record と Herdr の live 状態だけを読み,副作用を持たない.worktree の掃除や workspace を閉じる処理は元のファイルに残る.docstring の作業が本来の目的なので,分割はこの 1 回に留め,他の整理はしていない.
cleanup_worktrees.pyは docstring 追加で 500 行を超えた.コメントや docstring を削らず,責務で分けた.lib/primary_workspaces.pyに「エージェントが作った primary の Herdr workspace のうち,誰も使っていないものを探す」問い合わせ(idle_primary_workspaces)を移した.cleanup_worktrees.pyに残るのは,実際に閉じる側(runを使う副作用)である.テストは偽のherdrコマンドを使うので,移動で壊れない.この新モジュールを
deptryが first party と認識するよう,pyproject.tomlのknown_first_partyに 1 行だけ追加した(ruff 設定は変更していない).最後の有効化 PR のpyproject.toml変更とは別の箇所なので衝突しない.確認
ruff check --extend-select D,N --ignore D104,D105,D107と google convention,tests/**の D 除外で,lane の範囲(agents/hooks/lib,guard_file.py,verification_session.pyを除く)が 0 件.ruff check,ruff format --check,ty check: 通過.pytest全件:4531 passed, 1 skipped.計画からの変更:計画にない
lib/primary_workspaces.pyを file-length のために追加した.Refs #74
🤖 Generated with Claude Code