@rsconcept/rstool 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/skills/README.md CHANGED
@@ -4,14 +4,12 @@ Each skill lives in its own subdirectory: `skills/<skill-name>/SKILL.md` (plus r
4
4
 
5
5
  ## Layout
6
6
 
7
- | Path | Role |
8
- | :--- | :--- |
9
- | `INSTALL.md` | **Agent procedure** after `npm install` |
10
- | `rstool-helper/SKILL.md` | Thin **entry** skill — copy into the project’s agent skills folder (see `INSTALL.md`) |
11
- | `rstool-helper/GUIDE.md` | Canonical workflow and language primer |
12
- | `rstool-helper/REFERENCE.md` | API, stdio, contract |
13
- | `rstool-helper/EXAMPLES.md` | Worked examples and pitfalls |
14
- | `../docs/*.md` | Language reference (DOMAIN, SYNTAX, DIAGNOSTICS, …) |
7
+ - `INSTALL.md`: agent procedure after `npm install`
8
+ - `rstool-helper/SKILL.md`: thin entry skill — copy into the project’s agent skills folder (see `INSTALL.md`)
9
+ - `rstool-helper/GUIDE.md`: canonical workflow and language primer
10
+ - `rstool-helper/REFERENCE.md`: API, stdio, contract
11
+ - `rstool-helper/EXAMPLES.md`: worked examples and pitfalls
12
+ - `../docs/*.md`: language reference (DOMAIN, SYNTAX, DIAGNOSTICS, …)
15
13
 
16
14
  ## npm workflow
17
15
 
@@ -1,16 +1,10 @@
1
- # rstool — worked examples
1
+ # rstool Examples
2
2
 
3
- Install first:
3
+ Short examples for agents. For full scripts, see `../../examples/`.
4
4
 
5
- ```bash
6
- npm install @rsconcept/rstool
7
- ```
8
-
9
- ## Kinship-lite: structure vs term
10
-
11
- `S1` carries **typification** `ℬ(X1×X1)` (pairs over people); `D1` is a **definition** `Pr1(S1)` (parents). Do not put `X1×X1` on a `term` — that is the full Cartesian product.
5
+ ## Minimal Session
12
6
 
13
- ## In-process
7
+ `S1` carries typification `ℬ(X1×X1)` for relation pairs. `D1` computes `Pr1(S1)`. Do not put bare `X1×X1` on a `term` when you mean a relation structure.
14
8
 
15
9
  ```ts
16
10
  import { CstType, RSToolAgent } from '@rsconcept/rstool';
@@ -18,12 +12,10 @@ import { CstType, RSToolAgent } from '@rsconcept/rstool';
18
12
  const tool = new RSToolAgent();
19
13
  const { sessionId } = tool.createSession();
20
14
 
21
- // Base set — formal must be empty
22
15
  tool.addOrUpdateConstituenta(sessionId, {
23
16
  draft: { id: 1, alias: 'X1', cstType: CstType.BASE, definitionFormal: '' }
24
17
  });
25
18
 
26
- // Structure: typification of parent–child pairs (undefined; convention in real schemas)
27
19
  tool.addOrUpdateConstituenta(sessionId, {
28
20
  draft: {
29
21
  id: 2,
@@ -34,32 +26,33 @@ tool.addOrUpdateConstituenta(sessionId, {
34
26
  }
35
27
  });
36
28
 
37
- // Term: derived definition — first projection of S1
38
29
  const { state, diagnostics } = tool.addOrUpdateConstituenta(sessionId, {
39
30
  draft: { id: 3, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
40
31
  });
41
32
 
42
33
  console.log(state.analysis.success, diagnostics.length);
34
+ ```
43
35
 
44
- // Scratch check
45
- tool.analyzeExpression(sessionId, {
46
- expression: '(',
47
- cstType: CstType.TERM
48
- }); // success: false, syntax diagnostics
36
+ ## Analyze Before Upsert
49
37
 
50
- // Set base binding and evaluate a scratch arithmetic term
51
- tool.setConstituentaValue(sessionId, {
52
- target: 1,
53
- value: { 0: 'zero', 1: 'one' }
54
- });
55
- const evalResult = tool.evaluateExpression(sessionId, {
56
- expression: '1+2',
38
+ Use scratch analysis when syntax or `cstType` is uncertain.
39
+
40
+ ```ts
41
+ const analysis = tool.analyzeExpression(sessionId, {
42
+ expression: 'Pr1(S1)',
57
43
  cstType: CstType.TERM
58
44
  });
59
- console.log(evalResult.success, evalResult.value); // true, 3
45
+
46
+ if (!analysis.success) {
47
+ console.log(analysis.diagnostics.map(({ code, from, to }) => ({ code, from, to })));
48
+ }
60
49
  ```
61
50
 
62
- ## Wrapper client
51
+ Fix the reported `from` / `to` range, then re-run analysis. Do not retry unchanged input.
52
+
53
+ ## Wrapper Client
54
+
55
+ Use the wrapper when the agent talks to a separate `rstool-wrapper` process.
63
56
 
64
57
  ```ts
65
58
  import { CstType } from '@rsconcept/rstool';
@@ -69,29 +62,13 @@ const client = new RSToolWrapperClient();
69
62
  await client.waitUntilReady();
70
63
 
71
64
  const { sessionId } = await client.call<{ sessionId: string }>('createSession');
65
+
72
66
  await client.call('addOrUpdateConstituenta', {
73
67
  sessionId,
74
68
  input: {
75
69
  draft: { id: 1, alias: 'X1', cstType: CstType.BASE, definitionFormal: '' }
76
70
  }
77
71
  });
78
- await client.call('addOrUpdateConstituenta', {
79
- sessionId,
80
- input: {
81
- draft: {
82
- id: 2,
83
- alias: 'S1',
84
- cstType: CstType.STRUCTURED,
85
- definitionFormal: 'ℬ(X1×X1)'
86
- }
87
- }
88
- });
89
- await client.call('addOrUpdateConstituenta', {
90
- sessionId,
91
- input: {
92
- draft: { id: 3, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
93
- }
94
- });
95
72
 
96
73
  const diagnostics = await client.call('listDiagnostics', { sessionId });
97
74
  console.log(diagnostics);
@@ -99,34 +76,48 @@ console.log(diagnostics);
99
76
  await client.close();
100
77
  ```
101
78
 
102
- ## Manual stdio
79
+ Manual stdio is one JSON request per line:
103
80
 
104
- Start wrapper in one terminal:
105
-
106
- ```bash
107
- npx rstool-wrapper
81
+ ```jsonl
82
+ { "id": "1", "method": "createSession", "params": {} }
83
+ { "id": "2", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 1, "alias": "X1", "cstType": "basic", "definitionFormal": "" } } } }
108
84
  ```
109
85
 
110
- Paste one JSON request per line after the ready line appears:
86
+ ## Export / Import
111
87
 
112
- ```json
113
- { "id": "1", "method": "createSession", "params": {} }
88
+ ```ts
89
+ const payload = tool.exportSession(sessionId);
90
+ const restored = tool.importSession(payload);
114
91
  ```
