Skip to content

Enforce the thread-safe collector rather than rely on remembering it - #51

Merged
amrali-eg merged 1 commit into
masterfrom
fix/enforce-entry-sink
Aug 27, 2026
Merged

Enforce the thread-safe collector rather than rely on remembering it#51
amrali-eg merged 1 commit into
masterfrom
fix/enforce-entry-sink

Conversation

@amrali-eg

Copy link
Copy Markdown
Owner

Make the rule enforced, not remembered

The concurrent-callback contract was already documented, and was still broken in twenty test files. Documenting it again would be the same bet.

HarnessInvariantTests reads the test sources and fails the build when a List's Add is handed to ScanDirectory or ConvertFiles — the two calls whose callbacks the engine documents as concurrent.

Scoped deliberately

The first version was not, and produced seven false positives:

  • DirectoryTraversalWarningTests passes onWarning: warnings.Add to DirectoryTraversal.EnumerateFiles(...).ToList() — a plain sequential enumeration. Not this rule's business.
  • ScanEngineValidationTests already used EntrySink, but an unrelated List named entries elsewhere in the same file condemned it. Declarations now resolve to the nearest preceding one.

A rule that flags correct code is a rule people learn to ignore.

It checks itself

Two assertions about the search, not just its result:

  • It found call sites at all. A search looking in the wrong place is indistinguishable from a clean pass.
  • EntrySink is still in use. A ban with nothing to point at is one people work around.

Verified against a real violation

Reverting one file to the old pattern:

ConversionIdempotencyTests.cs:41: 'entries.Add' is a List's Add handed to a concurrent callback

File and line, then reverted.

424 passing.

🤖 Generated with Claude Code

The concurrent-callback contract was documented and still broken in twenty test
files. Documenting it again would be the same bet.

HarnessInvariantTests reads the test sources and fails when a List's Add is
handed to ScanDirectory or ConvertFiles, the two calls whose callbacks the engine
documents as concurrent. Scoped to those: callbacks passed to a plain sequential
enumeration are not this rule's business, and flagging them would make it noise
people learn to ignore. The first version was not scoped and produced seven false
positives, including a file whose EntrySink was condemned by an unrelated List of
the same name elsewhere in it - so declarations are now resolved to the nearest
one before the use.

Two things the rule asserts about itself. That it found call sites to examine at
all, because a search looking in the wrong place is indistinguishable from a
clean result. And that EntrySink is still actually used, because a ban with
nothing to point at is one people work around.

Verified against a deliberately reintroduced violation: it names the file and
line.

424 passing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@amrali-eg
amrali-eg merged commit 225b31c into master Aug 27, 2026
1 check passed
@amrali-eg
amrali-eg deleted the fix/enforce-entry-sink branch August 27, 2026 03:49
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