@kortexya/reasoninglayer 1.0.1 → 1.2.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 CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/config.ts
10
- var SDK_VERSION = "1.0.1";
10
+ var SDK_VERSION = "1.2.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -1519,6 +1519,24 @@ var Inference = class {
1519
1519
  format: "json",
1520
1520
  ...params
1521
1521
  });
1522
+ /**
1523
+ * @description In OSF/LIFE terms, an orchestrator wires neural sort-subsumption gates (`τ(x ⊑ S) ∈ [0, 1]`) for a conclusion sort and a set of antecedent sorts. Knowledge axioms reference homoiconic rule Ψ-terms registered in the tenant's KB. The first call lazily instantiates the underlying Candle-backed gates; subsequent calls within the same tenant share gate state. # Authorization Requires `X-Tenant-Id` header.
1524
+ *
1525
+ * @tags inference
1526
+ * @name ConfigureOrchestrator
1527
+ * @summary Register an OSF Neural-Predicate Orchestrator configuration for the calling tenant.
1528
+ * @request POST:/api/v1/inference/orchestrator/configure
1529
+ * @secure
1530
+ */
1531
+ configureOrchestrator = (data, params = {}) => this.http.request({
1532
+ path: `/api/v1/inference/orchestrator/configure`,
1533
+ method: "POST",
1534
+ body: data,
1535
+ secure: true,
1536
+ type: "application/json" /* Json */,
1537
+ format: "json",
1538
+ ...params
1539
+ });
1522
1540
  /**
1523
1541
  * @description # TRUE HOMOICONICITY Goals are first-class Ψ-terms that can be created, persisted, and reused. This endpoint creates a goal from clauses and optional constraints, persists it to PostgreSQL, and returns the goal ID for later use. # Authorization Requires X-Tenant-Id header.
1524
1542
  *
@@ -1690,6 +1708,42 @@ var Inference = class {
1690
1708
  format: "json",
1691
1709
  ...params
1692
1710
  });
1711
+ /**
1712
+ * @description In OSF/LIFE terms, the orchestrator forwards the Ψ-term through the conclusion gate to read `τ(x ⊑ conclusion_sort)`, then for each knowledge axiom evaluates its antecedent gates and combines them with the conclusion truth via Reichenbach (`1 − a + a · c`). The fused confidence aggregates per-axiom modus-ponens witness strength via noisy-OR. # Authorization Requires `X-Tenant-Id` header.
1713
+ *
1714
+ * @tags inference
1715
+ * @name PredictWithOrchestrator
1716
+ * @summary Score a single Ψ-term: conclusion subsumption probability + per-axiom firing trace + noisy-OR fused confidence.
1717
+ * @request POST:/api/v1/inference/orchestrator/predict
1718
+ * @secure
1719
+ */
1720
+ predictWithOrchestrator = (data, params = {}) => this.http.request({
1721
+ path: `/api/v1/inference/orchestrator/predict`,
1722
+ method: "POST",
1723
+ body: data,
1724
+ secure: true,
1725
+ type: "application/json" /* Json */,
1726
+ format: "json",
1727
+ ...params
1728
+ });
1729
+ /**
1730
+ * @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.
1731
+ *
1732
+ * @tags inference
1733
+ * @name TrainOrchestrator
1734
+ * @summary Run one training epoch over a labelled Ψ-term batch.
1735
+ * @request POST:/api/v1/inference/orchestrator/train
1736
+ * @secure
1737
+ */
1738
+ trainOrchestrator = (data, params = {}) => this.http.request({
1739
+ path: `/api/v1/inference/orchestrator/train`,
1740
+ method: "POST",
1741
+ body: data,
1742
+ secure: true,
1743
+ type: "application/json" /* Json */,
1744
+ format: "json",
1745
+ ...params
1746
+ });
1693
1747
  };
1694
1748
 
1695
1749
  // src/api-spec/generated/Cognitive.ts
