Skip to content

feat: recover affected tests and extension mapping - #203

Merged
lzehrung merged 8 commits into
mainfrom
recover/affected-extension-main
Aug 3, 2026
Merged

feat: recover affected tests and extension mapping#203
lzehrung merged 8 commits into
mainfrom
recover/affected-extension-main

Conversation

@lzehrung

@lzehrung lzehrung commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • recover the unmerged commits from P1: add affected tests command #146 and its stacked extension-mapping work on top of current main
  • add codegraph affected for deterministic changed-file-to-test selection, including deleted-source traversal
  • add configurable literal suffix-to-language mappings through CLI, sessions, graph building, caches, and docs
  • integrate both features with the current lazy CLI dispatcher and warm incremental index

Verification

  • npm run check (231 files, 2,707 tests passed, 19 skipped)
  • focused affected/config/session/cache/graph suites: 198 tests passed
  • smoke: node ./dist/cli.js affected src/cli.ts --root . --quiet --cache memory returned five candidate test paths

Draft for review; do not merge automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a deterministic “affected tests” workflow and restores/extends extension-to-language mapping support so custom literal suffixes participate consistently in discovery, indexing, graph building, cache keys, and graph delta behavior.

Changes:

  • Introduces codegraph affected (CLI plumbing + help/docs) with JSON/quiet output, depth-limited reverse-dependency traversal, filtering, stdin input, and git base/head diff input (including deleted-path traversal).
  • Adds languages.extensions in codegraph.config.json plus normalization/validation, and threads languageExtensions through sessions/agent sessions/indexer/graph builder/SQL edge collection.
  • Updates cache/manifest compatibility and graph-delta computation so mapping changes invalidate/recompute the right artifacts, with extensive new/updated tests.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/session.test.ts Verifies session build-option normalization and config-mapping application/reuse behavior.
tests/project-file-discovery.test.ts Adds POSIX-only coverage for case-sensitive ignore globs (including symlink crawling).
tests/graph-delta.test.ts Ensures graph delta reports edge changes when mappings change without file edits.
tests/codegraph-config.test.ts Adds validation/normalization tests for languages.extensions and cache-option comparisons.
tests/cli-command-modules.test.ts Ensures command module handlers forward languageExtensions correctly.
tests/cache-invalidation.test.ts Covers incremental discovery and graph/cache recomputation when mappings change.
tests/agent-session.test.ts Verifies agent session discovery/indexing honors config/programmatic mappings.
tests/affected.test.ts New end-to-end coverage for codegraph affected behaviors and outputs.
src/sql/sourceGraph.ts Makes SQL corpus/edge collection respect languageExtensions mapping.
src/session.ts Normalizes session identity to treat language-extension mappings consistently.
src/review/deleted.ts Generalizes deleted-import importer discovery and re-derives test importers via filtering.
src/languages/filePrep.ts Threads languageExtensions into file preparation so remapped suffixes parse correctly.
src/languages.ts Adds mapping normalization/validation helpers and extends supportForFile/languageForFile.
src/indexer/types.ts Extends BuildOptions with languageExtensions and re-exports relevant types.
src/indexer/parse-context.ts Passes languageExtensions into file preparation for indexing.
src/indexer/imports.ts Passes languageExtensions through import collection path.
src/indexer/build-workers.ts Threads languageExtensions into worker-side file preparation.
src/indexer/build-index.ts Extends discovery patterns, cache signatures, SQL handling, and graph delta for mappings.
src/indexer/build-cache/options.ts Normalizes/compares language-extension mappings for manifest compatibility.
src/indexer/build-cache/module-cache.ts Ensures bloom filter build uses mapped language support.
src/indexer/build-cache.ts Re-exports normalizeLanguageExtensions from build-cache surface.
src/graph-edge-collector.ts Uses mapped language support for SQL edge routing and file prep.
src/graph-builder.ts Ensures SQL fact cache and edge collection honor languageExtensions.
src/config.ts Adds languages.extensions config parsing + validation + normalization.
src/cli/options.ts Registers affected schema and CLI value parsing for --filter.
src/cli/inspect.ts Threads languageExtensions into inspect/hotspots and language counts.
src/cli/index.ts Threads languageExtensions into index command build options.
src/cli/help.ts Adds affected help text and updates suggested commands/examples.
src/cli/graphDelta.ts Forwards languageExtensions into graph-delta handler options.
src/cli/commandCatalog.ts Registers affected in command catalog.
src/cli/affected.ts Implements the affected command (inputs, traversal, filtering, outputs).
src/cli.ts Wires affected into dispatcher; propagates config mappings into CLI build options and discovery patterns.
src/agent/session.ts Extends agent session file planning/build options with languageExtensions + discovery patterns.
README.md Documents affected as the recommended “which tests should I run?” workflow.
docs/plans/2026-07-03-16-config-extension-mapping.md Updates plan notes for literal suffix rules and non-remappable SFC suffixes.
docs/library-api.md Documents passing languageExtensions from config into programmatic builds.
docs/cli.md Documents languages.extensions config and the new affected command usage/semantics.
codegraph-skill/codegraph/SKILL.md Updates skill surface/docs to include affected and mapping behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/indexer/build-index.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/indexer/build-index.ts:596

  • Filtering SQL files now calls supportForFile() for every project file, which is significantly more expensive than the prior extname check (it normalizes/sorts extension maps and may read samples for .h files). When no languageExtensions are configured (common case), this is avoidable overhead during indexing.
  const sqlFiles = normalizedFiles
    .filter((file) => supportForFile(file, opts?.languageExtensions)?.id === "sql")
    .sort((left, right) => left.localeCompare(right));

src/languages.ts:133

  • supportForFile() always runs mappedSupportForFile(), which normalizes/sorts the extension map even when no extension map is provided. Given how frequently supportForFile() is called during indexing, short-circuiting when extensionMap is undefined avoids unnecessary work in the default configuration.
export function supportForFile(
  filename: string,
  extensionMap?: LanguageExtensionMap | undefined,
): LanguageSupport | undefined {
  const mapped = mappedSupportForFile(filename, extensionMap);
  if (mapped) return mapped;
  const ext = path.extname(filename).toLowerCase();

@lzehrung
lzehrung marked this pull request as ready for review August 3, 2026 16:20
* Add configurable language extension mapping

* Address Copilot review: treat empty languageExtensions as unset, enforce dot-prefixed extension keys consistently

* Address review: consolidate languageExtensions normalization; fix disk cache NUL-byte truncation bug

* Address extension mapping review feedback

* Normalize language extension target IDs

* Scope extension case matching to generated patterns
@lzehrung
lzehrung force-pushed the recover/affected-extension-main branch from 61c3c76 to d34d585 Compare August 3, 2026 16:24
@lzehrung
lzehrung merged commit 7b454ae into main Aug 3, 2026
1 check passed
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.

2 participants