@rsconcept/domain 2.3.0 → 3.0.1

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 (104) hide show
  1. package/dist/{analyzer-fNhkwO-6.d.ts → analyzer-CzFaWR7w.d.ts} +4 -4
  2. package/dist/{api-Bf0f_uiI.d.ts → api-DgecYHjR.d.ts} +5 -3
  3. package/dist/{arguments-extractor-ngatANBI.d.ts → arguments-extractor-CXWRT5Ou.d.ts} +4 -4
  4. package/dist/{ast-C8sIpKdL.d.ts → ast-D-D6Rq3T.d.ts} +2 -3
  5. package/dist/{ast-annotations-CiIx8qBM.d.ts → ast-annotations-x4PJ_Lhc.d.ts} +4 -4
  6. package/dist/{calculator-DE89LtIM.d.ts → calculator-uPaTV3hc.d.ts} +5 -5
  7. package/dist/cctext/language-api.d.ts +0 -1
  8. package/dist/{diagnostics-CljEzVBV.js → diagnostics-D1Cp21nP.js} +36 -13
  9. package/dist/diagnostics-D1Cp21nP.js.map +1 -0
  10. package/dist/{diagnostics-Dac5sJhO.d.ts → diagnostics-DKyMf6q-.d.ts} +24 -8
  11. package/dist/{expression-generator-CoucLIkE.d.ts → expression-generator-CADzBw-C.d.ts} +3 -2
  12. package/dist/graph/index.d.ts +1 -0
  13. package/dist/index-CnuO4w8e.d.ts +13 -0
  14. package/dist/index-D5RahF1K.d.ts +2 -0
  15. package/dist/index-DCO4mxiO.d.ts +378 -0
  16. package/dist/index-DntDUXW1.d.ts +1 -0
  17. package/dist/index-x0_Y5uPV.d.ts +2 -0
  18. package/dist/index.d.ts +13 -13
  19. package/dist/index.js +1 -1
  20. package/dist/{lezer-tree-iS7LpLBJ.d.ts → lezer-tree-BQZqBT5A.d.ts} +1 -2
  21. package/dist/library/diagnostics.d.ts +1 -1
  22. package/dist/library/diagnostics.js +1 -1
  23. package/dist/library/index.d.ts +5 -5
  24. package/dist/library/index.js +1 -1
  25. package/dist/library/index.js.map +1 -1
  26. package/dist/library/oss-api.d.ts +11 -3
  27. package/dist/library/oss-api.js +45 -4
  28. package/dist/library/oss-api.js.map +1 -1
  29. package/dist/library/oss-layout-api.d.ts +0 -1
  30. package/dist/library/oss.d.ts +21 -16
  31. package/dist/library/oss.js +19 -13
  32. package/dist/library/oss.js.map +1 -1
  33. package/dist/library/rsengine.d.ts +6 -5
  34. package/dist/library/rsengine.js +1 -1
  35. package/dist/library/rsform-api/index.d.ts +2 -299
  36. package/dist/library/rsform-api/index.js +1 -1
  37. package/dist/library/rsform.d.ts +1 -1
  38. package/dist/library/rsmodel-api.d.ts +12 -7
  39. package/dist/library/rsmodel-api.js +6 -2
  40. package/dist/library/rsmodel-api.js.map +1 -1
  41. package/dist/library/rsmodel.d.ts +1 -1
  42. package/dist/library/structure-planner.d.ts +3 -3
  43. package/dist/library/structure-planner.js +1 -1
  44. package/dist/library/structure-planner.js.map +1 -1
  45. package/dist/{parser-Bwd8LxJ1.d.ts → parser-DkejtiOR.d.ts} +1 -2
  46. package/dist/parsing/ast.d.ts +1 -1
  47. package/dist/parsing/index.d.ts +3 -2
  48. package/dist/parsing/lezer-tree.d.ts +1 -1
  49. package/dist/rslang/api.d.ts +2 -2
  50. package/dist/rslang/ast-annotations.d.ts +1 -1
  51. package/dist/rslang/eval/calculator.d.ts +1 -1
  52. package/dist/rslang/eval/evaluation-cache.d.ts +3 -3
  53. package/dist/rslang/eval/evaluator.d.ts +3 -3
  54. package/dist/rslang/eval/value-api.d.ts +1 -1
  55. package/dist/rslang/eval/value.d.ts +1 -1
  56. package/dist/rslang/index.d.ts +11 -10
  57. package/dist/rslang/labels.d.ts +3 -3
  58. package/dist/rslang/parser/expression-generator.d.ts +1 -1
  59. package/dist/rslang/parser/normalize.d.ts +2 -1
  60. package/dist/rslang/parser/parser.d.ts +1 -1
  61. package/dist/rslang/parser/parser.terms.d.ts +1 -40
  62. package/dist/rslang/parser/syntax-errors/index.d.ts +3 -3
  63. package/dist/rslang/semantic/analyzer.d.ts +1 -1
  64. package/dist/rslang/semantic/arguments-extractor.d.ts +1 -1
  65. package/dist/rslang/semantic/type-auditor.d.ts +3 -3
  66. package/dist/rslang/semantic/typification-api.d.ts +1 -2
  67. package/dist/rslang/semantic/typification-parser.d.ts +1 -1
  68. package/dist/rslang/semantic/typification.d.ts +1 -1
  69. package/dist/rslang/semantic/value-auditor.d.ts +2 -2
  70. package/dist/rslang/typification-graph.d.ts +1 -1
  71. package/dist/shared/index.d.ts +1 -0
  72. package/dist/{typification-graph-BY_oGT82.d.ts → typification-graph-CSxDt18X.d.ts} +2 -3
  73. package/dist/{typification-9lNu9R4k.d.ts → typification-hWUoWCba.d.ts} +2 -1
  74. package/dist/{typification-parser-Dytsv9CI.d.ts → typification-parser-DFxj4JiQ.d.ts} +2 -3
  75. package/dist/{value-BduA_ZGp.d.ts → value-XpJOVzMP.d.ts} +2 -1
  76. package/dist/{value-api-CXLl_zg0.d.ts → value-api-Dw8UkwCD.d.ts} +3 -4
  77. package/package.json +8 -8
  78. package/src/library/diagnostics.ts +36 -11
  79. package/src/library/oss-api.test.ts +100 -5
  80. package/src/library/oss-api.ts +76 -6
  81. package/src/library/oss.ts +22 -16
  82. package/src/library/rsform-api/alias.ts +8 -8
  83. package/src/library/rsform-api/cst-type.ts +7 -5
  84. package/src/library/rsform-api/expression.ts +3 -3
  85. package/src/library/rsform-api/formal-graph.test.ts +2 -2
  86. package/src/library/rsform-api/formal-graph.ts +6 -10
  87. package/src/library/rsform-api/index.ts +18 -3
  88. package/src/library/rsform-api/semantic-relations.ts +4 -7
  89. package/src/library/rsform-api/stats.ts +6 -5
  90. package/src/library/rsform-api/structure.ts +12 -6
  91. package/src/library/rsform-api/substitution.ts +2 -2
  92. package/src/library/rsform-api/synthesis.test.ts +33 -2
  93. package/src/library/rsform-api/synthesis.ts +16 -12
  94. package/src/library/rsform-api/text-resolution.test.ts +2 -4
  95. package/src/library/rsform-api/text-resolution.ts +8 -8
  96. package/src/library/rsform-api/types.ts +89 -8
  97. package/src/library/rsmodel-api.ts +10 -5
  98. package/src/library/structure-planner.ts +6 -2
  99. package/src/library/template-instantiation.ts +11 -9
  100. package/dist/diagnostics-CljEzVBV.js.map +0 -1
  101. package/dist/index-BKZ67WMa.d.ts +0 -1
  102. package/dist/index-BVVgDSdq.d.ts +0 -1
  103. package/dist/index-DmtQKWjk.d.ts +0 -1
  104. package/dist/index-_6s0AX1B.d.ts +0 -1
@@ -1,11 +1,9 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
3
  import { resolveConstituentTextChange } from './text-resolution';
4
- import { type ResolvableConstituenta } from './types';
4
+ import { type TextResolvableFields } from './types';
5
5
 
