feat: recover affected tests and extension mapping - #203
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.extensionsincodegraph.config.jsonplus normalization/validation, and threadslanguageExtensionsthrough 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.
Contributor
There was a problem hiding this comment.
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
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
force-pushed
the
recover/affected-extension-main
branch
from
August 3, 2026 16:24
61c3c76 to
d34d585
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
maincodegraph affectedfor deterministic changed-file-to-test selection, including deleted-source traversalVerification
npm run check(231 files, 2,707 tests passed, 19 skipped)node ./dist/cli.js affected src/cli.ts --root . --quiet --cache memoryreturned five candidate test pathsDraft for review; do not merge automatically.