@diffci.com/diffci 0.3.31 → 0.3.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +23 -0
  2. package/dist-client/src/client/agent-setup.d.ts +18 -0
  3. package/dist-client/src/client/agent-setup.js +77 -0
  4. package/dist-client/src/client/agent-stop.d.ts +52 -0
  5. package/dist-client/src/client/agent-stop.js +101 -0
  6. package/dist-client/src/client/check-plan-junit.d.ts +25 -0
  7. package/dist-client/src/client/check-plan-junit.js +215 -0
  8. package/dist-client/src/client/check-plan.d.ts +42 -0
  9. package/dist-client/src/client/check-plan.js +143 -0
  10. package/dist-client/src/client/cli.js +288 -13
  11. package/dist-client/src/client/command-batches.d.ts +1 -0
  12. package/dist-client/src/client/command-batches.js +3 -1
  13. package/dist-client/src/client/enforce-misses-collect.js +6 -1
  14. package/dist-client/src/client/enforce-misses.d.ts +3 -2
  15. package/dist-client/src/client/enforce-misses.js +19 -59
  16. package/dist-client/src/client/failure-baseline.js +0 -0
  17. package/dist-client/src/client/full-command.d.ts +8 -0
  18. package/dist-client/src/client/full-command.js +31 -0
  19. package/dist-client/src/client/hook.d.ts +1 -1
  20. package/dist-client/src/client/hook.js +1 -1
  21. package/dist-client/src/client/job-summary.d.ts +7 -0
  22. package/dist-client/src/client/job-summary.js +78 -0
  23. package/dist-client/src/client/observe.d.ts +4 -0
  24. package/dist-client/src/client/observe.js +31 -2
  25. package/dist-client/src/client/report.d.ts +4 -0
  26. package/dist-client/src/client/test-results.js +7 -0
  27. package/dist-client/src/client/verify.d.ts +20 -0
  28. package/dist-client/src/client/verify.js +50 -12
  29. package/dist-client/src/client/watch.d.ts +36 -0
  30. package/dist-client/src/client/watch.js +76 -0
  31. package/dist-client/src/client/working-tree.d.ts +13 -0
  32. package/dist-client/src/client/working-tree.js +40 -1
  33. package/node_modules/@diffci.com/core/README.md +36 -5
  34. package/node_modules/@diffci.com/core/dist/cache/graph-cache.d.ts +1 -1
  35. package/node_modules/@diffci.com/core/dist/cache/graph-cache.js +3 -1
  36. package/node_modules/@diffci.com/core/dist/cache/graph-cache.js.map +1 -1
  37. package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +12 -0
  38. package/node_modules/@diffci.com/core/dist/git/git-diff.js +86 -0
  39. package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
  40. package/node_modules/@diffci.com/core/dist/git/types.d.ts +8 -0
  41. package/node_modules/@diffci.com/core/dist/planner/test-command.js +16 -0
  42. package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
  43. package/node_modules/@diffci.com/core/dist/repo/adapters/index.js +2 -1
  44. package/node_modules/@diffci.com/core/dist/repo/adapters/index.js.map +1 -1
  45. package/node_modules/@diffci.com/core/dist/repo/adapters/python.d.ts +32 -0
  46. package/node_modules/@diffci.com/core/dist/repo/adapters/python.js +273 -0
  47. package/node_modules/@diffci.com/core/dist/repo/adapters/python.js.map +1 -0
  48. package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +2 -0
  49. package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
  50. package/node_modules/@diffci.com/core/dist/repo/file-references.js +21 -0
  51. package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
  52. package/node_modules/@diffci.com/core/dist/repo/graph.d.ts +4 -0
  53. package/node_modules/@diffci.com/core/dist/repo/graph.js +182 -21
  54. package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
  55. package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +1 -0
  56. package/node_modules/@diffci.com/core/dist/repo/impact.js +29 -4
  57. package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
  58. package/node_modules/@diffci.com/core/dist/repo/types.d.ts +5 -0
  59. package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +3 -1
  60. package/node_modules/@diffci.com/core/src/git/git-diff.ts +72 -0
  61. package/node_modules/@diffci.com/core/src/git/types.ts +5 -0
  62. package/node_modules/@diffci.com/core/src/planner/test-command.ts +14 -0
  63. package/node_modules/@diffci.com/core/src/repo/adapters/index.ts +2 -1
  64. package/node_modules/@diffci.com/core/src/repo/adapters/python.ts +252 -0
  65. package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +2 -0
  66. package/node_modules/@diffci.com/core/src/repo/file-references.ts +19 -0
  67. package/node_modules/@diffci.com/core/src/repo/graph.ts +154 -20
  68. package/node_modules/@diffci.com/core/src/repo/impact.ts +27 -4
  69. package/node_modules/@diffci.com/core/src/repo/types.ts +5 -0
  70. package/package.json +3 -2
