@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/docs/CONCEPTUAL-SCHEMA.md +78 -0
- package/docs/CONSTITUENTA.md +37 -55
- package/docs/DIAGNOSTICS.md +85 -130
- package/docs/DOMAIN.md +68 -91
- package/docs/GRAMMAR-REF.md +35 -86
- package/docs/MODEL-TESTING.md +57 -0
- package/docs/PORTAL-API.md +22 -36
- package/docs/README.md +14 -12
- package/docs/SYNTAX.md +49 -104
- package/docs/TYPIFICATION.md +41 -60
- package/package.json +1 -1
- package/skills/README.md +6 -8
- package/skills/rstool-helper/EXAMPLES.md +83 -106
- package/skills/rstool-helper/GUIDE.md +68 -108
- package/skills/rstool-helper/REFERENCE.md +1 -0
- package/skills/rstool-helper/SKILL.md +5 -8
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
1
|
+
# rstool Examples
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Short examples for agents. For full scripts, see `../../examples/`.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
45
|
-
tool.analyzeExpression(sessionId, {
|
|
46
|
-
expression: '(',
|
|
47
|
-
cstType: CstType.TERM
|
|
48
|
-
}); // success: false, syntax diagnostics
|
|
36
|
+
## Analyze Before Upsert
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
45
|
+
|
|
46
|
+
if (!analysis.success) {
|
|
47
|
+
console.log(analysis.diagnostics.map(({ code, from, to }) => ({ code, from, to })));
|
|
48
|
+
}
|
|
60
49
|
```
|
|
61
50
|
|
|
62
|
-
|
|
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
|
-
|
|
79
|
+
Manual stdio is one JSON request per line:
|
|
103
80
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
86
|
+
## Export / Import
|
|
111
87
|
|
|
112
|
-
```
|
|
113
|
-
|
|
88
|
+
```ts
|
|
89
|
+
const payload = tool.exportSession(sessionId);
|
|
90
|
+
const restored = tool.importSession(payload);
|
|
114
91
|
```
|
|
115
92
|
|
|
116
|
-
|
|
93
|
+
Export includes session state and model values.
|
|
117
94
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
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: '
|
|
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:
|
|
131
|
+
draft: { id: 3, alias: 'D1', cstType: CstType.TERM, definitionFormal: 'Pr1(S1)' }
|
|
153
132
|
});
|
|
154
133
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
##
|
|
166
|
+
## Fix Syntax
|
|
191
167
|
|
|
192
168
|
1. `analyzeExpression` with the broken fragment and correct `cstType`.
|
|
193
|
-
2. Read
|
|
194
|
-
3. Edit substring of `definitionFormal` at those offsets.
|
|
195
|
-
4.
|
|
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
|
|
1
|
+
# RS Language & rstool
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Compact entry guide for agents. Keep details in linked docs.
|
|
4
4
|
|
|
5
|
-
**
|
|
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
|
-
|
|
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
|
-
|
|
9
|
+
- Library: `@rsconcept/rstool`.
|
|
10
|
+
- Analyzer: `@rsconcept/domain`.
|
|
11
|
+
- Stdio wrapper: `npx rstool-wrapper`, JSON per line.
|
|
12
|
+
- Node client: `RSToolWrapperClient`.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
## What to Read
|
|
14
15
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
30
|
+
## Workflow
|
|
31
31
|
|
|
32
|
-
1.
|
|
33
|
-
2.
|
|
34
|
-
3.
|
|
35
|
-
4.
|
|
36
|
-
5.
|
|
37
|
-
6.
|
|
38
|
-
7.
|
|
39
|
-
8.
|
|
40
|
-
9.
|
|
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
|
-
|
|
43
|
+
## Portal REST
|
|
43
44
|
|
|
44
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
+
## Syntax Cheatsheet
|
|
50
53
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
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
|
-
|
|
61
|
+
Read tool output; do not infer types by inspection.
|
|
58
62
|
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
71
|
+
## Declaration Order
|
|
110
72
|
|
|
111
|
-
1.
|
|
112
|
-
2.
|
|
113
|
-
3.
|
|
114
|
-
4.
|
|
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
|
-
|
|
78
|
+
## Natural-Language Fields
|
|
117
79
|
|
|
118
|
-
|
|
80
|
+
Keep `term`, `definitionText`, and `convention` in one language.
|
|
119
81
|
|
|
120
|
-
|
|
121
|
-
|
|
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`
|
|
128
|
-
- [ ]
|
|
129
|
-
- [ ]
|
|
130
|
-
- [ ]
|
|
131
|
-
- [ ] Diagnostics handled before commit/export
|
|
132
|
-
- [ ]
|
|
133
|
-
- [ ]
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|