Skip to content

fix: bound TypeScript semantic analysis to scan corpus#61

Merged
alxxjohn merged 2 commits into
mainfrom
fix/typescript-semantic-monorepo-scan
Jul 23, 2026
Merged

fix: bound TypeScript semantic analysis to scan corpus#61
alxxjohn merged 2 commits into
mainfrom
fix/typescript-semantic-monorepo-scan

Conversation

@alxxjohn

@alxxjohn alxxjohn commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes slow TypeScript semantic analysis in large monorepos without a root tsconfig.json.

TheExample repo configuration scans the repository root and excludes node_modules, but Codeguard’s TypeScript semantic fallback previously bypassed the
shared exclusion-aware corpus. When no root tsconfig.json existed, it recursively discovered TypeScript/JavaScript files itself—including dependencies and
generated output.

This caused the semantic analyzer to consider ~26,953 JS/TS files in example repo, including ~26,505 files under node_modules, instead of the ~448 eligible project source files.

Changes

  • Pass the runner’s shared, exclusion-aware corpus file list to TypeScript semantic analysis.

    • TypeScript semantic analysis now uses only Codeguard-eligible JS/TS source files.
    • The fallback no longer recursively discovers the entire target tree in normal Codeguard scans.
    • Existing direct callers without a runner context retain the prior fallback behavior.
  • Deduplicate concurrent TypeScript semantic analysis.

    • Quality, design, and security sections can request the same target analysis concurrently.
    • They now share one in-flight semantic run rather than spawning duplicate Node/TypeScript processes.
  • Split semantic-analysis responsibilities into focused files.

    • typescript_semantic.go: semantic execution and result handling.
    • typescript_semantic_flight.go: cache and concurrent-flight coordination.
    • typescript_semantic_sources.go: corpus-root selection and context integration.

Validation

  • go test ./internal/codeguard/checks/support ./tests/checks
  • go test -race ./internal/codeguard/checks/support
  • Built Codeguard from this branch and ran a full self-scan.
    • Exit code: 0
    • No Codeguard finding remains for the changed TypeScript semantic analyzer files.
    • Existing repository-wide warnings remain unchanged.

Performance result

Measured against Example repo with a full, cache-warm scan:

Version Full scan time
━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━
Before ~28 seconds
───────────── ────────────────
This branch 5.24 seconds

The expected CI impact is larger on cold/constrained Buildkite workers because the previous implementation could create multiple TypeScript programs over
node_modules.

Commits

  • f473e6e fix: bound TypeScript semantic analysis to scan corpus
  • 3232118 refactor: split TypeScript semantic helpers

@alxxjohn
alxxjohn merged commit 685cf99 into main Jul 23, 2026
14 checks passed
@alxxjohn
alxxjohn deleted the fix/typescript-semantic-monorepo-scan branch July 23, 2026 23:53
alxxjohn added a commit that referenced this pull request Jul 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.2.1](v1.2.0...v1.2.1)
(2026-07-23)


### Bug Fixes

* bound TypeScript semantic analysis to scan corpus
([f473e6e](f473e6e))
* bound TypeScript semantic analysis to scan corpus
([#61](#61))
([685cf99](685cf99))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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