@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.
@@ -9,11 +9,18 @@ export const locationSchema = z.object({
9
9
  start: z.number().int().nonnegative(),
10
10
  end: z.number().int().nonnegative(),
11
11
  });
12
+ export const summaryDiscoverySourceSchema = z.enum([
13
+ "local",
14
+ "package",
15
+ "community",
16
+ "builtin",
17
+ ]);
12
18
  export const evidenceSchema = z.object({
13
- kind: z.enum(["source", "type", "note", "model"]),
19
+ kind: z.enum(["source", "type", "note", "summary"]),
14
20
  message: z.string(),
15
21
  at: locationSchema.optional(),
16
- modelId: z.string().optional(),
22
+ summaryId: z.string().optional(),
23
+ summarySource: summaryDiscoverySourceSchema.optional(),
17
24
  declaration: z.string().optional(),
18
25
  });
19
26
  export const gapSchema = z.object({
@@ -64,7 +71,7 @@ export const sourceFileOriginSchema = z.object({
64
71
  export const additionalInputSourceSchema = z.discriminatedUnion("kind", [
65
72
  z.object({ kind: z.literal("config") }),
66
73
  z.object({ kind: z.literal("rule"), id: z.string() }),
67
- z.object({ kind: z.literal("adapter"), id: z.string() }),
74
+ z.object({ kind: z.literal("summary"), id: z.string() }),
68
75
  ]);
69
76
  export const additionalInputEntrySchema = z.object({
70
77
  file: z.string(),
@@ -76,16 +83,10 @@ export const ruleIdentitySchema = z.object({
76
83
  id: z.string(),
77
84
  digest: z.string(),
78
85
  });
79
- export const modelIdentitySchema = z.object({
80
- id: z.string(),
81
- version: z.string().optional(),
82
- digest: z.string(),
83
- });
84
86
  export const reportIdentitySchema = z.object({
85
87
  snapshotDigest: z.string(),
86
88
  configDigest: z.string(),
87
89
  rules: z.array(ruleIdentitySchema),
88
- models: z.array(modelIdentitySchema),
89
90
  });
90
91
  export const observationDetailEntrySchema = z.object({
91
92
  kind: z.enum(["query", "checkpoint", "engineStep"]),
@@ -101,6 +102,28 @@ export const observationDetailEntrySchema = z.object({
101
102
  summary: z.string(),
102
103
  detail: z.unknown().optional(),
103
104
  });
105
+ export const engineLoweringMetricsSchema = z.object({
106
+ functionsLowered: z.number().int().nonnegative(),
107
+ verticesCreated: z.number().int().nonnegative(),
108
+ durationMs: z.number().nonnegative(),
109
+ });
110
+ export const engineIrCacheMetricsSchema = z.object({
111
+ functionHits: z.number().int().nonnegative(),
112
+ functionMisses: z.number().int().nonnegative(),
113
+ filesReused: z.number().int().nonnegative(),
114
+ filesInvalidated: z.number().int().nonnegative(),
115
+ });
116
+ export const engineSummaryLookupMetricsSchema = z.object({
117
+ lookups: z.number().int().nonnegative(),
118
+ hits: z.number().int().nonnegative(),
119
+ misses: z.number().int().nonnegative(),
120
+ hitsBySource: z.object({
121
+ local: z.number().int().nonnegative(),
122
+ package: z.number().int().nonnegative(),
123
+ community: z.number().int().nonnegative(),
124
+ builtin: z.number().int().nonnegative(),
125
+ }),
126
+ });
104
127
  export const observationSchema = z.object({
105
128
  mode: z.enum(["summary", "detail"]),
106
129
  phases: z.object({
@@ -126,11 +149,9 @@ export const observationSchema = z.object({
126
149
  candidateCount: z.number().int().nonnegative(),
127
150
  checkpointCount: z.number().int().nonnegative(),
128
151
  providers: z.array(z.string()),
129
- nativeAdapters: z.array(z.object({
130
- packageName: z.string(),
131
- providerId: z.string(),
132
- status: z.enum(["loaded", "reused"]),
133
- })),
152
+ lowering: engineLoweringMetricsSchema,
153
+ irCache: engineIrCacheMetricsSchema,
154
+ summaryLookup: engineSummaryLookupMetricsSchema,
134
155
  limit: z
135
156
  .object({
136
157
  maxItems: z.number().int().nonnegative().optional(),
@@ -139,10 +160,6 @@ export const observationSchema = z.object({
139
160
  .optional(),
140
161
  truncated: z.boolean(),
141
162
  droppedCount: z.number().int().nonnegative(),
142
- engineExtractions: z.record(z.string(), z.object({
143
- extractions: z.number().int().nonnegative(),
144
- candidates: z.number().int().nonnegative(),
145
- })),
146
163
  details: z.array(observationDetailEntrySchema).optional(),
147
164
  });
148
165
  export const explainQueryStepSchema = z.object({
@@ -170,33 +187,10 @@ export const explainCleanupPathSchema = z.object({
170
187
  allocationLocation: locationSchema.optional(),
171
188
  scopeLocation: locationSchema,
172
189
  cleanupLocations: z.array(locationSchema),
173
- modelIds: z.array(z.string()),
190
+ summaryIds: z.array(z.string()),
174
191
  summary: z.string(),
175
192
  evidence: z.array(evidenceSchema),
176
193
  });
177
- export const explainGapResolutionSchema = z.object({
178
- providerId: z.string(),
179
- operation: z.string(),
180
- conclusion: z.string(),
181
- at: locationSchema.optional(),
182
- });
183
- export const explainLocalGapSchema = z.object({
184
- status: z.enum(["unresolved", "resolved_by_override"]),
185
- factTypeId: z.string(),
186
- providerId: z.string(),
187
- field: z.string().optional(),
188
- gap: gapSchema,
189
- subjectLocation: locationSchema.optional(),
190
- resolvedBy: explainGapResolutionSchema.optional(),
191
- impact: z.string().optional(),
192
- });
193
- export const explainProviderEvaluationSchema = z.object({
194
- providerId: z.string(),
195
- factTypeId: z.string().optional(),
196
- status: z.enum(["evaluated", "reused", "skipped"]),
197
- reason: z.string().optional(),
198
- subjectLocation: locationSchema.optional(),
199
- });
200
194
  export const explainResultSchema = z.object({
201
195
  ruleId: z.string(),
202
196
  target: z.object({
@@ -224,8 +218,6 @@ export const explainResultSchema = z.object({
224
218
  queries: z.array(explainQueryStepSchema),
225
219
  checkpoints: z.array(explainCheckpointTraceSchema),
226
220
  gaps: z.array(gapSchema),
227
- localGaps: z.array(explainLocalGapSchema),
228
- providerEvaluations: z.array(explainProviderEvaluationSchema),
229
221
  providers: z.array(z.string()),
230
222
  cleanupPaths: z.array(explainCleanupPathSchema),
231
223
  inlineIgnore: z
@@ -267,68 +259,21 @@ export const checkReportSchema = z.object({
267
259
  explanation: explainResultSchema.optional(),
268
260
  explanations: z.array(explainResultSchema).optional(),
269
261
  });
270
- export const factConflictPartySchema = z.object({
271
- providerId: z.string(),
272
- providers: z.array(z.string()),
273
- conclusion: z.unknown(),
274
- conclusionSummary: z.string(),
275
- evidence: z.array(evidenceSchema),
276
- });
277
- export const factConflictDetailsSchema = z.object({
278
- factTypeId: z.string(),
279
- projectId: z.string(),
280
- snapshotId: z.number().int().positive(),
281
- subjectHandleId: z.string(),
282
- subjectLocation: locationSchema.optional(),
283
- condition: z.unknown().optional(),
284
- reason: z.string(),
285
- parties: z.tuple([factConflictPartySchema, factConflictPartySchema]),
286
- });
287
262
  export const checkFailureSchema = z.object({
288
263
  reportVersion: z.literal(REPORT_SCHEMA_VERSION),
289
264
  code: z.string(),
290
265
  message: z.string(),
291
- conflict: factConflictDetailsSchema.optional(),
292
266
  });
293
267
  function toWireEvidence(ev) {
294
268
  return {
295
269
  kind: ev.kind,
296
270
  message: ev.message,
297
271
  ...(ev.at !== undefined ? { at: { ...ev.at } } : {}),
298
- ...(ev.modelId !== undefined ? { modelId: ev.modelId } : {}),
299
- ...(ev.declaration !== undefined ? { declaration: ev.declaration } : {}),
300
- };
301
- }
302
- export function toWireFactConflict(conflict) {
303
- const [party0, party1] = conflict.parties;
304
- return {
305
- factTypeId: conflict.factTypeId,
306
- projectId: conflict.projectId,
307
- snapshotId: conflict.snapshotId,
308
- subjectHandleId: conflict.subjectHandleId,
309
- ...(conflict.subjectLocation !== undefined
310
- ? { subjectLocation: { ...conflict.subjectLocation } }
311
- : {}),
312
- ...(conflict.condition !== undefined
313
- ? { condition: conflict.condition }
272
+ ...(ev.summaryId !== undefined ? { summaryId: ev.summaryId } : {}),
273
+ ...(ev.summarySource !== undefined
274
+ ? { summarySource: ev.summarySource }
314
275
  : {}),
315
- reason: conflict.reason,
316
- parties: [
317
- {
318
- providerId: party0.providerId,
319
- providers: [...party0.providers],
320
- conclusion: party0.conclusion,
321
- conclusionSummary: party0.conclusionSummary,
322
- evidence: party0.evidence.map(toWireEvidence),
323
- },
324
- {
325
- providerId: party1.providerId,
326
- providers: [...party1.providers],
327
- conclusion: party1.conclusion,
328
- conclusionSummary: party1.conclusionSummary,
329
- evidence: party1.evidence.map(toWireEvidence),
330
- },
331
- ],
276
+ ...(ev.declaration !== undefined ? { declaration: ev.declaration } : {}),
332
277
  };
333
278
  }
334
279
  function sanitizeWireJsonValue(value) {
@@ -372,11 +317,14 @@ function toWireObservation(obs) {
372
317
  candidateCount: obs.candidateCount,
373
318
  checkpointCount: obs.checkpointCount,
374
319
  providers: [...obs.providers],
375
- nativeAdapters: obs.nativeAdapters.map((adapter) => ({ ...adapter })),
376
- engineExtractions: Object.fromEntries(Object.entries(obs.engineExtractions).map(([providerId, stats]) => [
377
- providerId,
378
- { ...stats },
379
- ])),
320
+ lowering: { ...obs.lowering },
321
+ irCache: { ...obs.irCache },
322
+ summaryLookup: {
323
+ lookups: obs.summaryLookup.lookups,
324
+ hits: obs.summaryLookup.hits,
325
+ misses: obs.summaryLookup.misses,
326
+ hitsBySource: { ...obs.summaryLookup.hitsBySource },
327
+ },
380
328
  ...(obs.limit !== undefined
381
329
  ? {
382
330
  limit: {
@@ -481,42 +429,6 @@ function toWireExplainResult(exp) {
481
429
  message: g.message,
482
430
  ...(g.at !== undefined ? { at: { ...g.at } } : {}),
483
431
  })),
484
- localGaps: exp.localGaps.map((lg) => ({
485
- status: lg.status,
486
- factTypeId: lg.factTypeId,
487
- providerId: lg.providerId,
488
- ...(lg.field !== undefined ? { field: lg.field } : {}),
489
- gap: {
490
- kind: lg.gap.kind,
491
- message: lg.gap.message,
492
- ...(lg.gap.at !== undefined ? { at: { ...lg.gap.at } } : {}),
493
- },
494
- ...(lg.subjectLocation !== undefined
495
- ? { subjectLocation: { ...lg.subjectLocation } }
496
- : {}),
497
- ...(lg.resolvedBy !== undefined
498
- ? {
499
- resolvedBy: {
500
- providerId: lg.resolvedBy.providerId,
501
- operation: lg.resolvedBy.operation,
502
- conclusion: lg.resolvedBy.conclusion,
503
- ...(lg.resolvedBy.at !== undefined
504
- ? { at: { ...lg.resolvedBy.at } }
505
- : {}),
506
- },
507
- }
508
- : {}),
509
- ...(lg.impact !== undefined ? { impact: lg.impact } : {}),
510
- })),
511
- providerEvaluations: exp.providerEvaluations.map((pe) => ({
512
- providerId: pe.providerId,
513
- ...(pe.factTypeId !== undefined ? { factTypeId: pe.factTypeId } : {}),
514
- status: pe.status,
515
- ...(pe.reason !== undefined ? { reason: pe.reason } : {}),
516
- ...(pe.subjectLocation !== undefined
517
- ? { subjectLocation: { ...pe.subjectLocation } }
518
- : {}),
519
- })),
520
432
  providers: [...exp.providers],
521
433
  cleanupPaths: exp.cleanupPaths.map((cp) => ({
522
434
  instanceKey: cp.instanceKey,
@@ -525,17 +437,9 @@ function toWireExplainResult(exp) {
525
437
  : {}),
526
438
  scopeLocation: { ...cp.scopeLocation },
527
439
  cleanupLocations: cp.cleanupLocations.map((loc) => ({ ...loc })),
528
- modelIds: [...cp.modelIds],
440
+ summaryIds: [...cp.summaryIds],
529
441
  summary: cp.summary,
530
- evidence: cp.evidence.map((ev) => ({
531
- kind: ev.kind,
532
- message: ev.message,
533
- ...(ev.at !== undefined ? { at: { ...ev.at } } : {}),
534
- ...(ev.modelId !== undefined ? { modelId: ev.modelId } : {}),
535
- ...(ev.declaration !== undefined
536
- ? { declaration: ev.declaration }
537
- : {}),
538
- })),
442
+ evidence: cp.evidence.map(toWireEvidence),
539
443
  })),
540
444
  ...(exp.inlineIgnore !== undefined
541
445
  ? {
@@ -616,15 +520,7 @@ export function toWireReport(report) {
616
520
  ruleId: diag.ruleId,
617
521
  at: { ...diag.at },
618
522
  message: diag.message,
619
- evidence: diag.evidence.map((item) => ({
620
- kind: item.kind,
621
- message: item.message,
622
- ...(item.at !== undefined ? { at: { ...item.at } } : {}),
623
- ...(item.modelId !== undefined ? { modelId: item.modelId } : {}),
624
- ...(item.declaration !== undefined
625
- ? { declaration: item.declaration }
626
- : {}),
627
- })),
523
+ evidence: diag.evidence.map(toWireEvidence),
628
524
  projects: [...diag.projects],
629
525
  })),
630
526
  gaps: report.gaps.map((gap) => ({
@@ -639,11 +535,6 @@ export function toWireReport(report) {
639
535
  id: rule.id,
640
536
  digest: rule.digest,
641
537
  })),
642
- models: report.identity.models.map((model) => ({
643
- id: model.id,
644
- ...(model.version !== undefined ? { version: model.version } : {}),
645
- digest: model.digest,
646
- })),
647
538
  },
648
539
  ...(report.inlineIgnores !== undefined
649
540
  ? {
@@ -687,10 +578,10 @@ export function formatDiagnosticsLines(report) {
687
578
  const locSuffix = item.at
688
579
  ? ` (${item.at.file}:${item.at.line}:${item.at.column})`
689
580
  : "";
690
- const modelSuffix = item.modelId !== undefined
691
- ? ` [model=${item.modelId}${item.declaration !== undefined ? `:${item.declaration}` : ""}]`
581
+ const summarySuffix = item.summaryId !== undefined
582
+ ? ` [summary=${item.summaryId}${item.summarySource !== undefined ? `@${item.summarySource}` : ""}${item.declaration !== undefined ? `:${item.declaration}` : ""}]`
692
583
  : "";
693
- lines.push(` evidence (${item.kind}): ${item.message}${modelSuffix}${locSuffix}`);
584
+ lines.push(` evidence (${item.kind}): ${item.message}${summarySuffix}${locSuffix}`);
694
585
  }
695
586
  }
696
587
  return lines;
@@ -27,7 +27,7 @@ export declare const sessionReadyRecordSchema: z.ZodObject<{
27
27
  }, z.core.$strip>>;
28
28
  }, z.core.$strip>;
29
29
  export type WireSessionReadyRecord = z.infer<typeof sessionReadyRecordSchema>;
30
- export declare function formatSessionReadyText(record: WireSessionReadyRecord): import("@ykdz/cli-contract").TextLine;
30
+ export declare function formatSessionReadyText(record: WireSessionReadyRecord): import("@boringparts/cli-contract").TextLine;
31
31
  /**
32
32
  * Starts a long-lived shared session bound to a single project configuration, emits
33
33
  * a ready notification, serves cross-process `verule check --session` queries, and cleans
@@ -1,5 +1,5 @@
1
- import { dirname, resolve } from "node:path";
2
- import { text } from "@ykdz/cli-contract";
1
+ import { resolve } from "node:path";
2
+ import { text } from "@boringparts/cli-contract";
3
3
  import { z } from "zod";
4
4
  import { loadProjectConfigWithDependencies } from "./config-loader.js";
5
5
  import { REPORT_SCHEMA_VERSION, VeruleExecutionError, startSharedSession, } from "./index.js";
@@ -30,7 +30,6 @@ export async function* streamSharedSession(workingDirectory, configOption, socke
30
30
  cwd: workingDirectory,
31
31
  endpoint: socketOption,
32
32
  config: initial.config,
33
- adapterResolutionRoot: dirname(initial.configPath),
34
33
  watchFiles: [...watchFiles],
35
34
  ...(signal !== undefined ? { signal } : {}),
36
35
  loadConfig: async () => {
@@ -38,7 +37,6 @@ export async function* streamSharedSession(workingDirectory, configOption, socke
38
37
  return {
39
38
  config: loaded.config,
40
39
  watchFiles: loaded.watchFiles,
41
- adapterResolutionRoot: dirname(loaded.configPath),
42
40
  };
43
41
  },
44
42
  });
package/dist/session.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- import { type Model } from "tssae";
2
1
  import { type AnalysisSession, type CheckReport, type NormalizedVeruleConfig, type OpenSessionOptions, type Rule, type RunCheckOptions, type VeruleConfig } from "./types.ts";
3
2
  /** Returns all workspace source file paths tracked by the active session for file watching. */
4
3
  export declare function getSessionWorkspaceFiles(session: AnalysisSession): readonly string[];
5
- /** Validates a project model definition and attaches provenance metadata. */
6
- export declare function defineModel(model: Model): Model;
7
4
  /** Validates and normalizes a rule definition. */
8
5
  export declare function defineRule(rule: Rule): Rule;
9
6
  /** Validates and normalizes a Verule project configuration, defaulting to zero rules. */