@@ -114,7 +114,7 @@ function shortestDependentPathToTest(graph: DependencyGraph, changedFilePath: st
114
114
  function collectScriptsAmong(candidates: Iterable<string>, isTestFile: IsTestFile, layout: RepositoryLayout): string[] { const result: string[] = []; for (const path of candidates) { if (isScriptFile(path, layout) && !isTestFile(path)) result.push(path); } return result.sort(); }
115
115
  function makeEvidence(reason: ImpactReason, changedFile: string, message: string, affectedFile?: string, path?: ImpactEvidencePath): ImpactEvidence { return { reason, changedFile, affectedFile, message, path }; }
116
116
 
117
- function classifyChangedFile(file: ChangedFile, isTestFile: IsTestFile, layout: RepositoryLayout, repositoryFiles?: ReadonlySet<string>, referenceResolved: ReadonlySet<string> = new Set()): ChangedImpact["category"] {
117
+ function classifyChangedFile(file: ChangedFile, isTestFile: IsTestFile, layout: RepositoryLayout, repositoryFiles?: ReadonlySet<string>, referenceResolved: ReadonlySet<string> = new Set(), pythonSources: ReadonlySet<string> = new Set()): ChangedImpact["category"] {
118
118
  const path = file.path;
119
119
  const oldPath = file.oldPath;
120
120
  // Content inspection in analyzeGitDelta showed these cannot change how tests run; who reads them is
@@ -124,7 +124,9 @@ function classifyChangedFile(file: ChangedFile, isTestFile: IsTestFile, layout:
124
124
  if (isInfrastructureFile(path) || (oldPath && isInfrastructureFile(oldPath))) return "infrastructure";
125
125
  if (infrastructureRole(path) === "data") return "unknown";
126
126
  if (isDatabaseFile(path) || (oldPath && isDatabaseFile(oldPath))) return "database";
127
- if (isSourceFilePath(path)) {
127
+ // A .py file is code only where the Python adapter modelled it (2026-11-06); elsewhere, such as a
128
+ // script in a JavaScript repository, it stays an unknown file whose readers are resolved by reference.
129
+ if (isSourceFilePath(path) || pythonSources.has(path)) {
128
130
  if (isTestFile(path)) return "test";
129
131
  if (isScriptFile(path, layout)) return "script";
130
132
  if (classifyNextEntryPoint(path, layout)) return "entry-point";
@@ -259,6 +261,7 @@ export class ImpactAnalyzer {
259
261
  private dependencyLockfile: string | undefined;
260
262
  private packageJsonSpecifiersOnly = false;
261
263
  private specifiersOnlyManifests: ReadonlySet<string> = new Set();
264
+ private exportsRemaps: ReadonlyMap<string, { targets: readonly string[]; dataChanged: boolean }> = new Map();
262
265
  private readRepositoryFile: ((path: string) => string | undefined) | undefined;
263
266
  private sortedRepositoryFiles: string[] = [];
264
267
  private compiledProjectCache: CompiledProject[] | undefined;
@@ -348,7 +351,8 @@ export class ImpactAnalyzer {
348
351
  this.dependencyLockfile = delta.analysis.dependencyLockfile;
349
352
  this.packageJsonSpecifiersOnly = delta.analysis.packageJsonSpecifiersOnly === true;
350
353
  this.specifiersOnlyManifests = new Set(delta.analysis.specifiersOnlyManifests ?? []);
351
- const changedImpacts: ChangedImpact[] = delta.files.map((file) => ({ file, category: classifyChangedFile(file, this.isTestFile, this.layout, options.repositoryFiles, referenceResolved), reasons: changedFileReasons(file) }));
354
+ this.exportsRemaps = new Map(Object.entries(delta.analysis.exportsRemaps ?? {}));
355
+ const changedImpacts: ChangedImpact[] = delta.files.map((file) => ({ file, category: classifyChangedFile(file, this.isTestFile, this.layout, options.repositoryFiles, referenceResolved, new Set(profile.pythonSources ?? [])), reasons: changedFileReasons(file) }));
352
356
  const evidence: ImpactEvidence[] = [];
353
357
  const riskSignals: ImpactRiskSignal[] = [];
354
358
  const fallbackReasons: string[] = [...(graphResult.adapterBlockers ?? []), ...testDiscoveryErrors(profile)];
@@ -744,6 +748,19 @@ export class ImpactAnalyzer {
744
748
  this.addAffectedTest(changedPath, test, graph, affectedTests, "DECLARED_INPUT", evidence);
745
749
  }
746
750
  const covered = this.declaredCovered.has(changedPath);
751
+ // An `exports` remap reaches the importers of each subpath it changed, which depend on the subpath's
752
+ // target at HEAD or at the base. A target gone at HEAD is a changed file of this delta or was never
753
+ // importable; one present but outside the graph has unknown importers.
754
+ for (const target of this.exportsRemaps.get(changedPath)?.targets ?? []) {
755
+ if (hasNode(graph, target)) {
756
+ evidence.push(makeEvidence("DEPENDENCY_MANIFEST", changedPath, `${changedPath} remaps an export to ${target}`, target));
757
+ this.processSourceChange(target, graph, profile, affectedSources, affectedEntryPoints, affectedTests, affectedScripts, evidence);
758
+ } else if (this.repositoryFiles?.has(target) ?? true) {
759
+ const message = `${changedPath} remaps an export to ${target}, which is outside the dependency graph; full validation required`;
760
+ riskSignals.push({ level: "critical", reason: "DEPENDENCY_MANIFEST", message, paths: [changedPath] });
761
+ if (!fallbackReasons.includes(message)) fallbackReasons.push(message);
762
+ }
763
+ }
747
764
  // Go's embed metadata is ownership evidence regardless of suffix or documentation naming.
748
765
  // Traverse it before generic unknown/docs classification can discard the dependency.
749
766
  if (this.goEmbedPaths.has(changedPath)) {
@@ -790,7 +807,8 @@ export class ImpactAnalyzer {
790
807
  // A package.json edit limited to dependency requests is covered by dependency selection, like
791
808
  // the lockfile above, so finding no reader is not a gap. Tooling that loads a file naming it
792
809
  // still is (2026-11-02).
793
- const specifiersOnly = (changedPath === "package.json" && this.packageJsonSpecifiersOnly) || this.specifiersOnlyManifests.has(changedPath);
810
+ const specifiersOnly = (changedPath === "package.json" && this.packageJsonSpecifiersOnly) || this.specifiersOnlyManifests.has(changedPath)
811
+ || this.exportsRemaps.get(changedPath)?.dataChanged === false;
794
812
  const options = specifiersOnly ? { allowNoReaders: true, implicitReadersUnresolvable: true } : {};
795
813
  if (this.resolveByReference(changedPath, graph, profile, affectedSources, affectedEntryPoints, affectedTests, affectedScripts, evidence, options)) return;
796
814
  if (covered) return;
@@ -871,6 +889,11 @@ export class ImpactAnalyzer {
871
889
  if (!fallbackReasons.includes(message)) fallbackReasons.push(message);
872
890
  return;
873
891
  }
892
+ // A Python file is also run by name: a JavaScript test or script that calls `python scripts/x.py`
893
+ // names it without importing it. Those readers are added to what the Python graph selects (2026-11-06).
894
+ if (changedPath.endsWith(".py") && profile.pythonSources?.includes(changedPath)) {
895
+ this.resolveByReference(changedPath, graph, profile, affectedSources, affectedEntryPoints, affectedTests, affectedScripts, evidence, { allowNoReaders: true });
896
+ }
874
897
  this.processSourceChange(changedPath, graph, profile, affectedSources, affectedEntryPoints, affectedTests, affectedScripts, evidence);
875
898
  }
876
899
 
@@ -51,6 +51,11 @@ export interface RepositoryProfile {
51
51
  goDependencyPaths?: { sources: string[]; embeds: string[] };
52
52
  /** Maven/JUnit test file to owning reactor module (repo-relative, "." for root). */
53
53
  mavenTestModules?: Record<string, string>;
54
+ /** Python files and pytest test files the Python adapter modelled (adapters/python.ts), and the
55
+ * interpreter it found. Only these `.py` files are code; other `.py` files stay unknown files. */
56
+ pythonSources?: string[];
57
+ pythonTests?: string[];
58
+ pythonInterpreter?: string[];
54
59
  /** Nested modules excluded by an explicit root-module execution scope. Changes here force full CI. */
55
60
  goExcludedModuleRoots?: string[];
56
61
  vueScope?: { packageRoot: string; testConfig: string };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diffci.com/diffci",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "description": "Fail-closed, change-aware verification for AI coding agents with conservative affected-test selection",
5
5
  "keywords": [
6
6
  "ci",
@@ -76,7 +76,8 @@
76
76
  "test": "node scripts/run-tests.mjs"
77
77
  },
78
78
  "dependencies": {
79
- "@diffci.com/core": "git+https://github.com/DiffCI/core.git#d21cb9328c244fcc973364a699000f5f59807f2b",
79
+ "@diffci.com/core": "git+https://github.com/DiffCI/core.git#bad141841d434f1079a2f84216640c6af5f413f9",
80
+ "saxes": "6.0.0",
80
81
  "yaml": "^2.9.0"
81
82
  },
82
83
  "devDependencies": {