@@ -4271,6 +4325,24 @@ var Visualization = class {
4271
4325
  constructor(http) {
4272
4326
  this.http = http;
4273
4327
  }
4328
+ /**
4329
+ * @description Note: when MVCC branching isn't materialized as named branches in the user's store, this endpoint surfaces an empty diff. The shape is preserved so clients can rely on it without conditional code.
4330
+ *
4331
+ * @tags visualization
4332
+ * @name GetBranchDiffVisualization
4333
+ * @summary Render the diff between two MVCC branches of the tenant's term store. Each visible Ψ-term carries `properties.diff` ∈ `{added, removed, changed}` so the renderer can color-distinguish.
4334
+ * @request POST:/api/v1/visualization/branch-diff
4335
+ * @secure
4336
+ */
4337
+ getBranchDiffVisualization = (data, params = {}) => this.http.request({
4338
+ path: `/api/v1/visualization/branch-diff`,
4339
+ method: "POST",
4340
+ body: data,
4341
+ secure: true,
4342
+ type: "application/json" /* Json */,
4343
+ format: "json",
4344
+ ...params
4345
+ });
4274
4346
  /**
4275
4347
  * No description
4276
4348
  *
@@ -4289,6 +4361,75 @@ var Visualization = class {
4289
4361
  format: "json",
4290
4362
  ...params
4291
4363
  });
4364
+ /**
4365
+ * @description Each event is a JSON-encoded `DerivationStepEvent` with shape: ```json { "iteration": 3, "rule_id": "uuid", "antecedents": ["uuid",...], "derived_fact": "uuid" } ``` Sent once per record produced during the chainer pass. The client can animate each polygon emerging as its premise edges arrive.
4366
+ *
4367
+ * @tags visualization
4368
+ * @name GetDerivationStream
4369
+ * @summary SSE channel that streams the forward-chainer's derivation steps as they fire, instead of blocking until the full trace is assembled.
4370
+ * @request GET:/api/v1/visualization/derivation/stream
4371
+ * @secure
4372
+ */
4373
+ getDerivationStream = (params = {}) => this.http.request({
4374
+ path: `/api/v1/visualization/derivation/stream`,
4375
+ method: "GET",
4376
+ secure: true,
4377
+ ...params
4378
+ });
4379
+ /**
4380
+ * @description Runs the homoiconic forward chainer with provenance enabled and emits a [`VisualizationGraph`] in which: - **Nodes** are Ψ-terms (each one is either an asserted fact, a rule, or a derived fact). Rules surface as `NodeType::Rule`. - **Edges** are `EdgeType::Derivation`, oriented antecedent → rule-application → produced-fact, mirroring the proof DAG. - **Hyperedges** are `HyperedgeType::DerivationStep` — one per rule application, grouping the rule with all its antecedents plus the produced fact. Rendering each step as a polygon makes "this fact came from these premises via this rule" visually atomic — exactly the idea behind Aït-Kaci & Sasaki's proof-tree diagrams in OSF/LIFE papers.
4381
+ *
4382
+ * @tags visualization
4383
+ * @name GetDerivationVisualization
4384
+ * @summary Get the forward-chain derivation lattice as a meta-hypergraph.
4385
+ * @request POST:/api/v1/visualization/derivation
4386
+ * @secure
4387
+ */
4388
+ getDerivationVisualization = (data, params = {}) => this.http.request({
4389
+ path: `/api/v1/visualization/derivation`,
4390
+ method: "POST",
4391
+ body: data,
4392
+ secure: true,
4393
+ type: "application/json" /* Json */,
4394
+ format: "json",
4395
+ ...params
4396
+ });
4397
+ /**
4398
+ * No description
4399
+ *
4400
+ * @tags visualization
4401
+ * @name GetFunctionsVisualization
4402
+ * @summary Render the LIFE-style function definitions in the tenant's term store. A LIFE function is itself a Ψ-term (homoiconic) — typically a term whose sort is `function` (or a subtype) carrying features `head`, `body`, optional `equations`. This handler scans the store for terms matching that signature and emits one TermFeatures-style hyperedge per function so each is visually atomic.
4403
+ * @request POST:/api/v1/visualization/functions
4404
+ * @secure
4405
+ */
4406
+ getFunctionsVisualization = (data, params = {}) => this.http.request({
4407
+ path: `/api/v1/visualization/functions`,
4408
+ method: "POST",
4409
+ body: data,
4410
+ secure: true,
4411
+ type: "application/json" /* Json */,
4412
+ format: "json",
4413
+ ...params
4414
+ });
4415
+ /**
4416
+ * No description
4417
+ *
4418
+ * @tags visualization
4419
+ * @name GetGradedPosetVisualization
4420
+ * @summary Render the graded-poset projection of the tenant's sort hierarchy per "Weisfeiler & Lehman Go Categorical" (Choi, Kim, Yun 2026): - elements = sorts - dimension(σ) = topological depth from the lattice top - coverings = parent → child (subtype) - 4-adjacency edges when requested
4421
+ * @request POST:/api/v1/visualization/graded-poset
4422
+ * @secure
4423
+ */
4424
+ getGradedPosetVisualization = (data, params = {}) => this.http.request({
4425
+ path: `/api/v1/visualization/graded-poset`,
4426
+ method: "POST",
4427
+ body: data,
4428
+ secure: true,
4429
+ type: "application/json" /* Json */,
4430
+ format: "json",
4431
+ ...params
4432
+ });
4292
4433
  /**
4293
4434
  * No description
4294
4435
  *
@@ -4322,6 +4463,24 @@ var Visualization = class {
4322
4463
  secure: true,
4323
4464
  ...params
4324
4465
  });
4466
+ /**
4467
+ * @description The layout is computed once per tenant (per hierarchy snapshot) and cached. Coordinates are stable across requests, so the client can pan/zoom by submitting different bboxes and the same node always lands at the same screen position.
4468
+ *
4469
+ * @tags visualization
4470
+ * @name GetLatticeTile
4471
+ * @summary Render only the lattice nodes that fall inside the client's viewport, using a stable pre-computed deterministic layout. This scales to millions of sorts because the per-request work is O(K) where K is the number of nodes inside the viewport, not O(N).
4472
+ * @request POST:/api/v1/visualization/lattice-tile
4473
+ * @secure
4474
+ */
4475
+ getLatticeTile = (data, params = {}) => this.http.request({
4476
+ path: `/api/v1/visualization/lattice-tile`,
4477
+ method: "POST",
4478
+ body: data,
4479
+ secure: true,
4480
+ type: "application/json" /* Json */,
4481
+ format: "json",
4482
+ ...params
4483
+ });
4325
4484
  /**
4326
4485
  * @description Returns a graph representation of the sort hierarchy with nodes for each sort and edges for subtype relationships. Supports filtering by root sort and depth.
4327
4486
  *
@@ -4358,6 +4517,42 @@ var Visualization = class {
4358
4517
  format: "json",
4359
4518
  ...params
4360
4519
  });
4520
+ /**
4521
+ * @description BFS expands ancestors and/or descendants from the focus, emitting each visited sort with its signed hop distance as `level`. When the visit count would exceed `max_nodes`, the BFS halts and the `truncated` flag is set; the closest sorts are kept.
4522
+ *
4523
+ * @tags visualization
4524
+ * @name GetSortNeighborhood
4525
+ * @summary Render an N-hop neighborhood around a focus sort, capped at `max_nodes`. Designed for tenants with millions of sorts — the client never sees the full lattice; it browses by picking a focus and walking outward.
4526
+ * @request POST:/api/v1/visualization/sort-neighborhood
4527
+ * @secure
4528
+ */
4529
+ getSortNeighborhood = (data, params = {}) => this.http.request({
4530
+ path: `/api/v1/visualization/sort-neighborhood`,
4531
+ method: "POST",
4532
+ body: data,
4533
+ secure: true,
4534
+ type: "application/json" /* Json */,
4535
+ format: "json",
4536
+ ...params
4537
+ });
4538
+ /**
4539
+ * No description
4540
+ *
4541
+ * @tags visualization
4542
+ * @name GetTermListVisualization
4543
+ * @summary Paginated raw list of Ψ-terms for visualization. Mirrors the `lattice` endpoint but for terms — at 9M terms in the drug-discovery tenant the first page returns sub-second without loading the in-memory term store.
4544
+ * @request POST:/api/v1/visualization/term-list
4545
+ * @secure
4546
+ */
4547
+ getTermListVisualization = (data, params = {}) => this.http.request({
4548
+ path: `/api/v1/visualization/term-list`,
4549
+ method: "POST",
4550
+ body: data,
4551
+ secure: true,
4552
+ type: "application/json" /* Json */,
4553
+ format: "json",
4554
+ ...params
4555
+ });
4361
4556
  /**
4362
4557
  * No description
4363
4558
  *
@@ -4392,6 +4587,24 @@ var Visualization = class {
4392
4587
  format: "json",
4393
4588
  ...params
4394
4589
  });
4590
+ /**
4591
+ * @description **Unify (`⊔`)**: computes the meet on the Ψ-term lattice — the most-specific term that subsumes both operands. Variables in either operand bind to the corresponding sub-term in the other. **Anti-unify (`⊓`)**: computes the join — the least-general generalization (LGG) that subsumes both operands, introducing fresh variables where they disagree. This is the operation Aït-Kaci & Sasaki used for ILP rule synthesis. The handler runs the operation in a sandbox (trail-undone after snapshot) so the tenant's term store is not mutated by a visualization request. Returns operand1, operand2, and the result as polygons in one `VisualizationGraph`, with `properties.role` distinguishing each.
4592
+ *
4593
+ * @tags visualization
4594
+ * @name GetUnifyTermsVisualization
4595
+ * @summary Render the unification (or anti-unification) of two Ψ-terms.
4596
+ * @request POST:/api/v1/visualization/unify-terms
4597
+ * @secure
4598
+ */
4599
+ getUnifyTermsVisualization = (data, params = {}) => this.http.request({
4600
+ path: `/api/v1/visualization/unify-terms`,
4601
+ method: "POST",
4602
+ body: data,
4603
+ secure: true,
4604
+ type: "application/json" /* Json */,
4605
+ format: "json",
4606
+ ...params
4607
+ });
4395
4608
  /**
4396
4609
  * No description
4397
4610
  *
@@ -7440,6 +7653,100 @@ var Scheduling = class {
7440
7653
  });
7441
7654
  };
7442
7655
 
7656
+ // src/api-spec/generated/FlowNetworks.ts
7657
+ var FlowNetworks = class {
7658
+ http;
7659
+ constructor(http) {
7660
+ this.http = http;
7661
+ }
7662
+ /**
7663
+ * No description
7664
+ *
7665
+ * @tags flow-networks
7666
+ * @name CloneFlowNetwork
7667
+ * @summary Clone a flow network for what-if analysis.
7668
+ * @request POST:/api/v1/flow-networks/{network_id}/clone
7669
+ * @secure
7670
+ */
7671
+ cloneFlowNetwork = (networkId, params = {}) => this.http.request({
7672
+ path: `/api/v1/flow-networks/${networkId}/clone`,
7673
+ method: "POST",
7674
+ secure: true,
7675
+ format: "json",
7676
+ ...params
7677
+ });
7678
+ /**
7679
+ * No description
7680
+ *
7681
+ * @tags flow-networks
7682
+ * @name CommitFlowNetwork
7683
+ * @summary Commit structural mutations (capacity updates and/or new edges).
7684
+ * @request POST:/api/v1/flow-networks/{network_id}/commit
7685
+ * @secure
7686
+ */
7687
+ commitFlowNetwork = (networkId, data, params = {}) => this.http.request({
7688
+ path: `/api/v1/flow-networks/${networkId}/commit`,
7689
+ method: "POST",
7690
+ body: data,
7691
+ secure: true,
7692
+ type: "application/json" /* Json */,
7693
+ format: "json",
7694
+ ...params
7695
+ });
7696
+ /**
7697
+ * No description
7698
+ *
7699
+ * @tags flow-networks
7700
+ * @name CreateFlowNetwork
7701
+ * @summary Create a new flow network.
7702
+ * @request POST:/api/v1/flow-networks
7703
+ * @secure
7704
+ */
7705
+ createFlowNetwork = (data, params = {}) => this.http.request({
7706
+ path: `/api/v1/flow-networks`,
7707
+ method: "POST",
7708
+ body: data,
7709
+ secure: true,
7710
+ type: "application/json" /* Json */,
7711
+ format: "json",
7712
+ ...params
7713
+ });
7714
+ /**
7715
+ * No description
7716
+ *
7717
+ * @tags flow-networks
7718
+ * @name GetFlowNetwork
7719
+ * @summary Get a flow network's status.
7720
+ * @request GET:/api/v1/flow-networks/{network_id}
7721
+ * @secure
7722
+ */
7723
+ getFlowNetwork = (networkId, params = {}) => this.http.request({
7724
+ path: `/api/v1/flow-networks/${networkId}`,
7725
+ method: "GET",
7726
+ secure: true,
7727
+ format: "json",
7728
+ ...params
7729
+ });
7730
+ /**
7731
+ * No description
7732
+ *
7733
+ * @tags flow-networks
7734
+ * @name SolveFlowNetwork
7735
+ * @summary Solve a flow network with the chosen algorithm.
7736
+ * @request POST:/api/v1/flow-networks/{network_id}/solve
7737
+ * @secure
7738
+ */
7739
+ solveFlowNetwork = (networkId, data, params = {}) => this.http.request({
7740
+ path: `/api/v1/flow-networks/${networkId}/solve`,
7741
+ method: "POST",
7742
+ body: data,
7743
+ secure: true,
7744
+ type: "application/json" /* Json */,
7745
+ format: "json",
7746
+ ...params
7747
+ });
7748
+ };
7749
+
7443
7750
  // src/api-spec/generated/Admin.ts
