Skip to content

[Findings] Tighten CACHE_GUARD / BATCH_GUARD bare-word leak #112

Description

@AndresL230

Summary

The CACHE_GUARD and BATCH_GUARD regexes in src/scanner/local-waste-detector.ts and src/ast/waste/{cache,batch}-detector.ts match the bare words cache and batch within an ±8-line source window. Any fixture (or real-world file) with those words in a docstring, comment, or unrelated identifier silently suppresses findings.

Evidence

What to do

Tighten both guards from bare-word matches to call-shape or assignment matches:

  • CACHE_GUARD: require cache.get(, cache.set(, cacheKey:, useCache(, @cache, @cached, etc. — actual cache-API usage rather than the word.
  • BATCH_GUARD: require batch.create(, .batches., bulk(, chunk(, messageBatches., flushQueue(, enqueue( — actual batching-API usage.

Add explicit positive/negative tests:

  • Negative (must NOT suppress): docstring with the word "cache" or "batch", variable named batchSize, comment mentioning "this is a batch".
  • Positive (must suppress): cache.get(key), await batch.create({...}).

Acceptance criteria

  • CACHE_GUARD and BATCH_GUARD no longer match bare words; only call-shape / API-usage patterns.
  • Existing C1 fixtures (PR-2 / PR-3 / PR-4) continue to behave correctly.
  • New tests under src/test/c1-guard-tightening.test.ts covering both axes.
  • No regression to per-type metrics in benchmark/baseline.json.

Depends on

None (cleanup PR).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/findingsdocs/accuracy/findings.md — calibrated waste detector findingsenhancementNew feature or requestwave/1-findings-qualityC2 + C3 + guard-regex cleanup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions