Sdlc/Structural/StaticFactAssertion: stop flagging assert_path_exists and refute_path_exists #1356

Closed
opened 2026-10-25 21:23:06 +00:00 by jared · 2 comments
Owner

Problem

Sdlc/Structural/StaticFactAssertion flags assert_path_exists and refute_path_exists with a literal path. These two assertions check filesystem state at run time. They do not assert a definition. The fix the cop prescribes ("Delete it") deletes a real check.

Observed

Shape: a canonical Minitest assertion (static_fact_call.rb:9-16) that is not a block send, with every argument a literal or constant (static_node.rb:9-17). The cop is registered at .rubocop.yml:330 with no Exclude.

Counterexample: plugins/os/tests/worktree/finish_command_resolves_by_branch_test.rb:22. Sample code that also flags:

def test_file_written
  assert_path_exists "out.txt"
  refute_path_exists "tmp.lock"
end

Reproduce

bundle exec rubocop --only Sdlc/Structural/StaticFactAssertion plugins/os/tests/worktree/finish_command_resolves_by_branch_test.rb

Approach

Fix by shape, in the cop matcher: remove assert_path_exists and refute_path_exists from the canonical assertion list (static_fact_call.rb:12,15). Do not add a config Exclude list or a test-path exclusion.

Required work:

  1. Stop matching the path-existence assertions — check: absent assert_path_exists in plugins/os-sdlc/lib/os_sdlc/cops/structural/static_fact_assertion/static_fact_call.rb

Acceptance criteria

  1. Given assert_path_exists "out.txt" or refute_path_exists "tmp.lock", when the cop runs, then it reports no offense.
  2. Given assert_equal 1, 1, when the cop runs, then it still reports an offense.

Owner sketch

class OsSdlc::Cops::StaticFactCall
end

Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md).

VERDICT: CREATE

Origin

  • Trigger: #1325 zero-false-positive audit of every Sdlc cop.
  • Improvised this session: none
  • Chain: false positive on assert_path_exists ← canonical assertion list includes the path assertions (static_fact_call.rb:12,15) ← DESIGN (plugins/os-sdlc/lib/os_sdlc/cops/structural/static_fact_assertion/static_fact_call.rb)
  • Root candidate: none found; searched StaticFactAssertion, StaticFactCall, static fact, assert_path_exists, refute_path_exists
  • Where: plugins/os-sdlc/lib/os_sdlc/cops/structural/static_fact_assertion/static_fact_call.rb
  • Session: eb98cdcd-6783-46a0-b7df-cf18a8fe2a56
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-ticket-1325/eb98cdcd-6783-46a0-b7df-cf18a8fe2a56.jsonl
## Problem `Sdlc/Structural/StaticFactAssertion` flags `assert_path_exists` and `refute_path_exists` with a literal path. These two assertions check filesystem state at run time. They do not assert a definition. The fix the cop prescribes ("Delete it") deletes a real check. ## Observed Shape: a canonical Minitest assertion (`static_fact_call.rb:9-16`) that is not a block send, with every argument a literal or constant (`static_node.rb:9-17`). The cop is registered at `.rubocop.yml:330` with no Exclude. Counterexample: `plugins/os/tests/worktree/finish_command_resolves_by_branch_test.rb:22`. Sample code that also flags: ```ruby def test_file_written assert_path_exists "out.txt" refute_path_exists "tmp.lock" end ``` ## Reproduce ``` bundle exec rubocop --only Sdlc/Structural/StaticFactAssertion plugins/os/tests/worktree/finish_command_resolves_by_branch_test.rb ``` ## Approach Fix by shape, in the cop matcher: remove `assert_path_exists` and `refute_path_exists` from the canonical assertion list (`static_fact_call.rb:12,15`). Do not add a config Exclude list or a test-path exclusion. Required work: 1. Stop matching the path-existence assertions — check: absent `assert_path_exists` in `plugins/os-sdlc/lib/os_sdlc/cops/structural/static_fact_assertion/static_fact_call.rb` ## Acceptance criteria 1. Given `assert_path_exists "out.txt"` or `refute_path_exists "tmp.lock"`, when the cop runs, then it reports no offense. 2. Given `assert_equal 1, 1`, when the cop runs, then it still reports an offense. ## Owner sketch ```ruby class OsSdlc::Cops::StaticFactCall end ``` Found by the #1325 zero-false-positive audit (docs/plans/class-length-family/sdlc-cop-audit.md). VERDICT: CREATE ## Origin - Trigger: #1325 zero-false-positive audit of every Sdlc cop. - Improvised this session: none - Chain: false positive on `assert_path_exists` ← canonical assertion list includes the path assertions (`static_fact_call.rb:12,15`) ← DESIGN (`plugins/os-sdlc/lib/os_sdlc/cops/structural/static_fact_assertion/static_fact_call.rb`) - Root candidate: none found; searched StaticFactAssertion, StaticFactCall, static fact, assert_path_exists, refute_path_exists - Where: plugins/os-sdlc/lib/os_sdlc/cops/structural/static_fact_assertion/static_fact_call.rb - Session: eb98cdcd-6783-46a0-b7df-cf18a8fe2a56 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-ticket-1325/eb98cdcd-6783-46a0-b7df-cf18a8fe2a56.jsonl
Author
Owner

Work started on branch ticket-1356 via /os-sdlc:implement.

Work started on branch ticket-1356 via /os-sdlc:implement.
Author
Owner

Resolution

Done: StaticFactAssertion no longer flags assert_path_exists / refute_path_exists; both removed from the static-fact call list in static_fact_call.rb.

Evidence: Commit 8afb0dbe on ticket-1356 (implementation 209): new tests in plugins/os-sdlc/tests/cops/static_fact_assertion_test.rb; full suite green; contract-auditor pass.

Follow-ups: none

## Resolution **Done:** StaticFactAssertion no longer flags assert_path_exists / refute_path_exists; both removed from the static-fact call list in static_fact_call.rb. **Evidence:** Commit 8afb0dbe on ticket-1356 (implementation 209): new tests in plugins/os-sdlc/tests/cops/static_fact_assertion_test.rb; full suite green; contract-auditor pass. **Follow-ups:** none
jared closed this issue 2026-10-28 11:45:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#1356
No description provided.