115
92
 
116
- Use the returned `sessionId` in subsequent lines:
93
+ Export includes session state and model values.
117
94
 
118
- ```json
119
- { "id": "2", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 1, "alias": "X1", "cstType": "basic", "definitionFormal": "" } } } }
120
- { "id": "3", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 2, "alias": "S1", "cstType": "structure", "definitionFormal": "ℬ(X1×X1)" } } } }
121
- { "id": "4", "method": "addOrUpdateConstituenta", "params": { "sessionId": "...", "input": { "draft": { "id": 3, "alias": "D1", "cstType": "term", "definitionFormal": "Pr1(S1)" } } } }
122
- { "id": "5", "method": "listDiagnostics", "params": { "sessionId": "..." } }
95
+ ## Evaluation
96
+
97
+ ```ts
98
+ tool.setConstituentaValue(sessionId, {
99
+ target: 1,
100
+ value: { 0: 'zero', 1: 'one' }
101
+ });
102
+
103
+ const scratch = tool.evaluateExpression(sessionId, {
104
+ expression: '1+2',
105
+ cstType: CstType.TERM
106
+ });
107
+
108
+ console.log(scratch.success, scratch.value); // true, 3
123
109
  ```
124
110
 
125
- ## Export a small RSForm session
111
+ For stored definitions, set values for `basic`, `constant`, and `structure`, then call `evaluateConstituenta` or `recalculateModel`.
112
+
113
+ ## Semantic Smoke Test
114
+
115
+ When syntax is valid but meaning is uncertain, build a tiny model and assert the value.
126
116
 
127
117
  ```ts
