@agent-wiki/mcp 0.21.3 → 0.21.5
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/atlassian.d.ts +23 -0
- package/dist/atlassian.d.ts.map +1 -1
- package/dist/atlassian.js +92 -1
- package/dist/atlassian.js.map +1 -1
- package/dist/atlassian.test.d.ts +7 -0
- package/dist/atlassian.test.d.ts.map +1 -0
- package/dist/atlassian.test.js +220 -0
- package/dist/atlassian.test.js.map +1 -0
- package/dist/cobol/__tests__/db2-table-lineage.test.js +182 -1
- package/dist/cobol/__tests__/db2-table-lineage.test.js.map +1 -1
- package/dist/cobol/__tests__/field-lineage.test.js +559 -0
- package/dist/cobol/__tests__/field-lineage.test.js.map +1 -1
- package/dist/cobol/db2-table-lineage.d.ts +36 -0
- package/dist/cobol/db2-table-lineage.d.ts.map +1 -1
- package/dist/cobol/db2-table-lineage.js +98 -12
- package/dist/cobol/db2-table-lineage.js.map +1 -1
- package/dist/cobol/evidence-mapping.d.ts +1 -1
- package/dist/cobol/evidence-mapping.d.ts.map +1 -1
- package/dist/cobol/evidence-mapping.js +1 -0
- package/dist/cobol/evidence-mapping.js.map +1 -1
- package/dist/cobol/field-lineage.d.ts +66 -4
- package/dist/cobol/field-lineage.d.ts.map +1 -1
- package/dist/cobol/field-lineage.js +395 -23
- package/dist/cobol/field-lineage.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { parse } from "../parser.js";
|
|
|
3
3
|
import { extractModel } from "../extractors.js";
|
|
4
4
|
import { attachCallBoundLineage, buildFieldLineage, combineFieldLineage, generateFieldLineagePage, normalizeLoadedFieldLineage, } from "../field-lineage.js";
|
|
5
5
|
import { buildCallBoundLineage } from "../call-boundary-lineage.js";
|
|
6
|
+
import { buildDb2TableLineage } from "../db2-table-lineage.js";
|
|
6
7
|
function model(source, filename) {
|
|
7
8
|
return extractModel(parse(source, filename));
|
|
8
9
|
}
|
|
@@ -572,6 +573,564 @@ describe("COBOL field lineage", () => {
|
|
|
572
573
|
expect(normalized.summary.diagnosticsByKind).toEqual({ "parsed-zero-data-items": 0 });
|
|
573
574
|
expect(normalized.summary.deterministic.fields).toBe(3);
|
|
574
575
|
});
|
|
576
|
+
describe("Coverage section (#31)", () => {
|
|
577
|
+
it("renders ## Coverage as the first section after the frontmatter", () => {
|
|
578
|
+
const lineage = buildFieldLineage([
|
|
579
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
580
|
+
model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl"),
|
|
581
|
+
model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl"),
|
|
582
|
+
]);
|
|
583
|
+
const page = generateFieldLineagePage(lineage);
|
|
584
|
+
const frontmatterEnd = page.content.indexOf("---", page.content.indexOf("---") + 3) + 3;
|
|
585
|
+
const coverageAt = page.content.indexOf("## Coverage");
|
|
586
|
+
const overviewAt = page.content.indexOf("## Overview");
|
|
587
|
+
expect(coverageAt).toBeGreaterThan(frontmatterEnd);
|
|
588
|
+
expect(coverageAt).toBeLessThan(overviewAt);
|
|
589
|
+
expect(page.content).toContain("| Family | Indexed | Yielding lineage | Excluded (top reasons) |");
|
|
590
|
+
});
|
|
591
|
+
it("renders only the Copybook row when callBound and db2 are absent", () => {
|
|
592
|
+
const lineage = buildFieldLineage([
|
|
593
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
594
|
+
model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl"),
|
|
595
|
+
model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl"),
|
|
596
|
+
]);
|
|
597
|
+
const page = generateFieldLineagePage(lineage);
|
|
598
|
+
expect(page.content).toContain("| Copybook |");
|
|
599
|
+
expect(page.content).not.toContain("| Call boundary |");
|
|
600
|
+
expect(page.content).not.toContain("| DB2 |");
|
|
601
|
+
});
|
|
602
|
+
it("renders Call boundary and DB2 rows when those sections are present", () => {
|
|
603
|
+
const callerSrc = `
|
|
604
|
+
IDENTIFICATION DIVISION.
|
|
605
|
+
PROGRAM-ID. CALLER.
|
|
606
|
+
DATA DIVISION.
|
|
607
|
+
WORKING-STORAGE SECTION.
|
|
608
|
+
01 WS-REC.
|
|
609
|
+
05 WS-FIELD-A PIC X(5).
|
|
610
|
+
05 WS-OTHER PIC X(5).
|
|
611
|
+
PROCEDURE DIVISION.
|
|
612
|
+
A000-MAIN SECTION.
|
|
613
|
+
A100-START.
|
|
614
|
+
CALL "CALLEE" USING WS-REC.
|
|
615
|
+
STOP RUN.
|
|
616
|
+
`;
|
|
617
|
+
const calleeSrc = `
|
|
618
|
+
IDENTIFICATION DIVISION.
|
|
619
|
+
PROGRAM-ID. CALLEE.
|
|
620
|
+
DATA DIVISION.
|
|
621
|
+
LINKAGE SECTION.
|
|
622
|
+
01 LK-REC.
|
|
623
|
+
05 LK-FIELD-A PIC X(5).
|
|
624
|
+
05 LK-OTHER PIC X(5).
|
|
625
|
+
PROCEDURE DIVISION USING LK-REC.
|
|
626
|
+
A000-MAIN SECTION.
|
|
627
|
+
A100-START.
|
|
628
|
+
GOBACK.
|
|
629
|
+
`;
|
|
630
|
+
const writerSrc = `
|
|
631
|
+
IDENTIFICATION DIVISION.
|
|
632
|
+
PROGRAM-ID. WRITER.
|
|
633
|
+
DATA DIVISION.
|
|
634
|
+
WORKING-STORAGE SECTION.
|
|
635
|
+
01 WS-ID PIC X(10).
|
|
636
|
+
PROCEDURE DIVISION.
|
|
637
|
+
A000-MAIN SECTION.
|
|
638
|
+
A100-START.
|
|
639
|
+
EXEC SQL INSERT INTO CUSTOMERS (ID) VALUES (:WS-ID) END-EXEC.
|
|
640
|
+
STOP RUN.
|
|
641
|
+
`;
|
|
642
|
+
const readerSrc = `
|
|
643
|
+
IDENTIFICATION DIVISION.
|
|
644
|
+
PROGRAM-ID. READER.
|
|
645
|
+
DATA DIVISION.
|
|
646
|
+
WORKING-STORAGE SECTION.
|
|
647
|
+
01 WS-ID PIC X(10).
|
|
648
|
+
PROCEDURE DIVISION.
|
|
649
|
+
A000-MAIN SECTION.
|
|
650
|
+
A100-START.
|
|
651
|
+
EXEC SQL SELECT ID INTO :WS-ID FROM CUSTOMERS END-EXEC.
|
|
652
|
+
STOP RUN.
|
|
653
|
+
`;
|
|
654
|
+
const models = [
|
|
655
|
+
model(callerSrc, "CALLER.cbl"),
|
|
656
|
+
model(calleeSrc, "CALLEE.cbl"),
|
|
657
|
+
model(writerSrc, "WRITER.cbl"),
|
|
658
|
+
model(readerSrc, "READER.cbl"),
|
|
659
|
+
];
|
|
660
|
+
const callBound = buildCallBoundLineage(models);
|
|
661
|
+
const db2 = buildDb2TableLineage(models);
|
|
662
|
+
const lineage = combineFieldLineage(null, { callBound, db2 });
|
|
663
|
+
expect(lineage).not.toBeNull();
|
|
664
|
+
const page = generateFieldLineagePage(lineage);
|
|
665
|
+
expect(page.content).toContain("## Coverage");
|
|
666
|
+
expect(page.content).not.toContain("| Copybook |");
|
|
667
|
+
expect(page.content).toMatch(/\| Call boundary \| \d+ call site\(s\) \| \d+ pair\(s\) \|/);
|
|
668
|
+
expect(page.content).toMatch(/\| DB2 \| \d+ table\(s\) \| \d+ writer→reader pair\(s\) \|/);
|
|
669
|
+
});
|
|
670
|
+
it("Excluded column lists top-2 reasons (count desc, kind asc tiebreak) and — when none", () => {
|
|
671
|
+
// Call boundary with three diagnostic kinds at known counts.
|
|
672
|
+
// Construct two unresolved-callee, two dynamic-call, one arity-mismatch.
|
|
673
|
+
// Expected order in cell: 2 dynamic-call (kind asc on tie), 2 unresolved-callee.
|
|
674
|
+
const callerSrc = `
|
|
675
|
+
IDENTIFICATION DIVISION.
|
|
676
|
+
PROGRAM-ID. CALLER.
|
|
677
|
+
DATA DIVISION.
|
|
678
|
+
WORKING-STORAGE SECTION.
|
|
679
|
+
01 WS-A PIC X(5).
|
|
680
|
+
01 WS-B PIC X(5).
|
|
681
|
+
01 WS-CALLEE PIC X(8).
|
|
682
|
+
PROCEDURE DIVISION.
|
|
683
|
+
A000-MAIN SECTION.
|
|
684
|
+
A100-START.
|
|
685
|
+
CALL "MISSING1" USING WS-A.
|
|
686
|
+
CALL "MISSING2" USING WS-A.
|
|
687
|
+
CALL WS-CALLEE USING WS-A.
|
|
688
|
+
CALL WS-CALLEE USING WS-A.
|
|
689
|
+
CALL "CALLEE" USING WS-A WS-B.
|
|
690
|
+
STOP RUN.
|
|
691
|
+
`;
|
|
692
|
+
const calleeSrc = `
|
|
693
|
+
IDENTIFICATION DIVISION.
|
|
694
|
+
PROGRAM-ID. CALLEE.
|
|
695
|
+
DATA DIVISION.
|
|
696
|
+
LINKAGE SECTION.
|
|
697
|
+
01 LK-A PIC X(5).
|
|
698
|
+
PROCEDURE DIVISION USING LK-A.
|
|
699
|
+
A000-MAIN SECTION.
|
|
700
|
+
A100-START.
|
|
701
|
+
GOBACK.
|
|
702
|
+
`;
|
|
703
|
+
const callBound = buildCallBoundLineage([
|
|
704
|
+
model(callerSrc, "CALLER.cbl"),
|
|
705
|
+
model(calleeSrc, "CALLEE.cbl"),
|
|
706
|
+
]);
|
|
707
|
+
expect(callBound).not.toBeNull();
|
|
708
|
+
expect(callBound.summary.diagnosticsByKind["unresolved-callee"]).toBe(2);
|
|
709
|
+
expect(callBound.summary.diagnosticsByKind["dynamic-call"]).toBe(2);
|
|
710
|
+
expect(callBound.summary.diagnosticsByKind["arity-mismatch"]).toBe(1);
|
|
711
|
+
const lineage = combineFieldLineage(null, { callBound });
|
|
712
|
+
const page = generateFieldLineagePage(lineage);
|
|
713
|
+
// Find the Call boundary row inside the Coverage table.
|
|
714
|
+
const coverageStart = page.content.indexOf("## Coverage");
|
|
715
|
+
const overviewStart = page.content.indexOf("## Overview");
|
|
716
|
+
const coverageBlock = page.content.slice(coverageStart, overviewStart > 0 ? overviewStart : page.content.length);
|
|
717
|
+
// dynamic-call sorts before unresolved-callee alphabetically; both have
|
|
718
|
+
// count 2 so tiebreak is alphabetical asc. arity-mismatch (count 1) drops.
|
|
719
|
+
expect(coverageBlock).toContain("2 dynamic-call, 2 unresolved-callee");
|
|
720
|
+
expect(coverageBlock).not.toContain("arity-mismatch");
|
|
721
|
+
// All 5 CALLs failed at the site gate, so callSites=0, pairs=0,
|
|
722
|
+
// siteDropped=5 → Indexed = 5 call sites.
|
|
723
|
+
expect(coverageBlock).toMatch(/\| Call boundary \| 5 call site\(s\) \| 0 pair\(s\) \|/);
|
|
724
|
+
});
|
|
725
|
+
it("renders — in the Excluded column when a family has no diagnostics", () => {
|
|
726
|
+
// Clean copybook lineage, no parsed-zero-data-items diagnostics.
|
|
727
|
+
const lineage = buildFieldLineage([
|
|
728
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
729
|
+
model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl"),
|
|
730
|
+
model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl"),
|
|
731
|
+
]);
|
|
732
|
+
const page = generateFieldLineagePage(lineage);
|
|
733
|
+
const coverageStart = page.content.indexOf("## Coverage");
|
|
734
|
+
const overviewStart = page.content.indexOf("## Overview");
|
|
735
|
+
const coverageBlock = page.content.slice(coverageStart, overviewStart);
|
|
736
|
+
expect(coverageBlock).toMatch(/\| Copybook \|[^|]+\|[^|]+\| — \|/);
|
|
737
|
+
});
|
|
738
|
+
it("reflects parsed-zero-data-items in the Copybook row's Excluded cell (#30 + #31)", () => {
|
|
739
|
+
const emptyCopybook = " *> placeholder\n";
|
|
740
|
+
const lineage = buildFieldLineage([
|
|
741
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
742
|
+
model(emptyCopybook, "EMPTY.cpy"),
|
|
743
|
+
model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl"),
|
|
744
|
+
model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl"),
|
|
745
|
+
]);
|
|
746
|
+
const page = generateFieldLineagePage(lineage);
|
|
747
|
+
const coverageStart = page.content.indexOf("## Coverage");
|
|
748
|
+
const overviewStart = page.content.indexOf("## Overview");
|
|
749
|
+
const coverageBlock = page.content.slice(coverageStart, overviewStart);
|
|
750
|
+
expect(coverageBlock).toContain("1 parsed-zero-data-items");
|
|
751
|
+
// Indexed math: 1 participating copybook + 1 zero-data = 2 total.
|
|
752
|
+
expect(coverageBlock).toMatch(/\| Copybook \| 2 \| 1 deterministic, 0 inferred \|/);
|
|
753
|
+
});
|
|
754
|
+
});
|
|
755
|
+
describe("Semantic-Inferred tier (#35)", () => {
|
|
756
|
+
// Renamed scalar at depth 3 with matching parent path + 2 shared siblings.
|
|
757
|
+
// The depth is important: at depth ≤ 2, parentContextMatch collapses to
|
|
758
|
+
// "top-level" and gate 3 rejects the pair.
|
|
759
|
+
const customerNested = `
|
|
760
|
+
01 CUSTOMER-REC.
|
|
761
|
+
05 ADDRESS.
|
|
762
|
+
10 CUSTOMER-ID PIC X(10) USAGE DISPLAY.
|
|
763
|
+
10 STREET PIC X(30) USAGE DISPLAY.
|
|
764
|
+
10 ZIP PIC X(5) USAGE DISPLAY.
|
|
765
|
+
`;
|
|
766
|
+
const clientNested = `
|
|
767
|
+
01 CLIENT-REC.
|
|
768
|
+
05 ADDRESS.
|
|
769
|
+
10 CUST-ID PIC X(10) USAGE DISPLAY.
|
|
770
|
+
10 STREET PIC X(30) USAGE DISPLAY.
|
|
771
|
+
10 ZIP PIC X(5) USAGE DISPLAY.
|
|
772
|
+
`;
|
|
773
|
+
it("emits a semantic entry for a renamed scalar under matching parent + ≥2 siblings", () => {
|
|
774
|
+
const lineage = buildFieldLineage([
|
|
775
|
+
model(customerNested, "CUSTOMER-REC.cpy"),
|
|
776
|
+
model(clientNested, "CLIENT-REC.cpy"),
|
|
777
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
778
|
+
model(program("PROGB", "CLIENT-REC"), "PROGB.cbl"),
|
|
779
|
+
]);
|
|
780
|
+
expect(lineage).not.toBeNull();
|
|
781
|
+
expect(lineage.inferredSemantic).toHaveLength(1);
|
|
782
|
+
const entry = lineage.inferredSemantic[0];
|
|
783
|
+
expect(entry.confidence).toBe("semantic");
|
|
784
|
+
const leftLeaf = entry.left.qualifiedName.split(".").pop();
|
|
785
|
+
const rightLeaf = entry.right.qualifiedName.split(".").pop();
|
|
786
|
+
expect([leftLeaf, rightLeaf].sort()).toEqual(["CUST-ID", "CUSTOMER-ID"]);
|
|
787
|
+
expect(entry.evidence.qualifiedNameMatch).toBe("renamed");
|
|
788
|
+
expect(entry.evidence.parentContextMatch).toBe("exact");
|
|
789
|
+
expect(entry.evidence.siblingOverlap.length).toBeGreaterThanOrEqual(2);
|
|
790
|
+
expect(entry.rationale).toContain("Renamed field");
|
|
791
|
+
expect(lineage.summary.inferred.semantic).toBe(1);
|
|
792
|
+
});
|
|
793
|
+
it("Gate 4: drops the pair when shared siblings < 2", () => {
|
|
794
|
+
const customerThin = `
|
|
795
|
+
01 CUSTOMER-REC.
|
|
796
|
+
05 ADDRESS.
|
|
797
|
+
10 CUSTOMER-ID PIC X(10) USAGE DISPLAY.
|
|
798
|
+
10 STREET PIC X(30) USAGE DISPLAY.
|
|
799
|
+
`;
|
|
800
|
+
const clientThin = `
|
|
801
|
+
01 CLIENT-REC.
|
|
802
|
+
05 ADDRESS.
|
|
803
|
+
10 CUST-ID PIC X(10) USAGE DISPLAY.
|
|
804
|
+
10 STREET PIC X(30) USAGE DISPLAY.
|
|
805
|
+
`;
|
|
806
|
+
const lineage = buildFieldLineage([
|
|
807
|
+
model(customerThin, "CUSTOMER-REC.cpy"),
|
|
808
|
+
model(clientThin, "CLIENT-REC.cpy"),
|
|
809
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
810
|
+
model(program("PROGB", "CLIENT-REC"), "PROGB.cbl"),
|
|
811
|
+
]);
|
|
812
|
+
// STREET name-matches and emits as high-confidence inferred, so the
|
|
813
|
+
// lineage is non-null; the *semantic* tier specifically must be empty.
|
|
814
|
+
expect(lineage).not.toBeNull();
|
|
815
|
+
expect(lineage.inferredSemantic).toHaveLength(0);
|
|
816
|
+
expect(lineage.summary.inferred.semantic).toBe(0);
|
|
817
|
+
});
|
|
818
|
+
it("Gate 2: drops the pair when USAGE is missing on either side", () => {
|
|
819
|
+
const customerNoUsage = `
|
|
820
|
+
01 CUSTOMER-REC.
|
|
821
|
+
05 ADDRESS.
|
|
822
|
+
10 CUSTOMER-ID PIC X(10).
|
|
823
|
+
10 STREET PIC X(30).
|
|
824
|
+
10 ZIP PIC X(5).
|
|
825
|
+
`;
|
|
826
|
+
const clientNoUsage = `
|
|
827
|
+
01 CLIENT-REC.
|
|
828
|
+
05 ADDRESS.
|
|
829
|
+
10 CUST-ID PIC X(10).
|
|
830
|
+
10 STREET PIC X(30).
|
|
831
|
+
10 ZIP PIC X(5).
|
|
832
|
+
`;
|
|
833
|
+
const lineage = buildFieldLineage([
|
|
834
|
+
model(customerNoUsage, "CUSTOMER-REC.cpy"),
|
|
835
|
+
model(clientNoUsage, "CLIENT-REC.cpy"),
|
|
836
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
837
|
+
model(program("PROGB", "CLIENT-REC"), "PROGB.cbl"),
|
|
838
|
+
]);
|
|
839
|
+
expect(lineage).not.toBeNull();
|
|
840
|
+
expect(lineage.inferredSemantic).toHaveLength(0);
|
|
841
|
+
});
|
|
842
|
+
it("Gate 3: drops the pair when parent context collapses to top-level", () => {
|
|
843
|
+
// Depth 2 fields → parent suffix is empty on both sides → "top-level".
|
|
844
|
+
const customerTopLevel = `
|
|
845
|
+
01 CUSTOMER-REC.
|
|
846
|
+
05 CUSTOMER-ID PIC X(10) USAGE DISPLAY.
|
|
847
|
+
05 STREET PIC X(30) USAGE DISPLAY.
|
|
848
|
+
05 ZIP PIC X(5) USAGE DISPLAY.
|
|
849
|
+
`;
|
|
850
|
+
const clientTopLevel = `
|
|
851
|
+
01 CLIENT-REC.
|
|
852
|
+
05 CUST-ID PIC X(10) USAGE DISPLAY.
|
|
853
|
+
05 STREET PIC X(30) USAGE DISPLAY.
|
|
854
|
+
05 ZIP PIC X(5) USAGE DISPLAY.
|
|
855
|
+
`;
|
|
856
|
+
const lineage = buildFieldLineage([
|
|
857
|
+
model(customerTopLevel, "CUSTOMER-REC.cpy"),
|
|
858
|
+
model(clientTopLevel, "CLIENT-REC.cpy"),
|
|
859
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
860
|
+
model(program("PROGB", "CLIENT-REC"), "PROGB.cbl"),
|
|
861
|
+
]);
|
|
862
|
+
expect(lineage).not.toBeNull();
|
|
863
|
+
expect(lineage.inferredSemantic).toHaveLength(0);
|
|
864
|
+
});
|
|
865
|
+
it("Gate 5: drops the pair when a competing semantic match exists", () => {
|
|
866
|
+
// Three rec types with three differently-named ID fields. Each ID has
|
|
867
|
+
// two semantic candidates → every pair has competingMatches > 0 → all
|
|
868
|
+
// drop. The semantic tier never emits an ambiguous companion.
|
|
869
|
+
const partyRec = `
|
|
870
|
+
01 PARTY-REC.
|
|
871
|
+
05 ADDRESS.
|
|
872
|
+
10 CLIENT-ID PIC X(10) USAGE DISPLAY.
|
|
873
|
+
10 STREET PIC X(30) USAGE DISPLAY.
|
|
874
|
+
10 ZIP PIC X(5) USAGE DISPLAY.
|
|
875
|
+
`;
|
|
876
|
+
const lineage = buildFieldLineage([
|
|
877
|
+
model(customerNested, "CUSTOMER-REC.cpy"),
|
|
878
|
+
model(clientNested, "CLIENT-REC.cpy"),
|
|
879
|
+
model(partyRec, "PARTY-REC.cpy"),
|
|
880
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
881
|
+
model(program("PROGB", "CLIENT-REC"), "PROGB.cbl"),
|
|
882
|
+
model(program("PROGC", "PARTY-REC"), "PROGC.cbl"),
|
|
883
|
+
]);
|
|
884
|
+
expect(lineage).not.toBeNull();
|
|
885
|
+
expect(lineage.inferredSemantic).toHaveLength(0);
|
|
886
|
+
});
|
|
887
|
+
it("regression lock: rename-free corpus produces byte-identical name-keyed output", () => {
|
|
888
|
+
// Snapshot inferredHighConfidence / inferredAmbiguous / summary.inferred
|
|
889
|
+
// for a fixture that doesn't carry any rename pair. The new tier must
|
|
890
|
+
// be purely additive — these arrays should not shift.
|
|
891
|
+
const lineage = buildFieldLineage([
|
|
892
|
+
model(customerA, "CUSTOMER-A.cpy"),
|
|
893
|
+
model(customerB, "CUSTOMER-B.cpy"),
|
|
894
|
+
model(program("BILLINGA", "CUSTOMER-A"), "BILLINGA.cbl"),
|
|
895
|
+
model(program("BILLINGB", "CUSTOMER-B"), "BILLINGB.cbl"),
|
|
896
|
+
]);
|
|
897
|
+
expect(lineage).not.toBeNull();
|
|
898
|
+
expect(lineage.inferredSemantic).toEqual([]);
|
|
899
|
+
expect(lineage.summary.inferred.semantic).toBe(0);
|
|
900
|
+
// Spot-check name-matched output hasn't shifted: CUSTOMER-ID is the
|
|
901
|
+
// canonical inferred-high case for this fixture and must still emit.
|
|
902
|
+
expect(lineage.inferredHighConfidence.some((e) => e.fieldName === "CUSTOMER-ID")).toBe(true);
|
|
903
|
+
});
|
|
904
|
+
it("renderer: shows the ### Semantic-Inferred subsection only when entries exist", () => {
|
|
905
|
+
const empty = buildFieldLineage([
|
|
906
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
907
|
+
model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl"),
|
|
908
|
+
model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl"),
|
|
909
|
+
]);
|
|
910
|
+
expect(generateFieldLineagePage(empty).content).not.toContain("### Semantic-Inferred");
|
|
911
|
+
const withRename = buildFieldLineage([
|
|
912
|
+
model(customerNested, "CUSTOMER-REC.cpy"),
|
|
913
|
+
model(clientNested, "CLIENT-REC.cpy"),
|
|
914
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
915
|
+
model(program("PROGB", "CLIENT-REC"), "PROGB.cbl"),
|
|
916
|
+
]);
|
|
917
|
+
const page = generateFieldLineagePage(withRename);
|
|
918
|
+
expect(page.content).toContain("### Semantic-Inferred");
|
|
919
|
+
expect(page.content).toContain("CUSTOMER-ID");
|
|
920
|
+
expect(page.content).toContain("CUST-ID");
|
|
921
|
+
});
|
|
922
|
+
it("renderer: Coverage Yielding cell adds the semantic suffix only when count > 0", () => {
|
|
923
|
+
const empty = buildFieldLineage([
|
|
924
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
925
|
+
model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl"),
|
|
926
|
+
model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl"),
|
|
927
|
+
]);
|
|
928
|
+
const emptyPage = generateFieldLineagePage(empty);
|
|
929
|
+
const emptyCoverage = emptyPage.content.slice(emptyPage.content.indexOf("## Coverage"), emptyPage.content.indexOf("## Overview"));
|
|
930
|
+
expect(emptyCoverage).not.toContain("semantic");
|
|
931
|
+
const withRename = buildFieldLineage([
|
|
932
|
+
model(customerNested, "CUSTOMER-REC.cpy"),
|
|
933
|
+
model(clientNested, "CLIENT-REC.cpy"),
|
|
934
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
935
|
+
model(program("PROGB", "CLIENT-REC"), "PROGB.cbl"),
|
|
936
|
+
]);
|
|
937
|
+
const renamePage = generateFieldLineagePage(withRename);
|
|
938
|
+
const renameCoverage = renamePage.content.slice(renamePage.content.indexOf("## Coverage"), renamePage.content.indexOf("## Overview"));
|
|
939
|
+
expect(renameCoverage).toMatch(/\d+ deterministic, \d+ inferred, 1 semantic/);
|
|
940
|
+
});
|
|
941
|
+
it("normalizeLoadedFieldLineage backfills inferredSemantic + summary.inferred.semantic for pre-#35 JSON", () => {
|
|
942
|
+
const pre35 = {
|
|
943
|
+
summary: {
|
|
944
|
+
deterministic: { copybooks: 1, programs: 2, fields: 3 },
|
|
945
|
+
inferred: { copybooks: 0, programs: 0, highConfidence: 0, ambiguous: 0 },
|
|
946
|
+
diagnosticsByKind: { "parsed-zero-data-items": 0 },
|
|
947
|
+
},
|
|
948
|
+
copybookUsage: [],
|
|
949
|
+
deterministic: [],
|
|
950
|
+
inferredHighConfidence: [],
|
|
951
|
+
inferredAmbiguous: [],
|
|
952
|
+
diagnostics: [],
|
|
953
|
+
};
|
|
954
|
+
const normalized = normalizeLoadedFieldLineage(pre35);
|
|
955
|
+
expect(normalized.inferredSemantic).toEqual([]);
|
|
956
|
+
expect(normalized.summary.inferred.semantic).toBe(0);
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
describe("deterministic-via-replacing cohorts (#39 Phase B)", () => {
|
|
960
|
+
function withReplacing(programId, copybook, pairsClause) {
|
|
961
|
+
// pairsClause is the literal text following REPLACING, e.g.
|
|
962
|
+
// "CUSTOMER-ID BY CLIENT-ID" or "==CUSTOMER-ID== BY ==CLIENT-ID==".
|
|
963
|
+
return `
|
|
964
|
+
IDENTIFICATION DIVISION.
|
|
965
|
+
PROGRAM-ID. ${programId}.
|
|
966
|
+
DATA DIVISION.
|
|
967
|
+
WORKING-STORAGE SECTION.
|
|
968
|
+
COPY ${copybook} REPLACING ${pairsClause}.
|
|
969
|
+
PROCEDURE DIVISION.
|
|
970
|
+
A000-MAIN SECTION.
|
|
971
|
+
A100-START.
|
|
972
|
+
STOP RUN.
|
|
973
|
+
`;
|
|
974
|
+
}
|
|
975
|
+
it("emits one deterministic-via-replacing entry per renamed field when ≥2 consumers share the same REPLACING", () => {
|
|
976
|
+
const lineage = buildFieldLineage([
|
|
977
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
978
|
+
model(withReplacing("PROGA", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGA.cbl"),
|
|
979
|
+
model(withReplacing("PROGB", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGB.cbl"),
|
|
980
|
+
]);
|
|
981
|
+
expect(lineage).not.toBeNull();
|
|
982
|
+
const clientId = lineage.deterministic.find((e) => e.fieldName === "CLIENT-ID");
|
|
983
|
+
expect(clientId).toBeDefined();
|
|
984
|
+
expect(clientId.linkage).toBe("deterministic-via-replacing");
|
|
985
|
+
expect(clientId.replacing).toEqual({ fromName: "CUSTOMER-ID", toName: "CLIENT-ID" });
|
|
986
|
+
expect(clientId.programs.map((p) => p.id)).toEqual(["program:PROGA", "program:PROGB"]);
|
|
987
|
+
// The pre-substitution name doesn't show as a separate deterministic
|
|
988
|
+
// entry — both programs see the renamed name.
|
|
989
|
+
expect(lineage.deterministic.find((e) => e.fieldName === "CUSTOMER-ID")).toBeUndefined();
|
|
990
|
+
expect(lineage.summary.deterministic.viaReplacing).toBeGreaterThan(0);
|
|
991
|
+
});
|
|
992
|
+
it("untouched fields in a REPLACING cohort still emit with deterministic-via-replacing linkage, no replacing field", () => {
|
|
993
|
+
const lineage = buildFieldLineage([
|
|
994
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
995
|
+
model(withReplacing("PROGA", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGA.cbl"),
|
|
996
|
+
model(withReplacing("PROGB", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGB.cbl"),
|
|
997
|
+
]);
|
|
998
|
+
// ZIP-CODE is in the copybook but not renamed by the REPLACING.
|
|
999
|
+
const zip = lineage.deterministic.find((e) => e.fieldName === "ZIP-CODE");
|
|
1000
|
+
expect(zip).toBeDefined();
|
|
1001
|
+
expect(zip.linkage).toBe("deterministic-via-replacing"); // cohort label
|
|
1002
|
+
expect(zip.replacing).toBeUndefined();
|
|
1003
|
+
expect(zip.programs.map((p) => p.id)).toEqual(["program:PROGA", "program:PROGB"]);
|
|
1004
|
+
});
|
|
1005
|
+
it("two programs with DIFFERENT REPLACING clauses each form singleton cohorts — no deterministic", () => {
|
|
1006
|
+
const lineage = buildFieldLineage([
|
|
1007
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1008
|
+
model(withReplacing("PROGA", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGA.cbl"),
|
|
1009
|
+
model(withReplacing("PROGB", "CUSTOMER-REC", "CUSTOMER-ID BY ORDER-ID"), "PROGB.cbl"),
|
|
1010
|
+
]);
|
|
1011
|
+
// No cohort has ≥2 consumers → null (no deterministic + no inferred + no
|
|
1012
|
+
// semantic + no diagnostics).
|
|
1013
|
+
expect(lineage).toBeNull();
|
|
1014
|
+
});
|
|
1015
|
+
it("mixed cohorts: empty + REPLACING each ≥2 → two distinct deterministic entries", () => {
|
|
1016
|
+
const lineage = buildFieldLineage([
|
|
1017
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1018
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
1019
|
+
model(program("PROGB", "CUSTOMER-REC"), "PROGB.cbl"),
|
|
1020
|
+
model(withReplacing("PROGC", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGC.cbl"),
|
|
1021
|
+
model(withReplacing("PROGD", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGD.cbl"),
|
|
1022
|
+
]);
|
|
1023
|
+
expect(lineage).not.toBeNull();
|
|
1024
|
+
// Empty cohort emits CUSTOMER-ID (deterministic, programs A+B).
|
|
1025
|
+
const custId = lineage.deterministic.find((e) => e.fieldName === "CUSTOMER-ID" && e.linkage === "deterministic");
|
|
1026
|
+
expect(custId).toBeDefined();
|
|
1027
|
+
expect(custId.programs.map((p) => p.id).sort()).toEqual(["program:PROGA", "program:PROGB"]);
|
|
1028
|
+
expect(custId.replacing).toBeUndefined();
|
|
1029
|
+
// REPLACING cohort emits CLIENT-ID (deterministic-via-replacing, programs C+D).
|
|
1030
|
+
const clientId = lineage.deterministic.find((e) => e.fieldName === "CLIENT-ID" && e.linkage === "deterministic-via-replacing");
|
|
1031
|
+
expect(clientId).toBeDefined();
|
|
1032
|
+
expect(clientId.programs.map((p) => p.id).sort()).toEqual(["program:PROGC", "program:PROGD"]);
|
|
1033
|
+
expect(clientId.replacing).toEqual({ fromName: "CUSTOMER-ID", toName: "CLIENT-ID" });
|
|
1034
|
+
});
|
|
1035
|
+
it("regression lock: existing REPLACING-singleton fixture still yields null", () => {
|
|
1036
|
+
// Same fixture the pre-#39 test `does not treat COPY REPLACING
|
|
1037
|
+
// consumers as deterministic shared lineage` uses: one empty-cohort
|
|
1038
|
+
// consumer + one REPLACING-cohort consumer (each a singleton).
|
|
1039
|
+
const orderA = model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl");
|
|
1040
|
+
const orderB = model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl");
|
|
1041
|
+
orderB.copies[0].replacing = ["CUSTOMER-ID", "BY", "CLIENT-ID"];
|
|
1042
|
+
const lineage = buildFieldLineage([
|
|
1043
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1044
|
+
orderA,
|
|
1045
|
+
orderB,
|
|
1046
|
+
]);
|
|
1047
|
+
expect(lineage).toBeNull();
|
|
1048
|
+
});
|
|
1049
|
+
it("REPLACING substitution propagates through qualified-path segments", () => {
|
|
1050
|
+
// CUSTOMER-ADDRESS.ZIP-CODE — REPLACING renames CUSTOMER-ADDRESS to
|
|
1051
|
+
// CLIENT-ADDRESS. Both the parent segment in the qualified path and
|
|
1052
|
+
// the leaf-field's parentQualifiedName follow.
|
|
1053
|
+
const lineage = buildFieldLineage([
|
|
1054
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1055
|
+
model(withReplacing("PROGA", "CUSTOMER-REC", "CUSTOMER-ADDRESS BY CLIENT-ADDRESS"), "PROGA.cbl"),
|
|
1056
|
+
model(withReplacing("PROGB", "CUSTOMER-REC", "CUSTOMER-ADDRESS BY CLIENT-ADDRESS"), "PROGB.cbl"),
|
|
1057
|
+
]);
|
|
1058
|
+
const zip = lineage.deterministic.find((e) => e.fieldName === "ZIP-CODE");
|
|
1059
|
+
expect(zip).toBeDefined();
|
|
1060
|
+
// The path under the renamed parent is post-substitution.
|
|
1061
|
+
expect(zip.qualifiedNames.some((n) => n.includes("CLIENT-ADDRESS.ZIP-CODE"))).toBe(true);
|
|
1062
|
+
expect(zip.parentQualifiedNames.some((n) => n.endsWith("CLIENT-ADDRESS"))).toBe(true);
|
|
1063
|
+
});
|
|
1064
|
+
it("renderer: Coverage cell adds `(N via REPLACING)` suffix only when viaReplacing > 0", () => {
|
|
1065
|
+
const empty = buildFieldLineage([
|
|
1066
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1067
|
+
model(program("PROGA", "CUSTOMER-REC"), "PROGA.cbl"),
|
|
1068
|
+
model(program("PROGB", "CUSTOMER-REC"), "PROGB.cbl"),
|
|
1069
|
+
]);
|
|
1070
|
+
const emptyPage = generateFieldLineagePage(empty);
|
|
1071
|
+
const emptyCoverage = emptyPage.content.slice(emptyPage.content.indexOf("## Coverage"), emptyPage.content.indexOf("## Overview"));
|
|
1072
|
+
expect(emptyCoverage).not.toContain("via REPLACING");
|
|
1073
|
+
const withRepl = buildFieldLineage([
|
|
1074
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1075
|
+
model(withReplacing("PROGC", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGC.cbl"),
|
|
1076
|
+
model(withReplacing("PROGD", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGD.cbl"),
|
|
1077
|
+
]);
|
|
1078
|
+
const replPage = generateFieldLineagePage(withRepl);
|
|
1079
|
+
const replCoverage = replPage.content.slice(replPage.content.indexOf("## Coverage"), replPage.content.indexOf("## Overview"));
|
|
1080
|
+
expect(replCoverage).toMatch(/\d+ deterministic \(\d+ via REPLACING\)/);
|
|
1081
|
+
});
|
|
1082
|
+
it("renderer: Shared-fields Field cell shows `Y (was X)` for renamed entries", () => {
|
|
1083
|
+
const lineage = buildFieldLineage([
|
|
1084
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1085
|
+
model(withReplacing("PROGA", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGA.cbl"),
|
|
1086
|
+
model(withReplacing("PROGB", "CUSTOMER-REC", "CUSTOMER-ID BY CLIENT-ID"), "PROGB.cbl"),
|
|
1087
|
+
]);
|
|
1088
|
+
const page = generateFieldLineagePage(lineage);
|
|
1089
|
+
expect(page.content).toContain("CLIENT-ID (was CUSTOMER-ID)");
|
|
1090
|
+
expect(page.content).toContain("deterministic-via-replacing");
|
|
1091
|
+
});
|
|
1092
|
+
it("fragment-substitution cohorts (unparseable REPLACING) skip deterministic emission", () => {
|
|
1093
|
+
// Two consumers with the same fragment-style REPLACING that
|
|
1094
|
+
// parseReplacingPairs can't structure (e.g., `:T BY WS` — colon
|
|
1095
|
+
// prefix isn't a valid COBOL identifier start). They land in the
|
|
1096
|
+
// same cohort by raw-tuple identity, but we can't apply the
|
|
1097
|
+
// substitution, so we don't know what fields are actually renamed.
|
|
1098
|
+
// Pre-#39 behavior was "exclude from deterministic"; Phase B
|
|
1099
|
+
// preserves it by skipping the cohort.
|
|
1100
|
+
const orderA = model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl");
|
|
1101
|
+
const orderB = model(program("ORDERB", "CUSTOMER-REC"), "ORDERB.cbl");
|
|
1102
|
+
// Hand-construct the fragment shape — `parseReplacingPairs` rejects
|
|
1103
|
+
// tokens that fail [A-Z][A-Z0-9-]*, so the cohort has empty pairs
|
|
1104
|
+
// despite the raw-tuple being non-empty.
|
|
1105
|
+
orderA.copies[0].replacing = [":T", "BY", "WS"];
|
|
1106
|
+
orderB.copies[0].replacing = [":T", "BY", "WS"];
|
|
1107
|
+
const lineage = buildFieldLineage([
|
|
1108
|
+
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|
|
1109
|
+
orderA,
|
|
1110
|
+
orderB,
|
|
1111
|
+
]);
|
|
1112
|
+
// No deterministic emission from the fragment cohort. Singletons in
|
|
1113
|
+
// every other cohort either — lineage is null.
|
|
1114
|
+
expect(lineage).toBeNull();
|
|
1115
|
+
});
|
|
1116
|
+
it("normalizeLoadedFieldLineage backfills summary.deterministic.viaReplacing for pre-#39 JSON", () => {
|
|
1117
|
+
const pre39 = {
|
|
1118
|
+
summary: {
|
|
1119
|
+
deterministic: { copybooks: 1, programs: 2, fields: 3 },
|
|
1120
|
+
inferred: { copybooks: 0, programs: 0, highConfidence: 0, ambiguous: 0, semantic: 0 },
|
|
1121
|
+
diagnosticsByKind: { "parsed-zero-data-items": 0 },
|
|
1122
|
+
},
|
|
1123
|
+
copybookUsage: [],
|
|
1124
|
+
deterministic: [],
|
|
1125
|
+
inferredHighConfidence: [],
|
|
1126
|
+
inferredAmbiguous: [],
|
|
1127
|
+
inferredSemantic: [],
|
|
1128
|
+
diagnostics: [],
|
|
1129
|
+
};
|
|
1130
|
+
const normalized = normalizeLoadedFieldLineage(pre39);
|
|
1131
|
+
expect(normalized.summary.deterministic.viaReplacing).toBe(0);
|
|
1132
|
+
});
|
|
1133
|
+
});
|
|
575
1134
|
it("generates a lineage wiki summary page", () => {
|
|
576
1135
|
const lineage = buildFieldLineage([
|
|
577
1136
|
model(sharedCopybook, "CUSTOMER-REC.cpy"),
|