circle-ir 4.19.0 → 4.20.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 (175) hide show
  1. package/dist/analysis/advisories.d.ts +21 -3
  2. package/dist/analysis/advisories.d.ts.map +1 -1
  3. package/dist/analysis/advisories.js +26 -8
  4. package/dist/analysis/advisories.js.map +1 -1
  5. package/dist/analysis/arg-executing-programs.d.ts +16 -0
  6. package/dist/analysis/arg-executing-programs.d.ts.map +1 -0
  7. package/dist/analysis/arg-executing-programs.js +24 -0
  8. package/dist/analysis/arg-executing-programs.js.map +1 -0
  9. package/dist/analysis/config-loader.d.ts.map +1 -1
  10. package/dist/analysis/config-loader.js +10 -1
  11. package/dist/analysis/config-loader.js.map +1 -1
  12. package/dist/analysis/constant-caller-gate.d.ts +3 -1
  13. package/dist/analysis/constant-caller-gate.d.ts.map +1 -1
  14. package/dist/analysis/constant-caller-gate.js +108 -1
  15. package/dist/analysis/constant-caller-gate.js.map +1 -1
  16. package/dist/analysis/constant-propagation/index.d.ts.map +1 -1
  17. package/dist/analysis/constant-propagation/index.js +1 -1
  18. package/dist/analysis/constant-propagation/index.js.map +1 -1
  19. package/dist/analysis/constant-propagation/patterns.d.ts.map +1 -1
  20. package/dist/analysis/constant-propagation/patterns.js +5 -0
  21. package/dist/analysis/constant-propagation/patterns.js.map +1 -1
  22. package/dist/analysis/constant-propagation/propagator.d.ts +1 -1
  23. package/dist/analysis/constant-propagation/propagator.d.ts.map +1 -1
  24. package/dist/analysis/constant-propagation/propagator.js +15 -1
  25. package/dist/analysis/constant-propagation/propagator.js.map +1 -1
  26. package/dist/analysis/constant-propagation/types.d.ts +2 -0
  27. package/dist/analysis/constant-propagation/types.d.ts.map +1 -1
  28. package/dist/analysis/dependency-versions.d.ts +33 -0
  29. package/dist/analysis/dependency-versions.d.ts.map +1 -1
  30. package/dist/analysis/dependency-versions.js +70 -0
  31. package/dist/analysis/dependency-versions.js.map +1 -1
  32. package/dist/analysis/passes/constant-propagation-pass.d.ts.map +1 -1
  33. package/dist/analysis/passes/constant-propagation-pass.js +1 -0
  34. package/dist/analysis/passes/constant-propagation-pass.js.map +1 -1
  35. package/dist/analysis/passes/cross-file-pass.d.ts.map +1 -1
  36. package/dist/analysis/passes/cross-file-pass.js +61 -0
  37. package/dist/analysis/passes/cross-file-pass.js.map +1 -1
  38. package/dist/analysis/passes/csharp-sanitizer-credit.d.ts.map +1 -1
  39. package/dist/analysis/passes/csharp-sanitizer-credit.js +60 -3
  40. package/dist/analysis/passes/csharp-sanitizer-credit.js.map +1 -1
  41. package/dist/analysis/passes/deserialization-safety-gate-pass.d.ts +15 -0
  42. package/dist/analysis/passes/deserialization-safety-gate-pass.d.ts.map +1 -1
  43. package/dist/analysis/passes/deserialization-safety-gate-pass.js +60 -1
  44. package/dist/analysis/passes/deserialization-safety-gate-pass.js.map +1 -1
  45. package/dist/analysis/passes/interprocedural-pass.d.ts +23 -1
  46. package/dist/analysis/passes/interprocedural-pass.d.ts.map +1 -1
  47. package/dist/analysis/passes/interprocedural-pass.js +140 -0
  48. package/dist/analysis/passes/interprocedural-pass.js.map +1 -1
  49. package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
  50. package/dist/analysis/passes/language-sources-pass.js +110 -6
  51. package/dist/analysis/passes/language-sources-pass.js.map +1 -1
  52. package/dist/analysis/passes/resource-leak-pass.d.ts.map +1 -1
  53. package/dist/analysis/passes/resource-leak-pass.js +15 -3
  54. package/dist/analysis/passes/resource-leak-pass.js.map +1 -1
  55. package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
  56. package/dist/analysis/passes/sink-filter-pass.js +192 -8
  57. package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
  58. package/dist/analysis/passes/taint-propagation-pass.d.ts +7 -3
  59. package/dist/analysis/passes/taint-propagation-pass.d.ts.map +1 -1
  60. package/dist/analysis/passes/taint-propagation-pass.js +176 -15
  61. package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
  62. package/dist/analysis/passes/xml-entity-expansion-pass.d.ts.map +1 -1
  63. package/dist/analysis/passes/xml-entity-expansion-pass.js +50 -6
  64. package/dist/analysis/passes/xml-entity-expansion-pass.js.map +1 -1
  65. package/dist/analysis/pep440-version.d.ts +40 -0
  66. package/dist/analysis/pep440-version.d.ts.map +1 -0
  67. package/dist/analysis/pep440-version.js +149 -0
  68. package/dist/analysis/pep440-version.js.map +1 -0
  69. package/dist/analysis/rules.d.ts.map +1 -1
  70. package/dist/analysis/rules.js +6 -0
  71. package/dist/analysis/rules.js.map +1 -1
  72. package/dist/analysis/sbom.d.ts +43 -4
  73. package/dist/analysis/sbom.d.ts.map +1 -1
  74. package/dist/analysis/sbom.js +265 -33
  75. package/dist/analysis/sbom.js.map +1 -1
  76. package/dist/analysis/taint-matcher.d.ts.map +1 -1
  77. package/dist/analysis/taint-matcher.js +39 -3
  78. package/dist/analysis/taint-matcher.js.map +1 -1
  79. package/dist/analyzer.d.ts +6 -0
  80. package/dist/analyzer.d.ts.map +1 -1
  81. package/dist/analyzer.js +27 -1
  82. package/dist/analyzer.js.map +1 -1
  83. package/dist/browser/circle-ir.js +3151 -61
  84. package/dist/core/circle-ir-core.cjs +78 -6
  85. package/dist/core/circle-ir-core.js +78 -6
  86. package/dist/core/extractors/ts-declaration-detail.d.ts +8 -0
  87. package/dist/core/extractors/ts-declaration-detail.d.ts.map +1 -1
  88. package/dist/core/extractors/ts-declaration-detail.js +22 -0
  89. package/dist/core/extractors/ts-declaration-detail.js.map +1 -1
  90. package/dist/facts/arrow.d.ts +106 -0
  91. package/dist/facts/arrow.d.ts.map +1 -0
  92. package/dist/facts/arrow.js +196 -0
  93. package/dist/facts/arrow.js.map +1 -0
  94. package/dist/facts/facts2.d.ts +59 -0
  95. package/dist/facts/facts2.d.ts.map +1 -0
  96. package/dist/facts/facts2.js +362 -0
  97. package/dist/facts/facts2.js.map +1 -0
  98. package/dist/facts/index.d.ts +20 -0
  99. package/dist/facts/index.d.ts.map +1 -0
  100. package/dist/facts/index.js +14 -0
  101. package/dist/facts/index.js.map +1 -0
  102. package/dist/facts/java-facts.d.ts +56 -0
  103. package/dist/facts/java-facts.d.ts.map +1 -0
  104. package/dist/facts/java-facts.js +250 -0
  105. package/dist/facts/java-facts.js.map +1 -0
  106. package/dist/facts/order.d.ts +39 -0
  107. package/dist/facts/order.d.ts.map +1 -0
  108. package/dist/facts/order.js +120 -0
  109. package/dist/facts/order.js.map +1 -0
  110. package/dist/facts/schema.d.ts +60 -0
  111. package/dist/facts/schema.d.ts.map +1 -0
  112. package/dist/facts/schema.js +126 -0
  113. package/dist/facts/schema.js.map +1 -0
  114. package/dist/facts/schema2.d.ts +47 -0
  115. package/dist/facts/schema2.d.ts.map +1 -0
  116. package/dist/facts/schema2.js +194 -0
  117. package/dist/facts/schema2.js.map +1 -0
  118. package/dist/facts/table.d.ts +80 -0
  119. package/dist/facts/table.d.ts.map +1 -0
  120. package/dist/facts/table.js +548 -0
  121. package/dist/facts/table.js.map +1 -0
  122. package/dist/graph-facts/dead-code.d.ts +2 -0
  123. package/dist/graph-facts/dead-code.d.ts.map +1 -1
  124. package/dist/graph-facts/dead-code.js +1 -1
  125. package/dist/graph-facts/dead-code.js.map +1 -1
  126. package/dist/graph-facts/reach.d.ts +24 -6
  127. package/dist/graph-facts/reach.d.ts.map +1 -1
  128. package/dist/graph-facts/reach.js +52 -12
  129. package/dist/graph-facts/reach.js.map +1 -1
  130. package/dist/graph-facts/removal-reach.d.ts +2 -0
  131. package/dist/graph-facts/removal-reach.d.ts.map +1 -1
  132. package/dist/graph-facts/removal-reach.js +1 -1
  133. package/dist/graph-facts/removal-reach.js.map +1 -1
  134. package/dist/index.d.ts +10 -4
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +13 -2
  137. package/dist/index.js.map +1 -1
  138. package/dist/navigation/java-graph.d.ts +23 -0
  139. package/dist/navigation/java-graph.d.ts.map +1 -1
  140. package/dist/navigation/java-graph.js +222 -8
  141. package/dist/navigation/java-graph.js.map +1 -1
  142. package/dist/navigation/navigation-index.d.ts +9 -0
  143. package/dist/navigation/navigation-index.d.ts.map +1 -1
  144. package/dist/navigation/navigation-index.js +25 -0
  145. package/dist/navigation/navigation-index.js.map +1 -1
  146. package/dist/navigation/ts-call-edges.d.ts +9 -0
  147. package/dist/navigation/ts-call-edges.d.ts.map +1 -1
  148. package/dist/navigation/ts-call-edges.js.map +1 -1
  149. package/dist/resolution/cross-file.d.ts +44 -0
  150. package/dist/resolution/cross-file.d.ts.map +1 -1
  151. package/dist/resolution/cross-file.js +259 -13
  152. package/dist/resolution/cross-file.js.map +1 -1
  153. package/dist/stable-ids/files.d.ts +22 -0
  154. package/dist/stable-ids/files.d.ts.map +1 -0
  155. package/dist/stable-ids/files.js +28 -0
  156. package/dist/stable-ids/files.js.map +1 -0
  157. package/dist/stable-ids/hash.d.ts +16 -4
  158. package/dist/stable-ids/hash.d.ts.map +1 -1
  159. package/dist/stable-ids/hash.js +266 -80
  160. package/dist/stable-ids/hash.js.map +1 -1
  161. package/dist/stable-ids/index.d.ts +3 -2
  162. package/dist/stable-ids/index.d.ts.map +1 -1
  163. package/dist/stable-ids/index.js +3 -2
  164. package/dist/stable-ids/index.js.map +1 -1
  165. package/dist/stable-ids/nodes.d.ts +45 -1
  166. package/dist/stable-ids/nodes.d.ts.map +1 -1
  167. package/dist/stable-ids/nodes.js +118 -15
  168. package/dist/stable-ids/nodes.js.map +1 -1
  169. package/dist/stable-ids/ts-parse-errors.d.ts +5 -1
  170. package/dist/stable-ids/ts-parse-errors.d.ts.map +1 -1
  171. package/dist/stable-ids/ts-parse-errors.js +35 -2
  172. package/dist/stable-ids/ts-parse-errors.js.map +1 -1
  173. package/package.json +8 -4
  174. package/schemas/facts@1.json +134 -0
  175. package/schemas/facts@2.json +216 -0