128
- import { CstType, RSToolAgent } from '@rsconcept/rstool';
118
+ import { CstType, EvalStatus, RSToolAgent } from '@rsconcept/rstool';
129
119
 
120
+ const TUPLE_ID = -111;
130
121
  const tool = new RSToolAgent();
131
122
  const { sessionId } = tool.createSession();
132
123
 
@@ -134,62 +125,48 @@ tool.addOrUpdateConstituenta(sessionId, {
134
125
  draft: { id: 1, alias: 'X1', cstType: CstType.BASE, definitionFormal: '' }
135
126
  });
136
127
  tool.addOrUpdateConstituenta(sessionId, {
137
- draft: { id: 2, alias: 'C1', cstType: CstType.CONSTANT, definitionFormal: '' }
138
- });
139
- tool.addOrUpdateConstituenta(sessionId, {
140
- draft: {
141
- id: 3,
142
- alias: 'S1',
143
- cstType: CstType.STRUCTURED,
144
- definitionFormal: 'ℬ(X1×X1)',
145
- convention: 'Pairs (parent, child) over X1.'
146
- }
147
- });
148
- tool.addOrUpdateConstituenta(sessionId, {
149
- draft: { id: 4, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
128
+ draft: { id: 2, alias: 'S1', cstType: CstType.STRUCTURED, definitionFormal: 'ℬ(X1×X1)' }
150
129
  });
151
130
  tool.addOrUpdateConstituenta(sessionId, {
152
- draft: { id: 5, alias: 'A1', cstType: CstType.AXIOM, definitionFormal: '1=1' }
131
+ draft: { id: 3, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
153
132
  });
154
133
 
155
- const payload = tool.exportSession(sessionId);
156
- console.log(payload);
157
- ```
158
-
159
- ## Model and evaluation
160
-
161
- Full kinship modeling (`S1` values as tuples, `Pr1(S1)`, …): `examples/build-kinship-rsmodel.ts`.
162
-
163
- Minimal evaluation after bindings:
164
-
165
- ```ts
166
- tool.setConstituentaValue(sessionId, {
167
- target: 1,
168
- value: { 0: 'zero', 1: 'one' }
134
+ tool.setConstituentaValues(sessionId, {
135
+ items: [
136
+ { target: 1, value: { 0: 'ann', 1: 'bob', 2: 'cat' } },
137
+ {
138
+ target: 2,
139
+ value: [
140
+ [TUPLE_ID, 0, 1],
141
+ [TUPLE_ID, 0, 2]
142
+ ]
143
+ }
144
+ ]
169
145
  });
170
146
 
171
- const evaluated = tool.evaluateConstituenta(sessionId, {
172
- constituentId: 4 // D1 = Pr1(S1); needs S1 interpreted — see kinship example
173
- });
174
- console.log(evaluated.success, evaluated.value);
147
+ const result = tool.evaluateConstituenta(sessionId, { constituentId: 3 });
148
+
149
+ if (!result.success || result.status !== EvalStatus.HAS_DATA || JSON.stringify(result.value) !== '[0]') {
150
+ throw new Error(`Expected Pr1(S1) to select the first coordinate; got ${JSON.stringify(result)}`);
151
+ }
175
152
  ```
176
153
 
154
+ Use this pattern for tests that protect important definitions. Full kinship model: `../../examples/build-kinship-rsmodel.ts`. More notes: `../../docs/MODEL-TESTING.md`.
155
+
177
156
  ## Common mistakes
178
157
 
179
- | Mistake | Symptom |
180
- | -------------------------------------------------- | ------------------------------------------------ |
181
- | `definitionFormal: 'Z'` on `X1` (`basic`) | `0x8862` definitionNotAllowed |
182
- | `D1` uses `D2` before `D2` exists | globalNotTyped / undeclared global |
183
- | `analyzeExpression` with wrong `cstType` | Role-specific semantic errors |
184
- | Non-empty formal on `C1` (`constant`) | Same as basic definition not allowed |
185
- | `term` with `X1×X1` when modeling a **relation** | Full Cartesian product instead of typed pairs in `S#` |
186
- | `structure` with `Pr1(S1)` instead of a grade | Wrong role — projections belong on `term` / `F#` |
187
- | `setConstituentaValue` on inferrable `D1` (`term`) | Error: inferrable and cannot be set directly |
188
- | Evaluating before base binding set | May fail or return empty depending on expression |
158
+ - `definitionFormal: 'Z'` on `basic` / `constant` → `definitionNotAllowed`.
159
+ - `D1` uses `D2` before `D2` exists → global not typed / undeclared.
160
+ - Wrong `cstType` in `analyzeExpression` role-specific errors.
161
+ - `term` with `X1×X1` for a relation full Cartesian product, not relation typification.
162
+ - `structure` with `Pr1(S1)` → wrong role; projections belong on `term` / `function`.
163
+ - `setConstituentaValue` on `term`, `axiom`, or `statement` cannot set computed constituents directly.
164
+ - Evaluation before base bindings missing value, empty result, or evaluation failure.
189
165
 
190
- ## Fixing a syntax error
166
+ ## Fix Syntax
191
167
 
192
168
  1. `analyzeExpression` with the broken fragment and correct `cstType`.
193
- 2. Read first diagnostic `{ from, to, code }`.
194
- 3. Edit substring of `definitionFormal` at those offsets.
195
- 4. `addOrUpdateConstituenta` again with the same `id` / `alias`.
169
+ 2. Read `{ code, from, to, params }`.
170
+ 3. Edit the substring of `definitionFormal` at those offsets.
171
+ 4. Re-run analysis.
172
+ 5. Upsert with the same `id` / `alias`.
@@ -1,133 +1,93 @@
1
- # RS Language & rstool — Compact Guide for Agents
1
+ # RS Language & rstool
2
2
 
3
- **RS language** is a formal scheme notation for concepts, relations, operations—extends FOL, core: membership `x∈y`; typification via set-theoretic/logical expressions.
3
+ Compact entry guide for agents. Keep details in linked docs.
4
4
 
5
- **rstool** is the agent API for sessions, upserts, analysis, diagnostics, modeling/evaluation, (de)serialization.
5
+ **RSLang** is a formal notation for conceptual schemas: concepts, relations, operations, assertions. Core ideas: membership `x∈y`, set-theoretic expressions, logical expressions, typification.
6
6
 
7
- - Library: `@rsconcept/rstool` (npm)
8
- - Analyzer: `@rsconcept/domain` (dependency of rstool)
9
- - Language reference: `docs/*.md` next to this package (see table below)
7
+ **rstool** is the agent API for sessions, upserts, analysis, diagnostics, model values, evaluation, export/import.
10
8
 
11
- ## Docs / hints (canonical paths)
9
+ - Library: `@rsconcept/rstool`.
10
+ - Analyzer: `@rsconcept/domain`.
11
+ - Stdio wrapper: `npx rstool-wrapper`, JSON per line.
12
+ - Node client: `RSToolWrapperClient`.
12
13
 
13
- Paths below are relative to **this file** (`skills/rstool-helper/GUIDE.md`).
14
+ ## What to Read
14
15
 
15
- | Info | Location |
16
- | :--- | :--- |
17
- | rstool API, methods, error codes | [REFERENCE.md](REFERENCE.md) |
18
- | Worked examples, common mistakes | [EXAMPLES.md](EXAMPLES.md) |
19
- | Domain vocabulary (English) | [../../docs/DOMAIN.md](../../docs/DOMAIN.md) |
20
- | Constituenta fields, validation, ordering | [../../docs/CONSTITUENTA.md](../../docs/CONSTITUENTA.md) |
21
- | RSLang syntax (operators, quantifiers) | [../../docs/SYNTAX.md](../../docs/SYNTAX.md) |
22
- | Typification grades, radicals | [../../docs/TYPIFICATION.md](../../docs/TYPIFICATION.md) |
23
- | Diagnostic code → fix table | [../../docs/DIAGNOSTICS.md](../../docs/DIAGNOSTICS.md) |
24
- | Portal REST API (live data) | [../../docs/PORTAL-API.md](../../docs/PORTAL-API.md) |
25
- | Lezer grammar pointers | [../../docs/GRAMMAR-REF.md](../../docs/GRAMMAR-REF.md) |
26
- | Package README | [../../README.md](../../README.md) |
16
+ Paths are relative to this file.
27
17
 
28
- When working from **npm**, the same tree lives under `node_modules/@rsconcept/rstool/` (use the Read tool on those paths from the project root).
18
+ - API, methods, stdio, error codes: [REFERENCE.md](REFERENCE.md).
19
+ - Worked examples and pitfalls: [EXAMPLES.md](EXAMPLES.md).
20
+ - Domain terms: [../../docs/DOMAIN.md](../../docs/DOMAIN.md).
21
+ - Schema design rules: [../../docs/CONCEPTUAL-SCHEMA.md](../../docs/CONCEPTUAL-SCHEMA.md).
22
+ - Constituents and validation: [../../docs/CONSTITUENTA.md](../../docs/CONSTITUENTA.md).
23
+ - Syntax: [../../docs/SYNTAX.md](../../docs/SYNTAX.md).
24
+ - Typification: [../../docs/TYPIFICATION.md](../../docs/TYPIFICATION.md).
25
+ - Definition testing with small conceptual models: [../../docs/MODEL-TESTING.md](../../docs/MODEL-TESTING.md).
26
+ - Diagnostics: [../../docs/DIAGNOSTICS.md](../../docs/DIAGNOSTICS.md).
27
+ - Portal REST reads: [../../docs/PORTAL-API.md](../../docs/PORTAL-API.md).
28
+ - Grammar pointers: [../../docs/GRAMMAR-REF.md](../../docs/GRAMMAR-REF.md).
29
29
 
30
- ## Protocol Summary
30
+ ## Workflow
31
31
 
32
- 1. **Start session**: `createSession`
33
- 2. **Add bases/constants**: type `basic` (`X*`), `constant` (`C*`) `definitionFormal: ''`
34
- 3. **Add derived**: terms, axioms, etc.—only after dependencies present
35
- 4. **Analyze scratch**: `analyzeExpression`
36
- 5. **Process diagnostics**: check `analysis.diagnostics`/`listDiagnostics`; fix by range
37
- 6. **Checkpoint**: `commitStep` (message optional)
38
- 7. **Model values**: `setConstituentaValue` / `setConstituentaValues` for base bindings (`{0:"a",1:"b"}`) or structured values; `getModelState`
39
- 8. **Evaluate**: `evaluateExpression` (scratch) or `evaluateConstituenta` / `recalculateModel` (stored definitions)
40
- 9. **Export/import**: persist with `exportSession`/`importSession` (includes `state.model`)
32
+ 1. `createSession`.
33
+ 2. Add `basic` (`X#`) and `constant` (`C#`) with `definitionFormal: ''`.
34
+ 3. Add dependencies before dependents.
35
+ 4. Use `analyzeExpression` before upsert when unsure.
36
+ 5. When unsure about semantics, build a tiny conceptual model and evaluate test data.
37
+ 6. Fix diagnostics by `from` / `to` range in `definitionFormal`.
38
+ 7. `commitStep` when the state is coherent.
39
+ 8. Set base/model values with `setConstituentaValue(s)`.
40
+ 9. Evaluate with `evaluateExpression`, `evaluateConstituenta`, or `recalculateModel`.
41
+ 10. Persist with `exportSession` / `importSession`.
41
42
 
42
- **Clients**:
43
+ ## Portal REST
43
44
 
44
- - Node: use `RSToolWrapperClient`
45
- - Stdio process: `npx rstool-wrapper` — JSON per line
45
+ rstool never calls Portal REST itself. Fetch live data outside rstool, then import constituents with `addOrUpdateConstituenta`.
46
46
 
47
- ## API/REST
47
+ - UI host: `https://portal.acconcept.ru`.
48
+ - API host: `https://api.portal.acconcept.ru`.
49
+ - Useful reads: `/api/rsforms/{id}`, `/api/rsforms/{id}/details`, `/api/library/{id}/versions/{v}`, `/api/oss/{id}`, `/api/models/{id}`, `/schema`.
50
+ - Do not scrape SPA HTML or reuse UI query params like `?tab=`.
48
51
 
49
- For full reference see [../../docs/PORTAL-API.md](../../docs/PORTAL-API.md). Short form:
52
+ ## Syntax Cheatsheet
50
53
 
51
- - **Portal UI**: `https://portal.acconcept.ru`
52
- - **API**: `https://api.portal.acconcept.ru`
53
- - Endpoints: `GET /api/rsforms/{id}`, `GET /api/rsforms/{id}/details`, `GET /api/library/{id}/versions/{v}`, `GET /api/oss/{id}`, `GET /api/models/{id}`, OpenAPI at `GET /schema`.
54
- - Don't scrape SPA or use UI query params (`tab=`, etc.).
55
- - rstool itself never calls the REST API; bring data in via `addOrUpdateConstituenta` after fetching.
54
+ - Globals: `X1`, `C1`, `S1`, `D1`, `F1`, `P1`, `A1`, `T1`, `N1`, `R1`.
55
+ - Locals: `x`, `ξ`, `μ2`.
56
+ - Literals: `42`, `Z`, `∅`.
57
+ - Set expressions: `∪`, `∩`, `\`, `∆`, `×`, `ℬ(...)`, tuples, `Pr*`, `Fi*`.
58
+ - Logic: `¬`, `&`, `∨`, `⇒`, `⇔`, `∀`, `∃`, `=`, `≠`, `<`, `∈`, `⊆`.
59
+ - Parameterized expressions: `[arg1∈H1, arg2∈H2] body`.
56
60
 
57
- ## Constituent Types (`cstType`)
61
+ Read tool output; do not infer types by inspection.
58
62
 
59
- | cstType | Example | Formal | Notes |
60
- | :-------- | :------ | :-------- | :-------------------------------------------------------- |
61
- | basic | X1 | **empty** | Required |
62
- | constant | C1 | **empty** | Required |
63
- | nominal | S1 | allowed | Naming |
64
- | structure | S1 | allowed | Typification grade; base concept + `convention` |
65
- | term | D1 | allowed | Formal **definition**; derived concept, computed in model |
66
- | axiom | A1 | allowed | Logical; computed in model; required to be TRUE |
67
- | statement | T1 | allowed | Logical; computed in model |
68
- | function | F1 | allowed | Parameterized; derived concept |
69
- | predicate | P1 | allowed | Parameterized; derived concept |
70
-
71
- - Non-empty formal for `basic`/`constant` ⇒ error `0x8862` (`definitionNotAllowed`)
72
- - Empty `basic`/`constant` always typified
73
- - **Interpretable** (can set value): `basic`, `constant`, `structure`
74
- - **Inferrable** (computed, do not set directly): `term`, `axiom`, `statement`
75
-
76
- ## Structure (`S#`) vs term (`D#`)
77
-
78
- The same field `definitionFormal` has **different roles** depending on `cstType`:
79
-
80
- | | `structure` (`S#`) | `term` (`D#`) |
81
- | -------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
82
- | Role of `definitionFormal` | **Typification** — declares grade `H` (element structure) | **Definition** — declares how the concept is built from suppliers |
83
- | Concept class | **Undefined** — meaning from `convention` (+ axioms on `S#`) | **Derived** — meaning from the expression; no convention required |
84
- | Model interpretation | Values are **assigned** (or constrained by axioms); domain fills `S#` per convention | Value is **computed** via `evaluateConstituenta` / `recalculateModel` |
85
-
86
- **Same syntax, different semantics:** in `ℬ(X1×X1)` the fragment `X1×X1` is a **grade** (one ordered pair of base elements). On a **term** with body `X1×X1` alone, `×` builds the **full Cartesian product** — the set of all pairs from `X1`, not a relation typification.
87
-
88
- **Agent rule:** for a relation over `X1` (e.g. parent–child), upsert `S1` with `definitionFormal: 'ℬ(X1×X1)'` and a `convention`, then derive terms with projections/filters (`Pr1(S1)`, `Fi2[{ξ}](S1)`, …). Do not use bare `X1×X1` on a `term` when you meant the structure’s typification.
89
-
90
- See [EXAMPLES.md](EXAMPLES.md) (kinship-lite) and `../../examples/build-kinship-rsform.ts`.
91
-
92
- ## Syntax
93
-
94
- - **Globals**: `X1`, `C1`, `D1`, `F1`, `P1`, `A1`, `R1`
95
- - **Locals**: `x`, `ξ`, `μ2`
96
- - **Literals**: `42`, `Z`, `∅`
97
- - Full operator + precedence table: [../../docs/SYNTAX.md](../../docs/SYNTAX.md)
98
- - Grammar pointers: [../../docs/GRAMMAR-REF.md](../../docs/GRAMMAR-REF.md)
99
-
100
- ## Expression Types
101
-
102
- - **Set-theoretic**: `∪`, `∩`, `\`, `∆`, `×`, `∈`, `⊆`, `ℬ(...)`, tuples
103
- - **Logical**: `¬`, `&`, `∨`, `⇒`, `⇔`, `∀`, `∃`, comparisons `=`, `≠`, `<`
104
- - **Parameterized**: `[arg1∈H1, arg2∈H2] body`
105
- - Detailed semantics in [../../docs/SYNTAX.md](../../docs/SYNTAX.md); typification grades and radicals in [../../docs/TYPIFICATION.md](../../docs/TYPIFICATION.md).
63
+ ## Diagnostics Loop
106
64
 
107
- Always set `cstType` in upserts/analysis to true role.
65
+ 1. Check `analysis.success`.
66
+ 2. If false, read `analysis.diagnostics` or `listDiagnostics`.
67
+ 3. Map `code` to a fix in `DIAGNOSTICS.md`.
68
+ 4. Patch the reported `from` / `to` range.
69
+ 5. Re-run only after changing input.
108
70
 
109
- ## Diagnostics Loop
71
+ ## Declaration Order
110
72
 
111
- 1. Check `analysis.success`
112
- 2. If not, see `analysis.diagnostics` / `listDiagnostics`
113
- 3. Map `code` cause → fix via [../../docs/DIAGNOSTICS.md](../../docs/DIAGNOSTICS.md)
114
- 4. Use `from`, `to` to patch `definitionFormal`; re-send
73
+ 1. `basic`, `constant`.
74
+ 2. Core structures and key concepts.
75
+ 3. Derived constituents in topological order.
76
+ 4. Axioms and statements after their references.
115
77
 
116
- Don't infer types—always read tool output.
78
+ ## Natural-Language Fields
117
79
 
118
- ## Declaration Order
80
+ Keep `term`, `definitionText`, and `convention` in one language.
119
81
 
120
- 1. All `basic`, `constant`
121
- 2. Core/critical first
122
- 3. Topological: dependencies before dependents (e.g. `D1` before `D2` if `D2` refers to `D1`)
123
- 4. Derived right after their sources
82
+ - Extending a schema: use the schema's existing language.
83
+ - New schema: use the user's request language.
124
84
 
125
85
  ## Checklist
126
86
 
127
- - [ ] `sessionId` obtained & tracked
128
- - [ ] Bases/constants are empty formal
129
- - [ ] All dependencies exist before upsert
130
- - [ ] Matching `cstType`
131
- - [ ] Diagnostics handled before commit/export
132
- - [ ] Base bindings set before evaluating expressions that reference base elements
133
- - [ ] For other details, open [REFERENCE.md](REFERENCE.md) or linked `docs/*.md`
87
+ - [ ] `sessionId` tracked.
88
+ - [ ] `basic` / `constant` formals are empty.
89
+ - [ ] Dependencies exist before upsert.
90
+ - [ ] `cstType` matches the role.
91
+ - [ ] Diagnostics handled before commit/export.
92
+ - [ ] Ambiguous semantics checked on a small model when data examples are available.
93
+ - [ ] Base values set before evaluation.
@@ -143,6 +143,7 @@ Standalone agents should consult the bundled distilled docs (`docs/*.md` inside
143
143
  | Quantifiers | `docs/SYNTAX.md` § *Quantifiers* |
144
144
  | Parameterized functions, templates | `docs/SYNTAX.md` § *Parameterised* |
145
145
  | Correctness / validation mindset | `docs/SYNTAX.md` § *Correctness model* |
146
+ | Definition semantic tests | `docs/MODEL-TESTING.md` |
146
147
  | Domain vocabulary | `docs/DOMAIN.md` |
147
148
  | Constituent fields and ordering | `docs/CONSTITUENTA.md` |
148
149
  | Portal REST API | `docs/PORTAL-API.md` |
@@ -20,13 +20,11 @@ Then continue with the canonical files below.
20
20
 
21
21
  ## Canonical files (read before rstool work)
22
22
 
23
- | What | Path |
24
- | :--- | :--- |
25
- | **Start here** — workflow, cstType, S# vs D# | `node_modules/@rsconcept/rstool/skills/rstool-helper/GUIDE.md` |
26
- | API, stdio, contract | `node_modules/@rsconcept/rstool/skills/rstool-helper/REFERENCE.md` |
27
- | Examples, pitfalls | `node_modules/@rsconcept/rstool/skills/rstool-helper/EXAMPLES.md` |
28
- | Language / domain docs | `node_modules/@rsconcept/rstool/docs/*.md` |
29
- | Install procedure | `node_modules/@rsconcept/rstool/skills/INSTALL.md` |
23
+ - **Start here** workflow: `node_modules/@rsconcept/rstool/skills/rstool-helper/GUIDE.md`
24
+ - API, stdio, contract: `node_modules/@rsconcept/rstool/skills/rstool-helper/REFERENCE.md`
25
+ - Examples, pitfalls: `node_modules/@rsconcept/rstool/skills/rstool-helper/EXAMPLES.md`
26
+ - Language / domain docs: `node_modules/@rsconcept/rstool/docs/*.md`
27
+ - Install procedure: `node_modules/@rsconcept/rstool/skills/INSTALL.md`
30
28
 
31
29
  Always open **GUIDE.md** first when starting a rstool task, then **REFERENCE.md** / **EXAMPLES.md** / relevant `docs/*.md` as needed.
32
30
 
@@ -34,4 +32,3 @@ Always open **GUIDE.md** first when starting a rstool task, then **REFERENCE.md*
34
32
 
35
33
  - Package: `@rsconcept/rstool`; wrapper: `npx rstool-wrapper`
36
34
  - `@rsconcept/domain` is installed as a dependency (analyzer, errors in `src/rslang/error.ts`)
37
- - Do not copy GUIDE, REFERENCE, EXAMPLES, or `docs/` into the project skills folder — read them from `node_modules` paths above