@harness-engineering/graph 0.4.1 → 0.4.3

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/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const NODE_TYPES: readonly ["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement"];
3
+ declare const NODE_TYPES: readonly ["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement", "packed_summary"];
4
4
  type NodeType = (typeof NODE_TYPES)[number];
5
- declare const EDGE_TYPES: readonly ["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by"];
5
+ declare const EDGE_TYPES: readonly ["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by", "caches"];
6
6
  type EdgeType = (typeof EDGE_TYPES)[number];
7
7
  declare const OBSERVABILITY_TYPES: ReadonlySet<NodeType>;
8
8
  interface SourceLocation {
@@ -68,9 +68,18 @@ interface GraphMetadata {
68
68
  readonly edgeCount: number;
69
69
  }
70
70
  declare const CURRENT_SCHEMA_VERSION = 1;
71
+ /** Stability classification for prompt caching -- mirrors StabilityTier from @harness-engineering/types. */
72
+ type GraphStabilityTier = 'static' | 'session' | 'ephemeral';
73
+ /**
74
+ * Maps graph node types to their caching stability tier.
75
+ * Used by provider cache adapters to determine cache directives.
76
+ *
77
+ * Node types not listed here default to 'ephemeral' at resolution time.
78
+ */
79
+ declare const NODE_STABILITY: Record<string, GraphStabilityTier>;
71
80
  declare const GraphNodeSchema: z.ZodObject<{
72
81
  id: z.ZodString;
73
- type: z.ZodEnum<["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement"]>;
82
+ type: z.ZodEnum<["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement", "packed_summary"]>;
74
83
  name: z.ZodString;
75
84
  path: z.ZodOptional<z.ZodString>;
76
85
  location: z.ZodOptional<z.ZodObject<{
@@ -99,7 +108,7 @@ declare const GraphNodeSchema: z.ZodObject<{
99
108
  lastModified: z.ZodOptional<z.ZodString>;
100
109
  }, "strip", z.ZodTypeAny, {
101
110
  id: string;
102
- type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement";
111
+ type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement" | "packed_summary";
103
112
  name: string;
104
113
  metadata: Record<string, unknown>;
105
114
  path?: string | undefined;
@@ -116,7 +125,7 @@ declare const GraphNodeSchema: z.ZodObject<{
116
125
  lastModified?: string | undefined;
117
126
  }, {
118
127
  id: string;
119
- type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement";
128
+ type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement" | "packed_summary";
120
129
  name: string;
121
130
  metadata: Record<string, unknown>;
122
131
  path?: string | undefined;
@@ -135,17 +144,17 @@ declare const GraphNodeSchema: z.ZodObject<{
135
144
  declare const GraphEdgeSchema: z.ZodObject<{
136
145
  from: z.ZodString;
137
146
  to: z.ZodString;
138
- type: z.ZodEnum<["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by"]>;
147
+ type: z.ZodEnum<["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by", "caches"]>;
139
148
  confidence: z.ZodOptional<z.ZodNumber>;
140
149
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
141
150
  }, "strip", z.ZodTypeAny, {
142
- type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by";
151
+ type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by" | "caches";
143
152
  from: string;
144
153
  to: string;
145
154
  metadata?: Record<string, unknown> | undefined;
146
155
  confidence?: number | undefined;
147
156
  }, {
148
- type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by";
157
+ type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by" | "caches";
149
158
  from: string;
150
159
  to: string;
151
160
  metadata?: Record<string, unknown> | undefined;
@@ -179,6 +188,8 @@ declare class GraphStore {
179
188
  /** Pick the most selective index to start from. */
180
189
  private selectCandidates;
181
190
  getNeighbors(nodeId: string, direction?: 'outbound' | 'inbound' | 'both'): GraphNode[];
191
+ private collectNeighborIds;
192
+ private resolveNodes;
182
193
  get nodeCount(): number;
183
194
  get edgeCount(): number;
184
195
  clear(): void;
@@ -243,6 +254,45 @@ interface SerializedGraph {
243
254
  declare function saveGraph(dirPath: string, nodes: readonly GraphNode[], edges: readonly GraphEdge[]): Promise<void>;
244
255
  declare function loadGraph(dirPath: string): Promise<SerializedGraph | null>;
245
256
 
257
+ /**
258
+ * Minimal PackedEnvelope shape -- avoids circular dep on @harness-engineering/core.
259
+ * Canonical type: packages/core/src/compaction/envelope.ts — keep in sync.
260
+ */
261
+ interface PackedEnvelope {
262
+ meta: {
263
+ strategy: string[];
264
+ originalTokenEstimate: number;
265
+ compactedTokenEstimate: number;
266
+ reductionPct: number;
267
+ cached: boolean;
268
+ };
269
+ sections: Array<{
270
+ source: string;
271
+ content: string;
272
+ }>;
273
+ }
274
+
275
+ /** Normalize an intent string for deterministic cache keying. */
276
+ declare function normalizeIntent(intent: string): string;
277
+ /** Reads/writes PackedSummary nodes in the GraphStore. Validates via TTL + source freshness. */
278
+ declare class PackedSummaryCache {
279
+ private readonly store;
280
+ private readonly ttlMs;
281
+ constructor(store: GraphStore, ttlMs?: number);
282
+ /** Returns cached envelope with `cached: true` if valid, or null if miss/stale. */
283
+ get(intent: string): PackedEnvelope | null;
284
+ /** Parse and validate createdAt. Returns epoch ms or null if missing/malformed (GC-002). */
285
+ private parseCreatedMs;
286
+ /** GC-001: Checks source nodes exist and are unmodified since cache creation. */
287
+ private areSourcesFresh;
288
+ /** Parse envelope JSON and set cached: true. Returns null on invalid JSON. */
289
+ private parseEnvelope;
290
+ /** Write a PackedSummary node with caches edges to source nodes. */
291
+ set(intent: string, envelope: PackedEnvelope, sourceNodeIds: string[]): void;
292
+ /** Explicitly invalidate a cached packed summary. */
293
+ invalidate(intent: string): void;
294
+ }
295
+
246
296
  declare class ContextQL {
247
297
  private readonly store;
248
298
  constructor(store: GraphStore);
@@ -325,8 +375,16 @@ declare class GitIngestor {
325
375
  private readonly gitRunner?;
326
376
  constructor(store: GraphStore, gitRunner?: GitRunner | undefined);
327
377
  ingest(rootDir: string): Promise<IngestResult>;
378
+ private ingestCommit;
379
+ private ingestCoChanges;
328
380
  private runGit;
329
381
  private parseGitLog;
382
+ /**
383
+ * Process one line from git log output, updating the in-progress commit builder
384
+ * and flushing completed commits into the accumulator.
385
+ * Returns the updated current builder (null if flushed and not replaced).
386
+ */
387
+ private processLogLine;
330
388
  private computeCoChanges;
331
389
  }
332
390
 
@@ -368,10 +426,22 @@ declare class RequirementIngestor {
368
426
  * and create requirement nodes with convention-based edges.
369
427
  */
370
428
  ingestSpecs(specsDir: string): Promise<IngestResult>;
429
+ private ingestFeatureDir;
430
+ private ingestSpec;
431
+ private ingestRequirement;
371
432
  /**
372
433
  * Parse markdown content and extract numbered items from recognized sections.
373
434
  */
374
435
  private extractRequirements;
436
+ /**
437
+ * Check if a line is a section heading and return updated section state,
438
+ * or return null if the line is not a heading.
439
+ */
440
+ private processHeadingLine;
441
+ /**
442
+ * Build a requirement GraphNode from a matched numbered-item line.
443
+ */
444
+ private buildRequirementNode;
375
445
  /**
376
446
  * Convention-based linking: match requirement to code/test files
377
447
  * by feature name in their path.
@@ -434,6 +504,7 @@ declare class JiraConnector implements GraphConnector {
434
504
  private readonly httpClient;
435
505
  constructor(httpClient?: HttpClient);
436
506
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
507
+ private fetchAllIssues;
437
508
  private processIssue;
438
509
  }
439
510
 
@@ -452,6 +523,7 @@ declare class ConfluenceConnector implements GraphConnector {
452
523
  private readonly httpClient;
453
524
  constructor(httpClient?: HttpClient);
454
525
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
526
+ private fetchAllPagesHandled;
455
527
  private fetchAllPages;
456
528
  private processPage;
457
529
  }
@@ -462,6 +534,7 @@ declare class CIConnector implements GraphConnector {
462
534
  private readonly httpClient;
463
535
  constructor(httpClient?: HttpClient);
464
536
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
537
+ private fetchAndIngestRuns;
465
538
  }
466
539
 
467
540
  interface FusionResult {
@@ -480,6 +553,9 @@ declare class FusionLayer {
480
553
  private readonly semanticWeight;
481
554
  constructor(store: GraphStore, vectorStore?: VectorStore, keywordWeight?: number, semanticWeight?: number);
482
555
  search(query: string, topK?: number, queryEmbedding?: readonly number[]): FusionResult[];
556
+ private buildSemanticScores;
557
+ private resolveWeights;
558
+ private scoreNodes;
483
559
  private extractKeywords;
484
560
  private keywordScore;
485
561
  private singleKeywordScore;
@@ -524,6 +600,7 @@ declare class GraphEntropyAdapter {
524
600
  * 4. If target exists -> compare lastModified timestamps to determine staleness
525
601
  */
526
602
  computeDriftData(): GraphDriftData;
603
+ private classifyDocEdge;
527
604
  /**
528
605
  * BFS from entry points to find reachable vs unreachable code nodes.
529
606
  *
@@ -645,6 +722,9 @@ declare class GraphAnomalyAdapter {
645
722
  private readonly store;
646
723
  constructor(store: GraphStore);
647
724
  detect(options?: AnomalyDetectionOptions): AnomalyReport;
725
+ private filterMetrics;
726
+ private computeAllOutliers;
727
+ private computeOverlap;
648
728
  private collectMetricValues;
649
729
  private computeZScoreOutliers;
650
730
  private findArticulationPoints;
@@ -741,6 +821,14 @@ declare class EntityExtractor {
741
821
  * @returns Array of raw entity strings in priority order, deduplicated
742
822
  */
743
823
  extract(query: string): readonly string[];
824
+ /** Strategy 1: Quoted strings. Returns the set of consumed tokens. */
825
+ private extractQuoted;
826
+ /** Strategy 2: PascalCase/camelCase tokens. Returns the set of consumed tokens. */
827
+ private extractCasing;
828
+ /** Strategy 3: File paths. Returns the set of consumed tokens. */
829
+ private extractPaths;
830
+ /** Strategy 4: Remaining significant nouns after stop-word and intent-keyword removal. */
831
+ private extractNouns;
744
832
  }
745
833
 
746
834
  /**
@@ -828,17 +916,17 @@ declare class Assembler {
828
916
  assembleContext(intent: string, tokenBudget?: number): AssembledContext;
829
917
  private expandSearchResults;
830
918
  private truncateToFit;
831
- /**
832
- * Compute a token budget allocation across node types.
833
- */
919
+ private countNodesByType;
920
+ private computeModuleDensity;
921
+ private computeTypeWeights;
922
+ private allocateProportionally;
834
923
  computeBudget(totalTokens: number, phase?: string): GraphBudget;
835
924
  /**
836
925
  * Filter graph nodes relevant to a development phase.
837
926
  */
838
927
  filterForPhase(phase: string): GraphFilterResult;
839
- /**
840
- * Generate a markdown repository map from graph structure.
841
- */
928
+ private buildModuleLines;
929
+ private buildEntryPointLines;
842
930
  generateMap(): string;
843
931
  /**
844
932
  * Check documentation coverage of code nodes.
@@ -905,6 +993,8 @@ declare class GraphConstraintAdapter {
905
993
  private readonly store;
906
994
  constructor(store: GraphStore);
907
995
  computeDependencyGraph(): GraphDependencyData;
996
+ private collectFileNodePaths;
997
+ private collectImportEdges;
908
998
  computeLayerViolations(layers: LayerDef[], rootDir: string): GraphLayerViolation[];
909
999
  private resolveLayer;
910
1000
  }
@@ -958,7 +1048,10 @@ declare class GraphFeedbackAdapter {
958
1048
  private readonly store;
959
1049
  constructor(store: GraphStore);
960
1050
  computeImpactData(changedFiles: string[]): GraphImpactData;
1051
+ private collectFileImpact;
961
1052
  computeHarnessCheckData(): GraphHarnessCheckData;
1053
+ private countUndocumentedFiles;
1054
+ private countUnreachableNodes;
962
1055
  }
963
1056
 
964
1057
  interface TaskDefinition {
@@ -993,6 +1086,8 @@ declare class TaskIndependenceAnalyzer {
993
1086
  private readonly store;
994
1087
  constructor(store?: GraphStore);
995
1088
  analyze(params: IndependenceCheckParams): IndependenceResult;
1089
+ private buildFileSets;
1090
+ private computeAllPairs;
996
1091
  private validate;
997
1092
  private expandViaGraph;
998
1093
  private computePairOverlap;
@@ -1027,6 +1122,10 @@ declare class ConflictPredictor {
1027
1122
  private readonly store;
1028
1123
  constructor(store?: GraphStore);
1029
1124
  predict(params: IndependenceCheckParams): ConflictPrediction;
1125
+ private buildMetricMaps;
1126
+ private classifyConflicts;
1127
+ private countBySeverity;
1128
+ private classifyTransitiveOverlap;
1030
1129
  private classifyPair;
1031
1130
  private severityRank;
1032
1131
  private computePercentile;
@@ -1120,6 +1219,6 @@ declare class CascadeSimulator {
1120
1219
  private buildResult;
1121
1220
  }
1122
1221
 
1123
- declare const VERSION = "0.4.0";
1222
+ declare const VERSION = "0.4.3";
1124
1223
 
1125
- export { type AnomalyDetectionOptions, type AnomalyReport, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, CIConnector, CURRENT_SCHEMA_VERSION, type CascadeLayer, type CascadeNode, type CascadeResult, type CascadeSimulationOptions, CascadeSimulator, type ClassificationResult, CodeIngestor, CompositeProbabilityStrategy, type ConflictDetail, type ConflictPrediction, ConflictPredictor, type ConflictSeverity, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, FusionLayer, type FusionResult, GitIngestor, type GitRunner, GraphAnomalyAdapter, type GraphBudget, GraphComplexityAdapter, type GraphComplexityHotspot, type GraphComplexityResult, type GraphConnector, GraphConstraintAdapter, GraphCouplingAdapter, type GraphCouplingFileData, type GraphCouplingResult, type GraphCoverageReport, type GraphDeadCodeData, type GraphDependencyData, type GraphDriftData, type GraphEdge, GraphEdgeSchema, GraphEntropyAdapter, GraphFeedbackAdapter, type GraphFilterResult, type GraphHarnessCheckData, type GraphImpactData, type GraphLayerViolation, type GraphMetadata, type GraphNode, GraphNodeSchema, type GraphSnapshotSummary, GraphStore, type HttpClient, INTENTS, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeIngestor, type LinkResult, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, type PairResult, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, SlackConnector, type SourceLocation, type StatisticalOutlier, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, groupNodesByImpact, linkToCode, loadGraph, project, queryTraceability, saveGraph };
1224
+ export { type AnomalyDetectionOptions, type AnomalyReport, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, CIConnector, CURRENT_SCHEMA_VERSION, type PackedEnvelope as CacheableEnvelope, type CascadeLayer, type CascadeNode, type CascadeResult, type CascadeSimulationOptions, CascadeSimulator, type ClassificationResult, CodeIngestor, CompositeProbabilityStrategy, type ConflictDetail, type ConflictPrediction, ConflictPredictor, type ConflictSeverity, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, FusionLayer, type FusionResult, GitIngestor, type GitRunner, GraphAnomalyAdapter, type GraphBudget, GraphComplexityAdapter, type GraphComplexityHotspot, type GraphComplexityResult, type GraphConnector, GraphConstraintAdapter, GraphCouplingAdapter, type GraphCouplingFileData, type GraphCouplingResult, type GraphCoverageReport, type GraphDeadCodeData, type GraphDependencyData, type GraphDriftData, type GraphEdge, GraphEdgeSchema, GraphEntropyAdapter, GraphFeedbackAdapter, type GraphFilterResult, type GraphHarnessCheckData, type GraphImpactData, type GraphLayerViolation, type GraphMetadata, type GraphNode, GraphNodeSchema, type GraphSnapshotSummary, type GraphStabilityTier, GraphStore, type HttpClient, INTENTS, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeIngestor, type LinkResult, NODE_STABILITY, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, PackedSummaryCache, type PairResult, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, SlackConnector, type SourceLocation, type StatisticalOutlier, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, groupNodesByImpact, linkToCode, loadGraph, normalizeIntent, project, queryTraceability, saveGraph };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const NODE_TYPES: readonly ["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement"];
3
+ declare const NODE_TYPES: readonly ["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement", "packed_summary"];
4
4
  type NodeType = (typeof NODE_TYPES)[number];
5
- declare const EDGE_TYPES: readonly ["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by"];
5
+ declare const EDGE_TYPES: readonly ["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by", "caches"];
6
6
  type EdgeType = (typeof EDGE_TYPES)[number];
7
7
  declare const OBSERVABILITY_TYPES: ReadonlySet<NodeType>;
8
8
  interface SourceLocation {
@@ -68,9 +68,18 @@ interface GraphMetadata {
68
68
  readonly edgeCount: number;
69
69
  }
70
70
  declare const CURRENT_SCHEMA_VERSION = 1;
71
+ /** Stability classification for prompt caching -- mirrors StabilityTier from @harness-engineering/types. */
72
+ type GraphStabilityTier = 'static' | 'session' | 'ephemeral';
73
+ /**
74
+ * Maps graph node types to their caching stability tier.
75
+ * Used by provider cache adapters to determine cache directives.
76
+ *
77
+ * Node types not listed here default to 'ephemeral' at resolution time.
78
+ */
79
+ declare const NODE_STABILITY: Record<string, GraphStabilityTier>;
71
80
  declare const GraphNodeSchema: z.ZodObject<{
72
81
  id: z.ZodString;
73
- type: z.ZodEnum<["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement"]>;
82
+ type: z.ZodEnum<["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation", "design_token", "aesthetic_intent", "design_constraint", "requirement", "packed_summary"]>;
74
83
  name: z.ZodString;
75
84
  path: z.ZodOptional<z.ZodString>;
76
85
  location: z.ZodOptional<z.ZodObject<{
@@ -99,7 +108,7 @@ declare const GraphNodeSchema: z.ZodObject<{
99
108
  lastModified: z.ZodOptional<z.ZodString>;
100
109
  }, "strip", z.ZodTypeAny, {
101
110
  id: string;
102
- type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement";
111
+ type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement" | "packed_summary";
103
112
  name: string;
104
113
  metadata: Record<string, unknown>;
105
114
  path?: string | undefined;
@@ -116,7 +125,7 @@ declare const GraphNodeSchema: z.ZodObject<{
116
125
  lastModified?: string | undefined;
117
126
  }, {
118
127
  id: string;
119
- type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement";
128
+ type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation" | "design_token" | "aesthetic_intent" | "design_constraint" | "requirement" | "packed_summary";
120
129
  name: string;
121
130
  metadata: Record<string, unknown>;
122
131
  path?: string | undefined;
@@ -135,17 +144,17 @@ declare const GraphNodeSchema: z.ZodObject<{
135
144
  declare const GraphEdgeSchema: z.ZodObject<{
136
145
  from: z.ZodString;
137
146
  to: z.ZodString;
138
- type: z.ZodEnum<["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by"]>;
147
+ type: z.ZodEnum<["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by", "uses_token", "declares_intent", "violates_design", "platform_binding", "requires", "verified_by", "tested_by", "caches"]>;
139
148
  confidence: z.ZodOptional<z.ZodNumber>;
140
149
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
141
150
  }, "strip", z.ZodTypeAny, {
142
- type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by";
151
+ type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by" | "caches";
143
152
  from: string;
144
153
  to: string;
145
154
  metadata?: Record<string, unknown> | undefined;
146
155
  confidence?: number | undefined;
147
156
  }, {
148
- type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by";
157
+ type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by" | "uses_token" | "declares_intent" | "violates_design" | "platform_binding" | "requires" | "verified_by" | "tested_by" | "caches";
149
158
  from: string;
150
159
  to: string;
151
160
  metadata?: Record<string, unknown> | undefined;
@@ -179,6 +188,8 @@ declare class GraphStore {
179
188
  /** Pick the most selective index to start from. */
180
189
  private selectCandidates;
181
190
  getNeighbors(nodeId: string, direction?: 'outbound' | 'inbound' | 'both'): GraphNode[];
191
+ private collectNeighborIds;
192
+ private resolveNodes;
182
193
  get nodeCount(): number;
183
194
  get edgeCount(): number;
184
195
  clear(): void;
@@ -243,6 +254,45 @@ interface SerializedGraph {
243
254
  declare function saveGraph(dirPath: string, nodes: readonly GraphNode[], edges: readonly GraphEdge[]): Promise<void>;
244
255
  declare function loadGraph(dirPath: string): Promise<SerializedGraph | null>;
245
256
 
257
+ /**
258
+ * Minimal PackedEnvelope shape -- avoids circular dep on @harness-engineering/core.
259
+ * Canonical type: packages/core/src/compaction/envelope.ts — keep in sync.
260
+ */
261
+ interface PackedEnvelope {
262
+ meta: {
263
+ strategy: string[];
264
+ originalTokenEstimate: number;
265
+ compactedTokenEstimate: number;
266
+ reductionPct: number;
267
+ cached: boolean;
268
+ };
269
+ sections: Array<{
270
+ source: string;
271
+ content: string;
272
+ }>;
273
+ }
274
+
275
+ /** Normalize an intent string for deterministic cache keying. */
276
+ declare function normalizeIntent(intent: string): string;
277
+ /** Reads/writes PackedSummary nodes in the GraphStore. Validates via TTL + source freshness. */
278
+ declare class PackedSummaryCache {
279
+ private readonly store;
280
+ private readonly ttlMs;
281
+ constructor(store: GraphStore, ttlMs?: number);
282
+ /** Returns cached envelope with `cached: true` if valid, or null if miss/stale. */
283
+ get(intent: string): PackedEnvelope | null;
284
+ /** Parse and validate createdAt. Returns epoch ms or null if missing/malformed (GC-002). */
285
+ private parseCreatedMs;
286
+ /** GC-001: Checks source nodes exist and are unmodified since cache creation. */
287
+ private areSourcesFresh;
288
+ /** Parse envelope JSON and set cached: true. Returns null on invalid JSON. */
289
+ private parseEnvelope;
290
+ /** Write a PackedSummary node with caches edges to source nodes. */
291
+ set(intent: string, envelope: PackedEnvelope, sourceNodeIds: string[]): void;
292
+ /** Explicitly invalidate a cached packed summary. */
293
+ invalidate(intent: string): void;
294
+ }
295
+
246
296
  declare class ContextQL {
247
297
  private readonly store;
248
298
  constructor(store: GraphStore);
@@ -325,8 +375,16 @@ declare class GitIngestor {
325
375
  private readonly gitRunner?;
326
376
  constructor(store: GraphStore, gitRunner?: GitRunner | undefined);
327
377
  ingest(rootDir: string): Promise<IngestResult>;
378
+ private ingestCommit;
379
+ private ingestCoChanges;
328
380
  private runGit;
329
381
  private parseGitLog;
382
+ /**
383
+ * Process one line from git log output, updating the in-progress commit builder
384
+ * and flushing completed commits into the accumulator.
385
+ * Returns the updated current builder (null if flushed and not replaced).
386
+ */
387
+ private processLogLine;
330
388
  private computeCoChanges;
331
389
  }
332
390
 
@@ -368,10 +426,22 @@ declare class RequirementIngestor {
368
426
  * and create requirement nodes with convention-based edges.
369
427
  */
370
428
  ingestSpecs(specsDir: string): Promise<IngestResult>;
429
+ private ingestFeatureDir;
430
+ private ingestSpec;
431
+ private ingestRequirement;
371
432
  /**
372
433
  * Parse markdown content and extract numbered items from recognized sections.
373
434
  */
374
435
  private extractRequirements;
436
+ /**
437
+ * Check if a line is a section heading and return updated section state,
438
+ * or return null if the line is not a heading.
439
+ */
440
+ private processHeadingLine;
441
+ /**
442
+ * Build a requirement GraphNode from a matched numbered-item line.
443
+ */
444
+ private buildRequirementNode;
375
445
  /**
376
446
  * Convention-based linking: match requirement to code/test files
377
447
  * by feature name in their path.
@@ -434,6 +504,7 @@ declare class JiraConnector implements GraphConnector {
434
504
  private readonly httpClient;
435
505
  constructor(httpClient?: HttpClient);
436
506
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
507
+ private fetchAllIssues;
437
508
  private processIssue;
438
509
  }
439
510
 
@@ -452,6 +523,7 @@ declare class ConfluenceConnector implements GraphConnector {
452
523
  private readonly httpClient;
453
524
  constructor(httpClient?: HttpClient);
454
525
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
526
+ private fetchAllPagesHandled;
455
527
  private fetchAllPages;
456
528
  private processPage;
457
529
  }
@@ -462,6 +534,7 @@ declare class CIConnector implements GraphConnector {
462
534
  private readonly httpClient;
463
535
  constructor(httpClient?: HttpClient);
464
536
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
537
+ private fetchAndIngestRuns;
465
538
  }
466
539
 
467
540
  interface FusionResult {
@@ -480,6 +553,9 @@ declare class FusionLayer {
480
553
  private readonly semanticWeight;
481
554
  constructor(store: GraphStore, vectorStore?: VectorStore, keywordWeight?: number, semanticWeight?: number);
482
555
  search(query: string, topK?: number, queryEmbedding?: readonly number[]): FusionResult[];
556
+ private buildSemanticScores;
557
+ private resolveWeights;
558
+ private scoreNodes;
483
559
  private extractKeywords;
484
560
  private keywordScore;
485
561
  private singleKeywordScore;
@@ -524,6 +600,7 @@ declare class GraphEntropyAdapter {
524
600
  * 4. If target exists -> compare lastModified timestamps to determine staleness
525
601
  */
526
602
  computeDriftData(): GraphDriftData;
603
+ private classifyDocEdge;
527
604
  /**
528
605
  * BFS from entry points to find reachable vs unreachable code nodes.
529
606
  *
@@ -645,6 +722,9 @@ declare class GraphAnomalyAdapter {
645
722
  private readonly store;
646
723
  constructor(store: GraphStore);
647
724
  detect(options?: AnomalyDetectionOptions): AnomalyReport;
725
+ private filterMetrics;
726
+ private computeAllOutliers;
727
+ private computeOverlap;
648
728
  private collectMetricValues;
649
729
  private computeZScoreOutliers;
650
730
  private findArticulationPoints;
@@ -741,6 +821,14 @@ declare class EntityExtractor {
741
821
  * @returns Array of raw entity strings in priority order, deduplicated
742
822
  */
743
823
  extract(query: string): readonly string[];
824
+ /** Strategy 1: Quoted strings. Returns the set of consumed tokens. */
825
+ private extractQuoted;
826
+ /** Strategy 2: PascalCase/camelCase tokens. Returns the set of consumed tokens. */
827
+ private extractCasing;
828
+ /** Strategy 3: File paths. Returns the set of consumed tokens. */
829
+ private extractPaths;
830
+ /** Strategy 4: Remaining significant nouns after stop-word and intent-keyword removal. */
831
+ private extractNouns;
744
832
  }
745
833
 
746
834
  /**
@@ -828,17 +916,17 @@ declare class Assembler {
828
916
  assembleContext(intent: string, tokenBudget?: number): AssembledContext;
829
917
  private expandSearchResults;
830
918
  private truncateToFit;
831
- /**
832
- * Compute a token budget allocation across node types.
833
- */
919
+ private countNodesByType;
920
+ private computeModuleDensity;
921
+ private computeTypeWeights;
922
+ private allocateProportionally;
834
923
  computeBudget(totalTokens: number, phase?: string): GraphBudget;
835
924
  /**
836
925
  * Filter graph nodes relevant to a development phase.
837
926
  */
838
927
  filterForPhase(phase: string): GraphFilterResult;
839
- /**
840
- * Generate a markdown repository map from graph structure.
841
- */
928
+ private buildModuleLines;
929
+ private buildEntryPointLines;
842
930
  generateMap(): string;
843
931
  /**
844
932
  * Check documentation coverage of code nodes.
@@ -905,6 +993,8 @@ declare class GraphConstraintAdapter {
905
993
  private readonly store;
906
994
  constructor(store: GraphStore);
907
995
  computeDependencyGraph(): GraphDependencyData;
996
+ private collectFileNodePaths;
997
+ private collectImportEdges;
908
998
  computeLayerViolations(layers: LayerDef[], rootDir: string): GraphLayerViolation[];
909
999
  private resolveLayer;
910
1000
  }
@@ -958,7 +1048,10 @@ declare class GraphFeedbackAdapter {
958
1048
  private readonly store;
959
1049
  constructor(store: GraphStore);
960
1050
  computeImpactData(changedFiles: string[]): GraphImpactData;
1051
+ private collectFileImpact;
961
1052
  computeHarnessCheckData(): GraphHarnessCheckData;
1053
+ private countUndocumentedFiles;
1054
+ private countUnreachableNodes;
962
1055
  }
963
1056
 
964
1057
  interface TaskDefinition {
@@ -993,6 +1086,8 @@ declare class TaskIndependenceAnalyzer {
993
1086
  private readonly store;
994
1087
  constructor(store?: GraphStore);
995
1088
  analyze(params: IndependenceCheckParams): IndependenceResult;
1089
+ private buildFileSets;
1090
+ private computeAllPairs;
996
1091
  private validate;
997
1092
  private expandViaGraph;
998
1093
  private computePairOverlap;
@@ -1027,6 +1122,10 @@ declare class ConflictPredictor {
1027
1122
  private readonly store;
1028
1123
  constructor(store?: GraphStore);
1029
1124
  predict(params: IndependenceCheckParams): ConflictPrediction;
1125
+ private buildMetricMaps;
1126
+ private classifyConflicts;
1127
+ private countBySeverity;
1128
+ private classifyTransitiveOverlap;
1030
1129
  private classifyPair;
1031
1130
  private severityRank;
1032
1131
  private computePercentile;
@@ -1120,6 +1219,6 @@ declare class CascadeSimulator {
1120
1219
  private buildResult;
1121
1220
  }
1122
1221
 
1123
- declare const VERSION = "0.4.0";
1222
+ declare const VERSION = "0.4.3";
1124
1223
 
1125
- export { type AnomalyDetectionOptions, type AnomalyReport, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, CIConnector, CURRENT_SCHEMA_VERSION, type CascadeLayer, type CascadeNode, type CascadeResult, type CascadeSimulationOptions, CascadeSimulator, type ClassificationResult, CodeIngestor, CompositeProbabilityStrategy, type ConflictDetail, type ConflictPrediction, ConflictPredictor, type ConflictSeverity, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, FusionLayer, type FusionResult, GitIngestor, type GitRunner, GraphAnomalyAdapter, type GraphBudget, GraphComplexityAdapter, type GraphComplexityHotspot, type GraphComplexityResult, type GraphConnector, GraphConstraintAdapter, GraphCouplingAdapter, type GraphCouplingFileData, type GraphCouplingResult, type GraphCoverageReport, type GraphDeadCodeData, type GraphDependencyData, type GraphDriftData, type GraphEdge, GraphEdgeSchema, GraphEntropyAdapter, GraphFeedbackAdapter, type GraphFilterResult, type GraphHarnessCheckData, type GraphImpactData, type GraphLayerViolation, type GraphMetadata, type GraphNode, GraphNodeSchema, type GraphSnapshotSummary, GraphStore, type HttpClient, INTENTS, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeIngestor, type LinkResult, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, type PairResult, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, SlackConnector, type SourceLocation, type StatisticalOutlier, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, groupNodesByImpact, linkToCode, loadGraph, project, queryTraceability, saveGraph };
1224
+ export { type AnomalyDetectionOptions, type AnomalyReport, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, CIConnector, CURRENT_SCHEMA_VERSION, type PackedEnvelope as CacheableEnvelope, type CascadeLayer, type CascadeNode, type CascadeResult, type CascadeSimulationOptions, CascadeSimulator, type ClassificationResult, CodeIngestor, CompositeProbabilityStrategy, type ConflictDetail, type ConflictPrediction, ConflictPredictor, type ConflictSeverity, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, FusionLayer, type FusionResult, GitIngestor, type GitRunner, GraphAnomalyAdapter, type GraphBudget, GraphComplexityAdapter, type GraphComplexityHotspot, type GraphComplexityResult, type GraphConnector, GraphConstraintAdapter, GraphCouplingAdapter, type GraphCouplingFileData, type GraphCouplingResult, type GraphCoverageReport, type GraphDeadCodeData, type GraphDependencyData, type GraphDriftData, type GraphEdge, GraphEdgeSchema, GraphEntropyAdapter, GraphFeedbackAdapter, type GraphFilterResult, type GraphHarnessCheckData, type GraphImpactData, type GraphLayerViolation, type GraphMetadata, type GraphNode, GraphNodeSchema, type GraphSnapshotSummary, type GraphStabilityTier, GraphStore, type HttpClient, INTENTS, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeIngestor, type LinkResult, NODE_STABILITY, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, PackedSummaryCache, type PairResult, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, SlackConnector, type SourceLocation, type StatisticalOutlier, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, groupNodesByImpact, linkToCode, loadGraph, normalizeIntent, project, queryTraceability, saveGraph };