@specferret/core 0.1.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.
Files changed (57) hide show
  1. package/dist/config.d.ts +20 -0
  2. package/dist/config.d.ts.map +1 -0
  3. package/dist/config.js +32 -0
  4. package/dist/config.js.map +1 -0
  5. package/dist/context/index.d.ts +27 -0
  6. package/dist/context/index.d.ts.map +1 -0
  7. package/dist/context/index.js +72 -0
  8. package/dist/context/index.js.map +1 -0
  9. package/dist/extractor/frontmatter.d.ts +25 -0
  10. package/dist/extractor/frontmatter.d.ts.map +1 -0
  11. package/dist/extractor/frontmatter.js +49 -0
  12. package/dist/extractor/frontmatter.js.map +1 -0
  13. package/dist/extractor/hash.d.ts +7 -0
  14. package/dist/extractor/hash.d.ts.map +1 -0
  15. package/dist/extractor/hash.js +25 -0
  16. package/dist/extractor/hash.js.map +1 -0
  17. package/dist/extractor/typescript.d.ts +14 -0
  18. package/dist/extractor/typescript.d.ts.map +1 -0
  19. package/dist/extractor/typescript.js +232 -0
  20. package/dist/extractor/typescript.js.map +1 -0
  21. package/dist/extractor/validator.d.ts +24 -0
  22. package/dist/extractor/validator.d.ts.map +1 -0
  23. package/dist/extractor/validator.js +141 -0
  24. package/dist/extractor/validator.js.map +1 -0
  25. package/dist/index.d.ts +13 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +15 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/reconciler/import-suggestions.d.ts +10 -0
  30. package/dist/reconciler/import-suggestions.d.ts.map +1 -0
  31. package/dist/reconciler/import-suggestions.js +110 -0
  32. package/dist/reconciler/import-suggestions.js.map +1 -0
  33. package/dist/reconciler/index.d.ts +53 -0
  34. package/dist/reconciler/index.d.ts.map +1 -0
  35. package/dist/reconciler/index.js +214 -0
  36. package/dist/reconciler/index.js.map +1 -0
  37. package/dist/store/factory.d.ts +7 -0
  38. package/dist/store/factory.d.ts.map +1 -0
  39. package/dist/store/factory.js +52 -0
  40. package/dist/store/factory.js.map +1 -0
  41. package/dist/store/postgres.d.ts +25 -0
  42. package/dist/store/postgres.d.ts.map +1 -0
  43. package/dist/store/postgres.js +68 -0
  44. package/dist/store/postgres.js.map +1 -0
  45. package/dist/store/sqlite.d.ts +25 -0
  46. package/dist/store/sqlite.d.ts.map +1 -0
  47. package/dist/store/sqlite.js +180 -0
  48. package/dist/store/sqlite.js.map +1 -0
  49. package/dist/store/types.d.ts +79 -0
  50. package/dist/store/types.d.ts.map +1 -0
  51. package/dist/store/types.js +2 -0
  52. package/dist/store/types.js.map +1 -0
  53. package/dist/utils/paths.d.ts +6 -0
  54. package/dist/utils/paths.d.ts.map +1 -0
  55. package/dist/utils/paths.js +21 -0
  56. package/dist/utils/paths.js.map +1 -0
  57. package/package.json +44 -0
