Skip to content

build(lint): align ruff ignores with template-python and fix ARG001 - #124

Merged
furedea merged 8 commits into
mainfrom
build/align-ruff-ignores
Nov 10, 2026
Merged

furedea merged 8 commits into
mainfrom
build/align-ruff-ignores

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

概要

ruff 設定を template-python に揃える第 1 段(Refs #74).

  • 該当コードが 0 件の ignore を削除(B007, C401, DTZ005, FURB110, FURB122, FURB171, UP015, UP017).
  • ARG001 の ignore を削除し,検出された 139 件(src 1,tests 138)を設計として修正.
  • 残す project 固有の項目に理由コメントを付与(E402,[tool.ty.environment]).
  • PLR0917: 使わない方針.PLR0913(max-args = 3)が引数の総数を抑えるので位置引数の数も抑えられ,PLR0917 は何も足さない.ruff 0.16 以降は preview を卒業しており,ruff 0.17.0 では PLR prefix で有効(template の ruff 0.15.11 では無効).tests/** の per-file-ignore を削除し,全体の ignore に理由コメント付きで追加した.

ARG001 の修正(非自明なもの)

箇所 修正 理由
テスト約 120 件 副作用目的の fixture を @pytest.mark.usefixtures(...) に移し,シグネチャから削除 値を使わない依存は pytest の宣言的な指定で表すのが意図に合う
project fixture(dsh, hermes, pi) isolated_project / "repo" から作る.harness への依存は外し,3 モジュールとも pytestmark = pytest.mark.usefixtures("harness") で全テストに適用する(個別マーカーは削除) 値を使うので ARG001 の回避ではない.以前は project 経由で全テストが harness の分離済み HOME・ポリシーを使っていた.一部にだけ宣言すると,ローカルでは通って CI で落ちる(修正済み)/秘密マーカーに依存する否定テストが常に通る,という退行が起きるため,モジュール単位で宣言する(claude-review P2/P3)
project fixture(devin) isolated_project 依存を削除 他の fixture と重複しており,外してもテストが通る
verification_record(conftest) stub に verification_calls のパスを直接埋め込み,環境変数 VERIFICATION_TEST_CALLS を廃止 環境変数経由の暗黙結合を,fixture の値を使う明示的な結合に置換
recorded_primary / temporary merged は元どおり head を記録するだけの dict に戻し,workspace_listing と sandbox_tmp を別々の fixture(各 1 つのパスの唯一の定義)にした.recorded_primary は前者,temporary は後者を直接要求し,merged も両方に依存する.TMPDIR を os.environ から読み戻さず sandbox_tmp を使う 無関係な 2 つのパスを DTO にまとめない.XDG_STATE_HOME は autouse の state_home fixture で設定し(merged からは削除),recorded_primary が実環境の state home に書く余地をなくした.順序をテスト側で宣言する必要はなく,getfixturevalue の動的参照も使わない(claude-review P3)
test_trusted_owners_fallback の offline 空の autouse fixture を削除し pytestmark = pytest.mark.usefixtures("api") に 全テストに必要な副作用を module レベルで宣言
hooks fixture(skill commands) isolated_project を使う test 側の usefixtures に移動 fixture 自体は値を使わない
harness fixture(devin, dsh, hermes, pi) isolated_project を引数に取り,その値から home と root を作る usefixtures("harness") にすると isolated_project より先に走り,harness が消したコマンドルール環境変数を isolated_project が再設定する.依存を静的に戻して元の実行順を保つ(claude-review P3)
test_an_invalid_program_path_is_rejected parametrize を change のみにし,ラベルを pytest.param(..., id=...) に ラベル引数を usefixtures で fixture 扱いしていたのは誤り(claude-review P3).全 usefixtures 名を走査し,該当はこの 1 件だけだった
何も効かない usefixtures("monkeypatch") / ("tmp_path")(7 箇所) マーカーを削除 値も副作用もない要求なので,残す理由がない
system_message(provider_adapter) _event Formatter の形に合わせるためだけの引数
check(test_static_rules) _kind に変更し,未使用の readonly は削除 唯一の呼び出し元(lint_engine.diagnostics)が Callable[[str, Path], ...] として 2 引数で呼ぶ.位置引数の形は固定なので _kind は残し,呼ばれない readonly は不要
observe_lock(concurrency) 置換対象と同じ (path, *, timeout=None) を保ち,本体先頭で del timeout # The fake always waits 5 seconds. シグネチャを緩めず,意図的に無視する引数を明示

削除した ignore の元の理由(監査)

出典は dotfiles 8428059(2026-05-09,pyproject.toml 新規作成).59b76e7 がこの repo にコメントなしでコピーした.対象のスクリプトは dotfiles faa537f(2026-05-20)で dotfiles から出て,この repo では 309f46e(2026-09-12,skill-auditor など retired skill tooling の削除)で消えた.8428059 時点のツリーに削除対象 8 ルールをかけると 23 件あり,すべて agents/skills/skill-auditor/scripts/ 内だった.現在の tree には skill-auditor も run_audit も無く,同ルールの検出は 0 件.

ルール 検査内容 元の理由(引用) 今は当てはまらない理由
B007 ループ制御変数が本体で未使用 "os.walk tuple names document positional contents in existing code" 該当は collect_skills.py:235(dirs 未使用).スクリプトは削除済み.現在の os.walk は check_selection.py:238 と source_listing.py:29 の 2 箇所で,どちらも directories[:] = … で枝刈りに使い,3 名すべてを使う
C401 set(generator) を set 内包表記へ "Existing aggregation code favors explicit generator layout" 該当は collect_skills.py:362.削除済み
DTZ005 tz なしの datetime.now() "Timestamped local workspace names intentionally use local time" 該当は run_audit.py:73.削除済み.datetime.now() は現在 audit_log.py:324 の datetime.now(UTC) のみ.ローカル時刻が要るなら datetime.now().astimezone() で tz 付きにできる
FURB110 x if x else y を x or y へ "Existing JSON output code keeps explicit empty-list fallback branches" 該当は collect_transcripts.py:580,664.削除済み
FURB122 ループの f.write を writelines へ "Existing changelog writes favor straightforward loops" 該当は apply_patches.py:231.削除済み
FURB171 単一要素コンテナへの in "Existing message-type checks use tuple style consistently" 該当は collect_transcripts.py:284,773.削除済み
UP015 不要な open の mode 引数 "Explicit read/write modes are kept for CLI-script clarity" 該当は skill-auditor の 7 箇所.削除済み
UP017 timezone.utc を datetime.UTC へ "Existing code imports timezone explicitly" 該当は skill-auditor の 8 箇所.削除済み.現在は datetime.UTC を使用
ARG001 未使用の関数引数 "Patch schema keeps current_description for compatibility"(apply_patches.py) 対象は削除済み.現在の検出は 139 件で,この PR で設計として修正した

「検出 0 件」だけを理由にはしていない.上の対応を 8428059 のツリーと現在の tree の両方で確かめた.元の理由が今も成り立つ項目はなく,復元した entry は無い.

残した ignore の監査

この PR では変更しない.E501,I001,PTH,F541,FURB162,PERF401,PLW2901,RUF005 は別の open PR(#125)が削除し,その理由の監査も #125 にある.INP001 と PLR2004 は template も ignore しているので,このまま残す(template 側の根拠は別の議論).現在の検出数は ruff --isolated で数えた.

ルール 元の理由(dotfiles) 現在の検出 判断
E402 "run_audit adjusts sys.path before importing sibling scripts" 48 run_audit は削除済みだが,hooks と tests が sys.path を整えてから隣のモジュールを import する構造が同じ理由で残る.コメントを現状の理由に書き換えて残した
E501 "Embedded HTML/JS templates intentionally preserve long source strings" 27 埋め込みテンプレートは削除済み.現在は hooks の正規表現とテストのコマンド文字列.元の理由は当てはまらない.別 PR で理由を決める(残置の根拠はまだ無い)
F541 "Existing report/changelog writes include harmless f-string literals" 1(test_pinned_program_project.py) 元の理由の対象は削除済み.同上
FURB162 "Existing timestamp parser normalizes trailing Z explicitly" 1(test_audit_log.py) 元の対象は削除済み.同上
I001 "Keep script import blocks stable while sys.path bootstrapping is present" 147(135 ファイル) うち 28 ファイルが sys.path を操作する.残りは当てはまらない.同上
PERF401 "Existing batching code favors stepwise mutation for readability" 3(explain-visually/scripts/verify_page.py) 元の対象は削除済み.検出は別のスクリプト.同上
PTH "Legacy scripts use os.path; Path migration is a separate refactor" 13(os.getcwd など) 元の「別 refactor」はまだ行われておらず,理由は成り立つ
PLW2901 "Existing JSONL parser reuses line after stripping whitespace" 1(test_skill_commands.py) 元の対象は削除済み.同上
RUF005 "Existing path reconstruction code is clearer with list concatenation" 3 元の対象は削除済み.同上
INP001 / PLR2004 理由コメントなし(87ba9da で最初から存在) 72 / 113 理由が無いため判断不能

検証

  • ruff format / ruff check(--no-cache): 全件 pass
  • ty check: pass
  • pytest: 4521 passed, 1 skipped
  • ARG001 は ignore なしで 0 件

計画からの変更

なし.

🤖 Generated with Claude Code

Delete the ruff ignores that no longer match any code (B007, C401, DTZ005,
FURB110, FURB122, FURB171, UP015, UP017), keep the ignore list in the
template order, and explain E402 and the ty extra-paths entry.

Stop ignoring ARG001 and fix the findings by design:
- Tests move fixtures requested only for their side effect to
  pytest.mark.usefixtures.
- Fixture-to-fixture ordering uses the dependency's value or an explicit
  request.getfixturevalue call, since usefixtures has no effect on fixtures.
- Callbacks that only match a shared signature take underscore-prefixed names.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T11:23:50.125667Z
We couldn’t complete this review. Comment @codex review to try again.
dbc643e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Review summary (Claude)

I found no blocking issues. The PR has no P0, P1, P2 or P3 findings.

What I checked:

  • system_message: renaming event to _event is safe. Its only caller (provider_adapter.py:150) passes the arguments by position.
  • Test fake for check_file: the new _kind / _readonly names are safe. lint_engine.diagnostics calls the checker by position with two arguments.
  • observe_lock(path, **_options): still matches the keyword-only file_lock(..., blocking=, timeout=) calls.
  • Removing VERIFICATION_TEST_CALLS: nothing else in the repo references it, and the stub now embeds the verification_calls path directly.
  • pytestmark = usefixtures("api") replaces the empty autouse fixture with the same effect for every test in the module.
  • The ruff ignores removed in pyproject.toml have no remaining violations, according to the PR description.

I could not run pytest in this environment, so I am relying on the PR's reported results (4521 passed, 1 skipped).

Replace the request.getfixturevalue("merged") lookups with a real
dependency: merged now returns MergedHeads, which carries the fake Herdr
workspace listing and the sandbox TMPDIR that recorded_primary and
temporary used to rebuild or hardcode.

Keep the exact signature of the faked file_lock and mark the ignored
timeout with del, and drop the unused readonly parameter from the
check_file fake because its only caller passes two arguments.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

],
)
def test_secret_paths(run_cli: CliRunner, harness: Path, mode: str, payload: dict, blocked_path: str) -> None:
@pytest.mark.usefixtures("harness")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Moving harness into @pytest.mark.usefixtures changes the order fixtures are set up. pytest builds fixturenames as autouse + usefixtures + argnames, so harness now runs before run_cli → isolated_project. Before this PR it ran after.

harness deletes AGENT_COMMAND_PERMISSIONS, AGENT_ALLOWED_COMMAND_RULES and AGENT_FORBIDDEN_COMMAND_RULES so that the hook reads rules from AGENT_HARNESS_ROOT. Then isolated_project runs and sets them again to the repo's agents/... files. Those deletes now do nothing in every test that uses usefixtures("harness") (devin, dsh, hermes, pi; codex is not affected because its harness doesn't touch these variables).

The current tests in these modules use paths, patch, lint and harness modes, which don't read command rules, so nothing is hidden today. A future command-mode test added in this style would quietly read the repo rules instead of the harness copy. To keep the old order, you could have harness depend on isolated_project, or keep harness as an argument where the order matters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e92332a. The harness fixtures in devin, dsh, hermes and pi now take isolated_project and build their directories from it, so they run after it again as before. The deletes of the command-rule variables take effect again.

],
)
def test_an_invalid_program_path_is_rejected(tmp_path: Path, change: dict, reason: str) -> None:
@pytest.mark.usefixtures("reason")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: reason is a parametrize argument, not a fixture. usefixtures("reason") only works because parametrize accepts any name in fixturenames, so the test is using a side effect of pytest internals. It seems the string's only job is to label each case. A clearer way is to parametrize only change and pass the label as the case id, e.g. pytest.param({...}, id="parent"), or use ids=. Then nothing needs to be marked as a fixture.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e92332a. The cases now use pytest.param(..., id=...) and only change is parametrized. I also scanned every usefixtures name in tests/ against parametrize arguments and fixture definitions: reason was the only case; the monkeypatch/tmp_path markers that did nothing were removed.

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings (no P0 or P1).

The ruff ignore cleanup and the ARG001 fixes look correct. I read these closely:

  • MergedHeads: sandbox_tmp comes from TMPDIR after merged sets it to tmp_path/sandbox-tmp, so it is the same directory as before.
  • verification_record: the stub has the path written in directly, and nothing else reads VERIFICATION_TEST_CALLS.
  • project fixtures: harness.parent is tmp_path in dsh, hermes and pi, so the path is unchanged.
  • observe_lock and system_message: both keep their signatures.

Two optional (P3) notes, posted inline:

  • P3: usefixtures("harness") makes harness set up before isolated_project. isolated_project then sets the command-rule variables again (AGENT_COMMAND_PERMISSIONS, AGENT_ALLOWED_COMMAND_RULES, AGENT_FORBIDDEN_COMMAND_RULES) that harness had deleted, in the devin, dsh, hermes and pi modules. No current test depends on this, but a future command-mode test would read the repo rules instead of the harness copy.
  • P3: usefixtures("reason") marks a parametrize argument as a fixture. Passing the label as the case id (pytest.param(..., id=...)) would be clearer.

I could not run the test suite in this environment, so I am relying on the PR's reported results (4521 passed, 1 skipped).

Build the harness fixtures on isolated_project so they run after it, as
they did before they moved to usefixtures; harness deletes command-rule
variables that isolated_project would otherwise set again.

Label the parametrized pinned-program cases with pytest.param ids instead
of marking the label argument as a fixture, and remove the usefixtures
markers that only requested monkeypatch or tmp_path without any effect.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings (0 × P0/P1, no P2/P3 worth raising).

Checked:

  • provider_adapter.system_message: event → _event is safe. The only caller (ProviderAdapter, via profile.formatter(...)) passes it positionally, and nothing passes it by keyword.
  • pyproject.toml: removing ignores only makes linting stricter. No runtime effect.
  • harness fixtures (devin/dsh/hermes/pi) now depend on isolated_project. That fixture returns tmp_path, so the home/harness/repo paths stay the same. The dependency also guarantees harness's delenv of AGENT_* runs after isolated_project's setenv, so it no longer depends on argument order.
  • devin project no longer depends on isolated_project. Every test that uses it also requests run_cli, which depends on isolated_project, so the chdir/env setup still happens.
  • MergedHeads: workspace_listing and sandbox_tmp match the paths the fake Herdr and TMPDIR setup use (tmp_path/herdr_workspaces.json and tmp_path/sandbox-tmp). __setitem__ still writes the state file.
  • verification_record stub: the f-string inlines repr(path), and there are no other braces in the stub body, so the env-var removal is safe.
  • pytestmark = usefixtures("api") replaces the autouse offline fixture. api is still set up before every test in the module.
  • usefixtures conversions are behaviour-preserving. I found no test that lost a fixture whose side effect it relies on.

I didn't run the test suite in this review environment, so this rests on reading the code and the PR's reported pytest results (4521 passed).

…to fixtures

merged records merged PR heads again, with no extra fields. The fake Herdr
workspace listing and the sandbox TMPDIR are now separate workspace_listing
and sandbox_tmp fixtures, each the single definition of its path and each
requested directly by recorded_primary and temporary. TMPDIR is no longer
read back from os.environ right after it is set.

recorded_primary registers under the state home that merged sets, so its
tests request ("merged", "recorded_primary") together, which keeps that
order.

In the dsh, hermes and pi modules the project fixture builds the repository
from isolated_project, and the dsh tests that scan the harness's secret
marker pattern request harness themselves. Drop the per-test usefixtures("api")
that the module pytestmark already applies.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pytest.fixture
def project(tmp_path: Path, isolated_project: Path, harness: Path) -> Path:
root = tmp_path / "repo"
def project(isolated_project: Path) -> Path:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Tests that use project without harness no longer get isolated HOME / AGENT_HARNESS_ROOT. This applies to dsh, and to hermes and pi as well.

Before this PR, project pulled in harness, which set HOME to a tmp dir, set AGENT_HARNESS_ROOT, and cleared the AGENT_*_POLICY overrides. Tests like test_shell_git_guard_reads_the_bash_tool, test_forbidden_command_is_blocked and test_dispatch_* now run the adapter subprocess with the developer's real HOME. That means any ~/.claude / ~/.dsh rules on the machine can change the result.

isolated_project covers the rule-file env vars, so this is a loss of isolation rather than a confirmed failure. Still, an autouse fixture that only points HOME at a tmp dir would keep the old hermetic behavior without bringing back the hidden harness dependency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in aad21ad. dsh, hermes and pi now declare pytestmark = pytest.mark.usefixtures("harness") once per module, so every test again gets the isolated HOME and policy root that project used to bring in. The per-test markers are removed.

def project(tmp_path: Path, isolated_project: Path, harness: Path) -> Path:
root = tmp_path / "repo"
def project(isolated_project: Path) -> Path:
root = isolated_project / "repo"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: test_str_replace_editor_mutations_are_not_read_scanned (line 233) now always passes. project no longer depends on harness, and that test didn't get @pytest.mark.usefixtures("harness") like the other secret-marker tests did.

Without harness, the fixture-sensitive-marker pattern is never written to secret_content_patterns.json, so content read can't match the marker at all. returncode == 0 / empty stdout then holds whether or not str_replace_editor mutations get read-scanned, so a regression that starts scanning create/str_replace/insert would no longer fail.

The PR description says the dsh tests that scan for secret markers declare harness themselves. This one also relies on the marker, but it checks that nothing is blocked. Fix: add @pytest.mark.usefixtures("harness") to that test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in aad21ad. harness is now applied to every test in the dsh module by pytestmark, so the secret marker exists and the negative test can fail again. Same change for hermes and pi.

@github-actions

Copy link
Copy Markdown

Review summary

I reviewed the ruff ignore cleanup and the ARG001 fixes (139 sites). I couldn't run the test suite in this environment, so the points below come from reading the diff.

What checks out

  • provider_adapter.system_message(_event, …): the only caller is Profile.formatter, which passes the event positionally, so renaming the parameter changes nothing.
  • conftest.py: replacing VERIFICATION_TEST_CALLS with the embedded repr path, and splitting out workspace_listing / sandbox_tmp, keep the old behavior.
  • test_trusted_owners_fallback: the module-level pytestmark = usefixtures("api") keeps the network stubbed for every test, the same as the old autouse fixture.

Findings

  • P2: tests/dsh/test_dsh_hook_adapter.py: test_str_replace_editor_mutations_are_not_read_scanned lost the harness fixture, which defines the fixture-sensitive-marker pattern. This negative test now passes whether or not mutations are read-scanned. Add usefixtures("harness") to it.
  • P3: In the dsh, hermes and pi tests, tests that use project without harness now run the adapter with the real HOME and no AGENT_HARNESS_ROOT. That's a loss of test isolation, not a confirmed failure.

Nothing blocks the merge.

These tests read the harness's secret commit policy. They only passed on a
machine that has ~/.claude/hooks; in CI the policy file is missing and the
guard blocks. Declare the harness fixture they need.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pytest.fixture
def project(tmp_path: Path, isolated_project: Path, harness: Path) -> Path:
root = tmp_path / "repo"
def project(isolated_project: Path) -> Path:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Removing harness from project makes test_str_replace_editor_mutations_are_not_read_scanned (line ~236) pass no matter what the code does.

That test writes fixture-sensitive-marker to notes.txt and checks that content read does not block create/str_replace/insert. The marker only counts as a secret because harness writes it into secret_content_patterns.json. It does not appear anywhere in the real agents/hooks/rules policy, and nothing else in that test enables it. Before this PR, project pulled in harness for that reason. Now the test doesn't request harness, so the marker is never treated as a secret. If someone breaks the guard so mutations get read-scanned, the test still passes.

The PR description says the 4 dsh tests that scan for the marker now add usefixtures("harness") themselves. This negative test also needs the marker, but it was missed. Add @pytest.mark.usefixtures("harness") to it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in aad21ad (same change as the other thread): module-level pytestmark applies harness to the dsh, hermes and pi tests, including test_str_replace_editor_mutations_are_not_read_scanned.

@github-actions

Copy link
Copy Markdown

Review summary

Blocking findings (P0/P1): 0

  • P2: In tests/dsh/test_dsh_hook_adapter.py, project no longer depends on harness. As a result, test_str_replace_editor_mutations_are_not_read_scanned passes whether or not the guard works, because fixture-sensitive-marker is only a secret pattern when harness is active. Add usefixtures("harness") to that test. Details are in the inline comment.

Everything else checked out:

  • provider_adapter.system_message now names its unused argument _event. Callers pass it by position, so this doesn't change behaviour.
  • The ruff ignores that were removed had no matching code.
  • The rest of the fixture-to-usefixtures moves don't change what the tests check:
    • herdr, trusted_owners_fallback, skill commands
    • the verification_calls path is now written straight into the stub
    • the split of workspace_listing and sandbox_tmp out of merged
  • The harness fixtures now build their paths from isolated_project. That fixture returns tmp_path, so the paths are the same as before.
  • No security issues found.

🤖 Generated with Claude Code

The project fixture of these modules used to pull in harness, which gives
every test an isolated HOME and policy root. Declaring harness only on some
tests left others on the developer's real HOME and let the negative
str_replace_editor test pass without the secret marker it relies on.

Declare it once per module with pytestmark and drop the per-test markers.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Review summary

No findings. I looked for correctness bugs, security problems, and tests missing for changed behavior.

What I checked:

  • pyproject.toml: The ignore entries removed from the ruff config only switch lint rules back on. The PR reports that lint passes with them enabled.
  • provider_adapter.system_message: The argument is now named _event. Nothing calls it with event= (it is only used as a positional Formatter), so renaming it is safe.
  • harness fixtures (devin, dsh, hermes, pi): They now build their paths from isolated_project. That fixture returns tmp_path, so the paths are unchanged, and isolated_project still sets up before harness removes the rule environment variables. Fixtures listed in usefixtures (module-level or per-test) are set up before the test's own arguments, so harness still runs before project in hermes and pi.
  • Devin project without isolated_project: Every test that uses it also requests run_cli, and run_cli depends on isolated_project. The state-home path is the same value either way.
  • workspace_listing / sandbox_tmp / temporary: The paths are the same as before. Every test that uses temporary still requests merged, so TMPDIR is still set.
  • Fake check in test_static_rules: The only caller (lint_engine.diagnostics) passes two positional arguments, and nothing in agents/ passes readonly= to check_file, so the fake's new two-argument signature is safe.
  • Fake observe_lock: del timeout keeps the signature it replaces.

These changes are test-only refactors, apart from the one argument rename and the config change, so no new tests are needed.

🤖 Generated with Claude Code

PLR0913 with max-args = 3 already caps the total argument count, which
bounds the positional count, so PLR0917 adds nothing. It is active in ruff
0.17 through the PLR prefix, so ignore it for the whole project with that
reason and drop the tests-only entry.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.


@pytest.fixture
def recorded_primary(primary: Path, merged: dict[str, str], tmp_path: Path) -> None:
def recorded_primary(primary: Path, workspace_listing: Path) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] recorded_primary no longer depends on merged, but session_store.register still writes under whatever XDG_STATE_HOME is set when it runs. Nothing autouse in tests/conftest.py or tests/hooks/conftest.py isolates that variable. So isolation now relies on every caller listing "merged" before "recorded_primary". A future test that uses @pytest.mark.usefixtures("recorded_primary") alone, or lists the two in the other order, would write session records into the developer's real state home (~/.local/state) and then fail in a confusing way. All 8 current call sites are correct, so nothing is broken today. A static dependency on a small fixture that only sets the state home would keep the order guaranteed without bundling unrelated paths together.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dbc643e. XDG_STATE_HOME is now set by an autouse state_home fixture in tests/hooks/conftest.py, so it is in place before any fixture runs and no test can write session records into the real state home. The ordering requirement is gone: the tests use plain usefixtures("recorded_primary") again, and the line is removed from merged.

@github-actions

Copy link
Copy Markdown

Review summary

Blocking findings (P0/P1): 0

I reviewed the diff without running anything. Running pytest and ruff was not permitted in this environment.

Checked and found correct:

  • provider_adapter.system_message: renaming the argument to _event changes nothing, because callers pass it by position.
  • Fixture order for the harness / isolated_project adapters (devin, dsh, hermes, pi). Making harness depend on isolated_project keeps the old order, so isolated_project cannot reset env vars that harness changed. The harness in test_provider_adapters.py touches no variable that isolated_project sets, so running it first via usefixtures is safe.
  • devin project dropping isolated_project: every test that uses it also requests run_cli, which still pulls isolated_project in.
  • The verification_record stub now has the calls path written into it. No other code reads VERIFICATION_TEST_CALLS.
  • temporary / sandbox_tmp / workspace_listing: they behave the same as before. TemporaryDirectory is given an explicit dir, so it never reads TMPDIR.
  • The fake check in test_static_rules: lint_engine.diagnostics calls the checker with only two arguments, so removing readonly is safe.
  • The test_an_invalid_program_path_is_rejected parametrize change to pytest.param(..., id=...) is correct.

Non-blocking:

  • [P3] recorded_primary now relies on callers listing merged first to keep its state writes isolated. No autouse fixture sets XDG_STATE_HOME, so using it alone would write to the real state home. See the inline comment.

🤖 Generated with Claude Code

recorded_primary registers a session under XDG_STATE_HOME, which only the
merged fixture set, so its tests had to list merged first or write into the
developer's real state home. Set it once in an autouse state_home fixture and
drop the ordering requirement and the line from merged.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Review summary: no findings (0 blocking)

I reviewed the diff read-only. I could not run pytest or ruff in this environment, so the results below come from reading the code and checking it with grep.

  • provider_adapter.system_message: renaming event to _event is safe. It is only used as a Formatter value, and nothing passes event= as a keyword.
  • test_static_rules check(_kind, path): safe. lint_format only calls check_file through lint_engine.diagnostics, which passes 2 positional arguments.
  • harness / project fixtures (devin, dsh, hermes, pi): isolated_project returns tmp_path, so the home, harness and repo paths are the same as before. run_cli still depends on isolated_project, so dropping that dependency from devin's project changes neither setup order nor isolation.
  • The state_home autouse fixture in tests/hooks/conftest.py: tests that need a different XDG_STATE_HOME still get it. verification_calls and the audit-log tests set their own value, either after the autouse fixture runs or through an explicit env.
  • workspace_listing / sandbox_tmp: these replace the old hard-coded paths and the os.environ read-back with the same values. No leftover VERIFICATION_TEST_CALLS references remain.
  • pytest.param(..., id=...) in test_an_invalid_program_path_is_rejected: correct. The old code wrongly listed a label argument as a fixture.

Moving PLR0917 to the global ignore list relaxes linting for agents/ too. That is a policy choice the PR justifies, not a defect.

@furedea
furedea merged commit 53b1460 into main Nov 10, 2026
22 of 24 checks passed
@furedea
furedea deleted the build/align-ruff-ignores branch November 10, 2026 12:34
furedea added a commit that referenced this pull request Nov 10, 2026
)

## 概要

#74 段階 1B の PR 2.template-python が有効にしている小規模な ruff
規則を,agent-config でも有効にした(ignore から削除).

| 削除した ignore | 違反数 | 対応 |
| ---------------------------------------- | ------ |
------------------------------------------------- |
| I001 | 152 | 自動修正(import の並び替え) |
| E501 | 27 | docstring・コメント・文字列を折り返し,または短縮 |
| PTH(104, 105, 109, 111, 115, 117, 119) | 12 | pathlib へ置換 |
| PERF401 | 3 | `extend` とジェネレータ |
| RUF005 | 3 | アンパック |
| F541 | 1 | 自動修正 |
| FURB162 | 1 | 不要な `replace("Z", ...)` を削除 |
| PLW2901 | 1 | ループ変数の名前を分離 |

残した ignore(`E402`,`INP001`,`PLR2004`,`PLR0917`)のうち,理由を持つ `E402` と
`PLR0917` は,テンプレートと dotfiles と同じく理由を 1 行上の `# CODE: reason`
に書く形にそろえた(#124 の行末コメントから変更,末尾のピリオドなし).

`noqa` と per-file-ignores は追加していない.D/N(PR 3),ARG001 と tests の
PLR0917(c-ac1)はこの PR の範囲外.

## 削除した ignore の元の理由

dotfiles 8428059 で付いたコメントを,agent-config 59b76e7
がそのまま取り込んでいた.各理由が今も成り立つかを確認した.成り立つものはなく,ignore を戻す必要はない.

| ignore | 元の理由(dotfiles 8428059) | 今は成り立たない理由 |
| ------- |
--------------------------------------------------------------- |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
| E501 | 埋め込み HTML/JS テンプレートの長い文字列を保つ | agent-config に埋め込みテンプレートはない.違反
27 件は docstring・コメント・テストの文字列で,意味を変えずに折り返せた |
| I001 | `sys.path` を整える間,スクリプトの import ブロックを安定させる | ruff は `sys.path`
の操作などのコードで import ブロックを分けて整列するので,path 設定の前後の順序は変わらない.hook の import は
path 設定の後でのみ並び替わり,`ty` と全テストが通る |
| PTH | 古いスクリプトが `os.path` を使う.`Path` への移行は別の作業 | その移行がこの PR.12
か所を置換し,未知の `~user` の挙動差は上の変換で扱った |
| PERF401 | バッチ処理のコードは段階的な変更のほうが読みやすい | 違反 3 件は `verify_page` の同形のループで,1
つの `extend` にまとめたほうが読みやすい(バッチ処理のコードではない) |
| RUF005 | パス再構築のコードはリスト連結のほうが明快 | 違反 3
件はタプルの連結とテストのパラメータで,パス再構築ではない.アンパックで同じ読みやすさ |
| F541 | レポートや changelog の書き込みに無害な f 文字列がある | 該当は 1 件で,不要な `f` を外した |
| FURB162 | タイムスタンプのパーサーが末尾の `Z` を明示的に正規化する | 該当はテストの `replace("Z",
"+00:00")` のみ.対象は Python 3.15 で,`fromisoformat` が `Z` を直接読む(テストが通る) |
| PLW2901 | JSONL パーサーが空白除去後に `line` を再利用する | 該当は 1 件で,JSONL
パーサーではなくテストのループ変数 `block`.別名にして解消した |

## 設計上の判断(自明でない修正)

- `os.path.expanduser(pattern)`(shell_paths): `Path` は末尾の `/` や `//`
を正規化し,glob の意味が変わる.先頭セグメントだけ `Path(head).expanduser()` で展開し,残りはそのまま繋ぐ.
- `home_directory`(shell_words): `expanduser("~")` が `"~"`
を返す失敗判定をやめ,`Path.home()` の `RuntimeError` を `UnsupportedSyntax`
に変換する.失敗を値の比較ではなく例外で表す.
- `session_snapshot.link_signature`: `os.readlink` を `Path.readlink`
にしたため,リンク文字列が正規化される(`./x` は `x`,`x/` は `x`,`a//b` は
`a/b`).解決先は同じで,該当する綴りのリンクの署名が 1 度だけ変わる.`os.readlink` は PTH115
に該当し,生の文字列を保つには抑制が要るため,この正規化を承知のうえで受け入れた.
- `verify_page`: 3 つの同形のループを,(出所の表示,リソース列)の対応に対する 1 つの `extend`
にまとめた.メッセージは変わらない.
- `test_skill_commands`: ループ変数を `fenced_block` とし,dedent 後を `block`
とした(PLW2901).
- `test_forbidden_command`: 長い文字列リテラルの重複を `COMPANION` / `HOME_COMPANION`
定数にまとめた.
- 長い docstring は,元の文言を保ったまま,要約と補足に折り返した(`noqa` は使わない).`guard_command.py`
の分割(#128)のあとに rebase
し,`pinned_program_objection`(`command_objections.py`)と
`has_literal_words`(`literal_words.py`)の元の文言を復元した.サイズ上限に合わせた短縮はしていない.
- `Path.expanduser` / `Path.home` は,未知の `~user` で `RuntimeError`
を出す(`os.path.expanduser` は文字のまま返す).この PR が新たに導入した箇所を次のように扱う.
    - `shell_paths.expanded_paths`: `UnexpandableGlob` に変換し,確認(ask)に回す.
    - `shell_words.home_directory`: `UnsupportedSyntax` に変換する.
    - `guard_file.home_expanded`: 未知の `~user` は文字のまま扱い,保護パスに一致させない.
- `provider_adapter.Adapter.main`: 例外の一覧に `RuntimeError` を加え,hook が exit
1(非ブロック)で終わらず,ブロック(exit 2)になるようにした.
- `hook_input.py`,`audit_log.py`,`session_store.py`,`trusted_owners.py`
の `expanduser` は,この PR より前からある呼び出しで,今回の差分では変えていない.

## 確認

- `uv run ruff check` / `ruff format --check`: 通過
- `uv run ty check`: 通過
- `uv run pytest`: 4526 passed, 1 skipped(未知の `~user` の glob を paths
hook に通す回帰テスト,`home_directory` と `shell_paths` の単体テストを含む)
- lefthook の pre-commit(ruff, ty, file-length ほか): 通過

Refs #74

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.

1 participant