6
- function row(
7
- data: Partial<ResolvableConstituenta> & Pick<ResolvableConstituenta, 'alias' | 'id'>
8
- ): ResolvableConstituenta {
6
+ function row(data: Partial<TextResolvableFields> & Pick<TextResolvableFields, 'alias' | 'id'>): TextResolvableFields {
9
7
  return {
10
8
  id: data.id,
11
9
  alias: data.alias,
@@ -7,7 +7,7 @@ import { type TermContext } from '../../cctext/language';
7
7
  import { extractEntities, parseGrammemes, resolveTextReferences } from '../../cctext/language-api';
8
8
  import { Graph } from '../../graph';
9
9
 
10
- import { type ResolvableConstituenta } from './types';
10
+ import { type TextResolvableFields } from './types';
11
11
 
12
12
  /** Options controlling which texts to re-resolve after an edit. */
13
13
  export interface TextChangeOptions {
@@ -18,17 +18,17 @@ export interface TextChangeOptions {
18
18
  }
19
19
 
20
20
  /** Build term-reference graph: referenced constituent → dependent (backend {@code graph_term}). */
21
- export function buildTermReferenceGraph(items: readonly ResolvableConstituenta[]): Graph<number> {
21
+ export function buildTermReferenceGraph(items: readonly TextResolvableFields[]): Graph<number> {
22
22
  return buildReferenceGraph(items, 'term_raw');
23
23
  }
24
24
 
25
25
  /** Build definition-reference graph: referenced constituent → dependent (backend {@code graph_text}). */
26
- export function buildDefinitionReferenceGraph(items: readonly ResolvableConstituenta[]): Graph<number> {
26
+ export function buildDefinitionReferenceGraph(items: readonly TextResolvableFields[]): Graph<number> {
27
27
  return buildReferenceGraph(items, 'definition_raw');
28
28
  }
29
29
 
30
30
  /** Resolve all term and definition texts in topological order. Mutates items in place. */
31
- export function resolveAllConstituentTexts(items: ResolvableConstituenta[]): void {
31
+ export function resolveAllConstituentTexts(items: TextResolvableFields[]): void {
32
32
  const graphTerm = buildTermReferenceGraph(items);
33
33
  const idToItem = new Map(items.map(item => [item.id, item]));
34
34
  const context = buildTermContext(items);
@@ -56,7 +56,7 @@ export function resolveAllConstituentTexts(items: ResolvableConstituenta[]): voi
56
56
  * Mutates items in place.
57
57
  */
58
58
  export function resolveConstituentTextChange(
59
- items: ResolvableConstituenta[],
59
+ items: TextResolvableFields[],
60
60
  targetID: number,
61
61
  options: TextChangeOptions
62
62
  ): void {
@@ -117,7 +117,7 @@ export function resolveConstituentTextChange(
117
117
  // ====== Internals =======
118
118
 
119
119
  function buildReferenceGraph(
120
- items: readonly ResolvableConstituenta[],
120
+ items: readonly TextResolvableFields[],
121
121
  field: 'definition_raw' | 'term_raw'
122
122
  ): Graph<number> {
123
123
  const graph = new Graph<number>();
@@ -136,7 +136,7 @@ function buildReferenceGraph(
136
136
  return graph;
137
137
  }
138
138
 
139
- function buildTermContext(items: readonly ResolvableConstituenta[]): TermContext {
139
+ function buildTermContext(items: readonly TextResolvableFields[]): TermContext {
140
140
  const context: TermContext = {};
141
141
  for (const row of items) {
142
142
  context[row.alias] = toContextItem(row);
@@ -144,7 +144,7 @@ function buildTermContext(items: readonly ResolvableConstituenta[]): TermContext
144
144
  return context;
145
145
  }
146
146
 
147
- function toContextItem(row: ResolvableConstituenta): TermContext[string] {
147
+ function toContextItem(row: TextResolvableFields): TermContext[string] {
148
148
  return {
149
149
  nominal: row.term_resolved,
150
150
  forms: row.term_forms.map(form => ({ text: form.text, grams: parseGrammemes(form.tags) }))
@@ -1,11 +1,15 @@
1
1
  /**
2
- * Minimal constituenta shapes for schema transforms.
2
+ * Capability field slices for schema transforms.
3
+ *
4
+ * Named by concern/task (*Fields), not as subtypes of Constituenta —
5
+ * same idea as ConceptCore's RSConcept / TextConcept split.
3
6
  */
4
7
 
5
- import { type CstType, type TermForm } from '../rsform';
8
+ import { type ExpressionType, type TypePath } from '../../rslang';
9
+ import { type CstStatus, type CstType, type TermForm } from '../rsform';
6
10
 
7
- /** Minimal constituent fields required to restore order. */
8
- export interface OrderableConstituenta {
11
+ /** Fields needed to restore formal dependency order. */
12
+ export interface FormalOrderFields {
9
13
  id: number;
10
14
  alias: string;
11
15
  cst_type: CstType;
@@ -20,8 +24,8 @@ export interface SemanticRelations {
20
24
  childrenOf: Map<number, number[]>;
21
25
  }
22
26
 
23
- /** Constituent fields needed to resolve term/definition entity references. */
24
- export interface ResolvableConstituenta {
27
+ /** Fields needed to resolve term/definition entity references. */
28
+ export interface TextResolvableFields {
25
29
  id: number;
26
30
  alias: string;
27
31
  term_raw: string;
@@ -31,8 +35,85 @@ export interface ResolvableConstituenta {
31
35
  definition_resolved: string;
32
36
  }
33
37
 
34
- /** Constituent fields needed to allocate or reset aliases by type. */
35
- export interface AliasTypedConstituenta {
38
+ /** Fields needed to allocate or reset aliases by type. */
39
+ export interface AliasTypedFields {
36
40
  alias: string;
37
41
  cst_type: CstType;
38
42
  }
43
+
44
+ /** Fields needed to decide whether structure can be produced. */
45
+ export interface StructureCapableFields {
46
+ cst_type: CstType;
47
+ effectiveType: ExpressionType | null;
48
+ }
49
+
50
+ /** Fields needed for schema-issue checks (status + diagnostics). */
51
+ export interface SchemaIssueFields {
52
+ status: CstStatus;
53
+ diagnostics?: readonly { code: number }[] | null;
54
+ }
55
+
56
+ /** Fields needed to look up evaluation status for a model item. */
57
+ export interface ModelEvalFields {
58
+ id: number;
59
+ cst_type: CstType;
60
+ }
61
+
62
+ /** Fields needed to check missing convention / resolved term on basics. */
63
+ export interface BasicTextCheckFields {
64
+ cst_type: CstType;
65
+ convention: string;
66
+ term_resolved: string;
67
+ }
68
+
69
+ /** Fields needed to walk spawn paths for structure helpers. */
70
+ export interface SpawnPathFields {
71
+ id: number;
72
+ spawner?: number;
73
+ spawner_path?: TypePath;
74
+ }
75
+
76
+ /** Fields needed to extract template parameters from a bank item. */
77
+ export interface TemplateParamSourceFields {
78
+ definition_formal: string;
79
+ effectiveType: ExpressionType | null;
80
+ }
81
+
82
+ /** Fields copied from a template bank item when instantiating. */
83
+ export interface TemplateSourceFields extends TemplateParamSourceFields {
84
+ alias: string;
85
+ cst_type: CstType;
86
+ crucial: boolean;
87
+ convention: string;
88
+ definition_raw: string;
89
+ term_raw: string;
90
+ term_forms: TermForm[];
91
+ typification_manual: string;
92
+ value_is_property: boolean;
93
+ }
94
+
95
+ /** Fields needed to expand schema/model diagnostics into expressions. */
96
+ export interface DiagnosticSourceFields {
97
+ id: number;
98
+ alias: string;
99
+ cst_type: CstType;
100
+ term_resolved: string;
101
+ convention: string;
102
+ typification_manual: string;
103
+ definition_formal: string;
104
+ }
105
+
106
+ /** Fields needed for text search over constituenta content. */
107
+ export interface SearchableFields {
108
+ alias: string;
109
+ cst_type: CstType;
110
+ term_raw: string;
111
+ term_resolved: string;
112
+ definition_formal: string;
113
+ definition_raw: string;
114
+ definition_resolved: string;
115
+ convention: string;
116
+ }
117
+
118
+ /** Fields needed to build short UI descriptions / labels. */
119
+ export type DescribableFields = SearchableFields;
@@ -5,8 +5,8 @@ import { type EchelonCollection } from '../rslang/semantic/typification';
5
5
 
6
6
  import { modelStatusCstDiagnostic } from './diagnostics';
7
7
  import { type RSEngine } from './rsengine';
8
- import { type Constituenta, CstType, type RSForm } from './rsform';
9
- import { calculateSchemaStats, isBaseSet, isBasicConcept } from './rsform-api';
8
+ import { CstType, type RSForm } from './rsform';
9
+ import { calculateSchemaStats, isBaseSet, isBasicConcept, type ModelEvalFields } from './rsform-api';
10
10
  import { type BasicBinding, EvalStatus, type RSModelStats } from './rsmodel';
11
11
 
12
12
  const RANDOM_INTEGER_MIN = -100;
@@ -44,7 +44,7 @@ export function validateValueData(data: unknown): data is Value {
44
44
  export function generateRandomValue(
45
45
  type: Typification,
46
46
  basics: Map<number, BasicBinding>,
47
- cstByAlias: Map<string, Constituenta>,
47
+ cstByAlias: Map<string, { id: number }>,
48
48
  setElementsCount: number = DEFAULT_RANDOM_SET_ELEMENTS_COUNT
49
49
  ): Value | null {
50
50
  switch (type.typeID) {
@@ -125,10 +125,15 @@ export function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGen
125
125
  }
126
126
 
127
127
  /** Checks whether evaluation status contributes to model status issues. */
128
- export function isModelIssue(engine: RSEngine, cst: Constituenta): boolean {
128
+ export function isModelIssue(engine: RSEngine, cst: ModelEvalFields): boolean {
129
129
  return modelStatusCstDiagnostic(engine.getCstStatus(cst.id), cst.cst_type) !== null;
130
130
  }
131
131
 
132
+ /** Filters items whose evaluation status contributes to model issues. */
133
+ export function getEvalIssueItems(items: readonly ModelEvalFields[], engine: RSEngine): ModelEvalFields[] {
134
+ return items.filter(cst => isModelIssue(engine, cst));
135
+ }
136
+
132
137
  /** Evaluate if {@link CstType} is interpretable. */
133
138
  export function isInterpretable(type: CstType): boolean {
134
139
  switch (type) {
@@ -325,7 +330,7 @@ export function addValueElement(
325
330
 
326
331
  // ========= Internal functions ==========
327
332
 
328
- function countBaseElements(cst: Constituenta, engine: RSEngine): number {
333
+ function countBaseElements(cst: ModelEvalFields, engine: RSEngine): number {
329
334
  if (!isBasicConcept(cst.cst_type)) {
330
335
  return 0;
331
336
  }
@@ -4,7 +4,7 @@ import { labelType } from '../rslang/labels';
4
4
  import { bool, type EchelonFunctional, isTypification } from '../rslang/semantic/typification';
5
5
 
6
6
  import { type Constituenta, CstType, type RSForm } from './rsform';
7
- import { findCstByStructure } from './rsform-api';
7
+ import { findCstByStructure, type FormalOrderFields, type StructureCapableFields } from './rsform-api';
8
8
 
9
9
  /** Represents a node in the structure planner. */
10
10
  export interface SPNode {
@@ -95,7 +95,11 @@ export class StructurePlanner {
95
95
  }
96
96
 
97
97
  // ======= Internals =======
98
- function produceDefinition(target: Constituenta, rootType: Typification, path: TypePath): string {
98
+ function produceDefinition(
99
+ target: FormalOrderFields & StructureCapableFields,
100
+ rootType: Typification,
101
+ path: TypePath
102
+ ): string {
99
103
  let current = rootType;
100
104
  let expression = target.alias;
101
105
  let index = rootType.typeID === TypeID.collection ? 1 : 0;
@@ -16,14 +16,16 @@ import { labelType } from '../rslang/labels';
16
16
  import { TokenID } from '../rslang/parser/token';
17
17
  import { TypeID } from '../rslang/semantic/typification';
18
18
 
19
- import { type ArgumentValue, type Constituenta, type CstType, type RSForm } from './rsform';
19
+ import { type ArgumentValue, type CstType, type RSForm, type TermForm } from './rsform';
20
20
  import {
21
21
  applyMappingToConstituents,
22
22
  argumentValuesToMapping,
23
23
  generateAlias,
24
24
  inferTemplatedType,
25
25
  isFunctional,
26
- normalizeExpression
26
+ normalizeExpression,
27
+ type TemplateParamSourceFields,
28
+ type TemplateSourceFields
27
29
  } from './rsform-api';
28
30
 
29
31
  /**
@@ -42,7 +44,7 @@ export interface TemplateInstantiationItem {
42
44
  definition_formal: string;
43
45
  definition_raw: string;
44
46
  term_raw: string;
45
- term_forms: Constituenta['term_forms'];
47
+ term_forms: TermForm[];
46
48
  typification_manual: string;
47
49
  value_is_property: boolean;
48
50
  }
@@ -78,9 +80,9 @@ export interface TemplateInstantiationInput {
78
80
  /** Schema that will receive new constituents. */
79
81
  targetSchema: RSForm;
80
82
  /** All constituents of the selected expression-bank RSForm (not only the prototype). */
81
- templateItems: Constituenta[];
83
+ templateItems: TemplateSourceFields[];
82
84
  /** Template constituent chosen in the UI (main expression to add). */
83
- prototype: Constituenta;
85
+ prototype: TemplateSourceFields;
84
86
  /** User bindings from template parameter aliases to target-schema global aliases. */
85
87
  userArgs: ArgumentValue[];
86
88
  /**
@@ -118,10 +120,10 @@ export function planTemplateInstantiation(input: TemplateInstantiationInput): Te
118
120
  */
119
121
  export class TemplateInstantiationPlanner {
120
122
  private readonly targetSchema: RSForm;
121
- private readonly prototype: Constituenta;
123
+ private readonly prototype: TemplateSourceFields;
122
124
  private readonly userArgs: ArgumentValue[];
123
125
  private readonly mainItemTemplate: TemplateInstantiationItem;
124
- private readonly templateByAlias: Map<string, Constituenta>;
126
+ private readonly templateByAlias: Map<string, TemplateSourceFields>;
125
127
  private readonly userMapping: AliasMapping;
126
128
  private readonly depBindings = new Map<string, Map<string, string>>();
127
129
  private readonly depRefs = new Map<string, Set<string>>();
@@ -322,7 +324,7 @@ function formalDefinitionKey(cst_type: CstType, normalized: string): string {
322
324
  }
323
325
 
324
326
  function instantiateTemplateItem(
325
- template: Constituenta,
327
+ template: TemplateSourceFields,
326
328
  args: ArgumentValue[],
327
329
  alias: string
328
330
  ): TemplateInstantiationItem {
@@ -384,7 +386,7 @@ function bindingMapToArgs(params: TemplateParam[], bindings: Map<string, string>
384
386
  }));
385
387
  }
386
388
 
387
- function getTemplateParams(template: Constituenta): TemplateParam[] {
389
+ function getTemplateParams(template: TemplateParamSourceFields): TemplateParam[] {
388
390
  const effectiveType = template.effectiveType;
389
391
  if (effectiveType && (effectiveType.typeID === TypeID.function || effectiveType.typeID === TypeID.predicate)) {
390
392
  return effectiveType.args.map(arg => ({
@@ -1 +0,0 @@
1
- {"version":3,"file":"diagnostics-CljEzVBV.js","names":[],"sources":["../src/library/rsform-api/cst-type.ts","../src/library/rsform-api/alias.ts","../src/library/rsform-api/analysis.ts","../src/library/rsform-api/attribution.ts","../src/library/rsform-api/expression.ts","../src/library/rsform-api/semantic-relations.ts","../src/library/rsform-api/formal-graph.ts","../src/library/rsform-api/stats.ts","../src/library/rsform-api/structure.ts","../src/library/rsform-api/substitution.ts","../src/library/rsform-api/text-resolution.ts","../src/library/rsform-api/synthesis.ts","../src/library/rsform-api/transforms.ts","../src/library/diagnostics.ts"],"sourcesContent":["/**\n * CstType classification, prefixes, and capability predicates.\n */\n\nimport { TypeClass, TypeID, type Typification } from '../../rslang';\nimport { type EchelonFunctional, isTypification } from '../../rslang/semantic/typification';\nimport { type Constituenta, CstClass, CstType } from '../rsform';\n\n/** Record of {@link CstType} prefixes. */\nconst CST_TYPE_PREFIX: Record<CstType, string> = {\n [CstType.NOMINAL]: 'N',\n [CstType.BASE]: 'X',\n [CstType.CONSTANT]: 'C',\n [CstType.STRUCTURED]: 'S',\n [CstType.AXIOM]: 'A',\n [CstType.TERM]: 'D',\n [CstType.FUNCTION]: 'F',\n [CstType.PREDICATE]: 'P',\n [CstType.STATEMENT]: 'T'\n};\n\n/** Record of {@link CstType} to {@link CstClass} mapping. */\nconst CST_TYPE_TO_CLASS: Record<CstType, CstClass> = {\n [CstType.NOMINAL]: CstClass.NOMINAL,\n [CstType.BASE]: CstClass.BASIC,\n [CstType.CONSTANT]: CstClass.BASIC,\n [CstType.STRUCTURED]: CstClass.BASIC,\n [CstType.TERM]: CstClass.DERIVED,\n [CstType.FUNCTION]: CstClass.DERIVED,\n [CstType.AXIOM]: CstClass.STATEMENT,\n [CstType.PREDICATE]: CstClass.DERIVED,\n [CstType.STATEMENT]: CstClass.STATEMENT\n};\n\n/** Prefix for alias indicating {@link CstType}. */\nexport function getCstTypePrefix(type: CstType): string {\n return CST_TYPE_PREFIX[type];\n}\n\n/** Guess {@link CstType} from user input hint. */\nexport function guessCstType(hint: string): CstType | null {\n if (hint.length !== 1) {\n return null;\n }\n for (const [type, prefix] of Object.entries(CST_TYPE_PREFIX)) {\n if (hint === prefix) {\n return type as CstType;\n }\n }\n return null;\n}\n\n/** Infers the {@link CstClass} based on the provided {@link CstType} and template status. */\nexport function inferClass(type: CstType, isTemplate: boolean = false): CstClass {\n if (isTemplate) {\n return CstClass.TEMPLATE;\n }\n return CST_TYPE_TO_CLASS[type];\n}\n\n/** Check if {@link Constituenta} is a template or a category. */\nexport function isTemplateCst(cst: Constituenta): boolean {\n return cst.cst_type === CstType.FUNCTION || cst.cst_type === CstType.PREDICATE || cst.cst_type === CstType.STATEMENT;\n}\n\n/** Evaluate if {@link CstType} is basic concept. */\nexport function isBasicConcept(type: CstType): boolean {\n switch (type) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n return true;\n\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is base set or constant set. */\nexport function isBaseSet(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is a function. */\nexport function isFunctional(type: CstType): boolean {\n switch (type) {\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is logical. */\nexport function isLogical(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} can have manual typification. */\nexport function canHaveManualTypification(type: CstType): boolean {\n switch (type) {\n case CstType.STRUCTURED:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Checks whether a constituenta type supports formal definitions. */\nexport function canHaveFormalDefinition(cstType: CstType): boolean {\n return cstType !== CstType.BASE && cstType !== CstType.CONSTANT;\n}\n\n/** Returns expected {@link TypeClass} of formal definition for {@link CstType}. */\nexport function typeClassForCstType(cstType: CstType): TypeClass {\n switch (cstType) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.TERM:\n return TypeClass.typification;\n case CstType.FUNCTION:\n return TypeClass.function;\n case CstType.PREDICATE:\n return TypeClass.predicate;\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return TypeClass.logic;\n }\n}\n\n/** Evaluate if {@link Constituenta} can be used produce structure. */\nexport function canProduceStructure(cst: Constituenta): boolean {\n switch (cst.cst_type) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.PREDICATE:\n return false;\n }\n if (!cst.effectiveType) {\n return false;\n }\n if (cst.cst_type === CstType.FUNCTION) {\n const result = (cst.effectiveType as EchelonFunctional).result;\n return typeCanProduceStructure(result);\n }\n if (!isTypification(cst.effectiveType)) {\n return false;\n }\n return typeCanProduceStructure(cst.effectiveType as Typification);\n}\n\nfunction typeCanProduceStructure(type: Typification): boolean {\n if (type.typeID === TypeID.basic || type.typeID === TypeID.integer || type.typeID === TypeID.anyTypification) {\n return false;\n } else if (type.typeID === TypeID.tuple) {\n return true;\n } else {\n return (\n type.base.typeID !== TypeID.basic &&\n type.base.typeID !== TypeID.integer &&\n type.base.typeID !== TypeID.anyTypification\n );\n }\n}\n","/**\n * Alias generation, validation, and remapping.\n */\n\nimport { applyEntityReferenceMapping } from '../../cctext/language-api';\nimport { type AliasMapping, applyAliasMapping, applyTypificationMapping } from '../../rslang/api';\nimport { type ArgumentValue, CstType, type RSForm } from '../rsform';\n\nimport { getCstTypePrefix } from './cst-type';\nimport { type AliasTypedConstituenta } from './types';\n\n/** Fields of {@link Constituenta} updated in place by alias mapping. */\nexport interface ConstituentaMappableFields {\n alias: string;\n definition_formal: string;\n typification_manual: string;\n term_raw: string;\n definition_raw: string;\n}\n\n/** Build alias mapping from template argument bindings. */\nexport function argumentValuesToMapping(args: ArgumentValue[]): AliasMapping {\n const mapping: AliasMapping = {};\n for (const arg of args) {\n if (arg.value) {\n mapping[arg.alias] = arg.value;\n }\n }\n return mapping;\n}\n\n/** Validate alias format for a given {@link CstType} (prefix + digits, min length 2). */\nexport function validateAliasFormat(alias: string, type: CstType): boolean {\n if (alias.length < 2) {\n return false;\n }\n const prefix = getCstTypePrefix(type);\n if (!alias.startsWith(prefix)) {\n return false;\n }\n if (!/^\\d+$/.exec(alias.substring(prefix.length))) {\n return false;\n }\n return true;\n}\n\n/** Validate new alias against {@link CstType} and {@link RSForm}. */\nexport function validateNewAlias(alias: string, type: CstType, schema: RSForm): boolean {\n if (!validateAliasFormat(alias, type)) {\n return false;\n }\n if (schema.cstByAlias.has(alias)) {\n return false;\n }\n return true;\n}\n\n/** Generate alias for new {@link Constituenta} of a given {@link CstType} for current {@link RSForm}. */\nexport function generateAlias(type: CstType, schema: RSForm, takenAliases: string[] = []): string {\n const prefix = getCstTypePrefix(type);\n let index = schema.items.reduce((prev, cst) => {\n if (cst.cst_type !== type) {\n return prev;\n }\n const next = Number(cst.alias.substring(prefix.length)) + 1;\n return Math.max(prev, next);\n }, 1);\n let alias = `${prefix}${index}`;\n while (takenAliases.includes(alias)) {\n index = index + 1;\n alias = `${prefix}${index}`;\n }\n return alias;\n}\n\n/**\n * Remap formal expressions and terminological entity references in constituent fields.\n * Mutates each element of `items` in place; pass owned or cloned data only.\n */\nexport function applyMappingToConstituents<T extends ConstituentaMappableFields>(\n items: T[],\n mapping: AliasMapping,\n changeAliases: boolean\n): void {\n for (const cst of items) {\n if (changeAliases && cst.alias in mapping) {\n cst.alias = mapping[cst.alias];\n }\n cst.definition_formal = applyAliasMapping(cst.definition_formal, mapping);\n cst.typification_manual = applyTypificationMapping(cst.typification_manual, mapping);\n cst.term_raw = applyEntityReferenceMapping(cst.term_raw, mapping);\n cst.definition_raw = applyEntityReferenceMapping(cst.definition_raw, mapping);\n }\n}\n\n/** Highest numeric alias suffix for {@link type} among {@link items} (0 when none). */\nexport function maxAliasIndex(items: readonly AliasTypedConstituenta[], type: CstType): number {\n const prefix = getCstTypePrefix(type);\n return items.reduce((max, cst) => {\n if (cst.cst_type !== type) {\n return max;\n }\n const index = Number(cst.alias.slice(prefix.length));\n return Number.isFinite(index) ? Math.max(max, index) : max;\n }, 0);\n}\n\n/**\n * Build alias → new-alias mapping that renumbers each type sequentially in list order.\n * Matches backend {@code RSFormCached.reset_aliases}.\n */\nexport function buildSequentialAliasMapping(items: readonly AliasTypedConstituenta[]): AliasMapping {\n const counts: Record<string, number> = {};\n for (const value of Object.values(CstType)) {\n counts[value] = 1;\n }\n const mapping: AliasMapping = {};\n for (const cst of items) {\n const alias = `${getCstTypePrefix(cst.cst_type)}${counts[cst.cst_type]}`;\n counts[cst.cst_type] += 1;\n if (cst.alias !== alias) {\n mapping[cst.alias] = alias;\n }\n }\n return mapping;\n}\n\n/**\n * Allocate fresh aliases for {@link source} constituents being imported into a non-empty receiver.\n * Returns an empty mapping when the receiver has no items (aliases kept as-is).\n */\nexport function allocateImportAliases(\n receiver: readonly AliasTypedConstituenta[],\n source: readonly AliasTypedConstituenta[]\n): AliasMapping {\n if (receiver.length === 0) {\n return {};\n }\n const counts: Record<string, number> = {};\n for (const value of Object.values(CstType)) {\n counts[value] = maxAliasIndex(receiver, value);\n }\n const mapping: AliasMapping = {};\n for (const cst of source) {\n counts[cst.cst_type] += 1;\n mapping[cst.alias] = `${getCstTypePrefix(cst.cst_type)}${counts[cst.cst_type]}`;\n }\n return mapping;\n}\n\n/** Remove alias from expression. */\nexport function removeAliasReference(expression: string, alias: string): string {\n const escaped = alias.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n return expression.replaceAll(new RegExp(`\\\\b${escaped}\\\\b`, 'g'), '').trim();\n}\n\n/** Add alias to expression. */\nexport function addAliasReference(expression: string, alias: string): string {\n return expression + ' ' + alias;\n}\n","/**\n * Formal expression analysis against an RSForm schema.\n */\n\nimport { type Graph } from '../../graph';\nimport { type AnalysisFull, RSErrorCode, ValueClass } from '../../rslang';\nimport { extractGlobals } from '../../rslang/api';\nimport { basic, bool, constant } from '../../rslang/semantic/typification';\nimport { formatDependencyCycle, RSDiagnosticCode } from '../diagnostics';\nimport { CstType, type RSForm } from '../rsform';\n\nimport { canHaveFormalDefinition, typeClassForCstType } from './cst-type';\n\nexport function getAnalysisFor(expression: string, cstType: CstType, schema: RSForm, alias?: string): AnalysisFull {\n if (!canHaveFormalDefinition(cstType)) {\n if (expression.trim().length === 0) {\n const fallbackAlias = alias && alias.length > 0 ? alias : 'X0';\n const type = cstType === CstType.BASE ? bool(basic(fallbackAlias)) : bool(constant(fallbackAlias));\n return {\n success: true,\n type,\n valueClass: ValueClass.VALUE,\n errors: [],\n ast: null\n };\n }\n return {\n success: false,\n type: null,\n valueClass: null,\n errors: [\n {\n code: RSErrorCode.definitionNotAllowed,\n from: 0,\n to: Math.max(expression.length, 1),\n params: [cstType, alias ?? '']\n }\n ],\n ast: null\n };\n }\n const analysis = schema.analyzer.checkFull(expression, {\n expected: typeClassForCstType(cstType),\n isDomain: cstType === CstType.STRUCTURED\n });\n return refineAnalysisForDependencyCycles(analysis, expression, schema, alias);\n}\n\n/**\n * When an untyped / bare F·P reference names a constituent on a definition cycle with the\n * current expression, replace that error with {@link RSDiagnosticCode.schemaDependencyCycle}.\n *\n * Covers both semantic `globalNotTyped` (e.g. `F3[σ]`) and parser `globalFuncWithoutArgs`\n * (bare `P1` / `F1` treated as a call without arguments).\n *\n * Uses a draft dependency graph: incoming edges of the edited constituent are taken from\n * `expression`, so Check works before Save.\n */\nexport function refineAnalysisForDependencyCycles(\n analysis: AnalysisFull,\n expression: string,\n schema: RSForm,\n alias?: string\n): AnalysisFull {\n if (analysis.errors.length === 0 || !schema.graph) {\n return analysis;\n }\n\n const currentId = alias ? schema.cstByAlias.get(alias)?.id : undefined;\n const expressionGlobals = extractGlobals(expression);\n const draftGraph =\n currentId !== undefined ? buildDraftDependencyGraph(schema, currentId, expressionGlobals) : schema.graph;\n\n let changed = false;\n const errors = analysis.errors.map(error => {\n if (error.code !== RSErrorCode.globalNotTyped && error.code !== RSErrorCode.globalFuncWithoutArgs) {\n return error;\n }\n const missingAlias = error.params?.[0];\n if (!missingAlias) {\n return error;\n }\n const missing = schema.cstByAlias.get(missingAlias);\n if (!missing) {\n return error;\n }\n const cycleText = resolveDependencyCycleText(schema, draftGraph, currentId, missing.id);\n if (!cycleText) {\n return error;\n }\n changed = true;\n return {\n ...error,\n code: RSErrorCode.schemaDependencyCycle,\n params: [cycleText]\n };\n });\n return changed ? { ...analysis, errors } : analysis;\n}\n\n/**\n * Clone the schema graph and replace dependencies of `currentId` with globals from the\n * expression under check (unsaved draft).\n */\nfunction buildDraftDependencyGraph(schema: RSForm, currentId: number, expressionGlobals: ReadonlySet<string>): Graph {\n const graph = schema.graph.clone();\n const node = graph.at(currentId);\n if (node) {\n for (const parentId of [...node.inputs]) {\n graph.removeEdge(parentId, currentId);\n }\n } else {\n graph.addNode(currentId);\n }\n for (const globalAlias of expressionGlobals) {\n const source = schema.cstByAlias.get(globalAlias);\n if (source) {\n graph.addEdge(source.id, currentId);\n }\n }\n return graph;\n}\n\n/**\n * Resolve formatted cycle text for an untyped global reference in analysis.\n *\n * Uses `graph` (often a draft graph built from the expression under check). When\n * `currentId` is omitted, falls back to schema diagnostics on `missingId`.\n *\n * @returns Closed alias path such as `F3 → P1 → F3`, or `null` when no shared cycle exists.\n */\nfunction resolveDependencyCycleText(\n schema: RSForm,\n graph: Graph,\n currentId: number | undefined,\n missingId: number\n): string | null {\n for (const cycle of graph.findCycles()) {\n const members = new Set(cycle);\n if (!members.has(missingId)) {\n continue;\n }\n if (currentId !== undefined && !members.has(currentId)) {\n continue;\n }\n return formatDependencyCycle(cycle.map(id => schema.cstByID.get(id)?.alias ?? String(id)));\n }\n\n if (currentId === undefined) {\n const cycleDiag = schema.cstByID\n .get(missingId)\n ?.diagnostics.find(item => item.code === RSDiagnosticCode.schemaDependencyCycle);\n return cycleDiag?.params?.[0] ?? null;\n }\n\n return null;\n}\n","/**\n * Attribution remapping helpers for substitution and schema embedding.\n */\n\nimport { type Attribution } from '../rsform';\n\nfunction attributionKey(attr: Attribution): string {\n return `${attr.container}:${attr.attribute}`;\n}\n\n/**\n * Remap attributions when constituents are substituted (original → replacement).\n * Drops self-loops and duplicates. Matches sandbox / backend substitute attribution rewrite.\n */\nexport function remapAttributionsUnderSubstitution(\n attributions: readonly Attribution[],\n origToSub: ReadonlyMap<number, number>\n): Attribution[] {\n const result: Attribution[] = [];\n const seen = new Set<string>();\n\n for (const attr of attributions) {\n if (!origToSub.has(attr.container) && !origToSub.has(attr.attribute)) {\n const key = attributionKey(attr);\n if (!seen.has(key)) {\n seen.add(key);\n result.push({ ...attr });\n }\n continue;\n }\n\n const container = origToSub.get(attr.container) ?? attr.container;\n const attribute = origToSub.get(attr.attribute) ?? attr.attribute;\n if (container === attribute) {\n continue;\n }\n const key = `${container}:${attribute}`;\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n result.push({ container, attribute });\n }\n\n return result;\n}\n\n/**\n * Copy attributions whose both endpoints are in {@link sourceIdSet}, remapping ids via {@link idMap}.\n * Appends onto a clone of {@link existing} with dedupe. Used by schema embedding / insert.\n */\nexport function importAttributions(\n sourceAttributions: readonly Attribution[],\n sourceIdSet: ReadonlySet<number>,\n idMap: Readonly<Record<number, number>>,\n existing: readonly Attribution[] = []\n): Attribution[] {\n const result = existing.map(attr => ({ ...attr }));\n const seen = new Set(result.map(attributionKey));\n\n for (const attr of sourceAttributions) {\n if (!sourceIdSet.has(attr.container) || !sourceIdSet.has(attr.attribute)) {\n continue;\n }\n const container = idMap[attr.container];\n const attribute = idMap[attr.attribute];\n if (container === undefined || attribute === undefined || container === attribute) {\n continue;\n }\n const key = `${container}:${attribute}`;\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n result.push({ container, attribute });\n }\n\n return result;\n}\n\n/** Drop attributions that reference any id in {@link deletedIds}. */\nexport function filterAttributions(\n attributions: readonly Attribution[],\n deletedIds: ReadonlySet<number>\n): Attribution[] {\n return attributions.filter(attr => !deletedIds.has(attr.container) && !deletedIds.has(attr.attribute));\n}\n","/**\n * Formal expression helpers: normalization, templates, status.\n */\n\nimport { type AstNode } from '../../parsing';\nimport { ValueClass } from '../../rslang';\nimport { generateExpressionFromAst, parseRSLangExpression } from '../../rslang/api';\nimport { type ArgumentValue, type Constituenta, CstStatus, CstType } from '../rsform';\n\nimport { isBasicConcept } from './cst-type';\n\n/** Infers the status of an expression based on parsing and value information. */\nexport function inferStatus(parse: boolean, value?: ValueClass | null): CstStatus {\n if (!parse) {\n return CstStatus.INCORRECT;\n }\n if (value === null) {\n return CstStatus.INCALCULABLE;\n }\n if (value === ValueClass.PROPERTY) {\n return CstStatus.PROPERTY;\n }\n return CstStatus.VERIFIED;\n}\n\n/** Infers type of constituent for a given template and arguments. */\nexport function inferTemplatedType(templateType: CstType, args: ArgumentValue[]): CstType {\n if (args.length === 0 || args.some(arg => !arg.value)) {\n return templateType;\n } else if (templateType === CstType.PREDICATE) {\n return CstType.AXIOM;\n } else {\n return CstType.TERM;\n }\n}\n\n/**\n * Normalize a RSLang expression for duplicate comparison.\n *\n * Returns `null` for basic concepts without formal definitions. Pass a pre-parsed `ast`\n * when the expression was already analyzed to avoid re-parsing.\n */\nexport function normalizeExpression(expression: string, cst_type: CstType, ast?: AstNode | null): string | null {\n if (isBasicConcept(cst_type) && cst_type !== CstType.AXIOM) {\n return null;\n }\n const parsed = ast ?? parseRSLangExpression(expression);\n let normalized = '';\n if (parsed && !parsed.hasError) {\n normalized = generateExpressionFromAst(parsed, { normalize: true });\n } else {\n normalized = expression;\n }\n normalized = normalized.replace(/\\s+/g, '');\n return normalized === '' ? null : normalized;\n}\n\n/** Checks if given expression is a template. */\nexport function inferTemplate(expression: string): boolean {\n const match = expression.match(/R\\d+/g);\n return (match && match?.length > 0) ?? false;\n}\n\n/** Apply filter based on start {@link Constituenta} type. */\nexport function applyFilterCategory(start: Constituenta, items: Constituenta[]): Constituenta[] {\n const startIndex = items.indexOf(start);\n if (startIndex === -1) {\n return [];\n }\n const nextCategoryIndex = items.findIndex((cst, index) => index > startIndex && cst.cst_type === CstType.STATEMENT);\n\n return items.filter((_, index) => index >= startIndex && (nextCategoryIndex === -1 || index < nextCategoryIndex));\n}\n","/**\n * Semantic parent/children used when restoring constituent order.\n */\n\nimport { type Graph } from '../../graph';\nimport { extractGlobals, isSimpleExpression, splitTemplateDefinition } from '../../rslang/api';\nimport { CstType } from '../rsform';\n\nimport { isBaseSet, isFunctional } from './cst-type';\nimport { inferTemplate } from './expression';\nimport { type OrderableConstituenta, type SemanticRelations } from './types';\n\n/**\n * Infer semantic parent/children used for clustering during restore order.\n * Port of backend {@code SemanticInfo}.\n */\nexport function computeSemanticRelations(\n items: readonly OrderableConstituenta[],\n graph: Graph<number>\n): SemanticRelations {\n const byId = new Map(items.map(cst => [cst.id, cst]));\n const byAlias = new Map(items.map(cst => [cst.alias, cst]));\n const isTemplate = new Map<number, boolean>();\n const isSimple = new Map<number, boolean>();\n const parentOf = new Map<number, number>();\n const childrenOf = new Map<number, number[]>();\n\n for (const cst of items) {\n parentOf.set(cst.id, cst.id);\n childrenOf.set(cst.id, []);\n }\n\n function needCheckHead(sources: Set<number>, head: string): boolean {\n if (sources.size === 0) {\n return true;\n }\n if (sources.size !== 1) {\n return false;\n }\n const base = byId.get([...sources][0])!;\n return !isFunctional(base.cst_type) || splitTemplateDefinition(base.definition_formal).head !== head;\n }\n\n function extractSources(target: OrderableConstituenta): Set<number> {\n const sources = new Set<number>();\n if (!isFunctional(target.cst_type)) {\n for (const parentId of graph.at(target.id)?.inputs ?? []) {\n if (!(isTemplate.get(parentId) && isSimple.get(parentId))) {\n sources.add(parentOf.get(parentId) ?? parentId);\n }\n }\n return sources;\n }\n\n const expression = splitTemplateDefinition(target.definition_formal);\n for (const alias of extractGlobals(expression.body)) {\n const parent = byAlias.get(alias);\n if (!parent) {\n continue;\n }\n if (!(isTemplate.get(parent.id) && isSimple.get(parent.id))) {\n sources.add(parentOf.get(parent.id) ?? parent.id);\n }\n }\n if (needCheckHead(sources, expression.head)) {\n for (const alias of extractGlobals(expression.head)) {\n const parent = byAlias.get(alias);\n if (!parent) {\n continue;\n }\n if (!isBaseSet(parent.cst_type) && !(isTemplate.get(parent.id) && isSimple.get(parent.id))) {\n sources.add(parentOf.get(parent.id) ?? parent.id);\n }\n }\n }\n return sources;\n }\n\n function inferSimple(target: OrderableConstituenta): boolean {\n if (target.cst_type === CstType.STRUCTURED || isBaseSet(target.cst_type)) {\n return false;\n }\n const dependencies = graph.at(target.id)?.inputs ?? [];\n if (dependencies.some(id => isTemplate.get(id) && !isSimple.get(id))) {\n return false;\n }\n const expression = isFunctional(target.cst_type)\n ? splitTemplateDefinition(target.definition_formal).body\n : target.definition_formal;\n return isSimpleExpression(expression);\n }\n\n for (const cstId of graph.topologicalOrder()) {\n const cst = byId.get(cstId);\n if (!cst) {\n continue;\n }\n isTemplate.set(cstId, inferTemplate(cst.definition_formal));\n isSimple.set(cstId, inferSimple(cst));\n if (!isSimple.get(cstId) || cst.cst_type === CstType.STRUCTURED) {\n continue;\n }\n const sources = extractSources(cst);\n if (sources.size !== 1) {\n continue;\n }\n const parentId = [...sources][0];\n const parent = byId.get(parentId);\n if (!parent || isBaseSet(parent.cst_type)) {\n continue;\n }\n parentOf.set(cstId, parentId);\n childrenOf.get(parentId)!.push(cstId);\n }\n\n return { parentOf, childrenOf };\n}\n","/**\n * Formal dependency graph and declaration-order restore for RSForm constituents.\n */\n\nimport { Graph } from '../../graph';\nimport { extractGlobals } from '../../rslang/api';\nimport { CstType } from '../rsform';\n\nimport { computeSemanticRelations } from './semantic-relations';\nimport { type OrderableConstituenta, type SemanticRelations } from './types';\n\n/**\n * Build the formal dependency graph: supplier → dependent.\n * Matches backend {@code RSForm.graph_formal}.\n */\nexport function buildFormalDependencyGraph(items: readonly OrderableConstituenta[]): Graph<number> {\n const graph = new Graph<number>();\n const byAlias = new Map(items.map(cst => [cst.alias, cst]));\n for (const cst of items) {\n graph.addNode(cst.id);\n }\n for (const cst of items) {\n for (const alias of extractGlobals(cst.definition_formal)) {\n const supplier = byAlias.get(alias);\n if (supplier) {\n graph.addEdge(supplier.id, cst.id);\n }\n }\n }\n return graph;\n}\n\n/**\n * Reorder constituents: formal topology hard, semantic children sticky when ready,\n * otherwise stable against type/kernel preferred ranks.\n *\n * One Kahn pass over the formal dependency graph.\n */\nexport function restoreConstituentOrder<T extends OrderableConstituenta>(\n items: readonly T[],\n graph: Graph<number> = buildFormalDependencyGraph(items),\n relations: SemanticRelations = computeSemanticRelations(items, graph)\n): T[] {\n if (items.length <= 1) {\n return [...items];\n }\n\n const byId = new Map(items.map(cst => [cst.id, cst]));\n const preferred = kernelPriority(items, graph, relations.parentOf);\n const rank = new Map(preferred.map((cst, index) => [cst.id, index]));\n\n const remainingInputs = new Map<number, number>();\n for (const cst of preferred) {\n const inputs = graph.at(cst.id)?.inputs ?? [];\n remainingInputs.set(\n cst.id,\n inputs.reduce((count, src) => count + (rank.has(src) ? 1 : 0), 0)\n );\n }\n\n const ready = new Set<number>();\n for (const cst of preferred) {\n if ((remainingInputs.get(cst.id) ?? 0) === 0) {\n ready.add(cst.id);\n }\n }\n\n const children = new Map<number, number[]>();\n for (const cst of preferred) {\n children.set(\n cst.id,\n (relations.childrenOf.get(cst.id) ?? []).filter(childId => rank.has(childId))\n );\n }\n\n const result: T[] = [];\n const pendingChildren: number[] = [];\n\n function enqueueSticky(candidateIds: readonly number[]): void {\n const sticky = candidateIds.filter(\n childId => ready.has(childId) && !pendingChildren.includes(childId)\n );\n sticky.sort((left, right) => (rank.get(left) ?? 0) - (rank.get(right) ?? 0));\n pendingChildren.push(...sticky);\n }\n\n function pickReady(): number {\n while (pendingChildren.length > 0) {\n const childId = pendingChildren.shift()!;\n if (ready.has(childId)) {\n return childId;\n }\n }\n let best = -1;\n let bestRank = Number.POSITIVE_INFINITY;\n for (const nodeId of ready) {\n const nodeRank = rank.get(nodeId) ?? Number.POSITIVE_INFINITY;\n if (nodeRank < bestRank) {\n best = nodeId;\n bestRank = nodeRank;\n }\n }\n return best;\n }\n\n while (ready.size > 0 || pendingChildren.length > 0) {\n if (ready.size === 0) {\n pendingChildren.length = 0;\n continue;\n }\n const nodeId = pickReady();\n ready.delete(nodeId);\n result.push(byId.get(nodeId)!);\n\n for (const dependentId of graph.at(nodeId)?.outputs ?? []) {\n if (!remainingInputs.has(dependentId)) {\n continue;\n }\n const next = (remainingInputs.get(dependentId) ?? 0) - 1;\n remainingInputs.set(dependentId, next);\n if (next === 0) {\n ready.add(dependentId);\n }\n }\n\n enqueueSticky(children.get(nodeId) ?? []);\n }\n\n if (result.length < preferred.length) {\n const placed = new Set(result.map(cst => cst.id));\n for (const cst of preferred) {\n if (!placed.has(cst.id)) {\n result.push(cst);\n }\n }\n }\n\n return result;\n}\n\nfunction kernelPriority<T extends OrderableConstituenta>(\n items: readonly T[],\n graph: Graph<number>,\n parentOf: Map<number, number>\n): T[] {\n const byId = new Map(items.map(cst => [cst.id, cst]));\n const seen = new Set<number>();\n const result: T[] = [];\n\n function push(cst: T): void {\n if (seen.has(cst.id)) {\n return;\n }\n seen.add(cst.id);\n result.push(cst);\n }\n\n for (const cst of items) {\n if (cst.cst_type === CstType.BASE) {\n push(cst);\n }\n }\n for (const cst of items) {\n if (cst.cst_type === CstType.CONSTANT) {\n push(cst);\n }\n }\n for (const cst of items) {\n if ((graph.at(cst.id)?.inputs.length ?? 0) === 0) {\n push(cst);\n }\n }\n\n const kernelSeeds = items\n .filter(cst => {\n const parentId = parentOf.get(cst.id) ?? cst.id;\n const parent = byId.get(parentId);\n return (\n cst.cst_type === CstType.STRUCTURED ||\n cst.cst_type === CstType.AXIOM ||\n parent?.cst_type === CstType.STRUCTURED\n );\n })\n .map(cst => cst.id);\n const kernel = new Set<number>([...kernelSeeds, ...graph.expandAllInputs(kernelSeeds)]);\n for (const cst of items) {\n if (kernel.has(cst.id)) {\n push(cst);\n }\n }\n for (const cst of items) {\n push(cst);\n }\n return result;\n}\n","/**\n * Schema-level statistics and issue flags.\n */\n\nimport { TypeID, type Typification, ValueClass } from '../../rslang';\nimport { hasCstDiagnostic, RSDiagnosticCode } from '../diagnostics';\nimport { type Constituenta, CstStatus, CstType, type RSForm, type RSFormStats } from '../rsform';\n\nimport { isBasicConcept, isLogical } from './cst-type';\n\n/** Checks if {@link Constituenta} is a schema issue. */\nexport function isSchemaIssue(cst: Constituenta): boolean {\n return (\n (cst.diagnostics?.length ?? 0) > 0 || cst.status === CstStatus.INCORRECT || cst.status === CstStatus.INCALCULABLE\n );\n}\n\n/** Calculate statistics for {@link RSForm}. */\nexport function calculateSchemaStats(target: RSForm): RSFormStats {\n const stats: RSFormStats = {\n count_all: target.items.length,\n count_crucial: 0,\n step_complexity: 0,\n count_problematic: 0,\n count_homonyms: 0,\n count_formal_duplicates: 0,\n count_missing_basic_text: 0,\n count_type_mismatch: 0,\n count_incorrect: 0,\n count_property: 0,\n count_incalculable: 0,\n count_inherited: 0,\n count_text_term: 0,\n count_definition: 0,\n count_convention: 0,\n count_comment: 0,\n count_base: 0,\n count_constant: 0,\n count_structured: 0,\n count_axiom: 0,\n count_term: 0,\n count_function: 0,\n count_predicate: 0,\n count_statement: 0,\n count_nominal: 0\n };\n\n for (const cst of target.items) {\n if (cst.crucial) {\n stats.count_crucial += 1;\n }\n stats.step_complexity += calculateStepComplexity(cst);\n\n if (isSchemaIssue(cst)) {\n stats.count_problematic += 1;\n }\n if (hasCstDiagnostic(cst, RSDiagnosticCode.schemaHomonym)) {\n stats.count_homonyms += 1;\n }\n if (hasCstDiagnostic(cst, RSDiagnosticCode.schemaFormalDuplicate)) {\n stats.count_formal_duplicates += 1;\n }\n if (isMissingBasicText(cst)) {\n stats.count_missing_basic_text += 1;\n }\n if (cst.is_type_mismatch) {\n stats.count_type_mismatch += 1;\n }\n if (cst.status === CstStatus.INCORRECT) {\n stats.count_incorrect += 1;\n }\n if (cst.analysis?.valueClass === ValueClass.PROPERTY) {\n stats.count_property += 1;\n }\n if (cst.analysis?.success && cst.analysis.valueClass === null) {\n stats.count_incalculable += 1;\n }\n if (cst.is_inherited) {\n stats.count_inherited += 1;\n }\n if (cst.term_raw) {\n stats.count_text_term += 1;\n }\n if (cst.definition_raw) {\n stats.count_definition += 1;\n }\n if (isBasicConcept(cst.cst_type) && cst.convention) {\n stats.count_convention += 1;\n }\n if (!isBasicConcept(cst.cst_type) && !cst.convention) {\n stats.count_comment += 1;\n }\n\n switch (cst.cst_type) {\n case CstType.BASE:\n stats.count_base += 1;\n break;\n case CstType.CONSTANT:\n stats.count_constant += 1;\n break;\n case CstType.STRUCTURED:\n stats.count_structured += 1;\n break;\n case CstType.AXIOM:\n stats.count_axiom += 1;\n break;\n case CstType.TERM:\n stats.count_term += 1;\n break;\n case CstType.FUNCTION:\n stats.count_function += 1;\n break;\n case CstType.PREDICATE:\n stats.count_predicate += 1;\n break;\n case CstType.STATEMENT:\n stats.count_statement += 1;\n break;\n case CstType.NOMINAL:\n stats.count_nominal += 1;\n break;\n }\n }\n\n return stats;\n}\n\nfunction calculateStepComplexity(cst: Constituenta): number {\n if (cst.cst_type === CstType.AXIOM || cst.cst_type === CstType.NOMINAL || !isBasicConcept(cst.cst_type)) {\n return 0;\n }\n if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT || !cst.effectiveType) {\n return 1;\n }\n\n const type = cst.effectiveType as Typification;\n return calculateTypificationComplexity(type) + 1;\n}\n\nfunction calculateTypificationComplexity(type: Typification): number {\n switch (type.typeID) {\n case TypeID.basic:\n case TypeID.integer:\n case TypeID.anyTypification:\n return 0;\n case TypeID.tuple:\n return (\n type.factors.length + type.factors.reduce((sum, factor) => sum + calculateTypificationComplexity(factor), 0)\n );\n case TypeID.collection:\n if (type.base.typeID === TypeID.tuple) {\n let sum = 0;\n type.base.factors.forEach(factor => {\n sum += calculateTypificationComplexity(factor);\n });\n return sum + type.base.factors.length;\n } else if (type.base.typeID === TypeID.collection) {\n return calculateTypificationComplexity(type.base) + 1;\n }\n return 0;\n }\n}\n\n/** Non-logical basic concept missing convention and/or resolved term (trimmed). */\nfunction isMissingBasicText(cst: Constituenta): boolean {\n if (!isBasicConcept(cst.cst_type) || isLogical(cst.cst_type)) {\n return false;\n }\n return !cst.convention.trim() || !cst.term_resolved.trim();\n}\n","/**\n * Structure-path helpers for spawned constituents.\n */\n\nimport { TypeID, type TypePath, type Typification } from '../../rslang';\nimport { isTypification } from '../../rslang/semantic/typification';\nimport { applyPath } from '../../rslang/semantic/typification-api';\nimport { type Constituenta, type RSForm } from '../rsform';\n\n/**\n * Id to pass as `insert_after` when creating a new {@link Constituenta} spawned by `targetId`:\n * after the last existing child of that spawner, or after the spawner itself if none.\n */\nexport function inferNewSpawnPosition(schema: RSForm, targetId: number): number {\n let last: number | null = null;\n for (const cst of schema.items) {\n if (cst.spawner === targetId) {\n last = cst.id;\n }\n }\n return last ?? targetId;\n}\n\n/** Finds {@link Constituenta} by structure path. */\nexport function findCstByStructure(schema: RSForm, target: Constituenta, path: TypePath): Constituenta | null {\n const byId = schema.cstByID ?? new Map(schema.items.map(item => [item.id, item]));\n for (const cst of schema.items) {\n if (!cst.spawner_path) {\n continue;\n }\n const absolutePath = resolveAbsoluteSpawnerPath(cst, target.id, byId);\n if (absolutePath?.length === path.length && absolutePath.every((v, i) => v === path[i])) {\n return cst;\n }\n }\n return null;\n}\n\n/** Retrieves name for piece of target {@link Constituenta} structure. */\nexport function getStructureName(schema: RSForm, target: Constituenta, path: TypePath): string {\n const representation = findCstByStructure(schema, target, path);\n if (representation) {\n return `${representation.alias}: ${representation.term_resolved}`;\n }\n if (!isTypification(target.effectiveType)) {\n return '';\n }\n const type = applyPath(target.effectiveType as Typification, path);\n if (type?.typeID === TypeID.basic) {\n const cst = schema.cstByAlias.get(type.baseID);\n if (cst?.term_resolved) {\n return `${cst.alias}: ${cst.term_resolved}`;\n }\n }\n return '';\n}\n\nfunction resolveAbsoluteSpawnerPath(\n cst: Constituenta,\n targetId: number,\n byId: Map<number, Constituenta>\n): TypePath | null {\n if (!cst.spawner_path || cst.spawner == null) {\n return null;\n }\n if (cst.spawner === targetId) {\n return cst.spawner_path;\n }\n\n const visited = new Set<number>([cst.id]);\n let currentPath: number[] = [...cst.spawner_path];\n let currentSpawnerId: number | null = cst.spawner;\n\n while (currentSpawnerId != null) {\n if (currentSpawnerId === targetId) {\n return currentPath as TypePath;\n }\n if (visited.has(currentSpawnerId)) {\n return null;\n }\n visited.add(currentSpawnerId);\n\n const parent = byId.get(currentSpawnerId);\n if (!parent?.spawner_path || parent.spawner == null) {\n return null;\n }\n\n currentPath = [...parent.spawner_path, ...currentPath];\n currentSpawnerId = parent.spawner;\n }\n\n return null;\n}\n","/**\n * Constituenta substitution and post-import substitution remapping.\n */\n\nimport { type AliasMapping } from '../../rslang/api';\nimport { type Attribution, type Substitution } from '../rsform';\n\nimport { applyMappingToConstituents, type ConstituentaMappableFields } from './alias';\nimport { remapAttributionsUnderSubstitution } from './attribution';\n\n/** Result of applying substitutions to a schema fragment. */\nexport interface SubstitutionResult<T> {\n items: T[];\n attributions: Attribution[];\n deletedIds: Set<number>;\n /** Replacement constituent ids (survivors referenced by substitutions). */\n replacementIds: number[];\n}\n\n/**\n * Apply constituenta substitutions: remap attributions, drop originals, rewrite aliases in survivors.\n * Does not resolve texts — call {@link resolveAllConstituentTexts} afterwards.\n */\nexport function applyConstituentSubstitutions<T extends ConstituentaMappableFields & { id: number; alias: string }>(\n items: readonly T[],\n attributions: readonly Attribution[],\n substitutions: readonly Substitution[]\n): SubstitutionResult<T> {\n if (substitutions.length === 0) {\n return {\n items: [...items],\n attributions: attributions.map(attr => ({ ...attr })),\n deletedIds: new Set(),\n replacementIds: []\n };\n }\n\n const byId = new Map(items.map(cst => [cst.id, cst]));\n const mapping: AliasMapping = {};\n const deletedIds = new Set<number>();\n const origToSub = new Map<number, number>();\n const replacementIds: number[] = [];\n\n for (const { original, substitution } of substitutions) {\n const originalCst = byId.get(original);\n const substitutionCst = byId.get(substitution);\n if (!originalCst || !substitutionCst) {\n throw new Error(`applyConstituentSubstitutions: unknown constituenta ${original} -> ${substitution}`);\n }\n mapping[originalCst.alias] = substitutionCst.alias;\n deletedIds.add(original);\n origToSub.set(original, substitution);\n replacementIds.push(substitution);\n }\n\n const nextItems = items.filter(cst => !deletedIds.has(cst.id));\n applyMappingToConstituents(nextItems, mapping, false);\n\n return {\n items: nextItems,\n attributions: remapAttributionsUnderSubstitution(attributions, origToSub),\n deletedIds,\n replacementIds\n };\n}\n\n/**\n * Remap substitution endpoints after source constituents were inserted under new ids.\n * If {@link original} was imported, map it; otherwise map {@link substitution}.\n */\nexport function remapSubstitutionsAfterImport(\n substitutions: readonly Substitution[],\n sourceIdSet: ReadonlySet<number>,\n idMap: Readonly<Record<number, number>>\n): Substitution[] {\n return substitutions.map(sub => {\n if (sourceIdSet.has(sub.original)) {\n return { original: idMap[sub.original], substitution: sub.substitution };\n }\n return { original: sub.original, substitution: idMap[sub.substitution] };\n });\n}\n","/**\n * Cascade resolution of constituenta term/definition entity references.\n * Matches backend {@code RSForm.resolve_all_text} / {@code resolve_term_change}.\n */\n\nimport { type TermContext } from '../../cctext/language';\nimport { extractEntities, parseGrammemes, resolveTextReferences } from '../../cctext/language-api';\nimport { Graph } from '../../graph';\n\nimport { type ResolvableConstituenta } from './types';\n\n/** Options controlling which texts to re-resolve after an edit. */\nexport interface TextChangeOptions {\n termChanged: boolean;\n termRawChanged: boolean;\n definitionRawChanged: boolean;\n clearTargetForms: boolean;\n}\n\n/** Build term-reference graph: referenced constituent → dependent (backend {@code graph_term}). */\nexport function buildTermReferenceGraph(items: readonly ResolvableConstituenta[]): Graph<number> {\n return buildReferenceGraph(items, 'term_raw');\n}\n\n/** Build definition-reference graph: referenced constituent → dependent (backend {@code graph_text}). */\nexport function buildDefinitionReferenceGraph(items: readonly ResolvableConstituenta[]): Graph<number> {\n return buildReferenceGraph(items, 'definition_raw');\n}\n\n/** Resolve all term and definition texts in topological order. Mutates items in place. */\nexport function resolveAllConstituentTexts(items: ResolvableConstituenta[]): void {\n const graphTerm = buildTermReferenceGraph(items);\n const idToItem = new Map(items.map(item => [item.id, item]));\n const context = buildTermContext(items);\n\n for (const id of graphTerm.topologicalOrder()) {\n const row = idToItem.get(id);\n if (!row) {\n continue;\n }\n const resolved = resolveTextReferences(row.term_raw, context);\n if (resolved !== row.term_resolved) {\n row.term_resolved = resolved;\n row.term_forms = [];\n context[row.alias] = { nominal: row.term_resolved, forms: [] };\n }\n }\n\n for (const row of items) {\n row.definition_resolved = resolveTextReferences(row.definition_raw, context);\n }\n}\n\n/**\n * Resolve texts after a single constituent change, cascading dependents when the term changed.\n * Mutates items in place.\n */\nexport function resolveConstituentTextChange(\n items: ResolvableConstituenta[],\n targetID: number,\n options: TextChangeOptions\n): void {\n const idToItem = new Map(items.map(item => [item.id, item]));\n const target = idToItem.get(targetID);\n if (!target) {\n throw new Error(`resolveConstituentTextChange: unknown target ${targetID}`);\n }\n\n const context = buildTermContext(items);\n if (options.termRawChanged) {\n target.term_resolved = resolveTextReferences(target.term_raw, context);\n if (options.clearTargetForms) {\n target.term_forms = [];\n }\n context[target.alias] = toContextItem(target);\n } else if (options.termChanged) {\n context[target.alias] = toContextItem(target);\n }\n\n if (options.definitionRawChanged && !options.termChanged) {\n target.definition_resolved = resolveTextReferences(target.definition_raw, context);\n }\n\n if (!options.termChanged) {\n return;\n }\n\n const graphTerm = buildTermReferenceGraph(items);\n const graphText = buildDefinitionReferenceGraph(items);\n const expansion = graphTerm.expandAllOutputs([targetID]);\n const expansionSet = new Set(expansion);\n\n for (const id of graphTerm.topologicalOrder()) {\n if (!expansionSet.has(id)) {\n continue;\n }\n const expanded = idToItem.get(id);\n if (!expanded) {\n continue;\n }\n const resolved = resolveTextReferences(expanded.term_raw, context);\n if (resolved !== expanded.term_resolved) {\n expanded.term_resolved = resolved;\n expanded.term_forms = [];\n context[expanded.alias] = { nominal: expanded.term_resolved, forms: [] };\n }\n }\n\n const updateDefs = new Set([targetID, ...expansion, ...graphText.expandAllOutputs([targetID, ...expansion])]);\n for (const item of items) {\n if (updateDefs.has(item.id)) {\n item.definition_resolved = resolveTextReferences(item.definition_raw, context);\n }\n }\n}\n\n// ====== Internals =======\n\nfunction buildReferenceGraph(\n items: readonly ResolvableConstituenta[],\n field: 'definition_raw' | 'term_raw'\n): Graph<number> {\n const graph = new Graph<number>();\n const idByAlias = new Map(items.map(row => [row.alias, row.id]));\n for (const row of items) {\n graph.addNode(row.id);\n }\n for (const row of items) {\n for (const entity of extractEntities(row[field])) {\n const source = idByAlias.get(entity);\n if (source !== undefined) {\n graph.addEdge(source, row.id);\n }\n }\n }\n return graph;\n}\n\nfunction buildTermContext(items: readonly ResolvableConstituenta[]): TermContext {\n const context: TermContext = {};\n for (const row of items) {\n context[row.alias] = toContextItem(row);\n }\n return context;\n}\n\nfunction toContextItem(row: ResolvableConstituenta): TermContext[string] {\n return {\n nominal: row.term_resolved,\n forms: row.term_forms.map(form => ({ text: form.text, grams: parseGrammemes(form.tags) }))\n };\n}\n","/**\n * Schema embedding (synthesis): insert constituents from a source schema into a receiver,\n * then apply an identification (substitution) table.\n *\n * Mirrors backend `inline_synthesis` / `insert_from` + `substitute`\n * (Portal UI: «Встраивание схемы»).\n */\n\nimport { type AliasMapping } from '../../rslang/api';\nimport { type LibraryItem } from '../library';\nimport { type Attribution, type CstType, type RSForm, type Substitution } from '../rsform';\n\nimport { allocateImportAliases, applyMappingToConstituents, type ConstituentaMappableFields } from './alias';\nimport { importAttributions } from './attribution';\nimport { applyConstituentSubstitutions, remapSubstitutionsAfterImport } from './substitution';\nimport { resolveAllConstituentTexts } from './text-resolution';\nimport { type AliasTypedConstituenta, type ResolvableConstituenta } from './types';\n\n/** Constituent shape required for embedding / synthesis transforms. */\nexport type SynthesizableConstituenta = ConstituentaMappableFields &\n ResolvableConstituenta &\n AliasTypedConstituenta & {\n id: number;\n alias: string;\n cst_type: CstType;\n };\n\n/** Input for {@link inlineSynthesis}. */\nexport interface InlineSynthesisInput<T extends SynthesizableConstituenta> {\n /** Receiver schema constituents (order preserved; imports append). */\n receiverItems: readonly T[];\n /** Receiver attributions (default empty). */\n receiverAttributions?: readonly Attribution[];\n /**\n * Source constituents to insert (already filtered to the desired subset).\n * Cloned; originals are not mutated.\n */\n sourceItems: readonly T[];\n /** Source attributions whose both endpoints are among {@link sourceItems}. */\n sourceAttributions?: readonly Attribution[];\n /**\n * Identification table using pre-import ids:\n * one endpoint is a source id, the other a receiver id\n * (same rules as backend embedding / InlineSynthesis).\n */\n substitutions?: readonly Substitution[];\n /** Next free numeric id for inserted constituents. */\n nextId: number;\n}\n\n/** Result of {@link inlineSynthesis}. */\nexport interface InlineSynthesisResult<T extends SynthesizableConstituenta> {\n items: T[];\n attributions: Attribution[];\n /** Updated next-id after inserts. */\n nextId: number;\n /** Source id → inserted id. */\n idMap: Record<number, number>;\n /** Alias remapping applied to imported constituents (empty when receiver was empty). */\n aliasMapping: AliasMapping;\n /** Ids removed by substitutions. */\n deletedIds: Set<number>;\n /** Ids of newly inserted constituents (before any were deleted by substitutions). */\n insertedIds: number[];\n /** Survivor ids referenced by applied substitutions. */\n replacementIds: number[];\n}\n\n/**\n * Embed {@link InlineSynthesisInput.sourceItems} into the receiver and apply substitutions.\n * Resolves term/definition entity references on the result.\n * Does not mutate inputs.\n */\nexport function inlineSynthesis<T extends SynthesizableConstituenta>(\n input: InlineSynthesisInput<T>\n): InlineSynthesisResult<T> {\n const sourceItems = input.sourceItems;\n if (sourceItems.length === 0) {\n return {\n items: input.receiverItems.map(item => structuredClone(item)),\n attributions: (input.receiverAttributions ?? []).map(attr => ({ ...attr })),\n nextId: input.nextId,\n idMap: {},\n aliasMapping: {},\n deletedIds: new Set(),\n insertedIds: [],\n replacementIds: []\n };\n }\n\n const receiverItems = input.receiverItems.map(item => structuredClone(item));\n let attributions = (input.receiverAttributions ?? []).map(attr => ({ ...attr }));\n const aliasMapping = allocateImportAliases(receiverItems, sourceItems);\n const idMap: Record<number, number> = {};\n const inserted: T[] = [];\n const sourceIdSet = new Set(sourceItems.map(cst => cst.id));\n let nextId = input.nextId;\n\n for (const cst of sourceItems) {\n const newId = nextId;\n nextId += 1;\n idMap[cst.id] = newId;\n\n const cloned = structuredClone(cst);\n cloned.id = newId;\n if (Object.keys(aliasMapping).length > 0) {\n cloned.alias = aliasMapping[cst.alias];\n applyMappingToConstituents([cloned], aliasMapping, false);\n }\n inserted.push(cloned);\n }\n\n attributions = importAttributions(input.sourceAttributions ?? [], sourceIdSet, idMap, attributions);\n const items = receiverItems.concat(inserted);\n resolveAllConstituentTexts(items);\n\n const substitutions = input.substitutions ?? [];\n if (substitutions.length === 0) {\n return {\n items,\n attributions,\n nextId,\n idMap,\n aliasMapping,\n deletedIds: new Set(),\n insertedIds: inserted.map(cst => cst.id),\n replacementIds: []\n };\n }\n\n const remapped = remapSubstitutionsAfterImport(substitutions, sourceIdSet, idMap);\n const substituted = applyConstituentSubstitutions(items, attributions, remapped);\n resolveAllConstituentTexts(substituted.items);\n\n return {\n items: substituted.items,\n attributions: substituted.attributions,\n nextId,\n idMap,\n aliasMapping,\n deletedIds: substituted.deletedIds,\n insertedIds: inserted.map(cst => cst.id),\n replacementIds: substituted.replacementIds\n };\n}\n\n/** Sorts library items relevant for schema embedding with specified {@link RSForm}. */\nexport function sortItemsForInlineSynthesis(receiver: RSForm, items: readonly LibraryItem[]): LibraryItem[] {\n const result = items.filter(item => item.location === receiver.location);\n for (const item of items) {\n if (item.visible && item.owner === receiver.owner && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (item.visible && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (!result.includes(item)) {\n result.push(item);\n }\n }\n return result;\n}\n","/**\n * Pure constituenta list transforms: reorder, move, insert position.\n */\n\n/** Rebuild an item list following {@link orderedIds}. Throws if an id is missing. */\nexport function reorderItemsByIds<T extends { id: number }>(items: readonly T[], orderedIds: readonly number[]): T[] {\n const byId = new Map(items.map(item => [item.id, item]));\n return orderedIds.map(id => {\n const item = byId.get(id);\n if (!item) {\n throw new Error(`reorderItemsByIds: missing id ${id}`);\n }\n return item;\n });\n}\n\n/**\n * Move a subset of ids within an ordered id list.\n * {@link moveTo} is clamped to `[0, rest.length]` (index among non-moving items).\n */\nexport function moveIdsInOrder(ids: readonly number[], moving: readonly number[], moveTo: number): number[] {\n const movingSet = new Set(moving);\n const rest = ids.filter(id => !movingSet.has(id));\n const movingItems = ids.filter(id => movingSet.has(id));\n const clamped = Math.max(0, Math.min(moveTo, rest.length));\n return [...rest.slice(0, clamped), ...movingItems, ...rest.slice(clamped)];\n}\n\n/** Insert {@link item} after {@link insertAfter}, or append when null/undefined/missing. Mutates {@link items}. */\nexport function insertItemAfter<T extends { id: number }>(\n items: T[],\n item: T,\n insertAfter: number | null | undefined\n): void {\n if (insertAfter === null || insertAfter === undefined) {\n items.push(item);\n return;\n }\n const idx = items.findIndex(row => row.id === insertAfter);\n const insertAt = idx === -1 ? items.length : idx + 1;\n items.splice(insertAt, 0, item);\n}\n","/**\n * Module: Compact diagnostics for constituents (schema and model issue codes).\n */\n\nimport { type Graph } from '../graph';\nimport { labelType } from '../rslang/labels';\n\nimport { type Constituenta, type CstType } from './rsform';\nimport { isBasicConcept, isLogical } from './rsform-api';\nimport { EvalStatus } from './rsmodel';\n\n/** Origin of a diagnostic. */\nexport const DiagnosticKind = {\n EXPRESSION: 'expression',\n SCHEMA: 'schema',\n MODEL: 'model'\n} as const;\nexport type DiagnosticKind = (typeof DiagnosticKind)[keyof typeof DiagnosticKind];\n\n/** Schema and model diagnostic codes (same numeric format as {@link RSErrorCode}). */\nexport const RSDiagnosticCode = {\n schemaHomonym: 0x8901,\n schemaFormalDuplicate: 0x8902,\n schemaMissingConvention: 0x8903,\n schemaMissingTerm: 0x8904,\n schemaTypeMismatch: 0x8905,\n schemaDependencyCycle: 0x8906,\n\n modelEmpty: 0x8910,\n modelAxiomFalse: 0x8911,\n modelInvalidData: 0x8912,\n modelEvalFail: 0x8913\n} as const;\nexport type RSDiagnosticCode = (typeof RSDiagnosticCode)[keyof typeof RSDiagnosticCode];\n\n/** Compact diagnostic stored on {@link Constituenta} after schema loading. */\nexport interface CstDiagnostic {\n kind: DiagnosticKind;\n code: number;\n /** Positional message arguments (per-code; homonyms/duplicates use `[aliases]`). */\n params?: readonly string[];\n}\n\n/** Whether a constituent has a schema/model diagnostic with the given code. */\nexport function hasCstDiagnostic(cst: Constituenta, code: RSDiagnosticCode): boolean {\n return cst.diagnostics?.some(item => item.code === code) ?? false;\n}\n\n/**\n * Populate `diagnostics` on each constituent (homonyms, duplicates, metadata, type mismatch, cycles).\n *\n * Requires normalized formal definitions for duplicate detection (same as Portal loader).\n * When `graph` is provided, dependency cycles are reported as {@link RSDiagnosticCode.schemaDependencyCycle}.\n */\nexport function assignSchemaDiagnostics(\n items: Constituenta[],\n resolveAlias: (id: number) => string,\n normalizedDefinitions: ReadonlyMap<number, string>,\n graph?: Graph\n): void {\n const homonymById = detectHomonymDiagnostics(items, resolveAlias);\n const duplicateById = detectFormalDuplicateDiagnostics(items, resolveAlias, normalizedDefinitions);\n const cycleById = graph ? detectDependencyCycleDiagnostics(graph, resolveAlias) : new Map<number, CstDiagnostic>();\n\n for (const cst of items) {\n const diagnostics: CstDiagnostic[] = [];\n const cycle = cycleById.get(cst.id);\n if (cycle) {\n diagnostics.push(cycle);\n }\n const homonym = homonymById.get(cst.id);\n if (homonym) {\n diagnostics.push(homonym);\n }\n const duplicate = duplicateById.get(cst.id);\n if (duplicate) {\n diagnostics.push(duplicate);\n }\n diagnostics.push(...collectLocalSchemaDiagnostics(cst));\n cst.diagnostics = diagnostics;\n }\n}\n\n/**\n * Format a closed dependency cycle as `A → B → A`.\n *\n * Rotates the path to start at the lexicographically smallest alias so the same\n * cycle always renders identically regardless of graph traversal order.\n *\n * @param aliases Closed or open alias path from {@link Graph.findCycles}.\n * @returns Human-readable cycle text joined with ` → `.\n */\nexport function formatDependencyCycle(aliases: readonly string[]): string {\n if (aliases.length < 2) {\n return aliases.join(' → ');\n }\n\n const closed = aliases[0] === aliases[aliases.length - 1];\n const open = closed ? aliases.slice(0, -1) : [...aliases];\n if (open.length === 0) {\n return aliases.join(' → ');\n }\n\n let bestStart = 0;\n for (let index = 1; index < open.length; index++) {\n const alias = open[index];\n const bestAlias = open[bestStart];\n if (alias !== undefined && bestAlias !== undefined && alias < bestAlias) {\n bestStart = index;\n }\n }\n const rotated = [...open.slice(bestStart), ...open.slice(0, bestStart)];\n if (closed) {\n const first = rotated[0];\n if (first !== undefined) {\n rotated.push(first);\n }\n }\n return rotated.join(' → ');\n}\n\n/**\n * Map each node id that participates in a dependency cycle to a schema diagnostic.\n *\n * `params[0]` is the closed cycle path (`F3 → P1 → F3`).\n *\n * @param graph Constituent dependency graph (provider → dependent edges).\n * @param resolveAlias Maps node id to display alias for cycle formatting.\n * @returns One {@link CstDiagnostic} per node on each cyclic SCC.\n */\nexport function detectDependencyCycleDiagnostics(\n graph: Graph,\n resolveAlias: (id: number) => string\n): Map<number, CstDiagnostic> {\n const result = new Map<number, CstDiagnostic>();\n for (const cycle of graph.findCycles()) {\n if (cycle.length < 2) {\n continue;\n }\n const aliases = cycle.map(id => resolveAlias(id));\n const cycleText = formatDependencyCycle(aliases);\n const memberIds = new Set(cycle);\n for (const id of memberIds) {\n result.set(id, {\n kind: DiagnosticKind.SCHEMA,\n code: RSDiagnosticCode.schemaDependencyCycle,\n params: [cycleText]\n });\n }\n }\n return result;\n}\n\n/** Map a model evaluation status to a compact diagnostic, or `null` when not an issue. */\nexport function modelStatusCstDiagnostic(status: EvalStatus, cstType: CstType): CstDiagnostic | null {\n const code = modelStatusToCode(status, cstType);\n if (code === null) {\n return null;\n }\n return { kind: DiagnosticKind.MODEL, code, params: [String(status)] };\n}\n\nfunction collectLocalSchemaDiagnostics(cst: Constituenta): CstDiagnostic[] {\n const result: CstDiagnostic[] = [];\n if (cst.is_type_mismatch) {\n result.push({\n kind: DiagnosticKind.SCHEMA,\n code: RSDiagnosticCode.schemaTypeMismatch,\n params: [cst.typification_manual, labelType(cst.analysis.type)]\n });\n }\n if (isBasicConcept(cst.cst_type) && !isLogical(cst.cst_type)) {\n if (!cst.convention.trim()) {\n result.push({ kind: DiagnosticKind.SCHEMA, code: RSDiagnosticCode.schemaMissingConvention });\n }\n if (!cst.term_resolved.trim()) {\n result.push({ kind: DiagnosticKind.SCHEMA, code: RSDiagnosticCode.schemaMissingTerm });\n }\n }\n return result;\n}\n\nfunction detectGroupedAliasDiagnostics(\n items: Constituenta[],\n resolveAlias: (id: number) => string,\n groupKey: (cst: Constituenta) => string | undefined,\n code: RSDiagnosticCode\n): Map<number, CstDiagnostic> {\n const groups = new Map<string, Constituenta[]>();\n for (const cst of items) {\n const key = groupKey(cst);\n if (!key) {\n continue;\n }\n const group = groups.get(key) ?? [];\n group.push(cst);\n groups.set(key, group);\n }\n\n const result = new Map<number, CstDiagnostic>();\n for (const group of groups.values()) {\n if (group.length <= 1) {\n continue;\n }\n for (const cst of group) {\n const aliases = group\n .filter(other => other.id !== cst.id)\n .map(other => resolveAlias(other.id))\n .join(', ');\n result.set(cst.id, {\n kind: DiagnosticKind.SCHEMA,\n code,\n params: [aliases]\n });\n }\n }\n return result;\n}\n\nfunction detectHomonymDiagnostics(\n items: Constituenta[],\n resolveAlias: (id: number) => string\n): Map<number, CstDiagnostic> {\n return detectGroupedAliasDiagnostics(\n items,\n resolveAlias,\n cst => {\n const key = cst.term_resolved.trim().toLocaleLowerCase();\n return key === '' ? undefined : key;\n },\n RSDiagnosticCode.schemaHomonym\n );\n}\n\nfunction detectFormalDuplicateDiagnostics(\n items: Constituenta[],\n resolveAlias: (id: number) => string,\n normalizedDefinitions: ReadonlyMap<number, string>\n): Map<number, CstDiagnostic> {\n return detectGroupedAliasDiagnostics(\n items,\n resolveAlias,\n cst => normalizedDefinitions.get(cst.id),\n RSDiagnosticCode.schemaFormalDuplicate\n );\n}\n\nfunction modelStatusToCode(status: EvalStatus, cstType: CstType): RSDiagnosticCode | null {\n switch (status) {\n case EvalStatus.EMPTY:\n return isBasicConcept(cstType) ? RSDiagnosticCode.modelEmpty : null;\n case EvalStatus.AXIOM_FALSE:\n return RSDiagnosticCode.modelAxiomFalse;\n case EvalStatus.INVALID_DATA:\n return RSDiagnosticCode.modelInvalidData;\n case EvalStatus.EVAL_FAIL:\n return RSDiagnosticCode.modelEvalFail;\n default:\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA,MAAM,kBAA2C;EAC9C,QAAQ,UAAU;EAClB,QAAQ,OAAO;EACf,QAAQ,WAAW;EACnB,QAAQ,aAAa;EACrB,QAAQ,QAAQ;EAChB,QAAQ,OAAO;EACf,QAAQ,WAAW;EACnB,QAAQ,YAAY;EACpB,QAAQ,YAAY;AACvB;;AAGA,MAAM,oBAA+C;EAClD,QAAQ,UAAU,SAAS;EAC3B,QAAQ,OAAO,SAAS;EACxB,QAAQ,WAAW,SAAS;EAC5B,QAAQ,aAAa,SAAS;EAC9B,QAAQ,OAAO,SAAS;EACxB,QAAQ,WAAW,SAAS;EAC5B,QAAQ,QAAQ,SAAS;EACzB,QAAQ,YAAY,SAAS;EAC7B,QAAQ,YAAY,SAAS;AAChC;;AAGA,SAAgB,iBAAiB,MAAuB;CACtD,OAAO,gBAAgB;AACzB;;AAGA,SAAgB,aAAa,MAA8B;CACzD,IAAI,KAAK,WAAW,GAClB,OAAO;CAET,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,eAAe,GACzD,IAAI,SAAS,QACX,OAAO;CAGX,OAAO;AACT;;AAGA,SAAgB,WAAW,MAAe,aAAsB,OAAiB;CAC/E,IAAI,YACF,OAAO,SAAS;CAElB,OAAO,kBAAkB;AAC3B;;AAGA,SAAgB,cAAc,KAA4B;CACxD,OAAO,IAAI,aAAa,QAAQ,YAAY,IAAI,aAAa,QAAQ,aAAa,IAAI,aAAa,QAAQ;AAC7G;;A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