@@ -0,0 +1,141 @@
1
+ // Pure function. No I/O. No side effects. Ever.
2
+ // Validator layer — validates JSON Schema subset, classifies breaking/non-breaking/no-change.
3
+ /**
4
+ * JSON Schema keywords that are explicitly NOT supported by Ferret.
5
+ * If any appear in a schema, a warning is emitted but the schema is still accepted.
6
+ * See: spec/CONTRACT-SCHEMA.md — Part 3
7
+ */
8
+ const UNSUPPORTED_KEYWORDS = [
9
+ '$ref', 'allOf', 'anyOf', 'oneOf', 'not',
10
+ 'if', 'then', 'else', '$defs', 'definitions',
11
+ 'patternProperties', 'dependencies',
12
+ ];
13
+ /**
14
+ * Validates a schema object against the Ferret JSON Schema subset.
15
+ * Always returns valid: true — unsupported keywords produce warnings, not errors.
16
+ */
17
+ export function validateFerretSchema(shape, filePath) {
18
+ const warnings = [];
19
+ if (shape === null || typeof shape !== 'object') {
20
+ return { valid: true, warnings };
21
+ }
22
+ const serialised = JSON.stringify(shape);
23
+ for (const keyword of UNSUPPORTED_KEYWORDS) {
24
+ // Match the keyword as a JSON object key (surrounded by quotes)
25
+ if (serialised.includes(`"${keyword}"`)) {
26
+ warnings.push(`⚠ Unsupported JSON Schema keyword: ${keyword} in ${filePath}\n` +
27
+ ` Ferret supports a subset of JSON Schema.\n` +
28
+ ` See: spec/CONTRACT-SCHEMA.md — Part 3`);
29
+ }
30
+ }
31
+ return { valid: true, warnings };
32
+ }
33
+ /**
34
+ * Compares two schema objects and classifies the change.
35
+ *
36
+ * Breaking: required field removed, field type changed, enum value removed,
37
+ * response/array type changed, required field added
38
+ * Non-breaking: optional field added, enum value added
39
+ * No-change: property order changed, whitespace, required array reordered
40
+ */
41
+ export function compareSchemas(previous, current) {
42
+ // Normalise: work with plain objects only
43
+ const prev = (typeof previous === 'object' && previous !== null ? previous : {});
44
+ const curr = (typeof current === 'object' && current !== null ? current : {});
45
+ // 1. Check type change at this level
46
+ if (prev.type !== undefined && curr.type !== undefined && prev.type !== curr.type) {
47
+ return { classification: 'breaking', reason: `type changed from '${prev.type}' to '${curr.type}'` };
48
+ }
49
+ // 2. Check required fields
50
+ const prevRequired = normaliseRequired(prev.required);
51
+ const currRequired = normaliseRequired(curr.required);
52
+ const removedRequired = prevRequired.filter(f => !currRequired.includes(f));
53
+ if (removedRequired.length > 0) {
54
+ return { classification: 'breaking', reason: `required field(s) removed: ${removedRequired.join(', ')}` };
55
+ }
56
+ const addedRequired = currRequired.filter(f => !prevRequired.includes(f));
57
+ if (addedRequired.length > 0) {
58
+ return { classification: 'breaking', reason: `required field(s) added: ${addedRequired.join(', ')}` };
59
+ }
60
+ // 3. Check enum changes
61
+ const prevEnum = normaliseEnum(prev.enum);
62
+ const currEnum = normaliseEnum(curr.enum);
63
+ if (prevEnum !== null && currEnum !== null) {
64
+ const removedEnum = prevEnum.filter(v => !currEnum.includes(v));
65
+ if (removedEnum.length > 0) {
66
+ return { classification: 'breaking', reason: `enum value(s) removed: ${removedEnum.join(', ')}` };
67
+ }
68
+ const addedEnum = currEnum.filter(v => !prevEnum.includes(v));
69
+ if (addedEnum.length > 0) {
70
+ return { classification: 'non-breaking', reason: `enum value(s) added: ${addedEnum.join(', ')}` };
71
+ }
72
+ }
73
+ // 4. Check properties — look for type changes in existing properties, or optional additions
74
+ const prevProps = (prev.properties ?? {});
75
+ const currProps = (curr.properties ?? {});
76
+ for (const key of Object.keys(currProps)) {
77
+ if (!(key in prevProps)) {
78
+ // New property — only breaking if it's also in required (already caught above)
79
+ if (currRequired.includes(key)) {
80
+ return { classification: 'breaking', reason: `required field added: ${key}` };
81
+ }
82
+ // Not required — non-breaking addition
83
+ continue;
84
+ }
85
+ // Property exists in both — check for type change recursively
86
+ const nested = compareSchemas(prevProps[key], currProps[key]);
87
+ if (nested.classification === 'breaking') {
88
+ return { classification: 'breaking', reason: `property '${key}': ${nested.reason}` };
89
+ }
90
+ if (nested.classification === 'non-breaking') {
91
+ return { classification: 'non-breaking', reason: `property '${key}': ${nested.reason}` };
92
+ }
93
+ }
94
+ // 5. Check for property removals (any removal is breaking — even "optional" fields
95
+ // that consumers may depend on)
96
+ for (const key of Object.keys(prevProps)) {
97
+ if (!(key in currProps)) {
98
+ return { classification: 'breaking', reason: `property '${key}' removed` };
99
+ }
100
+ }
101
+ // 6. Check request/response top-level wrappers (Ferret API extension)
102
+ for (const wrapper of ['request', 'response']) {
103
+ if (prev[wrapper] !== undefined || curr[wrapper] !== undefined) {
104
+ const nested = compareSchemas(prev[wrapper] ?? {}, curr[wrapper] ?? {});
105
+ if (nested.classification === 'breaking') {
106
+ return { classification: 'breaking', reason: `${wrapper}: ${nested.reason}` };
107
+ }
108
+ if (nested.classification === 'non-breaking') {
109
+ return { classification: 'non-breaking', reason: `${wrapper}: ${nested.reason}` };
110
+ }
111
+ }
112
+ }
113
+ // 7. Check array items type change
114
+ if (prev.items !== undefined && curr.items !== undefined) {
115
+ const nested = compareSchemas(prev.items, curr.items);
116
+ if (nested.classification === 'breaking') {
117
+ return { classification: 'breaking', reason: `array items: ${nested.reason}` };
118
+ }
119
+ if (nested.classification === 'non-breaking') {
120
+ return { classification: 'non-breaking', reason: `array items: ${nested.reason}` };
121
+ }
122
+ }
123
+ // 8. Check if a new optional property was added (non-breaking)
124
+ const newOptionalKeys = Object.keys(currProps).filter(k => !(k in prevProps) && !currRequired.includes(k));
125
+ if (newOptionalKeys.length > 0) {
126
+ return { classification: 'non-breaking', reason: `optional field(s) added: ${newOptionalKeys.join(', ')}` };
127
+ }
128
+ return { classification: 'no-change', reason: 'schemas are semantically identical' };
129
+ }
130
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
131
+ function normaliseRequired(required) {
132
+ if (!Array.isArray(required))
133
+ return [];
134
+ return required.filter((v) => typeof v === 'string');
135
+ }
136
+ function normaliseEnum(enumVal) {
137
+ if (!Array.isArray(enumVal))
138
+ return null;
139
+ return enumVal.map(v => String(v));
140
+ }
141
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/extractor/validator.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,8FAA8F;AAc9F;;;;GAIG;AACH,MAAM,oBAAoB,GAAG;IAC3B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK;IACxC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAC5C,mBAAmB,EAAE,cAAc;CACpC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,QAAgB;IAEhB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAEzC,KAAK,MAAM,OAAO,IAAI,oBAAoB,EAAE,CAAC;QAC3C,gEAAgE;QAChE,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YACxC,QAAQ,CAAC,IAAI,CACX,sC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AE,CAAC;QACrF,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3G,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,4BAA4B,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9G,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,oCAAoC,EAAE,CAAC;AACvF,CAAC;AAED,gFAAgF;AAEhF,SAAS,iBAAiB,CAAC,QAAiB;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,CAAC;IACxC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,aAAa,CAAC,OAAgB;IACrC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from "./extractor/frontmatter.js";
2
+ export * from "./extractor/typescript.js";
3
+ export * from "./extractor/validator.js";
4
+ export * from "./extractor/hash.js";
5
+ export * from "./context/index.js";
6
+ export * from "./store/types.js";
7
+ export * from "./store/sqlite.js";
8
+ export * from "./store/factory.js";
9
+ export * from "./reconciler/index.js";
10
+ export * from "./reconciler/import-suggestions.js";
11
+ export * from "./config.js";
12
+ export * from "./utils/paths.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ // @specferret/core public API
2
+ // Do not export llm-fallback — dynamic import only, never a default export.
3
+ export * from "./extractor/frontmatter.js";
4
+ export * from "./extractor/typescript.js";
5
+ export * from "./extractor/validator.js";
6
+ export * from "./extractor/hash.js";
7
+ export * from "./context/index.js";
8
+ export * from "./store/types.js";
9
+ export * from "./store/sqlite.js";
10
+ export * from "./store/factory.js";
11
+ export * from "./reconciler/index.js";
12
+ export * from "./reconciler/import-suggestions.js";
13
+ export * from "./config.js";
14
+ export * from "./utils/paths.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,4EAA4E;AAE5E,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FerretContract, FerretDependency, FerretNode } from "../store/types.js";
2
+ export interface ImportSuggestion {
3
+ sourceContractId: string;
4
+ sourceFilePath: string;
5
+ suggestedImportId: string;
6
+ confidence: "medium" | "high";
7
+ evidence: string;
8
+ }
9
+ export declare function suggestMissingImports(nodes: FerretNode[], contracts: FerretContract[], dependencies: FerretDependency[]): ImportSuggestion[];
10
+ //# sourceMappingURL=import-suggestions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-suggestions.d.ts","sourceRoot":"","sources":["../../src/reconciler/import-suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,UAAU,EAAE,EACnB,SAAS,EAAE,cAAc,EAAE,EAC3B,YAAY,EAAE,gBAAgB,EAAE,GAC/B,gBAAgB,EAAE,CAgGpB"}
@@ -0,0 +1,110 @@
1
+ export function suggestMissingImports(nodes, contracts, dependencies) {
2
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
3
+ const nodeImportMap = new Map();
4
+ for (const dependency of dependencies) {
5
+ const imports = nodeImportMap.get(dependency.source_node_id) ?? new Set();
6
+ imports.add(dependency.target_contract_id);
7
+ nodeImportMap.set(dependency.source_node_id, imports);
8
+ }
9
+ const schemaKeysByContract = new Map();
10
+ for (const contract of contracts) {
11
+ schemaKeysByContract.set(contract.id, extractSchemaKeys(parseSchema(contract.shape_schema)));
12
+ }
13
+ const suggestions = [];
14
+ const seen = new Set();
15
+ for (const source of contracts) {
16
+ const sourceKeys = schemaKeysByContract.get(source.id) ?? new Set();
17
+ if (sourceKeys.size === 0) {
18
+ continue;
19
+ }
20
+ const importedTargets = nodeImportMap.get(source.node_id) ?? new Set();
21
+ const sourceNode = nodeById.get(source.node_id);
22
+ if (!sourceNode) {
23
+ continue;
24
+ }
25
+ const rankedCandidates = contracts
26
+ .filter((target) => target.id !== source.id && !importedTargets.has(target.id))
27
+ .map((target) => {
28
+ const targetKeys = schemaKeysByContract.get(target.id) ?? new Set();
29
+ const sharedKeys = intersectSets(sourceKeys, targetKeys);
30
+ const overlap = sourceKeys.size === 0 ? 0 : sharedKeys.length / sourceKeys.size;
31
+ return {
32
+ target,
33
+ targetKeys,
34
+ sharedKeys,
35
+ overlap,
36
+ };
37
+ })
38
+ .filter((candidate) => candidate.sharedKeys.length >= 2 &&
39
+ candidate.overlap >= 0.67 &&
40
+ candidate.targetKeys.size >= sourceKeys.size)
41
+ .sort((left, right) => {
42
+ if (right.sharedKeys.length !== left.sharedKeys.length) {
43
+ return right.sharedKeys.length - left.sharedKeys.length;
44
+ }
45
+ if (right.overlap !== left.overlap) {
46
+ return right.overlap - left.overlap;
47
+ }
48
+ return left.target.id.localeCompare(right.target.id);
49
+ })
50
+ .slice(0, 3);
51
+ for (const candidate of rankedCandidates) {
52
+ const confidence = candidate.sharedKeys.length >= 3 || candidate.overlap >= 0.75
53
+ ? "high"
54
+ : "medium";
55
+ const key = `${source.id}->${candidate.target.id}`;
56
+ if (seen.has(key)) {
57
+ continue;
58
+ }
59
+ seen.add(key);
60
+ suggestions.push({
61
+ sourceContractId: source.id,
62
+ sourceFilePath: sourceNode.file_path,
63
+ suggestedImportId: candidate.target.id,
64
+ confidence,
65
+ evidence: `shared shape keys: ${candidate.sharedKeys.slice(0, 3).join(", ")}`,
66
+ });
67
+ }
68
+ }
69
+ return suggestions.sort((left, right) => {
70
+ if (left.sourceContractId !== right.sourceContractId) {
71
+ return left.sourceContractId.localeCompare(right.sourceContractId);
72
+ }
73
+ return left.suggestedImportId.localeCompare(right.suggestedImportId);
74
+ });
75
+ }
76
+ function parseSchema(shapeSchema) {
77
+ try {
78
+ return JSON.parse(shapeSchema);
79
+ }
80
+ catch {
81
+ return {};
82
+ }
83
+ }
84
+ function extractSchemaKeys(schema) {
85
+ const keys = new Set();
86
+ const walk = (value) => {
87
+ if (!value || typeof value !== "object") {
88
+ return;
89
+ }
90
+ const record = value;
91
+ const properties = record.properties;
92
+ if (properties && typeof properties === "object") {
93
+ for (const [key, child] of Object.entries(properties)) {
94
+ keys.add(key);
95
+ walk(child);
96
+ }
97
+ }
98
+ const items = record.items;
99
+ if (items) {
100
+ walk(items);
101
+ }
102
+ };
103
+ walk(schema);
104
+ return keys;
105
+ }
106
+ function intersectSets(left, right) {
107
+ const shared = [...left].filter((item) => right.has(item));
108
+ return shared.sort((a, b) => a.localeCompare(b));
109
+ }
110
+ //# sourceMappingURL=import-suggestions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-suggestions.js","sourceRoot":"","sources":["../../src/reconciler/import-suggestions.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,qBAAqB,CACnC,KAAmB,EACnB,SAA2B,EAC3B,YAAgC;IAEhC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;IAErD,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;QACtC,MAAM,OAAO,GACX,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,IAAI,GAAG,EAAU,CAAC;QACpE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAC3C,aAAa,CAAC,GAAG,CAAC,UAA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K,QAAQ,EAAE,CAAC;YACxC,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,KAAgC,CAAC;QAChD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;YACjD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CACvC,UAAqC,CACtC,EAAE,CAAC;gBACF,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACd,IAAI,CAAC,KAAK,CAAC,CAAC;YACd,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,IAAiB,EAAE,KAAkB;IAC1D,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { DBStore } from "../store/types.js";
2
+ import { ImportSuggestion } from "./import-suggestions.js";
3
+ export interface UnresolvedImportViolation {
4
+ contractId: string;
5
+ filePath: string;
6
+ importPath: string;
7
+ }
8
+ export interface SelfImportViolation {
9
+ contractId: string;
10
+ filePath: string;
11
+ importPath: string;
12
+ }
13
+ export interface CircularImportViolation {
14
+ contractId: string;
15
+ filePath: string;
16
+ importPath: string;
17
+ cycle: string[];
18
+ }
19
+ export interface ImportIntegrityReport {
20
+ unresolvedImports: UnresolvedImportViolation[];
21
+ selfImports: SelfImportViolation[];
22
+ circularImports: CircularImportViolation[];
23
+ }
24
+ export interface ReconcileReport {
25
+ consistent: boolean;
26
+ flagged: Array<{
27
+ nodeId: string;
28
+ filePath: string;
29
+ triggeredByContractId: string;
30
+ impact: "direct" | "transitive";
31
+ depth: number;
32
+ }>;
33
+ integrityViolations: ImportIntegrityReport;
34
+ importSuggestions: ImportSuggestion[];
35
+ timestamp: string;
36
+ }
37
+ /**
38
+ * The Reconciler engine (Phase 3).
39
+ * It calculates the downstream impact of graph shape changes. Since resolving recursive graphs
40
+ * can be heavily database dependent, we execute an Application-level Breadth-First Search (BFS)
41
+ * to maintain 100% parity across SQLite and PostgreSQL effortlessly and stay extremely fast.
42
+ */
43
+ export declare class Reconciler {
44
+ private store;
45
+ constructor(store: DBStore);
46
+ /**
47
+ * Identifies completely unhandled ripples and propagates them up to 10 hops (S011)
48
+ */
49
+ reconcile(): Promise<ReconcileReport>;
50
+ private validateImportIntegrity;
51
+ private findCircularImports;
52
+ }
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reconciler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,yBAAyB,EAAE,CAAC;IAC/C,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,eAAe,EAAE,uBAAuB,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,MAAM,EAAE,QAAQ,GAAG,YAAY,CAAC;QAChC,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,mBAAmB,EAAE,qBAAqB,CAAC;IAC3C,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,OAAO;IAElC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAgH3C,OAAO,CAAC,uBAAuB;IAwF/B,OAAO,CAAC,mBAAmB;CAsD5B"}
@@ -0,0 +1,214 @@
1
+ import { suggestMissingImports, } from "./import-suggestions.js";
2
+ /**
3
+ * The Reconciler engine (Phase 3).
4
+ * It calculates the downstream impact of graph shape changes. Since resolving recursive graphs
5
+ * can be heavily database dependent, we execute an Application-level Breadth-First Search (BFS)
6
+ * to maintain 100% parity across SQLite and PostgreSQL effortlessly and stay extremely fast.
7
+ */
8
+ export class Reconciler {
9
+ store;
10
+ constructor(store) {
11
+ this.store = store;
12
+ }
13
+ /**
14
+ * Identifies completely unhandled ripples and propagates them up to 10 hops (S011)
15
+ */
16
+ async reconcile() {
17
+ const nodes = await this.store.getNodes();
18
+ const contracts = await this.store.getContracts();
19
+ const dependencies = await this.store.getDependencies();
20
+ const integrityViolations = this.validateImportIntegrity(nodes, contracts, dependencies);
21
+ const hasIntegrityViolations = integrityViolations.unresolvedImports.length > 0 ||
22
+ integrityViolations.selfImports.length > 0 ||
23
+ integrityViolations.circularImports.length > 0;
24
+ if (hasIntegrityViolations) {
25
+ return {
26
+ consistent: false,
27
+ flagged: [],
28
+ integrityViolations,
29
+ importSuggestions: [],
30
+ timestamp: new Date().toISOString(),
31
+ };
32
+ }
33
+ const importSuggestions = suggestMissingImports(nodes, contracts, dependencies);
34
+ const nodeMap = new Map(nodes.map((n) => [n.id, n]));
35
+ const contractMap = new Map(contracts.map((c) => [c.id, c]));
36
+ // 1. Identify "changed/trigger" contracts.
37
+ // In our simplified engine approach, any contract attached to a Node that is "needs-review"
38
+ // acts as a signal for propagation, OR any specifically updated shapes.
39
+ // For this prototype implementation, we'll traverse starting from specifically flagged nodes.
40
+ const triggerContracts = contracts.filter((c) => {
41
+ const parentNode = nodeMap.get(c.node_id);
42
+ return parentNode && parentNode.status === "needs-review";
43
+ });
44
+ const flaggedNodes = [];
45
+ // BFS Queue: [contractId, depth]
46
+ // S011 explicitly mandates capping transitive impact at 10 hops.
47
+ const queue = triggerContracts.map((c) => [
48
+ c.id,
49
+ 1,
50
+ ]);
51
+ const visitedContracts = new Set();
52
+ while (queue.length > 0) {
53
+ const [contractId, depth] = queue.shift();
54
+ if (visitedContracts.has(contractId) || depth > 10)
55
+ continue;
56
+ visitedContracts.add(contractId);
57
+ // Find nodes that import this contract
58
+ const dependentEdges = dependencies.filter((d) => d.target_contract_id === contractId);
59
+ for (const edge of dependentEdges) {
60
+ const dependentNodeId = edge.source_node_id;
61
+ const dependentNode = nodeMap.get(dependentNodeId);
62
+ if (!dependentNode)
63
+ continue;
64
+ // Skip nodes that are already reviewing or roadmap, per S011 instructions.
65
+ if (dependentNode.status === "needs-review" ||
66
+ dependentNode.status === "roadmap") {
67
+ continue;
68
+ }
69
+ // Flag the node natively
70
+ await this.store.updateNodeStatus(dependentNode.id, "needs-review");
71
+ dependentNode.status = "needs-review"; // Update internal ref mapping
72
+ flaggedNodes.push({
73
+ nodeId: dependentNode.id,
74
+ filePath: dependentNode.file_path,
75
+ triggeredByContractId: contractId,
76
+ impact: depth === 1 ? "direct" : "transitive",
77
+ depth,
78
+ });
79
+ // Enqueue cascading contracts exported by the now-flagged dependent node
80
+ const cascadingContracts = contracts.filter((c) => c.node_id === dependentNode.id);
81
+ for (const cContract of cascadingContracts) {
82
+ queue.push([cContract.id, depth + 1]);
83
+ }
84
+ }
85
+ }
86
+ // S012: graph is consistent when no nodes need review and all nodes are stable or roadmap.
87
+ // Roadmap nodes are planned-but-not-yet-built and are an acceptable stable state.
88
+ return {
89
+ consistent: flaggedNodes.length === 0 &&
90
+ nodes.every((n) => n.status === "stable" || n.status === "roadmap"),
91
+ flagged: flaggedNodes,
92
+ integrityViolations,
93
+ importSuggestions,
94
+ timestamp: new Date().toISOString(),
95
+ };
96
+ }
97
+ validateImportIntegrity(nodes, contracts, dependencies) {
98
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
99
+ const contractById = new Map(contracts.map((contract) => [contract.id, contract]));
100
+ const contractsByNodeId = new Map();
101
+ for (const contract of contracts) {
102
+ const existing = contractsByNodeId.get(contract.node_id) ?? [];
103
+ existing.push(contract);
104
+ contractsByNodeId.set(contract.node_id, existing);
105
+ }
106
+ const dependencyKeys = new Set();
107
+ const uniqueDependencies = dependencies.filter((dependency) => {
108
+ const key = `${dependency.source_node_id}->${dependency.target_contract_id}`;
109
+ if (dependencyKeys.has(key)) {
110
+ return false;
111
+ }
112
+ dependencyKeys.add(key);
113
+ return true;
114
+ });
115
+ const unresolvedImports = [];
116
+ const selfImports = [];
117
+ const adjacency = new Map();
118
+ for (const contract of contracts) {
119
+ adjacency.set(contract.id, new Set());
120
+ }
121
+ for (const dependency of uniqueDependencies) {
122
+ const sourceNode = nodeById.get(dependency.source_node_id);
123
+ const sourceContracts = contractsByNodeId.get(dependency.source_node_id) ?? [];
124
+ const targetContract = contractById.get(dependency.target_contract_id);
125
+ if (!sourceNode || sourceContracts.length === 0) {
126
+ continue;
127
+ }
128
+ if (!targetContract) {
129
+ for (const sourceContract of sourceContracts) {
130
+ unresolvedImports.push({
131
+ contractId: sourceContract.id,
132
+ filePath: sourceNode.file_path,
133
+ importPath: dependency.target_contract_id,
134
+ });
135
+ }
136
+ continue;
137
+ }
138
+ const selfImportingContracts = sourceContracts.filter((sourceContract) => sourceContract.id === dependency.target_contract_id);
139
+ for (const sourceContract of selfImportingContracts) {
140
+ selfImports.push({
141
+ contractId: sourceContract.id,
142
+ filePath: sourceNode.file_path,
143
+ importPath: dependency.target_contract_id,
144
+ });
145
+ }
146
+ for (const sourceContract of sourceContracts) {
147
+ if (sourceContract.id === dependency.target_contract_id) {
148
+ continue;
149
+ }
150
+ adjacency.get(sourceContract.id)?.add(dependency.target_contract_id);
151
+ }
152
+ }
153
+ const circularImports = this.findCircularImports(adjacency, contractById, nodeById);
154
+ return {
155
+ unresolvedImports,
156
+ selfImports,
157
+ circularImports,
158
+ };
159
+ }
160
+ findCircularImports(adjacency, contractById, nodeById) {
161
+ const visited = new Set();
162
+ const path = [];
163
+ const cycleMap = new Map();
164
+ const contractIds = [...adjacency.keys()].sort();
165
+ const visit = (contractId) => {
166
+ visited.add(contractId);
167
+ path.push(contractId);
168
+ const neighbors = [...(adjacency.get(contractId) ?? [])].sort();
169
+ for (const neighborId of neighbors) {
170
+ const existingIndex = path.indexOf(neighborId);
171
+ if (existingIndex !== -1) {
172
+ const cycle = [...path.slice(existingIndex), neighborId];
173
+ const key = canonicalizeCycle(cycle);
174
+ if (!cycleMap.has(key)) {
175
+ const sourceContractId = cycle[0];
176
+ const sourceContract = contractById.get(sourceContractId);
177
+ const sourceNode = sourceContract
178
+ ? nodeById.get(sourceContract.node_id)
179
+ : undefined;
180
+ cycleMap.set(key, {
181
+ contractId: sourceContractId,
182
+ filePath: sourceNode?.file_path ?? sourceContractId,
183
+ importPath: cycle.join(" -> "),
184
+ cycle,
185
+ });
186
+ }
187
+ continue;
188
+ }
189
+ if (!visited.has(neighborId)) {
190
+ visit(neighborId);
191
+ }
192
+ }
193
+ path.pop();
194
+ };
195
+ for (const contractId of contractIds) {
196
+ if (!visited.has(contractId)) {
197
+ visit(contractId);
198
+ }
199
+ }
200
+ return [...cycleMap.values()].sort((left, right) => left.importPath.localeCompare(right.importPath));
201
+ }
202
+ }
203
+ function canonicalizeCycle(cycle) {
204
+ const ring = cycle.slice(0, -1);
205
+ if (ring.length === 0) {
206
+ return "";
207
+ }
208
+ const rotations = ring.map((_, index) => {
209
+ const rotated = [...ring.slice(index), ...ring.slice(0, index)];
210
+ return `${rotated.join("->")}->${rotated[0]}`;
211
+ });
212
+ return rotations.sort()[0];
213
+ }
214
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reconciler/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAyCjC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACD;IAApB,YAAoB,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;IAAG,CAAC;IAEtC;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QAClD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAExD,MAAM,mBAAmB,GAAG,IAAI,CAAC,uBAAuB,CACtD,KAAK,EACL,SAAS,EACT,YAAY,CACb,CAAC;QACF,MAAM,sBAAsB,GAC1B,mBAAmB,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAChD,mBAAmB,CAAC,WAAW,CAAC,MAAM,GAAG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@@ -0,0 +1,7 @@
1
+ import { DBStore } from "./types.js";
2
+ /**
3
+ * Evaluates the current environment and configuration (handling overrides from the CI pipeline, S005)
4
+ * and returns the correct initialized database engine.
5
+ */
6
+ export declare function getStore(): Promise<DBStore>;
7
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/store/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMrC;;;GAGG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAyCjD"}