@kortexya/reasoninglayer 1.28.0 → 2.0.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/README.md +38 -18
- package/dist/index.cjs +176 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +349 -35
- package/dist/index.d.ts +349 -35
- package/dist/index.js +176 -18
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -186,16 +186,31 @@ browser code that has already gone through the platform's login flow.
|
|
|
186
186
|
|
|
187
187
|
## Response Metadata
|
|
188
188
|
|
|
189
|
+
A resource method resolves to the parsed body alone. To see a **successful**
|
|
190
|
+
response's status, headers or rate-limit budget, register an interceptor — it
|
|
191
|
+
wraps every request the client makes.
|
|
192
|
+
|
|
189
193
|
```typescript
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
const client = new ReasoningLayerClient({
|
|
195
|
+
baseUrl: 'https://platform.ovh.reasoninglayer.ai',
|
|
196
|
+
tenantId: 'your-tenant-uuid',
|
|
197
|
+
auth: { mode: 'cookie' },
|
|
198
|
+
interceptors: [
|
|
199
|
+
async (request, next) => {
|
|
200
|
+
const response = await next(request);
|
|
201
|
+
console.log(response.status); // 201
|
|
202
|
+
console.log(response.headers.get('x-ratelimit-remaining')); // '99'
|
|
203
|
+
return response;
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
});
|
|
192
207
|
|
|
193
|
-
|
|
194
|
-
const result = await client.sorts.withMetadata().createSort({ name: 'person' });
|
|
195
|
-
console.log(result.status); // 201
|
|
196
|
-
console.log(result.rateLimit); // { limit, remaining, retryAfter }
|
|
208
|
+
const sort = await client.sorts.createSort({ name: 'person' });
|
|
197
209
|
```
|
|
198
210
|
|
|
211
|
+
On a **failure**, the thrown `ApiError` carries `status` and `headers`
|
|
212
|
+
directly — see Error Handling below.
|
|
213
|
+
|
|
199
214
|
## Error Handling
|
|
200
215
|
|
|
201
216
|
```typescript
|
|
@@ -227,23 +242,28 @@ try {
|
|
|
227
242
|
The SDK provides builder functions for constructing API request values with full type safety:
|
|
228
243
|
|
|
229
244
|
```typescript
|
|
230
|
-
import { Value,
|
|
245
|
+
import { Value, FuzzyShape, guard, constrained, allen, SortBuilder, psi, LP } from '@kortexya/reasoninglayer';
|
|
231
246
|
|
|
232
|
-
// Tagged values (term CRUD)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
Value.
|
|
247
|
+
// Tagged values (term CRUD). A plain scalar needs no builder — the resource
|
|
248
|
+
// methods tag it for you. `Value.*` is for the shapes a scalar cannot express.
|
|
249
|
+
const features = { name: 'hello', age: 42 }; // tagged on the way to the wire
|
|
250
|
+
Value.reference('550e8400-e29b-41d4-a716-446655440000')
|
|
251
|
+
// { type: 'Reference', value: '550e8400-…' }
|
|
252
|
+
Value.fuzzyNumber(FuzzyShape.triangular(20, 22, 24))
|
|
253
|
+
// { type: 'FuzzyNumber', value: { kind: 'Triangular', … } }
|
|
236
254
|
|
|
237
|
-
// Untagged values (inference)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
255
|
+
// Untagged values (inference). `psi()` writes them: a scalar stays a scalar,
|
|
256
|
+
// and a '?Name' string becomes a logic variable.
|
|
257
|
+
psi('employee', { name: '?Name', department: 'Engineering' })
|
|
258
|
+
// { sortName: 'employee', features: { name: { name: '?Name' }, … } }
|
|
241
259
|
|
|
242
|
-
// Guard constraints
|
|
243
|
-
guard('gt', 100) // {
|
|
260
|
+
// Guard constraints — a guard is itself a Ψ-term
|
|
261
|
+
guard('gt', 100) // { sortName: 'guard_constraint', features: { op: 'gt', right: 100 } }
|
|
262
|
+
constrained('?Salary', guard('gt', 80000))
|
|
244
263
|
|
|
245
264
|
// Allen temporal relations
|
|
246
|
-
allen('before'
|
|
265
|
+
allen('before', '?Employment', intervalTermId)
|
|
266
|
+
// { type: 'Allen', intervalA: '?Employment', … }
|
|
247
267
|
|
|
248
268
|
// LP optimization
|
|
249
269
|
LP.maximize({ x: 3, y: 5 }) // objective function
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/config.ts
|
|
10
|
-
var SDK_VERSION = "
|
|
10
|
+
var SDK_VERSION = "2.0.0";
|
|
11
11
|
function resolveConfig(config) {
|
|
12
12
|
if (!config.baseUrl) {
|
|
13
13
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -1164,11 +1164,11 @@ var Sorts = class {
|
|
|
1164
1164
|
...params
|
|
1165
1165
|
});
|
|
1166
1166
|
/**
|
|
1167
|
-
* @description Per Definition IV.5 (Milanese & Pasi, IEEE TFS 2024 — CC-BY manuscript in reasoninglayer-sources/pdf_sources/), verbatim: ≺∼· ≝ ((≺∼ .− ∼) ⊍ ⪯)⊕ The combined chain preorder ≺∼ of Definition IV.1 with every DIRECTLY-similar pair deleted (`.−` zeroes the pair — it is not an arithmetic difference), the crisp order unioned back, and the result re-closed. A chain survives when its ENDPOINTS are not directly similar: slasher ⪯ horror ∼₀.₅ thriller keeps 0.5 while (horror, thriller) itself answers 0 — two similar sorts meet through their GLB instead (Fig. 4c: horror ⩏ thriller = slasher). The combined ≺∼ — where a direct ∼ edge IS a step; the coarse retrieval mode of Example V.4 — backs equivalence classes and term substitutability internally. (History: the differencing form here is ORIGINAL and faithful; #203 swapped in the combined semantics, and a 2026-08-23 pass re-documented that as correct from secondary sources. The accepted manuscript settled it the other way.)
|
|
1167
|
+
* @description Omitted, the answer is Def. IV.5 `≾̇` — the default because that is the relation the graded GLB and term substitutability are computed from. `granularity: "combined"` answers Def. IV.1 `≺∼`, where a similarity edge IS a step, so a directly-similar pair reads its similarity degree instead of the `0` the pair deletion gives it. A caller asking "how close are these two sorts" wants the second; a caller asking "does this sort substitute for that one" wants the first (#282). Per Definition IV.5 (Milanese & Pasi, IEEE TFS 2024 — CC-BY manuscript in reasoninglayer-sources/pdf_sources/), verbatim: ≺∼· ≝ ((≺∼ .− ∼) ⊍ ⪯)⊕ The combined chain preorder ≺∼ of Definition IV.1 with every DIRECTLY-similar pair deleted (`.−` zeroes the pair — it is not an arithmetic difference), the crisp order unioned back, and the result re-closed. A chain survives when its ENDPOINTS are not directly similar: slasher ⪯ horror ∼₀.₅ thriller keeps 0.5 while (horror, thriller) itself answers 0 — two similar sorts meet through their GLB instead (Fig. 4c: horror ⩏ thriller = slasher). The combined ≺∼ — where a direct ∼ edge IS a step; the coarse retrieval mode of Example V.4 — backs equivalence classes and term substitutability internally. (History: the differencing form here is ORIGINAL and faithful; #203 swapped in the combined semantics, and a 2026-08-23 pass re-documented that as correct from secondary sources. The accepted manuscript settled it the other way.)
|
|
1168
1168
|
*
|
|
1169
1169
|
* @tags sorts
|
|
1170
1170
|
* @name GetPreorderDegree
|
|
1171
|
-
* @summary Get preorder degree
|
|
1171
|
+
* @summary Get the preorder degree between two sorts, in either of the paper's two readings — `granularity` selects which, exactly as `GET /api/v1/sorts/quotient-order` does, and the answer echoes it back.
|
|
1172
1172
|
* @request POST:/api/v1/sorts/preorder-degree
|
|
1173
1173
|
*/
|
|
1174
1174
|
getPreorderDegree = (data, params = {}) => this.http.request({
|
|
@@ -1869,7 +1869,7 @@ var Inference = class {
|
|
|
1869
1869
|
...params
|
|
1870
1870
|
});
|
|
1871
1871
|
/**
|
|
1872
|
-
* @description # TRUE HOMOICONIC API Request contains a goal term and optional constraints. Response returns solutions with term-based substitutions. ## Temporal Reasoning Use constraints to filter by temporal relations: ```json { "goal": {"sort_name": "Employment", "features": {"valid_to": {"name": "?EndTime"}}}, "constraints": [{"type": "Guard", "left": "?EndTime", "op": "lt", "right": "1583020800000"}] } ``` ## Reading a solution `solutions[].proof.kind` says how the goal was established, and is always present: `proved` (a rule was applied — either it fired in this search, or the goal was a conclusion a forward chain had materialised and the engine recovered the rule from its recorded derivation, so `rule_term_id` and `rule_label` are filled), `fact` (a stored fact with no recorded derivation), `residuated` (an open-world leaf: unknown, never false), `unattributed` (a sound answer whose derivation the engine could not report). A client never has to infer this from the node's shape. A goal that carries `constraints` is a CONJUNCTION: its root node holds one subproof per clause and reports the strongest kind the clauses carry — `proved` when any clause was proved by a rule, else `fact`. `solutions[].substitution.bindings` carries one entry per query variable the engine resolved. A variable left unresolved is ABSENT; it is never bound to itself. # Authorization Requires X-Tenant-Id header. Traced: this is the path the zanzibar gateway hits for every permission check, so it is where an end-to-end trace either explains a slow request or does not. `skip_all` because the request body can be large and has no business in a span attribute.
|
|
1872
|
+
* @description # TRUE HOMOICONIC API Request contains a goal term and optional constraints. Response returns solutions with term-based substitutions. ## Temporal Reasoning Use constraints to filter by temporal relations: ```json { "goal": {"sort_name": "Employment", "features": {"valid_to": {"name": "?EndTime"}}}, "constraints": [{"type": "Guard", "left": "?EndTime", "op": "lt", "right": "1583020800000"}] } ``` ## Reading a solution `solutions[].proof.kind` says how the goal was established, and is always present: `proved` (a rule was applied — either it fired in this search, or the goal was a conclusion a forward chain had materialised and the engine recovered the rule from its recorded derivation, so `rule_term_id` and `rule_label` are filled), `fact` (a stored fact with no recorded derivation), `residuated` (an open-world leaf: unknown, never false), `unattributed` (a sound answer whose derivation the engine could not report). A client never has to infer this from the node's shape. A goal that carries `constraints` is a CONJUNCTION: its root node holds one subproof per clause and reports the strongest kind the clauses carry — `proved` when any clause was proved by a rule, else `fact`. `solutions[].substitution.bindings` carries one entry per query variable the engine resolved. A variable left unresolved is ABSENT; it is never bound to itself. ## Joining a proof to the thing it proves `proof.goal_term_id` is the TermId of the CONCLUSION the node proved. It joins to `POST /api/v1/query/by-sort` and `GET /api/v1/terms/{id}`, and two solutions of one goal share it only when they prove the same conclusion. It is ABSENT when there is no such id — a goal proved without a preceding `CHAIN` materialised no conclusion, and a derivation replayed from a persistent store cannot be attributed to one. A client falls back deliberately there rather than by accident. `proof.rule_head_term_id` names the rule's instantiated HEAD on a rule application, when it differs from the conclusion. ⛔ It is rule scaffolding: `GET /api/v1/terms/{id}` refuses it deliberately (#192). It is a grouping key, not a fetchable id. # Authorization Requires X-Tenant-Id header. Traced: this is the path the zanzibar gateway hits for every permission check, so it is where an end-to-end trace either explains a slow request or does not. `skip_all` because the request body can be large and has no business in a span attribute.
|
|
1873
1873
|
*
|
|
1874
1874
|
* @tags inference
|
|
1875
1875
|
* @name BackwardChain
|
|
@@ -13670,19 +13670,56 @@ function BulkSetSimilaritiesResponseFromApiToFront(dto) {
|
|
|
13670
13670
|
errors: dto.errors
|
|
13671
13671
|
};
|
|
13672
13672
|
}
|
|
13673
|
+
var SORT_PREORDER_GRANULARITIES = [
|
|
13674
|
+
"similarity_deleted",
|
|
13675
|
+
"combined"
|
|
13676
|
+
];
|
|
13677
|
+
function toSortPreorderGranularity(value) {
|
|
13678
|
+
const known = SORT_PREORDER_GRANULARITIES.find((candidate) => candidate === value);
|
|
13679
|
+
if (known === void 0) {
|
|
13680
|
+
throw new ValidationError(
|
|
13681
|
+
`Unknown preorder granularity "${value}" \u2014 expected ${SORT_PREORDER_GRANULARITIES.join(" or ")}.`
|
|
13682
|
+
);
|
|
13683
|
+
}
|
|
13684
|
+
return known;
|
|
13685
|
+
}
|
|
13673
13686
|
function GetPreorderDegreeRequestFromFrontToApi(model) {
|
|
13674
13687
|
return {
|
|
13675
13688
|
sort1_id: model.sort1Id,
|
|
13676
|
-
sort2_id: model.sort2Id
|
|
13689
|
+
sort2_id: model.sort2Id,
|
|
13690
|
+
granularity: model.granularity
|
|
13677
13691
|
};
|
|
13678
13692
|
}
|
|
13679
13693
|
function GetPreorderDegreeResponseFromApiToFront(dto) {
|
|
13680
13694
|
return {
|
|
13681
13695
|
sort1Id: dto.sort1_id,
|
|
13682
13696
|
sort2Id: dto.sort2_id,
|
|
13697
|
+
degree: dto.degree,
|
|
13698
|
+
granularity: toSortPreorderGranularity(dto.granularity)
|
|
13699
|
+
};
|
|
13700
|
+
}
|
|
13701
|
+
function QuotientClassFromApiToFront(dto) {
|
|
13702
|
+
return {
|
|
13703
|
+
sortIds: dto.sort_ids,
|
|
13704
|
+
size: dto.size,
|
|
13705
|
+
alpha: dto.alpha
|
|
13706
|
+
};
|
|
13707
|
+
}
|
|
13708
|
+
function QuotientOrderEdgeFromApiToFront(dto) {
|
|
13709
|
+
return {
|
|
13710
|
+
from: dto.from,
|
|
13711
|
+
to: dto.to,
|
|
13683
13712
|
degree: dto.degree
|
|
13684
13713
|
};
|
|
13685
13714
|
}
|
|
13715
|
+
function GetQuotientOrderResponseFromApiToFront(dto) {
|
|
13716
|
+
return {
|
|
13717
|
+
granularity: toSortPreorderGranularity(dto.granularity),
|
|
13718
|
+
classes: dto.classes.map(QuotientClassFromApiToFront),
|
|
13719
|
+
count: dto.count,
|
|
13720
|
+
orderEdges: dto.order_edges.map(QuotientOrderEdgeFromApiToFront)
|
|
13721
|
+
};
|
|
13722
|
+
}
|
|
13686
13723
|
function EquivalenceClassFromApiToFront(dto) {
|
|
13687
13724
|
return {
|
|
13688
13725
|
sortIds: dto.sort_ids,
|
|
@@ -14529,13 +14566,32 @@ var SortsClient = class {
|
|
|
14529
14566
|
/**
|
|
14530
14567
|
* Compute the preorder degree between two sorts.
|
|
14531
14568
|
*
|
|
14532
|
-
* @param request - Sort pair to compute preorder degree for
|
|
14533
|
-
*
|
|
14534
|
-
* @
|
|
14535
|
-
*
|
|
14536
|
-
* @
|
|
14537
|
-
*
|
|
14538
|
-
*
|
|
14569
|
+
* @param request - Sort pair to compute preorder degree for, and optionally
|
|
14570
|
+
* which of the two preorders to read it from.
|
|
14571
|
+
* @returns The preorder degree response including sort IDs, degree, and the
|
|
14572
|
+
* granularity the degree was read from.
|
|
14573
|
+
* @throws {@link ApiError} If the sorts do not exist, or if `granularity`
|
|
14574
|
+
* carries a spelling the engine does not accept.
|
|
14575
|
+
* @throws {@link ValidationError} If the engine answers a granularity this
|
|
14576
|
+
* SDK version does not know.
|
|
14577
|
+
*
|
|
14578
|
+
* @remarks
|
|
14579
|
+
* Per Definition IV.5 (Milanese and Pasi, IEEE TFS 2024), the dotted preorder
|
|
14580
|
+
* is `preorder_dot = ((combined_preorder .- similarity) union subsumption)^+`,
|
|
14581
|
+
* where `.-` DELETES each directly-similar pair — it is NOT an arithmetic
|
|
14582
|
+
* difference. So a directly-similar pair answers `0` under the default
|
|
14583
|
+
* granularity: two similar sorts meet through their GLB, not through each
|
|
14584
|
+
* other.
|
|
14585
|
+
*
|
|
14586
|
+
* `granularity` selects the reading, with the same two spellings
|
|
14587
|
+
* `GET /api/v1/sorts/quotient-order` uses:
|
|
14588
|
+
* - omitted or `similarity_deleted` — Definition IV.5, the default, and the
|
|
14589
|
+
* relation the graded GLB and term substitutability are computed from.
|
|
14590
|
+
* - `combined` — Definition IV.1, where a similarity edge IS a step, so a
|
|
14591
|
+
* directly-similar pair answers its similarity degree.
|
|
14592
|
+
*
|
|
14593
|
+
* The response always echoes the granularity back, so a `0.0` is never
|
|
14594
|
+
* ambiguous between "no path" and "the pair deletion zeroed it".
|
|
14539
14595
|
*
|
|
14540
14596
|
* Degree interpretation:
|
|
14541
14597
|
* - 1.0 = subsumption (sort1 <= sort2)
|
|
@@ -14546,17 +14602,78 @@ var SortsClient = class {
|
|
|
14546
14602
|
*
|
|
14547
14603
|
* @example
|
|
14548
14604
|
* ```typescript
|
|
14549
|
-
* const
|
|
14605
|
+
* const strict = await client.sorts.getPreorderDegree({
|
|
14550
14606
|
* sort1Id: 'uuid-1',
|
|
14551
14607
|
* sort2Id: 'uuid-2',
|
|
14552
14608
|
* });
|
|
14553
|
-
* console.log(
|
|
14609
|
+
* console.log(strict.degree, strict.granularity); // 0 'similarity_deleted'
|
|
14610
|
+
*
|
|
14611
|
+
* const coarse = await client.sorts.getPreorderDegree({
|
|
14612
|
+
* sort1Id: 'uuid-1',
|
|
14613
|
+
* sort2Id: 'uuid-2',
|
|
14614
|
+
* granularity: 'combined',
|
|
14615
|
+
* });
|
|
14616
|
+
* console.log(coarse.degree, coarse.granularity); // 0.5 'combined'
|
|
14554
14617
|
* ```
|
|
14555
14618
|
*/
|
|
14556
14619
|
async getPreorderDegree(request, requestOptions) {
|
|
14557
14620
|
const response = await this.sorts.getPreorderDegree(GetPreorderDegreeRequestFromFrontToApi(request), toRequestParams(requestOptions));
|
|
14558
14621
|
return GetPreorderDegreeResponseFromApiToFront(response.data);
|
|
14559
14622
|
}
|
|
14623
|
+
/**
|
|
14624
|
+
* Get the Definition IV.9 quotient order over the caller's own lattice.
|
|
14625
|
+
*
|
|
14626
|
+
* @param options - Which of the two fuzzy preorders to quotient. Omitted
|
|
14627
|
+
* means `combined`, the engine's default HERE.
|
|
14628
|
+
* @returns The equivalence classes with their degrees, and the fuzzy partial
|
|
14629
|
+
* order between them.
|
|
14630
|
+
* @throws {@link ApiError} 400 when `granularity` carries a spelling the
|
|
14631
|
+
* engine does not accept.
|
|
14632
|
+
* @throws {@link ValidationError} If the engine answers a granularity this
|
|
14633
|
+
* SDK version does not know.
|
|
14634
|
+
*
|
|
14635
|
+
* @remarks
|
|
14636
|
+
* This is the tenant-scoped companion of
|
|
14637
|
+
* {@link SortsClient.getEquivalenceClasses}: the classes, degrees and order
|
|
14638
|
+
* describe exactly the sorts the caller can see, where the older
|
|
14639
|
+
* equivalence-classes route computes process-wide and then filters. Prefer
|
|
14640
|
+
* this one.
|
|
14641
|
+
*
|
|
14642
|
+
* ⚠️ The default granularity here is `combined`, NOT the
|
|
14643
|
+
* `similarity_deleted` default of {@link SortsClient.getPreorderDegree}. The
|
|
14644
|
+
* two routes take the same two spellings and disagree on which is the
|
|
14645
|
+
* default, so state it when it matters. The response echoes it back either
|
|
14646
|
+
* way.
|
|
14647
|
+
*
|
|
14648
|
+
* `orderEdges` is SPARSE and indexes into `classes`: a pair with no edge has
|
|
14649
|
+
* degree `0`. The order is a partial order — antisymmetric, unlike either
|
|
14650
|
+
* preorder it is built from.
|
|
14651
|
+
*
|
|
14652
|
+
* Uses tagged serialization format.
|
|
14653
|
+
*
|
|
14654
|
+
* @example
|
|
14655
|
+
* ```typescript
|
|
14656
|
+
* const quotient = await client.sorts.getQuotientOrder({
|
|
14657
|
+
* granularity: 'similarity_deleted',
|
|
14658
|
+
* });
|
|
14659
|
+
*
|
|
14660
|
+
* for (const cls of quotient.classes) {
|
|
14661
|
+
* console.log(`class of ${cls.size} sorts, degree ${cls.alpha}`);
|
|
14662
|
+
* }
|
|
14663
|
+
* for (const edge of quotient.orderEdges) {
|
|
14664
|
+
* const lower = quotient.classes[edge.from];
|
|
14665
|
+
* const upper = quotient.classes[edge.to];
|
|
14666
|
+
* console.log(`${lower.sortIds} <= ${upper.sortIds} at ${edge.degree}`);
|
|
14667
|
+
* }
|
|
14668
|
+
* ```
|
|
14669
|
+
*/
|
|
14670
|
+
async getQuotientOrder(options, requestOptions) {
|
|
14671
|
+
const response = await this.sorts.getQuotientOrder(
|
|
14672
|
+
{ granularity: options?.granularity },
|
|
14673
|
+
toRequestParams(requestOptions)
|
|
14674
|
+
);
|
|
14675
|
+
return GetQuotientOrderResponseFromApiToFront(response.data);
|
|
14676
|
+
}
|
|
14560
14677
|
/**
|
|
14561
14678
|
* Get equivalence classes based on the combined preorder.
|
|
14562
14679
|
*
|
|
@@ -14564,8 +14681,16 @@ var SortsClient = class {
|
|
|
14564
14681
|
* @throws {@link ApiError} If the lattice cannot be computed.
|
|
14565
14682
|
*
|
|
14566
14683
|
* @remarks
|
|
14567
|
-
* Per Definition IV.9 (Milanese and Pasi 2024)
|
|
14568
|
-
* s1 ~ s2 iff
|
|
14684
|
+
* Per Definition IV.9 (Milanese and Pasi 2024), two sorts are equivalent when
|
|
14685
|
+
* each reaches the other: `s1 ~ s2` iff `preorder(s1, s2) > 0` AND
|
|
14686
|
+
* `preorder(s2, s1) > 0`. The preorder here is the COMBINED one, where a
|
|
14687
|
+
* similarity edge is itself a step — not the `similarity_deleted` default of
|
|
14688
|
+
* {@link SortsClient.getPreorderDegree}.
|
|
14689
|
+
*
|
|
14690
|
+
* ⚠️ This route computes PROCESS-WIDE and then filters, so its classes can
|
|
14691
|
+
* be shaped by sorts the caller cannot see. {@link SortsClient.getQuotientOrder}
|
|
14692
|
+
* computes on the tenant-visible hierarchy instead, returns the same classes
|
|
14693
|
+
* with their degrees, and adds the partial order between them. Prefer it.
|
|
14569
14694
|
*
|
|
14570
14695
|
* Uses tagged serialization format.
|
|
14571
14696
|
*
|
|
@@ -15872,6 +15997,7 @@ function ProofDtoFromApiToFront(dto) {
|
|
|
15872
15997
|
kind: dto.kind,
|
|
15873
15998
|
goalTermId: dto.goal_term_id,
|
|
15874
15999
|
ruleTermId: dto.rule_term_id,
|
|
16000
|
+
ruleHeadTermId: dto.rule_head_term_id,
|
|
15875
16001
|
goalDisplay: dto.goal_display,
|
|
15876
16002
|
ruleLabel: dto.rule_label,
|
|
15877
16003
|
substitution: HomoiconicSubstitutionDtoFromApiToFront(dto.substitution),
|
|
@@ -16751,6 +16877,14 @@ var InferenceClient = class {
|
|
|
16751
16877
|
*
|
|
16752
16878
|
* The `timeout_ms` field on the request is a wall-clock timeout for the search.
|
|
16753
16879
|
* When it fires, the backend returns whatever solutions have been found so far.
|
|
16880
|
+
*
|
|
16881
|
+
* To join a proof node to the thing it proves, read `proof.goalTermId` — the
|
|
16882
|
+
* conclusion's term ID, which `client.terms.getTerm()` and
|
|
16883
|
+
* `client.query.findBySort()` both answer for. It is OPTIONAL: a goal proved
|
|
16884
|
+
* without a preceding forward chain materialises no conclusion, so the node
|
|
16885
|
+
* carries no id and `proof.goalDisplay` renders it instead. Do not read
|
|
16886
|
+
* `proof.ruleHeadTermId` as a fetchable id — it names the rule's instantiated
|
|
16887
|
+
* head, which the term routes refuse.
|
|
16754
16888
|
*/
|
|
16755
16889
|
async backwardChain(request, requestOptions) {
|
|
16756
16890
|
const wireRequest = {
|
|
@@ -16854,13 +16988,37 @@ var InferenceClient = class {
|
|
|
16854
16988
|
/**
|
|
16855
16989
|
* Run negation-as-failure (NAF) proof search.
|
|
16856
16990
|
*
|
|
16857
|
-
* @param request - NAF prove request.
|
|
16991
|
+
* @param request - NAF prove request. Each literal's `term` takes a
|
|
16992
|
+
* {@link psi} term or a wire {@link TermInputDto}, like every other
|
|
16993
|
+
* term-carrying method.
|
|
16858
16994
|
* @returns NAF proof result.
|
|
16859
16995
|
*
|
|
16996
|
+
* @remarks
|
|
16997
|
+
* Uses the untagged (homoiconic) serialization format: a literal's features
|
|
16998
|
+
* are plain scalars and `"?Var"` strings.
|
|
16999
|
+
*
|
|
17000
|
+
* @example
|
|
17001
|
+
* ```typescript
|
|
17002
|
+
* const result = await client.inference.nafProve({
|
|
17003
|
+
* literals: [
|
|
17004
|
+
* { term: psi('employee', { name: '?Name' }) },
|
|
17005
|
+
* { term: psi('senior_engineer', { name: '?Name' }), negated: true },
|
|
17006
|
+
* ],
|
|
17007
|
+
* maxSolutions: 10,
|
|
17008
|
+
* });
|
|
17009
|
+
* ```
|
|
17010
|
+
*
|
|
16860
17011
|
* @see proveWithNegation — friendlier alias for this method.
|
|
16861
17012
|
*/
|
|
16862
17013
|
async nafProve(request, requestOptions) {
|
|
16863
|
-
const
|
|
17014
|
+
const wireRequest = {
|
|
17015
|
+
...request,
|
|
17016
|
+
literals: request.literals?.map((literal) => ({
|
|
17017
|
+
...literal,
|
|
17018
|
+
term: convertTermArg(literal.term)
|
|
17019
|
+
}))
|
|
17020
|
+
};
|
|
17021
|
+
const response = await this.api.nafProve(NafProveRequestFromFrontToApi(wireRequest), toRequestParams(requestOptions));
|
|
16864
17022
|
return NafProveResponseFromApiToFront(response.data);
|
|
16865
17023
|
}
|
|
16866
17024
|
/**
|