@boringparts/verule 0.1.0 → 0.2.0

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.
package/dist/session.js CHANGED
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { existsSync, realpathSync } from "node:fs";
3
3
  import { resolve } from "node:path";
4
4
  import { performance } from "node:perf_hooks";
5
- import { defineAdapter as tssaeDefineAdapter, defineModel as tssaeDefineModel, extractBasisEvidence, openProject, syntaxLocationOf, } from "tssae";
5
+ import { extractBasisEvidence, openProject, syntaxLocationOf, } from "tssae";
6
6
  import { createAdditionalInputRegistry, createScopedAdditionalInputRegistrar, validateAdditionalInputPaths, } from "./additional-inputs.js";
7
7
  import { INLINE_IGNORE_RULE_ID, parseInlineIgnoreDirectives, resolveInlineIgnores, } from "./inline-ignore.js";
8
8
  import { ObservationCollector, normalizeObserveConfig, normalizeTargetSpec, } from "./observation.js";
@@ -59,52 +59,6 @@ function validateRules(rules) {
59
59
  }
60
60
  return [...rules];
61
61
  }
62
- /** Validates a project model definition and attaches provenance metadata. */
63
- export function defineModel(model) {
64
- return invokeProjectSync(() => tssaeDefineModel(model));
65
- }
66
- function validateModels(models) {
67
- const seen = new Set();
68
- const validated = [];
69
- for (const model of models) {
70
- const normalized = defineModel(model);
71
- if (seen.has(normalized.id)) {
72
- throw new VeruleExecutionError("INVALID_CONFIG", `Duplicate model id: "${normalized.id}".`);
73
- }
74
- seen.add(normalized.id);
75
- validated.push(normalized);
76
- }
77
- return validated;
78
- }
79
- function validateAdapters(adapters) {
80
- const seen = new Set();
81
- const validated = [];
82
- for (const adapter of adapters) {
83
- const normalized = invokeProjectSync(() => tssaeDefineAdapter(adapter));
84
- if (seen.has(normalized.id)) {
85
- throw new VeruleExecutionError("INVALID_CONFIG", `Duplicate adapter id: "${normalized.id}".`);
86
- }
87
- seen.add(normalized.id);
88
- validated.push(normalized);
89
- }
90
- return validated;
91
- }
92
- function validateAdapterPackageNames(packageNames) {
93
- const seen = new Set();
94
- const normalized = [];
95
- for (const rawName of packageNames) {
96
- if (typeof rawName !== "string" || rawName.trim() === "") {
97
- throw new VeruleExecutionError("INVALID_CONFIG", "Adapter package names must be non-empty strings.");
98
- }
99
- const packageName = rawName.trim();
100
- if (seen.has(packageName)) {
101
- throw new VeruleExecutionError("INVALID_CONFIG", `Duplicate adapter package name: "${packageName}".`);
102
- }
103
- seen.add(packageName);
104
- normalized.push(packageName);
105
- }
106
- return normalized;
107
- }
108
62
  function selectRules(baseRules, ruleIds) {
109
63
  if (!ruleIds || ruleIds.length === 0) {
110
64
  return baseRules;
@@ -143,13 +97,6 @@ export function defineConfig(config) {
143
97
  throw new VeruleExecutionError("INVALID_CONFIG", '"projects" must contain at least one tsconfig path when specified.');
144
98
  }
145
99
  const rules = validateRules(config.rules ?? []);
146
- const models = validateModels(config.models ?? []);
147
- const configuredAdapters = config.adapters ?? [];
148
- const adapters = validateAdapters(configuredAdapters.filter((adapter) => typeof adapter !== "string"));
149
- const adapterPackages = validateAdapterPackageNames([
150
- ...("adapterPackages" in config ? config.adapterPackages : []),
151
- ...configuredAdapters.filter((adapter) => typeof adapter === "string"),
152
- ]);
153
100
  const additionalInputs = validateAdditionalInputPaths(config.additionalInputs);
154
101
  return {
155
102
  ...(config.tsconfig !== undefined ? { tsconfig: config.tsconfig } : {}),
@@ -157,9 +104,6 @@ export function defineConfig(config) {
157
104
  ? { projects: [...config.projects] }
158
105
  : {}),
159
106
  rules,
160
- models,
161
- adapters,
162
- adapterPackages,
163
107
  additionalInputs,
164
108
  };
165
109
  }
@@ -190,55 +134,17 @@ function summarizeRule(rule) {
190
134
  })),
