Skip to content

async-supervision scan regex misses compound #[cfg(all(test, feature = ...))] gates #6468

Description

@bug-ops

Finding

The mandatory tokio::spawn and blocking-pattern awk scans in .claude/rules/continuous-improvement.md (Async Supervision Audit section) only recognize the literal #[cfg(test)] attribute immediately followed by mod name { on the next line. Any test module gated by a compound expression — #[cfg(all(test, feature = "..."))] — is not detected as test-only, so every tokio::spawn inside it is counted as a production call site.

This was first identified in ci-1415 for one file (crates/zeph-durable/src/backend/local.rs, gated #[cfg(all(test, feature = "sqlite"))], 4 false positives). This cycle (ci-1418) found the same class recurring in two more files:

  • src/gateway_spawn.rs#[cfg(all(test, feature = "gateway"))] at line 360 — 5 false positives (lines with let forwarder = tokio::spawn(forward_webhooks(...))), present even at the ci-1415 baseline and never subtracted.
  • src/channel.rs#[cfg(all(test, feature = "tui"))] at line 289 — 1 false positive (elicit_task spawn inside app_channel_forwards_elicit_to_real_implementation), newly added in this cycle's window.

Impact

The raw scan count grew from 83 (ci-1415, HEAD 3aed7063) to 89 (ci-1418, HEAD c0fc51ed6), which on its face looks like a +6 regression against the documented baseline. Manual reconciliation (diffing old/new trees with git archive, checking each new hit's surrounding #[cfg(...)]) showed the true count of genuine non-test, non-EXEMPT production spawn sites is flat at 75 in both trees — the entire raw delta is test-code growth colliding with this blind spot. No actual regression occurred, but confirming that required a manual audit that the documented scan command was supposed to make unnecessary. The ci-1415 "79 true call sites" figure documented in continuous-improvement.md was itself already 4 too high (the gateway_spawn.rs false positives were present but unrecognized at that baseline too).

Location

.claude/rules/continuous-improvement.md, Async Supervision Audit section — the awk scan command's test-module detector:

/^[[:space:]]*#\[cfg\(test\)\]/ { pending_cfg=1; next }

Suggested fix

Broaden the detector regex to also match #[cfg(all(test, ...))] (and ideally any #[cfg(...)] whose condition list contains a bare test token), e.g.:

/^[[:space:]]*#\[cfg\(test\)\]/ { pending_cfg=1; next }
/^[[:space:]]*#\[cfg\(all\([^)]*\btest\b[^)]*\)\)\]/ { pending_cfg=1; next }

Re-run both scans after the fix, spot-check the newly-excluded lines (per the file's own "re-validate exclusions" convention), and record the corrected true baseline (currently 75, not 79/80) in continuous-improvement.md.

Why

Each CI cycle currently re-derives this by hand from a stale/wrong baseline, costing analyst time and risking a false-positive regression report or a masked real one in a future cycle with less careful reconciliation.

Metadata

Metadata

Assignees

Labels

P2High value, medium complexityarchArchitecture and designtech-debtTechnical debt

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions