@kortexya/reasoninglayer 1.23.0 → 1.24.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/dist/index.cjs +152 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +390 -32
- package/dist/index.d.ts +390 -32
- package/dist/index.js +152 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | object;
|
|
|
109
109
|
* This is the single source of truth for the version constant.
|
|
110
110
|
* The `scripts/release.sh` script updates this value alongside `package.json`.
|
|
111
111
|
*/
|
|
112
|
-
declare const SDK_VERSION = "1.
|
|
112
|
+
declare const SDK_VERSION = "1.24.0";
|
|
113
113
|
/**
|
|
114
114
|
* Authentication mode for the SDK.
|
|
115
115
|
*
|
|
@@ -764,11 +764,12 @@ interface AddRuleRequest$1 {
|
|
|
764
764
|
*/
|
|
765
765
|
antecedents?: TermInputDto$1[];
|
|
766
766
|
/**
|
|
767
|
-
* Certainty factor (
|
|
767
|
+
* Certainty factor. `None` (absent) is a crisp rule — degree 1.0; an
|
|
768
|
+
* explicit `0.0` is the t-norm annihilator, a rule that can never
|
|
769
|
+
* contribute a proof. The two are distinct on the wire (#217).
|
|
768
770
|
* @format double
|
|
769
|
-
* @default 1
|
|
770
771
|
*/
|
|
771
|
-
certainty?: number;
|
|
772
|
+
certainty?: number | null;
|
|
772
773
|
/** The conclusion term (head of the rule) */
|
|
773
774
|
term: TermInputDto$1;
|
|
774
775
|
}
|
|
@@ -11354,6 +11355,8 @@ type FeatureInputValueDto$1 = {
|
|
|
11354
11355
|
} | {
|
|
11355
11356
|
/** @format uuid */
|
|
11356
11357
|
sort_ref: string;
|
|
11358
|
+
} | {
|
|
11359
|
+
type: string;
|
|
11357
11360
|
} | {
|
|
11358
11361
|
name: string;
|
|
11359
11362
|
} | {
|
|
@@ -11852,7 +11855,11 @@ interface ForwardChainRequest$1 {
|
|
|
11852
11855
|
* Default: false (standard symbolic-only forward chaining)
|
|
11853
11856
|
*/
|
|
11854
11857
|
enable_provenance_tags?: boolean;
|
|
11855
|
-
/**
|
|
11858
|
+
/**
|
|
11859
|
+
* Initial facts (optional). The run's fact universe is the union of the
|
|
11860
|
+
* tenant's (gateway-visible) existing facts and these seeds, so a seed
|
|
11861
|
+
* AUGMENTS the base — it never replaces it (#218).
|
|
11862
|
+
*/
|
|
11856
11863
|
initial_facts?: TermInputDto$1[];
|
|
11857
11864
|
/**
|
|
11858
11865
|
* Maximum facts to derive
|
|
@@ -19792,34 +19799,21 @@ interface Objective$1 {
|
|
|
19792
19799
|
}
|
|
19793
19800
|
/** Direction of the objective function. */
|
|
19794
19801
|
type ObjectiveSense$1 = "minimize" | "maximize";
|
|
19795
|
-
/** One
|
|
19802
|
+
/** One observed unit. */
|
|
19796
19803
|
interface ObservationDto$1 {
|
|
19804
|
+
/** Binary treatment indicator (`true` = treated). */
|
|
19805
|
+
a: boolean;
|
|
19797
19806
|
/**
|
|
19798
|
-
*
|
|
19799
|
-
*
|
|
19800
|
-
* @min 0
|
|
19801
|
-
*/
|
|
19802
|
-
count: number;
|
|
19803
|
-
/** Distinct source documents. */
|
|
19804
|
-
documents: string[];
|
|
19805
|
-
/**
|
|
19806
|
-
* Unix seconds of the first sighting.
|
|
19807
|
+
* Discrete covariate stratum (integer code — bin a categorical or
|
|
19808
|
+
* coarsened-continuous confounder).
|
|
19807
19809
|
* @format int64
|
|
19808
19810
|
*/
|
|
19809
|
-
|
|
19811
|
+
x: number;
|
|
19810
19812
|
/**
|
|
19811
|
-
*
|
|
19812
|
-
* @format
|
|
19813
|
+
* Observed outcome.
|
|
19814
|
+
* @format double
|
|
19813
19815
|
*/
|
|
19814
|
-
|
|
19815
|
-
/** The normalised identity observations aggregate under. */
|
|
19816
|
-
normalized: string;
|
|
19817
|
-
/** Who saw it (`ingestion`, `extraction_certificate`, `sentinel_near_miss`). */
|
|
19818
|
-
producers: string[];
|
|
19819
|
-
/** The proposed sort's id, once a generate pass minted one. */
|
|
19820
|
-
proposed_sort_id?: string | null;
|
|
19821
|
-
/** Representative surface form. */
|
|
19822
|
-
surface: string;
|
|
19816
|
+
y: number;
|
|
19823
19817
|
}
|
|
19824
19818
|
/** Observational inputs for PN / PS */
|
|
19825
19819
|
interface ObservationalProbabilitiesDto$1 {
|
|
@@ -19842,7 +19836,7 @@ interface ObservationalProbabilitiesDto$1 {
|
|
|
19842
19836
|
/** Response of `GET /api/v1/sorts/proposals`. */
|
|
19843
19837
|
interface ObservationsResponse {
|
|
19844
19838
|
/** Observations, most recurrent first. */
|
|
19845
|
-
observations:
|
|
19839
|
+
observations: SightingDto[];
|
|
19846
19840
|
}
|
|
19847
19841
|
interface ObserveMultiRequest$1 {
|
|
19848
19842
|
/** Map of variable name to value */
|
|
@@ -23199,6 +23193,35 @@ interface RepairHintDto {
|
|
|
23199
23193
|
/** The feature or predicate the hint applies to. */
|
|
23200
23194
|
target: string;
|
|
23201
23195
|
}
|
|
23196
|
+
/**
|
|
23197
|
+
* Response of `PUT /api/v1/inference/rules/{id}`.
|
|
23198
|
+
*
|
|
23199
|
+
* ## Why two ids
|
|
23200
|
+
*
|
|
23201
|
+
* A rule's id **is** its head term id. Under `OSFKB_RULE_STABLE_IDS=1` that id
|
|
23202
|
+
* is content-addressed, so an edit that changes the head changes the id by
|
|
23203
|
+
* construction; under the default it is random, so a replacement changes it
|
|
23204
|
+
* anyway. There is no identity under which an edited rule is the same rule, so
|
|
23205
|
+
* the response names both: the id that was withdrawn, and the id that now
|
|
23206
|
+
* holds the edited clause. A client holding the old id must adopt the new one.
|
|
23207
|
+
*/
|
|
23208
|
+
interface ReplaceRuleResponse$1 {
|
|
23209
|
+
/** How the edit moved the rule base's guarantees. */
|
|
23210
|
+
certification: RuleCertificationDeltaDto;
|
|
23211
|
+
/**
|
|
23212
|
+
* The id the rule had before the edit. Every durable reference to it —
|
|
23213
|
+
* `derived_facts.rule_id`, each `proofs[].rule_id`, queued dataflow
|
|
23214
|
+
* events — was retracted rather than migrated: a conclusion proved by the
|
|
23215
|
+
* pre-edit clause is not proved by the post-edit one, which is the point
|
|
23216
|
+
* of the edit.
|
|
23217
|
+
* @format uuid
|
|
23218
|
+
*/
|
|
23219
|
+
previous_rule_id: string;
|
|
23220
|
+
/** The replacement rule, as created. */
|
|
23221
|
+
term: PsiTermDto$1;
|
|
23222
|
+
/** What withdrawing the previous rule removed. */
|
|
23223
|
+
withdrawal: RuleWithdrawalReport$1;
|
|
23224
|
+
}
|
|
23202
23225
|
/** Oversight verification result for the report. */
|
|
23203
23226
|
interface ReportVerification {
|
|
23204
23227
|
/**
|
|
@@ -24780,6 +24803,34 @@ interface RuleBaseCertificateDto {
|
|
|
24780
24803
|
/** The termination guarantee (or why it could not be established). */
|
|
24781
24804
|
termination: TerminationDto;
|
|
24782
24805
|
}
|
|
24806
|
+
/**
|
|
24807
|
+
* How an edit changed the rule base's termination and order-independence
|
|
24808
|
+
* guarantees.
|
|
24809
|
+
*
|
|
24810
|
+
* An edit can turn a certified-terminating rule base into a non-terminating
|
|
24811
|
+
* one, or introduce a functional conflict. `GET /api/v1/analysis/rule-base/certify`
|
|
24812
|
+
* computes the certificate live, so there is no stale cache to invalidate —
|
|
24813
|
+
* but a caller who never asks would discover the change when the next chain
|
|
24814
|
+
* run diverges. The write path therefore certifies before and after and
|
|
24815
|
+
* reports the delta.
|
|
24816
|
+
*/
|
|
24817
|
+
interface RuleCertificationDeltaDto {
|
|
24818
|
+
/** Whether it is order-independent after. */
|
|
24819
|
+
order_independent_after: boolean;
|
|
24820
|
+
/** Whether it was order-independent before the edit. */
|
|
24821
|
+
order_independent_before: boolean;
|
|
24822
|
+
/**
|
|
24823
|
+
* `true` when the edit weakened either guarantee. The edit is still
|
|
24824
|
+
* applied — refusing it would make a rule base unfixable once a previous
|
|
24825
|
+
* edit had broken it — but a client that ignores this field is flying
|
|
24826
|
+
* blind into a diverging chain run.
|
|
24827
|
+
*/
|
|
24828
|
+
regressed: boolean;
|
|
24829
|
+
/** Whether the rule base terminated before the edit. */
|
|
24830
|
+
terminated_before: boolean;
|
|
24831
|
+
/** Whether it terminates after. */
|
|
24832
|
+
terminates_after: boolean;
|
|
24833
|
+
}
|
|
24783
24834
|
/** A rule clause (OSF clause) */
|
|
24784
24835
|
interface RuleClauseDto$1 {
|
|
24785
24836
|
/** Constraints on variables in this clause */
|
|
@@ -24800,6 +24851,32 @@ type RuleConstraintDto$1 = {
|
|
|
24800
24851
|
var2: string;
|
|
24801
24852
|
type: "equal";
|
|
24802
24853
|
};
|
|
24854
|
+
/**
|
|
24855
|
+
* What `DELETE /api/v1/inference/rules/{id}` and
|
|
24856
|
+
* `PUT /api/v1/inference/rules/{id}` do about the conclusions the withdrawn
|
|
24857
|
+
* rule derived.
|
|
24858
|
+
*
|
|
24859
|
+
* A rule is not a row. Deleting one that silently keeps its derivations
|
|
24860
|
+
* leaves the knowledge base asserting conclusions whose only justification is
|
|
24861
|
+
* gone; deleting one that silently drops them destroys conclusions the caller
|
|
24862
|
+
* may not have known were at stake. Neither is a default anybody can audit,
|
|
24863
|
+
* so the disposition is named in the query — the same cut
|
|
24864
|
+
* `DELETE /api/v1/sorts/{id}?terms=…` applies to a sort's terms (#213).
|
|
24865
|
+
*
|
|
24866
|
+
* ## What it governs, and what it does not
|
|
24867
|
+
*
|
|
24868
|
+
* This decides the **materialized** tier only (`derived_facts`), because that
|
|
24869
|
+
* tier cannot re-derive itself synchronously — a row the withdrawal leaves
|
|
24870
|
+
* standing stays until the supervisor or a rebuild says otherwise.
|
|
24871
|
+
*
|
|
24872
|
+
* The **in-memory** tier is exact either way and needs no disposition: the
|
|
24873
|
+
* withdrawal walks the truth-maintenance cone from each deleted term and then
|
|
24874
|
+
* re-derives through the same cached `CHAIN;` plan the OSFQL service runs, so
|
|
24875
|
+
* every conclusion the surviving rules still prove comes back and every one
|
|
24876
|
+
* they do not is gone. The report's `consequences_invalidated` says how many
|
|
24877
|
+
* fell before the re-derivation.
|
|
24878
|
+
*/
|
|
24879
|
+
type RuleDerivationsDisposition$1 = "refuse" | "retract";
|
|
24803
24880
|
/** A draft inference rule. */
|
|
24804
24881
|
interface RuleDraftDto$1 {
|
|
24805
24882
|
/** Antecedent conditions (body). */
|
|
@@ -24885,6 +24962,63 @@ interface RuleUtilityDto$1 {
|
|
|
24885
24962
|
*/
|
|
24886
24963
|
utility: number;
|
|
24887
24964
|
}
|
|
24965
|
+
/**
|
|
24966
|
+
* What withdrawing a rule removed, in every tier that held part of it.
|
|
24967
|
+
*
|
|
24968
|
+
* A rule is one head row, N body rows, a rule-index entry, a set of in-memory
|
|
24969
|
+
* justifications, a set of `derived_facts` rows and their proof objects, and
|
|
24970
|
+
* the derived terms themselves. A response reporting only "deleted" would
|
|
24971
|
+
* name none of that, so each tier is counted separately.
|
|
24972
|
+
*/
|
|
24973
|
+
interface RuleWithdrawalReport$1 {
|
|
24974
|
+
/**
|
|
24975
|
+
* In-memory consequences invalidated by the truth-maintenance cone, before
|
|
24976
|
+
* the surviving ones were re-derived.
|
|
24977
|
+
* @min 0
|
|
24978
|
+
*/
|
|
24979
|
+
consequences_invalidated: number;
|
|
24980
|
+
/**
|
|
24981
|
+
* Materialized derivations (`derived_facts` rows) whose last proof this
|
|
24982
|
+
* rule was, so the row itself is gone.
|
|
24983
|
+
* @min 0
|
|
24984
|
+
*/
|
|
24985
|
+
derivations_removed: number;
|
|
24986
|
+
/**
|
|
24987
|
+
* Whether the derivation walk hit its visit cap and stopped early. A
|
|
24988
|
+
* truncated retraction is not a complete one; re-issue the request.
|
|
24989
|
+
*/
|
|
24990
|
+
derivations_truncated: boolean;
|
|
24991
|
+
/**
|
|
24992
|
+
* Materialized derivations that lost this rule's proofs but remain proved
|
|
24993
|
+
* by another rule. These are correctly left standing.
|
|
24994
|
+
* @min 0
|
|
24995
|
+
*/
|
|
24996
|
+
derivations_weakened: number;
|
|
24997
|
+
/**
|
|
24998
|
+
* Incomplete dataflow queue entries cancelled because they named this rule.
|
|
24999
|
+
* @min 0
|
|
25000
|
+
*/
|
|
25001
|
+
queued_events_cancelled: number;
|
|
25002
|
+
/**
|
|
25003
|
+
* The rule that was withdrawn.
|
|
25004
|
+
* @format uuid
|
|
25005
|
+
*/
|
|
25006
|
+
rule_id: string;
|
|
25007
|
+
/**
|
|
25008
|
+
* Terms deleted with it: the head plus the body, guard, variable and
|
|
25009
|
+
* operand terms the rule exclusively owned.
|
|
25010
|
+
* @min 0
|
|
25011
|
+
*/
|
|
25012
|
+
terms_deleted: number;
|
|
25013
|
+
/**
|
|
25014
|
+
* Terms of the rule's graph that were **kept** because something outside
|
|
25015
|
+
* the rule still holds them — another rule's antecedent, or a fact the
|
|
25016
|
+
* rule's body referenced. Deleting these would destroy data the rest of
|
|
25017
|
+
* the knowledge base owns.
|
|
25018
|
+
* @min 0
|
|
25019
|
+
*/
|
|
25020
|
+
terms_retained_shared: number;
|
|
25021
|
+
}
|
|
24888
25022
|
/** The payload an AG-UI client POSTs to start (or continue) a run. */
|
|
24889
25023
|
interface RunAgentInput {
|
|
24890
25024
|
/** Contextual key-value items. */
|
|
@@ -25972,6 +26106,46 @@ interface ShiftEffectResponse$1 {
|
|
|
25972
26106
|
*/
|
|
25973
26107
|
std_error: number;
|
|
25974
26108
|
}
|
|
26109
|
+
/**
|
|
26110
|
+
* One sighting on the wire — one unknown surface form the lattice does not
|
|
26111
|
+
* declare, with its recurrence evidence.
|
|
26112
|
+
*
|
|
26113
|
+
* Named `SightingDto`, not `ObservationDto`: the OpenAPI components namespace
|
|
26114
|
+
* is FLAT, and `crates/api/src/dto/semiparametric.rs` already registers an
|
|
26115
|
+
* `ObservationDto` — the `(x, a, y)` causal unit. Two live structs under one
|
|
26116
|
+
* schema name meant the spec silently kept only one, and the survivor
|
|
26117
|
+
* documented the wrong request body for `POST /api/v1/causal/ate` (#216). The
|
|
26118
|
+
* name is the schema; a rename costs nothing on the wire because the JSON
|
|
26119
|
+
* field names are the struct's, unchanged.
|
|
26120
|
+
*/
|
|
26121
|
+
interface SightingDto {
|
|
26122
|
+
/**
|
|
26123
|
+
* Sightings so far.
|
|
26124
|
+
* @format int64
|
|
26125
|
+
* @min 0
|
|
26126
|
+
*/
|
|
26127
|
+
count: number;
|
|
26128
|
+
/** Distinct source documents. */
|
|
26129
|
+
documents: string[];
|
|
26130
|
+
/**
|
|
26131
|
+
* Unix seconds of the first sighting.
|
|
26132
|
+
* @format int64
|
|
26133
|
+
*/
|
|
26134
|
+
first_seen: number;
|
|
26135
|
+
/**
|
|
26136
|
+
* Unix seconds of the latest sighting.
|
|
26137
|
+
* @format int64
|
|
26138
|
+
*/
|
|
26139
|
+
last_seen: number;
|
|
26140
|
+
/** The normalised identity observations aggregate under. */
|
|
26141
|
+
normalized: string;
|
|
26142
|
+
/** Who saw it (`ingestion`, `extraction_certificate`, `sentinel_near_miss`). */
|
|
26143
|
+
producers: string[];
|
|
26144
|
+
/** The proposed sort's id, once a generate pass minted one. */
|
|
26145
|
+
proposed_sort_id?: string | null;
|
|
26146
|
+
/** Representative surface form. */
|
|
26147
|
+
surface: string;
|
|
26148
|
+
}
|
|
25975
26149
|
/** A single similarity entry for bulk operations */
|
|
25976
26150
|
interface SimilarityEntry {
|
|
25977
26151
|
/**
|
|
@@ -34361,6 +34535,19 @@ declare class Inference<SecurityDataType = unknown> {
|
|
|
34361
34535
|
/** Also delete referenced terms */
|
|
34362
34536
|
delete_references?: boolean;
|
|
34363
34537
|
}, params?: RequestParams) => Promise<HttpResponse<DeleteGoalResponse$1, void>>;
|
|
34538
|
+
/**
|
|
34539
|
+
* @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag, and requires it under `OSFKB_REQUIRE_IF_MATCH=1`. Every request is captured by the audit middleware.
|
|
34540
|
+
*
|
|
34541
|
+
* @tags inference
|
|
34542
|
+
* @name DeleteRule
|
|
34543
|
+
* @summary Delete a rule.
|
|
34544
|
+
* @request DELETE:/api/v1/inference/rules/{id}
|
|
34545
|
+
* @secure
|
|
34546
|
+
*/
|
|
34547
|
+
deleteRule: (id: string, query?: {
|
|
34548
|
+
/** What to do about the conclusions this rule derived. */
|
|
34549
|
+
derivations?: RuleDerivationsDisposition$1;
|
|
34550
|
+
}, params?: RequestParams) => Promise<HttpResponse<RuleWithdrawalReport$1, void>>;
|
|
34364
34551
|
/**
|
|
34365
34552
|
* @description Never writes to the KB — returns validated drafts for human review.
|
|
34366
34553
|
*
|
|
@@ -34443,15 +34630,15 @@ declare class Inference<SecurityDataType = unknown> {
|
|
|
34443
34630
|
*/
|
|
34444
34631
|
getMetaSorts: (params?: RequestParams) => Promise<HttpResponse<MetaSortsResponse$1, any>>;
|
|
34445
34632
|
/**
|
|
34446
|
-
* @description # Authorization Requires X-Tenant-Id header.
|
|
34633
|
+
* @description # Authorization Requires X-Tenant-Id header, and the path tenant must equal it. # The path segment Named `{id}` because `DELETE` and `PUT` on the same path address ONE RULE by term id (#231), and one segment cannot carry two names. Here it is the tenant — and a redundant one, since any value but the authenticated principal is refused.
|
|
34447
34634
|
*
|
|
34448
34635
|
* @tags inference
|
|
34449
34636
|
* @name GetRules
|
|
34450
34637
|
* @summary Get all rules (clauses with antecedents) for a tenant
|
|
34451
|
-
* @request GET:/api/v1/inference/rules/{
|
|
34638
|
+
* @request GET:/api/v1/inference/rules/{id}
|
|
34452
34639
|
* @secure
|
|
34453
34640
|
*/
|
|
34454
|
-
getRules: (
|
|
34641
|
+
getRules: (id: string, params?: RequestParams) => Promise<HttpResponse<GetRulesResponse$1, any>>;
|
|
34455
34642
|
/**
|
|
34456
34643
|
* @description # TRUE HOMOICONICITY Goals are Ψ-terms persisted to PostgreSQL. This endpoint returns all goals for the authenticated tenant with summary information. # Authorization Requires X-Tenant-Id header.
|
|
34457
34644
|
*
|
|
@@ -34482,6 +34669,16 @@ declare class Inference<SecurityDataType = unknown> {
|
|
|
34482
34669
|
* @secure
|
|
34483
34670
|
*/
|
|
34484
34671
|
predictWithOrchestrator: (data: OrchestratorPredictRequest, params?: RequestParams) => Promise<HttpResponse<OrchestratorPredictResponse, void>>;
|
|
34672
|
+
/**
|
|
34673
|
+
* @description # An edit addresses ONE clause "Edit the rule for X" is ambiguous, because the authoring UI's "add clause" writes a *second* rule with the same conclusion, OR-unioned with the first. The path names a single rule term — one disjunct — so a client cannot silently edit the wrong one. # The old rule is withdrawn, not amended Everything `DELETE` does happens, always with the retract disposition: an edit that leaves the pre-edit clause's conclusions standing is exactly the defect this route exists to fix. The replacement is created through the same code `POST /api/v1/inference/rules` runs, so creation's guards — #227's guard canonicalisation, #219's range restriction, #217's certainty distinction — hold for an edit too, and a rejected replacement leaves the rule base untouched because the build runs BEFORE the clause is de-indexed. The response carries `previous_rule_id` alongside the new rule: a rule's id is its conclusion term id, so an edit changes it by construction. When the replacement is content-addressed to the same id (identical conclusion under `OSFKB_RULE_STABLE_IDS=1`), the two are equal and the edit was applied in place — the outgoing clause's now-unused antecedents are still collected and deleted. # Authorization Identical to `DELETE`: the delete guard on the outgoing rule, `If-Match` against its conclusion, and audit capture.
|
|
34674
|
+
*
|
|
34675
|
+
* @tags inference
|
|
34676
|
+
* @name ReplaceRule
|
|
34677
|
+
* @summary Replace a rule.
|
|
34678
|
+
* @request PUT:/api/v1/inference/rules/{id}
|
|
34679
|
+
* @secure
|
|
34680
|
+
*/
|
|
34681
|
+
replaceRule: (id: string, data: AddRuleRequest$1, params?: RequestParams) => Promise<HttpResponse<ReplaceRuleResponse$1, void>>;
|
|
34485
34682
|
/**
|
|
34486
34683
|
* @description In OSF/LIFE terms, the orchestrator pushes the conclusion gate and each antecedent gate toward the dual-weighted satisfaction objective `1 − ( w_D · K_D + w_K · K_K )` (paper eq. 4). Each call performs exactly one epoch over the supplied batch — the response carries the per-epoch metrics for that single epoch (multi-epoch aggregation is the caller's responsibility). # Authorization Requires `X-Tenant-Id` header.
|
|
34487
34684
|
*
|
|
@@ -35178,6 +35375,91 @@ interface GetRulesResponse {
|
|
|
35178
35375
|
/** The rules (clauses with antecedents). */
|
|
35179
35376
|
rules: RuleEntryDto[];
|
|
35180
35377
|
}
|
|
35378
|
+
/** What a rule withdrawal does about the conclusions the rule derived. */
|
|
35379
|
+
type RuleDerivationsDisposition = 'refuse' | 'retract';
|
|
35380
|
+
/**
|
|
35381
|
+
* What withdrawing a rule removed, in every tier that held part of it.
|
|
35382
|
+
*
|
|
35383
|
+
* @remarks
|
|
35384
|
+
* A rule is not a row. It is one conclusion term, N antecedent pattern terms,
|
|
35385
|
+
* a rule-index entry, a set of in-memory justifications, a set of materialized
|
|
35386
|
+
* derivations with their proof objects, and the derived terms themselves. Each
|
|
35387
|
+
* tier is counted separately, because a response reporting only "deleted" would
|
|
35388
|
+
* name none of it.
|
|
35389
|
+
*/
|
|
35390
|
+
interface RuleWithdrawalReport {
|
|
35391
|
+
/** The rule that was withdrawn (UUID). */
|
|
35392
|
+
ruleId: string;
|
|
35393
|
+
/**
|
|
35394
|
+
* Terms deleted with it: the conclusion plus the antecedent, guard, variable
|
|
35395
|
+
* and operand terms the rule exclusively owned.
|
|
35396
|
+
*/
|
|
35397
|
+
termsDeleted: number;
|
|
35398
|
+
/**
|
|
35399
|
+
* Terms of the rule's graph that were KEPT because something outside the rule
|
|
35400
|
+
* still holds them — another rule's antecedent, or a fact the body
|
|
35401
|
+
* referenced. Deleting these would destroy data the rest of the knowledge
|
|
35402
|
+
* base owns.
|
|
35403
|
+
*/
|
|
35404
|
+
termsRetainedShared: number;
|
|
35405
|
+
/** Materialized derivations whose last proof this rule was, so the row is gone. */
|
|
35406
|
+
derivationsRemoved: number;
|
|
35407
|
+
/**
|
|
35408
|
+
* Materialized derivations that lost this rule's proofs but remain proved by
|
|
35409
|
+
* another rule. These are correctly left standing.
|
|
35410
|
+
*/
|
|
35411
|
+
derivationsWeakened: number;
|
|
35412
|
+
/**
|
|
35413
|
+
* Whether the derivation walk hit its visit cap and stopped early. A
|
|
35414
|
+
* truncated retraction is not a complete one; re-issue the request.
|
|
35415
|
+
*/
|
|
35416
|
+
derivationsTruncated: boolean;
|
|
35417
|
+
/**
|
|
35418
|
+
* In-memory consequences invalidated by the truth-maintenance cone, before
|
|
35419
|
+
* the surviving ones were re-derived.
|
|
35420
|
+
*/
|
|
35421
|
+
consequencesInvalidated: number;
|
|
35422
|
+
/** Incomplete dataflow queue entries cancelled because they named this rule. */
|
|
35423
|
+
queuedEventsCancelled: number;
|
|
35424
|
+
}
|
|
35425
|
+
/** How an edit changed the rule base's termination and order-independence guarantees. */
|
|
35426
|
+
interface RuleCertificationDelta {
|
|
35427
|
+
/** Whether the rule base terminated before the edit. */
|
|
35428
|
+
terminatedBefore: boolean;
|
|
35429
|
+
/** Whether it terminates after. */
|
|
35430
|
+
terminatesAfter: boolean;
|
|
35431
|
+
/** Whether it was order-independent before the edit. */
|
|
35432
|
+
orderIndependentBefore: boolean;
|
|
35433
|
+
/** Whether it is order-independent after. */
|
|
35434
|
+
orderIndependentAfter: boolean;
|
|
35435
|
+
/**
|
|
35436
|
+
* `true` when the edit weakened either guarantee. The edit is still applied —
|
|
35437
|
+
* refusing it would make a rule base unfixable once a previous edit had
|
|
35438
|
+
* broken it — but a client that ignores this is flying blind into a diverging
|
|
35439
|
+
* chain run.
|
|
35440
|
+
*/
|
|
35441
|
+
regressed: boolean;
|
|
35442
|
+
}
|
|
35443
|
+
/** Result of replacing a rule. */
|
|
35444
|
+
interface ReplaceRuleResponse {
|
|
35445
|
+
/**
|
|
35446
|
+
* The id the rule had before the edit.
|
|
35447
|
+
*
|
|
35448
|
+
* @remarks
|
|
35449
|
+
* A rule's id IS its conclusion term id, so an edit changes it by
|
|
35450
|
+
* construction. Durable references to the old id are retracted rather than
|
|
35451
|
+
* migrated: a conclusion proved by the pre-edit clause is not proved by the
|
|
35452
|
+
* post-edit one, which is the point of the edit. A client holding the old id
|
|
35453
|
+
* must adopt the new one.
|
|
35454
|
+
*/
|
|
35455
|
+
previousRuleId: string;
|
|
35456
|
+
/** The replacement rule, as created. */
|
|
35457
|
+
term: PsiTermDto;
|
|
35458
|
+
/** What withdrawing the previous rule removed. */
|
|
35459
|
+
withdrawal: RuleWithdrawalReport;
|
|
35460
|
+
/** How the edit moved the rule base's guarantees. */
|
|
35461
|
+
certification: RuleCertificationDelta;
|
|
35462
|
+
}
|
|
35181
35463
|
/**
|
|
35182
35464
|
* Response listing the meta-sorts (built-in system sorts) for inference.
|
|
35183
35465
|
*
|
|
@@ -35507,17 +35789,21 @@ type inference_NafProveRequest = NafProveRequest;
|
|
|
35507
35789
|
type inference_NafProveResponse = NafProveResponse;
|
|
35508
35790
|
type inference_ProofDto = ProofDto;
|
|
35509
35791
|
type inference_ProvenanceTagDto = ProvenanceTagDto;
|
|
35792
|
+
type inference_ReplaceRuleResponse = ReplaceRuleResponse;
|
|
35510
35793
|
type inference_RuleAggregatorDto = RuleAggregatorDto;
|
|
35794
|
+
type inference_RuleCertificationDelta = RuleCertificationDelta;
|
|
35795
|
+
type inference_RuleDerivationsDisposition = RuleDerivationsDisposition;
|
|
35511
35796
|
type inference_RuleDraftClarificationQuestionDto = RuleDraftClarificationQuestionDto;
|
|
35512
35797
|
type inference_RuleDraftDto = RuleDraftDto;
|
|
35513
35798
|
type inference_RuleEntryDto = RuleEntryDto;
|
|
35514
35799
|
type inference_RuleTermDraftDto = RuleTermDraftDto;
|
|
35800
|
+
type inference_RuleWithdrawalReport = RuleWithdrawalReport;
|
|
35515
35801
|
type inference_SolutionDto = SolutionDto;
|
|
35516
35802
|
type inference_TaggedDerivedFact = TaggedDerivedFact;
|
|
35517
35803
|
type inference_TaggedForwardChainRequest = TaggedForwardChainRequest;
|
|
35518
35804
|
type inference_TaggedForwardChainResponse = TaggedForwardChainResponse;
|
|
35519
35805
|
declare namespace inference {
|
|
35520
|
-
export type { inference_AddFactRequest as AddFactRequest, inference_AddFactResponse as AddFactResponse, inference_AddRuleRequest as AddRuleRequest, inference_AddRuleResponse as AddRuleResponse, inference_AllenRelation as AllenRelation, inference_BackwardChainRequest as BackwardChainRequest, inference_BackwardChainResponse as BackwardChainResponse, inference_BayesianEffectDto as BayesianEffectDto, inference_BayesianPredictRequest as BayesianPredictRequest, inference_BayesianPredictResponse as BayesianPredictResponse, inference_BindingDto as BindingDto, inference_BulkAddFactsRequest as BulkAddFactsRequest, inference_BulkAddFactsResponse as BulkAddFactsResponse, inference_BulkAddRulesRequest as BulkAddRulesRequest, inference_BulkAddRulesResponse as BulkAddRulesResponse, inference_BulkFuzzyProveRequest as BulkFuzzyProveRequest, inference_BulkFuzzyProveResponse as BulkFuzzyProveResponse, inference_ClearFactsResponse as ClearFactsResponse, inference_ConstraintInputDto as ConstraintInputDto, inference_CreateGoalRequest as CreateGoalRequest, inference_CreateGoalResponse as CreateGoalResponse, inference_DeleteGoalResponse as DeleteGoalResponse, inference_DraftRulesRequest as DraftRulesRequest, inference_DraftRulesResponse as DraftRulesResponse, inference_FactConfidenceEntry as FactConfidenceEntry, inference_ForwardChainRequest as ForwardChainRequest, inference_ForwardChainResponse as ForwardChainResponse, inference_FuzzyProveRequest as FuzzyProveRequest, inference_FuzzyProveResponse as FuzzyProveResponse, inference_GetFactsResponse as GetFactsResponse, inference_GetRulesResponse as GetRulesResponse, inference_GoalDto as GoalDto, inference_GoalSummaryDto as GoalSummaryDto, inference_GuardOp as GuardOp, inference_HomoiconicSubstitutionDto as HomoiconicSubstitutionDto, inference_ListGoalsResponse as ListGoalsResponse, inference_LiteralInputDto as LiteralInputDto, inference_MetaSortsResponse as MetaSortsResponse, inference_NafProveRequest as NafProveRequest, inference_NafProveResponse as NafProveResponse, inference_ProofDto as ProofDto, inference_ProvenanceTagDto as ProvenanceTagDto, inference_RuleAggregatorDto as RuleAggregatorDto, inference_RuleDraftClarificationQuestionDto as RuleDraftClarificationQuestionDto, inference_RuleDraftDto as RuleDraftDto, inference_RuleEntryDto as RuleEntryDto, inference_RuleTermDraftDto as RuleTermDraftDto, inference_SolutionDto as SolutionDto, inference_TaggedDerivedFact as TaggedDerivedFact, inference_TaggedForwardChainRequest as TaggedForwardChainRequest, inference_TaggedForwardChainResponse as TaggedForwardChainResponse };
|
|
35806
|
+
export type { inference_AddFactRequest as AddFactRequest, inference_AddFactResponse as AddFactResponse, inference_AddRuleRequest as AddRuleRequest, inference_AddRuleResponse as AddRuleResponse, inference_AllenRelation as AllenRelation, inference_BackwardChainRequest as BackwardChainRequest, inference_BackwardChainResponse as BackwardChainResponse, inference_BayesianEffectDto as BayesianEffectDto, inference_BayesianPredictRequest as BayesianPredictRequest, inference_BayesianPredictResponse as BayesianPredictResponse, inference_BindingDto as BindingDto, inference_BulkAddFactsRequest as BulkAddFactsRequest, inference_BulkAddFactsResponse as BulkAddFactsResponse, inference_BulkAddRulesRequest as BulkAddRulesRequest, inference_BulkAddRulesResponse as BulkAddRulesResponse, inference_BulkFuzzyProveRequest as BulkFuzzyProveRequest, inference_BulkFuzzyProveResponse as BulkFuzzyProveResponse, inference_ClearFactsResponse as ClearFactsResponse, inference_ConstraintInputDto as ConstraintInputDto, inference_CreateGoalRequest as CreateGoalRequest, inference_CreateGoalResponse as CreateGoalResponse, inference_DeleteGoalResponse as DeleteGoalResponse, inference_DraftRulesRequest as DraftRulesRequest, inference_DraftRulesResponse as DraftRulesResponse, inference_FactConfidenceEntry as FactConfidenceEntry, inference_ForwardChainRequest as ForwardChainRequest, inference_ForwardChainResponse as ForwardChainResponse, inference_FuzzyProveRequest as FuzzyProveRequest, inference_FuzzyProveResponse as FuzzyProveResponse, inference_GetFactsResponse as GetFactsResponse, inference_GetRulesResponse as GetRulesResponse, inference_GoalDto as GoalDto, inference_GoalSummaryDto as GoalSummaryDto, inference_GuardOp as GuardOp, inference_HomoiconicSubstitutionDto as HomoiconicSubstitutionDto, inference_ListGoalsResponse as ListGoalsResponse, inference_LiteralInputDto as LiteralInputDto, inference_MetaSortsResponse as MetaSortsResponse, inference_NafProveRequest as NafProveRequest, inference_NafProveResponse as NafProveResponse, inference_ProofDto as ProofDto, inference_ProvenanceTagDto as ProvenanceTagDto, inference_ReplaceRuleResponse as ReplaceRuleResponse, inference_RuleAggregatorDto as RuleAggregatorDto, inference_RuleCertificationDelta as RuleCertificationDelta, inference_RuleDerivationsDisposition as RuleDerivationsDisposition, inference_RuleDraftClarificationQuestionDto as RuleDraftClarificationQuestionDto, inference_RuleDraftDto as RuleDraftDto, inference_RuleEntryDto as RuleEntryDto, inference_RuleTermDraftDto as RuleTermDraftDto, inference_RuleWithdrawalReport as RuleWithdrawalReport, inference_SolutionDto as SolutionDto, inference_TaggedDerivedFact as TaggedDerivedFact, inference_TaggedForwardChainRequest as TaggedForwardChainRequest, inference_TaggedForwardChainResponse as TaggedForwardChainResponse };
|
|
35521
35807
|
}
|
|
35522
35808
|
|
|
35523
35809
|
/**
|
|
@@ -35630,6 +35916,78 @@ declare class InferenceClient {
|
|
|
35630
35916
|
* ```
|
|
35631
35917
|
*/
|
|
35632
35918
|
getRules(): Promise<GetRulesResponse>;
|
|
35919
|
+
/**
|
|
35920
|
+
* Withdraw one rule from the knowledge base.
|
|
35921
|
+
*
|
|
35922
|
+
* @param ruleId - Term id of the rule (its conclusion), as returned by
|
|
35923
|
+
* {@link InferenceClient.addRule} or {@link InferenceClient.getRules}.
|
|
35924
|
+
* @param options - `derivations` decides what happens to the conclusions the
|
|
35925
|
+
* rule derived. Defaults to `'refuse'`.
|
|
35926
|
+
* @returns What the withdrawal removed, tier by tier.
|
|
35927
|
+
* @throws {ApiError} 400 if the id names a fact rather than a rule, or if the
|
|
35928
|
+
* rule still supports derivations under the default `'refuse'`; 403 for a
|
|
35929
|
+
* system, plugin-owned or bootstrap rule; 404 if no such rule exists.
|
|
35930
|
+
*
|
|
35931
|
+
* @remarks
|
|
35932
|
+
* A rule is not a row. Withdrawing one deletes its conclusion AND the
|
|
35933
|
+
* antecedent pattern, guard and variable terms it exclusively owns — a
|
|
35934
|
+
* conclusion-only delete would leave those patterns readable as ordinary
|
|
35935
|
+
* facts — while keeping every term the rest of the knowledge base still
|
|
35936
|
+
* holds.
|
|
35937
|
+
*
|
|
35938
|
+
* `'refuse'` (the default) refuses while the rule still proves materialized
|
|
35939
|
+
* conclusions and says how many; `'retract'` withdraws them with it. A delete
|
|
35940
|
+
* that silently drops derivations is as wrong as one that silently keeps
|
|
35941
|
+
* them, so neither is the unnamed default.
|
|
35942
|
+
*
|
|
35943
|
+
* @example
|
|
35944
|
+
* ```typescript
|
|
35945
|
+
* const report = await client.inference.deleteRule(ruleId, { derivations: 'retract' });
|
|
35946
|
+
* console.log(report.termsDeleted, report.derivationsRemoved);
|
|
35947
|
+
* ```
|
|
35948
|
+
*/
|
|
35949
|
+
deleteRule(ruleId: string, options?: {
|
|
35950
|
+
derivations?: RuleDerivationsDisposition;
|
|
35951
|
+
}): Promise<RuleWithdrawalReport>;
|
|
35952
|
+
/**
|
|
35953
|
+
* Replace one rule with a new one.
|
|
35954
|
+
*
|
|
35955
|
+
* @param ruleId - Term id of the rule (its conclusion) to replace.
|
|
35956
|
+
* @param request - The replacement rule, in the same shape
|
|
35957
|
+
* {@link InferenceClient.addRule} takes.
|
|
35958
|
+
* @returns The replacement, the id it replaced, what the withdrawal removed,
|
|
35959
|
+
* and how the rule base's guarantees moved.
|
|
35960
|
+
* @throws {ApiError} 422 if the replacement is rejected by the authoring
|
|
35961
|
+
* guards — in which case the original rule is left live; 400/403/404 as for
|
|
35962
|
+
* {@link InferenceClient.deleteRule}.
|
|
35963
|
+
*
|
|
35964
|
+
* @remarks
|
|
35965
|
+
* A rule's id IS its conclusion term id, so an edit changes it by
|
|
35966
|
+
* construction. The response carries `previousRuleId` alongside the new
|
|
35967
|
+
* rule; a client holding the old id must adopt the new one.
|
|
35968
|
+
*
|
|
35969
|
+
* The path names ONE rule term — one disjunct. Two rules with the same
|
|
35970
|
+
* conclusion are OR-unioned, so "edit the rule for X" is ambiguous and this
|
|
35971
|
+
* addresses a single clause.
|
|
35972
|
+
*
|
|
35973
|
+
* @example
|
|
35974
|
+
* ```typescript
|
|
35975
|
+
* const result = await client.inference.replaceRule(ruleId, {
|
|
35976
|
+
* term: psi('retiree', { name: Var('N') }),
|
|
35977
|
+
* antecedents: [psi('person', { name: Var('N') })],
|
|
35978
|
+
* });
|
|
35979
|
+
* console.log(result.previousRuleId, '->', result.term.termId);
|
|
35980
|
+
* if (result.certification.regressed) {
|
|
35981
|
+
* console.warn('the edit weakened the rule base guarantees');
|
|
35982
|
+
* }
|
|
35983
|
+
* ```
|
|
35984
|
+
*/
|
|
35985
|
+
replaceRule(ruleId: string, request: {
|
|
35986
|
+
term: TermInputArg;
|
|
35987
|
+
antecedents?: TermInputArg[];
|
|
35988
|
+
certainty?: number;
|
|
35989
|
+
aggregator?: RuleAggregatorDto | null;
|
|
35990
|
+
}): Promise<ReplaceRuleResponse>;
|
|
35633
35991
|
/**
|
|
35634
35992
|
* Query for matching data by searching rules and facts backwards from a goal pattern.
|
|
35635
35993
|
*
|