Skip to content

fix(audit-script): catch dynamic import() / require() / .d.ts FP classes (#6872 part 2) - #7330

Merged
mrveiss merged 1 commit into
Dev_new_guifrom
issue-6872b
May 9, 2026
Merged

mrveiss merged 1 commit into
Dev_new_guifrom
issue-6872b

Conversation

@mrveiss

@mrveiss mrveiss commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

Real audit count post-#7244 was 105 (not the masked-0 from the closure proof on #7128 — see #7244 for the postmortem). Sampling those 105 surfaced two more FP classes:

  1. Dynamic ES-module imports in TS/Vue routers: `() => import('@/views/CustomDashboard.vue')`. The audit's regex required a literal space after `import` — missing the `(` form. `CustomDashboard.vue` was flagged with 0 callers despite being wired in `router/index.ts:554`.

  2. TypeScript ambient declaration files (`.d.ts`). These are wired via `tsconfig.json` `include` paths, never via `import` — 0-caller reports are by design.

Fixes

`grep_count_production_callers` regex widened to also match:

Pattern Catches
`import(...X)` JS/TS dynamic ES-module imports
`require(...X)` CommonJS / Vite
`importlib.(...X)` Python dynamic
`import(...X)` Python dynamic

New `is_ambient_type_declaration(path)` helper

Skips `*.d.ts` files in `scan()` — same pattern as #7128b's `is_entry_point_script`.

Test deltas

  • +9 parametrized cases for the widened regex covering each new shape with positive + negative coverage (e.g. `logger.info('CustomDashboard usage')` correctly does NOT match).
  • +4 cases for `is_ambient_type_declaration`.
  • 76/76 audit-script tests pass.

Audit count drop

Stage Count Notes
Original (pre-fixes) 252 feature_routers.py + test_*.py + worktree-skip all conspired
After #7168 (test-prefix + registry) 165 worktree-skip still hid real count
After #7244 (entry-point + worktree-skip) 105 actual real count exposed
After this PR 85 dynamic-imports + .d.ts excluded

The remaining 85 are increasingly likely to be genuine wire-in candidates rather than FPs. Bulk-filing per #6872's original intent is now closer to safe.

Acceptance criteria

Refs #6872 (parent), #7109 (the gap was explicitly listed in this issue's body), #7244 (companion fix that exposed the real count)

🤖 Generated with Claude Code

…ses (#6872 part 2)

Real audit count post-#7244 was 105 (not the masked-0 from the closure
proof on #7128 — see #7244 for the postmortem). Sampling the 105 surfaced
two more FP classes:

1. **Dynamic ES-module imports** in TS/Vue routers:
   `() => import('@/views/CustomDashboard.vue')`. The audit's regex
   required a literal space after `import`, missing the `(` form.
   `CustomDashboard.vue` was flagged with 0 callers despite being
   wired in `router/index.ts:554`.

2. **TypeScript ambient declaration files** (`.d.ts`). These are wired
   via `tsconfig.json` `include` paths, never via `import` — so 0-caller
   reports are by design, not unwired.

Fixes:

- Widen `grep_count_production_callers` regex to also match:
    - `import('…/X')` — JS/TS dynamic ES-module
    - `require('./X')` — CommonJS / Vite
    - `importlib.import_module("X")` / `importlib.<other>("X")` — Python dynamic
    - `__import__("X")` — Python dynamic
- New `is_ambient_type_declaration(path)` helper skips `*.d.ts` files
  in `scan()`.

Tests: +4 cases for `is_ambient_type_declaration`, +9 parametrized cases
for the regex (each new shape has positive + negative coverage).
76/76 audit-script tests pass.

Real audit count drop:
  pre-#7244     :  ???? (silently masked by worktree-skip bug)
  post-#7244    :  165 → was real but had 60+ FPs from worktree paths
  post-rebase   :  105 (post-#7128b on the latest Dev_new_gui)
  this PR adds  : -13 dynamic-import FPs + ~7 .d.ts FPs
  current count :   85

Refs #6872 (parent), #7109 (lazy-import gap explicitly noted in body),
#7244 (companion FP fix that exposed the real count).
@mrveiss
mrveiss merged commit d1e2365 into Dev_new_gui May 9, 2026
1 of 2 checks passed
@mrveiss
mrveiss deleted the issue-6872b branch May 9, 2026 19:40
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

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