7444
7751
  var Admin = class {
7445
7752
  http;
@@ -7745,6 +8052,155 @@ var Ui = class {
7745
8052
  });
7746
8053
  };
7747
8054
 
8055
+ // src/api-spec/generated/Compliance.ts
8056
+ var Compliance = class {
8057
+ http;
8058
+ constructor(http) {
8059
+ this.http = http;
8060
+ }
8061
+ /**
8062
+ * No description
8063
+ *
8064
+ * @tags compliance
8065
+ * @name Append
8066
+ * @summary `POST /api/v1/compliance/audit/append`
8067
+ * @request POST:/api/v1/compliance/audit/append
8068
+ * @secure
8069
+ */
8070
+ append = (data, params = {}) => this.http.request({
8071
+ path: `/api/v1/compliance/audit/append`,
8072
+ method: "POST",
8073
+ body: data,
8074
+ secure: true,
8075
+ type: "application/json" /* Json */,
8076
+ format: "json",
8077
+ ...params
8078
+ });
8079
+ /**
8080
+ * No description
8081
+ *
8082
+ * @tags compliance
8083
+ * @name CaptureSnapshot
8084
+ * @summary `POST /api/v1/predictions/snapshot`
8085
+ * @request POST:/api/v1/predictions/snapshot
8086
+ * @secure
8087
+ */
8088
+ captureSnapshot = (data, params = {}) => this.http.request({
8089
+ path: `/api/v1/predictions/snapshot`,
8090
+ method: "POST",
8091
+ body: data,
8092
+ secure: true,
8093
+ type: "application/json" /* Json */,
8094
+ format: "json",
8095
+ ...params
8096
+ });
8097
+ /**
8098
+ * No description
8099
+ *
8100
+ * @tags compliance
8101
+ * @name GetSnapshot
8102
+ * @summary `GET /api/v1/predictions/snapshot/{id}`
8103
+ * @request GET:/api/v1/predictions/snapshot/{id}
8104
+ * @secure
8105
+ */
8106
+ getSnapshot = (id, params = {}) => this.http.request({
8107
+ path: `/api/v1/predictions/snapshot/${id}`,
8108
+ method: "GET",
8109
+ secure: true,
8110
+ format: "json",
8111
+ ...params
8112
+ });
8113
+ /**
8114
+ * No description
8115
+ *
8116
+ * @tags compliance
8117
+ * @name List
8118
+ * @summary `GET /api/v1/compliance/audit/list`
8119
+ * @request GET:/api/v1/compliance/audit/list
8120
+ * @secure
8121
+ */
8122
+ list = (query, params = {}) => this.http.request({
8123
+ path: `/api/v1/compliance/audit/list`,
8124
+ method: "GET",
8125
+ query,
8126
+ secure: true,
8127
+ format: "json",
8128
+ ...params
8129
+ });
8130
+ /**
8131
+ * No description
8132
+ *
8133
+ * @tags compliance
8134
+ * @name Summary
8135
+ * @summary `GET /api/v1/compliance/audit/summary`
8136
+ * @request GET:/api/v1/compliance/audit/summary
8137
+ * @secure
8138
+ */
8139
+ summary = (params = {}) => this.http.request({
8140
+ path: `/api/v1/compliance/audit/summary`,
8141
+ method: "GET",
8142
+ secure: true,
8143
+ format: "json",
8144
+ ...params
8145
+ });
8146
+ /**
8147
+ * @description Runs validation with a built-in stub provider that returns `Pending` for every entry. Real consumers wire their own `GroundTruthProviderPort` implementation and call `PredictionLedgerPort::validate` from a service.
8148
+ *
8149
+ * @tags compliance
8150
+ * @name ValidateStub
8151
+ * @summary `POST /api/v1/predictions/snapshot/{id}/validate-stub`
8152
+ * @request POST:/api/v1/predictions/snapshot/{id}/validate-stub
8153
+ * @secure
8154
+ */
8155
+ validateStub = (id, params = {}) => this.http.request({
8156
+ path: `/api/v1/predictions/snapshot/${id}/validate-stub`,
8157
+ method: "POST",
8158
+ secure: true,
8159
+ format: "json",
8160
+ ...params
8161
+ });
8162
+ /**
8163
+ * No description
8164
+ *
8165
+ * @tags compliance
8166
+ * @name Verify
8167
+ * @summary `GET /api/v1/compliance/audit/verify`
8168
+ * @request GET:/api/v1/compliance/audit/verify
8169
+ * @secure
8170
+ */
8171
+ verify = (params = {}) => this.http.request({
8172
+ path: `/api/v1/compliance/audit/verify`,
8173
+ method: "GET",
8174
+ secure: true,
8175
+ format: "json",
8176
+ ...params
8177
+ });
8178
+ };
8179
+
8180
+ // src/api-spec/generated/Operations.ts
8181
+ var Operations = class {
8182
+ http;
8183
+ constructor(http) {
8184
+ this.http = http;
8185
+ }
8186
+ /**
8187
+ * @description `POST /api/v1/operations/anti-unify` Accepts two Ψ-term ids and returns the LGG term computed by the engine's [`AntiUnificationEngine`](osfkb_domain::operations::ilp::AntiUnificationEngine). The LGG is persisted in the tenant's term store; the response carries both its id and an enriched view (sort name + display name + referenced-term summaries).
8188
+ *
8189
+ * @tags operations
8190
+ * @name AntiUnify
8191
+ * @summary Anti-unify two Ψ-terms (Least General Generalisation).
8192
+ * @request POST:/api/v1/operations/anti-unify
8193
+ */
8194
+ antiUnify = (data, params = {}) => this.http.request({
8195
+ path: `/api/v1/operations/anti-unify`,
8196
+ method: "POST",
8197
+ body: data,
8198
+ type: "application/json" /* Json */,
8199
+ format: "json",
8200
+ ...params
8201
+ });
8202
+ };
8203
+
7748
8204
  // src/normalizers/sorts.ts
