@harness-engineering/graph 0.5.0 → 0.7.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/index.d.mts CHANGED
@@ -252,7 +252,17 @@ interface SerializedGraph {
252
252
  readonly edges: readonly GraphEdge[];
253
253
  }
254
254
  declare function saveGraph(dirPath: string, nodes: readonly GraphNode[], edges: readonly GraphEdge[]): Promise<void>;
255
- declare function loadGraph(dirPath: string): Promise<SerializedGraph | null>;
255
+ type LoadGraphResult = {
256
+ status: 'loaded';
257
+ graph: SerializedGraph;
258
+ } | {
259
+ status: 'not_found';
260
+ } | {
261
+ status: 'schema_mismatch';
262
+ found: number;
263
+ expected: number;
264
+ };
265
+ declare function loadGraph(dirPath: string): Promise<LoadGraphResult>;
256
266
 
257
267
  /**
258
268
  * Minimal PackedEnvelope shape -- avoids circular dep on @harness-engineering/core.
@@ -449,6 +459,22 @@ declare class BusinessKnowledgeIngestor {
449
459
  private findMarkdownFiles;
450
460
  }
451
461
 
462
+ /**
463
+ * Ingests ADR files from docs/knowledge/decisions/ into the knowledge graph.
464
+ *
465
+ * Parses YAML frontmatter with fields: number, title, date, status, tier,
466
+ * source, supersedes. Creates `decision` type graph nodes with `decided`
467
+ * edges to code nodes mentioned in the body.
468
+ */
469
+ declare class DecisionIngestor {
470
+ private readonly store;
471
+ constructor(store: GraphStore);
472
+ ingest(decisionsDir: string): Promise<IngestResult>;
473
+ private parseFrontmatter;
474
+ private linkToCode;
475
+ private findDecisionFiles;
476
+ }
477
+
452
478
  declare class RequirementIngestor {
453
479
  private readonly store;
454
480
  constructor(store: GraphStore);
@@ -486,6 +512,33 @@ declare class RequirementIngestor {
486
512
  private linkByKeywordOverlap;
487
513
  }
488
514
 
515
+ /**
516
+ * Domain inference for graph nodes.
517
+ *
518
+ * Precedence (highest to lowest):
519
+ * 1. node.metadata.domain (explicit)
520
+ * 2. extraPatterns (config-provided)
521
+ * 3. DEFAULT_PATTERNS (built-in)
522
+ * 4. Generic first non-blocklisted path segment
523
+ * 5. KnowledgeLinker connector source (path-less facts)
524
+ * 6. 'unknown'
525
+ *
526
+ * Pattern format: 'prefix/<dir>'. Single-segment prefix only. <dir> captures
527
+ * the segment immediately after the prefix.
528
+ */
529
+ interface DomainInferenceOptions {
530
+ /** Additional patterns beyond the built-in defaults. Format: 'prefix/<dir>'. */
531
+ extraPatterns?: readonly string[];
532
+ /** Additional blocklisted segments beyond the built-in defaults. */
533
+ extraBlocklist?: readonly string[];
534
+ }
535
+ declare const DEFAULT_PATTERNS: readonly string[];
536
+ declare const DEFAULT_BLOCKLIST: ReadonlySet<string>;
537
+ declare function inferDomain(node: {
538
+ path?: string;
539
+ metadata?: Record<string, unknown>;
540
+ }, options?: DomainInferenceOptions): string;
541
+
489
542
  type DriftClassification = 'new' | 'drifted' | 'stale' | 'contradicting';
490
543
  interface KnowledgeSnapshotEntry {
491
544
  readonly id: string;
@@ -539,13 +592,25 @@ interface StagedEntry {
539
592
  readonly contentHash: string;
540
593
  readonly timestamp: string;
541
594
  }
595
+ interface GapEntry {
596
+ readonly nodeId: string;
597
+ readonly name: string;
598
+ readonly nodeType: NodeType;
599
+ readonly source: string;
600
+ readonly hasContent: boolean;
601
+ }
542
602
  interface DomainCoverage {
543
603
  readonly domain: string;
544
604
  readonly entryCount: number;
605
+ readonly extractedCount: number;
606
+ readonly gapCount: number;
607
+ readonly gapEntries: readonly GapEntry[];
545
608
  }
546
609
  interface GapReport {
547
610
  readonly domains: readonly DomainCoverage[];
548
611
  readonly totalEntries: number;
612
+ readonly totalExtracted: number;
613
+ readonly totalGaps: number;
549
614
  readonly generatedAt: string;
550
615
  }
551
616
  interface AggregateResult {
@@ -553,9 +618,11 @@ interface AggregateResult {
553
618
  }
554
619
  declare class KnowledgeStagingAggregator {
555
620
  private readonly projectDir;
556
- constructor(projectDir: string);
621
+ private readonly inferenceOptions;
622
+ constructor(projectDir: string, inferenceOptions?: DomainInferenceOptions);
557
623
  aggregate(extractorResults: readonly StagedEntry[], linkerResults: readonly StagedEntry[], diagramResults: readonly StagedEntry[]): Promise<AggregateResult>;
558
- generateGapReport(knowledgeDir: string): Promise<GapReport>;
624
+ private extractDocName;
625
+ generateGapReport(knowledgeDir: string, store?: GraphStore): Promise<GapReport>;
559
626
  writeGapReport(report: GapReport): Promise<void>;
560
627
  }
561
628
 
@@ -601,6 +668,12 @@ declare class ImageAnalysisExtractor {
601
668
  readonly maxFileSizeBytes: number;
602
669
  constructor(options: ImageAnalysisExtractorOptions);
603
670
  analyze(store: GraphStore, imagePaths: readonly string[]): Promise<IngestResult>;
671
+ /** Analyze a single image and add annotation + concept nodes to the store. */
672
+ private processImage;
673
+ /** Link annotation to its source file node if it exists. Returns 1 if linked, 0 otherwise. */
674
+ private linkToFileNode;
675
+ /** Create a business_concept node for a design pattern and link it. Returns edges added. */
676
+ private addDesignPatternConcept;
604
677
  }
605
678
 
606
679
  type ConflictType = 'value_mismatch' | 'definition_conflict' | 'status_divergence' | 'temporal_conflict';
@@ -646,8 +719,52 @@ interface CoverageReport {
646
719
  readonly generatedAt: string;
647
720
  }
648
721
  declare class CoverageScorer {
722
+ private readonly inferenceOptions;
723
+ constructor(inferenceOptions?: DomainInferenceOptions);
649
724
  score(store: GraphStore): CoverageReport;
650
- private domainFromPath;
725
+ }
726
+
727
+ /**
728
+ * Knowledge Document Materializer
729
+ *
730
+ * Takes GapEntry[] from the differential gap report and creates
731
+ * docs/knowledge/{domain}/*.md files from graph nodes.
732
+ * Frontmatter is compatible with BusinessKnowledgeIngestor's parseFrontmatter().
733
+ */
734
+
735
+ interface MaterializeOptions {
736
+ readonly projectDir: string;
737
+ readonly dryRun: boolean;
738
+ readonly maxDocs?: number;
739
+ }
740
+ interface MaterializeResult {
741
+ readonly created: readonly MaterializedDoc[];
742
+ readonly skipped: readonly SkippedEntry[];
743
+ }
744
+ interface MaterializedDoc {
745
+ readonly filePath: string;
746
+ readonly nodeId: string;
747
+ readonly domain: string;
748
+ readonly name: string;
749
+ }
750
+ interface SkippedEntry {
751
+ readonly nodeId: string;
752
+ readonly name: string;
753
+ readonly reason: 'no_content' | 'no_domain' | 'already_documented' | 'dry_run' | 'cap_reached';
754
+ }
755
+ declare class KnowledgeDocMaterializer {
756
+ private readonly store;
757
+ private readonly inferenceOptions;
758
+ constructor(store: GraphStore, inferenceOptions?: DomainInferenceOptions);
759
+ materialize(gapEntries: readonly GapEntry[], options: MaterializeOptions): Promise<MaterializeResult>;
760
+ private resolveEntry;
761
+ inferDomain(node: GraphNode): string | null;
762
+ generateFilename(name: string): string;
763
+ resolveCollision(dir: string, basename: string): Promise<string>;
764
+ formatDoc(node: GraphNode, domain: string): string;
765
+ /** Check if a doc with a matching title already exists in the domain directory. */
766
+ private hasExistingDoc;
767
+ mapNodeType(node: GraphNode): NodeType;
651
768
  }
652
769
 
653
770
  /**
@@ -671,12 +788,20 @@ interface KnowledgePipelineOptions {
671
788
  readonly analyzeImages?: boolean;
672
789
  readonly analysisProvider?: AnalysisProvider;
673
790
  readonly imagePaths?: readonly string[];
791
+ /**
792
+ * Domain-inference overrides threaded into KnowledgeStagingAggregator,
793
+ * CoverageScorer, and KnowledgeDocMaterializer. Sourced by the CLI from
794
+ * `harness.config.json#knowledge.domainPatterns` (→ extraPatterns) and
795
+ * `knowledge.domainBlocklist` (→ extraBlocklist). Defaults to {} when absent.
796
+ */
797
+ readonly inferenceOptions?: DomainInferenceOptions;
674
798
  }
675
799
  interface ExtractionCounts {
676
800
  readonly codeSignals: number;
677
801
  readonly diagrams: number;
678
802
  readonly linkerFacts: number;
679
803
  readonly businessKnowledge: number;
804
+ readonly decisions: number;
680
805
  readonly images: number;
681
806
  }
682
807
  interface KnowledgePipelineResult {
@@ -689,11 +814,18 @@ interface KnowledgePipelineResult {
689
814
  readonly remediations: readonly string[];
690
815
  readonly contradictions: ContradictionResult;
691
816
  readonly coverage: CoverageReport;
817
+ readonly materialization?: MaterializeResult;
692
818
  }
693
819
  declare class KnowledgePipelineRunner {
694
820
  private readonly store;
695
821
  constructor(store: GraphStore);
822
+ /** Resolved per-`run()` inference options. Set on entry to `run()`. */
823
+ private inferenceOptions;
696
824
  run(options: KnowledgePipelineOptions): Promise<KnowledgePipelineResult>;
825
+ /** Run the remediation convergence loop; returns iteration count and accumulated materialization. */
826
+ private runRemediationLoop;
827
+ /** Assemble the final pipeline result. */
828
+ private buildResult;
697
829
  private extract;
698
830
  private buildSnapshot;
699
831
  private reconcile;
@@ -705,12 +837,8 @@ declare class KnowledgePipelineRunner {
705
837
  }
706
838
 
707
839
  /**
708
- * Diagram-as-code parser types and format-specific implementations.
709
- *
710
- * Extracts entities and relationships from diagram files (Mermaid, D2, PlantUML)
711
- * and maps them to the knowledge graph.
840
+ * Shared types for diagram format parsers.
712
841
  */
713
-
714
842
  interface DiagramEntity {
715
843
  readonly id: string;
716
844
  readonly label: string;
@@ -733,29 +861,59 @@ interface DiagramFormatParser {
733
861
  canParse(content: string, ext: string): boolean;
734
862
  parse(content: string, filePath: string): DiagramParseResult;
735
863
  }
864
+
865
+ /**
866
+ * Mermaid diagram format parser.
867
+ *
868
+ * Handles .mmd and .mermaid files, supporting flowchart and sequence diagram types.
869
+ */
870
+
736
871
  declare class MermaidParser implements DiagramFormatParser {
737
872
  canParse(_content: string, ext: string): boolean;
738
873
  parse(content: string, _filePath: string): DiagramParseResult;
739
- private detectDiagramType;
740
- private parseFlowchart;
741
- private isDecisionNode;
742
- private parseSequence;
743
874
  }
875
+
876
+ /**
877
+ * D2 diagram format parser.
878
+ *
879
+ * Handles .d2 files, extracting entities and connections from D2 architecture diagrams.
880
+ */
881
+
744
882
  declare class D2Parser implements DiagramFormatParser {
745
883
  canParse(_content: string, ext: string): boolean;
746
884
  parse(content: string, _filePath: string): DiagramParseResult;
747
885
  }
886
+
887
+ /**
888
+ * PlantUML diagram format parser.
889
+ *
890
+ * Handles .puml and .plantuml files, supporting class and component diagram types.
891
+ */
892
+
748
893
  declare class PlantUmlParser implements DiagramFormatParser {
749
894
  canParse(_content: string, ext: string): boolean;
750
895
  parse(content: string, _filePath: string): DiagramParseResult;
751
- private detectDiagramType;
752
896
  }
897
+
898
+ /**
899
+ * Diagram-as-code parser orchestrator.
900
+ *
901
+ * Delegates to format-specific parsers (Mermaid, D2, PlantUML) and maps
902
+ * extracted entities/relationships to the knowledge graph.
903
+ *
904
+ * Format-specific implementations live in ./parsers/.
905
+ */
906
+
753
907
  declare class DiagramParser {
754
908
  private readonly store;
755
909
  private readonly parsers;
756
910
  constructor(store: GraphStore);
757
911
  parse(content: string, filePath: string): DiagramParseResult;
758
912
  ingest(projectDir: string): Promise<IngestResult>;
913
+ /** Map diagram entities to business_concept graph nodes. */
914
+ private addEntityNodes;
915
+ /** Map diagram relationships to references graph edges. */
916
+ private addRelationshipEdges;
759
917
  private findDiagramFiles;
760
918
  }
761
919
 
@@ -852,6 +1010,12 @@ declare class FigmaConnector implements GraphConnector {
852
1010
  constructor(httpClient?: HttpClient);
853
1011
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
854
1012
  private processFile;
1013
+ private ingestStyles;
1014
+ private processStyle;
1015
+ private ingestComponents;
1016
+ private processComponent;
1017
+ private addComponentIntent;
1018
+ private addComponentConstraint;
855
1019
  }
856
1020
 
857
1021
  declare class MiroConnector implements GraphConnector {
@@ -1700,6 +1864,6 @@ declare class CascadeSimulator {
1700
1864
  private buildResult;
1701
1865
  }
1702
1866
 
1703
- declare const VERSION = "0.4.3";
1867
+ declare const VERSION = "0.6.0";
1704
1868
 
1705
- export { ALL_EXTRACTORS, type AggregateResult, type AnomalyDetectionOptions, type AnomalyReport, ApiPathExtractor, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, BusinessKnowledgeIngestor, 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, type ConflictType, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, type Contradiction, ContradictionDetector, type ContradictionEntry, type ContradictionResult, type CoverageReport, CoverageScorer, D2Parser, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, type DetectedElement, type DiagramEntity, type DiagramFormatParser, type DiagramParseResult, DiagramParser, type DiagramRelationship, type DomainCoverage, type DomainCoverageScore, type DriftClassification, type DriftDetector, type DriftFinding, type DriftResult, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, EnumConstantExtractor, type ExtractionCounts, type ExtractionRecord, ExtractionRunner, FigmaConnector, FusionLayer, type FusionResult, type GapReport, 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, ImageAnalysisExtractor, type ImageAnalysisExtractorOptions, type AnalysisProvider as ImageAnalysisProvider, type ImageAnalysisResult, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeIngestor, type KnowledgePipelineOptions, type KnowledgePipelineResult, KnowledgePipelineRunner, type KnowledgeSnapshot, type KnowledgeSnapshotEntry, KnowledgeStagingAggregator, type Language, type LinkResult, MermaidParser, MiroConnector, NODE_STABILITY, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, PackedSummaryCache, type PairResult, PlantUmlParser, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, type SignalExtractor, SlackConnector, type SourceLocation, type StagedEntry, type StatisticalOutlier, StructuralDriftDetector, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TestDescriptionExtractor, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, ValidationRuleExtractor, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, createExtractionRunner, detectLanguage, groupNodesByImpact, linkToCode, loadGraph, normalizeIntent, project, queryTraceability, saveGraph };
1869
+ export { ALL_EXTRACTORS, type AggregateResult, type AnomalyDetectionOptions, type AnomalyReport, ApiPathExtractor, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, BusinessKnowledgeIngestor, 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, type ConflictType, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, type Contradiction, ContradictionDetector, type ContradictionEntry, type ContradictionResult, type CoverageReport, CoverageScorer, D2Parser, DEFAULT_BLOCKLIST, DEFAULT_PATTERNS, DecisionIngestor, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, type DetectedElement, type DiagramEntity, type DiagramFormatParser, type DiagramParseResult, DiagramParser, type DiagramRelationship, type DomainCoverage, type DomainCoverageScore, type DomainInferenceOptions, type DriftClassification, type DriftDetector, type DriftFinding, type DriftResult, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, EnumConstantExtractor, type ExtractionCounts, type ExtractionRecord, ExtractionRunner, FigmaConnector, FusionLayer, type FusionResult, type GapEntry, type GapReport, 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, ImageAnalysisExtractor, type ImageAnalysisExtractorOptions, type AnalysisProvider as ImageAnalysisProvider, type ImageAnalysisResult, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeDocMaterializer, KnowledgeIngestor, type KnowledgePipelineOptions, type KnowledgePipelineResult, KnowledgePipelineRunner, type KnowledgeSnapshot, type KnowledgeSnapshotEntry, KnowledgeStagingAggregator, type Language, type LinkResult, type LoadGraphResult, type MaterializeOptions, type MaterializeResult, type MaterializedDoc, MermaidParser, MiroConnector, NODE_STABILITY, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, PackedSummaryCache, type PairResult, PlantUmlParser, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, type SignalExtractor, type SkippedEntry, SlackConnector, type SourceLocation, type StagedEntry, type StatisticalOutlier, StructuralDriftDetector, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TestDescriptionExtractor, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, ValidationRuleExtractor, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, createExtractionRunner, detectLanguage, groupNodesByImpact, inferDomain, linkToCode, loadGraph, normalizeIntent, project, queryTraceability, saveGraph };
package/dist/index.d.ts CHANGED
@@ -252,7 +252,17 @@ interface SerializedGraph {
252
252
  readonly edges: readonly GraphEdge[];
253
253
  }
254
254
  declare function saveGraph(dirPath: string, nodes: readonly GraphNode[], edges: readonly GraphEdge[]): Promise<void>;
255
- declare function loadGraph(dirPath: string): Promise<SerializedGraph | null>;
255
+ type LoadGraphResult = {
256
+ status: 'loaded';
257
+ graph: SerializedGraph;
258
+ } | {
259
+ status: 'not_found';
260
+ } | {
261
+ status: 'schema_mismatch';
262
+ found: number;
263
+ expected: number;
264
+ };
265
+ declare function loadGraph(dirPath: string): Promise<LoadGraphResult>;
256
266
 
257
267
  /**
258
268
  * Minimal PackedEnvelope shape -- avoids circular dep on @harness-engineering/core.
@@ -449,6 +459,22 @@ declare class BusinessKnowledgeIngestor {
449
459
  private findMarkdownFiles;
450
460
  }
451
461
 
462
+ /**
463
+ * Ingests ADR files from docs/knowledge/decisions/ into the knowledge graph.
464
+ *
465
+ * Parses YAML frontmatter with fields: number, title, date, status, tier,
466
+ * source, supersedes. Creates `decision` type graph nodes with `decided`
467
+ * edges to code nodes mentioned in the body.
468
+ */
469
+ declare class DecisionIngestor {
470
+ private readonly store;
471
+ constructor(store: GraphStore);
472
+ ingest(decisionsDir: string): Promise<IngestResult>;
473
+ private parseFrontmatter;
474
+ private linkToCode;
475
+ private findDecisionFiles;
476
+ }
477
+
452
478
  declare class RequirementIngestor {
453
479
  private readonly store;
454
480
  constructor(store: GraphStore);
@@ -486,6 +512,33 @@ declare class RequirementIngestor {
486
512
  private linkByKeywordOverlap;
487
513
  }
488
514
 
515
+ /**
516
+ * Domain inference for graph nodes.
517
+ *
518
+ * Precedence (highest to lowest):
519
+ * 1. node.metadata.domain (explicit)
520
+ * 2. extraPatterns (config-provided)
521
+ * 3. DEFAULT_PATTERNS (built-in)
522
+ * 4. Generic first non-blocklisted path segment
523
+ * 5. KnowledgeLinker connector source (path-less facts)
524
+ * 6. 'unknown'
525
+ *
526
+ * Pattern format: 'prefix/<dir>'. Single-segment prefix only. <dir> captures
527
+ * the segment immediately after the prefix.
528
+ */
529
+ interface DomainInferenceOptions {
530
+ /** Additional patterns beyond the built-in defaults. Format: 'prefix/<dir>'. */
531
+ extraPatterns?: readonly string[];
532
+ /** Additional blocklisted segments beyond the built-in defaults. */
533
+ extraBlocklist?: readonly string[];
534
+ }
535
+ declare const DEFAULT_PATTERNS: readonly string[];
536
+ declare const DEFAULT_BLOCKLIST: ReadonlySet<string>;
537
+ declare function inferDomain(node: {
538
+ path?: string;
539
+ metadata?: Record<string, unknown>;
540
+ }, options?: DomainInferenceOptions): string;
541
+
489
542
  type DriftClassification = 'new' | 'drifted' | 'stale' | 'contradicting';
490
543
  interface KnowledgeSnapshotEntry {
491
544
  readonly id: string;
@@ -539,13 +592,25 @@ interface StagedEntry {
539
592
  readonly contentHash: string;
540
593
  readonly timestamp: string;
541
594
  }
595
+ interface GapEntry {
596
+ readonly nodeId: string;
597
+ readonly name: string;
598
+ readonly nodeType: NodeType;
599
+ readonly source: string;
600
+ readonly hasContent: boolean;
601
+ }
542
602
  interface DomainCoverage {
543
603
  readonly domain: string;
544
604
  readonly entryCount: number;
605
+ readonly extractedCount: number;
606
+ readonly gapCount: number;
607
+ readonly gapEntries: readonly GapEntry[];
545
608
  }
546
609
  interface GapReport {
547
610
  readonly domains: readonly DomainCoverage[];
548
611
  readonly totalEntries: number;
612
+ readonly totalExtracted: number;
613
+ readonly totalGaps: number;
549
614
  readonly generatedAt: string;
550
615
  }
551
616
  interface AggregateResult {
@@ -553,9 +618,11 @@ interface AggregateResult {
553
618
  }
554
619
  declare class KnowledgeStagingAggregator {
555
620
  private readonly projectDir;
556
- constructor(projectDir: string);
621
+ private readonly inferenceOptions;
622
+ constructor(projectDir: string, inferenceOptions?: DomainInferenceOptions);
557
623
  aggregate(extractorResults: readonly StagedEntry[], linkerResults: readonly StagedEntry[], diagramResults: readonly StagedEntry[]): Promise<AggregateResult>;
558
- generateGapReport(knowledgeDir: string): Promise<GapReport>;
624
+ private extractDocName;
625
+ generateGapReport(knowledgeDir: string, store?: GraphStore): Promise<GapReport>;
559
626
  writeGapReport(report: GapReport): Promise<void>;
560
627
  }
561
628
 
@@ -601,6 +668,12 @@ declare class ImageAnalysisExtractor {
601
668
  readonly maxFileSizeBytes: number;
602
669
  constructor(options: ImageAnalysisExtractorOptions);
603
670
  analyze(store: GraphStore, imagePaths: readonly string[]): Promise<IngestResult>;
671
+ /** Analyze a single image and add annotation + concept nodes to the store. */
672
+ private processImage;
673
+ /** Link annotation to its source file node if it exists. Returns 1 if linked, 0 otherwise. */
674
+ private linkToFileNode;
675
+ /** Create a business_concept node for a design pattern and link it. Returns edges added. */
676
+ private addDesignPatternConcept;
604
677
  }
605
678
 
606
679
  type ConflictType = 'value_mismatch' | 'definition_conflict' | 'status_divergence' | 'temporal_conflict';
@@ -646,8 +719,52 @@ interface CoverageReport {
646
719
  readonly generatedAt: string;
647
720
  }
648
721
  declare class CoverageScorer {
722
+ private readonly inferenceOptions;
723
+ constructor(inferenceOptions?: DomainInferenceOptions);
649
724
  score(store: GraphStore): CoverageReport;
650
- private domainFromPath;
725
+ }
726
+
727
+ /**
728
+ * Knowledge Document Materializer
729
+ *
730
+ * Takes GapEntry[] from the differential gap report and creates
731
+ * docs/knowledge/{domain}/*.md files from graph nodes.
732
+ * Frontmatter is compatible with BusinessKnowledgeIngestor's parseFrontmatter().
733
+ */
734
+
735
+ interface MaterializeOptions {
736
+ readonly projectDir: string;
737
+ readonly dryRun: boolean;
738
+ readonly maxDocs?: number;
739
+ }
740
+ interface MaterializeResult {
741
+ readonly created: readonly MaterializedDoc[];
742
+ readonly skipped: readonly SkippedEntry[];
743
+ }
744
+ interface MaterializedDoc {
745
+ readonly filePath: string;
746
+ readonly nodeId: string;
747
+ readonly domain: string;
748
+ readonly name: string;
749
+ }
750
+ interface SkippedEntry {
751
+ readonly nodeId: string;
752
+ readonly name: string;
753
+ readonly reason: 'no_content' | 'no_domain' | 'already_documented' | 'dry_run' | 'cap_reached';
754
+ }
755
+ declare class KnowledgeDocMaterializer {
756
+ private readonly store;
757
+ private readonly inferenceOptions;
758
+ constructor(store: GraphStore, inferenceOptions?: DomainInferenceOptions);
759
+ materialize(gapEntries: readonly GapEntry[], options: MaterializeOptions): Promise<MaterializeResult>;
760
+ private resolveEntry;
761
+ inferDomain(node: GraphNode): string | null;
762
+ generateFilename(name: string): string;
763
+ resolveCollision(dir: string, basename: string): Promise<string>;
764
+ formatDoc(node: GraphNode, domain: string): string;
765
+ /** Check if a doc with a matching title already exists in the domain directory. */
766
+ private hasExistingDoc;
767
+ mapNodeType(node: GraphNode): NodeType;
651
768
  }
652
769
 
653
770
  /**
@@ -671,12 +788,20 @@ interface KnowledgePipelineOptions {
671
788
  readonly analyzeImages?: boolean;
672
789
  readonly analysisProvider?: AnalysisProvider;
673
790
  readonly imagePaths?: readonly string[];
791
+ /**
792
+ * Domain-inference overrides threaded into KnowledgeStagingAggregator,
793
+ * CoverageScorer, and KnowledgeDocMaterializer. Sourced by the CLI from
794
+ * `harness.config.json#knowledge.domainPatterns` (→ extraPatterns) and
795
+ * `knowledge.domainBlocklist` (→ extraBlocklist). Defaults to {} when absent.
796
+ */
797
+ readonly inferenceOptions?: DomainInferenceOptions;
674
798
  }
675
799
  interface ExtractionCounts {
676
800
  readonly codeSignals: number;
677
801
  readonly diagrams: number;
678
802
  readonly linkerFacts: number;
679
803
  readonly businessKnowledge: number;
804
+ readonly decisions: number;
680
805
  readonly images: number;
681
806
  }
682
807
  interface KnowledgePipelineResult {
@@ -689,11 +814,18 @@ interface KnowledgePipelineResult {
689
814
  readonly remediations: readonly string[];
690
815
  readonly contradictions: ContradictionResult;
691
816
  readonly coverage: CoverageReport;
817
+ readonly materialization?: MaterializeResult;
692
818
  }
693
819
  declare class KnowledgePipelineRunner {
694
820
  private readonly store;
695
821
  constructor(store: GraphStore);
822
+ /** Resolved per-`run()` inference options. Set on entry to `run()`. */
823
+ private inferenceOptions;
696
824
  run(options: KnowledgePipelineOptions): Promise<KnowledgePipelineResult>;
825
+ /** Run the remediation convergence loop; returns iteration count and accumulated materialization. */
826
+ private runRemediationLoop;
827
+ /** Assemble the final pipeline result. */
828
+ private buildResult;
697
829
  private extract;
698
830
  private buildSnapshot;
699
831
  private reconcile;
@@ -705,12 +837,8 @@ declare class KnowledgePipelineRunner {
705
837
  }
706
838
 
707
839
  /**
708
- * Diagram-as-code parser types and format-specific implementations.
709
- *
710
- * Extracts entities and relationships from diagram files (Mermaid, D2, PlantUML)
711
- * and maps them to the knowledge graph.
840
+ * Shared types for diagram format parsers.
712
841
  */
713
-
714
842
  interface DiagramEntity {
715
843
  readonly id: string;
716
844
  readonly label: string;
@@ -733,29 +861,59 @@ interface DiagramFormatParser {
733
861
  canParse(content: string, ext: string): boolean;
734
862
  parse(content: string, filePath: string): DiagramParseResult;
735
863
  }
864
+
865
+ /**
866
+ * Mermaid diagram format parser.
867
+ *
868
+ * Handles .mmd and .mermaid files, supporting flowchart and sequence diagram types.
869
+ */
870
+
736
871
  declare class MermaidParser implements DiagramFormatParser {
737
872
  canParse(_content: string, ext: string): boolean;
738
873
  parse(content: string, _filePath: string): DiagramParseResult;
739
- private detectDiagramType;
740
- private parseFlowchart;
741
- private isDecisionNode;
742
- private parseSequence;
743
874
  }
875
+
876
+ /**
877
+ * D2 diagram format parser.
878
+ *
879
+ * Handles .d2 files, extracting entities and connections from D2 architecture diagrams.
880
+ */
881
+
744
882
  declare class D2Parser implements DiagramFormatParser {
745
883
  canParse(_content: string, ext: string): boolean;
746
884
  parse(content: string, _filePath: string): DiagramParseResult;
747
885
  }
886
+
887
+ /**
888
+ * PlantUML diagram format parser.
889
+ *
890
+ * Handles .puml and .plantuml files, supporting class and component diagram types.
891
+ */
892
+
748
893
  declare class PlantUmlParser implements DiagramFormatParser {
749
894
  canParse(_content: string, ext: string): boolean;
750
895
  parse(content: string, _filePath: string): DiagramParseResult;
751
- private detectDiagramType;
752
896
  }
897
+
898
+ /**
899
+ * Diagram-as-code parser orchestrator.
900
+ *
901
+ * Delegates to format-specific parsers (Mermaid, D2, PlantUML) and maps
902
+ * extracted entities/relationships to the knowledge graph.
903
+ *
904
+ * Format-specific implementations live in ./parsers/.
905
+ */
906
+
753
907
  declare class DiagramParser {
754
908
  private readonly store;
755
909
  private readonly parsers;
756
910
  constructor(store: GraphStore);
757
911
  parse(content: string, filePath: string): DiagramParseResult;
758
912
  ingest(projectDir: string): Promise<IngestResult>;
913
+ /** Map diagram entities to business_concept graph nodes. */
914
+ private addEntityNodes;
915
+ /** Map diagram relationships to references graph edges. */
916
+ private addRelationshipEdges;
759
917
  private findDiagramFiles;
760
918
  }
761
919
 
@@ -852,6 +1010,12 @@ declare class FigmaConnector implements GraphConnector {
852
1010
  constructor(httpClient?: HttpClient);
853
1011
  ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
854
1012
  private processFile;
1013
+ private ingestStyles;
1014
+ private processStyle;
1015
+ private ingestComponents;
1016
+ private processComponent;
1017
+ private addComponentIntent;
1018
+ private addComponentConstraint;
855
1019
  }
856
1020
 
857
1021
  declare class MiroConnector implements GraphConnector {
@@ -1700,6 +1864,6 @@ declare class CascadeSimulator {
1700
1864
  private buildResult;
1701
1865
  }
1702
1866
 
1703
- declare const VERSION = "0.4.3";
1867
+ declare const VERSION = "0.6.0";
1704
1868
 
1705
- export { ALL_EXTRACTORS, type AggregateResult, type AnomalyDetectionOptions, type AnomalyReport, ApiPathExtractor, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, BusinessKnowledgeIngestor, 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, type ConflictType, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, type Contradiction, ContradictionDetector, type ContradictionEntry, type ContradictionResult, type CoverageReport, CoverageScorer, D2Parser, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, type DetectedElement, type DiagramEntity, type DiagramFormatParser, type DiagramParseResult, DiagramParser, type DiagramRelationship, type DomainCoverage, type DomainCoverageScore, type DriftClassification, type DriftDetector, type DriftFinding, type DriftResult, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, EnumConstantExtractor, type ExtractionCounts, type ExtractionRecord, ExtractionRunner, FigmaConnector, FusionLayer, type FusionResult, type GapReport, 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, ImageAnalysisExtractor, type ImageAnalysisExtractorOptions, type AnalysisProvider as ImageAnalysisProvider, type ImageAnalysisResult, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeIngestor, type KnowledgePipelineOptions, type KnowledgePipelineResult, KnowledgePipelineRunner, type KnowledgeSnapshot, type KnowledgeSnapshotEntry, KnowledgeStagingAggregator, type Language, type LinkResult, MermaidParser, MiroConnector, NODE_STABILITY, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, PackedSummaryCache, type PairResult, PlantUmlParser, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, type SignalExtractor, SlackConnector, type SourceLocation, type StagedEntry, type StatisticalOutlier, StructuralDriftDetector, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TestDescriptionExtractor, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, ValidationRuleExtractor, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, createExtractionRunner, detectLanguage, groupNodesByImpact, linkToCode, loadGraph, normalizeIntent, project, queryTraceability, saveGraph };
1869
+ export { ALL_EXTRACTORS, type AggregateResult, type AnomalyDetectionOptions, type AnomalyReport, ApiPathExtractor, type ArticulationPoint, type AskGraphResult, type AssembledContext, Assembler, BusinessKnowledgeIngestor, 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, type ConflictType, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, type Contradiction, ContradictionDetector, type ContradictionEntry, type ContradictionResult, type CoverageReport, CoverageScorer, D2Parser, DEFAULT_BLOCKLIST, DEFAULT_PATTERNS, DecisionIngestor, DesignConstraintAdapter, DesignIngestor, type DesignStrictness, type DesignViolation, type DetectedElement, type DiagramEntity, type DiagramFormatParser, type DiagramParseResult, DiagramParser, type DiagramRelationship, type DomainCoverage, type DomainCoverageScore, type DomainInferenceOptions, type DriftClassification, type DriftDetector, type DriftFinding, type DriftResult, EDGE_TYPES, type EdgeQuery, type EdgeType, EntityExtractor, EntityResolver, EnumConstantExtractor, type ExtractionCounts, type ExtractionRecord, ExtractionRunner, FigmaConnector, FusionLayer, type FusionResult, type GapEntry, type GapReport, 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, ImageAnalysisExtractor, type ImageAnalysisExtractorOptions, type AnalysisProvider as ImageAnalysisProvider, type ImageAnalysisResult, type ImpactGroups, type IndependenceCheckParams, type IndependenceResult, type IngestResult, type Intent, IntentClassifier, JiraConnector, KnowledgeDocMaterializer, KnowledgeIngestor, type KnowledgePipelineOptions, type KnowledgePipelineResult, KnowledgePipelineRunner, type KnowledgeSnapshot, type KnowledgeSnapshotEntry, KnowledgeStagingAggregator, type Language, type LinkResult, type LoadGraphResult, type MaterializeOptions, type MaterializeResult, type MaterializedDoc, MermaidParser, MiroConnector, NODE_STABILITY, NODE_TYPES, type NodeCategory, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type OverlapDetail, PackedSummaryCache, type PairResult, PlantUmlParser, type ProbabilityStrategy, type ProjectionSpec, type RequirementCoverage, RequirementIngestor, type ResolvedEntity, ResponseFormatter, type SignalExtractor, type SkippedEntry, SlackConnector, type SourceLocation, type StagedEntry, type StatisticalOutlier, StructuralDriftDetector, SyncManager, type SyncMetadata, type TaskDefinition, TaskIndependenceAnalyzer, TestDescriptionExtractor, TopologicalLinker, type TraceabilityOptions, type TraceabilityResult, type TracedFile, VERSION, ValidationRuleExtractor, type VectorSearchResult, VectorStore, askGraph, classifyNodeCategory, createExtractionRunner, detectLanguage, groupNodesByImpact, inferDomain, linkToCode, loadGraph, normalizeIntent, project, queryTraceability, saveGraph };