@@ -0,0 +1,60 @@
1
+ /**
2
+ * `facts@1` — the fact relations circle-ir owes a graph store, as columns in
3
+ * canonical order keyed by `ids@0.1` (graph-store plan 0.1, T1; contract per
4
+ * the 2026-11-01 reconciliation record, decisions 1–11, and the stable-ids
5
+ * decision 1a: `flow` endpoints are node ids in their fixed-width form).
6
+ *
7
+ * Relations are **sets** with **no nulls**: the producer deduplicates after
8
+ * the canonical sort and reports what it dropped; "none" is a sentinel
9
+ * (`unresolved.receiver` empty, `decl.body_hash` all-zero bytes).
10
+ *
11
+ * This module mirrors `schemas/facts@1.json` field for field;
12
+ * `tests/facts/schema.test.ts` fails when the two drift. The JSON file is the
13
+ * document other implementations read; this module is what the emitter and
14
+ * the comparator run on. Nothing in `analyze()` or `buildJavaGraph()` touches
15
+ * it unless a caller asks for facts.
16
+ */
17
+ export declare const FACTS_SCHEME: 'facts@1';
18
+ export type FactsScheme = typeof FACTS_SCHEME;
19
+ /** Width in bytes of an `ids@0.1` id in a column (128 bits). */
20
+ export declare const FACTS_ID_WIDTH = 16;
21
+ /** Rows per record batch after the canonical sort. */
22
+ export declare const FACTS_CHUNK_ROWS = 65536;
23
+ export type FactsColumnType = 'fixed16' | 'u32' | 'utf8' | 'bool' | 'dict';
24
+ export interface FactsColumn {
25
+ readonly name: string;
26
+ readonly type: FactsColumnType;
27
+ /** Always `false` in `facts@1` (no nulls); kept so the schema file and the Arrow fields state it. */
28
+ readonly nullable: boolean;
29
+ /** `dict` columns: the whole vocabulary, in dictionary order. */
30
+ readonly values?: readonly string[];
31
+ }
32
+ export interface FactsRelation {
33
+ /** Sort keys, in order. The remaining columns follow in schema order. */
34
+ readonly key: readonly string[];
35
+ readonly columns: readonly FactsColumn[];
36
+ }
37
+ export declare const FACTS_RELATION_NAMES: readonly ['files', 'decl', 'call', 'unresolved', 'flow', 'imports', 'entries', 'moved'];
38
+ export type FactsRelationName = (typeof FACTS_RELATION_NAMES)[number];
39
+ export declare const FACTS_LANGUAGES: readonly ['java', 'typescript', 'javascript', 'python', 'go'];
40
+ export declare const FACTS_DECL_KINDS: readonly ['module', 'type', 'method', 'field', 'function'];
41
+ export declare const FACTS_TIERS: readonly ['exact', 'polymorphic', 'inferred'];
42
+ export declare const FACTS_UNRESOLVED_REASONS: readonly ['external', 'dynamic', 'generated', 'overload-ambiguous', 'parse-error', 'unsupported-language', 'unknown'];
43
+ export declare const FACTS_FLOW_KINDS: readonly ['def-use', 'taint'];
44
+ /** The engine's `entry-index@0.1` kinds (its `bean` written as `di`) plus the design's data-declared kinds. */
45
+ export declare const FACTS_ENTRY_KINDS: readonly ['main', 'route', 'listener', 'scheduled', 'export', 'di', 'reflection', 'lifecycle', 'test', 'osgi-ds', 'extension-point', 'data-declared', 'script'];
46
+ export declare const FACTS_ENTRY_CERTAINTIES: readonly ['declared', 'conventional', 'inferred'];
47
+ export declare const FACTS_MOVE_KINDS: readonly ['moved', 'renamed'];
48
+ export declare const FACTS_RELATIONS: Readonly<Record<FactsRelationName, FactsRelation>>;
49
+ /** The column indexes a relation sorts by: its key columns, then every other column in schema order. */
50
+ export declare function sortColumns(relation: FactsRelation): number[];
51
+ /**
52
+ * A cell: 16 id bytes, an unsigned 32-bit integer, a string (utf8 and dict
53
+ * columns alike) or a boolean. `null` stays in the type for the comparator's
54
+ * null-first rule (a dead branch: `facts@1` has no nullable column).
55
+ */
56
+ export type FactValue = Uint8Array | number | string | boolean | null;
57
+ /** One row, cells in schema column order. */
58
+ export type FactRow = readonly FactValue[];
59
+ export type FactRows = Readonly<Record<FactsRelationName, FactRow[]>>;
60
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/facts/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,YAAY,EAAG,SAAkB,CAAC;AAC/C,MAAM,MAAM,WAAW,GAAG,OAAO,YAAY,CAAC;AAE9C,gEAAgE;AAChE,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC,MAAM,MAAM,eAAe,G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E,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,CAAU,CAAC;AACjM,eAAO,MAAM,uBAAuB,YAAI,UAAU,EAAE,cAAc,EAAE,UAAU,CAAU,CAAC;AACzF,eAAO,MAAM,gBAAgB,YAAI,OAAO,EAAE,SAAS,CAAU,CAAC;AAK9D,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAiF9E,CAAC;AAEF,wGAAwG;AACxG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,CAQ7D;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEtE,6CAA6C;AAC7C,MAAM,MAAM,OAAO,GAAG,SAAS,SAAS,EAAE,CAAC;AAE3C,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * `facts@1` — the fact relations circle-ir owes a graph store, as columns in
3
+ * canonical order keyed by `ids@0.1` (graph-store plan 0.1, T1; contract per
4
+ * the 2026-11-01 reconciliation record, decisions 1–11, and the stable-ids
5
+ * decision 1a: `flow` endpoints are node ids in their fixed-width form).
6
+ *
7
+ * Relations are **sets** with **no nulls**: the producer deduplicates after
8
+ * the canonical sort and reports what it dropped; "none" is a sentinel
9
+ * (`unresolved.receiver` empty, `decl.body_hash` all-zero bytes).
10
+ *
11
+ * This module mirrors `schemas/facts@1.json` field for field;
12
+ * `tests/facts/schema.test.ts` fails when the two drift. The JSON file is the
13
+ * document other implementations read; this module is what the emitter and
14
+ * the comparator run on. Nothing in `analyze()` or `buildJavaGraph()` touches
15
+ * it unless a caller asks for facts.
16
+ */
17
+ export const FACTS_SCHEME = 'facts@1';
18
+ /** Width in bytes of an `ids@0.1` id in a column (128 bits). */
19
+ export const FACTS_ID_WIDTH = 16;
20
+ /** Rows per record batch after the canonical sort. */
21
+ export const FACTS_CHUNK_ROWS = 65536;
22
+ export const FACTS_RELATION_NAMES = ['files', 'decl', 'call', 'unresolved', 'flow', 'imports', 'entries', 'moved'];
23
+ export const FACTS_LANGUAGES = ['java', 'typescript', 'javascript', 'python', 'go'];
24
+ export const FACTS_DECL_KINDS = ['module', 'type', 'method', 'field', 'function'];
25
+ export const FACTS_TIERS = ['exact', 'polymorphic', 'inferred'];
26
+ export const FACTS_UNRESOLVED_REASONS = ['external', 'dynamic', 'generated', 'overload-ambiguous', 'parse-error', 'unsupported-language', 'unknown'];
27
+ export const FACTS_FLOW_KINDS = ['def-use', 'taint'];
28
+ /** The engine's `entry-index@0.1` kinds (its `bean` written as `di`) plus the design's data-declared kinds. */
29
+ export const FACTS_ENTRY_KINDS = ['main', 'route', 'listener', 'scheduled', 'export', 'di', 'reflection', 'lifecycle', 'test', 'osgi-ds', 'extension-point', 'data-declared', 'script'];
30
+ export const FACTS_ENTRY_CERTAINTIES = ['declared', 'conventional', 'inferred'];
31
+ export const FACTS_MOVE_KINDS = ['moved', 'renamed'];
32
+ const col = (name, type, nullable = false, values) => values ? { name, type, nullable, values } : { name, type, nullable };
33
+ export const FACTS_RELATIONS = {
34
+ files: {
35
+ key: ['file_id'],
36
+ columns: [
37
+ col('file_id', 'u32'),
38
+ col('path', 'utf8'),
39
+ col('content_hash', 'fixed16'),
40
+ col('language', 'dict', false, FACTS_LANGUAGES),
41
+ ],
42
+ },
43
+ decl: {
44
+ key: ['id'],
45
+ columns: [
46
+ col('id', 'fixed16'),
47
+ col('kind', 'dict', false, FACTS_DECL_KINDS),
48
+ col('qualified_name', 'utf8'),
49
+ col('signature', 'utf8'),
50
+ col('file_id', 'u32'),
51
+ col('line', 'u32'),
52
+ col('body_hash', 'fixed16'),
53
+ ],
54
+ },
55
+ call: {
56
+ key: ['caller_id', 'site_file', 'site_line', 'site_col', 'callee_id'],
57
+ columns: [
58
+ col('caller_id', 'fixed16'),
59
+ col('callee_id', 'fixed16'),
60
+ col('tier', 'dict', false, FACTS_TIERS),
61
+ col('method_name', 'utf8'),
62
+ col('site_file', 'u32'),
63
+ col('site_line', 'u32'),
64
+ col('site_col', 'u32'),
65
+ ],
66
+ },
67
+ unresolved: {
68
+ key: ['site_file', 'site_line', 'site_col', 'method_name', 'receiver', 'reason'],
69
+ columns: [
70
+ col('caller_id', 'fixed16'),
71
+ col('reason', 'dict', false, FACTS_UNRESOLVED_REASONS),
72
+ col('receiver', 'utf8'),
73
+ col('method_name', 'utf8'),
74
+ col('site_file', 'u32'),
75
+ col('site_line', 'u32'),
76
+ col('site_col', 'u32'),
77
+ ],
78
+ },
79
+ // Endpoints are ids@0.1 node ids in their fixed-width form (`nodeIdBytes`; the schema file's `node_id`).
80
+ flow: {
81
+ key: ['from_id', 'to_id', 'kind'],
82
+ columns: [
83
+ col('from_id', 'fixed16'),
84
+ col('to_id', 'fixed16'),
85
+ col('kind', 'dict', false, FACTS_FLOW_KINDS),
86
+ ],
87
+ },
88
+ imports: {
89
+ key: ['file_id', 'target', 'wildcard'],
90
+ columns: [
91
+ col('file_id', 'u32'),
92
+ col('target', 'utf8'),
93
+ col('wildcard', 'bool'),
94
+ ],
95
+ },
96
+ entries: {
97
+ key: ['decl_id', 'kind', 'source'],
98
+ columns: [
99
+ col('decl_id', 'fixed16'),
100
+ col('kind', 'dict', false, FACTS_ENTRY_KINDS),
101
+ col('source', 'utf8'),
102
+ col('certainty', 'dict', false, FACTS_ENTRY_CERTAINTIES),
103
+ ],
104
+ },
105
+ moved: {
106
+ key: ['old_id', 'new_id'],
107
+ columns: [
108
+ col('old_id', 'fixed16'),
109
+ col('new_id', 'fixed16'),
110
+ col('kind', 'dict', false, FACTS_MOVE_KINDS),
111
+ col('evidence', 'utf8'),
112
+ ],
113
+ },
114
+ };
115
+ /** The column indexes a relation sorts by: its key columns, then every other column in schema order. */
116
+ export function sortColumns(relation) {
117
+ const names = relation.columns.map(c => c.name);
118
+ const keys = relation.key.map(k => {
119
+ const i = names.indexOf(k);
120
+ if (i < 0)
121
+ throw new Error(`facts@1: key column ${k} is not a column`);
122
+ return i;
123
+ });
124
+ return [...keys, ...names.map((_, i) => i).filter(i => !keys.includes(i))];
125
+ }
126
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/facts/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAkB,CAAC;AAG/C,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAmBtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAG5H,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAU,CAAC;AAC7F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,CAAU,CAAC;AACzE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,sBAAsB,EAAE,SAAS,CAAU,CAAC;AAC9J,MAAM,CAAC,MAAM,gBAAgB,GAA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,EAAE;QAChC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;QACvE,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * `facts@2` — the successor of `facts@1`, published as a major in one step.
3
+ * Against `facts@1`: site positions are relative to the enclosing
4
+ * declaration's start line and carry no file (`rel_line`, `col`); declaration
5
+ * positions move to `decl_pos`; a stable file key (`file`, fixed16, a digest
6
+ * of the path) replaces the dense `file_id` in every relation that names a
7
+ * file; `decl` gains `name`, `parent_id` and the structural flags; new
8
+ * relations `decl_pos`, `ref`, `registration`, `parse_error`; and every
9
+ * relation states whether it is store-only (written and read for rendering,
10
+ * not loaded into the engine unless a rule names it).
11
+ *
12
+ * Everything else is as in `facts@1`: 128-bit ids, sets with no nulls, the
13
+ * total canonical order, fixed-size chunks, the column types and the
14
+ * vocabularies that survive.
15
+ *
16
+ * This module mirrors `schemas/facts@2.json` field for field;
17
+ * `tests/facts/schema2.test.ts` fails when the two drift. `facts@1`
18
+ * (`schema.ts`) stays the producer's default: `facts@2` is emitted only when
19
+ * a caller asks for it (`JavaGraphOptions.factsScheme`).
20
+ */
21
+ import { type FactRow, type FactsRelation } from './schema.js';
22
+ export declare const FACTS2_SCHEME: 'facts@2';
23
+ export type Facts2Scheme = typeof FACTS2_SCHEME;
24
+ /** A `facts@2` relation: a `facts@1` relation shape plus whether a store loads it into the engine. */
25
+ export interface Facts2Relation extends FactsRelation {
26
+ /** Written to the snapshot, digested and read back, but not loaded into the engine unless a rule names it. */
27
+ readonly storeOnly: boolean;
28
+ }
29
+ export declare const FACTS2_RELATION_NAMES: readonly ['files', 'decl', 'decl_pos', 'call', 'unresolved', 'ref', 'registration', 'parse_error', 'flow', 'imports', 'entries', 'moved'];
30
+ export type Facts2RelationName = (typeof FACTS2_RELATION_NAMES)[number];
31
+ /** Why a registration the recognizers saw could not be tied to a declaration. */
32
+ export declare const FACTS_REGISTRATION_REASONS: readonly ['handler-unresolved', 'manifest-unresolved', 'mount-unresolved'];
33
+ /** The parts of a stable file key, `<path>` standing for `files.path`. */
34
+ export declare const FACTS_FILE_KEY_PARTS: readonly ["ids@0.1", "file", '<path>'];
35
+ /**
36
+ * The stable file key of a repository-relative, `/`-separated path:
37
+ * `digest128(["ids@0.1", "file", path])` as 16 bytes. A function of the path
38
+ * and nothing else, so adding, removing or moving one file re-keys only that
39
+ * file's rows. The `file` kind of `ids@0.1` (stable-ids decision 6,
40
+ * `stable-ids/files.ts`).
41
+ */
42
+ export declare function fileKey(path: string): Uint8Array;
43
+ export declare const FACTS2_RELATIONS: Readonly<Record<Facts2RelationName, Facts2Relation>>;
44
+ /** The store-only relations, in schema order. */
45
+ export declare const FACTS2_STORE_ONLY: readonly Facts2RelationName[];
46
+ export type Fact2Rows = Readonly<Record<Facts2RelationName, FactRow[]>>;
47
+ //# sourceMappingURL=schema2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema2.d.ts","sourceRoot":"","sources":["../../src/facts/schema2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EASL,KAAK,OAAO,EAGZ,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,aAAa,EAAG,SAAkB,CAAC;AAChD,MAAM,MAAM,YAAY,GAAG,OAAO,aAAa,CAAC;AAEhD,sGAAsG;AACtG,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,8GAA8G;IAC9G,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,qBAAqB,YAChC,OAAO,EACP,MAAM,EACN,UAAU,EACV,MAAM,EACN,YAAY,EACZ,KAAK,EACL,cAAc,EACd,aAAa,EACb,MAAM,EACN,SAAS,EACT,SAAS,EACT,OAAO,CACC,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,YAAI,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,CAAU,CAAC;AAErH,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,+BAAwC,QAAQ,CAAU,CAAC;AAE5F;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEhD;AAKD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAyIjF,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,EAAE,SAAS,kBAAkB,EAAqE,CAAC;AAEjI,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * `facts@2` — the successor of `facts@1`, published as a major in one step.
3
+ * Against `facts@1`: site positions are relative to the enclosing
4
+ * declaration's start line and carry no file (`rel_line`, `col`); declaration
5
+ * positions move to `decl_pos`; a stable file key (`file`, fixed16, a digest
6
+ * of the path) replaces the dense `file_id` in every relation that names a
7
+ * file; `decl` gains `name`, `parent_id` and the structural flags; new
8
+ * relations `decl_pos`, `ref`, `registration`, `parse_error`; and every
9
+ * relation states whether it is store-only (written and read for rendering,
10
+ * not loaded into the engine unless a rule names it).
11
+ *
12
+ * Everything else is as in `facts@1`: 128-bit ids, sets with no nulls, the
13
+ * total canonical order, fixed-size chunks, the column types and the
14
+ * vocabularies that survive.
15
+ *
16
+ * This module mirrors `schemas/facts@2.json` field for field;
17
+ * `tests/facts/schema2.test.ts` fails when the two drift. `facts@1`
18
+ * (`schema.ts`) stays the producer's default: `facts@2` is emitted only when
19
+ * a caller asks for it (`JavaGraphOptions.factsScheme`).
20
+ */
21
+ import { STABLE_FILE_KIND, fileIdBytes } from '../stable-ids/files.js';
22
+ import { STABLE_ID_SCHEME } from '../stable-ids/types.js';
23
+ import { FACTS_DECL_KINDS, FACTS_ENTRY_CERTAINTIES, FACTS_ENTRY_KINDS, FACTS_FLOW_KINDS, FACTS_LANGUAGES, FACTS_MOVE_KINDS, FACTS_TIERS, FACTS_UNRESOLVED_REASONS, } from './schema.js';
24
+ export const FACTS2_SCHEME = 'facts@2';
25
+ export const FACTS2_RELATION_NAMES = [
26
+ 'files',
27
+ 'decl',
28
+ 'decl_pos',
29
+ 'call',
30
+ 'unresolved',
31
+ 'ref',
32
+ 'registration',
33
+ 'parse_error',
34
+ 'flow',
35
+ 'imports',
36
+ 'entries',
37
+ 'moved',
38
+ ];
39
+ /** Why a registration the recognizers saw could not be tied to a declaration. */
40
+ export const FACTS_REGISTRATION_REASONS = ['handler-unresolved', 'manifest-unresolved', 'mount-unresolved'];
41
+ /** The parts of a stable file key, `<path>` standing for `files.path`. */
42
+ export const FACTS_FILE_KEY_PARTS = [STABLE_ID_SCHEME, STABLE_FILE_KIND, '<path>'];
43
+ /**
44
+ * The stable file key of a repository-relative, `/`-separated path:
45
+ * `digest128(["ids@0.1", "file", path])` as 16 bytes. A function of the path
46
+ * and nothing else, so adding, removing or moving one file re-keys only that
47
+ * file's rows. The `file` kind of `ids@0.1` (stable-ids decision 6,
48
+ * `stable-ids/files.ts`).
49
+ */
50
+ export function fileKey(path) {
51
+ return fileIdBytes(path);
52
+ }
53
+ const col = (name, type, values) => values ? { name, type, nullable: false, values } : { name, type, nullable: false };
54
+ export const FACTS2_RELATIONS = {
55
+ files: {
56
+ key: ['file'],
57
+ storeOnly: false,
58
+ columns: [
59
+ col('file', 'fixed16'),
60
+ col('path', 'utf8'),
61
+ col('content_hash', 'fixed16'),
62
+ col('language', 'dict', FACTS_LANGUAGES),
63
+ col('partial', 'bool'),
64
+ ],
65
+ },
66
+ decl: {
67
+ key: ['id'],
68
+ storeOnly: false,
69
+ columns: [
70
+ col('id', 'fixed16'),
71
+ col('kind', 'dict', FACTS_DECL_KINDS),
72
+ col('name', 'utf8'),
73
+ col('qualified_name', 'utf8'),
74
+ col('signature', 'utf8'),
75
+ col('file', 'fixed16'),
76
+ col('parent_id', 'fixed16'),
77
+ col('body_hash', 'fixed16'),
78
+ col('type_only', 'bool'),
79
+ col('anonymous', 'bool'),
80
+ col('duplicate', 'bool'),
81
+ col('contained', 'bool'),
82
+ col('loads_parent', 'bool'),
83
+ ],
84
+ },
85
+ decl_pos: {
86
+ key: ['id'],
87
+ storeOnly: true,
88
+ columns: [
89
+ col('id', 'fixed16'),
90
+ col('line', 'u32'),
91
+ col('end_line', 'u32'),
92
+ col('col', 'u32'),
93
+ col('end_col', 'u32'),
94
+ ],
95
+ },
96
+ call: {
97
+ key: ['caller_id', 'rel_line', 'col', 'callee_id'],
98
+ storeOnly: false,
99
+ columns: [
100
+ col('caller_id', 'fixed16'),
101
+ col('callee_id', 'fixed16'),
102
+ col('tier', 'dict', FACTS_TIERS),
103
+ col('method_name', 'utf8'),
104
+ col('rel_line', 'u32'),
105
+ col('col', 'u32'),
106
+ col('declaring', 'bool'),
107
+ ],
108
+ },
109
+ unresolved: {
110
+ key: ['caller_id', 'rel_line', 'col', 'method_name', 'receiver', 'reason'],
111
+ storeOnly: false,
112
+ columns: [
113
+ col('caller_id', 'fixed16'),
114
+ col('reason', 'dict', FACTS_UNRESOLVED_REASONS),
115
+ col('receiver', 'utf8'),
116
+ col('method_name', 'utf8'),
117
+ col('rel_line', 'u32'),
118
+ col('col', 'u32'),
119
+ ],
120
+ },
121
+ ref: {
122
+ key: ['from_id', 'rel_line', 'col', 'to_id'],
123
+ storeOnly: false,
124
+ columns: [
125
+ col('from_id', 'fixed16'),
126
+ col('to_id', 'fixed16'),
127
+ col('rel_line', 'u32'),
128
+ col('col', 'u32'),
129
+ ],
130
+ },
131
+ registration: {
132
+ key: ['from_id', 'rel_line', 'col', 'reason'],
133
+ storeOnly: false,
134
+ columns: [
135
+ col('from_id', 'fixed16'),
136
+ col('reason', 'dict', FACTS_REGISTRATION_REASONS),
137
+ col('evidence', 'utf8'),
138
+ col('rel_line', 'u32'),
139
+ col('col', 'u32'),
140
+ ],
141
+ },
142
+ parse_error: {
143
+ key: ['file'],
144
+ storeOnly: true,
145
+ columns: [
146
+ col('file', 'fixed16'),
147
+ col('line', 'u32'),
148
+ col('col', 'u32'),
149
+ col('node_kind', 'utf8'),
150
+ col('parent_kind', 'utf8'),
151
+ ],
152
+ },
153
+ flow: {
154
+ key: ['from_id', 'to_id', 'kind'],
155
+ storeOnly: false,
156
+ columns: [
157
+ col('from_id', 'fixed16'),
158
+ col('to_id', 'fixed16'),
159
+ col('kind', 'dict', FACTS_FLOW_KINDS),
160
+ ],
161
+ },
162
+ imports: {
163
+ key: ['file', 'target', 'wildcard'],
164
+ storeOnly: false,
165
+ columns: [
166
+ col('file', 'fixed16'),
167
+ col('target', 'utf8'),
168
+ col('wildcard', 'bool'),
169
+ ],
170
+ },
171
+ entries: {
172
+ key: ['decl_id', 'kind', 'source'],
173
+ storeOnly: false,
174
+ columns: [
175
+ col('decl_id', 'fixed16'),
176
+ col('kind', 'dict', FACTS_ENTRY_KINDS),
177
+ col('source', 'utf8'),
178
+ col('certainty', 'dict', FACTS_ENTRY_CERTAINTIES),
179
+ ],
180
+ },
181
+ moved: {
182
+ key: ['old_id', 'new_id'],
183
+ storeOnly: false,
184
+ columns: [
185
+ col('old_id', 'fixed16'),
186
+ col('new_id', 'fixed16'),
187
+ col('kind', 'dict', FACTS_MOVE_KINDS),
188
+ col('evidence', 'utf8'),
189
+ ],
190
+ },
191
+ };
192
+ /** The store-only relations, in schema order. */
193
+ export const FACTS2_STORE_ONLY = FACTS2_RELATION_NAMES.filter(n => FACTS2_RELATIONS[n].storeOnly);
194
+ //# sourceMappingURL=schema2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema2.js","sourceRoot":"","sources":["../../src/facts/schema2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,wBAAwB,GAKzB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,aAAa,GAAG,SAAkB,CAAC;AAShD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO;IACP,MAAM;IACN,UAAU;IACV,MAAM;IACN,YAAY;IACZ,KAAK;IACL,cAAc;IACd,aAAa;IACb,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;CACC,CAAC;AAGX,iFAAiF;AACjF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,CAAU,CAAC;AAErH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,CAAU,CAAC;AAE5F;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,IAAqB,EAAE,MAA0B,EAAe,EAAE,CAC3F,MAAM,CAAC,CAAC,CAAC,EAAE,I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AQ,EAAE,UAAU,CAAC;QACnC,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE;YACP,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;YACtB,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC;YACrB,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC;SACxB;KACF;IACD,OAAO,EAAE;QACP,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;QAClC,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE;YACP,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC;YACzB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC;YACtC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC;YACrB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,uBAAuB,CAAC;SAClD;KACF;IACD,KAAK,EAAE;QACL,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;QACzB,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE;YACP,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC;YACxB,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC;YACxB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC;YACrC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC;SACxB;KACF;CACF,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAkC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * `facts@1` relations as columns: one typed array (or string array) per
3
+ * schema column, never an object per row. The emitter builds these straight
4
+ * from the graph, sorts a row-index permutation once with a comparator over
5
+ * the columns, drops adjacent duplicates (relations are sets) and gathers the
6
+ * kept rows — the shape Arrow wants, so the IPC encoder copies buffers
7
+ * instead of visiting cells. The row form (`FactRow`) stays as the reference
8
+ * for the comparator and for tests; `tableFromRows` / `tableRow` convert.
9
+ */
10
+ import { type FactRow, type FactsColumn, type FactsRelation } from './schema.js';
11
+ /**
12
+ * One column's cells, by schema type: `fixed16` → `Uint8Array` of 16 × rows
13
+ * bytes; `u32` → `Uint32Array`; `utf8` → `string[]`; `bool` → `Uint8Array`
14
+ * of 0/1 per row; `dict` → `Int8Array` of vocabulary indexes.
15
+ */
16
+ export type FactColumnData = Uint8Array | Uint32Array | Int8Array | string[];
17
+ export interface FactTable {
18
+ readonly length: number;
19
+ /** One entry per schema column, in schema order. */
20
+ readonly columns: readonly FactColumnData[];
21
+ }
22
+ /** An empty column of the right shape for `n` rows. */
23
+ export declare function allocColumn(c: FactsColumn, n: number): FactColumnData;
24
+ /** Empty columns for a relation with `n` rows. */
25
+ export declare function allocTable(relation: FactsRelation, n: number): FactColumnData[];
26
+ /** `value → index` for a dictionary column's vocabulary. */
27
+ export declare function dictIndex(c: FactsColumn): Map<string, number>;
28
+ /**
29
+ * Decode an `ids@0.1` id (26 lowercase base32 characters, 130 bits with 2
30
+ * zero padding bits) into 16 bytes at `out[offset..]`, allocating nothing.
31
+ */
32
+ export declare function idBytesInto(id: string, out: Uint8Array, offset: number): void;
33
+ /**
34
+ * Decodes ids into columns through a cache: a snapshot's ids repeat (every
35
+ * call edge names its caller and callee), so an id is decoded once into a
36
+ * pool and copied from there after.
37
+ */
38
+ export declare class IdDecoder {
39
+ private pool;
40
+ private readonly offsets;
41
+ private used;
42
+ /** Write the 16 bytes of `id` at `out[offset..]`. */
43
+ put(id: string, out: Uint8Array, offset: number): void;
44
+ }
45
+ /**
46
+ * Code-point order on two strings, fast path first: equal references, then
47
+ * the first differing UTF-16 unit, corrected only where a surrogate meets a
48
+ * non-surrogate (the one case where unit order and code-point order differ).
49
+ */
50
+ export declare function compareStrings(a: string, b: string): number;
51
+ type IndexComparator = (a: number, b: number) => number;
52
+ /**
53
+ * The relation's canonical order as a comparator on row indexes of `columns`:
54
+ * key columns, then every remaining column in schema order. Total over the
55
+ * cells, so `0` means the two rows are equal cell for cell.
56
+ */
57
+ export declare function tableComparator(relation: FactsRelation, columns: readonly FactColumnData[]): IndexComparator;
58
+ /**
59
+ * Canonical form of a relation's rows: sorted in the total order, exact
60
+ * duplicates dropped (relations are sets) and counted. Sorts a permutation
61
+ * once and gathers; the input columns are not modified.
62
+ */
63
+ export declare function canonicalTable(relation: FactsRelation, columns: readonly FactColumnData[], length: number): {
64
+ table: FactTable;
65
+ duplicatesDropped: number;
66
+ };
67
+ /** Adjacent rows of a canonical table that are equal on the key columns alone (what a store's key check would refuse). */
68
+ export declare function keyCollisions(relation: FactsRelation, table: FactTable): number;
69
+ /** Row `i` of a table as cells in schema order. */
70
+ export declare function tableRow(relation: FactsRelation, table: FactTable, i: number): FactRow;
71
+ /** Every row of a table, in table order. */
72
+ export declare function tableRows(relation: FactsRelation, table: FactTable): FactRow[];
73
+ /**
74
+ * Columns from rows in the row form, cells checked against their column
75
+ * (`null` is refused: `facts@1` has no nullable column). The rows keep their
76
+ * order; pass the result through `canonicalTable` for the canonical form.
77
+ */
78
+ export declare function tableFromRows(relation: FactsRelation, rows: readonly FactRow[]): FactTable;
79
+ export {};
80
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/facts/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAkB,KAAK,OAAO,EAAkB,KAAK,WAAW,EAAwB,KAAK,aAAa,EAAe,MAAM,aAAa,CAAC;AAGpJ;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,EAAE,CAAC;AAE7E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;CAC7C;A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