7749
8205
  function ConstraintDtoFromApiToFront(dto) {
7750
8206
  if (dto.type === "FuzzyPathSimilarity") {
@@ -20697,6 +21153,181 @@ var SchedulingClient = class {
20697
21153
  }
20698
21154
  };
20699
21155
 
21156
+ // src/normalizers/flow-networks.ts
21157
+ function EdgeSpecFromFrontToApi(edge) {
21158
+ const dto = {
21159
+ from: edge.from,
21160
+ to: edge.to,
21161
+ capacity: edge.capacity
21162
+ };
21163
+ if (edge.cost !== void 0 && edge.cost !== null) {
21164
+ dto.cost = edge.cost;
21165
+ }
21166
+ if (edge.label !== void 0 && edge.label !== null) {
21167
+ dto.label = edge.label;
21168
+ }
21169
+ return dto;
21170
+ }
21171
+ function EdgeCapacityUpdateFromFrontToApi(update) {
21172
+ return { label: update.label, capacity: update.capacity };
21173
+ }
21174
+ function CreateFlowNetworkRequestFromFrontToApi(request) {
21175
+ const dto = {
21176
+ nodes: request.nodes,
21177
+ source: request.source,
21178
+ sink: request.sink,
21179
+ edges: request.edges.map(EdgeSpecFromFrontToApi)
21180
+ };
21181
+ if (request.description !== void 0 && request.description !== null) {
21182
+ dto.description = request.description;
21183
+ }
21184
+ return dto;
21185
+ }
21186
+ function CommitFlowNetworkRequestFromFrontToApi(request) {
21187
+ const dto = {};
21188
+ if (request.updateCapacities !== void 0) {
21189
+ dto.update_capacities = request.updateCapacities.map(
21190
+ EdgeCapacityUpdateFromFrontToApi
21191
+ );
21192
+ }
21193
+ if (request.addEdges !== void 0) {
21194
+ dto.add_edges = request.addEdges.map(EdgeSpecFromFrontToApi);
21195
+ }
21196
+ return dto;
21197
+ }
21198
+ function SolveFlowNetworkRequestFromFrontToApi(request) {
21199
+ return { algorithm: request.algorithm };
21200
+ }
21201
+ function FlowNetworkResponseFromApiToFront(dto) {
21202
+ return {
21203
+ id: dto.id,
21204
+ source: dto.source,
21205
+ sink: dto.sink,
21206
+ nodeCount: dto.node_count,
21207
+ edgeCount: dto.edge_count,
21208
+ description: dto.description ?? void 0
21209
+ };
21210
+ }
21211
+ function EdgeFlowFromApiToFront(dto) {
21212
+ return {
21213
+ from: dto.from,
21214
+ to: dto.to,
21215
+ label: dto.label ?? void 0,
21216
+ capacity: dto.capacity,
21217
+ flow: dto.flow
21218
+ };
21219
+ }
21220
+ function EdgeClassificationFromApiToFront(dto) {
21221
+ return {
21222
+ from: dto.from,
21223
+ to: dto.to,
21224
+ label: dto.label ?? void 0,
21225
+ class: dto.class
21226
+ };
21227
+ }
21228
+ function MinCutFromApiToFront(dto) {
21229
+ return {
21230
+ sourceSide: dto.source_side,
21231
+ sinkSide: dto.sink_side,
21232
+ cutEdges: dto.cut_edges.map(EdgeFlowFromApiToFront)
21233
+ };
21234
+ }
21235
+ function SolveFlowNetworkResponseFromApiToFront(dto) {
21236
+ const wireClassifications = dto.classifications;
21237
+ return {
21238
+ algorithm: dto.algorithm,
21239
+ edgeFlows: dto.edge_flows.map(EdgeFlowFromApiToFront),
21240
+ totalFlow: dto.total_flow ?? void 0,
21241
+ totalCost: dto.total_cost ?? void 0,
21242
+ classifications: wireClassifications ? wireClassifications.map(EdgeClassificationFromApiToFront) : void 0,
21243
+ minCut: dto.min_cut ? MinCutFromApiToFront(dto.min_cut) : void 0
21244
+ };
21245
+ }
21246
+
21247
+ // src/resources/flow-networks.ts
21248
+ var FlowNetworksClient = class {
21249
+ /** @internal */
21250
+ api;
21251
+ /** @internal */
21252
+ constructor(api) {
21253
+ this.api = api;
21254
+ }
21255
+ /**
21256
+ * Create and persist a new flow network.
21257
+ *
21258
+ * @param request - graph shape, source/sink, and initial edges.
21259
+ * @returns metadata for the new network (including its id).
21260
+ * @throws HTTP 400 if the input is malformed (duplicate node names,
21261
+ * source/sink not in `nodes`, edges referencing unknown nodes,
21262
+ * negative capacities, duplicate edge labels).
21263
+ */
21264
+ async create(request) {
21265
+ const response = await this.api.createFlowNetwork(
21266
+ CreateFlowNetworkRequestFromFrontToApi(request)
21267
+ );
21268
+ return FlowNetworkResponseFromApiToFront(response.data);
21269
+ }
21270
+ /**
21271
+ * Fetch the current status snapshot of a flow network.
21272
+ *
21273
+ * @throws HTTP 404 if the id is unknown.
21274
+ */
21275
+ async get(networkId) {
21276
+ const response = await this.api.getFlowNetwork(networkId);
21277
+ return FlowNetworkResponseFromApiToFront(response.data);
21278
+ }
21279
+ /**
21280
+ * Clone an existing flow network for what-if analysis. The clone
21281
+ * receives a new id and its own mutable graph; the original is
21282
+ * unaffected.
21283
+ *
21284
+ * @throws HTTP 404 if the id is unknown.
21285
+ */
21286
+ async clone(networkId) {
21287
+ const response = await this.api.cloneFlowNetwork(networkId);
21288
+ return FlowNetworkResponseFromApiToFront(response.data);
21289
+ }
21290
+ /**
21291
+ * Apply structural mutations to an existing network: replace
21292
+ * capacities of labelled edges and/or append new edges. Both
21293
+ * fields on the request are optional; capacity updates apply
21294
+ * before new edges are added.
21295
+ *
21296
+ * @throws HTTP 400 if a referenced label is unknown, an appended
21297
+ * edge references undeclared nodes, or capacities are negative.
21298
+ * @throws HTTP 404 if the id is unknown.
21299
+ */
21300
+ async commit(networkId, request) {
21301
+ const response = await this.api.commitFlowNetwork(
21302
+ networkId,
21303
+ CommitFlowNetworkRequestFromFrontToApi(request)
21304
+ );
21305
+ return FlowNetworkResponseFromApiToFront(response.data);
21306
+ }
21307
+ /**
21308
+ * Run the chosen algorithm against the persisted network.
21309
+ *
21310
+ * @remarks
21311
+ * The response shape narrows per algorithm:
21312
+ *
21313
+ * - `max_flow` — `totalFlow` + `edgeFlows`.
21314
+ * - `min_cost_max_flow` — `totalFlow`, `totalCost`, `edgeFlows`.
21315
+ * - `classify_edges` / `classify_edges_optimal` — `classifications`.
21316
+ * - `min_cut` — `totalFlow`, `edgeFlows`, `minCut`.
21317
+ *
21318
+ * Fields irrelevant to the chosen algorithm are `undefined`.
21319
+ *
21320
+ * @throws HTTP 404 if the id is unknown.
21321
+ */
21322
+ async solve(networkId, request) {
21323
+ const response = await this.api.solveFlowNetwork(
21324
+ networkId,
21325
+ SolveFlowNetworkRequestFromFrontToApi(request)
21326
+ );
21327
+ return SolveFlowNetworkResponseFromApiToFront(response.data);
21328
+ }
21329
+ };
21330
+
20700
21331
  // src/normalizers/osfql.ts
20701
21332
  function OsfqlResponseFromApiToFront(dto) {
20702
21333
  return {
@@ -21759,6 +22390,243 @@ var UiClient = class {
21759
22390
  }
21760
22391
  };
21761
22392
 
22393
+ // src/normalizers/compliance.ts
22394
+ function AppendRequestFromFrontToApi(model) {
22395
+ const dto = {
22396
+ request_path: model.requestPath,
22397
+ request_hash: model.requestHash,
22398
+ response_hash: model.responseHash
22399
+ };
22400
+ if (model.dataVersions !== void 0) dto.data_versions = model.dataVersions;
22401
+ if (model.extra !== void 0) dto.extra = model.extra;
22402
+ return dto;
22403
+ }
22404
+ function AuditRecordFromApiToFront(dto) {
22405
+ return {
22406
+ id: dto.id,
22407
+ tenantId: dto.tenant_id,
22408
+ actor: dto.actor ?? null,
22409
+ timestamp: dto.timestamp,
22410
+ requestPath: dto.request_path,
22411
+ requestHash: dto.request_hash,
22412
+ responseHash: dto.response_hash,
22413
+ prevHash: dto.prev_hash,
22414
+ recordHash: dto.record_hash,
22415
+ gitRevision: dto.git_revision,
22416
+ dataVersions: dto.data_versions,
22417
+ extra: dto.extra
22418
+ };
22419
+ }
22420
+ function SummaryResponseFromApiToFront(dto) {
22421
+ const out = {
22422
+ nRecords: dto.n_records,
22423
+ perActor: dto.per_actor,
22424
+ perRequestPath: dto.per_request_path,
22425
+ tenantId: dto.tenant_id
22426
+ };
22427
+ if (dto.ts_first) out.tsFirst = dto.ts_first;
22428
+ if (dto.ts_last) out.tsLast = dto.ts_last;
22429
+ return out;
22430
+ }
22431
+ function VerifyResponseFromApiToFront(dto) {
22432
+ return {
22433
+ ok: dto.ok,
22434
+ nViolations: dto.n_violations,
22435
+ violations: dto.violations
22436
+ };
22437
+ }
22438
+ function CaptureSnapshotRequestFromFrontToApi(model) {
22439
+ const dto = {
22440
+ request_path_pattern: model.requestPathPattern
22441
+ };
22442
+ if (model.capturedAfter !== void 0) dto.captured_after = model.capturedAfter;
22443
+ if (model.maxEntries !== void 0) dto.max_entries = model.maxEntries;
22444
+ return dto;
22445
+ }
22446
+ function snapshotFilterFromApi(dto) {
22447
+ return {
22448
+ requestPathPattern: dto.request_path_pattern,
22449
+ capturedAfter: dto.captured_after ?? null,
22450
+ maxEntries: dto.max_entries ?? null
22451
+ };
22452
+ }
22453
+ function predictionEntryFromApi(dto) {
22454
+ return {
22455
+ id: dto.id,
22456
+ requestHash: dto.request_hash,
22457
+ responseSummary: dto.response_summary,
22458
+ sourceRecordId: dto.source_record_id,
22459
+ capturedStatus: dto.captured_status,
22460
+ validatedStatus: dto.validated_status ?? null,
22461
+ validatedAt: dto.validated_at ?? null
22462
+ };
22463
+ }
22464
+ function PredictionSnapshotFromApiToFront(dto) {
22465
+ return {
22466
+ id: dto.id,
22467
+ tenantId: dto.tenant_id,
22468
+ capturedAt: dto.captured_at,
22469
+ filter: snapshotFilterFromApi(dto.filter),
22470
+ entries: dto.entries.map(predictionEntryFromApi)
22471
+ };
22472
+ }
22473
+ function ValidationReportDtoFromApiToFront(dto) {
22474
+ return {
22475
+ snapshotId: dto.snapshot_id,
22476
+ completedAt: dto.completed_at,
22477
+ nTotal: dto.n_total,
22478
+ nPending: dto.n_pending,
22479
+ nValidated: dto.n_validated,
22480
+ nRefuted: dto.n_refuted,
22481
+ nUnknown: dto.n_unknown,
22482
+ validationRate: dto.validation_rate ?? null
22483
+ };
22484
+ }
22485
+
22486
+ // src/resources/compliance.ts
22487
+ var ComplianceClient = class {
22488
+ /** @internal */
22489
+ api;
22490
+ /** @internal */
22491
+ constructor(api) {
22492
+ this.api = api;
22493
+ }
22494
+ // ---------------------------------------------------------------
22495
+ // Audit ledger
22496
+ // ---------------------------------------------------------------
22497
+ /**
22498
+ * Append one record to the tenant's audit ledger.
22499
+ *
22500
+ * @param request - Hashes + path + optional metadata.
22501
+ * @returns The freshly appended record (with `recordHash` /
22502
+ * `prevHash` populated by the engine).
22503
+ */
22504
+ async append(request) {
22505
+ const response = await this.api.append(AppendRequestFromFrontToApi(request));
22506
+ return AuditRecordFromApiToFront(response.data);
22507
+ }
22508
+ /**
22509
+ * List audit records for this tenant, optionally filtered.
22510
+ *
22511
+ * @param options - Limit / glob filter on `requestPath`.
22512
+ */
22513
+ async list(options = {}) {
22514
+ const query = {};
22515
+ if (options.limit !== void 0) query.limit = options.limit;
22516
+ if (options.requestPathPattern !== void 0) {
22517
+ query.request_path_pattern = options.requestPathPattern;
22518
+ }
22519
+ const response = await this.api.list(query);
22520
+ return response.data.map(AuditRecordFromApiToFront);
22521
+ }
22522
+ /**
22523
+ * Top-line counts over the tenant's full ledger — useful for
22524
+ * dashboards and quick health checks.
22525
+ */
22526
+ async summary() {
22527
+ const response = await this.api.summary();
22528
+ return SummaryResponseFromApiToFront(response.data);
22529
+ }
22530
+ /**
22531
+ * Re-walk the hash chain end-to-end and report any breaks.
22532
+ *
22533
+ * @returns `ok: true` when the chain is intact. `violations` is
22534
+ * an engine-defined opaque list when it isn't.
22535
+ */
22536
+ async verify() {
22537
+ const response = await this.api.verify();
22538
+ return VerifyResponseFromApiToFront(response.data);
22539
+ }
22540
+ // ---------------------------------------------------------------
22541
+ // Prediction snapshots
22542
+ // ---------------------------------------------------------------
22543
+ /**
22544
+ * Capture a frozen slice of the audit ledger for later validation.
22545
+ *
22546
+ * @param request - Glob-style path filter + optional time / count
22547
+ * bounds.
22548
+ * @returns The freshly persisted snapshot, including every
22549
+ * captured `PredictionEntry`.
22550
+ *
22551
+ * @remarks
22552
+ * The `requestPathPattern` is mandatory. Without it the snapshot
22553
+ * would freeze the entire ledger, which is rarely useful.
22554
+ */
22555
+ async captureSnapshot(request) {
22556
+ const response = await this.api.captureSnapshot(
22557
+ CaptureSnapshotRequestFromFrontToApi(request)
22558
+ );
22559
+ return PredictionSnapshotFromApiToFront(response.data);
22560
+ }
22561
+ /**
22562
+ * Fetch a previously-captured snapshot by id.
22563
+ */
22564
+ async getSnapshot(id) {
22565
+ const response = await this.api.getSnapshot(id);
22566
+ return PredictionSnapshotFromApiToFront(response.data);
22567
+ }
22568
+ /**
22569
+ * Run the stub validator over a snapshot and return a
22570
+ * pending/validated/refuted/unknown report.
22571
+ *
22572
+ * @param id - Snapshot id.
22573
+ *
22574
+ * @remarks
22575
+ * "Stub" is the in-engine validator that defers the actual
22576
+ * ground-truth resolution to a `GroundTruthProviderPort` registered
22577
+ * on the backend. Without a registered provider every entry stays
22578
+ * `Pending`.
22579
+ */
22580
+ async validateStub(id) {
22581
+ const response = await this.api.validateStub(id);
22582
+ return ValidationReportDtoFromApiToFront(response.data);
22583
+ }
22584
+ };
22585
+
22586
+ // src/normalizers/operations.ts
22587
+ function AntiUnifyRequestFromFrontToApi(model) {
22588
+ return {
22589
+ term1_id: model.term1Id,
22590
+ term2_id: model.term2Id
22591
+ };
22592
+ }
22593
+ function AntiUnifyResponseFromApiToFront(dto) {
22594
+ return {
22595
+ lggTermId: dto.lgg_term_id,
22596
+ lgg: TermDtoFromApiToFront(dto.lgg),
22597
+ computationTimeMs: dto.computation_time_ms
22598
+ };
22599
+ }
22600
+
22601
+ // src/resources/operations.ts
22602
+ var OperationsClient = class {
22603
+ /** @internal */
22604
+ api;
22605
+ /** @internal */
22606
+ constructor(api) {
22607
+ this.api = api;
22608
+ }
22609
+ /**
22610
+ * Compute the anti-unification (Least General Generalisation) of
22611
+ * two Ψ-terms.
22612
+ *
22613
+ * @param request - The two term ids to generalise.
22614
+ * @returns The newly-created LGG term + enriched view + timing.
22615
+ *
22616
+ * @remarks
22617
+ * Both ids must already be registered in the tenant's term store.
22618
+ * The LGG is persisted; subsequent calls with the same operands
22619
+ * still produce a fresh LGG term (idempotency is not guaranteed at
22620
+ * this layer — wrap in your own cache if you need it).
22621
+ */
22622
+ async antiUnify(request) {
22623
+ const response = await this.api.antiUnify(
22624
+ AntiUnifyRequestFromFrontToApi(request)
22625
+ );
22626
+ return AntiUnifyResponseFromApiToFront(response.data);
22627
+ }
22628
+ };
22629
+
21762
22630
  // src/client.ts
21763
22631
  var ReasoningLayerClient = class {
21764
22632
  /** Sort (type hierarchy) operations. */
@@ -21849,6 +22717,8 @@ var ReasoningLayerClient = class {
21849
22717
  optimize;
21850
22718
  /** Scheduling feasibility via capacitated bipartite b-matching (staff rostering, assignment problems). */
21851
22719
  scheduling;
22720
+ /** Generic flow-network resource: max-flow, min-cost max-flow, edge classification, min-cut over a persisted graph. */
22721
+ flowNetworks;
21852
22722
  /** OSFQL execution operations. */
21853
22723
  osfql;
21854
22724
  /** Conversational AI operations (NL → OSFQL with self-correction). */
@@ -21861,6 +22731,10 @@ var ReasoningLayerClient = class {
21861
22731
  rlTraining;
21862
22732
  /** Sort-driven UI descriptor operations (describe, action, catalog). */
21863
22733
  ui;
22734
+ /** Hash-chained audit ledger and prediction-snapshot validation. */
22735
+ compliance;
22736
+ /** Low-level term-graph operations (anti-unification / LGG). */
22737
+ operations;
21864
22738
  // ─── Group Caches ─────────────────────────────────────────────────
21865
22739
  _core;
21866
22740
  _ai;
@@ -21924,11 +22798,12 @@ var ReasoningLayerClient = class {
21924
22798
  rlTraining: this.rlTraining
21925
22799
  };
21926
22800
  }
21927
- /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery, scheduling. */
22801
+ /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery, scheduling, flow networks. */
21928
22802
  get reasoningOps() {
21929
22803
  return this._reasoning ??= {
21930
22804
  optimize: this.optimize,
21931
22805
  scheduling: this.scheduling,
22806
+ flowNetworks: this.flowNetworks,
21932
22807
  ilp: this.ilp,
21933
22808
  cdl: this.cdl,
21934
22809
  execution: this.execution,
@@ -22084,6 +22959,7 @@ var ReasoningLayerClient = class {
22084
22959
  this.rag = new RagClient(generatedRag);
22085
22960
  this.optimize = new OptimizeClient(generatedInference, generatedSorts, generatedQuery, generatedTerms, resolved.tenantId);
22086
22961
  this.scheduling = new SchedulingClient(new Scheduling(generatedHttp));
22962
+ this.flowNetworks = new FlowNetworksClient(new FlowNetworks(generatedHttp));
22087
22963
  this.osfql = new OsfqlClient(generatedOsfql);
22088
22964
  this.conversation = new ConversationClient(generatedHttp);
22089
22965
  this.research = new ResearchClient(generatedHttp);
@@ -22093,6 +22969,8 @@ var ReasoningLayerClient = class {
22093
22969
  this.context = new ContextClient(generatedContext);
22094
22970
  this.rlTraining = new RlTrainingClient(generatedRlTraining);
22095
22971
  this.ui = new UiClient(generatedUi);
22972
+ this.compliance = new ComplianceClient(new Compliance(generatedHttp));
22973
+ this.operations = new OperationsClient(new Operations(generatedHttp));
22096
22974
  }
22097
22975
  };
22098
22976
 
@@ -22235,6 +23113,9 @@ __export(scheduling_exports, {
22235
23113
  });
22236
23114
  var ANY_ROLE = "any";
22237
23115
 
23116
+ // src/types/flow-networks.ts
23117
+ var flow_networks_exports = {};
23118
+
22238
23119
  // src/types/ilp.ts
22239
23120
  var ilp_exports = {};
22240
23121
 
@@ -22247,6 +23128,12 @@ var osfql_exports = {};
22247
23128
  // src/types/conversation.ts
22248
23129
  var conversation_exports = {};
22249
23130
 
23131
+ // src/types/compliance.ts
23132
+ var compliance_exports = {};
23133
+
23134
+ // src/types/operations.ts
23135
+ var operations_exports = {};
23136
+
22250
23137
  // src/types/research.ts
22251
23138
  var research_exports = {};
22252
23139
 
@@ -22936,6 +23823,7 @@ exports.Causal = causal_exports;
22936
23823
  exports.Cognitive = cognitive_exports;
22937
23824
  exports.Collections = collections_exports;
22938
23825
  exports.Communities = communities_exports;
23826
+ exports.Compliance = compliance_exports;
22939
23827
  exports.ConstraintViolationError = ConstraintViolationError;
22940
23828
  exports.Constraints = constraints_exports;
22941
23829
  exports.Control = control_exports;
@@ -22943,6 +23831,7 @@ exports.Conversation = conversation_exports;
22943
23831
  exports.Discovery = discovery_exports;
22944
23832
  exports.Execution = execution_exports;
22945
23833
  exports.Extract = extract_exports;
23834
+ exports.FlowNetworks = flow_networks_exports;
22946
23835
  exports.ForbiddenError = ForbiddenError;
22947
23836
  exports.Functions = functions_exports;
22948
23837
  exports.Fuzzy = fuzzy_exports;
@@ -22963,6 +23852,7 @@ exports.NetworkError = NetworkError;
22963
23852
  exports.NeuroSymbolic = neuro_symbolic_exports;
22964
23853
  exports.NotFoundError = NotFoundError;
22965
23854
  exports.Ontology = ontology_exports;
23855
+ exports.Operations = operations_exports;
22966
23856
  exports.Optimize = optimize_exports;
22967
23857
  exports.Osfql = osfql_exports;
22968
23858
  exports.Oversight = oversight_exports;