191
135
  };
192
136
  }
193
- function summarizeModel(model) {
194
- return {
195
- id: model.id,
196
- ...(model.version !== undefined ? { version: model.version } : {}),
197
- digest: sha256Prefix(stableSerialize({
198
- id: model.id,
199
- version: model.version ?? null,
200
- description: model.description ?? null,
201
- facts: model.facts ?? null,
202
- ...(model.instanceBehaviors !== undefined
203
- ? { instanceBehaviors: model.instanceBehaviors }
204
- : {}),
205
- ...(model.cleanupOperations !== undefined
206
- ? { cleanupOperations: model.cleanupOperations }
207
- : {}),
208
- ...(model.lifecycleEvents !== undefined
209
- ? { lifecycleEvents: model.lifecycleEvents }
210
- : {}),
211
- })),
212
- };
213
- }
214
- function summarizeAdapter(adapter) {
215
- return {
216
- id: adapter.id,
217
- version: adapter.version ?? null,
218
- provides: adapter.provides
219
- .map((provider) => provider.factType.id)
220
- .toSorted(),
221
- };
222
- }
223
- function computeReportIdentity(snapshotDigest, entries, rules, models, additionalInputs = [], adapters = [], adapterPackages = []) {
137
+ function computeReportIdentity(snapshotDigest, entries, rules, additionalInputs = []) {
224
138
  const ruleSummaries = rules.map(summarizeRule);
225
- const modelSummaries = models.map(summarizeModel);
226
- const adapterSummaries = adapters
227
- .map(summarizeAdapter)
228
- .toSorted((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
229
139
  const configDigest = sha256Prefix(stableSerialize({
230
140
  entries,
231
141
  rules: ruleSummaries,
232
- models: modelSummaries,
233
142
  ...(additionalInputs.length > 0 ? { additionalInputs } : {}),
234
- ...(adapterSummaries.length > 0 ? { adapters: adapterSummaries } : {}),
235
- ...(adapterPackages.length > 0 ? { adapterPackages } : {}),
236
143
  }));
237
144
  return {
238
145
  snapshotDigest,
239
146
  configDigest,
240
147
  rules: ruleSummaries,
241
- models: modelSummaries,
242
148
  };
243
149
  }
244
150
  function resolveCheckpointLocation(target) {
@@ -255,15 +161,6 @@ function resolveNextConfig(current, options) {
255
161
  return defineConfig(options.config);
256
162
  }
257
163
  const rules = options?.rules ? validateRules(options.rules) : current.rules;
258
- const models = options?.models
259
- ? validateModels(options.models)
260
- : current.models;
261
- const adapters = options?.adapters
262
- ? validateAdapters(options.adapters.filter((adapter) => typeof adapter !== "string"))
263
- : current.adapters;
264
- const adapterPackages = options?.adapters
265
- ? validateAdapterPackageNames(options.adapters.filter((adapter) => typeof adapter === "string"))
266
- : current.adapterPackages;
267
164
  const additionalInputs = options?.additionalInputs !== undefined
268
165
  ? validateAdditionalInputPaths(options.additionalInputs)
269
166
  : current.additionalInputs;
@@ -274,9 +171,6 @@ function resolveNextConfig(current, options) {
274
171
  return {
275
172
  projects: [...options.entries],
276
173
  rules,
277
- models,
278
- adapters,
279
- adapterPackages,
280
174
  additionalInputs,
281
175
  };
282
176
  }
@@ -284,9 +178,6 @@ function resolveNextConfig(current, options) {
284
178
  ...(current.tsconfig !== undefined ? { tsconfig: current.tsconfig } : {}),
285
179
  ...(current.projects !== undefined ? { projects: current.projects } : {}),
286
180
  rules,
287
- models,
288
- adapters,
289
- adapterPackages,
290
181
  additionalInputs,
291
182
  };
292
183
  }
@@ -304,7 +195,6 @@ export async function openSession(options) {
304
195
  : defineConfig({});
305
196
  const absCwd = resolve(options.cwd);
306
197
  const canonicalCwd = canonicalizeDir(absCwd);
307
- let adapterResolutionRoot = resolve(options.adapterResolutionRoot ?? absCwd);
308
198
  const sessionObserve = normalizeObserveConfig(options.observe, options.observeLimit);
309
199
  let openIoMetrics;
310
200
  const openStart = performance.now();
@@ -316,13 +206,7 @@ export async function openSession(options) {
316
206
  ...(normalizedConfig.projects !== undefined
317
207
  ? { projects: normalizedConfig.projects }
318
208
  : {}),
319
- models: normalizedConfig.models,
320
- adapters: [
321
- ...normalizedConfig.adapters,
322
- ...normalizedConfig.adapterPackages,
323
- ],
324
209
  additionalInputs: normalizedConfig.additionalInputs,
325
- adapterResolutionRoot,
326
210
  ...(sessionObserve.mode !== "off"
327
211
  ? {
328
212
  observe: sessionObserve,
@@ -338,6 +222,7 @@ export async function openSession(options) {
338
222
  };
339
223
  let closed = false;
340
224
  let pendingOpenIoMetrics = openIoMetrics;
225
+ const pendingUpdateIoMetrics = [];
341
226
  let pendingOpenDurationMs = openDurationMs;
342
227
  let pendingConfigLoadMs = options.configLoadMs ?? 0;
343
228
  const explicitRegistrations = [];
@@ -382,8 +267,6 @@ export async function openSession(options) {
382
267
  };
383
268
  return {
384
269
  project: projectCtx.project,
385
- models: projectCtx.models,
386
- getModel: (id) => projectCtx.getModel(id),
387
270
  findSyntax: (query) => invokeProjectQuery(() => projectCtx.findSyntax(query)),
388
271
  typeAt: (targets) => invokeProjectQuery(() => projectCtx.typeAt(targets)),
389
272
  listBranches: (functions) => invokeProjectQuery(() => projectCtx.listBranches(functions)),
@@ -403,7 +286,6 @@ export async function openSession(options) {
403
286
  projectInstances: (instances, opts) => invokeProjectQuery(() => projectCtx.projectInstances(instances, opts)),
404
287
  callEffects: (opts) => invokeProjectQuery(() => projectCtx.callEffects(opts)),
405
288
  instanceCleanup: (opts) => invokeProjectQuery(() => projectCtx.instanceCleanup(opts)),
406
- facts: (factType, opts) => invokeProjectQuery(() => projectCtx.facts(factType, opts)),
407
289
  registerAdditionalInput: (filePath) => {
408
290
  assertActiveSnapshot();
409
291
  return scopedAdditionalInputs.registerAdditionalInput(filePath);
@@ -412,6 +294,13 @@ export async function openSession(options) {
412
294
  assertActiveSnapshot();
413
295
  return scopedAdditionalInputs.readAdditionalInput(filePath);
414
296
  },
297
+ recordGaps: (gaps, gapOptions) => {
298
+ assertActiveSnapshot();
299
+ projectCtx.recordGaps(gaps);
300
+ if (gapOptions?.relatedLocation !== undefined && gaps.length > 0) {
301
+ collector.recordRuleGaps(ruleId, gaps, gapOptions.relatedLocation);
302
+ }
303
+ },
415
304
  report: (input) => {
416
305
  assertActiveSnapshot();
417
306
  collected.push({
@@ -460,28 +349,11 @@ export async function openSession(options) {
460
349
  pendingConfigLoadMs = 0;
461
350
  const openMs = pendingOpenDurationMs;
462
351
  pendingOpenDurationMs = 0;
463
- const configuredAdaptersById = new Map();
464
- for (const adapter of normalizedConfig.adapters) {
465
- configuredAdaptersById.set(adapter.id, {
466
- id: adapter.id,
467
- factTypeIds: adapter.provides.map((provider) => provider.factType.id),
468
- });
469
- }
470
- for (const native of tssaeSession.nativeAdapters) {
471
- if (!configuredAdaptersById.has(native.providerId)) {
472
- configuredAdaptersById.set(native.providerId, {
473
- id: native.providerId,
474
- factTypeIds: [],
475
- });
476
- }
477
- }
478
352
  const collector = new ObservationCollector({
479
353
  mode: effectiveObserve.mode,
480
354
  ...(effectiveObserve.limit !== undefined
481
355
  ? { limit: effectiveObserve.limit }
482
356
  : {}),
483
- nativeAdapters: tssaeSession.nativeAdapters,
484
- configuredAdapters: [...configuredAdaptersById.values()],
485
357
  ...(explainTarget !== undefined ? { explainTarget } : {}),
486
358
  configAndOpenMs: configLoadMs + openMs,
487
359
  });
@@ -489,6 +361,12 @@ export async function openSession(options) {
489
361
  collector.recordRpcCall(pendingOpenIoMetrics);
490
362
  pendingOpenIoMetrics = undefined;
491
363
  }
364
+ if (pendingUpdateIoMetrics.length > 0) {
365
+ for (const io of pendingUpdateIoMetrics) {
366
+ collector.recordRpcCall(io);
367
+ }
368
+ pendingUpdateIoMetrics.length = 0;
369
+ }
492
370
  const collected = [];
493
371
  const collectedGaps = [];
494
372
  const runRegistry = buildSessionRegistry(normalizedConfig.additionalInputs, explicitRegistrations, [], []);
@@ -556,22 +434,6 @@ export async function openSession(options) {
556
434
  : {}),
557
435
  ...(collector.isExplainEnabled()
558
436
  ? {
559
- onFactExplain: (event) => {
560
- collector.recordFactExplain({
561
- ruleId: rule.id,
562
- ...(event.subjectLocation !== undefined
563
- ? { subjectLocation: event.subjectLocation }
564
- : {}),
565
- gaps: event.gaps,
566
- localGaps: event.localGaps,
567
- });
568
- },
569
- onProviderEvaluation: (evaluation) => {
570
- collector.recordProviderEvaluation({
571
- ruleId: rule.id,
572
- evaluation,
573
- });
574
- },
575
437
  onCleanupCovered: (event) => {
576
438
  collector.recordCleanupPaths({
577
439
  ruleId: rule.id,
@@ -653,7 +515,7 @@ export async function openSession(options) {
653
515
  additionalInputs,
654
516
  diagnostics,
655
517
  gaps,
656
- identity: computeReportIdentity(tssaeSession.snapshotDigest, resolveProjectEntries(normalizedConfig), rules, normalizedConfig.models, normalizedConfig.additionalInputs, normalizedConfig.adapters, normalizedConfig.adapterPackages),
518
+ identity: computeReportIdentity(tssaeSession.snapshotDigest, resolveProjectEntries(normalizedConfig), rules, normalizedConfig.additionalInputs),
657
519
  ...(settlement.entries.length > 0
658
520
  ? { inlineIgnores: settlement.entries }
659
521
  : {}),
@@ -700,10 +562,9 @@ export async function openSession(options) {
700
562
  assertOpen();
701
563
  const changedAdditionalFiles = sessionRegistry.refresh();
702
564
  const nextConfig = resolveNextConfig(normalizedConfig, updateOptions);
703
- const nextAdapterResolutionRoot = resolve(updateOptions?.adapterResolutionRoot ?? adapterResolutionRoot);
704
565
  const nextEntries = resolveProjectEntries(nextConfig);
705
- const prevIdentity = computeReportIdentity("", resolveProjectEntries(normalizedConfig), normalizedConfig.rules, normalizedConfig.models, normalizedConfig.additionalInputs, normalizedConfig.adapters, normalizedConfig.adapterPackages);
706
- const nextIdentity = computeReportIdentity("", nextEntries, nextConfig.rules, nextConfig.models, nextConfig.additionalInputs, nextConfig.adapters, nextConfig.adapterPackages);
566
+ const prevIdentity = computeReportIdentity("", resolveProjectEntries(normalizedConfig), normalizedConfig.rules, normalizedConfig.additionalInputs);
567
+ const nextIdentity = computeReportIdentity("", nextEntries, nextConfig.rules, nextConfig.additionalInputs);
707
568
  const tssaeUpdate = await invokeProjectQuery(() => tssaeSession.update({
708
569
  ...(updateOptions?.changed !== undefined
709
570
  ? { changed: updateOptions.changed }
@@ -714,11 +575,16 @@ export async function openSession(options) {
714
575
  ...(updateOptions?.deleted !== undefined
715
576
  ? { deleted: updateOptions.deleted }
716
577
  : {}),
717
- adapterResolutionRoot: nextAdapterResolutionRoot,
718
578
  entries: nextEntries,
719
- models: nextConfig.models,
720
- adapters: [...nextConfig.adapters, ...nextConfig.adapterPackages],
721
579
  additionalInputs: nextConfig.additionalInputs,
580
+ ...(sessionObserve.mode !== "off"
581
+ ? {
582
+ observe: sessionObserve,
583
+ onRpcMetrics: (io) => {
584
+ pendingUpdateIoMetrics.push(io);
585
+ },
586
+ }
587
+ : {}),
722
588
  }));
723
589
  const invalidatedReasons = [...tssaeUpdate.recomputation.invalidatedBy];
724
590
  const existingReasons = new Set(invalidatedReasons);
@@ -741,7 +607,6 @@ export async function openSession(options) {
741
607
  invalidatedReasons.push("config");
742
608
  }
743
609
  normalizedConfig = nextConfig;
744
- adapterResolutionRoot = nextAdapterResolutionRoot;
745
610
  workspaceFileState.files = tssaeUpdate.workspaceSourceFiles;
746
611
  sessionRegistry = buildSessionRegistry(nextConfig.additionalInputs, explicitRegistrations, lastRuleRegistrations, tssaeSession.additionalInputs);
747
612
  const recomputation = {
@@ -108,9 +108,6 @@ export async function startSharedSession(options) {
108
108
  const endpoint = resolveEndpointPath(absCwd, options.endpoint);
109
109
  const controller = createWorkspaceController({
110
110
  cwd: absCwd,
111
- ...(options.adapterResolutionRoot !== undefined
112
- ? { adapterResolutionRoot: options.adapterResolutionRoot }
113
- : {}),
114
111
  ...(options.config !== undefined ? { config: options.config } : {}),
115
112
  ...(options.loadConfig !== undefined
116
113
  ? { loadConfig: options.loadConfig }
@@ -319,9 +316,7 @@ export async function requestSharedReport(options) {
319
316
  return;
320
317
  }
321
318
  if (!parsed.ok) {
322
- finishError(new VeruleExecutionError(parsed.error.code, parsed.error.message, parsed.error.conflict !== undefined
323
- ? { conflict: parsed.error.conflict }
324
- : undefined));
319
+ finishError(new VeruleExecutionError(parsed.error.code, parsed.error.message));
325
320
  return;
326
321
  }
327
322
  finishSuccess(parsed.report);
package/dist/types.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- import { type AdditionalInputEntry, type AdditionalInputSource, type ConfiguredAdapter, type DiagnosticLocation, type EngineProviderExtractionStats, type Evidence, type ExplainCleanupPath, type ExplainLocalGap, type ExplainProviderEvaluation, type FactConflictDetails, type Gap, type LibraryAdapter, type MemoryStats, type Model, type NativeAdapterObservation, type ObserveLimit, type ObserveLimitInput, type ObserveMode, type ObserveOptions, type ProjectContext, type ProjectSummary, type RecomputationScope, type SourceFileOrigin, type SourceTarget, type SyntaxRef, type TssaeErrorCode } from "tssae";
2
- import type { DiagnosticBasis } from "tssae";
3
- export type { AdditionalInputEntry, AdditionalInputSource, ConfiguredAdapter, DiagnosticLocation, EngineProviderExtractionStats, Evidence, ExplainCleanupPath, ExplainLocalGap, ExplainProviderEvaluation, FactConflictDetails, Gap, LibraryAdapter, MemoryStats, Model, NativeAdapterObservation, ObserveLimit, ObserveLimitInput, ObserveMode, ObserveOptions, ProjectContext, ProjectSummary, RecomputationScope, SourceFileOrigin, SourceTarget, SyntaxRef, TssaeErrorCode, } from "tssae";
1
+ import { type AdditionalInputEntry, type AdditionalInputSource, type DiagnosticBasis, type DiagnosticLocation, type EngineIrCacheMetrics, type EngineLoweringMetrics, type EngineSummaryLookupMetrics, type Evidence, type ExplainCleanupPath, type Gap, type MemoryStats, type ObserveLimit, type ObserveLimitInput, type ObserveMode, type ObserveOptions, type ProjectContext, type ProjectSummary, type RecomputationScope, type SourceFileOrigin, type SourceTarget, type SummaryConflictDetails, type SyntaxRef, type TssaeErrorCode } from "tssae";
2
+ export type { AdditionalInputEntry, AdditionalInputSource, DiagnosticLocation, EngineIrCacheMetrics, EngineLoweringMetrics, EngineSummaryLookupMetrics, Evidence, ExplainCleanupPath, Gap, MemoryStats, ObserveLimit, ObserveLimitInput, ObserveMode, ObserveOptions, ProjectContext, ProjectSummary, RecomputationScope, SourceFileOrigin, SourceTarget, SummaryConflictDetails, SyntaxRef, TssaeErrorCode, } from "tssae";
4
3
  export declare const REPORT_SCHEMA_VERSION: "1";
5
4
  export type VeruleErrorCode = TssaeErrorCode | "RULE_EXECUTION_ERROR";
6
5
  /** Execution failure raised when analysis configuration, loading, queries, or rules fail. */
7
6
  export declare class VeruleExecutionError extends Error {
8
7
  readonly code: VeruleErrorCode;
9
- readonly conflict?: FactConflictDetails;
8
+ readonly summaryConflict?: SummaryConflictDetails;
10
9
  constructor(code: VeruleErrorCode, message: string, options?: ErrorOptions & {
11
- readonly conflict?: FactConflictDetails;
10
+ readonly summaryConflict?: SummaryConflictDetails;
12
11
  });
13
12
  }
14
13
  /** Maps upstream `TssaeError` or unknown exceptions into `VeruleExecutionError`. */
@@ -36,16 +35,10 @@ export type RuleIdentitySummary = {
36
35
  readonly id: string;
37
36
  readonly digest: string;
38
37
  };
39
- export type ModelIdentitySummary = {
40
- readonly id: string;
41
- readonly version?: string;
42
- readonly digest: string;
43
- };
44
38
  export type ReportIdentity = {
45
39
  readonly snapshotDigest: string;
46
40
  readonly configDigest: string;
47
41
  readonly rules: readonly RuleIdentitySummary[];
48
- readonly models: readonly ModelIdentitySummary[];
49
42
  };
50
43
  export type ObservationPhases = {
51
44
  readonly configAndOpenMs: number;
@@ -89,11 +82,12 @@ export type ObservationReport = {
89
82
  readonly candidateCount: number;
90
83
  readonly checkpointCount: number;
91
84
  readonly providers: readonly string[];
92
- readonly nativeAdapters: readonly NativeAdapterObservation[];
85
+ readonly lowering: EngineLoweringMetrics;
86
+ readonly irCache: EngineIrCacheMetrics;
87
+ readonly summaryLookup: EngineSummaryLookupMetrics;
93
88
  readonly limit?: ObserveLimit;
94
89
  readonly truncated: boolean;
95
90
  readonly droppedCount: number;
96
- readonly engineExtractions: Readonly<Record<string, EngineProviderExtractionStats>>;
97
91
  readonly details?: readonly ObservationDetailEntry[];
98
92
  };
99
93
  export type ExplainStatus = "reported" | "excluded_by_checkpoint" | "excluded_by_query" | "not_in_candidates" | "target_not_in_project" | "suppressed_by_ignore" | "blocked_by_gap" | "covered_by_cleanup" | "rule_filtered";
@@ -130,8 +124,6 @@ export type ExplainResult = {
130
124
  readonly queries: readonly ExplainQueryStep[];
131
125
  readonly checkpoints: readonly ExplainCheckpointTrace[];
132
126
  readonly gaps: readonly Gap[];
133
- readonly localGaps: readonly ExplainLocalGap[];
134
- readonly providerEvaluations: readonly ExplainProviderEvaluation[];
135
127
  readonly providers: readonly string[];
136
128
  readonly cleanupPaths: readonly ExplainCleanupPath[];
137
129
  readonly inlineIgnore?: {
@@ -176,6 +168,9 @@ export type RuleContext = ProjectContext & {
176
168
  * When observation and explanation are disabled, `detail` is never invoked.
177
169
  */
178
170
  checkpoint: (name: string, target: CheckpointTarget, outcome: CheckpointOutcome, detail?: () => unknown) => void;
171
+ recordGaps: (gaps: readonly Gap[], options?: {
172
+ readonly relatedLocation?: DiagnosticLocation;
173
+ }) => void;
179
174
  };
180
175
  export type Rule = {
181
176
  readonly id: string;
@@ -186,17 +181,12 @@ export type VeruleConfig = {
186
181
  readonly tsconfig?: string;
187
182
  readonly projects?: readonly string[];
188
183
  readonly rules?: readonly Rule[];
189
- readonly models?: readonly Model[];
190
- readonly adapters?: readonly ConfiguredAdapter[];
191
184
  readonly additionalInputs?: readonly string[];
192
185
  };
193
186
  export type NormalizedVeruleConfig = {
194
187
  readonly tsconfig?: string;
195
188
  readonly projects?: readonly string[];
196
189
  readonly rules: readonly Rule[];
197
- readonly models: readonly Model[];
198
- readonly adapters: readonly LibraryAdapter[];
199
- readonly adapterPackages: readonly string[];
200
190
  readonly additionalInputs: readonly string[];
201
191
  };
202
192
  export type SessionCheckOptions = {
@@ -217,8 +207,6 @@ export type ExplainOptions = {
217
207
  export type OpenSessionOptions = {
218
208
  readonly cwd: string;
219
209
  readonly config?: VeruleConfig | NormalizedVeruleConfig;
220
- /** Directory used to resolve adapter package names; defaults to `cwd`. */
221
- readonly adapterResolutionRoot?: string;
222
210
  readonly observe?: ObserveMode | ObserveOptions;
223
211
  readonly observeLimit?: ObserveLimitInput;
224
212
  readonly configLoadMs?: number;
@@ -232,10 +220,7 @@ export type SessionUpdateOptions = {
232
220
  readonly created?: readonly string[];
233
221
  readonly deleted?: readonly string[];
234
222
  readonly config?: VeruleConfig | NormalizedVeruleConfig;
235
- readonly adapterResolutionRoot?: string;
236
223
  readonly rules?: readonly Rule[];
237
- readonly models?: readonly Model[];
238
- readonly adapters?: readonly ConfiguredAdapter[];
239
224
  readonly entries?: readonly string[];
240
225
  readonly additionalInputs?: readonly string[];
241
226
  };
@@ -263,14 +248,11 @@ export type AnalysisSession = {
263
248
  export type WatchTrigger = "initial" | "change";
264
249
  export type WatchConfigLoadResult = {
265
250
  readonly config: VeruleConfig | NormalizedVeruleConfig;
266
- readonly adapterResolutionRoot?: string;
267
251
  readonly watchFiles?: readonly string[];
268
252
  };
269
253
  export type WatchProjectOptions = {
270
254
  readonly cwd: string;
271
255
  readonly config?: VeruleConfig | NormalizedVeruleConfig;
272
- /** Directory used to resolve adapter package names; defaults to `cwd`. */
273
- readonly adapterResolutionRoot?: string;
274
256
  readonly loadConfig?: () => Promise<WatchConfigLoadResult>;
275
257
  readonly watchFiles?: readonly string[];
276
258
  readonly observe?: ObserveMode;
@@ -293,15 +275,12 @@ export type WatchFailureEvent = {
293
275
  readonly trigger: WatchTrigger;
294
276
  readonly code: VeruleErrorCode;
295
277
  readonly message: string;
296
- readonly conflict?: FactConflictDetails;
297
278
  };
298
279
  export type WatchEvent = WatchReportEvent | WatchFailureEvent;
299
280
  export type SharedSessionOptions = {
300
281
  readonly cwd: string;
301
282
  readonly endpoint: string;
302
283
  readonly config?: VeruleConfig | NormalizedVeruleConfig;
303
- /** Directory used to resolve adapter package names; defaults to `cwd`. */
304
- readonly adapterResolutionRoot?: string;
305
284
  readonly loadConfig?: () => Promise<WatchConfigLoadResult>;
306
285
  readonly watchFiles?: readonly string[];
307
286
  readonly observe?: ObserveMode;
package/dist/types.js CHANGED
@@ -3,13 +3,13 @@ export const REPORT_SCHEMA_VERSION = "1";
3
3
  /** Execution failure raised when analysis configuration, loading, queries, or rules fail. */
4
4
  export class VeruleExecutionError extends Error {
5
5
  code;
6
- conflict;
6
+ summaryConflict;
7
7
  constructor(code, message, options) {
8
8
  super(message, options);
9
9
  this.name = "VeruleExecutionError";
10
10
  this.code = code;
11
- if (options?.conflict !== undefined) {
12
- this.conflict = options.conflict;
11
+ if (options?.summaryConflict !== undefined) {
12
+ this.summaryConflict = options.summaryConflict;
13
13
  }
14
14
  }
15
15
  }
@@ -21,19 +21,21 @@ export function toVeruleError(error, fallbackCode = "ENGINE_ERROR") {
21
21
  if (error instanceof TssaeError) {
22
22
  return new VeruleExecutionError(error.code, error.message, {
23
23
  cause: error,
24
- ...(error.conflict !== undefined ? { conflict: error.conflict } : {}),
24
+ ...(error.summaryConflict !== undefined
25
+ ? { summaryConflict: error.summaryConflict }
26
+ : {}),
25
27
  });
26
28
  }
27
29
  if (error instanceof Error &&
28
30
  error.name === "TssaeError" &&
29
31
  "code" in error &&
30
32
  typeof error.code === "string") {
31
- const conflict = "conflict" in error && error.conflict !== undefined
32
- ? error.conflict
33
+ const summaryConflict = "summaryConflict" in error && error.summaryConflict !== undefined
34
+ ? error.summaryConflict
33
35
  : undefined;
34
36
  return new VeruleExecutionError(error.code, error.message, {
35
37
  cause: error,
36
- ...(conflict !== undefined ? { conflict } : {}),
38
+ ...(summaryConflict !== undefined ? { summaryConflict } : {}),
37
39
  });
38
40
  }
39
41
  const message = error instanceof Error ? error.message : String(error);