Skip to content

Fixture: Vitest config change that only adds a reporter #53

Closed

Description

@adityankale190895

Context: on a replay of one production app's history, DiffCI fell back to the full suite on 58% of commits, mostly because config, package.json, workflow or lockfile changes forced it to. Narrowing those safely is the main open problem.

vitest.config.* matches CONFIG_PATTERNS, so any edit runs everything. A common agent edit, adding a reporter or changing testTimeout, can't change which tests are affected. Add a synthetic-repo fixture in tests/repo/ that records today's behaviour (full fallback) and documents the case in docs/design/ as a candidate for narrowing. The fixture is the contribution; narrowing it is a follow-up.


New to DiffCI? See CONTRIBUTING.md: add a synthetic fixture, run npm test, and sign off commits with git commit -s. Comment here to claim the issue.

Activity

  1. added
    enhancement
    good first issue
    on Oct 29, 2026
  2. robertwmccarty-caelum commented on Oct 30, 2026

    @robertwmccarty-caelum
    Contributor

    Test-backed contribution for issue #53 (not a PR; no repository write access). I created the requested synthetic git-repository fixture against main@2d5cc05d459b9c59e46ba22b5ecc07ba0ce946f0 and ran it locally.

    Observed: A reporter-only edit and a testTimeout-only edit to vitest.config.ts each still trigger configChanged=true, CONFIG_GLOBAL, and fallbackRequired=true. Both tests pass (2/2); npm run typecheck also passes. These are assertions about DiffCI's current conservative behavior, not claims that skipping these edits is safe.

    Reproduce from that commit: save the fixture below as tests/repo/vitest-config-fallback.test.ts, run npm ci, then node --import tsx --test tests/repo/vitest-config-fallback.test.ts and npm run typecheck.

    Relevant implementation: config classification and fallback signal.

    Copyable, tested regression fixture (TypeScript)
    // SPDX-License-Identifier: MIT
    // Regression fixture for issue #53: a non-selection Vitest config edit still falls back.
    import { strict as assert } from "node:assert";
    import { execFileSync } from "node:child_process";
    import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
    import { tmpdir } from "node:os";
    import { dirname, join } from "node:path";
    import { describe, it } from "node:test";
    import { analyzeGitDelta } from "../../src/git/git-diff.js";
    import { buildDependencyGraph } from "../../src/repo/graph.js";
    import { ImpactAnalyzer } from "../../src/repo/impact.js";
    import { repositoryFileReader } from "../../src/repo/file-references.js";
    
    function write(root: string, path: string, content: string): void {
      const full = join(root, path);
      mkdirSync(dirname(full), { recursive: true });
      writeFileSync(full, content);
    }
    function git(root: string, ...args: string[]): string {
      return execFileSync("git", args, { cwd: root, encoding: "utf8" }).trim();
    }
    const config = (reporter: string, timeout: number) =>
      "import { defineConfig } from 'vitest/config';\n" +
      "export default defineConfig({ test: { include: ['src/**/*.test.ts'], " +
      "reporters: ['" + reporter + "'], testTimeout: " + timeout + " } });\n";
    
    describe("Vitest config-only changes: conservative fallback (#53)", () => {
      for (const testCase of [
        { name: "reporter-only", changed: config("verbose", 5000) },
        { name: "timeout-only", changed: config("default", 10000) },
      ]) {
        it(testCase.name + " edit still requests the full test suite", async () => {
          const root = mkdtempSync(join(tmpdir(), "diffci-vitest-config-"));
          try {
            git(root, "init", "--quiet");
            git(root, "config", "user.email", "[email protected]");
            git(root, "config", "user.name", "DiffCI fixture");
            write(root, "package.json", JSON.stringify({
              name: "vitest-config-fixture", private: true, type: "module",
              scripts: { test: "vitest run" }, devDependencies: { vitest: "^3.0.0" },
            }));
            write(root, "src/adder.ts", "export const add = (a: number, b: number) => a + b;\n");
            write(root, "src/adder.test.ts",
              "import { test, expect } from 'vitest';\n" +
              "import { add } from './adder';\n" +
              "test('adds', () => expect(add(1, 2)).toBe(3));\n");
            write(root, "vitest.config.ts", config("default", 5000));
            git(root, "add", "-A");
            git(root, "commit", "--quiet", "-m", "baseline");
            const baseSha = git(root, "rev-parse", "HEAD");
            write(root, "vitest.config.ts", testCase.changed);
            git(root, "add", "-A");
            git(root, "commit", "--quiet", "-m", testCase.name);
            const headSha = git(root, "rev-parse", "HEAD");
    
            const analyzed = await analyzeGitDelta({ repoPath: root, baseSha, headSha });
            assert.equal(analyzed.success, true);
            if (!analyzed.success) return;
            const delta = analyzed.delta;
            assert.deepEqual(delta.files.map((f) => f.path), ["vitest.config.ts"]);
            assert.equal(delta.analysis.configChanged, true);
            assert.deepEqual(delta.analysis.signalPaths?.config, ["vitest.config.ts"]);
    
            const graph = await buildDependencyGraph({ repoPath: root, excludeDirs: [".git", "node_modules"] });
            const impact = new ImpactAnalyzer().analyze(delta, graph, graph.profile, {
              repositoryFiles: analyzed.inventory?.files,
              readRepositoryFile: repositoryFileReader(root),
            });
            assert.equal(impact.fallbackRequired, true);
            assert.ok(impact.riskSignals.some((s) => s.reason === "CONFIG_GLOBAL"));
            assert.ok(impact.fallbackReasons.some((r) => /Configuration file\(s\) changed/.test(r)));
          } finally {
            rmSync(root, { recursive: true, force: true });
          }
        });
      }
    });

    Narrowing design note: only consider a later optimization when old/new config shapes are statically recognizable, the sole changed field is known non-selection metadata, and test inclusion/projects/workspaces/CI invocation remain provably identical. Custom reporters can have side effects; changing timeouts can affect pass/fail. Dynamic configs or unsupported fields must keep the full fallback. The fixture does not execute Vitest or prove arbitrary config changes safe.

    Attribution: prepared with AI assistance for a human BuddyLists / Linked AIs operator; not an autonomous-agent account or claim of independent identity. No changes were made to your repository.

  3. adityankale190895 commented on Oct 30, 2026

    @adityankale190895
    MemberAuthor

    Thanks, this is a useful fixture. I checked it against main@2d5cc05: both cases pass, npm run typecheck is clean, and both fail if vitest.config.* is removed from the config patterns in src/git/git-diff.ts, so it guards the behavior it describes.

    You don't need write access to contribute. Fork DiffCI/core, add the file at tests/repo/vitest-config-fallback.test.ts, and open a PR from your fork that references #53 (CONTRIBUTING.md has the steps). A PR records that you're contributing it under the repository's MIT terms, and you get credit in the history. Before opening it, please run npm test, npm run build and npm run audit:boundary as well.

    I agree with your design note. Any future narrowing should keep the full fallback unless the old and new configs are both statically recognizable and the only change is to non-selection fields. This fixture pins the conservative behavior until then.

    If you'd prefer not to open a PR, let me know and I'll add it myself and credit this comment.

  4. robertwmccarty-caelum commented on Oct 30, 2026

    @robertwmccarty-caelum
    Contributor

    Thanks for checking the fixture and offering the maintainer integration path. I reran the exact fixture from my earlier comment on a clean checkout of 2d5cc05d459b9c59e46ba22b5ecc07ba0ce946f0 (Node 24.22.1, isolated sandbox, npm ci successful).

    Verified results

    • node --import tsx --test tests/repo/vitest-config-fallback.test.ts: 2/2 pass
    • npm run typecheck: pass
    • npm test: 594/594 pass, 88 suites
    • npm run build: pass
    • npm run audit:boundary: initially fails, Outside reviewed release manifest: tests/repo/vitest-config-fallback.test.ts.

    Required companion change: Add "tests/repo/vitest-config-fallback.test.ts", to the files array in release-files.json, immediately before "tests/repo/workspaces.test.ts". With that one-line addition, I reran npm run audit:boundary: pass (225 reviewed files), and reran the fixture: 2/2 pass.

    This is a test-backed, AI-assisted contribution through the authorized account, not a claim of independent human code review. I won't submit a fork PR or sign a DCO attestation on someone else's behalf. Please use your offered maintainer-addition path if you want to incorporate the fixture, with credit to the original issue comment. Both files remain uncommitted in my isolated test environment; no production files were changed.

  5. adityankale190895 commented on Oct 30, 2026

    @adityankale190895
    MemberAuthor

    Added in #65 (a1b95b3), crediting your comment with a Co-authored-by trailer. Your release-files.json note was right; the entry is in. I also wrote up the narrowing conditions from your design note in docs/design/config-narrowing.md, which completes the issue. Thanks for the fixture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions